Commit cf49bda4 authored by 雍欢's avatar 雍欢

完善流程图中配置的表单字段权限与审批规则中配置的字段权限合并逻辑

parent ed2fd9ca
......@@ -159,7 +159,7 @@ public class OperatorUIElementPermissionBuilderImp implements OperatorUIElementP
}
private BpmnModel getBpmnModelByProcessInstanceId(String processInstanceId) {
if(processInstanceId == null) {
if (processInstanceId == null) {
return null;
}
String deploymentId = null;
......@@ -195,24 +195,25 @@ public class OperatorUIElementPermissionBuilderImp implements OperatorUIElementP
* @param uiElementPermissions 审批规则中配置的字段权限
*/
private List<Map<String, Object>> mergeFieldPermissions(List<Map<String, Object>> flowElementFieldPermissions, List<Map<String, Object>> uiElementPermissions) {
return uiElementPermissions.stream()
.collect(Collectors.groupingBy(it -> (String) it.get("approvalRuleHandlerId")))
.entrySet().stream()
.flatMap(entry -> {
String approvalRuleHandlerId = entry.getKey();
List<Map<String, Object>> permissions = entry.getValue();
List<?> uiElementPermissionFormFieldIds = permissions.stream()
.map(it -> it.get("formFieldId"))
.collect(Collectors.toList());
return flowElementFieldPermissions.stream()
.filter(it -> !uiElementPermissionFormFieldIds.contains(it.get("formFieldId")))
.map(it -> {
Map<String, Object> copy = new HashMap<>(it);
copy.put("approvalRuleHandlerId", approvalRuleHandlerId);
return copy;
});
})
.collect(Collectors.toList());
List<Map<String, Object>> mergeResult = new ArrayList<>(16);
// 先将流程图中配置的字段权限放入合并结果集中
mergeResult.addAll(flowElementFieldPermissions);
// 遍历审批规则中配置的字段权限,并在合并结果集中查询有相同formFieldId的配置,如果能找到就覆盖找到的配置,否则添加进合并结果集
for (Map<String, Object> o : uiElementPermissions) {
String formFieldId = (String) o.get("formFieldId");
if (StringUtils.isBlank(formFieldId)) {
// 不是关联的表单字段,直接添加进合并结果集
mergeResult.add(o);
}
Optional<Map<String, Object>> uiElementPermissionOptional = mergeResult.stream().filter(it -> it.get("formFieldId").equals(formFieldId)).findAny();
if (uiElementPermissionOptional.isPresent()) {
Map<String, Object> uiElementPermission = uiElementPermissionOptional.get();
uiElementPermission.putAll(o);
} else {
mergeResult.add(o);
}
}
return mergeResult;
}
private Optional<ExtensionAttribute> getFieldExtensionElement(BaseElement be, String fieldName) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment