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 e259803c..1d4c147a 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/report2/Report2Gener.java b/com.actionsoft.apps.coe.pal.output.pr/src/com/actionsoft/apps/coe/pal/output/pr/report2/Report2Gener.java index 35b3af17..52762e35 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 @@ -1,22 +1,37 @@ package com.actionsoft.apps.coe.pal.output.pr.report2; +import java.io.File; import java.util.*; +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; 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; 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.OutputWordUtil; +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.cache.PALRepositoryPropertyCache; +import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.cache.DesignerShapeRelationCache; 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.upfile.constant.CoeFileConstant; +import com.actionsoft.apps.coe.pal.pal.repository.upfile.dao.UpFileDao; +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.server.DispatcherRequest; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.server.fs.dc.DCProfileManager; +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; @@ -38,6 +53,7 @@ public class Report2Gener { // 防止生成过程中,停用或卸载该app public static boolean isRunning = false; public static final Object _lock = new Object(); + private UserContext userContext = null; GenerLogExd log = new GenerLogExd(); public Report2Gener() { } @@ -57,6 +73,7 @@ public class Report2Gener { try { synchronized (_lock) { isRunning = true; + userContext = DispatcherRequest.getUserContext(); String teamId = model.getTeamId(); String wsId = model.getWsId(); log.info("execute ready..."); @@ -68,7 +85,7 @@ public class Report2Gener { // ----预处理、校验---- OutputAppProfile appModel = OutputAppManager.getProfile(model.getProfileId()); String tempPath = appModel.getAppContext().getPath(); - String tempName = "步骤竖表-流程手册.xml"; + String tempName = "步骤竖表-流程手册2.xml"; log.info("begin..."); log.info("-------------------"); // ----文件处理----- @@ -120,18 +137,21 @@ public class Report2Gener { reportNameValue = reportNameValue.substring(0, 255); } String docName = ""; + String fileName = ""; if (indexMap.containsKey(reportNameValue)) { int index = indexMap.get(reportNameValue); index++; - log.info("得到word名称为:" + reportNameValue + "(" + index + ")"); - docName = docPath + reportNameValue + "(" + index + ")" + ".doc"; + fileName = reportNameValue + "(" + index + ")"; + log.info("得到word名称为:" + fileName); + docName = docPath + fileName + ".doc"; indexMap.put(reportNameValue, index); } else { - log.info("得到word名称为:" + reportNameValue); - docName = docPath + reportNameValue + ".doc"; - indexMap.put(reportNameValue, 1); + fileName = reportNameValue; + log.info("得到word名称为:" + fileName); + docName = docPath + fileName + ".doc"; + indexMap.put(fileName, 1); } - JSONObject dataMap = getData(repositoryId, wizardJsonData); + JSONObject dataMap = getData(repositoryId, wizardJsonData, docPath, fileName); if (dataMap != null) { OutputWordUtil.createDoc(dataMap, tempPath, tempName, docName); } @@ -139,135 +159,382 @@ public class Report2Gener { } } - private JSONObject getData(String repositoryId, JSONObject wizardJsonData) { + private JSONObject getData(String repositoryId, JSONObject wizardJsonData, String docPath, String fileName) { JSONObject dataMap = new JSONObject(); boolean raciRelationType = SDK.getAppAPI().getPropertyBooleanValue("com.actionsoft.apps.coe.pal.output.pr", "DETY_POSITION_ROLE_RELATION_TYPE", false); - dataMap.put("organizationType1", "涉及部门"); - dataMap.put("organizationType2", "涉及岗位\\角色"); + // 记录关联属性的流程节点,防止多次查询重复文件信息耗费时间 + Set relationFileIds = new HashSet<>(); + Map> relationFileMap = new HashMap<>(); + PrReportComment prReportComment = new PrReportComment(); - PALRepositoryModel repositoryModel = PALRepositoryCache.getCache().get(repositoryId); + PALRepositoryModel repositoryModel = PALRepositoryQueryAPIManager.getInstance().queryPalRepositoryModelByPalId(repositoryId); + + //流程绩效 + dataMap.put("pl_Name_process_performance_indicator", ""); + dataMap.put("pl_set_the_purpose", ""); + dataMap.put("pl_Index_definition", ""); + dataMap.put("pl_computational_formula", ""); + dataMap.put("pl_data_sources", ""); + dataMap.put("pl_unit_measurement", ""); + dataMap.put("pl_statistical_period", ""); + dataMap.put("pl_explain", ""); + List metrics = DesignerShapeRelationCache.getListByAttrId(repositoryModel.getId(), "", "Process_performance_metrics"); + if (metrics.size() != 0) { + for (DesignerShapeRelationModel relation : metrics) { + String relationFileId = relation.getRelationFileId();// 支持或相关文件的ID + String relationShapeId = relation.getRelationShapeId();//实例ID + //System.out.println(relationFileId + "/" + relationShapeId);//输出响应ID + List> relations = CoeDesignerUtil.getShapeMessageJson4(relationFileId); //流程文件内容 + for (Map entry : relations) { + Object attributes = entry.get("attributes"); + String resultJson = attributes.toString(); + JSONArray object= JSONArray.parseArray(resultJson); + for(int i=0; i dangerSet = new HashSet();// 风险 - Set kpiSet = new HashSet<>();// kpi - Map> relationFileMap = new HashMap<>(); - + Set regulateSet = new HashSet();// 控制 + Set KPISet = new HashSet();// kpi List> repositoryFileElements = CoeDesignerUtil.getShapeMessageJson4(repositoryId); //流程文件内容 if (wizardJsonData.getBoolean("orderNuberFirst")) { // 根据页面选择进行排序 OutputWordUtil.orderByNumber(repositoryFileElements); } + + // 流程附件列表 + UpFileDao upFileDao = new UpFileDao(); + StringBuffer sqlWhere = new StringBuffer(); + sqlWhere.append(" and PALREPOSITORYID ='").append(repositoryModel.getId()).append("'"); + List search = upFileDao.search(sqlWhere.toString()); + File file = null; + //三员管理下,用户密级与文件密级过滤显示 + if(HighSecurityUtil.isON()){ + PALRepositoryQueryAPIManager.getInstance().upFileSecurityFilter(this.userContext,search); + } + if (search != null && search.size() > 0) { + //创建附件目录及复制附件 + fileName = fileName + "_file"; + file = new File(docPath, fileName); + if (!file.exists()) { + log.info("创建附件"); + file.mkdir(); + } + } + + //文件属性附件处理 + int fileIndex = 1; + if (search != null && search.size() > 0) { + // 复制附件 + for (UpfileModel upfileModel : search) { + if (!"f".equals(upfileModel.getType())) {// 文件 + continue; + } + // 复制doccenter下的文件 + DCContext dcContext = null; + DCPluginProfile dcProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, CoeFileConstant.COE_UPFILE); + if (dcProfile != null) { + dcContext = new DCContext(userContext, dcProfile, CoEConstant.APP_ID, "file", upfileModel.getPl_uuid(), upfileModel.getFileName()); + } + File sourceFile = new UtilFile(dcContext.getFilePath()); + File targetFile = new UtilFile(file.toString() + File.separator + dcContext.getFileName()); + try { + UtilFile.copyFile(sourceFile, targetFile); + } catch (Exception e) { + System.out.println(e); + e.printStackTrace(); + } + JSONObject object = new JSONObject(); + object.put("file_name", fileIndex + "." + upfileModel.getFileName()); + String link = fileName + File.separator + upfileModel.getFileName(); + object.put("link", link); + fileTable.add(object); + fileIndex++; + } + } + //流程说明 if (repositoryFileElements != null) { int index = 1;// 流程步骤序号 int dangerIndex = 1;// 风险序号 - int kpiIndex = 1;// 指标序号 + int regulateIndex = 1;// 控制序号 for (Map shape : repositoryFileElements) { //如果图形元素不是流程步骤,不导出该元素 - if (PrReportComment.PROCESS_STEP.indexOf((String) shape.get("type")) == -1) { - continue; - } - boolean containDangerAttribute = false; - boolean containKPIAttribute = false; +// if (PrReportComment.PROCESS_STEP.indexOf((String)shape.get("type")) == -1 && "method_approval_node,method_service_node,method_manual_node".indexOf((String)shape.get("type")) == -1) { +// continue; +// } JSONObject _tr = new JSONObject(); - OutputWordUtil.setShapeDefaultValue2(repositoryId, _tr); //设置默认值 - _tr.put(OutputWordUtil.SERIAL_NUMBER, index); //序号 - _tr.put(OutputWordUtil.REPOSITORY_NAME, specialCharTransfer(repositoryModel.getName().replace("\n", ""))); //流程名称 - _tr.put(OutputWordUtil.SHAPE_NAME, specialCharTransfer(shape.get("text").toString()).replace("\n", OutputWordUtil.WRAPSTRING)); //步骤名称 + OutputWordUtil.setShapeDefaultValue2(repositoryId, _tr); //设置默认值 + _tr.put(OutputWordUtil.SERIAL_NUMBER, index); //序号 + _tr.put(OutputWordUtil.REPOSITORY_NAME, specialCharTransfer(repositoryModel.getName().replace("\n", ""))); //流程名称 + _tr.put(OutputWordUtil.SHAPE_NAME, specialCharTransfer(shape.get("text").toString()).replace("\n", OutputWordUtil.WRAPSTRING)); //步骤名称 + + /**序号改为流程编号**/ + /*_tr.put(OutputWordUtil.SERIAL_NUMBER, ""); //序号置空 + if (shape.containsKey("number")) { + _tr.put(OutputWordUtil.SERIAL_NUMBER, shape.get("number")); + }*/ + /**序号改为流程编号**/ + + // 节点的附件处理 + JSONArray shapeFileTable = new JSONArray(); //流程节点附件Table + if (search != null && search.size() > 0) { + // 复制附件 + for (UpfileModel upfileModel : search) { + if ("f".equals(upfileModel.getType())) { + continue; + } + if (!shape.get("id").equals(upfileModel.getShape_uuid())) { + continue; + } + // 复制doccenter下的文件 + DCContext dcContext = null; + DCPluginProfile dcProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, CoeFileConstant.COE_UPFILE); + if (dcProfile != null) { + dcContext = new DCContext(userContext, dcProfile, CoEConstant.APP_ID, upfileModel.getPl_uuid(), upfileModel.getShape_uuid(), upfileModel.getFileName()); + } + File sourceFile = new UtilFile(dcContext.getFilePath()); + File targetFile = new UtilFile(file.toString() + File.separator + dcContext.getFileName()); + try { + UtilFile.copyFile(sourceFile, targetFile); + } catch (Exception e) { + System.out.println(e); + e.printStackTrace(); + } + JSONObject object = new JSONObject(); + object.put("shape_file_name", fileIndex+"."+upfileModel.getFileName()); + String link = fileName + File.separator + upfileModel.getFileName(); + object.put("shape_file_link", link); + shapeFileTable.add(object); + fileIndex++; + } + } + if(shapeFileTable.size() == 0) {// 没有附件时给空值,不然使用office打开会解析错误 + JSONObject object = new JSONObject(); + object.put("shape_file_name", ""); + object.put("shape_file_link", ""); + shapeFileTable.add(object); + } + _tr.put("shape_File_Table", shapeFileTable); + JSONArray dataAttributes = (JSONArray) shape.get("attributes"); - // 组织(部门)、员工 - List dutyROrgList = new ArrayList<>(); - List approvalAOrgAList = new ArrayList<>(); - List counselorCOrgList = new ArrayList<>(); - List notifyIOrgList = new ArrayList<>(); - // 岗位、员工 - List dutyRRoleList = new ArrayList<>(); - List approvalARoleAList = new ArrayList<>(); - List counselorCRoleList = new ArrayList<>(); - List notifyIRoleList = new ArrayList<>(); - Map> map = OutputWordUtil.getShapeRelationAttrMap(repositoryId, shape.get("id").toString()); if (!dataAttributes.isEmpty()) { for (int i = 0; i < dataAttributes.size(); i++) { JSONObject obj = dataAttributes.getJSONObject(i); String attrId = obj.getString("key"); String attrValue = obj.getString("value"); _tr.put("shape_" + attrId, attrValue.replace("\n", OutputWordUtil.WRAPSTRING)); - if ("bpm_duty_r,bpm_approval_a,bpm_counselor_c,bpm_notify_i,duty_r,approval_a,counselor_c,notify_i".contains(attrId)) { - if (raciRelationType) {// 涉及部门、岗位/角色关联的是bpm组织部门、岗位、角色 - dataMap.put("organizationType1", "涉及部门\\人员"); - dataMap.put("organizationType2", "涉及岗位\\角色"); - if ("bpm_duty_r".equals(attrId)) { - raciRelationAwsOrg(map, "bpm_duty_r", dutyROrgList, dutyRRoleList); - } else if ("bpm_approval_a".equals(attrId)) { - raciRelationAwsOrg(map, "bpm_approval_a", approvalAOrgAList, approvalARoleAList); - } else if ("bpm_counselor_c".equals(attrId)) { - raciRelationAwsOrg(map, "bpm_counselor_c", counselorCOrgList, counselorCRoleList); - } else if ("bpm_notify_i".equals(attrId)) { - raciRelationAwsOrg(map, "bpm_notify_i", notifyIOrgList, notifyIRoleList); - } - } else { - if ("duty_r".equals(attrId)) { - raciRelationPalOrg(map, "duty_r", dutyROrgList, dutyRRoleList); - } else if ("approval_a".equals(attrId)) { - raciRelationPalOrg(map, "approval_a", approvalAOrgAList, approvalARoleAList); - } else if ("counselor_c".equals(attrId)) { - raciRelationPalOrg(map, "counselor_c", counselorCOrgList, counselorCRoleList); - } else if ("notify_i".equals(attrId)) { - raciRelationPalOrg(map, "notify_i", notifyIOrgList, notifyIRoleList); - } + if (raciRelationType) {// 涉及部门、岗位/角色关联的是bpm组织部门、岗位、角色 + if ("bpm_duty_r".equals(attrId)) { + _tr.put("shape_duty_r", attrValue.replace("\n", OutputWordUtil.WRAPSTRING)); + } + if ("bpm_approval_a".equals(attrId)) { + _tr.put("shape_approval_a", attrValue.replace("\n", OutputWordUtil.WRAPSTRING)); + } + if ("bpm_counselor_c".equals(attrId)) { + _tr.put("shape_counselor_c", attrValue.replace("\n", OutputWordUtil.WRAPSTRING)); + } + if ("bpm_notify_i".equals(attrId)) { + _tr.put("shape_notify_i", attrValue.replace("\n", OutputWordUtil.WRAPSTRING)); } } - if ("danger".equals(attrId)) { - JSONArray dangerTable = new JSONArray(); - dangerIndex = setTableValueOfRiskAndKPI(attrId, repositoryId, shape.get("id").toString(),dangerTable, dangerIndex, _tr.getString(OutputWordUtil.SHAPE_NAME), relationFileMap); + dangerIndex = setTableValueOfControlAndRisk(attrId, repositoryId, shape.get("id").toString(),dangerTable, dangerIndex, _tr.getString(OutputWordUtil.SHAPE_NAME), relationFileMap); dangerSet.clear(); - _tr.put(OutputWordUtil.TABLE_DANGER, dangerTable); - if (dangerTable.size() > 0) { - containDangerAttribute = true; - } - - } else if ("kpi".equals(attrId)) { - JSONArray kpiTable = new JSONArray(); - kpiIndex = setTableValueOfRiskAndKPI(attrId, repositoryId, shape.get("id").toString(), kpiTable, kpiIndex, _tr.getString(OutputWordUtil.SHAPE_NAME), relationFileMap); - kpiSet.clear(); - _tr.put(OutputWordUtil.TABLE_KPI, kpiTable); - if (kpiTable.size() > 0) { - containKPIAttribute = true; - } + }else if ("regulate".equals(attrId)) { + regulateIndex = setTableValueOfControlAndRisk(attrId, repositoryId, shape.get("id").toString(), regulateTable, regulateIndex, _tr.getString(OutputWordUtil.SHAPE_NAME), relationFileMap); + regulateSet.clear(); } } - _tr.put("shape_duty_r_org", StringUtils.join(dutyROrgList, ",").replace("\n", OutputWordUtil.WRAPSTRING)); - _tr.put("shape_approval_a_org", StringUtils.join(approvalAOrgAList, ",").replace("\n", OutputWordUtil.WRAPSTRING)); - _tr.put("shape_counselor_c_org", StringUtils.join(counselorCOrgList, ",").replace("\n", OutputWordUtil.WRAPSTRING)); - _tr.put("shape_notify_i_org", StringUtils.join(notifyIOrgList, ",").replace("\n", OutputWordUtil.WRAPSTRING)); - _tr.put("shape_duty_r_role", StringUtils.join(dutyRRoleList, ",").replace("\n", OutputWordUtil.WRAPSTRING)); - _tr.put("shape_approval_a_role", StringUtils.join(approvalARoleAList, ",").replace("\n", OutputWordUtil.WRAPSTRING)); - _tr.put("shape_counselor_c_role", StringUtils.join(counselorCRoleList, ",").replace("\n", OutputWordUtil.WRAPSTRING)); - _tr.put("shape_notify_i_role", StringUtils.join(notifyIRoleList, ",").replace("\n", OutputWordUtil.WRAPSTRING)); } repositoryShapeTable.add(_tr); index++; - if (containDangerAttribute) { - shapeDangerTable.add(_tr); - } - if (containKPIAttribute) { - shapeKPITable.add(_tr); - } } - } - dataMap.put(OutputWordUtil.TABLE_REPOSITORY_SHAPE, repositoryShapeTable); - dataMap.put(OutputWordUtil.TABLE_DANGER, shapeDangerTable); - dataMap.put(OutputWordUtil.TABLE_KPI, shapeKPITable); + // 流程步骤的指标表格 + setTableValueOfKPI("kpi", repositoryId, KPITable, relationFileMap); + JSONArray termTable = new JSONArray(); //术语定义Table + // 属性特征 属性代码KEY + PALRepositoryPropertyModel term = PALRepositoryPropertyCache.getPropertyByPropertyId(repositoryModel.getId(),"term"); + if (term != null) { + String termVal = term.getPropertyValue(); + JSONObject termObj = JSONObject.parseObject(termVal); + if (termObj != null && !termObj.isEmpty()) { + JSONArray tableArr = termObj.getJSONArray("table"); + if (tableArr != null && !tableArr.isEmpty()) { + for (Object obj : tableArr) { + JSONObject obj2 = (JSONObject) obj; + if (!"table_head".equals(obj2.getString("id"))) { + String name = obj2.getString("name"); + String desc = obj2.getString("desc"); + JSONObject tmp = new JSONObject(); + tmp.put("name", name); + tmp.put("desc", desc); + termTable.add(tmp); + } + } + } + } + } + + + JSONArray organizationTable = new JSONArray(); //组织职责Table + // 属性特征 属性代码KEY + PALRepositoryPropertyModel Organizational = PALRepositoryPropertyCache.getPropertyByPropertyId(repositoryModel.getId(),"Organizational_role"); + if (Organizational != null){ + String OrganizationalVal = Organizational.getPropertyValue(); + JSONObject OrganizationalObj = JSONObject.parseObject(OrganizationalVal); + if (OrganizationalObj != null && !OrganizationalObj.isEmpty()) { + JSONArray tableArr = OrganizationalObj.getJSONArray("table"); + if (tableArr != null && !tableArr.isEmpty()) { + for (Object obj : tableArr) { + JSONObject obj2 = (JSONObject) obj; + if (!"table_head".equals(obj2.getString("id"))) { + String name = obj2.getString("name"); + String desc = obj2.getString("desc"); + JSONObject tmp = new JSONObject(); + tmp.put("name", name); + tmp.put("desc", desc); + organizationTable.add(tmp); + } + } + } + } + } + + + //支持文件 + JSONArray supportfiles = new JSONArray(); //组织职责Table + List relationList = DesignerShapeRelationCache.getListByAttrId(repositoryModel.getId(), "", "support_files"); + int index = 0; + for (DesignerShapeRelationModel relation : relationList) { + String relationFileId = relation.getRelationFileId();// 支持或相关文件的ID + PALRepositoryModel model = PALRepositoryCache.getCache().get(relationFileId); + if (model != null) { + index++; + String name = model.getName(); + JSONObject tmp = new JSONObject(); + tmp.put("name", name); + tmp.put("desc", index); + + + supportfiles.add(tmp); + } + } + + //相关文件 R_relevant_flies + JSONArray relevant_flies = new JSONArray(); //组织职责Table + List relationList2 = DesignerShapeRelationCache.getListByAttrId(repositoryModel.getId(), "", "R_relevant_flies"); + int count = 0; + for (DesignerShapeRelationModel relation : relationList2) { + String relationFileId = relation.getRelationFileId();// 支持或相关文件的ID + PALRepositoryModel model = PALRepositoryCache.getCache().get(relationFileId); + if (model != null) { + count++; + String name = model.getName(); + JSONObject tmp = new JSONObject(); + tmp.put("name", name); + tmp.put("desc", count); + + relevant_flies.add(tmp); + } + } + + + + //System.out.println(relations+"==========relations"); + /*if (wizardJsonData.getBoolean("orderNuberFirst")) { // 根据页面选择进行排序 + OutputWordUtil.orderByNumber(relations); + }*/ + + + + + + // 2张表 + // 文件属性内容(文本内容)表 + // 文件属性内容关联表 + + // 根据绩效所属模型查询绩效形状的详细信息 + + + + // 流程文件属性术语与定义(表格类型) + + + + // 流程文件属性绩效形状的信息 + + // 流程文件属性相关文件和支持文件 + + //术语 + dataMap.put("term_table", termTable);//table4 + dataMap.put("term_table_count", termTable.size());//table4 + //组织和职责 + dataMap.put("organization_table", organizationTable);//table5 + dataMap.put("organization_table_count",organizationTable.size());//table5 + //支持文件 + dataMap.put("supports_table", supportfiles);//table6 + dataMap.put("supports_table_count", supportfiles.size());//table6 + //相关文件 + dataMap.put("relevant_table", relevant_flies);//table7 + dataMap.put("relevant_table_count", relevant_flies.size());//table7 + //流程绩效 + //dataMap.put("Process_performance_metrics_table",process_performance_metrics);//table8 + dataMap.put("metrics_count", metrics.size());// + + dataMap.put(OutputWordUtil.TABLE_REPOSITORY_SHAPE, repositoryShapeTable); + dataMap.put("TABLE_REPOSITORY_SHAPE_COUNT", repositoryShapeTable.size()); + dataMap.put("file_table", fileTable); + dataMap.put("file_table_count", fileIndex); + dataMap.put(OutputWordUtil.TABLE_DANGER, dangerTable); + dataMap.put(OutputWordUtil.TABLE_REGULATE, regulateTable); + dataMap.put(OutputWordUtil.TABLE_KPI, KPITable); + ReportRepositoryCompare compare = new ReportRepositoryCompare(); + JSONArray historyVersionModify = compare.getModifyVersionHistory(repositoryId); + dataMap.put("history_table", historyVersionModify); return dataMap; } @@ -389,4 +656,123 @@ public class Report2Gener { } } + /** + * 设置流程步骤的KPI表格 + * @param attrId + * @param fileId + * @param table + * @param relationFileMap + * @return + */ + public int setTableValueOfKPI(String attrId, String fileId, JSONArray table, Map> relationFileMap) { + int index = 1; + JSONArray result = new JSONArray(); + DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); + List list = dao.query(fileId, null, attrId, null, null); + for (DesignerShapeRelationModel model : list) { + String relationFileId = model.getRelationFileId(); + if (!relationFileMap.containsKey(relationFileId) && !UtilString.isEmpty(model.getShapeId())) { + Map shapes = new HashMap<>(); + List> fileElements = CoeDesignerUtil.getShapeMessageJson4(relationFileId); + for (Map shape : fileElements) { + String tempShapeId = shape.get("id").toString(); + shapes.put(tempShapeId, shape); + } + relationFileMap.put(relationFileId, shapes); + } + } + + Set relationShapeIdSet = new HashSet<>(); // 去重 + for (DesignerShapeRelationModel model : list) { + String relationFileId = model.getRelationFileId(); + String relationShapeId = model.getRelationShapeId(); + if (relationFileMap.containsKey(relationFileId)) { + Map elements = relationFileMap.get(relationFileId); + if (elements != null && elements.containsKey(relationShapeId)) { + Map shape = (Map) elements.get(relationShapeId); + if (!relationShapeIdSet.contains(shape.get("id").toString())) { + relationShapeIdSet.add(shape.get("id").toString()); + result.add(shape); + } + } + } + } + + for (int i = 0; i < result.size(); i++) { + Map shape = result.getJSONObject(i); + JSONObject _tr = new JSONObject(); + OutputWordUtil.setShapeDefaultValue2(shape.get("uuid").toString(), _tr); //设置默认值 + String name = specialCharTransfer(shape.get("text").toString()); + _tr.put(OutputWordUtil.SHAPE_NAME, name.replace("\n", OutputWordUtil.WRAPSTRING)); + _tr.put(OutputWordUtil.SERIAL_NUMBER, index); + JSONArray dataAttributes = (JSONArray) shape.get("attributes"); + for (int j = 0; j < dataAttributes.size(); j++) { + _tr.put("shape_" + dataAttributes.getJSONObject(j).getString("key"), specialCharTransfer(dataAttributes.getJSONObject(j).getString("value")).replace("\n", " ")); + } + table.add(_tr); + index++; + } + return index; + + } + + + public int setTableValueOfControlAndRisk(String attrId, String fileId, String shapeId, JSONArray table, int index, String processShapeName, Map> relationFileMap) { + JSONArray result = new JSONArray(); + DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); + List list = dao.query(fileId, shapeId, attrId, null, null); + for (DesignerShapeRelationModel model : list) { + String relationFileId = model.getRelationFileId(); + if (!relationFileMap.containsKey(relationFileId) && PALRepositoryCache.getCache().get(relationFileId) != null) { + Map shapes = new HashMap<>(); + List> fileElements = CoeDesignerUtil.getShapeMessageJson4(relationFileId); + for (Map shape : fileElements) { + String tempShapeId = shape.get("id").toString(); + shapes.put(tempShapeId, shape); + } + relationFileMap.put(relationFileId, shapes); + } + } + + Set relationShapeIdSet = new HashSet<>(); // 去重 + String filterShapeName = ""; + if ("danger".equals(attrId)) {// 风险 + filterShapeName = "risk"; + } else if ("regulate".equals(attrId)) {// 控制 + filterShapeName = "control"; + } + for (DesignerShapeRelationModel model : list) { + String relationFileId = model.getRelationFileId(); + String relationShapeId = model.getRelationShapeId(); + if (relationFileMap.containsKey(relationFileId)) { + Map elements = relationFileMap.get(relationFileId); + if (elements != null && elements.containsKey(relationShapeId)) { + Map shape = (Map) elements.get(relationShapeId); + if (!relationShapeIdSet.contains(shape.get("id").toString()) && filterShapeName.equals(shape.get("type"))) { + relationShapeIdSet.add(shape.get("id").toString()); + result.add(shape); + } + } + } + } + + for (int i = 0; i < result.size(); i++) { + Map shape = result.getJSONObject(i); + JSONObject _tr = new JSONObject(); + OutputWordUtil.setShapeDefaultValue2(shape.get("uuid").toString(), _tr); //设置默认值 + String name = specialCharTransfer(shape.get("text").toString()); + _tr.put("related_" + OutputWordUtil.SHAPE_NAME, processShapeName); + _tr.put(OutputWordUtil.SHAPE_NAME, name.replace("\n", OutputWordUtil.WRAPSTRING)); + _tr.put(OutputWordUtil.SERIAL_NUMBER, index); + JSONArray dataAttributes = (JSONArray) shape.get("attributes"); + for (int j = 0; j < dataAttributes.size(); j++) { + _tr.put("shape_" + dataAttributes.getJSONObject(j).getString("key"), specialCharTransfer(dataAttributes.getJSONObject(j).getString("value")).replace("\n", " ")); + } + table.add(_tr); + index++; + } + return index; + + } + }