mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 18:28:43 +08:00 
			
		
		
		
	【代码评审】工作流:快搭部分的 code review
This commit is contained in:
		| @@ -16,10 +16,10 @@ import java.util.Arrays; | ||||
| @AllArgsConstructor | ||||
| public enum BpmApproveMethodEnum implements IntArrayValuable { | ||||
|  | ||||
|     RANDOM_SELECT_ONE_APPROVE(1, "随机挑选一人审批"), | ||||
|     APPROVE_BY_RATIO(2, "多人会签(按通过比例)"), // 会签(按通过比例) | ||||
|     ANY_APPROVE(3, "多人或签(一人通过或拒绝)"), // 或签(通过只需一人,拒绝只需一人) | ||||
|     SEQUENTIAL_APPROVE(4, "依次审批"); // 依次审批 | ||||
|     RANDOM(1, "随机挑选一人审批"), | ||||
|     RATIO(2, "多人会签(按通过比例)"), // 会签(按通过比例) | ||||
|     ANY(3, "多人或签(一人通过或拒绝)"), // 或签(通过只需一人,拒绝只需一人) | ||||
|     SEQUENTIAL(4, "依次审批"); // 依次审批 | ||||
|  | ||||
|     /** | ||||
|      * 审批方式 | ||||
|   | ||||
| @@ -16,7 +16,7 @@ import java.util.Arrays; | ||||
| @AllArgsConstructor | ||||
| public enum BpmUserTaskRejectHandlerType implements IntArrayValuable { | ||||
|  | ||||
|     FINISH_PROCESS(1, "终止流程"), | ||||
|     FINISH_PROCESS_INSTANCE(1, "终止流程"), | ||||
|     RETURN_USER_TASK(2, "驳回到指定任务节点"); | ||||
|  | ||||
|     private final Integer type; | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import lombok.Getter; | ||||
|  | ||||
| import java.util.Arrays; | ||||
|  | ||||
| // TODO @jason:BpmUserTaskTimeoutHandlerTypeEnum 会不会更匹配哈 | ||||
| /** | ||||
|  * 用户任务超时处理执行动作枚举 | ||||
|  * | ||||
| @@ -16,9 +17,9 @@ import java.util.Arrays; | ||||
| @AllArgsConstructor | ||||
| public enum BpmUserTaskTimeoutActionEnum implements IntArrayValuable { | ||||
|  | ||||
|     AUTO_REMINDER(1,"自动提醒"), | ||||
|     AUTO_APPROVE(2, "自动同意"), | ||||
|     AUTO_REJECT(3, "自动拒绝"); | ||||
|     REMINDER(1,"自动提醒"), | ||||
|     APPROVE(2, "自动同意"), | ||||
|     REJECT(3, "自动拒绝"); | ||||
|  | ||||
|     private final Integer action; | ||||
|     private final String name; | ||||
|   | ||||
| @@ -61,16 +61,18 @@ public class BpmTaskRespVO { | ||||
|     private Long formId; | ||||
|     @Schema(description = "表单名字", example = "请假表单") | ||||
|     private String formName; | ||||
|     @Schema(description = "表单的配置-JSON 字符串") | ||||
|     @Schema(description = "表单的配置,JSON 字符串") | ||||
|     private String formConf; | ||||
|     @Schema(description = "表单项的数组") | ||||
|     private List<String> formFields; | ||||
|     @Schema(description = "提交的表单值", requiredMode = Schema.RequiredMode.REQUIRED) | ||||
|     private Map<String, Object> formVariables; | ||||
|     // TODO @jason:fieldsPermissions | ||||
|     @Schema(description = "表单字段权限值") | ||||
|     private Map<String,String> fieldsPermission; | ||||
|     private Map<String, String> fieldsPermission; | ||||
|     // TODO @jason:buttonsSettings | ||||
|     @Schema(description = "操作按钮设置值") | ||||
|     private Map<Integer,OperationButtonSetting> buttonsSetting; | ||||
|     private Map<Integer, OperationButtonSetting> buttonsSetting; | ||||
|  | ||||
|     @Data | ||||
|     @Schema(description = "流程实例") | ||||
|   | ||||
| @@ -111,8 +111,8 @@ public interface BpmTaskConvert { | ||||
|                 taskVO.setOwnerUser(BeanUtils.toBean(ownerUser, BpmProcessInstanceRespVO.User.class)); | ||||
|                 findAndThen(deptMap, ownerUser.getDeptId(), dept -> taskVO.getOwnerUser().setDeptName(dept.getName())); | ||||
|             } | ||||
|             if(BpmTaskStatusEnum.RUNNING.getStatus().equals(taskStatus)){ | ||||
|                 // 设置表单权限 TODO @芋艿 是不是还要加一个全局的权限 基于 processInstance 的权限 | ||||
|             if (BpmTaskStatusEnum.RUNNING.getStatus().equals(taskStatus)){ | ||||
|                 // 设置表单权限 TODO @芋艿 是不是还要加一个全局的权限 基于 processInstance 的权限;回复:可能不需要,但是发起人,需要有个权限配置 | ||||
|                 taskVO.setFieldsPermission(BpmnModelUtils.parseFormFieldsPermission(bpmnModel, task.getTaskDefinitionKey())); | ||||
|                 // 操作按钮设置 | ||||
|                 taskVO.setButtonsSetting(BpmnModelUtils.parseButtonsSetting(bpmnModel, task.getTaskDefinitionKey())); | ||||
|   | ||||
| @@ -12,7 +12,9 @@ import org.springframework.stereotype.Component; | ||||
| import java.util.Set; | ||||
|  | ||||
| /** | ||||
|  * 发起人自己 {@link BpmTaskCandidateUserStrategy} 实现类。 用于需要发起人信息复核等场景 | ||||
|  * 发起人自己 {@link BpmTaskCandidateUserStrategy} 实现类 | ||||
|  * | ||||
|  * 适合场景:用于需要发起人信息复核等场景 | ||||
|  * | ||||
|  * @author jason | ||||
|  */ | ||||
|   | ||||
| @@ -35,6 +35,7 @@ public interface BpmnModelConstants { | ||||
|      */ | ||||
|     String BOUNDARY_EVENT_TYPE = "boundaryEventType"; | ||||
|  | ||||
|     // TODO @jason:这个命名,应该也要改哈 | ||||
|     /** | ||||
|      * BPMN ExtensionElement 的扩展属性,用于标记用户任务超时执行动作 | ||||
|      */ | ||||
| @@ -45,7 +46,6 @@ public interface BpmnModelConstants { | ||||
|      * BPMN ExtensionElement 的扩展属性,用于标记用户任务拒绝处理类型 | ||||
|      */ | ||||
|     String USER_TASK_REJECT_HANDLER_TYPE = "rejectHandlerType"; | ||||
|  | ||||
|     /** | ||||
|      * BPMN ExtensionElement 的扩展属性,用于标记用户任务拒绝后的回退的任务 Id | ||||
|      */ | ||||
| @@ -56,6 +56,7 @@ public interface BpmnModelConstants { | ||||
|      */ | ||||
|     String USER_TASK_APPROVE_METHOD = "approveMethod"; | ||||
|  | ||||
|     // TODO @jason:这个命名,可能有个 fieldsPermissions 更合适点。可能 formPermissions 会更更合适。 | ||||
|     /** | ||||
|      * BPMN ExtensionElement 流程表单字段权限元素, 用于标记字段权限 | ||||
|      */ | ||||
| @@ -65,7 +66,6 @@ public interface BpmnModelConstants { | ||||
|      * BPMN ExtensionElement Attribute, 用于标记表单字段 | ||||
|      */ | ||||
|     String FORM_FIELD_PERMISSION_ELEMENT_FIELD_ATTRIBUTE = "field"; | ||||
|  | ||||
|     /** | ||||
|      * BPMN ExtensionElement Attribute, 用于标记表单权限 | ||||
|      */ | ||||
| @@ -75,12 +75,10 @@ public interface BpmnModelConstants { | ||||
|      * BPMN ExtensionElement 操作按钮设置元素, 用于审批节点操作按钮设置 | ||||
|      */ | ||||
|     String BUTTON_SETTING_ELEMENT = "buttonsSettings"; | ||||
|  | ||||
|     /** | ||||
|      * BPMN ExtensionElement Attribute, 用于标记按钮编号 | ||||
|      */ | ||||
|     String BUTTON_SETTING_ELEMENT_ID_ATTRIBUTE = "id"; | ||||
|  | ||||
|     /** | ||||
|      * BPMN ExtensionElement Attribute, 用于标记按钮显示名称 | ||||
|      */ | ||||
| @@ -91,14 +89,16 @@ public interface BpmnModelConstants { | ||||
|      */ | ||||
|     String BUTTON_SETTING_ELEMENT_ENABLE_ATTRIBUTE = "enable"; | ||||
|  | ||||
|     // TODO @芋艿:这里后面得关注下; | ||||
|     // TODO @jason:这个是不是可以删除啦 | ||||
|     /** | ||||
|      * BPMN End Event 节点 Id, 用于后端生成 End Event 节点 | ||||
|      */ | ||||
|     String END_EVENT_ID = "EndEvent_1"; | ||||
|  | ||||
|     // TODO @jason:这个是不是可以删除啦 | ||||
|     /** | ||||
|      * 支持转仿钉钉设计模型的 Bpmn 节点 | ||||
|      */ | ||||
|     Set<Class<? extends FlowNode>> SUPPORT_CONVERT_SIMPLE_FlOW_NODES = ImmutableSet.of(UserTask.class, EndEvent.class); | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -85,13 +85,13 @@ public class BpmTimerFiredEventListener extends AbstractFlowableEngineEventListe | ||||
|                     null, taskDefKey); | ||||
|             taskList.forEach(task -> { | ||||
|                 // 自动提醒 | ||||
|                 if (userTaskTimeoutAction == BpmUserTaskTimeoutActionEnum.AUTO_REMINDER) { | ||||
|                 if (userTaskTimeoutAction == BpmUserTaskTimeoutActionEnum.REMINDER) { | ||||
|                     TodoTaskReminderMessage message = new TodoTaskReminderMessage().setTenantId(Long.parseLong(task.getTenantId())) | ||||
|                             .setUserId(Long.parseLong(task.getAssignee())).setTaskName(task.getName()); | ||||
|                     todoTaskReminderProducer.sendReminderMessage(message); | ||||
|                 } | ||||
|                 // 自动同意 | ||||
|                 if (userTaskTimeoutAction == BpmUserTaskTimeoutActionEnum.AUTO_APPROVE) { | ||||
|                 if (userTaskTimeoutAction == BpmUserTaskTimeoutActionEnum.APPROVE) { | ||||
|                     // TODO @芋艿 这个上下文如何清除呢? 任务通过后, BpmProcessInstanceEventListener 会有回调 | ||||
|                     TenantContextHolder.setTenantId(Long.parseLong(task.getTenantId())); | ||||
|                     TenantContextHolder.setIgnore(false); | ||||
| @@ -100,7 +100,7 @@ public class BpmTimerFiredEventListener extends AbstractFlowableEngineEventListe | ||||
|                     bpmTaskService.approveTask(Long.parseLong(task.getAssignee()), req); | ||||
|                 } | ||||
|                 // 自动拒绝 | ||||
|                 if (userTaskTimeoutAction == BpmUserTaskTimeoutActionEnum.AUTO_REJECT) { | ||||
|                 if (userTaskTimeoutAction == BpmUserTaskTimeoutActionEnum.REJECT) { | ||||
|                     // TODO  @芋艿 这个上下文如何清除呢? 任务拒绝后, BpmProcessInstanceEventListener 会有回调 | ||||
|                     TenantContextHolder.setTenantId(Long.parseLong(task.getTenantId())); | ||||
|                     TenantContextHolder.setIgnore(false); | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import lombok.Data; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| // TODO @jason:这个貌似没用到,是不是可以删除啦 | ||||
| /** | ||||
|  * 仿钉钉流程设计器审批节点配置 Model | ||||
|  * | ||||
|   | ||||
| @@ -26,8 +26,10 @@ public class BpmnFormUtils { | ||||
|     private static final String CREATE_FORM_DISPLAY_ATTRIBUTE = "display"; | ||||
|     private static final String CREATE_FORM_DISABLED_ATTRIBUTE = "disabled"; | ||||
|  | ||||
|     // TODO @jason:这个方法,还要哇? | ||||
|     /** | ||||
|      * 修改 form-create 表单组件字段权限规则: 包括可编辑、只读、隐藏规则 | ||||
|      * | ||||
|      * @param fields 字段规则 | ||||
|      * @param fieldsPermission 字段权限 | ||||
|      * @return 修改权限后的字段规则 | ||||
|   | ||||
| @@ -27,7 +27,7 @@ import static cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.s | ||||
| import static cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO.TimeoutHandler; | ||||
| import static cn.iocoder.yudao.module.bpm.enums.definition.BpmBoundaryEventType.USER_TASK_TIMEOUT; | ||||
| import static cn.iocoder.yudao.module.bpm.enums.definition.BpmSimpleModelNodeType.*; | ||||
| import static cn.iocoder.yudao.module.bpm.enums.definition.BpmUserTaskTimeoutActionEnum.AUTO_REMINDER; | ||||
| import static cn.iocoder.yudao.module.bpm.enums.definition.BpmUserTaskTimeoutActionEnum.REMINDER; | ||||
| import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants.*; | ||||
| import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.SimpleModelConstants.*; | ||||
| import static org.flowable.bpmn.constants.BpmnXMLConstants.*; | ||||
| @@ -356,7 +356,7 @@ public class SimpleModelUtils { | ||||
|         boundaryEvent.setAttachedToRef(userTask); | ||||
|         TimerEventDefinition eventDefinition = new TimerEventDefinition(); | ||||
|         eventDefinition.setTimeDuration(timeoutHandler.getTimeDuration()); | ||||
|         if (Objects.equals(AUTO_REMINDER.getAction(), timeoutHandler.getAction()) && | ||||
|         if (Objects.equals(REMINDER.getAction(), timeoutHandler.getAction()) && | ||||
|                 timeoutHandler.getMaxRemindCount() != null && timeoutHandler.getMaxRemindCount() > 1) { | ||||
|             // 最大提醒次数 | ||||
|             eventDefinition.setTimeCycle(String.format("R%d/%s", timeoutHandler.getMaxRemindCount(), timeoutHandler.getTimeDuration())); | ||||
| @@ -475,7 +475,7 @@ public class SimpleModelUtils { | ||||
|  | ||||
|     private static void processMultiInstanceLoopCharacteristics(Integer approveMethod, Integer approveRatio, UserTask userTask) { | ||||
|         BpmApproveMethodEnum bpmApproveMethodEnum = BpmApproveMethodEnum.valueOf(approveMethod); | ||||
|         if (bpmApproveMethodEnum == null || bpmApproveMethodEnum == BpmApproveMethodEnum.RANDOM_SELECT_ONE_APPROVE) { | ||||
|         if (bpmApproveMethodEnum == null || bpmApproveMethodEnum == BpmApproveMethodEnum.RANDOM) { | ||||
|             return; | ||||
|         } | ||||
|         // 添加审批方式的扩展属性 | ||||
| @@ -484,16 +484,16 @@ public class SimpleModelUtils { | ||||
|         MultiInstanceLoopCharacteristics multiInstanceCharacteristics = new MultiInstanceLoopCharacteristics(); | ||||
|         //  设置 collectionVariable。本系统用不到。会在 仅仅为了校验。 | ||||
|         multiInstanceCharacteristics.setInputDataItem("${coll_userList}"); | ||||
|         if (bpmApproveMethodEnum == BpmApproveMethodEnum.ANY_APPROVE) { | ||||
|         if (bpmApproveMethodEnum == BpmApproveMethodEnum.ANY) { | ||||
|             multiInstanceCharacteristics.setCompletionCondition(ANY_OF_APPROVE_COMPLETE_EXPRESSION); | ||||
|             multiInstanceCharacteristics.setSequential(false); | ||||
|             userTask.setLoopCharacteristics(multiInstanceCharacteristics); | ||||
|         } else if (bpmApproveMethodEnum == BpmApproveMethodEnum.SEQUENTIAL_APPROVE) { | ||||
|         } else if (bpmApproveMethodEnum == BpmApproveMethodEnum.SEQUENTIAL) { | ||||
|             multiInstanceCharacteristics.setCompletionCondition(ALL_APPROVE_COMPLETE_EXPRESSION); | ||||
|             multiInstanceCharacteristics.setSequential(true); | ||||
|             multiInstanceCharacteristics.setLoopCardinality("1"); | ||||
|             userTask.setLoopCharacteristics(multiInstanceCharacteristics); | ||||
|         } else if (bpmApproveMethodEnum == BpmApproveMethodEnum.APPROVE_BY_RATIO) { | ||||
|         } else if (bpmApproveMethodEnum == BpmApproveMethodEnum.RATIO) { | ||||
|             Assert.notNull(approveRatio, "通过比例不能为空"); | ||||
|             double approvePct = approveRatio / (double) 100; | ||||
|             multiInstanceCharacteristics.setCompletionCondition(String.format(APPROVE_BY_RATIO_COMPLETE_EXPRESSION, String.format("%.2f", approvePct))); | ||||
|   | ||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @@ -137,7 +137,10 @@ public interface BpmTaskService { | ||||
|      * @param executionId execution Id | ||||
|      * @param taskDefineKey 任务定义 Key | ||||
|      */ | ||||
|     List<Task> getRunningTaskListByProcessInstanceId(String processInstanceId, Boolean assigned, String executionId, String taskDefineKey); | ||||
|     List<Task> getRunningTaskListByProcessInstanceId(String processInstanceId, | ||||
|                                                      Boolean assigned, | ||||
|                                                      String executionId, | ||||
|                                                      String taskDefineKey); | ||||
|  | ||||
|     /** | ||||
|      * 获取当前任务的可回退的 UserTask 集合 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV