package cn.huge.module.syncbydyh.service;
|
|
import cn.huge.base.common.exception.ServiceException;
|
import cn.huge.base.common.utils.ObjectUtils;
|
import cn.huge.module.cases.domain.dto.AcceptTaskDTO;
|
import cn.huge.module.cases.domain.po.*;
|
import cn.huge.module.cases.service.*;
|
import cn.huge.module.client.api.impl.CustClientImpl;
|
import cn.huge.module.cust.constant.UserBaseConsts;
|
import cn.huge.module.cust.dto.CtUnitDTO;
|
import cn.huge.module.cust.dto.CtUserDTO;
|
import cn.huge.module.disp.dto.DispCaseBaseDTO;
|
import cn.huge.module.judic.domain.po.JudicAssist;
|
import cn.huge.module.judic.domain.po.JudicInfo;
|
import cn.huge.module.judic.service.JudicAssistService;
|
import cn.huge.module.judic.service.JudicInfoService;
|
import cn.huge.module.syncbydyh.client.api.impl.SyncBydyhClientImpl;
|
import cn.huge.module.syncbydyh.domain.dto.ByCaseTaskDTO;
|
import cn.huge.module.syncbydyh.domain.dto.GZCaseDTO;
|
import cn.huge.module.syncbydyh.domain.dto.GZJudicAssistDTO;
|
import cn.huge.module.syncbydyh.domain.dto.GZJudicDTO;
|
import cn.huge.module.syncbydyh.domain.po.SyCause;
|
import cn.huge.module.syncbydyh.domain.po.ThirdCause;
|
import com.alibaba.fastjson.JSON;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import lombok.extern.slf4j.Slf4j;
|
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
/**
|
* @title: 白云区矛盾纠纷多元化解平台数据割接-公共逻辑处理
|
* @Description 白云区矛盾纠纷多元化解平台数据割接-公共逻辑处理
|
* @company hugeinfo
|
* @author liyj
|
* @Time 2024-08-19 20:04:19
|
* @version 1.0.0
|
*/
|
@Slf4j
|
@Service
|
public class ByToGzService{
|
|
@Autowired
|
private SyncBydyhClientImpl syncBydyhClient;
|
@Autowired
|
private CaseInfoService caseInfoService;
|
@Autowired
|
private CaseInfoUnfoldService caseInfoUnfoldService;
|
@Autowired
|
private CasePersonService casePersonService;
|
@Autowired
|
private CaseAgentService caseAgentService;
|
@Autowired
|
private CaseTaskService caseTaskService;
|
@Autowired
|
private ThirdCauseService thirdCauseService;
|
@Autowired
|
private SyCauseService syCauseService;
|
@Autowired
|
private CustClientImpl custClient;
|
@Autowired
|
private ByToGzCaseTaskService byToGzCaseTaskService;
|
@Autowired
|
private JudicInfoService judicInfoService;
|
@Autowired
|
private JudicAssistService judicAssistService;
|
|
/**
|
* 白云区矛盾纠纷多元化解平台数据割接-已结束的纠纷案件信息
|
*/
|
public void byToGzEndCase(){
|
try{
|
List<CaseInfo> errorCaseList = new ArrayList<>();
|
int operSize = 100;
|
// int endCaseCount = 1100;
|
int endCaseCount = syncBydyhClient.countEndCase();
|
if (endCaseCount > 0) {
|
int allPage = 1;
|
if(operSize < endCaseCount) {
|
allPage = (endCaseCount / operSize) + 1;
|
}
|
for (int operPage=1; operPage<=allPage; operPage++) {
|
List<GZCaseDTO> byToGzDTOList = syncBydyhClient.byToGzEndCase(operPage, operSize);
|
for (GZCaseDTO byToGzDTO: byToGzDTOList){
|
CaseInfo oldCaseInfo = caseInfoService.getById(byToGzDTO.getGzCaseInfoDTO().getId());
|
if (ObjectUtils.isEmpty(oldCaseInfo)) {
|
try {
|
// 新增案件信息
|
CaseInfo caseInfo = byToGzDTO.getGzCaseInfoDTO();
|
if (StringUtils.isNotEmpty(caseInfo.getCaseClaim())) {
|
if (caseInfo.getCaseClaim().length() > 200) {
|
caseInfo.setCaseClaim("详见申请材料");
|
}
|
}
|
if (StringUtils.isNotEmpty(caseInfo.getCaseDes())) {
|
if (caseInfo.getCaseDes().length() > 200) {
|
caseInfo.setCaseDes("详见申请材料");
|
}
|
}
|
caseInfoService.save(caseInfo);
|
// 新增案件扩展信息
|
caseInfoUnfoldService.save(byToGzDTO.getGzCaseInfoUnfoldDTO());
|
// 新增当事人信息
|
List<CasePerson> casePersonList = byToGzDTO.getGzCasePersonDTOList();
|
if (CollectionUtils.isNotEmpty(casePersonList)) {
|
for (CasePerson casePerson : casePersonList) {
|
casePersonService.save(casePerson);
|
}
|
}
|
// 新增当事人代理人信息
|
List<CaseAgent> caseAgentList = byToGzDTO.getGzCaseAgentDTOList();
|
if (CollectionUtils.isNotEmpty(caseAgentList)) {
|
for (CaseAgent caseAgent : caseAgentList) {
|
caseAgentService.save(caseAgent);
|
}
|
}
|
// 新增纠纷任务信息
|
List<CaseTask> caseTaskList = byToGzDTO.getGzCaseTaskDTOList();
|
if (CollectionUtils.isNotEmpty(caseTaskList)) {
|
for (CaseTask caseTask : caseTaskList) {
|
caseTaskService.save(caseTask);
|
}
|
}
|
} catch (Exception e) {
|
log.error("[ByToGzService.byToGzEndCase]调用失败,异常信息:" + e, e);
|
log.error("案件信息:" + byToGzDTO.getGzCaseInfoDTO().toString());
|
errorCaseList.add(byToGzDTO.getGzCaseInfoDTO());
|
}
|
}
|
}
|
}
|
}
|
}catch (Exception e){
|
log.error("[ByToGzService.byToGzEndCase]调用失败,异常信息:"+e, e);
|
throw new ServiceException("ByToGzService.byToGzEndCase", e);
|
}
|
}
|
|
/**
|
* 白云区矛盾纠纷多元化解平台数据割接-进行中的纠纷案件信息
|
*/
|
public void byToGzTodoCase(){
|
try{
|
int operSize = 100;
|
// int endCaseCount = 1100;
|
int endCaseCount = syncBydyhClient.countTodoCase();
|
if (endCaseCount > 0) {
|
int allPage = 1;
|
if(operSize < endCaseCount) {
|
allPage = (endCaseCount / operSize) + 1;
|
}
|
for (int operPage=1; operPage<=allPage; operPage++) {
|
List<GZCaseDTO> byToGzDTOList = syncBydyhClient.byToGzTodoCase(operPage, operSize);
|
for (GZCaseDTO byToGzDTO: byToGzDTOList){
|
CaseInfo oldCaseInfo = caseInfoService.getById(byToGzDTO.getGzCaseInfoDTO().getId());
|
if (ObjectUtils.isEmpty(oldCaseInfo)) {
|
try {
|
// 新增案件信息
|
CaseInfo caseInfo = byToGzDTO.getGzCaseInfoDTO();
|
if (StringUtils.isNotEmpty(caseInfo.getCaseClaim())) {
|
if (caseInfo.getCaseClaim().length() > 200) {
|
caseInfo.setCaseClaim("详见申请材料");
|
}
|
}
|
if (StringUtils.isNotEmpty(caseInfo.getCaseDes())) {
|
if (caseInfo.getCaseDes().length() > 200) {
|
caseInfo.setCaseDes("详见申请材料");
|
}
|
}
|
caseInfoService.save(caseInfo);
|
// 新增案件扩展信息
|
CaseInfoUnfold caseInfoUnfold = byToGzDTO.getGzCaseInfoUnfoldDTO();
|
caseInfoUnfoldService.save(caseInfoUnfold);
|
// 新增当事人信息
|
List<CasePerson> casePersonList = byToGzDTO.getGzCasePersonDTOList();
|
if (CollectionUtils.isNotEmpty(casePersonList)) {
|
for (CasePerson casePerson : casePersonList) {
|
casePersonService.save(casePerson);
|
}
|
}
|
// 新增当事人代理人信息
|
List<CaseAgent> caseAgentList = byToGzDTO.getGzCaseAgentDTOList();
|
if (CollectionUtils.isNotEmpty(caseAgentList)) {
|
for (CaseAgent caseAgent : caseAgentList) {
|
caseAgentService.save(caseAgent);
|
}
|
}
|
// 启动流程
|
caseTaskService.deleteByCaseId(caseInfo.getId());
|
if (StringUtils.isNotEmpty(caseInfoUnfold.getMediateUnitId())
|
&& StringUtils.isNotEmpty(caseInfo.getWantUnitId())
|
&& caseInfo.getWantUnitId().equals(caseInfoUnfold.getMediateUnitId())) {
|
CtUserDTO ctUserDTO = custClient.clientGetUserAll(caseInfo.getInputUserId());
|
byToGzCaseTaskService.webStartFlowZXSL(caseInfo, ctUserDTO);
|
} else {
|
DispCaseBaseDTO dispCaseBaseDTO = new DispCaseBaseDTO();
|
BeanUtils.copyProperties(caseInfo, dispCaseBaseDTO);
|
dispCaseBaseDTO.setWantUserId(null);
|
dispCaseBaseDTO.setWantUserName(null);
|
if (StringUtils.isNotEmpty(caseInfoUnfold.getMediateUnitId())) {
|
dispCaseBaseDTO.setWantUnitId(caseInfoUnfold.getMediateUnitId());
|
dispCaseBaseDTO.setWantUnitName(caseInfoUnfold.getMediateUnitName());
|
String dslCaseTaskId = byToGzCaseTaskService.webStartFlowLFDJ(caseInfo, dispCaseBaseDTO);
|
|
List<ByCaseTaskDTO> byCaseTaskDTOList = byToGzDTO.getByCaseTaskDTOList();
|
if (CollectionUtils.isNotEmpty(byCaseTaskDTOList)) {
|
for (ByCaseTaskDTO byCaseTaskDTO : byCaseTaskDTOList) {
|
if ("F22_00019-2".equals(byCaseTaskDTO.getTaskNode())) {
|
AcceptTaskDTO acceptTaskDTO = new AcceptTaskDTO();
|
acceptTaskDTO.setCaseTaskId(dslCaseTaskId);
|
try {
|
byToGzCaseTaskService.webAccept(acceptTaskDTO, byCaseTaskDTO.getHandlerUserId(), byCaseTaskDTO.getCreateTime());
|
} catch (Exception e) {
|
log.error(e.getMessage(), e);
|
}
|
}
|
}
|
}
|
} else {
|
byToGzCaseTaskService.webStartFlowLFDJ(caseInfo, dispCaseBaseDTO);
|
}
|
}
|
} catch (Exception e) {
|
log.error("[ByToGzService.byToGzEndCase]调用失败,异常信息:" + e, e);
|
}
|
}
|
}
|
}
|
}
|
}catch (Exception e){
|
log.error("[ByToGzService.byToGzEndCase]调用失败,异常信息:"+e, e);
|
throw new ServiceException("ByToGzService.byToGzEndCase", e);
|
}
|
}
|
|
/**
|
* 白云区矛盾纠纷多元化解平台数据割接-更新纠纷类型
|
*/
|
public void upThirdCause(){
|
try{
|
QueryWrapper<CaseInfo> caseInfoQueryWrapper = new QueryWrapper<>();
|
caseInfoQueryWrapper.select("id", "case_type").isNull("case_type_first");
|
List<CaseInfo> caseInfoList = caseInfoService.list(caseInfoQueryWrapper);
|
QueryWrapper<ThirdCause> thirdCauseQueryWrapper = new QueryWrapper<>();
|
for (CaseInfo caseInfo: caseInfoList){
|
thirdCauseQueryWrapper.clear();
|
thirdCauseQueryWrapper.eq("third_code", caseInfo.getCaseType());
|
ThirdCause thirdCause = thirdCauseService.getOne(thirdCauseQueryWrapper);
|
if (ObjectUtils.isNotEmpty(thirdCause)){
|
SyCause syCause = syCauseService.getById(thirdCause.getCauseCode());
|
if (ObjectUtils.isNotEmpty(syCause)){
|
// 查询父级
|
SyCause syCausePanrent = syCauseService.getById(syCause.getParentId());
|
if (ObjectUtils.isNotEmpty(syCausePanrent)){
|
try{
|
CaseInfo caseInfoPO = new CaseInfo();
|
caseInfoPO.setId(caseInfo.getId());
|
caseInfoPO.setCaseType(syCause.getId());
|
caseInfoPO.setCaseTypeName(syCause.getName());
|
caseInfoPO.setCaseTypeFirst(syCausePanrent.getId());
|
caseInfoPO.setCaseTypeFirstName(syCausePanrent.getName());
|
caseInfoService.updateCaseInfo(caseInfoPO);
|
}catch (Exception e){
|
log.error("[ByToGzService.upThirdCause]调用失败,异常信息:"+e, e);
|
}
|
}
|
}
|
}
|
}
|
}catch (Exception e){
|
log.error("[ByToGzService.byToGzEndCase]调用失败,异常信息:"+e, e);
|
throw new ServiceException("ByToGzService.byToGzEndCase", e);
|
}
|
|
}
|
|
/**
|
* 白云区矛盾纠纷多元化解平台数据割接-更新问题属地的村级社区
|
*/
|
public void upQueAddr(){
|
try{
|
List<CaseInfoUnfold> caseInfoUnfoldList = caseInfoUnfoldService.list();
|
for (CaseInfoUnfold caseInfoUnfold: caseInfoUnfoldList){
|
if (StringUtils.isNotEmpty(caseInfoUnfold.getMediateUnitId())) {
|
CtUnitDTO ctUnitDTO = custClient.getUnitById(caseInfoUnfold.getMediateUnitId());
|
if (ObjectUtils.isNotEmpty(ctUnitDTO)){
|
if (StringUtils.isNotEmpty(ctUnitDTO.getVillage())) {
|
CaseInfo caseInfo = new CaseInfo();
|
caseInfo.setId(caseInfoUnfold.getId());
|
caseInfo.setQueVillage(ctUnitDTO.getVillage());
|
caseInfo.setQueVillageName(ctUnitDTO.getVillageName());
|
caseInfoService.updateCaseInfo(caseInfo);
|
}
|
}
|
}
|
}
|
}catch (Exception e){
|
log.error("[ByToGzService.upQueAddr]调用失败,异常信息:"+e, e);
|
throw new ServiceException("ByToGzService.upQueAddr", e);
|
}
|
|
}
|
|
/**
|
* 白云区矛盾纠纷多元化解平台数据割接-更新纠纷类型
|
*/
|
public void upCauseByOld(){
|
try{
|
QueryWrapper<CaseInfo> caseInfoQueryWrapper = new QueryWrapper<>();
|
caseInfoQueryWrapper.select("id", "old_case_type").isNotNull("old_case_type");
|
List<CaseInfo> caseInfoList = caseInfoService.list(caseInfoQueryWrapper);
|
QueryWrapper<ThirdCause> thirdCauseQueryWrapper = new QueryWrapper<>();
|
for (CaseInfo caseInfo: caseInfoList){
|
thirdCauseQueryWrapper.clear();
|
thirdCauseQueryWrapper.eq("third_code", caseInfo.getOldCaseType());
|
ThirdCause thirdCause = thirdCauseService.getOne(thirdCauseQueryWrapper);
|
if (ObjectUtils.isNotEmpty(thirdCause)){
|
SyCause syCause = syCauseService.getById(thirdCause.getCauseCode());
|
if (ObjectUtils.isNotEmpty(syCause)){
|
// 查询父级
|
SyCause syCausePanrent = syCauseService.getById(syCause.getParentId());
|
if (ObjectUtils.isNotEmpty(syCausePanrent)){
|
try{
|
CaseInfo caseInfoPO = new CaseInfo();
|
caseInfoPO.setId(caseInfo.getId());
|
caseInfoPO.setCaseType(syCause.getId());
|
caseInfoPO.setCaseTypeName(syCause.getName());
|
caseInfoPO.setCaseTypeFirst(syCausePanrent.getId());
|
caseInfoPO.setCaseTypeFirstName(syCausePanrent.getName());
|
caseInfoService.updateCaseInfo(caseInfoPO);
|
}catch (Exception e){
|
log.error("[ByToGzService.upThirdCause]调用失败,异常信息:"+e, e);
|
}
|
}
|
}
|
}
|
}
|
}catch (Exception e){
|
log.error("[ByToGzService.byToGzEndCase]调用失败,异常信息:"+e, e);
|
throw new ServiceException("ByToGzService.byToGzEndCase", e);
|
}
|
|
}
|
|
|
/**
|
* 白云区矛盾纠纷多元化解平台数据割接-进行中的纠纷案件信息
|
*/
|
public void byToGzJudic(){
|
try{
|
int operSize = 100;
|
int judicCount = syncBydyhClient.countJudic();
|
if (judicCount > 0) {
|
int allPage = 1;
|
if(operSize < judicCount) {
|
allPage = (judicCount / operSize) + 1;
|
}
|
for (int operPage=1; operPage<=allPage; operPage++) {
|
List<GZJudicDTO> byToGzDTOList = syncBydyhClient.byToGzJudic(operPage, operSize);
|
log.info("byToGzJudic byToGzDTOList {}", JSON.toJSONString(byToGzDTOList));
|
for (GZJudicDTO byToGzDTO: byToGzDTOList){
|
JudicInfo judicInfo = judicInfoService.getById(byToGzDTO.getGzJudicInfoDTO().getId());
|
if (ObjectUtils.isEmpty(judicInfo)) {
|
judicInfo = new JudicInfo();
|
BeanUtils.copyProperties(byToGzDTO.getGzJudicInfoDTO(), judicInfo);
|
log.info("byToGzJudic judicInfo insert {}", JSON.toJSONString(judicInfo));
|
judicInfoService.save(judicInfo);
|
}
|
List<GZJudicAssistDTO> gzJudicAssistDTOList = byToGzDTO.getGzJudicAssistDTOList();
|
if(ObjectUtils.isNotEmpty(gzJudicAssistDTOList)){
|
for (GZJudicAssistDTO gzJudicAssistDTO: gzJudicAssistDTOList){
|
JudicAssist judicAssist = judicAssistService.getById(gzJudicAssistDTO.getId());
|
if(ObjectUtils.isEmpty(judicAssist)){
|
judicAssist = new JudicAssist();
|
BeanUtils.copyProperties(gzJudicAssistDTO, judicAssist);
|
log.info("byToGzJudic judicAssist insert {}", JSON.toJSONString(judicAssist));
|
judicAssistService.save(judicAssist);
|
}
|
}
|
}
|
}
|
}
|
}
|
}catch (Exception e){
|
log.error("[ByToGzService.byToGzJudic]调用失败,异常信息:"+e, e);
|
throw new ServiceException("ByToGzService.byToGzJudic", e);
|
}
|
}
|
|
}
|