From 07878f4bacfa9f6b6a57981379c2da4aa1fbd2fd Mon Sep 17 00:00:00 2001 From: haown <454902499@qq.com> Date: Thu, 21 Nov 2024 09:16:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=93=E7=97=85=E8=B7=AF=E5=BE=84=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=AE=8C=E6=88=90=E5=90=8E=E4=BF=AE=E6=94=B9=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E8=A1=A8=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SignPatientManageRouteNodeDto.java | 6 + .../SignPatientManageRouteServiceImpl.java | 14 -- .../ISignPatientManageRouteNodeService.java | 3 + ...SignPatientManageRouteNodeServiceImpl.java | 205 ++++++++++++++++++ .../impl/SpecialDiseaseNodeServiceImpl.java | 139 +++++++----- .../SignPatientManageRouteNodeMapper.xml | 6 + 6 files changed, 308 insertions(+), 65 deletions(-) diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/dto/signpatientmanageroutenode/SignPatientManageRouteNodeDto.java b/postdischarge-manage/src/main/java/com/xinelu/manage/dto/signpatientmanageroutenode/SignPatientManageRouteNodeDto.java index d30298bc..38c04299 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/dto/signpatientmanageroutenode/SignPatientManageRouteNodeDto.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/dto/signpatientmanageroutenode/SignPatientManageRouteNodeDto.java @@ -68,4 +68,10 @@ public class SignPatientManageRouteNodeDto { */ @ApiModelProperty(value = "AI:自动 或 COMMON:手动") private String phoneDialMethod; + + /** + * 专病路径节点id列表 + */ + @ApiModelProperty(value = "专病路径节点id列表") + private List routeNodeIds; } 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 7ab42ddb..e6da4b41 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 @@ -1111,18 +1111,4 @@ public class SignPatientManageRouteServiceImpl implements ISignPatientManageRout } } - /** - * @description 专病路径修改时修改任务,已经执行的任务不修改,未执行的任务进行删除或修改 - * @Param routeId 专病路径主键 - * @return null - * @Author haown - * @Date 2024-11-15 10:52 - */ - private void updateBySpecialDiseaseRoute(Long routeId) { - // 查询签约专病路径的sign_patientmanage_route - SignPatientManageRoute manageRouteQuery = new SignPatientManageRoute(); - manageRouteQuery.setRouteId(routeId); - List manageRouteList = signPatientManageRouteMapper.selectSignPatientManageRouteList(manageRouteQuery); - // 查询未执行任务 - } } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroutenode/ISignPatientManageRouteNodeService.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroutenode/ISignPatientManageRouteNodeService.java index 642aedf7..cf1554f5 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroutenode/ISignPatientManageRouteNodeService.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroutenode/ISignPatientManageRouteNodeService.java @@ -17,6 +17,7 @@ import com.xinelu.manage.vo.signpatientmanageroutenode.SignPatientManageNodeAudi import com.xinelu.manage.vo.signpatientmanageroutenode.SignPatientManageRouteNodeVo; import com.xinelu.manage.vo.signpatientmanageroutenode.SignPatientTaskVo; import com.xinelu.manage.vo.specialdiseasenode.PatientSpecialDiseaseNodeVo; +import com.xinelu.manage.vo.specialdiseasenode.SpecialDiseaseNodeVO; import java.time.LocalDateTime; import java.time.LocalTime; import java.util.List; @@ -220,4 +221,6 @@ public interface ISignPatientManageRouteNodeService { * 测试生成患者档案列表数据用 */ void generateStatistic(); + + void updateBySpecialDiseaseRoute(List delDiseaseNodeIds, List updateList, List addDiseaseNodeList); } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroutenode/impl/SignPatientManageRouteNodeServiceImpl.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroutenode/impl/SignPatientManageRouteNodeServiceImpl.java index 19d533f4..d89c64f1 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroutenode/impl/SignPatientManageRouteNodeServiceImpl.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroutenode/impl/SignPatientManageRouteNodeServiceImpl.java @@ -5,6 +5,7 @@ import com.alibaba.fastjson2.JSONObject; import com.xinelu.common.annotation.DataScope; import com.xinelu.common.constant.ApplyRangeContant; import com.xinelu.common.constant.RouteNodeNameConstants; +import com.xinelu.common.constant.SignRecordServiceStatusConstants; import com.xinelu.common.constant.TaskCreateTypeConstant; import com.xinelu.common.constant.TaskNodeTypeConstants; import com.xinelu.common.constant.TaskStatusConstant; @@ -1189,6 +1190,209 @@ public class SignPatientManageRouteNodeServiceImpl implements ISignPatientManage }); } + /** + * @description 专病路径修改时修改任务,已经执行的任务不修改,未执行的任务进行删除或修改 + * @Param routeId 专病路径主键 + * @return null + * @Author haown + * @Date 2024-11-15 10:52 + */ + @Override + public void updateBySpecialDiseaseRoute(List delDiseaseNodeIds, List updateList, List addDiseaseNodeList) { + // 删除的路径节点,未执行的任务删除 + if (CollectionUtils.isNotEmpty(delDiseaseNodeIds)) { + SignPatientManageRouteNodeDto signPatientManageRouteNodeDto = new SignPatientManageRouteNodeDto(); + signPatientManageRouteNodeDto.setRouteNodeIds(delDiseaseNodeIds); + signPatientManageRouteNodeDto.setNodeExecuteStatus(NodeExecuteStatusEnum.UNEXECUTED.getInfo()); + List delNodeList = signPatientManageRouteNodeMapper.selectSignPatientManageRouteNodeList(signPatientManageRouteNodeDto); + // 删除任务 + if (CollectionUtils.isNotEmpty(delNodeList)) { + signPatientManageRouteNodeMapper.deleteSignPatientManageRouteNodeByIds(delNodeList.stream().map(SignPatientManageRouteNode::getId).collect(Collectors.toList()).toArray(new Long[0])); + } + } + // 修改的路径节点,对未执行的任务进行修改 + if (CollectionUtils.isNotEmpty(updateList)) { + updateList.forEach(diseaseNode -> { + SignPatientManageRouteNodeDto signPatientManageRouteNodeDto = new SignPatientManageRouteNodeDto(); + signPatientManageRouteNodeDto.setRouteNodeId(diseaseNode.getId()); + signPatientManageRouteNodeDto.setNodeExecuteStatus(NodeExecuteStatusEnum.UNEXECUTED.getInfo()); + List updNodeList = signPatientManageRouteNodeMapper.selectSignPatientManageRouteNodeList(signPatientManageRouteNodeDto); + + if (CollectionUtils.isNotEmpty(updNodeList)) { + updNodeList.forEach(manageRouteNode -> { + SignPatientManageRoute signPatientManageRoute = signRouteMapper.selectSignPatientManageRouteById(manageRouteNode.getManageRouteId()); + // 查询患者画像信息 + List labelFieldContentList = labelFieldContentMapper.selectByPatientId(signPatientManageRoute.getPatientId()); + if (CollectionUtils.isEmpty(labelFieldContentList)) { + throw new ServiceException("请先维护画像信息"); + } + Long id = manageRouteNode.getId(); + BeanUtils.copyBeanProp(manageRouteNode, diseaseNode); + manageRouteNode.setManageRouteId(signPatientManageRoute.getId()); + manageRouteNode.setManageRouteName(signPatientManageRoute.getRouteName()); + manageRouteNode.setId(null); + manageRouteNode.setRouteNodeId(diseaseNode.getId()); + manageRouteNode.setDelFlag(0); + + // 根据模板类型,存放模板字段 + if(StringUtils.isNotBlank(diseaseNode.getTaskNodeType())) { + switch(diseaseNode.getTaskNodeType()) { + // 宣教 + case TaskNodeTypeConstants.PROPAGANDA_ARTICLE: + manageRouteNode.setPropagandaInfoId(diseaseNode.getTemplateId()); + manageRouteNode.setPropagandaTitle(diseaseNode.getTemplateName()); + break; + // 问卷 + case TaskNodeTypeConstants.QUESTIONNAIRE_SCALE: + QuestionInfo questionInfo = questionInfoService.selectQuestionInfoById(diseaseNode.getTemplateId()); + manageRouteNode.setQuestionInfoId(diseaseNode.getTemplateId()); + manageRouteNode.setQuestionnaireName(diseaseNode.getTemplateName()); + if (ObjectUtils.isNotEmpty(questionInfo)) { + manageRouteNode.setScriptInfoId(questionInfo.getScriptInfoId()); + manageRouteNode.setRobotPublishId(questionInfo.getRobotPublishId()); + // 节点是否是AI电话 + if (StringUtils.equals(PhoneDialMethodEnum.AI.getInfo(), manageRouteNode.getPhoneDialMethod()) && StringUtils.isBlank(questionInfo.getRobotPublishId())) { + throw new ServiceException("第三方机器人id为空"); + } + } + break; + // 话术 + case TaskNodeTypeConstants.PHONE_OUTBOUND: + manageRouteNode.setScriptInfoId(diseaseNode.getScriptInfoId()); + // 查询话术 + ScriptInfo scriptInfo = scriptInfoMapper.selectScriptInfoById(diseaseNode.getScriptInfoId()); + if (ObjectUtils.isNotEmpty(scriptInfo)) { + // 话术库json内容替换 + manageRouteNode.setPhoneNodeContent(getFlowScheme(scriptInfo.getFlowScheme(), labelFieldContentList)); + manageRouteNode.setRobotPublishId(scriptInfo.getRobotPublishId()); + // 节点是否是AI电话 + if (StringUtils.equals(PhoneDialMethodEnum.AI.getInfo(), manageRouteNode.getPhoneDialMethod()) && StringUtils.isBlank(scriptInfo.getRobotPublishId())) { + throw new ServiceException("第三方机器人id为空"); + } + } + break; + } + } + // 替换短信、公众号、小程序内容 + replaceTemplateInfo(manageRouteNode, diseaseNode, labelFieldContentList); + // 替换nodeContent + List manageNodeList = new ArrayList<>(); + if (StringUtils.contains(diseaseNode.getNodeContent(), "data-w-e-type")) { + SignPatientManageNodeAuditVo signPatientManageNodeAuditVo = new SignPatientManageNodeAuditVo(); + BeanUtils.copyBeanProp(signPatientManageNodeAuditVo, manageRouteNode); + List manageNodeAuditVoList = replaceNodeContent(signPatientManageNodeAuditVo, diseaseNode.getTaskPartitionDictId(), labelFieldContentList); + manageNodeAuditVoList.forEach(manageNodeAuditVo -> { + SignPatientManageRouteNode signNode = new SignPatientManageRouteNode(); + BeanUtils.copyBeanProp(signNode, manageNodeAuditVo); + signPatientManageRouteNodeMapper.updateSignPatientManageRouteNode(signNode); + }); + + } else { + signPatientManageRouteNodeMapper.updateSignPatientManageRouteNode(manageRouteNode); + } + }); + } + }); + + } + // 新增的路径节点,新增未执行任务 + if (CollectionUtils.isNotEmpty(addDiseaseNodeList)) { + // + List nodeSaveList = new ArrayList(); + addDiseaseNodeList.forEach(diseaseNode -> { + // 查询签约专病路径的sign_patient_manage_route + SignPatientManageRoute signPatientManageRoute = new SignPatientManageRoute(); + signPatientManageRoute.setRouteId(diseaseNode.getRouteId()); + List manageRouteList = signRouteMapper.selectSignPatientManageRouteList(signPatientManageRoute); + // 查询已审核通过的签约记录 + manageRouteList.forEach(manageRoute -> { + SignPatientRecord signPatientRecord = signPatientRecordMapper.selectByPrimaryKey(manageRoute.getSignPatientRecordId()); + // 审核通过并且在服务期限内的签约记录 + if (StringUtils.equals(SignRecordServiceStatusConstants.SERVICE_CENTER, signPatientRecord.getServiceStatus()) && StringUtils.equals(RouteCheckStatusEnum.AGREE.getInfo(), signPatientRecord.getPortaitCheckStatus()) && StringUtils.equals(RouteCheckStatusEnum.AGREE.getInfo(), signPatientRecord.getRouteCheckStatus())) { + // 查询患者画像信息 + List labelFieldContentList = labelFieldContentMapper.selectByPatientId(signPatientManageRoute.getPatientId()); + if (CollectionUtils.isEmpty(labelFieldContentList)) { + throw new ServiceException("请先维护画像信息"); + } + // 生成任务 + SignPatientManageRouteNode manageRouteNode = new SignPatientManageRouteNode(); + BeanUtils.copyBeanProp(manageRouteNode, diseaseNode); + manageRouteNode.setManageRouteId(signPatientManageRoute.getId()); + manageRouteNode.setManageRouteName(signPatientManageRoute.getRouteName()); + manageRouteNode.setId(null); + manageRouteNode.setRouteNodeId(diseaseNode.getId()); + manageRouteNode.setExecuteTime(diseaseNode.getExecutionTime()); + manageRouteNode.setDelFlag(0); + manageRouteNode.setRouteCheckStatus(RouteCheckStatusEnum.AGREE.getInfo()); + manageRouteNode.setNodeExecuteStatus(NodeExecuteStatusEnum.UNEXECUTED.getInfo()); + + // 根据模板类型,存放模板字段 + if(StringUtils.isNotBlank(diseaseNode.getTaskNodeType())) { + switch(diseaseNode.getTaskNodeType()) { + // 宣教 + case TaskNodeTypeConstants.PROPAGANDA_ARTICLE: + manageRouteNode.setPropagandaInfoId(diseaseNode.getTemplateId()); + manageRouteNode.setPropagandaTitle(diseaseNode.getTemplateName()); + break; + // 问卷 + case TaskNodeTypeConstants.QUESTIONNAIRE_SCALE: + QuestionInfo questionInfo = questionInfoService.selectQuestionInfoById(diseaseNode.getTemplateId()); + manageRouteNode.setQuestionInfoId(diseaseNode.getTemplateId()); + manageRouteNode.setQuestionnaireName(diseaseNode.getTemplateName()); + if (ObjectUtils.isNotEmpty(questionInfo)) { + manageRouteNode.setScriptInfoId(questionInfo.getScriptInfoId()); + manageRouteNode.setRobotPublishId(questionInfo.getRobotPublishId()); + // 节点是否是AI电话 + if (StringUtils.equals(PhoneDialMethodEnum.AI.getInfo(), manageRouteNode.getPhoneDialMethod()) && StringUtils.isBlank(questionInfo.getRobotPublishId())) { + throw new ServiceException("第三方机器人id为空"); + } + } + break; + // 话术 + case TaskNodeTypeConstants.PHONE_OUTBOUND: + manageRouteNode.setScriptInfoId(diseaseNode.getScriptInfoId()); + // 查询话术 + ScriptInfo scriptInfo = scriptInfoMapper.selectScriptInfoById(diseaseNode.getScriptInfoId()); + if (ObjectUtils.isNotEmpty(scriptInfo)) { + // 话术库json内容替换 + manageRouteNode.setPhoneNodeContent(getFlowScheme(scriptInfo.getFlowScheme(), labelFieldContentList)); + manageRouteNode.setRobotPublishId(scriptInfo.getRobotPublishId()); + // 节点是否是AI电话 + if (StringUtils.equals(PhoneDialMethodEnum.AI.getInfo(), manageRouteNode.getPhoneDialMethod()) && StringUtils.isBlank(scriptInfo.getRobotPublishId())) { + throw new ServiceException("第三方机器人id为空"); + } + } + break; + } + } + // 替换短信、公众号、小程序内容 + replaceTemplateInfo(manageRouteNode, diseaseNode, labelFieldContentList); + // 替换nodeContent + List manageNodeList = new ArrayList<>(); + if (StringUtils.contains(diseaseNode.getNodeContent(), "data-w-e-type")) { + SignPatientManageNodeAuditVo signPatientManageNodeAuditVo = new SignPatientManageNodeAuditVo(); + BeanUtils.copyBeanProp(signPatientManageNodeAuditVo, manageRouteNode); + List manageNodeAuditVoList = replaceNodeContent(signPatientManageNodeAuditVo, diseaseNode.getTaskPartitionDictId(), labelFieldContentList); + manageNodeAuditVoList.forEach(manageNodeAuditVo -> { + SignPatientManageRouteNode signNode = new SignPatientManageRouteNode(); + BeanUtils.copyBeanProp(signNode, manageNodeAuditVo); + manageNodeList.add(signNode); + }); + + } else { + manageNodeList.add(manageRouteNode); + } + nodeSaveList.addAll(manageNodeList); + } + }); + }); + // 保存 + if(CollectionUtils.isNotEmpty(nodeSaveList)) { + signPatientManageRouteNodeMapper.insertBatch(nodeSaveList); + } + } + } + /** * 根据管理路径生成任务 * @param signPatientManageRoute 签约管理路径 @@ -1408,4 +1612,5 @@ public class SignPatientManageRouteNodeServiceImpl implements ISignPatientManage } return retBoolean; } + } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/specialdiseasenode/impl/SpecialDiseaseNodeServiceImpl.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/specialdiseasenode/impl/SpecialDiseaseNodeServiceImpl.java index f3c4303d..dc733027 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/specialdiseasenode/impl/SpecialDiseaseNodeServiceImpl.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/specialdiseasenode/impl/SpecialDiseaseNodeServiceImpl.java @@ -3,7 +3,6 @@ package com.xinelu.manage.service.specialdiseasenode.impl; import com.alibaba.fastjson2.JSONObject; import com.xinelu.common.core.domain.AjaxResult; import com.xinelu.common.enums.PatientSexEnum; -import com.xinelu.common.enums.ReleaseStatusEnum; import com.xinelu.common.exception.ServiceException; import com.xinelu.common.utils.BaseUtil; import com.xinelu.common.utils.SecurityUtils; @@ -17,6 +16,7 @@ import com.xinelu.manage.mapper.patientnodeparamslcurrent.PatientNodeParamsCurre import com.xinelu.manage.mapper.specialdiseasenode.SpecialDiseaseNodeMapper; import com.xinelu.manage.mapper.specialdiseaseroute.SpecialDiseaseRouteMapper; import com.xinelu.manage.service.patientinfo.IPatientAllInfoViewService; +import com.xinelu.manage.service.signpatientmanageroutenode.ISignPatientManageRouteNodeService; import com.xinelu.manage.service.specialdiseasenode.ISpecialDiseaseNodeService; import com.xinelu.manage.vo.specialdiseasenode.RouteTaskAuditVo; import com.xinelu.manage.vo.specialdiseasenode.SpecialDiseaseNodeVO; @@ -60,6 +60,8 @@ public class SpecialDiseaseNodeServiceImpl implements ISpecialDiseaseNodeService private PatientInfoMapper patientInfoMapper; @Resource private IPatientAllInfoViewService patientAllInfoViewService; + @Resource + private ISignPatientManageRouteNodeService signPatientManageRouteNodeService; /** @@ -123,21 +125,21 @@ public class SpecialDiseaseNodeServiceImpl implements ISpecialDiseaseNodeService @Override public AjaxResult updateSpecialDiseaseNode(SpecialDiseaseRouteVO specialDiseaseNode) { - if (Objects.nonNull(specialDiseaseNode) && Objects.nonNull(specialDiseaseNode.getSpecialDiseaseRouteId())) { - SpecialDiseaseRoute specialDiseaseRoute = specialDiseaseRouteMapper.selectSpecialDiseaseRouteById(specialDiseaseNode.getSpecialDiseaseRouteId()); - if (specialDiseaseRoute.getParentRouteId() == null || specialDiseaseRoute.getParentRouteId() == 0) { - if (Objects.nonNull(specialDiseaseRoute) && StringUtils.isNotBlank(specialDiseaseRoute.getReleaseStatus()) && !ReleaseStatusEnum.UNPUBLISHED.getInfo().equals(specialDiseaseRoute.getReleaseStatus())) { - return AjaxResult.error("已发布过的专病路径不能修改!"); - } - } else { - // 判断主路径的发布状态 - SpecialDiseaseRoute parentRoute = specialDiseaseRouteMapper.selectSpecialDiseaseRouteById(specialDiseaseRoute.getParentRouteId()); - if (Objects.nonNull(parentRoute) && StringUtils.isNotBlank(parentRoute.getReleaseStatus()) && !StringUtils.equals(ReleaseStatusEnum.UNPUBLISHED.getInfo(), specialDiseaseRoute.getReleaseStatus())) { - return AjaxResult.error("已发布过的专病路径不能修改!"); - } - } - } - List longs = specialDiseaseNodeMapper.selectSpecialDiseaseRouteIds(specialDiseaseNode.getSpecialDiseaseRouteId()); + //if (Objects.nonNull(specialDiseaseNode) && Objects.nonNull(specialDiseaseNode.getSpecialDiseaseRouteId())) { + // SpecialDiseaseRoute specialDiseaseRoute = specialDiseaseRouteMapper.selectSpecialDiseaseRouteById(specialDiseaseNode.getSpecialDiseaseRouteId()); + // if (specialDiseaseRoute.getParentRouteId() == null || specialDiseaseRoute.getParentRouteId() == 0) { + // if (Objects.nonNull(specialDiseaseRoute) && StringUtils.isNotBlank(specialDiseaseRoute.getReleaseStatus()) && !ReleaseStatusEnum.UNPUBLISHED.getInfo().equals(specialDiseaseRoute.getReleaseStatus())) { + // return AjaxResult.error("已发布过的专病路径不能修改!"); + // } + // } else { + // // 判断主路径的发布状态 + // SpecialDiseaseRoute parentRoute = specialDiseaseRouteMapper.selectSpecialDiseaseRouteById(specialDiseaseRoute.getParentRouteId()); + // if (Objects.nonNull(parentRoute) && StringUtils.isNotBlank(parentRoute.getReleaseStatus()) && !StringUtils.equals(ReleaseStatusEnum.UNPUBLISHED.getInfo(), specialDiseaseRoute.getReleaseStatus())) { + // return AjaxResult.error("已发布过的专病路径不能修改!"); + // } + // } + //} + List oldIds = specialDiseaseNodeMapper.selectSpecialDiseaseRouteIds(specialDiseaseNode.getSpecialDiseaseRouteId()); SpecialDiseaseRoute specialDiseaseRoute = new SpecialDiseaseRoute(); BeanUtils.copyBeanProp(specialDiseaseRoute, specialDiseaseNode); specialDiseaseRoute.setUpdateTime(LocalDateTime.now()); @@ -148,41 +150,76 @@ public class SpecialDiseaseNodeServiceImpl implements ISpecialDiseaseNodeService log.info("修改专病路径失败"); throw new ServiceException("修改专病路径管理节点信息失败"); } - int deleteCount = specialDiseaseNodeMapper.deleteSpecialDiseaseNodeByRouteId(specialDiseaseRoute.getId()); - if (deleteCount < 0) { - log.info("删除管理节点信息失败"); - throw new ServiceException("修改专病路径管理节点信息失败"); - } - if (CollectionUtils.isEmpty(specialDiseaseNode.getSpecialDiseaseNodeList())) { - return AjaxResult.success(); - } - List specialDiseaseNodeVOS = new ArrayList<>(); - int i = 0; - for (SpecialDiseaseNodeVO diseaseNode : specialDiseaseNode.getSpecialDiseaseNodeList()) { - if (StringUtils.isBlank(diseaseNode.getRouteNodeName())) { - throw new ServiceException("请输入节点名称"); - } - if (diseaseNode.getRouteNodeDay() == null) { - throw new ServiceException("请输入节点时间"); - } - if (StringUtils.isBlank(diseaseNode.getTaskType()) || StringUtils.isBlank(diseaseNode.getTaskSubdivision())) { - throw new ServiceException("任务类型、任务细分不能为空"); - } - diseaseNode.setRouteId(specialDiseaseRoute.getId()); - diseaseNode.setRouteName(specialDiseaseNode.getRouteName()); - diseaseNode.setUpdateTime(LocalDateTime.now()); - diseaseNode.setUpdateBy(SecurityUtils.getUsername()); - if (CollectionUtils.isNotEmpty(longs) && (i < longs.size()) && Objects.nonNull(longs.get(i))) { - diseaseNode.setId(longs.get(i)); - i++; - } - specialDiseaseNodeVOS.add(diseaseNode); - } - int insertNodeCount = specialDiseaseNodeMapper.insertSpecialDiseaseNodeList(specialDiseaseNodeVOS); - if (insertNodeCount < 0) { - log.info("新增管理节点信息失败"); - throw new ServiceException("修改专病路径管理节点信息失败"); - } + + List diseaseNodeList = specialDiseaseNode.getSpecialDiseaseNodeList(); + if (CollectionUtils.isEmpty(diseaseNodeList)) { + return AjaxResult.success(); + } + // 循环节点查找新增、删除、修改的节点 + List insertList = new ArrayList<>(); + List updateList = new ArrayList<>(); + diseaseNodeList.forEach(diseaseNode -> { + if (StringUtils.isBlank(diseaseNode.getRouteNodeName())) { + throw new ServiceException("请输入节点名称"); + } + if (diseaseNode.getRouteNodeDay() == null) { + throw new ServiceException("请输入节点时间"); + } + if (StringUtils.isBlank(diseaseNode.getTaskType()) || StringUtils.isBlank(diseaseNode.getTaskSubdivision())) { + throw new ServiceException("任务类型、任务细分不能为空"); + } + if (diseaseNode.getSpecialDiseaseNodeId() == null) { + // 新增的节点 + insertList.add(diseaseNode); + } else { + // 修改的节点 + updateList.add(diseaseNode); + } + }); + List ids = diseaseNodeList.stream().map(SpecialDiseaseNodeVO::getSpecialDiseaseNodeId).collect(Collectors.toList()); + // ids与oldIds对比,oldIds中包含ids中不包含的为删除的节点,其余为修改的节点 + List deleteList = oldIds.stream().filter(item -> !ids.contains(item)).collect(Collectors.toList()); + // 删除节点 + if (CollectionUtils.isNotEmpty(deleteList)) { + int deleteCount = specialDiseaseNodeMapper.deleteSpecialDiseaseNodeByIds(deleteList.toArray(new Long[0])); + if (deleteCount < 0) { + log.info("删除管理节点信息失败"); + throw new ServiceException("修改专病路径管理节点信息失败"); + } + } + // 新增节点 + if (CollectionUtils.isNotEmpty(insertList)) { + List specialDiseaseNodeVOS = new ArrayList<>(); + insertList.forEach(diseaseNode -> { + diseaseNode.setRouteId(specialDiseaseRoute.getId()); + diseaseNode.setRouteName(specialDiseaseNode.getRouteName()); + diseaseNode.setCreateTime(LocalDateTime.now()); + diseaseNode.setCreateBy(SecurityUtils.getUsername()); + specialDiseaseNodeVOS.add(diseaseNode); + }); + int insertNodeCount = specialDiseaseNodeMapper.insertSpecialDiseaseNodeList(specialDiseaseNodeVOS); + if (insertNodeCount < 0) { + log.info("新增管理节点信息失败"); + throw new ServiceException("修改专病路径管理节点信息失败"); + } + } + // 修改节点 + if (CollectionUtils.isNotEmpty(updateList)) { + updateList.forEach(diseaseNode -> { + diseaseNode.setRouteId(specialDiseaseRoute.getId()); + diseaseNode.setRouteName(specialDiseaseNode.getRouteName()); + diseaseNode.setUpdateTime(LocalDateTime.now()); + diseaseNode.setUpdateBy(SecurityUtils.getUsername()); + diseaseNode.setId(diseaseNode.getSpecialDiseaseNodeId()); + int flag = specialDiseaseNodeMapper.updateSpecialDiseaseNode(diseaseNode); + if (flag < 0) { + log.info("修改管理节点信息失败"); + throw new ServiceException("修改专病路径管理节点信息失败"); + } + }); + } + // 修改任务表 + signPatientManageRouteNodeService.updateBySpecialDiseaseRoute(deleteList, updateList, insertList); return AjaxResult.success(); } 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 cb1db7f7..13ad78cb 100644 --- a/postdischarge-manage/src/main/resources/mapper/manage/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.xml +++ b/postdischarge-manage/src/main/resources/mapper/manage/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.xml @@ -129,6 +129,12 @@ and phone_dial_method = #{phoneDialMethod} + + and + + route_node_id = #{routeNodeId} + +