广州市综治平台后端
xusd
2025-06-07 36306491396230522fa20585c2621a7fc899849a
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
package cn.huge.module.ctuser.controller.web;
 
import cn.huge.base.common.dto.SelectTermDTO;
import cn.huge.base.common.utils.ObjectUtils;
import cn.huge.base.common.utils.ReturnFailUtils;
import cn.huge.base.common.utils.ReturnSucUtils;
import cn.huge.base.common.utils.SelectTermUtils;
import cn.huge.base.config.CurrentUser;
import cn.huge.module.ctrole.domain.po.CtRole;
import cn.huge.module.ctrole.service.CtRoleService;
import cn.huge.module.ctuser.domain.po.*;
import cn.huge.module.ctuser.dto.CtUserInfoDTO;
import cn.huge.module.ctuser.dto.CtUserSaveDTO;
import cn.huge.module.ctuser.service.*;
import cn.huge.module.cust.constant.RoleBaseEnum;
import cn.huge.module.cust.constant.UserBaseConsts;
import cn.huge.module.cust.dto.CtUserDTO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
 
/**
 * @title: 客户用户表接口api-web端
 * @description: 客户用户表接口api-web端
 * @company: hugeinfo
 * @author: liyj
 * @time: 2024-08-19 20:04:19
 * @version: 1.0.0
 */
@Slf4j
@RestController
@RequestMapping("/api/web/ctUser")
public class CtUserWebController {
 
    @Autowired(required = false)
    private HttpServletRequest request;
 
    @Autowired
    private CtUserService service;
 
    @Autowired
    private CtUnitService ctUnitService;
 
    @Autowired
    private CtRoleService ctRoleService;
 
    @Autowired
    private CtDeptService ctDeptService;
 
    @Autowired
    private CtUseroleService ctUseroleService;
 
    @Autowired
    private CtAccountService ctAccountService;
 
    @Autowired
    private CtUsepostService ctUsepostService;
 
    /**
    * 获取请求URL参数
    * @return Map<String, Object>
    */
    private Map<String, Object> getParameter(){
        Map<String, Object> terms = Maps.newHashMap();
        // 客户用户编号
        String id = request.getParameter("id");
        if (StringUtils.isNotBlank(id)){
            terms.put("id", id);
        }
        // 姓名
        String trueName = request.getParameter("trueName");
        if (StringUtils.isNotBlank(trueName)){
            terms.put("trueName", trueName);
        }
        // 性别
        String sex = request.getParameter("sex");
        if (StringUtils.isNotBlank(sex)){
            terms.put("sex", sex);
        }
        // 性别名称
        String sexName = request.getParameter("sexName");
        if (StringUtils.isNotBlank(sexName)){
            terms.put("sexName", sexName);
        }
        // 手机号码
        String mobile = request.getParameter("mobile");
        if (StringUtils.isNotBlank(mobile)){
            terms.put("mobile", mobile);
        }
        // 身份证号
        String idcard = request.getParameter("idcard");
        if (StringUtils.isNotBlank(idcard)){
            terms.put("idcard", idcard);
        }
        // 电子邮箱
        String email = request.getParameter("email");
        if (StringUtils.isNotBlank(email)){
            terms.put("email", email);
        }
        // 微信号
        String wechat = request.getParameter("wechat");
        if (StringUtils.isNotBlank(wechat)){
            terms.put("wechat", wechat);
        }
        // QQ号
        String qq = request.getParameter("qq");
        if (StringUtils.isNotBlank(qq)){
            terms.put("qq", qq);
        }
        // 现居地省
        String prov = request.getParameter("prov");
        if (StringUtils.isNotBlank(prov)){
            terms.put("prov", prov);
        }
        // 现居地省名称
        String provName = request.getParameter("provName");
        if (StringUtils.isNotBlank(provName)){
            terms.put("provName", provName);
        }
        // 现居地市
        String city = request.getParameter("city");
        if (StringUtils.isNotBlank(city)){
            terms.put("city", city);
        }
        // 现居地市名称
        String cityName = request.getParameter("cityName");
        if (StringUtils.isNotBlank(cityName)){
            terms.put("cityName", cityName);
        }
        // 现居地区
        String area = request.getParameter("area");
        if (StringUtils.isNotBlank(area)){
            terms.put("area", area);
        }
        // 现居地区名称
        String areaName = request.getParameter("areaName");
        if (StringUtils.isNotBlank(areaName)){
            terms.put("areaName", areaName);
        }
        // 现居地街道
        String road = request.getParameter("road");
        if (StringUtils.isNotBlank(road)){
            terms.put("road", road);
        }
        // 现居地街道名称
        String roadName = request.getParameter("roadName");
        if (StringUtils.isNotBlank(roadName)){
            terms.put("roadName", roadName);
        }
        // 现居地社区
        String village = request.getParameter("village");
        if (StringUtils.isNotBlank(village)){
            terms.put("village", village);
        }
        // 现居地社区名称
        String villageName = request.getParameter("villageName");
        if (StringUtils.isNotBlank(villageName)){
            terms.put("villageName", villageName);
        }
        // 现居地详细地址
        String addr = request.getParameter("addr");
        if (StringUtils.isNotBlank(addr)){
            terms.put("addr", addr);
        }
        // 头像
        String avatar = request.getParameter("avatar");
        if (StringUtils.isNotBlank(avatar)){
            terms.put("avatar", avatar);
        }
        // 组织编号
        String unitId = request.getParameter("unitId");
        if (StringUtils.isNotBlank(unitId)){
            terms.put("unitId", unitId);
        }
        // 组织名称
        String unitName = request.getParameter("unitName");
        if (StringUtils.isNotBlank(unitName)){
            terms.put("unitName", unitName);
        }
        // 部门编号
        String deptId = request.getParameter("deptId");
        if (StringUtils.isNotBlank(deptId)){
            terms.put("deptId", deptId);
        }
        // 部门名称
        String deptName = request.getParameter("deptName");
        if (StringUtils.isNotBlank(deptName)){
            terms.put("deptName", deptName);
        }
        // 加入方式,1:系统创建(默认),2:自主申请
        String joinWay = request.getParameter("joinWay");
        if (StringUtils.isNotBlank(joinWay)){
            terms.put("joinWay", joinWay);
        }
        // 实名认证状态,0:未认证,1:已认证
        String realStatus = request.getParameter("realStatus");
        if (StringUtils.isNotBlank(realStatus)){
            terms.put("realStatus", realStatus);
        }
        // 用户状态,1:有效(默认),2:停用,99:离职
        String status = request.getParameter("status");
        if (StringUtils.isNotBlank(status)){
            terms.put("status", status);
        }
        // 调解专长,多个用,隔开
        String goodField = request.getParameter("goodField");
        if (StringUtils.isNotBlank(goodField)){
            terms.put("goodField", goodField);
        }
        // 调解专长名称,多个用,隔开
        String goodFieldName = request.getParameter("goodFieldName");
        if (StringUtils.isNotBlank(goodFieldName)){
            terms.put("goodFieldName", goodFieldName);
        }
        // 调解范围,多个用,隔开
        String canField = request.getParameter("canField");
        if (StringUtils.isNotBlank(canField)){
            terms.put("canField", canField);
        }
        // 调解范围名称,多个用,隔开
        String canFieldName = request.getParameter("canFieldName");
        if (StringUtils.isNotBlank(canFieldName)){
            terms.put("canFieldName", canFieldName);
        }
        // 是否可以找他调(小程序),0:否,1:是
        String findStatus = request.getParameter("findStatus");
        if (StringUtils.isNotBlank(findStatus)){
            terms.put("findStatus", findStatus);
        }
        // 是否参与自动调度,0:否,1:是
        String dispStatus = request.getParameter("dispStatus");
        if (StringUtils.isNotBlank(dispStatus)){
            terms.put("dispStatus", dispStatus);
        }
        // 删除状态,0:未删除,1:已删除
        String deleteStatus = request.getParameter("deleteStatus");
        if (StringUtils.isNotBlank(deleteStatus)){
            terms.put("deleteStatus", deleteStatus);
        }
        // 所属客户编号
        String custId = request.getParameter("custId");
        if (StringUtils.isNotBlank(custId)){
            terms.put("custId", custId);
        }
        // 创建时间区间
        String createStart = request.getParameter("createStart");
        String createEnd = request.getParameter("createEnd");
        if(StringUtils.isNotBlank(createStart) && StringUtils.isNotBlank(createEnd)) {
            terms.put("createStart", createStart);
            terms.put("createEnd", createEnd);
        }
        // 更新时间区间
        String updateStart = request.getParameter("updateStart");
        String updateEnd = request.getParameter("updateEnd");
        if(StringUtils.isNotBlank(updateStart) && StringUtils.isNotBlank(updateEnd)) {
            terms.put("updateStart", updateStart);
            terms.put("updateEnd", updateEnd);
        }
        // 平台账号
        String acc = request.getParameter("acc");
        if (StringUtils.isNotBlank(acc)){
            terms.put("acc", acc);
        }
        // 角色编码
        String roleCode = request.getParameter("roleCode");
        if (StringUtils.isNotBlank(roleCode)){
            terms.put("roleCode", roleCode);
        }
 
        return terms;
    }
 
    /**
     * web端-人员信息管理-新增/新用户信息
     * @url {ctx}/api/web/ctUser/saveCtUser
     * @param userId
     * @return Object
     * @throws Exception
     */
    @PostMapping("/saveCtUser")
    public Object saveCtUser(@RequestBody CtUserSaveDTO ctUserSaveDTO, @CurrentUser String userId) {
        try {
            // 保存更新用户信息
            service.webSaveCtUser(ctUserSaveDTO, userId);
            return ReturnSucUtils.getRepInfo();
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
     * 获取人员信息列表查询条件
     * @url {ctx}/api/web/ctUser/listSelectTerm
     * @return userId 登录用户标识称
     * @return Object
     * @throws Exception
     */
    @GetMapping("/listSelectTerm")
    public Object listSelectTerm(@CurrentUser String userId) {
        try {
            Map<String, Object> result = service.webListSelectTerm(userId);
            return ReturnSucUtils.getRepInfo(result);
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
     * web端-人员信息管理-人员列表
     * @url {ctx}/api/web/ctUser/pageQuery
     * @param page 页码
     * @param size 每页数量
     * @return Object
     */
    @GetMapping("/pageQuery")
    public Object pageQuery(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size,
                            @CurrentUser String userId) {
        try {
            Map<String, Object> terms = getParameter();
            Map<String, Object> result = service.webPageQuery(page, size, terms, userId);
            return ReturnSucUtils.getRepInfo(result);
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
     * 更新人员状态信息
     * @url {ctx}/api/web/ctUser/updateCtUserStatus
     * @param id 编号 status :用户状态,1:在职(默认),2:停用,99:离职
     * @return Object
     * @throws Exception
     */
    @GetMapping("/updateCtUserStatus")
    public Object updateCtUserStatus(@RequestParam(value = "status") String status, @RequestParam(value = "id") String id) {
        try {
            // 修改状态
            UpdateWrapper<CtUser> ctUserUpdateWrapper = new UpdateWrapper();
            ctUserUpdateWrapper.eq("id", id);
            ctUserUpdateWrapper.set("status", status).set("update_time", new Date());
            service.update(ctUserUpdateWrapper);
            return ReturnSucUtils.getRepInfo();
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
     * 根据主键单个/批量删除
     * @url {ctx}/api/web/ctUser/removeByIds
     * @return Object
     * @throws Exception
     */
    @PostMapping("/removeByIds")
    public Object removeByIds(@RequestBody List<String> data) {
        try {
            service.removeListId(data);
            return ReturnSucUtils.getRepInfo();
        } catch (Exception e) {
            log.error("Controller接口[CtUserController.removeByIds]请求异常:"+e, e);
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
     * 选择人员
     * @url {ctx}/api/web/ctUser/userChoose
     * @return Object
     */
    @GetMapping("/userChoose")
    public Object userChoose(@CurrentUser String userId) {
        try {
            String roleCode = request.getParameter("roleCode");
            roleCode="";//放开全部角色都能出现
            List<SelectTermDTO> unitSelectTerms = service.userChoose(userId, roleCode);
            return ReturnSucUtils.getRepInfo(unitSelectTerms);
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo(e.getMessage());
        }
    }
 
    /**
     * 共通组件-根据人员编号查询单个人员信息及角色信息
     * @url {ctx}/api/web/ctUser/getByIdRole
     * @param id 主键编号
     * @return Object
     * @throws Exception
     */
    @GetMapping("/getByIdRole")
    public Object getByIdRole(@RequestParam(value = "id") String id) {
        try {
            CtUserInfoDTO ctUserInfoDTO = new CtUserInfoDTO();
            CtUser ctUser = service.getById(id);
            if (ObjectUtils.isNotEmpty(ctUser)) {
                BeanUtils.copyProperties(ctUser, ctUserInfoDTO);
                CtAccount ctAccount = ctAccountService.getByUserIdAndType(id, UserBaseConsts.ACC_TYPE_1);
                ctUserInfoDTO.setLoginTime(ctAccount.getLoginTime());
                ctUserInfoDTO.setAcc(ctAccount.getAcc());
                List<String> roleNameList = ctUseroleService.listRoleName(id);
                if (CollectionUtils.isNotEmpty(roleNameList)) {
                    String userRoles = roleNameList.stream().map(String::valueOf).collect(Collectors.joining("、"));
                    ctUserInfoDTO.setUserRoles(userRoles);
                }
            }
            return ReturnSucUtils.getRepInfo(ctUserInfoDTO);
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
     * 人工配置-统一修改单位名称
     * @url {ctx}/api/web/ctUser/updateUnitName
     * @return Object
     * @throws Exception
     */
    @GetMapping("/updateUnitName")
    public Object updateUnitName() {
        try {
            List<CtUser> ctUserList = service.list();
            for (CtUser ctUser: ctUserList){
                CtUnit ctUnit = ctUnitService.getById(ctUser.getUnitId());
                if (ObjectUtils.isNotEmpty(ctUnit)) {
                    ctUser.setUnitName(ctUnit.getUnitName());
                    service.updateCtUser(ctUser);
                }
            }
            return ReturnSucUtils.getRepInfo();
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
}