feat: 年度制修订各部门主动上报流程更换通用人员显示
This commit is contained in:
+2
-1
@@ -6,6 +6,7 @@ import com.jero.modules.activiti.process.esAnnualReport.entity.ProcessEsAnnualRe
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author: Mzaxd
|
||||
@@ -21,6 +22,6 @@ public class AnnualReportDataVO {
|
||||
private List<ProcessEsAnnualReport> dataList;
|
||||
|
||||
@JsonProperty("flowUser")
|
||||
private AnnualReportFlowUserVO flowUserVO;
|
||||
private Map<String, Object> flowUser;
|
||||
|
||||
}
|
||||
|
||||
-40
@@ -1,40 +0,0 @@
|
||||
package com.jero.modules.activiti.process.esAnnualReport.entity.vo;
|
||||
|
||||
import com.jero.common.aspect.annotation.Dict;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author: Mzaxd
|
||||
* @Date: 2023/10/26 17:29
|
||||
*/
|
||||
@Data
|
||||
public class AnnualReportFlowUserVO {
|
||||
|
||||
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname")
|
||||
@ApiModelProperty("标准化工程师")
|
||||
private String standardEngineer;
|
||||
|
||||
// 部所联络人
|
||||
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname")
|
||||
@ApiModelProperty("个部所联络人")
|
||||
private String contactUserList;
|
||||
|
||||
// 标准专家
|
||||
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname")
|
||||
@ApiModelProperty("工作组联络人")
|
||||
private String workGroupUserList;
|
||||
|
||||
// 主起草人主管级领导
|
||||
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname")
|
||||
@ApiModelProperty("收集联络人主管级领导")
|
||||
private String collectUserLeader;
|
||||
|
||||
// 主起草人主管级领导上级领导
|
||||
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname")
|
||||
@ApiModelProperty("联络人主管级上级领导")
|
||||
private String contactUserLeaderLeader;
|
||||
|
||||
@ApiModelProperty("是否下发")
|
||||
private boolean distribute;
|
||||
}
|
||||
+38
-67
@@ -8,14 +8,12 @@ import com.jero.common.constant.enums.YesOrNoEnum;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.vo.SysDictItemCore;
|
||||
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.enums.ProcessType;
|
||||
import com.jero.modules.activiti.process.common.service.ActFlowCommonService;
|
||||
import com.jero.modules.activiti.process.esAnnualReport.entity.ProcessEsAnnualReport;
|
||||
import com.jero.modules.activiti.process.esAnnualReport.entity.vo.AnnualReportDataVO;
|
||||
import com.jero.modules.activiti.process.esAnnualReport.entity.vo.AnnualReportFlowUserVO;
|
||||
import com.jero.modules.activiti.process.esAnnualReport.mapper.ProcessEsAnnualReportMapper;
|
||||
import com.jero.modules.activiti.process.esAnnualReport.service.ProcessEsAnnualReportService;
|
||||
import com.jero.modules.activiti.process.esInitChange.entity.enums.ESPProjectType;
|
||||
@@ -69,9 +67,6 @@ public class ProcessEsAnnualReportServiceImpl extends ServiceImpl<ProcessEsAnnua
|
||||
@Resource
|
||||
private ProcessNodeLinkService processNodeLinkService;
|
||||
|
||||
@Resource
|
||||
private ProcessNodeService processNodeService;
|
||||
|
||||
@Resource
|
||||
private ProcessAllService processAllService;
|
||||
|
||||
@@ -89,15 +84,17 @@ public class ProcessEsAnnualReportServiceImpl extends ServiceImpl<ProcessEsAnnua
|
||||
CommonVO commonVO = annualReportData.getCommonVO();
|
||||
// 当前用户Id
|
||||
String userId = UserUtils.getUserId();
|
||||
//
|
||||
Map<String, Object> variables = annualReportData.getFlowUser();
|
||||
// 设置流程变量
|
||||
Map<String, Object> variables = this.setVariables(annualReportData);
|
||||
Map<String, Object> actVariables = this.setVariables(annualReportData);
|
||||
// 启动流程
|
||||
ProcessInstance processInstance = actFlowCommonService.startProcess(processDefinitionKey, variables);
|
||||
ProcessInstance processInstance = actFlowCommonService.startProcess(processDefinitionKey, actVariables);
|
||||
// 获取流程实例ID
|
||||
String processDefinitionId = processInstance.getProcessDefinitionId();
|
||||
String processInstanceId = processInstance.getId();
|
||||
// 手动设置所有流程变量
|
||||
actFlowCommonService.setProcessVariables(processInstanceId, variables);
|
||||
actFlowCommonService.setProcessVariables(processInstanceId, actVariables);
|
||||
// 自动完成第一个任务
|
||||
actFlowCommonService.autoCompleteFirstTask(userId, processInstanceId, processDefinitionId, commonVO);
|
||||
// 保存选人信息
|
||||
@@ -113,32 +110,32 @@ public class ProcessEsAnnualReportServiceImpl extends ServiceImpl<ProcessEsAnnua
|
||||
}
|
||||
|
||||
public Map<String, Object> setVariables(AnnualReportDataVO annualReportData) {
|
||||
AnnualReportFlowUserVO annualReportFlowUserVO = annualReportData.getFlowUserVO();
|
||||
Map<String, Object> actVariables = new HashMap<>();
|
||||
CommonVO commonVO = annualReportData.getCommonVO();
|
||||
// 设置流程中各个节点的人
|
||||
Map<String, Object> map = new HashMap<>(this.setUserVariables(annualReportFlowUserVO));
|
||||
// 设置流程分支判断变量
|
||||
map.put("processDescription", commonVO.getProcessDescription());
|
||||
return map;
|
||||
}
|
||||
|
||||
public Map<String, Object> setUserVariables(AnnualReportFlowUserVO userVO) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
// 使用一个通用方法来只在不为空时添加键值对
|
||||
actFlowCommonService.putIfNotNull(map, "standardEngineer", userVO.getStandardEngineer());
|
||||
actFlowCommonService.putIfNotNull(map, "contactUserList", Optional.ofNullable(userVO.getContactUserList()).map(s -> Arrays.asList(s.split(","))).orElse(null));
|
||||
return map;
|
||||
Map<String, Object> flowUser = annualReportData.getFlowUser();
|
||||
actFlowCommonService.putIfNotNull(actVariables, "contactUserList", Optional.ofNullable((String)flowUser.get("contactUserList")).map(s -> Arrays.asList(s.split(","))).orElse(null));
|
||||
if (flowUser.get("workGroupUserList") == null || StrUtil.isBlank((String)flowUser.get("workGroupUserList"))) {
|
||||
actFlowCommonService.putIfNotNull(actVariables, "distribute", false);
|
||||
} else {
|
||||
actFlowCommonService.putIfNotNull(actVariables, "distribute", true);
|
||||
String relatedUsers = (String) flowUser.get("relatedUserList");
|
||||
// 将relatedUserList从逗号拼接转为List
|
||||
List<String> relatedUserList = StrUtil.split(relatedUsers, ',');
|
||||
actFlowCommonService.putIfNotNull(actVariables, "relatedUserList", relatedUserList);
|
||||
}
|
||||
for (Map.Entry<String, Object> entry : flowUser.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
if (!key.equals("contactUserList") && !key.equals("workGroupUserList")) {
|
||||
actVariables.put(key, entry.getValue());
|
||||
}
|
||||
}
|
||||
actVariables.put("processDescription", commonVO.getProcessDescription());
|
||||
return actVariables;
|
||||
}
|
||||
|
||||
private Map<String, Object> getUserMap(Map<String, Object> variables) {
|
||||
variables.remove("pass");
|
||||
variables.remove("processDescription");
|
||||
// 转成逗号拼接
|
||||
variables.put("contactUserList", Optional.ofNullable((List<String>) variables.get("contactUserList"))
|
||||
.map(list -> String.join(",", list))
|
||||
.orElse(""));
|
||||
variables.put("workGroupUserList", Optional.ofNullable((List<String>) variables.get("workGroupUserList"))
|
||||
.map(list -> String.join(",", list))
|
||||
.orElse(""));
|
||||
return variables;
|
||||
}
|
||||
|
||||
@@ -150,7 +147,7 @@ public class ProcessEsAnnualReportServiceImpl extends ServiceImpl<ProcessEsAnnua
|
||||
public void approvalProcess(AnnualReportDataVO annualReportDataVO, boolean pass) {
|
||||
String userId = UserUtils.getUserId();
|
||||
CommonVO commonVO = annualReportDataVO.getCommonVO();
|
||||
AnnualReportFlowUserVO flowUserVO = annualReportDataVO.getFlowUserVO();
|
||||
Map<String, Object> flowUserVO = annualReportDataVO.getFlowUser();
|
||||
List<ProcessEsAnnualReport> dataList = annualReportDataVO.getDataList();
|
||||
String taskId = commonVO.getTaskId();
|
||||
// 获取task
|
||||
@@ -163,18 +160,22 @@ public class ProcessEsAnnualReportServiceImpl extends ServiceImpl<ProcessEsAnnua
|
||||
String processDefinitionId = actFlowCommonService.getProcessDefId(processInstanceId);
|
||||
switch (taskName) {
|
||||
case CONTACT_USER_DISTRIBUTE:
|
||||
boolean distribute = flowUserVO.isDistribute();
|
||||
boolean distribute = (boolean) flowUserVO.get("distribute");
|
||||
taskService.setVariableLocal(taskId, "distribute", distribute);
|
||||
// 获取是否分发
|
||||
if (distribute) {
|
||||
String workGroupUsers = (String)flowUserVO.get("workGroupUserList");
|
||||
// 将workGroupUserList从逗号拼接转为List
|
||||
List<String> workGroupUserList = StrUtil.split(workGroupUsers, ',');
|
||||
// 设置流程变量
|
||||
taskService.setVariableLocal(taskId, "workGroupUserList", flowUserVO.getWorkGroupUserList());
|
||||
taskService.setVariableLocal(taskId, "workGroupUserList", workGroupUserList);
|
||||
}else {
|
||||
String contactUserLeaderLeader = (String)flowUserVO.get("contactUserLeaderLeader");
|
||||
// 保存联络人主管级上级领导
|
||||
dataList.forEach(data -> data.setContactUserLeaderLeader(flowUserVO.getContactUserLeaderLeader()));
|
||||
dataList.forEach(data -> data.setContactUserLeaderLeader(contactUserLeaderLeader));
|
||||
// 不分发,入库存表
|
||||
saveBatch(dataList);
|
||||
taskService.setVariableLocal(taskId, "contactUserLeaderLeader", flowUserVO.getContactUserLeaderLeader());
|
||||
taskService.setVariableLocal(taskId, "contactUserLeaderLeader", contactUserLeaderLeader);
|
||||
}
|
||||
break;
|
||||
case WORK_GROUP_COLLECT:
|
||||
@@ -182,11 +183,11 @@ public class ProcessEsAnnualReportServiceImpl extends ServiceImpl<ProcessEsAnnua
|
||||
String contactUser = (String) runtimeService.getVariable(executionId, "contactUser");
|
||||
dataList.forEach(data -> data.setContactUser(contactUser));
|
||||
// 保存收集联络人主管级领导
|
||||
dataList.forEach(data -> data.setCollectUserLeader(flowUserVO.getCollectUserLeader()));
|
||||
dataList.forEach(data -> data.setCollectUserLeader((String)flowUserVO.get("collectUserLeader")));
|
||||
dataList.forEach(data -> data.setWorkGroupUser(UserUtils.getUserId()));
|
||||
saveBatch(dataList);
|
||||
// 设置下一个节点的审批人流程变量
|
||||
taskService.setVariableLocal(taskId, "collectUserLeader", flowUserVO.getCollectUserLeader());
|
||||
taskService.setVariableLocal(taskId, "collectUserLeader", flowUserVO.get("collectUserLeader"));
|
||||
break;
|
||||
case CONTACT_USER_COLLECT:
|
||||
// 先删后增
|
||||
@@ -196,18 +197,7 @@ public class ProcessEsAnnualReportServiceImpl extends ServiceImpl<ProcessEsAnnua
|
||||
saveBatch(dataList);
|
||||
break;
|
||||
}
|
||||
if (pass) {
|
||||
if (flowUserVO != null) {
|
||||
Map<String, Object> userMap = new HashMap<>(this.setUserVariables(flowUserVO));
|
||||
processNodeLinkService.saveNodeUserLink(processDefinitionId, processInstanceId, userMap);
|
||||
Map<String, Object> variables = setUserVariables(flowUserVO);
|
||||
actFlowCommonService.setProcessVariables(processInstanceId, variables);
|
||||
}
|
||||
runtimeService.setVariable(processInstanceId, "pass", true);
|
||||
} else {
|
||||
// 设置流程变量
|
||||
runtimeService.setVariable(processInstanceId, "pass", false);
|
||||
}
|
||||
runtimeService.setVariable(processInstanceId, "pass", pass);
|
||||
// 更新审批表为完成,填充数据
|
||||
actFlowCommonService.updateApprovalInfo(commonVO, taskId, pass);
|
||||
// 审批节点
|
||||
@@ -276,28 +266,9 @@ public class ProcessEsAnnualReportServiceImpl extends ServiceImpl<ProcessEsAnnua
|
||||
annualReportDataVO.setDataList(list(wrapper));
|
||||
break;
|
||||
}
|
||||
// 选人组件内容填充
|
||||
annualReportDataVO.setFlowUserVO(this.getProcessUserInfo(processDefinitionId, processInstanceId));
|
||||
return annualReportDataVO;
|
||||
}
|
||||
|
||||
private AnnualReportFlowUserVO getProcessUserInfo(String processDefinitionId, String processInstanceId) {
|
||||
List<ProcessNode> nodeList = processNodeService.getNodeList(processDefinitionId, processInstanceId);
|
||||
AnnualReportFlowUserVO annualReportFlowUserVO = new AnnualReportFlowUserVO();
|
||||
Map<String, ProcessNode> userMap = nodeList.stream()
|
||||
.collect(Collectors.groupingBy(ProcessNode::getVariableName))
|
||||
.values()
|
||||
.stream()
|
||||
.map(nodes -> nodes.get(0)) // 选择每组的第一个元素
|
||||
.collect(Collectors.toMap(ProcessNode::getVariableName, node -> node));
|
||||
Optional.ofNullable(userMap.get("standardEngineer")).ifPresent(node -> annualReportFlowUserVO.setStandardEngineer(node.getLinkUserIds()));
|
||||
Optional.ofNullable(userMap.get("contactUserList")).ifPresent(node -> annualReportFlowUserVO.setContactUserList(node.getLinkUserIds()));
|
||||
Optional.ofNullable(userMap.get("workGroupUserList")).ifPresent(node -> annualReportFlowUserVO.setWorkGroupUserList(node.getLinkUserIds()));
|
||||
Optional.ofNullable(userMap.get("collectUserLeader")).ifPresent(node -> annualReportFlowUserVO.setCollectUserLeader(node.getLinkUserIds()));
|
||||
Optional.ofNullable(userMap.get("contactUserLeaderLeader")).ifPresent(node -> annualReportFlowUserVO.setContactUserLeaderLeader(node.getLinkUserIds()));
|
||||
return annualReportFlowUserVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> importData(MultipartFile file) {
|
||||
List<SysDictItemCore> listDict = commonAPI.getDictItemAll();
|
||||
|
||||
Reference in New Issue
Block a user