提交 8670b119 编写于 作者: lengyu's avatar lengyu

dynamic wf

上级 fd1f2ea1
...@@ -122,11 +122,11 @@ public class WFCoreService ...@@ -122,11 +122,11 @@ public class WFCoreService
private AuthenticationContext createAuthenticationContext() private AuthenticationContext createAuthenticationContext()
{ {
UserIdAuthenticationContext context=new UserIdAuthenticationContext(); UserIdAuthenticationContext context=new UserIdAuthenticationContext();
AuthenticationUser user=AuthenticationUser.getAuthenticationUser(); AuthenticationUser user=AuthenticationUser.getAuthenticationUser();
FlowUser principal=new FlowUser(); FlowUser principal=new FlowUser();
principal.setUser(user); principal.setUser(user);
String token=""; String token="";
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if(requestAttributes!=null) { if(requestAttributes!=null) {
HttpServletRequest request = requestAttributes.getRequest(); HttpServletRequest request = requestAttributes.getRequest();
...@@ -139,8 +139,8 @@ public class WFCoreService ...@@ -139,8 +139,8 @@ public class WFCoreService
token="Bearer "+jwtTokenUtil.generateToken(user); token="Bearer "+jwtTokenUtil.generateToken(user);
} }
principal.setToken(token); principal.setToken(token);
context.setPrincipal((Principal) principal); context.setPrincipal((Principal) principal);
return context; return context;
} }
...@@ -160,6 +160,13 @@ public class WFCoreService ...@@ -160,6 +160,13 @@ public class WFCoreService
return definitionKeys; return definitionKeys;
} }
public List<String> getDynaWorkflowKey(String dynainstid,String system,String appname,String entity) {
List<String> definitionKeys=new ArrayList<>();
for(WFProcessDefinition wfdef:wfModelService.getDynamicWorkflow(dynainstid,system,entity))
definitionKeys.add(wfdef.getDefinitionkey());
return definitionKeys;
}
public List<WFProcessNode> getWFStep(String system,String appname, String entity) { public List<WFProcessNode> getWFStep(String system,String appname, String entity) {
List<WFProcessNode> rt=new ArrayList<>(); List<WFProcessNode> rt=new ArrayList<>();
for(WFProcessDefinition wfdef:wfModelService.getWorkflow(system,entity)) { for(WFProcessDefinition wfdef:wfModelService.getWorkflow(system,entity)) {
...@@ -307,7 +314,7 @@ public class WFCoreService ...@@ -307,7 +314,7 @@ public class WFCoreService
} }
public List<WFTaskWay> getWFLinkByStep(String system,String appname, public List<WFTaskWay> getWFLinkByStep(String system,String appname,
String entity, String processDefinitionKey,String taskDefinitionKey) { String entity, String processDefinitionKey,String taskDefinitionKey) {
List<WFTaskWay> taskWays=new ArrayList<>(); List<WFTaskWay> taskWays=new ArrayList<>();
if((!StringUtils.isEmpty(processDefinitionKey))&&(!StringUtils.isEmpty(taskDefinitionKey))) { if((!StringUtils.isEmpty(processDefinitionKey))&&(!StringUtils.isEmpty(taskDefinitionKey))) {
UserTask userTask = wfModelService.getModelStepByKey(processDefinitionKey).get(taskDefinitionKey); UserTask userTask = wfModelService.getModelStepByKey(processDefinitionKey).get(taskDefinitionKey);
...@@ -383,6 +390,36 @@ public class WFCoreService ...@@ -383,6 +390,36 @@ public class WFCoreService
return ""; return "";
} }
public Map<String, Map<String,Object>> getDynaBusinessKeys(String system, String appname, String entity, String dynainstid, String userId) {
Map<String, Map<String,Object>> businessKeys = new HashMap<>();
if(StringUtils.isEmpty(userId))
userId=AuthenticationUser.getAuthenticationUser().getUserid();
if(StringUtils.isEmpty(userId) && StringUtils.isEmpty(dynainstid))
return businessKeys;
WFTaskSearchContext context =new WFTaskSearchContext();
List<String> keys = this.getDynaWorkflowKey(dynainstid,system,appname,entity);
if(!ObjectUtils.isEmpty(keys)){
context.getSearchCond().in("DefinitionKey",keys);
}
Page<WFTask> tasks = searchMyTask(context);
if(!ObjectUtils.isEmpty(tasks)){
for(WFTask task:tasks.getContent()) {
Object key=task.getProcessinstancebusinesskey();
if(key!=null) {
String str=key.toString();
if(str.indexOf(":k-")>0)
str=str.split(":k-")[1];
Map<String,Object> params = new HashMap();
params.put("srfprocessdefinitionkey",task.getProcessdefinitionkey());
params.put("srftaskdefinitionkey",task.getTaskdefinitionkey());
businessKeys.put(str,params);
}
}
}
return businessKeys;
}
public List<String> getBusinessKeys(String system,String appname, String entity,String processDefinitionKey,String taskDefinitionKey,String userId) public List<String> getBusinessKeys(String system,String appname, String entity,String processDefinitionKey,String taskDefinitionKey,String userId)
{ {
List<String> businessKeys = new ArrayList<>(); List<String> businessKeys = new ArrayList<>();
...@@ -413,7 +450,7 @@ public class WFCoreService ...@@ -413,7 +450,7 @@ public class WFCoreService
} }
public WFProcessInstance wfStart(String system,String appname, public WFProcessInstance wfStart(String system,String appname,
String entity,String businessKey,WFProcessInstance instance) { String entity,String businessKey,WFProcessInstance instance) {
String userId=AuthenticationUser.getAuthenticationUser().getUserid(); String userId=AuthenticationUser.getAuthenticationUser().getUserid();
if(StringUtils.isEmpty(userId)) if(StringUtils.isEmpty(userId))
throw new BadRequestAlertException("未传入当前用户",entity,businessKey); throw new BadRequestAlertException("未传入当前用户",entity,businessKey);
...@@ -448,7 +485,7 @@ public class WFCoreService ...@@ -448,7 +485,7 @@ public class WFCoreService
variables.put("wfversion",version); variables.put("wfversion",version);
//根据流程定义启动流程 //根据流程定义启动流程
Authentication.setAuthenticatedUserId(userId); Authentication.setAuthenticatedUserId(userId);
Authentication.setAuthenticationContext(createAuthenticationContext()); Authentication.setAuthenticationContext(createAuthenticationContext());
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processDefinitionKey,processInstanceBusinessKey, variables);//流程定时标识、业务标识、变量 ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processDefinitionKey,processInstanceBusinessKey, variables);//流程定时标识、业务标识、变量
instance.setBusinesskey(processInstanceBusinessKey); instance.setBusinesskey(processInstanceBusinessKey);
instance.setId(processInstance.getId()); instance.setId(processInstance.getId());
...@@ -462,7 +499,7 @@ public class WFCoreService ...@@ -462,7 +499,7 @@ public class WFCoreService
} }
public List<WFTaskWay> getWFLink(String system,String appname, public List<WFTaskWay> getWFLink(String system,String appname,
String entity, String businessKey,String taskDefinitionKey) { String entity, String businessKey,String taskDefinitionKey) {
List<WFTaskWay> taskWays=new ArrayList<>(); List<WFTaskWay> taskWays=new ArrayList<>();
String processInstanceBusinessKey=system+":"+entity+":k-"+businessKey; String processInstanceBusinessKey=system+":"+entity+":k-"+businessKey;
String userId=AuthenticationUser.getAuthenticationUser().getUserid(); String userId=AuthenticationUser.getAuthenticationUser().getUserid();
...@@ -535,7 +572,7 @@ public class WFCoreService ...@@ -535,7 +572,7 @@ public class WFCoreService
} }
public WFProcessInstance wfsubmit(String system,String appname, public WFProcessInstance wfsubmit(String system,String appname,
String entity,String businessKey,String taskId,WFTaskWay taskWay) { String entity,String businessKey,String taskId,WFTaskWay taskWay) {
String userId=AuthenticationUser.getAuthenticationUser().getUserid(); String userId=AuthenticationUser.getAuthenticationUser().getUserid();
if(StringUtils.isEmpty(userId)) if(StringUtils.isEmpty(userId))
...@@ -565,7 +602,7 @@ public class WFCoreService ...@@ -565,7 +602,7 @@ public class WFCoreService
//根据流程定义启动流程 //根据流程定义启动流程
Authentication.setAuthenticatedUserId(userId); Authentication.setAuthenticatedUserId(userId);
Authentication.setAuthenticationContext(createAuthenticationContext()); Authentication.setAuthenticationContext(createAuthenticationContext());
taskService.complete(taskId, variables,transientVariables); taskService.complete(taskId, variables,transientVariables);
WFProcessInstance instance = new WFProcessInstance(); WFProcessInstance instance = new WFProcessInstance();
...@@ -574,7 +611,7 @@ public class WFCoreService ...@@ -574,7 +611,7 @@ public class WFCoreService
} }
public WFProcessInstance getWFHistory(String system,String appname, public WFProcessInstance getWFHistory(String system,String appname,
String entity,String businessKey,String processInstanceId) String entity,String businessKey,String processInstanceId)
{ {
WFProcessInstance wfProcessInstance=new WFProcessInstance(); WFProcessInstance wfProcessInstance=new WFProcessInstance();
String processInstanceBusinessKey=system+":"+entity+":k-"+businessKey; String processInstanceBusinessKey=system+":"+entity+":k-"+businessKey;
...@@ -737,22 +774,22 @@ public class WFCoreService ...@@ -737,22 +774,22 @@ public class WFCoreService
public synchronized boolean wfdeploybpmns(List bpmnfiles){ public synchronized boolean wfdeploybpmns(List bpmnfiles){
if(bpmnfiles.size()>0){ if(bpmnfiles.size()>0){
bpmnfiles.forEach(item->{ bpmnfiles.forEach(item->{
Map<String,Object> bpmnfile= (Map) item; Map<String,Object> bpmnfile= (Map) item;
for (Map.Entry<String,Object> entry : bpmnfile.entrySet()) { for (Map.Entry<String,Object> entry : bpmnfile.entrySet()) {
InputStream in = null; InputStream in = null;
try { try {
in = new ByteArrayInputStream(String.valueOf(entry.getValue()).getBytes()); in = new ByteArrayInputStream(String.valueOf(entry.getValue()).getBytes());
wfdeploy(entry.getKey(), getBpmnFile(in),new WFREModel()); wfdeploy(entry.getKey(), getBpmnFile(in),new WFREModel());
} catch (Exception e) {} } catch (Exception e) {}
finally { finally {
if(in!=null) { if(in!=null) {
try { try {
in.close(); in.close();
} catch (IOException e) {} } catch (IOException e) {}
}
} }
} }
} }
}
); );
} }
return true; return true;
...@@ -899,7 +936,6 @@ public class WFCoreService ...@@ -899,7 +936,6 @@ public class WFCoreService
for(String booking:bookings.split(",")) for(String booking:bookings.split(","))
{ {
String processDefinitionKey; String processDefinitionKey;
if(!StringUtils.isEmpty(dynainstid)) if(!StringUtils.isEmpty(dynainstid))
processDefinitionKey="dyna-"+dynainstid+"-"+system+"-"+booking+"-"+params[1]; processDefinitionKey="dyna-"+dynainstid+"-"+system+"-"+booking+"-"+params[1];
else else
...@@ -987,7 +1023,7 @@ public class WFCoreService ...@@ -987,7 +1023,7 @@ public class WFCoreService
try try
{ {
if(is!=null) if(is!=null)
is.close(); is.close();
}catch (Exception exis){} }catch (Exception exis){}
try try
{ {
...@@ -1092,7 +1128,7 @@ public class WFCoreService ...@@ -1092,7 +1128,7 @@ public class WFCoreService
{ {
ServiceTask task=(ServiceTask)delegateExecution.getCurrentFlowElement(); ServiceTask task=(ServiceTask)delegateExecution.getCurrentFlowElement();
//HashMap curUser=(HashMap)delegateExecution.getVariable("curuser"); //HashMap curUser=(HashMap)delegateExecution.getVariable("curuser");
FlowUser curUser=FlowUser.getCurUser(); FlowUser curUser=FlowUser.getCurUser();
String businessKey=(String)delegateExecution.getVariable("businessKey"); String businessKey=(String)delegateExecution.getVariable("businessKey");
String cloudServiceId=(String)delegateExecution.getVariable("cloud-serviceid"); String cloudServiceId=(String)delegateExecution.getVariable("cloud-serviceid");
Map entity=(Map) activedata; Map entity=(Map) activedata;
...@@ -1231,7 +1267,6 @@ public class WFCoreService ...@@ -1231,7 +1267,6 @@ public class WFCoreService
} }
} }
} }
return strUsers; return strUsers;
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册