流程复制时对角色图、绩效图的自动复制进行优化

This commit is contained in:
446052889@qq.com 2025-06-04 15:15:31 +08:00
parent 110c016c59
commit 3792568d08
6 changed files with 336 additions and 220 deletions

View File

@ -4462,6 +4462,23 @@ public class PALRepository extends DaoObject<PALRepositoryModel> {
return r;
}
/**
* 更新扩展字段内容
* @param uuid
* @param ext2
*/
public int updateRepositoryExt2(String uuid, String ext2) {
PALRepositoryModelImpl plModel = (PALRepositoryModelImpl) PALRepositoryCache.getCache().get(uuid);
String sql = "UPDATE " + PALRepositoryModelImpl.DATABASE_ENTITY + " set " + PALRepositoryModelImpl.FIELD_PL_EXT2 + "=? WHERE " + PALRepositoryModelImpl.FIELD_UUID + "=?";
Object[] args = {ext2 == null ? "" : ext2, uuid};
int r = DBSql.update(sql, args);
if (r > 0) {
plModel.setExt2(ext2 == null ? "" : ext2);
PALRepositoryCache.getCache().put(uuid, plModel);
}
return r;
}
/**
* 更新扩展字段内容
* @param uuid

View File

@ -31,6 +31,7 @@ public class DesignerShapeRelationCache extends Cache<String, DesignerShapeRelat
registeIndex(DesignerShapeRelationCacheIndex3.class, new DesignerShapeRelationCacheIndex3()); // key:fileId_shapeId_attrId
registeIndex(DesignerShapeRelationCacheIndex4.class, new DesignerShapeRelationCacheIndex4()); // key:fileId_attrId
registeIndex(DesignerShapeRelationCacheIndex5.class, new DesignerShapeRelationCacheIndex5()); // key:fileId_relationShapeId_attrId
registeIndex(DesignerShapeRelationCacheIndex6.class, new DesignerShapeRelationCacheIndex6());// key:fileId_attrId_relationFileId
registeReplicateActionListener(new DeleteAction());
registeReplicateActionListener(new UpdateAction());
registeReplicateActionListener(new UpdateRelationAction());
@ -265,4 +266,10 @@ public class DesignerShapeRelationCache extends Cache<String, DesignerShapeRelat
public static List<DesignerShapeRelationModel> getListByFileIdAndAttrIdAndRelationShapeId(String fileId, String attrId, String relationShapeId) {
return Cache.iteratorToList(getCache().getByIndex(DesignerShapeRelationCacheIndex5.class, fileId + "_" + attrId + "_" + relationShapeId));
}
public static List<DesignerShapeRelationModel> getListByFileIdAndAttrIdAndRelationFileId(String fileId, String attrId, String relationFileId) {
return Cache.iteratorToList(getCache().getByIndex(DesignerShapeRelationCacheIndex6.class, fileId + "_" + attrId + "_" + relationFileId));
}
}

View File

@ -0,0 +1,16 @@
package com.actionsoft.apps.coe.pal.pal.repository.designer.relation.cache;
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel;
import com.actionsoft.bpms.commons.cache.ListValueIndex;
public class DesignerShapeRelationCacheIndex6 extends ListValueIndex<String, DesignerShapeRelationModel> {
@Override
public String key(DesignerShapeRelationModel t) {
String attrId = t.getAttrId();
if (attrId == null) {
attrId = "";
}
return t.getFileId() + "_" + attrId + "_" + t.getRelationFileId();
}
}

View File

@ -60,6 +60,9 @@ public class DesignerShapeRelationModel extends ModelBean {
public void setRelationShapeText(String relationShapeText) {
this.relationShapeText = relationShapeText;
}
@Override
public String toString() {
return "DesignerShapeRelationModel{" + "id='" + id + '\'' + ", fileId='" + fileId + '\'' + ", shapeId='" + shapeId + '\'' + ", shapeText='" + shapeText + '\'' + ", attrId='" + attrId + '\'' + ", relationFileId='" + relationFileId + '\'' + ", relationShapeId='" + relationShapeId + '\'' + ", relationShapeText='" + relationShapeText + '\'' + '}';
}
}

View File

@ -14,6 +14,7 @@ import java.text.Collator;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
@ -185,6 +186,7 @@ import com.actionsoft.sdk.local.api.PortalAPI;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@ -5440,7 +5442,7 @@ public class CoeProcessLevelWeb extends ActionWeb {
private String copyAllFile(String wsId, String teamId, String sourceUUID, String targetUUID, int index) {
ResponseObject ro = ResponseObject.newOkResponse();
PALRepositoryModel sourceModel = PALRepositoryCache.getCache().get(sourceUUID);
String rostr = copyCurrentFile(wsId, teamId, sourceUUID, targetUUID, index++);
String rostr = copyCurrentFile(wsId, teamId, sourceUUID, targetUUID, 0);
List<PALRepositoryModel> subModelList = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getCoeProcessLevelByPid(sourceUUID, sourceModel.getWsId());
if (subModelList != null && subModelList.size() > 0) {
for (PALRepositoryModel model : subModelList) {
@ -5547,15 +5549,11 @@ public class CoeProcessLevelWeb extends ActionWeb {
int orderIndex = -1;
Map<String, String> mapNewUUID = new HashMap<String, String>();
boolean isCorrelate = PALRepositoryQueryAPIManager.getInstance().isCorrelateBpms(sourceModel.getId(), true);
List<PALRepositoryModel> models = CoeProcessLevelUtil.queryPalRepositoryModelsByPalId(sourceModel.getId());
Collections.sort(models, new Comparator<PALRepositoryModel>() {
@Override
public int compare(PALRepositoryModel o1, PALRepositoryModel o2) {
return VersionUtil.compareVersionNo(o1.getVersion(), o2.getVersion(), true);
}
});
int version = 1;
for (PALRepositoryModel oldModel : models) {
List<PALRepositoryModel> sourceModels = CoeProcessLevelUtil.queryPalRepositoryModelsByPalId(sourceModel.getId());
Collections.sort(sourceModels, (o1, o2) -> VersionUtil.compareVersionNo(o1.getVersion(), o2.getVersion(), false));
Map<String, String> repositoryOldNewMap = new HashMap<String, String>();// 记录原来的流程版本与新的流程版本
// int version = 1;
for (PALRepositoryModel sourceVerModel : sourceModels) {
PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel();
PALRepositoryModelImpl newModel = new PALRepositoryModelImpl();
@ -5585,53 +5583,53 @@ public class CoeProcessLevelWeb extends ActionWeb {
newModel.setVersionId(versionId);
newModel.setPlRid(plRid);
newModel.setVersion(version);
newModel.setVersion(sourceVerModel.getVersion());
newModel.setHistoryMaxVersion("0");
if (version == 1) {
if (sourceVerModel.getId().equals(sourceVerModel.getVersionId())) {
newModel.setId(versionId);
newModel.setUse(true);
} else {
newModel.setId(UUIDGener.getUUID());
newModel.setUse(false);
}
newModel.setUse(sourceVerModel.isUse());
//如果为绩效图则复制文本到相应文件夹中
if (targetUUID.equals("control")) {
targetUUID = sourceModel.getParentId();
}
newModel.setParentId(targetUUID);
newModel.setNo(plNo);
newModel.setMethodId(oldModel.getMethodId());
newModel.setMethodCategory(oldModel.getMethodCategory());
newModel.setMilestone(oldModel.getMilestone());
newModel.setMethodId(sourceVerModel.getMethodId());
newModel.setMethodCategory(sourceVerModel.getMethodCategory());
newModel.setMilestone(sourceVerModel.getMilestone());
if (orderIndex == -1) {
orderIndex = coeProcessLevel.getChildrenMaxOrderIndexByPidAndWsId(targetUUID, wsId);
}
newModel.setOrderIndex(orderIndex + 1);
newModel.setName(oldModel.getName() + (index == 0 ? "(副本)" : ""));
newModel.setName(sourceVerModel.getName() + (index == 0 ? "(副本)" : ""));
String uid = super.getContext().getUID();
Timestamp nowTime = new Timestamp(System.currentTimeMillis());
newModel.setCreateUser(uid);
newModel.setCreateDate(nowTime);
newModel.setModifyUser(uid);
newModel.setModifyDate(nowTime);
newModel.setBottomLevel(oldModel.isBottomLevel());
newModel.setDesc(oldModel.getDesc());
newModel.setInput(oldModel.getInput());
newModel.setOutput(oldModel.getOutput());
newModel.setExecType(oldModel.getExecType());
newModel.setBottomLevel(sourceVerModel.isBottomLevel());
newModel.setDesc(sourceVerModel.getDesc());
newModel.setInput(sourceVerModel.getInput());
newModel.setOutput(sourceVerModel.getOutput());
newModel.setExecType(sourceVerModel.getExecType());
newModel.setSystemFile(false);
newModel.setSystemName(oldModel.getSystemName());
newModel.setSystemName(sourceVerModel.getSystemName());
newModel.setPublish(false);
newModel.setStop(false);
newModel.setApproval(false);
newModel.setDutyDept(oldModel.getDutyDept());
newModel.setDutyUser(oldModel.getDutyUser());
newModel.setExt1(oldModel.getExt1());
newModel.setExt2(oldModel.getExt2());
newModel.setExt3(oldModel.getExt3());
newModel.setDutyDept(sourceVerModel.getDutyDept());
newModel.setDutyUser(sourceVerModel.getDutyUser());
newModel.setExt1(sourceVerModel.getExt1());
newModel.setExt2(sourceVerModel.getExt2());
newModel.setExt3(sourceVerModel.getExt3());
//设置ext4不进行复制
newModel.setExt4("");
version++;
// version++;
repositoryOldNewMap.put(sourceVerModel.getId(), newModel.getId());
// 创建
try {
coeProcessLevel.insert(newModel);
@ -5647,13 +5645,13 @@ public class CoeProcessLevelWeb extends ActionWeb {
}
CoeProcessLevelNoCache.getInstance().reloadInBackground(targetWsId); // 重新装载编号
if (!isCorrelate) {// PAL流程
if (!UtilString.isEmpty(newModel.getFilePath()) && !UtilString.isEmpty(oldModel.getFilePath())) {
if (!UtilString.isEmpty(newModel.getFilePath()) && !UtilString.isEmpty(sourceVerModel.getFilePath())) {
CoeFile fileUtil = new CoeFile();
fileUtil.copyDefaultVersion(oldModel.getFilePath(), oldModel.getId(), newModel.getFilePath(), newModel.getId());
fileUtil.copyDefaultVersion(sourceVerModel.getFilePath(), sourceVerModel.getId(), newModel.getFilePath(), newModel.getId());
CoeDesignerImageCache.getCache().put(newModel.getId(), newModel.getId());// 图片更新记录缓存
}
} else {// PAL与BPMS关联流程从BPMS端获取数据
CoeProcessLevelCorrelateModel model = CoeProcessLevelCorrelateCache.getCache().get(oldModel.getId());
CoeProcessLevelCorrelateModel model = CoeProcessLevelCorrelateCache.getCache().get(sourceVerModel.getId());
if (model != null && model.isCorrelate()) {
ProcessDefinition processDefinition = ProcessDefCache.getInstance().get(model.getPlAwsId());
if (processDefinition != null) {
@ -5675,12 +5673,12 @@ public class CoeProcessLevelWeb extends ActionWeb {
}
}
mapNewUUID = createShapeIdRelation(oldModel, mapNewUUID, true);
mapNewUUID = createShapeIdRelation(sourceVerModel, mapNewUUID, true);
// 更新流程文件中节点id等信息
updateDefineShape(newModel, mapNewUUID, "");
//CoeProcessLevelUtil.copyRepositoryProperty(oldModel, newModel, mapNewUUID, _uc);
//ydq 修改
CoeProcessLevelUtil.copyRepositoryProperty(oldModel, newModel, mapNewUUID, _uc,true);
CoeProcessLevelUtil.copyRepositoryProperty(sourceVerModel, newModel, mapNewUUID, _uc,true);
//ydq 修改结束
} catch (Exception e) {
@ -5690,8 +5688,265 @@ public class CoeProcessLevelWeb extends ActionWeb {
String finalTargetUUID = targetUUID;
// 创建的副本进行权限处理
CoeCooperationAPIManager.getInstance().updateCooperationPerm(_uc, "复制", teamId, finalTargetUUID, versionId);
List<PALRepositoryModel> newVerModels = PALRepositoryCache.getByVersionId(versionId);
String useId = null;
for (PALRepositoryModel model : newVerModels) {
if (model.isUse()) {
useId = model.getId();
break;
}
}
if (useId == null) {// 若没有使用中模型例如流程有3个版本角色图有2个版本如果恰好使用中的流程版本没有角色图则2个角色图都是非使用中
useId = newVerModels.get(0).getId();
}
ro.put("mapNewUUID", mapNewUUID);
ro.put("useId", CoeProcessLevelDaoFacotory.createCoeProcessLevel().getCoeUseProcessLevelByRid(plRid).get(0).getId());
ro.put("repositoryOldNewMap", repositoryOldNewMap);
ro.put("useId", useId);
System.out.println("模型复制结果:" + repositoryOldNewMap);
// 对流程涉及到的角色图绩效图进行复制处理
// 看是否有用角色图绩效图
if (existingModels(new ArrayList<String>(repositoryOldNewMap.keySet()), "org.role")) {// 有角色图
System.out.println("复制流程图[" + sourceModel.getName() + "]时检测到有相关角色图,开始进行角色图复制...");
copyPalProcessLevelRoleCorrelationModelRepository(repositoryOldNewMap, mapNewUUID);
System.out.println("复制流程图[" + sourceModel.getName() + "]时检测到有相关角色图,角色图复制完成!");
}
if (existingModels(new ArrayList<String>(repositoryOldNewMap.keySet()), "control.kpi")) {// 有绩效图
System.out.println("复制流程图[" + sourceModel.getName() + "]时检测到有相关绩效图,开始进行绩效图复制...");
copyPalProcessLevelPerformanceCorrelationModelRepository(repositoryOldNewMap, mapNewUUID);
System.out.println("复制流程图[" + sourceModel.getName() + "]时检测到有相关绩效图,绩效图复制完成!");
}
}
/**
* 绩效图复制
* @param repositoryOldNewMap 复制的流程图旧新id关系
* @param mapNewUUID 复制的流程图的节点旧新id关系
*/
private String copyPalProcessLevelPerformanceCorrelationModelRepository(Map<String, String> repositoryOldNewMap, Map<String, String> mapNewUUID) {
ResponseObject ro = ResponseObject.newOkResponse();
PALRepository repositoryDao = CoeProcessLevelDaoFacotory.createCoeProcessLevel();
DesignerShapeRelationDao relationDao = new DesignerShapeRelationDao();
// 找出对应的角色图使用版本
String performanceId = null;
PALRepositoryModel usePerformanceModel = null;
for (String uuid : repositoryOldNewMap.keySet()) {
performanceId = getExistingModel(uuid, "control.kpi");
if (UtilString.isNotEmpty(performanceId)) {
System.out.println("找到了流程与之关联的任一绩效图[" + performanceId + "]");
break;
}
}
if (UtilString.isEmpty(performanceId)) {
System.out.println("没有找到流程与之关联的绩效图");
return ro.toString();
}
PALRepositoryModel performanceModel = PALRepositoryCache.getCache().get(performanceId);
List<PALRepositoryModel> performanceModels = PALRepositoryCache.getCache().getByVersionId(performanceModel.getVersionId());
for (PALRepositoryModel r : performanceModels) {
if (r.isUse()) {
usePerformanceModel = r;
break;
}
}
if (usePerformanceModel == null) {
System.out.println("没有找到流程与之关联的绩效图使用版本,默认使用最小版本号的绩效版本开始进行角色复制");
Collections.sort(performanceModels, (o1, o2) -> VersionUtil.compareVersionNo(o1.getVersion(), o2.getVersion(), false));
usePerformanceModel = performanceModels.get(0);
}
// 对绩效图使用版本进行复制
String copyRoleResult = copyFile(usePerformanceModel.getWsId(), null, usePerformanceModel.getId(), usePerformanceModel.getParentId(), "self");
if (!JSONObject.parseObject(copyRoleResult).get("result").equals("ok")) {
System.out.println("复制绩效图[" + performanceModel.getName() + "]时出现错误,请检查!");
return copyRoleResult;
}
Map<String, String> performanceRepositoryOldNewMap = (Map<String, String>) JSONObject.parseObject(copyRoleResult).getJSONObject("data").get("repositoryOldNewMap");
Map<String, String> performanceMapNewUUID = (Map<String, String>) JSONObject.parseObject(copyRoleResult).getJSONObject("data").get("mapNewUUID");
// 建立新的关联关系
for (Map.Entry<String, String> entry : performanceRepositoryOldNewMap.entrySet()) {
List<DesignerShapeRelationModel> insertRelationList = new ArrayList<>();
String oldPerformanceId = entry.getKey();
String newPerformanceId = entry.getValue();
PALRepositoryModel newPerformanceModel = PALRepositoryCache.getCache().get(newPerformanceId);
String ext2 = newPerformanceModel.getExt2();
// 1. 去除方括号
String content = ext2.substring(1, ext2.length() - 1);
// 2. 分割字符串并处理空格
List<String> ext2List = Arrays.stream(content.split(",")).map(String::trim).collect(Collectors.toList());
String oldProcessId = ext2List.get(1);
if (repositoryOldNewMap.containsKey(oldProcessId)) {
List dataList = new ArrayList();
dataList.add(0, "control.kpi");
dataList.add(1, repositoryOldNewMap.get(oldProcessId));
// 更新模型关系
repositoryDao.updateRepositoryExt2(newPerformanceId, dataList.toString());
System.out.println("更新绩效图[" + newPerformanceModel.getName() + "]的关联关系,新的绩效图[" + newPerformanceId + "]关联的新流程图[" + repositoryOldNewMap.get(oldProcessId) + "]");
List<DesignerShapeRelationModel> oldRelationModels = DesignerShapeRelationCache.getListByFileIdAndAttrIdAndRelationFileId(oldProcessId, "Process_performance_metrics", oldPerformanceId);
for (DesignerShapeRelationModel relationModel : oldRelationModels) {
String processShapeId = relationModel.getShapeId();
String performanceShapeId = relationModel.getRelationShapeId();
if (performanceMapNewUUID.containsKey(performanceShapeId)) {
// 创建新的关联关系
DesignerShapeRelationModel newRelationModel = new DesignerShapeRelationModel();
newRelationModel.setId(UUIDGener.getUUID());
newRelationModel.setFileId(repositoryOldNewMap.get(oldProcessId));
newRelationModel.setShapeId("");
newRelationModel.setShapeText(relationModel.getShapeText());
newRelationModel.setAttrId(relationModel.getAttrId());
newRelationModel.setRelationFileId(newPerformanceId);
newRelationModel.setRelationShapeId(performanceMapNewUUID.get(performanceShapeId));
newRelationModel.setRelationShapeText(relationModel.getRelationShapeText());
insertRelationList.add(newRelationModel);
}
}
}
if (insertRelationList.size() > 0) {
relationDao.barchInsert(insertRelationList);
System.out.println("绩效图[" + newPerformanceModel.getName() + "]关联的流程图[" + repositoryOldNewMap.get(oldProcessId) + "]节点关系复制完成!");
System.out.println("复制的节点关系:" + insertRelationList.toString());
}
}
return ro.toString();
}
/**
* 角色图复制
* @param repositoryOldNewMap 复制的流程图旧新id关系
* @param mapNewUUID 复制的流程图的节点旧新id关系
*/
private String copyPalProcessLevelRoleCorrelationModelRepository(Map<String, String> repositoryOldNewMap, Map<String, String> mapNewUUID) {
ResponseObject ro = ResponseObject.newOkResponse();
PALRepository repositoryDao = CoeProcessLevelDaoFacotory.createCoeProcessLevel();
DesignerShapeRelationDao relationDao = new DesignerShapeRelationDao();
// 找出对应的角色图使用版本
String roleId = null;
PALRepositoryModel useRoleModel = null;
for (String uuid : repositoryOldNewMap.keySet()) {
roleId = getExistingModel(uuid, "org.role");
if (UtilString.isNotEmpty(roleId)) {
System.out.println("找到了流程与之关联的任一角色图[" + roleId + "]");
break;
}
}
if (UtilString.isEmpty(roleId)) {
System.out.println("没有找到流程与之关联的角色图");
return ro.toString();
}
PALRepositoryModel roleModel = PALRepositoryCache.getCache().get(roleId);
List<PALRepositoryModel> roleModels = PALRepositoryCache.getCache().getByVersionId(roleModel.getVersionId());
for (PALRepositoryModel r : roleModels) {
if (r.isUse()) {
useRoleModel = r;
break;
}
}
if (useRoleModel == null) {
System.out.println("没有找到流程与之关联的角色图使用版本,默认使用最小版本号的角色版本开始进行角色复制");
Collections.sort(roleModels, (o1, o2) -> VersionUtil.compareVersionNo(o1.getVersion(), o2.getVersion(), false));
useRoleModel = roleModels.get(0);
}
// 对角色图使用版本进行复制
String copyRoleResult = copyFile(useRoleModel.getWsId(), null, useRoleModel.getId(), useRoleModel.getParentId(), "self");
if (!JSONObject.parseObject(copyRoleResult).get("result").equals("ok")) {
System.out.println("复制角色图[" + roleModel.getName() + "]时出现错误,请检查!");
return copyRoleResult;
}
Map<String, String> roleRepositoryOldNewMap = (Map<String, String>) JSONObject.parseObject(copyRoleResult).getJSONObject("data").get("repositoryOldNewMap");
Map<String, String> roleMapNewUUID = (Map<String, String>) JSONObject.parseObject(copyRoleResult).getJSONObject("data").get("mapNewUUID");
// 建立新的关联关系
for (Map.Entry<String, String> entry : roleRepositoryOldNewMap.entrySet()) {
List<DesignerShapeRelationModel> insertRelationList = new ArrayList<>();
String oldRoleId = entry.getKey();
String newRoleId = entry.getValue();
PALRepositoryModel newRoleModel = PALRepositoryCache.getCache().get(newRoleId);
String ext2 = newRoleModel.getExt2();
// 1. 去除方括号
String content = ext2.substring(1, ext2.length() - 1);
// 2. 分割字符串并处理空格
List<String> ext2List = Arrays.stream(content.split(",")).map(String::trim).collect(Collectors.toList());
String oldProcessId = ext2List.get(1);
if (repositoryOldNewMap.containsKey(oldProcessId)) {
List dataList = new ArrayList();
dataList.add(0, "org.role");
dataList.add(1, repositoryOldNewMap.get(oldProcessId));
// 更新模型关系
repositoryDao.updateRepositoryExt2(newRoleId, dataList.toString());
System.out.println("更新角色图[" + newRoleModel.getName() + "]的关联关系,新的角色图[" + newRoleId + "]关联的新流程图[" + repositoryOldNewMap.get(oldProcessId) + "]");
List<DesignerShapeRelationModel> oldRelationModels = DesignerShapeRelationCache.getListByFileIdAndAttrIdAndRelationFileId(oldProcessId, "role", oldRoleId);
for (DesignerShapeRelationModel relationModel : oldRelationModels) {
String processShapeId = relationModel.getShapeId();
String roleShapeId = relationModel.getRelationShapeId();
if (mapNewUUID.containsKey(processShapeId) && roleMapNewUUID.containsKey(roleShapeId)) {
// 创建新的关联关系
DesignerShapeRelationModel newRelationModel = new DesignerShapeRelationModel();
newRelationModel.setId(UUIDGener.getUUID());
newRelationModel.setFileId(repositoryOldNewMap.get(oldProcessId));
newRelationModel.setShapeId(mapNewUUID.get(processShapeId));
newRelationModel.setShapeText(relationModel.getShapeText());
newRelationModel.setAttrId(relationModel.getAttrId());
newRelationModel.setRelationFileId(newRoleId);
newRelationModel.setRelationShapeId(roleMapNewUUID.get(roleShapeId));
newRelationModel.setRelationShapeText(relationModel.getRelationShapeText());
insertRelationList.add(newRelationModel);
}
}
}
if (insertRelationList.size() > 0) {
relationDao.barchInsert(insertRelationList);
System.out.println("角色图[" + newRoleModel.getName() + "]关联的流程图[" + repositoryOldNewMap.get(oldProcessId) + "]节点关系复制完成!");
System.out.println("复制的节点关系:" + insertRelationList.toString());
}
}
return ro.toString();
}
/**
* 判断是否存在相关的角色图绩效图
* @param uuidList
* @param methodId
* @return
*/
private boolean existingModels(List<String> uuidList, String methodId) {
for (String uuid : uuidList) {
if (getExistingModel(uuid, methodId) != null) {
return true;
}
}
return false;
}
/**
* 获取已经存在的流程相关联的模型例如流程关联的角色图
* @param uuid 流程Id
* @param methodId 对应的建模方法ID
* @return
*/
private String getExistingModel(String uuid, String methodId) {
PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid);
if (model == null) {
return null;
}
// 1.查询有关联的methodId模型
List<String> paramList = new ArrayList<>();
List data = new ArrayList();
data.add(0, methodId.trim());
data.add(1, model.getId().trim());
String param = data.toString();// 查询参数
paramList.add(param);
// 2.查询符合的methodId模型列表并排序理论上只会有一个
PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel();
List<PALRepositoryModel> list = coeProcessLevel.searchRepositoryByMethodIdAndExt2(methodId, paramList);
if (CollectionUtils.isNotEmpty(list)) {
list.sort((m1,m2) -> {
if (m1.getVersion() == m2.getVersion()) {
return m1.getCreateDate().compareTo(m2.getCreateDate());
}
return m1.getVersion() > m2.getVersion() ? 1 : -1;
});
// 3.取排在首位的角色模型的模型ID
return list.get(0).getId();
}
return null;
}
private void updateDefineShape(PALRepositoryModelImpl newModel, Map<String, String> mapNewUUID, String define) {
@ -11370,8 +11625,6 @@ public class CoeProcessLevelWeb extends ActionWeb {
SDK.getLogAPI().consoleErr("复制文件[" + model.getName() + "][" + model.getId() + "]失败," + moveRo.getString("msg"));
return ResponseObject.newErrResponse(moveRo.getString("msg")).toString();
}
copyPalProcessLevelRoleCorrelationModelRepository(wsId, teamId, sourceId, result);
copyPalProcessLevelPerformanceCorrelationModelRepository(wsId, teamId, sourceId, result);
}
// 操作行为日志记录
if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) {
@ -11381,186 +11634,6 @@ public class CoeProcessLevelWeb extends ActionWeb {
return ro.toString();
}
/**
* 同步复制数据模型角色模型
*
* @param wsId
* @param teamId
* @param sourceIds
* @param targetId
* @return
*/
public String copyPalProcessLevelRoleCorrelationModelRepository(String wsId, String teamId, String sourceId, String resultmsg) {
ResponseObject ro = ResponseObject.newOkResponse();
CoeDesignerWeb coe = new CoeDesignerWeb(_uc);
Map<String, String> mapNewUUID = new HashMap<String, String>();
String useId = null;
String roleuseId = null;
//获取数据属性同步创建角色模型
DesignerShapeRelationDao dao = new DesignerShapeRelationDao();
PALRepositoryCache.getCache().get(sourceId);
List<DesignerShapeRelationModel> oldModelList = dao.getModelListByFileId(sourceId);
for (DesignerShapeRelationModel oldModel : oldModelList) {
//如果关联角色图则同步复制角色图关联关系,由于角色图规定为本流程使用所以获取一次
String methodIds = "";
if (oldModel.getAttrId().equals("role")) {
PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel();
String targetId = checkAndCreatePalRoleFolderModel(coeProcessLevel, wsId);
PALRepositoryModel model = PALRepositoryCache.getCache().get(oldModel.getRelationFileId());
String result = copyFile(wsId, teamId, oldModel.getRelationFileId(), targetId, "all");
if (JSONObject.parseObject(resultmsg).get("result").equals("ok")) {
useId = JSONObject.parseObject(resultmsg).getJSONObject("data").getJSONObject("msg").getJSONObject("data").get("useId").toString();
if (UtilString.isNotEmpty(useId)) {
if (JSONObject.parseObject(result).get("result").equals("ok")) {
roleuseId = JSONObject.parseObject(result).getJSONObject("data").getJSONObject("msg").getJSONObject("data").get("useId").toString();
if (UtilString.isNotEmpty(roleuseId)) {
//插入关联模型数据
List dataList = new ArrayList();
dataList.add(0, "org.role");
dataList.add(1, useId);
int r = DBSql.update("update APP_ACT_COE_PAL_REPOSITORY set EXT2=? where ID=?", new Object[] { dataList.toString(), roleuseId });
}
}
}
}
JSONObject moveRo = JSONObject.parseObject(result);
if (!"ok".equals(moveRo.getString("result"))) {
SDK.getLogAPI().consoleErr("复制文件[" + model.getName() + "][" + model.getId() + "]失败," + moveRo.getString("msg"));
return ResponseObject.newErrResponse(moveRo.getString("msg")).toString();
}
break;
}
}
List<PALRepositoryModel> models = CoeProcessLevelUtil.queryPalRepositoryModelsByPalId(sourceId);
PALRepositoryModel model = PALRepositoryCache.getCache().get(sourceId);
// 获取新旧节点关联关系
mapNewUUID = (Map<String, String>) JSONObject.parseObject(resultmsg).getJSONObject("data").getJSONObject("msg").getJSONObject("data").get("mapNewUUID");
for (DesignerShapeRelationModel oldModel : oldModelList) {
//重新设置修订关联关系
DesignerShapeRelationModel newModel1 = new DesignerShapeRelationModel();
newModel1.setId(UUIDGener.getUUID());
newModel1.setFileId(useId);
newModel1.setShapeId(mapNewUUID.get(oldModel.getShapeId()));
newModel1.setShapeText(oldModel.getShapeText());
newModel1.setAttrId(oldModel.getAttrId());
newModel1.setRelationFileId(roleuseId);
newModel1.setRelationShapeId(oldModel.getRelationShapeId());
newModel1.setRelationShapeText(oldModel.getRelationShapeText());
dao.insert(newModel1);
}
return ro.toString();
}
/**
* 同步复制文件属性绩效属性数据
*
* @param wsId
* @param teamId
* @param sourceIds
* @param targetId
* @return
*/
public String copyPalProcessLevelPerformanceCorrelationModelRepository(String wsId, String teamId, String sourceId, String resultmodel) {
ResponseObject ro = ResponseObject.newOkResponse();
String perforId = perforId = JSONObject.parseObject(resultmodel).getJSONObject("data").getJSONObject("msg").getJSONObject("data").get("useId").toString();
PALRepositoryPropertyDao repositoryPropertyDao = new PALRepositoryPropertyDao();
List<PALRepositoryPropertyModel> oldPropertyList = repositoryPropertyDao.getPropertysByPlid(sourceId, "");
List<PALRepositoryPropertyModel> newPropertyList = new ArrayList<PALRepositoryPropertyModel>();
if (oldPropertyList != null && oldPropertyList.size() > 0) {
for (PALRepositoryPropertyModel propertyModel : oldPropertyList) {
//文件属性存在流程绩效则同步创建关联关系
if (propertyModel.getPropertyId().equals("Process_performance_metrics")) {
String relationFileId = JSONObject.parseObject(propertyModel.getPropertyValue()).getString("relationFileId");
String[] splitRelationFileId;
PALRepositoryModel model;
if (UtilString.isNotEmpty(relationFileId)) {
if (relationFileId.contains(",")) {
splitRelationFileId = relationFileId.split(",");
relationFileId = splitRelationFileId[0];
} else {
relationFileId = relationFileId;
}
model = PALRepositoryCache.getCache().get(relationFileId);
String result = copyFile(wsId, teamId, relationFileId, "control", "all");
JSONObject moveRo = JSONObject.parseObject(result);
if (!"ok".equals(moveRo.getString("result"))) {
SDK.getLogAPI().consoleErr("复制文件[" + model.getName() + "][" + model.getId() + "]失败," + moveRo.getString("msg"));
return ResponseObject.newErrResponse(moveRo.getString("msg")).toString();
}
CoeDesignerWeb coe = new CoeDesignerWeb(_uc);
// 处理流程属性
String property = CoePropertyUtil.getPropertyValue(relationFileId + "_attr");
if (!UtilString.isEmpty(property)) {
CoePropertyUtil.createProperty(moveRo.getString("result") + "_attr", property);
}
Map<String, String> mapNewUUID = (Map<String, String>) JSONObject.parseObject(result).getJSONObject("data").getJSONObject("msg").getJSONObject("data").get("mapNewUUID");
String newuuid = JSONObject.parseObject(result).getJSONObject("data").getJSONObject("msg").getJSONObject("data").get("useId").toString();
DesignerShapeRelationDao dao = new DesignerShapeRelationDao();
List<DesignerShapeRelationModel> oldModelList = dao.getModelListByFileId(sourceId);
oldModelList.sort(Comparator.comparing(DesignerShapeRelationModel::getShapeText));
for (DesignerShapeRelationModel oldModel : oldModelList) {
if (oldModel.getAttrId().equals("Process_performance_metrics")) {
//重新设置修订关联关系
DesignerShapeRelationModel newModel1 = new DesignerShapeRelationModel();
newModel1.setId(UUIDGener.getUUID());
newModel1.setFileId(perforId);
newModel1.setShapeId(mapNewUUID.get(oldModel.getShapeId()));
newModel1.setShapeText(oldModel.getShapeText());
newModel1.setAttrId(oldModel.getAttrId());
newModel1.setRelationFileId(newuuid);
newModel1.setRelationShapeId(oldModel.getRelationShapeId());
newModel1.setRelationShapeText(oldModel.getRelationShapeText());
dao.insert(newModel1);
}
}
if (UtilString.isNotEmpty(newuuid)) {
//插入关联模型数据
List dataList = new ArrayList();
dataList.add(0, "control.kpi");
dataList.add(1, perforId);
int r = DBSql.update("update APP_ACT_COE_PAL_REPOSITORY set EXT2=? where ID=?", new Object[] { dataList.toString(), newuuid });
}
break;
}
}
}
}
return ro.toString();
}
/**
* 校验和创建角色模型文件夹
*