feat: 企标复审流程
This commit is contained in:
+1
-4
@@ -102,10 +102,7 @@ public class ProcessEsChangeServiceImpl extends ServiceImpl<ProcessEsChangeMappe
|
||||
}
|
||||
|
||||
public Map<String, Object> setVariables(ESChangeFlowUserVO flowUser) {
|
||||
boolean counterSign = StrUtil.isNotBlank(flowUser.getRelatedUser());
|
||||
HashMap<String, Object> map = new HashMap<>(this.setUserVariables(flowUser));
|
||||
actFlowCommonService.putIfNotNull(map, "counterSign", counterSign);
|
||||
return map;
|
||||
return new HashMap<>(this.setUserVariables(flowUser));
|
||||
}
|
||||
|
||||
public Map<String, Object> setUserVariables(ESChangeFlowUserVO flowUser) {
|
||||
|
||||
+3
-2
@@ -3,6 +3,7 @@ package com.jero.modules.activiti.process.esRecheck.entity.vo;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.jero.modules.activiti.process.common.entity.CommonVO;
|
||||
import com.jero.modules.activiti.process.esInitChange.entity.ProcessEsInitChange;
|
||||
import com.jero.modules.activiti.process.esRecheck.entity.ProcessEsRecheck;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@@ -17,8 +18,8 @@ public class ESRecheckDataVO {
|
||||
@JsonProperty("common")
|
||||
CommonVO common;
|
||||
|
||||
@JsonProperty("dataList")
|
||||
List<ProcessEsInitChange> data;
|
||||
@JsonProperty("data")
|
||||
ProcessEsRecheck data;
|
||||
|
||||
@JsonProperty("flowUser")
|
||||
ESRecheckFlowUserVO flowUser;
|
||||
|
||||
-5
@@ -15,11 +15,6 @@ public class ESRecheckFlowUserVO {
|
||||
@ApiModelProperty("主起草人")
|
||||
private String mainDraftUser;
|
||||
|
||||
// 相关人员
|
||||
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "username")
|
||||
@ApiModelProperty("相关人员")
|
||||
private String relatedUser;
|
||||
|
||||
// 主起草人主管级领导
|
||||
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "username")
|
||||
@ApiModelProperty("主起草人主管级领导")
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ public interface ProcessEsRecheckService extends IService<ProcessEsRecheck> {
|
||||
|
||||
void saveToDraft(ESRecheckDataVO recheckData);
|
||||
|
||||
ProcessEsRecheck getHandleData(String taskId);
|
||||
ESRecheckDataVO getHandleData(String taskId);
|
||||
|
||||
void approvalInitChange(ESRecheckDataVO recheckData, boolean pass);
|
||||
}
|
||||
|
||||
+188
-3
@@ -1,15 +1,39 @@
|
||||
package com.jero.modules.activiti.process.esRecheck.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.constant.enums.YesOrNoEnum;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.modules.activiti.entity.ProcessAll;
|
||||
import com.jero.modules.activiti.entity.ProcessNode;
|
||||
import com.jero.modules.activiti.enums.ProcessTypeEnum;
|
||||
import com.jero.modules.activiti.process.common.entity.CommonVO;
|
||||
import com.jero.modules.activiti.process.common.entity.ProcessDraft;
|
||||
import com.jero.modules.activiti.process.common.enums.ProcessType;
|
||||
import com.jero.modules.activiti.process.common.service.ActFlowCommonService;
|
||||
import com.jero.modules.activiti.process.common.service.ProcessDraftService;
|
||||
|
||||
import com.jero.modules.activiti.process.esRecheck.entity.ProcessEsRecheck;
|
||||
import com.jero.modules.activiti.process.esRecheck.entity.vo.ESRecheckDataVO;
|
||||
import com.jero.modules.activiti.process.esRecheck.entity.vo.ESRecheckFlowUserVO;
|
||||
import com.jero.modules.activiti.process.esRecheck.service.ProcessEsRecheckService;
|
||||
import com.jero.modules.activiti.process.esRecheck.mapper.ProcessEsRecheckMapper;
|
||||
import com.jero.modules.activiti.service.ProcessAllService;
|
||||
import com.jero.modules.activiti.service.ProcessNodeLinkService;
|
||||
import com.jero.modules.activiti.service.ProcessNodeService;
|
||||
import com.jero.modules.sys.utils.UserUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.activiti.engine.RuntimeService;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author ThinkBook
|
||||
* @description 针对表【process_es_recheck(企业标准)】的数据库操作Service实现
|
||||
@@ -21,24 +45,185 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
public class ProcessEsRecheckServiceImpl extends ServiceImpl<ProcessEsRecheckMapper, ProcessEsRecheck>
|
||||
implements ProcessEsRecheckService{
|
||||
|
||||
@Resource
|
||||
private ProcessAllService processAllService;
|
||||
|
||||
@Resource
|
||||
private ActFlowCommonService actFlowCommonService;
|
||||
|
||||
@Resource
|
||||
private ProcessDraftService processDraftService;
|
||||
|
||||
@Resource
|
||||
private ProcessNodeLinkService processNodeLinkService;
|
||||
|
||||
@Resource
|
||||
private ProcessNodeService processNodeService;
|
||||
|
||||
@Resource
|
||||
private RuntimeService runtimeService;
|
||||
|
||||
@Override
|
||||
public void startProcess(ESRecheckDataVO recheckData) {
|
||||
// 执行流程发起前的操作
|
||||
this.startRunTask(recheckData);
|
||||
// 流程Key
|
||||
String processDefinitionKey = ProcessType.ES_INIT_CHANGE.getProcessKey();
|
||||
// 当前用户Id
|
||||
String userId = UserUtils.getUserId();
|
||||
// 业务数据
|
||||
ProcessEsRecheck esArchive = recheckData.getData();
|
||||
// 通用数据
|
||||
CommonVO common = recheckData.getCommon();
|
||||
// 人员数据
|
||||
ESRecheckFlowUserVO flowUser = recheckData.getFlowUser();
|
||||
// 设置流程变量
|
||||
Map<String, Object> variables = this.setVariables(flowUser);
|
||||
// 启动流程
|
||||
ProcessInstance processInstance = actFlowCommonService.startProcess(processDefinitionKey, variables);
|
||||
// 获取流程实例ID
|
||||
String processDefinitionId = processInstance.getProcessDefinitionId();
|
||||
String processInstanceId = processInstance.getId();
|
||||
// 手动设置所有流程变量
|
||||
actFlowCommonService.setProcessVariables(processInstanceId, variables);
|
||||
// 自动完成第一个任务
|
||||
actFlowCommonService.autoCompleteFirstTask(userId, processInstanceId, processDefinitionId, common);
|
||||
// 设置流程实例Id
|
||||
esArchive.setProcessInstanceId(processInstanceId);
|
||||
// 保存到业务流程表
|
||||
save(esArchive);
|
||||
// 保存选人信息
|
||||
processNodeLinkService.saveNodeUserLink(processDefinitionId, processInstanceId, this.getUserMap(variables));
|
||||
// 根据流程实例id更新流程总表
|
||||
String prcName = common.getPrcName();
|
||||
String prcMes = common.getPrcMes();
|
||||
Date dueTime = common.getDueTime();
|
||||
Integer prcType = ProcessTypeEnum.ES_RECHECK.getValue();
|
||||
actFlowCommonService.updateProcessAll(processInstanceId, userId, prcName, prcMes, prcType, dueTime);
|
||||
}
|
||||
|
||||
public Map<String, Object> setVariables(ESRecheckFlowUserVO flowUser) {
|
||||
return new HashMap<>(this.setUserVariables(flowUser));
|
||||
}
|
||||
|
||||
public Map<String, Object> setUserVariables(ESRecheckFlowUserVO flowUser) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
// 使用一个通用方法来只在不为空时添加键值对
|
||||
actFlowCommonService.putIfNotNull(map, "standardizationUser", flowUser.getStandardizationUser());
|
||||
actFlowCommonService.putIfNotNull(map, "mainDraftUser", flowUser.getMainDraftUser());
|
||||
actFlowCommonService.putIfNotNull(map, "mainDraftUserLeader", flowUser.getMainDraftUserLeader());
|
||||
return map;
|
||||
}
|
||||
|
||||
private Map<String, Object> getUserMap(Map<String, Object> variables) {
|
||||
variables.remove("pass");
|
||||
return variables;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveToDraft(ESRecheckDataVO recheckData) {
|
||||
CommonVO commonVO = recheckData.getCommon();
|
||||
String taskId = commonVO.getTaskId();
|
||||
ProcessEsRecheck esArchive = recheckData.getData();
|
||||
saveOrUpdate(esArchive);
|
||||
// 先删后增
|
||||
LambdaUpdateWrapper<ProcessDraft> draftWrapper = new LambdaUpdateWrapper<>();
|
||||
if (StrUtil.isBlank(taskId)) {
|
||||
// 第一个节点点击保存没有taskId
|
||||
draftWrapper.eq(ProcessDraft::getPrcType, ProcessTypeEnum.ES_RECHECK.getValue());
|
||||
draftWrapper.eq(ProcessDraft::getCreateBy, UserUtils.getUserId());
|
||||
processDraftService.remove(draftWrapper);
|
||||
List<ProcessDraft> draftList = new ArrayList<>();
|
||||
ProcessDraft draft = new ProcessDraft();
|
||||
draft.setProjectId(esArchive.getId());
|
||||
draft.setPrcType(ProcessTypeEnum.ES_RECHECK.getValue());
|
||||
draftList.add(draft);
|
||||
processDraftService.saveBatch(draftList);
|
||||
} else {
|
||||
String processInstanceId = actFlowCommonService.getProcessInstanceIdByTaskId(taskId);
|
||||
draftWrapper.eq(ProcessDraft::getProjectId, esArchive.getId());
|
||||
processDraftService.remove(draftWrapper);
|
||||
List<ProcessDraft> draftList = new ArrayList<>();
|
||||
ProcessDraft draft = new ProcessDraft();
|
||||
draft.setProjectId(esArchive.getId());
|
||||
draft.setProcessInstanceId(processInstanceId);
|
||||
draft.setPrcName(commonVO.getPrcName());
|
||||
draft.setPrcType(ProcessTypeEnum.ES_RECHECK.getValue());
|
||||
draftList.add(draft);
|
||||
processDraftService.saveBatch(draftList);
|
||||
}
|
||||
}
|
||||
|
||||
public void startRunTask(ESRecheckDataVO recheckData) {
|
||||
// do nothing now
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProcessEsRecheck getHandleData(String taskId) {
|
||||
return null;
|
||||
public ESRecheckDataVO getHandleData(String taskId) {
|
||||
if (!actFlowCommonService.taskExists(taskId)) {
|
||||
throw new JeroBootException("任务不存在");
|
||||
}
|
||||
ESRecheckDataVO recheckData = new ESRecheckDataVO();
|
||||
// 使用流程引擎根据taskId找到流程实例Id
|
||||
String processInstanceId = actFlowCommonService.getProcessInstanceIdByTaskId(taskId);
|
||||
String processDefinitionId = actFlowCommonService.getProcessDefId(processInstanceId);
|
||||
// 获取流程通用数据
|
||||
ProcessAll process = processAllService.getByProcessInstanceId(processInstanceId);
|
||||
CommonVO commonVO = new CommonVO();
|
||||
commonVO.setPrcName(process.getPrcName());
|
||||
commonVO.setTaskId(process.getTaskId());
|
||||
commonVO.setPrcMes(process.getPrcMes());
|
||||
commonVO.setDueTime(process.getDueTime());
|
||||
recheckData.setCommon(commonVO);
|
||||
// 获取流程实例数据
|
||||
LambdaQueryWrapper<ProcessEsRecheck> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(ProcessEsRecheck::getProcessInstanceId, processInstanceId);
|
||||
lambdaQueryWrapper.eq(ProcessEsRecheck::getDelFlag, YesOrNoEnum.NO.getValue());
|
||||
ProcessEsRecheck data = getOne(lambdaQueryWrapper);
|
||||
recheckData.setData(data);
|
||||
// 选人组件内容填充
|
||||
recheckData.setFlowUser(this.getProcessUserInfo(processDefinitionId, processInstanceId));
|
||||
return recheckData;
|
||||
}
|
||||
|
||||
private ESRecheckFlowUserVO getProcessUserInfo(String processDefinitionId, String processInstanceId) {
|
||||
List<ProcessNode> nodeList = processNodeService.getNodeList(processDefinitionId, processInstanceId);
|
||||
ESRecheckFlowUserVO flowUser = new ESRecheckFlowUserVO();
|
||||
Map<String, ProcessNode> userMap = nodeList.stream().collect(Collectors.toMap(ProcessNode::getVariableName, node -> node));
|
||||
Optional.ofNullable(userMap.get("mainDraftUser")).ifPresent(node -> flowUser.setMainDraftUser(node.getLinkUserIds()));
|
||||
Optional.ofNullable(userMap.get("mainDraftUserLeader")).ifPresent(node -> flowUser.setMainDraftUserLeader(node.getLinkUserIds()));
|
||||
Optional.ofNullable(userMap.get("standardizationUser")).ifPresent(node -> flowUser.setStandardizationUser(node.getLinkUserIds()));
|
||||
return flowUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void approvalInitChange(ESRecheckDataVO recheckData, boolean pass) {
|
||||
|
||||
String userId = UserUtils.getUserId();
|
||||
CommonVO commonVO = recheckData.getCommon();
|
||||
ProcessEsRecheck data = recheckData.getData();
|
||||
String taskId = commonVO.getTaskId();
|
||||
if (StrUtil.isBlank(taskId) && !actFlowCommonService.taskExists(taskId)) {
|
||||
throw new JeroBootException("taskId为空或任务不存在");
|
||||
}
|
||||
String processInstanceId = actFlowCommonService.getProcessInstanceIdByTaskId(taskId);
|
||||
String processDefinitionId = actFlowCommonService.getProcessDefId(processInstanceId);
|
||||
if (pass) {
|
||||
if (data != null) {
|
||||
saveOrUpdate(data);
|
||||
ESRecheckFlowUserVO flowUserInfoVO = recheckData.getFlowUser();
|
||||
Map<String, Object> variables = this.setVariables(flowUserInfoVO);
|
||||
processNodeLinkService.saveNodeUserLink(processDefinitionId, processInstanceId, this.getUserMap(variables));
|
||||
actFlowCommonService.setProcessVariables(processInstanceId, variables);
|
||||
}
|
||||
runtimeService.setVariable(processInstanceId, "pass", true);
|
||||
} else {
|
||||
// 设置流程变量
|
||||
runtimeService.setVariable(processInstanceId, "pass", false);
|
||||
}
|
||||
// 更新审批表为完成,填充数据
|
||||
actFlowCommonService.updateApprovalInfo(commonVO, taskId, pass);
|
||||
//审批节点
|
||||
actFlowCommonService.completeTask(taskId, userId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user