提交 da16be9a 编写于 作者: zhouweidong's avatar zhouweidong

动态工作流

上级 ed4bc325
package cn.ibizlab.core.workflow.extensions.service;
import cn.ibizlab.core.workflow.extensions.domain.FlowUser;
import cn.ibizlab.core.workflow.domain.*;
import cn.ibizlab.core.workflow.extensions.domain.FlowUser;
import cn.ibizlab.core.workflow.filter.WFTaskSearchContext;
import cn.ibizlab.core.workflow.mapper.WFCoreMapper;
import cn.ibizlab.core.workflow.service.IWFGroupService;
import cn.ibizlab.core.workflow.service.IWFProcessDefinitionService;
import cn.ibizlab.core.workflow.service.IWFTaskService;
import cn.ibizlab.core.workflow.service.IWFUserService;
import cn.ibizlab.util.client.IBZUAAFeignClient;
import cn.ibizlab.util.domain.MsgBody;
import cn.ibizlab.util.errors.BadRequestAlertException;
import cn.ibizlab.util.helper.RuleUtils;
import cn.ibizlab.util.security.AuthTokenUtil;
import cn.ibizlab.util.security.AuthenticationUser;
import cn.ibizlab.util.service.RemoteService;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.node.ObjectNode;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.flowable.bpmn.BpmnAutoLayout;
import org.flowable.bpmn.converter.BpmnXMLConverter;
import org.flowable.bpmn.model.*;
......@@ -77,8 +72,6 @@ import java.security.Principal;
import java.sql.Timestamp;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.stream.Collectors;
@Service("wfCoreService")
@Slf4j
......@@ -151,6 +144,9 @@ public class WFCoreService
return context;
}
public List<WFProcessDefinition> getDynamicWorkflow(String dynamic, String system,String appname,String entity) {
return wfModelService.getDynamicWorkflow(dynamic,system,entity);
}
public List<WFProcessDefinition> getWorkflow(String system,String appname,String entity) {
......@@ -806,6 +802,7 @@ public class WFCoreService
curProcess = model.getMainProcess();
String bookings="";
String refgroups="";
String dynainstid = getDynainstId();
if(!curProcess.getExtensionElements().containsKey("field"))
{
log.error(bpmnFileName+"没有实体订阅");
......@@ -901,7 +898,12 @@ public class WFCoreService
boolean bchange=false;
for(String booking:bookings.split(","))
{
String processDefinitionKey=system+"-"+booking+"-"+params[1];
String processDefinitionKey;
if(!StringUtils.isEmpty(dynainstid))
processDefinitionKey="dyna-"+dynainstid+"-"+system+"-"+booking+"-"+params[1];
else
processDefinitionKey=system+"-"+booking+"-"+params[1];
WFProcessDefinition old=iwfProcessDefinitionService.get(processDefinitionKey);
WFProcessDefinition wfProcessDefinition=new WFProcessDefinition();
wfProcessDefinition.setDefinitionkey(processDefinitionKey);
......@@ -1302,4 +1304,23 @@ public class WFCoreService
}
}
}
/**
* 获取动态实例标识
* @return
*/
private String getDynainstId(){
String dynainstid = null;
if(RequestContextHolder.getRequestAttributes()==null && !(RequestContextHolder.getRequestAttributes() instanceof ServletRequestAttributes)){
return null;
}
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if(requestAttributes!=null) {
HttpServletRequest request = requestAttributes.getRequest();
if(request!=null && !StringUtils.isEmpty(request.getHeader("dynainstid"))){
dynainstid= request.getHeader("dynainstid");
}
}
return dynainstid;
}
}
......@@ -27,6 +27,11 @@ public class WFModelService
@Autowired
private IWFProcessDefinitionService iwfProcessDefinitionService;
public List<WFProcessDefinition> getDynamicWorkflow(String dynamic, String system,String entity) {
return iwfProcessDefinitionService.list(new QueryWrapper<WFProcessDefinition>().
likeRight("definitionkey","dyna-"+dynamic+"-"+system+"-"+entity+"-").eq("modelenable",1).orderByDesc("modelversion"));
}
public List<WFProcessDefinition> getWorkflow(String system,String entity) {
return iwfProcessDefinitionService.list(new QueryWrapper<WFProcessDefinition>().
likeRight("definitionkey",system+"-"+entity+"-").eq("modelenable",1).orderByDesc("modelversion"));
......
......@@ -51,6 +51,13 @@ public class WFCoreResource
@Lazy
public WFTaskMapping wfTaskMapping;
@ApiOperation(value = "getWFProcessDefinition", tags = {"WFProcessDefinition" }, notes = "根据系统实体查找当前适配的工作流模型")
@RequestMapping(method = RequestMethod.GET, value = "/{system}-app-{appname}/{dynainstid}/{entity}/process-definitions")
public ResponseEntity<List<WFProcessDefinition>> getDynaWorkflow(@PathVariable("system") String system ,@PathVariable("appname") String appname,@PathVariable("dynainstid") String dynamic,
@PathVariable("entity") String entity) {
return ResponseEntity.status(HttpStatus.OK).body(wfCoreService.getDynamicWorkflow(dynamic,system,appname,entity));
}
@ApiOperation(value = "getWFProcessDefinition", tags = {"WFProcessDefinition" }, notes = "根据系统实体查找当前适配的工作流模型")
@RequestMapping(method = RequestMethod.GET, value = "/{system}-app-{appname}/{entity}/process-definitions")
public ResponseEntity<List<WFProcessDefinition>> getworkflow(@PathVariable("system") String system,@PathVariable("appname") String appname,
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册