From 0228d036d63ad8f0e482ae88b025aad034ec46de Mon Sep 17 00:00:00 2001 From: Mr-wang Date: Mon, 9 Oct 2023 15:39:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=B5=81=E7=A8=8B=E6=B8=85?= =?UTF-8?q?=E5=8D=95=E7=9A=84ASLP,=E5=B9=B6=E4=B8=94=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E5=88=B6=E5=BA=A6=E6=96=87=E4=BB=B6=E7=9A=84?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aslp/GetCountByProcessList.java | 492 ++++++++++++++++++ .../coe/pal/processlist/plugin/Plugins.java | 6 +- .../service/FileManagementService.java | 448 +++++++++++++++- 3 files changed, 935 insertions(+), 11 deletions(-) create mode 100644 com.actionsoft.apps.coe.pal.processlist/src/com/actionsoft/apps/coe/pal/processlist/aslp/GetCountByProcessList.java diff --git a/com.actionsoft.apps.coe.pal.processlist/src/com/actionsoft/apps/coe/pal/processlist/aslp/GetCountByProcessList.java b/com.actionsoft.apps.coe.pal.processlist/src/com/actionsoft/apps/coe/pal/processlist/aslp/GetCountByProcessList.java new file mode 100644 index 00000000..0069e2fd --- /dev/null +++ b/com.actionsoft.apps.coe.pal.processlist/src/com/actionsoft/apps/coe/pal/processlist/aslp/GetCountByProcessList.java @@ -0,0 +1,492 @@ +package com.actionsoft.apps.coe.pal.processlist.aslp; + +import com.actionsoft.apps.coe.pal.constant.CoEConstant; +import com.actionsoft.apps.coe.pal.pal.method.cache.PALMethodCache; +import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel; +import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodModel; +import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryAPIManager; +import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache; +import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryPropertyCache; +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.apps.coe.pal.pal.repository.model.PALRepositoryPropertyModel; +import com.actionsoft.apps.coe.pal.pal.repository.util.CoeProcessLevelUtil; +import com.actionsoft.apps.coe.pal.processlist.cache.ProcessListConfigCache; +import com.actionsoft.apps.coe.pal.processlist.model.ProcessListConfigModel; +import com.actionsoft.apps.coe.pal.util.SubUtil; +import com.actionsoft.apps.resource.interop.aslp.ASLP; +import com.actionsoft.apps.resource.interop.aslp.Meta; +import com.actionsoft.bpms.commons.mvc.view.ResponseObject; +import com.actionsoft.bpms.org.model.DepartmentModel; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.util.UtilString; +import com.actionsoft.i18n.I18nRes; +import com.actionsoft.sdk.local.SDK; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; + +import java.util.*; + +public class GetCountByProcessList implements ASLP { + @Override + @Meta(parameter = { "name: 'sid', required: true, desc: 'sid'", + "name: 'createUser', required: true, desc: '创建人'" }) + public ResponseObject call(Map params) { + ResponseObject ro = ResponseObject.newWarnResponse("结果未知"); + // 校验参数 + String sid = (String) params.get("sid"); + if (!SDK.getPortalAPI().checkSession(sid)) { + ro = ResponseObject.newErrResponse("sid无效"); + return ro; + } + UserContext _uc = UserContext.fromSessionId(sid); + /** + * 这个是获取制度文件的文件个数 + */ + JSONObject jsonObject_control = new JSONObject(new LinkedHashMap<>()); + List jsonArray_control = new LinkedList<>(); + jsonArray_control.add("control.policy"); + jsonObject_control.put("type",jsonArray_control); + //{"frameworkSearchInput1Arr":[],"frameworkSearchInput2Arr":[],"frameworkSearchInput3Arr":[],"issuingDepartmentArr":[]} + JSONObject jsonObject_custom_control = new JSONObject(new LinkedHashMap<>()); + jsonObject_custom_control.put("frameworkSearchInput1Arr",new LinkedList<>()); + jsonObject_custom_control.put("frameworkSearchInput2Arr",new LinkedList<>()); + jsonObject_custom_control.put("frameworkSearchInput3Arr",new LinkedList<>()); + jsonObject_custom_control.put("issuingDepartmentArr",new LinkedList<>()); + int control_policy_size = getProcessListHeader("7d3ca852-a0bd-42e6-80b1-3dcea6f55083", "", "", "1,2,3,4", jsonObject_control.toString(), jsonObject_custom_control.toString(),_uc); + /** + * 这个是获取表单文件的文件个数 + * {"type":["data.form"]} + */ + JSONObject jsonObject_form = new JSONObject(new LinkedHashMap<>()); + List jsonArray_form = new LinkedList<>(); + jsonArray_form.add("data.form"); + jsonObject_form.put("type",jsonArray_form); + //{"frameworkSearchInput1Arr":[],"frameworkSearchInput2Arr":[],"frameworkSearchInput3Arr":[],"issuingDepartmentArr":[]} + JSONObject jsonObject_custom_form = new JSONObject(new LinkedHashMap<>()); + jsonObject_custom_form.put("frameworkSearchInput1Arr",new LinkedList<>()); + jsonObject_custom_form.put("frameworkSearchInput2Arr",new LinkedList<>()); + jsonObject_custom_form.put("frameworkSearchInput3Arr",new LinkedList<>()); + jsonObject_custom_form.put("issuingDepartmentArr",new LinkedList<>()); + int data_form_size = getProcessListHeader("7d3ca852-a0bd-42e6-80b1-3dcea6f55083", "", "", "1,2,3,4", jsonObject_form.toString(), jsonObject_custom_form.toString(),_uc); + + /** + * 这个是获取流程文件的文件个数 + * {"type":["process.epc","process.flowchart","process.bpmn2"]} + */ + + JSONObject jsonObject_process = new JSONObject(new LinkedHashMap<>()); + List list_process = new LinkedList<>(); + list_process.add("process.epc"); + list_process.add("process.flowchart"); + list_process.add("process.bpmn2"); + jsonObject_process.put("type",list_process); + //{"frameworkSearchInput1Arr":[],"frameworkSearchInput2Arr":[],"frameworkSearchInput3Arr":[],"issuingDepartmentArr":[]} + JSONObject jsonObject_custom_process = new JSONObject(new LinkedHashMap<>()); + jsonObject_custom_process.put("frameworkSearchInput1Arr",new LinkedList<>()); + jsonObject_custom_process.put("frameworkSearchInput2Arr",new LinkedList<>()); + jsonObject_custom_process.put("frameworkSearchInput3Arr",new LinkedList<>()); + jsonObject_custom_process.put("issuingDepartmentArr",new LinkedList<>()); + int process_size = getProcessListHeader("7d3ca852-a0bd-42e6-80b1-3dcea6f55083", "", "", "1,2,3,4", jsonObject_process.toString(), jsonObject_custom_process.toString(),_uc); + int size_tolal = process_size+control_policy_size+data_form_size; + ro.put("fileTotal",size_tolal); + ro.put("processFile",process_size); + ro.put("policyFile",control_policy_size); + ro.put("formFile",data_form_size); + return ro; + } + + /** + * 获取所有更多特性 + * @param category 流程分类,例如process + * @return + */ + private List getExtendAttrTableColumn(String wsId, String category) { + + List methodList = PALMethodCache.getPALMethodModelListByMethod(category); + List result = new ArrayList<>(); + Set ids = new HashSet<>(); + for (int i = 0; i < methodList.size(); i++) { + PALMethodModel model = methodList.get(i); + if (SDK.getAppAPI().isInstalled(model.getApp()) && SDK.getAppAPI().isActive(model.getApp())) { + // 获取所有属性 + List attrList = PALRepositoryAPIManager.getInstance().getValidAttributeModels(wsId, model.getId(), true); + for (PALMethodAttributeModel attr : attrList ) { + String id = attr.getKey(); + if (attr.getUse() && !ids.contains(id)) { + ids.add(id); + String name = attr.getNewTitle(); + String label = name; + String prop = id; + String width = "150"; + String minWidth = "150"; + String columnType = "extendAttr"; + boolean showOverflow = false; + JSONObject object1 = getJsonObject(prop, id, label, name, width, minWidth, showOverflow, columnType, "default"); + result.add(object1); + } + } + } + } + return result; + } + + /** + * 查询流程清单表头信息 + * @param wsId + * @param searchInput + * @param levelValue + * @param tableFilter 表格表头筛选条件 + * @return + */ + public int getProcessListHeader(String wsId, String teamId, String searchInput, String levelValue, String tableFilter, String customFilter,UserContext _uc) { + String category = "process"; + ResponseObject ro = ResponseObject.newOkResponse(); + // 获取默认的表格列 + LinkedHashMap defaultTableColumnMap = getDefaultFixedTableColumn(category); + // 获取流程下分类已经设置的更多特性 + List list = getExtendAttrTableColumn(wsId, category); + // 获取配置信息 + ProcessListConfigModel configModel = ProcessListConfigCache.getCache().get(wsId); + if (configModel == null || configModel.getCustomColumns() == null || configModel.getCustomColumns().isEmpty()) {// 从未配置,取默认 + // 默认已选中的配置项 + JSONArray customTableCheckedData = new JSONArray(); + for (Map.Entry entry : defaultTableColumnMap.entrySet()) { + customTableCheckedData.add(entry.getValue()); + } + ro.put("customTableCheckedData", customTableCheckedData);// 已选中表项 + ro.put("customTableUncheckedData", list);// 未选中表项 + } else { + // 获取配置信息 + JSONArray customColumns = configModel.getCustomColumns(); + JSONArray customTableCheckedData = new JSONArray();// 已选中表项 + Set checkedSet = new HashSet<>(); + LinkedHashMap extendAttrMap = new LinkedHashMap<>(16, 0.75f, true); + for (JSONObject obj : list) { + extendAttrMap.put(obj.getString("id"), obj); + } + // 判断已经设置的配置中在更多特性中是否还存在,存在则显示,不存在则不显示 + for (int i = 0; i < customColumns.size(); i++) { + JSONObject obj = customColumns.getJSONObject(i); + String columnType = obj.getString("columnType"); + String id = obj.getString("id"); + if ("extendAttr".equals(columnType)) { + // 检查是否还有该扩展字段 + if (extendAttrMap.containsKey(id)) {// 该属性还在已经配置好的更多特性中,则显示 + customTableCheckedData.add(obj); + checkedSet.add(id); + } + } else { + if (defaultTableColumnMap.containsKey(id)) { + customTableCheckedData.add(defaultTableColumnMap.get(id)); + } else { + customTableCheckedData.add(obj); + } + checkedSet.add(id); + } + } + // 未选中表项 + JSONArray customTableUncheckedData = new JSONArray(); + // 未选择的固定属性 + for (Map.Entry entry : defaultTableColumnMap.entrySet()) { + if (!checkedSet.contains(entry.getKey())) { + customTableUncheckedData.add(entry.getValue()); + } + } + // 未选择的扩展属性 + for (JSONObject obj : list) { + String id = obj.getString("id"); + if (!checkedSet.contains(id)) { + customTableUncheckedData.add(obj); + } + } + ro.put("customTableCheckedData", customTableCheckedData);// 已选中表项 + ro.put("customTableUncheckedData", customTableUncheckedData);// 未选中表项 + } + + List palList = getFilteredPalRepositoryList(wsId, teamId, category, searchInput, levelValue, tableFilter, customFilter,_uc); + return palList.size(); + } + private LinkedHashMap getDefaultFixedTableColumn(String category) { + String columnType = "default"; + LinkedHashMap map = new LinkedHashMap<>(16, 0.75f, true); + if ("process".equals(category)) { + // 编号(1-n排序)、序号(根据位置计算)、流程名称,类型,状态 + map.put("no_serialNumber", getJsonObject("no_serialNumber", "no_serialNumber", "序号", "序号", "78", "78", false, columnType, "default")); + map.put("no_default", getJsonObject("no_default", "no_default", "编号", "编号", "100", "100", false, columnType, "default")); + map.put("name", getJsonObject("name", "name", "流程名称", "流程名称", "250", "250", false, columnType, "name")); + JSONObject typeObj = getJsonObject("type", "type", "类型", "类型", "150", "150", false, columnType, "selectType"); + typeObj.put("filters", getProcessCategoryFilters(category)); + map.put("type", typeObj); + JSONObject statusObj = getJsonObject("status", "status", "状态", "状态", "150", "150", false, columnType, "selectStatus"); + statusObj.put("filters", getProcessStatusFilters()); + map.put("status", statusObj); + // map.put("parent_name",getJsonObject("parent_name","parent_name","上级名称","上级名称","250","250",false,columnType,"name")); + } + return map; + } + + + + /** + * 获取流程相关状态 + * @return + */ + private JSONArray getProcessStatusFilters() { + // 状态筛选项 + JSONArray processStatusArr = new JSONArray(); + JSONObject object3 = new JSONObject(); + object3.put("text", "设计中"); + object3.put("value", "designer"); + JSONObject object1 = new JSONObject(); + object1.put("text", "已发布"); + object1.put("value", "publish"); + JSONObject object2 = new JSONObject(); + object2.put("text", "已停用"); + object2.put("value", "stop"); + processStatusArr.add(object1); + processStatusArr.add(object2); + processStatusArr.add(object3); + return processStatusArr; + } + + + /** + * 获取分类下的建模方法 + * @param category + * @return + */ + private JSONArray getProcessCategoryFilters(String category) { + JSONArray categoryArr = new JSONArray(); + Set ids = new HashSet<>(); + if ("process".equals(category)) { + ids.add("default"); + JSONObject object = new JSONObject(); + object.put("text", I18nRes.findValue(CoEConstant.APP_ID, "default")); + object.put("value", "default"); + categoryArr.add(object); + } + List methodList = PALMethodCache.getPALMethodModelListByMethod("process"); + for (int i = 0; i < methodList.size(); i++) { + PALMethodModel model = methodList.get(i); + if (!ids.contains(model.getId()) && SDK.getAppAPI().isInstalled(model.getApp()) && SDK.getAppAPI().isActive(model.getApp())) { + JSONObject object = new JSONObject(); + object.put("text", I18nRes.findValue(CoEConstant.APP_ID, model.getId())); + object.put("value", model.getId()); + categoryArr.add(object); + } + } + return categoryArr; + } + + /** + * 组装对象 + * @param prop + * @param id + * @param label + * @param name + * @param width + * @param minWidth + * @param showOverflow + * @param columnType + * @param dataType + * @return + */ + private JSONObject getJsonObject(String prop, String id, String label, String name, String width, String minWidth, boolean showOverflow, String columnType, String dataType) { + JSONObject result = new JSONObject(); + result.put("prop", prop); + result.put("id", id); + result.put("label", label); + result.put("name", name); + result.put("width", width); + result.put("minWidth", minWidth); + result.put("showOverflow", showOverflow); + result.put("columnType", columnType); + result.put("dataType", dataType); + return result; + } + + + /** + * 获取符合条件的pal流程集合 + * @param wsId + * @param category + * @return + */ + private List getFilteredPalRepositoryList(String wsId, String teamId, String category, String searchInput, String levelValue, String tableFilter, String customFilter, UserContext _uc) { + // type,status + JSONObject tableFilterObj = JSONObject.parseObject(tableFilter); + // 类型 + List typeList = new ArrayList<>(); + if (tableFilterObj.containsKey("type")) { + typeList = JSONArray.parseArray(tableFilterObj.getString("type"), String.class); + } + // 状态 + List statusList = new ArrayList<>(); + if (tableFilterObj.containsKey("status")) { + statusList = JSONArray.parseArray(tableFilterObj.getString("status"), String.class); + } + + // 自定义筛选 + JSONObject customFilterObj = JSONObject.parseObject(customFilter); + JSONArray frameworkSearchInput1Arr = customFilterObj.getJSONArray("frameworkSearchInput1Arr");//流程架构L1 + JSONArray frameworkSearchInput2Arr = customFilterObj.getJSONArray("frameworkSearchInput2Arr");//流程架构L2 + JSONArray frameworkSearchInput3Arr = customFilterObj.getJSONArray("frameworkSearchInput3Arr");//流程架构L3 + JSONArray issuingDepartmentArr = customFilterObj.getJSONArray("issuingDepartmentArr");// 发布部门 + + Set l1Set = new HashSet<>(); + Set l2Set = new HashSet<>(); + Set l3Set = new HashSet<>(); + Set deptSet = new HashSet<>(); + + for (int i = 0; i < frameworkSearchInput1Arr.size(); i++) { + l1Set.add(handleCustomFilterName(frameworkSearchInput1Arr.getJSONObject(i).getString("name"))); + } + for (int i = 0; i < frameworkSearchInput2Arr.size(); i++) { + l2Set.add(handleCustomFilterName(frameworkSearchInput2Arr.getJSONObject(i).getString("name"))); + } + for (int i = 0; i < frameworkSearchInput3Arr.size(); i++) { + l3Set.add(handleCustomFilterName(frameworkSearchInput3Arr.getJSONObject(i).getString("name"))); + } + for (int i = 0; i < issuingDepartmentArr.size(); i++) { + String deptId = issuingDepartmentArr.getJSONObject(i).getString("id"); + deptSet.add(deptId); + // 添加所有子部门 + List list = new ArrayList<>(); + getAllSubDepartments(deptId, list); + for (DepartmentModel model : list) { + deptSet.add(model.getId()); + } + + } + + List palList = new ArrayList<>(); + Set ids = new HashSet<>(); + PALRepositoryCache.getAllChildrenModelsByPid(wsId, category, palList, ids); + // 获取所有正在设计中的 + List tmpPalList = new ArrayList<>(); + Set levelSet = new HashSet<>(); + String [] selectValueArr = levelValue.split(","); + for (int i = 0; i < selectValueArr.length; i++) { + if (!UtilString.isEmpty(selectValueArr[i])) { + levelSet.add(selectValueArr[i]); + } + } + // 小组权限筛选 + Set permVerIds = new HashSet<>(); + if (UtilString.isNotEmpty(teamId)) { + // 获取权限versionIds + permVerIds = CoeProcessLevelUtil.getPermRepositoryVersionIds(wsId, teamId, _uc.getUID(), null, null); + + } + for (PALRepositoryModel model: palList) { + if (!model.isUse()) {// 非设计中状态,过滤 + continue; + } + if (!UtilString.isEmpty(searchInput)) {// 流程名称条件不为空时,过滤名称 + if (!model.getName().toUpperCase().contains(searchInput.toUpperCase())) { + continue; + } + } + if (levelSet.size() > 0) {// 流程层级不为空时,过滤层级 + if (!levelSet.contains(model.getLevel() + "")) { + continue; + } + } + if (typeList.size() > 0) {// 分类筛选 + if (!typeList.contains(model.getMethodId())) { + continue; + } + } + if (statusList.size() > 0) {// 状态筛选 + if (model.isPublish() && !statusList.contains("publish")) { + continue; + } + if (model.isStop() && !statusList.contains("stop")) { + continue; + } + if (!statusList.contains("designer") && !model.isStop() && !model.isPublish() && !model.isApproval()) { + continue; + } + } + if (UtilString.isNotEmpty(teamId)) {// 小组权限判断 + if (!permVerIds.contains(model.getVersionId())) { + continue; + } + } + // 自定义筛选 + if (l1Set.size() > 0) { + PALRepositoryPropertyModel l1PropModel = PALRepositoryPropertyCache.getPropertyByPropertyId(model.getId(), "Process_Architecture_L1"); + if (l1PropModel == null || !l1Set.contains(l1PropModel.getPropertyValue())) { + continue; + } + } + if (l2Set.size() > 0) { + PALRepositoryPropertyModel l2PropModel = PALRepositoryPropertyCache.getPropertyByPropertyId(model.getId(), "Process_Architecture_L2"); + if (l2PropModel == null || !l2Set.contains(l2PropModel.getPropertyValue())) { + continue; + } + } + if (l3Set.size() > 0) { + PALRepositoryPropertyModel l3PropModel = PALRepositoryPropertyCache.getPropertyByPropertyId(model.getId(), "Process_Architecture_L3"); + if (l3PropModel == null || !l3Set.contains(l3PropModel.getPropertyValue())) { + continue; + } + } + if (deptSet.size() > 0) { + List list = DesignerShapeRelationCache.getByFileId(model.getId(), "Issuing_department"); + if (list == null || list.size() == 0) { + continue; + } + boolean flag = false; + for (DesignerShapeRelationModel relation : list) { + if (UtilString.isEmpty(relation.getShapeId())) {// 文件属性 + JSONObject obj = JSONObject.parseObject(relation.getRelationShapeText()); + String id = obj.getString("id"); + if (deptSet.contains(id)) { + flag = true; + break; + } + } + } + if (!flag) { + continue; + } + } + // 追加 + tmpPalList.add(model); + } + return tmpPalList; + } + + + private String handleCustomFilterName(String name) { + String str2 = ""; + String str1=name.substring(0, name.lastIndexOf(".")+1); + if(UtilString.isNotEmpty(str1)){ + String end=name.substring(name.lastIndexOf(".")+1); + int len=Integer.valueOf(SubUtil.getQuantity(end).length()); + str2=name.substring(str1.length()+len, name.length()); + }else{ + str2=name; + } + return str2.trim(); + } + + + /** + * 获取所有子部门 + * @param deptId + * @param result + */ + private void getAllSubDepartments(String deptId, List result) { + List subModels = SDK.getORGAPI().getSubDepartments(deptId); + if (subModels != null && subModels.size() > 0) { + for (DepartmentModel model : subModels) { + result.add(model); + getAllSubDepartments(model.getId(), result); + } + } + } +} diff --git a/com.actionsoft.apps.coe.pal.processlist/src/com/actionsoft/apps/coe/pal/processlist/plugin/Plugins.java b/com.actionsoft.apps.coe.pal.processlist/src/com/actionsoft/apps/coe/pal/processlist/plugin/Plugins.java index 7a26993f..926edc5a 100644 --- a/com.actionsoft.apps.coe.pal.processlist/src/com/actionsoft/apps/coe/pal/processlist/plugin/Plugins.java +++ b/com.actionsoft.apps.coe.pal.processlist/src/com/actionsoft/apps/coe/pal/processlist/plugin/Plugins.java @@ -5,13 +5,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import com.actionsoft.apps.coe.pal.processlist.aslp.GetCountByProcessList; import com.actionsoft.apps.coe.pal.processlist.cache.ProcessListConfigCache; import com.actionsoft.apps.coe.pal.processlist.web.PALRepositoryListWeb; import com.actionsoft.apps.listener.PluginListener; import com.actionsoft.apps.resource.AppContext; -import com.actionsoft.apps.resource.plugin.profile.AWSPluginProfile; -import com.actionsoft.apps.resource.plugin.profile.AppExtensionProfile; -import com.actionsoft.apps.resource.plugin.profile.CachePluginProfile; +import com.actionsoft.apps.resource.plugin.profile.*; public class Plugins implements PluginListener { @@ -36,6 +35,7 @@ public class Plugins implements PluginListener { params1.put("title", "流程清单"); params1.put("desc", "流程清单"); list.add(new AppExtensionProfile("PAL小组->流程清单", "aslp://com.actionsoft.apps.coe.pal.cooperation/registerApp", params1)); + list.add(new ASLPPluginProfile("GetCountByProcessList", GetCountByProcessList.class.getName(), "获取流程相关的个数", new HttpASLP(HttpASLP.AUTH_RSA, null))); return list; } diff --git a/com.awspaas.user.apps.yili.reportform/src/com/awspaas/user/apps/yili/reportform/service/FileManagementService.java b/com.awspaas.user.apps.yili.reportform/src/com/awspaas/user/apps/yili/reportform/service/FileManagementService.java index c87de413..25817fe8 100644 --- a/com.awspaas.user.apps.yili.reportform/src/com/awspaas/user/apps/yili/reportform/service/FileManagementService.java +++ b/com.awspaas.user.apps.yili.reportform/src/com/awspaas/user/apps/yili/reportform/service/FileManagementService.java @@ -8,24 +8,37 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.Period; import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import com.actionsoft.apps.coe.pal.constant.CoEConstant; +import com.actionsoft.apps.coe.pal.pal.method.cache.PALMethodCache; +import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel; +import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodModel; +import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryAPIManager; +import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache; import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryPropertyCache; +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.apps.coe.pal.pal.repository.model.PALRepositoryPropertyModel; +import com.actionsoft.apps.coe.pal.pal.repository.util.CoeProcessLevelUtil; +import com.actionsoft.apps.coe.pal.processlist.model.ProcessListConfigModel; +import com.actionsoft.apps.coe.pal.util.SubUtil; import com.actionsoft.bpms.bo.engine.BO; import com.actionsoft.bpms.commons.database.RowMap; import com.actionsoft.bpms.commons.mvc.view.ActionWeb; import com.actionsoft.bpms.commons.mvc.view.ResponseObject; +import com.actionsoft.bpms.org.model.DepartmentModel; import com.actionsoft.bpms.server.RequestParams; import com.actionsoft.bpms.server.UserContext; import com.actionsoft.bpms.util.DBSql; import com.actionsoft.bpms.util.UtilString; +import com.actionsoft.i18n.I18nRes; import com.actionsoft.sdk.local.SDK; +import com.actionsoft.sdk.local.api.AppAPI; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.awspaas.user.apps.yili.reportform.cache.ProcessListConfigCache; import com.awspaas.user.apps.yili.reportform.util.GetNodesUtil; import com.awspaas.user.apps.yili.reportform.util.TreeUtil; @@ -59,7 +72,7 @@ public class FileManagementService extends ActionWeb { Integer guideFile = 0; Integer formFile = 0; HashMap fileSortMap = new HashMap<>(); - //List fileRowMaps = DBSql.getMaps( "SELECT FILEID,PLMETHODID,POLICYTYPE FROM BO_EU_PAL_FILE1 WHERE FILESTATE='1'"); + /*//List fileRowMaps = DBSql.getMaps( "SELECT FILEID,PLMETHODID,POLICYTYPE FROM BO_EU_PAL_FILE1 WHERE FILESTATE='1'"); List fileRowMaps = DBSql.getMaps("SELECT ID AS FILEID,EXT6 AS PUBDEPT,PLMETHODID,EXT5 AS FILESTATE,EXT3 AS POLICYTYPE FROM APP_ACT_COE_PAL_REPOSITORY WHERE ISPUBLISH = '1' AND EXT5 = '1' AND PLMETHODID in ('process.epc','process.flowchart','control.policy','data.form')"); //List fileRowMaps = DBSql.getMaps( "SELECT FILEID,PLMETHODID,POLICYTYPE FROM BO_EU_PAL_FILE1 WHERE FILESTATE='1'"); if (null!=fileRowMaps && !fileRowMaps.isEmpty()) { @@ -80,8 +93,15 @@ public class FileManagementService extends ActionWeb { formFile += 1; } } - } - ro.put("fileTotal",fileTotal); + }*/ + ResponseObject execute = execute(uc.getUID(), uc.getSessionId()); + System.out.println("execute>>>>>>>>>>>>>>>>>>"+execute.toJSONObject()); + JSONObject data = execute.toJSONObject().getJSONObject("data"); + fileTotal = Integer.valueOf(data.getString("fileTotal")); + processFile = Integer.valueOf(data.getString("processFile")); + policyFile = Integer.valueOf(data.getString("policyFile")); + formFile = Integer.valueOf(data.getString("formFile")); + ro.put("fileTotal",fileTotal); fileSortMap.put("processFile",processFile); fileSortMap.put("policyFile",policyFile); fileSortMap.put("guideFile",guideFile); @@ -90,6 +110,418 @@ public class FileManagementService extends ActionWeb { return ro.toString(); } + + public ResponseObject execute(String createUser,String sid) { +// 调用App + String sourceAppId = "com.awspaas.user.apps.yili.reportform"; +// aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.coe.pal.processlist/GetCountByProcessList"; +// 参数定义列表 + Map params = new HashMap(); +//创建人,必填 + params.put("createUser", createUser); +//sid,必填 + params.put("sid", sid); + AppAPI appAPI = SDK.getAppAPI(); +//获取流程相关的个数 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + return ro; + } + + /** + * 获取所有更多特性 + * @param category 流程分类,例如process + * @return + */ + private List getExtendAttrTableColumn(String wsId, String category) { + + List methodList = PALMethodCache.getPALMethodModelListByMethod(category); + List result = new ArrayList<>(); + Set ids = new HashSet<>(); + for (int i = 0; i < methodList.size(); i++) { + PALMethodModel model = methodList.get(i); + if (SDK.getAppAPI().isInstalled(model.getApp()) && SDK.getAppAPI().isActive(model.getApp())) { + // 获取所有属性 + List attrList = PALRepositoryAPIManager.getInstance().getValidAttributeModels(wsId, model.getId(), true); + for (PALMethodAttributeModel attr : attrList ) { + String id = attr.getKey(); + if (attr.getUse() && !ids.contains(id)) { + ids.add(id); + String name = attr.getNewTitle(); + String label = name; + String prop = id; + String width = "150"; + String minWidth = "150"; + String columnType = "extendAttr"; + boolean showOverflow = false; + JSONObject object1 = getJsonObject(prop, id, label, name, width, minWidth, showOverflow, columnType, "default"); + result.add(object1); + } + } + } + } + return result; + } + + /** + * 查询流程清单表头信息 + * @param wsId + * @param searchInput + * @param levelValue + * @param tableFilter 表格表头筛选条件 + * @return + */ + public int getProcessListHeader(String wsId, String teamId, String searchInput, String levelValue, String tableFilter, String customFilter) { + String category = "process"; + ResponseObject ro = ResponseObject.newOkResponse(); + // 获取默认的表格列 + LinkedHashMap defaultTableColumnMap = getDefaultFixedTableColumn(category); + // 获取流程下分类已经设置的更多特性 + List list = getExtendAttrTableColumn(wsId, category); + // 获取配置信息 + ProcessListConfigModel configModel = ProcessListConfigCache.getCache().get(wsId); + if (configModel == null || configModel.getCustomColumns() == null || configModel.getCustomColumns().isEmpty()) {// 从未配置,取默认 + // 默认已选中的配置项 + JSONArray customTableCheckedData = new JSONArray(); + for (Map.Entry entry : defaultTableColumnMap.entrySet()) { + customTableCheckedData.add(entry.getValue()); + } + ro.put("customTableCheckedData", customTableCheckedData);// 已选中表项 + ro.put("customTableUncheckedData", list);// 未选中表项 + } else { + // 获取配置信息 + JSONArray customColumns = configModel.getCustomColumns(); + JSONArray customTableCheckedData = new JSONArray();// 已选中表项 + Set checkedSet = new HashSet<>(); + LinkedHashMap extendAttrMap = new LinkedHashMap<>(16, 0.75f, true); + for (JSONObject obj : list) { + extendAttrMap.put(obj.getString("id"), obj); + } + // 判断已经设置的配置中在更多特性中是否还存在,存在则显示,不存在则不显示 + for (int i = 0; i < customColumns.size(); i++) { + JSONObject obj = customColumns.getJSONObject(i); + String columnType = obj.getString("columnType"); + String id = obj.getString("id"); + if ("extendAttr".equals(columnType)) { + // 检查是否还有该扩展字段 + if (extendAttrMap.containsKey(id)) {// 该属性还在已经配置好的更多特性中,则显示 + customTableCheckedData.add(obj); + checkedSet.add(id); + } + } else { + if (defaultTableColumnMap.containsKey(id)) { + customTableCheckedData.add(defaultTableColumnMap.get(id)); + } else { + customTableCheckedData.add(obj); + } + checkedSet.add(id); + } + } + // 未选中表项 + JSONArray customTableUncheckedData = new JSONArray(); + // 未选择的固定属性 + for (Map.Entry entry : defaultTableColumnMap.entrySet()) { + if (!checkedSet.contains(entry.getKey())) { + customTableUncheckedData.add(entry.getValue()); + } + } + // 未选择的扩展属性 + for (JSONObject obj : list) { + String id = obj.getString("id"); + if (!checkedSet.contains(id)) { + customTableUncheckedData.add(obj); + } + } + ro.put("customTableCheckedData", customTableCheckedData);// 已选中表项 + ro.put("customTableUncheckedData", customTableUncheckedData);// 未选中表项 + } + + List palList = getFilteredPalRepositoryList(wsId, teamId, category, searchInput, levelValue, tableFilter, customFilter); + return palList.size(); + } + private LinkedHashMap getDefaultFixedTableColumn(String category) { + String columnType = "default"; + LinkedHashMap map = new LinkedHashMap<>(16, 0.75f, true); + if ("process".equals(category)) { + // 编号(1-n排序)、序号(根据位置计算)、流程名称,类型,状态 + map.put("no_serialNumber", getJsonObject("no_serialNumber", "no_serialNumber", "序号", "序号", "78", "78", false, columnType, "default")); + map.put("no_default", getJsonObject("no_default", "no_default", "编号", "编号", "100", "100", false, columnType, "default")); + map.put("name", getJsonObject("name", "name", "流程名称", "流程名称", "250", "250", false, columnType, "name")); + JSONObject typeObj = getJsonObject("type", "type", "类型", "类型", "150", "150", false, columnType, "selectType"); + typeObj.put("filters", getProcessCategoryFilters(category)); + map.put("type", typeObj); + JSONObject statusObj = getJsonObject("status", "status", "状态", "状态", "150", "150", false, columnType, "selectStatus"); + statusObj.put("filters", getProcessStatusFilters()); + map.put("status", statusObj); + // map.put("parent_name",getJsonObject("parent_name","parent_name","上级名称","上级名称","250","250",false,columnType,"name")); + } + return map; + } + + + + /** + * 获取流程相关状态 + * @return + */ + private JSONArray getProcessStatusFilters() { + // 状态筛选项 + JSONArray processStatusArr = new JSONArray(); + JSONObject object3 = new JSONObject(); + object3.put("text", "设计中"); + object3.put("value", "designer"); + JSONObject object1 = new JSONObject(); + object1.put("text", "已发布"); + object1.put("value", "publish"); + JSONObject object2 = new JSONObject(); + object2.put("text", "已停用"); + object2.put("value", "stop"); + processStatusArr.add(object1); + processStatusArr.add(object2); + processStatusArr.add(object3); + return processStatusArr; + } + + + /** + * 获取分类下的建模方法 + * @param category + * @return + */ + private JSONArray getProcessCategoryFilters(String category) { + JSONArray categoryArr = new JSONArray(); + Set ids = new HashSet<>(); + if ("process".equals(category)) { + ids.add("default"); + JSONObject object = new JSONObject(); + object.put("text", I18nRes.findValue(CoEConstant.APP_ID, "default")); + object.put("value", "default"); + categoryArr.add(object); + } + List methodList = PALMethodCache.getPALMethodModelListByMethod("process"); + for (int i = 0; i < methodList.size(); i++) { + PALMethodModel model = methodList.get(i); + if (!ids.contains(model.getId()) && SDK.getAppAPI().isInstalled(model.getApp()) && SDK.getAppAPI().isActive(model.getApp())) { + JSONObject object = new JSONObject(); + object.put("text", I18nRes.findValue(CoEConstant.APP_ID, model.getId())); + object.put("value", model.getId()); + categoryArr.add(object); + } + } + return categoryArr; + } + + /** + * 组装对象 + * @param prop + * @param id + * @param label + * @param name + * @param width + * @param minWidth + * @param showOverflow + * @param columnType + * @param dataType + * @return + */ + private JSONObject getJsonObject(String prop, String id, String label, String name, String width, String minWidth, boolean showOverflow, String columnType, String dataType) { + JSONObject result = new JSONObject(); + result.put("prop", prop); + result.put("id", id); + result.put("label", label); + result.put("name", name); + result.put("width", width); + result.put("minWidth", minWidth); + result.put("showOverflow", showOverflow); + result.put("columnType", columnType); + result.put("dataType", dataType); + return result; + } + + + /** + * 获取符合条件的pal流程集合 + * @param wsId + * @param category + * @return + */ + private List getFilteredPalRepositoryList(String wsId, String teamId, String category, String searchInput, String levelValue, String tableFilter, String customFilter) { + // type,status + JSONObject tableFilterObj = JSONObject.parseObject(tableFilter); + // 类型 + List typeList = new ArrayList<>(); + if (tableFilterObj.containsKey("type")) { + typeList = JSONArray.parseArray(tableFilterObj.getString("type"), String.class); + } + // 状态 + List statusList = new ArrayList<>(); + if (tableFilterObj.containsKey("status")) { + statusList = JSONArray.parseArray(tableFilterObj.getString("status"), String.class); + } + + // 自定义筛选 + JSONObject customFilterObj = JSONObject.parseObject(customFilter); + JSONArray frameworkSearchInput1Arr = customFilterObj.getJSONArray("frameworkSearchInput1Arr");//流程架构L1 + JSONArray frameworkSearchInput2Arr = customFilterObj.getJSONArray("frameworkSearchInput2Arr");//流程架构L2 + JSONArray frameworkSearchInput3Arr = customFilterObj.getJSONArray("frameworkSearchInput3Arr");//流程架构L3 + JSONArray issuingDepartmentArr = customFilterObj.getJSONArray("issuingDepartmentArr");// 发布部门 + + Set l1Set = new HashSet<>(); + Set l2Set = new HashSet<>(); + Set l3Set = new HashSet<>(); + Set deptSet = new HashSet<>(); + + for (int i = 0; i < frameworkSearchInput1Arr.size(); i++) { + l1Set.add(handleCustomFilterName(frameworkSearchInput1Arr.getJSONObject(i).getString("name"))); + } + for (int i = 0; i < frameworkSearchInput2Arr.size(); i++) { + l2Set.add(handleCustomFilterName(frameworkSearchInput2Arr.getJSONObject(i).getString("name"))); + } + for (int i = 0; i < frameworkSearchInput3Arr.size(); i++) { + l3Set.add(handleCustomFilterName(frameworkSearchInput3Arr.getJSONObject(i).getString("name"))); + } + for (int i = 0; i < issuingDepartmentArr.size(); i++) { + String deptId = issuingDepartmentArr.getJSONObject(i).getString("id"); + deptSet.add(deptId); + // 添加所有子部门 + List list = new ArrayList<>(); + getAllSubDepartments(deptId, list); + for (DepartmentModel model : list) { + deptSet.add(model.getId()); + } + + } + + List palList = new ArrayList<>(); + Set ids = new HashSet<>(); + PALRepositoryCache.getAllChildrenModelsByPid(wsId, category, palList, ids); + // 获取所有正在设计中的 + List tmpPalList = new ArrayList<>(); + Set levelSet = new HashSet<>(); + String [] selectValueArr = levelValue.split(","); + for (int i = 0; i < selectValueArr.length; i++) { + if (!UtilString.isEmpty(selectValueArr[i])) { + levelSet.add(selectValueArr[i]); + } + } + // 小组权限筛选 + Set permVerIds = new HashSet<>(); + if (UtilString.isNotEmpty(teamId)) { + // 获取权限versionIds + permVerIds = CoeProcessLevelUtil.getPermRepositoryVersionIds(wsId, teamId, _uc.getUID(), null, null); + + } + for (PALRepositoryModel model: palList) { + if (!model.isUse()) {// 非设计中状态,过滤 + continue; + } + if (!UtilString.isEmpty(searchInput)) {// 流程名称条件不为空时,过滤名称 + if (!model.getName().toUpperCase().contains(searchInput.toUpperCase())) { + continue; + } + } + if (levelSet.size() > 0) {// 流程层级不为空时,过滤层级 + if (!levelSet.contains(model.getLevel() + "")) { + continue; + } + } + if (typeList.size() > 0) {// 分类筛选 + if (!typeList.contains(model.getMethodId())) { + continue; + } + } + if (statusList.size() > 0) {// 状态筛选 + if (model.isPublish() && !statusList.contains("publish")) { + continue; + } + if (model.isStop() && !statusList.contains("stop")) { + continue; + } + if (!statusList.contains("designer") && !model.isStop() && !model.isPublish() && !model.isApproval()) { + continue; + } + } + if (UtilString.isNotEmpty(teamId)) {// 小组权限判断 + if (!permVerIds.contains(model.getVersionId())) { + continue; + } + } + // 自定义筛选 + if (l1Set.size() > 0) { + PALRepositoryPropertyModel l1PropModel = PALRepositoryPropertyCache.getPropertyByPropertyId(model.getId(), "Process_Architecture_L1"); + if (l1PropModel == null || !l1Set.contains(l1PropModel.getPropertyValue())) { + continue; + } + } + if (l2Set.size() > 0) { + PALRepositoryPropertyModel l2PropModel = PALRepositoryPropertyCache.getPropertyByPropertyId(model.getId(), "Process_Architecture_L2"); + if (l2PropModel == null || !l2Set.contains(l2PropModel.getPropertyValue())) { + continue; + } + } + if (l3Set.size() > 0) { + PALRepositoryPropertyModel l3PropModel = PALRepositoryPropertyCache.getPropertyByPropertyId(model.getId(), "Process_Architecture_L3"); + if (l3PropModel == null || !l3Set.contains(l3PropModel.getPropertyValue())) { + continue; + } + } + if (deptSet.size() > 0) { + List list = DesignerShapeRelationCache.getByFileId(model.getId(), "Issuing_department"); + if (list == null || list.size() == 0) { + continue; + } + boolean flag = false; + for (DesignerShapeRelationModel relation : list) { + if (UtilString.isEmpty(relation.getShapeId())) {// 文件属性 + JSONObject obj = JSONObject.parseObject(relation.getRelationShapeText()); + String id = obj.getString("id"); + if (deptSet.contains(id)) { + flag = true; + break; + } + } + } + if (!flag) { + continue; + } + } + // 追加 + tmpPalList.add(model); + } + return tmpPalList; + } + + + private String handleCustomFilterName(String name) { + String str2 = ""; + String str1=name.substring(0, name.lastIndexOf(".")+1); + if(UtilString.isNotEmpty(str1)){ + String end=name.substring(name.lastIndexOf(".")+1); + int len=Integer.valueOf(SubUtil.getQuantity(end).length()); + str2=name.substring(str1.length()+len, name.length()); + }else{ + str2=name; + } + return str2.trim(); + } + + + /** + * 获取所有子部门 + * @param deptId + * @param result + */ + private void getAllSubDepartments(String deptId, List result) { + List subModels = SDK.getORGAPI().getSubDepartments(deptId); + if (subModels != null && subModels.size() > 0) { + for (DepartmentModel model : subModels) { + result.add(model); + getAllSubDepartments(model.getId(), result); + } + } + } + + /** * @methodName: * @param: