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.base.common.utils.ObjectUtils;
|
import cn.huge.module.client.api.CaseClient;
|
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.griddata.domain.CaseAgent;
|
import cn.huge.module.griddata.domain.CaseInfo;
|
import cn.huge.module.griddata.domain.CaseInfoUnfold;
|
import cn.huge.module.griddata.domain.CasePerson;
|
import cn.huge.module.griddata.domain.vo.CaseVo;
|
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 java.util.ArrayList;
|
import java.util.LinkedHashMap;
|
import java.util.List;
|
|
/**
|
* 获取案件数据同步给亿迅
|
*/
|
@Slf4j
|
@Component
|
public class CaseClientImpl {
|
@Autowired
|
private CaseClient caseClient;
|
|
@Autowired
|
public CaseClientImpl(CaseClient caseClient) {
|
this.caseClient = caseClient;
|
}
|
|
/**
|
* ObjectMapper工具类
|
*/
|
private ObjectMapper objectMapper = new ObjectMapper();
|
|
public List<CaseInfo> getCaseInfo(CaseVo caseVo) {
|
try {
|
List<CaseInfo> caseInfoList = new ArrayList<>();
|
ReturnBO returnBo = caseClient.getCaseList(caseVo);
|
if (ReturnConsts.OK == returnBo.getCode()) {
|
if (ObjectUtils.isNotEmpty(returnBo.getData())){
|
List<LinkedHashMap> list = (List<LinkedHashMap>) returnBo.getData();
|
for (LinkedHashMap map : list) {
|
CaseInfo ctUnitDTO = JSON.parseObject(JSON.toJSONString(map), CaseInfo.class);
|
caseInfoList.add(ctUnitDTO);
|
}
|
}
|
|
return caseInfoList;
|
} else {
|
log.error("Client外服务接口[CaseClientImpl.getCaseInfo]请求异常:" + returnBo.getMsg(), returnBo.getMsg());
|
throw new ClientException("CaseClientImpl.getCaseInfo", returnBo.getMsg());
|
}
|
} catch (Exception e) {
|
log.error("service方法[CaseClientImpl.getCaseInfo]调用异常:" + e, e);
|
throw new ServiceException("CaseClientImpl.getCaseInfo", e);
|
}
|
}
|
|
public List<CaseInfoUnfold> getCaseInfoUnfold(String caseId) {
|
try {
|
ReturnBO returnBo = caseClient.getCaseUnfoldList(caseId);
|
List<CaseInfoUnfold> caseInfoList = new ArrayList<>();
|
if (ReturnConsts.OK == returnBo.getCode()) {
|
if (ObjectUtils.isNotEmpty(returnBo.getData())){
|
List<LinkedHashMap> list = (List<LinkedHashMap>) returnBo.getData();
|
for (LinkedHashMap map : list) {
|
CaseInfoUnfold ctUnitDTO = JSON.parseObject(JSON.toJSONString(map), CaseInfoUnfold.class);
|
caseInfoList.add(ctUnitDTO);
|
}
|
}
|
return caseInfoList;
|
} else {
|
log.error("Client外服务接口[CaseClientImpl.getCaseInfoUnfold]请求异常:" + returnBo.getMsg(), returnBo.getMsg());
|
throw new ClientException("CaseClientImpl.getCaseInfoUnfold", returnBo.getMsg());
|
}
|
} catch (Exception e) {
|
log.error("service方法[CaseClientImpl.getCaseInfoUnfold]调用异常:" + e, e);
|
throw new ServiceException("CaseClientImpl.getCaseInfoUnfold", e);
|
}
|
}
|
|
public List<CasePerson> getCasePerson(String caseId) {
|
try {
|
List<CasePerson> caseInfoList = new ArrayList<>();
|
ReturnBO returnBo = caseClient.getCasePersonList(caseId);
|
if (ReturnConsts.OK == returnBo.getCode()) {
|
if (ObjectUtils.isNotEmpty(returnBo.getData())){
|
List<LinkedHashMap> list = (List<LinkedHashMap>) returnBo.getData();
|
for (LinkedHashMap map : list) {
|
CasePerson ctUnitDTO = JSON.parseObject(JSON.toJSONString(map), CasePerson.class);
|
caseInfoList.add(ctUnitDTO);
|
}
|
}
|
return caseInfoList;
|
} else {
|
log.error("Client外服务接口[CaseClientImpl.getCasePerson]请求异常:" + returnBo.getMsg(), returnBo.getMsg());
|
throw new ClientException("CaseClientImpl.getCasePerson", returnBo.getMsg());
|
}
|
} catch (Exception e) {
|
log.error("service方法[CaseClientImpl.getCasePerson]调用异常:" + e, e);
|
throw new ServiceException("CaseClientImpl.getCasePerson", e);
|
}
|
}
|
|
public List<CaseAgent> getCaseAgent(String caseId) {
|
try {
|
List<CaseAgent> caseInfoList = new ArrayList<>();
|
ReturnBO returnBo = caseClient.getCaseAgentList(caseId);
|
if (ReturnConsts.OK == returnBo.getCode()) {
|
if (ObjectUtils.isNotEmpty(returnBo.getData())){
|
List<LinkedHashMap> list = (List<LinkedHashMap>) returnBo.getData();
|
for (LinkedHashMap map : list) {
|
CaseAgent ctUnitDTO = JSON.parseObject(JSON.toJSONString(map), CaseAgent.class);
|
caseInfoList.add(ctUnitDTO);
|
}
|
}
|
return caseInfoList;
|
} else {
|
log.error("Client外服务接口[CaseClientImpl.getCaseAgent]请求异常:" + returnBo.getMsg(), returnBo.getMsg());
|
throw new ClientException("CaseClientImpl.getCaseAgent", returnBo.getMsg());
|
}
|
} catch (Exception e) {
|
log.error("service方法[CaseClientImpl.getCaseAgent]调用异常:" + e, e);
|
throw new ServiceException("CaseClientImpl.getCaseAgent", e);
|
}
|
}
|
}
|