From 77f20090b25e6f168e3eccf4c47ea8dd695450a7 Mon Sep 17 00:00:00 2001
From: 文锦钊 <10491931+wen-jinzhao@user.noreply.gitee.com>
Date: Thu, 03 Jul 2025 15:44:29 +0800
Subject: [PATCH] feature:对接纠纷办理反馈信息

---
 dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/service/CaseFeedbackService.java |   87 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 86 insertions(+), 1 deletions(-)

diff --git a/dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/service/CaseFeedbackService.java b/dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/service/CaseFeedbackService.java
index e82ca3c..e54301e 100644
--- a/dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/service/CaseFeedbackService.java
+++ b/dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/service/CaseFeedbackService.java
@@ -1,12 +1,15 @@
 package cn.huge.module.cases.service;
+import java.util.ArrayList;
 
 import cn.huge.base.common.exception.ServiceException;
 import cn.huge.base.common.utils.DateUtils;
 import cn.huge.base.common.utils.IdUtils;
 import cn.huge.base.common.utils.ObjectUtils;
+import cn.huge.base.common.utils.ThreadPoolUtils;
 import cn.huge.module.cases.consts.CaseTaskConsts;
 import cn.huge.module.cases.domain.dto.MediatorDTO;
 import cn.huge.module.cases.domain.po.*;
+import cn.huge.module.cases.domain.vo.SaveEventFeedBackVo;
 import cn.huge.module.client.api.impl.CustClientImpl;
 import cn.huge.module.client.api.impl.SysClientImpl;
 import cn.huge.module.client.api.impl.UtilsClientImpl;
@@ -14,15 +17,18 @@
 import cn.huge.module.cust.dto.CtUnitDTO;
 import cn.huge.module.cust.dto.CtUserDTO;
 import cn.huge.module.mediate.constant.CaseBaseConsts;
+import cn.huge.module.mediate.constant.CaseBaseConstsEnum;
 import cn.huge.module.sys.dto.FileIdInfoBaseDTO;
 import cn.huge.module.sys.dto.FileInfoBaseDTO;
 import cn.huge.module.sys.dto.FileTypeInfoBaseDTO;
+import cn.huge.module.utils.TimeUtils;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.google.common.collect.Maps;
 import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.data.domain.Page;
@@ -32,6 +38,7 @@
 
 import javax.print.DocFlavor;
 import java.util.*;
+import java.util.concurrent.CompletableFuture;
 import java.util.stream.Collectors;
 
 /**
@@ -73,6 +80,9 @@
 
     @Autowired
     private CaseMediatorService caseMediatorService;
+
+    @Autowired
+    private CaseInfoService caseInfoService;
 
     /**
      * 更新对象
@@ -165,10 +175,83 @@
             }
             caseFeedback.setUpdateTime(nowDate);
             this.saveOrUpdate(caseFeedback);
+
+            //  异步同步纠纷办理反馈信息
+            asyncSaveEventFeedback(caseFeedback, userId);
+
         } catch (Exception e) {
             log.error("[caseFeedbackService.savecaseFeedback]调用失败,异常信息:" + e, e);
             throw new ServiceException("caseFeedbackService.savecaseFeedback", e);
         }
+    }
+
+    /**
+     * 异步保存办理反馈信息
+     *
+     * @param caseFeedback
+     * @param userId
+     */
+    private void asyncSaveEventFeedback(CaseFeedback caseFeedback, String userId) {
+        String caseId = caseFeedback.getCaseId();
+        CaseInfo caseInfo = caseInfoService.getById(caseId);
+        String canalSecond = caseInfo.getCanalSecond();
+
+        //  需要同步的渠道类型
+        List<String> needSyncTypeList = new ArrayList<>();
+        needSyncTypeList.add(CaseBaseConstsEnum.CASE_CANAL_SECOND_1.getIndex());
+        needSyncTypeList.add(CaseBaseConstsEnum.CASE_CANAL_SECOND_2.getIndex());
+        needSyncTypeList.add(CaseBaseConstsEnum.CASE_CANAL_SECOND_7.getIndex());
+
+        if (!needSyncTypeList.contains(canalSecond)) {
+            log.info("当前来源的事项不需要同步,来源为:" + CaseBaseConstsEnum.getDes(canalSecond));
+            return ;
+        }
+
+        //  使用单例设计的线程池来异步同步
+        ThreadPoolUtils.submit(()->{
+            log.info("异步保存办理反馈信息开始");
+            //  保存办理反馈信息后需要同步到大平台中
+            String evtId = caseInfo.getCaseRef();
+
+            //  反馈用户信息
+            CtUserDTO ctUserDTO = custClient.clientGetUser(userId);
+            CtUnitDTO ctUnitDTO = custClient.getUnitById(ctUserDTO.getUnitId());
+
+            //  反馈意见内容
+            String handleContent = caseFeedback.getHandleContent();
+
+            //  反馈时间
+            Date now = new Date();
+            String appTime = TimeUtils.format(now,TimeUtils.STANDARD_PATTERN);
+            String processingTime = TimeUtils.format(TimeUtils.after(now,14),TimeUtils.STANDARD_PATTERN);
+
+            //  构建参数
+            SaveEventFeedBackVo saveEventFeedBackVo = new SaveEventFeedBackVo();
+            saveEventFeedBackVo.setId(caseId);
+            saveEventFeedBackVo.setEvtId(evtId);
+
+            //  先传递当前子系统的用户id
+            saveEventFeedBackVo.setAppUserId(userId);
+            saveEventFeedBackVo.setAppUserName(ctUserDTO.getTrueName());
+            saveEventFeedBackVo.setAppOrgId(ctUnitDTO.getId());
+            saveEventFeedBackVo.setAppOrgName(ctUnitDTO.getUnitName());
+
+            saveEventFeedBackVo.setAppTime(appTime);
+            saveEventFeedBackVo.setApproveContent(handleContent);
+            saveEventFeedBackVo.setProcessingTime(processingTime);
+            saveEventFeedBackVo.setHandleType("");
+
+            //  附件信息
+            List<FileInfoBaseDTO> fileInfoList = caseFeedback.getFileInfoList();
+            saveEventFeedBackVo.setFileInfoList(fileInfoList);
+
+            //  发起同步
+            sysClient.saveEventFeedback(saveEventFeedBackVo);
+            log.info("异步保存办理反馈信息成功!!");
+            return null;
+        });
+
+
     }
 
     /**
@@ -327,12 +410,14 @@
             QueryWrapper<CaseInfoUnfold> caseInfoUnfoldQueryWrapper = new QueryWrapper<>();
             caseInfoUnfoldQueryWrapper.eq("id", caseFeedback.getCaseId());
             CaseInfoUnfold caseInfoUnfold = unfoldService.getOne(caseInfoUnfoldQueryWrapper);
-            if (caseInfoUnfold.getMediateUnitId().equals(loginUser.getUnitId())) {
+            if (caseInfoUnfold.getMediateUnitId() != null && caseInfoUnfold.getMediateUnitId().equals(loginUser.getUnitId())) {
                 caseFeedback.setHandleType(CaseTaskConsts.HANDLE_TYPE_1);
             } else {
                 caseFeedback.setHandleType(CaseTaskConsts.HANDLE_TYPE_2);
             }
             this.save(caseFeedback);
+            //  异步同步纠纷办理反馈信息
+            asyncSaveEventFeedback(caseFeedback, userId);
         } catch (Exception e) {
             log.error("[caseFeedbackService.savecaseFeedback]调用失败,异常信息:" + e, e);
             throw new ServiceException("caseFeedbackService.savecaseFeedback", e);

--
Gitblit v1.8.0