Kaynağa Gözat

流程文件生成bug修复

demon 8 yıl önce
ebeveyn
işleme
8f1f2e72dc

+ 3 - 0
hos-broker/src/main/java/com/yihu/hos/broker/services/camel/CamelCompiler.java

@ -36,8 +36,11 @@ public class CamelCompiler {
            //错误信息打印
            List diagnosticList = diagnostics.getDiagnostics();
            for (Object aDiagnosticList : diagnosticList) {
                System.out.println(aDiagnosticList.toString());
                logger.error(aDiagnosticList.toString());
            }
        }else {
            System.out.println("编译成功"+sourcePath);
        }
        return success;

+ 11 - 1
hos-broker/src/main/java/com/yihu/hos/broker/services/camel/ESBCamelService.java

@ -80,6 +80,7 @@ public class ESBCamelService {
            logger.debug("start camel router success," + serviceFlow.getRouteCode());
            return Result.error("服务流程增加成功!");
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e);
            return Result.error("服务流程增加失败!");
        }
@ -112,6 +113,7 @@ public class ESBCamelService {
            return Result.error("服务流程变更增加成功!");
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e);
            return Result.error("服务流程变更增加失败!");
        }
@ -247,7 +249,15 @@ public class ESBCamelService {
        String sourcePath = ClassFileUtil.getFilePath(resource, handleFile.getPackageName(), handleFile.getClassName(), ClassFileUtil.JAVA_FILE);
        logger.info(sourcePath);
        return CamelCompiler.compile(sourcePath, resource.toString());
        boolean succ = CamelCompiler.compile(sourcePath, resource.getPath());
        if (succ){
            //编译成功后将class文件上传至mongodb;文件名为类名+ routeCode
            String packagePath = StringUtil.replaceStrAll(handleFile.getPackageName(), ".", "/");
            String classPath =  resource.getPath()+ packagePath + "/" + handleFile.getClassName() + ClassFileUtil.CLASS_FILE;
            String s = GridFSUtil.uploadFile(dbName, classPath, handleFile.getClassName()+handleFile.getRouteCode() + ClassFileUtil.CLASS_FILE);
            System.out.println("新生成Class文件:"+s);
        }
        return succ;
    }
    private void deleteClassFile(ServiceFlow.HandleFile handleFile) {

+ 4 - 3
hos-core/src/main/java/com/yihu/hos/core/datatype/ClassFileUtil.java

@ -13,7 +13,8 @@ public class ClassFileUtil {
    public static final String CLASS_FILE = ".class";
    public static final Logger logger = LoggerFactory.getLogger(ClassFileUtil.CLASS_FILE);
    public static final String JAVA_FILE = ".java";
    private static String packagePathTemplate = System.getProperty("user.dir")//获取到项目的根路径
            + "/hos-broker/src/main/java/";
    /**
     * 工具类不允许进行实例化
     */
@ -132,7 +133,7 @@ public class ClassFileUtil {
    public static FileOutputStream createFile(URL url, String packageName, String className, String fileType) {
        try {
            String packagePath = StringUtil.replaceStrAll(packageName, ".", "/");
            File packageFile = new File(url.getPath() + "/" + packagePath);
            File packageFile = new File(packagePathTemplate + "/" + packagePath);
            if (!packageFile.exists()) {
                boolean mkdirs = packageFile.mkdirs();
                if (!mkdirs) {
@ -162,6 +163,6 @@ public class ClassFileUtil {
    public static String getFilePath(URL url, String packageName, String className, String fileType) {
        String packagePath = StringUtil.replaceStrAll(packageName, ".", "/");
        return url.getPath() + packagePath + "/" + className + fileType;
        return packagePathTemplate + packagePath + "/" + className + fileType;
    }
}

+ 2 - 2
hos-rest/src/main/java/com/yihu/hos/rest/services/crawler/DatacollectService.java

@ -18,8 +18,8 @@ import com.yihu.hos.rest.models.crawler.config.SysConfig;
import com.yihu.hos.rest.models.crawler.patient.PatientIdentity;
import com.yihu.hos.rest.models.rs.*;
import com.yihu.hos.rest.services.standard.StdService;
import com.yihu.hos.web.framework.constrant.DateConvert;
import com.yihu.hos.web.framework.constrant.SqlConstants;
import com.yihu.hos.web.framework.constant.DateConvert;
import com.yihu.hos.web.framework.constant.SqlConstants;
import com.yihu.hos.web.framework.model.ActionResult;
import com.yihu.hos.web.framework.util.GridFSUtil;
import org.bson.types.ObjectId;

+ 2 - 1
hos-saas/src/main/java/com/yihu/hos/saas/models/TenantModel.java

@ -1,6 +1,7 @@
package com.yihu.hos.saas.models;
import com.yihu.hos.saas.models.common.IdModel;
import com.yihu.hos.tenant.models.common.IdModel;
import javax.persistence.Column;
import javax.persistence.Entity;

+ 2 - 1
hos-saas/src/main/java/com/yihu/hos/saas/models/TestModel.java

@ -1,6 +1,7 @@
package com.yihu.hos.saas.models;
import com.yihu.hos.saas.models.common.IdModel;
import com.yihu.hos.tenant.models.common.IdModel;
import javax.persistence.Column;
import javax.persistence.Entity;

+ 1 - 1
hos-saas/src/main/java/com/yihu/hos/saas/models/UserModel.java

@ -1,7 +1,7 @@
package com.yihu.hos.saas.models;
import com.yihu.hos.saas.models.common.IdModel;
import com.yihu.hos.tenant.models.common.IdModel;
import javax.persistence.Column;
import javax.persistence.Entity;

+ 2 - 1
hos-saas/src/main/java/com/yihu/hos/saas/models/UserTenantModel.java

@ -1,6 +1,7 @@
package com.yihu.hos.saas.models;
import com.yihu.hos.saas.models.common.IdModel;
import com.yihu.hos.tenant.models.common.IdModel;
import javax.persistence.Column;
import javax.persistence.Entity;

+ 26 - 11
src/main/java/com/yihu/hos/system/service/FlowManager.java

@ -550,17 +550,24 @@ public class FlowManager implements IFlowManage {
                }
            }
            String deName = DES.decrypt(flowTemp.getClassPath(), DES.COMMON_PASSWORD);//吉阿米果的文件名
            //生成新的route文件
            String newFileName = genRouteJavaFile(flow.getCode(), flowTemp.getClassName(), deName, newCron);
            String enNewFileName = DES.encrypt(newFileName,DES.COMMON_PASSWORD);
            ServiceFlow serviceFlow = new ServiceFlow();
            serviceFlow.setRouteCode(flow.getCode());
            serviceFlow.setFlowType(ServiceFlowConstant.JAVA);
            ServiceFlow.HandleFile handleFile = new ServiceFlow.HandleFile();
            handleFile.setRouteCode(flow.getCode());
            handleFile.setFileType(ServiceFlowConstant.JAVA);
            handleFile.setPackageName(flowTemp.getClassPath());
            handleFile.setClassName(flowTemp.getClassName());
            handleFile.setFilePath(basePath.toString());
            handleFile.setPackageName(basePath.toString());
            handleFile.setClassName(flowTemp.getClassName()+flow.getCode());
            handleFile.setFilePath(enNewFileName);
            handleFile.setUsage(ServiceFlowConstant.FLOW_TYPE_ROUTE);
            ArrayList<ServiceFlow.HandleFile>  handleFiles =new ArrayList<>();
            handleFiles.add(handleFile);
            serviceFlow.setHandleFiles(handleFiles);
            serviceFlowEventService.serviceFlowModifiedAdd(serviceFlow);
            return flowId;
        }
@ -597,18 +604,22 @@ public class FlowManager implements IFlowManage {
            newFlowClass.setIsUpdate("1");
            //生成新的route文件
            String newFileName = genRouteJavaFile(newFlow.getCode(), flowTemp.getClassName(), deName, newCron);
            String enNewFileName = DES.encrypt(newFileName,DES.COMMON_PASSWORD);
            if (newFileName != null) {
                ServiceFlow serviceFlow = new ServiceFlow();
                serviceFlow.setRouteCode(newFlow.getCode());
                serviceFlow.setFlowType(ServiceFlowConstant.CLASS);
                ServiceFlow.HandleFile handleFile = new ServiceFlow.HandleFile();
                handleFile.setRouteCode(newFlow.getCode());
                handleFile.setFileType(ServiceFlowConstant.CLASS);
                handleFile.setFileType(ServiceFlowConstant.JAVA);
                handleFile.setPackageName(flowTemp.getPackageName());
                handleFile.setClassName(flowTemp.getClassName());
                handleFile.setFilePath(newFileName);
                handleFile.setClassName(flowTemp.getClassName()+newFlow.getCode());
                handleFile.setFilePath(enNewFileName);
                handleFile.setUsage(ServiceFlowConstant.FLOW_TYPE_ROUTE);
                ArrayList<ServiceFlow.HandleFile>  handleFiles =new ArrayList<>();
                handleFiles.add(handleFile);
                serviceFlow.setHandleFiles(handleFiles);
                serviceFlowEventService.serviceFlowModifiedAdd(serviceFlow);
                return newFlow.getId();
            } else {
@ -637,6 +648,7 @@ public class FlowManager implements IFlowManage {
            newFlow.setCreateDate(new Date());
            newFlow.setFileType(ServiceFlowConstant.CLASS);
            flowDao.saveEntity(newFlow);
            ArrayList<ServiceFlow.HandleFile>  handleFiles =new ArrayList<>();
            //新增processor记录
            for (SystemServiceFlowTemp process : flowTempProces) {
@ -662,6 +674,8 @@ public class FlowManager implements IFlowManage {
                processClass.setIsUpdate("1");
                //生成新的java文件
                String newFileName = genProcessorJavaFile(jobId, newFlow.getCode(), deName, processClass.getClassName());
                String enNewFileName = DES.encrypt(newFileName,DES.COMMON_PASSWORD);
                if (newFileName != null) {
                    //发送消息
                    ServiceFlow serviceFlow = new ServiceFlow();
@ -669,12 +683,13 @@ public class FlowManager implements IFlowManage {
                    serviceFlow.setFlowType(ServiceFlowConstant.CLASS);
                    ServiceFlow.HandleFile handleFile = new ServiceFlow.HandleFile();
                    handleFile.setRouteCode(newFlow.getCode());
                    handleFile.setFileType(ServiceFlowConstant.CLASS);
                    handleFile.setFileType(ServiceFlowConstant.JAVA);
                    handleFile.setPackageName(processClass.getPackageName());
                    handleFile.setClassName(processClass.getClassName());
                    handleFile.setFilePath(newFileName);
                    handleFile.setFilePath(enNewFileName);
                    handleFile.setUsage(ServiceFlowConstant.FLOW_TYPE_PROCESSOR);
                    handleFiles.add(handleFile);
                    serviceFlow.setHandleFiles(handleFiles);
                    serviceFlowEventService.serviceFlowModifiedAdd(serviceFlow);
                    flowClassDao.saveEntity(processClass);
                } else {