广州市综治平台后端
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
package cn.huge.module.client.api.impl;
 
import cn.huge.base.common.bo.ReturnBO;
import cn.huge.base.common.constant.ReturnConsts;
import cn.huge.base.common.dto.SelectTermDTO;
import cn.huge.base.common.exception.ClientException;
import cn.huge.base.common.exception.ServiceException;
import cn.huge.base.common.utils.ObjectUtils;
import cn.huge.module.client.api.CustClient;
import cn.huge.module.cust.dto.CtUnitDTO;
import cn.huge.module.cust.dto.CtUserDTO;
import cn.huge.module.cust.dto.PaUserDTO;
import cn.huge.module.mediate.dto.WechatBindCaseDTO;
import cn.huge.module.sys.dto.FileIdTypeInfoBaseDTO;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
 
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
 
/**
 * @title: 客户用户中心微服务调用接口实现
 * @description: 客户用户中心微服务调用接口实现
 * @company: hugeinfo
 * @author: liyj
 * @time: 2021-11-05 16:51:48
 * @version: 1.0.0
 */
@Slf4j
@Component
public class CustClientImpl {
 
    private CustClient custClient;
 
    @Autowired
    public CustClientImpl(CustClient custClient) {
        this.custClient = custClient;
    }
 
    /**
     * ObjectMapper工具类
     */
    private ObjectMapper objectMapper = new ObjectMapper();
 
    /**
     * 内部用户-获取登录用户
     * @param userId 用户编号
     * @return CtUserDTO
     */
    public CtUserDTO clientGetUser(String userId){
        try{
            ReturnBO returnBo = custClient.clientGetUser(userId);
            if (ReturnConsts.OK == returnBo.getCode()){
                CtUserDTO loginUser = objectMapper.convertValue(returnBo.getData(), CtUserDTO.class);
                return loginUser;
            }else{
                log.error("Client外服务接口[CustClientImpl.clientGetUser]请求异常:" + returnBo.getMsg(), returnBo.getMsg());
                throw new ClientException("CustClientImpl.clientGetUser", returnBo.getMsg());
            }
        }catch (Exception e){
            log.error("service方法[CustClientImpl.clientGetUser]调用异常:"+e, e);
            throw new ServiceException("CustClientImpl.clientGetUser", e);
        }
    }
 
    /**
     * 内部用户-获取登录用户-所有信息
     * @param userId
     * @return
     */
    public CtUserDTO clientGetUserAll(String userId){
        try{
            ReturnBO returnBo = custClient.clientGetUserAll(userId);
            if (ReturnConsts.OK == returnBo.getCode()){
                CtUserDTO loginUser = objectMapper.convertValue(returnBo.getData(), CtUserDTO.class);
                return loginUser;
            }else{
                log.error("Client外服务接口[CustClientImpl.clientGetUserAll]请求异常:" + returnBo.getMsg(), returnBo.getMsg());
                throw new ClientException("CustClientImpl.clientGetUserAll", returnBo.getMsg());
            }
        }catch (Exception e){
            log.error("service方法[CustClientImpl.clientGetUserAll]调用异常:"+e, e);
            throw new ServiceException("CustClientImpl.clientGetUserAll", e);
        }
    }
 
    /**
     * 当事人-获取登录用户-所有信息
     * @param userId 用户编号
     * @return
     */
    public PaUserDTO paclientGetUser(String userId){
        try{
            ReturnBO returnBo = custClient.paclientGetUser(userId);
            if (ReturnConsts.OK == returnBo.getCode()){
                PaUserDTO loginUser = objectMapper.convertValue(returnBo.getData(), PaUserDTO.class);
                return loginUser;
            }else{
                log.error("Client外服务接口[CustClientImpl.paclientGetUser]请求异常:" + returnBo.getMsg(), returnBo.getMsg());
                throw new ClientException("CustClientImpl.paclientGetUser", returnBo.getMsg());
            }
        }catch (Exception e){
            log.error("service方法[CustClientImpl.paclientGetUser]调用异常:"+e, e);
            throw new ServiceException("CustClientImpl.paclientGetUser", e);
        }
    }
 
    /**
     * pc端提交案件后-获取相关当事人用户编号
     * @param wechatBindCaseDTO 实体对象
     * @return ReturnBO
     */
    public String bindGetUserId(WechatBindCaseDTO wechatBindCaseDTO){
        String userId = null;
        try{
            ReturnBO returnBo = custClient.bindGetUserId(wechatBindCaseDTO);
            if (ReturnConsts.OK == returnBo.getCode()){
                userId = (String) returnBo.getData();
            }else{
                log.error("Client外服务接口[CustClientImpl.bindGetUserId]请求异常:" + returnBo.getMsg(), returnBo.getMsg());
            }
        }catch (Exception e){
            log.error("service方法[CustClientImpl.bindGetUserId]调用异常:"+e, e);
        }
        return userId;
    }
 
    /**
     * 根据id查询组织信息
     * @url {ctx}/api/client/ctUnit/getUnitById
     * @param unitId 组织编号
     * @return Object
     */
    public CtUnitDTO getUnitById(String unitId){
        try{
            ReturnBO returnBo = custClient.getUnitById(unitId);
            if (ReturnConsts.OK == returnBo.getCode()){
                CtUnitDTO ctUnitDTO = objectMapper.convertValue(returnBo.getData(), CtUnitDTO.class);
                return ctUnitDTO;
            }else{
                log.error("Client外服务接口[CustClientImpl.getUnitById]请求异常:" + returnBo.getMsg(), returnBo.getMsg());
                throw new ClientException("CustClientImpl.getUnitById", returnBo.getMsg());
            }
        }catch (Exception e){
            log.error("service方法[CustClientImpl.getUnitById]调用异常:"+e, e);
            throw new ServiceException("CustClientImpl.getUnitById", e);
        }
    }
 
    /**
     * 获取上级综治中心
     * @url {ctx}/api/client/ctUnit/getParentZzzxUnit
     * @param unitId 组织编号
     * @return Object
     */
    public CtUnitDTO getParentZzzxUnit(String unitId){
        try{
            ReturnBO returnBo = custClient.getParentZzzxUnit(unitId);
            if (ReturnConsts.OK == returnBo.getCode()){
                CtUnitDTO ctUnitDTO = objectMapper.convertValue(returnBo.getData(), CtUnitDTO.class);
                return ctUnitDTO;
            }else{
                log.error("Client外服务接口[CustClientImpl.getParentZzzxUnit]请求异常:" + returnBo.getMsg(), returnBo.getMsg());
                throw new ClientException("CustClientImpl.getParentZzzxUnit", returnBo.getMsg());
            }
        }catch (Exception e){
            log.error("service方法[CustClientImpl.getParentZzzxUnit]请求成功,处理异常:"+e, e);
            throw new ServiceException("CustClientImpl.getParentZzzxUnit", e);
        }
    }
 
    /**
     * 获取本级综治中心
     * @url {ctx}/api/client/ctUnit/getBjZzzx
     * @param unitId 组织编号
     * @return Object
     */
    public CtUnitDTO getBjZzzx(String unitId){
        try{
            ReturnBO returnBo = custClient.getBjZzzx(unitId);
            if (ReturnConsts.OK == returnBo.getCode()){
                CtUnitDTO ctUnitDTO = objectMapper.convertValue(returnBo.getData(), CtUnitDTO.class);
                return ctUnitDTO;
            }else{
                log.error("Client外服务接口[CustClientImpl.getBjZzzx]请求异常:" + returnBo.getMsg(), returnBo.getMsg());
                throw new ClientException("CustClientImpl.getBjZzzx", returnBo.getMsg());
            }
        }catch (Exception e){
            log.error("service方法[CustClientImpl.getBjZzzx]请求成功,处理异常:"+e, e);
            throw new ServiceException("CustClientImpl.getBjZzzx", e);
        }
    }
 
    /**
     * 查询用户所在的单位信息
     * @url {ctx}/api/client/ctUnit/getUnitByUserId
     * @param userId 用户编号
     * @return Object
     */
    public CtUnitDTO getUnitByUserId(String userId){
        try{
            ReturnBO returnBo = custClient.getUnitByUserId(userId);
            if (ReturnConsts.OK == returnBo.getCode()){
                CtUnitDTO ctUnitDTO = objectMapper.convertValue(returnBo.getData(), CtUnitDTO.class);
                return ctUnitDTO;
            }else{
                log.error("Client外服务接口[CustClientImpl.getUnitByUserId]请求异常:" + returnBo.getMsg(), returnBo.getMsg());
                throw new ClientException("CustClientImpl.getUnitByUserId", returnBo.getMsg());
            }
        }catch (Exception e){
            log.error("service方法[CustClientImpl.getUnitByUserId]调用异常:"+e, e);
            throw new ServiceException("CustClientImpl.getUnitByUserId", e);
        }
    }
 
    /**
     * 根据id查询组织信息
     * @url {ctx}/api/client/ctUnit/listByTerms
     * @param terms 条件
     * @return Object
     */
    public List<CtUnitDTO> listByTerms(Map<String, Object> terms){
        List<CtUnitDTO> ctUnitDTOList = new ArrayList<>();
        try{
            ReturnBO returnBo = custClient.listByTerms(terms);
            if (ReturnConsts.OK == returnBo.getCode()){
                if (ObjectUtils.isNotEmpty(returnBo.getData())){
                    List<LinkedHashMap> list = (List<LinkedHashMap>) returnBo.getData();
                    for (LinkedHashMap map : list) {
                        CtUnitDTO ctUnitDTO = JSON.parseObject(JSON.toJSONString(map), CtUnitDTO.class);
                        ctUnitDTOList.add(ctUnitDTO);
                    }
                }
            }else{
                log.error("Client外服务接口[CustClientImpl.listByTerms]请求异常:" + returnBo.getMsg(), returnBo.getMsg());
                throw new ClientException("CustClientImpl.listByTerms", returnBo.getMsg());
            }
        }catch (Exception e){
            log.error("service方法[CustClientImpl.listByTerms]调用异常:"+e, e);
            throw new ServiceException("CustClientImpl.listByTerms", e);
        }
        return ctUnitDTOList;
    }
}