广州市综治平台后端
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
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.exception.ClientException;
import cn.huge.base.common.exception.ServiceException;
import cn.huge.module.ai.domain.dto.CaseInfoDetailDto;
import cn.huge.module.ai.domain.dto.DyhCaseDetailDTO;
import cn.huge.module.ai.domain.po.*;
import cn.huge.module.client.api.KnowledgeCaseClient;
import cn.huge.module.cust.dto.CtUserDTO;
import com.fasterxml.jackson.databind.DeserializationFeature;
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.RequestBody;
 
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.annotation.PostConstruct;
 
/**
 * @title: 案件知识库微服务调用接口实现
 * @description: 案件知识库微服务调用接口实现
 * @company: hugeinfo
 * @version: 1.0.0
 */
@Slf4j
@Component
public class KnowledgeCaseClientImpl {
 
    private KnowledgeCaseClient knowledgeCaseClient;
 
    @Autowired
    public KnowledgeCaseClientImpl(KnowledgeCaseClient knowledgeCaseClient) {
        this.knowledgeCaseClient = knowledgeCaseClient;
    }
 
    /**
     * ObjectMapper工具类
     */
    private ObjectMapper objectMapper = new ObjectMapper();
    //
    // @PostConstruct
    // public void init() {
    //     // 配置ObjectMapper支持常用日期格式
    //     objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
    //     // 配置日期反序列化更宽松的处理
    //     objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    // }
 
    /**
     * 获取案件详情
     * @param id 案件ID
     * @return DyhCaseDetailDTO
     */
    public DyhCaseDetailDTO getCaseDetail(String id) {
        try {
            ReturnBO returnBO = knowledgeCaseClient.getCaseDetail(id);
            if (ReturnConsts.OK == returnBO.getCode()) {
                return objectMapper.convertValue(returnBO.getData(), DyhCaseDetailDTO.class);
            } else {
                log.error("Client外服务接口[KnowledgeCaseClientImpl.getCaseDetail]请求异常:未获取到案件详情");
                throw new ClientException("KnowledgeCaseClientImpl.getCaseDetail", "未获取到案件详情");
            }
        } catch (Exception e) {
            log.error("service方法[KnowledgeCaseClientImpl.getCaseDetail]调用异常:" + e, e);
            throw new ServiceException("KnowledgeCaseClientImpl.getCaseDetail", e);
        }
    }
 
    /**
     * 检查案件相似度关系
     * @param relations 查询条件
     * @return List<CaseSimilarityRelations>
     */
    public List<CaseSimilarityRelations> checkRelations(CaseSimilarityRelations relations) {
        try {
            List<CaseSimilarityRelations> similarityRelations = knowledgeCaseClient.checkRelations(relations);
            // List<CaseSimilarityRelations> similarityRelations = objectMapper.convertValue(knowledgeCaseClient.checkRelations(relations), List.class);
            if (similarityRelations != null) {
                return similarityRelations;
            } else {
                log.error("Client外服务接口[KnowledgeCaseClientImpl.checkRelations]请求异常:未获取到相似案件关系");
                return new ArrayList<>();
            }
        } catch (Exception e) {
            log.error("service方法[KnowledgeCaseClientImpl.checkRelations]调用异常:" + e, e);
            throw new ServiceException("KnowledgeCaseClientImpl.checkRelations", e);
        }
    }
 
    /**
     * 获取案件标题
     * @param id 案件ID
     * @return DyhCaseInfo 仅包含id和caseTitle
     */
    public DyhCaseInfo getCaseTitleById(String id) {
        try {
            // DyhCaseInfo caseInfo = knowledgeCaseClient.getCaseTitleById(id);
            ReturnBO returnBo = knowledgeCaseClient.getCaseTitleById(id);
            log.info("Client外服务接口[KnowledgeCaseClientImpl.getCaseTitleById]请求成功,返回结果:" + returnBo);
            if (ReturnConsts.OK == returnBo.getCode()){
                return objectMapper.convertValue(returnBo.getData(), DyhCaseInfo.class);
            } else {
                log.error("Client外服务接口[KnowledgeCaseClientImpl.getCaseTitleById]请求异常:未获取到案件标题");
                throw new ClientException("KnowledgeCaseClientImpl.getCaseTitleById", "未获取到案件标题");
            }
        } catch (Exception e) {
            log.error("service方法[KnowledgeCaseClientImpl.getCaseTitleById]调用异常:" + e, e);
            throw new ServiceException("KnowledgeCaseClientImpl.getCaseTitleById", e);
        }
    }
 
    /**
     * 获取裁判文书案件标题
     * @param id 案件ID
     * @return CpwsCaseInfo 仅包含id和caseName
     */
    public CpwsCaseInfo getCpwsCaseTitleById(String id) {
        try {
            ReturnBO returnBo = knowledgeCaseClient.getCpwsCaseTitleById(id);
            log.info("Client外服务接口[KnowledgeCaseClientImpl.getCpwsCaseTitleById]请求成功,返回结果:" + returnBo);
            if (ReturnConsts.OK == returnBo.getCode()){
                return objectMapper.convertValue(returnBo.getData(), CpwsCaseInfo.class);
            } else {
                log.error("Client外服务接口[KnowledgeCaseClientImpl.getCpwsCaseTitleById]请求异常:未获取到案件标题");
                throw new ClientException("KnowledgeCaseClientImpl.getCpwsCaseTitleById", "未获取到案件标题");
            }
        } catch (Exception e) {
            log.error("service方法[KnowledgeCaseClientImpl.getCpwsCaseTitleById]调用异常:" + e, e);
            throw new ServiceException("KnowledgeCaseClientImpl.getCpwsCaseTitleById", e);
        }
    }
 
    /**
     * 检查案件风险评估记录
     * @param caseId 案件ID
     * @return List<AiCaseRisk>
     */
    public List<AiCaseRisk> checkRisks(AiCaseRisk risk) {
        try {
            List<AiCaseRisk> aiCaseRiskList = knowledgeCaseClient.checkRisks(risk);
            log.debug("Client外服务接口[KnowledgeCaseClientImpl.checkRisks]请求成功,返回结果:" + aiCaseRiskList);
            if (aiCaseRiskList != null) {
                return aiCaseRiskList;
            } else {
                log.error("Client外服务接口[KnowledgeCaseClientImpl.checkRisks]请求异常:未获取到风险评估记录");
                return new ArrayList<>();
            }
        } catch (Exception e) {
            log.error("service方法[KnowledgeCaseClientImpl.checkRisks]调用异常:" + e, e);
            throw new ServiceException("KnowledgeCaseClientImpl.checkRisks", e);
        }
    }
 
    /**
     * 获取裁判文书案件文本详情
     * @param id 案件文本ID
     * @return CpwsCaseText
     */
    public CpwsCaseText getCpwsCaseTextById(String id) {
        try {
            ReturnBO returnBo = knowledgeCaseClient.getCpwsCaseTextById(id);
            log.info("Client外服务接口[KnowledgeCaseClientImpl.getCpwsCaseTextById]请求成功,返回结果:" + returnBo);
            if (ReturnConsts.OK == returnBo.getCode()){
                return objectMapper.convertValue(returnBo.getData(), CpwsCaseText.class);
            } else {
                log.error("Client外服务接口[KnowledgeCaseClientImpl.getCpwsCaseTextById]请求异常:未获取到案件文本详情");
                throw new ClientException("KnowledgeCaseClientImpl.getCpwsCaseTextById", "未获取到案件文本详情");
            }
        } catch (Exception e) {
            log.error("service方法[KnowledgeCaseClientImpl.getCpwsCaseTextById]调用异常:" + e, e);
            throw new ServiceException("KnowledgeCaseClientImpl.getCpwsCaseTextById", e);
        }
    }
 
    /**
     * 检查案件与法条关系
     * @param relations 查询条件
     * @return List<LawSimilarityRelations>
     */
    public List<LawSimilarityRelations> checkLawRelations(LawSimilarityRelations relations) {
        try {
            List<LawSimilarityRelations> lawRelations = knowledgeCaseClient.checkLawRelations(relations);
            if (lawRelations != null) {
                return lawRelations;
            } else {
                log.error("Client外服务接口[KnowledgeCaseClientImpl.checkLawRelations]请求异常:未获取到法条关系");
                return new ArrayList<>();
            }
        } catch (Exception e) {
            log.error("service方法[KnowledgeCaseClientImpl.checkLawRelations]调用异常:" + e, e);
            throw new ServiceException("KnowledgeCaseClientImpl.checkLawRelations", e);
        }
    }
 
    /**
     * 获取法律详情
     * @param id 法律ID
     * @return LawProvision
     */
    public LawProvision getLawProvisionById(String id) {
        try {
            ReturnBO returnBo = knowledgeCaseClient.getLawProvisionById(id);
            log.info("Client外服务接口[KnowledgeCaseClientImpl.getLawProvisionById]请求成功,返回结果:" + returnBo);
            if (ReturnConsts.OK == returnBo.getCode()){
                return objectMapper.convertValue(returnBo.getData(), LawProvision.class);
            } else {
                log.error("Client外服务接口[KnowledgeCaseClientImpl.getLawProvisionById]请求异常:未获取到法律详情");
                throw new ClientException("KnowledgeCaseClientImpl.getLawProvisionById", "未获取到法律详情");
            }
        } catch (Exception e) {
            log.error("service方法[KnowledgeCaseClientImpl.getLawProvisionById]调用异常:" + e, e);
            throw new ServiceException("KnowledgeCaseClientImpl.getLawProvisionById", e);
        }
    }