epc流程编号处理

This commit is contained in:
446052889@qq.com 2022-08-28 21:15:01 +08:00
parent d3ae4612fc
commit 66527ad69d
3 changed files with 43 additions and 140 deletions

View File

@ -232,6 +232,10 @@ public class EpcGraphTree {
return no <= 0 ? (no + "") : no < 10 ? ("0" + no) : (no + "");
}
/**
* 新的排序
* @return
*/
public JSONObject sort5() {
int columnIndex = 1;
sort6(headerShapes, columnIndex);
@ -239,6 +243,7 @@ public class EpcGraphTree {
EpcGraphModel model = entry.getValue();
columnIndex = columnIndex > model.getColumn() ? columnIndex : model.getColumn();
}
int no = 1;
for (int i = 1; i <= columnIndex; i++) {
List<EpcGraphModel> list = new ArrayList<>();
for (Map.Entry<String, EpcGraphModel> entry : graphShapeMap.entrySet()) {
@ -251,7 +256,6 @@ public class EpcGraphTree {
list.sort((e1, e2)-> {
return shapeObjMap.get(e1.getId()).getJSONObject("props").getInteger("x") - shapeObjMap.get(e2.getId()).getJSONObject("props").getInteger("x");
});
int no = 1;
// 赋值编号兼具串联的处理
for (EpcGraphModel model : list) {
if (model.getNo() != 0) {// 编号计算过的忽略
@ -259,15 +263,46 @@ public class EpcGraphTree {
}
// 设置当前编号为no
model.setNo(no++);
//System.out.println("当前节点:" + model.getName());
//System.out.println("开始查找串联节点");
// 寻找串联特征的节点依次进行串联编号
// if (model.)
if (model.getPrevShapes().size() <= 1 && model.getNextShapes().size() == 1) {
EpcGraphModel tmp = graphShapeMap.get(model.getNextShapes().get(0));
while (tmp != null && tmp.getPrevShapes().size() == 1 && tmp.getNextShapes().size() <= 1) {
if (tmp.getNo() != 0) {
break;
}
// System.out.println("查找到了串联节点:" + tmp.getName());
tmp.setNo(no++);
if (tmp.getNextShapes().size() > 0) {
tmp = graphShapeMap.get(tmp.getNextShapes().get(0));
} else {
tmp = null;
}
}
}
}
}
return null;
no = graphShapeMap.size() + 1;
List<EpcGraphModel> list = new ArrayList<>();
for (Map.Entry<String, EpcGraphModel> entry : graphShapeMap.entrySet()) {
EpcGraphModel model = entry.getValue();
if (model.getNo() == 0) {
model.setNo(no++);
}
if (model.isHasNum()) {
list.add(model);
}
}
list.sort((e1, e2)-> {return e1.getNo() - e2.getNo();});
JSONObject result = new JSONObject();
int no2 = 1;
for (EpcGraphModel model : list) {
result.put(model.getId(), getNoStr(no2));
// System.out.println("" + model.getName() + "】的编号是【" + getNoStr(no2) + "");
no2++;
}
return result;
}
private void sort6(List<String> headerShapes, int columnIndex) {
@ -283,136 +318,6 @@ public class EpcGraphTree {
}
}
public JSONObject sort3() {
int index = 1;
Set<String> ids = new HashSet<>();
sort4(headerShapes, index, ids);
index = graphShapeMap.size() + 1;
List<EpcGraphModel> list = new ArrayList<>();
for (Map.Entry<String, EpcGraphModel> entry : graphShapeMap.entrySet()) {
EpcGraphModel model = entry.getValue();
if (model.getNo() == 0) {
model.setNo(index++);
}
if (model.isHasNum()) {
list.add(model);
}
}
list.sort((e1, e2)-> {return e1.getNo() - e2.getNo();});
JSONObject result = new JSONObject();
int no = 1;
for (EpcGraphModel model : list) {
result.put(model.getId(), getNoStr(no));
System.out.println("" + model.getName() + "】的编号是【" + getNoStr(no) + "");
no++;
}
return result;
}
private void sort4(List<String> nextStartList, int index, Set<String> ids) {
for (int i = 0; i < nextStartList.size(); i++) {
EpcGraphModel model = graphShapeMap.get(nextStartList.get(i));
System.out.println("处理节点:" + model.getName());
while ("a".equalsIgnoreCase("b")) {
System.out.println("节点" + model.getName() + " 进入查找串联循环");
List<String> nextList = model.getNextShapes();
boolean flag = false;
if (nextList.size() == 0) {
flag = true;
nextList.set(i, null);
if (!ids.contains(model.getId())) {
model.setNo(index++);
model.setPrevShapes(new ArrayList<>());
model.setNextShapes(new ArrayList<>());
ids.add(model.getId());
}
}
if (nextList.size() == 1) {
if (nextList.get(0).equals(nextStartList.get(i))) {
nextStartList.remove(i);
}
}
String nextId = null;
if (model.getNextShapes().size() == 1) {
nextId = model.getNextShapes().get(0);
graphShapeMap.get(model.getNextShapes().get(0)).getPrevShapes().remove(model.getId());
}
nextStartList.set(i, nextId);
if (!ids.contains(model.getId())) {
model.setNo(index++);
model.setPrevShapes(new ArrayList<>());
model.setNextShapes(new ArrayList<>());
ids.add(model.getId());
}
if (nextId == null) {
model = null;
} else {
model = graphShapeMap.get(nextId);
}
}
}
// nextStartList 处理寻找真正的nextStartList
// for (int i = 0; i < nextStartList.size(); i++) {
// EpcGraphModel model = graphShapeMap.get(nextStartList.get(i));
// System.out.println("处理节点:" + model.getName());
// while (model != null && model.isSinglePrevAndNext()) {
// System.out.println("节点" + model.getName() + " 进入查找串联循环");
// String nextId = null;
// if (model.getNextShapes().size() == 1) {
// nextId = model.getNextShapes().get(0);
// graphShapeMap.get(model.getNextShapes().get(0)).getPrevShapes().remove(model.getId());
// }
// nextStartList.set(i, nextId);
// if (!ids.contains(model.getId())) {
// model.setNo(index++);
// model.setPrevShapes(new ArrayList<>());
// model.setNextShapes(new ArrayList<>());
// ids.add(model.getId());
// }
// if (nextId == null) {
// model = null;
// } else {
// model = graphShapeMap.get(nextId);
// }
// }
// }
// 对nextStartList处理编号,处理前后关系置空
List<String> tmpList = new ArrayList<>();
for (String id : nextStartList) {
if (!UtilString.isEmpty(id) && !tmpList.contains(id)) {
tmpList.add(id);
}
}
nextStartList = tmpList;
for (String id : nextStartList) {
if (!ids.contains(id)) {
ids.add(id);
EpcGraphModel model = graphShapeMap.get(id);
model.setNo(index++);
model.setPrevShapes(new ArrayList<>());
for (String next : model.getNextShapes()) {
graphShapeMap.get(next).getPrevShapes().remove(model.getId());
}
model.setNextShapes(new ArrayList<>());
}
}
// 寻找下一次的nextStartList
initHeaderData();
if (headerShapes.size() > 0) {
sort4(headerShapes, index, ids);
}
}
/**
* 编号
* 1.标记路径访问次数

View File

@ -62,9 +62,7 @@ public class EpcGraphWeb extends ActionWeb {
tree.initData(hasNumShapeNames, elements);
JSONObject result = new JSONObject();
result.put("attrId", "activity_number");
result.put("data", new JSONObject());
tree.sort5();
tree.testColumn();
result.put("data", tree.sort5());
ResponseObject ro = ResponseObject.newOkResponse();
ro.setData(result);
return ro.toString();