From 031b2ac6bf613eadc3e9729aba48c0c5ced22b04 Mon Sep 17 00:00:00 2001 From: yujh Date: Fri, 21 Feb 2025 18:19:59 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E9=97=A8=E8=AF=95=E5=9B=BE=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../template/page/Department.html | 93 +++---- .../controller/DataViewController.java | 11 +- .../reportform/service/DataViewService.java | 231 ++++++++++++++++-- 3 files changed, 270 insertions(+), 65 deletions(-) diff --git a/com.awspaas.user.apps.yili.integration/template/page/Department.html b/com.awspaas.user.apps.yili.integration/template/page/Department.html index 7ba816bf..1873ca28 100644 --- a/com.awspaas.user.apps.yili.integration/template/page/Department.html +++ b/com.awspaas.user.apps.yili.integration/template/page/Department.html @@ -15,7 +15,7 @@
- AI文件搜索 + AI文件搜索 - +
@@ -137,7 +137,7 @@ {{node.data.name}} - + @@ -176,8 +176,8 @@
-
数据加载中...
- +
数据加载中...
+
@@ -257,7 +257,9 @@ checkedInfo:false, checked1:false,//选中状态 concatenatedNamesTooltip:'暂无发布部门', - doesItExist:false + doesItExist:false, + // 防抖计时器 + debounceTimer: null }; }, mounted(){ @@ -334,13 +336,7 @@ }, watch: { filtertreeText(val){ - if(this.checkedInfo==true){ - this.fitlerNoFrameOptions = this.noFrameOptions.filter(option => { - return option.name.toLowerCase().includes(val.toLowerCase()); - }); - }else{ - this.$refs.treeNode.filter(val); - } + this.search(); }, filterText(val) { this.$refs.tree.filter(val); @@ -349,29 +345,29 @@ methods: { // 全部选中 - chooseAll() { - this.roleList = ""; - // 判断按钮的状态 - if (this.checked1) { - this.loading=true; - // 设置 - this.$refs.tree.setCheckedNodes(this.list); - } else { - this.$refs.tree.setCheckedNodes([]); - } - this.treelist = this.$refs.tree.getCheckedKeys(); - this.treeListNodes = this.$refs.tree.getCheckedNodes(); + chooseAll() { + this.roleList = ""; + // 判断按钮的状态 + if (this.checked1) { + this.loading=true; + // 设置 + this.$refs.tree.setCheckedNodes(this.list); + } else { + this.$refs.tree.setCheckedNodes([]); + } + this.treeListNodes = this.$refs.tree.getCheckedNodes(); + this.treelist = this.$refs.tree.getCheckedKeys(); this.selectdept = JSON.stringify(this.treelist) this.options = [] if (this.treelist.length == 0) { this.selectdept = [] } this.leftTreedatabind() - }, - //增加键盘回车事件 + }, + //增加键盘回车事件 search(){ // 控制一下,如果用户没输入东西就不去搜索 - if(this.filtertreeText == ""){ + /*if(this.filtertreeText == ""){ return }else{ if(this.checkedInfo==true){ @@ -381,7 +377,19 @@ }else{ this.$refs.treeNode.filter(this.filtertreeText); } + + }*/ + // 清除之前的计时器 + if (this.debounceTimer) { + clearTimeout(this.debounceTimer); } + // 设置新的计时器 + this.debounceTimer = setTimeout(() => { + // 调用查询接口的方法 + this.loading=true; + this.options = [] + this.leftTreedatabind() + }, 500); // 500 毫秒的延迟,可以根据实际需求调整 }, navtab(e){ this.tab = e; @@ -443,7 +451,8 @@ this.options = [] let params = { dept: _this.selectdept, - fileType: _this.filetype + fileType: _this.filetype, + filtertreeText: _this.filtertreeText } $.ajax({ url: api.leftTreeurl, @@ -475,7 +484,7 @@ _this.formFileNum = 0 } //最后搜索一下 - this.search(); + //this.search(); }); }, @@ -485,7 +494,8 @@ this.options = [] let params = { dept: _this.selectdept, - fileType: _this.filetype + fileType: _this.filetype, + filtertreeText: _this.filtertreeText } $.ajax({ url: api.leftTreeurl, @@ -510,7 +520,7 @@ _this.defaultkey.push(element.ID) }); //最后搜索一下 - this.search(); + //this.search(); } }); }, @@ -531,7 +541,7 @@ } }, selcetchangetype(e) { - this.loading=true; + this.loading=true; this.filetype = this.selectvalue this.options = [] this.leftTreedatabind() @@ -564,7 +574,7 @@ nodeArry.push(nodeObj.data) this.$refs.tree.setCheckedNodes(nodeArry); this.treeListNodes = this.$refs.tree.getCheckedNodes(); - this.selectdept = []; + //this.selectdept = []; this.processFileNum = '';//流程数量 this.policyFileNum = '';//制度数量 if(this.checkedInfo==true){ @@ -590,16 +600,17 @@ setDefault(){ this.treelist.push(this.departmentId); this.idjson.push(this.departmentId); + this.selectdept = JSON.stringify(this.treelist) }, openGptHome() { //let url = "https://chatgpt-uat.dcin-test.digitalyili.com/welcome?from=libchat&lib=ef2b50fd79c52577d51222bc58b231d7&priv=1&sid=" + sid ; //this.fullscreen = window.innerWidth <= 768; // 小屏幕时全屏显示 - //https://yiligpt.x.digitalyili.com/libchat?lib=b8e082947190f2aa4fca0d96a5a95ea5&priv=1&sid= + //https://yiligpt.x.digitalyili.com/libchat?lib=b8e082947190f2aa4fca0d96a5a95ea5&priv=1&sid= //this.newPageUrl = "https://iam.digitalyili.com/proxy/sso?target=https://yiligpt.x.digitalyili.com/libchat?lib=b8e082947190f2aa4fca0d96a5a95ea5&priv=1&sid=" + sid; - var sids=encodeURIComponent(sid); - //this.newPageUrl = "https://iam.digitalyili.com/proxy/sso?target=https%3A%2F%2Fyiligpt.x.digitalyili.com%2Flibchat%3Flib%3Db8e082947190f2aa4fca0d96a5a95ea5%26priv%3D1%26sid%3D"+ sids; - this.newPageUrl = "https://iam.digitalyili.com/proxy/sso?target=https://yiligpt.x.digitalyili.com/libchat%25253Flib=b8e082947190f2aa4fca0d96a5a95ea5%252526priv=1%252526sid="+ sids; - document.cookie = "AWSSESSIONID="+sid; + var sids=encodeURIComponent(sid); + //this.newPageUrl = "https://iam.digitalyili.com/proxy/sso?target=https%3A%2F%2Fyiligpt.x.digitalyili.com%2Flibchat%3Flib%3Db8e082947190f2aa4fca0d96a5a95ea5%26priv%3D1%26sid%3D"+ sids; + this.newPageUrl = "https://iam.digitalyili.com/proxy/sso?target=https://yiligpt.x.digitalyili.com/libchat%25253Flib=b8e082947190f2aa4fca0d96a5a95ea5%252526priv=1%252526sid="+ sids; + document.cookie = "AWSSESSIONID="+sid; this.param1=sid; this.dialogVisible = true; @@ -611,7 +622,7 @@ this.dialogVisible = false; window.open("https://iam.digitalyili.com/proxy/sso?target=https%3A%2F%2Fyiligpt.x.digitalyili.com%2Fauth-center%253Fplatform%253Doa%2526lib%253Db8e082947190f2aa4fca0d96a5a95ea5%2526priv%253D1", "_blank"); } - }, + }, }); @@ -702,7 +713,7 @@ .el-input--prefix .el-input__inner{padding-left: 45px; height: 35px;line-height: 35px; width: 90%;} .el-input__icon{line-height: 35px;} .el-input--suffix .el-input__inner{ height: 35px;line-height: 35px; width: 100%;} -#postSearchCart .el-input{width: 81%!important;} + #postSearchCart .el-input{width: 81%!important;} .el-input__suffix{right: 25px;} /* 左侧手风琴样式 */ .el-tree-node__content{ background-color: #f1f5fa!important;padding: 6px 10px!important;} diff --git a/com.awspaas.user.apps.yili.reportform/src/com/awspaas/user/apps/yili/reportform/controller/DataViewController.java b/com.awspaas.user.apps.yili.reportform/src/com/awspaas/user/apps/yili/reportform/controller/DataViewController.java index 9a4144d1..0f026b9e 100644 --- a/com.awspaas.user.apps.yili.reportform/src/com/awspaas/user/apps/yili/reportform/controller/DataViewController.java +++ b/com.awspaas.user.apps.yili.reportform/src/com/awspaas/user/apps/yili/reportform/controller/DataViewController.java @@ -67,10 +67,17 @@ public class DataViewController { } return queryTermsDeptVal; } + @Mapping(value = "com.awspaas.user.apps.yili.reportform.service.DataViewService_deptView", desc = "部门视图") public String deptView(UserContext uc, RequestParams params) { - String deptViewVal = deptViewVal = new DataViewService(uc).deptView(uc, params); - return deptViewVal; + //这里先做一个参数,用于新旧切换 + String deptViewVersion = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.reportform", "deptViewVersion"); + System.out.println(">>>deptViewVersion = " + deptViewVersion); + if("2.0".equals(deptViewVersion)){ + return new DataViewService(uc).getDeptViewInfo(uc, params); + }else{ + return new DataViewService(uc).deptView(uc, params); + } } } diff --git a/com.awspaas.user.apps.yili.reportform/src/com/awspaas/user/apps/yili/reportform/service/DataViewService.java b/com.awspaas.user.apps.yili.reportform/src/com/awspaas/user/apps/yili/reportform/service/DataViewService.java index f2eed024..e1819276 100644 --- a/com.awspaas.user.apps.yili.reportform/src/com/awspaas/user/apps/yili/reportform/service/DataViewService.java +++ b/com.awspaas.user.apps.yili.reportform/src/com/awspaas/user/apps/yili/reportform/service/DataViewService.java @@ -24,19 +24,15 @@ import com.alibaba.fastjson.JSONObject; import com.awspaas.user.apps.yili.reportform.util.GetNodesUtil; import com.awspaas.user.apps.yili.reportform.util.TaskUtil; import com.awspaas.user.apps.yili.reportform.util.TreeUtil; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.TreeSet; -import java.util.function.Function; + +import java.sql.Connection; +import java.util.*; import java.util.stream.Collectors; import net.sf.json.JSONArray; import org.springframework.util.StringUtils; +import javax.lang.model.SourceVersion; + import static java.util.stream.Collectors.collectingAndThen; import static java.util.stream.Collectors.toCollection; @@ -1672,11 +1668,7 @@ public class DataViewService fileTypes.add(fileType); fileType = new HashMap<>(); fileType.put("termsKey", "policyFile"); - fileType.put("termsVal", "制度"); - fileTypes.add(fileType); - fileType = new HashMap<>(); - fileType.put("termsKey", "guideFile"); - fileType.put("termsVal", "操作指导"); + fileType.put("termsVal", "制度/操作指导"); fileTypes.add(fileType); fileType = new HashMap<>(); fileType.put("termsKey", "formFile"); @@ -1700,13 +1692,77 @@ public class DataViewService } - - - - - - - + /** + * 根据查询条件获取部门视图数据 + * @param uc 用户上下文 + * @param params 参数列表 + * @return + */ + public String getDeptViewInfo(UserContext uc, RequestParams params) { + ResponseObject ro = ResponseObject.newOkResponse(); + List frameIDs = new ArrayList<>();//树的架构文件集合 + LinkedHashMap filesCount = new LinkedHashMap<>();//各文件数量集合 + filesCount.put("processFileNum", 0); + filesCount.put("policyFileNum", 0); + filesCount.put("guideFileNum", 0); + filesCount.put("formFileNum", 0); + filesCount.put("processschemeFileNum", 0); + filesCount.put("engineeringtandardFileNum", 0); + List fileMaps = new ArrayList<>(); + String deptString = params.get("dept"); //前端部门过滤字段 + String fileType = params.get("fileType");//前端文件类型过滤字段 + String filterTreeText = params.get("filtertreeText");//前端文件名称过滤字段 + System.out.println(">>>deptString = " + deptString); + System.out.println(">>>fileType = " + fileType); + System.out.println(">>>filterTreeText = " + filterTreeText); + //默认的过滤文件类型 + Set validMethodIds = new HashSet<>(Arrays.asList( + "process.epc", + "control.policy", + "process.flowchart", + "engineering.standard", + "process.scheme" + )); + //先获取流程资产库全部文件 + String wsId = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.reportform", "wsId"); + Iterator allPALRepositoryList = PALRepositoryCache.getByWsId(wsId); + //遍历全部文件,把符合条件的集合加入fileMaps中 + while (allPALRepositoryList.hasNext()) { + Map fileMap = new HashMap();//model组装的fileMap数据 + PALRepositoryModel model = allPALRepositoryList.next(); + String methodId = model.getMethodId();//文件类型 + String policyType = model.getExt3();//策略类型 + // 过滤无效文件 + if (!isValidFile(model, filterTreeText, deptString, fileType, validMethodIds)) { + continue; + } + //1. 获取树的架构信息 + String plParentId = model.getParentId(); + PALRepositoryModel reFileModel = PALRepositoryCache.getCache().get(plParentId); + if (null != reFileModel) { + String PLMETHODID = reFileModel.getMethodId(); + if (PLMETHODID.equals("process.framework")) { + frameIDs.add(plParentId); + } + String rePPLPARENTID = reFileModel.getParentId(); + frameIDs.add(rePPLPARENTID); + } + //把model信息组装成最终想要的信息 + model2FileMap(uc,model,fileMap); + //最后统计文件数量 + addFileTypeNum(methodId,policyType,filesCount,fileMap); + fileMaps.add(fileMap); + } + //把架构信息,增加的fileMaps里 + addFrameInfoToFileMaps(fileMaps,frameIDs); + //组装成树 + List fileTreeNodes = TreeUtil.buildTreeFileFirst("0", fileMaps, "process", "frame", null, null); + //组装返回信息 开始 + ro.put("filesCount", filesCount); + ro.put("fileMaps", fileTreeNodes); + //组装返回信息 结束 + return ro.toString(); + } public String deptView(UserContext uc, RequestParams params) { ResponseObject ro = ResponseObject.newOkResponse(); @@ -2034,7 +2090,6 @@ public class DataViewService path = "./w?cmd=com.actionsoft.apps.coe.pal.publisher_publish_file_open&uuid=" + fileRowMap.getString("FILEID") + "&" + "sid=" + sid + "&" + "taskId=" + taskId; - nodeType = "file"; fileMap.put("ID", fileRowMap.getString("FILEID")); fileMap.put("PARENTID", fileRowMap.getString("PLPARENTID")); @@ -2442,4 +2497,136 @@ public class DataViewService } return taskId; } + + /** + * 计算指定文件类型数量 + * @param methodId + */ + public void addFileTypeNum(String methodId,String policyType,LinkedHashMap filesCount,Map fileMap){ + if (methodId.equals("process.epc") || methodId.equals("process.flowchart")) { + fileMap.put("fileType", "processFile"); + filesCount.put("processFileNum", filesCount.get("processFileNum") +1); + } else if (methodId.equals("control.policy") && (UtilString.isEmpty(policyType) || policyType.equals("regulation"))) { + fileMap.put("fileType", "policyFile"); + filesCount.put("policyFileNum", filesCount.get("policyFileNum") +1); + } else if (methodId.equals("control.policy") && policyType.equals("I/O_L4")) { + fileMap.put("fileType", "guideFile"); + filesCount.put("guideFileNum", filesCount.get("guideFileNum") +1); + } else if (methodId.equals("data.form")) { + fileMap.put("fileType", "formFile"); + filesCount.put("formFileNum", filesCount.get("formFileNum") +1); + }else if(methodId.equals("engineering.standard")){ + fileMap.put("fileType", "engineeringtandardFile"); + filesCount.put("engineeringtandardFileNum", filesCount.get("engineeringtandardFileNum") +1); + } else if (methodId.equals("process.scheme")) { + fileMap.put("fileType", "processschemeFile"); + filesCount.put("processschemeFileNum", filesCount.get("processschemeFileNum") +1); + } + } + + /** + * 把架构信息,增加的fileMaps里 + * @param fileMaps + * @param frameIDs + */ + public void addFrameInfoToFileMaps(List fileMaps,List frameIDs){ + List frameRowMaps = new ArrayList<>(); + frameIDs = frameIDs.stream().distinct().collect(Collectors.toList()); + for (String frameID : frameIDs) { + frameRowMaps = GetNodesUtil.getParentFrame(frameID, frameRowMaps); + } + frameRowMaps = frameRowMaps.stream() + .collect(collectingAndThen( + toCollection( + () -> new TreeSet<>(Comparator.comparing(o -> o.getString("FRAMEID")))), + ArrayList::new)); + + for (RowMap frameRowMap : frameRowMaps) { + Map frameMap = new HashMap<>(); + String nodeType = "frame"; + frameMap.put("ID", frameRowMap.getString("FRAMEID")); + frameMap.put("PARENTID", frameRowMap.getString("FRAMEPARENTID")); + frameMap.put("name", frameRowMap.getString("FRAMENAME")); + frameMap.put("ORDERINDEX", frameRowMap.getString("FRAMEORDERINDEX")); + frameMap.put("TLEVEL", frameRowMap.getString("FRAMELEVEL")); + frameMap.put("nodeType", nodeType); + fileMaps.add(frameMap); + } + } + + /** + * model信息转fileMap + * @param model + * @param fileMap + */ + public void model2FileMap(UserContext uc,PALRepositoryModel model,Map fileMap){ + String path = "./w?cmd=com.actionsoft.apps.coe.pal.publisher_publish_file_open&uuid=" + model.getId() + "&" + "sid=" + uc.getSessionId() + "&" + "taskId="; + String nodeType = "file"; + fileMap.put("ID", model.getId()); + fileMap.put("PARENTID", model.getParentId()); + fileMap.put("name", model.getName()); + fileMap.put("PLMETHODID", model.getMethodId()); + fileMap.put("PUBDATETIME", model.getPublishDate()); + fileMap.put("path", path); + fileMap.put("ORDERINDEX",model.getOrderIndex()); + fileMap.put("nodeType", nodeType); + } + + /** + * 判断文件是否有效 + */ + private boolean isValidFile(PALRepositoryModel model,String filterTreeText,String deptString,String fileType,Set validMethodIds) { + String methodId = model.getMethodId(); + String fileName = model.getName(); + // 1. 文件发布状态检查 + if (!model.isPublish() || model.isStop() || !"1".equals(model.getExt5()) || + UtilString.isEmpty(model.getExt6())) { + return false; + } + // 2. 文件名称过滤 ,如果前端查文件名称,则名称匹配上则直接返回,无需走类型过滤和部门过滤 + if(UtilString.isNotEmpty(filterTreeText) && !fileName.contains(filterTreeText)){ + return false; + } + // 3. 文件类型过滤 + //查询条件为空,则查默认的文件类型 + if(UtilString.isEmpty(fileType) && !validMethodIds.contains(methodId)){ + return false; + } + //查询条件不为空,且不为全部 + if (UtilString.isNotEmpty(fileType) && !fileType.equals("totalFile")){ + //查询流程 + if(fileType.equals("processFile") && !methodId.equals("process.epc") && !methodId.equals("process.flowchart")){ + return false; + } + //查询制度 + if(fileType.equals("policyFile") && !methodId.equals("control.policy")){ + return false; + } + //查询表单 + if(fileType.equals("formFile") && !methodId.equals("data.form")){ + return false; + } + //查询工程技术标准 + if(fileType.equals("engineeringtandardFile") && !methodId.equals("engineering.standard")){ + return false; + } + //查询方案图 + if(fileType.equals("processschemeFile") && !methodId.equals("process.scheme")){ + return false; + } + } + // 4. 部门过滤 + //没有查询文件名时,才过滤部门 + if(UtilString.isEmpty(filterTreeText)){ + if(UtilString.isEmpty(deptString)){ + return false; + } + String[] deptArray = model.getExt6().split(","); + if (Arrays.stream(deptArray).noneMatch(deptString::contains)) { + return false; + } + } + return true; + } + }