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);
|
}
|
}
|
}
|