From e282e3bb247adc903e201e85239a504548efa7c6 Mon Sep 17 00:00:00 2001
From: wangwh <2397901735@qq.com>
Date: Tue, 10 Sep 2024 14:26:20 +0800
Subject: [PATCH] 1、修改查询下级所有组织接口 2、首页相关接口

---
 dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/service/CaseTaskService.java |  214 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 204 insertions(+), 10 deletions(-)

diff --git a/dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/service/CaseTaskService.java b/dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/service/CaseTaskService.java
index 8c8a2b8..77d68a3 100644
--- a/dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/service/CaseTaskService.java
+++ b/dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/service/CaseTaskService.java
@@ -3,7 +3,14 @@
 import cn.huge.base.common.exception.ServiceException;
 import cn.huge.base.common.utils.DateUtils;
 import cn.huge.base.common.utils.IdUtils;
+import cn.huge.module.cases.dao.mapper.*;
+import cn.huge.module.cases.domain.dto.*;
 import cn.huge.base.common.utils.ObjectUtils;
+import cn.huge.module.cases.domain.dto.CaseFlowDTO;
+import cn.huge.module.cases.domain.dto.TabButtonDTO;
+import cn.huge.module.cases.domain.dto.TabButtonInfoDTO;
+import cn.huge.module.cases.domain.po.CaseAssistApply;
+import cn.huge.module.cases.domain.po.CaseInfoUnfold;
 import cn.huge.module.cases.domain.dto.*;
 import cn.huge.module.cases.domain.po.*;
 import cn.huge.module.client.api.impl.CustClientImpl;
@@ -11,10 +18,14 @@
 import cn.huge.module.client.api.impl.SysClientImpl;
 import cn.huge.module.client.api.impl.UtilsClientImpl;
 import cn.huge.module.cases.dao.mapper.CaseTaskMapper;
+import cn.huge.module.cases.domain.po.CaseTask;
 import cn.huge.module.constant.BaseConsts;
 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.mediate.constant.AuditBaseConsts;
+import cn.huge.module.mediate.constant.AuditBaseConstsEnum;
+import cn.huge.module.mediate.constant.CaseBaseConsts;
 import cn.huge.module.disp.constant.DispBaseConstsEnum;
 import cn.huge.module.disp.dto.CaseDispBaseDTO;
 import cn.huge.module.disp.dto.DispCaseBaseDTO;
@@ -31,6 +42,7 @@
 import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Sort;
 import org.springframework.stereotype.Service;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.data.domain.Page;
@@ -38,6 +50,8 @@
 import org.springframework.data.domain.PageRequest;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.PostConstruct;
+import java.time.temporal.ChronoUnit;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -75,6 +89,21 @@
     private CaseInfoUnfoldService caseInfoUnfoldService;
     @Autowired
     private CaseWindupApplyService caseWindupApplyService;
+
+    @Autowired
+    private CaseWindupApplyMapper caseWindupApplyMapper;
+
+    @Autowired
+    private CaseReturnMapper caseReturnMapper;
+
+    @Autowired
+    private CaseAppearMapper caseAppearMapper;
+
+    @Autowired
+    private CaseAssistApplyMapper caseAssistApplyMapper;
+
+    @Autowired
+    private CaseAssistApplyService assistApplyService;
 
     /**
     * 更新对象
@@ -429,22 +458,187 @@
     }
 
     /**
-     * 按条件统计
+     * 获取首页统计数量
      * @param userId 用户编号
      * @return long
      */
-    public Map<String, Long> getCountList(String userId){
-        CtUserDTO loginUser = custClient.clientGetUserAll(userId);
-        Map<String, Object> terms = new HashMap<>();
-        terms.put("candeUnitId", loginUser.getUnitId());
-        terms.put("candeDeptId", loginUser.getDeptId());
-        mapper.countTaskList(terms);
-        superviseService.countCaseSuperviseList(0,loginUser.getUnitId());
-        Map<String, Long> result = new HashMap<>();
-        return result;
+    public FrontPageCountDTO getCountList(String userId){
+        try {
+            CtUserDTO loginUser = custClient.clientGetUserAll(userId);
+            Map<String, Object> terms = new HashMap<>();
+            terms.put("candeUnitId", loginUser.getUnitId());
+            terms.put("candeDeptId", loginUser.getDeptId());
+            FrontPageCountDTO frontPageCountDTO = mapper.countTaskList(terms);
+            long supervise = superviseService.countCaseSuperviseList(0,loginUser.getUnitId());
+            frontPageCountDTO.setSupervise(supervise);
+            long countApplyReview = caseWindupApplyMapper.countApplyReview(loginUser.getUnitId());
+            long countReturnReview = caseReturnMapper.countReturnReview(loginUser.getUnitId());
+            long countAppearReview = caseAppearMapper.countAppearReview(loginUser.getUnitId());
+            long countAssistReview = caseAssistApplyMapper.countAssistReview(loginUser.getUnitId());
+            frontPageCountDTO.setWaitReview(countApplyReview+countReturnReview+countAppearReview+countAssistReview);
+            return frontPageCountDTO;
+        }catch (Exception e) {
+            log.error("[CaseTaskService.getCountList]调用失败,异常信息:" + e, e);
+            throw new ServiceException("CaseTaskService.getCountList", e);
+        }
     }
 
     /**
+     * 首页-查询待办任务-受分派
+     * @param page 分页对象
+     * @param terms 条件
+     * @return Page
+     */
+    public Page<FrontPageListDTO> pageMyTaskFp(PageRequest page, Map<String, Object> terms){
+        try {
+            long total = mapper.countMyTaskFp(terms);
+            List<FrontPageListDTO> frontPageListDTOList = mapper.pageMyTaskFp(page, terms);
+            return new PageImpl<FrontPageListDTO>(frontPageListDTOList, page, total);
+        }catch (Exception e) {
+            log.error("[CaseTaskService.pageMyTaskFp]调用失败,异常信息:" + e, e);
+            throw new ServiceException("CaseTaskService.pageMyTaskFp", e);
+        }
+
+    }
+
+    /**
+     * 首页-查询待办任务-受签收
+     * @param page 分页对象
+     * @param terms 条件
+     * @return Page
+     */
+    public Page<FrontPageListDTO> pageMyTaskQs(PageRequest page, Map<String, Object> terms){
+        try {
+            long total = mapper.countMyTaskQs(terms);
+            List<FrontPageListDTO> frontPageListDTOList = mapper.pageMyTaskQs(page, terms);
+            return new PageImpl<FrontPageListDTO>(frontPageListDTOList, page, total);
+        }catch (Exception e) {
+            log.error("[CaseTaskService.pageMyTaskQs]调用失败,异常信息:" + e, e);
+            throw new ServiceException("CaseTaskService.pageMyTaskQs", e);
+        }
+    }
+
+    /**
+     * 首页-查询待办任务-受待理
+     * @param page 分页对象
+     * @param terms 条件
+     * @return Page
+     */
+    public Page<FrontPageListDTO> pageMyTaskSl(PageRequest page, Map<String, Object> terms){
+        try {
+            long total = mapper.countMyTaskSl(terms);
+            List<FrontPageListDTO> frontPageListDTOList = mapper.pageMyTaskSl(page, terms);
+            return new PageImpl<FrontPageListDTO>(frontPageListDTOList, page, total);
+        }catch (Exception e) {
+            log.error("[CaseTaskService.pageMyTaskQs]调用失败,异常信息:" + e, e);
+            throw new ServiceException("CaseTaskService.pageMyTaskQs", e);
+        }
+    }
+
+    /**
+     * 首页-查询待办任务-办理中
+     * @param page 分页对象
+     * @param terms 条件
+     * @return Page
+     */
+    public Page<FrontPageListDTO> pageMyTaskBlz(PageRequest page, Map<String, Object> terms){
+        try {
+            long total = mapper.countMyTaskProcessing(terms);
+            List<FrontPageListDTO> frontPageListDTOList = mapper.pageMyTaskProcessing(page, terms);
+            List<String> caseIdList = new ArrayList<>();
+            Date now = DateUtils.getNowDate();
+            for(FrontPageListDTO frontPageListDTO: frontPageListDTOList){
+                long milliseconds1 = frontPageListDTO.getTurnaroundTime().getTime();
+                long milliseconds2 = now.getTime();
+                long diff = milliseconds2 - milliseconds1;
+                long daysBetween = diff / (24 * 60 * 60 * 1000);
+                frontPageListDTO.setProcessingDays(daysBetween);
+                caseIdList.add(frontPageListDTO.getCaseId());
+            }
+            if(CollectionUtils.isNotEmpty(caseIdList)){
+                QueryWrapper<CaseAssistApply> assistApplyQueryWrapper = new QueryWrapper<>();
+                assistApplyQueryWrapper.in("case_id", caseIdList).eq("apply_status", AuditBaseConsts.AUDIT_STATUS_1)
+                        .eq("audit_result", AuditBaseConstsEnum.AUDIT_RESULT_1.getIndex());
+                List<CaseAssistApply> caseAssistApplyList = assistApplyService.list(assistApplyQueryWrapper);
+                for(CaseAssistApply caseAssistApply: caseAssistApplyList){
+                    for(FrontPageListDTO frontPageListDTO: frontPageListDTOList){
+                        if(frontPageListDTO.getCaseId().equals(caseAssistApply.getCaseId())){
+                            frontPageListDTO.setCooperatingUnit(caseAssistApply.getApplyAssistUnitName());
+                        }
+                    }
+                }
+            }
+
+            return new PageImpl<FrontPageListDTO>(frontPageListDTOList, page, total);
+        }catch (Exception e) {
+            log.error("[CaseTaskService.pageMyTaskQs]调用失败,异常信息:" + e, e);
+            throw new ServiceException("CaseTaskService.pageMyTaskQs", e);
+        }
+    }
+
+    /**
+     * 首页-查询待办任务-办理任务
+     * @param page 分页对象
+     * @param terms 条件
+     * @return Page
+     */
+    public Page<FrontPageListDTO> pageMyTaskBl(PageRequest page, Map<String, Object> terms){
+        try {
+            long total = caseWindupApplyMapper.countMySubmitApplyReview(terms);
+            List<FrontPageListDTO> frontPageListDTOList = caseWindupApplyMapper.pageMySubmitApplyReview(page, terms);
+
+            List<String> caseIdList = new ArrayList<>();
+            caseIdList = frontPageListDTOList.stream().map(FrontPageListDTO ::getCaseId).collect(Collectors.toList());
+            if(CollectionUtils.isNotEmpty(caseIdList)){
+                QueryWrapper<CaseAssistApply> assistApplyQueryWrapper = new QueryWrapper<>();
+                assistApplyQueryWrapper.in("case_id", caseIdList).eq("apply_status", AuditBaseConsts.AUDIT_STATUS_1)
+                        .eq("audit_result", AuditBaseConstsEnum.AUDIT_RESULT_1.getIndex());
+                List<CaseAssistApply> caseAssistApplyList = assistApplyService.list(assistApplyQueryWrapper);
+                for(CaseAssistApply caseAssistApply: caseAssistApplyList){
+                    for(FrontPageListDTO frontPageListDTO: frontPageListDTOList){
+                        if(frontPageListDTO.getCaseId().equals(caseAssistApply.getCaseId())){
+                            frontPageListDTO.setCooperatingUnit(caseAssistApply.getApplyAssistUnitName());
+                        }
+                    }
+                }
+            }
+            return new PageImpl<FrontPageListDTO>(frontPageListDTOList, page, total);
+        }catch (Exception e) {
+            log.error("[CaseTaskService.pageMyTaskQs]调用失败,异常信息:" + e, e);
+            throw new ServiceException("CaseTaskService.pageMyTaskQs", e);
+        }
+    }
+
+    /**
+     * 首页-待审核分页查询
+     * @param page 分页对象
+     * @param terms 条件
+     * @return Page
+     */
+    public Page<FrontPageListDTO> pageMyTaskSh(PageRequest page, int type, Map<String, Object> terms){
+        try {
+            long total = 0;
+            List<FrontPageListDTO> frontPageListDTOList = new ArrayList<>();
+            if(1 == type){
+                total = caseReturnMapper.countMyTaskReturnReview(terms);
+                frontPageListDTOList = caseReturnMapper.pageMyTaskReturnReview(page,terms);
+            }else if(2 == type){
+                total = caseAppearMapper.countMyTaskAppearReview(terms);
+                frontPageListDTOList = caseAppearMapper.pageMyTaskAppearReview(page, terms);
+            }else if(3 == type){
+                total = caseWindupApplyMapper.countMyTaskApplyReview(terms);
+                frontPageListDTOList = caseWindupApplyMapper.pageMyTaskApplyReview(page, terms);
+            }else if(4 == type){
+                total = caseAssistApplyMapper.countMyTaskAssistReview(terms);
+                frontPageListDTOList = caseAssistApplyMapper.pageMyTaskAssistReview(page, terms);
+            }
+            return new PageImpl<FrontPageListDTO>(frontPageListDTOList, page, total);
+        }catch (Exception e) {
+            log.error("[CaseTaskService.pageMyTaskQs]调用失败,异常信息:" + e, e);
+            throw new ServiceException("CaseTaskService.pageMyTaskQs", e);
+        }
+    }
+    /**
      * wechat端-查询流程进度
      * @param caseId 纠纷编号
      * @return

--
Gitblit v1.8.0