批量下载功能按发布部门筛选

This commit is contained in:
zhaol 2024-11-19 16:57:47 +08:00
parent 651a5a1e66
commit 82ab4c2de0
5 changed files with 466 additions and 16 deletions

View File

@ -436,6 +436,7 @@ public class OutPutReportWeb extends ActionWeb {
}
public String PALFileJsonDataRootTreeDataByDepartment(String methodType, String wsid, String versionType, String teamId,String departId) {
JSONArray jsonArr = null;
//if (teamId == null || "".equals(teamId)) {
if (teamId == null) {

View File

@ -16,6 +16,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import com.actionsoft.bpms.server.conf.portal.AWSPortalConf;
import com.actionsoft.bpms.util.*;
@ -2180,7 +2181,7 @@ public class PALRepositoryQueryAPIManager {
removeIds.append(model.getId()).append(",");
}
}
result.addAll(list2Json(context, newList, isUsed, isPublished, removeIds.toString(), type, true));
result.addAll(list2DepartJson(context, newList, isUsed, isPublished, removeIds.toString(), type, true,departId));
return result;
}
@ -2435,6 +2436,119 @@ public class PALRepositoryQueryAPIManager {
return jsonArray;
}
/****************************************报告生成器下载流程模型筛选****************************************************************/
/**
* 通过流程model列表获取流程树的json数组
*
* @param context
* @param list
* @return
*/
public JSONArray list2DepartJson(UserContext context, List<PALRepositoryModel> list, boolean isUsed, boolean isPublished) {
return list2DepartJson(context, list, isUsed, isPublished, null, null);
}
/**************************************************** 流程树相关方法 *******************************************************/
private JSONArray list2DepartJson(UserContext context, List<PALRepositoryModel> list, boolean isUsed, boolean isPublished, String removeIds, String param) {
JSONArray jsonArray = new JSONArray();
for (PALRepositoryModel model : list) {
JSONObject object = new JSONObject();
object.put("id", model.getId().trim());
object.put("pid", model.getNewParentId().trim());
if (removeIds != null && removeIds.contains(model.getId().trim())) {
object.put("nocheck", true);
} else {
object.put("nocheck", false);
}
object.put("plNo", CoeProcessLevelUtil.getProcessLevelNoByUUId(model.getId(), model.getWsId()).trim());
object.put("name", I18nRes.findValue(CoEConstant.APP_ID, context.getLanguage(), model.getName()).trim());
object.put("wsId", model.getWsId());
PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId());
if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类
object.put("title", object.get("name"));
} else {
object.put("title", object.get("name") + " " + VersionUtil.getVersionStrV(model.getVersion()).trim());
}
//三员管理文件密级校验
if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()) {
ResponseObject responseObject = new CoeProcessLevelWeb(DispatcherRequest.getUserContext()).checkFilePemission(model.getId());
if (responseObject.isErr() && (methodModel != null && !methodModel.isFolder())) {
object.put("nocheck", true);
}
}
object.put("drop", false);
object.put("isSystemFile", model.isSystemFile());
object.put("plMethodId", model.getMethodId().trim());
if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类
object.put("iconFont", "&#58930;");
} else {
object.put("iconFont", "&#59101;");
}
List<PALRepositoryModel> children = null;
if (isUsed) {
children = getUsedPalRepositoryModelsByPid(model.getWsId(), model.getId());
if ("designer".equals(param) && children != null && children.size() > 0) {// 过滤掉发布版本
List<PALRepositoryModel> tempChildren = new ArrayList<>();
for (PALRepositoryModel model2 : children) {
if (!model2.isPublish()) {
tempChildren.add(model2);
}
}
children = tempChildren;
}
} else if (isPublished) {
children = getPublishedPalRepositoryModelsByPid(model.getWsId(), model.getId());
}
if (children == null || children.size() == 0) {
object.put("isParent", false);
//String icon = object.getString("icon");
object.put("leaf", true);// 叶子节点
// object.put("icon", icon.replace("16.png", "16.leaf.png"));
} else {
object.put("isParent", true);
object.put("open", false);
}
object.put("plLevel", model.getLevel());
object.put("plOrdexIndex", model.getOrderIndex());
object.put("plDiagramUrl", model.getDiagramUrl());
object.put("isDrops", model.isSystemFile());
object.put("isPublish", model.isPublish());
object.put("isStop", model.isStop());
object.put("isApproval", model.isApproval());
object.put("ext1", model.getExt1());
object.put("ext2", model.getExt2());
object.put("ext3", model.getExt3());
object.put("ext4", model.getExt4());
object.put("isUse", model.isUse());
object.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + model.getId() + "&type=1&wsid=" + model.getWsId());
object.put("plCategory", model.getMethodCategory());
object.put("versionId", model.getVersionId());
object.put("orderIndex", model.getOrderIndex());
object.put("isBottomLevel", model.isBottomLevel());
String dutyDeptId = model.getDutyDept();
object.put("dutyDeptId", dutyDeptId == null ? "" : dutyDeptId);
String plDutyDeptName = dutyDeptId;
if (!UtilString.isEmpty(dutyDeptId)) {
if (SDK.getORGAPI().getDepartmentById(dutyDeptId) != null) {
plDutyDeptName = SDK.getORGAPI().getDepartmentById(dutyDeptId).getName();
}
}
object.put("dutyDeptName", UtilString.isEmpty(dutyDeptId) ? "" : plDutyDeptName);
String plDutyPerson = model.getDutyUser();
object.put("dutyPersonId", model.getDutyUser() == null ? "" : model.getDutyUser());
object.put("dutyPersionName", UtilString.isEmpty(plDutyPerson) ? "" : SDK.getORGAPI().getUserAliasNames(plDutyPerson));
jsonArray.add(object);
}
return jsonArray;
}
private JSONArray list2Json(UserContext context, List<PALRepositoryModel> list, boolean isUsed, boolean isPublished, String removeIds, String param, boolean statusSuffix) {
JSONArray jsonArray = new JSONArray();
for (PALRepositoryModel model : list) {
@ -2530,6 +2644,350 @@ public class PALRepositoryQueryAPIManager {
return jsonArray;
}
private JSONArray list2DepartJson(UserContext context, List<PALRepositoryModel> list, boolean isUsed, boolean isPublished, String removeIds, String param, boolean statusSuffix,String departId) {
JSONArray jsonArray = new JSONArray();
/*DepartmentModel departmentById = SDK.getORGAPI().getDepartmentById(departId);
ArrayList<String> dep=new ArrayList<String>();
dep.add(departId);
ArrayList subDepartmentsList = getChildDept(departId, new ArrayList<>());
long startTime = System.currentTimeMillis();*/
for(PALRepositoryModel o:list){
System.out.println("过滤前======="+o.getName());
}
// 先过滤掉空的架构与空的文件夹
list = list.stream().filter(model -> {
boolean flag = true;
if (model.getMethodId().equals("process.framework")) {
flag = this.filterEmptyMoldel(model.getWsId(), model.getVersionId());
}
return flag;
}).collect(Collectors.toList());
for(PALRepositoryModel o:list){
System.out.println("过滤后======="+o.getName());
}
String[] spilt=departId.split(",");
JSONArray orgIdList=new JSONArray();
for(String ele:spilt){
orgIdList.add(ele);
}
Set<String> tempOrgList = new HashSet<>();
if (orgIdList.size() > 0) {
orgIdList.stream().forEach(parentOrgId -> {
List<DepartmentModel> subDepartments = SDK.getORGAPI().getSubDepartments((String) parentOrgId);
tempOrgList.add((String) parentOrgId);
if (subDepartments.size() > 0) {
this.findSubDepartmentIds((String) parentOrgId, tempOrgList);
}
});
list = list.stream().filter(model -> {
boolean flag = false;
if ("org".equals(model.getMethodCategory()) || "itsystem.normal".equals(model.getMethodId())) {
return true;
}
if ("process.framework".equals(model.getMethodId()) || "default".equals(model.getMethodId())) {
flag = this.filterIsMatchPropertyModel(model.getWsId(), model.getVersionId(), tempOrgList);
} else {
List<RowMap> rlatRowMap = DBSql.getMaps("SELECT RELATIONSHAPETEXT FROM APP_ACT_COE_PAL_SHAPE_RLAT where FILEID = '" + model.getId() + "' and ATTRID='Issuing_department'");
for (RowMap oneRowMap : rlatRowMap) {
String relationshapetext = oneRowMap.getString("RELATIONSHAPETEXT");
JSONObject js = JSONObject.parseObject(relationshapetext);
String deptId = js.getString("id");
flag = tempOrgList.contains(deptId);
if (flag)
break;
}
/*List<DesignerShapeRelationModel> relationModels = DesignerShapeRelationCache.getByFileId(model.getId(), "Issuing_department");
// 是否有发布部门的文件属性可能会有多个值
if (relationModels != null && relationModels.size() > 0) {
for (DesignerShapeRelationModel relationModel : relationModels) {
JSONObject relationObj = JSONObject.parseObject(relationModel.getRelationShapeText());
String deptId = relationObj.getString("id");
flag = tempOrgList.contains(deptId);
if (flag)
break;
}
}*/
}
return flag;
}).collect(Collectors.toList());
}
/*list = list.stream().filter(model -> {
boolean flag = true;
if (model.getMethodId().equals("process.framework")) {
flag = this.filterEmptyMoldel(model.getWsId(), model.getId());
}
return flag;
}).collect(Collectors.toList());*/
/*list = list.stream().filter(model -> {
if ("org".equals(model.getMethodCategory()) || "itsystem.normal".equals(model.getMethodId())) {
return true;
}
boolean flag = false;
if ("process.framework".equals(model.getMethodId()) || "default".equals(model.getMethodId())) {
flag = this.filterIsMatchPropertyModel(model.getWsId(), model.getVersionId(), subDepartmentsList);
} else {
List<DesignerShapeRelationModel> relationModels = DesignerShapeRelationCache.getByFileId(model.getId(), "Issuing_department");
// 是否有发布部门的文件属性可能会有多个值
if (relationModels != null && relationModels.size() > 0) {
for (DesignerShapeRelationModel relationModel : relationModels) {
JSONObject relationObj = JSONObject.parseObject(relationModel.getRelationShapeText());
String deptId = relationObj.getString("id");
flag = subDepartmentsList.contains(deptId);
if (flag)
break;
}
}
}
return flag;
}).collect(Collectors.toList());*/
for (PALRepositoryModel model : list) {
JSONObject object = new JSONObject();
object.put("id", model.getId().trim());
object.put("pid", model.getNewParentId().trim());
if (removeIds != null && removeIds.contains(model.getId().trim())) {
object.put("nocheck", true);
continue;
} else {
object.put("nocheck", false);
}
object.put("plNo", CoeProcessLevelUtil.getProcessLevelNoByUUId(model.getId(), model.getWsId()).trim());
object.put("name", I18nRes.findValue(CoEConstant.APP_ID, context.getLanguage(), model.getName()).trim() + (statusSuffix && !"default".equals(model.getMethodId()) && !"process.framework".equals(model.getMethodId()) ? "" + getStatusLabel(model) + "" : ""));
object.put("wsId", model.getWsId());
PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(model.getMethodId());
if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类
object.put("title", object.get("name"));
} else {
object.put("title", object.get("name") + " " + VersionUtil.getVersionStrV(model.getVersion()).trim());
}
//三员管理文件密级校验
if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()) {
ResponseObject responseObject = new CoeProcessLevelWeb(DispatcherRequest.getUserContext()).checkFilePemission(model.getId());
if (responseObject.isErr() && (methodModel != null && !methodModel.isFolder())) {
object.put("nocheck", true);
}
}
object.put("drop", false);
object.put("isSystemFile", model.isSystemFile());
object.put("plMethodId", model.getMethodId().trim());
if (methodModel == null || methodModel.isFolder()) {// 没有该建模方法或者是文件夹类
object.put("iconFont", "&#58930;");
} else {
object.put("iconFont", "&#59101;");
}
List<PALRepositoryModel> children = null;
if (isUsed) {
children = getUsedPalRepositoryModelsByPid(model.getWsId(), model.getId());
if ("designer".equals(param) && children != null && children.size() > 0) {// 过滤掉发布版本
List<PALRepositoryModel> tempChildren = new ArrayList<>();
for (PALRepositoryModel model2 : children) {
if (!model2.isPublish()) {
tempChildren.add(model2);
}
}
children = tempChildren;
}
} else if (isPublished) {
children = getPublishedPalRepositoryModelsByPid(model.getWsId(), model.getId());
}
if (children == null || children.size() == 0) {
object.put("isParent", false);
//String icon = object.getString("icon");
object.put("leaf", true);// 叶子节点
// object.put("icon", icon.replace("16.png", "16.leaf.png"));
} else {
object.put("isParent", true);
object.put("open", false);
}
object.put("plLevel", model.getLevel());
object.put("plOrdexIndex", model.getOrderIndex());
object.put("plDiagramUrl", model.getDiagramUrl());
object.put("isDrops", model.isSystemFile());
object.put("isPublish", model.isPublish());
object.put("isStop", model.isStop());
object.put("isApproval", model.isApproval());
object.put("ext1", model.getExt1());
object.put("ext2", model.getExt2());
object.put("ext3", model.getExt3());
object.put("ext4", model.getExt4());
object.put("isUse", model.isUse());
object.put("url", "./w?sid=" + context.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_portal_page&ruuid=" + model.getId() + "&type=1&wsid=" + model.getWsId());
object.put("plCategory", model.getMethodCategory());
object.put("versionId", model.getVersionId());
object.put("orderIndex", model.getOrderIndex());
object.put("isBottomLevel", model.isBottomLevel());
String dutyDeptId = model.getDutyDept();
object.put("dutyDeptId", dutyDeptId == null ? "" : dutyDeptId);
String plDutyDeptName = dutyDeptId;
if (!UtilString.isEmpty(dutyDeptId)) {
if (SDK.getORGAPI().getDepartmentById(dutyDeptId) != null) {
plDutyDeptName = SDK.getORGAPI().getDepartmentById(dutyDeptId).getName();
}
}
object.put("dutyDeptName", UtilString.isEmpty(dutyDeptId) ? "" : plDutyDeptName);
String plDutyPerson = model.getDutyUser();
object.put("dutyPersonId", model.getDutyUser() == null ? "" : model.getDutyUser());
object.put("dutyPersionName", UtilString.isEmpty(plDutyPerson) ? "" : SDK.getORGAPI().getUserAliasNames(plDutyPerson));
jsonArray.add(object);
/*if(model.getMethodId().equals("process.framework")) {
}else{
List<RowMap> rlatRowMap = DBSql.getMaps("SELECT RELATIONSHAPETEXT FROM APP_ACT_COE_PAL_SHAPE_RLAT where FILEID = '" + model.getId() + "' and ATTRID='Issuing_department'");
if (rlatRowMap.size() > 0) {
// 发布部门
String dempId = "";
for (RowMap oneRowMap : rlatRowMap) {
String relationshapetext = oneRowMap.getString("RELATIONSHAPETEXT");
JSONObject js = JSONObject.parseObject(relationshapetext);
String getDepartId=js.getString("id");
boolean contains = subDepartmentsList.contains(getDepartId);
if(contains){
jsonArray.add(object);
}
}
}
}*/
}
return jsonArray;
}
/**
* 递归查找当前父部门下的所有子部门
*
* @param parentOrgId
* @param orgIds
*/
private 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());
this.findSubDepartmentIds(department.getId(), orgIds);
}
}
/**
* 判断当前架构或者文件夹下是否含有
* 匹配的文件属性发布部门
*
* @param wsId
* @param pid
* @param orgIdList
* @return
*/
private boolean filterIsMatchPropertyModel(String wsId, String pid, Set<String> orgIdList) {
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 = this.filterIsMatchPropertyModel(wsId, currentModel.getVersionId(), orgIdList);
} else {
List<DesignerShapeRelationModel> relationModels = DesignerShapeRelationCache.getByFileId(currentModel.getId(), "Issuing_department");
// 是否有发布部门的文件属性可能会有多个值
if (relationModels != null && relationModels.size() > 0) {
for (DesignerShapeRelationModel relationModel : relationModels) {
JSONObject relationObj = JSONObject.parseObject(relationModel.getRelationShapeText());
String deptId = relationObj.getString("id");
flag = orgIdList.contains(deptId);
if (flag)
break;
}
}
}
if (flag)
break;
}
return flag;
}
private 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 = this.filterEmptyMoldel(wsId, currentModel.getVersionId());
} else {
flag = true;
}
if (flag)
break;
}
return flag;
}
/**
* 获取该部门下面所有子部门
* @param arr_test
* @param departmentById
* @return
*/
public static ArrayList getChildDept(String deptID,ArrayList<String> deptIDList) {
deptIDList.add(deptID);
Object[] sqlParams = new Object[]{};
sqlParams = new Object[]{deptID};
List<RowMap> subDeptMaps = DBSql.getMaps("SELECT ID FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID=?",sqlParams);
if (null!=subDeptMaps && !subDeptMaps.isEmpty()) {
for (RowMap subDeptMap : subDeptMaps) {
deptID = subDeptMap.getString("ID");
getChildDept(deptID,deptIDList);
}
}
return deptIDList;
}
private String getStatusLabel(PALRepositoryModel repositoryModel){
String statusLabel = "设计中";
if (repositoryModel.isApproval()){

View File

@ -1616,26 +1616,13 @@ public class CoeProcessLevelUtil {
public static List<PALRepositoryModel> getPermRepositoryListByDeptId(String wsId, String teamId, String userId, String category, String method, boolean isUse, boolean isPublish,String departId) {
List<PALRepositoryModel> result = new ArrayList<>();
Set<String> versionIds = getPermRepositoryVersionIds(wsId, teamId, userId, category, method);
for (String versionId : versionIds) {
List<PALRepositoryModel> list = PALRepositoryCache.getByVersionId(versionId);
if (list != null) {
for (PALRepositoryModel model : list) {
if ((isUse && model.isUse()) || (isPublish && model.isPublish())) {
List<RowMap> rlatRowMap = DBSql.getMaps("SELECT RELATIONSHAPETEXT FROM APP_ACT_COE_PAL_SHAPE_RLAT where FILEID = '" + model.getId() + "' and ATTRID='Issuing_department'");
if (rlatRowMap.size() > 0) {
// 发布部门
String dempId = "";
for (RowMap oneRowMap : rlatRowMap) {
String relationshapetext = oneRowMap.getString("RELATIONSHAPETEXT");
JSONObject js = JSONObject.parseObject(relationshapetext);
String getDepartId=js.getString("id");
if(getDepartId.equals(departId)){
result.add(model);
}
}
}
result.add(model);
}
}
}
@ -1645,6 +1632,8 @@ public class CoeProcessLevelUtil {
/**
* 获取最近编辑的模型文件
*

View File

@ -62,7 +62,9 @@
leafType: "dept",//叶子节点类型,user:用户;dept:部门
filterClass: ""//过滤事件
},
},
separator : ","//逗号 空格……分隔符
};
$("#address_dept").address(options);