解决发布部门/支持文件排序问题

This commit is contained in:
zhal 2022-11-02 14:05:08 +08:00
parent 859402c698
commit b8f90fd4fa
7 changed files with 140 additions and 72 deletions

View File

@ -6,15 +6,7 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.*;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.actionsoft.apps.coe.pal.cooperation.CoeCooperationAPIManager; import com.actionsoft.apps.coe.pal.cooperation.CoeCooperationAPIManager;
import com.actionsoft.apps.coe.pal.log.CoEOpLogAPI; import com.actionsoft.apps.coe.pal.log.CoEOpLogAPI;
@ -95,6 +87,7 @@ import com.actionsoft.apps.coe.pal.pal.repository.util.CoeProcessLevelUtil;
import com.actionsoft.apps.coe.pal.pal.ws.dao.CoeWorkSpace; import com.actionsoft.apps.coe.pal.pal.ws.dao.CoeWorkSpace;
import com.actionsoft.apps.coe.pal.pal.ws.web.VersionUtil; import com.actionsoft.apps.coe.pal.pal.ws.web.VersionUtil;
import com.actionsoft.apps.coe.pal.util.StringHandleUtil; import com.actionsoft.apps.coe.pal.util.StringHandleUtil;
import com.actionsoft.bpms.util.Base64;
import com.actionsoft.exception.AWSException; import com.actionsoft.exception.AWSException;
import com.actionsoft.i18n.I18nRes; import com.actionsoft.i18n.I18nRes;
import com.actionsoft.sdk.local.SDK; import com.actionsoft.sdk.local.SDK;
@ -5430,6 +5423,9 @@ public class PALRepositoryQueryAPIManager {
if ("relation".equals(attributeModel.getType())) { if ("relation".equals(attributeModel.getType())) {
List<String> inputValueList = new ArrayList<>(); List<String> inputValueList = new ArrayList<>();
List<DesignerShapeRelationModel> list = DesignerShapeRelationCache.getListByAttrId(plModel.getId(), "", attributeModel.getKey()); List<DesignerShapeRelationModel> list = DesignerShapeRelationCache.getListByAttrId(plModel.getId(), "", attributeModel.getKey());
if(attributeModel.getKey().equals("support_files")){
list.sort(Comparator.comparing(DesignerShapeRelationModel::getRelationShapeText));
}
if (list != null && list.size() > 0) { if (list != null && list.size() > 0) {
// 判断是否有重复数据进行重复过滤 // 判断是否有重复数据进行重复过滤
Set<String> tempStrs = new HashSet<>(); Set<String> tempStrs = new HashSet<>();
@ -5504,8 +5500,11 @@ public class PALRepositoryQueryAPIManager {
List<String> positionValList = new ArrayList<>(); List<String> positionValList = new ArrayList<>();
List<String> roleValList = new ArrayList<>(); List<String> roleValList = new ArrayList<>();
List<String> userValList = new ArrayList<>(); List<String> userValList = new ArrayList<>();
JSONArray depjsonArray=new JSONArray();
if (list != null && list.size() > 0) { if (list != null && list.size() > 0) {
Set<String> filter = new HashSet<String>();// 去重记录 Set<String> filter = new HashSet<String>();// 去重记录
list.sort((m1, m2) -> { list.sort((m1, m2) -> {
return m1.getId().compareTo(m2.getId()); return m1.getId().compareTo(m2.getId());
}); });
@ -5514,14 +5513,31 @@ public class PALRepositoryQueryAPIManager {
JSONObject object = JSONObject.parseObject(model.getRelationShapeText()); JSONObject object = JSONObject.parseObject(model.getRelationShapeText());
boolean flag = false; boolean flag = false;
// 查询最新名称 // 查询最新名称
if ("department".equals(object.getString("type"))) { /*if ("department".equals(object.getString("type"))) {
DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id")); DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id"));
if (dept != null && !filter.contains(dept.getId())) { if (dept != null && !filter.contains(dept.getId())) {
deptValList.add(dept.getName()); deptValList.add(dept.getName());
filter.add(dept.getId()); filter.add(dept.getId());
flag = true; flag = true;
} }
}*/
/*************************************部门自定义排序改造******************************************************/
if ("department".equals(object.getString("type"))) {
DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id"));
if (dept != null && !filter.contains(dept.getId())) {
if(object.getString("timestamp")!=null){
flag = false;
depjsonArray.add(object);
}else{
deptValList.add(dept.getName());
filter.add(dept.getId());
flag = true;
}
}
} }
if ("position".equals(object.getString("type"))) {// 岗位先用角色代替 if ("position".equals(object.getString("type"))) {// 岗位先用角色代替
RoleModel role = SDK.getORGAPI().getRoleById(object.getString("id")); RoleModel role = SDK.getORGAPI().getRoleById(object.getString("id"));
if (role != null && !filter.contains(role.getId())) { if (role != null && !filter.contains(role.getId())) {
@ -5549,6 +5565,22 @@ public class PALRepositoryQueryAPIManager {
if (flag) { if (flag) {
attrObj.getJSONArray("value").add(object); attrObj.getJSONArray("value").add(object);
} }
}
}
/*********************************自定义排序*******************************/
if(depjsonArray.size()>0 && depjsonArray.getJSONObject(0).getString("timestamp")!=null){
Set<String> filter1 = new HashSet<String>();// 去重记录
depjsonArray.sort(Comparator.comparing(st ->((JSONObject)st).getString("timestamp")));
JSONObject jo = new JSONObject(new LinkedHashMap());
for(int b=0;b<depjsonArray.size();b++){
JSONObject onedata=depjsonArray.getJSONObject(b);
DepartmentModel dept = SDK.getORGAPI().getDepartmentById(onedata.getString("id"));
deptValList.add(dept.getName());
filter1.add(dept.getId());
attrObj.getJSONArray("value").add(onedata);
} }
} }
} }

View File

@ -2,15 +2,7 @@ package com.actionsoft.apps.coe.pal.pal.repository.designer.relation.web;
import java.io.File; import java.io.File;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.ArrayList; import java.util.*;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.actionsoft.apps.AppsConst; import com.actionsoft.apps.AppsConst;
import com.actionsoft.apps.coe.pal.constant.CoEConstant; import com.actionsoft.apps.coe.pal.constant.CoEConstant;
@ -974,6 +966,9 @@ public class DesignerRelationShapeWeb extends ActionWeb {
} }
String tmpStr = StringUtils.join(versionIds, ","); String tmpStr = StringUtils.join(versionIds, ",");
List<DesignerShapeRelationModel> list = dao.getModelListByShapeIdAndRelationShapeId(ruuid, shapeId, null, tmpStr); List<DesignerShapeRelationModel> list = dao.getModelListByShapeIdAndRelationShapeId(ruuid, shapeId, null, tmpStr);
if(attrId.equals("support_files")){
list.sort(Comparator.comparing(DesignerShapeRelationModel::getRelationShapeText));
}
for (DesignerShapeRelationModel model : list) { for (DesignerShapeRelationModel model : list) {
if (ids.contains(model.getRelationFileId())) { if (ids.contains(model.getRelationFileId())) {
continue; continue;
@ -994,6 +989,7 @@ public class DesignerRelationShapeWeb extends ActionWeb {
} else {// 关联形状 } else {// 关联形状
Set<String> ids = new HashSet<>(); Set<String> ids = new HashSet<>();
List<DesignerShapeRelationModel> list = dao.getModelListByShapeIdAndRelationShapeId(ruuid, shapeId, relationShapeIds, null); List<DesignerShapeRelationModel> list = dao.getModelListByShapeIdAndRelationShapeId(ruuid, shapeId, relationShapeIds, null);
for (DesignerShapeRelationModel model : list) { for (DesignerShapeRelationModel model : list) {
if (ids.contains(model.getRelationShapeId()) && !"shapeAndFile".equals(type)) { if (ids.contains(model.getRelationShapeId()) && !"shapeAndFile".equals(type)) {
continue; continue;
@ -2633,6 +2629,7 @@ public class DesignerRelationShapeWeb extends ActionWeb {
treeData.add(role); treeData.add(role);
} }
JSONArray depjsonArray=new JSONArray();
// 获取已保存数据 // 获取已保存数据
JSONObject o = new JSONObject(); JSONObject o = new JSONObject();
Iterator<DesignerShapeRelationModel> modelIterator = DesignerShapeRelationCache.getByAttrId(fileId, shapeId, attrId); Iterator<DesignerShapeRelationModel> modelIterator = DesignerShapeRelationCache.getByAttrId(fileId, shapeId, attrId);
@ -2644,13 +2641,22 @@ public class DesignerRelationShapeWeb extends ActionWeb {
JSONObject object = JSONObject.parseObject(model.getRelationShapeText()); JSONObject object = JSONObject.parseObject(model.getRelationShapeText());
boolean flag = false; boolean flag = false;
// 查询最新名称 // 查询最新名称
if (scope.contains("department") && "department".equals(object.getString("type"))) { /*if (scope.contains("department") && "department".equals(object.getString("type"))) {
DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id")); DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id"));
if (dept != null && !filter.contains(dept.getId())) { if (dept != null && !filter.contains(dept.getId())) {
flag = true; flag = true;
object.put("name", dept.getName()); object.put("name", dept.getName());
filter.add(dept.getId()); filter.add(dept.getId());
} }
}*/
//使用自定义排序规则
if (scope.contains("department") && "department".equals(object.getString("type"))) {
DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id"));
if (dept != null && !filter.contains(dept.getId())) {
flag = true;
depjsonArray.add(object);
}
} }
if (scope.contains("user") && "user".equals(object.getString("type"))) { if (scope.contains("user") && "user".equals(object.getString("type"))) {
UserModel user = SDK.getORGAPI().getUser(object.getString("id")); UserModel user = SDK.getORGAPI().getUser(object.getString("id"));
@ -2682,8 +2688,22 @@ public class DesignerRelationShapeWeb extends ActionWeb {
} }
} }
} }
map.put("treeData", treeData); map.put("treeData", treeData);
map.put("checkedList", o);
/******************************自定义排序******************************************************/
if(depjsonArray.size()>0 && depjsonArray.getJSONObject(0).getString("timestamp")!=null){
depjsonArray.sort(Comparator.comparing(st ->((JSONObject)st).getString("timestamp")));
JSONObject jo = new JSONObject(new LinkedHashMap());
for(int b=0;b<depjsonArray.size();b++){
JSONObject onedata=depjsonArray.getJSONObject(b);
jo.put(onedata.getString("id"), onedata);
}
map.put("checkedList", jo);
}else{
map.put("checkedList", o);
}
return HtmlPageTemplate.merge(CoEConstant.APP_ID, "pal.pl.repository.designer.shapes.aws.org.htm", map); return HtmlPageTemplate.merge(CoEConstant.APP_ID, "pal.pl.repository.designer.shapes.aws.org.htm", map);
} }

View File

@ -21,6 +21,7 @@ import com.actionsoft.apps.coe.pal.util.SubUtil;
import com.actionsoft.apps.lifecycle.api.AppsAPIManager; import com.actionsoft.apps.lifecycle.api.AppsAPIManager;
import com.actionsoft.apps.resource.AppContext; import com.actionsoft.apps.resource.AppContext;
import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile; import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile;
import com.actionsoft.bpms.bo.engine.BO;
import com.actionsoft.bpms.bpmn.constant.ProcessDefinitionConst; import com.actionsoft.bpms.bpmn.constant.ProcessDefinitionConst;
import com.actionsoft.bpms.bpmn.engine.cache.ProcessDefCache; import com.actionsoft.bpms.bpmn.engine.cache.ProcessDefCache;
import com.actionsoft.bpms.bpmn.engine.cache.util.ProcessDefUtil; import com.actionsoft.bpms.bpmn.engine.cache.util.ProcessDefUtil;
@ -2532,6 +2533,12 @@ public class CoeProcessLevelWeb extends ActionWeb {
String shapeId = ""; String shapeId = "";
if ("relation".equals(attributeModel.getType())) { if ("relation".equals(attributeModel.getType())) {
List<DesignerShapeRelationModel> list = DesignerShapeRelationCache.getListByAttrId(uuid, "", attributeModel.getKey()); List<DesignerShapeRelationModel> list = DesignerShapeRelationCache.getListByAttrId(uuid, "", attributeModel.getKey());
//如果类型为支持文件根据时间戳排序
if(attributeModel.getKey().equals("support_files")){
list.sort(Comparator.comparing(DesignerShapeRelationModel::getRelationShapeText));
}
if (list != null && list.size() > 0) { if (list != null && list.size() > 0) {
// 判断是否有重复数据进行重复过滤 // 判断是否有重复数据进行重复过滤
Set<String> tempStrs = new HashSet<>(); Set<String> tempStrs = new HashSet<>();
@ -2579,62 +2586,40 @@ public class CoeProcessLevelWeb extends ActionWeb {
} }
// 关联bpm组织架构 // 关联bpm组织架构
JSONArray dataArr = new JSONArray(); JSONArray dataArr = new JSONArray();
JSONArray depjsonArray=new JSONArray();
if ("awsorg".equals(attributeModel.getType())) { if ("awsorg".equals(attributeModel.getType())) {
List<DesignerShapeRelationModel> list = DesignerShapeRelationCache.getListByAttrId(uuid, "", attributeModel.getKey()); List<DesignerShapeRelationModel> list = DesignerShapeRelationCache.getListByAttrId(uuid, "", attributeModel.getKey());
if(list.size()>0){
for(int b=0;b<list.size();b++){
JSONObject jo=JSONObject.parseObject(list.get(b).getRelationShapeText());
/*for(){
}*/
}
}
/*for (int j = newBean.size(); j < dateSourceList.size(); j++) {
if (!dateSourceList.get(i).get.equals(dateSourceList.get(j).getId())) {
Bean bean2 = dateSourceList.get(j);
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Date or1 = sf.parse(maxBean.getStr("MIND_TIME"));
Date or2 = sf.parse(bean2.getStr("MIND_TIME"));
if (or2.after(or1)) {
// 如果比他大则替换为最大
maxBean = bean2;
}
} catch (ParseException e) {
e.printStackTrace();
}
}
}
// 将最大的添加到list中
newBean.add(maxBean);*/
List<DesignerShapeRelationModel> list2=new ArrayList<DesignerShapeRelationModel>();
if (list != null && list.size() > 0) { if (list != null && list.size() > 0) {
Set<String> filter = new HashSet<String>();// 去重记录 Set<String> filter = new HashSet<String>();// 去重记录
for (DesignerShapeRelationModel model : list) { for (DesignerShapeRelationModel model : list) {
if ("00000000-0000-0000-0000-000000000000".equals(model.getRelationFileId()) && "00000000-0000-0000-0000-000000000000".equals(model.getRelationShapeId())) { if ("00000000-0000-0000-0000-000000000000".equals(model.getRelationFileId()) && "00000000-0000-0000-0000-000000000000".equals(model.getRelationShapeId())) {
JSONObject object = JSONObject.parseObject(model.getRelationShapeText()); JSONObject object = JSONObject.parseObject(model.getRelationShapeText());
// 查询最新名称 // 查询最新名称
if ("department".equals(object.getString("type"))) { /*if ("department".equals(object.getString("type"))) {
DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id")); DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id"));
if (dept != null && !filter.contains(dept.getId())) { if (dept != null && !filter.contains(dept.getId())) {
object.put("name", dept.getName()); object.put("name", dept.getName());
filter.add(dept.getId()); filter.add(dept.getId());
dataArr.add(object); dataArr.add(object);
} }
}*/
if ("department".equals(object.getString("type"))) {
DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id"));
if (dept != null && !filter.contains(dept.getId())) {
if(object.getString("timestamp")!=null){
depjsonArray.add(object);
}else{
object.put("name", dept.getName());
filter.add(dept.getId());
dataArr.add(object);
}
}
} }
if ("position".equals(object.getString("type"))) {// 岗位先用角色代替 if ("position".equals(object.getString("type"))) {// 岗位先用角色代替
RoleModel role = SDK.getORGAPI().getRoleById(object.getString("id")); RoleModel role = SDK.getORGAPI().getRoleById(object.getString("id"));
if (role != null && !filter.contains(role.getId())) { if (role != null && !filter.contains(role.getId())) {
@ -2662,12 +2647,40 @@ public class CoeProcessLevelWeb extends ActionWeb {
} }
} }
} }
// 数据组合 if(depjsonArray.size()>0 && depjsonArray.getJSONObject(0).getString("timestamp")!=null){
List<String> valueList = new ArrayList<>();
for (int i = 0; i < dataArr.size(); i++) { depjsonArray.sort(Comparator.comparing(st ->((JSONObject)st).getString("timestamp")));
valueList.add(dataArr.getJSONObject(i).getString("name")); JSONArray dataArr2 = new JSONArray();
Set<String> filter1 = new HashSet<String>();// 去重记录
for(int t=0;t<depjsonArray.size();t++){
if ("department".equals(depjsonArray.getJSONObject(t).getString("type"))) {
DepartmentModel dept = SDK.getORGAPI().getDepartmentById(depjsonArray.getJSONObject(t).getString("id"));
if (dept != null && !filter1.contains(dept.getId())) {
filter1.add(dept.getId());
dataArr2.add(depjsonArray.get(t));
}
}
}
// 数据组合
List<String> valueList = new ArrayList<>();
for (int i = 0; i < dataArr2.size(); i++) {
valueList.add(dataArr2.getJSONObject(i).getString("name"));
}
inputValue = StringUtils.join(valueList, ",");
}else {
// 数据组合
List<String> valueList = new ArrayList<>();
for (int i = 0; i < dataArr.size(); i++) {
valueList.add(dataArr.getJSONObject(i).getString("name"));
}
inputValue = StringUtils.join(valueList, ",");
} }
inputValue = StringUtils.join(valueList, ",");
} }
inputValue = inputValue.replaceAll("'", "&apos;"); inputValue = inputValue.replaceAll("'", "&apos;");
@ -2757,6 +2770,7 @@ public class CoeProcessLevelWeb extends ActionWeb {
} }
/** /**
* 判断是否为json格式 * 判断是否为json格式
* @param str * @param str
@ -3171,7 +3185,8 @@ public class CoeProcessLevelWeb extends ActionWeb {
relationModel.setAttrId(relationObj.getString("attrId")); relationModel.setAttrId(relationObj.getString("attrId"));
relationModel.setRelationFileId(relationFileId); relationModel.setRelationFileId(relationFileId);
relationModel.setRelationShapeId(""); relationModel.setRelationShapeId("");
relationModel.setRelationShapeText(""); long l = System.currentTimeMillis();
relationModel.setRelationShapeText(l+"");
// 获取文件 // 获取文件
JSONObject refObj = JSONObject.parseObject(attrModelMap.get(attrId).getRef()); JSONObject refObj = JSONObject.parseObject(attrModelMap.get(attrId).getRef());
String relationType = refObj.containsKey("type") ? refObj.getString("type") : "shape"; String relationType = refObj.containsKey("type") ? refObj.getString("type") : "shape";

View File

@ -1,10 +1,12 @@
var checkedOrgList = {};// 记录最终结果 var checkedOrgList = {};// 记录最终结果
var setting = {}; var setting = {};
var checkTree; var checkTree;
var orgindex=1;
$(document).ready(function() { $(document).ready(function() {
initSetting(); initSetting();
checkedOrgList = checkedList; checkedOrgList = checkedList;
checkTree = awsui.tree.init($("#tree"), setting); checkTree = awsui.tree.init($("#tree"), setting);
// 初始化已选中 // 初始化已选中
initCheckedList(); initCheckedList();
@ -101,7 +103,8 @@ function getCurrentCheck(dom, node) {
obj.id = node.uuid; obj.id = node.uuid;
obj.type = node.type; obj.type = node.type;
obj.name = node.name; obj.name = node.name;
obj.orgindex=orgindex++; var timestamp = new Date().valueOf();
obj.timestamp=timestamp;
checkedOrgList[node.uuid] = obj; checkedOrgList[node.uuid] = obj;
} else { } else {
// 无子节点,直接删除 // 无子节点,直接删除

View File

@ -491,6 +491,7 @@ function deleteRelation(obj) {
//获取关联信息 //获取关联信息
function getRelationShapeInfos() { function getRelationShapeInfos() {
var relations = new Array(); var relations = new Array();
$("#relationShapes div.relation_div").each(function(){ $("#relationShapes div.relation_div").each(function(){
var obj = { var obj = {
@ -606,7 +607,6 @@ function autoAjaxWaitFn() {
} }
function autoajax(ro) { function autoajax(ro) {
debugger;
if(relationType == 'file') {// 前后置流程 if(relationType == 'file') {// 前后置流程
closeProcessSearchDialog(); closeProcessSearchDialog();
$('#processSearchData').empty(); $('#processSearchData').empty();

View File

@ -612,7 +612,6 @@ function saveDialogTableValue(tableValue,id,dom) {
} }
function saveContent(obj) { function saveContent(obj) {
// debugger;
var sid = $("#sid").val(); var sid = $("#sid").val();
var uuid = $("#id").val(); var uuid = $("#id").val();
var id = obj.attr("id"); var id = obj.attr("id");
@ -1526,7 +1525,6 @@ function openRelationAwsorgDialog(obj) {
//将关联关系保存到数据库(AWS org) //将关联关系保存到数据库(AWS org)
function saveRelevanceAwsOrgShapesTODB(awsorgValueArr, shapeId, shapeName, objId) { function saveRelevanceAwsOrgShapesTODB(awsorgValueArr, shapeId, shapeName, objId) {
debugger;
$.ajax({ $.ajax({
type : "POST", type : "POST",
url : "./jd?sid=" + $("#sid").val() url : "./jd?sid=" + $("#sid").val()