diff --git a/com.actionsoft.apps.coe.method.process.epc/method/process.epc/diagram.attribute.custom.xml b/com.actionsoft.apps.coe.method.process.epc/method/process.epc/diagram.attribute.custom.xml
index 44a465ef..3116a49f 100644
--- a/com.actionsoft.apps.coe.method.process.epc/method/process.epc/diagram.attribute.custom.xml
+++ b/com.actionsoft.apps.coe.method.process.epc/method/process.epc/diagram.attribute.custom.xml
@@ -22,15 +22,16 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/CooperationQueryAPIManager.java b/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/CooperationQueryAPIManager.java
index ac468beb..d4bfd9c3 100644
--- a/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/CooperationQueryAPIManager.java
+++ b/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/CooperationQueryAPIManager.java
@@ -5,10 +5,7 @@ import com.actionsoft.apps.coe.pal.constant.CoEConstant;
import com.actionsoft.apps.coe.pal.cooperation.aslp.ListApps;
import com.actionsoft.apps.coe.pal.cooperation.cache.model.TeamInfo;
import com.actionsoft.apps.coe.pal.cooperation.cache.model.UserInfo;
-import com.actionsoft.apps.coe.pal.cooperation.dao.CoeCooperationMemberDao;
-import com.actionsoft.apps.coe.pal.cooperation.dao.CoeCooperationRoleDao;
-import com.actionsoft.apps.coe.pal.cooperation.dao.CoeCooperationRolePermDao;
-import com.actionsoft.apps.coe.pal.cooperation.dao.CoeCooperationTeamDao;
+import com.actionsoft.apps.coe.pal.cooperation.dao.*;
import com.actionsoft.apps.coe.pal.cooperation.extend.CooperationAppManager;
import com.actionsoft.apps.coe.pal.cooperation.extend.CooperationAppProfile;
import com.actionsoft.apps.coe.pal.cooperation.model.CoeCooperationMemberModel;
@@ -144,59 +141,6 @@ public class CooperationQueryAPIManager {
}
}
- public List getAllTeamInfo(){
- List list = new ArrayList<>();
-
- List allTeam = new CoeCooperationTeamDao().getAllTeam();
- for (CoeCooperationTeamModel teamModel : allTeam) {
- TeamInfo teamInfo = new TeamInfo();
- teamInfo.setTeamId(teamModel.getId());
- List userInfos = this.getUserInfoByTeamId(teamModel.getId());
- teamInfo.setUsers(userInfos);
- list.add(teamInfo);
- }
- return list;
- }
-
- public List getUserInfoByTeamId(String teamId){
- List list = new ArrayList<>();
-
- List memberModels = new CoeCooperationMemberDao().queryUserListByTeam(teamId);
- for (CoeCooperationMemberModel memberModel : memberModels) {
- UserInfo userInfo = new UserInfo();
- userInfo.setUserid(memberModel.getUserId());
- userInfo.getRoleIds().add(memberModel.getRoleId());
-
- //获取角色信息,设置全局权限
- CoeCooperationRoleModel roleModel = new CoeCooperationRoleDao().queryById(memberModel.getRoleId());
- userInfo.setAppPermission( roleModel.getAppPerm());
- List actionPermList = Arrays.stream(roleModel.getActionPerm().split(",")).collect(Collectors.toList());
- userInfo.getOperatePermission().addAll(actionPermList);
- //设置全部数据权限
- userInfo.setIsAllDataPermission(roleModel.getDataPerm().equals("all"));
-
- if (!userInfo.getIsAllDataPermission()){
- //获取角色下数据权限,设置数据权限
- List rolePerms = new CoeCooperationRolePermDao().getRolePermByTeamIdAndRoleId(teamId, memberModel.getRoleId());
- for (CoeCooperationRolePermModel rolePerm : rolePerms) {
- Set dataPerm = userInfo.getDataPermission().get(rolePerm.getPalVersionId());
- if (null == dataPerm){
- dataPerm = new HashSet<>();
- }
- if (StringUtils.isNotEmpty(rolePerm.getActionPerm())){
- dataPerm.addAll(Arrays.asList(rolePerm.getActionPerm().split(",").clone()));
- }
- userInfo.getDataPermission().put(rolePerm.getPalVersionId(), dataPerm);
- }
- }
-
- list.add(userInfo);
- }
-
- return list;
- }
-
-
/**
* 根据父节点获取权限范围内的子流程(小组权限范围内)
* @param wsId
diff --git a/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/plugins/Plugins.java b/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/plugins/Plugins.java
index 6daa8b83..5eb06033 100644
--- a/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/plugins/Plugins.java
+++ b/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/plugins/Plugins.java
@@ -32,8 +32,6 @@ public class Plugins implements PluginListener {
params2.put("deletedClass", "");
list.add(new AppExtensionProfile("PAL小组->回收站", "aslp://com.actionsoft.apps.coe.pal.cooperation/registerApp", params2));
- //小组用户权限信息cache
- list.add(new CachePluginProfile(CooperationCache.class));
return list;
}
}
diff --git a/com.actionsoft.apps.coe.pal.datamigration/db/1.0/mysql.sql b/com.actionsoft.apps.coe.pal.datamigration/db/1.0/mysql.sql
new file mode 100644
index 00000000..b082f63c
--- /dev/null
+++ b/com.actionsoft.apps.coe.pal.datamigration/db/1.0/mysql.sql
@@ -0,0 +1 @@
+CREATE TABLE APP_ACT_COE_PAL_DATAM_LOG(ID CHAR(36) NOT NULL ,WSID CHAR(36),FILENAME VARCHAR(100), FILEPATH VARCHAR(500), LOGPATH VARCHAR(500), CREATEUSER VARCHAR(20),CREATEUSERNAME VARCHAR(20),CREATEDATE DATETIME, STARTDATE DATETIME, ENDDATE DATETIME, RESULTSTATUS SMALLINT(1), MAININFO VARCHAR(500), EXT1 VARCHAR(64),EXT2 VARCHAR(128),EXT3 VARCHAR(255),EXT4 VARCHAR(255) ,CONSTRAINT APP_ACT_COE_PAL_DATAM_LOG_PK PRIMARY KEY (ID));
\ No newline at end of file
diff --git a/com.actionsoft.apps.coe.pal.datamigration/db/1.0/oracle.sql b/com.actionsoft.apps.coe.pal.datamigration/db/1.0/oracle.sql
new file mode 100644
index 00000000..1f422e3f
--- /dev/null
+++ b/com.actionsoft.apps.coe.pal.datamigration/db/1.0/oracle.sql
@@ -0,0 +1 @@
+CREATE TABLE APP_ACT_COE_PAL_DATAM_LOG(ID CHAR(36) NOT NULL ,WSID CHAR(36),FILENAME NVARCHAR2(100), FILEPATH NVARCHAR2(500), LOGPATH NVARCHAR2(500), CREATEUSER NVARCHAR2(20),CREATEUSERNAME NVARCHAR2(20), CREATEDATE DATE, STARTDATE DATE, ENDDATE DATE, RESULTSTATUS NUMBER(1), MAININFO NVARCHAR2(500), EXT1 NVARCHAR2(64),EXT2 NVARCHAR2(128),EXT3 NVARCHAR2(255),EXT4 NVARCHAR2(255) ,CONSTRAINT APP_ACT_COE_PAL_DATAM_LOG_PK PRIMARY KEY (ID));
\ No newline at end of file
diff --git a/com.actionsoft.apps.coe.pal.datamigration/lib/com.actionsoft.apps.coe.pal.datamigration.jar b/com.actionsoft.apps.coe.pal.datamigration/lib/com.actionsoft.apps.coe.pal.datamigration.jar
index b029ebda..7266556f 100644
Binary files a/com.actionsoft.apps.coe.pal.datamigration/lib/com.actionsoft.apps.coe.pal.datamigration.jar and b/com.actionsoft.apps.coe.pal.datamigration/lib/com.actionsoft.apps.coe.pal.datamigration.jar differ
diff --git a/com.actionsoft.apps.coe.pal.datamigration/lib/lombok-1.18.16.jar b/com.actionsoft.apps.coe.pal.datamigration/lib/lombok-1.18.16.jar
new file mode 100644
index 00000000..20f85ff2
Binary files /dev/null and b/com.actionsoft.apps.coe.pal.datamigration/lib/lombok-1.18.16.jar differ
diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/DataMigrationController.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/DataMigrationController.java
index bb412ff4..d8f4dbd6 100644
--- a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/DataMigrationController.java
+++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/DataMigrationController.java
@@ -9,6 +9,15 @@ import com.actionsoft.bpms.server.bind.annotation.Mapping;
@Controller
public class DataMigrationController {
+ /**
+ * 数据迁移
+ * @param uc
+ * @param wsId
+ * @param groupValue
+ * @param fileValue
+ * @param fileName
+ * @return
+ */
@Mapping("com.actionsoft.apps.coe.pal.datamigration_data_migrate")
public String dataMigrate(UserContext uc, String wsId,String groupValue,String fileValue,String fileName) {
return new DataMigrationWeb(uc).dataMigrate(wsId,groupValue,fileValue,fileName);
diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/constant/ArisConstant.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/constant/ArisConstant.java
new file mode 100644
index 00000000..7fee0f76
--- /dev/null
+++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/constant/ArisConstant.java
@@ -0,0 +1,16 @@
+package com.actionsoft.apps.coe.pal.datamigration.aris.constant;
+
+public class ArisConstant {
+
+ public final static String REPOSITORY_NAME = "arisXML";// aris xml文件导入dc根目录
+
+ public final static String UPFILE = "upfile";// aris xml文件上传根目录,在REPOSITORY_NAME之下
+
+ public final static String LOG_GROUP_VALUE = "log";// aris xml文件导入日志根目录,在REPOSITORY_NAME之下
+
+ public final static String IMPORT_LOG_FILE_SIMPLE = "simpleImport.log";// 简要日志,展示给前端,体现大致的导入内容和进度
+ public final static String IMPORT_LOG_FILE_FULL = "fullImport.log";// 详细日志,包括全量信息内容
+ public final static String IMPORT_LOG_FILE_WARN = "warnErrImport.log";// 错误&警告日志,单独记录错误&警告日志,同时详细日志中也有记录
+
+
+}
diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/util/XMLUtil.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/util/XMLUtil.java
index e7173514..1edf383a 100755
--- a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/util/XMLUtil.java
+++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/util/XMLUtil.java
@@ -24,12 +24,12 @@ public class XMLUtil {
* @param fromFilePath
* @param toFilePath
*/
- public static void unicode2String(String fromFilePath, String toFilePath) {
+ public static void unicode2String(String fromFilePath, String toFilePath) throws DocumentException, FileNotFoundException{
Document d = XMLUtil.readXML(fromFilePath, true);
XMLUtil.writeXml(d, toFilePath);
}
- public static Document readXML(String filePath, boolean ignoreDtd) {
+ public static Document readXML(String filePath, boolean ignoreDtd) throws DocumentException, FileNotFoundException {
if (filePath == null) {
return null;
}
@@ -60,16 +60,12 @@ public class XMLUtil {
return document;
} catch (DocumentException e) {
- File fil = new File(filePath);
- try {
- document = reader.read(fil);
- } catch (Exception e1) {
-
- }
+ e.printStackTrace();
+ throw e;
} catch (Exception e) {
e.printStackTrace();
+ throw e;
}
- return null;
}
public static Document readXMLFromInputStream(InputStream in) {
diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/web/ArisXmlHandleWeb.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/web/ArisXmlHandleWeb.java
index 5e302355..bc3735e1 100644
--- a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/web/ArisXmlHandleWeb.java
+++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/web/ArisXmlHandleWeb.java
@@ -2,12 +2,15 @@ package com.actionsoft.apps.coe.pal.datamigration.aris.web;
import com.actionsoft.apps.coe.pal.datamigration.aris.mapping.ModelMappingAPIManager;
import com.actionsoft.apps.coe.pal.datamigration.aris.model.*;
+import com.actionsoft.apps.coe.pal.datamigration.constant.Constant;
+import com.actionsoft.apps.coe.pal.datamigration.util.LogUtil;
import com.actionsoft.bpms.util.UtilString;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Document;
import org.dom4j.Element;
+import java.io.File;
import java.util.*;
/**
@@ -29,22 +32,22 @@ public class ArisXmlHandleWeb {
public Map> objDefLinkerMap = new HashMap<>();// 记录所有定义形状的连线map记录
-
- // 连线 todo
-
- // 属性 todo
-
// 处理文档
- public void handleXmlDoc(Document doc) {
- // 获取根元素节点
- Element root = doc.getRootElement();
- String groupPath = "/";
- getNodes(root, groupPath);
- // 整合Model路径
- calculateModelPath();
- // 计算定义形状之间的连线
- calculateObjDefLinker();
- test();
+ public void handleXmlDoc(Document doc) throws Exception{
+ try {
+ // 获取根元素节点
+ Element root = doc.getRootElement();
+ String groupPath = "/";
+ getNodes(root, groupPath);
+ // 整合Model路径
+ calculateModelPath();
+ // 计算定义形状之间的连线
+ calculateObjDefLinker();
+ // test();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
}
/**
diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/web/ArisXmlImportRun.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/web/ArisXmlImportRun.java
new file mode 100644
index 00000000..fd42ac3f
--- /dev/null
+++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/web/ArisXmlImportRun.java
@@ -0,0 +1,1447 @@
+package com.actionsoft.apps.coe.pal.datamigration.aris.web;
+
+import com.actionsoft.apps.coe.pal.constant.CoEConstant;
+import com.actionsoft.apps.coe.pal.datamigration.aris.mapping.ModelMappingAPIManager;
+import com.actionsoft.apps.coe.pal.datamigration.aris.model.*;
+import com.actionsoft.apps.coe.pal.datamigration.constant.Constant;
+import com.actionsoft.apps.coe.pal.datamigration.log.cache.LogRealTimeCountCache;
+import com.actionsoft.apps.coe.pal.datamigration.log.model.LogRealTimeCountModel;
+import com.actionsoft.apps.coe.pal.datamigration.util.LogUtil;
+import com.actionsoft.apps.coe.pal.datamigration.util.ProcessUtil;
+import com.actionsoft.apps.coe.pal.datamigration.util.ShapeUtil;
+import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel;
+import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryAPIManager;
+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.dao.CoeProcessLevelDaoFacotory;
+import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepository;
+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.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.dao.DesignerShapeRelationDao;
+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.pal.repository.model.PALRepositoryModel;
+import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryPropertyModel;
+import com.actionsoft.apps.coe.pal.pal.repository.model.impl.PALRepositoryModelImpl;
+import com.actionsoft.apps.coe.pal.pal.repository.util.CoeProcessLevelUtil;
+import com.actionsoft.bpms.server.UserContext;
+import com.actionsoft.bpms.util.UUIDGener;
+import com.actionsoft.bpms.util.UtilDate;
+import com.actionsoft.bpms.util.UtilString;
+import com.actionsoft.exception.AWSException;
+import com.actionsoft.i18n.I18nRes;
+import com.actionsoft.sdk.local.SDK;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.commons.lang.StringUtils;
+
+import java.io.File;
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.stream.Collectors;
+
+public class ArisXmlImportRun {
+
+ private UserContext uc;
+ private String wsId;
+ private String logId;
+ private String logPath;
+ private File simpleLogFile;
+ private File fullLogFile;
+ private File warnLogFile;
+ private String filePath;
+ private String fileName;
+ private long startTime;
+
+ private long endTime;
+
+ public ArisXmlImportRun(UserContext uc, String wsId, String logId, String logPath, File simpleLogFile, File fullLogFile, File warnLogFile, String filePath, String fileName, long startTime) {
+ this.uc = uc;
+ this.wsId = wsId;
+ this.logId = logId;
+ this.logPath = logPath;
+ this.simpleLogFile = simpleLogFile;
+ this.fullLogFile = fullLogFile;
+ this.warnLogFile = warnLogFile;
+ this.filePath = filePath;
+ this.fileName = fileName;
+ this.startTime = startTime;
+ }
+
+ public void execute(ArisXmlHandleWeb handleWeb) {
+ Map groupMap = handleWeb.groupMap;// 文件夹/组基本信息map记录
+
+ Map modelMap = handleWeb.modelMap;// 模型基本信息map记录
+
+ Map objDefMap = handleWeb.objDefMap;// 形状定义map记录
+
+ Map> modelObjOccMap = handleWeb.modelObjOccMap;// 模型内形状map记录
+
+ Map objOccMap = handleWeb.objOccMap;// 所有形状
+
+ Map> cxnOccMap = handleWeb.cxnOccMap;// 形状连线记录
+
+ Map> objDefLinkerMap = handleWeb.objDefLinkerMap;// 记录所有定义形状的连线map记录
+
+ Map> methodAttrsMap = new HashMap<>();// 属性存储
+
+ PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel();
+
+ try {
+ // 获取所有IT系统图,并查询所有IT系统形状
+ Map itShapeMap = new HashMap<>();
+ Set ids = new HashSet<>();
+ List itModels = new ArrayList<>();
+ PALRepositoryCache.getAllChildrenModelsByPid(wsId, "itsystem", itModels, ids);
+ for (PALRepositoryModel itModel : itModels) {
+ String definition = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(null, itModel.getId());
+ List list = com.actionsoft.apps.coe.pal.pal.repository.designer.util.ShapeUtil.getShapeJsonToJsonObject(definition);
+ for (JSONObject shape: list) {
+ JSONObject obj = new JSONObject();
+ obj.put("shapeId", shape.getString("id"));
+ obj.put("plId", itModel.getId());
+ obj.put("shapeName", shape.getString("text"));
+ itShapeMap.put(shape.getString("text"), obj);
+ }
+ }
+ String rolefolderId = checkAndCreatePalRoleFolderModel(coeProcessLevel, wsId);// 创建/获取角色文件夹ID,作为角色的顶级文件夹
+
+ // 获取所有PAL EPC的模型
+ Map palArisPropValMap = getPalRepositoryXmlPathMap(wsId);
+
+ List arisEpcModelList = new ArrayList<>();
+ for (Map.Entry entry : modelMap.entrySet()) {
+ ModelModel arisModel = entry.getValue();
+ if ("MT_EEPC".equals(arisModel.getType())) {
+ arisEpcModelList.add(arisModel);
+ }
+ }
+ // 按照路径排序
+ arisEpcModelList.sort((a1, a2)-> {
+ return a1.getModelPath().compareTo(a2.getModelPath());
+ });
+
+ String arisRootPath = "\\伊利集团业务流程管理平台";
+ int totalArisCount = LogRealTimeCountCache.getCache().get(logId).getTotalCount();
+ for (int i = 0; i < arisEpcModelList.size(); i++) {
+ ModelModel arisModel = arisEpcModelList.get(i);
+ String arisPath = arisRootPath + arisModel.getModelPath();
+ int importingCount = i + 1;// 当前是导入的第几个
+ LogRealTimeCountCache.getCache().get(logId).setImportingCount(importingCount);// 当前记录缓存
+ // 当前正在导入的流程全部日志记录,方便对照
+ LogUtil.appendLog("-----------------【" + importingCount + "/" + totalArisCount + "】-----------------", simpleLogFile, fullLogFile, warnLogFile);
+
+ // 校验Aris是否空模型
+ List objOccModels = modelObjOccMap.get(arisModel.getId());
+ if (objOccModels == null || objOccModels.size() == 0) {
+ // 空模型当作警告处理,全部记录
+ LogUtil.appendLog(Constant.LOG_WARNING + "Aris流程" + "【" + arisModel.getName() + "】内容为空,导入忽略", simpleLogFile, fullLogFile, warnLogFile);
+ LogUtil.appendLog(Constant.LOG_DESC + "该流程所属路径:" + arisPath);
+ LogRealTimeCountCache.getCache().get(logId).setArisBlankCount(LogRealTimeCountCache.getCache().get(logId).getArisBlankCount() + 1);
+ continue;
+ }
+
+ // PAL流程与Aris流程进行匹配
+ boolean flag = false;
+ PALRepositoryModel palModel = null;
+ for (Map.Entry entry : palArisPropValMap.entrySet()) {
+ if (arisPath.equals(entry.getValue())) {
+ String palId = entry.getKey();
+ PALRepositoryModel plModel = PALRepositoryCache.getCache().get(palId);
+ if (arisModel.getName().trim().equals(plModel.getName().trim())) {
+ palModel = plModel;
+ flag = true;
+ // 匹配成功不记录到警告日志中
+ LogUtil.appendLog(Constant.LOG_SUCCESS + "Aris流程" + "【" + arisModel.getName() + "】与PAL流程" + "【" + palModel.getName() + "】", simpleLogFile, fullLogFile);
+ LogUtil.appendLog(Constant.LOG_DESC + "Aris流程所属路径:" + arisPath);
+ LogUtil.appendLog(Constant.LOG_DESC + "PAL流程所属路径:" + ProcessUtil.getRepositoryPath(palModel.getId()));
+ break;
+ }
+ }
+ }
+ // 未匹配成功
+ if (!flag) {
+ LogUtil.appendLog(Constant.LOG_WARNING + "Aris流程" + "【" + arisModel.getName() + "】未匹配到PAL流程", simpleLogFile, fullLogFile, warnLogFile);
+ LogUtil.appendLog(Constant.LOG_DESC + "Aris流程所属路径:" + arisPath, simpleLogFile, fullLogFile, warnLogFile);
+ LogRealTimeCountCache.getCache().get(logId).setMatchFieldCount(LogRealTimeCountCache.getCache().get(logId).getMatchFieldCount() + 1);
+ continue;
+ }
+ // 判断计划导入到的PAL流程是否已经存在数据
+ String plId = palModel.getId();
+ // 模型是否可导入
+ BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(plId, 0);
+ if (defineModel == null) {
+ defineModel = CoeDesignerUtil.createModel(plId, 0);
+ defineModel.setCreateHistory(false);
+ }
+ String timestamp = new SimpleDateFormat(CoeDesignerConstant.DATE_TIME_STYLE_YYYY_MM_DD_HH_MM_SS).format(new Date());
+ defineModel.setUpdateTime(timestamp);
+ String define = defineModel.getDefinition();
+ JSONObject definition = JSONObject.parseObject(define);
+ JSONObject elements = definition.getJSONObject("elements");
+ if (elements != null && !elements.isEmpty()) {
+ LogUtil.appendLog(Constant.LOG_WARNING + "匹配到的PAL流程模型已存在数据,不允许导入,忽略", simpleLogFile, fullLogFile, warnLogFile);
+ LogRealTimeCountCache.getCache().get(logId).setPalExistsCount(LogRealTimeCountCache.getCache().get(logId).getPalExistsCount() + 1);
+ continue;
+ }
+
+ LogUtil.appendLog(Constant.LOG_START + "导入Aris流程" + "【" + arisModel.getName() + "】", simpleLogFile, fullLogFile, warnLogFile);
+
+ Map arisFunIdRelationPalRoleMap = new HashMap<>();// aris功能模型与aris角色模型的id映射,key:aris fun shape id,value:pal role id
+ Map palRoleIdRelationNameMap = new HashMap<>();// key pal role shape id ,value:pal role shape text
+ // 创建角色模型和角色元素,并且获取aris角色与pal角色映射关系
+ String roleMdoelId = createRoleModelAndElements(coeProcessLevel, rolefolderId, wsId, palModel, arisModel, modelObjOccMap, objDefMap, objOccMap, cxnOccMap, objDefLinkerMap, arisFunIdRelationPalRoleMap, methodAttrsMap, palRoleIdRelationNameMap);
+
+ // 存储当前模型下ARIS图形ID与PAL图形ID映射关系
+ Map idRelationMap = new HashMap<>();
+
+ Map palShapeIdRelationArisOccIdMap = new HashMap<>();
+ // 创建形状和连线
+ JSONObject newElements = createShapeElement(wsId, idRelationMap, palModel, arisModel, modelObjOccMap, objDefMap, objOccMap, cxnOccMap, palShapeIdRelationArisOccIdMap);
+
+ // 处理输入输出活动属性
+ this.handleShapeInputOutAttr(palModel, newElements);
+
+ // 处理角色属性与流程相应的活动节点关联
+ this.handleProcessAttrRoleRelation(wsId, palModel.getId(), arisFunIdRelationPalRoleMap, palShapeIdRelationArisOccIdMap, newElements, arisModel, modelObjOccMap, objDefMap, roleMdoelId, palRoleIdRelationNameMap);
+
+ // 处理流程关联属性IT系统
+ this.handleProcessAttrItSystemRelation(wsId, idRelationMap, palModel.getId(), newElements, arisModel, modelObjOccMap, objDefMap, objDefLinkerMap, itShapeMap);
+
+ // 前后置流程处理
+ this.handleProcessAttrLeadOrRearProcess(wsId, idRelationMap, palModel.getId(), newElements, arisModel, modelObjOccMap, objDefMap);
+
+ // 增加其他默认的属性,值默认为空 by孙连辉 20220626
+ this.handleShapeDefaultAttr(wsId, palModel, newElements, methodAttrsMap);
+
+ definition.put("elements", newElements);
+ // 设置画布大小
+ setDiagramHeightWidth(definition, newElements);
+ defineModel.setDefinition(definition.toString());
+ // 保存文件
+ CoeDesignerAPIManager.getInstance().storeDefinition(defineModel);// dao操作
+
+ // 记录结束日志
+ endTime = System.currentTimeMillis();
+ Timestamp endDate = new Timestamp(System.currentTimeMillis());
+
+
+ LogRealTimeCountCache.getCache().get(logId).setSuccessCount(LogRealTimeCountCache.getCache().get(logId).getSuccessCount() + 1);
+
+
+ LogUtil.appendLog(Constant.LOG_END + "保存PAL流程【" + palModel.getName() + "】的形状和连线", simpleLogFile, fullLogFile);
+ LogUtil.appendLog(Constant.LOG_END + "导入Aris流程" + "【" + arisModel.getName() + "】", simpleLogFile, fullLogFile, warnLogFile);
+ }
+ Timestamp endDate = new Timestamp(System.currentTimeMillis());
+ LogRealTimeCountModel model = LogRealTimeCountCache.getCache().get(logId);
+ String takeTimeText = takeTime(endTime, startTime);
+ String resultMsg = "导入完成,总耗时【" + takeTimeText + "】,ArisXML流程总共【" + model.getTotalCount() + "】,导入成功【" + model.getSuccessCount() + "】条,导入失败【" + (model.getTotalCount() - model.getSuccessCount())
+ + "】条(PAL已存在的数据【" + model.getPalExistsCount() + "】条),Aris流程为空模型的数据【" + model.getArisBlankCount() + "】条,Aris与PAL匹配失败的数据【" + model.getMatchFieldCount() + "】条)";
+ LogUtil.appendLog(Constant.LOG_END + "," + resultMsg, simpleLogFile, fullLogFile, warnLogFile);
+ LogUtil.appendLog("Aris XML流程导入 End " + UtilDate.datetimeFormat(endDate), simpleLogFile, fullLogFile, warnLogFile);
+ LogUtil.appendLog("--------------------------------", simpleLogFile, fullLogFile, warnLogFile);
+ } catch (Exception e) {
+ e.printStackTrace();
+ // 记录结束日志
+ endTime = System.currentTimeMillis();
+ Timestamp endDate = new Timestamp(System.currentTimeMillis());
+ LogRealTimeCountModel model = LogRealTimeCountCache.getCache().get(logId);
+ String takeTimeText = takeTime(endTime, startTime);
+ String resultMsg = "导入失败,报错信息:" + e.getMessage() + ",总耗时【" + takeTimeText + "】,导入成功【" + model.getSuccessCount() + "】条,导入失败【" + (model.getTotalCount() - model.getSuccessCount())
+ + "】条(PAL已存在的数据【" + model.getPalExistsCount() + "】条),Aris流程为空模型的数据【" + model.getArisBlankCount() + "】条,Aris与PAL匹配失败的数据【" + model.getMatchFieldCount() + "】条)";
+ LogUtil.updateLog(logId, endDate, Constant.LOG_RESULT_StATUS_ERROR, resultMsg);
+ LogUtil.appendLog(Constant.LOG_ERROR + "," + resultMsg, simpleLogFile, fullLogFile, warnLogFile);
+ }
+ }
+
+ /**
+ * 计算使用时间
+ * @param endTime
+ * @param startTime
+ * @return
+ */
+ private String takeTime(long endTime, long startTime) {
+ long time = endTime - startTime;
+ String timeMsg = "";
+ if (time > 1000 * 60) {
+ timeMsg = "【" + (time / 1000 / 60) + "】分钟";
+ } else if (time > 1000) {
+ timeMsg = "【" + (time / 1000) + "】秒";
+ } else {
+ timeMsg = "【" + time + "】毫秒";
+ }
+ return timeMsg;
+ }
+
+
+ /**
+ * 获取所有epc模型,key:epc-id,value:arisUrl
+ * @return
+ */
+ private Map getPalRepositoryXmlPathMap(String wsId) {
+ Map propValMap = new HashMap<>();
+ Iterator iterator = PALRepositoryCache.getByWsId(wsId);
+ List list = new ArrayList<>();
+
+ while (iterator.hasNext()) {
+ // 无多版本情况,不考虑
+ PALRepositoryModel model = iterator.next();
+ if (Constant.PROCESS_EPC.equals(model.getMethodId())) {
+ list.add(model);
+ }
+ }
+ PALRepositoryPropertyDao dao = new PALRepositoryPropertyDao();
+ List propertyModels = dao.queryByWsId(wsId);
+ propertyModels = propertyModels.stream().filter(item -> Constant.METHOD_ARIS_URL.equals(item.getPropertyId())).collect(Collectors.toList());
+ Map map = new HashMap<>();
+ for (PALRepositoryPropertyModel prop : propertyModels) {
+ map.put(prop.getPlId(), prop.getPropertyValue());
+ }
+ for (PALRepositoryModel model : list) {
+ if (map.containsKey(model.getId())) {
+ propValMap.put(model.getId(), map.get(model.getId()));
+ }
+ }
+ return propValMap;
+ }
+
+ /**
+ * 校验和创建角色模型文件夹
+ * @param coeProcessLevel
+ * @param wsId
+ * @return 已经存在的或新创建的角色模型ID
+ */
+ private String checkAndCreatePalRoleFolderModel(PALRepository coeProcessLevel, String wsId) {
+ // 组织下创建【角色模型】文件夹
+ List defaultModels = PALRepositoryQueryAPIManager.getInstance().getPalRepositoryModelsByWsIdAndMethodId(wsId, "org");
+ defaultModels = defaultModels.stream()
+ .filter(model -> "default".equals(model.getMethodId()))
+ .filter(model -> Constant.DEFAULT_FOLDER_NAME.equals(model.getName())).collect(Collectors.toList());
+ if (defaultModels.size() == 0) {
+ String id = UUIDGener.getUUID();
+
+ int orderIndex = coeProcessLevel.getChildrenMaxOrderIndexByPidAndWsId("org", wsId) + 1;
+ Timestamp nowTime = new Timestamp(System.currentTimeMillis());
+ PALRepositoryModelImpl defaultModel = CoeProcessLevelUtil.createPALRepositoryModel(id, UUIDGener.getUUID(), wsId, Constant.DEFAULT_FOLDER_NAME, "", orderIndex, "org", "org", true, 1,
+ id, false, "default", "0", 1, null, null, uc.getUID(), uc.getUID(), nowTime, null, null, null, null,
+ null, null, null, null, null, -1);
+ coeProcessLevel.insert(defaultModel);
+ defaultModels.add(defaultModel);
+ LogUtil.appendLog(Constant.LOG_SUCCESS + "角色模型文件夹创建", simpleLogFile, fullLogFile);
+ return defaultModel.getId();
+ } else {
+ LogUtil.appendLog(Constant.LOG_WARNING + "角色模型文件夹已存在,不再重复创建", simpleLogFile, fullLogFile, warnLogFile);
+ return defaultModels.get(0).getId();
+ }
+ }
+
+ /**
+ * 自定义属性
+ * @param wsId
+ * @param palModel
+ * @param elements
+ * @param methodAttrsMap
+ */
+ private void handleShapeDefaultAttr(String wsId, PALRepositoryModel palModel, JSONObject elements, Map> methodAttrsMap) {
+ LogUtil.appendLog(Constant.LOG_START + "PAL" + I18nRes.findValue(CoEConstant.APP_ID, palModel.getMethodId()) + "【" + palModel.getName() + "】中形状属性按照属性配置进行属性完善", simpleLogFile, fullLogFile);
+ for (String key : elements.keySet()) {
+ JSONObject shape = elements.getJSONObject(key);
+ if ("linker".equals(shape.getString("name"))) {
+ continue;
+ }
+ String shapeMehtodId = shape.getString("category").replace("_", ".");
+ String shapeName = shape.getString("name");
+
+ if (methodAttrsMap.containsKey(palModel.getMethodId()) && methodAttrsMap.containsKey(shapeName)) {
+ } else {
+ if (!methodAttrsMap.containsKey(palModel.getMethodId())) {
+ methodAttrsMap.put(palModel.getMethodId(), new HashMap<>());
+ }
+ JSONObject attrs = ShapeUtil.getProcessUseShapeMethodAttrByShapeName(palModel.getWsId(), shapeMehtodId, palModel.getMethodId(), shapeName);
+ if (attrs != null) {
+ methodAttrsMap.get(palModel.getMethodId()).put(shapeName, attrs);
+ }
+ }
+ JSONObject attrs = methodAttrsMap.get(palModel.getMethodId()).get(shapeName);// 最终属性内容
+ attrs = JSONObject.parseObject(attrs.toString());// 复制
+ JSONArray dataAttributes = shape.getJSONArray("dataAttributes");
+ if (!dataAttributes.isEmpty() && dataAttributes.size() > 0) {
+ for (Object attribute : dataAttributes) {
+ JSONObject obj = (JSONObject) attribute;
+ if (obj.containsKey("attributesJsonArray")) {
+ JSONArray attributesJsonArray = obj.getJSONArray("attributesJsonArray");
+ Set attrIds = new HashSet<>();
+ for (int i = 0; i < attributesJsonArray.size(); i++) {
+ if (attributesJsonArray.getJSONObject(i).containsKey("id")) {
+ attrIds.add(attributesJsonArray.getJSONObject(i).getString("id"));
+ }
+ }
+ for (String attrId : attrs.keySet()) {
+ if (!attrIds.contains(attrId)) {
+ JSONObject eleAttrObj = getDefaultAttrObj(attrs.getJSONObject(attrId));
+ LogUtil.appendLog(Constant.LOG_END + "PAL" + I18nRes.findValue(CoEConstant.APP_ID, palModel.getMethodId()) + "【" + palModel.getName() + "】中形状【" + shape.getString("text") + "】完善【" + eleAttrObj.getString("name") + "】属性配置", simpleLogFile, fullLogFile);
+ attributesJsonArray.add(eleAttrObj);
+ }
+ }
+ }
+ }
+ }
+ }
+ LogUtil.appendLog(Constant.LOG_END + "PAL" + I18nRes.findValue(CoEConstant.APP_ID, palModel.getMethodId()) + "【" + palModel.getName() + "】中形状属性按照属性配置进行属性完善", simpleLogFile, fullLogFile);
+ }
+
+ /**
+ * 创建PAL形状
+ *
+ * @param palModel
+ * @param arisModel
+ * @param modelObjOccMap
+ * @param objDefMap
+ * @return
+ */
+ private JSONObject createShapeElement(String wsId, Map idRelationMap, PALRepositoryModel palModel, ModelModel arisModel, Map> modelObjOccMap, Map objDefMap, Map objOccMap, Map> cxnOccMap, Map palShapeIdRelationArisOccIdMap) {
+ LogUtil.appendLog(Constant.LOG_START + "创建PAL流程【" + arisModel.getName() + "】相关形状", simpleLogFile, fullLogFile);
+ // aris中该模型所有形状
+ List objOccModels = modelObjOccMap.get(arisModel.getId());
+ int zindex = 1;
+ JSONObject elements = new JSONObject();
+ Map objDefMappingMap = ModelMappingAPIManager.getInstance().getObjDefMappingMap();
+ for (ObjOccModel objOccModel : objOccModels) {
+ ObjDefModel objDefModel = objDefMap.get(objOccModel.getDefId());// 形状定义
+ if (objDefMappingMap.containsKey(objDefModel.getTypeNum() + "-" + objOccModel.getSymbolNum())) {
+ ObjDefMappingModel objDefMappingModel = objDefMappingMap.get(objDefModel.getTypeNum() + "-" + objOccModel.getSymbolNum());// Aris与PAL形状映射关系
+ String shapeMethodId = objDefMappingModel.getShapeMethod();
+ String shapeType = objDefMappingModel.getShapeType();
+ // 伊利导入形状定制
+ String symbolNum = objDefMappingModel.getSymbolNum();
+ String typeNum = objDefMappingModel.getTypeNum();
+ String arisShapeName = objDefMap.get(objOccModel.getDefId()).getName();
+ String method = shapeMethodId;
+ String shapeName = shapeType;
+ // fun
+// if ("OT_FUNC".equals(symbolNum) && "ST_FUNC".equals(typeNum)) {
+ if ("ST_FUNC".equals(symbolNum) && "OT_FUNC".equals(typeNum)) {
+ if (arisShapeName.contains("审批") || arisShapeName.contains("审核")) {
+ shapeName = "method_service_node";
+ } else {
+ shapeName = "method_service_node4";
+ }
+// } else if ("OT_FUNC".equals(symbolNum) && "ST_SYS_FUNC_ACT".equals(typeNum)) {// sys_fun
+ } else if ("ST_SYS_FUNC_ACT".equals(symbolNum) && "OT_FUNC".equals(typeNum)) {// sys_fun
+ if (arisShapeName.contains("审批") || arisShapeName.contains("审核")) {
+ shapeName = "method_approval_node";
+ } else {
+ shapeName = "method_approval_node3";
+ }
+ }
+
+ JSONObject shape = ShapeUtil.getProcessShapeDefinitionByName(shapeMethodId, shapeName);
+ // 定义位置、大小
+ if (shape == null) {
+ // pal形状不存在,记录日志
+ LogUtil.appendLog(Constant.LOG_WARNING + "Aris流程" + "【 " + arisModel.getName() + " 】的形状【 " + objDefModel.getName() + " 】形状类型在PAL中缺失,忽略导入该形状", simpleLogFile, fullLogFile, warnLogFile);
+ continue;
+ }
+ String shapeId = UUIDGener.getObjectId();
+ palShapeIdRelationArisOccIdMap.put(shapeId, objOccModel.getId());
+ idRelationMap.put(objOccModel.getId(), shapeId);// 记录形状aris形状id与pal形状id
+ shape.put("id", shapeId);
+ // 处理当前图形节点的关联属性【编号】问题
+ if (objDefModel.getAttrData().containsKey("AT_PROC_CODE")) {
+ List attributeModels = CoeDesignerShapeAPIManager.getInstance().getValidAttributeModels(wsId, objDefMappingModel.getShapeMethod(), shapeName, objDefMappingModel.getShapeMethod());
+ attributeModels = attributeModels.stream().filter(item -> Constant.METHOD_NUMBER.equals(item.getKey())).collect(Collectors.toList());
+ PALMethodAttributeModel attributeModel = attributeModels.get(0);
+ JSONObject attrNumberObj = new JSONObject();
+ attrNumberObj.put("value", objDefModel.getAttrData().getString("AT_PROC_CODE"));
+ attrNumberObj.put("key", attributeModel.getKey());
+ attrNumberObj.put("isRequired", attributeModel.getIsRequired());
+ attrNumberObj.put("ref", attributeModel.getRef());
+ attrNumberObj.put("readonly", attributeModel.getReadonly());
+ attrNumberObj.put("scope", attributeModel.getScope());
+ attrNumberObj.put("name", attributeModel.getTitle());
+ attrNumberObj.put("id", attributeModel.getKey());
+ attrNumberObj.put("textarea", attributeModel.getType());
+ attrNumberObj.put("groupPath", attributeModel.getGroupPath());
+ attrNumberObj.put("desc", attributeModel.getDesc());
+
+ JSONArray dataAttributes = shape.getJSONArray("dataAttributes");
+ if (!dataAttributes.isEmpty() && dataAttributes.size() > 0) {
+ for (Object attribute : dataAttributes) {
+ JSONObject obj = (JSONObject) attribute;
+ if (obj.containsKey("attributesJsonArray")) {
+ obj.getJSONArray("attributesJsonArray").add(attrNumberObj);
+ break;
+ }
+ }
+ }
+ LogUtil.appendLog(Constant.LOG_END + "创建PAL流程【" + palModel.getName() + "】的形状【" + shape.getString("text") + "】的编号属性内容【" + objDefModel.getAttrData().getString("AT_PROC_CODE") + "】", fullLogFile);
+ }
+
+// 处理活动节点描述 --by shang
+ if (objDefModel.getAttrData().containsKey("AT_DESC")) {
+ List attributeModels = CoeDesignerShapeAPIManager.getInstance().getValidAttributeModels(wsId, objDefMappingModel.getShapeMethod(), "process", objDefMappingModel.getShapeMethod());
+ attributeModels = attributeModels.stream().filter(item -> Constant.METHOD_DESC.equals(item.getKey())).collect(Collectors.toList());
+ PALMethodAttributeModel attributeModel = attributeModels.get(0);
+ JSONObject attrDescObj = new JSONObject();
+ attrDescObj.put("value", objDefModel.getAttrData().getString("AT_DESC"));
+ attrDescObj.put("key", attributeModel.getKey());
+ attrDescObj.put("isRequired", attributeModel.getIsRequired());
+ attrDescObj.put("ref", attributeModel.getRef());
+ attrDescObj.put("readonly", attributeModel.getReadonly());
+ attrDescObj.put("scope", attributeModel.getScope());
+ attrDescObj.put("name", attributeModel.getTitle());
+ attrDescObj.put("id", attributeModel.getKey());
+ attrDescObj.put("textarea", attributeModel.getType());
+ attrDescObj.put("groupPath", attributeModel.getGroupPath());
+ attrDescObj.put("desc", attributeModel.getDesc());
+
+ JSONArray dataAttributes = shape.getJSONArray("dataAttributes");
+ if (!dataAttributes.isEmpty() && dataAttributes.size() > 0) {
+ for (Object attribute : dataAttributes) {
+ JSONObject obj = (JSONObject) attribute;
+ if (obj.containsKey("attributesJsonArray")) {
+ List usedAttributeModels = CoeDesignerShapeAPIManager.getInstance().getValidAndUseAttributeModels(wsId, objDefMappingModel.getShapeMethod(), shapeName, objDefMappingModel.getShapeMethod());
+ usedAttributeModels.forEach(item -> {
+ attrDescObj.put("id", item.getKey());
+ attrDescObj.put("value","");
+ });
+ obj.getJSONArray("attributesJsonArray").add(attrDescObj);
+
+ break;
+ }
+ }
+ }
+ LogUtil.appendLog(Constant.LOG_START + "创建PAL流程【" + palModel.getName() + "】的形状【" + shape.getString("text") + "】的描述属性内容【" + objDefModel.getAttrData().getString("AT_DESC") + "】", fullLogFile);
+
+ }
+
+ if (shape.containsKey("attribute") && shape.getJSONObject("attribute").containsKey("editable") && !shape.getJSONObject("attribute").getBooleanValue("editable")) {// 不可编辑名称
+
+ } else {// 重命名名称
+ String name = objDefModel.getName();// 形状名称
+ shape.put("text", name);
+ }
+
+ JSONObject props = shape.getJSONObject("props");// 位置大小
+ props.put("zindex", zindex++);
+ props.put("x", objOccModel.getX());
+ props.put("y", objOccModel.getY());
+ props.put("w", objOccModel.getW());
+ props.put("h", objOccModel.getH());
+ elements.put(shapeId, shape);
+ LogUtil.appendLog(Constant.LOG_END + "创建PAL流程" + "【 " + palModel.getName() + " 】的形状【 " + shape.getString("text") + " 】", fullLogFile);
+ } else {
+ // pal缺少对应的形状
+ LogUtil.appendLog(Constant.LOG_WARNING + "Aris流程" + "【 " + arisModel.getName() + " 】的形状【" + objDefModel.getName() + "】在PAL中缺失,忽略导入该形状", simpleLogFile, fullLogFile, warnLogFile);
+ }
+ }
+ // 形状连线处理
+ for (ObjOccModel occ : objOccModels) {
+ if (cxnOccMap.containsKey(occ.getId())) {
+ List cxnOccModels = cxnOccMap.get(occ.getId());
+ for (CxnOccModel cxn : cxnOccModels) {
+ if (idRelationMap.containsKey(cxn.getId()) && idRelationMap.containsKey(cxn.getToId())) {
+ List positionModels = cxn.getPositionList();
+ JSONObject linkerObj = ModelMappingAPIManager.getInstance().getLinkerDef();
+ String linkerId = UUIDGener.getObjectId();
+ linkerObj.put("id", linkerId);
+ JSONObject props = linkerObj.getJSONObject("props");
+ props.put("zindex", zindex++);// 层次
+ linkerObj.put("props", props);
+ linkerObj.put("points", getLinkerPoints(positionModels));
+ JSONObject from = linkerObj.getJSONObject("from");
+ from.put("id", idRelationMap.get(cxn.getId()));
+ from.put("angle", getLinkerAngle(positionModels, "from"));
+ from.put("x", positionModels.get(0).getX());
+ from.put("y", positionModels.get(0).getY());
+ linkerObj.put("from", from);
+ JSONObject to = linkerObj.getJSONObject("to");
+ to.put("id", idRelationMap.get(cxn.getToId()));
+ to.put("angle", getLinkerAngle(positionModels, "to"));
+ to.put("x", positionModels.get(positionModels.size() - 1).getX());
+ to.put("y", positionModels.get(positionModels.size() - 1).getY());
+ linkerObj.put("to", to);
+ elements.put(linkerId, linkerObj);
+ String fromName = UtilString.isEmpty(elements.getJSONObject(from.getString("id")).getString("text")) ? elements.getJSONObject(from.getString("id")).getString("title") : elements.getJSONObject(from.getString("id")).getString("text");
+ String toName = UtilString.isEmpty(elements.getJSONObject(to.getString("id")).getString("text")) ? elements.getJSONObject(to.getString("id")).getString("title") : elements.getJSONObject(to.getString("id")).getString("text");
+
+ LogUtil.appendLog(Constant.LOG_END + "创建PAL流程" + "【 " + arisModel.getName() + " 】的形状连线,从【 " + fromName + " 】到【 " + toName + " 】", fullLogFile);
+ } else {
+ // 不包含的连线
+ }
+ }
+ }
+ }
+ LogUtil.appendLog(Constant.LOG_END + "创建PAL流程【" + arisModel.getName() + "】相关形状/连线", simpleLogFile, fullLogFile);
+ return elements;
+ }
+
+ /**
+ * 在现有输出的图形结构上转化输入 输出活动属性,并将图上输入输出及连线删除
+ */
+ private void handleShapeInputOutAttr(PALRepositoryModel palModel, JSONObject elements) {
+ LogUtil.appendLog(Constant.LOG_START + "创建PAL流程【" + palModel.getName() + "】相关形状的输入输出属性", simpleLogFile, fullLogFile);
+ // 存放待删除图形的KEY
+ List removeKey = new ArrayList<>();
+
+ Map> nextShapeMap = new HashMap<>();// 记录当前形状的下一个(多个)形状
+ Map> prevShapeMap = new HashMap<>();// 记录当前形状的上一个(多个)形状
+ for (String key : elements.keySet()) {
+ JSONObject shapeObj = elements.getJSONObject(key);
+ if ("linker".equals(shapeObj.getString("name"))) {
+ // 输入
+ String shapeId = shapeObj.getString("id");
+ // 查找入线
+ String fromId = shapeObj.getJSONObject("from").getString("id");
+ String toId = shapeObj.getJSONObject("to").getString("id");
+ // 记录from->to Map
+ if (!nextShapeMap.containsKey(fromId)) {
+ nextShapeMap.put(fromId, new HashSet<>());
+ }
+ nextShapeMap.get(fromId).add(toId);
+
+ if (!prevShapeMap.containsKey(toId)) {
+ prevShapeMap.put(toId, new HashSet<>());
+ }
+ prevShapeMap.get(toId).add(fromId);
+ }
+ }
+
+ Map> shapeInputMap = new HashMap<>();// 记录形状的所有输出
+ Map> shapeOutMap = new HashMap<>();// 记录形状的所有输入
+ for (String key : elements.keySet()) {
+ JSONObject shapeObj = elements.getJSONObject(key);
+ if (!"linker".equals(shapeObj.getString("name"))) {
+ // 输入
+ String shapeId = shapeObj.getString("id");
+ // 查找入线(输入)
+ if (prevShapeMap.containsKey(shapeId)) {
+ for (Map.Entry> entry : prevShapeMap.entrySet()) {
+ if (key.equals(entry.getKey())) {
+ Set prevShapeIds = entry.getValue();
+ for (String prevShapeId : prevShapeIds) {
+ JSONObject prevShape = elements.getJSONObject(prevShapeId);
+ if ("document".equals(prevShape.getString("name"))) {
+ if (!shapeInputMap.containsKey(shapeId)) {
+ shapeInputMap.put(shapeId, new HashSet<>());
+ }
+ shapeInputMap.get(shapeId).add(prevShape.getString("text"));
+ }
+ }
+ }
+ }
+ }
+ // 查找出线
+ if (nextShapeMap.containsKey(shapeId)) {
+ for (Map.Entry> entry : nextShapeMap.entrySet()) {
+ if (key.equals(entry.getKey())) {
+ Set nextShapeIds = entry.getValue();
+ for (String nextShapeId : nextShapeIds) {
+ JSONObject nextShape = elements.getJSONObject(nextShapeId);
+ if ("document".equals(nextShape.getString("name"))) {
+ if (!shapeOutMap.containsKey(shapeId)) {
+ shapeOutMap.put(shapeId, new HashSet<>());
+ }
+ shapeOutMap.get(shapeId).add(nextShape.getString("text"));
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+ for (String key : elements.keySet()) {
+ JSONObject shapeObj = elements.getJSONObject(key);
+ if ("linker".equals(shapeObj.getString("name"))) {
+ JSONObject from = elements.getJSONObject(shapeObj.getJSONObject("from").getString("id"));
+ if ("document".equals(from.getString("name"))) {
+ removeKey.add(key);
+ removeKey.add(from.getString("id"));
+ }
+ JSONObject to = elements.getJSONObject(shapeObj.getJSONObject("to").getString("id"));
+ if ("document".equals(to.getString("name"))) {
+ removeKey.add(key);
+ removeKey.add(to.getString("id"));
+ }
+ }
+ }
+ // 删除画布上的输入输出和其连线
+ removeKey.stream().forEach(key -> elements.remove(key));
+ LogUtil.appendLog(Constant.LOG_END + "删除PAL流程【" + palModel.getName() + "】相关输入输出形状和其连线", simpleLogFile, fullLogFile);
+ Map attrMap = new HashMap<>();
+ JSONObject attrs1 = ShapeUtil.getProcessUseShapeMethodAttrByShapeName(palModel.getWsId(), palModel.getMethodId(), palModel.getMethodId(), "method_service_node");
+ attrMap.put("method_service_node", attrs1);
+ JSONObject attrs2 = ShapeUtil.getProcessUseShapeMethodAttrByShapeName(palModel.getWsId(), palModel.getMethodId(), palModel.getMethodId(), "method_service_node4");
+ attrMap.put("method_service_node4", attrs2);
+ JSONObject attrs3 = ShapeUtil.getProcessUseShapeMethodAttrByShapeName(palModel.getWsId(), palModel.getMethodId(), palModel.getMethodId(), "method_approval_node");
+ attrMap.put("method_approval_node", attrs3);
+ JSONObject attrs4 = ShapeUtil.getProcessUseShapeMethodAttrByShapeName(palModel.getWsId(), palModel.getMethodId(), palModel.getMethodId(), "method_approval_node3");
+ attrMap.put("method_approval_node3", attrs4);
+
+ for (String key : elements.keySet()) {
+ JSONObject shapeObj = elements.getJSONObject(key);
+ if (!"linker".equals(shapeObj.getString("name"))) {
+ if (attrMap.containsKey(shapeObj.getString("name"))) {
+ JSONObject attrs = attrMap.get(shapeObj.getString("name"));
+ if (shapeInputMap.containsKey(key)) {// 有输入属性
+ // 输入属性
+ if (attrs != null && attrs.size() > 0 && attrs.containsKey(Constant.METHOD_INPUT)) {
+ JSONObject attrObj = JSONObject.parseObject(attrs.getJSONObject(Constant.METHOD_INPUT).toString());
+ List contentList = new ArrayList<>(shapeInputMap.get(key));
+ Collections.sort(contentList);
+ attrObj.put("value", StringUtils.join(contentList, ","));
+ JSONArray dataAttributes = shapeObj.getJSONArray("dataAttributes");
+ if (!dataAttributes.isEmpty() && dataAttributes.size() > 0) {
+ for (Object attribute : dataAttributes) {
+ JSONObject obj = (JSONObject) attribute;
+ if (obj.containsKey("attributesJsonArray")) {
+ JSONArray attributesJsonArray = obj.getJSONArray("attributesJsonArray");
+ attributesJsonArray.add(attrObj);
+ LogUtil.appendLog(Constant.LOG_END + "PAL流程【" + palModel.getName() + "】形状【" + shapeObj.getString("text") + "】的输入属性内容是【" + attrObj.getString("value") + "】", simpleLogFile, fullLogFile);
+ }
+ }
+ }
+ } else {
+ LogUtil.appendLog(Constant.LOG_END + "PAL流程【" + palModel.getName() + "】形状【" + shapeObj.getString("text") + "】没有配置输入属性,忽略输入属性赋值", simpleLogFile, fullLogFile, warnLogFile);
+ }
+ }
+ if (shapeOutMap.containsKey(key)) {// 有输出属性
+ // 输出属性
+ if (attrs != null && attrs.size() > 0 && attrs.containsKey(Constant.METHOD_OUTPUT)) {
+ JSONObject attrObj = JSONObject.parseObject(attrs.getJSONObject(Constant.METHOD_OUTPUT).toString());
+ List contentList = new ArrayList<>(shapeOutMap.get(key));
+ Collections.sort(contentList);
+ attrObj.put("value", StringUtils.join(contentList, ","));
+ JSONArray dataAttributes = shapeObj.getJSONArray("dataAttributes");
+ if (!dataAttributes.isEmpty() && dataAttributes.size() > 0) {
+ for (Object attribute : dataAttributes) {
+ JSONObject obj = (JSONObject) attribute;
+ if (obj.containsKey("attributesJsonArray")) {
+ JSONArray attributesJsonArray = obj.getJSONArray("attributesJsonArray");
+ attributesJsonArray.add(attrObj);
+ LogUtil.appendLog(Constant.LOG_END + "PAL流程【" + palModel.getName() + "】形状【" + shapeObj.getString("text") + "】没有配置输出属性,忽略输出属性赋值", simpleLogFile, fullLogFile, warnLogFile);
+ }
+ }
+ }
+ } else {
+ LogUtil.appendLog(Constant.LOG_END + "PAL流程【" + palModel.getName() + "】形状【" + shapeObj.getString("text") + "】没有配置输出属性,忽略输出属性赋值", simpleLogFile, fullLogFile, warnLogFile);
+ }
+ }
+
+ }
+ }
+ }
+ LogUtil.appendLog(Constant.LOG_END + "创建PAL流程【" + palModel.getName() + "】相关形状的输入输出属性", simpleLogFile, fullLogFile);
+ }
+
+ /**
+ * 处理流程属性前后置流程
+ *
+ * @param wsId
+ * @param idRelationMap
+ * @param repositoryModelId
+ * @param elements
+ * @param arisModel
+ * @param modelObjOccMap
+ * @param objDefMap
+ */
+ private void handleProcessAttrLeadOrRearProcess(String wsId, Map idRelationMap, String repositoryModelId, JSONObject elements, ModelModel arisModel,
+ Map> modelObjOccMap, Map objDefMap) {
+ LogUtil.appendLog(Constant.LOG_START + "PAL流程【" + arisModel.getName() + "】相关前置流程/后置流程进行处理关联", simpleLogFile, fullLogFile);
+ // 如果当前流程下无图形信息 直接返回
+ List objOccModels = modelObjOccMap.get(arisModel.getId());
+ // 获取ARIS图形定义与PAL图形定义关系
+ Map objDefMappingMap = ModelMappingAPIManager.getInstance().getObjDefMappingMap();
+ ObjDefMappingModel objDefMappingModel = objDefMappingMap.get("OT_FUNC-ST_PRCS_IF");
+ List attributeModels = PALRepositoryAPIManager.getInstance().getValidAttributeModels(wsId, objDefMappingModel.getShapeMethod());
+// List leadProcess = attributeModels.stream().filter(item -> "lead_process".equals(item.getKey())).collect(Collectors.toList());
+// --by shang
+ List leadProcess = attributeModels.stream().filter(item -> Constant.METHOD_PRE_PROCESS.equals(item.getKey())).collect(Collectors.toList());
+ PALMethodAttributeModel leadAttrModel = leadProcess.get(0);
+ List rearProcess = attributeModels.stream().filter(item -> Constant.METHOD_NEXT_PROCESS.equals(item.getKey())).collect(Collectors.toList());
+ PALMethodAttributeModel rearAttrModel = rearProcess.get(0);
+ // 存放待删除图形的KEY
+ List removeKey = new ArrayList<>();
+ for (ObjOccModel objOccModel : objOccModels) {
+ ObjDefModel objDefModel = objDefMap.get(objOccModel.getDefId());// 形状定义
+ // 根据ARIS图形定义信息判断当前模型下的所有形状里是否有系统形状
+ if (objDefModel.getTypeNum().equals(objDefMappingModel.getTypeNum()) && objDefModel.getSymbolNum().equals(objDefMappingModel.getSymbolNum())) {
+ // 如果有输入输出形状 取出关联的PAL模型ID
+ String shapeId = idRelationMap.get(objOccModel.getId());
+ JSONObject leadOrRearObj = elements.getJSONObject(shapeId);
+ for (String key : elements.keySet()) {
+ JSONObject tempShapeObj = elements.getJSONObject(key);
+ if ("linker".equals(tempShapeObj.getString("name"))) {
+ if (tempShapeObj.getJSONObject("from").getString("id").equals(shapeId)) {
+ // lead_process
+ PALRepositoryPropertyDao propertyDao = new PALRepositoryPropertyDao();
+ PALRepositoryPropertyModel propertyModel = new PALRepositoryPropertyModel();
+ propertyModel.setId(UUIDGener.getUUID());
+ propertyModel.setPlId(repositoryModelId);
+ propertyModel.setPropertyId(leadAttrModel.getKey());
+ propertyModel.setPropertyName(leadAttrModel.getNewTitle());
+ JSONObject propValue = new JSONObject();
+ propValue.put("fileId", repositoryModelId);
+ propValue.put("shapeId", "");
+ propValue.put("shapeText", "");
+ propValue.put("attrId", leadAttrModel.getKey());
+ propValue.put("relationFileId", new JSONArray());
+ propValue.put("relationShapeId", "");
+ propValue.put("relationShapeText", "");
+ propValue.put("groupPath", leadAttrModel.getGroupPath());
+ List repositoryModels = PALRepositoryQueryAPIManager.getInstance().getPalRepositoryModelsByWsIdAndMethodId(wsId, "process.epc");
+ repositoryModels = repositoryModels.stream().filter(model -> leadOrRearObj.getString("text").equals(model.getName())).collect(Collectors.toList());
+ if (repositoryModels.size() > 0) {
+ propValue.getJSONArray("relationFileId").add(repositoryModels.get(0).getId());
+ }
+ propertyModel.setPropertyValue(propValue.toString());
+ propertyModel.setOrderIndex(0);
+ propertyDao.insert(propertyModel);
+ removeKey.add(key);
+ removeKey.add(shapeId);
+ LogUtil.appendLog(Constant.LOG_END + "PAL流程【" + arisModel.getName() + "】相关前置流程进行处理关联,前置属性内容【" + repositoryModels.get(0).getName() + "】", fullLogFile);
+ break;
+ } else if (tempShapeObj.getJSONObject("to").getString("id").equals(shapeId)) {
+ // rear_process
+ PALRepositoryPropertyDao propertyDao = new PALRepositoryPropertyDao();
+ PALRepositoryPropertyModel propertyModel = new PALRepositoryPropertyModel();
+ propertyModel.setId(UUIDGener.getUUID());
+ propertyModel.setPlId(repositoryModelId);
+ propertyModel.setPropertyId(rearAttrModel.getKey());
+ propertyModel.setPropertyName(rearAttrModel.getNewTitle());
+ JSONObject propValue = new JSONObject();
+ propValue.put("fileId", repositoryModelId);
+ propValue.put("shapeId", "");
+ propValue.put("shapeText", "");
+ propValue.put("attrId", rearAttrModel.getKey());
+ propValue.put("relationFileId", new JSONArray());
+ propValue.put("relationShapeId", "");
+ propValue.put("relationShapeText", "");
+ propValue.put("groupPath", "");
+ List repositoryModels = PALRepositoryQueryAPIManager.getInstance().getPalRepositoryModelsByWsIdAndMethodId(wsId, "process.epc");
+ repositoryModels = repositoryModels.stream().filter(model -> leadOrRearObj.getString("text").equals(model.getName())).collect(Collectors.toList());
+ if (repositoryModels.size() > 0) {
+ propValue.getJSONArray("relationFileId").add(repositoryModels.get(0).getId());
+ }
+ propertyModel.setPropertyValue(propValue.toString());
+ propertyModel.setOrderIndex(0);
+ propertyDao.insert(propertyModel);
+ removeKey.add(key);
+ removeKey.add(shapeId);
+ LogUtil.appendLog(Constant.LOG_END + "PAL流程【" + arisModel.getName() + "】相关后置流程进行处理关联,后置属性内容【" + repositoryModels.get(0).getName() + "】", fullLogFile);
+ break;
+ } else {
+ continue;
+ }
+ }
+ }
+ }
+ }
+ removeKey.stream().forEach(key -> elements.remove(key));
+ LogUtil.appendLog(Constant.LOG_END + "PAL流程【" + arisModel.getName() + "】相关前置流程/后置流程进行处理关联", simpleLogFile, fullLogFile);
+ }
+
+ /**
+ * 处理流程关联属性IT系统
+ * @param wsId
+ * @param idRelationMap
+ * @param repositoryModelId
+ * @param elements
+ * @param arisModel
+ * @param modelObjOccMap
+ * @param objDefMap
+ * @param objDefLinkerMap
+ * @param itShapeMap
+ */
+ private void handleProcessAttrItSystemRelation(String wsId, Map idRelationMap, String repositoryModelId, JSONObject elements, ModelModel arisModel,
+ Map> modelObjOccMap,
+ Map objDefMap, Map> objDefLinkerMap, Map itShapeMap) {
+ LogUtil.appendLog(Constant.LOG_START + "PAL流程【" + arisModel.getName() + "】相关信息系统与形状进行关联", simpleLogFile, fullLogFile);
+ // 获取ARIS图形定义与PAL图形定义关系
+ Map objDefMappingMap = ModelMappingAPIManager.getInstance().getObjDefMappingMap();
+ ObjDefMappingModel objDefMappingModel = objDefMappingMap.get("OT_APPL_SYS_TYPE-ST_APPL_SYS_TYPE");
+ // 获取当前ARIS模型下所有的图形信息
+ List objOccModels = modelObjOccMap.get(arisModel.getId());
+ Map> shapeRelationItMap = new HashMap<>();// 记录PAL形状关联的IT系统文本
+ for (ObjOccModel objOccModel: objOccModels) {
+ String objDefId = objOccModel.getDefId();
+ // 获取定义形状通过连线进行连接的所有定义形状
+ Set toObjDefIds = objDefLinkerMap.get(objDefId);
+ if (toObjDefIds == null || toObjDefIds.size() == 0) {
+ continue;
+ }
+ // 取出所有IT系统
+ Set shapeRelationItObjDefNames = new HashSet<>();// 记录当前形状的IT系统(s)
+ for (String toObjDefId: toObjDefIds) {
+ ObjDefModel objDefModel = objDefMap.get(toObjDefId);
+ if (objDefModel.getSymbolNum().equals(objDefMappingModel.getSymbolNum()) && objDefModel.getTypeNum().equals(objDefMappingModel.getTypeNum())) {
+ // 是IT系统
+ shapeRelationItObjDefNames.add(objDefModel.getName());
+ }
+ }
+ if (shapeRelationItObjDefNames.size() > 0) {
+ shapeRelationItMap.put(idRelationMap.get(objOccModel.getId()), shapeRelationItObjDefNames);
+ }
+ }
+ List relationList = new ArrayList<>();
+ for (Map.Entry> entry: shapeRelationItMap.entrySet()) {
+ String shapeId = entry.getKey();
+ Set itShapeNames = entry.getValue();
+ for (String itShapeName: itShapeNames) {
+ if (itShapeMap.containsKey(itShapeName)) {
+ DesignerShapeRelationModel m = new DesignerShapeRelationModel();
+ m.setId(UUIDGener.getUUID());
+ m.setFileId(repositoryModelId);
+ m.setShapeId(shapeId);
+ m.setShapeText(elements.getJSONObject(shapeId).getString("text"));
+ m.setRelationFileId(itShapeMap.get(itShapeName).getString("plId"));
+ m.setRelationShapeId(itShapeMap.get(itShapeName).getString("shapeId"));
+ m.setRelationShapeText(itShapeMap.get(itShapeName).getString("shapeName"));
+ m.setAttrId(Constant.METHOD_INFO_SYSTEM);
+ relationList.add(m);
+
+ } else {
+ LogUtil.appendLog(Constant.LOG_WARNING + "流程【" + arisModel.getName() + "】中的活动节点【" + elements.getJSONObject(shapeId).getString("text") + "】未找到IT系统【" + itShapeName + "】", simpleLogFile, fullLogFile, warnLogFile);
+ }
+ }
+ }
+ // 保存关联关系
+ if (relationList.size() > 0) {
+ DesignerShapeRelationDao relationDao = new DesignerShapeRelationDao();
+ relationList.stream().forEach(item -> LogUtil.appendLog(Constant.LOG_END + "流程【" + arisModel.getName() + "】中的活动节点【" + item.getShapeText() + "】关联IT系统【" + item.getRelationShapeText() + "】", simpleLogFile, fullLogFile));
+ relationDao.barchInsert(relationList);
+ LogUtil.appendLog(Constant.LOG_END + "PAL流程【" + arisModel.getName() + "】相关信息系统与形状进行关联", simpleLogFile, fullLogFile);
+ }
+ }
+
+ /**
+ * 处理关联属性【角色】与流程关联
+ * @param wsId
+ * @param repositoryModelId
+ * @param arisFunIdRelationPalRoleMap
+ * @param palShapeIdRelationArisOccIdMap
+ * @param elements
+ * @param arisModel
+ * @param modelObjOccMap
+ * @param objDefMap
+ * @param roleMdoelId
+ * @param palRoleIdRelationNameMap
+ * @throws AWSException
+ */
+ private void handleProcessAttrRoleRelation(String wsId, String repositoryModelId, Map arisFunIdRelationPalRoleMap, Map palShapeIdRelationArisOccIdMap, JSONObject elements, ModelModel arisModel,
+ Map> modelObjOccMap, Map objDefMap, String roleMdoelId, Map palRoleIdRelationNameMap) throws AWSException {
+
+ LogUtil.appendLog(Constant.LOG_START + "PAL流程【" + arisModel.getName() + "】相关角色与形状进行关联,并删除流程图上多余的角色和连线", simpleLogFile, fullLogFile);
+ // 获取ARIS图形定义与PAL图形定义关系
+ Map objDefMappingMap = ModelMappingAPIManager.getInstance().getObjDefMappingMap();
+ ObjDefMappingModel objDefMappingModel = objDefMappingMap.get("OT_PERS_TYPE-ST_EMPL_TYPE");
+ // 获取当前ARIS模型下所有的图形信息
+ List objOccModels = modelObjOccMap.get(arisModel.getId());
+ // 存放待删除图形的KEY
+ List removeKey = new ArrayList<>();
+ // 流程关联属性结果集
+ List relationList = new ArrayList<>();
+
+ Map map = new HashMap<>();
+ for (Map.Entry entry : palShapeIdRelationArisOccIdMap.entrySet()) {
+ String shapeId = entry.getKey();
+ String arisShapeId = entry.getValue();
+ if (arisFunIdRelationPalRoleMap.containsKey(arisShapeId)) {
+ String roleShapeId = arisFunIdRelationPalRoleMap.get(arisShapeId);
+ DesignerShapeRelationModel m = new DesignerShapeRelationModel();
+ m.setId(UUIDGener.getUUID());
+ m.setFileId(repositoryModelId);
+ m.setShapeId(shapeId);
+ m.setShapeText(elements.getJSONObject(shapeId).getString("text"));
+ m.setRelationFileId(roleMdoelId);
+ m.setRelationShapeId(roleShapeId);
+ m.setRelationShapeText(palRoleIdRelationNameMap.get(roleShapeId));
+ m.setAttrId(Constant.METHOD_ROLE);
+ relationList.add(m);
+ }
+ }
+
+ Set roleIdSet = new HashSet<>();
+ for (String key : elements.keySet()) {
+ JSONObject tempShapeObj = elements.getJSONObject(key);
+ if ("role".equals(tempShapeObj.getString("name"))) {
+ roleIdSet.add(key);
+ }
+ }
+ for (String key : elements.keySet()) {
+ JSONObject tempShapeObj = elements.getJSONObject(key);
+ if ("linker".equals(tempShapeObj.getString("name"))) {
+ String text = "";
+ if (roleIdSet.contains(tempShapeObj.getJSONObject("from").getString("id"))) {
+ text = elements.getJSONObject(tempShapeObj.getJSONObject("from").getString("id")).getString("text");
+ // 删除图形与连线
+ removeKey.add(key);
+ removeKey.add(tempShapeObj.getJSONObject("from").getString("id"));
+ } else if (roleIdSet.contains(tempShapeObj.getJSONObject("to").getString("id"))) {
+ text = elements.getJSONObject(tempShapeObj.getJSONObject("to").getString("id")).getString("text");
+ // 删除图形与连线
+ removeKey.add(key);
+ removeKey.add(tempShapeObj.getJSONObject("to").getString("id"));
+ }
+ LogUtil.appendLog(Constant.LOG_END + "删除PAL流程【" + arisModel.getName() + "】" + "角色形状【" +text + "】和其连线", fullLogFile);
+ }
+ }
+
+ // 删除没有与活动进行连线相连的角色形状(角色图中已包含该角色图标)
+ for (String key : elements.keySet()) {
+ JSONObject tempShapeObj = elements.getJSONObject(key);
+ if ("role".equals(tempShapeObj.getString("name")) && !removeKey.contains(tempShapeObj.getString("id"))) {
+ removeKey.add(key);
+ LogUtil.appendLog(Constant.LOG_END + "删除PAL流程【" + arisModel.getName() + "】" + "角色形状【" + tempShapeObj.getString("text") + "】,该角色无连线连接到活动(角色图中已包含该角色图标)", fullLogFile);
+ }
+ }
+
+ // 保存关联关系
+ if (relationList.size() > 0) {
+ DesignerShapeRelationDao relationDao = new DesignerShapeRelationDao();
+ relationList.stream().forEach(item -> LogUtil.appendLog(Constant.LOG_END + "保存PAL流程【" + arisModel.getName() + "】中的活动节点【" + item.getShapeText() + "】关联当前流程下角色【" + item.getRelationShapeText() + "】"));
+ relationDao.barchInsert(relationList);
+ }
+ removeKey.stream().forEach(key -> elements.remove(key));
+ LogUtil.appendLog(Constant.LOG_END + "删除PAL流程【" + arisModel.getName() + "】的相关角色形状和其连线", simpleLogFile, fullLogFile);
+ LogUtil.appendLog(Constant.LOG_END + "PAL流程【" + arisModel.getName() + "】相关角色与形状进行关联,并删除流程图上多余的角色和连线", simpleLogFile, fullLogFile);
+ }
+
+ /**
+ * 设置画布大小
+ *
+ * @param elements
+ */
+ private void setDiagramHeightWidth(JSONObject definition, JSONObject elements) {
+ // 获取最大宽高,给100长度富余
+ JSONObject maxHW = getMaxPositionXY(elements);
+ int maxX = maxHW.getInteger("maxX") + 150;
+ int maxH = maxHW.getInteger("maxY") + 150;
+ JSONObject page = definition.getJSONObject("page");
+ int pageW = page.getInteger("width");
+ int pageH = page.getInteger("height");
+ page.put("width", pageW > maxX ? pageW : maxX);
+ page.put("height", pageH > maxH ? pageH : maxH);
+ definition.put("page", page);
+ }
+
+ private JSONObject getMaxPositionXY(JSONObject elements) {
+ int maxX = -99999;
+ int maxY = -99999;
+ Iterator 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)) {
+ JSONObject props = shape.getJSONObject("props");
+ int x = props.getInteger("x");
+ int y = props.getInteger("y");
+ maxX = maxX < x ? x : maxX;
+ maxY = maxY < y ? y : maxY;
+ }
+ }
+ JSONObject result = new JSONObject();
+ result.put("maxX", maxX);
+ result.put("maxY", maxY);
+ return result;
+ }
+
+
+
+
+
+ /**
+ * 创建具有合理位置的节点数据
+ *
+ * @param elements
+ * @param shapeRowCount
+ * @return
+ */
+ private JSONArray getMethodElementsJSONArray(JSONArray elements, int shapeRowCount) {
+ JSONArray result = new JSONArray();
+ int zindex = 0;
+ int initX = 0;
+ int initY = 0;
+ int pageEdge = 100;
+ int count = 0;
+ initX += pageEdge;
+ initY += pageEdge;
+ for (int i = 0; i < elements.size(); i++) {
+ JSONObject shape = elements.getJSONObject(i);
+ count++;
+ if (count % (shapeRowCount + 1) == 0) {
+ count = 1;
+ initY += 130;
+ // 换行
+ initX = 0;
+ initX = pageEdge + initX;
+ }
+ zindex++;
+ if (shape.containsKey("dataAttributes")) {
+ JSONArray dataAttributes = JSONArray.parseArray(shape.getString("dataAttributes"));
+ for (int index = 0; index < dataAttributes.size(); index++) {
+ dataAttributes.getJSONObject(index).put("id", UUIDGener.getObjectId());
+ }
+ shape.put("dataAttributes", dataAttributes);
+ }
+ int totalWidth = 240;// 每个节点总宽度,空白+节点+空白
+ int totalHeight = 200;// 每个节点总高度,空白+节点+空白
+ int x = 0;
+ int y = 0;
+ int w = validateJson(shape.getJSONObject("props").getInteger("w"));
+ int h = validateJson(shape.getJSONObject("props").getInteger("h"));
+ int leftBlankWidth = (totalWidth - w) / 2;
+ int topBlankHeight = (totalHeight - h) / 2;
+ x = initX + leftBlankWidth;
+ initX = x + w + leftBlankWidth;
+ y = initY + topBlankHeight;
+// y = pageEdge + initY;
+// if (y < 0) {
+// y = 100;
+// }
+ JSONObject props = shape.getJSONObject("props");
+ props.put("x", x);
+ props.put("y", y);
+ props.put("zindex", zindex);
+ shape.put("props", props);
+ result.add(shape);
+ }
+ return result;
+ }
+
+ /**
+ * 创建角色模型和角色元素,并且获取aris角色与pal角色映射关系
+ * 角色与流程活动都是以角色为起点连接流程活动
+ * 角色与岗位都是以岗位为起点连接角色
+ * 活动与角色是1对1关系,不存在单活动对应多个角色
+ * @param coeProcessLevel
+ * @param parentId
+ * @param wsId
+ * @param palModel
+ * @param arisModel
+ * @param modelObjOccMap
+ * @param objDefMap
+ * @param objOccMap
+ * @param cxnOccMap
+ * @param objDefLinkerMap
+ * @param arisFunIdRelationPalRoleMap
+ * @param methodAttrsMap
+ * @return
+ */
+ private String createRoleModelAndElements(PALRepository coeProcessLevel, String parentId, String wsId, PALRepositoryModel palModel, ModelModel arisModel, Map> modelObjOccMap, Map objDefMap, Map objOccMap, Map> cxnOccMap, Map> objDefLinkerMap, Map arisFunIdRelationPalRoleMap, Map> methodAttrsMap, Map palRoleIdRelationNameMap) {
+ LogUtil.appendLog(Constant.LOG_START + "创建流程模型对应的角色模型", simpleLogFile, fullLogFile);
+
+ // 统计模型内的角色信息,创建角色与形状的关联关系,提前创建活动与角色的id关联关系,建立角色的角色图,角色图中处理岗位为文本属性内容
+
+ // 统计模型内所有的角色形状
+ List objOccModels = modelObjOccMap.get(arisModel.getId());
+ // 获取角色
+ List roleObjOccModels = new ArrayList<>();
+ for (ObjOccModel objOccModel : objOccModels) {
+ ObjDefModel objDefModel = objDefMap.get(objOccModel.getDefId());
+ if (objDefModel.getTypeNum().equals("OT_PERS_TYPE") && objDefModel.getSymbolNum().equals("ST_EMPL_TYPE")) {// 角色
+ roleObjOccModels.add(objOccModel);
+ }
+ }
+ if (roleObjOccModels.size() == 0) {
+ LogUtil.appendLog(Constant.LOG_WARNING + "Aris流程【" + arisModel.getName() + "】无任何角色模型,忽略角色与岗位导入", simpleLogFile, fullLogFile, warnLogFile);
+ return null;
+ }
+
+ Set noneRelationRole = new HashSet<>();
+
+ // 创建角色与形状关联关系
+ // 获取当前aris模型内的所有角色list
+ List roleCxnOccModels = new ArrayList<>();
+ for (ObjOccModel roleOccModel : roleObjOccModels) {
+ List list = cxnOccMap.get(roleOccModel.getId());
+ // list为null,该角色在该模型中没有连接任何的活动,忽略导入该角色
+ if (list == null) {
+ LogUtil.appendLog(Constant.LOG_WARNING + "Aris流程【" + arisModel.getName() + "】检测到角色" + objDefMap.get(roleOccModel.getDefId()).getName() + "尚未连接到任何活动上,该角色可能不与任何流程活动相关联", simpleLogFile, fullLogFile, warnLogFile);
+ noneRelationRole.add(objDefMap.get(roleOccModel.getDefId()).getName());
+ continue;
+ }
+ for (CxnOccModel cxnOccModel : list) {
+ if (cxnOccModel.getModelId().equals(arisModel.getId())) {
+ roleCxnOccModels.add(cxnOccModel);
+ }
+ }
+ }
+ if (roleCxnOccModels.size() == 0) {
+ LogUtil.appendLog(Constant.LOG_WARNING + "Aris流程【" + arisModel.getName() + "】检测到无任何角色模型与流程活动进行连接,该流程与对应的角色图没有关联关系", simpleLogFile, fullLogFile, warnLogFile);
+ }
+
+ // 记录重复的角色,根据名称进行记录
+ Map> repeatRoleMap = new HashMap<>();
+ // 记录aris功能活动与角色的关系
+ Map arisFunRelationRoleMap = new HashMap<>();
+ // 记录重复的角色名称
+ for (CxnOccModel cxnOccModel: roleCxnOccModels) {
+ ObjOccModel occModel = objOccMap.get(cxnOccModel.getId());
+ ObjDefModel objDefModel = objDefMap.get(occModel.getDefId());
+ arisFunRelationRoleMap.put(cxnOccModel.getToId(), objDefModel.getName());
+ String roleName = objDefModel.getName();
+ if (!repeatRoleMap.containsKey(roleName)) {
+ repeatRoleMap.put(roleName, new HashSet<>());
+ }
+ repeatRoleMap.get(roleName).add(occModel.getId());
+ }
+ // 没有关联活动的角色,也加入到角色图中
+ for (String roleName : noneRelationRole) {
+ if (!repeatRoleMap.containsKey(roleName)) {
+ repeatRoleMap.put(roleName, new HashSet<>());
+ }
+ }
+
+ // 创建角色图的名称与PAL角色图形状ID对应关系
+ Map roleNamePalIdMap = new HashMap<>();
+ for (String roleName : repeatRoleMap.keySet()) {
+ String roleShapeId = UUIDGener.getObjectId();
+ roleNamePalIdMap.put(roleName, roleShapeId);
+ palRoleIdRelationNameMap.put(roleShapeId, roleName);
+ }
+ // 记录Aris功能Occ ID与PALroleId关联关系
+ for (Map.Entry entry : arisFunRelationRoleMap.entrySet()) {
+ if (roleNamePalIdMap.containsKey(entry.getValue())) {
+ arisFunIdRelationPalRoleMap.put(entry.getKey(), roleNamePalIdMap.get(entry.getValue()));
+ }
+ }
+
+ // 角色名称与岗位名称合集
+ Map> roleRelationPositonMap = new HashMap<>();
+ // 查找角色对应的岗位
+ for (ObjOccModel roleOccModel : roleObjOccModels) {
+ ObjDefModel roleObjDefModel = objDefMap.get(roleOccModel.getDefId());
+ String linkedModelIds = roleObjDefModel.getLinkedModelIds();
+ if (UtilString.isEmpty(linkedModelIds)) {// 角色无关联角色图
+ LogUtil.appendLog(Constant.LOG_WARNING + "Aris流程【" + arisModel.getName() + "】检测到角色【" + roleObjDefModel.getName() + "】角色无任何关联岗位,忽略该角色的岗位", simpleLogFile, fullLogFile, warnLogFile);
+ } else {// 角色有关联角色图
+ List relationPositonList = modelObjOccMap.get(linkedModelIds);// linkedModelIds按照单个值对待,暂无发现多值
+ if (relationPositonList == null || relationPositonList.size() == 0) {// 角色有关联图但是关联的角色图查询不到
+ LogUtil.appendLog(Constant.LOG_WARNING + "Aris流程【" + arisModel.getName() + "】检测到角色【" + roleObjDefModel.getName() + "】角色存在关联的角色图【" + linkedModelIds + "】,但无法查询对应角色图内容,忽略该角色的岗位", simpleLogFile, fullLogFile, warnLogFile);
+ } else {
+ for (ObjOccModel objOccModel: relationPositonList) {
+ ObjDefModel positionDefModel = objDefMap.get(objOccModel.getDefId());
+ if (positionDefModel.getTypeNum().equals("OT_POS") && positionDefModel.getSymbolNum().equals("ST_POS")) {
+ // 查询出岗位,记录到角色中,角色名称为key,岗位名称为value
+ if (!roleRelationPositonMap.containsKey(roleObjDefModel.getName())) {
+ roleRelationPositonMap.put(roleObjDefModel.getName(), new HashSet<>());
+ }
+ roleRelationPositonMap.get(roleObjDefModel.getName()).add(positionDefModel.getName());
+ }
+ }
+ }
+ }
+ }
+
+ // 生成一个空的与流程同名角色模型文件
+ String id = UUIDGener.getUUID();
+ int orderIndex = coeProcessLevel.getChildrenMaxOrderIndexByPidAndWsId(parentId, wsId) + 1;
+ Timestamp nowTime = new Timestamp(System.currentTimeMillis());
+
+ PALRepositoryModelImpl model = CoeProcessLevelUtil.createPALRepositoryModel(id, UUIDGener.getUUID(), wsId, arisModel.getName(), "", orderIndex, parentId, "org", true, 1,
+ id, false, "org.role", "0", 1, null, null, uc.getUID(), uc.getUID(), nowTime, null, null, null, null,
+ null, null, null, null, null, -1);
+ coeProcessLevel.insert(model);
+ LogUtil.appendLog(Constant.LOG_END + "创建与Aris流程同名的角色图【" + arisModel.getName() + "】【" + model.getId() + "】", simpleLogFile, fullLogFile);
+ BaseModel baseModel = CoeDesignerAPIManager.getInstance().getDefinition(model.getId(), 0);
+ if (baseModel == null) {
+ baseModel = CoeDesignerUtil.createModel(model.getId(), 0);
+ baseModel.setCreateHistory(false);
+ }
+ baseModel.setUpdateTime(new SimpleDateFormat(CoeDesignerConstant.DATE_TIME_STYLE_YYYY_MM_DD_HH_MM_SS).format(new Date()));
+ String define = baseModel.getDefinition();
+ JSONObject definition = JSONObject.parseObject(define);
+ JSONObject elements = definition.getJSONObject("elements");
+ Map objDefMappingMap = ModelMappingAPIManager.getInstance().getObjDefMappingMap();
+ ObjDefMappingModel objDefMappingModel = objDefMappingMap.get("OT_PERS_TYPE-ST_EMPL_TYPE");
+ String shapeMethodId = objDefMappingModel.getShapeMethod();
+ String shapeType = objDefMappingModel.getShapeType();
+ JSONObject shapeDefine = ShapeUtil.getProcessShapeDefinitionByName(shapeMethodId, shapeType);
+
+ JSONArray shapes = new JSONArray();
+ for (Map.Entry entry: roleNamePalIdMap.entrySet()) {
+ String shapeText = entry.getKey();
+ String shapeId = entry.getValue();
+ JSONObject newShape = JSONObject.parseObject(shapeDefine.toString());
+ newShape.put("id", shapeId);
+ newShape.put("text", shapeText);
+ shapes.add(newShape);
+ }
+
+ JSONArray newShapes = this.getMethodElementsJSONArray(shapes, 6);
+
+ for (int i = 0; i < newShapes.size(); i++) {
+ JSONObject shapeObj = newShapes.getJSONObject(i);
+ elements.put(shapeObj.getString("id"), shapeObj);
+ LogUtil.appendLog(Constant.LOG_END + "创建角色图【" + arisModel.getName() + "】角色形状图标【" + shapeObj.getString("text") + "】", simpleLogFile);
+ }
+ LogUtil.appendLog(Constant.LOG_END + "创建角色图【" + arisModel.getName() + "】角色形状图标【" + elements.size() + "】个", simpleLogFile, fullLogFile);
+
+ // 设置角色图形状默认属性配置
+ this.handleShapeDefaultAttr(wsId, palModel, elements, methodAttrsMap);
+
+ // 完善岗位属性
+ for (String key : elements.keySet()) {
+ JSONObject shape = elements.getJSONObject(key);
+ if ("linker".equals(shape.getString("name"))) {
+ continue;
+ }
+ String shapeText = shape.getString("text");
+ if (roleRelationPositonMap.containsKey(shapeText) && roleRelationPositonMap.get(shapeText).size() > 0) {
+ Set postText = roleRelationPositonMap.get(shapeText);
+ List list = new ArrayList<>(postText);
+ Collections.sort(list);
+ String postTextVal = StringUtils.join(list, ",");// 岗位内容
+ JSONArray dataAttributes = shape.getJSONArray("dataAttributes");
+ if (!dataAttributes.isEmpty() && dataAttributes.size() > 0) {
+ for (Object attribute : dataAttributes) {
+ JSONObject obj = (JSONObject) attribute;
+ if (obj.containsKey("attributesJsonArray")) {
+ JSONArray attributesJsonArray = obj.getJSONArray("attributesJsonArray");
+ boolean flag = false;
+ for (int i = 0; i < attributesJsonArray.size(); i++) {
+ if (attributesJsonArray.getJSONObject(i).containsKey("id")) {
+ String attrId = Constant.METHOD_POST_TEXT;
+ if (attrId.equals(attributesJsonArray.getJSONObject(i).getString("id"))) {
+ flag = true;
+ attributesJsonArray.getJSONObject(i).put("value", postTextVal);
+ LogUtil.appendLog(Constant.LOG_END + "设置角色图【" + arisModel.getName() + "】角色形状图标【" + shapeText + "】的岗位属性值为" + "【" + postTextVal + "】", fullLogFile);
+ }
+ }
+ }
+ if (!flag) {
+ LogUtil.appendLog(Constant.LOG_WARNING + "角色图【" + arisModel.getName() + "】角色形状图标【" + shapeText + "】没有岗位属性配置", simpleLogFile, fullLogFile, warnLogFile);
+ }
+ }
+ }
+ }
+ } else {
+ LogUtil.appendLog(Constant.LOG_WARNING + "角色图【" + arisModel.getName() + "】角色形状图标【" + shapeText + "】无岗位属性内容值", simpleLogFile, fullLogFile, warnLogFile);
+ }
+ }
+ LogUtil.appendLog(Constant.LOG_END + "角色图【" + arisModel.getName() + "】角色形状图标关联岗位内容", simpleLogFile, fullLogFile, warnLogFile);
+ definition.put("elements", elements);
+ // 设置画布大小
+ setDiagramHeightWidth(definition, elements);
+ baseModel.setDefinition(definition.toString());
+ // 保存文件
+ CoeDesignerAPIManager.getInstance().storeDefinition(baseModel);// dao操作
+ LogUtil.appendLog(Constant.LOG_END + "角色图【" + arisModel.getName() + "】新增保存", simpleLogFile, fullLogFile, warnLogFile);
+ return id;
+ }
+
+ private int validateJson(Integer index) {
+ return index == null ? 0 : index;
+ }
+
+ /**
+ * 获取连线的折点(不包括起始端)
+ *
+ * @param positionModels
+ * @return
+ */
+ private Object getLinkerPoints(List positionModels) {
+ JSONArray result = new JSONArray();
+ if (positionModels.size() > 2) {
+ for (int i = 1; i < positionModels.size() - 1; i++) {
+ JSONObject obj = new JSONObject();
+ obj.put("x", positionModels.get(i).getX());
+ obj.put("y", positionModels.get(i).getY());
+ result.add(obj);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * 获取连线angle
+ *
+ * @param positionModels
+ * @param type
+ * @return
+ */
+ private double getLinkerAngle(List positionModels, String type) {
+ if (positionModels.size() < 2) {
+ System.out.println("出错了");
+ return 0;
+ } else if (positionModels.size() == 2) {
+ if (positionModels.get(0).getX() == positionModels.get(1).getX()) {
+ if ("from".equals(type)) {
+ return (positionModels.get(0).getY() - positionModels.get(1).getY() > 0) ? Constant.ANGLE_DOWN : Constant.ANGLE_UP;
+ } else {
+ return (positionModels.get(0).getY() - positionModels.get(1).getY() > 0) ? Constant.ANGLE_UP : Constant.ANGLE_DOWN;
+ }
+ } else {
+ if ("from".equals(type)) {
+ return (positionModels.get(0).getX() - positionModels.get(1).getX() > 0) ? Constant.ANGLE_RIGHT : Constant.ANGLE_LEFT;
+ } else {
+ return (positionModels.get(0).getX() - positionModels.get(1).getX() > 0) ? Constant.ANGLE_LEFT : Constant.ANGLE_RIGHT;
+ }
+ }
+ } else {
+ List list = new ArrayList<>();
+ if ("from".equals(type)) {
+ list.add(new PositionModel(positionModels.get(0).getX(), positionModels.get(0).getY()));
+ list.add(new PositionModel(positionModels.get(1).getX(), positionModels.get(1).getY()));
+ } else {
+ list.add(new PositionModel(positionModels.get(positionModels.size() - 2).getX(), positionModels.get(positionModels.size() - 2).getY()));
+ list.add(new PositionModel(positionModels.get(positionModels.size() - 1).getX(), positionModels.get(positionModels.size() - 1).getY()));
+ }
+ return getLinkerAngle(list, type);
+ }
+ }
+
+ /**
+ * 获取默认属性内容
+ * @param attr
+ * @return
+ */
+ private JSONObject getDefaultAttrObj (JSONObject attr) {
+ String ref = attr.getString("ref");
+ boolean readonly = attr.getBooleanValue("readonly");
+ String scope = attr.getString("scope");
+ String attrName = attr.getString("title");
+ String attrId = attr.getString("id");
+ String type = attr.getString("type");
+ String groupPath = attr.getString("groupPath");
+ String attrKey = attr.getString("key");
+ String attrValue = "";
+ JSONObject object2 = new JSONObject();
+ object2.put("ref", ref);
+ object2.put("readonly", readonly);
+ object2.put("scope", scope);
+ object2.put("name", attrName);
+ object2.put("id", attrId);
+ object2.put("type", type);
+ object2.put("groupPath", groupPath);
+ object2.put("key", attrKey);
+ object2.put("value", "");
+ return object2;
+ }
+
+ /**
+ * 根据级别排序
+ */
+ private class Comparator1 implements Comparator {
+ @Override
+ public int compare(PALRepositoryModel model1, PALRepositoryModel model2) {
+ Integer level1 = model1.getLevel();
+ Integer level2 = model2.getLevel();
+ int result = level1.compareTo(level2);
+ if (result == 0) {
+ Integer index1 = model1.getOrderIndex();
+ Integer index2 = model2.getOrderIndex();
+ result = index1.compareTo(index2);
+ }
+ return result;
+ }
+ }
+}
diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/web/ArisXmlImportWeb.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/web/ArisXmlImportWeb.java
new file mode 100644
index 00000000..42831970
--- /dev/null
+++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/web/ArisXmlImportWeb.java
@@ -0,0 +1,375 @@
+package com.actionsoft.apps.coe.pal.datamigration.aris.web;
+
+import com.actionsoft.apps.coe.pal.constant.CoEConstant;
+import com.actionsoft.apps.coe.pal.datamigration.aris.constant.ArisConstant;
+import com.actionsoft.apps.coe.pal.datamigration.aris.model.*;
+import com.actionsoft.apps.coe.pal.datamigration.aris.util.XMLUtil;
+import com.actionsoft.apps.coe.pal.datamigration.constant.Constant;
+import com.actionsoft.apps.coe.pal.datamigration.log.cache.LogRealTimeCountCache;
+import com.actionsoft.apps.coe.pal.datamigration.log.model.LogModel;
+import com.actionsoft.apps.coe.pal.datamigration.log.model.LogRealTimeCountModel;
+import com.actionsoft.apps.coe.pal.datamigration.util.LogUtil;
+import com.actionsoft.apps.coe.pal.datamigration.util.ShapeUtil;
+import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel;
+import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryAPIManager;
+import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager;
+import com.actionsoft.apps.coe.pal.pal.repository.designer.CoeDesignerShapeAPIManager;
+import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile;
+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.server.fs.DCContext;
+import com.actionsoft.bpms.server.fs.dc.DCProfileManager;
+import com.actionsoft.bpms.util.UUIDGener;
+import com.actionsoft.bpms.util.UtilDate;
+import com.actionsoft.bpms.util.UtilString;
+import com.actionsoft.i18n.I18nRes;
+import com.alibaba.fastjson.JSONObject;
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+public class ArisXmlImportWeb extends ActionWeb {
+
+ UserContext _uc;
+
+ public ArisXmlImportWeb() {
+ }
+
+ public ArisXmlImportWeb(UserContext uc) {
+ _uc = uc;
+ }
+
+ private String logId;
+ private String logPath;
+ private File simpleLogFile;
+ private File fullLogFile;
+ private File warnLogFile;
+ private String filePath;
+ private String fileName;
+ private long startTime = System.currentTimeMillis();
+
+ // Timestamp startDate = new Timestamp(System.currentTimeMillis());
+
+
+ public void initParams () {
+ logId = UUIDGener.getUUID();// 记录缓存
+ String fileValue = "arisXML-" + new SimpleDateFormat("yyyy-MM-dd-HHmmss").format(new Date()) + "-" + _uc.getUID();
+ // 创建dc目录
+ DCPluginProfile dcProfile = DCProfileManager.getDCProfile(Constant.APP_ID, ArisConstant.REPOSITORY_NAME);
+ DCContext dc = new DCContext(_uc, dcProfile, Constant.APP_ID, ArisConstant.LOG_GROUP_VALUE, fileValue);
+ String dirPath = dc.getPath();
+ File dir = new File(dirPath);
+ dir.mkdirs();
+ simpleLogFile = new File(dirPath, ArisConstant.IMPORT_LOG_FILE_SIMPLE);
+ try {
+ simpleLogFile.createNewFile();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ fullLogFile = new File(dirPath, ArisConstant.IMPORT_LOG_FILE_FULL);
+ try {
+ fullLogFile.createNewFile();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ warnLogFile = new File(dirPath, ArisConstant.IMPORT_LOG_FILE_WARN);
+ try {
+ warnLogFile.createNewFile();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ logPath = simpleLogFile.getPath();// 前端实时展示的日志
+ }
+
+ /**
+ * 创建日志记录Model
+ * @param id
+ * @param wsId
+ * @param fileName
+ * @param filePath
+ * @param createDate
+ * @return
+ */
+ private void createLogModel(String id, String wsId, String fileName, String filePath, Timestamp createDate) {
+ LogModel model = new LogModel();
+ model.setId(id);
+ model.setWsId(wsId);
+ model.setFileName(fileName);
+ model.setFilePath(filePath);
+ model.setLogPath(logPath);
+ model.setCreateUser(_uc.getUID());
+ model.setCreateUserName(_uc.getUserName());
+ model.setCreateDate(createDate);
+ model.setStartDate(createDate);
+ model.setResultStatus(Constant.LOG_RESULT_StATUS_RUN);
+ model.setMainInfo("导入进行中");
+ // 存储日志db
+ LogUtil.createLog(model);
+ }
+
+ /**
+ * 导入停止时更新日志db状态
+ * @param logFileMsg
+ * @param logDbMsg
+ */
+ private void updateErrLog(String logFileMsg, String logDbMsg) {
+ // 记录日志
+ LogUtil.appendLog(logFileMsg, simpleLogFile, fullLogFile, warnLogFile);
+ // 日志表记录导入结果
+ LogUtil.updateLog(logId, new Timestamp(System.currentTimeMillis()), Constant.LOG_RESULT_StATUS_ERROR, logDbMsg);
+ // 清空缓存
+ LogRealTimeCountCache.getCache().remove(logId);
+ }
+
+ /**
+ * 迁移测试
+ *
+ * @param wsId
+ * @return
+ */
+ public String dataMigrate(String wsId, String groupValue, String fileValue, String fileName) {
+ // 初始化一些参数
+ initParams();
+ // 读取dc
+ DCPluginProfile dcProfile = DCProfileManager.getDCProfile(Constant.APP_ID, "migration");// repositoryName要调整新的路径,配合前端, todo
+ DCContext dc = new DCContext(_uc, dcProfile, Constant.APP_ID, groupValue, fileValue, fileName);
+ this.fileName = fileName;
+ this.filePath = dc.getFilePath();
+ Timestamp startDate = new Timestamp(startTime);
+ // 创建日志信息db
+ createLogModel(logId, wsId, fileName, filePath, startDate);
+ LogUtil.appendLog("注:该日志文件存储简要日志信息", simpleLogFile);
+ LogUtil.appendLog("注:该日志文件存储详细日志信息", fullLogFile);
+ LogUtil.appendLog("注:该日志文件记录警告、出错日志信息", warnLogFile);
+
+ LogUtil.appendLog("Aris XML流程导入 Begin " + UtilDate.datetimeFormat(startDate), simpleLogFile, fullLogFile, warnLogFile);
+
+ String msg;
+
+ // 校验资产库是否存在可用
+ boolean isActive = PALRepositoryQueryAPIManager.getInstance().isActiveWorkSpace(wsId);
+ if (!isActive) {
+ msg = Constant.LOG_ERROR + "资产库不存在或已停用," + Constant.IMPORT_STOP_MSG;
+ updateErrLog(msg, msg);
+ return ResponseObject.newErrResponse("资产库不存在或已停用").toString();
+ }
+ LogUtil.appendLog(Constant.LOG_SUCCESS + "校验资产库存在并可用", simpleLogFile, fullLogFile);
+
+ // 校验文件/形状属性配置是否正常
+ ResponseObject checkRo = checkMethodConfig(wsId);
+ if (checkRo.isErr()) {
+ return checkRo.toString();
+ }
+ // 校验文件是否存在
+ File file = new File(dc.getFilePath());
+ if (!file.exists()) {
+ msg = Constant.LOG_ERROR + "上传文件不存在," + Constant.IMPORT_STOP_MSG;
+ updateErrLog(msg, msg);
+ return ResponseObject.newErrResponse("上传文件不存在").toString();
+ }
+ LogUtil.appendLog(Constant.LOG_SUCCESS + "校验上传文件是否存在", simpleLogFile, fullLogFile);
+
+ if (!".xml".equals(fileName.substring(fileName.lastIndexOf(".")))) {
+ msg = Constant.LOG_ERROR + "上传文件名称格式不正确," + Constant.IMPORT_STOP_MSG;
+ updateErrLog(msg, msg);
+ return ResponseObject.newErrResponse("上传文件名称格式不正确,请上传XML文件").toString();
+ }
+ LogUtil.appendLog(Constant.LOG_SUCCESS + "校验上传文件是否为XML格式", simpleLogFile, fullLogFile);
+
+ // 校验xml文档是否能够正常解析
+ Document doc = analysisXMLFile(file.getPath(), true);
+ // String toFilePath = "/Users/sunlh/Documents/ideaData/actionsoft/aws6.4.1.1008.yili2/apps/com.actionsoft.apps.coe.pal.datamigration/testFile/targetFile/";
+ // XMLUtil.writeXml(d, toFilePath + fileName);
+ // 解析xml文件
+ if (doc == null) {
+ msg = Constant.LOG_ERROR + "解析XML文件结构," + Constant.IMPORT_STOP_MSG;
+ updateErrLog(msg, msg);
+ return ResponseObject.newErrResponse("解析XML文件错误,详情见日志").toString();
+ }
+ LogUtil.appendLog(Constant.LOG_SUCCESS + "解析XML文件结构", simpleLogFile, fullLogFile);
+ ArisXmlHandleWeb handleWeb = new ArisXmlHandleWeb();
+ // 解析Aris流程内容
+ try {
+ handleWeb.handleXmlDoc(doc);
+ } catch (Exception e) {
+ e.printStackTrace();
+ msg = Constant.LOG_ERROR + "解析XML文件内容异常,异常信息:" + e.getMessage() + "," + Constant.IMPORT_STOP_MSG;
+ updateErrLog(msg, msg);
+ }
+ LogUtil.appendLog(Constant.LOG_SUCCESS + "解析XML文件内容", simpleLogFile, fullLogFile);
+
+ // 统计epc流程图的个数,用以进度展示
+ int totalEpcCount = countProcessMainInfo(handleWeb.modelMap);
+ if (totalEpcCount == 0) {
+ msg = Constant.LOG_ERROR + "上传文件不包含任何" + I18nRes.findValue(CoEConstant.APP_ID, Constant.PROCESS_EPC) + "," + Constant.IMPORT_STOP_MSG;
+ updateErrLog(msg, msg);
+ return ResponseObject.newErrResponse("上传文件不包含任何" + I18nRes.findValue(CoEConstant.APP_ID, Constant.PROCESS_EPC)).toString();
+ }
+ // 存储缓存,导入计数
+ LogRealTimeCountModel countModel = new LogRealTimeCountModel();
+ countModel.setTotalCount(totalEpcCount);
+ countModel.setSuccessCount(0);
+ countModel.setArisBlankCount(0);
+ countModel.setPalExistsCount(0);
+ countModel.setImportingCount(0);
+ countModel.setMatchFieldCount(0);
+ LogRealTimeCountCache.getCache().put(logId, countModel, true);
+
+ LogUtil.appendLog(Constant.LOG_START + "导入" + I18nRes.findValue(CoEConstant.APP_ID, Constant.PROCESS_EPC + ",共【" + totalEpcCount + "】条流程"));
+ // 开始执行导入
+ new Thread(()->{new ArisXmlImportRun(_uc, wsId, logId, logPath, simpleLogFile, fullLogFile, warnLogFile, this.filePath, this.fileName, startTime).execute(handleWeb);}) .start();
+
+ ResponseObject ro = ResponseObject.newOkResponse();
+ ro.put("logId", logId);
+ ro.put("path", logPath);
+ ro.put("endLog", Constant.END_LOG);
+ return ro.toString();
+ }
+
+ /**
+ * 统计EPC流程图个数,用以展示进度
+ * @param modelMap
+ */
+ private int countProcessMainInfo(Map modelMap) {
+ int count = 0;
+ for (Map.Entry entry : modelMap.entrySet()) {
+ ModelModel model = entry.getValue();
+ if ("MT_EEPC".equals(model.getType())) {
+ count++;
+ }
+ }
+ return count;
+ }
+
+ /**
+ * 解析xml文档
+ * @param path
+ * @param b
+ * @return
+ */
+ private Document analysisXMLFile(String path, boolean b) {
+ Document d = null;
+ try {
+ d = XMLUtil.readXML(path, true);
+ } catch (DocumentException e) {
+ e.printStackTrace();
+ String msg = Constant.LOG_ERROR + "解析XML文件结构出错,错误信息:" + e.getMessage() + Constant.IMPORT_STOP_MSG;
+ updateErrLog(msg, msg);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ String msg = Constant.LOG_ERROR + "解析XML文件结构出错,错误信息:" + e.getMessage() + Constant.IMPORT_STOP_MSG;
+ updateErrLog(msg, msg);
+ }
+ return d;
+ }
+
+ /**
+ * 校验文件/形状属性是否存在
+ * @param wsId
+ * @return
+ */
+ private ResponseObject checkMethodConfig(String wsId) {
+ // 校验EPC图的文件属性
+ // 校验前置流程、后置流程
+ ResponseObject checkRo = checkMethodAttrExist(wsId, Constant.PROCESS_EPC, null, Constant.METHOD_PRE_PROCESS, Constant.METHOD_NEXT_PROCESS, Constant.METHOD_ARIS_URL);
+ if (checkRo.isErr()) {
+ return checkRo;
+ }
+ // 校验epc流程图的形状属性是否配置
+ // 校验线上审批的编号、输入、输出、描述、角色、信息系统
+ checkRo = checkMethodAttrExist(wsId, Constant.PROCESS_EPC, Constant.METHOD_APPROVAL_NODE, Constant.METHOD_NUMBER, Constant.METHOD_INPUT, Constant.METHOD_OUTPUT, Constant.METHOD_DESC, Constant.METHOD_ROLE, Constant.METHOD_INFO_SYSTEM);
+ if (checkRo.isErr()) {
+ return checkRo;
+ }
+ // 校验线下审批的编号、输入、输出、描述、角色、信息系统
+ checkRo = checkMethodAttrExist(wsId, Constant.PROCESS_EPC, Constant.METHOD_SERVICE_NODE, Constant.METHOD_NUMBER, Constant.METHOD_INPUT, Constant.METHOD_OUTPUT, Constant.METHOD_DESC, Constant.METHOD_ROLE, Constant.METHOD_INFO_SYSTEM);
+ if (checkRo.isErr()) {
+ return checkRo;
+ }
+ // 校验系统任务的编号、输入、输出、描述、角色、信息系统
+ checkRo = checkMethodAttrExist(wsId, Constant.PROCESS_EPC, Constant.METHOD_APPROVAL_NODE3, Constant.METHOD_NUMBER, Constant.METHOD_INPUT, Constant.METHOD_OUTPUT, Constant.METHOD_DESC, Constant.METHOD_ROLE, Constant.METHOD_INFO_SYSTEM);
+ if (checkRo.isErr()) {
+ return checkRo;
+ }
+ // 校验人工任务的编号、输入、输出、描述、角色、信息系统
+ checkRo = checkMethodAttrExist(wsId, Constant.PROCESS_EPC, Constant.METHOD_SERVICE_NODE4, Constant.METHOD_NUMBER, Constant.METHOD_INPUT, Constant.METHOD_OUTPUT, Constant.METHOD_DESC, Constant.METHOD_ROLE, Constant.METHOD_INFO_SYSTEM);
+ if (checkRo.isErr()) {
+ return checkRo;
+ }
+ // 校验角色图的岗位属性
+ // 校验角色的岗位文本
+ checkRo = checkMethodAttrExist(wsId, Constant.ORG_ROLE, Constant.METHOD_ROLE, Constant.METHOD_POST_TEXT);
+ if (checkRo.isErr()) {
+ return checkRo;
+ }
+ return ResponseObject.newOkResponse();
+ }
+
+ /**
+ * 校验属性是否存在
+ * @param methodId
+ * @param shapeName
+ * @param attrs
+ * @return
+ */
+ private ResponseObject checkMethodAttrExist(String wsId, String methodId, String shapeName, String ... attrs) {
+ String methodName = I18nRes.findValue(CoEConstant.APP_ID, methodId);
+ // 形状属性校验
+ if (UtilString.isNotEmpty(shapeName)) {
+ JSONObject shape = ShapeUtil.getProcessShapeDefinitionByName(methodId, shapeName);
+ if (isEmptyJsonOject(shape)) {
+ String msg = Constant.LOG_ERROR + "模型【" + methodName + "】中的形状【" + shapeName + "】不存在," + Constant.IMPORT_STOP_MSG;
+ updateErrLog(msg, msg);
+ return ResponseObject.newErrResponse("模型【" + methodName + "】中的形状【" + shapeName + "】不存在");
+ }
+ String shapeText = shape.getString("text");
+ List list = CoeDesignerShapeAPIManager.getInstance().getValidAndUseAttributeModels(wsId, methodId, shapeName, methodId);
+ Map attrMap = new HashMap<>();
+ for (PALMethodAttributeModel attrModel : list) {
+ attrMap.put(attrModel.getKey(), attrModel);
+ }
+ for (String attrId : attrs) {
+ if (!attrMap.containsKey(attrId)) {
+ String msg = Constant.LOG_ERROR + "模型【" + methodName + "】中的形状【" + shapeText + "】属性【" + attrId + "】不存在,请检查相应属性配置," + Constant.IMPORT_STOP_MSG;
+ updateErrLog(msg, msg);
+ return ResponseObject.newErrResponse("模型【" + methodName + "】中的形状【" + shapeText + "】属性【" + attrId + "】不存在");
+ }
+ LogUtil.appendLog(Constant.LOG_SUCCESS + "模型【" + methodName + "】中的形状【" + shapeText + "】属性【" + attrId + "】", simpleLogFile, fullLogFile);
+ }
+ } else {
+ // 文件属性校验
+ List list = PALRepositoryAPIManager.getInstance().getValidAndUseAttributeModels(wsId, methodId);
+ Map attrMap = new HashMap<>();
+ for (PALMethodAttributeModel attrModel : list) {
+ attrMap.put(attrModel.getKey(), attrModel);
+ }
+ for (String attrId : attrs) {
+ if (!attrMap.containsKey(attrId)) {
+ String msg = Constant.LOG_ERROR + "模型【" + methodName + "】的文件属性【" + attrId + "】不存在,请检查相应属性配置," + Constant.IMPORT_STOP_MSG;
+ updateErrLog(msg, msg);
+ return ResponseObject.newErrResponse("模型【" + methodName + "】的文件属性【" + attrId + "】不存在");
+ }
+ LogUtil.appendLog(Constant.LOG_SUCCESS + "模型【" + methodName + "】的文件属性【" + attrId + "】", simpleLogFile, fullLogFile);
+ }
+ }
+ return ResponseObject.newOkResponse();
+ }
+
+ /**
+ * 校验是否为空的对象
+ * @param o
+ * @return
+ */
+ private boolean isEmptyJsonOject(JSONObject o) {
+ return o == null || o.isEmpty();
+ }
+
+}
\ No newline at end of file
diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/constant/Constant.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/constant/Constant.java
index 4679079d..7327a64f 100644
--- a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/constant/Constant.java
+++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/constant/Constant.java
@@ -14,7 +14,7 @@ public class Constant {
public final static double ANGLE_LEFT = 3.141592653589793;
public final static double ANGLE_UP = 4.71238898038469;
- // 建模属性代码--编号
+ // 建模属性代码--编号 --活动序号
// public static final String METHOD_NUMBER = "number";
public static final String METHOD_NUMBER = "activity_number";
@@ -46,11 +46,11 @@ public class Constant {
// 建模属性代码--前置流程
// public static final String METHOD_PRE_PROCESS = "PRE_PROCESS";
- public static final String METHOD_PRE_PROCESS = "pre_process";
+ public static final String METHOD_PRE_PROCESS = "lead_process";
// 建模属性代码--后置流程
// public static final String METHOD_NEXT_PROCESS = "NEXT_PROCESS";
- public static final String METHOD_NEXT_PROCESS = "next_process";
+ public static final String METHOD_NEXT_PROCESS = "rear_process";
// 流程属性--ARIS地址
// public static final String METHOD_ARIS_URL = "ARISURL";
@@ -58,4 +58,48 @@ public class Constant {
// 存放与流程同名的角色模型的文件夹名称
public static final String DEFAULT_FOLDER_NAME = "角色模型";
+
+
+ // 日志常量记录
+ public static final String LOG_SUCCESS = "【成功】";
+ public static final String LOG_WARNING = "【警告】";
+ public static final String LOG_ERROR = "【错误】";
+ // 日志导入开始节点
+ public static final String LOG_START = "【开始】";
+ // 日志导入完成节点
+ public static final String LOG_END = "【完成】";
+ public static final String LOG_DESC = "【说明】";
+
+
+ // 日志表resultType字段常量code
+ public static final int LOG_RESULT_StATUS_RUN = 0;// 进行中
+ public static final int LOG_RESULT_StATUS_SUCCESS = 1;// 完成
+ public static final int LOG_RESULT_StATUS_ERROR = 2;// 失败
+
+ public static final String IMPORT_STOP_MSG = "导入停止";
+
+ // 日志结束语
+ public static final String END_LOG = "**建议下载本次输出日志做备忘";
+
+
+ public static final String PROCESS_EPC = "process.epc";
+
+ public static final String ORG_ROLE = "org.role";
+
+ public static final String ITSYSTEM_NORMAIL = "itsystem.normal";
+
+ public static final String METHOD_APPROVAL_NODE = "method_approval_node";// 线上审批
+
+ public static final String METHOD_SERVICE_NODE = "method_service_node";// 线下审批
+
+ public static final String METHOD_APPROVAL_NODE3 = "method_approval_node3";// 系统任务
+ public static final String METHOD_SERVICE_NODE4 = "method_service_node4";// 人工任务
+
+
+
+
+
+
+
+
}
diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/log/cache/LogRealTimeCountCache.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/log/cache/LogRealTimeCountCache.java
new file mode 100644
index 00000000..b3ae7306
--- /dev/null
+++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/log/cache/LogRealTimeCountCache.java
@@ -0,0 +1,27 @@
+package com.actionsoft.apps.coe.pal.datamigration.log.cache;
+
+import com.actionsoft.apps.coe.pal.datamigration.log.model.LogRealTimeCountModel;
+import com.actionsoft.apps.resource.plugin.profile.CachePluginProfile;
+import com.actionsoft.bpms.commons.cache.Cache;
+import com.actionsoft.bpms.commons.cache.CacheManager;
+
+/**
+ * 存储导入数据
+ * @author sunlh
+ *
+ */
+public class LogRealTimeCountCache extends Cache{
+
+ public LogRealTimeCountCache(CachePluginProfile configuration) {
+ super(configuration);
+ }
+
+ @Override
+ protected void load() {
+ }
+
+ public static LogRealTimeCountCache getCache() {
+ return CacheManager.getCache(LogRealTimeCountCache.class);
+ }
+
+}
diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/log/dao/LogDao.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/log/dao/LogDao.java
new file mode 100644
index 00000000..a5593d7f
--- /dev/null
+++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/log/dao/LogDao.java
@@ -0,0 +1,169 @@
+package com.actionsoft.apps.coe.pal.datamigration.log.dao;
+
+import com.actionsoft.apps.coe.pal.datamigration.log.model.LogModel;
+import com.actionsoft.bpms.commons.database.RowMapper;
+import com.actionsoft.bpms.commons.mvc.dao.DaoObject;
+import com.actionsoft.bpms.util.DBSql;
+import com.actionsoft.bpms.util.UUIDGener;
+import com.actionsoft.bpms.util.UtilString;
+import com.actionsoft.exception.AWSDataAccessException;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class LogDao extends DaoObject {
+ @Override
+ public int insert(LogModel model) throws AWSDataAccessException {
+ if (model == null) {
+ return 0;
+ }
+ Connection conn = DBSql.open();
+ int r = 0;
+ if (UtilString.isEmpty(model.getId())) {
+ model.setId(UUIDGener.getUUID());
+ }
+ Map paraMap = new HashMap();
+ paraMap.put(LogModel.ID, model.getId());
+ paraMap.put(LogModel.WSID, model.getWsId());
+ paraMap.put(LogModel.FILENAME, model.getFileName());
+ paraMap.put(LogModel.FILEPATH, model.getFilePath());
+ paraMap.put(LogModel.LOGPATH, model.getLogPath());
+ paraMap.put(LogModel.CREATEUSER, model.getCreateUser());
+ paraMap.put(LogModel.CREATEUSERNAME, model.getCreateUserName());
+ paraMap.put(LogModel.CREATEDATE, model.getCreateDate());
+ paraMap.put(LogModel.STARTDATE, model.getStartDate());
+ paraMap.put(LogModel.ENDDATE, model.getEndDate());
+ paraMap.put(LogModel.RESULTSTATUS, model.getResultStatus());
+ paraMap.put(LogModel.MAININFO, model.getMainInfo());
+ paraMap.put(LogModel.EXT1, model.getExt1());
+ paraMap.put(LogModel.EXT2, model.getExt2());
+ paraMap.put(LogModel.EXT3, model.getExt3());
+ paraMap.put(LogModel.EXT4, model.getExt4());
+ String sql = DBSql.getInsertStatement(entityName(), paraMap);
+ r = DBSql.update(conn, sql, paraMap);
+ DBSql.close(conn);
+ return r;
+ }
+
+ @Override
+ public int update(LogModel model) throws AWSDataAccessException {
+ String updateSql = "UPDATE "+ entityName()
+ + " SET "+ LogModel.WSID +"=?, "
+ + LogModel.FILENAME +"=?, "
+ + LogModel.FILEPATH +"=?, "
+ + LogModel.LOGPATH +"=?, "
+ + LogModel.CREATEUSER +"=?, "
+ + LogModel.CREATEUSERNAME +"=?, "
+ + LogModel.CREATEDATE +"=?, "
+ + LogModel.STARTDATE +"=?, "
+ + LogModel.ENDDATE +"=?, "
+ + LogModel.RESULTSTATUS +"=?, "
+ + LogModel.MAININFO +"=?, "
+ + LogModel.EXT1 +"=?, "
+ + LogModel.EXT2 +"=?, "
+ + LogModel.EXT3 +"=?, "
+ + LogModel.EXT4 +"=? "
+ + "WHERE "+ LogModel.ID +"=? ";
+ return DBSql.update(updateSql, new Object[] {model.getWsId(), model.getFileName(), model.getFilePath(), model.getLogPath(), model.getCreateUser(), model.getCreateUserName(),
+ model.getCreateDate(), model.getStartDate(), model.getEndDate(), model.getResultStatus(), model.getMainInfo(), model.getExt1(), model.getExt2(), model.getExt3(), model.getExt4(), model.getId()});
+ }
+
+ /**
+ * 更新关键信息
+ * @param id
+ * @param endDate
+ * @param resultType
+ * @param mainInfo
+ * @return
+ */
+ public int update(String id, Timestamp endDate, int resultType, String mainInfo) {
+ String updateSql = "UPDATE "+ entityName()
+ + " SET "+ LogModel.ENDDATE +"=?, "
+ + LogModel.RESULTSTATUS +"=?, "
+ + LogModel.MAININFO +"=? "
+ + "WHERE "+ LogModel.ID +"=? ";
+ return DBSql.update(updateSql, new Object[] {endDate, resultType, mainInfo, id});
+ }
+
+ @Override
+ public String entityName() {
+ return LogModel.DATABASE_ENTITY;
+ }
+
+ @Override
+ public RowMapper rowMapper() {
+ return new Mapper();
+ }
+
+ /**
+ * 获取单条日志记录信息
+ * @param id
+ * @return
+ */
+ public LogModel getInstance(String id) {
+ String sql = "SELECT * FROM " + entityName() + " WHERE ID = ?";
+ return DBSql.getObject(sql, rowMapper(), id);
+ }
+
+ /**
+ * 获取所有日志,按照创建时间倒序查询
+ * @return
+ */
+ public List getAllInstance() {
+ String sql = "SELECT * FROM " + entityName() + " ORDER BY " + LogModel.CREATEDATE + " DESC";
+ return DBSql.query(sql, rowMapper());
+ }
+
+ /**
+ * 删除
+ * @param id
+ * @throws AWSDataAccessException
+ */
+ public void remove(String id) throws AWSDataAccessException{
+ String sql = "DELETE FROM " + entityName()
+ + " WHERE " + LogModel.ID + "=?";
+ DBSql.update(sql, new Object[]{id});
+ }
+
+ /**
+ * 删除所有
+ */
+ public void removeAll() throws AWSDataAccessException{
+ String sql = "DELETE FROM " + entityName();
+ DBSql.update(sql);
+ }
+
+ private class Mapper implements RowMapper {
+ public LogModel mapRow(ResultSet rset, int rowNum) throws SQLException {
+ LogModel model = new LogModel();
+ try {
+ model.setId(rset.getString(LogModel.ID));
+ model.setWsId(rset.getString(LogModel.WSID));
+ model.setFileName(rset.getString(LogModel.FILENAME));
+ model.setFilePath(rset.getString(LogModel.FILEPATH));
+ model.setLogPath(rset.getString(LogModel.LOGPATH));
+ model.setCreateUser(rset.getString(LogModel.CREATEUSER));
+ model.setCreateUserName(rset.getString(LogModel.CREATEUSERNAME));
+ model.setCreateDate(rset.getTimestamp(LogModel.CREATEDATE));
+ model.setStartDate(rset.getTimestamp(LogModel.STARTDATE));
+ model.setEndDate(rset.getTimestamp(LogModel.ENDDATE));
+ model.setResultStatus(rset.getInt(LogModel.RESULTSTATUS));
+ model.setMainInfo(rset.getString(LogModel.MAININFO));
+ model.setExt1(rset.getString(LogModel.EXT1));
+ model.setExt2(rset.getString(LogModel.EXT2));
+ model.setExt3(rset.getString(LogModel.EXT3));
+ model.setExt4(rset.getString(LogModel.EXT4));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return model;
+ }
+ }
+
+
+}
diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/log/model/LogModel.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/log/model/LogModel.java
new file mode 100644
index 00000000..3aff4049
--- /dev/null
+++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/log/model/LogModel.java
@@ -0,0 +1,177 @@
+package com.actionsoft.apps.coe.pal.datamigration.log.model;
+
+import java.sql.Timestamp;
+
+/**
+ * 日志记录表
+ */
+public class LogModel {
+
+ public static final String DATABASE_ENTITY = "APP_ACT_COE_PAL_DATAM_LOG";
+ public static final String ID = "ID";
+ public static final String WSID = "WSID";
+ public static final String FILENAME = "FILENAME";
+ public static final String FILEPATH = "FILEPATH";
+ public static final String LOGPATH = "LOGPATH";
+ public static final String CREATEUSER = "CREATEUSER";
+ public static final String CREATEUSERNAME = "CREATEUSERNAME";
+ public static final String CREATEDATE = "CREATEDATE";
+ public static final String STARTDATE = "STARTDATE";
+ public static final String ENDDATE = "ENDDATE";
+ public static final String RESULTSTATUS = "RESULTSTATUS";
+ public static final String MAININFO = "MAININFO";
+ public static final String EXT1 = "EXT1";
+ public static final String EXT2 = "EXT2";
+ public static final String EXT3 = "EXT3";
+ public static final String EXT4 = "EXT4";
+
+
+
+ private String id;
+ private String wsId;// 资产库ID
+ private String fileName;// 上传文件名,若若是多个文件,只写一个文件,例如xxxxx文件等xx个文件
+ private String filePath;// dc路径(包含此次上传所有文件的上级文件夹路径)
+ private String logPath;// dc路径,存储日志文件的路径
+ private String createUser;// 创建人userId
+ private String createUserName;// 创建人中文名称
+ private Timestamp createDate;// 上传时间,程序开始导入时间
+ private Timestamp startDate;// 上传时间,程序开始导入时间
+ private Timestamp endDate;// 最终结束时间,成功/失败都需要记录
+ private int resultStatus;// 结果状态,0进行中,1成功,2失败
+ private String mainInfo;// 一句话简介整个上传结果,内容无限制,示例:若是进行中可描述为:正在上传;若是失败可描述为具体的异常信息;若是成功可描述为:上传多少条,成功多少条信息
+ private String ext1;// 扩展字段
+ private String ext2;// 扩展字段
+ private String ext3;// 扩展字段
+ private String ext4;// 扩展字段
+
+ public LogModel() {
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getWsId() {
+ return wsId;
+ }
+
+ public void setWsId(String wsId) {
+ this.wsId = wsId;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
+ public String getFilePath() {
+ return filePath;
+ }
+
+ public void setFilePath(String filePath) {
+ this.filePath = filePath;
+ }
+
+ public String getLogPath() {
+ return logPath;
+ }
+
+ public void setLogPath(String logPath) {
+ this.logPath = logPath;
+ }
+
+ public String getCreateUser() {
+ return createUser;
+ }
+
+ public void setCreateUser(String createUser) {
+ this.createUser = createUser;
+ }
+
+ public String getCreateUserName() {
+ return createUserName;
+ }
+
+ public void setCreateUserName(String createUserName) {
+ this.createUserName = createUserName;
+ }
+
+ public Timestamp getCreateDate() {
+ return createDate;
+ }
+
+ public void setCreateDate(Timestamp createDate) {
+ this.createDate = createDate;
+ }
+
+ public Timestamp getStartDate() {
+ return startDate;
+ }
+
+ public void setStartDate(Timestamp startDate) {
+ this.startDate = startDate;
+ }
+
+ public Timestamp getEndDate() {
+ return endDate;
+ }
+
+ public void setEndDate(Timestamp endDate) {
+ this.endDate = endDate;
+ }
+
+ public int getResultStatus() {
+ return resultStatus;
+ }
+
+ public void setResultStatus(int resultStatus) {
+ this.resultStatus = resultStatus;
+ }
+
+ public String getMainInfo() {
+ return mainInfo;
+ }
+
+ public void setMainInfo(String mainInfo) {
+ this.mainInfo = mainInfo;
+ }
+
+ public String getExt1() {
+ return ext1;
+ }
+
+ public void setExt1(String ext1) {
+ this.ext1 = ext1;
+ }
+
+ public String getExt2() {
+ return ext2;
+ }
+
+ public void setExt2(String ext2) {
+ this.ext2 = ext2;
+ }
+
+ public String getExt3() {
+ return ext3;
+ }
+
+ public void setExt3(String ext3) {
+ this.ext3 = ext3;
+ }
+
+ public String getExt4() {
+ return ext4;
+ }
+
+ public void setExt4(String ext4) {
+ this.ext4 = ext4;
+ }
+}
diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/log/model/LogRealTimeCountModel.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/log/model/LogRealTimeCountModel.java
new file mode 100644
index 00000000..d5bab425
--- /dev/null
+++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/log/model/LogRealTimeCountModel.java
@@ -0,0 +1,67 @@
+package com.actionsoft.apps.coe.pal.datamigration.log.model;
+
+import com.actionsoft.bpms.commons.mvc.model.ModelBean;
+
+
+public class LogRealTimeCountModel extends ModelBean {
+
+ private int totalCount;// 总共条数
+ private int successCount;// 成功条数
+ private int importingCount;// 当前正在导入的第几条数据
+ private int palExistsCount;// pal已存在条数,针对Aris xml流程导入
+ private int arisBlankCount;// aris没有模型的条数,针对Aris xml流程导入
+ private int matchFieldCount;// aris与PAL匹配失败的数据条数,针对Aris xml流程导入
+ // 可自定义其他类型数据导入/迁移计数对象
+
+
+ public LogRealTimeCountModel() {
+ }
+
+ public int getTotalCount() {
+ return totalCount;
+ }
+
+ public void setTotalCount(int totalCount) {
+ this.totalCount = totalCount;
+ }
+
+ public int getSuccessCount() {
+ return successCount;
+ }
+
+ public void setSuccessCount(int successCount) {
+ this.successCount = successCount;
+ }
+
+ public int getPalExistsCount() {
+ return palExistsCount;
+ }
+
+ public void setPalExistsCount(int palExistsCount) {
+ this.palExistsCount = palExistsCount;
+ }
+
+ public int getArisBlankCount() {
+ return arisBlankCount;
+ }
+
+ public void setArisBlankCount(int arisBlankCount) {
+ this.arisBlankCount = arisBlankCount;
+ }
+
+ public int getImportingCount() {
+ return importingCount;
+ }
+
+ public void setImportingCount(int importingCount) {
+ this.importingCount = importingCount;
+ }
+
+ public int getMatchFieldCount() {
+ return matchFieldCount;
+ }
+
+ public void setMatchFieldCount(int matchFieldCount) {
+ this.matchFieldCount = matchFieldCount;
+ }
+}
diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/plugin/Plugins.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/plugin/Plugins.java
index f54775f6..61ee1fd4 100755
--- a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/plugin/Plugins.java
+++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/plugin/Plugins.java
@@ -1,5 +1,7 @@
package com.actionsoft.apps.coe.pal.datamigration.plugin;
+import com.actionsoft.apps.coe.pal.datamigration.aris.constant.ArisConstant;
+import com.actionsoft.apps.coe.pal.datamigration.log.cache.LogRealTimeCountCache;
import com.actionsoft.apps.coe.pal.datamigration.web.DataMigrationWeb;
import com.actionsoft.apps.coe.pal.pal.repository.upfile.CoeFileProcessor;
import com.actionsoft.apps.listener.PluginListener;
@@ -21,8 +23,11 @@ public class Plugins implements PluginListener {
public List register(AppContext context) {
List list = new ArrayList();
+ // 注册缓存
+ list.add(new CachePluginProfile(LogRealTimeCountCache.class));
list.add(new DCPluginProfile("migration", CoeFileProcessor.class.getName(), "存放数据迁移文件", false, false));
+ list.add(new DCPluginProfile(ArisConstant.REPOSITORY_NAME, CoeFileProcessor.class.getName(), "存在arisXML数据迁移日志", false, false));
// PAL应用扩展点
Map params0 = new HashMap();
diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/LogUtil.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/LogUtil.java
new file mode 100644
index 00000000..3ad528e8
--- /dev/null
+++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/LogUtil.java
@@ -0,0 +1,159 @@
+package com.actionsoft.apps.coe.pal.datamigration.util;
+
+import com.actionsoft.apps.coe.pal.datamigration.log.dao.LogDao;
+import com.actionsoft.apps.coe.pal.datamigration.log.model.LogModel;
+import com.actionsoft.bpms.commons.log.auditing.constant.AuditConst;
+import com.actionsoft.bpms.commons.security.logging.model.Level;
+import com.actionsoft.bpms.server.UserContext;
+import com.actionsoft.sdk.local.SDK;
+
+import java.io.*;
+import java.nio.charset.StandardCharsets;
+import java.sql.Timestamp;
+import java.util.List;
+
+public class LogUtil {
+
+ /**
+ * 追加日志内容
+ * @param content 内容
+ * @param file 文件
+ */
+ public static void appendLog(String content, File file) {
+ try {
+ String logFilePath = file.getPath();
+ // 构造函数中的第二个参数true表示以追加形式写文件
+ FileOutputStream fos = new FileOutputStream(logFilePath, true);
+ OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
+ osw.write(content + "\n");
+ osw.close();
+ fos.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.out.println("文件写入失败!" + e);
+ }
+ }
+
+ public static void appendLog(String content, File ... files) {
+ for (File file : files) {
+ appendLog(content, file);
+ }
+ }
+
+ public static String getStackTrace(Throwable t) {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ try {
+ t.printStackTrace(pw);
+ return sw.toString();
+ } finally {
+ pw.close();
+ }
+ }
+
+ public static String getLogContent(File file) {
+ StringBuilder builder = new StringBuilder();
+ InputStreamReader reader = null;
+ BufferedReader br = null;
+ try {
+ reader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8);
+ br = new BufferedReader(reader);
+ String s;
+ while ((s = br.readLine()) != null) {
+ builder.append(s).append("\n");
+ }
+
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ if (reader != null) {
+ reader.close();
+ }
+ if (br != null) {
+ br.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ return builder.toString();
+ }
+
+ /**
+ * 记录一条审计日志
+ * @param me
+ * @param op
+ * @param obj
+ * @param info
+ * @param level
+ */
+ public static void recordAuditLog(UserContext me, String op, String obj, String info, Level level) {
+ SDK.getLogAPI().audit(AuditConst.CHANNEL_CLIENT, AuditConst.CATALOG_PROCESS, me.getUID(), op, obj, info, me.getClientIP(), level);
+ }
+
+ /**
+ * 创建日志(日志操作行为,非具体日志信息)
+ * @param model
+ * @return
+ */
+ public static int createLog(LogModel model) {
+ return new LogDao().insert(model);
+ }
+
+ /**
+ * 查询日志(日志操作行为,非具体日志信息)
+ * @param id
+ * @return
+ */
+ public static LogModel queryLog(String id) {
+ return new LogDao().getInstance(id);
+ }
+
+ /**
+ * 删除日志(日志操作行为,非具体日志信息)
+ * @param id
+ */
+ public static void removeLog(String id) {
+ new LogDao().remove(id);
+ }
+
+ /**
+ * 清空日志(日志操作行为,非具体日志信息)
+ */
+ public static void removeAllLog() {
+ new LogDao().removeAll();
+ }
+
+ /**
+ * 查询所有日(日志操作行为,非具体日志信息),按照创建时间倒序
+ * @return
+ */
+ public static List queryAllLog() {
+ return new LogDao().getAllInstance();
+ }
+
+ /**
+ * 更新日志(日志操作行为,非具体日志信息)
+ * @param model
+ * @return
+ */
+ public static int updateLog(LogModel model) {
+ return new LogDao().update(model);
+ }
+
+ /**
+ * 更新日志(日志操作行为,非具体日志信息)
+ * @param id
+ * @param endDate 结束时间
+ * @param resultType 结果状态
+ * @param mainInfo 主要信息
+ * @return
+ */
+ public static int updateLog(String id, Timestamp endDate, int resultType, String mainInfo) {
+ return new LogDao().update(id, endDate, resultType, mainInfo);
+ }
+
+}
diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/ProcessUtil.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/ProcessUtil.java
index 7f47fc2c..39b2ddfa 100644
--- a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/ProcessUtil.java
+++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/ProcessUtil.java
@@ -9,11 +9,14 @@ import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodModel;
import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryAPIManager;
import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager;
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
+import com.actionsoft.apps.coe.pal.pal.repository.util.CoeProcessLevelUtil;
import com.actionsoft.apps.lifecycle.api.AppsAPIManager;
import com.actionsoft.apps.resource.AppContext;
import com.actionsoft.bpms.server.UserContext;
import com.actionsoft.i18n.I18nRes;
+import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
+import org.apache.commons.lang.StringUtils;
import java.util.*;
@@ -183,11 +186,8 @@ public class ProcessUtil {
* @return
*/
public static boolean isView(PALRepositoryModel model) {
- if (model.isPublish() || model.isApproval() || model.isStop()) {
- return true;
- }
- return false;
- }
+ return model.isPublish() || model.isApproval() || model.isStop();
+ }
/**
*
@@ -197,10 +197,21 @@ public class ProcessUtil {
public static boolean isBlank(UserContext uc, PALRepositoryModel model) {
String define = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(uc, model.getId());
JSONObject array = JSONObject.parseObject(define);
- if (array.containsKey("elements") && array.getJSONObject("elements").size() == 0) {
- return true;
+ return array.containsKey("elements") && array.getJSONObject("elements").size() == 0;
+ }
+
+ /**
+ * 获取模型文本路径
+ * @param id
+ * @return
+ */
+ public static String getRepositoryPath(String id) {
+ JSONArray pathArr = CoeProcessLevelUtil.getRepositoryPath(id);
+ List list = new ArrayList<>();
+ for (int i = 0; i < pathArr.size(); i++) {
+ list.add(pathArr.getJSONObject(i).getString("name"));
}
- return false;
+ return StringUtils.join(list, "\\");
}
}
diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/WordUtil.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/WordUtil.java
index 31f7319b..dfce5459 100644
--- a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/WordUtil.java
+++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/WordUtil.java
@@ -3,6 +3,7 @@ package com.actionsoft.apps.coe.pal.datamigration.util;
import com.actionsoft.apps.coe.pal.datamigration.constant.Constant;
import com.actionsoft.apps.coe.pal.datamigration.model.po.WordAttribute;
import com.actionsoft.apps.coe.pal.datamigration.model.po.WordField;
+import com.actionsoft.apps.coe.pal.pal.ws.web.VersionUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@@ -271,9 +272,13 @@ public class WordUtil {
String text = cell.text().trim();
//去除text特殊符号
if (null != text && !"".equals(text)) {
- text = text.replaceAll("\\p{C}", "");
+ text = text.replaceAll("\\p{C}", " ");
+ }
+ if (text.matches("[\\u4e00-\\u9fa5\\s]+$")){
+ text = text.replace(" ",",");
+ }else {
+ text = text.replace(" ","");
}
- text.replace(" ","");
if (i == 0){
//首行为标题行
diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readword/CustomXWPFDocument.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readword/CustomXWPFDocument.java
new file mode 100644
index 00000000..ad86764f
--- /dev/null
+++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readword/CustomXWPFDocument.java
@@ -0,0 +1,94 @@
+package com.actionsoft.apps.coe.pal.datamigration.util.readword;
+
+/**
+ * @author baizp
+ * @Description:
+ * @date 2022/6/21 17:21
+ */
+import java.io.IOException;
+
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
+import org.apache.xmlbeans.*;
+import org.openxmlformats.schemas.drawingml.x2006.main.*;
+import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTInline;
+
+/**
+ * [ref] https://issues.apache.org/bugzilla/show_bug.cgi?id=49765
+ * [ref] http://pastebin.com/index/CbQ3iw8t, http://pastebin.com/2YAneYgt
+ */
+public class CustomXWPFDocument extends XWPFDocument
+{
+ public CustomXWPFDocument() throws IOException
+ {
+ super();
+ }
+
+ public void createPictureCxCy(String blipId,int id, long cx, long cy)
+ {
+ CTInline inline = createParagraph().createRun().getCTR().addNewDrawing().addNewInline();
+
+ String picXml = "" +
+ "" +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ "";
+
+ //CTGraphicalObjectData graphicData = inline.addNewGraphic().addNewGraphicData();
+ XmlToken xmlToken = null;
+ try
+ {
+ xmlToken = XmlToken.Factory.parse(picXml);
+ }
+ catch(XmlException xe)
+ {
+ xe.printStackTrace();
+ }
+ inline.set(xmlToken);
+ //graphicData.set(xmlToken);
+
+ inline.setDistT(0);
+ inline.setDistB(0);
+ inline.setDistL(0);
+ inline.setDistR(0);
+
+ CTPositiveSize2D extent = inline.addNewExtent();
+ extent.setCx(cx);
+ extent.setCy(cy);
+
+ CTNonVisualDrawingProps docPr = inline.addNewDocPr();
+ docPr.setId(id);
+ docPr.setName("Picture " + id);
+ docPr.setDescr("Generated");
+ }
+
+ public void createPicture(String blipId,int id, int width, int height)
+ {
+ final int EMU = 9525;
+ width *= EMU;
+ height *= EMU;
+ //String blipId = getAllPictures().get(id).getPackageRelationship().getId();
+
+ createPictureCxCy(blipId, id, width, height);
+ }
+}
diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readword/WordFinal.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readword/WordFinal.java
index cbf2502f..40d0ebe3 100644
--- a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readword/WordFinal.java
+++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readword/WordFinal.java
@@ -174,13 +174,12 @@ public class WordFinal {
if("f".equals(type)){
model.setShape_uuid("");
model.setType("f");
- model.setPl_uuid(reid);
}else {
model.setShape_uuid(reid);
model.setType("s");
- model.setPl_uuid("");
}
model.setUuid(UUIDGener.getUUID());
+ model.setPl_uuid(reid);
model.setFileName(filename);
model.setDownload(1);
model.setCreateUser(me.getUID());
diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/web/DataMigrationWeb.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/web/DataMigrationWeb.java
index cb416065..b6e48ae4 100644
--- a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/web/DataMigrationWeb.java
+++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/web/DataMigrationWeb.java
@@ -5,12 +5,15 @@ import com.actionsoft.apps.coe.pal.datamigration.aris.mapping.ModelMappingAPIMan
import com.actionsoft.apps.coe.pal.datamigration.aris.model.*;
import com.actionsoft.apps.coe.pal.datamigration.aris.util.XMLUtil;
import com.actionsoft.apps.coe.pal.datamigration.aris.web.ArisXmlHandleWeb;
+import com.actionsoft.apps.coe.pal.datamigration.aris.web.ArisXmlImportWeb;
import com.actionsoft.apps.coe.pal.datamigration.constant.Constant;
import com.actionsoft.apps.coe.pal.datamigration.model.po.AwsOrgInfo;
import com.actionsoft.apps.coe.pal.datamigration.model.po.WordField;
import com.actionsoft.apps.coe.pal.datamigration.util.ExcelUtil;
import com.actionsoft.apps.coe.pal.datamigration.util.ShapeUtil;
import com.actionsoft.apps.coe.pal.datamigration.util.WordUtil;
+import com.actionsoft.apps.coe.pal.log.CoEOpLogAPI;
+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.repository.PALRepositoryAPIManager;
@@ -104,1351 +107,11 @@ public class DataMigrationWeb extends ActionWeb {
macroLibraries.put("settingParam", JSON.toJSON(macroLibraries));
// 操作行为日志记录 todo
if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) {
- // CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_APPCENTER, CoEOpLogConst.OP_ACCESS, CoEOpLogConst.INFO_APPCENTER_ACCESS_PREFIX + SDK.getAppAPI().getAppContext(ProcessListConstant.PROCESSLIST).getName() + CoEOpLogConst.INFO_APPCENTER_ACCESS_SUFFIX);
- printMsg("记录行为操作日志");
+ CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_APPCENTER, CoEOpLogConst.OP_ACCESS, CoEOpLogConst.INFO_APPCENTER_ACCESS_PREFIX + SDK.getAppAPI().getAppContext(Constant.APP_ID).getName() + CoEOpLogConst.INFO_APPCENTER_ACCESS_SUFFIX);
}
return HtmlPageTemplate.merge(Constant.APP_ID, "main.htm", macroLibraries);
}
- /**
- * 迁移测试
- *
- * @param wsId
- * @return
- */
- public String dataMigrate(String wsId, String groupValue, String fileValue, String fileName) {
- ResponseObject ro = ResponseObject.newOkResponse();
- // 校验资产库
- boolean isActive = PALRepositoryQueryAPIManager.getInstance().isActiveWorkSpace(wsId);
- if (!isActive) {
- return ResponseObject.newErrResponse("资产库不存在或已停用").toString();
- }
- DCPluginProfile dcProfile = DCProfileManager.getDCProfile("com.actionsoft.apps.coe.pal.datamigration", "migration");
- DCContext dc = new DCContext(_uc, dcProfile, "com.actionsoft.apps.coe.pal.datamigration", groupValue, fileValue, fileName);
- File file = new File(dc.getFilePath());
-
- if (!file.exists()) {
- ro = ResponseObject.newErrResponse("上传文件不存在");
- return ro.toString();
- } else if (!".xml".equals(fileName.substring(fileName.lastIndexOf(".")))) {
- ro = ResponseObject.newErrResponse("上传文件格式不正确,请上传xml文件");
- return ro.toString();
- }
-
- //
- String number = this.checkMethodInfo(wsId, "process.epc", "process", "process.epc", "过程链图", "编号", Constant.METHOD_NUMBER);
- if (UtilString.isNotEmpty(number)) return ResponseObject.newWarnResponse(number).toString();
- // 校验角色图下是否有建模属性【岗位】
- // String post = this.checkMethodInfo(wsId, "org.normal", "org", "org.normal", "角色图", "岗位", Constant.METHOD_POST);
- // if (UtilString.isNotEmpty(post)) return ResponseObject.newWarnResponse(post).toString();
- // 校验过程链图下是否有建模属性【角色】
- String role = this.checkMethodInfo(wsId, "process.epc", "process", "process.epc", "过程链图", "角色", Constant.METHOD_ROLE);
- if (UtilString.isNotEmpty(role)) return ResponseObject.newWarnResponse(role).toString();
- // 校验过程链图下是否有建模属性【IT系统】
- String itSystem = this.checkMethodInfo(wsId, "process.epc", "process", "process.epc", "过程链图", "IT系统", Constant.METHOD_INFO_SYSTEM);
- if (UtilString.isNotEmpty(itSystem)) return ResponseObject.newWarnResponse(itSystem).toString();
- // 校验过程链图下是否有建模属性【输入】
- String input = this.checkMethodInfo(wsId, "process.epc", "process", "process.epc", "过程链图", "输入", Constant.METHOD_INPUT);
- if (UtilString.isNotEmpty(input)) return ResponseObject.newWarnResponse(input).toString();
- // 校验过程链图下是否有建模属性【输出】
- String out = this.checkMethodInfo(wsId, "process.epc", "process", "process.epc", "过程链图", "输出", Constant.METHOD_OUTPUT);
- if (UtilString.isNotEmpty(out)) return ResponseObject.newWarnResponse(out).toString();
- List attributeModels = PALRepositoryAPIManager.getInstance().getValidAttributeModels(wsId, "process.epc");
- List leadProcess = attributeModels.stream().filter(item -> Constant.METHOD_PRE_PROCESS.equals(item.getKey())).collect(Collectors.toList());
- if (leadProcess.size() == 0) {
- return ResponseObject.newWarnResponse("请打开建模管理应用,查看当前建模分类【过程链图】下是否存在【前置流程/" + Constant.METHOD_PRE_PROCESS + "】建模属性").toString();
- }
- List rearProcess = attributeModels.stream().filter(item -> Constant.METHOD_NEXT_PROCESS.equals(item.getKey())).collect(Collectors.toList());
- if (rearProcess.size() == 0) {
- return ResponseObject.newWarnResponse("请打开建模管理应用,查看当前建模分类【过程链图】下是否存在【后置流程/" + Constant.METHOD_NEXT_PROCESS + "】建模属性").toString();
- }
- // 校验过程链图下是否有文件属性【前置流程】【后置流程】
- PALRepositoryAttributeDao attributeDao = new PALRepositoryAttributeDao();
- List fileAttributes = attributeDao.getFileAttribute(wsId, "process.epc");
- fileAttributes = fileAttributes.stream()
- .filter(attrModel -> Constant.METHOD_PRE_PROCESS.equals(attrModel.getAttrId()) || Constant.METHOD_NEXT_PROCESS.equals(attrModel.getAttrId()))
- .collect(Collectors.toList());
- if (fileAttributes.size() < 2) {
- return ResponseObject.newWarnResponse("请打开建模管理应用,查看当前建模分类【过程链图】下是否存在【前置/后置流程|" + Constant.METHOD_PRE_PROCESS + "/" + Constant.METHOD_NEXT_PROCESS + "】建模属性").toString();
- }
-
- // wsId = "ad5f246a-b618-4908-92f8-94fda59c78eb";// 测试资产库--伊利项目
- // String filePath = "/Users/actionsoft/Documents/workspace/IDEA/yili/apps/com.actionsoft.apps.coe.pal.datamigration/testFile/sourceFile/";
- // String fileName = "999actionsoft.xml";
- // String fileName = "publishxmlexport.xml";
- // String fileName = "xmlexport.xml";
- // 读取xml文件
- Document d = XMLUtil.readXML(file.getPath(), true);
- String toFilePath = "/Users/sunlh/Documents/ideaData/actionsoft/aws6.4.1.1008.yili2/apps/com.actionsoft.apps.coe.pal.datamigration/testFile/targetFile/";
- XMLUtil.writeXml(d, toFilePath + fileName);
- // 解析xml文件
- if (d == null) {
- return ResponseObject.newErrResponse().toString();
- }
- ArisXmlHandleWeb handleWeb = new ArisXmlHandleWeb();
- // 解析
- handleWeb.handleXmlDoc(d);
-
- Map groupMap = handleWeb.groupMap;// 文件夹/组基本信息map记录
-
- Map modelMap = handleWeb.modelMap;// 模型基本信息map记录
-
- Map objDefMap = handleWeb.objDefMap;// 形状定义map记录
-
- Map> modelObjOccMap = handleWeb.modelObjOccMap;// 模型内形状map记录
-
- Map objOccMap = handleWeb.objOccMap;// 所有形状
-
- Map> cxnOccMap = handleWeb.cxnOccMap;// 形状连线记录
-
- Map> objDefLinkerMap = handleWeb.objDefLinkerMap;// 记录所有定义形状的连线map记录
-
- Map> methodAttrsMap = new HashMap<>();// 属性存储
-
- // 获取所有IT系统图,并查询所有IT系统形状
- Map itShapeMap = new HashMap<>();
- Set ids = new HashSet<>();
- List itModels = new ArrayList<>();
- PALRepositoryCache.getAllChildrenModelsByPid(wsId, "itsystem", itModels, ids);
- for (PALRepositoryModel itModel : itModels) {
- String definition = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(null, itModel.getId());
- List list = com.actionsoft.apps.coe.pal.pal.repository.designer.util.ShapeUtil.getShapeJsonToJsonObject(definition);
- for (JSONObject shape: list) {
- JSONObject obj = new JSONObject();
- obj.put("shapeId", shape.getString("id"));
- obj.put("plId", itModel.getId());
- obj.put("shapeName", shape.getString("text"));
- itShapeMap.put(shape.getString("text"), obj);
- }
- }
-
- PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel();
-
- // 存储匹配到与未匹配到的模型信息
- List matchModels = new ArrayList<>();
- List unMatchModels = new ArrayList<>();
- // 存储已经匹配上但是文件里已经有内容【可能导入重复】的模型信息
- List repeatModels = new ArrayList<>();
- // 存储不包含图形的流程,无任何形状的流程不进行导入
- List currentModelNoShape = new ArrayList<>();
- for (Map.Entry entry : modelMap.entrySet()) {
- ModelModel arisModel = entry.getValue();
- // 创建角色模型
- List objOccModels = modelObjOccMap.get(arisModel.getId());
- if (objOccModels == null || objOccModels.size() == 0) {
- currentModelNoShape.add(arisModel);
- printMsg("流程" + arisModel.getName() + arisModel.getId() + "无任何模型,导入忽略");
- continue;
- }
- // 匹配模型
- PALRepositoryModel palModel = matchPalModel(arisModel, wsId);
- if (palModel != null) {
- matchModels.add(arisModel);
- String plId = palModel.getId();
- // 模型是否可导入
- BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(plId, 0);
- if (defineModel == null) {
- defineModel = CoeDesignerUtil.createModel(plId, 0);
- defineModel.setCreateHistory(false);
- }
- String timestamp = new SimpleDateFormat(CoeDesignerConstant.DATE_TIME_STYLE_YYYY_MM_DD_HH_MM_SS).format(new Date());
- defineModel.setUpdateTime(timestamp);
- String define = defineModel.getDefinition();
- JSONObject definition = JSONObject.parseObject(define);
- JSONObject elements = definition.getJSONObject("elements");
- if (elements != null && !elements.isEmpty()) {
- // 导入模型已存在数据,不允许导入 todo
- repeatModels.add(arisModel);
- printMsg("[" + arisModel.getName() + "] 导入流程模型已存在数据,不允许导入,对同名角色模型进行忽略处理");
- continue;
- }
-
- String rolefolderId = checkAndCreatePalRoleFolderModel(coeProcessLevel, wsId);// 创建/获取角色文件夹ID,作为角色的顶级文件夹
- Map arisFunIdRelationPalRoleMap = new HashMap<>();// aris功能模型与aris角色模型的id映射,key:aris fun shape id,value:pal role id
- Map palRoleIdRelationNameMap = new HashMap<>();// key pal role shape id ,value:pal role shape text
- // 创建角色模型和角色元素,并且获取aris角色与pal角色映射关系
- String roleMdoelId = createRoleModelAndElements(coeProcessLevel, rolefolderId, wsId, currentModelNoShape, palModel, arisModel, modelObjOccMap, objDefMap, objOccMap, cxnOccMap, objDefLinkerMap, arisFunIdRelationPalRoleMap, methodAttrsMap, palRoleIdRelationNameMap);
-
- // 存储当前模型下ARIS图形ID与PAL图形ID映射关系
- Map idRelationMap = new HashMap<>();
-
- Map palShapeIdRelationArisOccIdMap = new HashMap<>();
- // 创建形状和连线
- JSONObject newElements = createShapeElement(wsId, idRelationMap, palModel, arisModel, modelObjOccMap, objDefMap, objOccMap, cxnOccMap, palShapeIdRelationArisOccIdMap);
-
- // 处理输入输出活动属性
- this.handleShapeInputOutAttr(palModel, newElements);
-
- // 处理角色属性与流程相应的活动节点关联
- this.handleProcessAttrRoleRelation(wsId, palModel.getId(), arisFunIdRelationPalRoleMap, palShapeIdRelationArisOccIdMap, newElements, arisModel, modelObjOccMap, objDefMap, roleMdoelId, palRoleIdRelationNameMap);
-
- // 处理流程关联属性IT系统
- this.handleProcessAttrItSystemRelation(wsId, idRelationMap, palModel.getId(), newElements, arisModel, modelObjOccMap, objDefMap, objDefLinkerMap, itShapeMap);
-
- this.handleProcessAttrLeadOrRearProcess(wsId, currentModelNoShape, idRelationMap, palModel.getId(), newElements, arisModel, modelObjOccMap, objDefMap);
-
- // 增加其他默认的属性,值默认为空 by孙连辉 20220626
- this.handleShapeDefaultAttr(wsId, palModel, newElements, methodAttrsMap);
-
- definition.put("elements", newElements);
- // 设置画布大小
- setDiagramHeightWidth(definition, newElements);
- defineModel.setDefinition(definition.toString());
- // 保存文件
- CoeDesignerAPIManager.getInstance().storeDefinition(defineModel);// dao操作
-
- } else {
- unMatchModels.add(arisModel);
- }
- }
- // System.out.println(wsId);
- ro = ResponseObject.newOkResponse("处理完毕");
- ro.put("matchModels", matchModels);
- ro.put("unMatchModels", unMatchModels);
- ro.put("repeatModels", repeatModels);
- ro.put("currentModelNoShape", currentModelNoShape);
- return ro.toString();
- }
-
- /**
- * 创建角色模型和角色元素,并且获取aris角色与pal角色映射关系
- * 角色与流程活动都是以角色为起点连接流程活动
- * 角色与岗位都是以岗位为起点连接角色
- * 活动与角色是1对1关系,不存在单活动对应多个角色
- * @param coeProcessLevel
- * @param parentId
- * @param wsId
- * @param currentModelNoShape
- * @param palModel
- * @param arisModel
- * @param modelObjOccMap
- * @param objDefMap
- * @param objOccMap
- * @param cxnOccMap
- * @param objDefLinkerMap
- * @param arisFunIdRelationPalRoleMap
- * @param methodAttrsMap
- * @return
- */
- private String createRoleModelAndElements(PALRepository coeProcessLevel, String parentId, String wsId, List currentModelNoShape, PALRepositoryModel palModel, ModelModel arisModel, Map> modelObjOccMap, Map objDefMap, Map objOccMap, Map> cxnOccMap, Map> objDefLinkerMap, Map arisFunIdRelationPalRoleMap, Map> methodAttrsMap, Map palRoleIdRelationNameMap) {
- // 统计模型内的角色信息,创建角色与形状的关联关系,提前创建活动与角色的id关联关系,建立角色的角色图,角色图中处理岗位为文本属性内容
-
- // 统计模型内所有的角色形状
- List objOccModels = modelObjOccMap.get(arisModel.getId());
- // 获取角色
- List roleObjOccModels = new ArrayList<>();
- for (ObjOccModel objOccModel : objOccModels) {
- ObjDefModel objDefModel = objDefMap.get(objOccModel.getDefId());
- if (objDefModel.getTypeNum().equals("OT_PERS_TYPE") && objDefModel.getSymbolNum().equals("ST_EMPL_TYPE")) {// 角色
- roleObjOccModels.add(objOccModel);
- }
- }
- if (roleObjOccModels.size() == 0) {
- printMsg("流程模型" + palModel.getName() + "无任何角色模型,忽略角色与岗位导入");
- return null;
- }
- // 创建角色与形状关联关系
- // 获取当前aris模型内的所有角色list
- List roleCxnOccModels = new ArrayList<>();
- for (ObjOccModel roleOccModel : roleObjOccModels) {
- List list = cxnOccMap.get(roleOccModel.getId());
- for (CxnOccModel cxnOccModel : list) {
- if (cxnOccModel.getModelId().equals(arisModel.getId())) {
- roleCxnOccModels.add(cxnOccModel);
- }
- }
- }
- if (roleCxnOccModels.size() == 0) {
- printMsg("流程模型" + palModel.getName() + "无任何角色模型与流程活动进行连接,忽略角色与岗位导入");
- return null;
- }
-
- // 记录重复的角色,根据名称进行记录
- Map> repeatRoleMap = new HashMap<>();
- // 记录aris功能活动与角色的关系
- Map arisFunRelationRoleMap = new HashMap<>();
- // 记录重复的角色名称
- for (CxnOccModel cxnOccModel: roleCxnOccModels) {
- ObjOccModel occModel = objOccMap.get(cxnOccModel.getId());
- ObjDefModel objDefModel = objDefMap.get(occModel.getDefId());
- arisFunRelationRoleMap.put(cxnOccModel.getToId(), objDefModel.getName());
- String roleName = objDefModel.getName();
- if (!repeatRoleMap.containsKey(roleName)) {
- repeatRoleMap.put(roleName, new HashSet<>());
- }
- repeatRoleMap.get(roleName).add(occModel.getId());
- }
-
- // 创建角色图的名称与PAL角色图形状ID对应关系
- Map roleNamePalIdMap = new HashMap<>();
- for (String roleName : repeatRoleMap.keySet()) {
- String roleShapeId = UUIDGener.getObjectId();
- roleNamePalIdMap.put(roleName, roleShapeId);
- palRoleIdRelationNameMap.put(roleShapeId, roleName);
- }
- // 记录Aris功能Occ ID与PALroleId关联关系
- for (Map.Entry entry : arisFunRelationRoleMap.entrySet()) {
- if (roleNamePalIdMap.containsKey(entry.getValue())) {
- arisFunIdRelationPalRoleMap.put(entry.getKey(), roleNamePalIdMap.get(entry.getValue()));
- }
- }
-
- // 角色名称与岗位名称合集
- Map> roleRelationPositonMap = new HashMap<>();
- // 查找角色对应的岗位
- for (ObjOccModel roleOccModel : roleObjOccModels) {
- ObjDefModel roleObjDefModel = objDefMap.get(roleOccModel.getDefId());
- String linkedModelIds = roleObjDefModel.getLinkedModelIds();
- if (UtilString.isEmpty(linkedModelIds)) {// 角色无关联角色图
- printMsg("流程模型" + palModel.getName() + roleObjDefModel.getName() + "角色无任何关联岗位,忽略该角色岗位");
- } else {// 角色有关联角色图
- List relationPositonList = modelObjOccMap.get(linkedModelIds);// linkedModelIds按照单个值对待,暂无发现多值
- if (relationPositonList == null || relationPositonList.size() == 0) {// 角色有关联图但是关联的角色图查询不到
- printMsg("流程模型" + palModel.getName() + roleObjDefModel.getName() + "角色存在关联LinkedModels.IdRefs:" + linkedModelIds + " 但无法查询对应Model内容");
- } else {
- for (ObjOccModel objOccModel: relationPositonList) {
- ObjDefModel positionDefModel = objDefMap.get(objOccModel.getDefId());
- if (positionDefModel.getTypeNum().equals("OT_POS") && positionDefModel.getSymbolNum().equals("ST_POS")) {
- // 查询出岗位,记录到角色中,角色名称为key,岗位名称为value
- if (!roleRelationPositonMap.containsKey(roleObjDefModel.getName())) {
- roleRelationPositonMap.put(roleObjDefModel.getName(), new HashSet<>());
- }
- roleRelationPositonMap.get(roleObjDefModel.getName()).add(positionDefModel.getName());
- }
- }
- }
- }
- }
-
- // 生成一个空的与流程同名角色模型文件
- String id = UUIDGener.getUUID();
- int orderIndex = coeProcessLevel.getChildrenMaxOrderIndexByPidAndWsId(parentId, wsId) + 1;
- Timestamp nowTime = new Timestamp(System.currentTimeMillis());
-
- PALRepositoryModelImpl model = CoeProcessLevelUtil.createPALRepositoryModel(id, UUIDGener.getUUID(), wsId, arisModel.getName(), "", orderIndex, parentId, "org", true, 1,
- id, false, "org.role", "0", 1, null, null, _uc.getUID(), _uc.getUID(), nowTime, null, null, null, null,
- null, null, null, null, null, -1);
- coeProcessLevel.insert(model);
- printMsg("与流程同名的角色空模型创建完成【文件ID】" + model.getId());
- BaseModel baseModel = CoeDesignerAPIManager.getInstance().getDefinition(model.getId(), 0);
- if (baseModel == null) {
- baseModel = CoeDesignerUtil.createModel(model.getId(), 0);
- baseModel.setCreateHistory(false);
- }
- baseModel.setUpdateTime(new SimpleDateFormat(CoeDesignerConstant.DATE_TIME_STYLE_YYYY_MM_DD_HH_MM_SS).format(new Date()));
- String define = baseModel.getDefinition();
- JSONObject definition = JSONObject.parseObject(define);
- JSONObject elements = definition.getJSONObject("elements");
- Map objDefMappingMap = ModelMappingAPIManager.getInstance().getObjDefMappingMap();
- ObjDefMappingModel objDefMappingModel = objDefMappingMap.get("OT_PERS_TYPE-ST_EMPL_TYPE");
- String shapeMethodId = objDefMappingModel.getShapeMethod();
- String shapeType = objDefMappingModel.getShapeType();
- JSONObject shapeDefine = ShapeUtil.getProcessShapeDefinitionByName(shapeMethodId, shapeType);
-
- JSONArray shapes = new JSONArray();
- for (Map.Entry entry: roleNamePalIdMap.entrySet()) {
- String shapeText = entry.getKey();
- String shapeId = entry.getValue();
- JSONObject newShape = JSONObject.parseObject(shapeDefine.toString());
- newShape.put("id", shapeId);
- newShape.put("text", shapeText);
- shapes.add(newShape);
- }
-
- JSONArray newShapes = this.getMethodElementsJSONArray(shapes, 6);
- for (int i = 0; i < newShapes.size(); i++) {
- JSONObject shapeObj = newShapes.getJSONObject(i);
- elements.put(shapeObj.getString("id"), shapeObj);
- printMsg("生成角色图 角色【" + shapeObj.getString("text") + "】");
- }
-
- // 设置角色图形状默认属性配置
- this.handleShapeDefaultAttr(wsId, palModel, elements, methodAttrsMap);
-
- // 完善岗位属性
- for (String key : elements.keySet()) {
- JSONObject shape = elements.getJSONObject(key);
- if ("linker".equals(shape.getString("name"))) {
- continue;
- }
- String shapeText = shape.getString("text");
- if (roleRelationPositonMap.containsKey(shapeText) && roleRelationPositonMap.get(shapeText).size() > 0) {
- Set postText = roleRelationPositonMap.get(shapeText);
- List list = new ArrayList<>(postText);
- Collections.sort(list);
- String postTextVal = StringUtils.join(list, ",");// 岗位内容
- JSONArray dataAttributes = shape.getJSONArray("dataAttributes");
- if (!dataAttributes.isEmpty() && dataAttributes.size() > 0) {
- for (Object attribute : dataAttributes) {
- JSONObject obj = (JSONObject) attribute;
- if (obj.containsKey("attributesJsonArray")) {
- JSONArray attributesJsonArray = obj.getJSONArray("attributesJsonArray");
- boolean flag = false;
- for (int i = 0; i < attributesJsonArray.size(); i++) {
- if (attributesJsonArray.getJSONObject(i).containsKey("id")) {
- String attrId = Constant.METHOD_POST_TEXT;
- if (attrId.equals(attributesJsonArray.getJSONObject(i).getString("id"))) {
- flag = true;
- attributesJsonArray.getJSONObject(i).put("value", postTextVal);
- printMsg("角色图" + model.getName() + "角色" + shapeText + "岗位属性值为" + postTextVal);
- }
- }
- }
- if (!flag) {
- printMsg("角色图" + model.getName() + "角色" + shapeText + "没有岗位属性配置" + Constant.METHOD_POST_TEXT);
- }
- }
- }
- }
- } else {
- printMsg("角色图" + model.getName() + "角色" + shapeText + "无岗位属性内容值");
- }
- }
- definition.put("elements", elements);
- // 设置画布大小
- setDiagramHeightWidth(definition, elements);
- baseModel.setDefinition(definition.toString());
- // 保存文件
- CoeDesignerAPIManager.getInstance().storeDefinition(baseModel);// dao操作
- return id;
- }
-
- /**
- * 校验和创建角色模型文件夹
- * @param coeProcessLevel
- * @param wsId
- * @return 已经存在的或新创建的角色模型ID
- */
- private String checkAndCreatePalRoleFolderModel(PALRepository coeProcessLevel, String wsId) {
- // 组织下创建【角色模型】文件夹
- List defaultModels = PALRepositoryQueryAPIManager.getInstance().getPalRepositoryModelsByWsIdAndMethodId(wsId, "org");
- defaultModels = defaultModels.stream()
- .filter(model -> "default".equals(model.getMethodId()))
- .filter(model -> Constant.DEFAULT_FOLDER_NAME.equals(model.getName())).collect(Collectors.toList());
- if (defaultModels.size() == 0) {
- String id = UUIDGener.getUUID();
-
- int orderIndex = coeProcessLevel.getChildrenMaxOrderIndexByPidAndWsId("org", wsId) + 1;
- Timestamp nowTime = new Timestamp(System.currentTimeMillis());
- PALRepositoryModelImpl defaultModel = CoeProcessLevelUtil.createPALRepositoryModel(id, UUIDGener.getUUID(), wsId, Constant.DEFAULT_FOLDER_NAME, "", orderIndex, "org", "org", true, 1,
- id, false, "default", "0", 1, null, null, _uc.getUID(), _uc.getUID(), nowTime, null, null, null, null,
- null, null, null, null, null, -1);
- coeProcessLevel.insert(defaultModel);
- defaultModels.add(defaultModel);
- printMsg("角色模型文件夹创建成功 " + defaultModel.getId());
- return defaultModel.getId();
- } else {
- printMsg("角色模型文件夹已存在,不再重复创建");
- return defaultModels.get(0).getId();
- }
- }
-
- /**
- * 自定义属性
- * @param wsId
- * @param palModel
- * @param elements
- * @param methodAttrsMap
- */
- private void handleShapeDefaultAttr(String wsId, PALRepositoryModel palModel, JSONObject elements, Map> methodAttrsMap) {
- for (String key : elements.keySet()) {
- JSONObject shape = elements.getJSONObject(key);
- if ("linker".equals(shape.getString("name"))) {
- continue;
- }
- String shapeMehtodId = shape.getString("category").replace("_", ".");
- String shapeName = shape.getString("name");
-
- if (methodAttrsMap.containsKey(palModel.getMethodId()) && methodAttrsMap.containsKey(shapeName)) {
- } else {
- if (!methodAttrsMap.containsKey(palModel.getMethodId())) {
- methodAttrsMap.put(palModel.getMethodId(), new HashMap<>());
- }
- JSONObject attrs = ShapeUtil.getProcessUseShapeMethodAttrByShapeName(palModel.getWsId(), shapeMehtodId, palModel.getMethodId(), shapeName);
- if (attrs != null) {
- methodAttrsMap.get(palModel.getMethodId()).put(shapeName, attrs);
- }
- }
- JSONObject attrs = methodAttrsMap.get(palModel.getMethodId()).get(shapeName);// 最终属性内容
- attrs = JSONObject.parseObject(attrs.toString());// 复制
- JSONArray dataAttributes = shape.getJSONArray("dataAttributes");
- if (!dataAttributes.isEmpty() && dataAttributes.size() > 0) {
- for (Object attribute : dataAttributes) {
- JSONObject obj = (JSONObject) attribute;
- if (obj.containsKey("attributesJsonArray")) {
- JSONArray attributesJsonArray = obj.getJSONArray("attributesJsonArray");
- Set attrIds = new HashSet<>();
- for (int i = 0; i < attributesJsonArray.size(); i++) {
- if (attributesJsonArray.getJSONObject(i).containsKey("id")) {
- attrIds.add(attributesJsonArray.getJSONObject(i).getString("id"));
- }
- }
- for (String attrId : attrs.keySet()) {
- if (!attrIds.contains(attrId)) {
- JSONObject eleAttrObj = getDefaultAttrObj(attrs.getJSONObject(attrId));
- attributesJsonArray.add(eleAttrObj);
- }
- }
- }
- }
- }
- }
- }
-
- /**
- * 获取默认属性内容
- * @param attr
- * @return
- */
- private JSONObject getDefaultAttrObj (JSONObject attr) {
- String ref = attr.getString("ref");
- boolean readonly = attr.getBooleanValue("readonly");
- String scope = attr.getString("scope");
- String attrName = attr.getString("title");
- String attrId = attr.getString("id");
- String type = attr.getString("type");
- String groupPath = attr.getString("groupPath");
- String attrKey = attr.getString("key");
- String attrValue = "";
- JSONObject object2 = new JSONObject();
- object2.put("ref", ref);
- object2.put("readonly", readonly);
- object2.put("scope", scope);
- object2.put("name", attrName);
- object2.put("id", attrId);
- object2.put("type", type);
- object2.put("groupPath", groupPath);
- object2.put("key", attrKey);
- object2.put("value", "");
- return object2;
- }
-
- /**
- * 设置画布大小
- *
- * @param elements
- */
- private void setDiagramHeightWidth(JSONObject definition, JSONObject elements) {
- // 获取最大宽高,给100长度富余
- JSONObject maxHW = getMaxPositionXY(elements);
- int maxX = maxHW.getInteger("maxX") + 150;
- int maxH = maxHW.getInteger("maxY") + 150;
- JSONObject page = definition.getJSONObject("page");
- int pageW = page.getInteger("width");
- int pageH = page.getInteger("height");
- page.put("width", pageW > maxX ? pageW : maxX);
- page.put("height", pageH > maxH ? pageH : maxH);
- definition.put("page", page);
- }
-
- private JSONObject getMaxPositionXY(JSONObject elements) {
- int maxX = -99999;
- int maxY = -99999;
- Iterator 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)) {
- JSONObject props = shape.getJSONObject("props");
- int x = props.getInteger("x");
- int y = props.getInteger("y");
- maxX = maxX < x ? x : maxX;
- maxY = maxY < y ? y : maxY;
- }
- }
- JSONObject result = new JSONObject();
- result.put("maxX", maxX);
- result.put("maxY", maxY);
- return result;
- }
-
- /**
- * 校验一些必备的建模属性
- * @param wsId
- * @param shapeMethodId
- * @param shapeMethodName
- * @param methodId
- * @param categoryName
- * @param methodName
- * @param methodCode
- * @return
- */
- private String checkMethodInfo(String wsId, String shapeMethodId, String shapeMethodName, String methodId, String categoryName, String methodName, String methodCode) {
- // 一些环境提前校验 比如必备的建模属性
- List attributeModels = CoeDesignerShapeAPIManager.getInstance().getValidAttributeModels(wsId, shapeMethodId, shapeMethodName, methodId);
- attributeModels = attributeModels.stream().filter(item -> methodCode.equals(item.getKey())).collect(Collectors.toList());
- if (attributeModels.size() == 0) {
- return ResponseObject.newErrResponse("请打开建模管理应用,查看当前建模分类【" + categoryName + "】下是否存在【" + methodName + "/" + methodCode + "】建模属性").toString();
- }
- return "";
- }
-
- /**
- * 创建PAL形状
- *
- * @param palModel
- * @param arisModel
- * @param modelObjOccMap
- * @param objDefMap
- * @return
- */
- private JSONObject createShapeElement(String wsId, Map idRelationMap, PALRepositoryModel palModel, ModelModel arisModel, Map> modelObjOccMap, Map objDefMap, Map objOccMap, Map> cxnOccMap, Map palShapeIdRelationArisOccIdMap) {
- // aris中该模型所有形状
- List objOccModels = modelObjOccMap.get(arisModel.getId());
- int zindex = 1;
- JSONObject elements = new JSONObject();
- Map objDefMappingMap = ModelMappingAPIManager.getInstance().getObjDefMappingMap();
- for (ObjOccModel objOccModel : objOccModels) {
- ObjDefModel objDefModel = objDefMap.get(objOccModel.getDefId());// 形状定义
- if (objDefMappingMap.containsKey(objDefModel.getTypeNum() + "-" + objOccModel.getSymbolNum())) {
- ObjDefMappingModel objDefMappingModel = objDefMappingMap.get(objDefModel.getTypeNum() + "-" + objOccModel.getSymbolNum());// Aris与PAL形状映射关系
- String shapeMethodId = objDefMappingModel.getShapeMethod();
- String shapeType = objDefMappingModel.getShapeType();
- // 伊利导入形状定制
- String symbolNum = objDefMappingModel.getSymbolNum();
- String typeNum = objDefMappingModel.getTypeNum();
- String arisShapeName = objDefMap.get(objOccModel.getDefId()).getName();
- String method = shapeMethodId;
- String shapeName = shapeType;
- // fun
- if ("OT_FUNC".equals(symbolNum) && "ST_FUNC".equals(typeNum)) {
- if (arisShapeName.contains("审批") || arisShapeName.contains("审核")) {
- shapeName = "method_service_node";
- } else {
- shapeName = "method_service_node4";
- }
- } else if ("OT_FUNC".equals(symbolNum) && "ST_SYS_FUNC_ACT".equals(typeNum)) {// sys_fun
- if (arisShapeName.contains("审批") || arisShapeName.contains("审核")) {
- shapeName = "method_approval_node";
- } else {
- shapeName = "method_approval_node3";
- }
- }
-
- JSONObject shape = ShapeUtil.getProcessShapeDefinitionByName(shapeMethodId, shapeName);
- String shapeId = UUIDGener.getObjectId();
- palShapeIdRelationArisOccIdMap.put(shapeId, objOccModel.getId());
- idRelationMap.put(objOccModel.getId(), shapeId);// 记录形状aris形状id与pal形状id
- shape.put("id", shapeId);
- // 处理当前图形节点的关联属性【编号】问题
- if (objDefModel.getAttrData().containsKey("AT_PROC_CODE")) {
- List attributeModels = CoeDesignerShapeAPIManager.getInstance().getValidAttributeModels(wsId, objDefMappingModel.getShapeMethod(), shapeName, objDefMappingModel.getShapeMethod());
- attributeModels = attributeModels.stream().filter(item -> Constant.METHOD_NUMBER.equals(item.getKey())).collect(Collectors.toList());
- if (attributeModels.size() == 0) {
- throw new AWSException("请打开建模管理应用,查看当前【过程链】建模分类下是否存在【编号/" + Constant.METHOD_NUMBER + "】建模属性");
- }
- PALMethodAttributeModel attributeModel = attributeModels.get(0);
- JSONObject attrNumberObj = new JSONObject();
- attrNumberObj.put("value", objDefModel.getAttrData().getString("AT_PROC_CODE"));
- attrNumberObj.put("key", attributeModel.getKey());
- attrNumberObj.put("isRequired", attributeModel.getIsRequired());
- attrNumberObj.put("ref", attributeModel.getRef());
- attrNumberObj.put("readonly", attributeModel.getReadonly());
- attrNumberObj.put("scope", attributeModel.getScope());
- attrNumberObj.put("name", attributeModel.getTitle());
- attrNumberObj.put("id", attributeModel.getKey());
- attrNumberObj.put("textarea", attributeModel.getType());
- attrNumberObj.put("groupPath", attributeModel.getGroupPath());
- attrNumberObj.put("desc", attributeModel.getDesc());
-
- JSONArray dataAttributes = shape.getJSONArray("dataAttributes");
- if (!dataAttributes.isEmpty() && dataAttributes.size() > 0) {
- for (Object attribute : dataAttributes) {
- JSONObject obj = (JSONObject) attribute;
- if (obj.containsKey("attributesJsonArray")) {
- obj.getJSONArray("attributesJsonArray").add(attrNumberObj);
- break;
- }
- }
- }
- }
-
-
-// 处理活动节点描述 --by shang
- if (objDefModel.getAttrData().containsKey("AT_DESC")) {
- List attributeModels = CoeDesignerShapeAPIManager.getInstance().getValidAttributeModels(wsId, objDefMappingModel.getShapeMethod(), "process", objDefMappingModel.getShapeMethod());
- attributeModels = attributeModels.stream().filter(item -> Constant.METHOD_DESC.equals(item.getKey())).collect(Collectors.toList());
- if (attributeModels.size() == 0) {
- throw new AWSException("请打开建模管理应用,查看当前【过程链】建模分类下是否存在【活动描述/" + Constant.METHOD_DESC + "】建模属性");
- }
- PALMethodAttributeModel attributeModel = attributeModels.get(0);
- JSONObject attrDescObj = new JSONObject();
- attrDescObj.put("value", objDefModel.getAttrData().getString("AT_DESC"));
- attrDescObj.put("key", attributeModel.getKey());
- attrDescObj.put("isRequired", attributeModel.getIsRequired());
- attrDescObj.put("ref", attributeModel.getRef());
- attrDescObj.put("readonly", attributeModel.getReadonly());
- attrDescObj.put("scope", attributeModel.getScope());
- attrDescObj.put("name", attributeModel.getTitle());
- attrDescObj.put("id", attributeModel.getKey());
- attrDescObj.put("textarea", attributeModel.getType());
- attrDescObj.put("groupPath", attributeModel.getGroupPath());
- attrDescObj.put("desc", attributeModel.getDesc());
-
- JSONArray dataAttributes = shape.getJSONArray("dataAttributes");
- if (!dataAttributes.isEmpty() && dataAttributes.size() > 0) {
- for (Object attribute : dataAttributes) {
- JSONObject obj = (JSONObject) attribute;
- if (obj.containsKey("attributesJsonArray")) {
-
- // 处理图形上默认勾选的属性,没有值的属性置空 --by shang
-// List allValidAndUseShapeAttributeModels = CoeDesignerShapeAPIManager.getInstance().getAllValidAndUseShapeAttributeModels(wsId, objDefMappingModel.getShapeMethod());
- List usedAttributeModels = CoeDesignerShapeAPIManager.getInstance().getValidAndUseAttributeModels(wsId, objDefMappingModel.getShapeMethod(), shapeName, objDefMappingModel.getShapeMethod());
- usedAttributeModels.forEach(item -> {
- attrDescObj.put("id", item.getKey());
- attrDescObj.put("value","");
- });
- obj.getJSONArray("attributesJsonArray").add(attrDescObj);
-
- break;
- }
- }
- }
- }
-
-
- // 定义位置、大小
- if (shape == null) {
- // pal形状不存在,记录日志 todo
- printMsg("pal没有对应形状定义");
- continue;
- }
- if (shape.containsKey("attribute") && shape.getJSONObject("attribute").containsKey("editable") && !shape.getJSONObject("attribute").getBooleanValue("editable")) {// 不可编辑名称
-
- } else {// 重命名名称
- String name = objDefMap.get(objOccModel.getDefId()).getName();// 形状名称
- shape.put("text", name);
- }
-
- JSONObject props = shape.getJSONObject("props");// 位置大小
- props.put("zindex", zindex++);
- props.put("x", objOccModel.getX());
- props.put("y", objOccModel.getY());
- props.put("w", objOccModel.getW());
- props.put("h", objOccModel.getH());
- elements.put(shapeId, shape);
- } else {
- // pal缺少对应的形状
- printMsg("pal缺少对应的形状:" + objDefModel.getName());
- System.out.println(objDefModel.getTypeNum() + "-" + objDefModel.getSymbolNum());
- System.out.println(objDefMappingMap.containsKey(objDefModel.getTypeNum() + "-" + objDefModel.getSymbolNum()));
- }
- }
- // 形状连线处理
- for (ObjOccModel occ : objOccModels) {
- if (cxnOccMap.containsKey(occ.getId())) {
- List cxnOccModels = cxnOccMap.get(occ.getId());
- for (CxnOccModel cxn : cxnOccModels) {
- if (idRelationMap.containsKey(cxn.getId()) && idRelationMap.containsKey(cxn.getToId())) {
- List positionModels = cxn.getPositionList();
- JSONObject linkerObj = ModelMappingAPIManager.getInstance().getLinkerDef();
- String linkerId = UUIDGener.getObjectId();
- linkerObj.put("id", linkerId);
- JSONObject props = linkerObj.getJSONObject("props");
- props.put("zindex", zindex++);// 层次
- linkerObj.put("props", props);
- linkerObj.put("points", getLinkerPoints(positionModels));
- JSONObject from = linkerObj.getJSONObject("from");
- from.put("id", idRelationMap.get(cxn.getId()));
- from.put("angle", getLinkerAngle(positionModels, "from"));
- from.put("x", positionModels.get(0).getX());
- from.put("y", positionModels.get(0).getY());
- linkerObj.put("from", from);
- JSONObject to = linkerObj.getJSONObject("to");
- to.put("id", idRelationMap.get(cxn.getToId()));
- to.put("angle", getLinkerAngle(positionModels, "to"));
- to.put("x", positionModels.get(positionModels.size() - 1).getX());
- to.put("y", positionModels.get(positionModels.size() - 1).getY());
- linkerObj.put("to", to);
- elements.put(linkerId, linkerObj);
- } else {
- // 不包含的连线
- }
- }
- }
- }
- return elements;
- }
-
- /**
- * 在现有输出的图形结构上转化输入 输出活动属性,并将图上输入输出及连线删除
- */
- private void handleShapeInputOutAttr(PALRepositoryModel palModel, JSONObject elements) {
- // 存放待删除图形的KEY
- List removeKey = new ArrayList<>();
-
- Map> nextShapeMap = new HashMap<>();// 记录当前形状的下一个(多个)形状
- Map> prevShapeMap = new HashMap<>();// 记录当前形状的上一个(多个)形状
- for (String key : elements.keySet()) {
- JSONObject shapeObj = elements.getJSONObject(key);
- if ("linker".equals(shapeObj.getString("name"))) {
- // 输入
- String shapeId = shapeObj.getString("id");
- // 查找入线
- String fromId = shapeObj.getJSONObject("from").getString("id");
- String toId = shapeObj.getJSONObject("to").getString("id");
- // 记录from->to Map
- if (!nextShapeMap.containsKey(fromId)) {
- nextShapeMap.put(fromId, new HashSet<>());
- }
- nextShapeMap.get(fromId).add(toId);
-
- if (!prevShapeMap.containsKey(toId)) {
- prevShapeMap.put(toId, new HashSet<>());
- }
- prevShapeMap.get(toId).add(fromId);
- }
- }
-
- Map> shapeInputMap = new HashMap<>();// 记录形状的所有输出
- Map> shapeOutMap = new HashMap<>();// 记录形状的所有输入
- for (String key : elements.keySet()) {
- JSONObject shapeObj = elements.getJSONObject(key);
- if (!"linker".equals(shapeObj.getString("name"))) {
- // 输入
- String shapeId = shapeObj.getString("id");
- // 查找入线(输入)
- if (prevShapeMap.containsKey(shapeId)) {
- for (Map.Entry> entry : prevShapeMap.entrySet()) {
- if (key.equals(entry.getKey())) {
- Set prevShapeIds = entry.getValue();
- for (String prevShapeId : prevShapeIds) {
- JSONObject prevShape = elements.getJSONObject(prevShapeId);
- if ("document".equals(prevShape.getString("name"))) {
- if (!shapeInputMap.containsKey(shapeId)) {
- shapeInputMap.put(shapeId, new HashSet<>());
- }
- shapeInputMap.get(shapeId).add(prevShape.getString("text"));
- }
- }
- }
- }
- }
- // 查找出线
- if (nextShapeMap.containsKey(shapeId)) {
- for (Map.Entry> entry : nextShapeMap.entrySet()) {
- if (key.equals(entry.getKey())) {
- Set nextShapeIds = entry.getValue();
- for (String nextShapeId : nextShapeIds) {
- JSONObject nextShape = elements.getJSONObject(nextShapeId);
- if ("document".equals(nextShape.getString("name"))) {
- if (!shapeOutMap.containsKey(shapeId)) {
- shapeOutMap.put(shapeId, new HashSet<>());
- }
- shapeOutMap.get(shapeId).add(nextShape.getString("text"));
- }
- }
- }
- }
- }
- }
- }
-
-
- for (String key : elements.keySet()) {
- JSONObject shapeObj = elements.getJSONObject(key);
- if ("linker".equals(shapeObj.getString("name"))) {
- JSONObject from = elements.getJSONObject(shapeObj.getJSONObject("from").getString("id"));
- if ("document".equals(from.getString("name"))) {
- removeKey.add(key);
- removeKey.add(from.getString("id"));
- }
- JSONObject to = elements.getJSONObject(shapeObj.getJSONObject("to").getString("id"));
- if ("document".equals(to.getString("name"))) {
- removeKey.add(key);
- removeKey.add(to.getString("id"));
- }
- }
- }
- // 删除画布上的输入输出和其连线
- removeKey.stream().forEach(key -> elements.remove(key));
-
- Map attrMap = new HashMap<>();
- JSONObject attrs1 = ShapeUtil.getProcessUseShapeMethodAttrByShapeName(palModel.getWsId(), palModel.getMethodId(), palModel.getMethodId(), "method_service_node");
- attrMap.put("method_service_node", attrs1);
- JSONObject attrs2 = ShapeUtil.getProcessUseShapeMethodAttrByShapeName(palModel.getWsId(), palModel.getMethodId(), palModel.getMethodId(), "method_service_node4");
- attrMap.put("method_service_node4", attrs2);
- JSONObject attrs3 = ShapeUtil.getProcessUseShapeMethodAttrByShapeName(palModel.getWsId(), palModel.getMethodId(), palModel.getMethodId(), "method_approval_node");
- attrMap.put("method_approval_node", attrs3);
- JSONObject attrs4 = ShapeUtil.getProcessUseShapeMethodAttrByShapeName(palModel.getWsId(), palModel.getMethodId(), palModel.getMethodId(), "method_approval_node3");
- attrMap.put("method_approval_node3", attrs4);
-
- for (String key : elements.keySet()) {
- JSONObject shapeObj = elements.getJSONObject(key);
- if (!"linker".equals(shapeObj.getString("name"))) {
- if (attrMap.containsKey(shapeObj.getString("name"))) {
- JSONObject attrs = attrMap.get(shapeObj.getString("name"));
- if (shapeInputMap.containsKey(key)) {// 有输入属性
- // 输入属性
- if (attrs != null && attrs.size() > 0 && attrs.containsKey(Constant.METHOD_INPUT)) {
- JSONObject attrObj = JSONObject.parseObject(attrs.getJSONObject(Constant.METHOD_INPUT).toString());
- List contentList = new ArrayList<>(shapeInputMap.get(key));
- Collections.sort(contentList);
- attrObj.put("value", StringUtils.join(contentList, ","));
- JSONArray dataAttributes = shapeObj.getJSONArray("dataAttributes");
- if (!dataAttributes.isEmpty() && dataAttributes.size() > 0) {
- for (Object attribute : dataAttributes) {
- JSONObject obj = (JSONObject) attribute;
- if (obj.containsKey("attributesJsonArray")) {
- JSONArray attributesJsonArray = obj.getJSONArray("attributesJsonArray");
- attributesJsonArray.add(attrObj);
- printMsg("流程" + palModel.getName() + "的节点" + shapeObj.getString("text") + "输入属性内容" + attrObj.getString("value"));
- }
- }
- }
- } else {
- printMsg("流程" + palModel.getName() + "的节点" + shapeObj.getString("text") + "没有配置输入属性");
- }
- }
- if (shapeOutMap.containsKey(key)) {// 有输出属性
- // 输出属性
- if (attrs != null && attrs.size() > 0 && attrs.containsKey(Constant.METHOD_OUTPUT)) {
- JSONObject attrObj = JSONObject.parseObject(attrs.getJSONObject(Constant.METHOD_OUTPUT).toString());
- List contentList = new ArrayList<>(shapeOutMap.get(key));
- Collections.sort(contentList);
- attrObj.put("value", StringUtils.join(contentList, ","));
- JSONArray dataAttributes = shapeObj.getJSONArray("dataAttributes");
- if (!dataAttributes.isEmpty() && dataAttributes.size() > 0) {
- for (Object attribute : dataAttributes) {
- JSONObject obj = (JSONObject) attribute;
- if (obj.containsKey("attributesJsonArray")) {
- JSONArray attributesJsonArray = obj.getJSONArray("attributesJsonArray");
- attributesJsonArray.add(attrObj);
- printMsg("流程" + palModel.getName() + "的节点" + shapeObj.getString("text") + "输出属性内容" + attrObj.getString("value"));
- }
- }
- }
- } else {
- printMsg("流程" + palModel.getName() + "的节点" + shapeObj.getString("text") + "没有配置输出属性");
- }
- }
-
- }
- }
- }
- }
-
- /**
- * 处理流程属性前后置流程
- *
- * @param wsId
- * @param currentModelNoShape
- * @param idRelationMap
- * @param repositoryModelId
- * @param elements
- * @param arisModel
- * @param modelObjOccMap
- * @param objDefMap
- */
- private void handleProcessAttrLeadOrRearProcess(String wsId, List currentModelNoShape, Map idRelationMap, String repositoryModelId, JSONObject elements, ModelModel arisModel,
- Map> modelObjOccMap, Map objDefMap) {
- // 如果当前流程下无图形信息 直接返回
- List objOccModels = modelObjOccMap.get(arisModel.getId());
- if (objOccModels == null || objOccModels.size() == 0) {
- currentModelNoShape.add(arisModel);
- return;
- }
- // 获取ARIS图形定义与PAL图形定义关系
- Map objDefMappingMap = ModelMappingAPIManager.getInstance().getObjDefMappingMap();
- ObjDefMappingModel objDefMappingModel = objDefMappingMap.get("OT_FUNC-ST_PRCS_IF");
- List attributeModels = PALRepositoryAPIManager.getInstance().getValidAttributeModels(wsId, objDefMappingModel.getShapeMethod());
-// List leadProcess = attributeModels.stream().filter(item -> "lead_process".equals(item.getKey())).collect(Collectors.toList());
-// --by shang
- List leadProcess = attributeModels.stream().filter(item -> Constant.METHOD_PRE_PROCESS.equals(item.getKey())).collect(Collectors.toList());
- PALMethodAttributeModel leadAttrModel = leadProcess.get(0);
- List rearProcess = attributeModels.stream().filter(item -> Constant.METHOD_NEXT_PROCESS.equals(item.getKey())).collect(Collectors.toList());
- PALMethodAttributeModel rearAttrModel = rearProcess.get(0);
- // 存放待删除图形的KEY
- List removeKey = new ArrayList<>();
- // 流程关联属性结果集
- List relationList = new ArrayList<>();
- for (ObjOccModel objOccModel : objOccModels) {
- ObjDefModel objDefModel = objDefMap.get(objOccModel.getDefId());// 形状定义
- // 根据ARIS图形定义信息判断当前模型下的所有形状里是否有系统形状
- if (objDefModel.getTypeNum().equals(objDefMappingModel.getTypeNum()) && objDefModel.getSymbolNum().equals(objDefMappingModel.getSymbolNum())) {
- // 如果有输入输出形状 取出关联的PAL模型ID
- String shapeId = idRelationMap.get(objOccModel.getId());
- JSONObject leadOrRearObj = elements.getJSONObject(shapeId);
- for (String key : elements.keySet()) {
- JSONObject tempShapeObj = elements.getJSONObject(key);
- if ("linker".equals(tempShapeObj.getString("name"))) {
- if (tempShapeObj.getJSONObject("from").getString("id").equals(shapeId)) {
- // lead_process
- PALRepositoryPropertyDao propertyDao = new PALRepositoryPropertyDao();
- PALRepositoryPropertyModel propertyModel = new PALRepositoryPropertyModel();
- propertyModel.setId(UUIDGener.getUUID());
- propertyModel.setPlId(repositoryModelId);
- propertyModel.setPropertyId(leadAttrModel.getKey());
- propertyModel.setPropertyName(leadAttrModel.getNewTitle());
- JSONObject propValue = new JSONObject();
- propValue.put("fileId", repositoryModelId);
- propValue.put("shapeId", "");
- propValue.put("shapeText", "");
- propValue.put("attrId", leadAttrModel.getKey());
- propValue.put("relationFileId", new JSONArray());
- propValue.put("relationShapeId", "");
- propValue.put("relationShapeText", "");
- propValue.put("groupPath", leadAttrModel.getGroupPath());
- List repositoryModels = PALRepositoryQueryAPIManager.getInstance().getPalRepositoryModelsByWsIdAndMethodId(wsId, "process.epc");
- repositoryModels = repositoryModels.stream().filter(model -> leadOrRearObj.getString("text").equals(model.getName())).collect(Collectors.toList());
- if (repositoryModels.size() > 0) {
- propValue.getJSONArray("relationFileId").add(repositoryModels.get(0).getId());
- }
- propertyModel.setPropertyValue(propValue.toString());
- propertyModel.setOrderIndex(0);
- propertyDao.insert(propertyModel);
- removeKey.add(key);
- removeKey.add(shapeId);
- break;
- } else if (tempShapeObj.getJSONObject("to").getString("id").equals(shapeId)) {
- // rear_process
- PALRepositoryPropertyDao propertyDao = new PALRepositoryPropertyDao();
- PALRepositoryPropertyModel propertyModel = new PALRepositoryPropertyModel();
- propertyModel.setId(UUIDGener.getUUID());
- propertyModel.setPlId(repositoryModelId);
- propertyModel.setPropertyId(rearAttrModel.getKey());
- propertyModel.setPropertyName(rearAttrModel.getNewTitle());
- JSONObject propValue = new JSONObject();
- propValue.put("fileId", repositoryModelId);
- propValue.put("shapeId", "");
- propValue.put("shapeText", "");
- propValue.put("attrId", rearAttrModel.getKey());
- propValue.put("relationFileId", new JSONArray());
- propValue.put("relationShapeId", "");
- propValue.put("relationShapeText", "");
- propValue.put("groupPath", "");
- List repositoryModels = PALRepositoryQueryAPIManager.getInstance().getPalRepositoryModelsByWsIdAndMethodId(wsId, "process.epc");
- repositoryModels = repositoryModels.stream().filter(model -> leadOrRearObj.getString("text").equals(model.getName())).collect(Collectors.toList());
- if (repositoryModels.size() > 0) {
- propValue.getJSONArray("relationFileId").add(repositoryModels.get(0).getId());
- }
- propertyModel.setPropertyValue(propValue.toString());
- propertyModel.setOrderIndex(0);
- propertyDao.insert(propertyModel);
- removeKey.add(key);
- removeKey.add(shapeId);
- break;
- } else {
- continue;
- }
- }
- }
- }
- }
- removeKey.stream().forEach(key -> elements.remove(key));
- }
-
- /**
- * 处理流程关联属性IT系统
- * @param wsId
- * @param idRelationMap
- * @param repositoryModelId
- * @param elements
- * @param arisModel
- * @param modelObjOccMap
- * @param objDefMap
- * @param objDefLinkerMap
- * @param itShapeMap
- */
- private void handleProcessAttrItSystemRelation(String wsId, Map idRelationMap, String repositoryModelId, JSONObject elements, ModelModel arisModel,
- Map> modelObjOccMap,
- Map objDefMap, Map> objDefLinkerMap, Map itShapeMap) {
- // 获取ARIS图形定义与PAL图形定义关系
- Map objDefMappingMap = ModelMappingAPIManager.getInstance().getObjDefMappingMap();
- ObjDefMappingModel objDefMappingModel = objDefMappingMap.get("OT_APPL_SYS_TYPE-ST_APPL_SYS_TYPE");
- // 获取当前ARIS模型下所有的图形信息
- List objOccModels = modelObjOccMap.get(arisModel.getId());
- Map> shapeRelationItMap = new HashMap<>();// 记录PAL形状关联的IT系统文本
- for (ObjOccModel objOccModel: objOccModels) {
- String objDefId = objOccModel.getDefId();
- // 获取定义形状通过连线进行连接的所有定义形状
- Set toObjDefIds = objDefLinkerMap.get(objDefId);
- if (toObjDefIds == null || toObjDefIds.size() == 0) {
- continue;
- }
- // 取出所有IT系统
- Set