Browse Source

流程编排

zhenglingfeng 8 years ago
parent
commit
2ea8d1d5b9

+ 6 - 4
hos-broker/src/main/java/com/yihu/hos/common/listener/ApplicationStartListener.java

@ -67,12 +67,12 @@ public class ApplicationStartListener implements ApplicationListener<ContextRefr
            Integer flowId = systemServiceFlow.getId();
            String code = systemServiceFlow.getCode();
            //默认所有class均为正确
            isCorrectClassMap.put(code, true);
            // 这是system业务系统在本地存储class的根目录
            File systemClassFlowPath = new File(this.getClass().getProtectionDomain().getClassLoader().getResource("").getPath() + "/" + code);
            File systemClassFlowPath = new File(this.getClass().getProtectionDomain().getClassLoader().getResource("").getPath());
            List<SystemServiceFlowClass> processesClassList = systemServiceFlowClassGroupMap.get("processor" + flowId);
            List<SystemServiceFlowClass> routesClassList = systemServiceFlowClassGroupMap.get("route" + flowId);
            // 创建processor文件
            isCorrectClassMap.put(code, true);
            if (!CollectionUtil.isEmpty(processesClassList)) {
                for (SystemServiceFlowClass processesClass : processesClassList) {
                    String className = processesClass.getClassName();
@ -82,7 +82,7 @@ public class ApplicationStartListener implements ApplicationListener<ContextRefr
                    Boolean flag = ClassFileUtil.createClassfile(systemClassFlowPath.toURI().toURL(), packageName, className, classPath);
                    // 记录到工具类中,以便其它线程需要时进行取用
                    if (flag) {
                        SystemClassMapping.getSystemClassNameMapping().put(code + BrokerConstant.PROCESSOR, code + CoreConstant.DOT + packageName + CoreConstant.DOT + className);
                        SystemClassMapping.getSystemClassNameMapping().put(code + BrokerConstant.PROCESSOR, packageName + CoreConstant.DOT + className);
                    } else {
                        isCorrectClassMap.put(code, flag);
                    }
@ -98,7 +98,7 @@ public class ApplicationStartListener implements ApplicationListener<ContextRefr
                    Boolean flag =ClassFileUtil.createClassfile(systemClassFlowPath.toURI().toURL(), packageName, className, classPath);
                    // 记录到工具类中,以便其它线程需要时进行取用
                    if (flag) {
                        SystemClassMapping.getSystemClassNameMapping().put(code + BrokerConstant.ROUTE, code + CoreConstant.DOT + packageName + CoreConstant.DOT + className);
                        SystemClassMapping.getSystemClassNameMapping().put(code + BrokerConstant.ROUTE, packageName + CoreConstant.DOT + className);
                    } else {
                        isCorrectClassMap.put(code, flag);
                    }
@ -116,6 +116,8 @@ public class ApplicationStartListener implements ApplicationListener<ContextRefr
                        }
                    }
                }
            } else {
                isCorrectClassMap.put(code, false);
            }
            if (isCorrectClassMap.get(code)) {
                if (!systemClassFlowPaths.contains(systemClassFlowPath)) {

+ 1 - 1
hos-camel/src/main/java/com/yihu/hos/api/processor/ApiProcessor.java

@ -1,4 +1,4 @@
package com.yihu.hos.api.processor;
package api.processor;
import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;

+ 3 - 3
hos-camel/src/main/java/com/yihu/hos/api/route/ApiRouteBulider.java

@ -1,6 +1,6 @@
package com.yihu.hos.api.route;
package api.route;
import com.yihu.hos.api.processor.ApiProcessor;
import api.processor.ApiProcessor;
import org.apache.camel.builder.RouteBuilder;
/**
@ -10,7 +10,7 @@ import org.apache.camel.builder.RouteBuilder;
public class ApiRouteBulider extends RouteBuilder {
    @Override
    public void configure() throws Exception {
        from("jetty:http://0.0.0.0:9090/api/v1").routeId("api")
        from("jetty:http://localhost:9090/api/v1").routeId("api")
                .process(new ApiProcessor());
    }
}

+ 1 - 0
hos-core/src/main/java/com/yihu/hos/core/datatype/ClassFileUtil.java

@ -31,6 +31,7 @@ public class ClassFileUtil {
            if (!systemFlowFile.exists()) {
                systemFlowFile.mkdirs();
            }
            packageName = StringUtil.replaceStrAll(packageName, ".", "/");
            File packageFile = new File(systemFlowURL.getPath() + "/" + packageName);
            if (!packageFile.exists()) {
                packageFile.mkdirs();

+ 5 - 1
pom.xml

@ -30,7 +30,7 @@
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
@ -59,6 +59,10 @@
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-data-jpa</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>

+ 6 - 3
src/main/java/com/yihu/hos/system/controller/FlowController.java

@ -2,6 +2,7 @@ package com.yihu.hos.system.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.hos.common.constants.Constants;
import com.yihu.hos.config.FilePathConfig;
import com.yihu.hos.system.model.SystemServiceFlow;
import com.yihu.hos.system.model.SystemServiceFlowClass;
import com.yihu.hos.system.model.SystemServiceFlowTemp;
@ -9,6 +10,7 @@ import com.yihu.hos.system.service.FlowManager;
import com.yihu.hos.system.service.intf.IFlowManage;
import com.yihu.hos.web.framework.model.Result;
import com.yihu.hos.web.framework.util.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
@ -42,7 +44,8 @@ public class FlowController extends BaseController {
    @Value("${esb.camelFile}")
    private String camelFile;
    @Autowired
    private FilePathConfig filePathConfig;
    /**
     *  流程管理管理界面
     *
@ -221,13 +224,13 @@ public class FlowController extends BaseController {
    public Object uploadImg(@RequestParam MultipartFile file,HttpServletRequest request
    ) {
        //TODO 文件地址设置
        String basePath = this.getServletContext().getRealPath(File.separator) + File.separator + "upload";
        String basePath = filePathConfig.getFilePath();
        String path = flowManage.uploadFile(file, basePath);
        if (StringUtils.isEmpty(path)){
            return Result.error("上传失败");
        }else {
            return Result.success(path);
            return Result.success(filePathConfig.getServerPath() + "/" + path);
        }
    }

+ 1 - 1
src/main/resources/application.yml

@ -35,7 +35,7 @@ spring:
    pooled: false
esb:
  genCamelUrl: http://192.168.131.11:8099/esb/genCamelFile
  camelFile: E:/
  camelFile: D:\
upload:
  file:
    path: D:\code\newHealth\new-esb\esb\src\main\webapp

+ 2 - 2
src/main/webapp/WEB-INF/ehr/jsp/system/flow/editorFlowJs.jsp

@ -237,8 +237,8 @@
                        success:  function processJson(data){
                            if(data.successFlg){
                                formsay.attr("class","say true").html("上传成功");
                                formObj.find("input[type=text]").attr("data-id","/upload/"+data.message)//设置已上传的文件的ID
                                formObj.find("input[type=text]").val("/upload/"+data.message)//设置已上传的文件的ID
                                formObj.find("input[type=text]").attr("data-id", data.message)//设置已上传的文件的ID
                                formObj.find("input[type=text]").val(data.message)//设置已上传的文件的ID
                                formObj.closest("div").find("span").html("重新导入<i></i>");
                            }else{

+ 1 - 2
src/main/webapp/WEB-INF/ehr/jsp/system/flow/flowJs.jsp

@ -158,8 +158,7 @@
        showImage: function (chart) {
            var me = this;
            var title = "流程图";
            debugger
            var url = "${contextRoot}"+"/"+chart;
            var url = chart;
            $("#divedit").show();
            $("#divImg").attr("src",url);