补充文件提交
This commit is contained in:
parent
0db1332a24
commit
c90e54d487
@ -0,0 +1,314 @@
|
|||||||
|
package com.actionsoft.apps.coe.pal.pal.repository.util;
|
||||||
|
|
||||||
|
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
|
||||||
|
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.cache.DesignerShapeRelationCache;
|
||||||
|
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel;
|
||||||
|
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
|
||||||
|
import com.actionsoft.bpms.org.model.DepartmentModel;
|
||||||
|
import com.actionsoft.sdk.local.SDK;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author oYang
|
||||||
|
* @Description PAL 左侧目录树 架构过滤 工具类
|
||||||
|
* @createTime 2024年12月23日 16:15:00
|
||||||
|
*/
|
||||||
|
public class PALFrameworkFilterUtil2 {
|
||||||
|
|
||||||
|
static class Node {
|
||||||
|
private String wsId; // 资产库ID
|
||||||
|
private String id; // 模型ID
|
||||||
|
private String versionId; // 版本ID
|
||||||
|
private String pid;
|
||||||
|
private String name; // 模型名称
|
||||||
|
private String category;
|
||||||
|
private String methodId; // 模型类型 default | framework | 建模
|
||||||
|
private String createUser;
|
||||||
|
private String modifyUser;
|
||||||
|
|
||||||
|
public Node(String wsId, String id, String versionId, String pid, String name, String category, String methodId, String createUser, String modifyUser) {
|
||||||
|
this.wsId = wsId;
|
||||||
|
this.id = id;
|
||||||
|
this.versionId = versionId;
|
||||||
|
this.pid = pid;
|
||||||
|
this.name = name;
|
||||||
|
this.category = category;
|
||||||
|
this.methodId = methodId;
|
||||||
|
this.createUser = createUser;
|
||||||
|
this.modifyUser = modifyUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWsId() {
|
||||||
|
return wsId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersionId() {
|
||||||
|
return versionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPid() {
|
||||||
|
return pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCategory() {
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMethodId() {
|
||||||
|
return methodId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCreateUser() {
|
||||||
|
return createUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModifyUser() {
|
||||||
|
return modifyUser;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Node transform(PALRepositoryModel model) {
|
||||||
|
return new Node(model.getWsId(), model.getId(), model.getVersionId(), model.getNewParentId(), model.getName(), model.getMethodCategory(), model.getMethodId(), model.getCreateUser(), model.getModifyUser());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Node transform(JSONObject model){
|
||||||
|
return new Node(model.getString("wsId"), model.containsKey("currId") ? model.getString("currId") : model.getString("id"), model.getString("versionId"), model.getString("pid"), model.getString("name"), model.containsKey("plCategory") ? model.getString("plCategory") : model.getString("category"), model.containsKey("plMethodId") ? model.getString("plMethodId") : model.getString("methodId"), model.getString("createUser"), model.getString("modifyUser"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 架构过滤
|
||||||
|
* @param dataArray 数据集合
|
||||||
|
* @param createUserList 勾选的创建人集合
|
||||||
|
* @param orgIdList 勾选的部门ID集合
|
||||||
|
* @param methodIdList 勾选的建模方法集合
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static JSONArray filter(JSONArray dataArray, JSONArray orgIdList, JSONArray methodIdList) {
|
||||||
|
|
||||||
|
Set<String> orgIds = getOrgIds(orgIdList);
|
||||||
|
|
||||||
|
// 1、过滤掉空文件或者空架构
|
||||||
|
dataArray = filterEmpty(dataArray);
|
||||||
|
|
||||||
|
// 2、根据创建人、组织、建模方法过滤
|
||||||
|
Set<String> setOfId = dataArray.stream()
|
||||||
|
.map(model -> transform((JSONObject) model))
|
||||||
|
.filter(node -> {
|
||||||
|
if ("org".equals(node.getCategory()) || "itsystem.normal".equals(node.getMethodId())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return filter(node, orgIds, methodIdList);
|
||||||
|
})
|
||||||
|
.map(Node::getId)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
return dataArray.stream().map(obj -> (JSONObject)obj).filter(obj -> setOfId.stream().anyMatch(id -> id.equals(obj.containsKey("currId") ? obj.getString("currId") : obj.getString("id")))).collect(Collectors.toCollection(JSONArray::new));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 架构过滤
|
||||||
|
* @param list 数据集合
|
||||||
|
* @param createUserList 勾选的创建人集合
|
||||||
|
* @param orgIdList 勾选的部门ID集合
|
||||||
|
* @param methodIdList 勾选的建模方法集合
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static List<PALRepositoryModel> filter(List<PALRepositoryModel> list, JSONArray orgIdList, JSONArray methodIdList) {
|
||||||
|
|
||||||
|
Set<String> orgIds = getOrgIds(orgIdList);
|
||||||
|
|
||||||
|
// 1、过滤掉空文件或者空架构
|
||||||
|
list = filterEmpty(list);
|
||||||
|
|
||||||
|
// 2、根据创建人、组织、建模方法过滤
|
||||||
|
Set<String> setOfId = list.stream()
|
||||||
|
.map(model -> transform(model))
|
||||||
|
.filter(node -> {
|
||||||
|
if ("org".equals(node.getCategory()) || "itsystem.normal".equals(node.getMethodId())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return filter(node, orgIds, methodIdList);
|
||||||
|
})
|
||||||
|
.map(Node::getId)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
// 3、根据 nodeList 过滤 list
|
||||||
|
return list.stream().filter(model -> setOfId.stream().anyMatch(id -> id.equals(model.getId()))).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点过滤
|
||||||
|
* @param node 节点信息
|
||||||
|
* @param createUserList 创建人列表
|
||||||
|
* @param orgIdList 组织列表
|
||||||
|
* @param methodIdList 建模方法列表
|
||||||
|
* @return true:符合 false:不符合
|
||||||
|
*/
|
||||||
|
public static boolean filter(Node node, Set<String> orgIdList, JSONArray methodIdList){
|
||||||
|
boolean exist = false;
|
||||||
|
// 文件节点直接判断 符合直接保留
|
||||||
|
if (!("process.framework".equals(node.getMethodId()) || "default".equals(node.getMethodId()))){
|
||||||
|
exist = predicateCondition(node, orgIdList, methodIdList);
|
||||||
|
if (exist){
|
||||||
|
return exist;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 非文件节点 或者 文件节点下子节点
|
||||||
|
Iterator<PALRepositoryModel> iterator = PALRepositoryCache.getByPid(node.getWsId(), node.getVersionId());
|
||||||
|
while (iterator.hasNext()){
|
||||||
|
Node childNode = transform(iterator.next());
|
||||||
|
exist = filter(childNode, orgIdList, methodIdList);
|
||||||
|
if (exist){
|
||||||
|
return exist;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点过滤条件 保证同时满足三个条件
|
||||||
|
* @param node 节点信息
|
||||||
|
* @param createUserList 创建人集合
|
||||||
|
* @param orgIdList 组织集合
|
||||||
|
* @param methodIdList 建模方法集合
|
||||||
|
* @return Boolean
|
||||||
|
*/
|
||||||
|
public static boolean predicateCondition(Node node, Set<String> orgIdList, JSONArray methodIdList){
|
||||||
|
|
||||||
|
boolean publishDeptCondition = false;
|
||||||
|
if (CollectionUtils.isEmpty(orgIdList)){
|
||||||
|
publishDeptCondition = true;
|
||||||
|
}else {
|
||||||
|
List<DesignerShapeRelationModel> relationModels = DesignerShapeRelationCache.getByFileId(node.getId(), "Issuing_department");
|
||||||
|
// 是否有发布部门的文件属性【可能会有多个值】
|
||||||
|
if (CollectionUtils.isNotEmpty(relationModels)) {
|
||||||
|
for (DesignerShapeRelationModel relationModel : relationModels) {
|
||||||
|
JSONObject relationObj = JSONObject.parseObject(relationModel.getRelationShapeText());
|
||||||
|
String deptId = relationObj.getString("id");
|
||||||
|
publishDeptCondition = orgIdList.contains(deptId);
|
||||||
|
if (publishDeptCondition)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
boolean methodIdCondition = false;
|
||||||
|
if (CollectionUtils.isEmpty(methodIdList)){
|
||||||
|
methodIdCondition = true;
|
||||||
|
}else {
|
||||||
|
methodIdCondition = methodIdList.contains(node.getMethodId());
|
||||||
|
}
|
||||||
|
return publishDeptCondition && methodIdCondition;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有子部门ID
|
||||||
|
* @param orgIdList 勾选的组织ID集合
|
||||||
|
* @return Set<String>
|
||||||
|
*/
|
||||||
|
private static Set<String> getOrgIds(JSONArray orgIdList){
|
||||||
|
Set<String> tempOrgList = new HashSet<>();
|
||||||
|
orgIdList.stream().forEach(parentOrgId -> {
|
||||||
|
List<DepartmentModel> subDepartments = SDK.getORGAPI().getSubDepartments((String) parentOrgId);
|
||||||
|
tempOrgList.add((String) parentOrgId);
|
||||||
|
if (subDepartments.size() > 0) {
|
||||||
|
findSubDepartmentIds((String) parentOrgId, tempOrgList);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return tempOrgList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归查找当前父部门下的所有子部门
|
||||||
|
*
|
||||||
|
* @param parentOrgId
|
||||||
|
* @param orgIds
|
||||||
|
*/
|
||||||
|
private static void findSubDepartmentIds(String parentOrgId, Set<String> orgIds) {
|
||||||
|
List<DepartmentModel> subDepartments = SDK.getORGAPI().getSubDepartments(parentOrgId);
|
||||||
|
if (subDepartments.size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (DepartmentModel department : subDepartments) {
|
||||||
|
orgIds.add(department.getId());
|
||||||
|
findSubDepartmentIds(department.getId(), orgIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过滤空文件或者空架构
|
||||||
|
* @param dataArray 数据
|
||||||
|
* @return JSONArray
|
||||||
|
*/
|
||||||
|
private static JSONArray filterEmpty(JSONArray dataArray) {
|
||||||
|
return dataArray.stream()
|
||||||
|
.map(o -> (JSONObject)o).filter(obj -> {
|
||||||
|
boolean flag = true;
|
||||||
|
// 组织下的内容不在【架构筛选】功能的影响内
|
||||||
|
if (!("org".equals(obj.getString("plCategory")) || "itsystem.normal".equals(obj.getString("plMethodId")))) {
|
||||||
|
if ("process.framework".equals(obj.getString("plMethodId")) || "default".equals(obj.getString("plMethodId"))) {
|
||||||
|
flag = filterEmptyMoldel(obj.getString("wsId"), obj.getString("versionId"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}).collect(Collectors.toCollection(JSONArray::new));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过滤空文件或者空架构
|
||||||
|
* @param list 数据
|
||||||
|
* @return List<PALRepositoryModel>
|
||||||
|
*/
|
||||||
|
private static List<PALRepositoryModel> filterEmpty(List<PALRepositoryModel> list) {
|
||||||
|
return list.stream().filter(model -> {
|
||||||
|
boolean flag = true;
|
||||||
|
// 组织下的内容与IT系统图不在【架构筛选】影响范围之内
|
||||||
|
if (!("org".equals(model.getMethodCategory()) || "itsystem.normal".equals(model.getMethodId()))) {
|
||||||
|
if ("process.framework".equals(model.getMethodId()) || "default".equals(model.getMethodId())) {
|
||||||
|
flag = filterEmptyMoldel(model.getWsId(), model.getVersionId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归判断是否为空文件或者空架构
|
||||||
|
* @param wsId 资产库ID
|
||||||
|
* @param pid 父节点ID
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
private static boolean filterEmptyMoldel(String wsId, String pid) {
|
||||||
|
boolean flag = false;
|
||||||
|
Iterator<PALRepositoryModel> iterator = PALRepositoryCache.getByPid(wsId, pid);
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
PALRepositoryModel currentModel = iterator.next();
|
||||||
|
if ("process.framework".equals(currentModel.getMethodId()) || "default".equals(currentModel.getMethodId())) {
|
||||||
|
flag = filterEmptyMoldel(wsId, currentModel.getVersionId());
|
||||||
|
} else {
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
if (flag)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user