fix(标准解读流程): 加签
This commit is contained in:
@@ -170,4 +170,6 @@ public class ResultCommon {
|
||||
|
||||
// 流程已分发,禁止驳回
|
||||
public static final String PROCESS_ALREADY_DISTRIBUTED = "process.already.distributed";
|
||||
// 不是会签节点任务
|
||||
public static final String PROCESS_NOT_COUNTERSIGNATURE = "process.not.countersignature";
|
||||
}
|
||||
|
||||
+4
-4
@@ -45,10 +45,6 @@ public class StandardInterpretCommon {
|
||||
* 解读人填写信息(分发)
|
||||
*/
|
||||
public static final String INTERPRETING_PEOPLE_FILLOUT = "interpreting_people_fillout";
|
||||
/**
|
||||
* 标准主解读人填写解读信息(不分发)
|
||||
*/
|
||||
public static final String MASTER_INTERPRET_FILLOUT = "master_interpret_fillout";
|
||||
/**
|
||||
* 标准主解读人审核(分发)
|
||||
*/
|
||||
@@ -103,6 +99,10 @@ public class StandardInterpretCommon {
|
||||
* 会签
|
||||
*/
|
||||
public static final String JOINTLY_SIGN_LIST = "jointlySignList";
|
||||
/**
|
||||
* 会签(每人)
|
||||
*/
|
||||
public static final String JOINTLY_SIGN = "jointlySign";
|
||||
/**
|
||||
* 部门科室经理
|
||||
*/
|
||||
|
||||
+19
-19
@@ -39,6 +39,7 @@ import com.jero.modules.activiti.process.standardinterpret.vo.StandardInterpretF
|
||||
import com.jero.modules.activiti.service.ProcessAllService;
|
||||
import com.jero.modules.activiti.service.ProcessApprovalRecordService;
|
||||
import com.jero.modules.activiti.service.ProcessNodeLinkService;
|
||||
import com.jero.modules.activiti.util.ActivityCountersign;
|
||||
import com.jero.modules.laws.documenttool.entity.LawsDocumentSplit;
|
||||
import com.jero.modules.laws.documenttool.mapper.DocumentSplitMapper;
|
||||
import com.jero.modules.laws.documenttool.mapper.LawsDocumentSplitMapper;
|
||||
@@ -58,6 +59,8 @@ import com.jero.modules.system.service.ISysDepartService;
|
||||
import com.jero.modules.system.service.ISysDictService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.activiti.engine.ManagementService;
|
||||
import org.activiti.engine.RepositoryService;
|
||||
import org.activiti.engine.RuntimeService;
|
||||
import org.activiti.engine.TaskService;
|
||||
import org.activiti.engine.delegate.DelegateTask;
|
||||
@@ -105,6 +108,7 @@ public class StandardInterpretFlowServiceImpl implements StandardInterpretFlowSe
|
||||
private final RuntimeService runtimeService;
|
||||
private final TaskService taskService;
|
||||
private final ProcessAllService processAllService;
|
||||
private final RepositoryService repositoryService;
|
||||
private final ProcessApprovalRecordService processApprovalRecordService;
|
||||
private final ProcessNodeLinkService processNodeLinkService;
|
||||
private final ProcessStandardInterpretService processStandardInterpretService;
|
||||
@@ -121,10 +125,14 @@ public class StandardInterpretFlowServiceImpl implements StandardInterpretFlowSe
|
||||
private final LawsDocumentSplitMapper lawsDocumentSplitMapper;
|
||||
private final SarFileSplitItemsValEOMapper sarFileSplitItemsValEOMapper;
|
||||
private final IDocumentSplitService documentSplitService;
|
||||
private final ManagementService managementService;
|
||||
|
||||
private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
private final List<String> tempList = new ArrayList<>();
|
||||
|
||||
private String taskId;
|
||||
private String userId;
|
||||
|
||||
@Override
|
||||
public void flowStart(StandardInterpretFlowDTO standardInterpretFlowDTO) {
|
||||
// 流程信息
|
||||
@@ -849,25 +857,17 @@ public class StandardInterpretFlowServiceImpl implements StandardInterpretFlowSe
|
||||
new LambdaQueryWrapper<ProcessStandardInterpret>()
|
||||
.eq(ProcessStandardInterpret::getProjectId, projectId));
|
||||
if (!Objects.isNull(processStandardInterpret)){
|
||||
String newCountersignPersonIds = processStandardInterpret.getCountersignPersonIds() + "," + userId;
|
||||
// 更新会签用户
|
||||
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||
runtimeService.setVariable(task.getExecutionId(), StandardInterpretCommon.JOINTLY_SIGN_LIST,
|
||||
Arrays.asList(newCountersignPersonIds.split(",")));
|
||||
|
||||
taskService.addCandidateUser(taskId, newCountersignPersonIds);
|
||||
// 增加会签数量
|
||||
Integer all = (Integer) taskService.getVariable(taskId, "nrOfInstances");
|
||||
taskService.setVariable(taskId, "nrOfInstances", all + 1);
|
||||
System.out.println("===================="+task);
|
||||
|
||||
List<Task> subTasks = taskService.createTaskQuery().executionId(task.getExecutionId()).list();
|
||||
|
||||
|
||||
processStandardInterpretService.update(
|
||||
new LambdaUpdateWrapper<ProcessStandardInterpret>()
|
||||
.eq(ProcessStandardInterpret::getId, processStandardInterpret.getId())
|
||||
.set(ProcessStandardInterpret::getCountersignPersonIds, newCountersignPersonIds));
|
||||
Boolean b = managementService.executeCommand(
|
||||
new ActivityCountersign(taskId, userId, StandardInterpretCommon.JOINTLY_SIGN));
|
||||
if (Boolean.TRUE.equals(b)){
|
||||
// 处理业务表
|
||||
String newCountersignPersonIds = processStandardInterpret.getCountersignPersonIds() + "," + userId;
|
||||
// 更新会签人员信息
|
||||
processStandardInterpretService.update(
|
||||
new LambdaUpdateWrapper<ProcessStandardInterpret>()
|
||||
.eq(ProcessStandardInterpret::getId, processStandardInterpret.getId())
|
||||
.set(ProcessStandardInterpret::getCountersignPersonIds, newCountersignPersonIds));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.jero.modules.activiti.util;
|
||||
|
||||
import com.jero.common.api.vo.ResultCommon;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.util.SpringContextUtils;
|
||||
import org.activiti.bpmn.model.BpmnModel;
|
||||
import org.activiti.bpmn.model.Process;
|
||||
import org.activiti.bpmn.model.UserTask;
|
||||
import org.activiti.engine.RepositoryService;
|
||||
import org.activiti.engine.RuntimeService;
|
||||
import org.activiti.engine.TaskService;
|
||||
import org.activiti.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior;
|
||||
import org.activiti.engine.impl.context.Context;
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.ExecutionEntityImpl;
|
||||
import org.activiti.engine.impl.persistence.entity.ExecutionEntityManager;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntityImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @ClassName: ActivityCountersign
|
||||
* @Description: 会签节点加签
|
||||
* @Author: yjz
|
||||
* @Date: 2024-07-15 15:34
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class ActivityCountersign implements Command<Boolean> {
|
||||
|
||||
// 任务ID
|
||||
private final String taskId;
|
||||
// 用户ID,多个逗号分割
|
||||
private final String userIds;
|
||||
// 会签节点人员变量
|
||||
private final String assignee;
|
||||
// 任务列表下标
|
||||
private static final String LOOP_COUNTER = "loopCounter";
|
||||
// 任务总个数
|
||||
private static final String NR_OF_INSTANCES = "nrOfInstances";
|
||||
// 当前活跃任务个数(未完成)
|
||||
private static final String NR_OF_ACTIVE_INSTANCES = "nrOfActiveInstances";
|
||||
private final TaskService taskService;
|
||||
private final RuntimeService runtimeService;
|
||||
private final RepositoryService repositoryService;
|
||||
private final Logger logger = LoggerFactory.getLogger(ActivityCountersign.class);
|
||||
|
||||
public ActivityCountersign(String taskId, String userId, String assignee) {
|
||||
this.taskId = taskId;
|
||||
this.userIds = userId;
|
||||
this.assignee = assignee;
|
||||
this.runtimeService = SpringContextUtils.getBean(RuntimeService.class);
|
||||
this.taskService = SpringContextUtils.getBean(TaskService.class);
|
||||
this.repositoryService = SpringContextUtils.getBean(RepositoryService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean execute(CommandContext commandContext) {
|
||||
TaskEntityImpl task = (TaskEntityImpl) taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||
ExecutionEntityImpl execution = (ExecutionEntityImpl) runtimeService.createExecutionQuery()
|
||||
.executionId(task.getExecutionId()).singleResult();
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
|
||||
Process process = bpmnModel.getProcesses().get(0);
|
||||
|
||||
UserTask userTask = (UserTask) process.getFlowElement(task.getTaskDefinitionKey());
|
||||
|
||||
if (userTask.getLoopCharacteristics() == null) {
|
||||
throw new JeroBootException(ResultCommon.PROCESS_NOT_COUNTERSIGNATURE);
|
||||
}
|
||||
|
||||
// 获取父级
|
||||
ExecutionEntityImpl parentNode = execution.getParent();
|
||||
|
||||
// 获取流程变量
|
||||
// 任务总个数
|
||||
int nrOfInstances = (int) runtimeService.getVariable(parentNode.getId(), NR_OF_INSTANCES);
|
||||
// 当前活跃任务个数(未完成)
|
||||
int nrOfActiveInstances =
|
||||
(int) runtimeService.getVariable(parentNode.getId(), NR_OF_ACTIVE_INSTANCES);
|
||||
|
||||
// 获取管理器
|
||||
ExecutionEntityManager executionEntityManager = Context.getCommandContext().getExecutionEntityManager();
|
||||
|
||||
Object behavior = userTask.getBehavior();
|
||||
if (behavior instanceof ParallelMultiInstanceBehavior) {
|
||||
String[] userIdList = userIds.split(",");
|
||||
// 更新 任务总个数
|
||||
runtimeService.setVariable(parentNode.getId(), NR_OF_INSTANCES,
|
||||
nrOfInstances + userIdList.length);
|
||||
// 更新 当前活跃任务个数(未完成)
|
||||
runtimeService.setVariable(parentNode.getId(), NR_OF_ACTIVE_INSTANCES,
|
||||
nrOfActiveInstances + userIdList.length);
|
||||
|
||||
// 加签
|
||||
for (String userId : userIdList) {
|
||||
// 创建子任务
|
||||
ExecutionEntity newExecution = executionEntityManager.createChildExecution(parentNode);
|
||||
newExecution.setActive(true);
|
||||
newExecution.setVariableLocal(LOOP_COUNTER, nrOfInstances);
|
||||
newExecution.setVariableLocal(assignee, userId);
|
||||
newExecution.setCurrentFlowElement(userTask);
|
||||
// 任务总个数 +1
|
||||
nrOfInstances++;
|
||||
// 推入时间表序列
|
||||
Context.getAgenda().planContinueMultiInstanceOperation(newExecution);
|
||||
logger.info("=============task:[{}] 加签:[{}]=============", taskId, userId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -82,3 +82,4 @@ assess.delete.error2=When there is data under evaluation in the project, deletio
|
||||
new.en.standard.number.conflict=The new enterprise standard number is duplicated with the existing enterprise standard number, please modify and submit it again
|
||||
|
||||
process.already.distributed=The process has been distributed, do not reject!
|
||||
process.not.countersignature=It is not a countersign node task!
|
||||
|
||||
@@ -82,3 +82,4 @@ assess.delete.error2=\u9879\u76EE\u4E2D\u6709\u8BC4\u4F30\u4E2D\u7684\u6570\u636
|
||||
new.en.standard.number.conflict=\u8BE5\u65B0\u4F01\u6807\u7F16\u53F7\u4E0E\u5DF2\u5B58\u5728\u7684\u4F01\u6807\u7F16\u53F7\u91CD\u590D\uFF0C\u8BF7\u91CD\u65B0\u4FEE\u6539\u63D0\u4EA4
|
||||
|
||||
process.already.distributed=\u6D41\u7A0B\u5DF2\u5206\u53D1,\u7981\u6B62\u9A73\u56DE!
|
||||
process.not.countersignature=\u4E0D\u662F\u4F1A\u7B7E\u8282\u70B9\u4EFB\u52A1!
|
||||
|
||||
Reference in New Issue
Block a user