制度手册查询属性空指针异常
This commit is contained in:
parent
483064000e
commit
d3ae4612fc
Binary file not shown.
@ -4992,6 +4992,9 @@ public class PALRepositoryQueryAPIManager {
|
||||
String attrValue = "";
|
||||
if (attrDataMap.containsKey(key)) {
|
||||
JSONObject jsonObj = attrDataMap.get(key);
|
||||
if (jsonObj == null) {
|
||||
continue;
|
||||
}
|
||||
String type = attributeModel.getType();
|
||||
if ("string".equals(type)) {
|
||||
attrValue = jsonObj.containsKey("value") ? jsonObj.getString("value") : "";
|
||||
|
||||
@ -14,6 +14,7 @@ public class EpcGraphModel {
|
||||
private int no;// 编号
|
||||
private List<String> prevShapes;// 入线
|
||||
private List<String> nextShapes;// 出线
|
||||
private int column;// 列
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
@ -78,4 +79,12 @@ public class EpcGraphModel {
|
||||
public void setHasNum(boolean hasNum) {
|
||||
this.hasNum = hasNum;
|
||||
}
|
||||
|
||||
public int getColumn() {
|
||||
return column;
|
||||
}
|
||||
|
||||
public void setColumn(int column) {
|
||||
this.column = column;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
package com.actionsoft.apps.coe.pal.pal.repository.designer.no.epc.tree;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.CoeDesignerShapeAPIManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.no.epc.model.EpcGraphModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryAttributeModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
|
||||
import com.actionsoft.bpms.util.UUIDGener;
|
||||
import com.actionsoft.bpms.util.UtilString;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@ -45,6 +42,7 @@ public class EpcGraphTree {
|
||||
initHeaderData();
|
||||
// 去除环结构(有向图不能有环结构,否则无法进行拓扑排序)
|
||||
removeHoopRelation(headerShapes);
|
||||
|
||||
// test();
|
||||
// testNo();
|
||||
}
|
||||
@ -73,10 +71,19 @@ public class EpcGraphTree {
|
||||
}
|
||||
}
|
||||
|
||||
public void testColumn() {
|
||||
for (Map.Entry<String, EpcGraphModel> entry : graphShapeMap.entrySet()) {
|
||||
String shape = entry.getKey();
|
||||
EpcGraphModel model = entry.getValue();
|
||||
System.out.println("【" + model.getName() + "】的所属列是【" + model.getColumn() + "】");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化开始节点
|
||||
*/
|
||||
private void initHeaderData() {
|
||||
headerShapes.clear();
|
||||
for (Map.Entry<String, EpcGraphModel> entry : graphShapeMap.entrySet()) {
|
||||
if (entry.getValue().getNextShapes().size() > 0 && entry.getValue().getPrevShapes().size() == 0) {
|
||||
headerShapes.add(entry.getKey());
|
||||
@ -225,28 +232,186 @@ public class EpcGraphTree {
|
||||
return no <= 0 ? (no + "") : no < 10 ? ("0" + no) : (no + "");
|
||||
}
|
||||
|
||||
private void newSort() {
|
||||
String id = UUIDGener.getUUID();
|
||||
EpcGraphModel newHeader = new EpcGraphModel();
|
||||
newHeader.setId(id);
|
||||
newHeader.setShapeName("起点归并");
|
||||
newHeader.setPrevShapes(new ArrayList<>());
|
||||
newHeader.setName("起点归并");
|
||||
newHeader.setNextShapes(headerShapes);
|
||||
graphShapeMap.put(id, newHeader);
|
||||
// sort
|
||||
newSort2(newHeader, 1);
|
||||
public JSONObject sort5() {
|
||||
int columnIndex = 1;
|
||||
sort6(headerShapes, columnIndex);
|
||||
for (Map.Entry<String, EpcGraphModel> entry : graphShapeMap.entrySet()) {
|
||||
EpcGraphModel model = entry.getValue();
|
||||
columnIndex = columnIndex > model.getColumn() ? columnIndex : model.getColumn();
|
||||
}
|
||||
for (int i = 1; i <= columnIndex; i++) {
|
||||
List<EpcGraphModel> list = new ArrayList<>();
|
||||
for (Map.Entry<String, EpcGraphModel> entry : graphShapeMap.entrySet()) {
|
||||
EpcGraphModel model = entry.getValue();
|
||||
if (model.getColumn() == i) {
|
||||
list.add(model);
|
||||
}
|
||||
}
|
||||
// 排序
|
||||
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) {// 编号计算过的忽略
|
||||
continue;
|
||||
}
|
||||
// 设置当前编号为no
|
||||
model.setNo(no++);
|
||||
// 寻找串联特征的节点,依次进行串联编号
|
||||
// if (model.)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void newSort2(EpcGraphModel parent, int index) {
|
||||
List<String> nextList = graphShapeMap.get(parent).getNextShapes();
|
||||
|
||||
|
||||
|
||||
|
||||
private void sort6(List<String> headerShapes, int columnIndex) {
|
||||
Set<String> ids = new HashSet<>();
|
||||
for (String shape : headerShapes) {
|
||||
EpcGraphModel model = graphShapeMap.get(shape);
|
||||
model.setColumn(columnIndex);
|
||||
List<String> nextList = model.getNextShapes();
|
||||
ids.addAll(nextList);
|
||||
}
|
||||
if (ids.size() > 0) {
|
||||
sort6(new ArrayList<>(ids), ++columnIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 编号
|
||||
|
||||
@ -62,7 +62,9 @@ public class EpcGraphWeb extends ActionWeb {
|
||||
tree.initData(hasNumShapeNames, elements);
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("attrId", "activity_number");
|
||||
result.put("data", tree.sort());
|
||||
result.put("data", new JSONObject());
|
||||
tree.sort5();
|
||||
tree.testColumn();
|
||||
ResponseObject ro = ResponseObject.newOkResponse();
|
||||
ro.setData(result);
|
||||
return ro.toString();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user