部门试图代码优化

This commit is contained in:
yujh 2025-02-21 18:19:59 +08:00
parent 708c6fbdba
commit 031b2ac6bf
3 changed files with 270 additions and 65 deletions

View File

@ -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);
@ -359,8 +355,8 @@
} else {
this.$refs.tree.setCheckedNodes([]);
}
this.treelist = this.$refs.tree.getCheckedKeys();
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) {
@ -371,7 +367,7 @@
//增加键盘回车事件
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();
}
});
},
@ -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,6 +600,7 @@
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 ;

View File

@ -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);
}
}
}

View File

@ -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<String> frameIDs = new ArrayList<>();//树的架构文件集合
LinkedHashMap<String, Integer> 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<Map> 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<String> 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<PALRepositoryModel> allPALRepositoryList = PALRepositoryCache.getByWsId(wsId);
//遍历全部文件把符合条件的集合加入fileMaps中
while (allPALRepositoryList.hasNext()) {
Map fileMap = new HashMap<String,String>();//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<Map> 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<String, Integer> 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<Map> fileMaps,List<String> frameIDs){
List<RowMap> 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<String,Object> 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<String> 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;
}
}