airhead 8 роки тому
батько
коміт
508f67fa3e

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

@ -53,8 +53,8 @@ public class ESBCamelService {
    private String configuration = "runtime";
    @Autowired
    private ObjectMapper objectMapper;
    @Value("${hos.esb.rest-url}")
    private String centerUrl;
    @Value("${hos.filesystem.url}")
    private String fsUrl;
    @Value("${spring.data.mongodb.gridFsDatabase}")
    private String dbName;
@ -241,7 +241,7 @@ public class ESBCamelService {
//        boolean read = GridFSUtil.readFile(db, outputStream, fileName);
        //从中心下载
        String downUrl = centerUrl + "/tenant/down/" + handleFile.getFilePath();
        String downUrl = fsUrl + "/tenant/down/" + handleFile.getFilePath();
        String sourcePath =  ClassFileUtil.downFile(downUrl, resource, handleFile.getPackageName(), handleFile.getClassName(), ClassFileUtil.CLASS_FILE);
        if (sourcePath==null) {
@ -268,7 +268,7 @@ public class ESBCamelService {
//        }
        //从中心下载java文件
        String downUrl = centerUrl + "/tenant/down/" + handleFile.getFilePath();
        String downUrl = fsUrl + "/tenant/down/" + handleFile.getFilePath();
        String sourcePath =  ClassFileUtil.downFile(downUrl, resource, handleFile.getPackageName(), handleFile.getClassName(), ClassFileUtil.JAVA_FILE);
        if (sourcePath == null) {
@ -285,7 +285,7 @@ public class ESBCamelService {
//            TODO 上传到本地mongodb和中心mongodb
            String fileName = DES.decrypt(handleFile.getFilePath(), DES.COMMON_PASSWORD).replaceAll(ClassFileUtil.JAVA_FILE,ClassFileUtil.CLASS_FILE);
            String enFileName = DES.encrypt(fileName, DES.COMMON_PASSWORD);
            String uploadUrl = centerUrl + "/tenant/upload/" + enFileName;
            String uploadUrl = fsUrl + "/tenant/upload/" + enFileName;
            ClassFileUtil.uploadFile(uploadUrl,new File(classPath),fileName);
        }
        return succ;
@ -305,14 +305,14 @@ public class ESBCamelService {
        ClassFileUtil.deleteClassfile(javaPath);
        //TODO 从中心删除
        //删除class文件
        String delJavaUrl = centerUrl + "/tenant/delFile/" + handleFile.getFilePath();
        String delJavaUrl = fsUrl + "/tenant/delFile/" + handleFile.getFilePath();
        ClassFileUtil.deleteFile(delJavaUrl);
        //删除java文件
        String classFilePath = DES.decrypt( handleFile.getFilePath(),DES.COMMON_PASSWORD);
        String javaFilePath = classFilePath.replace(ClassFileUtil.CLASS_FILE,ClassFileUtil.JAVA_FILE);
        String enJavaPath = DES.encrypt(javaFilePath,DES.COMMON_PASSWORD);
        String delClassUrl = centerUrl + "/tenant/delFile/" + enJavaPath;
        String delClassUrl = fsUrl + "/tenant/delFile/" + enJavaPath;
         ClassFileUtil.deleteFile(delClassUrl);
        // 完成
        logger.info("===================" + handleFile.getPackageName() + CoreConstant.DOT + handleFile.getClassName() + ".class 删除过程结束");

+ 4 - 4
hos-broker/src/main/resources/application.yml

@ -34,8 +34,8 @@ spring:
    ip: localhost
    port: 8066
hos:
  esb:
    rest-url: http://localhost:8080/esb
  filesystem:
    url: 127.0.0.1:9010/dfs/file
  arbiter:
    enable: true
    url: http://localhost:10135
@ -74,8 +74,8 @@ spring:
    ip: localhost
    port: 8066
hos:
  esb:
    rest-url: http://172.19.103.67:8080/esb
  filesystem:
    url: 127.0.0.1:9010/dfs/file
  arbiter:
    enable: true
    url: http://172.19.103.67:10135

+ 5 - 0
hos-parent/pom.xml

@ -325,6 +325,11 @@
                <artifactId>camel-restlet</artifactId>
                <version>${camel-version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-servlet</artifactId>
                <version>${camel-version}</version>
            </dependency>
            <!-- camel end -->
            <!-- ActiveMQ -->

+ 52 - 0
hos-web-framework/src/main/java/com/yihu/hos/web/framework/util/DFSUtil.java

@ -0,0 +1,52 @@
package com.yihu.hos.web.framework.util;
import com.yihu.hos.core.http.HTTPResponse;
import com.yihu.hos.core.http.HttpClientKit;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
 * MongoDB GridFS 操作类
 *
 * @author HZY
 * @vsrsion 1.0
 * Created at 2016/7/21.
 */
@Component
public class DFSUtil {
    @Value("")
    private String dfsUrl;
    /**
     * 读取文件内容
     *
     * @param fileName 文件名
     * @return
     */
    public String readFileContent(String fileName) {
        HTTPResponse httpResponse = HttpClientKit.get("dfsUrl/file" + fileName);
        if (httpResponse.getStatusCode() == 200) {
            return httpResponse.getBody();
        }
        return null;
    }
    /**
     * 上传文件至Mongodb by GridFS
     *
     * @param filePath     上传的文件路径
     * @param saveFileName 保存到mongo的文件名
     * @param params       自定义保存字段
     */
    public String uploadFile(String filePath, String saveFileName, Map<String, Object> params) {
//        HTTPResponse httpResponse = HttpClientKit.post("dfsUrl/file" + fileName);
//        if (httpResponse.getStatusCode() == 200) {
//            return httpResponse.getBody();
//        }
//
        return null;
    }
}

+ 1 - 26
src/main/java/com/yihu/hos/ESBApplication.java

@ -1,27 +1,13 @@
package com.yihu.hos;
import com.yihu.hos.config.BeanConfig;
import com.yihu.hos.interceptor.WebMvcInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.mongodb.gridfs.GridFsOperations;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@SpringBootApplication
public class ESBApplication extends WebMvcConfigurerAdapter  implements CommandLineRunner {
    private BeanConfig configuration;
    @Autowired
    private GridFsOperations operations;
    @Autowired
    public void setConfiguration(BeanConfig configuration) {
        this.configuration = configuration;
    }
public class ESBApplication extends WebMvcConfigurerAdapter {
    public static void main(String[] args) throws Exception {
        SpringApplication application = new SpringApplication(ESBApplication.class);
        application.run(args);
@ -30,17 +16,6 @@ public class ESBApplication extends WebMvcConfigurerAdapter  implements CommandL
    // 增加拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        GridFSUtil.gridFsOperations = operations;
        registry.addInterceptor(new WebMvcInterceptor());
    }
    @Override
    public void run(String... strings) throws Exception {
//        MqServerConfig config = new MqServerConfig();
//        config.serverPort = configuration.getZbusPort();
//        config.storePath = configuration.getZbusStore();
//        final MqServer server = new MqServer(config);
//        server.start();
//        System.out.println("zbus 启动成功!");
    }
}

+ 10 - 44
src/main/java/com/yihu/hos/config/BeanConfig.java

@ -19,11 +19,8 @@ import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import org.springframework.web.servlet.i18n.CookieLocaleResolver;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import org.zbus.broker.ZbusBroker;
import org.zbus.mq.server.MqServer;
import org.zbus.mq.server.MqServerConfig;
import javax.sql.DataSource;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Locale;
import java.util.Properties;
@ -42,24 +39,17 @@ public class BeanConfig {
    @Autowired
    private DataSource dataSource;
    @Value("${hos.zbus.port}")
    private Integer zbusPort;
    @Value("${hos.zbus.store}")
    private String zbusStore;
    @Value("${hos.zbus.url}")
    private String zbusUrl;
    private ZbusBroker zbusBroker;
    @Value("${hos.filesystem.url}")
    private String fsUrl;
    @Bean
    public ZbusBroker getZbusBroker() {
        try {
            MqServerConfig config = new MqServerConfig();
            config.serverPort = this.getZbusPort();
            config.storePath = this.getZbusStore();
            final MqServer server = new MqServer(config);
            server.start();
            System.out.println("zbus 启动成功!");
            zbusBroker = new ZbusBroker("127.0.0.1:" + zbusPort);
            zbusBroker = new ZbusBroker(zbusUrl);
            return zbusBroker;
        } catch (Exception e) {
            e.printStackTrace();
@ -67,12 +57,8 @@ public class BeanConfig {
        return null;
    }
    public Integer getZbusPort() {
        return zbusPort;
    }
    public String getZbusStore() {
        return zbusStore;
    public String getZbusUrl() {
        return zbusUrl;
    }
    @Bean
@ -102,29 +88,6 @@ public class BeanConfig {
        return hibernateTransactionManager;
    }
//    @Bean( destroyMethod = "close")
//    public BasicDataSource dataSource() {
//        if (StringUtils.isEmpty(datasourcePropertyResolver.get("url").toString())) {
//            System.out.println("Your database connection pool configuration is incorrect!" +
//                    " Please check your Spring profile, current profiles are:"+
//                    Arrays.toString(environment.getActiveProfiles()));
//            throw new ApplicationContextException(
//                    "Database connection pool is not configured correctly");
//        }
//        BasicDataSource dataSource = new BasicDataSource();
//        dataSource.setUrl(datasourcePropertyResolver.get("url").toString());
//        dataSource.setUsername(datasourcePropertyResolver.get("username").toString());
//        dataSource.setPassword(datasourcePropertyResolver.get("password").toString());
//        dataSource.setInitialSize((Integer)datasourcePropertyResolver.get("initial-size"));
//        dataSource.setMaxTotal((Integer)datasourcePropertyResolver.get("max-total"));
//        dataSource.setMinIdle((Integer)datasourcePropertyResolver.get("min-idle"));
//        dataSource.setMaxIdle((Integer)datasourcePropertyResolver.get("max-idle"));
//        dataSource.setValidationQuery(datasourcePropertyResolver.get("validation-query").toString());
//        dataSource.setRemoveAbandonedTimeout(55);
//        dataSource.setTestOnBorrow((boolean)datasourcePropertyResolver.get("test-on-borrow"));
//        return dataSource;
//    }
    //文经上传
    @Bean
    public CommonsMultipartResolver multipartResolver() {
@ -189,4 +152,7 @@ public class BeanConfig {
        super.finalize();
    }
    public String getFsUrl() {
        return fsUrl;
    }
}

+ 2 - 2
src/main/java/com/yihu/hos/remoteManage/controller/RemoteShellController.java

@ -1,8 +1,8 @@
package com.yihu.hos.remoteManage.controller;
package com.yihu.hos.remotemanage.controller;
import com.yihu.hos.common.constants.ContextAttributes;
import com.yihu.hos.interceptor.LocalContext;
import com.yihu.hos.remoteManage.service.RemoteShellService;
import com.yihu.hos.remotemanage.service.RemoteShellService;
import com.yihu.hos.web.framework.model.Result;
import com.yihu.hos.web.framework.util.controller.BaseController;
import io.swagger.annotations.ApiParam;

+ 1 - 1
src/main/java/com/yihu/hos/remoteManage/service/RemoteShellService.java

@ -1,4 +1,4 @@
package com.yihu.hos.remoteManage.service;
package com.yihu.hos.remotemanage.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.hos.common.constants.ContextAttributes;

+ 0 - 33
src/main/java/com/yihu/hos/system/controller/AppController.java

@ -316,37 +316,4 @@ public class AppController extends BaseController {
        }
    }
    /* ========================================== 上传相关(后面可抽出) ================================================= */
    /**
     * 文件上传
     * @param file
     * @return
     */
    @RequestMapping(value = "/upload", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public Object upload(@RequestParam MultipartFile file) {
        try {
            CommonsMultipartFile transferFile = (CommonsMultipartFile)file;
            return appManager.uploadFile(transferFile);
        } catch (Exception e) {
            return Result.error("上传失败!");
        }
    }
    /**
     * 图片查看
     * @return
     */
    @RequestMapping(value = "/read/{fileName}", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public Object read(HttpServletResponse response, @PathVariable("fileName")  String fileName) {
        // response.setContentType("image/*");
        try {
            OutputStream os = response.getOutputStream();
            return appManager.readFile(os, fileName);
        } catch (Exception e) {
            return Result.error("读取失败!");
        }
    }
}

+ 0 - 43
src/main/java/com/yihu/hos/system/controller/FlowController.java

@ -121,17 +121,6 @@ public class FlowController extends BaseController {
            ObjectMapper objectMapper = new ObjectMapper();
            SystemServiceFlow flow = objectMapper.readValue(flowClass,SystemServiceFlow.class);
//            SystemServiceFlow obj = new SystemServiceFlow();
//            BeanUtils.populate(obj, request.getParameterMap());
//
//            List<SystemServiceFlowClass> flowClass = new ArrayList<>();
//            BeanUtils.populate(flowClass, request.getParameterMap());
//            obj.setFlowClassArray(flowClass);
//
//            List<SystemServiceFlowTemp> flowTemps = new ArrayList<>();
//            BeanUtils.populate(flowTemps, request.getParameterMap());
//            obj.setFlowTempArray(flowTemps);
            return flowManage.addFlow(flow);
        } catch (Exception ex) {
            ex.printStackTrace();
@ -180,38 +169,6 @@ public class FlowController extends BaseController {
    }
    /**
     * 文件上传
     * @param file
     * @return
     */
    @RequestMapping(value = "/upload", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public Object upload(@RequestParam MultipartFile file) {
        //TODO 文件地址设置
        try {
            CommonsMultipartFile transferFile = (CommonsMultipartFile)file;
            return flowManage.uploadFile(transferFile);
        } catch (Exception e) {
            return Result.error("上传失败");
        }
    }
    /**
     * 图片查看
     * @return
     */
    @RequestMapping(value = "/read/{fileName}", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public Object read(HttpServletResponse response, @PathVariable("fileName")  String fileName) {
        try {
            OutputStream os = response.getOutputStream();
            return flowManage.readFile(os, fileName);
        } catch (Exception e) {
            return Result.error("读取失败!");
        }
    }
    @RequestMapping(value = "/flowTempList", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public Result flowTempList(String type) {

+ 0 - 27
src/main/java/com/yihu/hos/system/service/AppManager.java

@ -156,33 +156,6 @@ public class AppManager {
        return Result.success("删除成功");
    }
    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("读取失败");
    }
    private void sendMsg(String event, SystemServiceEndpoint endpoint) {
        if (zbusBroker == null) {
            logger.error("zbusBroker is null.");

+ 33 - 114
src/main/java/com/yihu/hos/system/service/FlowManager.java

@ -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;
@ -21,11 +21,14 @@ import com.yihu.hos.web.framework.model.bo.ServiceFlow;
import org.springframework.beans.factory.annotation.Autowired;
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;
/**
 * 系统流程管理业务类
@ -36,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,36 +52,6 @@ public class FlowManager {
    @Resource(name = FlowTempDao.BEAN_ID)
    private FlowTempDao flowTempDao;
    @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文件
     *
@ -87,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("\""));
@ -104,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;
            }
@ -128,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) {
@ -223,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("保存成功");
@ -274,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;
                    }
                }
@ -310,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);
@ -419,33 +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) {
        String dbName = "upload";
        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消息-更新路由
     *
@ -541,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);
@ -579,9 +500,6 @@ public class FlowManager {
            }
            String deName = DES.decrypt(flowTemp.getClassPath(), DES.COMMON_PASSWORD);//吉阿米果的文件名
            //生成新的route文件
            String newFileName = genRouteJavaFile(flow.getCode(), flowTemp.getClassName(), deName, newCron);
@ -667,7 +585,7 @@ public class FlowManager {
        String filePath = this.getClass().getProtectionDomain().getClassLoader().getResource("").getPath() + "temp/" + fileName;
        boolean succ = FileUtil.writeFile(filePath, fileInfo, "UTF-8");
        if (succ) {
            fileName = GridFSUtil.uploadFile(filePath, fileName, null);
//            fileName = GridFSUtil.uploadFile(filePath, fileName, null);
        } else {
            return null;
        }
@ -788,7 +706,8 @@ public class FlowManager {
    }
    /**
     *  服务启动/暂停
     * 服务启动/暂停
     *
     * @param flowId 流程ID
     * @param oper   服务操作;1:启动;0:暂停
     * @return
@ -817,11 +736,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;

+ 3 - 4
src/main/resources/application.yml

@ -55,8 +55,9 @@ spring:
    proxy-target-class: true
hos:
  zbus:
    port: 15555
    store: ./store
    url: 127.0.0.1:9020
  filesystem:
    url: 127.0.0.1:9010/dfs/file
  mysql:
    filePath: e://learn.sql   #租户基础表 sql文件位置
service-gateway:
@ -107,8 +108,6 @@ spring:
hos:
  zbus:
    url: 172.17.110.202:15555
    port: 15555
    store: ./store
  mysql:
    filePath: /usr/local/esb/esb.sql   #租户基础表 sql文件位置
service-gateway:

+ 0 - 7
src/test/java/com/yihu/hos/HosAdminApplicationTests.java

@ -15,13 +15,6 @@ import java.io.IOException;
public class HosAdminApplicationTests {
	@Test
	public void contextLoads() throws IOException {
		String newName = "text"+System.currentTimeMillis()+".java";
		String newFilePath = "/upload/"+newName;
		String  content = GridFSUtil.readFileContent( "955569af-43fb-422f-bded-d88f99cad1f9QuartzRoute.java");
		boolean succ = FileUtil.writeFile(newFilePath, content, "UTF-8");
		newName = GridFSUtil.uploadFile( newFilePath, newName,null);
		System.out.println(content);
	}
}