| 
					
				 | 
			
			
				@ -2,14 +2,11 @@ package com.yihu.hos.system.service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.common.constants.Constants; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.config.MongoConfig; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.core.datatype.StringUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.core.encrypt.DES; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.core.file.FileUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.services.ServiceFlowEventService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.system.dao.FlowClassDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.system.dao.FlowDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.system.dao.FlowTempDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.system.dao.intf.IFlowClassDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.system.dao.intf.IFlowDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.system.dao.intf.IFlowTempDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.system.model.SystemServiceFlow; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.system.model.SystemServiceFlowClass; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.system.model.SystemServiceFlowTemp; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -17,14 +14,14 @@ import com.yihu.hos.system.service.intf.IFlowManage; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.web.framework.model.ActionResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.web.framework.model.DictItem; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.web.framework.model.Result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.web.framework.util.GridFSUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				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 com.yihu.hos.config.MongoConfig; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.core.datatype.StringUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.core.encrypt.DES; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.List; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -41,17 +38,16 @@ import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				public class FlowManager implements IFlowManage { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public static final String BEAN_ID = "flowManager"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    ServiceFlowEventService serviceFlowEventService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Resource(name = "flowDao") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private IFlowDao flowDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private FlowDao flowDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Resource(name = FlowClassDao.BEAN_ID) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private IFlowClassDao flowClassDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private FlowClassDao flowClassDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Resource(name = FlowTempDao.BEAN_ID) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private IFlowTempDao flowTempDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    ServiceFlowEventService serviceFlowEventService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private FlowTempDao flowTempDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private MongoConfig mongoConfig; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Override 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -59,6 +55,61 @@ public class FlowManager implements IFlowManage { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return flowDao.getFlowList(params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return List<ServiceFlow> 返回所有可运行流程 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception ... 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<ServiceFlow> getServiceFlowList() throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<ServiceFlow> serviceFlowList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<SystemServiceFlow> classFlowList = flowDao.getFlowList(Constants.CLASS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (SystemServiceFlow systemServiceFlow : classFlowList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ServiceFlow serviceFlow = new ServiceFlow(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            serviceFlow.setRouteCode(systemServiceFlow.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            serviceFlow.setFlowType(systemServiceFlow.getFileType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<SystemServiceFlowClass> classList = flowClassDao.getFlowClassByFlowId(systemServiceFlow.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ArrayList<ServiceFlow.HandleFile> handleFileList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (SystemServiceFlowClass flowClass : classList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ServiceFlow.HandleFile handleFile = serviceFlow.new HandleFile(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                handleFile.setFileType(Constants.CLASS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                handleFile.setClassName(flowClass.getClassName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                handleFile.setPackageName(flowClass.getPackageName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                handleFile.setFilePath(flowClass.getClassPath()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                handleFile.setUsage(flowClass.getType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                handleFileList.add(handleFile); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            serviceFlow.setHandleFiles(handleFileList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            serviceFlowList.add(serviceFlow); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<SystemServiceFlow> javaFlowList = flowDao.getFlowList(Constants.JAVA); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (SystemServiceFlow systemServiceFlow : javaFlowList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ServiceFlow serviceFlow = new ServiceFlow(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            serviceFlow.setRouteCode(systemServiceFlow.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<SystemServiceFlowTemp> tempList = flowTempDao.getFlowTempByFlowId(systemServiceFlow.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ArrayList<ServiceFlow.HandleFile> handleFileList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (SystemServiceFlowTemp flowTemp : tempList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ServiceFlow.HandleFile handleFile = serviceFlow.new HandleFile(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                handleFile.setFileType(Constants.JAVA); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                handleFile.setClassName(flowTemp.getClassName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                handleFile.setPackageName(flowTemp.getPackageName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                handleFile.setFilePath(flowTemp.getClassPath()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                handleFile.setUsage(flowTemp.getType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                handleFileList.add(handleFile); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            serviceFlow.setHandleFiles(handleFileList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            serviceFlowList.add(serviceFlow); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return serviceFlowList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public SystemServiceFlow getFlowById(Integer id) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return flowDao.getEntity(SystemServiceFlow.class, id); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -69,17 +120,17 @@ public class FlowManager implements IFlowManage { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        obj.setCreateDate(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        flowDao.saveEntity(obj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (Constants.CLASS.equals(obj.getFileType())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (Constants.CLASS.equals(obj.getFileType())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<SystemServiceFlowClass> flowClassList = obj.getFlowClassArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (SystemServiceFlowClass flowClass:flowClassList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (SystemServiceFlowClass flowClass : flowClassList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                flowClass.setFlowId(obj.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                flowDao.saveEntity(flowClass); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //发送消息到MQ对列 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sendUpdateMessage(obj.getCode(), flowClass, Constants.FLOW_OP_ADD); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else if (Constants.JAVA.equals(obj.getFileType())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } else if (Constants.JAVA.equals(obj.getFileType())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<SystemServiceFlowTemp> flowTempList = obj.getFlowTempArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (SystemServiceFlowTemp flowTemp:flowTempList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (SystemServiceFlowTemp flowTemp : flowTempList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                flowTemp.setFlowId(obj.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                flowDao.saveEntity(flowTemp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -99,21 +150,21 @@ public class FlowManager implements IFlowManage { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        flow.setFileType(obj.getFileType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (Constants.JAVA.equals(flow.getFileType())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (Constants.JAVA.equals(flow.getFileType())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<SystemServiceFlowTemp> flowTempList = obj.getFlowTempArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            boolean succ = flowTempDao.deleteFlowTempByFlowId(obj.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (succ){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (SystemServiceFlowTemp flowTemp:flowTempList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (succ) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (SystemServiceFlowTemp flowTemp : flowTempList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    flowTempDao.saveEntity(flowTemp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else if (Constants.CLASS.equals(flow.getFileType())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } else if (Constants.CLASS.equals(flow.getFileType())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Integer> classIds = flowClassDao.getFlowClassIds(obj.getId());//原flowclass集合 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<SystemServiceFlowClass> flowClassList = obj.getFlowClassArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            SystemServiceFlowClass flowClassRoute = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String oper = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (SystemServiceFlowClass flowClass:flowClassList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (flowClass.getId()!=null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (SystemServiceFlowClass flowClass : flowClassList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (flowClass.getId() != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    classIds.remove(flowClass.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    flowClassDao.updateEntity(flowClass); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (!flowClass.getType().equals(Constants.FLOW_TYPE_ROUTE)) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -122,7 +173,7 @@ public class FlowManager implements IFlowManage { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        flowClassRoute = flowClass; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        oper = Constants.FLOW_OP_UPDATE; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (!flowClass.getType().equals(Constants.FLOW_TYPE_ROUTE)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        flowClassDao.saveEntity(flowClass); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        sendUpdateMessage(flow.getCode(), flowClass, Constants.FLOW_OP_ADD); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -133,8 +184,8 @@ public class FlowManager implements IFlowManage { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //删除判断 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (classIds !=null && classIds.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (Integer id:classIds){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (classIds != null && classIds.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (Integer id : classIds) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    SystemServiceFlowClass flowClass = getFlowClassById(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    flowClassDao.deleteEntity(flowClass); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (!flowClass.getType().equals(Constants.FLOW_TYPE_ROUTE)) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -154,7 +205,6 @@ public class FlowManager implements IFlowManage { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        flowDao.updateEntity(flow); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return Result.success("更新成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -162,25 +212,25 @@ public class FlowManager implements IFlowManage { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Result deleteFlow(Integer id) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        SystemServiceFlow flow = flowDao.getEntity(SystemServiceFlow.class, id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<SystemServiceFlowClass> flowClassList = flowClassDao.getFlowClassByFlowId(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        SystemServiceFlowClass flowClassRoute = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String oper = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (SystemServiceFlowClass flowClass:flowClassList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            flowClassDao.deleteEntity(flowClass); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //发送消息到MQ对列 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (!flowClass.getType().equals(Constants.FLOW_TYPE_ROUTE)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sendUpdateMessage(flow.getCode(), flowClass, Constants.FLOW_OP_DELETE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                flowClassRoute = flowClass; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                flowClassRoute.setIsUpdate("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                oper = Constants.FLOW_OP_DELETE; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (flowClassRoute != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sendUpdateMessage(flow.getCode(), flowClassRoute, oper); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<SystemServiceFlowClass> processorFlowClassList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (Constants.JAVA.equals(flow.getFileType())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            flowTempDao.deleteFlowTempByFlowId(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (SystemServiceFlowClass flowClass:flowClassList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                flowClassDao.deleteEntity(flowClass); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                flowClass.setIsUpdate("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //发送消息到MQ对列 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (flowClass.getType().equals(Constants.FLOW_TYPE_ROUTE)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sendUpdateMessage(flow.getCode(), flowClass, Constants.FLOW_OP_DELETE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    processorFlowClassList.add(flowClass); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (SystemServiceFlowClass serviceFlowClass : processorFlowClassList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sendUpdateMessage(flow.getCode(), serviceFlowClass, Constants.FLOW_OP_DELETE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        flowDao.deleteEntity(flow); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return Result.success("删除成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -216,7 +266,7 @@ public class FlowManager implements IFlowManage { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public boolean deleteFlowClassByFlowId(Integer flowId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        boolean succ =flowClassDao.deleteFlowClassByFlowId(flowId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        boolean succ = flowClassDao.deleteFlowClassByFlowId(flowId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return succ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -283,7 +333,7 @@ public class FlowManager implements IFlowManage { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //processor 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            switch (operate){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case "add" : serviceFlowEventService.processorAdded(flowCode, flowClass.getPackageName(), flowClass.getClassName(), flowClass.getClassPath()); break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case "delete" : serviceFlowEventService.processorDataDeleted(flowCode, flowClass.getPackageName(), flowClass.getClassName(), flowClass.getClassPath()); break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case "delete" : serviceFlowEventService.processorDataDeleted(flowCode, flowClass.getPackageName(), flowClass.getClassName()); break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case "update" : serviceFlowEventService.processorDataChanged(flowCode, flowClass.getPackageName(), flowClass.getClassName(), flowClass.getClassPath()); break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                default : break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -297,13 +347,12 @@ public class FlowManager implements IFlowManage { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public  ActionResult getFlowList(String type) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public ActionResult getFlowList(String type) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<SystemServiceFlow> flowList = flowDao.getFlowList(type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        ActionResult re = new ActionResult(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(flowList!=null&&flowList.size()>0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (flowList != null && flowList.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<DictItem> dictList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for(SystemServiceFlow item:flowList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (SystemServiceFlow item : flowList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                DictItem dict = new DictItem(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                dict.setCode(item.getId().toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                dict.setValue(item.getName()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -341,6 +390,141 @@ public class FlowManager implements IFlowManage { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Integer addRouteFile(Integer tempId,Integer flowId, String newCron ,Long timestamp) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        ObjectMapper objectMapper = new ObjectMapper(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<SystemServiceFlowTemp> flowTempRouters = flowTempDao.getFlowTemps(tempId, Constants.FLOW_TYPE_ROUTE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        SystemServiceFlow newFlow = getFlowById(flowId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //route模板文件记录是否存在。不存在就返回。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (!flowTempRouters.isEmpty()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String,String> params = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            SystemServiceFlowTemp flowTemp =flowTempRouters.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            StringBuilder basePath = new StringBuilder();; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (flowTemp.getPackageName()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String packagePath[] = flowTemp.getPackageName().split("\\."); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (int i=0;i<packagePath.length;i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    basePath.append(packagePath[i]).append("/"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //新增processor记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String newClassName = flowTemp.getClassName()+timestamp; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String newRoutePath =null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                params = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                params.put("routeId", newFlow.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                params.put("type",Constants.FLOW_TYPE_ROUTE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                params.put("filePath", flowTemp.getClassPath()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                params.put("packageName", basePath.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                params.put("oldClassName", flowTemp.getClassName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                params.put("newClassName",newClassName);//原文件名加当前时间戳 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                params.put("newCron",newCron); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                HTTPResponse response  = HttpClientKit.post(genCamelUrl, params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (response.getStatusCode()==200 ){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Map<String,Object> body = objectMapper.readValue(response.getBody(),Map.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    boolean succ = (boolean) body.get("successFlg"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (succ){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        newRoutePath = body.get("message").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    System.out.println(response.getBody()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    SystemServiceFlowClass newFlowClass = new SystemServiceFlowClass(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    newFlowClass.setPackageName(flowTemp.getPackageName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    newFlowClass.setClassName(newClassName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    newFlowClass.setClassPath(newRoutePath); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    newFlowClass.setFlowId(newFlow.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    newFlowClass.setType(Constants.FLOW_TYPE_ROUTE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    flowClassDao.saveEntity(newFlowClass); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    newFlowClass.setIsUpdate("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sendUpdateMessage(newFlow.getCode(), newFlowClass, Constants.FLOW_OP_ADD); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return newFlow.getId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Integer addProcessorFile(Integer flowId, String newCron,Long timestamp) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        ObjectMapper objectMapper = new ObjectMapper(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<SystemServiceFlowTemp> flowClassRouters = flowTempDao.getFlowTemps(flowId, Constants.FLOW_TYPE_ROUTE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<SystemServiceFlowTemp> flowClassProces = flowTempDao.getFlowTemps(flowId, Constants.FLOW_TYPE_PROCESSOR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        SystemServiceFlow oldFlow = getFlowById(flowId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //route模板文件记录是否存在。不存在就返回。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (!flowClassRouters.isEmpty()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String,String> params = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            SystemServiceFlowTemp flowTemp =flowClassRouters.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            StringBuilder basePath = new StringBuilder();; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (flowTemp.getPackageName()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String packagePath[] = flowTemp.getPackageName().split("\\."); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (int i=0;i<packagePath.length;i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    basePath.append(packagePath[i]).append("/"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //成功生成文件后,添加flow和flowclass记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //生成新流程 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            SystemServiceFlow newFlow = new SystemServiceFlow(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            newFlow.setName(oldFlow.getName()+timestamp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            newFlow.setCode(oldFlow.getCode()+timestamp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            newFlow.setChart(oldFlow.getChart()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            newFlow.setValid(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            newFlow.setCreateDate(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            newFlow.setFileType(Constants.CLASS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            flowDao.saveEntity(newFlow); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //新增processor记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (SystemServiceFlowTemp process:flowClassProces){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                String newProcessName = process.getClassName()+timestamp; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String newProcessPath = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                StringBuilder proPath =  new StringBuilder( );; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (process.getPackageName()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String packagePath[] = process.getPackageName().split("\\."); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    for (int i=0;i<packagePath.length;i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        proPath.append(packagePath[i]).append("/"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                params = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                params.put("routeId", newFlow.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                params.put("type",Constants.FLOW_TYPE_PROCESSOR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                params.put("filePath", process.getClassPath()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                params.put("packageName", proPath.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                params.put("newClassName",process.getClassName());//原文件名加当前时间戳 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                params.put("oldClassName", process.getClassName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                params.put("newCron",newCron); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                HTTPResponse response = HttpClientKit.post(genCamelUrl, params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (response.getStatusCode()==200 ){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Map<String,Object> body = objectMapper.readValue(response.getBody(),Map.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    boolean succ = (boolean) body.get("successFlg"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (succ){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        newProcessPath = body.get("message").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        System.out.println(response.getBody()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        SystemServiceFlowClass processClass = new SystemServiceFlowClass(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        processClass.setPackageName(process.getPackageName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        processClass.setClassName(process.getClassName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        processClass.setClassPath(newProcessPath); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        processClass.setFlowId(newFlow.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        processClass.setType(Constants.FLOW_TYPE_PROCESSOR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        flowClassDao.saveEntity(processClass); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        processClass.setIsUpdate("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        sendUpdateMessage(newFlow.getCode(), processClass, Constants.FLOW_OP_ADD); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return newFlow.getId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 修改任务,修改camel相关文件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param flowId 流程ID 
			 |