diff --git a/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar b/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar index b5b3976a..99edaacf 100644 Binary files a/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar and b/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar differ diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/dao/PALRepository.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/dao/PALRepository.java index f968cba9..9eb2bbcf 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/dao/PALRepository.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/dao/PALRepository.java @@ -4462,6 +4462,23 @@ public class PALRepository extends DaoObject { 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 diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/cache/DesignerShapeRelationCache.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/cache/DesignerShapeRelationCache.java index 3cdd360e..62fb3abd 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/cache/DesignerShapeRelationCache.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/cache/DesignerShapeRelationCache.java @@ -31,6 +31,7 @@ public class DesignerShapeRelationCache extends Cache getListByFileIdAndAttrIdAndRelationShapeId(String fileId, String attrId, String relationShapeId) { return Cache.iteratorToList(getCache().getByIndex(DesignerShapeRelationCacheIndex5.class, fileId + "_" + attrId + "_" + relationShapeId)); } + + public static List getListByFileIdAndAttrIdAndRelationFileId(String fileId, String attrId, String relationFileId) { + return Cache.iteratorToList(getCache().getByIndex(DesignerShapeRelationCacheIndex6.class, fileId + "_" + attrId + "_" + relationFileId)); + } + } + diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/cache/DesignerShapeRelationCacheIndex6.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/cache/DesignerShapeRelationCacheIndex6.java new file mode 100644 index 00000000..6963d5bd --- /dev/null +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/cache/DesignerShapeRelationCacheIndex6.java @@ -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 { + + @Override + public String key(DesignerShapeRelationModel t) { + String attrId = t.getAttrId(); + if (attrId == null) { + attrId = ""; + } + return t.getFileId() + "_" + attrId + "_" + t.getRelationFileId(); + } +} diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/model/DesignerShapeRelationModel.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/model/DesignerShapeRelationModel.java index 1d3800b0..79f86d21 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/model/DesignerShapeRelationModel.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/model/DesignerShapeRelationModel.java @@ -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 + '\'' + '}'; + } } diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/web/CoeProcessLevelWeb.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/web/CoeProcessLevelWeb.java index 8306f25c..c1d82026 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/web/CoeProcessLevelWeb.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/web/CoeProcessLevelWeb.java @@ -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 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 mapNewUUID = new HashMap(); boolean isCorrelate = PALRepositoryQueryAPIManager.getInstance().isCorrelateBpms(sourceModel.getId(), true); - List models = CoeProcessLevelUtil.queryPalRepositoryModelsByPalId(sourceModel.getId()); - Collections.sort(models, new Comparator() { - @Override - public int compare(PALRepositoryModel o1, PALRepositoryModel o2) { - return VersionUtil.compareVersionNo(o1.getVersion(), o2.getVersion(), true); - } - }); - int version = 1; - for (PALRepositoryModel oldModel : models) { + List sourceModels = CoeProcessLevelUtil.queryPalRepositoryModelsByPalId(sourceModel.getId()); + Collections.sort(sourceModels, (o1, o2) -> VersionUtil.compareVersionNo(o1.getVersion(), o2.getVersion(), false)); + Map repositoryOldNewMap = new HashMap();// 记录原来的流程版本与新的流程版本 + // 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 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(repositoryOldNewMap.keySet()), "org.role")) {// 有角色图 + System.out.println("复制流程图[" + sourceModel.getName() + "]时检测到有相关角色图,开始进行角色图复制..."); + copyPalProcessLevelRoleCorrelationModelRepository(repositoryOldNewMap, mapNewUUID); + System.out.println("复制流程图[" + sourceModel.getName() + "]时检测到有相关角色图,角色图复制完成!"); + } + if (existingModels(new ArrayList(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 repositoryOldNewMap, Map 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 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 performanceRepositoryOldNewMap = (Map) JSONObject.parseObject(copyRoleResult).getJSONObject("data").get("repositoryOldNewMap"); + Map performanceMapNewUUID = (Map) JSONObject.parseObject(copyRoleResult).getJSONObject("data").get("mapNewUUID"); + // 建立新的关联关系 + for (Map.Entry entry : performanceRepositoryOldNewMap.entrySet()) { + List 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 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 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 repositoryOldNewMap, Map 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 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 roleRepositoryOldNewMap = (Map) JSONObject.parseObject(copyRoleResult).getJSONObject("data").get("repositoryOldNewMap"); + Map roleMapNewUUID = (Map) JSONObject.parseObject(copyRoleResult).getJSONObject("data").get("mapNewUUID"); + // 建立新的关联关系 + for (Map.Entry entry : roleRepositoryOldNewMap.entrySet()) { + List 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 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 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 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 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 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 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 mapNewUUID = new HashMap(); - String useId = null; - String roleuseId = null; - //获取数据属性同步创建角色模型 - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - PALRepositoryCache.getCache().get(sourceId); - - List 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 models = CoeProcessLevelUtil.queryPalRepositoryModelsByPalId(sourceId); - - PALRepositoryModel model = PALRepositoryCache.getCache().get(sourceId); - // 获取新旧节点关联关系 - mapNewUUID = (Map) 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 oldPropertyList = repositoryPropertyDao.getPropertysByPlid(sourceId, ""); - List newPropertyList = new ArrayList(); - 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 mapNewUUID = (Map) 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 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(); - } - /** * 校验和创建角色模型文件夹 *