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

工作流部署

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