From 569e60a0ebd5f49f756cd74b72f42341aebf4441 Mon Sep 17 00:00:00 2001 From: haown <454902499@qq.com> Date: Wed, 3 Jul 2024 14:29:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E5=AD=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...SignPatientManageRouteNodeServiceImpl.java | 54 +++++++++++++------ 1 file changed, 39 insertions(+), 15 deletions(-) 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 6a9384ca..b52647a8 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 @@ -58,9 +58,11 @@ import com.xinelu.manage.vo.signpatientmanageroutenode.AppletRouteNodeListVo; import com.xinelu.manage.vo.signpatientmanageroutenode.PatientManageNodeInfoVo; import com.xinelu.manage.vo.signpatientmanageroutenode.PatientManageNodeListVo; import com.xinelu.manage.vo.signpatientmanageroutenode.PatientTaskVo; +import com.xinelu.manage.vo.signpatientmanageroutenode.SignPatientManageNodeAuditVo; import com.xinelu.manage.vo.signpatientmanageroutenode.SignPatientManageRouteNodeInfoVo; import com.xinelu.manage.vo.signpatientmanageroutenode.SignPatientManageRouteNodeVo; import com.xinelu.manage.vo.specialdiseasenode.PatientSpecialDiseaseNodeVo; +import com.xinelu.manage.vo.specialdiseasenode.SpecialDiseaseNodeVO; import com.xinelu.manage.vo.specialdiseaseroute.SpecialDiseaseRouteVO; import java.lang.reflect.Field; import java.math.BigDecimal; @@ -770,7 +772,7 @@ public class SignPatientManageRouteNodeServiceImpl implements ISignPatientManage // 查询路径节点 SpecialDiseaseNode specialDiseaseNodeQuery = new SpecialDiseaseNode(); specialDiseaseNodeQuery.setRouteId(signPatientManageRoute.getRouteId()); - List nodeList = specialDiseaseNodeMapper.selectSpecialDiseaseNodeList(specialDiseaseNodeQuery); + List nodeList = specialDiseaseNodeMapper.selectSpeciaDiseaseNodeVoList(specialDiseaseNodeQuery); // 查询患者画像信息 List labelFieldContentList = labelFieldContentMapper.selectByPatientId(patientId); if (CollectionUtils.isEmpty(labelFieldContentList)) { @@ -824,7 +826,7 @@ public class SignPatientManageRouteNodeServiceImpl implements ISignPatientManage // 替换nodeContent List manageNodeList = new ArrayList<>(); if (StringUtils.contains(node.getNodeContent(), "data-w-e-type")) { - manageNodeList = replaceNodeContent(manageRouteNode, node, labelFieldContentList); + manageNodeList = replaceNodeContent(manageRouteNode, node.getTaskPartitionDictId(), labelFieldContentList); } else { manageNodeList.add(manageRouteNode); } @@ -863,7 +865,7 @@ public class SignPatientManageRouteNodeServiceImpl implements ISignPatientManage //过滤出符合条件的对象,不匹配返回null。 LabelFieldInfoContentVo labelFieldContent = labelFieldContentList.stream().filter(s -> Objects.equals(s.getFieldCode(), matcher.group(1))).findFirst().orElse(null); if (ObjectUtils.isNotEmpty(labelFieldContent)) { - flowScheme = flowScheme.replaceAll("#\\{([^\\}]*)\\}", ObjectUtils.isEmpty(labelFieldContent) ? "" : labelFieldContent.getFieldValue()); + flowScheme = flowScheme.replaceAll("#\\{"+matcher.group(1) +"\\}", ObjectUtils.isEmpty(labelFieldContent) ? "" : labelFieldContent.getFieldValue()); } } } @@ -887,7 +889,7 @@ public class SignPatientManageRouteNodeServiceImpl implements ISignPatientManage // 过滤出符合条件的对象,不匹配返回null。 LabelFieldInfoContentVo labelFieldContent = labelFieldContentList.stream().filter(s -> Objects.equals(s.getFieldCode(), matcher.group(1))).findFirst().orElse(null); if (ObjectUtils.isNotEmpty(labelFieldContent)) { - textMessageContent = textMessageContent.replaceAll("#\\{([^\\}]*)\\}", ObjectUtils.isEmpty(labelFieldContent) ? "" : labelFieldContent.getFieldValue()); + textMessageContent = textMessageContent.replaceAll("#\\{"+matcher.group(1) +"\\}", ObjectUtils.isEmpty(labelFieldContent) ? "" : labelFieldContent.getFieldValue()); } } return textMessageContent; @@ -910,7 +912,7 @@ public class SignPatientManageRouteNodeServiceImpl implements ISignPatientManage } // 替换小程序模板 if (node.getAppletPushSign() != null && node.getAppletPushSign() == 1) { - manageRouteNode.setAppletNodeContent(replaceWeChatTemplate(node.getOfficialTemplateId(), labelFieldContentList)); + manageRouteNode.setAppletNodeContent(replaceWeChatTemplate(node.getAppletTemplateId(), labelFieldContentList)); } } @@ -931,7 +933,7 @@ public class SignPatientManageRouteNodeServiceImpl implements ISignPatientManage // 过滤出符合条件的对象,不匹配返回null。 LabelFieldInfoContentVo labelFieldContent = labelFieldContentList.stream().filter(s -> Objects.equals(s.getFieldCode(), matcher.group(1))).findFirst().orElse(null); if (ObjectUtils.isNotEmpty(labelFieldContent)) { - templateContent = templateContent.replaceAll("#\\{([^\\}]*)\\}", ObjectUtils.isEmpty(labelFieldContent) ? "" : labelFieldContent.getFieldValue()); + templateContent = templateContent.replaceAll("#\\{"+matcher.group(1) +"\\}", ObjectUtils.isEmpty(labelFieldContent) ? "" : labelFieldContent.getFieldValue()); } } return templateContent; @@ -939,24 +941,46 @@ public class SignPatientManageRouteNodeServiceImpl implements ISignPatientManage /** * 替换节点内容 - * @param node 节点 + * @param taskPartitionDictId 节点任务细分id * @param labelFieldContentList 画像信息 * @return 替换标签后的节点列表 */ - private List replaceNodeContent(SignPatientManageRouteNode manageRouteNode, SpecialDiseaseNode node, List labelFieldContentList) { + private List replaceNodeContent(SignPatientManageRouteNode manageRouteNode, Long taskPartitionDictId, List labelFieldContentList) { List manageNodeList = new ArrayList<>(); - // 按照任务细分分组 - Map> groupbyPartition = labelFieldContentList.stream().collect(Collectors.groupingBy(LabelFieldInfoContentVo::getTaskPartitionDictId)); - List nodeParamList = groupbyPartition.get(node.getTaskSubdivision()); - // 参数按照序列号分组 - if (CollectionUtils.isNotEmpty(nodeParamList)) { - Map> groupBySn = nodeParamList.stream().collect(Collectors.groupingBy(LabelFieldInfoContentVo::getPortraitSn)); + Map> groupByRang = labelFieldContentList.stream().collect(Collectors.groupingBy(LabelFieldInfoContentVo::getApplyRange)); + // 筛选应用范围是否有私用的画像 + List privateLabelFields = groupByRang.get("PRIVATE"); + List publicLabelFields = groupByRang.get("PUBLIC"); + + // 按照sn进行分组,判断生成几条任务 + Map> groupByPartition = privateLabelFields.stream().collect(Collectors.groupingBy(LabelFieldInfoContentVo::getTaskPartitionDictId)); + List nodeLabelFieldContent = groupByPartition.get(taskPartitionDictId); + if (CollectionUtils.isEmpty(privateLabelFields) || CollectionUtils.isEmpty(nodeLabelFieldContent)) { + // 都是公有属性,只生成一条任务 + SignPatientManageNodeAuditVo manageNode = new SignPatientManageNodeAuditVo(); + BeanUtils.copyBeanProp(manageNode, manageRouteNode); + // 替换文本 + Map map = publicLabelFields.stream().collect(Collectors.toMap(LabelFieldInfoContentVo::getFieldCode,LabelFieldInfoContentVo::getFieldValue,(key1,key2)->key2)); + Document document = Jsoup.parse(manageNode.getNodeContent()); + // 需要提取的span + Elements spanlist = document.select("span[data-w-e-type]"); + for (Element span : spanlist) { + String paramKey = span.attr("data-fieldMark"); + span.text(map.getOrDefault(paramKey, "")); + span.unwrap(); + } + manageNode.setNodeContent(document.body().html()); + manageNodeList.add(manageNode); + } else { + Map> groupBySn = nodeLabelFieldContent.stream().collect(Collectors.groupingBy(LabelFieldInfoContentVo::getPortraitSn)); for (String portraitSn : groupBySn.keySet()) { - SignPatientManageRouteNode manageNode = new SignPatientManageRouteNode(); + SignPatientManageNodeAuditVo manageNode = new SignPatientManageNodeAuditVo(); BeanUtils.copyBeanProp(manageNode, manageRouteNode); // 替换文本 List nodeParams = groupBySn.get(portraitSn); + nodeParams.addAll(publicLabelFields); + Map map = nodeParams.stream().collect(Collectors.toMap(LabelFieldInfoContentVo::getFieldCode,LabelFieldInfoContentVo::getFieldValue,(key1,key2)->key2)); Document document = Jsoup.parse(manageNode.getNodeContent()); // 需要提取的span