前后置流程功能开发,流程删除触发相关的流程接口形状删除
This commit is contained in:
parent
7d4fc49f3e
commit
18692464c2
Binary file not shown.
@ -4,12 +4,7 @@ import java.io.File;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import com.actionsoft.apps.AppsConst;
|
||||
import com.actionsoft.apps.coe.pal.constant.CoEConstant;
|
||||
@ -20,8 +15,14 @@ import com.actionsoft.apps.coe.pal.log.CoEOpLogConst;
|
||||
import com.actionsoft.apps.coe.pal.pal.method.cache.PALMethodCache;
|
||||
import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.constant.CoeDesignerConstant;
|
||||
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;
|
||||
import com.actionsoft.apps.coe.pal.system.logger.CoeLogger;
|
||||
import com.actionsoft.apps.lifecycle.api.AppsAPIManager;
|
||||
import com.actionsoft.bpms.commons.htmlframework.HtmlPageTemplate;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ActionWeb;
|
||||
@ -56,6 +57,7 @@ import com.actionsoft.apps.coe.pal.system.property.CoePropertyUtil;
|
||||
import com.actionsoft.apps.coe.pal.teamwork.dao.TeamPerm;
|
||||
import com.actionsoft.bpms.util.UtilString;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -224,6 +226,8 @@ public class CoeProcessRecycleWeb extends ActionWeb {
|
||||
relationDao.deleteByFileId(model.getId());
|
||||
// 删除被动关联信息,分为两种,一种是关联了当前文件,一种是关联了当前文件的形状。关联了文件存储的是versionId,需要判断是否有在用的模型,有则保留关联关系
|
||||
List<String> removeRelationIds = new ArrayList<>();
|
||||
Set<String> rearSet = new HashSet<>();// 被删除文件作为后置流程的模型
|
||||
Set<String> leadSet = new HashSet<>();// 被删除文件作为前置流程的模型
|
||||
// 只判断relationShapeId为空,即关联了文件,因为存储的是versionId,判断是否有在用的其他version,没有直接删除,还有在用的其他版本,则保留此关系
|
||||
List<DesignerShapeRelationModel> list1 = relationDao.query(null, null, null, model.getVersionId(), null);
|
||||
for (DesignerShapeRelationModel m1 : list1) {
|
||||
@ -231,6 +235,12 @@ public class CoeProcessRecycleWeb extends ActionWeb {
|
||||
List<PALRepositoryModel> list = PALRepositoryCache.getByVersionId(model.getVersionId());
|
||||
if (list == null || list.size() == 0) {
|
||||
removeRelationIds.add(m1.getId());
|
||||
// 伊利前后置流程的数据处理 by sunlh 20221025
|
||||
if ("rear_process".equals(m1.getAttrId())) {// 后置流程
|
||||
rearSet.add(m1.getFileId());
|
||||
} else if ("lead_process".equals(m1.getAttrId())) {// 前置流程
|
||||
leadSet.add(m1.getFileId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -249,6 +259,10 @@ public class CoeProcessRecycleWeb extends ActionWeb {
|
||||
if (list == null || list.size() == 0) {
|
||||
relationDao.deleteByRelationShapeId(model.getVersionId());
|
||||
}
|
||||
// 更新将该模型作为前后置流程相关模型 伊利 by sunlh 20221025
|
||||
updateLeadRearRepositoryDesigner(leadSet, "top", model);
|
||||
updateLeadRearRepositoryDesigner(rearSet, "bottom", model);
|
||||
|
||||
// 删除文件特殊属性
|
||||
PALRepositorySpecialPropertyDao dao1 = new PALRepositorySpecialPropertyDao();
|
||||
dao1.deleteByPlId(model.getId());
|
||||
@ -297,6 +311,123 @@ public class CoeProcessRecycleWeb extends ActionWeb {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新将该模型作为前后置流程相关模型 伊利 by sunlh 20221025
|
||||
*/
|
||||
private void updateLeadRearRepositoryDesigner(Set<String> set, String position, PALRepositoryModel removeModel) {
|
||||
for (String uuid : set) {
|
||||
PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid);
|
||||
if (model != null) {
|
||||
String define = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(_uc, uuid);
|
||||
try {
|
||||
boolean update = false;
|
||||
JSONObject definition = JSONObject.parseObject(define);
|
||||
JSONObject elements = definition.getJSONObject("elements");
|
||||
JSONArray procedureShapeArr= getProcedureShapeArr(elements);
|
||||
for (int i = 0; i < procedureShapeArr.size(); i++) {
|
||||
JSONObject shape = procedureShapeArr.getJSONObject(i);
|
||||
if (matchProcedureObj(shape, removeModel.getVersionId(), removeModel.getName(), position)) {
|
||||
update = true;
|
||||
String id = shape.getString("id");
|
||||
elements.getJSONObject(id).put("text", shape.getString("shapeText") + "(已删除)");
|
||||
elements.getJSONObject(id).remove("attrMark");
|
||||
}
|
||||
}
|
||||
if (update) {
|
||||
// 保存
|
||||
BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(uuid, 0);
|
||||
if (defineModel == null) {
|
||||
defineModel = CoeDesignerUtil.createModel(uuid, 0);
|
||||
defineModel.setCreateHistory(false);
|
||||
}
|
||||
definition.put("elements", elements);
|
||||
defineModel.setDefinition(definition.toString());
|
||||
defineModel.setUpdateTime(new SimpleDateFormat(CoeDesignerConstant.DATE_TIME_STYLE_YYYY_MM_DD_HH_MM_SS).format(new Date()));
|
||||
// 保存文件
|
||||
CoeDesignerAPIManager.getInstance().storeDefinition(defineModel);// dao操作
|
||||
// 记录操作行为日志
|
||||
if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) {
|
||||
CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_UPDATE, CoEOpLogConst.INFO_REPOSITORY_DESIGNER_UPDATE + ",文件属性["+ ("top".equals(position) ? "前置" : "后置") +"流程]被删除触发流程接口形状更新");
|
||||
SDK.getLogAPI().consoleInfo("[成功][" + removeModel.getName() + "]被删除,文件属性["+ ("top".equals(position) ? "前置" : "后置") +"流程]被删除触发流程[" + model.getName() + "][" + model.getId() + "]流程接口形状更新,流程接口形状增加已删除标记");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
SDK.getLogAPI().consoleErr("模型["+ model.getName() +"][" + model.getId() + "]模型文件转换JSON异常");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean matchProcedureObj(JSONObject shape, String versionId, String name, String position) {
|
||||
if (shape.containsKey("attrMark") && shape.getJSONObject("attrMark") != null) {
|
||||
return versionId.equals(shape.getJSONObject("attrMark").getString("versionId"));
|
||||
} else {
|
||||
if ("top".equals(position)) {// 前置,多出线,零入线且名称匹配
|
||||
if (shape.getJSONArray("fromLinkerArr").size() > 0 && shape.getJSONArray("toLinkerArr").size() == 0 && shape.getString("shapeText").equals(name)) {
|
||||
return true;
|
||||
}
|
||||
} else if ("bottom".equals(position)) {// 后置,多入线,零出线且名称匹配
|
||||
if (shape.getJSONArray("toLinkerArr").size() > 0 && shape.getJSONArray("fromLinkerArr").size() == 0 && shape.getString("shapeText").equals(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private JSONArray getProcedureShapeArr(JSONObject elements) {
|
||||
JSONArray result = new JSONArray();
|
||||
Iterator<String> it = elements.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
String key = it.next();
|
||||
JSONObject shape = elements.getJSONObject(key);
|
||||
String name = shape.getString("name");
|
||||
if ("procedure".equals(name)) {// 流程接口
|
||||
JSONObject obj = new JSONObject();
|
||||
String shapeText = shape.getString("text");
|
||||
JSONArray fromLinkerArr = new JSONArray();
|
||||
JSONArray toLinkerArr = new JSONArray();
|
||||
JSONObject attrMark = shape.getJSONObject("attrMark");
|
||||
obj.put("id", key);
|
||||
obj.put("shapeText", shapeText);
|
||||
obj.put("fromLinkerArr", fromLinkerArr);
|
||||
obj.put("toLinkerArr", toLinkerArr);
|
||||
obj.put("attrMark", attrMark);
|
||||
getInterfaceShapeLink(obj, elements);
|
||||
result.add(obj);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void getInterfaceShapeLink(JSONObject obj, JSONObject elements) {
|
||||
Iterator<String> it = elements.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
String key = it.next();
|
||||
JSONObject shape = elements.getJSONObject(key);
|
||||
String name = shape.getString("name");
|
||||
if ("linker".equals(name)) {// 连线
|
||||
// 出线
|
||||
JSONObject from = shape.getJSONObject("from");
|
||||
// 入线
|
||||
JSONObject to = shape.getJSONObject("to");
|
||||
if (from != null && to != null) {
|
||||
String fromId = from.getString("id");
|
||||
String toId = to.getString("id");
|
||||
if (obj.getString("id").equals(fromId)) {
|
||||
obj.getJSONArray("fromLinkerArr").add(key);
|
||||
}
|
||||
if (obj.getString("id").equals(toId)) {
|
||||
obj.getJSONArray("toLinkerArr").add(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空回收站
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user