制度手册格式调整
This commit is contained in:
parent
cedd42df6f
commit
88bd2336ee
Binary file not shown.
@ -95,7 +95,7 @@ public class Report1Gener {
|
||||
// ----预处理、校验----
|
||||
OutputAppProfile appModel = OutputAppManager.getProfile(model.getProfileId());
|
||||
String tempPath = appModel.getAppContext().getPath();
|
||||
String tempName = "制度-手册3.xml";
|
||||
String tempName = "制度-手册4.xml";
|
||||
log.info("begin...");
|
||||
log.info("-------------------");
|
||||
// ----文件处理-----
|
||||
@ -469,10 +469,10 @@ public class Report1Gener {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("shape_file_name", upfileModel.getFileName());
|
||||
object.put("file_name", upfileModel.getFileName());
|
||||
String link = fileName + File.separator + upfileModel.getFileName();
|
||||
object.put("shape_file_link", link);
|
||||
shapeFileTable.add(object);
|
||||
object.put("link", link);
|
||||
fileTable.add(object);
|
||||
}
|
||||
}
|
||||
if(shapeFileTable.size() == 0) {// 没有附件时给空值,不然使用office打开会解析错误
|
||||
|
||||
@ -1,393 +0,0 @@
|
||||
package com.awspaas.apps.coe.pal.output.zd.report2;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
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.cache.PALRepositoryCache;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryPropertyCache;
|
||||
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.system.property.CoePropertyUtil;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
import com.actionsoft.bpms.server.fs.DCContext;
|
||||
import com.actionsoft.sdk.local.api.internal.PlatformAPIImpl;
|
||||
import com.awspaas.apps.coe.pal.output.zd.util.PrReportComment;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import javax.wsdl.Output;
|
||||
|
||||
import static com.actionsoft.apps.coe.pal.pal.output.util.OutputWordUtil.specialCharTransfer;
|
||||
|
||||
/**
|
||||
* 生成流程手册-步骤竖表的入口
|
||||
*
|
||||
* @author zhangming
|
||||
*/
|
||||
public class Report2Gener {
|
||||
// 防止生成过程中,停用或卸载该app
|
||||
public static boolean isRunning = false;
|
||||
public static final Object _lock = new Object();
|
||||
GenerLogExd log = new GenerLogExd();
|
||||
public Report2Gener() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成文件
|
||||
*
|
||||
* @param model OutputTaskModel对象
|
||||
* @param wizardJsonData 向导收集的Json参数(targetFiles、relationFiles、options...)
|
||||
* @param dcContext 要生成报告的DC目录对象,已准备好
|
||||
* @return 将文件生成到output目录下,返回状态
|
||||
*
|
||||
* @see PlatformAPIImpl#getDefaultLanguage()
|
||||
* @see PlatformAPIImpl#getlanguages()
|
||||
*/
|
||||
public ResponseObject execute(OutputTaskModel model, String wizardJsonData, DCContext dcContext) {
|
||||
try {
|
||||
synchronized (_lock) {
|
||||
isRunning = true;
|
||||
String teamId = model.getTeamId();
|
||||
String wsId = model.getWsId();
|
||||
log.info("execute ready...");
|
||||
log.info("-------------------");
|
||||
log.info("TeamId=" + teamId);
|
||||
log.info("wsId=" + wsId);
|
||||
JSONObject jsonObj = JSONObject.parseObject(wizardJsonData);
|
||||
log.info("dcPath=" + dcContext.getPath());
|
||||
// ----预处理、校验----
|
||||
OutputAppProfile appModel = OutputAppManager.getProfile(model.getProfileId());
|
||||
String tempPath = appModel.getAppContext().getPath();
|
||||
//String tempName = "步骤竖表-流程手册.xml";
|
||||
String tempName = "制度-手册.xml";
|
||||
log.info("begin...");
|
||||
log.info("-------------------");
|
||||
// ----文件处理-----
|
||||
genarateWord(tempPath, tempName, dcContext.getPath(), jsonObj);
|
||||
log.info("end");
|
||||
}
|
||||
} finally {
|
||||
isRunning = false;
|
||||
}
|
||||
return ResponseObject.newOkResponse().put("logs", log.logs());
|
||||
}
|
||||
|
||||
private void genarateWord(String tempPath, String tempName, String docPath, JSONObject wizardJsonData) {
|
||||
String[] repositoryIds = wizardJsonData.getString("targetFileId").split(",");
|
||||
|
||||
String reportName = wizardJsonData.getString("reportNameIsItName"); //页面上设计的文件命名规则
|
||||
Map<String, Integer> indexMap = new HashMap<String, Integer>();
|
||||
for (String repositoryId : repositoryIds) {
|
||||
if (repositoryId == null || "".equals(repositoryId)) {
|
||||
continue;
|
||||
}
|
||||
PALRepositoryModel model = PALRepositoryCache.getCache().get(repositoryId);
|
||||
if (model != null) {
|
||||
//获取文件扩展属性
|
||||
String json = CoePropertyUtil.getPropertyValue(model.getId() + "_attr");
|
||||
JSONObject extendAttr = new JSONObject();
|
||||
if (json != null && !"".equals(json) && !"null".equals(json)) {
|
||||
JSONArray jsonArray = JSONArray.parseArray(json);
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject object = jsonArray.getJSONObject(i);
|
||||
extendAttr.put(object.getString("id"), object.get("value"));
|
||||
}
|
||||
}
|
||||
//文件的扩展属性
|
||||
List<PALRepositoryPropertyModel> repositoryPropertyList = PALRepositoryPropertyCache.getPropertyByPlId(model.getId());
|
||||
if (repositoryPropertyList != null && repositoryPropertyList.size() > 0) {
|
||||
for (PALRepositoryPropertyModel repositoryPropertyModel : repositoryPropertyList) {
|
||||
extendAttr.put(repositoryPropertyModel.getPropertyId(), repositoryPropertyModel.getPropertyValue());
|
||||
}
|
||||
}
|
||||
List<String> reportNameLabels = OutputExcelUtil.string2label(reportName);
|
||||
String reportNameValue = reportName;
|
||||
if (reportNameLabels.size() > 0) {
|
||||
reportNameValue = OutputExcelUtil.label2value(model, extendAttr, null, reportName);
|
||||
|
||||
}
|
||||
reportNameValue = reportNameValue.replaceAll(OutputExcelUtil.FILENAMEREGX, "");
|
||||
if (reportNameValue.length() > 255) {
|
||||
reportNameValue = reportNameValue.substring(0, 255);
|
||||
}
|
||||
String docName = "";
|
||||
if (indexMap.containsKey(reportNameValue)) {
|
||||
int index = indexMap.get(reportNameValue);
|
||||
index++;
|
||||
log.info("得到word名称为:" + reportNameValue + "(" + index + ")");
|
||||
docName = docPath + reportNameValue + "(" + index + ")" + ".doc";
|
||||
indexMap.put(reportNameValue, index);
|
||||
} else {
|
||||
log.info("得到word名称为:" + reportNameValue);
|
||||
docName = docPath + reportNameValue + ".doc";
|
||||
indexMap.put(reportNameValue, 1);
|
||||
}
|
||||
JSONObject dataMap = getData(repositoryId, wizardJsonData);
|
||||
if (dataMap != null) {
|
||||
OutputWordUtil.createDoc(dataMap, tempPath, tempName, docName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private JSONObject getData(String repositoryId, JSONObject wizardJsonData) {
|
||||
JSONObject dataMap = new JSONObject();
|
||||
boolean raciRelationType = SDK.getAppAPI().getPropertyBooleanValue("com.awspaas.user.apps.coe.pal.output.zd", "DETY_POSITION_ROLE_RELATION_TYPE", false);
|
||||
|
||||
dataMap.put("organizationType1", "涉及部门");
|
||||
dataMap.put("organizationType2", "涉及岗位\\角色");
|
||||
PrReportComment prReportComment = new PrReportComment();
|
||||
PALRepositoryModel repositoryModel = PALRepositoryCache.getCache().get(repositoryId);
|
||||
if (repositoryModel == null) {
|
||||
return null;
|
||||
}
|
||||
prReportComment.getCommentContent(dataMap, repositoryModel); // 获取一些公共的数据(手册首页的手册岗位名称、部门、时间等)
|
||||
|
||||
JSONArray repositoryShapeTable = new JSONArray(); // 流程步骤table
|
||||
JSONArray shapeDangerTable = new JSONArray(); // 流程步骤的风控要求table
|
||||
JSONArray shapeKPITable = new JSONArray(); // 流程步骤的量化指标table
|
||||
|
||||
Set<String> dangerSet = new HashSet<String>();// 风险
|
||||
Set<String> kpiSet = new HashSet<>();// kpi
|
||||
Map<String, Map<String, Object>> relationFileMap = new HashMap<>();
|
||||
|
||||
List<Map<String, Object>> repositoryFileElements = CoeDesignerUtil.getShapeMessageJson4(repositoryId); //流程文件内容
|
||||
if (wizardJsonData.getBoolean("orderNuberFirst")) { // 根据页面选择进行排序
|
||||
OutputWordUtil.orderByNumber(repositoryFileElements);
|
||||
}
|
||||
if (repositoryFileElements != null) {
|
||||
int index = 1;// 流程步骤序号
|
||||
int dangerIndex = 1;// 风险序号
|
||||
int kpiIndex = 1;// 指标序号
|
||||
for (Map<String, Object> shape : repositoryFileElements) {
|
||||
//如果图形元素不是流程步骤,不导出该元素
|
||||
if (PrReportComment.PROCESS_STEP.indexOf((String) shape.get("type")) == -1) {
|
||||
continue;
|
||||
}
|
||||
boolean containDangerAttribute = false;
|
||||
boolean containKPIAttribute = false;
|
||||
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)); //步骤名称
|
||||
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);
|
||||
}
|
||||
} 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 ("danger".equals(attrId)) {
|
||||
JSONArray dangerTable = new JSONArray();
|
||||
dangerIndex = setTableValueOfRiskAndKPI(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
_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);
|
||||
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置风险控制表格
|
||||
* @param attrId
|
||||
* @param fileId
|
||||
* @param shapeId
|
||||
* @param table
|
||||
* @param index
|
||||
* @param relationFileMap
|
||||
* @return
|
||||
*/
|
||||
public int setTableValueOfRiskAndKPI(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 ("kpi".equals(attrId)) {// 控制
|
||||
filterShapeName = "kpi";
|
||||
}
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门、岗位、角色、人员数据
|
||||
* @param map
|
||||
* @param orgList
|
||||
* @param roleList
|
||||
*/
|
||||
private void raciRelationAwsOrg(Map<String, List<DesignerShapeRelationModel>> map, String attrId, List<String> orgList, List<String> roleList) {
|
||||
if (map.containsKey(attrId)) {
|
||||
for (DesignerShapeRelationModel model : map.get(attrId)) {
|
||||
JSONObject orgObj = JSONObject.parseObject(model.getRelationShapeText());
|
||||
String orgType = orgObj.getString("type");
|
||||
String orgName = orgObj.getString("name");
|
||||
if ("department".equals(orgType) || "user".equals(orgType)) {// 部门人员
|
||||
orgList.add(orgName);
|
||||
} else if ("position".equals(orgType) || "role".equals(orgType)) {// 岗位角色
|
||||
roleList.add(orgName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门、岗位、角色、人员数据
|
||||
* @param map
|
||||
* @param orgList
|
||||
* @param roleList
|
||||
*/
|
||||
private void raciRelationPalOrg(Map<String, List<DesignerShapeRelationModel>> map, String attrId, List<String> orgList, List<String> roleList) {
|
||||
if (map.containsKey(attrId)) {
|
||||
for (DesignerShapeRelationModel model : map.get(attrId)) {
|
||||
String relationFileId = model.getRelationFileId();
|
||||
String relationShapeId = model.getRelationShapeId();
|
||||
List<Map<String, Object>> relationFileElements = CoeDesignerUtil.getShapeMessageJson4(relationFileId); // 关联流程文件内容
|
||||
if (relationFileElements != null) {
|
||||
for (Map<String, Object> element : relationFileElements) {
|
||||
String id = (String) element.get("id");
|
||||
if (id.equals(relationShapeId)) {
|
||||
String type = element.get("type").toString();
|
||||
if ("organization".equals(type)) {
|
||||
orgList.add(element.get("text").toString().replace("\n", OutputWordUtil.WRAPSTRING));
|
||||
} else if ("position".equals(type) || "role".equals(type)) {
|
||||
roleList.add(element.get("text").toString().replace("\n", OutputWordUtil.WRAPSTRING));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
package com.awspaas.apps.coe.pal.output.zd.report2;
|
||||
|
||||
import com.actionsoft.bpms.commons.mvc.view.ActionWeb;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
import com.actionsoft.sdk.local.api.internal.PlatformAPIImpl;
|
||||
|
||||
/**
|
||||
* 向导收集该报告的特定选项
|
||||
*
|
||||
*/
|
||||
public class Report2WizardOption extends ActionWeb {
|
||||
|
||||
public Report2WizardOption(UserContext userContext) {
|
||||
super(userContext);
|
||||
}
|
||||
|
||||
public Report2WizardOption() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 实现约定的getOption方法
|
||||
*
|
||||
* @param teamId 小组Id
|
||||
* @param wsId 资产库Id
|
||||
* @param lang 语言
|
||||
* @param wizardJsonData 向导收集的Json参数(targetFiles、relationFiles...)
|
||||
* @return 含有回调js的html片段
|
||||
*/
|
||||
public String getOption(String teamId, String wsId, String lang, String wizardJsonData) {
|
||||
return "hi! ZD";
|
||||
}
|
||||
}
|
||||
@ -1,250 +0,0 @@
|
||||
package com.awspaas.apps.coe.pal.output.zd.report3;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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.method.model.PALMethodModel;
|
||||
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.cache.PALRepositoryCache;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryPropertyCache;
|
||||
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.system.property.CoePropertyUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
import com.actionsoft.bpms.server.fs.DCContext;
|
||||
import com.actionsoft.sdk.local.api.internal.PlatformAPIImpl;
|
||||
import com.awspaas.apps.coe.pal.output.zd.util.PrReportComment;
|
||||
|
||||
/**
|
||||
* 生成流程手册-单步骤表的入口
|
||||
*
|
||||
* @author zhangming
|
||||
*/
|
||||
public class Report3Gener {
|
||||
// 防止生成过程中,停用或卸载该app
|
||||
public static boolean isRunning = false;
|
||||
public static final Object _lock = new Object();
|
||||
GenerLogExd log = new GenerLogExd();
|
||||
public Report3Gener() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成文件
|
||||
*
|
||||
* @param model OutputTaskModel对象
|
||||
* @param wizardJsonData 向导收集的Json参数(targetFiles、relationFiles、options...)
|
||||
* @param dcContext 要生成报告的DC目录对象,已准备好
|
||||
* @return 将文件生成到output目录下,返回状态
|
||||
*
|
||||
* @see PlatformAPIImpl#getDefaultLanguage()
|
||||
* @see PlatformAPIImpl#getlanguages()
|
||||
*/
|
||||
public ResponseObject execute(OutputTaskModel model, String wizardJsonData, DCContext dcContext) {
|
||||
try {
|
||||
synchronized (_lock) {
|
||||
isRunning = true;
|
||||
String teamId = model.getTeamId();
|
||||
String wsId = model.getWsId();
|
||||
log.info("execute ready...");
|
||||
log.info("-------------------");
|
||||
log.info("TeamId=" + teamId);
|
||||
log.info("wsId=" + wsId);
|
||||
JSONObject jsonObj = JSONObject.parseObject(wizardJsonData);
|
||||
log.info("dcPath=" + dcContext.getPath());
|
||||
// ----预处理、校验----
|
||||
OutputAppProfile appModel = OutputAppManager.getProfile(model.getProfileId());
|
||||
String tempPath = appModel.getAppContext().getPath();
|
||||
//String tempName = "单步骤单表-流程手册.xml";
|
||||
String tempName = "制度-手册.xml";
|
||||
log.info("begin...");
|
||||
log.info("-------------------");
|
||||
// ----文件处理-----
|
||||
genarateWord(tempPath, tempName, dcContext.getPath(), jsonObj);
|
||||
log.info("end");
|
||||
}
|
||||
} finally {
|
||||
isRunning = false;
|
||||
}
|
||||
return ResponseObject.newOkResponse().put("logs", log.logs());
|
||||
}
|
||||
|
||||
private void genarateWord(String tempPath, String tempName, String docPath, JSONObject wizardJsonData) {
|
||||
String[] repositoryIds = wizardJsonData.getString("targetFileId").split(",");
|
||||
|
||||
String reportName = wizardJsonData.getString("reportNameIsItName"); //页面上设计的文件命名规则
|
||||
Map<String, Integer> indexMap = new HashMap<String, Integer>();
|
||||
for (String repositoryId : repositoryIds) {
|
||||
if (repositoryId == null || "".equals(repositoryId)) {
|
||||
continue;
|
||||
}
|
||||
PALRepositoryModel model = PALRepositoryCache.getCache().get(repositoryId);
|
||||
if (model != null) {
|
||||
//获取文件扩展属性
|
||||
String json = CoePropertyUtil.getPropertyValue(model.getId() + "_attr");
|
||||
JSONObject extendAttr = new JSONObject();
|
||||
if (json != null && !"".equals(json) && !"null".equals(json)) {
|
||||
JSONArray jsonArray = JSONArray.parseArray(json);
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject object = jsonArray.getJSONObject(i);
|
||||
extendAttr.put(object.getString("id"), object.get("value"));
|
||||
}
|
||||
}
|
||||
//文件的扩展属性
|
||||
List<PALRepositoryPropertyModel> repositoryPropertyList = PALRepositoryPropertyCache.getPropertyByPlId(model.getId());
|
||||
if (repositoryPropertyList != null && repositoryPropertyList.size() > 0) {
|
||||
for (PALRepositoryPropertyModel repositoryPropertyModel : repositoryPropertyList) {
|
||||
extendAttr.put(repositoryPropertyModel.getPropertyId(), repositoryPropertyModel.getPropertyValue());
|
||||
}
|
||||
}
|
||||
List<String> reportNameLabels = OutputExcelUtil.string2label(reportName);
|
||||
String reportNameValue = reportName;
|
||||
if (reportNameLabels.size() > 0) {
|
||||
reportNameValue = OutputExcelUtil.label2value(model, extendAttr, null, reportName);
|
||||
|
||||
}
|
||||
reportNameValue = reportNameValue.replaceAll(OutputExcelUtil.FILENAMEREGX, "");
|
||||
if (reportNameValue.length() > 255) {
|
||||
reportNameValue = reportNameValue.substring(0, 255);
|
||||
}
|
||||
String docName = "";
|
||||
if (indexMap.containsKey(reportNameValue)) {
|
||||
int index = indexMap.get(reportNameValue);
|
||||
index++;
|
||||
log.info("得到word名称为:" + reportNameValue + "(" + index + ")");
|
||||
docName = docPath + reportNameValue + "(" + index + ")" + ".doc";
|
||||
indexMap.put(reportNameValue, index);
|
||||
} else {
|
||||
log.info("得到word名称为:" + reportNameValue);
|
||||
docName = docPath + reportNameValue + ".doc";
|
||||
indexMap.put(reportNameValue, 1);
|
||||
}
|
||||
JSONObject dataMap = getData(repositoryId, wizardJsonData);
|
||||
if (dataMap != null) {
|
||||
OutputWordUtil.createDoc(dataMap, tempPath, tempName, docName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private JSONObject getData(String repositoryId, JSONObject wizardJsonData) {
|
||||
JSONObject dataMap = new JSONObject();
|
||||
|
||||
PrReportComment prReportComment = new PrReportComment();
|
||||
PALRepositoryModel repositoryModel = PALRepositoryCache.getCache().get(repositoryId);
|
||||
if (repositoryModel == null) {
|
||||
return null;
|
||||
}
|
||||
prReportComment.getCommentContent(dataMap, repositoryModel); // 获取一些公共的数据(手册首页的手册岗位名称、部门、时间等)
|
||||
|
||||
JSONArray repositoryShapeTable = new JSONArray(); // 流程步骤table
|
||||
|
||||
List<Map<String, Object>> repositoryFileElements = CoeDesignerUtil.getShapeMessageJson(repositoryId); // 流程文件内容
|
||||
if (wizardJsonData.getBoolean("orderNuberFirst")) {
|
||||
OutputWordUtil.orderByNumber(repositoryFileElements);
|
||||
}
|
||||
if (repositoryFileElements != null) {
|
||||
int index = 1;
|
||||
for (Map<String, Object> shape : repositoryFileElements) {
|
||||
boolean containDangerAttribute = false;
|
||||
boolean containKPIAttribute = false;
|
||||
// 如果图形元素不是流程步骤,不导出该元素
|
||||
if (PrReportComment.PROCESS_STEP.indexOf((String) shape.get("type")) == -1) {
|
||||
continue;
|
||||
}
|
||||
JSONObject _tr = new JSONObject();
|
||||
OutputWordUtil.setShapeDefaultValue(repositoryId, _tr);
|
||||
_tr.put(OutputWordUtil.SERIAL_NUMBER, index); // 序号
|
||||
_tr.put(OutputWordUtil.REPOSITORY_NAME, repositoryModel.getName().replace("\n", "")); // 流程名称
|
||||
_tr.put(OutputWordUtil.SHAPE_NAME, shape.get("text").toString().replace("\n", OutputWordUtil.WRAPSTRING)); // 步骤名称
|
||||
|
||||
JSONObject dataAttributes = (JSONObject) shape.get("attributes");
|
||||
if (dataAttributes != null) {
|
||||
_tr.put(OutputWordUtil.SHAPE_DESC, dataAttributes.get("shapeDesc")); // 工作详细描述
|
||||
JSONArray dataAttributesJsonArray = dataAttributes.getJSONArray("attributesJsonArray");
|
||||
|
||||
Map<String, String> shapeModelMap = OutputWordUtil.getShapeRelationMap((String) shape.get("id"));
|
||||
for (int i = 0; i < dataAttributesJsonArray.size(); i++) {
|
||||
JSONObject dataAttribute = dataAttributesJsonArray.getJSONObject(i);
|
||||
if (dataAttribute.containsKey("value")) {
|
||||
// 获取关联属性的属性值
|
||||
OutputWordUtil.setShapeValue(_tr, dataAttribute, shapeModelMap);
|
||||
// 判断是否包含风险属性或KPI属性
|
||||
String attributeValue = dataAttribute.getString("value");
|
||||
String attributeKey = dataAttribute.getString("key");
|
||||
if (!"".equals(attributeValue)) {
|
||||
if ("danger".equals(attributeKey)) {
|
||||
containDangerAttribute = true;
|
||||
JSONArray danger = new JSONArray();
|
||||
JSONObject danger_tr = new JSONObject();
|
||||
JSONArray dangerTable = new JSONArray();
|
||||
OutputWordUtil.setTableValue(dangerTable, attributeValue);
|
||||
danger_tr.put(OutputWordUtil.TABLE_DANGER, dangerTable);
|
||||
danger.add(danger_tr);
|
||||
_tr.put(OutputWordUtil.TABLE_DANGER, danger);
|
||||
} else if ("kpi".equals(attributeKey)) {
|
||||
containKPIAttribute = true;
|
||||
JSONArray kpi = new JSONArray();
|
||||
JSONObject kpi_tr = new JSONObject();
|
||||
JSONArray kpiTable = new JSONArray();
|
||||
OutputWordUtil.setTableValue(kpiTable, attributeValue);
|
||||
kpi_tr.put(OutputWordUtil.TABLE_KPI, kpiTable);
|
||||
kpi.add(kpi_tr);
|
||||
_tr.put(OutputWordUtil.TABLE_KPI, kpi);
|
||||
} else if ("organization".equals(dataAttribute.getString("groupPath"))) {
|
||||
OutputWordUtil.setTrValue(_tr, attributeValue, "shape_" + attributeKey, shapeModelMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!containDangerAttribute) {
|
||||
_tr.put(OutputWordUtil.TABLE_DANGER, new JSONArray());
|
||||
}
|
||||
if (!containKPIAttribute) {
|
||||
_tr.put(OutputWordUtil.TABLE_KPI, new JSONArray());
|
||||
}
|
||||
|
||||
repositoryShapeTable.add(_tr);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
dataMap.put(OutputWordUtil.TABLE_REPOSITORY_SHAPE, repositoryShapeTable);
|
||||
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
private JSONArray getEmptyTable(String methodId) {
|
||||
JSONArray table = new JSONArray();
|
||||
JSONObject _tr = new JSONObject();
|
||||
PALMethodModel palMethodModel = PALMethodCache.getPALMethodModelById(methodId);
|
||||
_tr.put(OutputWordUtil.SHAPE_NAME, "");
|
||||
_tr.put(OutputWordUtil.SHAPE_NUMBER, "");
|
||||
List<PALMethodAttributeModel> attributes = palMethodModel.getAttributes();
|
||||
if (attributes != null) {
|
||||
for (PALMethodAttributeModel attribute : attributes) {
|
||||
String scope = attribute.getScope();
|
||||
if (!"%".equals(scope)) {
|
||||
_tr.put("shape_" + attribute.getKey(), "");
|
||||
}
|
||||
}
|
||||
}
|
||||
table.add(_tr);
|
||||
return table;
|
||||
}
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
package com.awspaas.apps.coe.pal.output.zd.report3;
|
||||
|
||||
import com.actionsoft.bpms.commons.mvc.view.ActionWeb;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
import com.actionsoft.sdk.local.api.internal.PlatformAPIImpl;
|
||||
|
||||
/**
|
||||
* 向导收集该报告的特定选项
|
||||
*
|
||||
*/
|
||||
public class Report3WizardOption extends ActionWeb {
|
||||
|
||||
public Report3WizardOption(UserContext userContext) {
|
||||
super(userContext);
|
||||
}
|
||||
|
||||
public Report3WizardOption() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 实现约定的getOption方法
|
||||
*
|
||||
* @param teamId 小组Id
|
||||
* @param wsId 资产库Id
|
||||
* @param lang 语言
|
||||
* @param wizardJsonData 向导收集的Json参数(targetFiles、relationFiles...)
|
||||
* @return 含有回调js的html片段
|
||||
*/
|
||||
public String getOption(String teamId, String wsId, String lang, String wizardJsonData) {
|
||||
return "hi! ZD";
|
||||
}
|
||||
}
|
||||
@ -1,364 +0,0 @@
|
||||
package com.awspaas.apps.coe.pal.output.zd.report4;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.constant.CoEConstant;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.extend.GenerLogExd;
|
||||
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.cache.PALRepositoryCache;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryPropertyCache;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepository;
|
||||
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.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.actionsoft.apps.AppsConst;
|
||||
import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile;
|
||||
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.UtilString;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.actionsoft.sdk.local.api.AppAPI;
|
||||
import com.actionsoft.sdk.local.api.internal.PlatformAPIImpl;
|
||||
|
||||
public class Report4Gener {
|
||||
// 防止生成过程中,停用或卸载该app
|
||||
public static boolean isRunning = false;
|
||||
public static final Object _lock = new Object();
|
||||
GenerLogExd log = new GenerLogExd();
|
||||
public Report4Gener() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成文件
|
||||
*
|
||||
* @param model OutputTaskModel对象
|
||||
* @param wizardJsonData 向导收集的Json参数(targetFiles、relationFiles、options...)
|
||||
* @param dcContext 要生成报告的DC目录对象,已准备好
|
||||
* @return 将文件生成到output目录下,返回状态
|
||||
*
|
||||
* @see PlatformAPIImpl#getDefaultLanguage()
|
||||
* @see PlatformAPIImpl#getlanguages()
|
||||
*/
|
||||
public ResponseObject execute(OutputTaskModel model, String wizardJsonData, DCContext dcContext) {
|
||||
try {
|
||||
synchronized (_lock) {
|
||||
isRunning = true;
|
||||
String teamId = model.getTeamId();
|
||||
String wsId = model.getWsId();
|
||||
log.info("execute ready...");
|
||||
log.info("-------------------");
|
||||
log.info("TeamId=" + teamId);
|
||||
log.info("wsId=" + wsId);
|
||||
JSONObject jsonObj = JSONObject.parseObject(wizardJsonData);
|
||||
log.info("dcPath=" + dcContext.getPath());
|
||||
// ----预处理、校验----
|
||||
String tempId = "6a2435a5-9da1-45e5-8060-84a683041844";
|
||||
log.info("begin...");
|
||||
log.info("-------------------");
|
||||
// ----文件处理-----
|
||||
genarateWord(tempId, dcContext, jsonObj);
|
||||
log.info("end");
|
||||
}
|
||||
} finally {
|
||||
isRunning = false;
|
||||
}
|
||||
return ResponseObject.newOkResponse().put("logs", log.logs());
|
||||
}
|
||||
|
||||
private void genarateWord(String tempId, DCContext dcContext, JSONObject wizardJsonData) {
|
||||
String[] repositoryIds = wizardJsonData.getString("targetFileId").split(",");
|
||||
|
||||
String reportName = wizardJsonData.getString("reportNameIsItName"); //页面上设计的文件命名规则
|
||||
Map<String, Integer> indexMap = new HashMap<String, Integer>();
|
||||
for (String repositoryId : repositoryIds) {
|
||||
if (repositoryId == null || "".equals(repositoryId)) {
|
||||
continue;
|
||||
}
|
||||
PALRepositoryModel model = PALRepositoryCache.getCache().get(repositoryId);
|
||||
if (model == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//图形关联信息
|
||||
DesignerShapeRelationDao dao = new DesignerShapeRelationDao();
|
||||
List<DesignerShapeRelationModel> relationModels = dao.query(model.getId(), null, null, null, null);
|
||||
Map<String, String> relationValue = new HashMap<String, String>();
|
||||
if (relationModels != null && relationModels.size() > 0) {
|
||||
for (DesignerShapeRelationModel relationModel : relationModels) {
|
||||
relationValue.put(relationModel.getRelationShapeId(), relationModel.getRelationShapeText());
|
||||
}
|
||||
}
|
||||
//获取文件属性
|
||||
JSONArray dataParams = new JSONArray(); //标签数据
|
||||
JSONObject labelData1 = new JSONObject();
|
||||
labelData1.put("type", "string");
|
||||
JSONObject stringData = new JSONObject();
|
||||
int level = model.getLevel();
|
||||
if (level > 2) {
|
||||
level = level - 2;
|
||||
stringData.put("PLNAMEL" + level, model.getName());
|
||||
stringData.put("PLNO" + level, model.getNo());
|
||||
String plrp = model.getOwnerUser();
|
||||
if (!UtilString.isEmpty(plrp)) {
|
||||
plrp = relationValue.containsKey(plrp) ? relationValue.get(plrp) : "";
|
||||
}
|
||||
stringData.put("PLRP" + level, plrp);
|
||||
PALRepositoryModel parentModel = PALRepositoryCache.getCache().get(model.getParentId());
|
||||
while (level > 1 && parentModel != null) {
|
||||
level --;
|
||||
stringData.put("PLNAMEL" + level, parentModel.getName());
|
||||
stringData.put("PLNOL" + level, parentModel.getNo());
|
||||
String parentPlrp = parentModel.getOwnerUser();
|
||||
if (!UtilString.isEmpty(plrp)) {
|
||||
parentPlrp = relationValue.containsKey(parentPlrp) ? relationValue.get(parentPlrp) : "";
|
||||
}
|
||||
stringData.put("PLRPL" + level, parentPlrp);
|
||||
parentModel = PALRepositoryCache.getCache().get(parentModel.getParentId());
|
||||
}
|
||||
}
|
||||
for (int i = 0; i <= 4; i++) {
|
||||
if (!stringData.containsKey("PLNAMEL" + i)) {
|
||||
stringData.put("PLNAMEL" + i, "");
|
||||
}
|
||||
if (!stringData.containsKey("PLNO" + i)) {
|
||||
stringData.put("PLNOL" + i, "");
|
||||
}
|
||||
if (!stringData.containsKey("PLRP" + i)) {
|
||||
stringData.put("PLRPL" + i, "");
|
||||
}
|
||||
}
|
||||
|
||||
stringData.put("VERSION", model.getVersion());
|
||||
stringData.put("PLDESC", model.getDesc());
|
||||
//模型和节点的关联属性
|
||||
|
||||
String plrd = model.getOwnerDept();
|
||||
if (!UtilString.isEmpty(plrd)) {
|
||||
plrd = relationValue.containsKey(plrd) ? relationValue.get(plrd) : "";
|
||||
}
|
||||
stringData.put("PLRD", plrd);
|
||||
String plrp = model.getOwnerUser();
|
||||
if (!UtilString.isEmpty(plrp)) {
|
||||
plrp = relationValue.containsKey(plrp) ? relationValue.get(plrp) : "";
|
||||
}
|
||||
stringData.put("PLRP", plrp);
|
||||
stringData.put("PLINPUT", model.getInput());
|
||||
stringData.put("PLOUTPUT", model.getOutput());
|
||||
//文件扩展属性
|
||||
String json = CoePropertyUtil.getPropertyValue(model.getId() + "_attr");
|
||||
JSONObject extendAttr = new JSONObject();
|
||||
if (json != null && !"".equals(json) && !"null".equals(json)) {
|
||||
JSONArray jsonArray = JSONArray.parseArray(json);
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject object = jsonArray.getJSONObject(i);
|
||||
extendAttr.put(object.getString("id"), object.get("value"));
|
||||
String attributeValue = object.containsKey("value") ? object.get("value").toString() : "";
|
||||
if (attributeValue.startsWith("{")) {
|
||||
attributeValue = JSONObject.parseObject(attributeValue).getString("relationShapeText");
|
||||
}
|
||||
stringData.put(object.getString("id").toUpperCase(), attributeValue);
|
||||
}
|
||||
}
|
||||
//文件的扩展属性
|
||||
List<PALRepositoryPropertyModel> repositoryPropertyList = PALRepositoryPropertyCache.getPropertyByPlId(model.getId());
|
||||
if (repositoryPropertyList != null && repositoryPropertyList.size() > 0) {
|
||||
for (PALRepositoryPropertyModel repositoryPropertyModel : repositoryPropertyList) {
|
||||
extendAttr.put(repositoryPropertyModel.getPropertyId(), repositoryPropertyModel.getPropertyValue());
|
||||
String attributeValue = repositoryPropertyModel.getPropertyValue();
|
||||
if (attributeValue.startsWith("{")) {
|
||||
attributeValue = JSONObject.parseObject(attributeValue).getString("relationShapeText");
|
||||
}
|
||||
stringData.put(repositoryPropertyModel.getPropertyId().toUpperCase(), attributeValue);
|
||||
}
|
||||
}
|
||||
List<String> reportNameLabels = OutputExcelUtil.string2label(reportName);
|
||||
String reportNameValue = reportName;
|
||||
if (reportNameLabels.size() > 0) {
|
||||
reportNameValue = OutputExcelUtil.label2value(model, extendAttr, null, reportName);
|
||||
|
||||
}
|
||||
reportNameValue = reportNameValue.replaceAll(OutputExcelUtil.FILENAMEREGX, "");
|
||||
if (reportNameValue.length() > 255) {
|
||||
reportNameValue = reportNameValue.substring(0, 255);
|
||||
}
|
||||
String fileName = ""; //生成的文件名
|
||||
if (indexMap.containsKey(reportNameValue)) {
|
||||
int index = indexMap.get(reportNameValue);
|
||||
index++;
|
||||
log.info("得到word名称为:" + reportNameValue + "(" + index + ")");
|
||||
fileName = reportNameValue + "(" + index + ")";
|
||||
indexMap.put(reportNameValue, index);
|
||||
} else {
|
||||
log.info("得到word名称为:" + reportNameValue);
|
||||
fileName = reportNameValue;
|
||||
indexMap.put(reportNameValue, 1);
|
||||
}
|
||||
|
||||
labelData1.put("data", stringData);
|
||||
dataParams.add(labelData1);
|
||||
|
||||
//获取流程模型中的节点以及节点属性(只取有编号的)
|
||||
List<Map<String, Object>> repositoryFileElements = CoeDesignerUtil.getShapeMessageJson(repositoryId); //流程文件内容
|
||||
if (repositoryFileElements != null) {
|
||||
JSONObject labelData2 = new JSONObject();
|
||||
labelData2.put("type", "table");
|
||||
JSONArray tableData = new JSONArray();
|
||||
|
||||
//获取节点的number属性
|
||||
for (Map<String, Object> shape : repositoryFileElements) {
|
||||
if (!shape.containsKey("number")) {
|
||||
JSONObject dataAttributes = (JSONObject)shape.get("attributes");
|
||||
if (dataAttributes != null && dataAttributes.containsKey("attributesJsonArray")) {
|
||||
JSONArray privateAttributes = dataAttributes.getJSONArray("attributesJsonArray");
|
||||
for (int index = 0; index < privateAttributes.size(); index++) {
|
||||
JSONObject privateAttribute = privateAttributes.getJSONObject(index);
|
||||
if (privateAttribute.containsKey("id") && privateAttribute.getString("id").equals("number")) {
|
||||
shape.put("number", privateAttribute.getString("value"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
OutputWordUtil.orderByNumber(repositoryFileElements);
|
||||
|
||||
for (Map<String, Object> shape : repositoryFileElements) {
|
||||
String number = shape.containsKey("number") ? shape.get("number").toString() : "";
|
||||
if (UtilString.isEmpty(number)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("T-NUMBER", number);
|
||||
object.put("T-NAME", shape.get("text").toString());
|
||||
|
||||
JSONObject dataAttributes = (JSONObject)shape.get("attributes");
|
||||
if (dataAttributes != null && dataAttributes.containsKey("attributesJsonArray")) {
|
||||
object.put("T-DESC", dataAttributes.getString("shapeDesc"));
|
||||
JSONArray privateAttributes = dataAttributes.getJSONArray("attributesJsonArray");
|
||||
for (int index = 0; index < privateAttributes.size(); index++) {
|
||||
JSONObject privateAttribute = privateAttributes.getJSONObject(index);
|
||||
if (!privateAttribute.containsKey("value")) {
|
||||
continue;
|
||||
}
|
||||
String value = privateAttribute.getString("value");
|
||||
if (value.startsWith("[")) {
|
||||
value = value.replace("[", "").replace("]", "");
|
||||
String[] values = value.split(",");
|
||||
StringBuilder stmp = new StringBuilder();
|
||||
for (String tmp : values) {
|
||||
if (relationValue.containsKey(tmp)) {
|
||||
stmp.append(relationValue.get(tmp)).append(",");
|
||||
} else {
|
||||
stmp.append(tmp).append(",");
|
||||
}
|
||||
}
|
||||
value = stmp.toString();
|
||||
if (value.endsWith(",")) {
|
||||
value = value.substring(0, value.length() - 1);
|
||||
}
|
||||
}
|
||||
object.put("T-" + privateAttribute.getString("id").toUpperCase(), value);
|
||||
}
|
||||
}
|
||||
tableData.add(object);
|
||||
}
|
||||
labelData2.put("data", tableData);
|
||||
dataParams.add(labelData2);
|
||||
}
|
||||
|
||||
//流程图
|
||||
JSONObject labelData3 = new JSONObject();
|
||||
labelData3.put("type", "image");
|
||||
JSONObject image = new JSONObject();
|
||||
image.put("PL_DIAGRAM", model.getFilePath() + model.getId() + ".png");
|
||||
labelData3.put("data", image);
|
||||
dataParams.add(labelData3);
|
||||
|
||||
//版本table
|
||||
List<PALRepositoryModel> versionList = new PALRepository().getAllRepositoryByVersionId(model.getVersionId());
|
||||
JSONObject labelData4 = new JSONObject();
|
||||
labelData4.put("type", "table");
|
||||
JSONArray tableData4 = new JSONArray();
|
||||
for (PALRepositoryModel versionModel : versionList) {
|
||||
JSONObject labelData4Object = new JSONObject();
|
||||
String attrjson = CoePropertyUtil.getPropertyValue(versionModel.getId() + "_attr");
|
||||
labelData4Object.put("T-VERSION", versionModel.getVersion());
|
||||
if (!UtilString.isEmpty(attrjson)) {
|
||||
JSONArray jsonArray = JSONArray.parseArray(attrjson);
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject object = jsonArray.getJSONObject(i);
|
||||
extendAttr.put(object.getString("id"), object.get("value"));
|
||||
String attributeValue = object.containsKey("value") ? object.get("value").toString() : "";
|
||||
if (attributeValue.startsWith("{")) {
|
||||
attributeValue = JSONObject.parseObject(attributeValue).getString("relationShapeText");
|
||||
}
|
||||
labelData4Object.put("T-" + object.getString("id").toUpperCase(), attributeValue);
|
||||
}
|
||||
}
|
||||
tableData4.add(labelData4Object);
|
||||
}
|
||||
labelData4.put("data", tableData4);
|
||||
dataParams.add(labelData4);
|
||||
|
||||
String aslp = "aslp://com.actionsoft.apps.addons.docgenerator/documentGenerate";
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("sid", dcContext.getSession().getSessionId());
|
||||
params.put("gtype", "word");
|
||||
params.put("repositoryName", dcContext.getRepositoryName());
|
||||
params.put("groupValue", dcContext.getGroupValue());
|
||||
params.put("fileValue", dcContext.getFileValue());
|
||||
params.put("fileName", fileName);
|
||||
params.put("tempId", tempId);
|
||||
params.put("labelData", dataParams);
|
||||
|
||||
//流程附件信息
|
||||
StringBuilder upfileString = new StringBuilder();
|
||||
List<UpfileModel> upfiles = new UpFileDao().searchByRepositoryId(model.getId(), "f");
|
||||
if (upfiles != null && upfiles.size() > 0) {
|
||||
for (UpfileModel upfile : upfiles) {
|
||||
DCContext dcContextFile = getDCContext( UserContext.fromSessionId(dcContext.getSession().getSessionId()), upfile);
|
||||
if (dcContextFile != null) {
|
||||
upfileString.append(dcContextFile.getPath() + upfile.getFileName()).append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (upfileString.length() > 0) {
|
||||
String upfilesData = upfileString.toString();
|
||||
if (upfilesData.endsWith(",")) {
|
||||
upfilesData = upfilesData.substring(0, upfilesData.length() - 1);
|
||||
}
|
||||
params.put("upfiles", upfilesData);
|
||||
}
|
||||
|
||||
AppAPI appAPI = SDK.getAppAPI();
|
||||
ResponseObject ro = SDK.getAppAPI().callASLP(appAPI.getAppContext("com.awspaas.user.apps.coe.pal.output.zd"), aslp, params);
|
||||
}
|
||||
}
|
||||
|
||||
private DCContext getDCContext(UserContext context, UpfileModel model) {
|
||||
DCContext dcContext = null;
|
||||
DCPluginProfile dcProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, CoeFileConstant.COE_UPFILE);
|
||||
if (dcProfile != null) {
|
||||
if ("f".equals(model.getType())) {// 文件
|
||||
dcContext = new DCContext(context, dcProfile, CoEConstant.APP_ID,"file", model.getPl_uuid(), model.getFileName());
|
||||
} else {// 图形
|
||||
dcContext = new DCContext(context, dcProfile, CoEConstant.APP_ID, model.getPl_uuid(), model.getShape_uuid(), model.getFileName());
|
||||
}
|
||||
}
|
||||
return dcContext;
|
||||
}
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
package com.awspaas.apps.coe.pal.output.zd.report4;
|
||||
|
||||
import com.actionsoft.bpms.commons.mvc.view.ActionWeb;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
|
||||
public class Report4WizardOption extends ActionWeb {
|
||||
public Report4WizardOption(UserContext userContext) {
|
||||
super(userContext);
|
||||
}
|
||||
|
||||
public Report4WizardOption() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 实现约定的getOption方法
|
||||
*
|
||||
* @param teamId 小组Id
|
||||
* @param wsId 资产库Id
|
||||
* @param lang 语言
|
||||
* @param wizardJsonData 向导收集的Json参数(targetFiles、relationFiles...)
|
||||
* @return 含有回调js的html片段
|
||||
*/
|
||||
public String getOption(String teamId, String wsId, String lang, String wizardJsonData) {
|
||||
return "hi! ZD";
|
||||
}
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
package com.awspaas.apps.coe.pal.output.zd.report5;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.pal.output.extend.GenerLogExd;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
import com.actionsoft.bpms.server.fs.DCContext;
|
||||
import com.actionsoft.sdk.local.api.internal.PlatformAPIImpl;
|
||||
|
||||
public class Report5Gener {
|
||||
// 防止生成过程中,停用或卸载该app
|
||||
public static boolean isRunning = false;
|
||||
public static final Object _lock = new Object();
|
||||
GenerLogExd log = new GenerLogExd();
|
||||
public Report5Gener() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成文件
|
||||
*
|
||||
* @param model OutputTaskModel对象
|
||||
* @param wizardJsonData 向导收集的Json参数(targetFiles、relationFiles、options...)
|
||||
* @param dcContext 要生成报告的DC目录对象,已准备好
|
||||
* @return 将文件生成到output目录下,返回状态
|
||||
*
|
||||
* @see PlatformAPIImpl#getDefaultLanguage()
|
||||
* @see PlatformAPIImpl#getlanguages()
|
||||
*/
|
||||
public ResponseObject execute(OutputTaskModel model, String wizardJsonData, DCContext dcContext) {
|
||||
|
||||
return ResponseObject.newOkResponse().put("logs", log.logs());
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
package com.awspaas.apps.coe.pal.output.zd.report5;
|
||||
|
||||
import com.actionsoft.bpms.commons.mvc.view.ActionWeb;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
|
||||
public class Report5WizardOption extends ActionWeb {
|
||||
public Report5WizardOption(UserContext userContext) {
|
||||
super(userContext);
|
||||
}
|
||||
|
||||
public Report5WizardOption() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 实现约定的getOption方法
|
||||
*
|
||||
* @param teamId 小组Id
|
||||
* @param wsId 资产库Id
|
||||
* @param lang 语言
|
||||
* @param wizardJsonData 向导收集的Json参数(targetFiles、relationFiles...)
|
||||
* @return 含有回调js的html片段
|
||||
*/
|
||||
public String getOption(String teamId, String wsId, String lang, String wizardJsonData) {
|
||||
return "hi! ZD";
|
||||
}
|
||||
}
|
||||
|
||||
BIN
com.awspaas.user.apps.coe.pal.output.zd/制度-手册4.doc
Normal file
BIN
com.awspaas.user.apps.coe.pal.output.zd/制度-手册4.doc
Normal file
Binary file not shown.
6988
com.awspaas.user.apps.coe.pal.output.zd/制度-手册4.xml
Normal file
6988
com.awspaas.user.apps.coe.pal.output.zd/制度-手册4.xml
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user