liurunyu
2024-06-20 ff08d741fcec20ebb6ef95514a59704a06a13a8b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
package com.dy.pipIrrSell.client;
 
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pipIrrGlobal.daoBa.BaDistrictMapper;
import com.dy.pipIrrGlobal.daoBa.BaSettingsMapper;
import com.dy.pipIrrGlobal.daoSe.SeClientMapper;
import com.dy.pipIrrGlobal.daoSe.SeOpenIdMapper;
import com.dy.pipIrrGlobal.pojoSe.SeClient;
import com.dy.pipIrrGlobal.pojoSe.SeOpenId;
import com.dy.pipIrrGlobal.voSe.VoClient;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.utils.PojoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
import java.util.Map;
 
/**
 * @author ZhuBaoMin
 * @date 2023/12/21 19:17
 * @LastEditTime 2023/12/21 19:17
 * @Description
 */
 
@Slf4j
@Service
public class ClientSv {
    @Autowired
    private SeClientMapper seClientMapper;
 
    @Autowired
    private BaDistrictMapper baDistrictMapper;
 
    @Autowired
    private BaSettingsMapper baSettingsMapper;
 
    @Autowired
    private SeOpenIdMapper seOpenIdMapper;
 
    /**
     * 根据指定条件获取农户数据
     * @param queryVo
     * @return
     */
    public QueryResultVo<List<VoClient>> getClients(QueryVo queryVo){
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo) ;
        Long itemTotal = seClientMapper.getRecordCount(params);
 
        QueryResultVo<List<VoClient>> rsVo = new QueryResultVo<>() ;
        rsVo.pageSize = queryVo.pageSize ;
        rsVo.pageCurr = queryVo.pageCurr ;
 
        rsVo.calculateAndSet(itemTotal, params);
        rsVo.obj = seClientMapper.getClients(params);
 
        return rsVo ;
    }
 
    /**
     * 根据主键获取农户对象
     * @param id 农户主键
     * @return 农户对象
     */
    public VoClient getOneClient(Long id) {
        SeClient seClient = seClientMapper.selectByPrimaryKey(id);
        VoClient voClient = SeClientToVoClient.INSTANCT.po2vo(seClient);
        return voClient;
    }
    /**
     * 增开农户
     * @param po
     * @return
     */
    public Integer addClient(SeClient po) {
        return seClientMapper.insertSelective(po);
    }
 
    /**
     * 根据6位区划串模糊查询农户编号
     * @param district6
     * @return
     */
    public String getClientNumOfMax(String district6) {
        return seClientMapper.getClientNumOfMax(district6);
    }
 
    /**
     * 根据村编号获取5级区划信息
     * @param villageId 村编号(主键)
     * @return 5级行政区划信息
     */
    public Map getDistrictsByVillageId(Long villageId) {
        return baDistrictMapper.getDistrictsByVillageId(villageId);
    }
 
    /**
     * 根据农户ID逻辑删除农户
     */
    public Integer deleteClientById(Long id) {
        return seClientMapper.deleteClientById(id);
    }
 
    /**
     * 修改农户对象
     * @param po 农户对象
     * @return 修改记录条数
     */
    public Integer updateByPrimaryKey(SeClient po) {
        return seClientMapper.updateByPrimaryKey(po);
    }
 
    /**
     * 根据主键获取村ID
     * @param id
     * @return
     */
    public Long getVillageIdById(Long id) {
        return seClientMapper.getVillageIdById(id);
    }
 
    /**
     * 获取虚拟卡号最大值
     * @return
     */
    public Long getMa1xVirtualId() {
        return seClientMapper.getMa1xVirtualId();
    }
 
    /**
     * 获取用水方式列表
     * @return
     */
    public List<Map<String, Object>> getWaterTypes() {
        return seClientMapper.getWaterTypes();
    }
 
    /**
     * 根据配置项获取配置项值
     * @param itemName
     * @return
     */
    public String getItemValue(String itemName) {
        return baSettingsMapper.getItemValue(itemName);
    }
 
    /**
     * 根据电话号码获取农户ID
     * @param phoneNumber
     * @return
     */
    public Long getClientIdByPhone(String phoneNumber) {
        return seClientMapper.getClientIdByPhone(phoneNumber);
    }
 
    /**
     * 添加微信用户账户记录
     * @param po
     * @return
     */
    public Long addOpenId(SeOpenId po) {
        seOpenIdMapper.insert(po);
        //return po.getClientId();
        return po.getId();
    }
}