Sfoglia il codice sorgente

流程编辑器逻辑修改

zhenglingfeng 8 anni fa
parent
commit
b9b466872c

+ 2 - 2
src/main/java/com/yihu/hos/system/controller/ProcessController.java

@ -66,9 +66,9 @@ public class ProcessController  extends BaseController {
        try {
            Integer flowId = processManager.generateFlow(code, name, flowJson);
            if (flowId == null) {
                return Result.error("生成业务流程失败");
                return Result.error("生成业务流程失败,请确认流程图是否编辑错误");
            }
            processManager.saveProcess(code, name, flowId, positionJson);
            processManager.saveProcess(code, name, flowId, positionJson, flowJson);
            return Result.success("生成业务流程成功");
        } catch (Exception e) {

+ 9 - 0
src/main/java/com/yihu/hos/system/model/ProcessResultModel.java

@ -8,6 +8,7 @@ public class ProcessResultModel implements java.io.Serializable {
	private String name;
	private String value;
	private String config;
	private String nodeType;
	public String getName() {
@ -26,6 +27,14 @@ public class ProcessResultModel implements java.io.Serializable {
		this.value = value;
	}
	public String getConfig() {
		return config;
	}
	public void setConfig(String config) {
		this.config = config;
	}
	public String getNodeType() {
		return nodeType;
	}

+ 9 - 0
src/main/java/com/yihu/hos/system/model/SystemServiceFlowProcess.java

@ -6,6 +6,7 @@ public class SystemServiceFlowProcess implements java.io.Serializable {
    private String name;
    private Integer flowId;
    private String result;
    private String flowResult;
    public Integer getId() {
        return id;
@ -39,6 +40,14 @@ public class SystemServiceFlowProcess implements java.io.Serializable {
        this.result = result;
    }
    public String getFlowResult() {
        return flowResult;
    }
    public void setFlowResult(String flowResult) {
        this.flowResult = flowResult;
    }
    public Integer getFlowId() {
        return flowId;
    }

+ 13 - 13
src/main/java/com/yihu/hos/system/service/ProcessEditor.java

@ -65,39 +65,39 @@ public class ProcessEditor {
    public StringBuilder montage(String nodeName) {
        JsonNode node = nodeMap.get(nodeName);
        String nodeType = node.get("nodeType").asText();
        String config = node.get("config").asText();
        String value = node.get("value").asText();
        String name = node.get("name").asText();
        StringBuilder bodyBuilderTemp = new StringBuilder();
        if (nodeType.equals("start")) {
            bodyBuilder.append("from(\"");
            bodyBuilder.append(value + "\")");
            bodyBuilder.append(config + "\")");
            if (!StringUtil.isEmpty(code)) {
                bodyBuilder.append(".routeId(\""+code+"\")");
            }
        } else if (nodeType.equals("processor")) {
            String className = value.substring(value.lastIndexOf(".") + 1, value.length());
            String className = config.substring(value.lastIndexOf(".") + 1, value.length());
            addPackageList("import " + value + ";\n");
            JsonNode param = node.get("param");
            if (param == null) {
                bodyBuilderTemp.append("\n.process(new "+className+"())");
            addPackageList("import " + config + ";\n");
            if (config == null) {
                bodyBuilderTemp.append("\n.process(new "+className+"(\"\"))");
            } else {
                bodyBuilderTemp.append("\n.process(new "+className+"("+param+"))");
                bodyBuilderTemp.append("\n.process(new "+className+"("+config+"))");
            }
        } else if (nodeType.equals("judgement")) {
            judgement(value, nodeName, bodyBuilderTemp);
            judgement(config, nodeName, bodyBuilderTemp);
        } else if (nodeType.equals("circle")) {
            split(value, bodyBuilderTemp);
            split(config, bodyBuilderTemp);
        } else if (nodeType.equals("aggregate")) {
            aggregate(value, bodyBuilderTemp);
            aggregate(config, bodyBuilderTemp);
        } else if (nodeType.equals("multicast")) {
            multicast(value, nodeName, bodyBuilderTemp);
            multicast(config, nodeName, bodyBuilderTemp);
        } else if (nodeType.equals("format")) {
            format(value, nodeName, bodyBuilderTemp);
            format(config, nodeName, bodyBuilderTemp);
        } else {
//                    bodyBuilder.append("\n.setHeader(Exchange.HTTP_METHOD, constant(\"POST\"))");
            bodyBuilderTemp.append("\n.to(\"");
            bodyBuilderTemp.append(value + "\")");
            bodyBuilderTemp.append(config + "\")");
        }
        while (nodeIt.hasNext()) {
            List<Edge<String>> edgeList = mDG.getEdgeList(nodeName);

+ 10 - 1
src/main/java/com/yihu/hos/system/service/ProcessManager.java

@ -46,6 +46,7 @@ public class ProcessManager {
            ProcessResultModel resultModel = new ProcessResultModel();
            resultModel.setName(endpoint.getName());
            resultModel.setValue(endpoint.getEndpoint());
            resultModel.setConfig(endpoint.getEndpoint());
            resultModel.setNodeType("service");
            appIdList.add(endpoint.getAppId());
@ -114,11 +115,13 @@ public class ProcessManager {
        ProcessResultModel json2xml = new ProcessResultModel();
        json2xml.setName("json转xml格式转换器");
        json2xml.setValue("unmarshal");
        json2xml.setConfig("unmarshal");
        json2xml.setNodeType("format");
        ProcessResultModel xml2json = new ProcessResultModel();
        xml2json.setName("xml转json格式转换器");
        xml2json.setValue("marshal");
        xml2json.setConfig("marshal");
        xml2json.setNodeType("format");
        resultModelList.add(json2xml);
        resultModelList.add(xml2json);
@ -127,6 +130,7 @@ public class ProcessManager {
            ProcessResultModel resultModel = new ProcessResultModel();
            resultModel.setName(processor.getName());
            resultModel.setValue(processor.getPackageName() + "." + processor.getClassName());
            resultModel.setConfig(processor.getPackageName() + "." + processor.getClassName());
            resultModel.setNodeType("processor");
            resultModelList.add(resultModel);
        }
@ -134,12 +138,13 @@ public class ProcessManager {
        return Result.success(result);
    }
    public void saveProcess(String code, String name, Integer flowId, String positionJsonStr) throws Exception {
    public void saveProcess(String code, String name, Integer flowId, String positionJsonStr, String flowJsonStr) throws Exception {
        SystemServiceFlowProcess process = new SystemServiceFlowProcess();
        process.setCode(code);
        process.setName(name);
        process.setResult(positionJsonStr);
        process.setFlowId(flowId);
        process.setFlowResult(flowJsonStr);
        processDao.saveEntity(process);
    }
@ -196,6 +201,10 @@ public class ProcessManager {
    }
    public Integer generateFlow(String code, String name, String flowJsonStr) throws Exception {
        SystemServiceFlowProcess process = processDao.getFlowProcessByCode(code);
        if (process != null) {
            return null;
        }
        String root = "";
        ObjectMapper objectMapper = new ObjectMapper();
        JsonNode flowJson = objectMapper.readValue(flowJsonStr, JsonNode.class);

+ 5 - 0
src/main/resources/resource/SystemServiceFlowProcess.hbm.xml

@ -24,6 +24,11 @@
                <comment>模板编辑结果</comment>
            </column>
        </property>
        <property name="flowResult" type="java.lang.String">
            <column name="flow_result">
                <comment>流程编辑结果</comment>
            </column>
        </property>
        <property name="flowId" type="java.lang.Integer">
            <column name="flow_id" length="11">
                <comment>流程ID</comment>