From 69fdc83bc60955eb528734b91a193452622abc8a Mon Sep 17 00:00:00 2001 From: zhouxiantao <1026371446@qq.com> Date: Tue, 10 Sep 2024 16:55:23 +0800 Subject: [PATCH] 小程序,AI助手加入缓存机制 --- dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/service/CaseTaskService.java | 218 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 207 insertions(+), 11 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 63e49c9..4937f75 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; @@ -25,12 +36,14 @@ import cn.huge.module.flow.service.FlowInfoService; import cn.huge.module.mediate.constant.*; import cn.huge.module.sys.constant.SyTimeEnum; +import com.alibaba.fastjson.JSON; 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.data.domain.Sort; import org.springframework.stereotype.Service; import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Page; @@ -38,6 +51,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 +90,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; /** * 更新对象 @@ -240,7 +270,7 @@ // 根据流程显示button List<TabButtonInfoDTO> buttonList = new LinkedList<>(); if (ObjectUtils.isNotEmpty(caseTask)) { - if (FlowNodeEnum.FLOW_NODE_SJ_DFP.getIndex().equals(caseTask.getNodeId())) { + if (FlowNodeEnum.FLOW_NODE_ZJ_DFP.getIndex().equals(caseTask.getNodeId())) { tabList.add(dslxq); tabList.add(sqjl); @@ -429,21 +459,186 @@ } /** - * 按条件统计 + * 获取首页统计数量 * @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 纠纷编号 @@ -481,6 +676,7 @@ BeanUtils.copyProperties(caseInfo, dispCaseBaseDTO); dispCaseBaseDTO.setCaseId(caseInfo.getId()); CaseDispBaseDTO caseDispBaseDTO = dispClient.sysDisp(dispCaseBaseDTO); + log.info(JSON.toJSONString(caseDispBaseDTO)); // 目前平台只能调度给组织 if (DispBaseConstsEnum.TARGET_TYPE_1.getIndex().equals(caseDispBaseDTO.getTargetType())) { // 目前平台只做镇街、村居级别的调度, -- Gitblit v1.8.0