Browse Source

rest 采集上传接口初步修改

huangzhiyong 8 years ago
parent
commit
d1df6333e2

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

@ -8,10 +8,10 @@ import com.mongodb.client.model.Filters;
import com.yihu.hos.core.constants.CoreConstant;
import com.yihu.hos.core.datatype.ClassFileUtil;
import com.yihu.hos.core.datatype.StringUtil;
import com.yihu.hos.core.encrypt.DES;
import com.yihu.hos.web.framework.constant.ServiceFlowConstant;
import com.yihu.hos.web.framework.model.Result;
import com.yihu.hos.web.framework.model.bo.ServiceFlow;
import org.apache.camel.Route;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.bson.Document;
@ -24,6 +24,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
/**
 * 对于Broker来说,Camel路由的加载只有这样的几个过程。
@ -65,19 +66,39 @@ public class ESBCamelService {
            ServiceFlow serviceFlow = serviceFlowValid.getServiceFlow();
            ArrayList<ServiceFlow.HandleFile> handleFiles = serviceFlowValid.getHandleFiles();
            for (ServiceFlow.HandleFile handleFile : handleFiles) {
                boolean created;
                if ("java".equals(handleFile.getFileType())) {
                    logger.debug("generate class file...");
                    created = this.generateClassFile(handleFile);
                } else {
                    logger.debug("create class file");
                    created = this.createClassFile(handleFile);
            if ("java".equals(serviceFlowValid.getServiceFlow().getFlowType())) {
                final boolean[] created = new boolean[1];
                //先生成和编译 processor
                handleFiles.stream().filter(handleFile -> ServiceFlowConstant.FLOW_TYPE_PROCESSOR.equals(handleFile.getUsage())).forEach(handleFile -> {
                    try {
                        if (this.generateClassFile(handleFile)) created[0] = true;
                        else created[0] = false;
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                });
                if (!created[0]) {
                    return Result.error("服务流程启动失败!");
                }
                if (!created) {
                    logger.debug("create class file failed");
                    return Result.error("服务流程增加失败!");
                handleFiles.stream().filter(handleFile -> ServiceFlowConstant.FLOW_TYPE_ROUTE.equals(handleFile.getUsage())).forEach(handleFile -> {
                    try {
                        if (this.generateClassFile(handleFile)) created[0] = true;
                        else created[0] = false;
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                });
                if (!created[0]) {
                    return Result.error("服务流程启动失败!");
                }
            } else {
                for (ServiceFlow.HandleFile handleFile : handleFiles) {
                    boolean created = this.createClassFile(handleFile);
                    if (!created) {
                        return Result.error("服务流程启动失败!");
                    }
                }
            }
@ -103,25 +124,51 @@ public class ESBCamelService {
        try {
            ServiceFlowValid serviceFlowValid = new ServiceFlowValid(msg).invoke();
            if (serviceFlowValid.is()) return Result.error("必要的入参数据不正确,请检查!");
            List<Route> routes = SystemCamelContext.getContext().getRoutes();
            ServiceFlow serviceFlow = serviceFlowValid.getServiceFlow();
            SystemCamelContext.stopRouter(serviceFlow.getRouteCode());
            boolean b = SystemCamelContext.removeRouter(serviceFlow.getRouteCode());
            boolean created;
            ArrayList<ServiceFlow.HandleFile> handleFiles = serviceFlowValid.getHandleFiles();
            for (ServiceFlow.HandleFile handleFile : handleFiles) {
                if ("java".equals(handleFile.getFileType())) {
                    created = this.generateClassFile(handleFile);
                } else {
                    created = this.createClassFile(handleFile);
            if ("java".equals(serviceFlowValid.getServiceFlow().getFlowType())) {
                final boolean[] created = new boolean[1];
                //先生成和编译 processor
                handleFiles.stream().filter(handleFile -> ServiceFlowConstant.FLOW_TYPE_PROCESSOR.equals(handleFile.getUsage())).forEach(handleFile -> {
                    try {
                        if (this.generateClassFile(handleFile)) created[0] = true;
                        else created[0] = false;
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                });
                if (!created[0]) {
                    return Result.error("服务流程启动失败!");
                }
                handleFiles.stream().filter(handleFile -> ServiceFlowConstant.FLOW_TYPE_ROUTE.equals(handleFile.getUsage())).forEach(handleFile -> {
                    try {
                        if (this.generateClassFile(handleFile)) created[0] = true;
                        else created[0] = false;
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                });
                if (!created[0]) {
                    return Result.error("服务流程启动失败!");
                }
                if (!created) {
                    return Result.error("服务流程变更增加失败!");
            } else {
                for (ServiceFlow.HandleFile handleFile : handleFiles) {
                    boolean created = this.createClassFile(handleFile);
                    if (!created) {
                        return Result.error("服务流程启动失败!");
                    }
                }
            }
            this.addRouter(serviceFlowValid.getHandleFiles());
//            SystemCamelContext.startRouter(serviceFlow.getRouteCode());
            SystemCamelContext.startRouter(serviceFlow.getRouteCode());
            return Result.error("服务流程变更增加成功!");
        } catch (Exception e) {
@ -188,21 +235,47 @@ public class ESBCamelService {
            ServiceFlow serviceFlow = serviceFlowValid.getServiceFlow();
            String routeCode = serviceFlow.getRouteCode();
            ArrayList<ServiceFlow.HandleFile> handleFiles = serviceFlowValid.getHandleFiles();
            for (ServiceFlow.HandleFile handleFile : handleFiles) {
                boolean created;
                if ("java".equals(handleFile.getFileType())) {
                    created = this.generateClassFile(handleFile);
                } else {
                    created = this.createClassFile(handleFile);
            if ("java".equals(serviceFlowValid.getServiceFlow().getFlowType())) {
                final boolean[] created = new boolean[1];
                //先生成和编译 processor
                handleFiles.stream().filter(handleFile -> ServiceFlowConstant.FLOW_TYPE_PROCESSOR.equals(handleFile.getUsage())).forEach(handleFile -> {
                    try {
                        if (this.generateClassFile(handleFile)) created[0] = true;
                        else created[0] = false;
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                });
                if (!created[0]) {
                    return Result.error("服务流程启动失败!");
                }
                if (!created) {
                handleFiles.stream().filter(handleFile -> ServiceFlowConstant.FLOW_TYPE_ROUTE.equals(handleFile.getUsage())).forEach(handleFile -> {
                    try {
                        if (this.generateClassFile(handleFile)) created[0] = true;
                        else created[0] = false;
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                });
                if (!created[0]) {
                    return Result.error("服务流程启动失败!");
                }
            } else {
                for (ServiceFlow.HandleFile handleFile : handleFiles) {
                    boolean created = this.createClassFile(handleFile);
                    if (!created) {
                        return Result.error("服务流程启动失败!");
                    }
                }
            }
            this.addRouter(handleFiles);
            this.addRouter(handleFiles);
            SystemCamelContext.startRouter(serviceFlow.getRouteCode());
            List<Route> routes = SystemCamelContext.getContext().getRoutes();
            return Result.success("服务流程启动成功!");
        } catch (Exception e) {

+ 2 - 2
hos-camel2/src/main/java/camel/collect/route/CollectQuartzRoute.java

@ -6,7 +6,7 @@ import org.apache.camel.builder.RouteBuilder;
public class CollectQuartzRoute extends RouteBuilder {
    public void configure() throws Exception {
        from("quartz://myGroup/myTimerName?cron=0/3 * * * * ?").routeId("routeId").process(new CollectProcessor0())
                .setHeader(Exchange.HTTP_METHOD, constant("POST")).to("http4://localhost:8088/camel.crawler/camel.collect").to("stream:out");
        from("quartz://myGroup/collectTimer?cron=0/3 * * * * ?").routeId("routeId").process(new CollectProcessor0())
                .setHeader(Exchange.HTTP_METHOD, constant("POST")).to("http4://localhost:8088/crawler/collect").to("stream:out");
    }
}

+ 2 - 2
hos-camel2/src/main/java/camel/crawler/route/CrawlerQuartzRoute.java

@ -9,7 +9,7 @@ import org.apache.camel.builder.RouteBuilder;
 */
public class CrawlerQuartzRoute extends RouteBuilder {
    public void configure() throws Exception {
        from("quartz://myGroup/myTimerName?cron=0/3 * * * * ?").routeId("routeId").process(new DefaultHttpProcessor("{\"jobId\": \"sfsfsgafcas\"}"))
                .setHeader(Exchange.HTTP_METHOD, constant("POST")).to("http4://localhost:8088/camel.crawler/patientList").to("stream:out");
        from("quartz://myGroup/crawlerTimer?cron=0/3 * * * * ?").routeId("routeId").process(new DefaultHttpProcessor("{\"jobId\": \"jobId\"}"))
                .setHeader(Exchange.HTTP_METHOD, constant("POST")).to("http4://localhost:8088/crawler/patientList").to("stream:out");
    }
}

+ 6 - 16
hos-core/src/main/java/com/yihu/hos/core/datatype/ClassFileUtil.java

@ -220,12 +220,7 @@ public class ClassFileUtil {
    public static String uploadFile(String uploadUrl, File file, String fileName) {
        try {
            boolean succ = upload(uploadUrl, file, fileName);//文件内容
            if (succ) {
                return fileName;
            } else {
                return null;
            }
            return upload(uploadUrl, file);
        } catch (Exception e) {
            return null;
        }
@ -279,7 +274,7 @@ public class ClassFileUtil {
     * @param file 文件名
     * @return
     */
    public static boolean upload(String url, File file, String fileName) {
    public static String upload(String url, File file, String fileName) {
        CloseableHttpClient httpClient = HttpClients.createDefault();
        HttpPost httpPost = new HttpPost(url);
        CloseableHttpResponse response = null;
@ -296,17 +291,12 @@ public class ClassFileUtil {
            response.setHeader("Content-Type", "application/json;charset=UTF-8");
            entity = response.getEntity();
            int code = response.getStatusLine().getStatusCode();
            Map<String, Object> responMap = parseRespon(entity);
            if (code == 200) {
                boolean succ = (boolean) responMap.get("successFlg");
                if (!succ) {
                    System.out.println("请求成功,上传失败!message:" + responMap.get("message").toString());
                    ;
                }
                return succ;
                System.out.println("请求成功,上传成功!entry:" +  response.getEntity().getContent().toString());;
                return response.getEntity().getContent().toString();
            } else {
                System.out.println("上传请求失败,status:" + code);
                return false;
                return null;
            }
        } catch (IOException e) {
            e.printStackTrace();
@ -319,7 +309,7 @@ public class ClassFileUtil {
            }
        }
        return false;
        return null;
    }
    /**

+ 57 - 0
hos-rest/src/main/java/com/yihu/hos/rest/common/configuration/MongoConfig.java

@ -0,0 +1,57 @@
package com.yihu.hos.rest.common.configuration;
import com.mongodb.Mongo;
import com.mongodb.MongoClient;
import com.mongodb.MongoCredential;
import com.mongodb.ServerAddress;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import static java.util.Collections.singletonList;
/**
 * @created Airhead 2016/7/27.
 */
@Configuration
public class MongoConfig {
    @Value("${spring.data.mongodb.host}")
    private String host;
    @Value("${spring.data.mongodb.port}")
    private int port;
    @Value("${spring.data.mongodb.username}")
    private String username;
    @Value("${spring.data.mongodb.password}")
    private String password;
    @Value("${spring.data.mongodb.authenticationDatabase}")
    private String authenticationDatabase;
    @Bean
    public MongoClient mongoClient() throws Exception {
        return new MongoClient(singletonList(new ServerAddress(host, port)),
                singletonList(MongoCredential.createCredential(username, authenticationDatabase, password.toCharArray())));
    }
    @Bean
    public Mongo mongo() throws Exception {
        return new MongoClient(singletonList(new ServerAddress(host, port)),
                singletonList(MongoCredential.createCredential(username, authenticationDatabase, password.toCharArray())));
    }
    public String getHost() {
        return host;
    }
    public int getPort() {
        return port;
    }
    public String getUsername() {
        return username;
    }
    public String getPassword() {
        return password;
    }
}

+ 1 - 0
hos-rest/src/main/java/com/yihu/hos/rest/controllers/CrawlerController.java

@ -134,6 +134,7 @@ public class CrawlerController {
        try {
            return crawlerManager.dataCrawlerByJobId(jobId);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("采集上传失败");
        }
    }

+ 8 - 0
hos-rest/src/main/resources/application.yml

@ -11,6 +11,14 @@ local:
---
spring:
  profiles: dev
  data:
    mongodb:
      host: 172.19.103.57
      port: 27017
      username: esb
      password: esb
      authenticationDatabase: admin
      database: runtime
qlc:
  rpc:
    ip: 172.18.20.21

+ 1 - 1
hos-rest/src/main/resources/config/http.properties

@ -1,5 +1,5 @@
httpUrl = https://192.168.131.120:443/api/v1.0
httpUrl = https://172.19.103.221:10000/api/v1.0
#  http://172.19.103.73:1443/api/v1.0
#\uFFFD\uFFFDhttps://192.168.131.15:4432/api/v1.0
  #https://172.19.103.73:443/api/v1.0

+ 1 - 1
hos-rest/src/main/resources/spring/applicationContext.xml

@ -24,7 +24,7 @@
    <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://192.168.1.220:8066/hos1?useUnicode=true&amp;characterEncoding=UTF-8"/>
        <property name="url" value="jdbc:mysql://172.19.103.57:8066/hos2?useUnicode=true&amp;characterEncoding=UTF-8"/>
        <property name="username" value="hos"/>
        <property name="password" value="123456"/>
        <property name="initialSize" value="1"/>

+ 54 - 37
src/main/java/com/yihu/hos/system/service/FlowManager.java

@ -3,7 +3,6 @@ package com.yihu.hos.system.service;
import com.yihu.hos.common.constants.ContextAttributes;
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;
import com.yihu.hos.services.ServiceFlowEventService;
@ -19,6 +18,7 @@ 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;
@ -51,6 +51,8 @@ public class FlowManager {
    private FlowClassDao flowClassDao;
    @Resource(name = FlowTempDao.BEAN_ID)
    private FlowTempDao flowTempDao;
    @Value("${hos.filesystem.url}")
    private String fsUrl;
    /**
     * 生成Route流程的java文件
@ -61,11 +63,13 @@ public class FlowManager {
     * @param newCron      cron表达式
     * @return
     */
    public String genRouteJavaFile(String routeId, String className, String tempFilePath, String newCron) {
    public String genRouteJavaFile(String jobId,String routeId, String className, String tempFilePath, String newCron) {
        try {
            //TODO 临时文件夹
            String newFileName = className + routeId + ".java";
            String newFilePath = "/temp/" + newFileName;
            byte[] content = ClassFileUtil.down(tempFilePath);
            String newFilePath = "D:/temp/" + newFileName;
            String uploadUrl = fsUrl + "/" + tempFilePath;
            byte[] content = ClassFileUtil.down(uploadUrl);
            if (content == null) {
                return null;
            }
@ -82,9 +86,11 @@ public class FlowManager {
            }
            //修改routeId;模板规则 routeId("routeId")
            text = text.replace("routeId(\"routeId\")", "routeId(\"" + routeId + "\")");
            //修改jobId;模板规则 "{\"jobId\": \"jobId\"}"
            text = text.replace("{\\\"jobId\\\": \\\"jobId\\\"}", "{\\\"jobId\\\": \\\""+ jobId +"\\\"}");
            boolean succ = FileUtil.writeFile(newFilePath, text, "UTF-8");
            if (succ) {
                newFileName = ClassFileUtil.uploadFile(beanConfig.getFsUrl(), new File(newFilePath + newFileName), newFileName);
                newFileName = ClassFileUtil.uploadFile(beanConfig.getFsUrl(), new File(newFilePath), newFileName);
            } else {
                return null;
            }
@ -109,9 +115,10 @@ public class FlowManager {
    public String genProcessorJavaFile(String jobId, String routeId, String tempFilePath, String className) {
        try {
            String newFileName = className + routeId + ".java";
            String newFilePath = "/temp/" + className;
            byte[] content = ClassFileUtil.down(tempFilePath);
            //TODO 临时文件夹设置
            String newFilePath = "D:/temp/" + newFileName;
            String uploadUrl = fsUrl + "/" + tempFilePath;
            byte[] content = ClassFileUtil.down(uploadUrl);
            if (content == null) {
                return null;
            }
@ -121,7 +128,7 @@ public class FlowManager {
            boolean succ = FileUtil.writeFile(newFilePath, text, "UTF-8");
            //TODO 上传到GridFS
            if (succ) {
                newFileName = ClassFileUtil.uploadFile(beanConfig.getFsUrl(), new File(newFilePath + newFileName), newFileName);
                newFileName = ClassFileUtil.uploadFile(beanConfig.getFsUrl(), new File(newFilePath), newFileName);
                return newFileName;
            }
        } catch (Exception e) {
@ -437,16 +444,17 @@ public class FlowManager {
    public Integer genCamelFile(String jobId, Integer flowTempId, String newCron) throws Exception {
        Long timestamp = System.currentTimeMillis();
        //发送生成processor文件的消息
        Integer newFlowId = sendAddProcessor(jobId, flowTempId, timestamp);
        Integer newFlowId = sendAddProcessor(jobId, flowTempId, timestamp, newCron);
        if (newFlowId != null) {
            //发送生成route文件的消息
            newFlowId = sendAddRoute(flowTempId, newFlowId, newCron);
            if (newFlowId != null) {
                return newFlowId;
            } else {
                System.out.println("生成route文件失败");
                return null;
            }
//            newFlowId = sendAddRoute(flowTempId, newFlowId, newCron);
//            if (newFlowId != null) {
//                return newFlowId;
//            } else {
//                System.out.println("生成route文件失败");
//                return null;
//            }
            return newFlowId;
        } else {
            System.out.println("生成processor文件失败");
            return null;
@ -496,7 +504,7 @@ public class FlowManager {
            }
            //生成新的route文件
            String newPath = genRouteJavaFile(flow.getCode(), flowTemp.getClassName(), flowTemp.getClassPath(), newCron);
            String newPath = genRouteJavaFile(jobId,flow.getCode(), flowTemp.getClassName(), flowTemp.getClassPath(), newCron);
            serviceFlow.setRouteCode(flow.getCode());
            serviceFlow.setFlowType(ServiceFlowConstant.JAVA);
            ServiceFlow.HandleFile handleFile = new ServiceFlow.HandleFile();
@ -532,7 +540,7 @@ public class FlowManager {
            }
            //新增processor记录
            String newPath = genRouteJavaFile(newFlow.getCode(), flowTemp.getClassName(), flowTemp.getClassPath(), newCron);
            String newPath = genRouteJavaFile("" ,newFlow.getCode(), flowTemp.getClassName(), flowTemp.getClassPath(), newCron);
            SystemServiceFlowClass newFlowClass = new SystemServiceFlowClass();
            newFlowClass.setPackageName(flowTemp.getPackageName());
            newFlowClass.setClassName(flowTemp.getClassName() + newFlow.getCode());
@ -620,9 +628,9 @@ public class FlowManager {
        }
    }
    public Integer sendAddProcessor(String jobId, Integer flowId, Long timestamp) throws Exception {
    public Integer sendAddProcessor(String jobId, Integer flowId, Long timestamp, String newCron) throws Exception {
        List<SystemServiceFlowTemp> flowTempRouters = flowTempDao.getFlowTemps(flowId, ServiceFlowConstant.FLOW_TYPE_ROUTE);
        List<SystemServiceFlowTemp> flowTempProces = flowTempDao.getFlowTemps(flowId, ServiceFlowConstant.FLOW_TYPE_PROCESSOR);
        List<SystemServiceFlowTemp> flowTempProces = flowTempDao.getFlowTempByFlowId(flowId);
        SystemServiceFlow oldFlow = getFlowById(flowId);
        //route模板文件记录是否存在。不存在就返回。
@ -640,9 +648,11 @@ public class FlowManager {
            ArrayList<ServiceFlow.HandleFile> handleFiles = new ArrayList<>();
            //新增processor记录
            ServiceFlow serviceFlow = new ServiceFlow();
            serviceFlow.setRouteCode(newFlow.getCode());
            serviceFlow.setFlowType(ServiceFlowConstant.JAVA);
            for (SystemServiceFlowTemp process : flowTempProces) {
                StringBuilder proPath = new StringBuilder();
                if (process.getPackageName() != null) {
                    //生成“/"分割的包名
                    String packagePath[] = process.getPackageName().split("\\.");
@ -651,37 +661,44 @@ public class FlowManager {
                    }
                }
                String newPath = genProcessorJavaFile(jobId, newFlow.getCode(), process.getClassPath(), process.getClassName());
                SystemServiceFlowClass processClass = new SystemServiceFlowClass();
                processClass.setPackageName(process.getPackageName());
                processClass.setClassName(process.getClassName());
                processClass.setClassPath(processClass.getClassPath());
                processClass.setFlowId(newFlow.getId());
                processClass.setType(ServiceFlowConstant.FLOW_TYPE_PROCESSOR);
                processClass.setType(process.getType());
                processClass.setIsUpdate("1");
                if (newPath != 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.JAVA);
                    handleFile.setPackageName(processClass.getPackageName());
                //发送消息
                ServiceFlow.HandleFile handleFile = new ServiceFlow.HandleFile();
                handleFile.setRouteCode(newFlow.getCode());
                handleFile.setFileType(ServiceFlowConstant.JAVA);
                handleFile.setPackageName(processClass.getPackageName());
                handleFile.setUsage(processClass.getType());
                String newPath = null;
                if (ServiceFlowConstant.FLOW_TYPE_PROCESSOR.equals(process.getType())) {
                    newPath = genProcessorJavaFile(jobId, newFlow.getCode(), process.getClassPath(), process.getClassName());
                    handleFile.setClassName(processClass.getClassName());
                } else {
                    newPath = genRouteJavaFile(jobId,newFlow.getCode(), process.getClassName(), process.getClassPath(), newCron);
                    handleFile.setClassName(processClass.getClassName() + newFlow.getCode());
                }
                if (newPath != null) {
                    handleFile.setFilePath(newPath);
                    handleFile.setUsage(ServiceFlowConstant.FLOW_TYPE_PROCESSOR);
                    handleFiles.add(handleFile);
                    serviceFlow.setHandleFiles(handleFiles);
                    serviceFlowEventService.serviceFlowModifiedAdd(serviceFlow);
                    processClass.setClassPath(newPath);
                    flowClassDao.saveEntity(processClass);
                } else {
                    System.out.println("生成processor的java文件过程出错");
                    return null;
                }
            }
            serviceFlow.setHandleFiles(handleFiles);
            serviceFlowEventService.serviceFlowModifiedAdd(serviceFlow);
            return newFlow.getId();
        }

+ 4 - 4
src/main/webapp/WEB-INF/ehr/jsp/datacollect/editorJob.jsp

@ -59,16 +59,16 @@
            </div>
        </div>
        <div class="m-form-group">
            <label>任务实现方式:</label>
            <label>任务类型:</label>
            <div class="m-form-control">
                <div class="u-checkbox-wrap m-form-control">
                    <input type="radio" name="jobContentType" value="0">微服务
                    <input type="radio" name="jobContentType" value="1" checked>类
                    <input type="radio" name="jobContentType" value="0" checked>采集
                    <input type="radio" name="jobContentType" value="1" >上传
                </div>
            </div>
        </div>
        <div class="m-form-group">
            <label id="lbJobContent">类名:</label>
            <label id="lbJobContent">关联模板流程:</label>
            <div class="m-form-control">
                <input type="text" name="flowTempId" id="jobContentClass">
                <input type="hidden" name="flowId" id="flowId" >

+ 41 - 71
src/main/webapp/WEB-INF/ehr/jsp/datacollect/editorJobJs.jsp

@ -8,8 +8,8 @@
        flowTempId:0,
        flowArrays:[],
        beforeServeTime:false,
        archiveUpload:"com.yihu.ehr.job.service.ArchiveUploadJob",
        crawlerFlowUpload:"com.yihu.ehr.job.service.CrawlerFlowUploadJob",
        archiveUpload:"0",
        crawlerFlowUpload:"1",
        $form:$("#div_form"),
        $listPlan:null,//适配方案列表
        $listDataset:null,//数据集列表
@ -38,45 +38,22 @@
                },
                onStepChanged:function(b,to,from){
                    if(to==1){
                        if($('#jobContentClass').ligerComboBox("getValue")==me.crawlerFlowUpload){//类名为任务编排上传类
                            me.needReloadCrawlerDst = true;
                            me.$listPlan.setOptions({ url: '${contextRoot}/crawler/savedSchemeList'});
                            me.$listPlan.loadData(true);
                        }else{
                            me.$listPlan._setData($.parseJSON('${schemeList}'));
                            me.$listPlan.reRender();
                        }
                        me.$listPlan._setData($.parseJSON('${schemeList}'));
                        me.$listPlan.reRender();
                    }
                    else if(to==2){
                        //接口为档案上传时,数据集不可编辑
                        if($('#jobContentClass').ligerComboBox("getValue")==me.archiveUpload)
                        {
                            me.$listDataset.set("columns", [
                                { display: '数据集代码', name: 'jobDatasetCode' },
                                { display: '数据集名称', name: 'jobDatasetName' }
                            ]);
                        }else if($('#jobContentClass').ligerComboBox("getValue")==me.crawlerFlowUpload){//类名为任务编排上传类,数据集只能查看
                            $("#listDataset").hide();
                            $("#crawlerListDataset").show();
                            var selected = me.$listPlan.getSelectedRow();
                            if(selected!=null && me.needReloadCrawlerDst) {
                                me.$crawlerFlowDataset.setOptions({parms: [{ name: 'version', value:selected.id}],checkbox:false});
                                me.$crawlerFlowDataset.loadData(true);
                            }
                            return false;
                        }
                        else{
                            me.$listDataset.set("columns", [
                                { display: '数据集代码', name: 'jobDatasetCode' },
                                { display: '数据集名称', name: 'jobDatasetName' },
                                { display: '执行条件', name: 'jobDatasetCondition', render: function (row,rowIndex) {
                                    var html = '<div class="m-inline-buttons" style="width:55px;">';
                                    html += "<a href=\"javascript:void(0)\" onclick=\"javascript:editorJob.setCondition("+rowIndex+");\">设置筛选</a>";
                                    return html;
                                } }
                            ]);
                        }
                        me.$listDataset.set("columns", [
                            { display: '数据集代码', name: 'jobDatasetCode' },
                            { display: '数据集名称', name: 'jobDatasetName' },
                            { display: '执行条件', name: 'jobDatasetCondition', render: function (row,rowIndex) {
                                var html = '<div class="m-inline-buttons" style="width:55px;">';
                                html += "<a href=\"javascript:void(0)\" onclick=\"javascript:editorJob.setCondition("+rowIndex+");\">设置筛选</a>";
                                return html;
                            } }
                        ]);
                        $("#listDataset").show();
                        $("#crawlerListDataset").hide();
                        //刷新数据集
@ -99,7 +76,7 @@
                    {
                        me.setAchiveUploadType();
                    }else{
                        liger.get("jobContentClass").selectValue(flowTempId);
                        liger.get("jobContentClass").selectValue(me.flowTempId);
                    }
                },
@ -172,7 +149,7 @@
                isChecked:function(row){
                    if($("#txtSchemeVersion").val()==row.version)
                    {
                        if(me.needReloadCrawlerDst && $('#jobContentClass').ligerComboBox("getValue")==me.crawlerFlowUpload){//类名为任务编排上传类
                        if(me.needReloadCrawlerDst && $('input[name="jobContentType"]').ligerComboBox("getValue")==me.crawlerFlowUpload){//类名为任务编排上传类
                            me.$crawlerFlowDataset.setOptions({parms: [{ name: 'version', value:row.id}],checkbox:false});
                            me.$crawlerFlowDataset.loadData(true);
                            me.needReloadCrawlerDst = false;
@ -390,17 +367,18 @@
                $('input[name="jobType"]').ligerRadio('setValue',model.jobType);
                //非档案上传时隐藏
                if($('#jobContentClass').ligerComboBox("getValue")==me.archiveUpload || $('#jobContentClass').ligerComboBox("getValue")==me.crawlerFlowUpload) {
                    $("#divDelayTime").hide();
                    $("#divRepeat").hide();
                if($('input[name="jobContentType"]').ligerComboBox("getValue")==me.crawlerFlowUpload) {
                    $("#divDelayTime").show();
                    $("#divRepeat").show();
                }
                if(model.jobType=="0")//单次执行
                {
                    $("#divTimeInterval").hide();
                    //接口为档案上传时
                    if($('#jobContentClass').ligerComboBox("getValue")==me.archiveUpload  || $('#jobContentClass').ligerComboBox("getValue")==me.crawlerFlowUpload) {
                        $("#divDelayTime").hide();
                    if( $('input[name="jobContentType"]').ligerComboBox("getValue")==me.crawlerFlowUpload) {
                        $("#divDelayTime").show();
                        $("#divRepeat").show();
                        $("#repeatStartTime").ligerDateEditor("setValue",model.repeatStartTime);
                        $("#repeatEndTime").ligerDateEditor("setValue",model.repeatEndTime);
@ -409,9 +387,9 @@
                else{
                    $("#divTimeInterval").show();
                    //接口为档案上传时
                    if($('#jobContentClass').ligerComboBox("getValue")==me.archiveUpload  || $('#jobContentClass').ligerComboBox("getValue")==me.crawlerFlowUpload) {
                    if( $('input[name="jobContentType"]').ligerComboBox("getValue")==me.crawlerFlowUpload) {
                        $("#divDelayTime").show();
                        $("#divRepeat").hide();
//                        $("#divRepeat").hide();
                        $("#repeatStartTime").ligerDateEditor("setValue",model.repeatStartTime);
                        $("#txtDelayTime").val(model.delayTime);
                    }
@ -435,9 +413,9 @@
            var content = $("#jobContentClass").ligerComboBox("getValue");
            if($('#jobContentClass').ligerComboBox("getValue")==me.crawlerFlowUpload) {//任务编排上传类,不需要选择数据集,直接设值
                $("#txtJobDataset").val(JSON.stringify(me.$crawlerFlowDataset.getData()));
            }
//            if($('input[name="jobContentType"]').ligerRadio("getValue")==me.crawlerFlowUpload) {//任务编排上传类,不需要选择数据集,直接设值
//                $("#txtJobDataset").val(JSON.stringify(me.$crawlerFlowDataset.getData()));
//            }
            var model ={
                id:$('#txtId').val(),
@ -469,7 +447,8 @@
            {
                jobType = $('input[name="jobType"]').ligerRadio("getValue");
            }
            if($('#jobContentClass').ligerComboBox("getValue")!=me.archiveUpload && $('#jobContentClass').ligerComboBox("getValue")!=me.crawlerFlowUpload) {
            if( $('input[name="jobContentType"]').ligerComboBox("getValue")!=me.crawlerFlowUpload) {
                $("#divDelayTime").hide();
                $("#divRepeatStart").hide();
                $("#divRepeatEnd").hide();
@ -482,8 +461,8 @@
            {
                $("#divTimeInterval").hide();
                //接口为档案上传时
                if($('#jobContentClass').ligerComboBox("getValue")==me.archiveUpload || $('#jobContentClass').ligerComboBox("getValue")==me.crawlerFlowUpload) {
                    $("#divDelayTime").hide();
                if($('input[name="jobContentType"]').ligerComboBox("getValue")==me.crawlerFlowUpload) {
                    $("#divDelayTime").show();
                    $("#divRepeatStart").show();
                    $("#divRepeatEnd").show();
                    $("#txtDelayTime").val("");
@ -492,29 +471,20 @@
            else{
                $("#divTimeInterval").show();
                //接口为档案上传时
                if($('#jobContentClass').ligerComboBox("getValue")==me.archiveUpload  || $('#jobContentClass').ligerComboBox("getValue")==me.crawlerFlowUpload) {
                if( $('input[name="jobContentType"]').ligerComboBox("getValue")==me.crawlerFlowUpload) {
                    $("#divDelayTime").show();
                    $("#repeatEndTime").ligerDateEditor("setValue","");
                    $("#divRepeatStart").show();
                    $("#divRepeatEnd").hide();
                    $("#divRepeatEnd").show();
                }
            }
        },
        //设置任务执行类型
        setJobContentType:function(jobContentType,jobContent){
            if(jobContentType == "0")
            {
                $("#lbJobContent").html("微服务地址:")
                $("#txtJobContent").show().val(jobContent);
                $("#jobContentClass").parent().parent().hide();
                $("#jobContentClass").ligerComboBox("setValue","");
            }
            else{
                $("#lbJobContent").html("类名:")
                $("#txtJobContent").val("").hide();
                $("#jobContentClass").parent().parent().show();
                $("#jobContentClass").ligerComboBox("setValue",jobContent);
            }
            $("#lbJobContent").html("关联流程模板:")
            $("#txtJobContent").val("").hide();
            $("#jobContentClass").parent().parent().show();
            $("#jobContentClass").ligerComboBox("setValue",jobContent);
        },
        //设置数据集条件
        setCondition:function(rowIndex)
@ -632,7 +602,7 @@
                    }
                    //档案上传接口值校验
                    if($('#jobContentClass').ligerComboBox("getValue")==me.archiveUpload)
                    if($('input[name="jobContentType"]').ligerComboBox("getValue")==me.archiveUpload)
                    {
                        if(data.jobType == "0") {
                            if($("#repeatStartTime").ligerDateEditor("getValue")==""&&$("#repeatEndTime").ligerDateEditor("getValue")=="")
@ -673,7 +643,7 @@
                }
                case 3:
                {
                    if($('#jobContentClass').ligerComboBox("getValue")!=me.crawlerFlowUpload) {//不是任务编排上传类
                    if($('input[name="jobContentType"]').ligerComboBox("getValue")!=me.crawlerFlowUpload) {//不是任务编排上传类
                        var dataset = $("#txtJobDataset").val();
                        //数据集不能为空
                        if(dataset == null || dataset =="[]")
@ -688,7 +658,7 @@
                        }
                        //判断是否设置轮询字段和字段类型   档案上传不校验 @modify by cyj
                        if($('#jobContentClass').ligerComboBox("getValue")!=me.archiveUpload) {
                        if($('input[name="jobContentType"]').ligerComboBox("getValue")!=me.archiveUpload) {
                            var selected = me.$listDataset.getSelectedRows();
                            for(var i=0;i<selected.length;i++)
                            {