步骤竖表手册项目内容调整

This commit is contained in:
anhc 2022-07-18 17:19:22 +08:00
parent 901c9e2026
commit bbe0305cee
2 changed files with 482 additions and 96 deletions

View File

@ -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<String> relationFileIds = new HashSet<>();
Map<String, Map<String, Object>> 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<DesignerShapeRelationModel> 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<Map<String, Object>> relations = CoeDesignerUtil.getShapeMessageJson4(relationFileId); //流程文件内容
for (Map<String, Object> entry : relations) {
Object attributes = entry.get("attributes");
String resultJson = attributes.toString();
JSONArray object= JSONArray.parseArray(resultJson);
for(int i=0; i<object.size(); i++) {
String key = object.getJSONObject(i).getString("key");
//if (key.equals("explain") || key.equals("statistical_period") || key.equals("unit_measurement") || key.equals("data_sources") || key.equals("computational_formula") || key.equals("Index_definition") || key.equals("objective") || key.equals("Name_process_performance_indicator")) {
if (key.equals("Name_process_performance_indicator")){//指标名称 Name_process_performance_indicator
String value = object.getJSONObject(i).getString("value");
dataMap.put("pl_Name_process_performance_indicator", value);
}else if (key.equals("set_the_purpose")){//设置目的 set_the_purpose
String value = object.getJSONObject(i).getString("value");
dataMap.put("pl_set_the_purpose", value);
}else if (key.equals("Index_definition")){//指标定义 Index_definition
String value = object.getJSONObject(i).getString("value");
dataMap.put("pl_Index_definition", value);
}else if (key.equals("computational_formula")){//计算公式 computational_formula
String value = object.getJSONObject(i).getString("value");
dataMap.put("pl_computational_formula", value);
}else if (key.equals("data_sources")){//数据来源 data_sources
String value = object.getJSONObject(i).getString("value");
dataMap.put("pl_data_sources", value);
}else if (key.equals("unit_measurement")){//计量单位 unit_measurement
String value = object.getJSONObject(i).getString("value");
dataMap.put("pl_unit_measurement", value);
}else if (key.equals("statistical_period")){//统计周期 statistical_period
String value = object.getJSONObject(i).getString("value");
dataMap.put("pl_statistical_period", value);
}else if (key.equals("explain")){// explain
String value = object.getJSONObject(i).getString("value");
dataMap.put("pl_explain", value);
}
}
}
}
}
dataMap.put("organizationType", "涉及部门及岗位\\角色");
if (repositoryModel == null) {
return null;
}
prReportComment.getCommentContent(dataMap, repositoryModel); // 获取一些公共的数据(手册首页的手册岗位名称部门时间等)
prReportComment.getCommentContent(dataMap, repositoryModel);//获取一些公共的数据(手册首页的手册岗位名称部门时间等)
JSONArray repositoryShapeTable = new JSONArray();//流程步骤Table
JSONArray repositoryShapeTable = new JSONArray(); // 流程步骤table
JSONArray shapeDangerTable = new JSONArray(); // 流程步骤的风控要求table
JSONArray shapeKPITable = new JSONArray(); // 流程步骤的量化指标table
JSONArray fileTable = new JSONArray(); //流程附件Table
JSONArray dangerTable = new JSONArray(); //风险Table
JSONArray regulateTable = new JSONArray(); //控制Table
JSONArray KPITable = new JSONArray(); //相关绩效考核Table
Set<String> dangerSet = new HashSet<String>();// 风险
Set<String> kpiSet = new HashSet<>();// kpi
Map<String, Map<String, Object>> relationFileMap = new HashMap<>();
Set<String> regulateSet = new HashSet<String>();// 控制
Set<String> KPISet = new HashSet<String>();// kpi
List<Map<String, Object>> 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<UpfileModel> 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<String, Object> 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)); //步骤名称
/**序号改为流程编号**/
/*_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<String> dutyROrgList = new ArrayList<>();
List<String> approvalAOrgAList = new ArrayList<>();
List<String> counselorCOrgList = new ArrayList<>();
List<String> notifyIOrgList = new ArrayList<>();
// 岗位员工
List<String> dutyRRoleList = new ArrayList<>();
List<String> approvalARoleAList = new ArrayList<>();
List<String> counselorCRoleList = new ArrayList<>();
List<String> notifyIRoleList = new ArrayList<>();
Map<String, List<DesignerShapeRelationModel>> 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);
_tr.put("shape_duty_r", attrValue.replace("\n", OutputWordUtil.WRAPSTRING));
}
} 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 ("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);
}
}
// 流程步骤的指标表格
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<DesignerShapeRelationModel> 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<DesignerShapeRelationModel> 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(OutputWordUtil.TABLE_DANGER, shapeDangerTable);
dataMap.put(OutputWordUtil.TABLE_KPI, shapeKPITable);
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<String, Map<String, Object>> relationFileMap) {
int index = 1;
JSONArray result = new JSONArray();
DesignerShapeRelationDao dao = new DesignerShapeRelationDao();
List<DesignerShapeRelationModel> 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<String, Object> shapes = new HashMap<>();
List<Map<String, Object>> fileElements = CoeDesignerUtil.getShapeMessageJson4(relationFileId);
for (Map<String, Object> shape : fileElements) {
String tempShapeId = shape.get("id").toString();
shapes.put(tempShapeId, shape);
}
relationFileMap.put(relationFileId, shapes);
}
}
Set<String> relationShapeIdSet = new HashSet<>(); // 去重
for (DesignerShapeRelationModel model : list) {
String relationFileId = model.getRelationFileId();
String relationShapeId = model.getRelationShapeId();
if (relationFileMap.containsKey(relationFileId)) {
Map<String, Object> elements = relationFileMap.get(relationFileId);
if (elements != null && elements.containsKey(relationShapeId)) {
Map<String, Object> shape = (Map<String, Object>) 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<String, Object> 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<String, Map<String, Object>> relationFileMap) {
JSONArray result = new JSONArray();
DesignerShapeRelationDao dao = new DesignerShapeRelationDao();
List<DesignerShapeRelationModel> 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<String, Object> shapes = new HashMap<>();
List<Map<String, Object>> fileElements = CoeDesignerUtil.getShapeMessageJson4(relationFileId);
for (Map<String, Object> shape : fileElements) {
String tempShapeId = shape.get("id").toString();
shapes.put(tempShapeId, shape);
}
relationFileMap.put(relationFileId, shapes);
}
}
Set<String> 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<String, Object> elements = relationFileMap.get(relationFileId);
if (elements != null && elements.containsKey(relationShapeId)) {
Map<String, Object> shape = (Map<String, Object>) 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<String, Object> 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;
}
}