|  | @ -1,8 +1,8 @@
 | 
	
		
			
				|  |  | package com.yihu.hos.system.service;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.yihu.hos.common.constants.ContextAttributes;
 | 
	
		
			
				|  |  | import com.yihu.hos.config.MongoConfig;
 | 
	
		
			
				|  |  | import com.yihu.hos.core.datatype.StringUtil;
 | 
	
		
			
				|  |  | import com.yihu.hos.config.BeanConfig;
 | 
	
		
			
				|  |  | import com.yihu.hos.core.datatype.ClassFileUtil;
 | 
	
		
			
				|  |  | import com.yihu.hos.core.encrypt.DES;
 | 
	
		
			
				|  |  | import com.yihu.hos.core.file.FileUtil;
 | 
	
		
			
				|  |  | import com.yihu.hos.interceptor.LocalContext;
 | 
	
	
		
			
				|  | @ -19,14 +19,16 @@ import com.yihu.hos.web.framework.model.DictItem;
 | 
	
		
			
				|  |  | import com.yihu.hos.web.framework.model.Result;
 | 
	
		
			
				|  |  | import com.yihu.hos.web.framework.model.bo.ServiceFlow;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Value;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  | import org.springframework.web.multipart.commons.CommonsMultipartFile;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import javax.annotation.Resource;
 | 
	
		
			
				|  |  | import java.io.OutputStream;
 | 
	
		
			
				|  |  | import java.util.*;
 | 
	
		
			
				|  |  | import java.io.File;
 | 
	
		
			
				|  |  | import java.nio.charset.StandardCharsets;
 | 
	
		
			
				|  |  | import java.util.ArrayList;
 | 
	
		
			
				|  |  | import java.util.Date;
 | 
	
		
			
				|  |  | import java.util.List;
 | 
	
		
			
				|  |  | import java.util.Map;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
		
			
				|  |  |  * 系统流程管理业务类
 | 
	
	
		
			
				|  | @ -37,10 +39,11 @@ import java.util.*;
 | 
	
		
			
				|  |  |  */
 | 
	
		
			
				|  |  | @Service("flowManager")
 | 
	
		
			
				|  |  | public class FlowManager {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public static final String BEAN_ID = "flowManager";
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     ServiceFlowEventService serviceFlowEventService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BeanConfig beanConfig;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Resource(name = "flowDao")
 | 
	
		
			
				|  |  |     private FlowDao flowDao;
 | 
	
	
		
			
				|  | @ -48,38 +51,6 @@ public class FlowManager {
 | 
	
		
			
				|  |  |     private FlowClassDao flowClassDao;
 | 
	
		
			
				|  |  |     @Resource(name = FlowTempDao.BEAN_ID)
 | 
	
		
			
				|  |  |     private FlowTempDao flowTempDao;
 | 
	
		
			
				|  |  |     @Value("${spring.data.mongodb.gridFsDatabase}")
 | 
	
		
			
				|  |  |     private String dbName;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private MongoConfig mongoConfig;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 生成processor的java文件
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param routeId      流程Code
 | 
	
		
			
				|  |  |      * @param tempFilePath 模板文件名
 | 
	
		
			
				|  |  |      * @param className    模板类名
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public static String genProcessorJavaFile(String routeId, String tempFilePath, String className) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             String newFileName = className + routeId + ".java";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String newFilePath = "/temp/" + className;
 | 
	
		
			
				|  |  |             String text = GridFSUtil.readFileContent(tempFilePath);
 | 
	
		
			
				|  |  |             boolean succ = FileUtil.writeFile(newFilePath, text, "UTF-8");
 | 
	
		
			
				|  |  |             //TODO 上传到GridFS
 | 
	
		
			
				|  |  |             if (succ) {
 | 
	
		
			
				|  |  |                 newFileName = GridFSUtil.uploadFile( newFilePath, newFileName,null);
 | 
	
		
			
				|  |  |                 return newFileName;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             System.out.println("生成processor的java文件操作出错");
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return null;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 生成Route流程的java文件
 | 
	
	
		
			
				|  | @ -90,11 +61,16 @@ public class FlowManager {
 | 
	
		
			
				|  |  |      * @param newCron      cron表达式
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public static String genRouteJavaFile(String routeId, String className, String tempFilePath, String newCron) {
 | 
	
		
			
				|  |  |     public String genRouteJavaFile(String routeId, String className, String tempFilePath, String newCron) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             String newFileName = className + routeId + ".java";
 | 
	
		
			
				|  |  |             String newFilePath = "/temp/" + newFileName;
 | 
	
		
			
				|  |  |             String text = GridFSUtil.readFileContent( tempFilePath);
 | 
	
		
			
				|  |  |             byte[] content = ClassFileUtil.down(tempFilePath);
 | 
	
		
			
				|  |  |             if (content == null) {
 | 
	
		
			
				|  |  |                 return null;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String text = new String(content, StandardCharsets.UTF_8);
 | 
	
		
			
				|  |  |             if (text.contains("?cron=")) {
 | 
	
		
			
				|  |  |                 String oldStr = text.substring(text.indexOf("?cron=") + 6);
 | 
	
		
			
				|  |  |                 String cron = oldStr.substring(0, oldStr.indexOf("\""));
 | 
	
	
		
			
				|  | @ -107,9 +83,8 @@ public class FlowManager {
 | 
	
		
			
				|  |  |             //修改routeId;模板规则 routeId("routeId")
 | 
	
		
			
				|  |  |             text = text.replace("routeId(\"routeId\")", "routeId(\"" + routeId + "\")");
 | 
	
		
			
				|  |  |             boolean succ = FileUtil.writeFile(newFilePath, text, "UTF-8");
 | 
	
		
			
				|  |  |             //TODO 上传到GridFS
 | 
	
		
			
				|  |  |             if (succ) {
 | 
	
		
			
				|  |  |                 newFileName = GridFSUtil.uploadFile( newFilePath, newFileName,null);
 | 
	
		
			
				|  |  |                 newFileName = ClassFileUtil.uploadFile(beanConfig.getFsUrl(), new File(newFilePath + newFileName), newFileName);
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 return null;
 | 
	
		
			
				|  |  |             }
 | 
	
	
		
			
				|  | @ -131,17 +106,22 @@ public class FlowManager {
 | 
	
		
			
				|  |  |      * @param className    模板类名
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public static String genProcessorJavaFile(String jobId, String routeId, String tempFilePath, String className) {
 | 
	
		
			
				|  |  |     public String genProcessorJavaFile(String jobId, String routeId, String tempFilePath, String className) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             String newFileName = className + routeId + ".java";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String newFilePath = "/temp/" + className;
 | 
	
		
			
				|  |  |             String text = GridFSUtil.readFileContent( tempFilePath);
 | 
	
		
			
				|  |  |             byte[] content = ClassFileUtil.down(tempFilePath);
 | 
	
		
			
				|  |  |             if (content == null) {
 | 
	
		
			
				|  |  |                 return null;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String text = new String(content, StandardCharsets.UTF_8);
 | 
	
		
			
				|  |  |             text = text.replace("jobId=jobId", "jobId=" + jobId);
 | 
	
		
			
				|  |  |             boolean succ = FileUtil.writeFile(newFilePath, text, "UTF-8");
 | 
	
		
			
				|  |  |             //TODO 上传到GridFS
 | 
	
		
			
				|  |  |             if (succ) {
 | 
	
		
			
				|  |  |                 newFileName = GridFSUtil.uploadFile( newFilePath, newFileName,null);
 | 
	
		
			
				|  |  |                 newFileName = ClassFileUtil.uploadFile(beanConfig.getFsUrl(), new File(newFilePath + newFileName), newFileName);
 | 
	
		
			
				|  |  |                 return newFileName;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
	
		
			
				|  | @ -226,27 +206,10 @@ public class FlowManager {
 | 
	
		
			
				|  |  |             serviceFlowEventService.serviceFlowAdded(serviceFlow);
 | 
	
		
			
				|  |  |         } else if (ServiceFlowConstant.JAVA.equals(obj.getFileType())) {
 | 
	
		
			
				|  |  |             List<SystemServiceFlowTemp> flowTempList = obj.getFlowTempArray();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | //            ServiceFlow serviceFlow = new ServiceFlow();
 | 
	
		
			
				|  |  | //            serviceFlow.setRouteCode(obj.getCode());
 | 
	
		
			
				|  |  | //            serviceFlow.setFlowType(ServiceFlowConstant.JAVA);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             for (SystemServiceFlowTemp flowTemp : flowTempList) {
 | 
	
		
			
				|  |  |                 flowTemp.setFlowId(obj.getId());
 | 
	
		
			
				|  |  |                 flowDao.saveEntity(flowTemp);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | //                ServiceFlow.HandleFile handleFile = new ServiceFlow.HandleFile();
 | 
	
		
			
				|  |  | //                handleFile.setRouteCode(obj.getCode());
 | 
	
		
			
				|  |  | //                handleFile.setFileType(ServiceFlowConstant.JAVA);
 | 
	
		
			
				|  |  | //                handleFile.setPackageName(flowTemp.getPackageName());
 | 
	
		
			
				|  |  | //                handleFile.setClassName(flowTemp.getClassName());
 | 
	
		
			
				|  |  | //                handleFile.setFilePath(flowTemp.getClassPath());
 | 
	
		
			
				|  |  | //                handleFile.setUsage(flowTemp.getType());
 | 
	
		
			
				|  |  | //                serviceFlow.addHandleFile(handleFile);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | //            serviceFlowEventService.serviceFlowAdded(serviceFlow);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return Result.success("保存成功");
 | 
	
	
		
			
				|  | @ -277,26 +240,15 @@ public class FlowManager {
 | 
	
		
			
				|  |  |             List<Integer> classIds = flowClassDao.getFlowClassIds(obj.getId());//原flowclass集合
 | 
	
		
			
				|  |  |             List<SystemServiceFlowClass> flowClassList = obj.getFlowClassArray();
 | 
	
		
			
				|  |  |             SystemServiceFlowClass flowClassRoute = null;
 | 
	
		
			
				|  |  |             String oper = "";
 | 
	
		
			
				|  |  |             serviceFlow.setRouteCode(obj.getCode());
 | 
	
		
			
				|  |  |             serviceFlow.setFlowType(ServiceFlowConstant.CLASS);
 | 
	
		
			
				|  |  |             for (SystemServiceFlowClass flowClass : flowClassList) {
 | 
	
		
			
				|  |  |                 if (flowClass.getId() != null) {
 | 
	
		
			
				|  |  |                     classIds.remove(flowClass.getId());
 | 
	
		
			
				|  |  |                     flowClassDao.updateEntity(flowClass);
 | 
	
		
			
				|  |  |                     if (flowClass.getType().equals(ServiceFlowConstant.FLOW_TYPE_ROUTE)) {
 | 
	
		
			
				|  |  | //                        sendUpdateMessage(flow.getCode(), flowClass, ServiceFlowConstant.FLOW_OP_UPDATE);
 | 
	
		
			
				|  |  | //                    } else {
 | 
	
		
			
				|  |  |                         flowClassRoute = flowClass;
 | 
	
		
			
				|  |  |                         oper = ServiceFlowConstant.FLOW_OP_UPDATE;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     if (!flowClass.getType().equals(ServiceFlowConstant.FLOW_TYPE_ROUTE)) {
 | 
	
		
			
				|  |  |                         flowClassDao.saveEntity(flowClass);
 | 
	
		
			
				|  |  | //                        sendUpdateMessage(flow.getCode(), flowClass, ServiceFlowConstant.FLOW_OP_ADD);
 | 
	
		
			
				|  |  |                     } else {
 | 
	
		
			
				|  |  |                         flowClassRoute = flowClass;
 | 
	
		
			
				|  |  |                         oper = ServiceFlowConstant.FLOW_OP_ADD;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -313,24 +265,17 @@ public class FlowManager {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             serviceFlowEventService.serviceFlowModifiedAdd(serviceFlow);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //删除判断
 | 
	
		
			
				|  |  |             if (classIds != null && classIds.size() > 0) {
 | 
	
		
			
				|  |  |                 for (Integer id : classIds) {
 | 
	
		
			
				|  |  |                     SystemServiceFlowClass flowClass = getFlowClassById(id);
 | 
	
		
			
				|  |  |                     flowClassDao.deleteEntity(flowClass);
 | 
	
		
			
				|  |  |                     if (flowClass.getType().equals(ServiceFlowConstant.FLOW_TYPE_ROUTE)) {
 | 
	
		
			
				|  |  | //                        sendUpdateMessage(flow.getCode(), flowClass, ServiceFlowConstant.FLOW_OP_DELETE);
 | 
	
		
			
				|  |  | //                    } else {
 | 
	
		
			
				|  |  |                         flowClassRoute = flowClass;
 | 
	
		
			
				|  |  |                         flowClassRoute.setIsUpdate("1");
 | 
	
		
			
				|  |  |                         oper = ServiceFlowConstant.FLOW_OP_DELETE;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | //            if (flowClassRoute != null) {
 | 
	
		
			
				|  |  | //                sendUpdateMessage(flow.getCode(), flowClassRoute, oper);
 | 
	
		
			
				|  |  | //            }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         flowDao.updateEntity(flow);
 | 
	
	
		
			
				|  | @ -422,32 +367,6 @@ public class FlowManager {
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public Result uploadFile(CommonsMultipartFile file) {
 | 
	
		
			
				|  |  |         String newFileName;
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             String fileName = UUID.randomUUID() + file.getFileItem().getName();
 | 
	
		
			
				|  |  |             newFileName = GridFSUtil.uploadFile(file.getInputStream(),fileName,null);
 | 
	
		
			
				|  |  |             if (!StringUtil.isEmpty(newFileName)) {
 | 
	
		
			
				|  |  |                 return Result.success(DES.encrypt(newFileName, DES.COMMON_PASSWORD));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return Result.error("上传失败");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public Result readFile(OutputStream os, String fileName) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             fileName = DES.decrypt(fileName, DES.COMMON_PASSWORD);
 | 
	
		
			
				|  |  |             GridFSUtil.readFile(mongoConfig.mongoClient().getDatabase(dbName), os, fileName);
 | 
	
		
			
				|  |  |             return Result.success("读取成功");
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return Result.error("读取失败");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 发送MQ消息-更新路由
 | 
	
		
			
				|  |  |      *
 | 
	
	
		
			
				|  | @ -543,7 +462,7 @@ public class FlowManager {
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public Integer updateCamelFile(String jobId,Integer flowTempId, Integer flowId, String newCron) throws Exception {
 | 
	
		
			
				|  |  |     public Integer updateCamelFile(String jobId, Integer flowTempId, Integer flowId, String newCron) throws Exception {
 | 
	
		
			
				|  |  |          /* 修改route文件无需重新生成flowClass记录,文件名根据className+routeId 生成;*/
 | 
	
		
			
				|  |  |         List<SystemServiceFlowTemp> flowTempRouters = flowTempDao.getFlowTemps(flowTempId, ServiceFlowConstant.FLOW_TYPE_ROUTE);
 | 
	
		
			
				|  |  |         List<SystemServiceFlowTemp> flowTempProces = flowTempDao.getFlowTemps(flowTempId, ServiceFlowConstant.FLOW_TYPE_PROCESSOR);
 | 
	
	
		
			
				|  | @ -556,12 +475,8 @@ public class FlowManager {
 | 
	
		
			
				|  |  |             ServiceFlow serviceFlow = new ServiceFlow();
 | 
	
		
			
				|  |  |             //新增processor记录
 | 
	
		
			
				|  |  |             for (SystemServiceFlowTemp process : flowTempProces) {
 | 
	
		
			
				|  |  |                 String deName = DES.decrypt(process.getClassPath(), DES.COMMON_PASSWORD);//吉阿米果的文件名
 | 
	
		
			
				|  |  |                 String newFileName = genProcessorJavaFile(jobId, flow.getCode(), deName, process.getClassName());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 //生成新的java文件
 | 
	
		
			
				|  |  |                 String enNewFileName = DES.encrypt(newFileName, DES.COMMON_PASSWORD);
 | 
	
		
			
				|  |  |                 if (newFileName != null) {
 | 
	
		
			
				|  |  |                 String newPath = genProcessorJavaFile(jobId, flow.getCode(), process.getClassPath(), process.getClassName());
 | 
	
		
			
				|  |  |                 if (newPath != null) {
 | 
	
		
			
				|  |  |                     //发送消息
 | 
	
		
			
				|  |  |                     serviceFlow.setRouteCode(flow.getCode());
 | 
	
		
			
				|  |  |                     serviceFlow.setFlowType(ServiceFlowConstant.CLASS);
 | 
	
	
		
			
				|  | @ -570,7 +485,7 @@ public class FlowManager {
 | 
	
		
			
				|  |  |                     handleFile.setFileType(ServiceFlowConstant.JAVA);
 | 
	
		
			
				|  |  |                     handleFile.setPackageName(process.getPackageName());
 | 
	
		
			
				|  |  |                     handleFile.setClassName(process.getClassName());
 | 
	
		
			
				|  |  |                     handleFile.setFilePath(enNewFileName);
 | 
	
		
			
				|  |  |                     handleFile.setFilePath(newPath);
 | 
	
		
			
				|  |  |                     handleFile.setUsage(ServiceFlowConstant.FLOW_TYPE_PROCESSOR);
 | 
	
		
			
				|  |  |                     handleFiles.add(handleFile);
 | 
	
		
			
				|  |  |                     serviceFlow.setHandleFiles(handleFiles);
 | 
	
	
		
			
				|  | @ -580,14 +495,8 @@ public class FlowManager {
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             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);
 | 
	
		
			
				|  |  |             String newPath = genRouteJavaFile(flow.getCode(), flowTemp.getClassName(), flowTemp.getClassPath(), newCron);
 | 
	
		
			
				|  |  |             serviceFlow.setRouteCode(flow.getCode());
 | 
	
		
			
				|  |  |             serviceFlow.setFlowType(ServiceFlowConstant.JAVA);
 | 
	
		
			
				|  |  |             ServiceFlow.HandleFile handleFile = new ServiceFlow.HandleFile();
 | 
	
	
		
			
				|  | @ -595,7 +504,7 @@ public class FlowManager {
 | 
	
		
			
				|  |  |             handleFile.setFileType(ServiceFlowConstant.JAVA);
 | 
	
		
			
				|  |  |             handleFile.setPackageName(flowTemp.getPackageName());
 | 
	
		
			
				|  |  |             handleFile.setClassName(flowTemp.getClassName() + flow.getCode());
 | 
	
		
			
				|  |  |             handleFile.setFilePath(enNewFileName);
 | 
	
		
			
				|  |  |             handleFile.setFilePath(newPath);
 | 
	
		
			
				|  |  |             handleFile.setUsage(ServiceFlowConstant.FLOW_TYPE_ROUTE);
 | 
	
		
			
				|  |  |             handleFiles.add(handleFile);
 | 
	
		
			
				|  |  |             serviceFlow.setHandleFiles(handleFiles);
 | 
	
	
		
			
				|  | @ -623,22 +532,18 @@ public class FlowManager {
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //新增processor记录
 | 
	
		
			
				|  |  |             String deName = DES.decrypt(flowTemp.getClassPath(), DES.COMMON_PASSWORD);//吉阿米果的文件名
 | 
	
		
			
				|  |  |             String newFileName = genRouteJavaFile(newFlow.getCode(), flowTemp.getClassName(), deName, newCron);
 | 
	
		
			
				|  |  |             String enClassName = DES.encrypt(newFileName.replace(".java", ".class"), DES.COMMON_PASSWORD);//生成机密过的classPath
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String newPath = genRouteJavaFile(newFlow.getCode(), flowTemp.getClassName(), flowTemp.getClassPath(), newCron);
 | 
	
		
			
				|  |  |             SystemServiceFlowClass newFlowClass = new SystemServiceFlowClass();
 | 
	
		
			
				|  |  |             newFlowClass.setPackageName(flowTemp.getPackageName());
 | 
	
		
			
				|  |  |             newFlowClass.setClassName(flowTemp.getClassName() + newFlow.getCode());
 | 
	
		
			
				|  |  |             newFlowClass.setClassPath(enClassName);
 | 
	
		
			
				|  |  |             newFlowClass.setClassPath(flowTemp.getClassPath());
 | 
	
		
			
				|  |  |             newFlowClass.setFlowId(newFlow.getId());
 | 
	
		
			
				|  |  |             newFlowClass.setType(ServiceFlowConstant.FLOW_TYPE_ROUTE);
 | 
	
		
			
				|  |  |             flowClassDao.saveEntity(newFlowClass);
 | 
	
		
			
				|  |  |             newFlowClass.setIsUpdate("1");
 | 
	
		
			
				|  |  |             //生成新的route文件
 | 
	
		
			
				|  |  |             String enNewFileName = DES.encrypt(newFileName, DES.COMMON_PASSWORD);//加密文件名
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if (newFileName != null) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if (newPath != null) {
 | 
	
		
			
				|  |  |                 ServiceFlow serviceFlow = new ServiceFlow();
 | 
	
		
			
				|  |  |                 serviceFlow.setRouteCode(newFlow.getCode());
 | 
	
		
			
				|  |  |                 serviceFlow.setFlowType(ServiceFlowConstant.CLASS);
 | 
	
	
		
			
				|  | @ -647,7 +552,7 @@ public class FlowManager {
 | 
	
		
			
				|  |  |                 handleFile.setFileType(ServiceFlowConstant.JAVA);
 | 
	
		
			
				|  |  |                 handleFile.setPackageName(flowTemp.getPackageName());
 | 
	
		
			
				|  |  |                 handleFile.setClassName(flowTemp.getClassName() + newFlow.getCode());
 | 
	
		
			
				|  |  |                 handleFile.setFilePath(enNewFileName);
 | 
	
		
			
				|  |  |                 handleFile.setFilePath(newPath);
 | 
	
		
			
				|  |  |                 handleFile.setUsage(ServiceFlowConstant.FLOW_TYPE_ROUTE);
 | 
	
		
			
				|  |  |                 ArrayList<ServiceFlow.HandleFile> handleFiles = new ArrayList<>();
 | 
	
		
			
				|  |  |                 handleFiles.add(handleFile);
 | 
	
	
		
			
				|  | @ -668,8 +573,9 @@ public class FlowManager {
 | 
	
		
			
				|  |  |         String fileName = javaName + ".java";
 | 
	
		
			
				|  |  |         String filePath = this.getClass().getProtectionDomain().getClassLoader().getResource("").getPath() + "temp/" + fileName;
 | 
	
		
			
				|  |  |         boolean succ = FileUtil.writeFile(filePath, fileInfo, "UTF-8");
 | 
	
		
			
				|  |  |         String path = "";
 | 
	
		
			
				|  |  |         if (succ) {
 | 
	
		
			
				|  |  |             fileName = GridFSUtil.uploadFile(filePath, fileName, null);
 | 
	
		
			
				|  |  |             path = ClassFileUtil.uploadFile(beanConfig.getFsUrl(), new File(filePath), fileName);
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             return null;
 | 
	
		
			
				|  |  |         }
 | 
	
	
		
			
				|  | @ -683,8 +589,6 @@ public class FlowManager {
 | 
	
		
			
				|  |  |             systemServiceFlow.setFileType(ServiceFlowConstant.JAVA);
 | 
	
		
			
				|  |  |             flowDao.saveEntity(systemServiceFlow);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String enFileName = DES.encrypt(fileName, DES.COMMON_PASSWORD);//加密文件名
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             ServiceFlow serviceFlow = new ServiceFlow();
 | 
	
		
			
				|  |  |             serviceFlow.setRouteCode(code);
 | 
	
		
			
				|  |  |             serviceFlow.setFlowType(ServiceFlowConstant.CLASS);
 | 
	
	
		
			
				|  | @ -693,18 +597,17 @@ public class FlowManager {
 | 
	
		
			
				|  |  |             handleFile.setFileType(ServiceFlowConstant.JAVA);
 | 
	
		
			
				|  |  |             handleFile.setPackageName(packageName);
 | 
	
		
			
				|  |  |             handleFile.setClassName(javaName);
 | 
	
		
			
				|  |  |             handleFile.setFilePath(enFileName);
 | 
	
		
			
				|  |  |             handleFile.setFilePath(path);
 | 
	
		
			
				|  |  |             handleFile.setUsage(ServiceFlowConstant.FLOW_TYPE_ROUTE);
 | 
	
		
			
				|  |  |             ArrayList<ServiceFlow.HandleFile> handleFiles = new ArrayList<>();
 | 
	
		
			
				|  |  |             handleFiles.add(handleFile);
 | 
	
		
			
				|  |  |             serviceFlow.setHandleFiles(handleFiles);
 | 
	
		
			
				|  |  |             serviceFlowEventService.serviceFlowAdded(serviceFlow);
 | 
	
		
			
				|  |  |             String enClassName = DES.encrypt(javaName + ".class", DES.COMMON_PASSWORD);//生成加密过的classPath
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             SystemServiceFlowClass flowClass = new SystemServiceFlowClass();
 | 
	
		
			
				|  |  |             flowClass.setPackageName(packageName);
 | 
	
		
			
				|  |  |             flowClass.setClassName(javaName);
 | 
	
		
			
				|  |  |             flowClass.setClassPath(enClassName);
 | 
	
		
			
				|  |  |             flowClass.setClassPath(path);
 | 
	
		
			
				|  |  |             flowClass.setFlowId(systemServiceFlow.getId());
 | 
	
		
			
				|  |  |             flowClass.setType(ServiceFlowConstant.FLOW_TYPE_ROUTE);
 | 
	
		
			
				|  |  |             flowClass.setIsUpdate("1");
 | 
	
	
		
			
				|  | @ -748,21 +651,17 @@ public class FlowManager {
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 String deName = DES.decrypt(process.getClassPath(), DES.COMMON_PASSWORD);//吉阿米果的文件名
 | 
	
		
			
				|  |  |                 String newFileName = genProcessorJavaFile(jobId, newFlow.getCode(), deName, process.getClassName());
 | 
	
		
			
				|  |  |                 String newPath = genProcessorJavaFile(jobId, newFlow.getCode(), process.getClassPath(), process.getClassName());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 String enClassName = DES.encrypt(newFileName.replace(".java", ".class"), DES.COMMON_PASSWORD);//生成机密过的classPath
 | 
	
		
			
				|  |  |                 SystemServiceFlowClass processClass = new SystemServiceFlowClass();
 | 
	
		
			
				|  |  |                 processClass.setPackageName(process.getPackageName());
 | 
	
		
			
				|  |  |                 processClass.setClassName(process.getClassName());
 | 
	
		
			
				|  |  |                 processClass.setClassPath(enClassName);
 | 
	
		
			
				|  |  |                 processClass.setClassPath(processClass.getClassPath());
 | 
	
		
			
				|  |  |                 processClass.setFlowId(newFlow.getId());
 | 
	
		
			
				|  |  |                 processClass.setType(ServiceFlowConstant.FLOW_TYPE_PROCESSOR);
 | 
	
		
			
				|  |  |                 processClass.setIsUpdate("1");
 | 
	
		
			
				|  |  |                 //生成新的java文件
 | 
	
		
			
				|  |  |                 String enNewFileName = DES.encrypt(newFileName, DES.COMMON_PASSWORD);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 if (newFileName != null) {
 | 
	
		
			
				|  |  |                 if (newPath != null) {
 | 
	
		
			
				|  |  |                     //发送消息
 | 
	
		
			
				|  |  |                     ServiceFlow serviceFlow = new ServiceFlow();
 | 
	
		
			
				|  |  |                     serviceFlow.setRouteCode(newFlow.getCode());
 | 
	
	
		
			
				|  | @ -772,7 +671,7 @@ public class FlowManager {
 | 
	
		
			
				|  |  |                     handleFile.setFileType(ServiceFlowConstant.JAVA);
 | 
	
		
			
				|  |  |                     handleFile.setPackageName(processClass.getPackageName());
 | 
	
		
			
				|  |  |                     handleFile.setClassName(processClass.getClassName());
 | 
	
		
			
				|  |  |                     handleFile.setFilePath(enNewFileName);
 | 
	
		
			
				|  |  |                     handleFile.setFilePath(newPath);
 | 
	
		
			
				|  |  |                     handleFile.setUsage(ServiceFlowConstant.FLOW_TYPE_PROCESSOR);
 | 
	
		
			
				|  |  |                     handleFiles.add(handleFile);
 | 
	
		
			
				|  |  |                     serviceFlow.setHandleFiles(handleFiles);
 | 
	
	
		
			
				|  | @ -790,7 +689,8 @@ public class FlowManager {
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      *  服务启动/暂停
 | 
	
		
			
				|  |  |      * 服务启动/暂停
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param flowId 流程ID
 | 
	
		
			
				|  |  |      * @param oper   服务操作;1:启动;0:暂停
 | 
	
		
			
				|  |  |      * @return
 | 
	
	
		
			
				|  | @ -819,11 +719,11 @@ public class FlowManager {
 | 
	
		
			
				|  |  |                 handleFiles.add(handleFile);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             serviceFlow.setHandleFiles(handleFiles);
 | 
	
		
			
				|  |  |             if (1 == oper){
 | 
	
		
			
				|  |  |             if (1 == oper) {
 | 
	
		
			
				|  |  |                 serviceFlowEventService.serviceFlowStarted(serviceFlow);
 | 
	
		
			
				|  |  |             }else if (0 == oper){
 | 
	
		
			
				|  |  |             } else if (0 == oper) {
 | 
	
		
			
				|  |  |                 serviceFlowEventService.serviceFlowStopped(serviceFlow);
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 return false;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             return true;
 |