广州市综治平台后端
xusd
2025-06-12 899c73b04d15a67b94bc3894a54c33418e285212
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
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
package cn.huge.module.ctuser.controller.web;
 
import cn.huge.base.common.dto.SelectTermDTO;
import cn.huge.base.common.utils.ReturnFailUtils;
import cn.huge.base.common.utils.ReturnSucUtils;
import cn.huge.base.config.CurrentUser;
import cn.huge.module.ctuser.domain.po.CtUnit;
import cn.huge.module.ctuser.domain.po.CtUser;
import cn.huge.module.ctuser.dto.AppearUnitDTO;
import cn.huge.module.ctuser.service.CtUnitService;
import cn.huge.module.ctuser.service.CtUserService;
import cn.huge.module.cust.dto.CtUnitDTO;
import cn.huge.module.cust.dto.CtUserDTO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
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.List;
import java.util.Map;
 
/**
 * @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/ctUnit")
public class CtUnitWebController {
 
    @Autowired(required = false)
    private HttpServletRequest request;
 
    @Autowired
    private CtUnitService service;
    @Autowired
    private CtUserService ctUserService;
 
 
    /**
    * 获取请求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 level = request.getParameter("level");
        if (StringUtils.isNotBlank(level)){
            terms.put("level", level);
        }
        // 父级组织,根级为root
        String parentId = request.getParameter("parentId");
        if (StringUtils.isNotBlank(parentId)){
            terms.put("parentId", parentId);
        }
        // 组织级别,1:市级,2:区级,3:镇街级,4:村居级
        String unitGrade = request.getParameter("unitGrade");
        if (StringUtils.isNotBlank(unitGrade)){
            terms.put("unitGrade", unitGrade);
        }
        // 组织名称
        String unitName = request.getParameter("unitName");
        if (StringUtils.isNotBlank(unitName)){
            terms.put("unitName", unitName);
        }
        // 组织类型,
        // 调解组织类型(101:综治中心,102:直属部门,103:村居社区,104:法院,105:司法局,106:司法所,107:行专业调委会,108:企事业调委会,199:演示测试),
        // 行政组织类型(201:政法委,202:其他)
        String unitType = request.getParameter("unitType");
        if (StringUtils.isNotBlank(unitType)){
            terms.put("unitType", unitType);
        }
        // 组织机构代码
        String unitCode = request.getParameter("unitCode");
        if (StringUtils.isNotBlank(unitCode)){
            terms.put("unitCode", unitCode);
        }
        // 描述
        String unitDes = request.getParameter("unitDes");
        if (StringUtils.isNotBlank(unitDes)){
            terms.put("unitDes", unitDes);
        }
        // 单位负责人姓名
        String dutyName = request.getParameter("dutyName");
        if (StringUtils.isNotBlank(dutyName)){
            terms.put("dutyName", dutyName);
        }
        // 单位负责人手机号码
        String dutyMobile = request.getParameter("dutyMobile");
        if (StringUtils.isNotBlank(dutyMobile)){
            terms.put("dutyMobile", dutyMobile);
        }
        // 单位负责人身份证
        String dutyIdcard = request.getParameter("dutyIdcard");
        if (StringUtils.isNotBlank(dutyIdcard)){
            terms.put("dutyIdcard", dutyIdcard);
        }
        // 加入方式,1:系统创建,2:自主申请
        String joinWay = request.getParameter("joinWay");
        if (StringUtils.isNotBlank(joinWay)){
            terms.put("joinWay", joinWay);
        }
        // 组织地址省
        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 lng = request.getParameter("lng");
        if (StringUtils.isNotBlank(lng)){
            terms.put("lng", lng);
        }
        // 组织纬度
        String lat = request.getParameter("lat");
        if (StringUtils.isNotBlank(lat)){
            terms.put("lat", lat);
        }
        // 调解专长,多个用,隔开
        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);
        }
        return terms;
    }
 
    /**
    * 条件查询多个
    * @url {ctx}/api/web/ctUnit/listQuery
    * @return Object
    */
    @GetMapping("/listQuery")
    public Object listQuery() {
        try {
            Map<String, Object> terms = getParameter();
            return ReturnSucUtils.getRepInfo(service.listTerms(terms));
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
    * 条件分页查询
    * @url {ctx}/api/web/ctUnit/pageQuery
    * @param page 页码
    * @param size 每页数量
    * @return Object
    */
    @GetMapping("/pageQuery")
    public Object pageQuery(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size) {
        try {
            Map<String, Object> terms = getParameter();
            Sort sort = Sort.by(Sort.Direction.DESC, "create_time");
            PageRequest pageRequest = PageRequest.of(page-1, size, sort);
            Page<CtUnit> ctUnitPage = service.pageQuery(pageRequest, terms);
            return ReturnSucUtils.getRepInfo( "处理成功", ctUnitPage);
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
    * 根据编号查询单个
    * @url {ctx}/api/web/ctUnit/getById
    * @param id 主键编号
    * @return Object
    */
    @GetMapping("/getById")
    public Object getById(@RequestParam(value = "id") String id) {
        try {
            return ReturnSucUtils.getRepInfo(service.getById(id));
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
    * 根据主键单个
    * @url {ctx}/api/web/ctUnit/deleteById
    * @param id 主键编号
    * @return Object
    */
    @GetMapping("/deleteById")
    public Object deleteById(@RequestParam(value = "id") String id) {
        try {
            service.removeById(id);
            return ReturnSucUtils.getRepInfo();
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
    * 新增或更新对象
    * @url {ctx}/api/web/ctUnit/saveCtUnit
    * @param ctUnit 实体对象
    * @return Object
    */
    @PostMapping("/saveCtUnit")
    public Object saveCtUnit(@RequestBody CtUnit ctUnit) {
        try {
            service.saveCtUnit(ctUnit);
            return ReturnSucUtils.getRepInfo();
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
     * 获取所有组织(包含所有下级子组织)树形结构
     * @url {ctx}/api/web/ctUnit/listUnitTree
     * @param userId 登录用户标识称
     * @return Object
     */
    @GetMapping("/listUnitTree")
    public Object listUnitTree(@CurrentUser String userId) {
        try {
            // 获取当前登录用户
            CtUser ctUser = ctUserService.getById(userId);
            // 查询当前登录用户下的所有单位
            List<CtUnit> ctUnits = service.listUnitTree(ctUser.getCustId(), ctUser.getUnitId());
            return ReturnSucUtils.getRepInfo( "查询成功", ctUnits);
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo( "查询失败", null);
        }
    }
 
    /**
     * 获取组织详情(包含组织下的部门详情)
     * @url {ctx}/api/web/ctUnit/getUnitAndDept?id=
     * @param id 组织编号
     * @return Object
     */
    @GetMapping("/getUnitAndDept")
    public Object getUnitAndDept(@RequestParam(value = "id") String id) {
        try {
            //查询该用户组织和部门
            CtUnit ctUnit = service.getUnitAndDept(id);
            return ReturnSucUtils.getRepInfo( "查询成功", ctUnit);
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo( "查询失败", null);
        }
    }
 
    /**
     * 根据主键编号删除单位
     * @url {ctx}/api/web/ctUnit/removeByIds
     * @param ids 主键编号
     * @return Object
     * @throws Exception
     */
    @GetMapping("/removeByIds")
    public Object removeByIds(@RequestParam(value = "ids") String ids) {
        try {
            service.removeById(ids);
            return ReturnSucUtils.getRepInfo();
        } catch (Exception e) {
            log.error("Controller接口[CtUnitController.removeByIds]请求异常:"+e, e);
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
     * 交办-选择组织
     * @url {ctx}/api/web/ctUnit/unitChoose
     * @param userId 组织编号
     * @return Object
     */
    @GetMapping("/unitChoose")
    public Object unitChoose(@CurrentUser String userId) {
        try {
            List<SelectTermDTO> unitSelectTerms = service.unitChoose(userId);
            return ReturnSucUtils.getRepInfo(unitSelectTerms);
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo(e.getMessage());
        }
    }
 
    @GetMapping("/unitChoose4Union")
    public Object unitChoose4Union(@CurrentUser String userId) {
        try {
            List<SelectTermDTO> unitSelectTerms = service.unitChoose4Union(userId);
            return ReturnSucUtils.getRepInfo(unitSelectTerms);
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo(e.getMessage());
        }
    }
 
    /**
     * 联合处置申请-选择组织
     * @url {ctx}/api/web/ctUnit/assistApplyUnitChoose
     * @param userId 组织编号
     * @return Object
     */
    @GetMapping("/assistApplyUnitChoose")
    public Object assistApplyUnitChoose(@CurrentUser String userId) {
        try {
            List<SelectTermDTO> unitSelectTerms = service.assistApplyUnitChoose(userId);
            return ReturnSucUtils.getRepInfo(unitSelectTerms);
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo(e.getMessage());
        }
    }
 
    /**
     * web端任务处理-上报-查询上报的目标组织
     * @url {ctx}/api/web/ctUnit/getAppearToUnit
     * @return Object
     */
    @GetMapping("/getAppearToUnit")
    public Object getAppearToUnit(@CurrentUser String userId) {
        try {
            // 获取当前登录用户
            CtUserDTO loginUser = ctUserService.clientGetUserAll(userId);
            CtUnitDTO ctUnitDTO = service.getParentZzzx(loginUser.getUnitId());
            AppearUnitDTO appearUnitDTO = new AppearUnitDTO();
            appearUnitDTO.setAuditUnitId(ctUnitDTO.getId());
            appearUnitDTO.setAuditUnitName(ctUnitDTO.getUnitName());
            return ReturnSucUtils.getRepInfo(appearUnitDTO);
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo(e.getMessage());
        }
    }
 
    /**
     * 转入人民调解系统列表-选择组织
     * @url {ctx}/api/web/ctUnit/rmtjUnitChoose
     * @param userId 组织编号
     * @return Object
     */
    @GetMapping("/rmtjUnitChoose")
    public Object rmtjUnitChoose(@CurrentUser String userId) {
        try {
            List<SelectTermDTO> unitSelectTerms = service.rmtjUnitChoose(userId);
            return ReturnSucUtils.getRepInfo(unitSelectTerms);
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo(e.getMessage());
        }
    }
 
    /**
     * 查询客户下的法院
     * @url {ctx}/api/web/ctUnit/listCourt
     * @return Object
     */
    @GetMapping("/listCourt")
    public Object listCourt(@CurrentUser String userId) {
        try {
            return ReturnSucUtils.getRepInfo(service.listCourt(userId));
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo(e.getMessage());
        }
    }
 
    /**
     * 获取所有组织树形结构
     * @url {ctx}/api/web/ctUnit/unitTree
     * @return Object
     */
    @GetMapping("/unitTree")
    public Object unitTree(@CurrentUser String userId) {
        try {
            return ReturnSucUtils.getRepInfo( "查询成功", service.unitTree(userId));
        } catch (Exception e) {
            log.error("Controller接口[CtUnitWebController.unitTree]请求异常:"+e, e);
            return ReturnFailUtils.getRepInfo( "查询失败", null);
        }
    }
 
    /**
     * 联合处置申请获取所有组织树形结构
     * @url {ctx}/api/web/ctUnit/unitTree4Union
     * @return Object
     */
    @GetMapping("/unitTree4Union")
    public Object unitTree4Union(@CurrentUser String userId) {
        try {
            return ReturnSucUtils.getRepInfo( "查询成功", service.unitTree4Union(userId));
        } catch (Exception e) {
            log.error("Controller接口[CtUnitWebController.unitTree]请求异常:"+e, e);
            return ReturnFailUtils.getRepInfo( "查询失败", null);
        }
    }
}