Commit 459e363c by zhouhaibao

Merge branch 'v2.0.1' of http://192.168.3.233:8090/platform/platform-process-server into v2.0.1

2 parents 868c1e00 1e49919f
package cn.com.glsx.process.modules.model; package cn.com.glsx.process.modules.model;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import lombok.Data; import lombok.Data;
import org.springframework.util.StringUtils;
import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* 操作符 * 操作符
...@@ -16,4 +23,21 @@ public class SopDataOperatorDTO { ...@@ -16,4 +23,21 @@ public class SopDataOperatorDTO {
// from SopDataConditionDTO // from SopDataConditionDTO
private String unit; private String unit;
private String style; private String style;
/**
* 一般value存储多值,用,分隔
* desc字段存储value的一些描述数据
*/
public String getDescByValue() {
if (!StringUtils.hasLength(this.getValue()) || !StringUtils.hasLength(this.getDesc())) {
return this.getValue();
}
String[] values = this.getValue().split(",");
if (values.length == 0) {
return this.getValue();
}
Map<String, String> descValueMap = JSON.parseObject(this.getDesc(), new TypeReference<Map<String, String>>() {
});
return Arrays.stream(values).map(p -> descValueMap.getOrDefault(p, p)).collect(Collectors.joining(","));
}
} }
\ No newline at end of file \ No newline at end of file
...@@ -126,6 +126,7 @@ public class KeHuLvChengAssembler { ...@@ -126,6 +126,7 @@ public class KeHuLvChengAssembler {
SopTplNode stageNode = PROTO_CONVERTER.proto2tpl(stageProto); SopTplNode stageNode = PROTO_CONVERTER.proto2tpl(stageProto);
stageNode.setNodeId(tplNodeLastNum++); stageNode.setNodeId(tplNodeLastNum++);
stageNode.setNodeName(String.format("%s-%s", stageValue, stageNode.getNodeName()));
stageNode.setNodeParamDef(JacksonUtil.jsonStrDeepSub(STAGE_TPL_NODE_PARAM_DEF_TPL, String.format("{\"stage\":{\"defaultValue\":\"%s\"}}", stageValue))); stageNode.setNodeParamDef(JacksonUtil.jsonStrDeepSub(STAGE_TPL_NODE_PARAM_DEF_TPL, String.format("{\"stage\":{\"defaultValue\":\"%s\"}}", stageValue)));
stageNode.setNodeKey(String.format("%s%d", stageProto.getNodeKey(), stageOrder)); stageNode.setNodeKey(String.format("%s%d", stageProto.getNodeKey(), stageOrder));
...@@ -199,9 +200,9 @@ public class KeHuLvChengAssembler { ...@@ -199,9 +200,9 @@ public class KeHuLvChengAssembler {
* 封装sop触达节点 * 封装sop触达节点
* *
* @param tplNodeProto 触达节点原型 * @param tplNodeProto 触达节点原型
* @param nodeId 节点id * @param nodeId 节点id
* @param nodeParamDef 页面传参的节点 nodeParamDef 参数 * @param nodeParamDef 页面传参的节点 nodeParamDef 参数
* @param stageid 节点所属阶段的顺序 * @param stageid 节点所属阶段的顺序
* @return * @return
*/ */
private SopTplNode getNotifyNodeFromProto(SopTplNodeProto tplNodeProto, Integer nodeId, String nodeParamDef, Integer stageid) { private SopTplNode getNotifyNodeFromProto(SopTplNodeProto tplNodeProto, Integer nodeId, String nodeParamDef, Integer stageid) {
...@@ -209,6 +210,10 @@ public class KeHuLvChengAssembler { ...@@ -209,6 +210,10 @@ public class KeHuLvChengAssembler {
notifyTplNode.setNodeId(nodeId); notifyTplNode.setNodeId(nodeId);
notifyTplNode.setNodeKey(String.format("%s%d", tplNodeProto.getNodeKey(), notifyTplNode.getNodeId())); notifyTplNode.setNodeKey(String.format("%s%d", tplNodeProto.getNodeKey(), notifyTplNode.getNodeId()));
String stageName = JacksonUtil.getStrValueInJsonStrByPath(nodeParamDef, "stage/defaultValue");
String dayStr = JacksonUtil.getStrValueInJsonStrByPath(nodeParamDef, "day/defaultValue");
notifyTplNode.setNodeName(String.format("%s-第%s天-%s", stageName, dayStr, notifyTplNode.getNodeName()));
nodeParamDef = JacksonUtil.jsonStrDeepSub(notifyTplNode.getNodeParamDef(), nodeParamDef); nodeParamDef = JacksonUtil.jsonStrDeepSub(notifyTplNode.getNodeParamDef(), nodeParamDef);
nodeParamDef = JacksonUtil.jsonStrDeepSub(nodeParamDef, String.format("{\"stageid\": {\"defaultValue\": %d}}", stageid)); nodeParamDef = JacksonUtil.jsonStrDeepSub(nodeParamDef, String.format("{\"stageid\": {\"defaultValue\": %d}}", stageid));
notifyTplNode.setNodeParamDef(nodeParamDef); notifyTplNode.setNodeParamDef(nodeParamDef);
...@@ -287,7 +292,7 @@ public class KeHuLvChengAssembler { ...@@ -287,7 +292,7 @@ public class KeHuLvChengAssembler {
// 获取阶段更新的sql // 获取阶段更新的sql
SopInst sopInst = SopInstConverter.INSTANCE.dto2do(instDTO); SopInst sopInst = SopInstConverter.INSTANCE.dto2do(instDTO);
Map<String, String> stageSqlMap = sopDataService.parseSQL(sopInst); Map<String, String> stageSqlMap = sopDataService.parseSQL(sopInst);
String updateSql = String.join("\n", stageSqlMap.values()); String updateSql = String.join(" ", stageSqlMap.values());
String nodeContent = updateStageNode.getNodeContent(); String nodeContent = updateStageNode.getNodeContent();
Map<String, Object> nodeContentMap = JSON.parseObject(nodeContent, Map.class); Map<String, Object> nodeContentMap = JSON.parseObject(nodeContent, Map.class);
......
...@@ -8,9 +8,7 @@ import com.glsx.plat.core.annotation.ResponseResultBody; ...@@ -8,9 +8,7 @@ import com.glsx.plat.core.annotation.ResponseResultBody;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
...@@ -30,4 +28,10 @@ public class SopDataController extends BaseController { ...@@ -30,4 +28,10 @@ public class SopDataController extends BaseController {
public List<SopDataActionDTO> listCondition(SopDataActionSearch search) { public List<SopDataActionDTO> listCondition(SopDataActionSearch search) {
return sopDataService.listCondition(search); return sopDataService.listCondition(search);
} }
@Operation(summary = "根据某一阶段条件获取条件名称", description = "根据某一阶段条件获取条件名称")
@PostMapping("/condition/getConditionTitle")
public String parseParamRemarkTitle(@RequestBody SopDataActionDTO actionDTO) {
return sopDataService.parseParamRemarkTitle(actionDTO);
}
} }
...@@ -22,6 +22,7 @@ import org.springframework.stereotype.Service; ...@@ -22,6 +22,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.text.MessageFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -123,7 +124,7 @@ public class SopDataService { ...@@ -123,7 +124,7 @@ public class SopDataService {
* *
* @param action 所属条件 * @param action 所属条件
*/ */
private String parseParamRemarkTitle(SopDataActionDTO action) { public String parseParamRemarkTitle(SopDataActionDTO action) {
if (!StringUtils.hasLength(action.getParamRemark())) { if (!StringUtils.hasLength(action.getParamRemark())) {
return action.getParamRemark(); return action.getParamRemark();
} }
...@@ -138,26 +139,30 @@ public class SopDataService { ...@@ -138,26 +139,30 @@ public class SopDataService {
if (CollectionUtils.isEmpty(conditions)) { if (CollectionUtils.isEmpty(conditions)) {
return subTitle; return subTitle;
} }
List<String> subConditionTitleList = new ArrayList<>(); List<String> conditionTitleList = new ArrayList<>();
for (SopDataConditionDTO condition : conditions) { for (SopDataConditionDTO condition : conditions) {
String subConditionTitle = StringUtils.hasLength(condition.getParamRemark()) ? JSON.parseObject(condition.getParamRemark()).getString("title") : ""; String conditionTitle = "";
// 将占位符替换真实数据,占位符采用[]包裹 if (StringUtils.hasLength(condition.getParamRemark())) {
if (!CollectionUtils.isEmpty(condition.getOperators())) { conditionTitle = JSON.parseObject(condition.getParamRemark()).getString("title");
Map<String, String> map = condition.getOperators().stream() // 将占位符替换真实数据,占位符采用[]包裹
.filter(p -> StringUtils.hasLength(p.getValue())) if (!CollectionUtils.isEmpty(condition.getOperators())) {
.collect(Collectors.groupingBy(o -> o.getName(), Collectors.mapping(o -> o.getValue(), Collectors.joining(",")))); Map<String, String> map = condition.getOperators().stream()
for (Map.Entry<String, String> e : map.entrySet()) { .filter(p -> StringUtils.hasLength(p.getValue()))
subConditionTitle = subConditionTitle .collect(Collectors.groupingBy(o -> o.getName(), Collectors.mapping(o -> o.getDescByValue(), Collectors.joining(","))));
.replaceFirst("\\[([^\\]]+)\\]", e.getKey()) for (Map.Entry<String, String> e : map.entrySet()) {
.replaceFirst("\\[([^\\]]+)\\]", e.getValue()); conditionTitle = conditionTitle
.replaceFirst("\\[([^\\]]+)\\]", e.getKey())
.replaceFirst("\\[([^\\]]+)\\]", e.getValue());
}
} }
} }
if (!CollectionUtils.isEmpty(condition.getSubConditions())) { if (!CollectionUtils.isEmpty(condition.getSubConditions())) {
subConditionTitle += parseParamRemarkTitle(condition.getSubConditions()); conditionTitle += parseParamRemarkTitle(condition.getSubConditions());
} }
subConditionTitleList.add(subConditionTitle); conditionTitleList.add(conditionTitle);
} }
subTitle += joinWithDelimiter(", 且", subConditionTitleList); subTitle += joinWithDelimiter(", 且", conditionTitleList);
return subTitle; return subTitle;
} }
...@@ -229,17 +234,27 @@ public class SopDataService { ...@@ -229,17 +234,27 @@ public class SopDataService {
if (CollectionUtils.isEmpty(condition.getOperators())) { if (CollectionUtils.isEmpty(condition.getOperators())) {
return condStr; return condStr;
} }
// 针对“页面配置”等这种条件(type=1)进行特殊处理,对value值进行拆分,放在sql的占位中
if ("页面配置".equals(condition.getName())) {
SopDataOperatorDTO operator = condition.getOperators().get(0);
String[] vals = operator.getValue().split("\\+");
if (vals.length == 0) {
return "";
}
return MessageFormat.format(condStr, vals);
}
List<String> operatorStrList = new ArrayList<>(); List<String> operatorStrList = new ArrayList<>();
for (SopDataOperatorDTO operator : condition.getOperators()) { for (SopDataOperatorDTO operator : condition.getOperators()) {
if (StringUtils.hasLength(operator.getValue())) { if (!StringUtils.hasLength(operator.getValue())) {
String value; continue;
if ("in".equals(operator.getKey()) || "nin".equals(operator.getKey())) { }
value = "(" + Arrays.stream(operator.getValue().split(",")).map(p -> "'" + p + "'").collect(Collectors.joining(",")) + ")"; String value;
} else { if ("in".equals(operator.getKey()) || "nin".equals(operator.getKey())) {
value = "'" + operator.getValue() + "'"; value = "(" + Arrays.stream(operator.getValue().split(",")).map(p -> "'" + p + "'").collect(Collectors.joining(",")) + ")";
} } else {
operatorStrList.add(condStr + " " + operator.getKey() + " " + value); value = "'" + operator.getValue() + "'";
} }
operatorStrList.add(condStr + " " + operator.getKey() + " " + value);
} }
condStr = joinWithDelimiter(" and ", operatorStrList); condStr = joinWithDelimiter(" and ", operatorStrList);
return condStr; return condStr;
......
...@@ -79,9 +79,10 @@ public class TestSopService { ...@@ -79,9 +79,10 @@ public class TestSopService {
.put("paramRemark", "{\"title\": \"天数[xx][X]天\"}") .put("paramRemark", "{\"title\": \"天数[xx][X]天\"}")
.put("operators", Lists.newArrayList(ImmutableMap.builder() .put("operators", Lists.newArrayList(ImmutableMap.builder()
.put("id", "1") .put("id", "1")
.put("name", "等于") .put("name", "包含")
.put("key", "=") .put("key", "in")
.put("value", "11") .put("value", "a,b,c")
.put("desc", "{\"a\":\"A\", \"b\":\"B\"}")
.build())) .build()))
.build())) .build()))
.build())).build()).build(); .build())).build()).build();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!