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 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 { - // todo warn - printMsg("流程【" + arisModel.getName() + "】中的活动节点【" + elements.getJSONObject(shapeId).getString("text") + "】未找到IT系统【" + itShapeName + "】"); - } - } - } - // 保存关联关系 - if (relationList.size() > 0) { - DesignerShapeRelationDao relationDao = new DesignerShapeRelationDao(); - relationList.stream().forEach(item -> printMsg("流程【" + arisModel.getName() + "】中的活动节点【" + item.getShapeText() + "】关联当前流程下IT系统【" + item.getRelationShapeText() + "】")); - relationDao.barchInsert(relationList); - } - } - - /** - * 处理关联属性【角色】与流程关联 - * @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 { - // 获取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")); - } - printMsg("流程" + arisModel.getName() + "删除角色形状" + text + "和其连线"); - } - } - - // 保存关联关系 - if (relationList.size() > 0) { - DesignerShapeRelationDao relationDao = new DesignerShapeRelationDao(); - relationList.stream().forEach(item -> printMsg("流程【" + arisModel.getName() + "】中的活动节点【" + item.getShapeText() + "】关联当前流程下角色【" + item.getRelationShapeText() + "】")); - relationDao.barchInsert(relationList); - } - removeKey.stream().forEach(key -> elements.remove(key)); - } - - /** - * 创建具有合理位置的节点数据 - * - * @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; - } - - private int validateJson(Integer index) { - return index == null ? 0 : index; - } - - /** - * 获取连线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 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; - } - - /** - * Aris模型匹配PAL模型 - * - * @param arisModel - * @return - */ - private PALRepositoryModel matchPalModel(ModelModel arisModel, String wsId) { - // 查询当前资产库中建模类型是EPC的所有流程文件属性 - PALRepositoryPropertyDao dao = new PALRepositoryPropertyDao(); - List propertyModels = dao.queryByWsId(wsId); - propertyModels = propertyModels.stream().filter(item -> Constant.METHOD_ARIS_URL.equals(item.getPropertyId())).collect(Collectors.toList()); - String modelPath = "\\伊利集团业务流程管理平台" + arisModel.getModelPath(); - boolean flag = false; - PALRepositoryModel repositoryModel = null; - // printMsg("MODEL PATH "+modelPath); - for (PALRepositoryPropertyModel propertyModel : propertyModels) { - if (propertyModel.getPropertyValue().equals(modelPath)) { - // printMsg("ARIS路径 "+propertyModel.getPropertyValue()); - repositoryModel = new PALRepository().getInstance(propertyModel.getPlId()); - if (arisModel.getName().trim().equals(repositoryModel.getName())) { - printMsg("匹配到的MODEL PATH " + modelPath + "\\" + arisModel.getName()); - flag = true; - break; - } else { - repositoryModel = null; - } - } - } - if (!flag) { - // 未匹配出结果,记录日志 todo - printMsg("未匹配出结果MODEL PATH " + modelPath + "\\" + arisModel.getName()); - } - return repositoryModel; - } - - private void printMsg(String msg) { - SDK.getLogAPI().consoleInfo(msg); - } - /** * 流程属性数据Word导入 * @@ -1548,12 +211,10 @@ public class DataMigrationWeb extends ActionWeb { importProperty.setPropertyValue(object.toJSONString()); propDao.update(importProperty); } else if ("awsorg".equals(repositoryAttrModel.getType())) { - //aws组织架构解析,这里是做单组织结构的解析,ToDo:多组结构解析 + //aws组织架构解析,多组结构解析 String orgName = (String) wordField.getData(); - AwsOrgInfo orgByName = this.getOrgByName(orgName); - if (null != orgByName) { - List awsOrgInfos = new ArrayList<>(); - awsOrgInfos.add(orgByName); + List awsOrgInfos = this.getOrgByName(orgName); + if (!awsOrgInfos.isEmpty()) { //先更新property数据 [{"name":"部门3","id":"fdea04c8-502f-4367-82b7-a5ebe0ce5f67","type":"department"}] importProperty.setPropertyValue(JSON.toJSONString(awsOrgInfos)); propDao.update(importProperty); @@ -1765,6 +426,109 @@ public class DataMigrationWeb extends ActionWeb { return ro.toString(); } + /** + * 设置画布大小 + * + * @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; + } + + private int validateJson(Integer index) { + return index == null ? 0 : index; + } + private DCContext getFileDcContext(String groupValue, String fileValue, String fileName) { DCContext context = null; @@ -1776,48 +540,46 @@ public class DataMigrationWeb extends ActionWeb { return context; } - private AwsOrgInfo getOrgByName(String name) { - AwsOrgInfo awsOrgInfo = null; + private List getOrgByName(String name) { + List awsOrgInfos = new ArrayList<>(); + List nameList = Arrays.stream(name.split(",")).collect(Collectors.toList()); //从公司级别递归寻找name相同结构 //公司 Iterator companyIterator = CompanyCache.getCache().iterator(); while (companyIterator.hasNext()) { CompanyModel companyModel = companyIterator.next(); - if (companyModel.getNameI18N().equalsIgnoreCase(name)) { - awsOrgInfo = new AwsOrgInfo(companyModel.getId(), companyModel.getNameI18N(), companyModel.getType()); - break; + if (nameList.contains(companyModel.getNameI18N())) { + awsOrgInfos.add(new AwsOrgInfo(companyModel.getId(), companyModel.getNameI18N(), companyModel.getType())); } } - if (null == awsOrgInfo) { + if (awsOrgInfos.isEmpty()) { //部门 Iterator departIterator = DepartmentCache.getCache().iterator(); while (departIterator.hasNext()) { DepartmentModel departmentModel = departIterator.next(); - if (departmentModel.getNameI18N().equalsIgnoreCase(name)) { - awsOrgInfo = new AwsOrgInfo(departmentModel.getId(), departmentModel.getNameI18N(), departmentModel.getType()); - break; + if (nameList.contains(departmentModel.getNameI18N())) { + awsOrgInfos.add(new AwsOrgInfo(departmentModel.getId(), departmentModel.getNameI18N(), departmentModel.getType())); } } } - if (null == awsOrgInfo) { + if (awsOrgInfos.isEmpty()) { //用户 Iterator userIterator = UserCache.getCache().iterator(); while (userIterator.hasNext()) { UserModel userModel = userIterator.next(); - if (userModel.getUserNameI18N().equalsIgnoreCase(name)) { - awsOrgInfo = new AwsOrgInfo(userModel.getUID(), userModel.getUserNameI18N(), "user"); - break; + if (nameList.contains(userModel.getUserNameI18N())) { + awsOrgInfos.add(new AwsOrgInfo(userModel.getUID(), userModel.getUserNameI18N(), "user")); } } } - if (null == awsOrgInfo) { + if (awsOrgInfos.isEmpty()) { //岗位 } - return awsOrgInfo; + return awsOrgInfos; } /** @@ -1850,4 +612,16 @@ public class DataMigrationWeb extends ActionWeb { } return name.substring(start + 1, end); } + + /** + * Aris流程数据迁移 + * @param wsId + * @param groupValue + * @param fileValue + * @param fileName + * @return + */ + public String dataMigrate(String wsId, String groupValue, String fileValue, String fileName) { + return new ArisXmlImportWeb(_uc).dataMigrate(wsId, groupValue, fileValue, fileName); + } } diff --git a/com.actionsoft.apps.coe.pal.output.pr/lib/com.actionsoft.apps.coe.pal.output.pr.jar b/com.actionsoft.apps.coe.pal.output.pr/lib/com.actionsoft.apps.coe.pal.output.pr.jar index 45bd0967..10097938 100644 Binary files a/com.actionsoft.apps.coe.pal.output.pr/lib/com.actionsoft.apps.coe.pal.output.pr.jar and b/com.actionsoft.apps.coe.pal.output.pr/lib/com.actionsoft.apps.coe.pal.output.pr.jar differ diff --git a/com.actionsoft.apps.coe.pal.output.pr/src/com/actionsoft/apps/coe/pal/output/pr/Plugins.java b/com.actionsoft.apps.coe.pal.output.pr/src/com/actionsoft/apps/coe/pal/output/pr/Plugins.java index 713dc4cb..bd2b5d7e 100644 --- a/com.actionsoft.apps.coe.pal.output.pr/src/com/actionsoft/apps/coe/pal/output/pr/Plugins.java +++ b/com.actionsoft.apps.coe.pal.output.pr/src/com/actionsoft/apps/coe/pal/output/pr/Plugins.java @@ -67,17 +67,6 @@ public class Plugins implements PluginListener { params2.put("templates", array2.toString()); list.add(new AppExtensionProfile("PAL报告->步骤竖表", "aslp://com.actionsoft.apps.coe.pal/registerOutputApp", params2)); - /*Map params4 = new HashMap(); - params4.put("groupName", "流程手册"); - params4.put("title", "流程手册"); - params4.put("targetMethodScope", PrReportComment.TARGET_METHOD_SCOPE);// 建模大类、建模方法,多个用逗号隔开,如果为空表示全部 - params4.put("targetMethodType", "");// 建模方法中的图元,为空表示只选择文件,不选择图元;为"-"表示所有类型图元 - params4.put("relationMethodScope", "-");// 如果设置-,表示不需要用户选择关联范围,向导页被忽略 - params4.put("lang", "cn");// 该App支持的语言,多个用逗号隔开 - params4.put("optionClass", Report4WizardOption.class.getName());// 附加的报表选项,如果该值没有,向导页被忽略 - params4.put("generClass", Report4Gener.class.getName());// 生成报告 - list.add(new AppExtensionProfile("PAL报告->流程手册", "aslp://com.actionsoft.apps.coe.pal/registerOutputApp", params4));*/ - return list; } diff --git a/com.actionsoft.apps.coe.pal.output.pr/src/com/actionsoft/apps/coe/pal/output/pr/report1/Report1Gener.java b/com.actionsoft.apps.coe.pal.output.pr/src/com/actionsoft/apps/coe/pal/output/pr/report1/Report1Gener.java index 2da5511f..48967483 100644 --- a/com.actionsoft.apps.coe.pal.output.pr/src/com/actionsoft/apps/coe/pal/output/pr/report1/Report1Gener.java +++ b/com.actionsoft.apps.coe.pal.output.pr/src/com/actionsoft/apps/coe/pal/output/pr/report1/Report1Gener.java @@ -3,7 +3,6 @@ package com.actionsoft.apps.coe.pal.output.pr.report1; import java.io.File; import java.util.*; -import com.actionsoft.apps.AppsConst; import com.actionsoft.apps.coe.pal.constant.CoEConstant; import com.actionsoft.apps.coe.pal.output.pr.util.PrReportComment; import com.actionsoft.apps.coe.pal.output.pr.util.ReportRepositoryCompare; @@ -12,7 +11,6 @@ import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppManager; import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppProfile; import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel; import com.actionsoft.apps.coe.pal.pal.output.util.OutputExcelUtil; -import com.actionsoft.apps.coe.pal.pal.output.util.OutputUtil; import com.actionsoft.apps.coe.pal.pal.output.util.OutputWordUtil; import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager; import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache; @@ -28,7 +26,6 @@ import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel; import com.actionsoft.apps.coe.pal.system.property.CoePropertyUtil; import com.actionsoft.apps.coe.pal.util.HighSecurityUtil; import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile; -import com.actionsoft.bpms.commons.mvc.dao.IDaoQuery; import com.actionsoft.bpms.commons.mvc.view.ResponseObject; import com.actionsoft.bpms.server.DispatcherRequest; import com.actionsoft.bpms.server.UserContext; @@ -41,8 +38,10 @@ import com.actionsoft.sdk.local.api.internal.PlatformAPIImpl; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; + import static com.actionsoft.apps.coe.pal.pal.output.util.OutputWordUtil.specialCharTransfer; + /** * 生成流程手册-步骤横表横表的入口 * @@ -185,7 +184,7 @@ public class Report1Gener { // 记录关联属性的流程节点,防止多次查询重复文件信息耗费时间 Set relationFileIds = new HashSet<>(); Map> relationFileMap = new HashMap<>(); - + PrReportComment prReportComment = new PrReportComment(); PALRepositoryModel repositoryModel = PALRepositoryQueryAPIManager.getInstance().queryPalRepositoryModelByPalId(repositoryId); if (repositoryModel == null) { @@ -202,6 +201,7 @@ public class Report1Gener { Set dangerSet = new HashSet();// 风险 Set regulateSet = new HashSet();// 控制 Set KPISet = new HashSet();// kpi + System.out.println("id======================="+repositoryId); List> repositoryFileElements = CoeDesignerUtil.getShapeMessageJson4(repositoryId); //流程文件内容 if (wizardJsonData.getBoolean("orderNuberFirst")) { // 根据页面选择进行排序 diff --git a/com.actionsoft.apps.coe.pal.output.pr/src/com/actionsoft/apps/coe/pal/output/pr/report2/Report2Gener.java b/com.actionsoft.apps.coe.pal.output.pr/src/com/actionsoft/apps/coe/pal/output/pr/report2/Report2Gener.java index 8d37fe2d..35b3af17 100644 --- a/com.actionsoft.apps.coe.pal.output.pr/src/com/actionsoft/apps/coe/pal/output/pr/report2/Report2Gener.java +++ b/com.actionsoft.apps.coe.pal.output.pr/src/com/actionsoft/apps/coe/pal/output/pr/report2/Report2Gener.java @@ -2,6 +2,7 @@ package com.actionsoft.apps.coe.pal.output.pr.report2; import java.util.*; +import com.actionsoft.apps.coe.pal.output.pr.util.PrReportComment; import com.actionsoft.apps.coe.pal.pal.output.extend.GenerLogExd; import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppManager; import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppProfile; @@ -19,8 +20,6 @@ import com.actionsoft.apps.coe.pal.system.property.CoePropertyUtil; import com.actionsoft.sdk.local.SDK; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; - -import com.actionsoft.apps.coe.pal.output.pr.util.PrReportComment; import com.actionsoft.bpms.commons.mvc.view.ResponseObject; import com.actionsoft.bpms.server.fs.DCContext; import com.actionsoft.sdk.local.api.internal.PlatformAPIImpl; diff --git a/com.actionsoft.apps.coe.pal.output.pr/src/com/actionsoft/apps/coe/pal/output/pr/util/PrReportComment.java b/com.actionsoft.apps.coe.pal.output.pr/src/com/actionsoft/apps/coe/pal/output/pr/util/PrReportComment.java index 99de029e..123ceccd 100644 --- a/com.actionsoft.apps.coe.pal.output.pr/src/com/actionsoft/apps/coe/pal/output/pr/util/PrReportComment.java +++ b/com.actionsoft.apps.coe.pal.output.pr/src/com/actionsoft/apps/coe/pal/output/pr/util/PrReportComment.java @@ -7,38 +7,20 @@ import java.io.IOException; import java.sql.Timestamp; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; import javax.imageio.ImageIO; - import com.actionsoft.apps.coe.pal.constant.CoEConstant; import com.actionsoft.apps.coe.pal.pal.manage.publish.dao.PublishListHistory; import com.actionsoft.apps.coe.pal.pal.output.util.OutputWordUtil; import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager; -import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryAttributeCache; -import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache; -import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryPropertyCache; -import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepositoryPropertyDao; -import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.cache.DesignerShapeRelationCache; -import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel; -import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryAttributeModel; 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.util.CoeProcessLevelUtil; -import com.actionsoft.apps.coe.pal.system.property.CoePropertyUtil; -import org.apache.commons.lang.StringUtils; - import com.actionsoft.bpms.org.cache.UserCache; import com.actionsoft.bpms.util.Base64; import com.actionsoft.bpms.util.UtilDate; import com.actionsoft.bpms.util.UtilFile; import com.actionsoft.bpms.util.UtilString; import com.actionsoft.sdk.local.SDK; - import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; diff --git a/com.actionsoft.apps.coe.pal.output.pr/src/com/actionsoft/apps/coe/pal/output/pr/util/ReportRepositoryCompare.java b/com.actionsoft.apps.coe.pal.output.pr/src/com/actionsoft/apps/coe/pal/output/pr/util/ReportRepositoryCompare.java index c9453674..7e987c49 100644 --- a/com.actionsoft.apps.coe.pal.output.pr/src/com/actionsoft/apps/coe/pal/output/pr/util/ReportRepositoryCompare.java +++ b/com.actionsoft.apps.coe.pal.output.pr/src/com/actionsoft/apps/coe/pal/output/pr/util/ReportRepositoryCompare.java @@ -6,13 +6,10 @@ import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; - -import com.actionsoft.apps.coe.pal.constant.CoEConstant; import com.actionsoft.apps.coe.pal.pal.output.util.OutputWordUtil; import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager; import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryAttributeCache; diff --git a/com.actionsoft.apps.coe.pal.output.pr/~$横表-流程手册2.doc b/com.actionsoft.apps.coe.pal.output.pr/~$横表-流程手册2.doc new file mode 100644 index 00000000..6e18ba5f Binary files /dev/null and b/com.actionsoft.apps.coe.pal.output.pr/~$横表-流程手册2.doc differ diff --git a/com.actionsoft.apps.coe.pal.output.pr/~WRL0001.tmp b/com.actionsoft.apps.coe.pal.output.pr/~WRL0001.tmp new file mode 100644 index 00000000..5c7dd00a Binary files /dev/null and b/com.actionsoft.apps.coe.pal.output.pr/~WRL0001.tmp differ diff --git a/com.actionsoft.apps.coe.pal.output.pr/步骤横表-流程手册2.doc b/com.actionsoft.apps.coe.pal.output.pr/步骤横表-流程手册2.doc index 5c7dd00a..7e086a16 100644 Binary files a/com.actionsoft.apps.coe.pal.output.pr/步骤横表-流程手册2.doc and b/com.actionsoft.apps.coe.pal.output.pr/步骤横表-流程手册2.doc differ diff --git a/com.actionsoft.apps.coe.pal.output.pr/步骤横表-流程手册2.xml b/com.actionsoft.apps.coe.pal.output.pr/步骤横表-流程手册2.xml index 41484c68..84db3b23 100644 --- a/com.actionsoft.apps.coe.pal.output.pr/步骤横表-流程手册2.xml +++ b/com.actionsoft.apps.coe.pal.output.pr/步骤横表-流程手册2.xml @@ -5901,7 +5901,7 @@ y7fdOgAAAABJRU5ErkJggk== - ${pl_Purpose} + ${pl_goal} @@ -6664,7 +6664,7 @@ y7fdOgAAAABJRU5ErkJggk== - ${table2.shape_activity_name} + ${table2.shape_activity_number} diff --git a/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar b/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar index f0bb383f..9e688ca7 100644 Binary files a/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar and b/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar differ diff --git a/com.actionsoft.apps.coe.pal/manifest.xml b/com.actionsoft.apps.coe.pal/manifest.xml index aa01e66d..71261d43 100755 --- a/com.actionsoft.apps.coe.pal/manifest.xml +++ b/com.actionsoft.apps.coe.pal/manifest.xml @@ -81,10 +81,11 @@ AWS PAL(Process Asset Library)流程资产库是AWS CoE平台的重要产品组 true false - close - [{"name":"分类1","url":"","children":[{"name":"百度链接","url":"http://www.baidu.com"},{"name":"腾讯链接","url":"https://www.tencent.com/zh-cn/"}]},{"name":"分类2","url":"","children":[{"name":"搜狐网链接","url":"https://www.sohu.com/"},{"name":"人民网链接","url":"http://www.people.com.cn/"}]},{"name":"凤凰网链接","url":"https://www.ifeng.com/"}] + close + [{"name":"分类1","url":"","children":[{"name":"百度链接","url":"http://www.baidu.com"},{"name":"腾讯链接","url":"https://www.tencent.com/zh-cn/"}]},{"name":"分类2","url":"","children":[{"name":"搜狐网链接","url":"https://www.sohu.com/"},{"name":"人民网链接","url":"http://www.people.com.cn/"}]},{"name":"凤凰网链接","url":"https://www.ifeng.com/"}] + {"control.risk":{"risk":{"desc":"描述企业内部流程涉及的各级风险点"},"control":{"desc":"描述企业内部流程涉及的各级风险的控制措施"}},"itsystem.normal":{"cloudServer":{"desc":"描述企业接入的云服务设施"},"database":{"desc":"描述企业提供的数据库服务类型,如某Oracle数据库"},"appSystem":{"desc":"描述企业提供的应用系统,如某供应链管理系统、业务流程管理平台"},"device":{"desc":"描述企业提供的各种IT设备"}},"control.kpi":{"kpi":{"desc":"描述企业内部绩效计划、绩效辅导与实施、绩效考核、绩效反馈与改进"}},"process.evc":{"valueChain6":{"desc":"一个基本增值活动或辅助增值活动"},"valueChain5":{"desc":"一个基本增值活动或辅助增值活动"},"valueChain4":{"desc":"一个基本增值活动或辅助增值活动"},"valueChain3":{"desc":"一个基本增值活动或辅助增值活动"},"valueChain2":{"desc":"一个基本增值活动或辅助增值活动"},"valueChain1":{"desc":"一个基本增值活动或辅助增值活动"}},"control.policy":{"item":{"desc":"描述企业内部各级管理制度的具体条款"},"regulation":{"desc":"描述企业内部流程涉及的各级管理制度"}},"data.form":{"form":{"desc":"输入或输出的数据是一个完整的数据结构(或单据)"},"forms":{"desc":"输入或输出的数据由多个数据结构(或单据)组成"}},"process.flowchart":{"internalStorage":{"desc":"存储在存储器中的数据"},"predefinedProcess":{"desc":"在另外地方已得到详细说明的一个操作或一组操作"},"data":{"desc":"表示数据"},"document":{"desc":"表示属于该过程的书面信息"},"paperTape":{"desc":"旧式电脑使用的穿孔纸带输入"},"storedData":{"desc":"表示一般的数据存储"},"preparation":{"desc":"表示修改一条指令或一组指令以影响随后的活动"},"horizontalPool":{"desc":"包含多个泳道,对元素进行区分"},"verticalLane":{"desc":"对泳池里的流程元素的进行组织和分类"},"parallelMode":{"desc":"表示同步进行两个或两个以上并行方式的操作"},"terminator":{"desc":"表示过程的开始或结束"},"offPageReference":{"desc":"表示一组流程,可以用跨页引用进行标识"},"horizontalLane":{"desc":"对泳池里的流程元素的进行组织和分类"},"annotation":{"desc":"标识注解的内容"},"manualInput":{"desc":"人工输入的数据"},"onPageReference":{"desc":"表示流程图的待续,圈内有一子字母或数字"},"process":{"desc":"表示过程中的一个单独步骤"},"manualOperation":{"desc":"由人工完成的操作"},"loopLimit":{"desc":"去上角的上限值和去下角的下限值分别表示循环的开始和结束"},"decision":{"desc":"表示过程中的一项判定或一个分岔点"},"display":{"desc":"在机器上显示"},"verticalPool":{"desc":"包含多个泳道,对元素进行区分"},"sequentialData":{"desc":"老式磁带存储的数据"},"directData":{"desc":"表示流程图中存储在硬盘上的数据源"},"card":{"desc":"旧式电脑使用的打孔卡"}},"process.epc":{"or":{"desc":"表示一件事情可能产生的几个结果中,至少有一个会发生"},"method_service_node":{"desc":"描述流程中的手工活动"},"verticalPool":{"desc":"包含多个泳道,对元素进行区分"},"procedure":{"desc":"本流程的某个环节后引用的其它流程"},"method_approval_node":{"desc":"描述流程中的人机交互活动"},"horizontalPool":{"desc":"包含多个泳道,对元素进行区分"},"verticalLane":{"desc":"对泳池里的流程元素的进行组织和分类"},"method_approval_node3":{"desc":"描述流程中的人机交互活动"},"and":{"desc":"表示一件事情可能产生的几个结果或后续活动,全部发生;或表示一件事情的发生需要几个条件同时满足"},"method_service_node4":{"desc":"描述流程中的手工活动"},"xor":{"desc":"表示一件事情可能产生的几个结果中,有且只有一个会发生"},"event":{"desc":"描述流程运行的状态"},"horizontalLane":{"desc":"对泳池里的流程元素的进行组织和分类"}},"org.role":{"role":{"desc":"一般用于表示执行某一流程步骤的流程角色"}},"process.bpmn2":{"signalIntermediateThrowingEvent":{"desc":"向外广播信号后,流程继续向后执行"},"callActivityCallingProcess":{"desc":"调用定义的全局过程"},"textAnnotation":{"desc":"给元素附加信息,便于理解"},"timerStartEvent":{"desc":"到达设置的日期/时间后,触发流程执行"},"horizontalPool":{"desc":"包含多个泳道,对元素进行区分"},"signalEndEvent":{"desc":"向外广播信号,结束所在分支的执行"},"verticalLane":{"desc":"对泳池里的流程元素的进行组织和分类"},"errorBoundaryInterrputingEvent":{"desc":"捕获活动内部抛出的错误信息,中断正常流程,触发错误处理流程"},"endEvent":{"desc":"结束所在分支的执行"},"serviceTask":{"desc":"使用Web服务或自动化应用的任务"},"exclusiveGateway":{"desc":""},"startEvent":{"desc":"触发流程的执行"},"receiveTask":{"desc":"等待并接受外部参与者发送的消息,消息接受完毕则任务执行完毕"},"signalStartEvent":{"desc":"接收信息,并触发流程的执行"},"messageIntermediateCatchEvent":{"desc":"捕获到特定消息后,该事件被触发,流程继续向后执行"},"messageIntermediateThrowingEvent":{"desc":"向其他参与方发送消息后,流程继续向后执行"},"signalIntermediateCatchEvent":{"desc":"捕获到其他参与方广播的信号后,该事件被触发,流程继续向后执行"},"errorEndEvent":{"desc":"错误结束事件"},"horizontalLane":{"desc":"对泳池里的流程元素的进行组织和分类"},"group":{"desc":"对元素进行分类,不影响流程的执行"},"scriptTask":{"desc":"定义一段执行脚本,由流程引擎执行,脚本执行完毕则任务执行完毕"},"businessRuleTask":{"desc":"调用业务规则引擎进行数据的计算并获得计算结果"},"manualTask":{"desc":"没有任何流程引擎和应用程序协助的纯手工任务"},"signalBoundaryInterrputingEvent":{"desc":"捕获特定信号,中断正常流程,触发异常处理流程"},"verticalPool":{"desc":"包含多个泳道,对元素进行区分"},"compensationBoundaryInterrputingEvent":{"desc":"捕获活动内部抛出的补偿信息,中断正常流程,触发执行补偿活动"},"userTask":{"desc":"在应用程序的协助下,由人工完成的任务"},"terminateEndEvent":{"desc":"结束所有分支的执行"},"messageStartEvent":{"desc":"接收消息,并触发流程的执行"},"messageEndEvent":{"desc":"向其他参与方发送消息,结束所在分支的执行"},"sendTask":{"desc":"向外部参与者发送消息,消息发送完毕则任务执行完毕"},"messageBoundaryInterrputingEvent":{"desc":"捕获特定消息,中断正常流程,触发异常处理流程"},"transaction":{"desc":"遵循特定事务规约的一系列活动"},"timerIntermediateCatchEvent":{"desc":"到达某个特定时间/日期后,触发该事件,流程继续向后执行"}},"org.normal":{"role":{"desc":"一般用于表示执行某一流程步骤的流程角色"},"organization":{"desc":"描述企业内部固定的组织单位"},"position":{"desc":"描述企业内部各部门的实际岗位"},"employee":{"desc":"表示企业的具体员工"}}} - {"default":{"code":"&#xe621;","color":"#FFB718"},"process.businessLevel":{"code":"&#xe8fa;","color":"#FFB718"},"process.businessArea":{"code":"&#xe8f9;","color":"#FFB718"},"process.processGroup":{"code":"&#xe8f6;","color":"#FFB718"},"control.kpi":{"code":"&#xe6f6;","color":"#ff9421"},"control.policy":{"code":"&#xe69c;","color":"#009b52"},"control.risk":{"code":"&#xe73e","color":"#dc4f39"},"data.form":{"code":"&#xe80b;","color":"#009b52"},"itsystem.normal":{"code":"&#xe7ce;","color":"#4E7FF9"},"org.normal":{"code":"&#xe6b6;","color":"#ff9421"},"process.bpmn2":{"code":"&#58981;","color":"#4E7FF9"},"process.evc":{"code":"&#xe8ef;","color":"#4E7FF9"}} + {"default":{"code":"&#xe621;","color":"#FFB718"},"process.businessLevel":{"code":"&#xe8fa;","color":"#FFB718"},"process.businessArea":{"code":"&#xe8f9;","color":"#FFB718"},"process.processGroup":{"code":"&#xe8f6;","color":"#FFB718"},"control.kpi":{"code":"&#xe6f6;","color":"#ff9421"},"control.policy":{"code":"&#xe69c;","color":"#009b52"},"control.risk":{"code":"&#xe73e","color":"#dc4f39"},"data.form":{"code":"&#xe80b;","color":"#009b52"},"itsystem.normal":{"code":"&#xe7ce;","color":"#4E7FF9"},"org.normal":{"code":"&#xe6b6;","color":"#ff9421"},"process.bpmn2":{"code":"&#58981;","color":"#4E7FF9"},"process.evc":{"code":"&#xe8ef;","color":"#4E7FF9"}} diff --git a/com.actionsoft.apps.coe.pal/method/control.policy/diagram.attribute.custom.xml b/com.actionsoft.apps.coe.pal/method/control.policy/diagram.attribute.custom.xml index 2f3ee385..c051c3fd 100644 --- a/com.actionsoft.apps.coe.pal/method/control.policy/diagram.attribute.custom.xml +++ b/com.actionsoft.apps.coe.pal/method/control.policy/diagram.attribute.custom.xml @@ -4,7 +4,7 @@ - + @@ -19,12 +19,12 @@ - - - + + + diff --git a/com.actionsoft.apps.coe.pal/method/org.role/diagram.attribute.custom.xml b/com.actionsoft.apps.coe.pal/method/org.role/diagram.attribute.custom.xml index 938bb495..9ef283ff 100644 --- a/com.actionsoft.apps.coe.pal/method/org.role/diagram.attribute.custom.xml +++ b/com.actionsoft.apps.coe.pal/method/org.role/diagram.attribute.custom.xml @@ -2,5 +2,6 @@ - + + diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/CoEPALController.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/CoEPALController.java index 2f79fc32..99e39a41 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/CoEPALController.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/CoEPALController.java @@ -57,7 +57,7 @@ public class CoEPALController { @Mapping("com.actionsoft.apps.coe.pal_main_page") public String COEPALMAIN(UserContext me, String wsuuid) { Map macroLibraries = new HashMap(); - CoeWorkSpaceModel model = (CoeWorkSpaceModel) CoeWorkSpaceDaoFactory.createCoeWorkSpace().getInstance(wsuuid); + CoeWorkSpaceModel model = CoeWorkSpaceDaoFactory.createCoeWorkSpace().getInstance(wsuuid); macroLibraries.put("sid", me.getSessionId()); macroLibraries.put("wsuuid", wsuuid); // 资产库去掉了版本号,已不做多版本 @@ -203,6 +203,16 @@ public class CoEPALController { return web.getManageMethodData(); } + /** + * 保存形状定义描述 + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal_pl_manage_method_object_desc_save") + public String coePalPlManageMethodObjectDescSave(UserContext me, String shapeName, String desc, String methodId) { + PalManageWeb web = new PalManageWeb(me); + return web.saveMethodObjectDesc(shapeName, desc, methodId); + } + /** * 建模方法->查询特定建模方法的形状定义数据 * @param me @@ -1331,7 +1341,7 @@ public class CoEPALController { @Deprecated @Mapping("com.actionsoft.apps.coe.pal_processlevel_query_check") public String coePALPROCESSLEVELQUERYCHECK(UserContext me, String uuid) { - PALRepositoryModel coeProcessLevelModel = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); + PALRepositoryModel coeProcessLevelModel = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); return coeProcessLevelModel != null ? uuid : ""; } @@ -2917,17 +2927,16 @@ public class CoEPALController { } - - /** + /** * 弹窗新建角色图形创建相应图形 * @param me * @param * @return */ - @Mapping("com.actionsoft.apps.coe.pal_pl_repository_designer_relation_shape_createDialogModel") - public String createDialogModel(UserContext me,String uuid,String methodId,String category) { + @Mapping("com.actionsoft.apps.coe.pal_pl_repository_designer_relation_shape_createDialogModel") + public String createDialogModel(UserContext me,String uuid,String methodId) { CoeProcessLevelWeb web = new CoeProcessLevelWeb(me); - return web.createDialogModel(uuid,methodId,category); + return web.createDialogModel(uuid,methodId); } @@ -2938,9 +2947,9 @@ public class CoEPALController { * @return */ @Mapping("com.actionsoft.apps.coe.pal_pl_repository_designer_relation_find_same_role") - public String relationFindSameRole(UserContext me,String uuid) { + public String relationFindSameRole(UserContext me,String uuid,String methodId) { CoeProcessLevelWeb web = new CoeProcessLevelWeb(me); - return web.relationFindSameRole(uuid); + return web.relationFindSameRole(uuid,methodId); } diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/CoeCooperationAPIManager.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/CoeCooperationAPIManager.java index 096a38aa..1d2e0624 100644 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/CoeCooperationAPIManager.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/CoeCooperationAPIManager.java @@ -2,6 +2,9 @@ package com.actionsoft.apps.coe.pal.cooperation; import com.actionsoft.apps.coe.pal.constant.CoEConstant; +import com.actionsoft.apps.coe.pal.cooperation.cache.CooperationCache; +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.constant.CoeCooperationConst; import com.actionsoft.apps.coe.pal.cooperation.dao.*; import com.actionsoft.apps.coe.pal.cooperation.model.*; @@ -24,10 +27,12 @@ import com.actionsoft.bpms.util.UtilString; import com.actionsoft.sdk.local.SDK; import com.actionsoft.sdk.local.api.AppAPI; import com.alibaba.fastjson.JSONArray; +import org.apache.commons.lang.StringUtils; import javax.servlet.RequestDispatcher; import java.sql.Timestamp; import java.util.*; +import java.util.stream.Collectors; /** * @Created by sunlh @@ -580,28 +585,43 @@ public class CoeCooperationAPIManager { * @param ro havingWritePerm、havingRemovePerm、havingVersionManagePerm 返回true false */ public void queryCooperationMemberActionPerm(String teamId, String userId, ResponseObject ro) { - // 权限获取 - boolean havingWritePerm = true; - boolean havingRemovePerm = true; - boolean havingVersionManagePerm = true; - int validUserPermDataCount = 0;// 当前小组成员有效(流程表中存在)的数据权限数量 - if (!UtilString.isEmpty(teamId) && isInstall()) { - CoeCooperationRoleModel role = queryCooperationRoleByUser(teamId, userId); - if (role != null) { - if (role.getActionPerm() == null) { - role.setActionPerm(""); - }; - havingWritePerm = role.getActionPerm().contains(CoeCooperationConst.ACTION_WRITE);// 新增、修改权限 - havingRemovePerm = role.getActionPerm().contains(CoeCooperationConst.ACTION_DELETE);// 删除权限 - havingVersionManagePerm = role.getActionPerm().contains(CoeCooperationConst.ACTION_VERSION);// 版本管理权限 + boolean isOlderVersion = SDK.getAppAPI().getPropertyBooleanValue("com.actionsoft.apps.coe.pal", "IsOlderVersion", true); + if (isOlderVersion){ + // 权限获取 + boolean havingWritePerm = true; + boolean havingRemovePerm = true; + boolean havingVersionManagePerm = true; + int validUserPermDataCount = 0;// 当前小组成员有效(流程表中存在)的数据权限数量 + if (!UtilString.isEmpty(teamId) && isInstall()) { + Set userOperatePermission = CooperationCache.getUserOperatePermission(teamId, userId); + havingWritePerm = userOperatePermission.contains(CoeCooperationConst.ACTION_WRITE);// 新增、修改权限 + havingRemovePerm = userOperatePermission.contains(CoeCooperationConst.ACTION_DELETE);// 删除权限 + havingVersionManagePerm = userOperatePermission.contains(CoeCooperationConst.ACTION_VERSION);// 版本管理权限 } + ro.put("isOlderVersion", isOlderVersion); + ro.put("havingWritePerm", havingWritePerm);// 新增、修改权限 + ro.put("havingRemovePerm", havingRemovePerm);// 删除权限 + ro.put("havingVersionManagePerm", havingVersionManagePerm);// 版本管理权限 + Set permDataVerIdList = CooperationCache.getUserDataVisitablePermission(teamId, userId,true); + validUserPermDataCount = permDataVerIdList != null ? permDataVerIdList.size() : 0; + ro.put("validUserPermDataCount", validUserPermDataCount); + }else { + boolean havingCreatePerm = true; + boolean havingBatchPerm = true; + int validUserPermDataCount = 0; + if (!UtilString.isEmpty(teamId) && isInstall()) { + Set userOperatePermission = CooperationCache.getUserOperatePermission(teamId, userId); + havingCreatePerm = userOperatePermission.contains(CoeCooperationConst.ACTION_CREATE_PROCESS); + havingBatchPerm = userOperatePermission.contains(CoeCooperationConst.ACTION_BATCH); + } + + ro.put("isOlderVersion", !isOlderVersion);// 新增、修改权限 + ro.put("havingCreatePerm", havingCreatePerm);// 新增、修改权限 + ro.put("havingBatchPerm", havingBatchPerm);// 删除权限 + Set dataVisitablePermission = CooperationCache.getUserDataVisitablePermission(teamId, userId,true); + validUserPermDataCount = dataVisitablePermission != null ? dataVisitablePermission.size() : 0; + ro.put("validUserPermDataCount", validUserPermDataCount); } - ro.put("havingWritePerm", havingWritePerm);// 新增、修改权限 - ro.put("havingRemovePerm", havingRemovePerm);// 删除权限 - ro.put("havingVersionManagePerm", havingVersionManagePerm);// 版本管理权限 - List permDataVerIdList = queryCooperationRoleDataPermByTeamUser(teamId, userId, true); - validUserPermDataCount = permDataVerIdList != null ? permDataVerIdList.size() : 0; - ro.put("validUserPermDataCount", validUserPermDataCount); } /** @@ -735,4 +755,125 @@ public class CoeCooperationAPIManager { return false; } + + 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 permVerIds = new CoeCooperationTeamPermDao().getCooperationTeamPermVerIds(teamModel.getId()); + teamInfo.getVersionIds().addAll(permVerIds); + + list.add(teamInfo); + } + return list; + } + + public List getUserInfoByTeamId(String teamId){ + List list = new ArrayList<>(); + + Map userMap = new HashMap<>(); + List memberModels = new CoeCooperationMemberDao().queryUserListByTeam(teamId); + for (CoeCooperationMemberModel memberModel : memberModels) { + UserInfo userInfo = userMap.get(memberModel.getUserId()); + if (null == userInfo){ + userInfo = new UserInfo(); + userInfo.setUserid(memberModel.getUserId()); + userInfo.getRoleIds().add(memberModel.getRoleId()); + }else { + userInfo.getRoleIds().add(memberModel.getRoleId()); + } + userMap.put(memberModel.getUserId(),userInfo); + } + + for (UserInfo userInfo : userMap.values()) { + List roleIds = userInfo.getRoleIds(); + Set appPerm = this.getAppPerm(roleIds); + userInfo.setAppPermission(appPerm); + + Set actionPerm = this.getActionPerm(roleIds); + userInfo.setOperatePermission(actionPerm); + + boolean allDataPerm = this.isAllDataPerm(roleIds); + userInfo.setIsAllDataPermission(allDataPerm); + + if (!allDataPerm){ + Map> dataPerm = this.getDataPerm(teamId, roleIds); + userInfo.setDataPermission(dataPerm); + } + } + + list.addAll(userMap.values()); + return list; + } + + private Set getAppPerm(List roleIds){ + Set set = new HashSet<>(); + for (String roleId : roleIds) { + CoeCooperationRoleModel roleModel = new CoeCooperationRoleDao().queryById(roleId); + if (null == roleModel){ + continue; + } + //设置全局app权限 + List appPerm = Arrays.stream(roleModel.getAppPerm().split(",")).collect(Collectors.toList()); + set.addAll(appPerm); + } + return set; + } + + private Set getActionPerm(List roleIds){ + Set set = new HashSet<>(); + for (String roleId : roleIds) { + CoeCooperationRoleModel roleModel = new CoeCooperationRoleDao().queryById(roleId); + if (null == roleModel){ + continue; + } + //设置全局操作权限 + List actionPermList = Arrays.stream(roleModel.getActionPerm().split(",")).collect(Collectors.toList()); + set.addAll(actionPermList); + } + return set; + } + + private boolean isAllDataPerm(List roleIds){ + for (String roleId : roleIds) { + CoeCooperationRoleModel roleModel = new CoeCooperationRoleDao().queryById(roleId); + if (null == roleModel){ + continue; + } + if (roleModel.getDataPerm().equals("all")){ + return true; + } + } + return false; + } + + private Map> getDataPerm(String teamId,List roleIds){ + Map> map = new HashMap<>(); + for (String roleId : roleIds) { + CoeCooperationRoleModel roleModel = new CoeCooperationRoleDao().queryById(roleId); + if (null == roleModel) { + continue; + } + //获取角色下数据权限,设置数据权限 + List rolePerms = new CoeCooperationRolePermDao().getRolePermByTeamIdAndRoleId(teamId, roleId); + for (CoeCooperationRolePermModel rolePerm : rolePerms) { + Set dataPerm = map.get(rolePerm.getPalVersionId()); + if (null == dataPerm){ + dataPerm = new HashSet<>(); + } + if (StringUtils.isNotEmpty(rolePerm.getActionPerm())){ + dataPerm.addAll(Arrays.asList(rolePerm.getActionPerm().split(",").clone())); + } + map.put(rolePerm.getPalVersionId(), dataPerm); + } + } + return map; + } + } diff --git a/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/cache/CooperationCache.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/cache/CooperationCache.java similarity index 61% rename from com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/cache/CooperationCache.java rename to com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/cache/CooperationCache.java index 1247ee21..cda73bc6 100644 --- a/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/cache/CooperationCache.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/cache/CooperationCache.java @@ -1,16 +1,21 @@ package com.actionsoft.apps.coe.pal.cooperation.cache; -import com.actionsoft.apps.coe.pal.cooperation.CooperationQueryAPIManager; + +import com.actionsoft.apps.coe.pal.constant.CoEConstant; +import com.actionsoft.apps.coe.pal.cooperation.CoeCooperationAPIManager; 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.constant.Constant; -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.constant.CoeCooperationConst; +import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache; +import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel; import com.actionsoft.apps.resource.plugin.profile.CachePluginProfile; import com.actionsoft.bpms.commons.cache.Cache; import com.actionsoft.bpms.commons.cache.CacheManager; +import com.actionsoft.bpms.commons.mvc.view.ResponseObject; import com.actionsoft.bpms.util.ConsolePrinter; import com.actionsoft.sdk.local.SDK; +import com.actionsoft.sdk.local.api.AppAPI; +import com.alibaba.fastjson.JSONArray; import java.util.*; import java.util.stream.Collectors; @@ -22,13 +27,13 @@ public class CooperationCache extends Cache { @Override protected void load() { - List allTeamInfo = CooperationQueryAPIManager.getInstance().getAllTeamInfo(); + List allTeamInfo = CoeCooperationAPIManager.getInstance().getAllTeamInfo(); for (TeamInfo teamInfo : allTeamInfo) { put(teamInfo.getTeamId(),teamInfo); } //平台console打印 - ConsolePrinter.info("[" + SDK.getAppAPI().getAppContext(Constant.APP_ID).getNameI18N() + "]Cache加载pal 小组用户角色权限信息 [" + (( allTeamInfo == null) ? 0 : allTeamInfo.size()) + "个]"); + ConsolePrinter.info("[" + SDK.getAppAPI().getAppContext(CoEConstant.APP_ID).getNameI18N() + "]Cache加载pal 小组用户角色权限信息 [" + (( allTeamInfo == null) ? 0 : allTeamInfo.size()) + "个]"); } @@ -74,6 +79,9 @@ public class CooperationCache extends Cache { */ public static UserInfo getUserInfo(String teamId,String userid){ TeamInfo teamInfo = getCache().get(teamId); + if (null == teamInfo){ + return null; + } for (UserInfo user : teamInfo.getUsers()) { if (user.getUserid().equals(userid)){ return user; @@ -120,30 +128,54 @@ public class CooperationCache extends Cache { if (null == userInfo){ return new HashSet<>(); } - String appPerm = userInfo.getAppPermission(); - if ("all".equals(appPerm)){ + Set appPermission = userInfo.getAppPermission(); + if (appPermission.contains("all")){ Set set = new HashSet<>(); - List appProfiles = CooperationAppManager.getList(); - for (CooperationAppProfile profile : appProfiles) { - set.add(profile.getId()); + // aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.coe.pal.cooperation/listApps"; + //列出已注册的流程团队扩展App + ResponseObject ro = SDK.getAppAPI().callASLP(SDK.getAppAPI().getAppContext(CoEConstant.APP_ID), aslp, new HashMap()); + if (ro.isOk()) { + JSONArray appArr = (JSONArray)((Map)ro.getData()).get("apps"); + for (int i = 0; i < appArr.size(); i++) { + set.add(appArr.getJSONObject(i).getString("id")); + } } return set; } - return Arrays.stream(appPerm.split(",")).collect(Collectors.toSet()); + return appPermission; } /** * 根据小组与用户id获取用户数据访问权限 * @param teamId * @param userid + * @param isValidPermData 查询使用中的文件标志,true:过滤掉进入回收站的数据,false:查询全部权限数据 * @return */ - public static Set getUserDataVisitablePermission(String teamId,String userid){ + public static Set getUserDataVisitablePermission(String teamId,String userid,boolean isValidPermData){ UserInfo userInfo = CooperationCache.getUserInfo(teamId, userid); if (null == userInfo){ return new HashSet<>(); } - return userInfo.getDataPermission().keySet(); + if (userInfo.getIsAllDataPermission()){ + TeamInfo teamInfo = CooperationCache.getTeamInfo(teamId); + return teamInfo.getVersionIds(); + } + Set set = new HashSet<>(); + Set keySet = userInfo.getDataPermission().keySet(); + for (String next : keySet) { + if (isValidPermData) { + // 在流程表的校验,抛弃回收站中删除文件 + List verModels = PALRepositoryCache.getByVersionId(next); + if (verModels != null && verModels.size() > 0) { + set.add(next); + } + }else { + set.add(next); + } + } + return set; } /** @@ -158,6 +190,9 @@ public class CooperationCache extends Cache { if (null == userInfo){ return new HashSet<>(); } + if (userInfo.getIsAllDataPermission()){ + return Arrays.stream(new String [] {CoeCooperationConst.ACTION_WRITE,CoeCooperationConst.ACTION_DELETE,CoeCooperationConst.ACTION_VERSION}).collect(Collectors.toSet()); + } return userInfo.getDataPermission().get(versionId); } diff --git a/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/cache/model/TeamInfo.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/cache/model/TeamInfo.java similarity index 68% rename from com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/cache/model/TeamInfo.java rename to com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/cache/model/TeamInfo.java index eac713f5..fd6585fb 100644 --- a/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/cache/model/TeamInfo.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/cache/model/TeamInfo.java @@ -1,7 +1,9 @@ package com.actionsoft.apps.coe.pal.cooperation.cache.model; import java.io.Serializable; +import java.util.HashSet; import java.util.List; +import java.util.Set; public class TeamInfo implements Serializable { private static final long serialVersionUID = 1L; @@ -10,6 +12,8 @@ public class TeamInfo implements Serializable { private List users; + private Set versionIds = new HashSet<>(); + public TeamInfo() {} public String getTeamId() { @@ -27,4 +31,12 @@ public class TeamInfo implements Serializable { public void setUsers(List users) { this.users = users; } + + public Set getVersionIds() { + return versionIds; + } + + public void setVersionIds(Set versionIds) { + this.versionIds = versionIds; + } } diff --git a/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/cache/model/UserInfo.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/cache/model/UserInfo.java similarity index 85% rename from com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/cache/model/UserInfo.java rename to com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/cache/model/UserInfo.java index b79e5b16..fde1e912 100644 --- a/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/cache/model/UserInfo.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/cache/model/UserInfo.java @@ -9,7 +9,7 @@ public class UserInfo implements Serializable { private String userid; private List roleIds = new ArrayList<>(); private Set operatePermission = new HashSet<>(); - private String appPermission ; + private Set appPermission = new HashSet<>(); private Map> dataPermission = new HashMap<>(); private boolean isAllDataPermission; @@ -40,11 +40,11 @@ public class UserInfo implements Serializable { this.operatePermission = operatePermission; } - public String getAppPermission() { + public Set getAppPermission() { return appPermission; } - public void setAppPermission(String appPermission) { + public void setAppPermission(Set appPermission) { this.appPermission = appPermission; } @@ -52,7 +52,7 @@ public class UserInfo implements Serializable { return dataPermission; } - public void setIsDataPermission(Map> dataPermission) { + public void setDataPermission(Map> dataPermission) { this.dataPermission = dataPermission; } diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/constant/CoeCooperationConst.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/constant/CoeCooperationConst.java index abdcf7c3..bfacb990 100644 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/constant/CoeCooperationConst.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/constant/CoeCooperationConst.java @@ -61,4 +61,14 @@ public class CoeCooperationConst { */ public static final String ACTION_VERSION = "v"; + /** + * 新版角色操作权限:新建流程 + */ + public static final String ACTION_CREATE_PROCESS = "createProcess"; + + /** + * 新版角色操作权限:新建流程 + */ + public static final String ACTION_BATCH = "batch"; + } diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/log/CoEOpLogConst.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/log/CoEOpLogConst.java index 52a0853f..63cde017 100644 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/log/CoEOpLogConst.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/log/CoEOpLogConst.java @@ -151,6 +151,14 @@ public class CoEOpLogConst extends AuditConst { public static final String INFO_OUTPUT_DOWNLOAD = "下载报告手册文档"; public static final String INFO_OUTPUT_DOWNLOAD_LOG = "下载报告手册文档日志"; + // 数据迁移 + public static final String INFO_DATAMIGRATION_ACCESS = "访问数据迁移模块"; + public static final String INFO_DATAMIGRATION_CREATE = "新建数据迁移"; + public static final String INFO_DATAMIGRATION_UPDATE = "更新数据迁移"; + public static final String INFO_DATAMIGRATION_DELETE = "访问数据迁移"; + public static final String INFO_DATAMIGRATION_DOWNLOAD_LOG = "下载数据迁移日志"; + + diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/manage/method/PalManageWeb.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/manage/method/PalManageWeb.java index 3f8a60d3..7d5e8bab 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/manage/method/PalManageWeb.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/manage/method/PalManageWeb.java @@ -418,24 +418,26 @@ public class PalManageWeb extends ActionWeb { tempSchema = replaceTextEPC(tempSchema); List list = getSchemaToJson(tempSchema); String type = I18nRes.findValue(CoEConstant.APP_ID, methodId.split("\\.")[0]); + // 建模对象描述 + JSONObject methodObjectDesc = SDK.getAppAPI().getPropertyJSONObjectValue(CoEConstant.APP_ID, "METHOD_OBJECT_DESC", new JSONObject()); JSONArray data = new JSONArray(); for (int i = 0; i < list.size(); i++) { String s = list.get(i); String name = ""; String title = ""; if (s.contains("name:\"")) { - s = s.substring(s.indexOf("name:\""), s.length()); + s = s.substring(s.indexOf("name:\"")); name = s.substring(s.indexOf("name:\"") + 6, s.indexOf("\",")); } else { - s = s.substring(s.indexOf("name:"), s.length()); + s = s.substring(s.indexOf("name:")); name = s.substring(s.indexOf("name:") + 5, s.indexOf("\",")); } if (s.contains("title:\"")) { - s = s.substring(s.indexOf("title:\""), s.length()); + s = s.substring(s.indexOf("title:\"")); title = s.substring(s.indexOf("title:\"") + 7, s.indexOf("\",")); } else { - s = s.substring(s.indexOf("title:"), s.length()); + s = s.substring(s.indexOf("title:")); title = s.substring(s.indexOf("title:") + 6, s.indexOf(",")); } if ("Participant".equals(title) || "VerticalSeparatorBar".equals(title) || "verticalSeparatorBar".equals(name) || "horizontalSeparatorBar".equals(name)) { @@ -452,6 +454,12 @@ public class PalManageWeb extends ActionWeb { obj.put("modelId", methodId); obj.put("type", type); obj.put("showShapeConfig", !name.equals("horizontalSeparator") && !name.equals("verticalSeparator")); + // 描述信息查询 + String desc = ""; + if (methodObjectDesc.containsKey(methodId) && methodObjectDesc.getJSONObject(methodId).containsKey(name) && methodObjectDesc.getJSONObject(methodId).getJSONObject(name).containsKey("desc")) { + desc = methodObjectDesc.getJSONObject(methodId).getJSONObject(name).getString("desc"); + } + obj.put("desc", desc); data.add(obj); } ro.put("data", data); @@ -1410,4 +1418,25 @@ public class PalManageWeb extends ActionWeb { return HtmlPageTemplate.merge(CoEConstant.APP_ID, template, map); } + /** + * 保存形状定义描述 + * @param shapeName 形状name + * @param desc 形状定义描述 + * @param methodId 建模方法 + * @return + */ + public String saveMethodObjectDesc(String shapeName, String desc, String methodId) { + ResponseObject ro = ResponseObject.newOkResponse(); + desc = desc == null ? "" : desc.trim(); + JSONObject methodObjectDesc = SDK.getAppAPI().getPropertyJSONObjectValue(CoEConstant.APP_ID, "METHOD_OBJECT_DESC", new JSONObject()); + if (!methodObjectDesc.containsKey(methodId)) { + methodObjectDesc.put(methodId, new JSONObject()); + } + if (!methodObjectDesc.getJSONObject(methodId).containsKey(shapeName)) { + methodObjectDesc.getJSONObject(methodId).put(shapeName, new JSONObject()); + } + methodObjectDesc.getJSONObject(methodId).getJSONObject(shapeName).put("desc", desc); + SDK.getAppAPI().setProperty(CoEConstant.APP_ID, "METHOD_OBJECT_DESC", methodObjectDesc.toString()); + return ro.toString(); + } } diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/output/OutputAPIManager.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/output/OutputAPIManager.java index 009079d4..a71033a3 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/output/OutputAPIManager.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/output/OutputAPIManager.java @@ -1,5 +1,6 @@ package com.actionsoft.apps.coe.pal.pal.output; -import java.io.FileInputStream; + +import java.io.FileInputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -35,227 +36,226 @@ import com.alibaba.fastjson.JSONObject; /** * 报告生成器内部API封装 - * + * * @author jack - * */ public class OutputAPIManager { - private static OutputAPIManager instance = new OutputAPIManager(); + private static OutputAPIManager instance = new OutputAPIManager(); - private OutputAPIManager() { - } + private OutputAPIManager() { + } - public static OutputAPIManager getInstance() { - return instance; - } + public static OutputAPIManager getInstance() { + return instance; + } - // -------------------任务保存/提取---------------------- + // -------------------任务保存/提取---------------------- - /** - * 保存向导限定目标范围、限定关联范围、报告选项等非数据库持久的JSON数据串 - * - * @param wsId 资产库id - * @param id 任务Id - * @param profileId 报告生成器扩展App的配置Id - * @param jsonData 拼装的json数据串 - */ - public void saveWizardJsonData(String wsId, String id, String profileId, String jsonData) throws AWSException { - // --------app appProfile---------- - OutputAppProfile appProfile = OutputAppManager.getProfile(profileId); - if (appProfile == null) - throw new AWSException("Not Find OutputAppProfile! profileId=" + profileId); - // --------dc context----------- - DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT); - if (dcProfile == null) - throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); - DCContext dcContext = new DCContext(null, dcProfile, appProfile.getAppContext().getId(), wsId, id, OutputConst.FILE_WIZARD_CONFIG); - InputStream in = null; - try { - in = new ByteArrayInputStream(jsonData.getBytes("UTF-8")); - boolean isSave = SDK.getDCAPI().write(in, dcContext); - if (!isSave) { - throw new AWSException("Save Parameter Error!"); - } - } catch (Exception e) { - throw new AWSException(e); - } finally { - try { - if (in != null) - in.close(); - } catch (Exception e) { - } - } - } + /** + * 保存向导限定目标范围、限定关联范围、报告选项等非数据库持久的JSON数据串 + * + * @param wsId 资产库id + * @param id 任务Id + * @param profileId 报告生成器扩展App的配置Id + * @param jsonData 拼装的json数据串 + */ + public void saveWizardJsonData(String wsId, String id, String profileId, String jsonData) throws AWSException { + // --------app appProfile---------- + OutputAppProfile appProfile = OutputAppManager.getProfile(profileId); + if (appProfile == null) + throw new AWSException("Not Find OutputAppProfile! profileId=" + profileId); + // --------dc context----------- + DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT); + if (dcProfile == null) + throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); + DCContext dcContext = new DCContext(null, dcProfile, appProfile.getAppContext().getId(), wsId, id, OutputConst.FILE_WIZARD_CONFIG); + InputStream in = null; + try { + in = new ByteArrayInputStream(jsonData.getBytes("UTF-8")); + boolean isSave = SDK.getDCAPI().write(in, dcContext); + if (!isSave) { + throw new AWSException("Save Parameter Error!"); + } + } catch (Exception e) { + throw new AWSException(e); + } finally { + try { + if (in != null) + in.close(); + } catch (Exception e) { + } + } + } - /** - * 删除文件 - * - * @param wsId 资产库id - * @param id 任务Id - * @param profileId 报告生成器扩展App的配置Id - * @throws AWSException - */ - public void delFile(String wsId, String id, String profileId) throws AWSException { - UtilFile file = getFilePath(wsId, id, profileId); - if (file.isDirectory()) { - File[] files = file.listFiles(); - for (File f : files) { - if (f.exists()) { - boolean flag = f.getAbsoluteFile().delete(); - } - } - file.delete(); - } - } + /** + * 删除文件 + * + * @param wsId 资产库id + * @param id 任务Id + * @param profileId 报告生成器扩展App的配置Id + * @throws AWSException + */ + public void delFile(String wsId, String id, String profileId) throws AWSException { + UtilFile file = getFilePath(wsId, id, profileId); + if (file.isDirectory()) { + File[] files = file.listFiles(); + for (File f : files) { + if (f.exists()) { + boolean flag = f.getAbsoluteFile().delete(); + } + } + file.delete(); + } + } - /** - * 删除资产库时同时删除文件 - * - * @param wsid 资产库id - * @throws AWSException - */ - public void delTaskByWsid(String wsid) throws AWSException { - List list = new OutputTask().getTasksByWsid(wsid); - if (new OutputTask().delTaskByWsid(wsid)) { - String profileId = null; - for (OutputTaskModel model : list) { - profileId = model.getProfileId(); - delFile(wsid, model.getId(), model.getProfileId()); - } - if (profileId != null) { - delFile(wsid, "", profileId); - } - } - } + /** + * 删除资产库时同时删除文件 + * + * @throws AWSException + * @param wsid 资产库id + */ + public void delTaskByWsid(String wsid) throws AWSException { + List list = new OutputTask().getTasksByWsid(wsid); + if (new OutputTask().delTaskByWsid(wsid)) { + String profileId = null; + for (OutputTaskModel model : list) { + profileId = model.getProfileId(); + delFile(wsid, model.getId(), model.getProfileId()); + } + if (profileId != null) { + delFile(wsid, "", profileId); + } + } + } - /** - * 得到文件 - * - * @param wsId 资产库id - * @param id 任务Id - * @param profileId 报告生成器扩展App的配置Id - * @throws AWSException - */ - public UtilFile getFilePath(String wsId, String id, String profileId) throws AWSException { - OutputAppProfile appProfile = OutputAppManager.getProfile(profileId); - if (appProfile == null) - throw new AWSException("Not Find OutputAppProfile! profileId=" + profileId); - DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT); - if (dcProfile == null) - throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); - DCContext dcContext = new DCContext(null, dcProfile, appProfile.getAppContext().getId(), wsId, id); - UtilFile file = new UtilFile(dcContext.getPath()); - return file; - } + /** + * 得到文件 + * + * @param wsId 资产库id + * @param id 任务Id + * @param profileId 报告生成器扩展App的配置Id + * @throws AWSException + */ + public UtilFile getFilePath(String wsId, String id, String profileId) throws AWSException { + OutputAppProfile appProfile = OutputAppManager.getProfile(profileId); + if (appProfile == null) + throw new AWSException("Not Find OutputAppProfile! profileId=" + profileId); + DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT); + if (dcProfile == null) + throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); + DCContext dcContext = new DCContext(null, dcProfile, appProfile.getAppContext().getId(), wsId, id); + UtilFile file = new UtilFile(dcContext.getPath()); + return file; + } - /** - * 保存向导限定目标范围、限定关联范围、报告选项等非数据库持久的JSON数据串 - * - * @param wsId 资产库id - * @param id 任务Id - * @param profileId 报告生成器扩展App的配置Id - */ - public String getWizardJsonData(String wsId, String id, String profileId) throws AWSException { - // --------app appProfile---------- - OutputAppProfile appProfile = OutputAppManager.getProfile(profileId); - if (appProfile == null) - throw new AWSException("Not Find OutputAppProfile! profileId=" + profileId); - // --------dc context----------- - DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT); - if (dcProfile == null) - throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); - DCContext dcContext = new DCContext(null, dcProfile, appProfile.getAppContext().getId(), wsId, id, OutputConst.FILE_WIZARD_CONFIG); - File configFile = new File(dcContext.getFilePath()); - // 如果该配置还不存在,没有保存过 - if (!configFile.exists()) { - return ""; - } - InputStream in = null; - try { - //in = SDK.getDCAPI().read(dcContext); - in = new FileInputStream(configFile); - int b = -1; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - while((b=in.read())!=-1){ - baos.write(b); - } - return baos.toString("UTF-8"); - } catch (Exception e) { - throw new AWSException(e); - } finally { - try { - if (in != null) - in.close(); - } catch (Exception e) { - } - } - } + /** + * 保存向导限定目标范围、限定关联范围、报告选项等非数据库持久的JSON数据串 + * + * @param wsId 资产库id + * @param id 任务Id + * @param profileId 报告生成器扩展App的配置Id + */ + public String getWizardJsonData(String wsId, String id, String profileId) throws AWSException { + // --------app appProfile---------- + OutputAppProfile appProfile = OutputAppManager.getProfile(profileId); + if (appProfile == null) + throw new AWSException("Not Find OutputAppProfile! profileId=" + profileId); + // --------dc context----------- + DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT); + if (dcProfile == null) + throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); + DCContext dcContext = new DCContext(null, dcProfile, appProfile.getAppContext().getId(), wsId, id, OutputConst.FILE_WIZARD_CONFIG); + File configFile = new File(dcContext.getFilePath()); + // 如果该配置还不存在,没有保存过 + if (!configFile.exists()) { + return ""; + } + InputStream in = null; + try { + //in = SDK.getDCAPI().read(dcContext); + in = new FileInputStream(configFile); + int b = -1; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + while ((b = in.read()) != -1) { + baos.write(b); + } + return baos.toString("UTF-8"); + } catch (Exception e) { + throw new AWSException(e); + } finally { + try { + if (in != null) + in.close(); + } catch (Exception e) { + } + } + } - // -------------------任务执行/操作---------------------- + // -------------------任务执行/操作---------------------- - /** - * 克隆一个任务 - * - * @param userId 操作人账户 - * @param id 源任务id,必须是已执行完毕的 - * @throws AWSException - */ - public void cloneTask(String userId, String id) throws Exception { - OutputTaskModel outputTaskModel = new OutputTask().queryById(id); - if (outputTaskModel == null) - throw new AWSException("Not Find outputTask! id=" + id); - if (outputTaskModel.getTaskState() != OutputConst.TASK_STATE_SUCESS && outputTaskModel.getTaskState() != OutputConst.TASK_STATE_ERROR) - throw new AWSException("Task State is " + outputTaskModel.getTaskState() + ", Refuse to Clone!"); - OutputAppProfile appProfile = OutputAppManager.getProfile(outputTaskModel.getProfileId()); - if (appProfile == null) - throw new AWSException("Not Find OutputAppProfile! profileId=" + outputTaskModel.getProfileId()); - // --------dc context----------- - DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT); - if (dcProfile == null) - throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); - DCContext sourceDcContext = new DCContext(null, dcProfile, appProfile.getAppContext().getId(), outputTaskModel.getWsId(), id, OutputConst.FILE_WIZARD_CONFIG); - //判断源文件是否存在 - UtilFile sourceFile = new UtilFile(sourceDcContext.getFilePath()); - if (!sourceFile.exists()) { - throw new Exception("sourceFile not found"); - } - outputTaskModel.setId(UUIDGener.getUUID()); - outputTaskModel.setUserId(userId); - new OutputTask().insert(outputTaskModel); - // copy config.txt - DCContext targetDcContext = new DCContext(null, dcProfile, appProfile.getAppContext().getId(), outputTaskModel.getWsId(), outputTaskModel.getId(), OutputConst.FILE_WIZARD_CONFIG); - SDK.getDCAPI().copyDCFile(sourceDcContext, targetDcContext); - } + /** + * 克隆一个任务 + * + * @param userId 操作人账户 + * @param id 源任务id,必须是已执行完毕的 + * @throws AWSException + */ + public void cloneTask(String userId, String id) throws Exception { + OutputTaskModel outputTaskModel = new OutputTask().queryById(id); + if (outputTaskModel == null) + throw new AWSException("Not Find outputTask! id=" + id); + if (outputTaskModel.getTaskState() != OutputConst.TASK_STATE_SUCESS && outputTaskModel.getTaskState() != OutputConst.TASK_STATE_ERROR) + throw new AWSException("Task State is " + outputTaskModel.getTaskState() + ", Refuse to Clone!"); + OutputAppProfile appProfile = OutputAppManager.getProfile(outputTaskModel.getProfileId()); + if (appProfile == null) + throw new AWSException("Not Find OutputAppProfile! profileId=" + outputTaskModel.getProfileId()); + // --------dc context----------- + DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT); + if (dcProfile == null) + throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); + DCContext sourceDcContext = new DCContext(null, dcProfile, appProfile.getAppContext().getId(), outputTaskModel.getWsId(), id, OutputConst.FILE_WIZARD_CONFIG); + //判断源文件是否存在 + UtilFile sourceFile = new UtilFile(sourceDcContext.getFilePath()); + if (!sourceFile.exists()) { + throw new Exception("sourceFile not found"); + } + outputTaskModel.setId(UUIDGener.getUUID()); + outputTaskModel.setUserId(userId); + new OutputTask().insert(outputTaskModel); + // copy config.txt + DCContext targetDcContext = new DCContext(null, dcProfile, appProfile.getAppContext().getId(), outputTaskModel.getWsId(), outputTaskModel.getId(), OutputConst.FILE_WIZARD_CONFIG); + SDK.getDCAPI().copyDCFile(sourceDcContext, targetDcContext); + } - /** - * 创建线程,执行报告生成任务 - * - * @param id - */ - public void startTask(String id, UserContext uc) throws AWSException { - OutputTaskModel outputTaskModel = new OutputTask().queryById(id); - if (outputTaskModel == null) - throw new AWSException("Not Find outputTask! id=" + id); + /** + * 创建线程,执行报告生成任务 + * + * @param id + */ + public void startTask(String id, UserContext uc) throws AWSException { + OutputTaskModel outputTaskModel = new OutputTask().queryById(id); + if (outputTaskModel == null) + throw new AWSException("Not Find outputTask! id=" + id); - if (outputTaskModel.getTaskState() != OutputConst.TASK_STATE_NONE) - throw new AWSException("Task State is " + outputTaskModel.getTaskState() + ", Refuse to Start!"); + if (outputTaskModel.getTaskState() != OutputConst.TASK_STATE_NONE) + throw new AWSException("Task State is " + outputTaskModel.getTaskState() + ", Refuse to Start!"); - // --------app appProfile---------- - OutputAppProfile appProfile = OutputAppManager.getProfile(outputTaskModel.getProfileId()); - if (appProfile == null) - throw new AWSException("Not Find OutputAppProfile! profileId=" + outputTaskModel.getProfileId()); - String gennerClass = appProfile.getGenerClass(); - if (UtilString.isEmpty(gennerClass)) - throw new AWSException("OutputAppProfile 'gennerClass' is Null! AppName=" + appProfile.getTitle()); + // --------app appProfile---------- + OutputAppProfile appProfile = OutputAppManager.getProfile(outputTaskModel.getProfileId()); + if (appProfile == null) + throw new AWSException("Not Find OutputAppProfile! profileId=" + outputTaskModel.getProfileId()); + String gennerClass = appProfile.getGenerClass(); + if (UtilString.isEmpty(gennerClass)) + throw new AWSException("OutputAppProfile 'gennerClass' is Null! AppName=" + appProfile.getTitle()); - // --------dc context----------- - DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT); - if (dcProfile == null) - throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); - DCContext dcContext = new DCContext(uc, dcProfile, appProfile.getAppContext().getId(), outputTaskModel.getWsId(), id); + // --------dc context----------- + DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT); + if (dcProfile == null) + throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); + DCContext dcContext = new DCContext(uc, dcProfile, appProfile.getAppContext().getId(), outputTaskModel.getWsId(), id); - // ---------config--------------- - String wizardJsonData = getWizardJsonData(outputTaskModel.getWsId(), id, appProfile.getId()); + // ---------config--------------- + String wizardJsonData = getWizardJsonData(outputTaskModel.getWsId(), id, appProfile.getId()); /*JSONObject object = JSONObject.parseObject(wizardJsonData); String fileIds = object.getString("targetFileId"); @@ -274,251 +274,252 @@ public class OutputAPIManager { signalThread.setName("CoE Output Report Genner-" + appProfile.getTitle() + "-" + outputTaskModel.getTaskName() + "-" + arr[i]); signalThread.start(); }*/ - - // start thread - GennerReport gener = new GennerReport(outputTaskModel, appProfile, dcContext, wizardJsonData); - - Thread signalThread = new Thread(gener); - signalThread.setName("CoE Output Report Genner-" + appProfile.getTitle() + "-" + outputTaskModel.getTaskName()); - signalThread.start(); - // 操作行为日志记录 - if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { - CoEOpLogAPI.auditOkOp(uc, CoEOpLogConst.MODULE_CATEGORY_APPCENTER, CoEOpLogConst.OP_CREATE, CoEOpLogConst.INFO_OUTPUT_CREATE); - } - } - - /** - * 创建线程,执行报告生成任务 - * - * @param id - */ - public ResponseObject startTaskAndReturnResult(String id, UserContext uc) throws AWSException { - OutputTaskModel outputTaskModel = new OutputTask().queryById(id); - if (outputTaskModel == null) - throw new AWSException("Not Find outputTask! id=" + id); - if (outputTaskModel.getTaskState() != OutputConst.TASK_STATE_NONE) - throw new AWSException("Task State is " + outputTaskModel.getTaskState() + ", Refuse to Start!"); + // start thread + GennerReport gener = new GennerReport(outputTaskModel, appProfile, dcContext, wizardJsonData); - // --------app appProfile---------- - OutputAppProfile appProfile = OutputAppManager.getProfile(outputTaskModel.getProfileId()); - if (appProfile == null) - throw new AWSException("Not Find OutputAppProfile! profileId=" + outputTaskModel.getProfileId()); - String gennerClass = appProfile.getGenerClass(); - if (UtilString.isEmpty(gennerClass)) - throw new AWSException("OutputAppProfile 'gennerClass' is Null! AppName=" + appProfile.getTitle()); + Thread signalThread = new Thread(gener); + signalThread.setName("CoE Output Report Genner-" + appProfile.getTitle() + "-" + outputTaskModel.getTaskName()); + signalThread.start(); + // 操作行为日志记录 + if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { + CoEOpLogAPI.auditOkOp(uc, CoEOpLogConst.MODULE_CATEGORY_APPCENTER, CoEOpLogConst.OP_CREATE, CoEOpLogConst.INFO_OUTPUT_CREATE); + } + } - // --------dc context----------- - DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT); - if (dcProfile == null) - throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); - DCContext dcContext = new DCContext(uc, dcProfile, appProfile.getAppContext().getId(), outputTaskModel.getWsId(), id); + /** + * 创建线程,执行报告生成任务 + * + * @param id + */ + public ResponseObject startTaskAndReturnResult(String id, UserContext uc) throws AWSException { + OutputTaskModel outputTaskModel = new OutputTask().queryById(id); + if (outputTaskModel == null) + throw new AWSException("Not Find outputTask! id=" + id); - // ---------config--------------- - String wizardJsonData = getWizardJsonData(outputTaskModel.getWsId(), id, appProfile.getId()); - - CallableGennerReport gener = new CallableGennerReport(outputTaskModel, appProfile, dcContext, wizardJsonData); - FutureTask task = new FutureTask<>(gener); - Thread signalThread = new Thread(task); - signalThread.setName("CoE Output Report Genner-" + appProfile.getTitle() + "-" + outputTaskModel.getTaskName()); - signalThread.start(); - try { - return task.get(); - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); - return ResponseObject.newErrResponse(); - } - } + if (outputTaskModel.getTaskState() != OutputConst.TASK_STATE_NONE) + throw new AWSException("Task State is " + outputTaskModel.getTaskState() + ", Refuse to Start!"); - /** - * 三员管理模式下,重新生成步骤横表手册 - * @param outputTaskModel - */ - public void reGennerReport(UserContext uc,OutputTaskModel outputTaskModel,String id){ + // --------app appProfile---------- + OutputAppProfile appProfile = OutputAppManager.getProfile(outputTaskModel.getProfileId()); + if (appProfile == null) + throw new AWSException("Not Find OutputAppProfile! profileId=" + outputTaskModel.getProfileId()); + String gennerClass = appProfile.getGenerClass(); + if (UtilString.isEmpty(gennerClass)) + throw new AWSException("OutputAppProfile 'gennerClass' is Null! AppName=" + appProfile.getTitle()); - if (outputTaskModel == null) - throw new AWSException("Not Find outputTask! "); + // --------dc context----------- + DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT); + if (dcProfile == null) + throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); + DCContext dcContext = new DCContext(uc, dcProfile, appProfile.getAppContext().getId(), outputTaskModel.getWsId(), id); - // --------app appProfile---------- - OutputAppProfile appProfile = OutputAppManager.getProfile(outputTaskModel.getProfileId()); - if (appProfile == null) - throw new AWSException("Not Find OutputAppProfile! profileId=" + outputTaskModel.getProfileId()); - String gennerClass = appProfile.getGenerClass(); - if (UtilString.isEmpty(gennerClass)) - throw new AWSException("OutputAppProfile 'gennerClass' is Null! AppName=" + appProfile.getTitle()); + // ---------config--------------- + String wizardJsonData = getWizardJsonData(outputTaskModel.getWsId(), id, appProfile.getId()); - // --------dc context----------- - DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT); - if (dcProfile == null) - throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); - DCContext dcContext = new DCContext(uc, dcProfile, appProfile.getAppContext().getId(), outputTaskModel.getWsId(), id); + CallableGennerReport gener = new CallableGennerReport(outputTaskModel, appProfile, dcContext, wizardJsonData); + FutureTask task = new FutureTask<>(gener); + Thread signalThread = new Thread(task); + signalThread.setName("CoE Output Report Genner-" + appProfile.getTitle() + "-" + outputTaskModel.getTaskName()); + signalThread.start(); + try { + return task.get(); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + return ResponseObject.newErrResponse(); + } + } - // ---------config--------------- - //获取原有config.txt的json - String wizardJsonData = getWizardJsonData(outputTaskModel.getWsId(), outputTaskModel.getId(), appProfile.getId()); + /** + * 三员管理模式下,重新生成步骤横表手册 + * + * @param outputTaskModel + */ + public void reGennerReport(UserContext uc, OutputTaskModel outputTaskModel, String id) { - // 根据原有config保存新的配置 - this.saveWizardJsonData(outputTaskModel.getWsId(), id, outputTaskModel.getProfileId(), wizardJsonData); + if (outputTaskModel == null) + throw new AWSException("Not Find outputTask! "); - //同步执行 - GennerReport gener = new GennerReport(outputTaskModel, appProfile, dcContext, wizardJsonData); - gener.run(); - } + // --------app appProfile---------- + OutputAppProfile appProfile = OutputAppManager.getProfile(outputTaskModel.getProfileId()); + if (appProfile == null) + throw new AWSException("Not Find OutputAppProfile! profileId=" + outputTaskModel.getProfileId()); + String gennerClass = appProfile.getGenerClass(); + if (UtilString.isEmpty(gennerClass)) + throw new AWSException("OutputAppProfile 'gennerClass' is Null! AppName=" + appProfile.getTitle()); - class CallableGennerReport implements Callable { + // --------dc context----------- + DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT); + if (dcProfile == null) + throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); + DCContext dcContext = new DCContext(uc, dcProfile, appProfile.getAppContext().getId(), outputTaskModel.getWsId(), id); - private OutputTaskModel task; - private OutputAppProfile appProfile; - private DCContext dcContext; - private String wizardJsonData; + // ---------config--------------- + //获取原有config.txt的json + String wizardJsonData = getWizardJsonData(outputTaskModel.getWsId(), outputTaskModel.getId(), appProfile.getId()); - public CallableGennerReport(OutputTaskModel task, OutputAppProfile appProfile, DCContext dcContext, String wizardJsonData) { - this.appProfile = appProfile; - this.task = task; - this.dcContext = dcContext; - this.wizardJsonData = wizardJsonData; - } - - @Override - public ResponseObject call() throws Exception { - Constructor cons = null; - try { - cons = ClassReflect.getConstructor(appProfile.getGenerClass(), null, appProfile.getAppContext()); - } catch (Exception e) { - e.printStackTrace(); - SDK.getAppAPI().err(appProfile.getAppContext(), appProfile.getGenerClass() + "--" + e.toString()); - return ResponseObject.newErrResponse(); - } - // 获得该接口实现类实例 - try { - Class generClass = appProfile.getAppContext().getBindClassLoader().loadClass(appProfile.getGenerClass()); - Object obj = cons.newInstance(); - Method execute = generClass.getMethod("execute", new Class[] { OutputTaskModel.class, String.class, DCContext.class }); - // 标记执行 - new OutputTask().updateRunning(task.getId()); - // 正式执行 - ResponseObject ro = (ResponseObject) execute.invoke(obj, new Object[] { task, wizardJsonData, dcContext }); - // 处理日志 - List logs = (List) ro.get("logs"); - if (logs != null && !logs.isEmpty()) { - StringBuilder sb = new StringBuilder(); - for (String msg : logs) { - sb.append(msg + (AWSServerConf.isLinuxOS() ? "" : "\r") + "\n"); - } - // 保存日志文件 - InputStream in = null; - try { - in = new ByteArrayInputStream(sb.toString().getBytes("UTF-8")); - dcContext.setFileName(OutputConst.FILE_TASK_LOG); - SDK.getDCAPI().write(in, dcContext); - } catch (Exception e) { - e.printStackTrace(); - } finally { - try { - if (in != null) - in.close(); - } catch (Exception e) { - } - } - } - // 标记结束 - if (ro.isOk()) { - new OutputTask().updateSucess(task.getId()); - return ResponseObject.newOkResponse(); - } else { - new OutputTask().updateError(task.getId()); - return ResponseObject.newErrResponse(); - } - } catch (Exception e) { - e.printStackTrace(); - SDK.getAppAPI().err(appProfile.getAppContext(), appProfile.getGenerClass() + "--" + e.toString()); - return ResponseObject.newErrResponse(); - } - } - - } - - /** - * 得到限定范围的流程id - * - * @param wsId 资产库id - * @param id 任务Id - * @param profileId 报告生成器扩展App的配置Id - * @return - * @throws AWSException - */ - /* public String getargetFileIds(String wsId, String id, String profileId) - * throws AWSException { UtilFile file = new UtilFile(getFilePath(wsId, id, - * profileId) + "/" + OutputConst.FILE_WIZARD_CONFIG); if (file.exists()) { - * String config = file.readStr(); return - * JSONObject.fromObject(config).getString("targetFileId"); } return ""; } */ + // 根据原有config保存新的配置 + this.saveWizardJsonData(outputTaskModel.getWsId(), id, outputTaskModel.getProfileId(), wizardJsonData); + + //同步执行 + GennerReport gener = new GennerReport(outputTaskModel, appProfile, dcContext, wizardJsonData); + gener.run(); + } + + class CallableGennerReport implements Callable { + + private OutputTaskModel task; + private OutputAppProfile appProfile; + private DCContext dcContext; + private String wizardJsonData; + + public CallableGennerReport(OutputTaskModel task, OutputAppProfile appProfile, DCContext dcContext, String wizardJsonData) { + this.appProfile = appProfile; + this.task = task; + this.dcContext = dcContext; + this.wizardJsonData = wizardJsonData; + } + + @Override + public ResponseObject call() throws Exception { + Constructor cons = null; + try { + cons = ClassReflect.getConstructor(appProfile.getGenerClass(), null, appProfile.getAppContext()); + } catch (Exception e) { + e.printStackTrace(); + SDK.getAppAPI().err(appProfile.getAppContext(), appProfile.getGenerClass() + "--" + e.toString()); + return ResponseObject.newErrResponse(); + } + // 获得该接口实现类实例 + try { + Class generClass = appProfile.getAppContext().getBindClassLoader().loadClass(appProfile.getGenerClass()); + Object obj = cons.newInstance(); + Method execute = generClass.getMethod("execute", new Class[]{OutputTaskModel.class, String.class, DCContext.class}); + // 标记执行 + new OutputTask().updateRunning(task.getId()); + // 正式执行 + ResponseObject ro = (ResponseObject) execute.invoke(obj, new Object[]{task, wizardJsonData, dcContext}); + // 处理日志 + List logs = (List) ro.get("logs"); + if (logs != null && !logs.isEmpty()) { + StringBuilder sb = new StringBuilder(); + for (String msg : logs) { + sb.append(msg + (AWSServerConf.isLinuxOS() ? "" : "\r") + "\n"); + } + // 保存日志文件 + InputStream in = null; + try { + in = new ByteArrayInputStream(sb.toString().getBytes("UTF-8")); + dcContext.setFileName(OutputConst.FILE_TASK_LOG); + SDK.getDCAPI().write(in, dcContext); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (in != null) + in.close(); + } catch (Exception e) { + } + } + } + // 标记结束 + if (ro.isOk()) { + new OutputTask().updateSucess(task.getId()); + return ResponseObject.newOkResponse(); + } else { + new OutputTask().updateError(task.getId()); + return ResponseObject.newErrResponse(); + } + } catch (Exception e) { + e.printStackTrace(); + SDK.getAppAPI().err(appProfile.getAppContext(), appProfile.getGenerClass() + "--" + e.toString()); + return ResponseObject.newErrResponse(); + } + } + + } + + /** + * 得到限定范围的流程id + * + * @param wsId 资产库id + * @param id 任务Id + * @param profileId 报告生成器扩展App的配置Id + * @return + * @throws AWSException + */ + /* public String getargetFileIds(String wsId, String id, String profileId) + * throws AWSException { UtilFile file = new UtilFile(getFilePath(wsId, id, + * profileId) + "/" + OutputConst.FILE_WIZARD_CONFIG); if (file.exists()) { + * String config = file.readStr(); return + * JSONObject.fromObject(config).getString("targetFileId"); } return ""; } */ } class GennerReport implements Runnable { - private OutputTaskModel task; - private OutputAppProfile appProfile; - private DCContext dcContext; - private String wizardJsonData; + private OutputTaskModel task; + private OutputAppProfile appProfile; + private DCContext dcContext; + private String wizardJsonData; - public GennerReport(OutputTaskModel task, OutputAppProfile appProfile, DCContext dcContext, String wizardJsonData) { - this.appProfile = appProfile; - this.task = task; - this.dcContext = dcContext; - this.wizardJsonData = wizardJsonData; - } + public GennerReport(OutputTaskModel task, OutputAppProfile appProfile, DCContext dcContext, String wizardJsonData) { + this.appProfile = appProfile; + this.task = task; + this.dcContext = dcContext; + this.wizardJsonData = wizardJsonData; + } - public void run() { - Constructor cons = null; - try { - cons = ClassReflect.getConstructor(appProfile.getGenerClass(), null, appProfile.getAppContext()); - } catch (Exception e) { - e.printStackTrace(); - SDK.getAppAPI().err(appProfile.getAppContext(), appProfile.getGenerClass() + "--" + e.toString()); - } - if (cons != null) { - // 获得该接口实现类实例 - try { - Class generClass = appProfile.getAppContext().getBindClassLoader().loadClass(appProfile.getGenerClass()); - Object obj = cons.newInstance(); - Method execute = generClass.getMethod("execute", new Class[] { OutputTaskModel.class, String.class, DCContext.class }); - // 标记执行 - new OutputTask().updateRunning(task.getId()); - // 正式执行 - ResponseObject ro = (ResponseObject) execute.invoke(obj, new Object[] { task, wizardJsonData, dcContext }); - // 处理日志 - List logs = (List) ro.get("logs"); - if (logs != null && !logs.isEmpty()) { - StringBuilder sb = new StringBuilder(); - for (String msg : logs) { - sb.append(msg + (AWSServerConf.isLinuxOS() ? "" : "\r") + "\n"); - } - // 保存日志文件 - InputStream in = null; - try { - in = new ByteArrayInputStream(sb.toString().getBytes("UTF-8")); - dcContext.setFileName(OutputConst.FILE_TASK_LOG); - SDK.getDCAPI().write(in, dcContext); - } catch (Exception e) { - e.printStackTrace(); - } finally { - try { - if (in != null) - in.close(); - } catch (Exception e) { - } - } - } - // 标记结束 - if (ro.isOk()) { - new OutputTask().updateSucess(task.getId()); - } else { - new OutputTask().updateError(task.getId()); - } - } catch (Exception e) { - e.printStackTrace(); - SDK.getAppAPI().err(appProfile.getAppContext(), appProfile.getGenerClass() + "--" + e.toString()); - } - } - } + public void run() { + Constructor cons = null; + try { + cons = ClassReflect.getConstructor(appProfile.getGenerClass(), null, appProfile.getAppContext()); + } catch (Exception e) { + e.printStackTrace(); + SDK.getAppAPI().err(appProfile.getAppContext(), appProfile.getGenerClass() + "--" + e.toString()); + } + if (cons != null) { + // 获得该接口实现类实例 + try { + Class generClass = appProfile.getAppContext().getBindClassLoader().loadClass(appProfile.getGenerClass()); + Object obj = cons.newInstance(); + Method execute = generClass.getMethod("execute", new Class[]{OutputTaskModel.class, String.class, DCContext.class}); + // 标记执行 + new OutputTask().updateRunning(task.getId()); + // 正式执行 + ResponseObject ro = (ResponseObject) execute.invoke(obj, new Object[]{task, wizardJsonData, dcContext}); + // 处理日志 + List logs = (List) ro.get("logs"); + if (logs != null && !logs.isEmpty()) { + StringBuilder sb = new StringBuilder(); + for (String msg : logs) { + sb.append(msg + (AWSServerConf.isLinuxOS() ? "" : "\r") + "\n"); + } + // 保存日志文件 + InputStream in = null; + try { + in = new ByteArrayInputStream(sb.toString().getBytes("UTF-8")); + dcContext.setFileName(OutputConst.FILE_TASK_LOG); + SDK.getDCAPI().write(in, dcContext); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (in != null) + in.close(); + } catch (Exception e) { + } + } + } + // 标记结束 + if (ro.isOk()) { + new OutputTask().updateSucess(task.getId()); + } else { + new OutputTask().updateError(task.getId()); + } + } catch (Exception e) { + e.printStackTrace(); + SDK.getAppAPI().err(appProfile.getAppContext(), appProfile.getGenerClass() + "--" + e.toString()); + } + } + } } diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/web/DesignerRelationShapeWeb.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/web/DesignerRelationShapeWeb.java index f744da95..6ff9bd54 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/web/DesignerRelationShapeWeb.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/web/DesignerRelationShapeWeb.java @@ -760,7 +760,7 @@ public class DesignerRelationShapeWeb extends ActionWeb { JSONArray jsonArr_new= new JSONArray(); JSONArray objects=JSONArray.parseArray(treeJson); //角色图属性代码是role/绩效图属性代码是 - if (attrId.equals("role") || attrId.equals("performance")) { + if (attrId.equals("role") || attrId.equals("Process_performance_metrics")) { if (objects != null) { for (int i = 0; i < objects.size(); i++) { JSONObject jsonObject = objects.getJSONObject(i); diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/web/CoeDesignerWeb.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/web/CoeDesignerWeb.java index 8b9936d0..f42b2983 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/web/CoeDesignerWeb.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/web/CoeDesignerWeb.java @@ -5,6 +5,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -183,11 +184,11 @@ public class CoeDesignerWeb extends ActionWeb { try { int size = myArray.size(); for (i = 0; i < size; i++) { - uid = myArray.get(i).toString(); + uid = myArray.get(i); if (uid.trim().equals("")) continue; uid = SDK.getORGAPI().getUserId(uid); - UserModel model = (UserModel) UserCache.getModel(uid); + UserModel model = UserCache.getModel(uid); String name = uid; if (model != null) { name = model.getUserName(); @@ -461,7 +462,7 @@ public class CoeDesignerWeb extends ActionWeb { if (!plModel.isPublish() && !isView && !plModel.isStop() && !plModel.isApproval()) { CoeListenCacheManager manager = CoeListenCacheManager.getInstance(); Map listenClients = manager.getCollaborationUsers(rUUID); - StringBuilder userPhoto = new StringBuilder(""); + StringBuilder userPhoto = new StringBuilder(); int userNum = 1; if (listenClients != null) { for (ListenClient listenClient : listenClients.values()) { @@ -502,11 +503,7 @@ public class CoeDesignerWeb extends ActionWeb { UtilFile utilFile = new UtilFile(p + "/" + plModel.getId() + ".png"); if (utilFile.exists()) { byte[] base64Bytes = Base64.encode(utilFile.readBytes()); - try { - diagram = "data:image/png;base64," + new String(base64Bytes, "UTF-8"); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } + diagram = "data:image/png;base64," + new String(base64Bytes, StandardCharsets.UTF_8); } } } @@ -604,6 +601,8 @@ public class CoeDesignerWeb extends ActionWeb { } // 帮助工具栏扩展 getHelptoolExtUrl(macroLibraries); + // 图形描述 + getMethodObjectDesc(macroLibraries); // 操作行为日志记录 if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_ACCESS, CoEOpLogConst.INFO_REPOSITORY_ACCESS); @@ -624,6 +623,27 @@ public class CoeDesignerWeb extends ActionWeb { } } + /** + * 获取形状描述定义 + * @param macroLibraries + */ + private void getMethodObjectDesc(Map macroLibraries) { + JSONObject result = new JSONObject(); + JSONObject methodObjectDesc = SDK.getAppAPI().getPropertyJSONObjectValue(CoEConstant.APP_ID, "METHOD_OBJECT_DESC", new JSONObject()); + for (String methodId : methodObjectDesc.keySet()) { + for (String shapeName : methodObjectDesc.getJSONObject(methodId).keySet()) { + JSONObject shapeObj = methodObjectDesc.getJSONObject(methodId).getJSONObject(shapeName); + if (shapeObj.containsKey("desc")) { + String desc = shapeObj.getString("desc"); + if (desc != null && !"".equals(desc.trim())) { + result.put(methodId + '-' + shapeName, desc); + } + } + } + } + macroLibraries.put("methodObjectDesc", result); + } + /** * 帮助工具栏扩展 * @param macroLibraries @@ -733,11 +753,7 @@ public class CoeDesignerWeb extends ActionWeb { e.printStackTrace(); } byte[] base64Bytes = Base64.encode(utilFile.readBytes()); - try { - diagram = "data:image/png;base64," + new String(base64Bytes, "UTF-8"); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } + diagram = "data:image/png;base64," + new String(base64Bytes, StandardCharsets.UTF_8); } } } @@ -913,7 +929,7 @@ public class CoeDesignerWeb extends ActionWeb { macroLibraries.put("checkouttime", UtilDate.getAliasDatetime(DesignerFileUtil.getCheckOutTime(appId, processDefId))); macroLibraries.put("checkoutip", DesignerFileUtil.getCheckOutIP(appId, processDefId)); macroLibraries.put("user", getContext().getUID()); - UserModel model = (UserModel) UserCache.getModel(getContext().getUID()); + UserModel model = UserCache.getModel(getContext().getUID()); macroLibraries.put("currentUserName", model.getUserName()); } @@ -1441,7 +1457,7 @@ public class CoeDesignerWeb extends ActionWeb { public JSONArray getHistoryDataJson(String uuid) { JSONArray historyJson = new JSONArray(); - PALRepositoryModel plModel = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); + PALRepositoryModel plModel = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); if (!"".equals(plModel.getFilePath())) { CoeFile jsonUtil = new CoeFile(); historyJson = jsonUtil.getHistoryJsonData(plModel.getFilePath()); @@ -1462,7 +1478,7 @@ public class CoeDesignerWeb extends ActionWeb { JSONObject json = new JSONObject(); JSONArray versions = getHistoryDataJson(uuid); JSONObject users = new JSONObject(); - UserModel model = (UserModel) UserCache.getModel(getContext().getUID()); + UserModel model = UserCache.getModel(getContext().getUID()); users.put(getContext().getUID(), model.getUserName()); json.put("users", users); json.put("versions", versions); @@ -1561,7 +1577,7 @@ public class CoeDesignerWeb extends ActionWeb { * @deprecated */ private Map updateCPShapes(String olduuid, String uuId, String define) { - PALRepositoryModel levelModel = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuId); + PALRepositoryModel levelModel = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuId); String filePath = levelModel.getFilePath(); filePath = filePath + File.separator + levelModel.getId(); UtilFile utilFile = new UtilFile(filePath); @@ -1582,11 +1598,7 @@ public class CoeDesignerWeb extends ActionWeb { } } if (list.size() > 0 && updateShapes(list, uuId)) { - try { - utilFile.write(messageJson.getBytes("utf-8")); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } + utilFile.write(messageJson.getBytes(StandardCharsets.UTF_8)); } DesignerRelationShapeCacheManager cache = DesignerRelationShapeCacheManager.getInstance(); Map> shapeMap = cache.getEventMap(); @@ -1691,7 +1703,7 @@ public class CoeDesignerWeb extends ActionWeb { if (uuid.indexOf("obj_") == 0) { photo = "data:image/png;base64," + BPMNIO.getBPMNImage( ProcessDefCache.getInstance().getModel(uuid).getAppId(), uuid); } else { - PALRepositoryModel cplm = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); + PALRepositoryModel cplm = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); if (cplm != null) { PALRepositoryQueryAPIManager.getInstance().checkImage(cplm.getId(), true, false);// 生成图片 String path = cplm.getFilePath(); @@ -1699,11 +1711,7 @@ public class CoeDesignerWeb extends ActionWeb { UtilFile utilFile = new UtilFile(path + "/" + cplm.getId() + ".png"); if (utilFile.exists()) { byte[] base64Bytes = Base64.encode(utilFile.readBytes()); - try { - photo = "data:image/png;base64," + new String(base64Bytes, "UTF-8"); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } + photo = "data:image/png;base64," + new String(base64Bytes, StandardCharsets.UTF_8); } } } @@ -1846,7 +1854,7 @@ public class CoeDesignerWeb extends ActionWeb { FileOutputStream fos = null; try { fos = new FileOutputStream(exportFile); - fos.write(buffer.toString().getBytes("UTF-8")); + fos.write(buffer.toString().getBytes(StandardCharsets.UTF_8)); fos.flush(); fos.close(); } catch (IOException e) { @@ -1913,7 +1921,7 @@ public class CoeDesignerWeb extends ActionWeb { FileOutputStream fos = null; try { fos = new FileOutputStream(exportFile); - fos.write(JSON.toJSONString(object).getBytes("UTF-8")); + fos.write(JSON.toJSONString(object).getBytes(StandardCharsets.UTF_8)); fos.flush(); fos.close(); } catch (IOException e) { @@ -1935,7 +1943,7 @@ public class CoeDesignerWeb extends ActionWeb { e.printStackTrace(); } } else { - PALRepositoryModel cplm = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); + PALRepositoryModel cplm = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); if (cplm == null) throw new AWSException("流程未找到 " + uuid); PALRepositoryQueryAPIManager.getInstance().checkImage(cplm.getId(), true, true);// 生成图片 String path = cplm.getFilePath(); @@ -2052,7 +2060,7 @@ public class CoeDesignerWeb extends ActionWeb { if (!pdfDir.exists()) { pdfDir.mkdirs(); } - String date = new SimpleDateFormat("yyyyMMdd").format(new Date()).toString(); + String date = new SimpleDateFormat("yyyyMMdd").format(new Date()); /*File [] pdfFiles = pdfDir.listFiles(new MyFilenameFilter(date)); int maxNo = 0; if (pdfFiles != null && pdfFiles.length > 0) { @@ -2214,7 +2222,7 @@ public class CoeDesignerWeb extends ActionWeb { if (isAdmin) { shapes.append(methodModel.getSchema()).append("\r\n"); } else { - shapes.append(schema.substring(0, schema.indexOf("Schema.addShape"))).append("\r\n"); + shapes.append(schema, 0, schema.indexOf("Schema.addShape")).append("\r\n"); } if (methodModel.getCustomSchema() != null) { shapes.append(methodModel.getCustomSchema()).append("\r\n"); @@ -2457,7 +2465,7 @@ public class CoeDesignerWeb extends ActionWeb { newSchemas[i] = ""; } } - oldSchema = new StringBuilder(""); + oldSchema = new StringBuilder(); for (int i = 0; i < newSchemas.length; i++) { if (!"".equals(newSchemas[i])) { oldSchema.append("Schema.addShape").append(newSchemas[i]).append("\n\r"); @@ -2465,17 +2473,11 @@ public class CoeDesignerWeb extends ActionWeb { } } - try { - // 写入新模板 - schema = schema.replaceAll("\\\\t\\\\n", "\t\n").replaceAll("\\\\", ""); - schema = "Schema.addShape(" + schema + ");\n\r"; - oldSchema.append(schema); - file.write(oldSchema.toString().getBytes("UTF-8")); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - ro = ResponseObject.newErrResponse(); - return ro.toString(); - } + // 写入新模板 + schema = schema.replaceAll("\\\\t\\\\n", "\t\n").replaceAll("\\\\", ""); + schema = "Schema.addShape(" + schema + ");\n\r"; + oldSchema.append(schema); + file.write(oldSchema.toString().getBytes(StandardCharsets.UTF_8)); // 更新缓存 PALMethodModel palMethodModel = PALMethodCache.getPALMethodModelMap().get(methodId); @@ -2525,19 +2527,15 @@ public class CoeDesignerWeb extends ActionWeb { newSchemas[i] = ""; } } - StringBuilder oldSchema = new StringBuilder(""); + StringBuilder oldSchema = new StringBuilder(); for (int i = 0; i < newSchemas.length; i++) { if (!"".equals(newSchemas[i])) { oldSchema.append("Schema.addShape").append(newSchemas[i]).append("\n\r"); } } - try { - // 重新写入文件 - file.write(oldSchema.toString().getBytes("UTF-8")); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } + // 重新写入文件 + file.write(oldSchema.toString().getBytes(StandardCharsets.UTF_8)); // 重新加载缓存 PALMethodModel palMethodModel = PALMethodCache.getPALMethodModelMap().get(methodId); @@ -3065,7 +3063,7 @@ public class CoeDesignerWeb extends ActionWeb { Set ids = new HashSet<>(); sb.append(plModel.getName()); ids.add(plModel.getId()); - getFilePath(sb, ids, (PALRepositoryModel)plModel); + getFilePath(sb, ids, plModel); macroLibraries.put("toolbarName", sb.toString()); List shapeIds = new ArrayList<>();// 当前流程所有节点 @@ -3309,7 +3307,7 @@ public class CoeDesignerWeb extends ActionWeb { return null; } if (uuid != null && !"".equals(uuid)) { - PALRepositoryModel m = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); + PALRepositoryModel m = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); PALMethodModel palMethodModel = PALMethodCache.getPALMethodModelById(m.getMethodId()); if (palMethodModel == null) { return null; @@ -3646,7 +3644,7 @@ public class CoeDesignerWeb extends ActionWeb { */ public String deletePalDesignerVersion(String wsId, String teamId, String id) { ResponseObject ro; - PALRepositoryModel plModel = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(id); + PALRepositoryModel plModel = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(id); List list = new ArrayList(); list.add(plModel); CoeProcessRecycleWeb recycleWeb = new CoeProcessRecycleWeb(_uc); @@ -3678,7 +3676,7 @@ public class CoeDesignerWeb extends ActionWeb { public String changePalDesignerVersionUse(String wsId, String teamId, String id) { int answer = 0; PALRepository repository = CoeProcessLevelDaoFacotory.createCoeProcessLevel(); - PALRepositoryModel lastPlModel = (PALRepositoryModel) repository.getInstance(id); + PALRepositoryModel lastPlModel = repository.getInstance(id); answer = repository.updateStateOfVersionUuid(lastPlModel.getVersionId());// 更新所有的为0 answer = repository.updateUseStateOfVersionUuid(lastPlModel.getId());// 更新当前版本为使用状态 CoeProcessLevelNoCache.getInstance().reloadInBackground(lastPlModel.getWsId()); diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/job/SynchronousOrgJob.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/job/SynchronousOrgJob.java index 4bb7a24e..b28d11b7 100644 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/job/SynchronousOrgJob.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/job/SynchronousOrgJob.java @@ -1,17 +1,15 @@ package com.actionsoft.apps.coe.pal.pal.repository.job; -import com.actionsoft.apps.coe.pal.datamigration.util.DiagramUtil; -import com.actionsoft.apps.coe.pal.datamigration.util.ShapeUtil; -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.designer.manage.CoeDesignerAPIManager; import com.actionsoft.apps.coe.pal.pal.repository.designer.model.BaseModel; 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.impl.PALRepositoryModelImpl; import com.actionsoft.apps.coe.pal.pal.repository.util.CoeProcessLevelUtil; +import com.actionsoft.apps.coe.pal.pal.repository.util.DiagramsUtil; +import com.actionsoft.apps.coe.pal.pal.repository.util.ShapeUtil; import com.actionsoft.bpms.commons.database.RowMap; import com.actionsoft.bpms.schedule.IJob; import com.actionsoft.bpms.util.DBSql; @@ -223,7 +221,7 @@ public class SynchronousOrgJob implements IJob { } // 设置画布大小 - DiagramUtil.setDiagramHeightWidth(definition, elements); + DiagramsUtil.setDiagramHeightWidth(definition, elements); defineModel.setDefinition(definition.toString()); // 保存文件 CoeDesignerAPIManager.getInstance().storeDefinition(defineModel);// dao操作 diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/util/DiagramUtil.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/util/DiagramsUtil.java similarity index 95% rename from com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/util/DiagramUtil.java rename to com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/util/DiagramsUtil.java index 1ef868a5..9850eb83 100644 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/util/DiagramUtil.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/util/DiagramsUtil.java @@ -1,50 +1,52 @@ -package com.actionsoft.apps.coe.pal.pal.repository.util; - -import com.alibaba.fastjson.JSONObject; - -import java.util.Iterator; - -public class DiagramUtil { - - - /** - * 设置画布大小 - * @param elements - */ - public static 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); - } - - - - public static 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; - } -} +package com.actionsoft.apps.coe.pal.pal.repository.util; + +import com.alibaba.fastjson.JSONObject; + +import java.util.Iterator; + +public class DiagramsUtil { + + + + /** + * 设置画布大小 + * @param elements + */ + public static 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); + } + + + + public static 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; + } + +} diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/util/ShapeUtil.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/util/ShapeUtil.java new file mode 100644 index 00000000..a2f9d80b --- /dev/null +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/util/ShapeUtil.java @@ -0,0 +1,313 @@ +package com.actionsoft.apps.coe.pal.pal.repository.util; + +import com.actionsoft.apps.AppsConst; +//import com.actionsoft.apps.coe.pal.datamigration.util.ProcessUtil; +import com.actionsoft.apps.coe.pal.pal.method.PALMethodManager; +import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel; +import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodModel; +import com.actionsoft.apps.coe.pal.pal.repository.designer.CoeDesignerShapeAPIManager; +import com.actionsoft.apps.coe.pal.pal.repository.designer.util.CoeDesignerUtil; +import com.actionsoft.apps.lifecycle.api.AppsAPIManager; +import com.actionsoft.apps.resource.AppContext; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; + +import java.util.*; + +public class ShapeUtil { + + /** + * BPMN图并不全部使用,给定范围 + */ + private static List bpmnShapeScope() { + List list = new ArrayList<>(); + list.add("startEvent");// 开始事件 + list.add("messageStartEvent");// 消息开始事件 + list.add("timerStartEvent");// 时间开始事件 + list.add("signalStartEvent");// 信号开始事件 + list.add("userTask");// 人工任务 + list.add("serviceTask");// 服务任务 + list.add("manualTask");// 手工任务 + list.add("scriptTask");// 脚本任务 + list.add("inclusiveGateway");// 包容网关 + list.add("complexGateway");// 复杂网关 + list.add("eventBasedGateway");// 事件网关 + list.add("parallelGateway");// 并行网关 + list.add("exclusiveGateway");// 排他网关 + list.add("timerIntermediateCatchEvent");// 捕获时间事件 + list.add("messageIntermediateCatchEvent");// 捕获消息事件 + list.add("signalIntermediateCatchEvent");// 捕获信号事件 + list.add("messageIntermediateThrowingEvent");// 抛出消息事件 + list.add("signalIntermediateThrowingEvent");// 抛出信号事件 + list.add("messageBoundaryInterrputingEvent");// 边界消息事件 + list.add("signalBoundaryInterrputingEvent");// 边界信号事件 + list.add("errorBoundaryInterrputingEvent");// 边界错误事件 + list.add("endEvent");// 结束事件 + list.add("terminateEndEvent");// 终止事件 + list.add("messageEndEvent");// 消息结束事件 + list.add("signalEndEvent");// 信号结束事件 + list.add("errorEndEvent");// 错误结束事件 + list.add("callActivityCallingProcess");// 调用子流程 + list.add("group");// 组 + // list.add("textAnnotation");// 注释 + return list; + } + + + + /** + * 获取流程下文件分类 + * @return + */ + public static List getProcessCategoryCategoryMehtodList() { + List list = new ArrayList(); + List methodModels = PALMethodManager.getInstance().getPALMethodModelListByMethod("process"); + List listApps = AppsAPIManager.getInstance().getInstalledApps(); + int size = listApps.size(); + Map map1 = new HashMap(); + for (int i = 0; i < size; i++) { + map1.put(listApps.get(i).getId(), listApps.get(i).getRuntimeState()); + } + for (int i = 0, methodSize = methodModels.size(); i < methodSize; i++) { + PALMethodModel palMethodModel = methodModels.get(i); + String appId = palMethodModel.getId(); + if (map1.containsKey("com.actionsoft.apps.coe.method." + appId)) { + String methodId1 = map1.get("com.actionsoft.apps.coe.method." + appId); + if (methodId1.equals(AppsConst.RUNTIME_STATE_STOPPED) || methodId1.equals(AppsConst.RUNTIME_STATE_FAILED) || methodId1.equals(AppsConst.RUNTIME_STATE_READY) || methodId1.equals(AppsConst.RUNTIME_STATE_STARTING) || methodId1.equals(AppsConst.RUNTIME_STATE_STOPPING) || methodId1.equals(AppsConst.RUNTIME_STATE_UNINSTALLED) || methodId1.equals(AppsConst.RUNTIME_STATE_UNINSTALLING) || methodId1.equals(AppsConst.RUNTIME_STATE_FAILED)) + continue; + } + list.add(palMethodModel.getId()); + } + return list; + } + + + /** + * 获取流程类别下所有模型的形状title + * @return + */ + public static Map> getProcessShapeTitles() { + Map> result = new HashMap<>(); + // 获取流程类别下所有的模型分类 + List methods = getProcessCategoryCategoryMehtodList(); + for (String methodId : methods) { + List list = new ArrayList<>(); + JSONArray shapes = CoeDesignerUtil.getShapeDefinition(methodId); + for (Object shape : shapes) { + JSONObject shapeObj = (JSONObject) shape; + if (shapeObj.containsKey("title")) { + if (methodId.contains("bpmn")) { + if (bpmnShapeScope().contains(shapeObj.getString("name"))) { + list.add(shapeObj.getString("title")); + } + } else { + list.add(shapeObj.getString("title")); + } + } + } + result.put(methodId, list); + } + return result; + } + + public static List getProcessShapeTypeList(String methodId) { + List result = new ArrayList<>(); + JSONArray shapes = CoeDesignerUtil.getShapeDefinition(methodId); + for (Object shape : shapes) { + JSONObject shapeObj = (JSONObject) shape; + if (shapeObj.containsKey("title")) { + if (methodId.contains("bpmn")) { + if (bpmnShapeScope().contains(shapeObj.getString("name"))) { + result.add(shapeObj.getString("title")); + } + } else { + result.add(shapeObj.getString("title")); + } + } + } + return result; + } + + public static JSONArray getProcessShapeTypeArr(String methodId) { + JSONArray result = new JSONArray(); + JSONArray shapes = CoeDesignerUtil.getShapeDefinition(methodId); + for (Object shape : shapes) { + JSONObject shapeObj = (JSONObject) shape; + if (shapeObj.containsKey("title")) { + if (methodId.contains("bpmn")) { + if (bpmnShapeScope().contains(shapeObj.getString("name"))) { + result.add(shapeObj.getString("title")); + } + } else { + result.add(shapeObj.getString("title")); + } + } + } + return result; + } + + public static Set getProcessMethodAttrNames(String wsId, String methodId) { + Set result = new HashSet<>(); + List attributeModelList = CoeDesignerShapeAPIManager.getInstance().getAllValidShapeAttributeModels(wsId, methodId); + for (PALMethodAttributeModel attributeModel : attributeModelList) { + result.add(attributeModel.getNewTitle()); + } + return result; + } + + public static String getProcessShapeName(String methodId, String shapeTitle) { + JSONArray shapes = CoeDesignerUtil.getShapeDefinition(methodId); + for (Object shape : shapes) { + JSONObject shapeObj = (JSONObject) shape; + if (shapeObj.containsKey("title")) { + if (methodId.contains("bpmn")) { + if (bpmnShapeScope().contains(shapeObj.getString("name")) && shapeObj.getString("title").equals(shapeTitle)) { + return shapeObj.getString("name"); + } + } else { + if (shapeObj.getString("title").equals(shapeTitle)) { + return shapeObj.getString("name"); + } + } + } + } + return null; + } + + /** + * 获取流程节点定义 + * @param methodId 类型 + * @param shapeTitle 节点默认标题 + * @return + */ + public static JSONObject getProcessShapeDefinition(String methodId, String shapeTitle) { + JSONArray shapes = CoeDesignerUtil.getShapeDefinition(methodId); + for (Object shape : shapes) { + JSONObject shapeObj = (JSONObject) shape; + if (shapeObj.containsKey("title")) { + if (methodId.contains("bpmn")) { + if (bpmnShapeScope().contains(shapeObj.getString("name")) && shapeObj.getString("title").equals(shapeTitle)) { + return shapeObj; + } + } else { + if (shapeObj.getString("title").equals(shapeTitle)) { + return shapeObj; + } + } + } + } + return null; + } + + /** + * 获取流程节点定义 + * @param methodId 类型 + * @param shapeName 节点类型 + * @return + */ + public static JSONObject getProcessShapeDefinitionByName(String methodId, String shapeName) { + JSONArray shapes = CoeDesignerUtil.getShapeDefinition(methodId); + for (Object shape : shapes) { + JSONObject shapeObj = (JSONObject) shape; + if (shapeObj.containsKey("name")) { + String name = shapeObj.getString("name"); + if (methodId.contains("bpmn")) { + if (bpmnShapeScope().contains(shapeObj.getString("name")) && name.equals(shapeName)) { + return shapeObj; + } + } else { + if (name.equals(shapeName)) { + return shapeObj; + } + } + } + } + return null; + } + + /** + * 具体流程类别下的扩展属性列表 + * @param methodId + * @return + */ + public static JSONObject getProcessUseShapeMethodAttrByShapeName(String wsId, String shapeMethod, String methodId, String shapeName) { + JSONObject result = new JSONObject(); + List attributeModelList = CoeDesignerShapeAPIManager.getInstance().getValidAndUseAttributeModels(wsId, shapeMethod, shapeName, methodId); + for (PALMethodAttributeModel attributeModel : attributeModelList) { + String scope = attributeModel.getScope(); + if (scope.contains("*") || "*".equals(scope) || scope.contains(shapeName)) { + JSONObject obj = new JSONObject(); + obj.put("readonly", attributeModel.getReadonly()); + obj.put("id", attributeModel.getKey()); + obj.put("key", attributeModel.getKey()); + obj.put("scope", attributeModel.getScope()); + obj.put("name", attributeModel.getTitle()); + obj.put("title", attributeModel.getNewTitle()); + obj.put("type", attributeModel.getType()); + obj.put("ref", attributeModel.getRef()); + obj.put("groupPath", attributeModel.getGroupPath()); + result.put(attributeModel.getKey(), obj); + } + } + return result; + } + + /** + * 具体流程类别下的扩展属性列表 + * @param methodId + * @return + */ + public static JSONObject getProcessShapeMethodAttr(String wsId, String methodId, String shapeTitle) { + JSONObject result = new JSONObject(); + // 获取图形名称的 + String shapeName = getProcessShapeName(methodId, shapeTitle); + if (shapeName == null) { + return result; + } + List attributeModelList = CoeDesignerShapeAPIManager.getInstance().getAllValidShapeAttributeModels(wsId, methodId); + for (PALMethodAttributeModel attributeModel : attributeModelList) { + String scope = attributeModel.getScope(); + if (scope.contains("*") || "*".equals(scope) || scope.contains(shapeName)) { + JSONObject obj = new JSONObject(); + obj.put("readonly", attributeModel.getReadonly()); + obj.put("id", attributeModel.getKey()); + obj.put("key", attributeModel.getKey()); + obj.put("scope", attributeModel.getScope()); + obj.put("name", attributeModel.getTitle()); + obj.put("title", attributeModel.getNewTitle()); + obj.put("type", attributeModel.getType()); + obj.put("ref", attributeModel.getRef()); + obj.put("groupPath", attributeModel.getGroupPath()); + result.put(attributeModel.getNewTitle(), obj); + } + } + return result; + } + + /** + * 具体流程类别下的扩展属性列表 + * @param methodId + * @return + */ + public static JSONObject getProcessShapeMethodAttrById(String wsId, String methodId, String attrId) { + JSONObject result = new JSONObject(); + List attributeModelList = CoeDesignerShapeAPIManager.getInstance().getAllValidShapeAttributeModels(wsId, methodId); + for (PALMethodAttributeModel attributeModel : attributeModelList) { + if (attrId.equals(attributeModel.getKey())) { + result.put("readonly", attributeModel.getReadonly()); + result.put("pid", attributeModel.getGroupPath()); + result.put("id", attributeModel.getKey()); + result.put("key", attributeModel.getKey()); + result.put("scope", attributeModel.getScope()); + result.put("name", attributeModel.getTitle()); + result.put("title", attributeModel.getNewTitle()); + result.put("type", attributeModel.getType()); + result.put("ref", attributeModel.getRef()); + result.put("value", attributeModel.getValue()); + result.put("groupPath", attributeModel.getGroupPath()); + } + } + return result; + } + +} diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/web/CoeProcessLevelWeb.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/web/CoeProcessLevelWeb.java index e7d5ff97..b299415c 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/web/CoeProcessLevelWeb.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/web/CoeProcessLevelWeb.java @@ -5,7 +5,7 @@ import com.actionsoft.apps.AppsConst; import com.actionsoft.apps.coe.pal.cooperation.CoeCooperationAPIManager; import com.actionsoft.apps.coe.pal.log.CoEOpLogAPI; import com.actionsoft.apps.coe.pal.log.CoEOpLogConst; -import com.actionsoft.apps.coe.pal.pal.repository.util.DiagramUtil; +import com.actionsoft.apps.coe.pal.pal.repository.util.DiagramsUtil; import com.actionsoft.apps.coe.pal.pal.repository.util.ShapeUtils; import com.actionsoft.apps.coe.pal.pal.ws.constant.CoeWsConstant; import com.actionsoft.apps.coe.pal.util.HighSecurityUtil; @@ -8052,6 +8052,9 @@ public class CoeProcessLevelWeb extends ActionWeb { return ro.toString(); } + + + /** * 根据用户选择类型创建相应制度图形 * @param type @@ -8080,7 +8083,7 @@ public class CoeProcessLevelWeb extends ActionWeb { //新建一个uuid String shapeId = UUIDGener.getObjectId(); - //拿到基础结构 + //拿到基础结构 JSONObject shape; if(type.equals("1")){ shape=ShapeUtils.getProcessShapeDefinitionByName("control_policy", "regulation"); @@ -8106,7 +8109,7 @@ public class CoeProcessLevelWeb extends ActionWeb { elements.put(shapeId, shape); // 设置画布大小 - DiagramUtil.setDiagramHeightWidth(definition, elements); + DiagramsUtil.setDiagramHeightWidth(definition, elements); defineModel.setDefinition(definition.toString()); // 保存文件 CoeDesignerAPIManager.getInstance().storeDefinition(defineModel);// dao操作 @@ -8121,11 +8124,11 @@ public class CoeProcessLevelWeb extends ActionWeb { } /** - * 创建角色图 + * 创建角色/绩效/表单模型 * @return * by zhaolei */ - public String createDialogModel(String uuid,String methodId,String category){ + public String createDialogModel(String uuid,String methodId){ ResponseObject ro = ResponseObject.newOkResponse(); try { @@ -8134,27 +8137,41 @@ public class CoeProcessLevelWeb extends ActionWeb { if (rowMap != null) { String plname = rowMap.getString("PLNAME"); + String titleName=null; + String shapName=null; + String parentId=null; + String category=null; + String graphTitle=null; + if(methodId.equals("org.role")){ + titleName="角色图"; + shapName="role"; + parentId="org"; + category="org"; + graphTitle="角色"; + }else if(methodId.equals("process")){ + titleName="表单图"; + shapName="form"; + parentId="data"; + category="data"; + methodId="data.form"; + graphTitle="表单"; + }else if(methodId.equals("control.kpi")){ + titleName="绩效图"; + shapName="kpi"; + parentId="control"; + category="control"; + graphTitle="绩效"; + } + //先执行新建操作产生plid PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel(); String plRid = UUIDGener.getUUID(); String id = UUIDGener.getUUID(); - String titleName=null; - String shapName=null; - if(methodId.equals("control.kpi")){ - titleName="绩效图"; - shapName="kpi"; - }else if(methodId.equals("org.role")){ - titleName="角色图"; - shapName="role"; - }else if(methodId.equals("data.form")){ - titleName="表单图"; - shapName="form"; - } Timestamp nowTime = new Timestamp(System.currentTimeMillis()); PALRepositoryModelImpl model = CoeProcessLevelUtil.createPALRepositoryModel(id, plRid, "6f4e292c-1b90-4dd2-8c20-7da159cb20a5", plname + titleName, - "", 1, shapName, category, true, 1, + "", 1, parentId, category, true, 1, id, false, methodId, "0", 1, null, null, "admin", "admin", nowTime, null, uuid, null, null, null, null, null, null, null, 1); @@ -8176,11 +8193,10 @@ public class CoeProcessLevelWeb extends ActionWeb { //新建一个uuid String shapeId = UUIDGener.getObjectId(); - //拿到基础结构 JSONObject shape = ShapeUtils.getProcessShapeDefinitionByName(methodId, shapName); shape.put("id", shapeId); - shape.put("text", titleName); + shape.put("text", graphTitle); JSONObject props = shape.getJSONObject("props");// 位置大小 props.put("zindex", 0); @@ -8192,7 +8208,7 @@ public class CoeProcessLevelWeb extends ActionWeb { elements.put(shapeId, shape); // 设置画布大小 - DiagramUtil.setDiagramHeightWidth(definition, elements); + DiagramsUtil.setDiagramHeightWidth(definition, elements); defineModel.setDefinition(definition.toString()); // 保存文件 CoeDesignerAPIManager.getInstance().storeDefinition(defineModel);// dao操作 @@ -8215,9 +8231,9 @@ public class CoeProcessLevelWeb extends ActionWeb { * @param uuid * @return */ - public String relationFindSameRole(String uuid){ + public String relationFindSameRole(String uuid,String methodId){ ResponseObject ro = ResponseObject.newOkResponse(); - RowMap rowMap=DBSql.getMap("SELECT EXT2 FROM APP_ACT_COE_PAL_REPOSITORY WHERE EXT2=?",uuid); + RowMap rowMap=DBSql.getMap("SELECT EXT2 FROM APP_ACT_COE_PAL_REPOSITORY WHERE EXT2=? AND PLMETHODID=?",uuid,methodId); if(rowMap!=null){ ro.put("result", "ok"); }else{ diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/plugin/Plugins.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/plugin/Plugins.java index 90ccaa9f..f9e37732 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/plugin/Plugins.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/plugin/Plugins.java @@ -14,6 +14,7 @@ import com.actionsoft.apps.coe.pal.aslp.MethodAPI.QueryMethodListByMethod; import com.actionsoft.apps.coe.pal.aslp.PermAPI.*; import com.actionsoft.apps.coe.pal.aslp.PublishAPI.PublishPALRepository; import com.actionsoft.apps.coe.pal.aslp.RepositoryAPI.*; +import com.actionsoft.apps.coe.pal.cooperation.cache.CooperationCache; import com.actionsoft.apps.coe.pal.pal.home.aslp.RegisterExtendsApp; import com.actionsoft.apps.coe.pal.pal.method.aslp.RegisterMethodApp; import com.actionsoft.apps.coe.pal.pal.repository.addons.RepositoryDiagramExistMark; @@ -165,6 +166,9 @@ public class Plugins implements PluginListener { list.add(new ASLPPluginProfile("queryAllPublishedPALRepositoryModelsByPid", QueryAllPublishedPALRepositoryModelsByPid.class.getName(), "获取流程资产库下所有已发布的子流程,请直接调用SDK.getPALRepositoryQueryAPI.getAllPublishedPalRepositoryModelsByPid()方法", new HttpASLP(HttpASLP.AUTH_AWS_SID, null))); list.add(new AddOnsPluginProfile(RepositoryDiagramExistMark.class.getName(), "PAL初始化模型图标记", null)); + + //小组用户权限信息cache + list.add(new CachePluginProfile(CooperationCache.class)); return list; } diff --git a/com.actionsoft.apps.coe.pal/template/page/main.htm b/com.actionsoft.apps.coe.pal/template/page/main.htm index 0775bf7d..5701653f 100644 --- a/com.actionsoft.apps.coe.pal/template/page/main.htm +++ b/com.actionsoft.apps.coe.pal/template/page/main.htm @@ -13,4 +13,4 @@ var mainType = "<#mainType>"; var uid = "<#uid>"; var wHref = "./w"; - var jdHref = "./jd";
\ No newline at end of file + var jdHref = "./jd";
\ No newline at end of file diff --git a/com.actionsoft.apps.coe.pal/template/page/pal.pl.level.create.htm b/com.actionsoft.apps.coe.pal/template/page/pal.pl.level.create.htm index 793ed96d..ab01700f 100755 --- a/com.actionsoft.apps.coe.pal/template/page/pal.pl.level.create.htm +++ b/com.actionsoft.apps.coe.pal/template/page/pal.pl.level.create.htm @@ -160,7 +160,6 @@
  • 附件
  • -
  • 在线编辑
@@ -1287,6 +1292,18 @@ +
+
+ 版本差异 + +
+
+
+ + +
+
+
@@ -85,150 +85,150 @@ - + @@ -251,17 +251,17 @@ <#js> - - - - - - - - - - - + + + + + + + + + + + <#processlink_ete_js> - -
-
-
- <#checkoutTip> - <#fileName> -
-
- <#versionNum> -
- + +
+
+
+ <#checkoutTip> + <#fileName> +
+
+ <#versionNum>
+
- -
- <#saveUI> - -
-
-
-
-
-
-
-
-
-
- - -
-
Arial
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
- -
-
-
- -
- -
- -