Quellcode durchsuchen

Merge branch 'master' of http://192.168.1.220:10080/esb/esb

# Conflicts:
#	src/main/java/com/yihu/hos/system/service/FlowManager.java
Airhead vor 8 Jahren
Ursprung
Commit
947b3a56d7
1 geänderte Dateien mit 40 neuen und 11 gelöschten Zeilen
  1. 40 11
      src/main/java/com/yihu/hos/system/service/FlowManager.java

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

@ -54,6 +54,33 @@ public class FlowManager implements IFlowManage {
    @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.readFile("upload", tempFilePath);
            boolean succ = FileUtil.writeFile(newFilePath, text, "UTF-8");
            //TODO 上传到GridFS
            if (succ) {
                newFileName = GridFSUtil.uploadFile("upload", newFilePath, newFileName);
                return newFileName;
            }
        } catch (Exception e) {
            System.out.println("生成processor的java文件操作出错");
            e.printStackTrace();
        }
        return null;
    }
    /**
     * 生成Route流程的java文件
     *
@ -98,17 +125,19 @@ public class FlowManager implements IFlowManage {
    /**
     * 生成processor的java文件
     *
     * @param jobId        任务Id
     * @param routeId      流程Code
     * @param tempFilePath 模板文件名
     * @param className    模板类名
     * @return
     */
    public static String genProcessorJavaFile(String routeId, String tempFilePath, String className) {
    public static String genProcessorJavaFile(String jobId, String routeId, String tempFilePath, String className) {
        try {
            String newFileName = className + routeId + ".java";
            String newFilePath = "/temp/" + className;
            String text = GridFSUtil.readFile("upload", tempFilePath);
            text = text.replace("jobId=jobId", "jobId=" + jobId);
            boolean succ = FileUtil.writeFile(newFilePath, text, "UTF-8");
            //TODO 上传到GridFS
            if (succ) {
@ -182,6 +211,8 @@ public class FlowManager implements IFlowManage {
        return serviceFlowList;
    }
        /* ===================================  flowClass 部分================================================*/
    @Override
    public SystemServiceFlow getFlowById(Integer id) throws Exception {
        return flowDao.getEntity(SystemServiceFlow.class, id);
@ -211,8 +242,6 @@ public class FlowManager implements IFlowManage {
        return Result.success("保存成功");
    }
        /* ===================================  flowClass 部分================================================*/
    @Transactional
    public Result updateFlow(SystemServiceFlow obj) throws Exception {
        SystemServiceFlow flow = flowDao.getEntity(SystemServiceFlow.class, obj.getId());
@ -451,11 +480,11 @@ public class FlowManager implements IFlowManage {
     * @param newCron
     * @throws Exception
     */
    public Integer genCamelFile(String jobId,Integer flowTempId, String newCron) throws Exception {
    public Integer genCamelFile(String jobId, Integer flowTempId, String newCron) throws Exception {
        Long timestamp = System.currentTimeMillis();
        //发送生成processor文件的消息
        Integer newFlowId = sendAddProcessor(jobId,flowTempId, timestamp);
        if (newFlowId != null){
        Integer newFlowId = sendAddProcessor(jobId, flowTempId, timestamp);
        if (newFlowId != null) {
            //发送生成route文件的消息
            newFlowId = sendAddRoute(flowTempId, newFlowId, newCron);
            if (newFlowId != null) {
@ -565,9 +594,9 @@ public class FlowManager implements IFlowManage {
        return null;
    }
    public Integer sendAddProcessor(String jobId,Integer flowId, Long timestamp) throws Exception {
        List<SystemServiceFlowTemp> flowTempRouters = flowTempDao.getFlowTemps(flowId, Constants.FLOW_TYPE_ROUTE);
        List<SystemServiceFlowTemp> flowTempProces = flowTempDao.getFlowTemps(flowId, Constants.FLOW_TYPE_PROCESSOR);
    public Integer sendAddProcessor(String jobId, Integer flowId, Long timestamp) throws Exception {
        List<SystemServiceFlowTemp> flowTempRouters = flowTempDao.getFlowTemps(flowId, ServiceFlowConstant.FLOW_TYPE_ROUTE);
        List<SystemServiceFlowTemp> flowTempProces = flowTempDao.getFlowTemps(flowId, ServiceFlowConstant.FLOW_TYPE_PROCESSOR);
        SystemServiceFlow oldFlow = getFlowById(flowId);
        //route模板文件记录是否存在。不存在就返回。
@ -606,8 +635,8 @@ public class FlowManager implements IFlowManage {
                processClass.setType(ServiceFlowConstant.FLOW_TYPE_PROCESSOR);
                processClass.setIsUpdate("1");
                //生成新的java文件
                String newFileName = genProcessorJavaFile(jobId,newFlow.getCode(),deName,processClass.getClassName());
                if (newFileName!=null){
                String newFileName = genProcessorJavaFile(jobId, newFlow.getCode(), deName, processClass.getClassName());
                if (newFileName != null) {
                    //发送消息
                    ServiceFlow serviceFlow = new ServiceFlow();
                    serviceFlow.setRouteCode(newFlow.getCode());