流程清单查询文件属性时性能优化

This commit is contained in:
446052889@qq.com 2022-11-24 17:55:36 +08:00
parent 2c4056a284
commit 5eeccf41fe
4 changed files with 18 additions and 6 deletions

View File

@ -3,6 +3,7 @@ package com.actionsoft.apps.coe.pal.processlist.web;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import com.actionsoft.apps.coe.pal.constant.CoEConstant;
import com.actionsoft.apps.coe.pal.log.CoEOpLogAPI;
@ -15,6 +16,7 @@ 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.dao.CoeProcessLevelDaoFacotory;
import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepository;
import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepositoryPropertyDao;
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;
@ -873,7 +875,10 @@ public class PALRepositoryListWeb extends ActionWeb {
JSONArray headConfigs = JSONArray.parseArray(tableHead.toString());
// 查询表格数据
JSONArray result = new JSONArray();
PALRepositoryPropertyDao propertyDao = new PALRepositoryPropertyDao();
List<PALRepositoryPropertyModel> propertyModelList = propertyDao.queryByWsId(wsId);
for (PALRepositoryModel model: tempList) {
List<PALRepositoryPropertyModel> props = propertyModelList.stream().filter(prop -> {return prop.getPlId().equals(model.getId());}).collect(Collectors.toList());
JSONObject obj = new JSONObject();
obj.put("id", model.getId());
obj.put("methodId", model.getMethodId());
@ -881,7 +886,7 @@ public class PALRepositoryListWeb extends ActionWeb {
// obj.put("statusCode", model.isApproval() ? "approval" : model.isPublish() ? "publish" : model.isStop() ? "stop" : "designer");
obj.put("version", VersionUtil.getVersionStrV(model.getVersion()));
// 获取所有扩展属性的值
JSONObject extendAttrValObj = CoeProcessLevelUtil.getProcessLevelPropertyVal(model.getId());
JSONObject extendAttrValObj = CoeProcessLevelUtil.getProcessLevelPropertyVal(model.getId(), model, props);
JSONObject object = new JSONObject();
Iterator iter = extendAttrValObj.entrySet().iterator();
while (iter.hasNext()) {
@ -1131,6 +1136,8 @@ public class PALRepositoryListWeb extends ActionWeb {
styleData.setRightBorderColor(HSSFColor.BLACK.index);
styleData.setBorderTop(BorderStyle.THIN);
styleData.setTopBorderColor(HSSFColor.BLACK.index);
PALRepositoryPropertyDao propertyDao = new PALRepositoryPropertyDao();
List<PALRepositoryPropertyModel> propertyModelList = propertyDao.queryByWsId(wsId);
for (int i = 0; i < palList.size(); i++) {
PALRepositoryModel model = palList.get(i);
rowIndex++;
@ -1180,10 +1187,11 @@ public class PALRepositoryListWeb extends ActionWeb {
}
// 获取所有扩展属性的值
JSONObject extendAttrValObj = new JSONObject();
List<PALRepositoryPropertyModel> props = propertyModelList.stream().filter(prop -> {return prop.getPlId().equals(model.getId());}).collect(Collectors.toList());
if (extendAttr) {// 如果表格中没有更多特性则不查询节省时间
if(null!=model) {
try {
extendAttrValObj = CoeProcessLevelUtil.getProcessLevelPropertyVal(model.getId());
extendAttrValObj = CoeProcessLevelUtil.getProcessLevelPropertyVal(model.getId(), model, props);
} catch (Exception e) {
System.err.println("清单无法导出的模型ID"+model.getId());
// TODO: handle exception

View File

@ -2133,16 +2133,20 @@ public class CoeProcessLevelUtil {
return result;
}
public static JSONObject getProcessLevelPropertyVal(String uuid) {
return getProcessLevelPropertyVal(uuid, (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid), new PALRepositoryPropertyDao().getPropertysByPlid(uuid, null));
}
/**
* 文件自定义属性
* @param uuid
*/
public static JSONObject getProcessLevelPropertyVal(String uuid) {
public static JSONObject getProcessLevelPropertyVal(String uuid, PALRepositoryModel m, List<PALRepositoryPropertyModel> propertys) {
int index = 1;
JSONObject result = new JSONObject();
PALRepositoryModel plModel = PALRepositoryCache.getCache().get(uuid);
Map<String, Object> map = new HashMap<String, Object>();
PALRepositoryModel m = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(plModel.getId());
// PALRepositoryModel m = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(plModel.getId());
// 获取所有文件属性
List<PALMethodAttributeModel> methodAttrModels = PALRepositoryAPIManager.getInstance().getValidAttributeModels(m.getWsId(), m.getMethodId());
if (methodAttrModels != null && methodAttrModels.size() > 0) {
@ -2157,8 +2161,8 @@ public class CoeProcessLevelUtil {
}
PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(m.getMethodId());
List<PALMethodAttributeGroupModel> groups = methodModel.getGroup();
PALRepositoryPropertyDao dao = new PALRepositoryPropertyDao();
List<PALRepositoryPropertyModel> propertys = dao.getPropertysByPlid(plModel.getId(), null);
// PALRepositoryPropertyDao dao = new PALRepositoryPropertyDao();
// List<PALRepositoryPropertyModel> propertys = dao.getPropertysByPlid(plModel.getId(), null);
//List<PALRepositoryPropertyModel> propertys = PALRepositoryPropertyCache.getPropertyByPlId(plModel.getId());
// 排序
propertys.sort((p1, p2) -> (sortAttrMap.containsKey(p1.getPropertyId()) ? sortAttrMap.get(p1.getPropertyId()) : 0) - (sortAttrMap.containsKey(p2.getPropertyId()) ? sortAttrMap.get(p2.getPropertyId()) : 0));