修改生成任务。

This commit is contained in:
haown 2024-07-12 10:37:08 +08:00
parent 29cc1732db
commit 8c058ac870
4 changed files with 165 additions and 137 deletions

View File

@ -499,10 +499,14 @@ public class SignPatientManageRouteServiceImpl implements ISignPatientManageRout
manageRouteNode.setPropagandaInfoId(node.getTemplateId());
manageRouteNode.setPropagandaTitle(node.getTemplateName());
// 查询宣教表
PropagandaMaterialsVo propagandaMaterialsVo = propagandaInfoService.selectPropagandaInfoById(node.getTemplateId());
templateDetail = JSONObject.parseObject(JSONObject.toJSONString(propagandaMaterialsVo));
if (manageRouteNode.getPropagandaInfoId() != null) {
PropagandaMaterialsVo propagandaMaterialsVo = propagandaInfoService.selectPropagandaInfoById(node.getTemplateId());
if (ObjectUtils.isNotEmpty(propagandaMaterialsVo)) {
templateDetail = JSONObject.parseObject(JSONObject.toJSONString(propagandaMaterialsVo));
manageRouteNode.setTemplateDetail(templateDetail);
}
}
manageRouteNode.setTemplateType(TemplateTypeConstants.PROPAGANDA);
manageRouteNode.setTemplateDetail(templateDetail);
break;
// 问卷
case TaskNodeTypeConstants.QUESTIONNAIRE_SCALE:
@ -557,70 +561,76 @@ public class SignPatientManageRouteServiceImpl implements ISignPatientManageRout
manageNodeList.forEach(manageNode -> {
manageNode.setRouteNodeNameCN(RouteNodeNameEnum.getNameByInfo(manageNode.getRouteNodeName()).getName());
JSONObject templateDetail = new JSONObject();
switch(manageNode.getTaskType()) {
// 电话外呼
case TaskNodeTypeConstants.PHONE_OUTBOUND:
// 电话外呼分为话术和问卷两种根据模板id判断选择的哪种模板
if (manageNode.getPhoneId() != null) { // 话术
ScriptInfo scriptInfo = scriptInfoMapper.selectScriptInfoById(manageNode.getPhoneId());
if (ObjectUtils.isNotEmpty(scriptInfo)) {
// 话术库json内容替换
manageNode.setPhoneNodeContent(signPatientManageRouteNodeService.getFlowScheme(scriptInfo.getFlowScheme(), labelFieldContentList));
templateDetail = JSONObject.parseObject(JSONObject.toJSONString(scriptInfo));
manageNode.setTemplateType(TemplateTypeConstants.SCRIPT);
manageNode.setTemplateDetail(templateDetail);
if (StringUtils.isNotBlank(manageNode.getTaskNodeType())) {
switch(manageNode.getTaskNodeType()) {
// 电话外呼
case TaskNodeTypeConstants.PHONE_OUTBOUND:
// 电话外呼分为话术和问卷两种根据模板id判断选择的哪种模板
if (manageNode.getPhoneId() != null) { // 话术
ScriptInfo scriptInfo = scriptInfoMapper.selectScriptInfoById(manageNode.getPhoneId());
if (ObjectUtils.isNotEmpty(scriptInfo)) {
// 话术库json内容替换
manageNode.setPhoneNodeContent(signPatientManageRouteNodeService.getFlowScheme(scriptInfo.getFlowScheme(), labelFieldContentList));
templateDetail = JSONObject.parseObject(JSONObject.toJSONString(scriptInfo));
manageNode.setTemplateType(TemplateTypeConstants.SCRIPT);
manageNode.setTemplateDetail(templateDetail);
}
} else if (manageNode.getQuestionInfoId() != null) { // 问卷
// 查询问卷详情
QuestionVO questionVO = questionInfoService.selectQuestionInfoById(manageNode.getQuestionInfoId());
if (ObjectUtils.isNotEmpty(questionVO)) {
templateDetail = JSONObject.parseObject(JSONObject.toJSONString(questionVO));
manageNode.setTemplateType(TemplateTypeConstants.QUESTIONNAIRE);
manageNode.setTemplateDetail(templateDetail);
}
}
} else if (manageNode.getQuestionInfoId() != null) { // 问卷
// 电话短信内容
if (manageNode.getPhoneMessageTemplateId() != null) {
// 查询短信库
manageNode.setPhoneMessageTemplateContent(signPatientManageRouteNodeService.replaceMessageInfo(manageNode.getPhoneMessageTemplateId(), labelFieldContentList));
}
break;
// 问卷
case TaskNodeTypeConstants.QUESTIONNAIRE_SCALE:
// 查询问卷详情
QuestionVO questionVO = questionInfoService.selectQuestionInfoById(manageNode.getQuestionInfoId());
if (ObjectUtils.isNotEmpty(questionVO)) {
templateDetail = JSONObject.parseObject(JSONObject.toJSONString(questionVO));
manageNode.setTemplateType(TemplateTypeConstants.QUESTIONNAIRE);
manageNode.setTemplateDetail(templateDetail);
if (manageNode.getQuestionInfoId() != null) {
QuestionVO questionVO = questionInfoService.selectQuestionInfoById(manageNode.getQuestionInfoId());
if (ObjectUtils.isNotEmpty(questionVO)) {
templateDetail = JSONObject.parseObject(JSONObject.toJSONString(questionVO));
manageNode.setTemplateType(TemplateTypeConstants.QUESTIONNAIRE);
manageNode.setTemplateDetail(templateDetail);
}
}
}
// 电话短信内容
if (manageNode.getPhoneMessageTemplateId() != null) {
// 查询短信库
manageNode.setPhoneMessageTemplateContent(signPatientManageRouteNodeService.replaceMessageInfo(manageNode.getPhoneMessageTemplateId(), labelFieldContentList));
}
break;
// 问卷
case TaskNodeTypeConstants.QUESTIONNAIRE_SCALE:
// 查询问卷详情
QuestionVO questionVO = questionInfoService.selectQuestionInfoById(manageNode.getQuestionInfoId());
if (ObjectUtils.isNotEmpty(questionVO)) {
templateDetail = JSONObject.parseObject(JSONObject.toJSONString(questionVO));
manageNode.setTemplateType(TemplateTypeConstants.QUESTIONNAIRE);
manageNode.setTemplateDetail(templateDetail);
}
break;
// 宣教
case TaskNodeTypeConstants.PROPAGANDA_ARTICLE:
// 查询宣教详情
PropagandaMaterialsVo propagandaMaterialsVo = propagandaInfoService.selectPropagandaInfoById(manageNode.getPropagandaInfoId());
if (ObjectUtils.isNotEmpty(propagandaMaterialsVo)) {
templateDetail = JSONObject.parseObject(JSONObject.toJSONString(propagandaMaterialsVo));
manageNode.setTemplateType(TemplateTypeConstants.PROPAGANDA);
manageNode.setTemplateDetail(templateDetail);
}
break;
// 文字提醒
case TaskNodeTypeConstants.TEXT_REMIND:
break;
// 宣教
case TaskNodeTypeConstants.PROPAGANDA_ARTICLE:
// 查询宣教详情
if (manageNode.getPropagandaInfoId() != null) {
PropagandaMaterialsVo propagandaMaterialsVo = propagandaInfoService.selectPropagandaInfoById(manageNode.getPropagandaInfoId());
if (ObjectUtils.isNotEmpty(propagandaMaterialsVo)) {
templateDetail = JSONObject.parseObject(JSONObject.toJSONString(propagandaMaterialsVo));
manageNode.setTemplateType(TemplateTypeConstants.PROPAGANDA);
manageNode.setTemplateDetail(templateDetail);
}
}
break;
// 文字提醒
case TaskNodeTypeConstants.TEXT_REMIND:
manageNode.setTemplateType(TaskContentConstants.TEXT_REMIND);
break;
// 人工随访
//case TaskContentConstants.ARTIFICIAL_FOLLOW_UP:
// // 查询问卷详情
// if (manageNode.getFollowTemplateId() != null) {
// QuestionVO questionVO1 = questionInfoService.selectQuestionInfoById(manageNode.getFollowTemplateId());
// if (ObjectUtils.isNotEmpty(questionVO1)) {
// templateDetail = JSONObject.parseObject(JSONObject.toJSONString(questionVO1));
// manageNode.setTemplateType(TemplateTypeConstants.QUESTIONNAIRE);
// manageNode.setTemplateDetail(templateDetail);
// }
// }
// break;
break;
// 人工随访
//case TaskContentConstants.ARTIFICIAL_FOLLOW_UP:
// // 查询问卷详情
// if (manageNode.getFollowTemplateId() != null) {
// QuestionVO questionVO1 = questionInfoService.selectQuestionInfoById(manageNode.getFollowTemplateId());
// if (ObjectUtils.isNotEmpty(questionVO1)) {
// templateDetail = JSONObject.parseObject(JSONObject.toJSONString(questionVO1));
// manageNode.setTemplateType(TemplateTypeConstants.QUESTIONNAIRE);
// manageNode.setTemplateDetail(templateDetail);
// }
// }
// break;
}
}
manageNodeAuditList.add(manageNode);
});

View File

@ -74,6 +74,7 @@ import java.time.LocalTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@ -820,9 +821,13 @@ public class SignPatientManageRouteNodeServiceImpl implements ISignPatientManage
List<LabelFieldInfoContentVo> privateLabelFields = groupByRang.get("PRIVATE");
List<LabelFieldInfoContentVo> publicLabelFields = groupByRang.get("PUBLIC");
Map<Long, List<LabelFieldInfoContentVo>> groupByPartition = new HashMap<>();
List<LabelFieldInfoContentVo> nodeLabelFieldContent = new ArrayList<>();
// 按照sn进行分组判断生成几条任务
Map<Long, List<LabelFieldInfoContentVo>> groupByPartition = privateLabelFields.stream().collect(Collectors.groupingBy(LabelFieldInfoContentVo::getTaskPartitionDictId));
List<LabelFieldInfoContentVo> nodeLabelFieldContent = groupByPartition.get(taskPartitionDictId);
if (CollectionUtils.isNotEmpty(privateLabelFields)) {
groupByPartition = privateLabelFields.stream().collect(Collectors.groupingBy(LabelFieldInfoContentVo::getTaskPartitionDictId));
nodeLabelFieldContent = groupByPartition.get(taskPartitionDictId);
}
if (CollectionUtils.isEmpty(privateLabelFields) || CollectionUtils.isEmpty(nodeLabelFieldContent)) {
// 都是公有属性只生成一条任务
SignPatientManageNodeAuditVo manageNode = new SignPatientManageNodeAuditVo();

View File

@ -473,85 +473,97 @@ public class SignPatientRecordServiceImpl implements ISignPatientRecordService {
// 按照公共私用分组
Map<String, List<LabelFieldInfoContentVo>> groupByRang = labelFieldContentList.stream().collect(Collectors.groupingBy(LabelFieldInfoContentVo::getApplyRange));
// 筛选应用范围是否有私用的画像
List<LabelFieldInfoContentVo> privateLabelFields = groupByRang.get("PRIVATE");
List<LabelFieldInfoContentVo> publicLabelFields = groupByRang.get("PUBLIC");
List<LabelFieldInfoContentVo> privateLabelFields = groupByRang.getOrDefault("PRIVATE", new ArrayList<>());
List<LabelFieldInfoContentVo> publicLabelFields = groupByRang.getOrDefault("PUBLIC", new ArrayList<>());
Map<Long, List<LabelFieldInfoContentVo>> groupByPartition = privateLabelFields.stream().collect(Collectors.groupingBy(LabelFieldInfoContentVo::getTaskPartitionDictId));
nodeList.forEach(node -> {
List<LabelFieldInfoContentVo> nodeLabelFields = groupByPartition.get(node.getTaskPartitionDictId());
if (CollectionUtils.isEmpty(nodeLabelFields)) {
Document document = Jsoup.parse(node.getNodeContent());
// 需要提取的span
Elements spanlist = document.select("span[data-w-e-type]");
Map<String, LabelFieldInfoContentVo> map = publicLabelFields.stream().collect(Collectors.toMap(LabelFieldInfoContentVo::getFieldCode,LabelFieldInfoContentVo->LabelFieldInfoContentVo ,(key1,key2)->key2));
for (Element span : spanlist) {
String paramKey = span.attr("data-fieldMark");
LabelFieldInfoContentVo labelFieldInfoContentVo = map.get(paramKey);
if (ObjectUtils.isNotEmpty(labelFieldInfoContentVo)) {
PatientNodeParamsCurrent paramsCurrent = new PatientNodeParamsCurrent();
paramsCurrent.setPatientId(signPatientRecord.getPatientId());
paramsCurrent.setPatientName(signPatientRecord.getPatientName());
paramsCurrent.setTaskPartitionDictId(node.getTaskPartitionDictId());
paramsCurrent.setTaskPartitionDictName(node.getTaskPartitionDictName());
paramsCurrent.setTaskTypeId(node.getTaskTypeId());
paramsCurrent.setTaskTypeName(node.getTaskTypeName());
paramsCurrent.setRouteId(node.getRouteId());
paramsCurrent.setRouteName(node.getRouteName());
paramsCurrent.setRouteNodeId(node.getId());
paramsCurrent.setRouteNodeName(node.getRouteNodeName());
paramsCurrent.setParamKey(paramKey);
paramsCurrent.setParamValue(labelFieldInfoContentVo.getFieldValue());
paramsCurrent.setParamName(labelFieldInfoContentVo.getFieldName());
paramsCurrent.setPortraitSn(labelFieldInfoContentVo.getPortraitSn());
paramsCurrentList.add(paramsCurrent);
PatientNodeParamsLog paramsLog = new PatientNodeParamsLog();
BeanUtils.copyBeanProp(paramsLog, paramsCurrent);
paramsLogList.add(paramsLog);
if (StringUtils.contains(node.getNodeContent(), "data-w-e-type")) {
boolean hasPrivate = false;
List<LabelFieldInfoContentVo> nodeLabelFields = new ArrayList<>();
if (StringUtils.isNotBlank(node.getNodeContent()) && StringUtils.contains("data-w-e-type", node.getNodeContent())) {
if (!CollectionUtils.isEmpty(privateLabelFields)) {
Map<Long, List<LabelFieldInfoContentVo>> groupByPartition = privateLabelFields.stream().collect(Collectors.groupingBy(LabelFieldInfoContentVo::getTaskPartitionDictId));
nodeLabelFields = groupByPartition.get(node.getTaskPartitionDictId());
if (!CollectionUtils.isEmpty(nodeLabelFields)) {
hasPrivate = true;
}
}
}
} else {
Map<String, List<LabelFieldInfoContentVo>> groupBySn = nodeLabelFields.stream().collect(Collectors.groupingBy(LabelFieldInfoContentVo::getPortraitSn));
// 查询node中的标签
if (!CollectionUtils.isEmpty(publicLabelFields) && StringUtils.isNotBlank(node.getNodeContent()) && StringUtils.contains("data-w-e-type", node.getNodeContent())) {
if (hasPrivate) {
// 从公共和私有查询标签
Map<String, List<LabelFieldInfoContentVo>> groupBySn = nodeLabelFields.stream().collect(Collectors.groupingBy(LabelFieldInfoContentVo::getPortraitSn));
// 查询node中的标签
if (!CollectionUtils.isEmpty(publicLabelFields)) {
Document document = Jsoup.parse(node.getNodeContent());
// 需要提取的span
Elements spanlist = document.select("span[data-w-e-type]");
for(String sn : groupBySn.keySet()) {
List<LabelFieldInfoContentVo> snLabelField = groupBySn.get(sn);
snLabelField.addAll(publicLabelFields);
Map<String, LabelFieldInfoContentVo> map = snLabelField.stream().collect(Collectors.toMap(LabelFieldInfoContentVo::getFieldCode,LabelFieldInfoContentVo->LabelFieldInfoContentVo ,(key1,key2)->key2));
for (Element span : spanlist) {
String paramKey = span.attr("data-fieldMark");
LabelFieldInfoContentVo labelFieldInfoContentVo = map.get(paramKey);
if (ObjectUtils.isNotEmpty(labelFieldInfoContentVo)) {
PatientNodeParamsCurrent paramsCurrent = new PatientNodeParamsCurrent();
paramsCurrent.setPatientId(signPatientRecord.getPatientId());
paramsCurrent.setPatientName(signPatientRecord.getPatientName());
paramsCurrent.setTaskPartitionDictId(node.getTaskPartitionDictId());
paramsCurrent.setTaskPartitionDictName(node.getTaskPartitionDictName());
paramsCurrent.setTaskTypeId(node.getTaskTypeId());
paramsCurrent.setTaskTypeName(node.getTaskTypeName());
paramsCurrent.setRouteId(node.getRouteId());
paramsCurrent.setRouteName(node.getRouteName());
paramsCurrent.setRouteNodeId(node.getId());
paramsCurrent.setRouteNodeName(node.getRouteNodeName());
paramsCurrent.setParamKey(paramKey);
paramsCurrent.setParamValue(labelFieldInfoContentVo.getFieldValue());
paramsCurrent.setParamName(labelFieldInfoContentVo.getFieldName());
paramsCurrent.setPortraitSn(labelFieldInfoContentVo.getPortraitSn());
paramsCurrentList.add(paramsCurrent);
PatientNodeParamsLog paramsLog = new PatientNodeParamsLog();
BeanUtils.copyBeanProp(paramsLog, paramsCurrent);
paramsLogList.add(paramsLog);
}
}
}
}
} else {
// 只取公共标签
Document document = Jsoup.parse(node.getNodeContent());
// 需要提取的span
Elements spanlist = document.select("span[data-w-e-type]");
for(String sn : groupBySn.keySet()) {
List<LabelFieldInfoContentVo> snLabelField = groupBySn.get(sn);
snLabelField.addAll(publicLabelFields);
Map<String, LabelFieldInfoContentVo> map = snLabelField.stream().collect(Collectors.toMap(LabelFieldInfoContentVo::getFieldCode,LabelFieldInfoContentVo->LabelFieldInfoContentVo ,(key1,key2)->key2));
Map<String, LabelFieldInfoContentVo> map = publicLabelFields.stream().collect(Collectors.toMap(LabelFieldInfoContentVo::getFieldCode,LabelFieldInfoContentVo->LabelFieldInfoContentVo ,(key1,key2)->key2));
for (Element span : spanlist) {
String paramKey = span.attr("data-fieldMark");
LabelFieldInfoContentVo labelFieldInfoContentVo = map.get(paramKey);
if (ObjectUtils.isNotEmpty(labelFieldInfoContentVo)) {
PatientNodeParamsCurrent paramsCurrent = new PatientNodeParamsCurrent();
paramsCurrent.setPatientId(signPatientRecord.getPatientId());
paramsCurrent.setPatientName(signPatientRecord.getPatientName());
paramsCurrent.setTaskPartitionDictId(node.getTaskPartitionDictId());
paramsCurrent.setTaskPartitionDictName(node.getTaskPartitionDictName());
paramsCurrent.setTaskTypeId(node.getTaskTypeId());
paramsCurrent.setTaskTypeName(node.getTaskTypeName());
paramsCurrent.setRouteId(node.getRouteId());
paramsCurrent.setRouteName(node.getRouteName());
paramsCurrent.setRouteNodeId(node.getId());
paramsCurrent.setRouteNodeName(node.getRouteNodeName());
paramsCurrent.setParamKey(paramKey);
paramsCurrent.setParamValue(labelFieldInfoContentVo.getFieldValue());
paramsCurrent.setParamName(labelFieldInfoContentVo.getFieldName());
paramsCurrent.setPortraitSn(labelFieldInfoContentVo.getPortraitSn());
paramsCurrentList.add(paramsCurrent);
PatientNodeParamsLog paramsLog = new PatientNodeParamsLog();
BeanUtils.copyBeanProp(paramsLog, paramsCurrent);
paramsLogList.add(paramsLog);
}
for (Element span : spanlist) {
String paramKey = span.attr("data-fieldMark");
LabelFieldInfoContentVo labelFieldInfoContentVo = map.get(paramKey);
if (ObjectUtils.isNotEmpty(labelFieldInfoContentVo)) {
PatientNodeParamsCurrent paramsCurrent = new PatientNodeParamsCurrent();
paramsCurrent.setPatientId(signPatientRecord.getPatientId());
paramsCurrent.setPatientName(signPatientRecord.getPatientName());
paramsCurrent.setTaskPartitionDictId(node.getTaskPartitionDictId());
paramsCurrent.setTaskPartitionDictName(node.getTaskPartitionDictName());
paramsCurrent.setTaskTypeId(node.getTaskTypeId());
paramsCurrent.setTaskTypeName(node.getTaskTypeName());
paramsCurrent.setRouteId(node.getRouteId());
paramsCurrent.setRouteName(node.getRouteName());
paramsCurrent.setRouteNodeId(node.getId());
paramsCurrent.setRouteNodeName(node.getRouteNodeName());
paramsCurrent.setParamKey(paramKey);
paramsCurrent.setParamValue(labelFieldInfoContentVo.getFieldValue());
paramsCurrent.setParamName(labelFieldInfoContentVo.getFieldName());
paramsCurrent.setPortraitSn(labelFieldInfoContentVo.getPortraitSn());
paramsCurrentList.add(paramsCurrent);
PatientNodeParamsLog paramsLog = new PatientNodeParamsLog();
BeanUtils.copyBeanProp(paramsLog, paramsCurrent);
paramsLogList.add(paramsLog);
}
}
}
}
});
if (!CollectionUtils.isEmpty(paramsCurrentList)) {
patientNodeParamsCurrentMapper.insertList(paramsCurrentList);
@ -559,4 +571,5 @@ public class SignPatientRecordServiceImpl implements ISignPatientRecordService {
}
}
}
}

View File

@ -786,11 +786,11 @@
sdn.route_node_name routeNodeName,
sdn.route_node_day routeNodeDay,
sdn.execute_time executionTime,
GROUP_CONCAT(sdn.task_type SEPARATOR ',') as taskPartitionCodes,
GROUP_CONCAT(sdn.task_node_type SEPARATOR ',') as taskPartitionCodes,
GROUP_CONCAT(dic.dict_label SEPARATOR ',') as taskPartitionDictNames
from sign_patient_manage_route_node sdn
left join sys_dict_data dic on sdn.task_type = dic.dict_value
where sdn.manage_route_id = #{manageRouteId} and dic.dict_type ='task_content'
left join sys_dict_data dic on sdn.task_node_type = dic.dict_value
where sdn.manage_route_id = #{manageRouteId} and dic.dict_type ='task_node_type'
group by sdn.route_node_name, sdn.route_node_day
</select>
@ -799,12 +799,12 @@
node.*,
dic.dict_label as taskTypeName
from sign_patient_manage_route_node node
left join sys_dict_data dic on node.task_type = dic.dict_value
left join sys_dict_data dic on node.task_node_type = dic.dict_value
where node.manage_route_id in
<foreach item="manageRouteId" collection="manageRouteIds" open="(" separator="," close=")">
#{manageRouteId}
</foreach>
and dic.dict_type ='task_content'
and dic.dict_type ='task_node_type'
</select>
<select id="selectNodesByManageIds" resultMap="SignPatientManageRouteNodeResult">