提交 13d72b1c 编写于 作者: sq3536's avatar sq3536

工作流部署

上级 bf25ac0b
......@@ -36,9 +36,6 @@ import java.util.Map;
@Component
public class ProcessInstanceListener implements FlowableEventListener {
@Autowired
@Lazy
private WFCoreService wfCoreService;
@Autowired
@Lazy
......@@ -48,8 +45,6 @@ public class ProcessInstanceListener implements FlowableEventListener {
@Lazy
private RemoteService remoteService;
@Autowired
private AuthTokenUtil jwtTokenUtil;
@Override
public void onEvent(FlowableEvent evt) {
......@@ -62,8 +57,9 @@ public class ProcessInstanceListener implements FlowableEventListener {
if(executionEntity.getVariable("cloud-serviceid")==null)
return;
String businessKey=(String)executionEntity.getVariable("businessKey");
AuthenticationUser curUser=(AuthenticationUser)executionEntity.getVariable("curuser");
HashMap curUser=(HashMap) executionEntity.getVariable("curuser");
String entity=executionEntity.getVariable("entitys").toString();
String cloudServiceid=executionEntity.getVariable("cloud-serviceid").toString();
Map setting=wfModelService.getProcessGlobalSetting(executionEntity.getProcessDefinitionId());
String wfstepfield="";
......@@ -75,30 +71,41 @@ public class ProcessInstanceListener implements FlowableEventListener {
String udstatefield="";
if(setting.containsKey("udstatefield"+"_"+entity))
udstatefield=setting.get("udstatefield"+"_"+entity).toString();
String wfstate="";
if(setting.containsKey("wfstate"+"_"+entity))
wfstate=setting.get("wfstate"+"_"+entity).toString();
String wfstatefield="";
if(setting.containsKey("wfstatefield"+"_"+entity))
wfstatefield=setting.get("wfstatefield"+"_"+entity).toString();
String wfverfield="";
if(setting.containsKey("wfverfield"+"_"+entity))
wfverfield=setting.get("wfverfield"+"_"+entity).toString();
String majortext_field="";
if(setting.containsKey("majortext"+"_"+entity))
{
majortext_field = setting.get("majortext" + "_" + entity).toString();
Object activedata=executionEntity.getVariable("activedata");
if(activedata!=null)
executionEntity.setVariable("majortext",((Map)activedata).get(majortext_field));
}
executionEntity.setVariable("wfstepfield",wfstepfield);
executionEntity.setVariable("wfinstfield",wfinstfield);
executionEntity.setVariable("udstatefield",udstatefield);
executionEntity.setVariable("wfstate",wfstate);
executionEntity.setVariable("wfstatefield",wfstatefield);
executionEntity.setVariable("wfverfield",wfverfield);
executionEntity.setVariable("majortextfield",majortext_field);
Map callbackArg=new LinkedHashMap();
if(!StringUtils.isEmpty(wfinstfield))
callbackArg.put(wfinstfield,executionEntity.getProcessInstanceId());
if(!StringUtils.isEmpty(wfstate))
callbackArg.put(wfstate,1);
if(!StringUtils.isEmpty(wfstatefield))
callbackArg.put(wfstatefield,1);
if(!StringUtils.isEmpty(udstatefield))
callbackArg.put(udstatefield,"20");
if((!StringUtils.isEmpty(wfverfield))&&(executionEntity.getVariable("wfversion")!=null))
callbackArg.put(wfverfield,Integer.parseInt(executionEntity.getVariable("wfversion").toString()));
if(callbackArg.size()>0) {
String token="Bearer "+jwtTokenUtil.generateToken(curUser);
if(curUser.get("bearer-token")==null)
return;
String token=curUser.get("bearer-token").toString();
remoteService.getClient(cloudServiceid).put(entity + "/" + businessKey, token,callbackArg);
}
}
......@@ -117,7 +124,7 @@ public class ProcessInstanceListener implements FlowableEventListener {
if(executionEntity.getVariable("cloud-serviceid")==null)
return;
String businessKey=(String)executionEntity.getVariable("businessKey");
AuthenticationUser curUser=(AuthenticationUser)executionEntity.getVariable("curuser");
HashMap curUser=(HashMap) executionEntity.getVariable("curuser");
String entity=executionEntity.getVariable("entitys").toString();
String cloudServiceid=executionEntity.getVariable("cloud-serviceid").toString();
String wfstepfield = executionEntity.getVariable("wfstepfield").toString();
......@@ -131,7 +138,9 @@ public class ProcessInstanceListener implements FlowableEventListener {
if(!StringUtils.isEmpty(wfstepfield))
callbackArg.put(wfstepfield,"");
if(callbackArg.size()>0) {
String token="Bearer "+jwtTokenUtil.generateToken(curUser);
if(curUser.get("bearer-token")==null)
return;
String token=curUser.get("bearer-token").toString();
remoteService.getClient(cloudServiceid).put(entity + "/" + businessKey, token,callbackArg);
}
......@@ -169,7 +178,7 @@ public class ProcessInstanceListener implements FlowableEventListener {
if(event.getExecution().getVariable("cloud-serviceid")==null)
return;
String businessKey=(String)event.getExecution().getVariable("businessKey");
AuthenticationUser curUser=(AuthenticationUser)event.getExecution().getVariable("curuser");
HashMap curUser=(HashMap) event.getExecution().getVariable("curuser");
String entity=event.getExecution().getVariable("entitys").toString();
String cloudServiceid=event.getExecution().getVariable("cloud-serviceid").toString();
String wfstepfield = event.getExecution().getVariable("wfstepfield").toString();
......@@ -177,7 +186,9 @@ public class ProcessInstanceListener implements FlowableEventListener {
if(!StringUtils.isEmpty(wfstepfield)&&event.getActivityId().startsWith("tid-"))
callbackArg.put(wfstepfield,event.getActivityId().split("-")[1]);
if(callbackArg.size()>0) {
String token="Bearer "+jwtTokenUtil.generateToken(curUser);
if(curUser.get("bearer-token")==null)
return;
String token=curUser.get("bearer-token").toString();
remoteService.getClient(cloudServiceid).put(entity + "/" + businessKey, token,callbackArg);
}
......
......@@ -60,6 +60,25 @@ public class WFCoreService
@Autowired
private IWFProcessDefinitionService iwfProcessDefinitionService;
@Autowired
private AuthTokenUtil jwtTokenUtil;
private HashMap getCurUser()
{
HashMap curUser=new HashMap();
AuthenticationUser user=AuthenticationUser.getAuthenticationUser();
curUser.put("userid",user.getUserid());
curUser.put("username",user.getUsername());
curUser.put("personname",user.getPersonname());
curUser.put("orgid",user.getOrgid());
curUser.put("mdeptid",user.getMdeptid());
curUser.put("bcode",user.getBcode());
curUser.put("orgInfo",user.getOrgInfo());
curUser.put("sessionParams",user.getSessionParams());
curUser.put("bearer-token","Bearer "+jwtTokenUtil.generateToken(user));
return curUser;
}
public List<WFProcessDefinition> getWorkflow(String system,String appname,String entity) {
return wfModelService.getWorkflow(system,entity);
......@@ -161,7 +180,7 @@ public class WFCoreService
Map<String, Object> variables = new LinkedHashMap<>();
variables.put("businessKey",businessKey);
variables.put("activedata",instance.get("activedata"));
variables.put("curuser",AuthenticationUser.getAuthenticationUser());
variables.put("curuser",getCurUser());
variables.put("cloud-serviceid",system+"-"+appname);
variables.put("system",system);
variables.put("appname",appname);
......@@ -263,9 +282,9 @@ public class WFCoreService
}
if(!StringUtils.isEmpty(taskDefinitionKey))
query.taskDefinitionKey(taskDefinitionKey);
List<Task> tasks=query.includeProcessVariables().listPage(0,500);
List<Task> tasks=query.listPage(0,500);
for(Task task:tasks) {
Object key=task.getProcessVariables().get("businessKey");
Object key=task.getCategory();
if(key!=null) {
String str=key.toString();
if(str.indexOf(":k-")>0)
......@@ -292,7 +311,7 @@ public class WFCoreService
Map<String, Object> transientVariables = new LinkedHashMap<>();
transientVariables.put("activedata",taskWay.get("activedata"));
transientVariables.put("curuser",AuthenticationUser.getAuthenticationUser());
transientVariables.put("curuser",getCurUser());
//根据流程定义启动流程
Authentication.setAuthenticatedUserId(userId);
......@@ -469,8 +488,6 @@ public class WFCoreService
@Autowired
private RemoteService remoteService;
@Autowired
private AuthTokenUtil jwtTokenUtil;
public void execute(DelegateExecution delegateExecution,Object activedata) throws Exception {
//String entity = (String)delegateExecution.getVariable("pass");
......@@ -478,7 +495,7 @@ public class WFCoreService
{
ServiceTask task=(ServiceTask)delegateExecution.getCurrentFlowElement();
AuthenticationUser curUser=(AuthenticationUser)delegateExecution.getVariable("curuser");
HashMap curUser=(HashMap)delegateExecution.getVariable("curuser");
String businessKey=(String)delegateExecution.getVariable("businessKey");
String cloudServiceId=(String)delegateExecution.getVariable("cloud-serviceid");
......@@ -504,7 +521,9 @@ public class WFCoreService
}
if(StringUtils.isEmpty(serviceEntity)||StringUtils.isEmpty(serviceDEAction))
return;
String token="Bearer "+jwtTokenUtil.generateToken(curUser);
if(curUser.get("bearer-token")==null)
return;
String token=curUser.get("bearer-token").toString();
String path=serviceEntity;
//cloudServiceId="support5";
if(serviceDEAction.equalsIgnoreCase("create"))
......@@ -543,7 +562,7 @@ public class WFCoreService
return new Timestamp(new java.util.Date().getTime());
}
public String getGroupUsers(String groupIds, AuthenticationUser user, LinkedHashMap<String,Object> activedata)
public String getGroupUsers(String groupIds, HashMap user, LinkedHashMap<String,Object> activedata)
{
String strUsers="";
if(StringUtils.isEmpty(groupIds))
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册