mirror of
				https://github.com/YunaiV/ruoyi-vue-pro.git
				synced 2025-10-30 10:05:59 +08:00 
			
		
		
		
	bpm:code review 快搭实现
This commit is contained in:
		| @ -13,14 +13,22 @@ import lombok.Getter; | ||||
| @AllArgsConstructor | ||||
| public enum BpmFieldPermissionEnum { | ||||
|  | ||||
|     // TODO @jason:改成 WRITE、READ、NONE,更符合权限的感觉哈 | ||||
|     EDITABLE(1, "可编辑"), | ||||
|     READONLY(2, "只读"), | ||||
|     HIDE(3, "隐藏"); | ||||
|  | ||||
|     /** | ||||
|      * 权限 | ||||
|      */ | ||||
|     private final Integer permission; | ||||
|     /** | ||||
|      * 名字 | ||||
|      */ | ||||
|     private final String name; | ||||
|  | ||||
|     public static BpmFieldPermissionEnum valueOf(Integer permission) { | ||||
|         return ArrayUtil.firstMatch(item -> item.getPermission().equals(permission), values()); | ||||
|     } | ||||
|  | ||||
| } | ||||
|  | ||||
| @ -38,6 +38,7 @@ public enum BpmSimpleModelNodeType implements IntArrayValuable { | ||||
|  | ||||
|     /** | ||||
|      * 判断是否为分支节点 | ||||
|      * | ||||
|      * @param type 节点类型 | ||||
|      */ | ||||
|     public static boolean isBranchNode(Integer type) { | ||||
|  | ||||
| @ -141,7 +141,7 @@ public class BpmTaskController { | ||||
|         // 获得 BpmnModel | ||||
|         BpmnModel bpmnModel = bpmProcessDefinitionService.getProcessDefinitionBpmnModel(processInstance.getProcessDefinitionId()); | ||||
|         return success(BpmTaskConvert.INSTANCE.buildTaskListByProcessInstanceId(taskList, processInstance, | ||||
|                 formMap, userMap, deptMap,bpmnModel)); | ||||
|                 formMap, userMap, deptMap, bpmnModel)); | ||||
|     } | ||||
|  | ||||
|     @PutMapping("/approve") | ||||
|  | ||||
| @ -95,6 +95,7 @@ public interface BpmTaskConvert { | ||||
|             BpmFormDO form = MapUtil.get(formMap, NumberUtils.parseLong(task.getFormKey()), BpmFormDO.class); | ||||
|             if (form != null) { | ||||
|                 // 测试一下权限处理 | ||||
|                 // TODO @jason:这里是不是还没实现完哈? | ||||
| //                List<String> afterChangedFields = BpmnFormUtils.changeCreateFormFiledPermissionRule(form.getFields(), | ||||
| //                        BpmnModelUtils.parseFormFieldsPermission(bpmnModel, task.getTaskDefinitionKey())); | ||||
|  | ||||
|  | ||||
| @ -1,5 +1,6 @@ | ||||
| package cn.iocoder.yudao.module.bpm.framework.flowable.core.enums; | ||||
|  | ||||
| // TODO @jason:这个类,挪到 BpmnModelConstants 里,会不会好点,因为后续 BPMN 标准也需要使用这些字段哈; | ||||
| /** | ||||
|  * 仿钉钉快搭 JSON 常量信息 | ||||
|  * | ||||
| @ -7,18 +8,20 @@ package cn.iocoder.yudao.module.bpm.framework.flowable.core.enums; | ||||
|  */ | ||||
| public interface SimpleModelConstants { | ||||
|  | ||||
|     // TODO @jason:改成 FORM_FIELD_PERMISSION_ELEMENT 会不会更精准哈; | ||||
|     /** | ||||
|      * 流程表单字段权限, 用于标记字段权限 | ||||
|      */ | ||||
|     String FIELDS_PERMISSION = "fieldsPermission"; | ||||
|  | ||||
|     // TODO @jason:改成 FORM_FIELD_PERMISSION_ELEMENT_FIELD_ATTRIBUTE 会不会更精准哈; | ||||
|     /** | ||||
|      * 字段属性 | ||||
|      */ | ||||
|     String FIELD_ATTRIBUTE = "field"; | ||||
|  | ||||
|     // TODO @jason:改成 FORM_FIELD_PERMISSION_ELEMENT_PERMISSION_ATTRIBUTE 会不会更精准哈; | ||||
|     /** | ||||
|      * 权限属性 | ||||
|      */ | ||||
|     String PERMISSION_ATTRIBUTE = "permission"; | ||||
|  | ||||
| } | ||||
|  | ||||
| @ -25,11 +25,12 @@ public class BpmnModelUtils { | ||||
|     public static Integer parseCandidateStrategy(FlowElement userTask) { | ||||
|         Integer candidateStrategy = NumberUtils.parseInt(userTask.getAttributeValue( | ||||
|                 BpmnModelConstants.NAMESPACE, BpmnModelConstants.USER_TASK_CANDIDATE_STRATEGY)); | ||||
|         // @芋艿 尝试从 ExtensionElement 取. 后续相关扩展是否都可以 存 extensionElement。 如表单权限。 按钮权限 | ||||
|         // TODO @芋艿 尝试从 ExtensionElement 取. 后续相关扩展是否都可以 存 extensionElement。 如表单权限。 按钮权限 | ||||
|         if (candidateStrategy == null) { | ||||
|             ExtensionElement element = CollUtil.getFirst(userTask.getExtensionElements().get(BpmnModelConstants.USER_TASK_CANDIDATE_STRATEGY)); | ||||
|             // TODO @jason:改成下面这样,是不是看着更简洁哈 | ||||
| //            candidateStrategy = element != null ? NumberUtils.parseInt(element.getElementText()) : null; | ||||
|             candidateStrategy = NumberUtils.parseInt(Optional.ofNullable(element).map(ExtensionElement::getElementText).orElse(null)); | ||||
|  | ||||
|         } | ||||
|         return candidateStrategy; | ||||
|     } | ||||
| @ -44,16 +45,17 @@ public class BpmnModelUtils { | ||||
|         return candidateParam; | ||||
|     } | ||||
|  | ||||
|     public static Map<String,Integer> parseFormFieldsPermission(BpmnModel bpmnModel, String flowElementId) { | ||||
|     // TODO @jason:貌似这个没地方调用??? | ||||
|     public static Map<String, Integer> parseFormFieldsPermission(BpmnModel bpmnModel, String flowElementId) { | ||||
|         FlowElement flowElement = getFlowElementById(bpmnModel, flowElementId); | ||||
|         if (flowElement == null) { | ||||
|             return null; | ||||
|         } | ||||
|         final HashMap<String, Integer> fieldsPermission = MapUtil.newHashMap(); | ||||
|         Map<String, Integer> fieldsPermission = MapUtil.newHashMap(); | ||||
|         List<ExtensionElement> extensionElements = flowElement.getExtensionElements().get(SimpleModelConstants.FIELDS_PERMISSION); | ||||
|         extensionElements.forEach(el -> { | ||||
|             String field = el.getAttributeValue(FLOWABLE_EXTENSIONS_NAMESPACE, FIELD_ATTRIBUTE); | ||||
|             String permission = el.getAttributeValue(FLOWABLE_EXTENSIONS_NAMESPACE, SimpleModelConstants.PERMISSION_ATTRIBUTE); | ||||
|         extensionElements.forEach(element -> { | ||||
|             String field = element.getAttributeValue(FLOWABLE_EXTENSIONS_NAMESPACE, FIELD_ATTRIBUTE); | ||||
|             String permission = element.getAttributeValue(FLOWABLE_EXTENSIONS_NAMESPACE, SimpleModelConstants.PERMISSION_ATTRIBUTE); | ||||
|             if (StrUtil.isNotEmpty(field) && StrUtil.isNotEmpty(permission)) { | ||||
|                 fieldsPermission.put(field, Integer.parseInt(permission)); | ||||
|             } | ||||
|  | ||||
| @ -207,7 +207,6 @@ public class SimpleModelUtils { | ||||
|         // TODO @jason:建议使用 ServiceTask,通过 executionListeners 实现; | ||||
|         // @芋艿 ServiceTask 就可以了吧。 不需要 executionListeners | ||||
|         addCandidateElements(node, serviceTask); | ||||
|  | ||||
|         return serviceTask; | ||||
|     } | ||||
|  | ||||
|  | ||||
| @ -15,12 +15,14 @@ import java.util.Map; | ||||
|  | ||||
| import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.SimpleModelConstants.FIELD_ATTRIBUTE; | ||||
|  | ||||
| // TODO @jason:这个类,挪到 framework 那的 util 包下哈; | ||||
| /** | ||||
|  *  Bpmn 流程表单相关工具方法 | ||||
|  * | ||||
|  * @author jason | ||||
|  */ | ||||
| public class BpmnFormUtils { | ||||
|  | ||||
|     private static final String CREATE_FORM_DISPLAY_ATTRIBUTE = "display"; | ||||
|     private static final String CREATE_FORM_DISABLED_ATTRIBUTE = "disabled"; | ||||
|  | ||||
| @ -65,4 +67,5 @@ public class BpmnFormUtils { | ||||
|         }); | ||||
|         return afterChangedFields; | ||||
|     } | ||||
|  | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV