diff --git a/postdischarge-common/src/main/java/com/xinelu/common/enums/PhoneDialMethodEnum.java b/postdischarge-common/src/main/java/com/xinelu/common/enums/PhoneDialMethodEnum.java index 40396b98..ac1b81a7 100644 --- a/postdischarge-common/src/main/java/com/xinelu/common/enums/PhoneDialMethodEnum.java +++ b/postdischarge-common/src/main/java/com/xinelu/common/enums/PhoneDialMethodEnum.java @@ -11,6 +11,12 @@ import lombok.Getter; @Getter public enum PhoneDialMethodEnum { + + /** + * AI + */ + ALL("ALL"), + /** * AI */ diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/controller/signpatientmanageroute/SignPatientManageRouteController.java b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/signpatientmanageroute/SignPatientManageRouteController.java index 8f8994cf..f27839ff 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/controller/signpatientmanageroute/SignPatientManageRouteController.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/signpatientmanageroute/SignPatientManageRouteController.java @@ -183,4 +183,18 @@ public class SignPatientManageRouteController extends BaseController { public R> getRecordList(@PathVariable("patientId") Long patientId) { return R.ok(signPatientManageRouteService.getRecordList(patientId)); } + + @ApiOperation("任务管理") + @GetMapping("taskManagement") + public TableDataInfo taskManagement(ManualFollowUpDTO manualFollowUpDTO) { + startPage(); + List list = signPatientManageRouteService.taskManagement(manualFollowUpDTO); + return getDataTable(list); + } + + @ApiOperation("批量删除未执行任务") + @PostMapping("batchDeleteTask") + public AjaxResult batchDeleteTask(Long[] ids){ + return signPatientManageRouteService.batchDeleteTask(ids); + } } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/dto/manualfollowup/ManualFollowUpDTO.java b/postdischarge-manage/src/main/java/com/xinelu/manage/dto/manualfollowup/ManualFollowUpDTO.java index 821b9279..1dab5985 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/dto/manualfollowup/ManualFollowUpDTO.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/dto/manualfollowup/ManualFollowUpDTO.java @@ -90,6 +90,6 @@ public class ManualFollowUpDTO extends BaseEntity { @ApiModelProperty(value = "任务执行类型(批量还是单个执行,'批量任务:BATCH_TASK,单个实时拔打任务:ACTUAL_TIME_TASK')") private String taskExcuteType; - - + @ApiModelProperty(value = "任务节点类型,电话外呼:PHONE_OUTBOUND,问卷量表:QUESTIONNAIRE_SCALE,宣教文章:PROPAGANDA_ARTICLE,文字提醒:TEXT_REMIND") + private String taskNodeType; } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/signpatientmanageroute/SignPatientManageRouteMapper.java b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/signpatientmanageroute/SignPatientManageRouteMapper.java index 9c007420..b82dd550 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/signpatientmanageroute/SignPatientManageRouteMapper.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/signpatientmanageroute/SignPatientManageRouteMapper.java @@ -99,4 +99,37 @@ public interface SignPatientManageRouteMapper { * @return */ String selectPatientPhone(Long patientId); + + /** + * 根据节点ids查询路径ids + * + * @param ids 节点ids + * @return SignPatientManageRoute + */ + List selectRouteByNodeIds(List ids); + + /** + * 根据路径ids查询是否存在子路径 + * + * @param ids 路径ids + * @return SignPatientManageRoute + */ + List selectRouteByParentRouteIds(List ids); + + /** + * 删除路径 + * + * @param ids 路径ids + * @return int + */ + int updateSignPatientManageRouteByIds(List ids); + + + /** + * 查询子路径同级子路径 + * + * @param ids 子路径ids + * @return SignPatientManageRoute + */ + List selectParentRouteIds(List ids); } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.java b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.java index c072d010..3ba47d89 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.java @@ -223,4 +223,20 @@ public interface SignPatientManageRouteNodeMapper { * @return UploadRobotPublishRecordVo */ List selectTaskOptionContented(UploadRobotPublishRecordDto uploadRobotPublishRecordDto); + + /** + * 根据节点ids查询同路径的节点ids + * + * @param ids 节点ids + * @return SignPatientManageRouteNode + */ + List selectSameManageRouteNodeIdByNodeIds(Long[] ids); + + /** + * 根据路径ids查询路径的节点ids + * + * @param ids 路径ids + * @return SignPatientManageRouteNode + */ + List selectSameManageRouteNodeIdByRouteIds(List ids); } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroute/ISignPatientManageRouteService.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroute/ISignPatientManageRouteService.java index b24062e9..17342b75 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroute/ISignPatientManageRouteService.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroute/ISignPatientManageRouteService.java @@ -133,4 +133,20 @@ public interface ISignPatientManageRouteService { Boolean sendSms(SmsInfoDTO smsInfoDTO) throws ClientException, ServiceException; void shortMessageSendRecordExtracted(PatientQuestionSubmitResultDTO dto, LocalDateTime time, Boolean b, String createBy); + + /** + * 任务管理 + * @param manualFollowUpDTO 人工随访查询DTO + * @return ManualFollowUpVO 人工随访代办VO + */ + List taskManagement(ManualFollowUpDTO manualFollowUpDTO); + + /** + * + * 批量删除未执行任务 + * + * @param ids 任务id + * @return AjaxResult + */ + AjaxResult batchDeleteTask(Long[] ids); } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroute/impl/SignPatientManageRouteServiceImpl.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroute/impl/SignPatientManageRouteServiceImpl.java index 37bad247..ea6ba7a3 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroute/impl/SignPatientManageRouteServiceImpl.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroute/impl/SignPatientManageRouteServiceImpl.java @@ -32,7 +32,6 @@ import com.xinelu.manage.domain.signpatientmanageroute.SignPatientManageRoute; import com.xinelu.manage.domain.signpatientmanageroutenode.SignPatientManageRouteNode; import com.xinelu.manage.domain.signpatientrecord.SignPatientRecord; import com.xinelu.manage.domain.signroutetriggercondition.SignRouteTriggerCondition; -import com.xinelu.manage.domain.taskpartitiondict.TaskPartitionDict; import com.xinelu.manage.dto.aiob.ActualTimeTaskDto; import com.xinelu.manage.dto.manualfollowup.ManualFollowUpDTO; import com.xinelu.manage.dto.patientinfo.PatientInfoDto; @@ -647,6 +646,195 @@ public class SignPatientManageRouteServiceImpl implements ISignPatientManageRout shortMessageSendRecordMapper.insertShortMessageSendRecord(shortMessageSendRecord); } + /** + * 任务管理 + * + * @param manualFollowUpDTO 人工随访查询DTO + * @return ManualFollowUpVO 人工随访代办VO + */ + @Override + @DataScope(agencyAlias = "pi", deptAlias = "pi") + public List taskManagement(ManualFollowUpDTO manualFollowUpDTO) { + if (manualFollowUpDTO.getNodeExecuteStatus().equals(NodeExecuteStatusEnum.UNEXECUTED.getInfo())) { + manualFollowUpDTO.setPhoneNodeExecuteResultStatus(null); + } + if (StringUtils.isNotBlank(manualFollowUpDTO.getPhoneDialMethod()) && manualFollowUpDTO.getPhoneDialMethod().equals(PhoneDialMethodEnum.ALL.getInfo())) { + manualFollowUpDTO.setPhoneDialMethod(null); + } + //1、查询 + List manualFollowUpVOS = signPatientManageRouteMapper.selectManualFollowUpList(manualFollowUpDTO); + if (CollectionUtils.isEmpty(manualFollowUpVOS) || manualFollowUpVOS.size() == 0) { + return manualFollowUpVOS; + } + //字典名称匹配 + ArrayList strings = new ArrayList<>(); + strings.add("task_node_type"); + strings.add("route_name"); + List sysDictDataList = sysDictDataMapper.selectDictDataByTypeList(strings); + for (ManualFollowUpVO manualFollowUpVO : manualFollowUpVOS) { + SysDictData taskNodeType = sysDictDataList.stream().filter(Objects::nonNull).filter(item -> item.getDictValue().equals(manualFollowUpVO.getTaskNodeType())).findFirst().orElse(new SysDictData()); + if (StringUtils.isNotBlank(taskNodeType.getDictLabel())) { + manualFollowUpVO.setTaskNodeTypeName(taskNodeType.getDictLabel()); + } + SysDictData routeNodeName = sysDictDataList.stream().filter(Objects::nonNull).filter(item -> item.getDictValue().equals(manualFollowUpVO.getRouteNodeName())).findFirst().orElse(new SysDictData()); + if (StringUtils.isNotBlank(routeNodeName.getDictLabel())) { + manualFollowUpVO.setRouteNode(routeNodeName.getDictLabel()); + } + } + //2、1如果是查询已执行的任务,直接返回查询结果a + if (manualFollowUpDTO.getNodeExecuteStatus().equals(NodeExecuteStatusEnum.EXECUTED.getInfo())) { + return manualFollowUpVOS; + } + //2.2如果是查询“所有”、"未执行“任务,则直接返回查询结果 + if (StringUtils.isNotBlank(manualFollowUpDTO.getTimeSign()) && manualFollowUpDTO.getTimeSign().equals("WHOLE")) { + return manualFollowUpVOS; + } + //2.3如果是查询未执行(截止到当前时间)的任务, + ArrayList manualFollowUps = new ArrayList<>(); + for (ManualFollowUpVO manualFollowUpVO : manualFollowUpVOS) { + //3.1判断路径节点,组装数据 + //任务执行时间, + LocalDate localDate = null; + if (Objects.nonNull(manualFollowUpVO.getNodePlanTime()) && StringUtils.isNotBlank(manualFollowUpVO.getNodePlanTime().toString())) { + localDate = manualFollowUpVO.getNodePlanTime().toLocalDate(); + } else { + //3.2根据出院时间 和 第几天 计算 + if (Objects.nonNull(manualFollowUpVO.getDischargeTime())) { + localDate = manualFollowUpVO.getDischargeTime().plusDays(manualFollowUpVO.getRouteNodeDay()).toLocalDate(); + } + //3.3根据就诊时间 和 第几天 计算 + if (Objects.isNull(manualFollowUpVO.getDischargeTime()) && Objects.nonNull(manualFollowUpVO.getVisitTime())) { + localDate = manualFollowUpVO.getVisitTime().plusDays(manualFollowUpVO.getRouteNodeDay()).toLocalDate(); + } + //3.4如果为空,不予处理 + if (Objects.isNull(localDate)) { + continue; + } + } + //3.5如果截止到当前时间,已到期,则放入返回集合 + boolean before = localDate.isBefore(LocalDate.now()) || localDate.isEqual(LocalDate.now()); + if (before) { + //转换成中文…… + manualFollowUpVO.setRouteNodeName(RouteNodeNameEnum.getNameByInfo(manualFollowUpVO.getRouteNodeName()).getName()); + manualFollowUpVO.setPlanTime(localDate); + // 3.6 放入集合 + manualFollowUps.add(manualFollowUpVO); + } + } + + //返回今天之前任务 + return manualFollowUps; + } + + /** + * 批量删除未执行任务 + * + * @param ids 任务id + * @return AjaxResult + */ + @Override + public AjaxResult batchDeleteTask(Long[] ids) { + int deleteNodeCount = signPatientManageRouteNodeMapper.deleteSignPatientManageRouteNodeByIds(ids); + if (deleteNodeCount < 0) { + return AjaxResult.error("删除失败,请联系管理员!"); + } + List signPatientManageRouteNodes = signPatientManageRouteNodeMapper.selectSameManageRouteNodeIdByNodeIds(ids); + //无同级节点id + List noSameLevelNodeIds = new ArrayList<>(); + //有同级节点,且同级节点状态不为0,不删除上级路径 + for (Long aLong : ids) { + List collect = signPatientManageRouteNodes.stream().filter(Objects::nonNull).filter(item -> item.getId().equals(aLong)).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(collect) || collect.size() == 0) { + noSameLevelNodeIds.add(aLong); + } + } + //无同级节点,查询上级路径 signPatientManageRoutes 上级路径ids + List signPatientManageRoutes = signPatientManageRouteMapper.selectRouteByNodeIds(noSameLevelNodeIds); + if (CollectionUtils.isEmpty(signPatientManageRoutes) || signPatientManageRoutes.size() == 0) { + return AjaxResult.success(); + } + //上级为主路径ids + List manageRouteIds = new ArrayList<>(); + //上级为子路径ids + List patientManageRouteIds = new ArrayList<>(); + //List patientManageRouteIds = new ArrayList<>(); + //上级为主路径,查询是否有子路径。上级为子路径继续查询同级信息 + for (SignPatientManageRoute signPatientManageRoute : signPatientManageRoutes) { + if (Objects.nonNull(signPatientManageRoute.getParentRouteId())) { + patientManageRouteIds.add(signPatientManageRoute.getId()); + } else { + manageRouteIds.add(signPatientManageRoute.getId()); + } + } + //上级为主路径,查询是否有子路径 + if (CollectionUtils.isNotEmpty(manageRouteIds)) { + manageRouteIds = manageRouteIds.stream().distinct().collect(Collectors.toList()); + List parentRoutes = signPatientManageRouteMapper.selectRouteByParentRouteIds(manageRouteIds); + if (CollectionUtils.isEmpty(parentRoutes) || parentRoutes.size() == 0) { + int updateRouteCount = signPatientManageRouteMapper.updateSignPatientManageRouteByIds(manageRouteIds); + if (updateRouteCount < 0) { + return AjaxResult.error("删除失败,请联系管理员!"); + } + } + //有子路径不删,无子路径删除 delete无子路径id集合 + List delete = new ArrayList<>(); + for (Long manageRouteId : manageRouteIds) { + List equalsCollect = parentRoutes.stream().filter(Objects::nonNull).filter(item -> item.getParentRouteId().equals(manageRouteId)).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(equalsCollect) || equalsCollect.size() == 0) { + delete.add(manageRouteId); + } + } + if (CollectionUtils.isEmpty(delete) || delete.size() == 0) { + int updateRouteCount = signPatientManageRouteMapper.updateSignPatientManageRouteByIds(delete); + if (updateRouteCount < 0) { + return AjaxResult.error("删除失败,请联系管理员!"); + } + } + } + //上级为子路径查询除自己以外的同级,无同级,查询上级是否有其他节点,有同级,过 + if (CollectionUtils.isNotEmpty(patientManageRouteIds)) { + int updateRouteCount = signPatientManageRouteMapper.updateSignPatientManageRouteByIds(patientManageRouteIds); + if (updateRouteCount < 0) { + return AjaxResult.error("删除失败,请联系管理员!"); + } + List mainRouteIds = new ArrayList<>(); + //查询上级为子路径查询除自己以外的同级 + List patientSignPatientManageRoutes = signPatientManageRouteMapper.selectParentRouteIds(patientManageRouteIds); + if (CollectionUtils.isNotEmpty(patientSignPatientManageRoutes) || patientSignPatientManageRoutes.size() != 0) { + for (Long patientManageRouteId : patientManageRouteIds) { + List collect = patientSignPatientManageRoutes.stream().filter(Objects::nonNull).filter(item -> item.getParentRouteId().equals(patientManageRouteId)).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(collect) || collect.size() == 0) { + mainRouteIds.add(patientManageRouteId); + } + } + //无同级,查询上级是否有其他节点 + List mainSignPatientManageRouteNodes = signPatientManageRouteNodeMapper.selectSameManageRouteNodeIdByRouteIds(mainRouteIds); + if (CollectionUtils.isEmpty(mainSignPatientManageRouteNodes) || mainSignPatientManageRouteNodes.size() == 0) { + int updateMainRouteCount = signPatientManageRouteMapper.updateSignPatientManageRouteByIds(mainRouteIds); + if (updateMainRouteCount < 0) { + return AjaxResult.error("删除失败,请联系管理员!"); + } + } + //无其他节点删除 + List delete = new ArrayList<>(); + for (Long mainRouteId : mainRouteIds) { + List collect = mainSignPatientManageRouteNodes.stream().filter(Objects::nonNull).filter(item -> item.getManageRouteId().equals(mainRouteId)).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(collect) || collect.size() == 0) { + delete.add(mainRouteId); + } + } + if (CollectionUtils.isEmpty(delete) || delete.size() == 0) { + int count = signPatientManageRouteMapper.updateSignPatientManageRouteByIds(delete); + if (count < 0) { + return AjaxResult.error("删除失败,请联系管理员!"); + } + } + } + } + return AjaxResult.success(); + } + + /** * 电话记录 * @@ -1145,7 +1333,8 @@ public class SignPatientManageRouteServiceImpl implements ISignPatientManageRout signPatientManageRouteNode.setPhoneMessageRemind(StringUtils.isBlank(routeNode.getPhoneMessageRemind()) ? null : routeNode.getPhoneMessageRemind()); signPatientManageRouteNode.setPhoneMessageTemplateId(Objects.isNull(routeNode.getPhoneMessageTemplateId()) ? null : routeNode.getPhoneMessageTemplateId()); signPatientManageRouteNode.setPhoneMessageTemplateName(StringUtils.isBlank(routeNode.getPhoneMessageTemplateName()) ? null : routeNode.getPhoneMessageTemplateName()); - signPatientManageRouteNode.setPhoneDialMethod(StringUtils.isBlank(routeNode.getPhoneDialMethod()) ? null : routeNode.getPhoneDialMethod()); signPatientManageRouteNode.setPhonePushSign(Objects.isNull(routeNode.getPhonePushSign()) ? null : routeNode.getPhonePushSign()); + signPatientManageRouteNode.setPhoneDialMethod(StringUtils.isBlank(routeNode.getPhoneDialMethod()) ? null : routeNode.getPhoneDialMethod()); + signPatientManageRouteNode.setPhonePushSign(Objects.isNull(routeNode.getPhonePushSign()) ? null : routeNode.getPhonePushSign()); } //根据问卷ID,获取问卷信息 zyk 20241216 QuestionInfo questionInfo = questionInfoService.selectQuestionInfoById(signPatientManageRouteNode.getQuestionInfoId()); diff --git a/postdischarge-manage/src/main/resources/mapper/manage/signpatientmanageroute/SignPatientManageRouteMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/signpatientmanageroute/SignPatientManageRouteMapper.xml index 150db275..334e27f0 100644 --- a/postdischarge-manage/src/main/resources/mapper/manage/signpatientmanageroute/SignPatientManageRouteMapper.xml +++ b/postdischarge-manage/src/main/resources/mapper/manage/signpatientmanageroute/SignPatientManageRouteMapper.xml @@ -364,9 +364,12 @@ LEFT JOIN patient_visit_record pvr ON pi.patient_visit_record_id = pvr.id pi.del_flag = 0 + and spmrn.del_flag = 0 and spmrn.phone_push_sign = 1 AND spmrn.route_check_status = 'AGREE' - AND spmrn.task_node_type in ('PHONE_OUTBOUND','QUESTIONNAIRE_SCALE') + + AND spmrn.task_node_type = #{taskNodeType} + AND pi.patient_name LIKE concat('%', #{patientName}, '%') @@ -415,7 +418,10 @@ AND (spmrn.phone_node_execute_result_status is null or spmrn.phone_node_execute_result_status = ' ') - + + AND (spmrn.phone_dial_method = 'AI' OR spmrn.phone_dial_method = 'COMMON') + + AND spmrn.phone_dial_method = #{phoneDialMethod} -- 如果是单个执行类型,应考虑默认为空时,按单个任务处理 @@ -691,4 +697,38 @@ from patient_info where id = #{id} + + + + + + + update sign_patient_manage_route set route_sort = 10000000 where id in + + #{id} + + + + diff --git a/postdischarge-manage/src/main/resources/mapper/manage/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.xml index 3f654f00..98d3f56c 100644 --- a/postdischarge-manage/src/main/resources/mapper/manage/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.xml +++ b/postdischarge-manage/src/main/resources/mapper/manage/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.xml @@ -1369,4 +1369,25 @@ AND pqor.option_choose_sign = #{optionChooseSign} ORDER BY spmrn.create_time DESC + + + +