制度图编号
This commit is contained in:
parent
5806832d73
commit
d7a6f9be2f
Binary file not shown.
@ -5,6 +5,7 @@ import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.CoeDesignerShapeAPIManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.no.epc.tree.EpcGraphTree;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.no.policy.web.PolicyShapeSortWeb;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryAttributeModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
|
||||
@ -12,6 +13,7 @@ import com.actionsoft.bpms.commons.mvc.view.ActionWeb;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.logging.log4j.core.tools.picocli.CommandLine;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -35,6 +37,9 @@ public class EpcGraphWeb extends ActionWeb {
|
||||
if (model == null) {
|
||||
return ResponseObject.newErrResponse("模型不存在,uuid:" + uuid).toString();
|
||||
}
|
||||
if ("control.policy".equals(model.getMethodId())) {
|
||||
return refreshControlDesignerNo(uuid);
|
||||
}
|
||||
EpcGraphTree tree = new EpcGraphTree();
|
||||
|
||||
String define = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(uc, uuid);
|
||||
@ -67,4 +72,16 @@ public class EpcGraphWeb extends ActionWeb {
|
||||
ro.setData(result);
|
||||
return ro.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 制度图编号
|
||||
* @param uuid
|
||||
* @return
|
||||
*/
|
||||
private String refreshControlDesignerNo(String uuid) {
|
||||
String define = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(uc, uuid);
|
||||
JSONObject definition = JSONObject.parseObject(define);
|
||||
JSONObject elements = definition.getJSONObject("elements");
|
||||
return new PolicyShapeSortWeb(uc).sort(uuid).toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,165 @@
|
||||
package com.actionsoft.apps.coe.pal.pal.repository.designer.no.policy.web;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.util.ShapeUtil;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ActionWeb;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
import com.actionsoft.bpms.util.UtilString;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 控制图形状排序编号
|
||||
*/
|
||||
public class PolicyShapeSortWeb extends ActionWeb {
|
||||
|
||||
private UserContext uc;
|
||||
public PolicyShapeSortWeb(UserContext uc) {
|
||||
this.uc = uc;
|
||||
}
|
||||
|
||||
public ResponseObject sort(String palId) {
|
||||
PALRepositoryModel model = PALRepositoryCache.getCache().get(palId);
|
||||
|
||||
// 查询模型文件
|
||||
String define = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(uc, palId);
|
||||
JSONObject definition = JSONObject.parseObject(define);
|
||||
JSONObject elements = definition.getJSONObject("elements");
|
||||
// 查找根节点
|
||||
List<JSONObject> rootList = queryRootShapeIdList(elements);
|
||||
if (rootList.size() == 0) {
|
||||
return ResponseObject.newErrResponse("当前制度不存在根节点,导出失败");
|
||||
}
|
||||
if (rootList.size() > 1) {
|
||||
return ResponseObject.newErrResponse("当前制度的根节点数量多于1个,不支持导出");
|
||||
}
|
||||
|
||||
JSONObject rootShape = rootList.get(0);
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("attrId", "activity_number");
|
||||
result.put("data", queryAllShapeResult(rootShape, elements, palId));
|
||||
ResponseObject ro = ResponseObject.newOkResponse();
|
||||
ro.setData(result);
|
||||
return ro;
|
||||
}
|
||||
|
||||
private JSONObject queryAllShapeResult(JSONObject rootShape, JSONObject elements, String palId) {
|
||||
JSONObject linkerObj = new JSONObject();
|
||||
Iterator<String> it = elements.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
String key = it.next();
|
||||
JSONObject shape = elements.getJSONObject(key);
|
||||
String shapeName = shape.getString("name");
|
||||
if("linker".equals(shapeName)) {
|
||||
linkerObj.put(shape.getString("id"), shape);
|
||||
}
|
||||
}
|
||||
JSONObject result = new JSONObject();
|
||||
String initNo = "4";
|
||||
Set<String> ids = new HashSet<>();
|
||||
queryNextShapes(result, rootShape, linkerObj, elements, palId, initNo, 0, ids);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询下一个节点(s)
|
||||
* @param result
|
||||
* @param parentShape
|
||||
* @param linkerObj
|
||||
* @param elements
|
||||
*/
|
||||
private void queryNextShapes(JSONObject result, JSONObject parentShape, JSONObject linkerObj, JSONObject elements, String palId, String initNo, int index, Set<String> ids) {
|
||||
String parentId = parentShape.getString("id");
|
||||
List<JSONObject> childrenList = new ArrayList<>();
|
||||
Iterator<String> linkerIt = linkerObj.keySet().iterator();
|
||||
while (linkerIt.hasNext()) {
|
||||
String linkerId = linkerIt.next();
|
||||
JSONObject from = linkerObj.getJSONObject(linkerId).getJSONObject("from");
|
||||
if (from.containsKey("id") && from.getString("id").equals(parentId)) {
|
||||
// 获取下一个形状
|
||||
JSONObject to = linkerObj.getJSONObject(linkerId).getJSONObject("to");
|
||||
if (to.containsKey("id") && UtilString.isNotEmpty(to.getString("id"))) {
|
||||
JSONObject nextShape = elements.getJSONObject(to.getString("id"));
|
||||
if (nextShape != null) {
|
||||
childrenList.add(nextShape);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (childrenList.size() > 0) {
|
||||
// 排序(由上到下)
|
||||
childrenList.sort((s1, s2) -> {
|
||||
JSONObject props1 = s1.getJSONObject("props");
|
||||
int y1 = props1.getIntValue("y");
|
||||
JSONObject props2 = s2.getJSONObject("props");
|
||||
int y2 = props2.getIntValue("y");
|
||||
return y1 - y2;
|
||||
});
|
||||
for (JSONObject child : childrenList) {
|
||||
String childId = child.getString("id");
|
||||
if (ids.contains(childId)) {// 防止出现环结构
|
||||
continue;
|
||||
}
|
||||
ids.add(childId);
|
||||
if ("item2".equals(child.getString("name"))) {
|
||||
// 是条款
|
||||
index++;
|
||||
String newInitNo = initNo + "." + index;
|
||||
result.put(childId, newInitNo);
|
||||
queryNextShapes(result, child, linkerObj, elements, palId, newInitNo, 0, ids);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找根节点
|
||||
* @param elements
|
||||
* @return
|
||||
*/
|
||||
private List<JSONObject> queryRootShapeIdList(JSONObject elements) {
|
||||
List<JSONObject> result = new ArrayList<>();
|
||||
// 获取所有连线
|
||||
JSONObject linkerObj = new JSONObject();
|
||||
{
|
||||
Iterator<String> it = elements.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
String key = it.next();
|
||||
JSONObject shape = elements.getJSONObject(key);
|
||||
String shapeName = shape.getString("name");
|
||||
if("linker".equals(shapeName)) {
|
||||
linkerObj.put(shape.getString("id"), shape);
|
||||
}
|
||||
}
|
||||
}
|
||||
Iterator<String> it = elements.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
String key = it.next();
|
||||
JSONObject shape = elements.getJSONObject(key);
|
||||
String shapeName = shape.getString("name");
|
||||
boolean isRoot = true;
|
||||
if("regulation".equals(shapeName)) {// 只获取制度
|
||||
// 如果形状没有连接它的形状(形状的to指向该形状),则默认为根节点
|
||||
Iterator<String> linkerIt = linkerObj.keySet().iterator();
|
||||
while (linkerIt.hasNext()) {
|
||||
String linkerId = linkerIt.next();
|
||||
JSONObject to = linkerObj.getJSONObject(linkerId).getJSONObject("to");
|
||||
if (to.containsKey("id") && to.getString("id").equals(shape.getString("id"))) {
|
||||
isRoot = false;
|
||||
}
|
||||
}
|
||||
if (isRoot) {
|
||||
result.add(shape);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@ -351,7 +351,7 @@
|
||||
$(document).ready(function(){
|
||||
// 自定义帮助扩展
|
||||
initCustomHelpToolExtMenuUrl();
|
||||
if (methodId !== 'process.epc') {
|
||||
if (methodId !== 'process.epc' && methodId != 'control.policy') {
|
||||
$('#bar_sort').css('display','none')
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user