|
@ -150,7 +150,7 @@ public class FlowManager {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Result getFlowList(Map<String, Object> params) throws Exception {
|
|
|
return flowDao.getFlowList(params);
|
|
|
}
|
|
@ -190,7 +190,7 @@ public class FlowManager {
|
|
|
|
|
|
/* =================================== flowClass 部分================================================*/
|
|
|
|
|
|
|
|
|
|
|
|
public SystemServiceFlow getFlowById(Integer id) throws Exception {
|
|
|
return flowDao.getEntity(SystemServiceFlow.class, id);
|
|
|
}
|
|
@ -322,8 +322,10 @@ public class FlowManager {
|
|
|
@Transactional
|
|
|
public Result deleteFlow(Integer id) throws Exception {
|
|
|
SystemServiceFlow flow = flowDao.getEntity(SystemServiceFlow.class, id);
|
|
|
if (flow == null){ return Result.error("删除流程失败");}
|
|
|
ArrayList<ServiceFlow.HandleFile> handleFiles =new ArrayList<>();
|
|
|
if (flow == null) {
|
|
|
return Result.error("删除流程失败");
|
|
|
}
|
|
|
ArrayList<ServiceFlow.HandleFile> handleFiles = new ArrayList<>();
|
|
|
List<SystemServiceFlowClass> flowClassList = flowClassDao.getFlowClassByFlowId(id);
|
|
|
if (ServiceFlowConstant.JAVA.equals(flow.getFileType())) {
|
|
|
flowTempDao.deleteFlowTempByFlowId(id);
|
|
@ -353,12 +355,12 @@ public class FlowManager {
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Result getFlowClassList(Map<String, Object> params) throws Exception {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<SystemServiceFlowClass> getFlowClassByFlowId(Integer flowId) throws Exception {
|
|
|
return flowClassDao.getFlowClassByFlowId(flowId);
|
|
|
}
|
|
@ -384,13 +386,13 @@ public class FlowManager {
|
|
|
return succ;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<SystemServiceFlowTemp> getFlowTempByFlowId(Integer id) throws Exception {
|
|
|
return flowTempDao.getFlowTempByFlowId(id);
|
|
|
}
|
|
|
|
|
|
//TODO
|
|
|
|
|
|
|
|
|
public boolean genFlewByflowTempId(Integer flowTempId) throws Exception {
|
|
|
SystemServiceFlow flow = getFlowById(flowTempId);
|
|
|
//生成新的route类
|
|
@ -399,7 +401,7 @@ public class FlowManager {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Result uploadFile(CommonsMultipartFile file) {
|
|
|
String dbName = "upload";
|
|
|
String newFileName;
|
|
@ -414,7 +416,7 @@ public class FlowManager {
|
|
|
return Result.error("上传失败");
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Result readFile(OutputStream os, String fileName) {
|
|
|
String dbName = "upload";
|
|
|
try {
|
|
@ -469,7 +471,7 @@ public class FlowManager {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
|
|
|
|
|
|
public ActionResult getFlowList(String type) throws Exception {
|
|
|
List<SystemServiceFlow> flowList = flowDao.getFlowList(type);
|
|
|
ActionResult re = new ActionResult();
|
|
@ -521,7 +523,7 @@ public class FlowManager {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
|
|
|
|
|
|
public Integer updateCamelFile(Integer flowTempId, Integer flowId, String newCron) throws Exception {
|
|
|
/* 修改route文件无需重新生成flowClass记录,文件名根据className+routeId 生成;*/
|
|
|
List<SystemServiceFlowTemp> flowTempRouters = flowTempDao.getFlowTemps(flowTempId, ServiceFlowConstant.FLOW_TYPE_ROUTE);
|
|
@ -542,7 +544,7 @@ public class FlowManager {
|
|
|
|
|
|
//生成新的route文件
|
|
|
String newFileName = genRouteJavaFile(flow.getCode(), flowTemp.getClassName(), deName, newCron);
|
|
|
String enNewFileName = DES.encrypt(newFileName,DES.COMMON_PASSWORD);
|
|
|
String enNewFileName = DES.encrypt(newFileName, DES.COMMON_PASSWORD);
|
|
|
ServiceFlow serviceFlow = new ServiceFlow();
|
|
|
serviceFlow.setRouteCode(flow.getCode());
|
|
|
serviceFlow.setFlowType(ServiceFlowConstant.JAVA);
|
|
@ -550,10 +552,10 @@ public class FlowManager {
|
|
|
handleFile.setRouteCode(flow.getCode());
|
|
|
handleFile.setFileType(ServiceFlowConstant.JAVA);
|
|
|
handleFile.setPackageName(basePath.toString());
|
|
|
handleFile.setClassName(flowTemp.getClassName()+flow.getCode());
|
|
|
handleFile.setClassName(flowTemp.getClassName() + flow.getCode());
|
|
|
handleFile.setFilePath(enNewFileName);
|
|
|
handleFile.setUsage(ServiceFlowConstant.FLOW_TYPE_ROUTE);
|
|
|
ArrayList<ServiceFlow.HandleFile> handleFiles =new ArrayList<>();
|
|
|
ArrayList<ServiceFlow.HandleFile> handleFiles = new ArrayList<>();
|
|
|
handleFiles.add(handleFile);
|
|
|
serviceFlow.setHandleFiles(handleFiles);
|
|
|
serviceFlowEventService.serviceFlowModifiedAdd(serviceFlow);
|
|
@ -592,7 +594,7 @@ public class FlowManager {
|
|
|
newFlowClass.setIsUpdate("1");
|
|
|
//生成新的route文件
|
|
|
String newFileName = genRouteJavaFile(newFlow.getCode(), flowTemp.getClassName(), deName, newCron);
|
|
|
String enNewFileName = DES.encrypt(newFileName,DES.COMMON_PASSWORD);
|
|
|
String enNewFileName = DES.encrypt(newFileName, DES.COMMON_PASSWORD);
|
|
|
|
|
|
if (newFileName != null) {
|
|
|
ServiceFlow serviceFlow = new ServiceFlow();
|
|
@ -602,10 +604,10 @@ public class FlowManager {
|
|
|
handleFile.setRouteCode(newFlow.getCode());
|
|
|
handleFile.setFileType(ServiceFlowConstant.JAVA);
|
|
|
handleFile.setPackageName(flowTemp.getPackageName());
|
|
|
handleFile.setClassName(flowTemp.getClassName()+newFlow.getCode());
|
|
|
handleFile.setClassName(flowTemp.getClassName() + newFlow.getCode());
|
|
|
handleFile.setFilePath(enNewFileName);
|
|
|
handleFile.setUsage(ServiceFlowConstant.FLOW_TYPE_ROUTE);
|
|
|
ArrayList<ServiceFlow.HandleFile> handleFiles =new ArrayList<>();
|
|
|
ArrayList<ServiceFlow.HandleFile> handleFiles = new ArrayList<>();
|
|
|
handleFiles.add(handleFile);
|
|
|
serviceFlow.setHandleFiles(handleFiles);
|
|
|
serviceFlowEventService.serviceFlowModifiedAdd(serviceFlow);
|
|
@ -636,7 +638,7 @@ public class FlowManager {
|
|
|
newFlow.setCreateDate(new Date());
|
|
|
newFlow.setFileType(ServiceFlowConstant.CLASS);
|
|
|
flowDao.saveEntity(newFlow);
|
|
|
ArrayList<ServiceFlow.HandleFile> handleFiles =new ArrayList<>();
|
|
|
ArrayList<ServiceFlow.HandleFile> handleFiles = new ArrayList<>();
|
|
|
|
|
|
//新增processor记录
|
|
|
for (SystemServiceFlowTemp process : flowTempProces) {
|
|
@ -662,7 +664,7 @@ public class FlowManager {
|
|
|
processClass.setIsUpdate("1");
|
|
|
//生成新的java文件
|
|
|
String newFileName = genProcessorJavaFile(jobId, newFlow.getCode(), deName, processClass.getClassName());
|
|
|
String enNewFileName = DES.encrypt(newFileName,DES.COMMON_PASSWORD);
|
|
|
String enNewFileName = DES.encrypt(newFileName, DES.COMMON_PASSWORD);
|
|
|
|
|
|
if (newFileName != null) {
|
|
|
//发送消息
|
|
@ -691,5 +693,48 @@ public class FlowManager {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 服务启动/暂停
|
|
|
* @param flowId 流程ID
|
|
|
* @param oper 服务操作;1:启动;0:暂停
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public boolean serviceOpenOrPause(Integer flowId, Integer oper) throws Exception {
|
|
|
SystemServiceFlow flow = flowDao.getEntity(SystemServiceFlow.class, flowId);
|
|
|
if (flow != null) {
|
|
|
List<SystemServiceFlowClass> flowClassList = flowClassDao.getFlowClassByFlowId(flowId);
|
|
|
//route模板文件记录是否存在。不存在就返回。
|
|
|
ArrayList<ServiceFlow.HandleFile> handleFiles = new ArrayList<>();
|
|
|
//新增processor记录
|
|
|
ServiceFlow serviceFlow = new ServiceFlow();
|
|
|
serviceFlow.setRouteCode(flow.getCode());
|
|
|
serviceFlow.setFlowType(ServiceFlowConstant.CLASS);
|
|
|
for (SystemServiceFlowClass flowClass : flowClassList) {
|
|
|
// String deName = DES.decrypt(flowClass.getClassPath(), DES.COMMON_PASSWORD);//吉阿米果的文件名
|
|
|
//发送消息
|
|
|
ServiceFlow.HandleFile handleFile = new ServiceFlow.HandleFile();
|
|
|
handleFile.setRouteCode(flow.getCode());
|
|
|
handleFile.setFileType(ServiceFlowConstant.CLASS);
|
|
|
handleFile.setPackageName(flowClass.getPackageName());
|
|
|
handleFile.setClassName(flowClass.getClassName());
|
|
|
handleFile.setFilePath(flowClass.getClassPath());
|
|
|
handleFile.setUsage(ServiceFlowConstant.FLOW_TYPE_PROCESSOR);
|
|
|
handleFiles.add(handleFile);
|
|
|
}
|
|
|
serviceFlow.setHandleFiles(handleFiles);
|
|
|
if (1 == oper){
|
|
|
serviceFlowEventService.serviceFlowStarted(serviceFlow);
|
|
|
}else if (0 == oper){
|
|
|
serviceFlowEventService.serviceFlowStopped(serviceFlow);
|
|
|
}else {
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|