发布流程提交的时候进行连线校验
This commit is contained in:
parent
7ac4e04d9c
commit
2f8705f714
@ -7,6 +7,8 @@ import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.dao.CoeProcessLevelDaoFacotory;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepositoryPropertyDao;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.CoeDesignerShapeAPIManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.manage.CoeDesignerAPIManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.model.BaseModel;
|
||||
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.designer.util.CoeDesignerUtil;
|
||||
@ -24,6 +26,7 @@ import com.actionsoft.bpms.bpmn.engine.listener.ListenerConst;
|
||||
import com.actionsoft.bpms.commons.database.RowMap;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
import com.actionsoft.bpms.util.DBSql;
|
||||
import com.actionsoft.bpms.util.UtilFile;
|
||||
import com.actionsoft.bpms.util.UtilString;
|
||||
import com.actionsoft.exception.AWSException;
|
||||
import com.actionsoft.exception.BPMNError;
|
||||
@ -31,10 +34,7 @@ import com.actionsoft.sdk.local.SDK;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
public class PublishFormBeforeSaveEvent extends InterruptListener implements InterruptListenerInterface {
|
||||
|
||||
@ -247,14 +247,72 @@ public class PublishFormBeforeSaveEvent extends InterruptListener implements Int
|
||||
|
||||
/**
|
||||
* 判断文件属性、数据属性校验
|
||||
* @param sid
|
||||
* @param uuid
|
||||
* @param obj
|
||||
* @return
|
||||
*/
|
||||
public void defineQualityCheck(String uuid){
|
||||
|
||||
PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid);
|
||||
String vison = getVison(uuid);
|
||||
List<JSONObject> elements_fei = getShapeJsonToJsonObject2(vison);
|
||||
StringBuffer sb6= new StringBuffer();
|
||||
StringBuilder sbs = new StringBuilder();
|
||||
List<String> list_linker = new LinkedList<>();
|
||||
//连线数据增加
|
||||
for (JSONObject o : elements_fei) {
|
||||
String shapeId = o.getString("id");
|
||||
|
||||
String shapeName = o.getString("name");
|
||||
if (!shapeName.equals("linker")) {
|
||||
list_linker.add(shapeId);
|
||||
}
|
||||
}
|
||||
|
||||
for (JSONObject o : elements_fei) {
|
||||
String shapeId = o.getString("id");
|
||||
|
||||
String shapeName = o.getString("name");
|
||||
//System.out.println("这个名字是什么>>>>>>>" + shapeName);
|
||||
if (shapeName.equals("linker")) {
|
||||
JSONObject from = o.getJSONObject("from");
|
||||
JSONObject to = o.getJSONObject("to");
|
||||
String from_id = from.getString("id");
|
||||
String to_id = to.getString("id");
|
||||
if (UtilString.isNotEmpty(from_id)) {
|
||||
list_linker.remove(from_id);
|
||||
}else {
|
||||
JSONObject definition = JSONObject.parseObject(vison);
|
||||
JSONObject elements = definition.getJSONObject("elements");
|
||||
JSONObject string = elements.getJSONObject(to_id);
|
||||
String title = string.getString("title");
|
||||
sb6.append("\""+title+"\"").append("连线没有入线");
|
||||
list_linker.add("\""+title+"\""+"连线没有入线");
|
||||
}
|
||||
if (UtilString.isNotEmpty(to_id)) {
|
||||
list_linker.remove(to_id);
|
||||
}else {
|
||||
JSONObject definition = JSONObject.parseObject(vison);
|
||||
JSONObject elements = definition.getJSONObject("elements");
|
||||
JSONObject string = elements.getJSONObject(from_id);
|
||||
String title = string.getString("title");
|
||||
sb6.append("\""+title+"\"").append("连线没有出线");
|
||||
list_linker.add("\""+title+"\""+"连线没有出线");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
//System.out.println("m的值>>>>>>>>>>>" + ms);
|
||||
}
|
||||
|
||||
//System.out.println("linker>>>>>>>>>>>>" + list_linker.size());
|
||||
if (list_linker.size() > 0) {
|
||||
sbs.append("连线校验:");
|
||||
sbs.append(sb6);
|
||||
sb6.append("校验未通过,请检查模型是否都已连线!");
|
||||
}
|
||||
if (sbs.length()>0){
|
||||
throw new BPMNError("0313", sbs.toString());
|
||||
}
|
||||
|
||||
/************************************文件属性校验************************************/
|
||||
ResponseObject ro = ResponseObject.newOkResponse();
|
||||
PALRepositoryModel m = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid);
|
||||
@ -388,4 +446,119 @@ public class PublishFormBeforeSaveEvent extends InterruptListener implements Int
|
||||
|
||||
}
|
||||
|
||||
public static List<JSONObject> getShapeJsonToJsonObject2(String messageJson) {
|
||||
List<JSONObject> list = new ArrayList<JSONObject>();
|
||||
JSONObject definition = JSONObject.parseObject(messageJson);
|
||||
JSONObject elements = definition.getJSONObject("elements");
|
||||
Iterator<String> ite = elements.keySet().iterator();
|
||||
while (ite.hasNext()) {
|
||||
String key = ite.next();
|
||||
JSONObject shape = elements.getJSONObject(key);
|
||||
String name = shape.getString("name");
|
||||
if ("linker".equals(name)){
|
||||
JSONObject jsonObj = new JSONObject();
|
||||
jsonObj.put("id", key);
|
||||
jsonObj.put("name", shape.getString("name"));
|
||||
jsonObj.put("from", shape.getString("from"));
|
||||
jsonObj.put("to", shape.getString("to"));
|
||||
list.add(jsonObj);
|
||||
}
|
||||
if (!"linker".equals(name) && shape.get("dataAttributes") != null) {
|
||||
JSONObject jsonObj = new JSONObject();
|
||||
jsonObj.put("id", key);
|
||||
jsonObj.put("name", shape.getString("name"));
|
||||
jsonObj.put("title", shape.getString("title"));
|
||||
jsonObj.put("text", shape.getString("text"));
|
||||
jsonObj.put("category", shape.getString("category"));
|
||||
jsonObj.put("dataAttributes", getCustom(shape.getJSONArray("dataAttributes")));
|
||||
list.add(jsonObj);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public static JSONObject getCustom(JSONArray ja) {
|
||||
JSONObject json = new JSONObject();
|
||||
for (Object object : ja) {
|
||||
JSONObject attr = (JSONObject) object;
|
||||
if (attr.containsKey("linksArray")) {
|
||||
json.put("linksArray", attr.get("linksArray"));
|
||||
}
|
||||
if (attr.containsKey("attributesContent")) {
|
||||
json.put("attributesContent", attr.get("attributesContent"));
|
||||
}
|
||||
if (attr.containsKey("attributesJsonArray")) {
|
||||
json.put("attributesJsonArray", attr.get("attributesJsonArray"));
|
||||
}
|
||||
if (attr.containsKey("privateAttribute")) {
|
||||
json.put("privateAttribute", attr.get("privateAttribute"));
|
||||
}
|
||||
if (attr.containsKey("privateShapesName")) {
|
||||
json.put("privateShapesName", attr.get("privateShapesName"));
|
||||
}
|
||||
if (attr.containsKey("privateAttributeContent")) {
|
||||
json.put("privateAttributeContent", attr.get("privateAttributeContent"));
|
||||
}
|
||||
if (attr.containsKey("shapeGroupId")) {
|
||||
json.put("shapeGroupId", attr.get("shapeGroupId"));
|
||||
}
|
||||
if (attr.containsKey("isCopy")) {
|
||||
json.put("isCopy", attr.get("isCopy"));
|
||||
}
|
||||
if (attr.containsKey("shapeDesc")) {
|
||||
json.put("shapeDesc", attr.get("shapeDesc"));
|
||||
}
|
||||
if (attr.containsKey("upFilesArray")) {
|
||||
json.put("upFilesArray", attr.get("upFilesArray"));
|
||||
}
|
||||
if (attr.containsKey("relevanceShapes")) {
|
||||
json.put("relevanceShapes", attr.get("relevanceShapes"));
|
||||
}
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据uuid寻找对应的json文件即图形文件
|
||||
* @param uuid 文件id
|
||||
* @return json文件
|
||||
*/
|
||||
public String getVison(String uuid) {
|
||||
List<Map<String, Object>> fileElements = CoeDesignerUtil.getShapeMessageJson4(uuid);
|
||||
JSONObject definition = new JSONObject(new LinkedHashMap<>());
|
||||
if (fileElements.size() > 0) {
|
||||
for (Map<String, Object> str : fileElements) {
|
||||
|
||||
BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(uuid, 0);
|
||||
|
||||
String define = defineModel.getDefinition();
|
||||
definition = JSONObject.parseObject(define);
|
||||
|
||||
}
|
||||
}
|
||||
return definition.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据图形的json文件路径得到文件中图形的json数组
|
||||
*
|
||||
* @param filePath 图形josn文件路径
|
||||
* @return
|
||||
*/
|
||||
public JSONArray getShapeJsonFromFile(String filePath) {
|
||||
if (filePath == null) {
|
||||
return null;
|
||||
}
|
||||
UtilFile jsonFile = new UtilFile(filePath);
|
||||
String josn = jsonFile.readStrUTF8();
|
||||
if (josn == null || "".equals(josn)) {
|
||||
return null;
|
||||
}
|
||||
String definition = jsonFile.readStrUTF8();
|
||||
return JSONArray.parseArray(definition);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user