perf: 优化企标立项变更发起流程
This commit is contained in:
+5
-52
@@ -44,7 +44,7 @@ public class ActFlowCommonService {
|
||||
/**
|
||||
* 启动流程实例
|
||||
*/
|
||||
public ProcessInstance startProcess(String processDefinitionKey, InitChangeDataVO initChangeData, Map<String, Object> variables) {
|
||||
public ProcessInstance startProcess(String processDefinitionKey, Map<String, Object> variables) {
|
||||
ProcessDefinition latestProcessDefinition = repositoryService.createProcessDefinitionQuery()
|
||||
.processDefinitionKey(processDefinitionKey)
|
||||
.orderByProcessDefinitionVersion().desc()
|
||||
@@ -58,29 +58,25 @@ public class ActFlowCommonService {
|
||||
// 流程定义ID
|
||||
String processDefinitionId = processInstance.getProcessDefinitionId();
|
||||
log.info("【启动流程】- 成功,processDefinitionId:{}", processDefinitionId);
|
||||
log.info("启动流程实例成功,流程定义ID为:{}", processDefinitionId);
|
||||
return processInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成提交任务
|
||||
*/
|
||||
public void completeTask(String remark, String taskId, String userId, Map<String, Object> map) {
|
||||
public void completeTask(String taskId, String userId, Map<String, Object> map) {
|
||||
//任务Id 查询任务对象
|
||||
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||
|
||||
if (task == null) {
|
||||
if (!taskExists(taskId)) {
|
||||
log.error("找不到对应任务");
|
||||
throw new JeroBootException("找不到对应任务");
|
||||
}
|
||||
|
||||
//任务对象 获取流程实例Id
|
||||
String processInstanceId = task.getProcessInstanceId();
|
||||
|
||||
//设置审批人的userId
|
||||
Authentication.setAuthenticatedUserId(userId);
|
||||
|
||||
//添加记录
|
||||
taskService.addComment(taskId, processInstanceId, remark);
|
||||
log.info("-----------完成任务操作 开始----------");
|
||||
log.info("任务Id=" + taskId);
|
||||
log.info("负责人id=" + userId);
|
||||
@@ -121,37 +117,6 @@ public class ActFlowCommonService {
|
||||
return listMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看个人任务信息
|
||||
*/
|
||||
public List<Map<String, Object>> taskInfoList(String userid, CenterQueryVO centerQueryVO, Integer pageNo, Integer pageSize) {
|
||||
//TODO 分页
|
||||
TaskQuery taskQuery = taskService.createTaskQuery().taskAssignee(userid);
|
||||
|
||||
List<Task> list = taskQuery.orderByTaskCreateTime().desc().list();
|
||||
|
||||
List<Map<String, Object>> listMap = new ArrayList<>();
|
||||
for (Task task : list) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("taskId", task.getId());
|
||||
map.put("prcId", task.getProcessInstanceId());
|
||||
map.put("prcName", task.getProcessDefinitionId());
|
||||
LoginUser assigneeUser = sysBaseAPI.getUserById(task.getAssignee());
|
||||
map.put("assignee", assigneeUser.getId());
|
||||
map.put("assigneeText", assigneeUser.getUsername());
|
||||
map.put("claimTaskTime", task.getCreateTime());
|
||||
ProcessInstance processInstance = runtimeService
|
||||
.createProcessInstanceQuery()
|
||||
.processInstanceId(task.getProcessInstanceId())
|
||||
.singleResult();
|
||||
|
||||
//TODO 根据流程Id找到对应业务流程实体
|
||||
|
||||
listMap.add(map);
|
||||
}
|
||||
return listMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转办
|
||||
*/
|
||||
@@ -160,18 +125,6 @@ public class ActFlowCommonService {
|
||||
log.info("转办 任务Id:{} 转办用户Id{}", taskId, userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 待办任务列表
|
||||
* @param centerQueryVO
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> todoTaskList(CenterQueryVO centerQueryVO, Integer pageNo, Integer pageSize) {
|
||||
String userId = UserUtils.getUserId();
|
||||
return this.taskInfoList(userId, centerQueryVO, pageNo, pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断任务是否存在
|
||||
* @param taskId
|
||||
@@ -211,7 +164,7 @@ public class ActFlowCommonService {
|
||||
log.info("当前用户ID:{},相关联的流程定义ID:{}", userId, map.get("processDefinitionId").toString());
|
||||
log.info("匹配到的任务ID:{}", map.get("taskId").toString());
|
||||
|
||||
this.completeTask("同意", map.get("taskId").toString(), userId, map);
|
||||
this.completeTask(map.get("taskId").toString(), userId, map);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ public class ProcessEsAnnualReportServiceImpl extends ServiceImpl<ProcessEsAnnua
|
||||
// TODO 根据当前节点类型保存数据
|
||||
// 设置流程变量
|
||||
// 完成任务
|
||||
actFlowCommonService.completeTask("同意", taskId, userId, null);
|
||||
actFlowCommonService.completeTask(taskId, userId, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+33
-49
@@ -28,8 +28,6 @@ import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -60,35 +58,6 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl<ProcessEsInitCha
|
||||
@Resource
|
||||
private EnterpriseStandardUtil esUtil;
|
||||
|
||||
public Map<String, Object> setVariables(InitChangeDataVO initChangeData) {
|
||||
FlowUserInfoVO flowUserInfoVO = initChangeData.getFlowUserInfoVO();
|
||||
ProcessEsInitChange initChange = initChangeData.getDataList().get(0);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
// 设置流程中各个节点的人
|
||||
map.put("createUser", UserUtils.getUserIdByUserName(flowUserInfoVO.getCreateUser()));
|
||||
map.put("contactUser", flowUserInfoVO.getContactUser());
|
||||
map.put("standardExpertList", Optional.ofNullable(flowUserInfoVO.getStandardExpert()).map(s -> Arrays.asList(s.split(","))).orElse(Collections.emptyList()));
|
||||
map.put("mainDraftUserLeader", flowUserInfoVO.getMainDraftUserLeader());
|
||||
map.put("mainDraftUserLeaderLeader", flowUserInfoVO.getMainDraftUserLeaderLeader());
|
||||
map.put("standardizationApprovalUser", flowUserInfoVO.getStandardizationApprovalUser());
|
||||
map.put("newMainDraftUserLeaderLeader", flowUserInfoVO.getNewMainDraftUserLeaderLeader());
|
||||
map.put("newMainDraftUserLeader", flowUserInfoVO.getNewMainDraftUserLeader());
|
||||
map.put("relatedUserList", Optional.ofNullable(flowUserInfoVO.getRelatedUser()).map(s -> Arrays.asList(s.split(","))).orElse(Collections.emptyList()));
|
||||
map.put("copyUser", flowUserInfoVO.getCopyUser());
|
||||
// 设置流程分支判断变量
|
||||
map.put("applicationCategory", initChange.getApplicationCategory());
|
||||
map.put("projectType", initChange.getProjectType());
|
||||
return map;
|
||||
}
|
||||
|
||||
public void startRunTask(InitChangeDataVO initChangeData) {
|
||||
List<ProcessEsInitChange> esInitChangeList = initChangeData.getDataList();
|
||||
// 校验企标编号是否冲突
|
||||
if (!esUtil.verifyEnStandardNumber(esInitChangeList.get(0).getOriginEnStandardNo())) {
|
||||
throw new JeroBootException("企标编号冲突,请重新生成");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InitChangeDataVO getHandleData(String taskId) {
|
||||
InitChangeDataVO initChangeDataVO = new InitChangeDataVO();
|
||||
@@ -114,6 +83,7 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl<ProcessEsInitCha
|
||||
|
||||
@Override
|
||||
public void startInitChange(InitChangeDataVO initChangeData) {
|
||||
// 执行流程发起前的操作
|
||||
this.startRunTask(initChangeData);
|
||||
|
||||
// 流程Key
|
||||
@@ -124,28 +94,13 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl<ProcessEsInitCha
|
||||
// 设置流程变量
|
||||
Map<String, Object> variables = setVariables(initChangeData);
|
||||
// 启动流程
|
||||
ProcessInstance processInstance = actFlowCommonService.startProcess(processDefinitionKey, initChangeData, variables);
|
||||
ProcessInstance processInstance = actFlowCommonService.startProcess(processDefinitionKey, variables);
|
||||
|
||||
// 获取流程实例ID
|
||||
String processDefinitionId = processInstance.getProcessDefinitionId();
|
||||
String processInstanceId = processInstance.getId();
|
||||
log.info("启动流程实例成功,流程定义ID为:{}", processDefinitionId);
|
||||
// 完成第一个任务
|
||||
List<Map<String, Object>> taskList = actFlowCommonService.myTaskList(userId);
|
||||
if (!CollectionUtils.isEmpty(taskList)) {
|
||||
for (Map<String, Object> map : taskList) {
|
||||
if (map.get("assignee").toString().equals(userId) &&
|
||||
map.get("processDefinitionId").toString().equals(processDefinitionId) &&
|
||||
map.get("processInstanceId").toString().equals(processInstanceId)) { // 添加这一行来进行更精确的匹配
|
||||
|
||||
log.info("当前用户ID:{},相关联的流程定义ID:{}", userId, map.get("processDefinitionId").toString());
|
||||
log.info("匹配到的任务ID:{}", map.get("taskId").toString());
|
||||
|
||||
actFlowCommonService.completeTask("同意", map.get("taskId").toString(), userId, map);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 自动完成第一个任务
|
||||
actFlowCommonService.autoCompleteFirstTask(userId, processInstanceId, processDefinitionId);
|
||||
// 设置流程实例Id
|
||||
for (ProcessEsInitChange esInitChange : esInitChangeList) {
|
||||
esInitChange.setProcessInstanceId(processInstance.getId());
|
||||
@@ -215,6 +170,35 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl<ProcessEsInitCha
|
||||
// processDraftService.saveBatch(draftList);
|
||||
}
|
||||
|
||||
public Map<String, Object> setVariables(InitChangeDataVO initChangeData) {
|
||||
FlowUserInfoVO flowUserInfoVO = initChangeData.getFlowUserInfoVO();
|
||||
ProcessEsInitChange initChange = initChangeData.getDataList().get(0);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
// 设置流程中各个节点的人
|
||||
map.put("createUser", UserUtils.getUserIdByUserName(flowUserInfoVO.getCreateUser()));
|
||||
map.put("contactUser", flowUserInfoVO.getContactUser());
|
||||
map.put("standardExpertList", Optional.ofNullable(flowUserInfoVO.getStandardExpert()).map(s -> Arrays.asList(s.split(","))).orElse(Collections.emptyList()));
|
||||
map.put("mainDraftUserLeader", flowUserInfoVO.getMainDraftUserLeader());
|
||||
map.put("mainDraftUserLeaderLeader", flowUserInfoVO.getMainDraftUserLeaderLeader());
|
||||
map.put("standardizationApprovalUser", flowUserInfoVO.getStandardizationApprovalUser());
|
||||
map.put("newMainDraftUserLeaderLeader", flowUserInfoVO.getNewMainDraftUserLeaderLeader());
|
||||
map.put("newMainDraftUserLeader", flowUserInfoVO.getNewMainDraftUserLeader());
|
||||
map.put("relatedUserList", Optional.ofNullable(flowUserInfoVO.getRelatedUser()).map(s -> Arrays.asList(s.split(","))).orElse(Collections.emptyList()));
|
||||
map.put("copyUser", flowUserInfoVO.getCopyUser());
|
||||
// 设置流程分支判断变量
|
||||
map.put("applicationCategory", initChange.getApplicationCategory());
|
||||
map.put("projectType", initChange.getProjectType());
|
||||
return map;
|
||||
}
|
||||
|
||||
public void startRunTask(InitChangeDataVO initChangeData) {
|
||||
List<ProcessEsInitChange> esInitChangeList = initChangeData.getDataList();
|
||||
// 校验企标编号是否冲突
|
||||
if (!esUtil.verifyEnStandardNumber(esInitChangeList.get(0).getOriginEnStandardNo())) {
|
||||
throw new JeroBootException("企标编号冲突,请重新生成");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeByProcessInstanceId(String processInstanceId) {
|
||||
LambdaUpdateWrapper<ProcessEsInitChange> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
|
||||
Reference in New Issue
Block a user