Commit 86d6972f by 赵剑炜

调整审核流

parent d9e206c1
...@@ -77,7 +77,7 @@ public class CounterSignListener implements ExecutionListener { ...@@ -77,7 +77,7 @@ public class CounterSignListener implements ExecutionListener {
} }
else if (Type.equals("2"))//指定角色 else if (Type.equals("5"))//指定角色
{ {
List<String> Roles=group.getApproverIds(); List<String> Roles=group.getApproverIds();
if (Roles.size()>0)//角色不为空 if (Roles.size()>0)//角色不为空
...@@ -103,7 +103,7 @@ public class CounterSignListener implements ExecutionListener { ...@@ -103,7 +103,7 @@ public class CounterSignListener implements ExecutionListener {
} }
else if (Type.equals("3"))//指定组织机构中的角色 else if (Type.equals("7"))//指定组织机构中的角色
{ {
// List<UserListDTO> userList=orgUserMapper.QueryUserByRoleIdAndOrg(role); // List<UserListDTO> userList=orgUserMapper.QueryUserByRoleIdAndOrg(role);
List<String> Roles=group.getApproverIds(); List<String> Roles=group.getApproverIds();
...@@ -138,7 +138,7 @@ public class CounterSignListener implements ExecutionListener { ...@@ -138,7 +138,7 @@ public class CounterSignListener implements ExecutionListener {
} }
} }
else if (Type.equals("5"))//上级审批 else if (Type.equals("1"))//上级审批
{ {
LoginUser StartUser= LoginContext.getContext().getLoginUser(); LoginUser StartUser= LoginContext.getContext().getLoginUser();
List<UserListDTO> userList= orgUserMapper.QueryUserWithParentOrg(StartUser.getUserId().toString()); List<UserListDTO> userList= orgUserMapper.QueryUserWithParentOrg(StartUser.getUserId().toString());
......
...@@ -608,32 +608,7 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper, ...@@ -608,32 +608,7 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper,
return new Inout(id, id); return new Inout(id, id);
} }
private BpmnModel assemBpmnModel(FlowChildNode childNode,
Integer groupId) {
BpmnModel bpmnModel = new BpmnModel();
List<SequenceFlow> sequenceFlows = Lists.newArrayList();
Map<String, ChildNode> childNodeMap = new HashMap<>();
bpmnModel.setTargetNamespace(groupId + "");
Process process = new Process();
process.setId(WorkFlowConstants.PROCESS_PREFIX);
bpmnModel.addProcess(process);
StartEvent startEvent = createStartEvent();
process.addFlowElement(startEvent);
String lastNode = null;
EndEvent endEvent = createEndEvent();
process.addFlowElement(endEvent);
List<FlowableListener> executionListeners = new ArrayList<>();
FlowableListener flowableListener = new FlowableListener();
flowableListener.setEvent(ExecutionListener.EVENTNAME_END);
flowableListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
flowableListener.setImplementation("${processListener}");
executionListeners.add(flowableListener);
process.setExecutionListeners(executionListeners);
new BpmnAutoLayout(bpmnModel).execute();
return bpmnModel;
}
...@@ -666,10 +641,10 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper, ...@@ -666,10 +641,10 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper,
try { try {
LoginUser StartUser=new LoginUser(); LoginUser StartUser=new LoginUser();
// StartUser.setUserId(Long.valueOf(1000)); StartUser.setUserId(Long.valueOf("1694954953210986498"));
// StartUser= LoginContext.getContext().getLoginUser();
StartUser= LoginContext.getContext().getLoginUser();
//
JSONObject formData = processInstanceDto.getFormData(); JSONObject formData = processInstanceDto.getFormData();
Authentication.setAuthenticatedUserId(StartUser.getUserId().toString()); Authentication.setAuthenticatedUserId(StartUser.getUserId().toString());
Map<String,Object> processVariables= new HashMap<>(); Map<String,Object> processVariables= new HashMap<>();
...@@ -703,12 +678,12 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper, ...@@ -703,12 +678,12 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper,
.businessStatus(BUSINESS_STATUS_1) .businessStatus(BUSINESS_STATUS_1)
.start(); .start();
//手动完成第一个任务 //手动完成第一个任务
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); // Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
Object ts=new Object(); // Object ts=new Object();
if(task!=null){ // if(task!=null){
taskService.complete(task.getId()); // taskService.complete(task.getId());
//
} // }
return ApiRes.success(true); return ApiRes.success(true);
} }
catch (Exception e){ catch (Exception e){
...@@ -940,12 +915,25 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper, ...@@ -940,12 +915,25 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper,
for (HistoricTaskInstance task : tasks) { for (HistoricTaskInstance task : tasks) {
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult(); HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult();
Boolean flag = historicProcessInstance.getEndTime() == null ? false : true; Boolean flag = historicProcessInstance.getEndTime() == null ? false : true;
BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
BpmnModel bpmnModel = null;
try {
bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
} catch (Exception e) {
// 处理获取BpmnModel异常的情况
e.printStackTrace(); // 可以将异常信息打印到日志中
// 可以在这里设置默认的BpmnModel或采取其他处理措施
}
Map<String, Object> processVariables = task.getProcessVariables(); Map<String, Object> processVariables = task.getProcessVariables();
TaskVO taskVO = new TaskVO(); TaskVO taskVO = new TaskVO();
taskVO.setTaskId(task.getId()); taskVO.setTaskId(task.getId());
taskVO.setProcessInstanceId(task.getProcessInstanceId()); taskVO.setProcessInstanceId(task.getProcessInstanceId());
taskVO.setProcessDefinitionName(bpmnModel.getMainProcess().getName()); if (bpmnModel!=null)
{
taskVO.setProcessDefinitionName(bpmnModel.getMainProcess().getName());
}
taskVO.setStartUser(JSONObject.parseObject(MapUtil.getStr(processVariables, START_USER_INFO), new TypeReference<UserInfo>() { taskVO.setStartUser(JSONObject.parseObject(MapUtil.getStr(processVariables, START_USER_INFO), new TypeReference<UserInfo>() {
})); }));
taskVO.setStartTime(historicProcessInstance.getStartTime()); taskVO.setStartTime(historicProcessInstance.getStartTime());
......
...@@ -25,7 +25,9 @@ public class BpmnConvert { ...@@ -25,7 +25,9 @@ public class BpmnConvert {
@Resource @Resource
private IdWorker idWorker; private IdWorker idWorker;
private static String id(String prefix) {
return prefix + "_" + UUID.randomUUID().toString().replace("-", "").toLowerCase();
}
public static BpmnModel toBpmn(JsonNode processNode, JsonNode formNode,String formName,String templateId) { public static BpmnModel toBpmn(JsonNode processNode, JsonNode formNode,String formName,String templateId) {
//表单存储 //表单存储
JSONObject jsonObject=new JSONObject(); JSONObject jsonObject=new JSONObject();
...@@ -55,15 +57,24 @@ public class BpmnConvert { ...@@ -55,15 +57,24 @@ public class BpmnConvert {
bpmnModel.addProcess(process); bpmnModel.addProcess(process);
// 二.开始结束节点 // 二.开始结束节点
StartEvent startEvent = new StartEvent();// 新建开始节点 StartEvent startEvent = new StartEvent();// 新建开始节点
startEvent.setId("_start"); startEvent.setId(id("start"));
startEvent.setInitiator("initiator"); startEvent.setInitiator("initiator");
process.addFlowElement(startEvent);// 绘制到图纸 process.addFlowElement(startEvent);// 绘制到图纸
EndEvent endEvent = new EndEvent(); // 新建结束节点 EndEvent endEvent = new EndEvent(); // 新建结束节点
endEvent.setId("_end");// 绘制到图纸 endEvent.setId(id("end"));// 绘制到图纸
process.addFlowElement(endEvent); process.addFlowElement(endEvent);
// 三.递归绘制节点 // 三.递归绘制节点
drawNode("0",process, processNode,formNode, "_start", "_end", null); drawNode("0",process, processNode,formNode, startEvent.getId(), endEvent.getId(), null);
List<FlowableListener> executionListeners =new ArrayList<>();
FlowableListener flowableListener=new FlowableListener();
flowableListener.setEvent(ExecutionListener.EVENTNAME_END);
flowableListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
flowableListener.setImplementation("${processListener}");
executionListeners.add(flowableListener);
process.setExecutionListeners(executionListeners);
// 四.自动布局 // 四.自动布局
new BpmnAutoLayout(bpmnModel).execute(); new BpmnAutoLayout(bpmnModel).execute();
// 五.转xml // 五.转xml
...@@ -88,6 +99,7 @@ public class BpmnConvert { ...@@ -88,6 +99,7 @@ public class BpmnConvert {
if (node.get("childNode").toString().equals("null")) { if (node.get("childNode").toString().equals("null")) {
// 没有下一步, 绘制指向结束的线 // 没有下一步, 绘制指向结束的线
process.addFlowElement(createSequenceFlow(inout.getOut(), endId, null)); process.addFlowElement(createSequenceFlow(inout.getOut(), endId, null));
} else { } else {
// 有下一步, 递归绘制下一个节点 // 有下一步, 递归绘制下一个节点
drawNode("",process, node.get("childNode"),formJson, inout.getOut(), endId, null); drawNode("",process, node.get("childNode"),formJson, inout.getOut(), endId, null);
...@@ -211,12 +223,7 @@ public class BpmnConvert { ...@@ -211,12 +223,7 @@ public class BpmnConvert {
listener.setEvent(ExecutionListener.EVENTNAME_START);//监听任务启动 listener.setEvent(ExecutionListener.EVENTNAME_START);//监听任务启动
listener.setImplementationType(IMPLEMENTATION_TYPE_DELEGATEEXPRESSION); listener.setImplementationType(IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
listener.setImplementation("${counterSignListener}");//启动角色分配监听事件 listener.setImplementation("${counterSignListener}");//启动角色分配监听事件
FlowableListener flowableListener = new FlowableListener();
flowableListener.setEvent(ExecutionListener.EVENTNAME_END);
flowableListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
flowableListener.setImplementation("${processListener}");
taskListeners.add(listener); taskListeners.add(listener);
taskListeners.add(flowableListener);
return taskListeners; return taskListeners;
} }
...@@ -247,6 +254,8 @@ public class BpmnConvert { ...@@ -247,6 +254,8 @@ public class BpmnConvert {
String condition = JsonToELConverter.convertToEL(conditionGroup); String condition = JsonToELConverter.convertToEL(conditionGroup);
//条件线路 根前端数据对接 内容为EL表达式 //条件线路 根前端数据对接 内容为EL表达式
process.addFlowElement(createSequenceFlow(startId, endId, condition)); process.addFlowElement(createSequenceFlow(startId, endId, condition));
} else { } else {
// 有子流程,递归绘制子流程 // 有子流程,递归绘制子流程
//解释JSON数据,转换为EL表达式 //解释JSON数据,转换为EL表达式
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论