制度手册代码提交
This commit is contained in:
parent
856ddc6b07
commit
215d52de8e
BIN
com.awspaas.user.apps.coe.pal.output.zd/lib/Spire.Doc.jar
Normal file
BIN
com.awspaas.user.apps.coe.pal.output.zd/lib/Spire.Doc.jar
Normal file
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -22,146 +22,171 @@ import com.alibaba.fastjson.JSONObject;
|
||||
*/
|
||||
@Controller
|
||||
public class ReportPrController {
|
||||
/**
|
||||
* 报告下载
|
||||
*
|
||||
* @param me
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.awspaas.user.apps.coe.pal.output.zd_downloadreport")
|
||||
public String downloadReport(UserContext me, String id) {
|
||||
OutputTaskModel model = new OutputTask().getTaskReportById(id);
|
||||
ResponseObject ro = null;
|
||||
JSONObject json = new JSONObject();
|
||||
if (model != null) {
|
||||
//三员管理,步骤横表下载重新生成手册
|
||||
if (HighSecurityUtil.isON()){
|
||||
//流程文件密级switch开启,密级权限校验
|
||||
if (HighSecurityUtil.fileSecuritySwitch()){
|
||||
ResponseObject securityPermission = PALRepositoryQueryAPIManager.getInstance().checkOutputSecurityPermission(me, model);
|
||||
if (securityPermission.isErr()){
|
||||
return securityPermission.toString();
|
||||
}
|
||||
}
|
||||
String taskName = model.getTaskName();
|
||||
if ("步骤横表".equals(taskName)){
|
||||
// 重新设置生成id,与用户id
|
||||
String uuid = UUIDGener.getUUID();
|
||||
model.setUserId(me.getUID());
|
||||
/**
|
||||
* 报告下载
|
||||
*
|
||||
* @param me
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.awspaas.user.apps.coe.pal.output.zd_downloadreport")
|
||||
public String downloadReport(UserContext me, String id) {
|
||||
OutputTaskModel model = new OutputTask().getTaskReportById(id);
|
||||
ResponseObject ro = null;
|
||||
JSONObject json = new JSONObject();
|
||||
if (model != null) {
|
||||
//三员管理,步骤横表下载重新生成手册
|
||||
if (HighSecurityUtil.isON()) {
|
||||
//流程文件密级switch开启,密级权限校验
|
||||
if (HighSecurityUtil.fileSecuritySwitch()) {
|
||||
ResponseObject securityPermission = PALRepositoryQueryAPIManager.getInstance().checkOutputSecurityPermission(me, model);
|
||||
if (securityPermission.isErr()) {
|
||||
return securityPermission.toString();
|
||||
}
|
||||
}
|
||||
String taskName = model.getTaskName();
|
||||
if ("步骤横表".equals(taskName)) {
|
||||
// 重新设置生成id,与用户id
|
||||
String uuid = UUIDGener.getUUID();
|
||||
model.setUserId(me.getUID());
|
||||
|
||||
// 重新生成手册文件
|
||||
OutputAPIManager.getInstance().reGennerReport(me,model,uuid);
|
||||
// 重新生成手册文件
|
||||
OutputAPIManager.getInstance().reGennerReport(me, model, uuid);
|
||||
|
||||
// 重新构建手册下载URL
|
||||
id = uuid;
|
||||
}
|
||||
}
|
||||
try {
|
||||
ro = ResponseObject.newOkResponse();
|
||||
json.put("url", OutputDCFileProcessor.getReportDownloadURL(model.getWsId(), id, model.getProfileId(), me, model.getTaskName()));
|
||||
ro.setData(json);
|
||||
} catch (Exception e) {
|
||||
ro = ResponseObject.newErrResponse();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return ro.toString();
|
||||
}
|
||||
// 重新构建手册下载URL
|
||||
id = uuid;
|
||||
}
|
||||
}
|
||||
try {
|
||||
ro = ResponseObject.newOkResponse();
|
||||
json.put("url", OutputDCFileProcessor.getReportDownloadURL(model.getWsId(), id, model.getProfileId(), me, model.getTaskName()));
|
||||
ro.setData(json);
|
||||
} catch (Exception e) {
|
||||
ro = ResponseObject.newErrResponse();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return ro.toString();
|
||||
}
|
||||
|
||||
/*
|
||||
* 预览报告
|
||||
* @param me
|
||||
* @param wsid
|
||||
* */
|
||||
@Mapping("com.awspaas.user.apps.coe.pal.output.zd_previewreport")
|
||||
public String previewReport(UserContext me, String id) {
|
||||
OutputTaskModel model = new OutputTask().getTaskReportById(id);
|
||||
ResponseObject rs = ResponseObject.newOkResponse();
|
||||
if (model != null) {
|
||||
//三员管理,流程文件密级switch开启,密级权限校验
|
||||
if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()){
|
||||
ResponseObject securityPermission = PALRepositoryQueryAPIManager.getInstance().checkOutputSecurityPermission(me, model);
|
||||
if (securityPermission.isErr()){
|
||||
return securityPermission.toString();
|
||||
}
|
||||
}
|
||||
try {
|
||||
return OutputDCFileProcessor.doPreviewReport(model.getWsId(), id, model.getProfileId(), me);
|
||||
} catch (Exception e) {
|
||||
rs = ResponseObject.newErrResponse();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return rs.toString();
|
||||
}
|
||||
/*
|
||||
* 预览报告
|
||||
* @param me
|
||||
* @param wsid
|
||||
* */
|
||||
@Mapping("com.awspaas.user.apps.coe.pal.output.zd_previewreport")
|
||||
public String previewReport(UserContext me, String id) {
|
||||
OutputTaskModel model = new OutputTask().getTaskReportById(id);
|
||||
ResponseObject rs = ResponseObject.newOkResponse();
|
||||
if (model != null) {
|
||||
//三员管理,流程文件密级switch开启,密级权限校验
|
||||
if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()) {
|
||||
ResponseObject securityPermission = PALRepositoryQueryAPIManager.getInstance().checkOutputSecurityPermission(me, model);
|
||||
if (securityPermission.isErr()) {
|
||||
return securityPermission.toString();
|
||||
}
|
||||
}
|
||||
try {
|
||||
return OutputDCFileProcessor.doPreviewReport(model.getWsId(), id, model.getProfileId(), me);
|
||||
} catch (Exception e) {
|
||||
rs = ResponseObject.newErrResponse();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return rs.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 日志下载
|
||||
*
|
||||
* @param me
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.awspaas.user.apps.coe.pal.output.zd_downloadlog")
|
||||
public String downloadLog(UserContext me, String id) {
|
||||
OutputTaskModel model = new OutputTask().getTaskReportById(id);
|
||||
ResponseObject ro = null;
|
||||
JSONObject json = new JSONObject();
|
||||
if (model != null) {
|
||||
//三员管理,流程文件密级switch开启,密级权限校验
|
||||
if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()){
|
||||
ResponseObject securityPermission = PALRepositoryQueryAPIManager.getInstance().checkOutputSecurityPermission(me, model);
|
||||
if (securityPermission.isErr()){
|
||||
return securityPermission.toString();
|
||||
}
|
||||
}
|
||||
try {
|
||||
ro = ResponseObject.newOkResponse();
|
||||
json.put("url", OutputDCFileProcessor.getReportLogDownloadURL(model.getWsId(), id, model.getProfileId(), me, model.getTaskName()));
|
||||
ro.setData(json);
|
||||
} catch (Exception e) {
|
||||
ro = ResponseObject.newErrResponse();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return ro.toString();
|
||||
}
|
||||
/**
|
||||
* 日志下载
|
||||
*
|
||||
* @param me
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.awspaas.user.apps.coe.pal.output.zd_downloadlog")
|
||||
public String downloadLog(UserContext me, String id) {
|
||||
OutputTaskModel model = new OutputTask().getTaskReportById(id);
|
||||
ResponseObject ro = null;
|
||||
JSONObject json = new JSONObject();
|
||||
if (model != null) {
|
||||
//三员管理,流程文件密级switch开启,密级权限校验
|
||||
if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()) {
|
||||
ResponseObject securityPermission = PALRepositoryQueryAPIManager.getInstance().checkOutputSecurityPermission(me, model);
|
||||
if (securityPermission.isErr()) {
|
||||
return securityPermission.toString();
|
||||
}
|
||||
}
|
||||
try {
|
||||
ro = ResponseObject.newOkResponse();
|
||||
json.put("url", OutputDCFileProcessor.getReportLogDownloadURL(model.getWsId(), id, model.getProfileId(), me, model.getTaskName()));
|
||||
ro.setData(json);
|
||||
} catch (Exception e) {
|
||||
ro = ResponseObject.newErrResponse();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return ro.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 报告克隆
|
||||
*
|
||||
* @param me
|
||||
* @param teamId
|
||||
* @param wsid
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.awspaas.user.apps.coe.pal.output.zd_clonetask")
|
||||
public String cloneTask(UserContext me, String id, String teamId, String wsid) {
|
||||
ResponseObject ro = null;
|
||||
//三员管理,流程文件密级switch开启,密级权限校验
|
||||
if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()) {
|
||||
OutputTaskModel model = new OutputTask().getTaskReportById(id);
|
||||
if (null != model) {
|
||||
ResponseObject securityPermission = PALRepositoryQueryAPIManager.getInstance().checkOutputSecurityPermission(me, model);
|
||||
if (securityPermission.isErr()) {
|
||||
return securityPermission.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
OutputAPIManager.getInstance().cloneTask(me.getUID(), id);
|
||||
OutPutReportWeb outPutReport = new OutPutReportWeb(me);
|
||||
int total = outPutReport.getCountTotal(wsid, teamId);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("totalPage", total);
|
||||
ro = ResponseObject.newOkResponse();
|
||||
ro.setData(json);
|
||||
} catch (Exception e) {
|
||||
ro = ResponseObject.newErrResponse();
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ro.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 制度手册正文导出
|
||||
*
|
||||
* @param me
|
||||
* @param teamId
|
||||
* @param wsid
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.awspaas.user.apps.coe.pal.output.zd_systemManualTextExport")
|
||||
public String systemManualTextExport(UserContext me, String id, String teamId, String wsid) {
|
||||
ResponseObject ro = null;
|
||||
try {
|
||||
ro = ResponseObject.newOkResponse();
|
||||
InstitutionalTextWeb institutionalTextWeb = new InstitutionalTextWeb(me);
|
||||
institutionalTextWeb.systemManualTextExport();
|
||||
} catch (Exception e) {
|
||||
ro = ResponseObject.newErrResponse();
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ro.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 报告克隆
|
||||
*
|
||||
* @param me
|
||||
* @param teamId
|
||||
* @param wsid
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.awspaas.user.apps.coe.pal.output.zd_clonetask")
|
||||
public String cloneTask(UserContext me, String id, String teamId, String wsid) {
|
||||
ResponseObject ro = null;
|
||||
//三员管理,流程文件密级switch开启,密级权限校验
|
||||
if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()){
|
||||
OutputTaskModel model = new OutputTask().getTaskReportById(id);
|
||||
if (null != model){
|
||||
ResponseObject securityPermission = PALRepositoryQueryAPIManager.getInstance().checkOutputSecurityPermission(me, model);
|
||||
if (securityPermission.isErr()){
|
||||
return securityPermission.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
OutputAPIManager.getInstance().cloneTask(me.getUID(), id);
|
||||
OutPutReportWeb outPutReport = new OutPutReportWeb(me);
|
||||
int total = outPutReport.getCountTotal(wsid, teamId);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("totalPage", total);
|
||||
ro = ResponseObject.newOkResponse();
|
||||
ro.setData(json);
|
||||
} catch (Exception e) {
|
||||
ro = ResponseObject.newErrResponse();
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ro.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,28 +1,5 @@
|
||||
package com.awspaas.apps.coe.pal.output.zd.report1;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentException;
|
||||
import org.dom4j.Element;
|
||||
|
||||
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.extend.OutputAppManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppProfile;
|
||||
@ -32,35 +9,25 @@ 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.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.commons.mvc.view.ResponseObject;
|
||||
import com.actionsoft.bpms.server.DispatcherRequest;
|
||||
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.DBSql;
|
||||
import com.actionsoft.bpms.util.UtilDate;
|
||||
import com.actionsoft.bpms.util.UtilFile;
|
||||
import com.actionsoft.bpms.util.UtilString;
|
||||
import com.actionsoft.exception.AWSQuotaException;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.actionsoft.sdk.local.api.internal.PlatformAPIImpl;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.awspaas.apps.coe.pal.output.zd.util.PrReportComment;
|
||||
import com.awspaas.apps.coe.pal.output.zd.util.ReportRepositoryCompare;
|
||||
import com.awspaas.apps.coe.pal.output.zd.util.XMLUtil;
|
||||
import com.spire.doc.FileFormat;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
|
||||
import static com.actionsoft.apps.coe.pal.pal.output.util.OutputWordUtil.specialCharTransfer;
|
||||
|
||||
@ -70,252 +37,256 @@ import static com.actionsoft.apps.coe.pal.pal.output.util.OutputWordUtil.special
|
||||
* @author zhangming
|
||||
*/
|
||||
public class Report1Gener {
|
||||
// 防止生成过程中,停用或卸载该app
|
||||
public static boolean isRunning = false;
|
||||
public static final Object _lock = new Object();
|
||||
private UserContext userContext = null;
|
||||
GenerLogExd log = new GenerLogExd();
|
||||
//word换行符
|
||||
private final String WRAPSTRING = "</w:t></w:r></w:p><w:p><w:pPr><w:keepNext w:val=\"off\"/><w:keepLines w:val=\"off\"/><w:pageBreakBefore w:val=\"off\"/><w:widowControl/><w:kinsoku/><w:wordWrap/><w:overflowPunct/><w:topLinePunct w:val=\"off\"/><w:autoSpaceDE/><w:autoSpaceDN/><w:adjustRightInd/><w:snapToGrid/><w:spacing w:line=\"240\" w:line-rule=\"auto\"/><w:ind w:left=\"0\" w:right=\"0\" w:right-chars=\"0\" w:first-line=\"0\" w:first-line-chars=\"0\"/><w:jc w:val=\"both\"/><w:textAlignment w:val=\"auto\"/><w:outlineLvl w:val=\"9\"/><w:rPr><w:rFonts w:ascii=\"宋体\" w:h-ansi=\"宋体\" w:fareast=\"宋体\" w:cs=\"宋体\" w:hint=\"fareast\"/><w:color w:val=\"auto\"/><w:sz w:val=\"21\"/><w:sz-cs w:val=\"21\"/><w:lang w:val=\"EN-US\"/></w:rPr></w:pPr><w:r><w:rPr><w:rFonts w:ascii=\"宋体\" w:h-ansi=\"宋体\" w:fareast=\"宋体\" w:cs=\"宋体\" w:hint=\"fareast\"/><w:color w:val=\"auto\"/><w:sz w:val=\"21\"/><w:sz-cs w:val=\"21\"/><w:lang w:val=\"EN-US\"/></w:rPr><w:t>";
|
||||
// 防止生成过程中,停用或卸载该app
|
||||
public static boolean isRunning = false;
|
||||
public static final Object _lock = new Object();
|
||||
private UserContext userContext = null;
|
||||
GenerLogExd log = new GenerLogExd();
|
||||
//word换行符
|
||||
private final String WRAPSTRING = "</w:t></w:r></w:p><w:p><w:pPr><w:keepNext w:val=\"off\"/><w:keepLines w:val=\"off\"/><w:pageBreakBefore w:val=\"off\"/><w:widowControl/><w:kinsoku/><w:wordWrap/><w:overflowPunct/><w:topLinePunct w:val=\"off\"/><w:autoSpaceDE/><w:autoSpaceDN/><w:adjustRightInd/><w:snapToGrid/><w:spacing w:line=\"240\" w:line-rule=\"auto\"/><w:ind w:left=\"0\" w:right=\"0\" w:right-chars=\"0\" w:first-line=\"0\" w:first-line-chars=\"0\"/><w:jc w:val=\"both\"/><w:textAlignment w:val=\"auto\"/><w:outlineLvl w:val=\"9\"/><w:rPr><w:rFonts w:ascii=\"宋体\" w:h-ansi=\"宋体\" w:fareast=\"宋体\" w:cs=\"宋体\" w:hint=\"fareast\"/><w:color w:val=\"auto\"/><w:sz w:val=\"21\"/><w:sz-cs w:val=\"21\"/><w:lang w:val=\"EN-US\"/></w:rPr></w:pPr><w:r><w:rPr><w:rFonts w:ascii=\"宋体\" w:h-ansi=\"宋体\" w:fareast=\"宋体\" w:cs=\"宋体\" w:hint=\"fareast\"/><w:color w:val=\"auto\"/><w:sz w:val=\"21\"/><w:sz-cs w:val=\"21\"/><w:lang w:val=\"EN-US\"/></w:rPr><w:t>";
|
||||
|
||||
public Report1Gener() {
|
||||
}
|
||||
public Report1Gener() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成文件
|
||||
*
|
||||
* @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) throws FileNotFoundException {
|
||||
try {
|
||||
// synchronized (_lock) {
|
||||
// isRunning = true;
|
||||
// userContext = UserContext.fromUID(model.getUserId());
|
||||
userContext = DispatcherRequest.getUserContext();
|
||||
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 = "制度-手册5.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());
|
||||
}
|
||||
/**
|
||||
* 生成文件
|
||||
*
|
||||
* @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) throws FileNotFoundException {
|
||||
try {
|
||||
// synchronized (_lock) {
|
||||
// isRunning = true;
|
||||
// userContext = UserContext.fromUID(model.getUserId());
|
||||
userContext = DispatcherRequest.getUserContext();
|
||||
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 = "制度-手册5.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());
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建word
|
||||
* @param tempPath
|
||||
* @param tempName
|
||||
* @param docPath
|
||||
* @param wizardJsonData
|
||||
*/
|
||||
private void genarateWord(String tempPath, String tempName, String docPath, JSONObject wizardJsonData) throws FileNotFoundException {
|
||||
String[] repositoryIds = wizardJsonData.getString("targetFileId").split(",");
|
||||
/**
|
||||
* 创建word
|
||||
*
|
||||
* @param tempPath
|
||||
* @param tempName
|
||||
* @param docPath
|
||||
* @param wizardJsonData
|
||||
*/
|
||||
private void genarateWord(String tempPath, String tempName, String docPath, JSONObject wizardJsonData) throws FileNotFoundException {
|
||||
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 = PALRepositoryQueryAPIManager.getInstance().queryPalRepositoryModelByPalId(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) {
|
||||
if ("P_versions".equals(repositoryPropertyModel.getPropertyId())){
|
||||
String plvers = model.getVersion()+"";
|
||||
String plver = "";
|
||||
if (!"".equals(plvers)) {
|
||||
if (plvers.length() > 1) {
|
||||
plver = plvers.substring(0, 1) + "."
|
||||
+ plvers.substring(plvers.length() - 1, plvers.length());
|
||||
} else {
|
||||
plver = plvers.substring(0, 1) + ".0";
|
||||
}
|
||||
}
|
||||
extendAttr.put(repositoryPropertyModel.getPropertyId(), "V"+plver);
|
||||
}else {
|
||||
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);
|
||||
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 = PALRepositoryQueryAPIManager.getInstance().queryPalRepositoryModelByPalId(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) {
|
||||
if ("P_versions".equals(repositoryPropertyModel.getPropertyId())) {
|
||||
String plvers = model.getVersion() + "";
|
||||
String plver = "";
|
||||
if (!"".equals(plvers)) {
|
||||
if (plvers.length() > 1) {
|
||||
plver = plvers.substring(0, 1) + "."
|
||||
+ plvers.substring(plvers.length() - 1, plvers.length());
|
||||
} else {
|
||||
plver = plvers.substring(0, 1) + ".0";
|
||||
}
|
||||
}
|
||||
extendAttr.put(repositoryPropertyModel.getPropertyId(), "V" + plver);
|
||||
} else {
|
||||
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 = "";
|
||||
String fileName = "";
|
||||
if (indexMap.containsKey(reportNameValue)) {
|
||||
int index = indexMap.get(reportNameValue);
|
||||
index++;
|
||||
fileName = reportNameValue + "(" + index + ")";
|
||||
log.info("得到word名称为:" + fileName);
|
||||
docName = docPath + fileName + ".doc";
|
||||
indexMap.put(reportNameValue, index);
|
||||
} else {
|
||||
fileName = reportNameValue;
|
||||
log.info("得到word名称为:" + fileName);
|
||||
docName = docPath + fileName + ".doc";
|
||||
indexMap.put(fileName, 1);
|
||||
}
|
||||
JSONObject dataMap = getData2(repositoryId, wizardJsonData, docPath, fileName);
|
||||
if (dataMap != null) {
|
||||
OutputWordUtil.createZdDoc2(dataMap, tempPath, tempName, docName,wizardJsonData, repositoryId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
reportNameValue = reportNameValue.replaceAll(OutputExcelUtil.FILENAMEREGX, "");
|
||||
if (reportNameValue.length() > 255) {
|
||||
reportNameValue = reportNameValue.substring(0, 255);
|
||||
}
|
||||
String docName = "";
|
||||
String fileName = "";
|
||||
if (indexMap.containsKey(reportNameValue)) {
|
||||
int index = indexMap.get(reportNameValue);
|
||||
index++;
|
||||
fileName = reportNameValue + "(" + index + ")";
|
||||
log.info("得到word名称为:" + fileName);
|
||||
docName = docPath + fileName + ".doc";
|
||||
indexMap.put(reportNameValue, index);
|
||||
} else {
|
||||
fileName = reportNameValue;
|
||||
log.info("得到word名称为:" + fileName);
|
||||
docName = docPath + fileName + ".doc";
|
||||
indexMap.put(fileName, 1);
|
||||
}
|
||||
JSONObject dataMap = getData2(repositoryId, wizardJsonData, docPath, fileName);
|
||||
if (dataMap != null) {
|
||||
OutputWordUtil.createDoc2(dataMap, tempPath, tempName, docName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文档数据
|
||||
* @param repositoryId
|
||||
* @param wizardJsonData
|
||||
* @return
|
||||
*/
|
||||
private JSONObject getData2(String repositoryId, JSONObject wizardJsonData, String docPath, String fileName) {
|
||||
JSONObject dataMap = new JSONObject();
|
||||
dataMap.put("organizationType", "涉及部门及岗位\\角色");
|
||||
boolean raciRelationType = SDK.getAppAPI().getPropertyBooleanValue("com.awspaas.user.apps.coe.pal.output.zd", "DETY_POSITION_ROLE_RELATION_TYPE", false);
|
||||
/**
|
||||
* 获取文档数据
|
||||
*
|
||||
* @param repositoryId
|
||||
* @param wizardJsonData
|
||||
* @return
|
||||
*/
|
||||
private JSONObject getData2(String repositoryId, JSONObject wizardJsonData, String docPath, String fileName) {
|
||||
JSONObject dataMap = new JSONObject();
|
||||
dataMap.put("organizationType", "涉及部门及岗位\\角色");
|
||||
boolean raciRelationType = SDK.getAppAPI().getPropertyBooleanValue("com.awspaas.user.apps.coe.pal.output.zd", "DETY_POSITION_ROLE_RELATION_TYPE", false);
|
||||
|
||||
// 记录关联属性的流程节点,防止多次查询重复文件信息耗费时间
|
||||
Set<String> relationFileIds = new HashSet<>();
|
||||
Map<String, Map<String, Object>> relationFileMap = new HashMap<>();
|
||||
// 记录关联属性的流程节点,防止多次查询重复文件信息耗费时间
|
||||
Set<String> relationFileIds = new HashSet<>();
|
||||
Map<String, Map<String, Object>> relationFileMap = new HashMap<>();
|
||||
|
||||
PrReportComment prReportComment = new PrReportComment();
|
||||
PALRepositoryModel repositoryModel = PALRepositoryQueryAPIManager.getInstance().queryPalRepositoryModelByPalId(repositoryId);
|
||||
if (repositoryModel == null) {
|
||||
return null;
|
||||
}
|
||||
PrReportComment prReportComment = new PrReportComment();
|
||||
PALRepositoryModel repositoryModel = PALRepositoryQueryAPIManager.getInstance().queryPalRepositoryModelByPalId(repositoryId);
|
||||
if (repositoryModel == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
prReportComment.getCommentContent(dataMap, repositoryModel); // 获取一些公共的数据(手册首页的手册岗位名称、部门、时间等)
|
||||
prReportComment.getCommentContent(dataMap, repositoryModel); // 获取一些公共的数据(手册首页的手册岗位名称、部门、时间等)
|
||||
|
||||
ReportRepositoryCompare compare = new ReportRepositoryCompare();
|
||||
JSONArray historyVersionModify = compare.getModifyVersionHistory(repositoryId);
|
||||
dataMap.put("history_table", historyVersionModify);
|
||||
ReportRepositoryCompare compare = new ReportRepositoryCompare();
|
||||
JSONArray historyVersionModify = compare.getModifyVersionHistory(repositoryId);
|
||||
dataMap.put("history_table", historyVersionModify);
|
||||
|
||||
// 修订记录
|
||||
dataMap.put("version_history_table", getVersionHistoryTable(repositoryModel));
|
||||
// 修订记录
|
||||
dataMap.put("version_history_table", getVersionHistoryTable(repositoryModel));
|
||||
|
||||
return dataMap;
|
||||
}
|
||||
public static boolean isNumeric(String str) {
|
||||
for (int i = str.length(); --i >= 0;) {
|
||||
int chr = str.charAt(i);
|
||||
if (chr < 48 || chr > 57)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* 修订记录
|
||||
* @param repositoryModel
|
||||
* @return
|
||||
*/
|
||||
private JSONArray getVersionHistoryTable(PALRepositoryModel repositoryModel) {
|
||||
JSONArray versionHistoryTable = new JSONArray();// 修订记录
|
||||
List<PALRepositoryModel> list = PALRepositoryCache.getByVersionId(repositoryModel.getVersionId());
|
||||
list.sort((m1, m2)-> {
|
||||
return m1.getVersion() - m2.getVersion() > 0 ? 1 : -1;
|
||||
});
|
||||
for (PALRepositoryModel model : list) {
|
||||
if(model.getVersion()>repositoryModel.getVersion()) {
|
||||
continue;
|
||||
}
|
||||
JSONObject obj = new JSONObject();
|
||||
Map<String, JSONObject> map = PALRepositoryQueryAPIManager.queryRepositoryAttributeById(model.getId());
|
||||
// 版本P_versions,制度用的是versions
|
||||
String attr = "versions";
|
||||
String val = "";
|
||||
String plvers = model.getVersion()+"";
|
||||
String plver = "";
|
||||
if (!"".equals(plvers)) {
|
||||
if (plvers.length() > 1) {
|
||||
plver = plvers.substring(0, 1) + "."
|
||||
+ plvers.substring(plvers.length() - 1, plvers.length());
|
||||
} else {
|
||||
plver = plvers.substring(0, 1) + ".0";
|
||||
}
|
||||
}
|
||||
//val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING);
|
||||
obj.put(attr, "V"+plver);
|
||||
// 拟制/修订单位Issuing_department
|
||||
attr = "Issuing_department";
|
||||
val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING);
|
||||
obj.put(attr, val);
|
||||
// 拟制/修订人Drafted_and_revised_by
|
||||
attr = "Drafted_and_revised_by";
|
||||
val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING);
|
||||
obj.put(attr, val);
|
||||
// 拟制/修订日期Drafted_and_revised_date
|
||||
attr = "Drafted_and_revised_date";
|
||||
val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING);
|
||||
if (UtilString.isNotEmpty(val)) {
|
||||
try {
|
||||
Timestamp timestamp = UtilDate.parseTsFromDateTime(val);
|
||||
val = UtilDate.yearFormat(timestamp) + "年" + Integer.parseInt(UtilDate.monthFormat(timestamp)) + "月" + UtilDate.dayFormat(timestamp) + "日";
|
||||
} catch (Exception e) {
|
||||
//e.printStackTrace();
|
||||
}
|
||||
}
|
||||
obj.put(attr, val);
|
||||
// 审核人auditor
|
||||
attr = "auditor";
|
||||
val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING);
|
||||
obj.put(attr, val);
|
||||
// 复核人reviewer
|
||||
attr = "reviewer";
|
||||
val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING);
|
||||
obj.put(attr, val);
|
||||
// 审批人approver
|
||||
attr = "approver";
|
||||
val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING);
|
||||
obj.put(attr, val);
|
||||
// 修订内容及理由Contents_and_reasons_for_revision
|
||||
attr = "Contents_and_reasons_for_revision";
|
||||
val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING);
|
||||
obj.put(attr, val);
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
versionHistoryTable.add(obj);
|
||||
}
|
||||
return versionHistoryTable;
|
||||
}
|
||||
public static boolean isNumeric(String str) {
|
||||
for (int i = str.length(); --i >= 0; ) {
|
||||
int chr = str.charAt(i);
|
||||
if (chr < 48 || chr > 57)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修订记录
|
||||
*
|
||||
* @param repositoryModel
|
||||
* @return
|
||||
*/
|
||||
private JSONArray getVersionHistoryTable(PALRepositoryModel repositoryModel) {
|
||||
JSONArray versionHistoryTable = new JSONArray();// 修订记录
|
||||
List<PALRepositoryModel> list = PALRepositoryCache.getByVersionId(repositoryModel.getVersionId());
|
||||
list.sort((m1, m2) -> {
|
||||
return m1.getVersion() - m2.getVersion() > 0 ? 1 : -1;
|
||||
});
|
||||
for (PALRepositoryModel model : list) {
|
||||
if (model.getVersion() > repositoryModel.getVersion()) {
|
||||
continue;
|
||||
}
|
||||
JSONObject obj = new JSONObject();
|
||||
Map<String, JSONObject> map = PALRepositoryQueryAPIManager.queryRepositoryAttributeById(model.getId());
|
||||
// 版本P_versions,制度用的是versions
|
||||
String attr = "versions";
|
||||
String val = "";
|
||||
String plvers = model.getVersion() + "";
|
||||
String plver = "";
|
||||
if (!"".equals(plvers)) {
|
||||
if (plvers.length() > 1) {
|
||||
plver = plvers.substring(0, 1) + "."
|
||||
+ plvers.substring(plvers.length() - 1, plvers.length());
|
||||
} else {
|
||||
plver = plvers.substring(0, 1) + ".0";
|
||||
}
|
||||
}
|
||||
//val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING);
|
||||
obj.put(attr, "V" + plver);
|
||||
// 拟制/修订单位Issuing_department
|
||||
attr = "Issuing_department";
|
||||
val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING);
|
||||
obj.put(attr, val);
|
||||
// 拟制/修订人Drafted_and_revised_by
|
||||
attr = "Drafted_and_revised_by";
|
||||
val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING);
|
||||
obj.put(attr, val);
|
||||
// 拟制/修订日期Drafted_and_revised_date
|
||||
attr = "Drafted_and_revised_date";
|
||||
val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING);
|
||||
if (UtilString.isNotEmpty(val)) {
|
||||
try {
|
||||
Timestamp timestamp = UtilDate.parseTsFromDateTime(val);
|
||||
val = UtilDate.yearFormat(timestamp) + "年" + Integer.parseInt(UtilDate.monthFormat(timestamp)) + "月" + UtilDate.dayFormat(timestamp) + "日";
|
||||
} catch (Exception e) {
|
||||
//e.printStackTrace();
|
||||
}
|
||||
}
|
||||
obj.put(attr, val);
|
||||
// 审核人auditor
|
||||
attr = "auditor";
|
||||
val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING);
|
||||
obj.put(attr, val);
|
||||
// 复核人reviewer
|
||||
attr = "reviewer";
|
||||
val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING);
|
||||
obj.put(attr, val);
|
||||
// 审批人approver
|
||||
attr = "approver";
|
||||
val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING);
|
||||
obj.put(attr, val);
|
||||
// 修订内容及理由Contents_and_reasons_for_revision
|
||||
attr = "Contents_and_reasons_for_revision";
|
||||
val = specialCharTransfer(map.containsKey(attr) ? (map.get(attr).getString("text")) : "").replace("\n", WRAPSTRING);
|
||||
obj.put(attr, val);
|
||||
|
||||
versionHistoryTable.add(obj);
|
||||
}
|
||||
return versionHistoryTable;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BIN
com.awspaas.user.apps.coe.pal.output.zd/制度-手册6.doc
Normal file
BIN
com.awspaas.user.apps.coe.pal.output.zd/制度-手册6.doc
Normal file
Binary file not shown.
3361
com.awspaas.user.apps.coe.pal.output.zd/制度-手册6.xml
Normal file
3361
com.awspaas.user.apps.coe.pal.output.zd/制度-手册6.xml
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user