管理版本插入位置问题修改|oa审批wps代码、生成手册代码提交
This commit is contained in:
parent
fc68390288
commit
a394a1c2d5
Binary file not shown.
@ -3,6 +3,9 @@ package com.actionsoft.apps.coe.pal.output.pr.report1;
|
||||
import static com.actionsoft.apps.coe.pal.pal.output.util.OutputWordUtil.specialCharTransfer;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
@ -107,7 +110,28 @@ public class Report1Gener {
|
||||
OutputAppProfile appModel = OutputAppManager.getProfile(model.getProfileId());
|
||||
String tempPath = appModel.getAppContext().getPath();
|
||||
//String tempName = "步骤横表-流程手册.xml";
|
||||
String tempName = "步骤横表-流程手册4.xml";
|
||||
|
||||
|
||||
//增加判断文件类型逻辑,因为可能有多个,取其中第一个文件,判断文件类型
|
||||
String targetFileId = "";
|
||||
String[] targetFileIds = jsonObj.getString("targetFileId").split(",");
|
||||
for (String fileId : targetFileIds) {
|
||||
if(UtilString.isNotEmpty(fileId)){
|
||||
targetFileId = fileId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String tempName;
|
||||
String methodId=PALRepositoryCache.getCache().get(targetFileId).getMethodId();
|
||||
if(methodId.equals("process.oaApprove")){
|
||||
tempName = "步骤横表-流程手册5.xml";
|
||||
}else {
|
||||
tempName = "步骤横表-流程手册4.xml";
|
||||
}
|
||||
|
||||
|
||||
log.info("begin...");
|
||||
log.info("-------------------");
|
||||
// ----文件处理-----
|
||||
@ -144,6 +168,8 @@ public class Report1Gener {
|
||||
if(repositoryModel1.getMethodId().equals("process.framework")){
|
||||
continue;
|
||||
}
|
||||
|
||||
String methodId=repositoryModel1.getMethodId();
|
||||
PALRepositoryModel model = PALRepositoryQueryAPIManager.getInstance().queryPalRepositoryModelByPalId(repositoryId);
|
||||
if (model != null) {
|
||||
//获取文件扩展属性
|
||||
@ -195,11 +221,21 @@ public class Report1Gener {
|
||||
}
|
||||
JSONObject dataMap = getData(repositoryId, wizardJsonData, docPath, fileName);
|
||||
if (dataMap != null) {
|
||||
if(methodId.equals("process.oaApprove")){
|
||||
OutputWordUtil.createOAApproveDoc(dataMap, tempPath, tempName, docName, repositoryId);
|
||||
}else{
|
||||
OutputWordUtil.createDoc2(dataMap, tempPath, tempName, docName, repositoryId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取文档数据
|
||||
|
||||
@ -27,11 +27,12 @@ import com.actionsoft.bpms.util.*;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import jodd.util.StringUtil;
|
||||
|
||||
import static com.actionsoft.apps.coe.pal.pal.output.util.OutputWordUtil.specialCharTransfer;
|
||||
|
||||
public class PrReportComment {
|
||||
public static String TARGET_METHOD_SCOPE = "process.bpmn2,process.epc,process.flowchart,process.framework";
|
||||
public static String TARGET_METHOD_SCOPE = "process.bpmn2,process.epc,process.flowchart,process.framework,process.oaApprove";
|
||||
public static String PROCESS_STEP = "userTask,serviceTask,manualTask,receiveTask,sendTask,scriptTask,businessRuleTask,callActivityCallingProcess,method,process,predefinedProcess,decision";
|
||||
|
||||
//word换行符
|
||||
@ -288,9 +289,7 @@ public class PrReportComment {
|
||||
dataMap.put("pl_" + propertyObj.getString("key"), OutputWordUtil.specialCharTransfer(propertyObj.getString("value")));
|
||||
}
|
||||
}else if (propertyObj.getString("key").equals("T_supplementary_articles")) {
|
||||
if (propertyObj.getString("value").equals("")) {
|
||||
dataMap.put("pl_" + propertyObj.getString("key"), "无");
|
||||
}else{
|
||||
if (StringUtil.isNotEmpty(propertyObj.getString("value"))) {
|
||||
dataMap.put("pl_" + propertyObj.getString("key"), OutputWordUtil.specialCharTransfer(propertyObj.getString("value")));
|
||||
}
|
||||
}else if("P_versions".equals(propertyObj.getString("key"))) {
|
||||
|
||||
@ -3915,6 +3915,12 @@
|
||||
</w:tbl>
|
||||
</#if>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<w:p wsp:rsidR="00AC2941" wsp:rsidRDefault="00AC2941">
|
||||
<w:pPr>
|
||||
<w:pStyle w:val="IDSTYLERDDEFAULT"/>
|
||||
@ -3922,6 +3928,14 @@
|
||||
</w:p>
|
||||
</wx:sub-section>
|
||||
</#if>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<wx:sub-section>
|
||||
<w:p wsp:rsidR="00581922" wsp:rsidRDefault="00581922">
|
||||
<w:pPr>
|
||||
@ -4212,6 +4226,7 @@
|
||||
</wx:sect>
|
||||
<wx:sect>
|
||||
<wx:sub-section>
|
||||
|
||||
<w:p wsp:rsidR="00AC2941" wsp:rsidRDefault="00AC2941" wsp:rsidP="00CF7D26">
|
||||
<w:pPr>
|
||||
<w:pStyle w:val="1"/>
|
||||
@ -7020,7 +7035,7 @@
|
||||
</wx:sub-section>
|
||||
</#if>
|
||||
|
||||
<!-- 外部文件开始 -->
|
||||
<!-- 外部文件开始 -->
|
||||
<#if (relevant_table_count >0 )>
|
||||
<wx:sub-section>
|
||||
|
||||
@ -7249,7 +7264,7 @@
|
||||
</w:p>
|
||||
</wx:sub-section>
|
||||
</#if>
|
||||
<!-- 外部文件结束 -->
|
||||
<!-- 外部文件结束 -->
|
||||
|
||||
<#if (T_supplementary_articles_count >0)>
|
||||
<wx:sub-section>
|
||||
@ -7305,6 +7320,8 @@
|
||||
</w:p>
|
||||
</wx:sub-section>
|
||||
</#if>
|
||||
|
||||
|
||||
<w:sectPr wsp:rsidR="00140F58" wsp:rsidRPr="00822EA9">
|
||||
<w:hdr w:type="odd">
|
||||
<w:tbl>
|
||||
|
||||
5813
com.actionsoft.apps.coe.pal.output.pr/步骤横表-流程手册5.xml
Normal file
5813
com.actionsoft.apps.coe.pal.output.pr/步骤横表-流程手册5.xml
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -2599,6 +2599,7 @@ public class CoEPALController {
|
||||
public String COEPALOUTPUTREPORTOutputProcessCreate(UserContext me, String wsId, String teamId, String fileId) {
|
||||
PALRepositoryModel model = PALRepositoryCache.getCache().get(fileId);
|
||||
String methodId = model.getMethodId();
|
||||
|
||||
if ("data.form".equals(methodId)) {
|
||||
return PALRepositoryQueryAPIManager.getInstance().createOutputReportBd(wsId, me.getUID(), teamId, fileId);
|
||||
//方案手册走制度手册逻辑
|
||||
|
||||
@ -55,6 +55,7 @@ import freemarker.template.Configuration;
|
||||
import freemarker.template.Template;
|
||||
import freemarker.template.TemplateException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.pdfbox.text.TextPosition;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
@ -463,10 +464,15 @@ public class OutputWordUtil {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* oa审批审批流程创建word
|
||||
* @param dataMap
|
||||
* @param tempPath
|
||||
* @param tempName
|
||||
* @param docName
|
||||
* @param repositoryId
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
public static void createOAApproveDoc(JSONObject dataMap, String tempPath, String tempName, String docName,String repositoryId) throws FileNotFoundException {
|
||||
Configuration configuration = new Configuration();
|
||||
configuration.setDefaultEncoding("UTF-8");
|
||||
@ -508,13 +514,68 @@ public class OutputWordUtil {
|
||||
}
|
||||
|
||||
|
||||
BO oaapprovalBO = SDK.getBOAPI().getByKeyField("BO_EU_OA_APPROVAL_TEMPLATE_TJ", "FILEUUID", repositoryId);
|
||||
if (null == oaapprovalBO || !"1".equals(oaapprovalBO.getString("STATUS"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<FormFile> processfile = SDK.getBOAPI().getFiles(oaapprovalBO.getId(), "PROCESSFILE");
|
||||
if (processfile.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
FormFile formFile = processfile.get(0);
|
||||
DCContext fileDCContext = SDK.getBOAPI().getFileDCContext(formFile);
|
||||
|
||||
// 加载目标文件和待合并文档2
|
||||
Document docs1 = new Document();
|
||||
docs1.loadFromFile(outFile.getPath());
|
||||
Document docs2 = new Document();
|
||||
System.out.println("fileDCContext.getFilePath()======="+fileDCContext.getFilePath());
|
||||
docs2.loadFromFile(fileDCContext.getFilePath());
|
||||
|
||||
|
||||
Section lastSection1 = docs1.getLastSection();
|
||||
|
||||
// 删除最后一个节
|
||||
docs1.getSections().remove(lastSection1);
|
||||
|
||||
|
||||
System.out.println("嘻嘻嘻嘻嘻嘻休息休息=");
|
||||
// 提取所有表格
|
||||
List<Table> allTables = extractAllTables(docs2);
|
||||
System.out.println("找到11111111 " + allTables.size() + " 个表格");
|
||||
|
||||
if (allTables.size() >= 4) {
|
||||
// 拆分表格:前2个表格,后2个表格
|
||||
List<Table> firstTwoTables = allTables.subList(0, 1);
|
||||
|
||||
TextPosition position = findTextPosition(docs1, "流程图");
|
||||
|
||||
if (position != null) {
|
||||
// 在前面插入前2个表格
|
||||
insertTablesBeforeText(docs1, firstTwoTables, position);
|
||||
|
||||
// 6. 获取docs2中剩余的内容(除了前两个表格)
|
||||
List<DocumentObject> remainingContent = extractRemainingContent(docs2, firstTwoTables.size());
|
||||
|
||||
// 7. 将剩余内容插入到docs1的最后一节
|
||||
insertContentToLastSection(docs1, remainingContent);
|
||||
|
||||
|
||||
// 保存合并后的文档
|
||||
docs1.saveToFile(outFile.getPath(), FileFormat.Docx);
|
||||
System.out.println("文档合并成功!");
|
||||
} else {
|
||||
System.out.println("未找到文本'流程图'");
|
||||
}
|
||||
} else {
|
||||
System.out.println("源文档中的表格数量不足4个,当前只有: " + allTables.size());
|
||||
}
|
||||
|
||||
docs1.dispose();
|
||||
docs2.dispose();
|
||||
|
||||
|
||||
Document doc = new Document(outFile.getPath());
|
||||
|
||||
|
||||
|
||||
@ -522,6 +583,155 @@ public class OutputWordUtil {
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 提取剩余内容(除了前n个表格)
|
||||
*/
|
||||
private static List<DocumentObject> extractRemainingContent(Document document, int tablesToSkip) {
|
||||
List<DocumentObject> remainingContent = new ArrayList<>();
|
||||
int skippedTables = 0;
|
||||
|
||||
for (int i = 0; i < document.getSections().getCount(); i++) {
|
||||
Section section = document.getSections().get(i);
|
||||
for (int j = 0; j < section.getBody().getChildObjects().getCount(); j++) {
|
||||
DocumentObject obj = section.getBody().getChildObjects().get(j);
|
||||
|
||||
if (obj instanceof Table) {
|
||||
if (skippedTables < tablesToSkip) {
|
||||
skippedTables++;
|
||||
continue; // 跳过前n个表格
|
||||
}
|
||||
}
|
||||
|
||||
// 克隆对象以避免重复引用问题
|
||||
remainingContent.add(obj.deepClone());
|
||||
}
|
||||
}
|
||||
return remainingContent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 将内容插入到最后一节
|
||||
*/
|
||||
private static void insertContentToLastSection(Document docs1, List<DocumentObject> content) {
|
||||
int lastSectionIndex = docs1.getSections().getCount() - 1;
|
||||
Section lastSection = docs1.getSections().get(lastSectionIndex);
|
||||
|
||||
// 在插入前添加分页符(可选)
|
||||
Paragraph pageBreak = new Paragraph(docs1);
|
||||
pageBreak.appendBreak(BreakType.Page_Break);
|
||||
lastSection.getBody().getChildObjects().add(pageBreak);
|
||||
|
||||
// 插入剩余内容
|
||||
for (DocumentObject obj : content) {
|
||||
lastSection.getBody().getChildObjects().add(obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 提取文档中的所有表格
|
||||
*/
|
||||
private static List<Table> extractAllTables(Document doc) {
|
||||
List<Table> tables = new ArrayList<>();
|
||||
|
||||
for (Object sectionObj : doc.getSections()) {
|
||||
Section section = (Section) sectionObj;
|
||||
|
||||
for (Object obj : section.getBody().getChildObjects()) {
|
||||
if (obj instanceof Table) {
|
||||
tables.add((Table) obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tables;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找文本位置
|
||||
*/
|
||||
private static TextPosition findTextPosition(Document doc, String targetText) {
|
||||
for (int s = 0; s < doc.getSections().getCount(); s++) {
|
||||
Section section = doc.getSections().get(s);
|
||||
|
||||
for (int p = 0; p < section.getParagraphs().getCount(); p++) {
|
||||
Paragraph paragraph = section.getParagraphs().get(p);
|
||||
String paragraphText = paragraph.getText();
|
||||
|
||||
if (paragraphText.contains(targetText)) {
|
||||
return new TextPosition(s, p, paragraphText.indexOf(targetText));
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在指定文本前插入表格
|
||||
*/
|
||||
private static void insertTablesBeforeText(Document mainDoc, List<Table> tables, TextPosition position) {
|
||||
Section mainSection = mainDoc.getSections().get(position.getSectionIndex());
|
||||
Paragraph targetParagraph = mainSection.getParagraphs().get(position.getParagraphIndex());
|
||||
int insertIndex = mainSection.getBody().getChildObjects().indexOf(targetParagraph);
|
||||
|
||||
// 在前方插入表格(反向插入以保持顺序)
|
||||
for (int i = tables.size() - 1; i >= 0; i--) {
|
||||
Table clonedTable = tables.get(i).deepClone();
|
||||
mainSection.getBody().getChildObjects().insert(insertIndex, clonedTable);
|
||||
|
||||
// 在每个表格前添加一个空段落作为间隔
|
||||
Paragraph spacingPara = new Paragraph(mainDoc);
|
||||
mainSection.getBody().getChildObjects().insert(insertIndex, spacingPara);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 在指定文本后插入表格
|
||||
*/
|
||||
private static void insertTablesAfterText(Document mainDoc, List<Table> tables, TextPosition position) {
|
||||
Section mainSection = mainDoc.getSections().get(position.getSectionIndex());
|
||||
Paragraph targetParagraph = mainSection.getParagraphs().get(position.getParagraphIndex());
|
||||
int insertIndex = mainSection.getBody().getChildObjects().indexOf(targetParagraph) + 1;
|
||||
|
||||
// 在后方插入表格
|
||||
for (Table table : tables) {
|
||||
Table clonedTable = table.deepClone();
|
||||
mainSection.getBody().getChildObjects().insert(insertIndex, clonedTable);
|
||||
insertIndex++;
|
||||
|
||||
// 在每个表格后添加一个空段落作为间隔
|
||||
Paragraph spacingPara = new Paragraph(mainDoc);
|
||||
mainSection.getBody().getChildObjects().insert(insertIndex, spacingPara);
|
||||
insertIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文本位置信息类
|
||||
*/
|
||||
static class TextPosition {
|
||||
private int sectionIndex;
|
||||
private int paragraphIndex;
|
||||
private int textOffset;
|
||||
|
||||
public TextPosition(int sectionIndex, int paragraphIndex, int textOffset) {
|
||||
this.sectionIndex = sectionIndex;
|
||||
this.paragraphIndex = paragraphIndex;
|
||||
this.textOffset = textOffset;
|
||||
}
|
||||
|
||||
public int getSectionIndex() { return sectionIndex; }
|
||||
public int getParagraphIndex() { return paragraphIndex; }
|
||||
public int getTextOffset() { return textOffset; }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成word文件
|
||||
*
|
||||
@ -982,7 +1192,6 @@ public class OutputWordUtil {
|
||||
//页眉文字
|
||||
TableCell cell = table.getRows().get(0).getCells().get(0);
|
||||
String text = cell.getParagraphs().get(0).getText();// 假设单元格中只有一个TextRange
|
||||
System.out.println("HEADERFONT = " + text);
|
||||
cell.getParagraphs().get(0).setText(dataMap.getString("HEADERFONT"));
|
||||
//页眉logo
|
||||
String logoUrl = dataMap.getString("LOGOURL");
|
||||
@ -1018,7 +1227,6 @@ public class OutputWordUtil {
|
||||
TableCell cell = table.getRows().get(0).getCells().get(0);
|
||||
// 修改单元格中的文本
|
||||
String text = cell.getParagraphs().get(0).getText();// 假设单元格中只有一个TextRange
|
||||
System.out.println("FOOTERFONT = " + text);
|
||||
cell.getParagraphs().get(0).setText(dataMap.getString("FOOTERFONT"));
|
||||
}
|
||||
DocumentObject obj = sourceFooter.getChildObjects().get(j).deepClone();
|
||||
@ -3106,6 +3314,47 @@ public class OutputWordUtil {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 插入文档2内容(保持格式与文件协调)
|
||||
Section doc2Sec = docs2.getSections().get(0);
|
||||
boolean isFirstPara = true;
|
||||
for (Object obj : doc2Sec.getParagraphs()) {
|
||||
Paragraph doc2Para = (Paragraph) obj;
|
||||
Paragraph clonedPara = (Paragraph) doc2Para.deepClone();
|
||||
ParagraphFormat format = clonedPara.getFormat();
|
||||
|
||||
// 核心格式:确保同页且不挤压
|
||||
format.setPageBreakBefore(false);
|
||||
format.setPageBreakAfter(false);
|
||||
format.setKeepLines(true);
|
||||
format.setKeepFollow(true);
|
||||
format.setLineSpacingRule(LineSpacingRule.At_Least);
|
||||
format.setLineSpacing(12f); // 适配文件中行高
|
||||
|
||||
// 第一段与表格保持6磅间距(避免贴紧表格底部)
|
||||
if (isFirstPara) {
|
||||
float beforeSpacing = format.getBeforeSpacing();
|
||||
format.setBeforeSpacing(beforeSpacing > 0 ? beforeSpacing : 6f);
|
||||
isFirstPara = false;
|
||||
}
|
||||
|
||||
// 插入到目标位置(表格下方)
|
||||
targetSection.getParagraphs().insert(targetParaIndex, clonedPara);
|
||||
}
|
||||
|
||||
// 调整后续段落(如矩阵标题)与插入内容的间距
|
||||
ParagraphFormat targetFormat = targetPara.getFormat();
|
||||
targetFormat.setBeforeSpacing(6f); // 与插入内容保持6磅间距
|
||||
targetFormat.setPageBreakBefore(false);
|
||||
|
||||
// 保存文档
|
||||
docs1.saveToFile(filePath, FileFormat.Docx_2013);
|
||||
docs1.dispose();
|
||||
docs2.dispose();
|
||||
|
||||
|
||||
} else if ("活动说明后".equals(text)) {
|
||||
|
||||
|
||||
@ -3140,16 +3389,6 @@ public class OutputWordUtil {
|
||||
if (targetPara != null)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 未找到目标位置则退出
|
||||
if (targetPara == null || targetSection == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 在目标文档末尾添加分节符,确保新节可以有不同的页面设置
|
||||
@ -3174,50 +3413,6 @@ public class OutputWordUtil {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Section doc2Sec = docs2.getSections().get(0);
|
||||
for (Object obj : doc2Sec.getParagraphs()) {
|
||||
Paragraph doc2Para = (Paragraph) obj;
|
||||
Paragraph clonedPara = (Paragraph) doc2Para.deepClone();
|
||||
ParagraphFormat format = clonedPara.getFormat();
|
||||
|
||||
|
||||
|
||||
|
||||
// 核心格式:确保同页且不挤压
|
||||
format.setPageBreakBefore(false);
|
||||
format.setPageBreakAfter(false);
|
||||
format.setKeepLines(true);
|
||||
format.setKeepFollow(true);
|
||||
format.setLineSpacingRule(LineSpacingRule.At_Least);
|
||||
format.setLineSpacing(12f); // 适配文件中行高
|
||||
|
||||
// 第一段与表格保持6磅间距(避免贴紧表格底部)
|
||||
// if (isFirstPara) {
|
||||
// float beforeSpacing = format.getBeforeSpacing();
|
||||
// format.setBeforeSpacing(beforeSpacing > 0 ? beforeSpacing : 6f);
|
||||
// isFirstPara = false;
|
||||
// }
|
||||
|
||||
// 插入到目标位置(表格下方)
|
||||
targetSection.getParagraphs().insert(targetParaIndex, clonedPara);
|
||||
targetParaIndex++;
|
||||
}
|
||||
|
||||
// 调整后续段落(如矩阵标题)与插入内容的间距
|
||||
ParagraphFormat targetFormat = targetPara.getFormat();
|
||||
targetFormat.setBeforeSpacing(6f); // 与插入内容保持6磅间距
|
||||
targetFormat.setPageBreakBefore(false);*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 保存文档
|
||||
docs1.saveToFile(filePath, FileFormat.Docx_2013);
|
||||
docs1.dispose();
|
||||
@ -3225,72 +3420,7 @@ public class OutputWordUtil {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static List<String> extractAllTables(String filePath) {
|
||||
List<String> tablesContent = new ArrayList<>();
|
||||
Document doc = new Document();
|
||||
doc.loadFromFile(filePath);
|
||||
for (Object obj : doc.getSections()) {
|
||||
Section sec = (Section) obj;
|
||||
for (Object table : sec.getTables()) {
|
||||
System.out.println("talble=" + table);
|
||||
Table table1 = (Table) obj;
|
||||
tablesContent.add(extractTableContent(table1));
|
||||
}
|
||||
}
|
||||
return tablesContent;
|
||||
}
|
||||
|
||||
|
||||
private static String extractTableContent(Table table) {
|
||||
StringBuilder tableContent = new StringBuilder();
|
||||
int rowCount = table.getRows().getCount();
|
||||
int colCount = 0;
|
||||
if (rowCount > 0)
|
||||
colCount = table.getRows().get(0).getCells().getCount();
|
||||
tableContent.append("(").append(rowCount).append("").append(colCount).append("\n");
|
||||
for (int i = 0; i < rowCount; i++) {
|
||||
TableRow row = table.getRows().get(i);
|
||||
for (int j = 0; j < row.getCells().getCount(); j++) {
|
||||
TableCell cell = row.getCells().get(j);
|
||||
String cellText = extractCellContent(cell);
|
||||
System.out.println("cellText====" + cellText);
|
||||
tableContent.append(cellText);
|
||||
if (j < row.getCells().getCount() - 1)
|
||||
tableContent.append("\t");
|
||||
}
|
||||
tableContent.append("\n");
|
||||
}
|
||||
return tableContent.toString();
|
||||
}
|
||||
|
||||
|
||||
private static String extractCellContent(TableCell cell) {
|
||||
StringBuilder cellContent = new StringBuilder();
|
||||
for (int k = 0; k < cell.getParagraphs().getCount(); k++) {
|
||||
Paragraph para = cell.getParagraphs().get(k);
|
||||
cellContent.append(para.getText());
|
||||
if (k < cell.getParagraphs().getCount() - 1)
|
||||
cellContent.append("\n");
|
||||
}
|
||||
return cellContent.toString();
|
||||
}
|
||||
|
||||
|
||||
// 新增:清除文档中的分页符(针对文档2)
|
||||
private static void clearPageBreaks(Document doc) {
|
||||
for (Object obj : doc.getSections()) {
|
||||
Section section= (Section) obj;
|
||||
// 遍历段落,移除手动分页符(假设分页符以特殊字符或元素存在)
|
||||
for (Object obj1 : section.getParagraphs()) {
|
||||
Paragraph para = (Paragraph) obj1;
|
||||
String paraText = para.getText();
|
||||
if (paraText.contains("\f")) {
|
||||
para.setText(paraText.replace("\f", "")); // 清除分页符字符
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -450,6 +450,7 @@
|
||||
var teamId = "<#teamId>";
|
||||
var jssdk;
|
||||
var mrStatus = "0";
|
||||
var apprivalStatus = "0";
|
||||
</script>
|
||||
<!--工具js-->
|
||||
<script type='text/javascript' charset='UTF-8' src='../apps/com.actionsoft.apps.coe.pal/lib/designer/extend/js/util/map.js'></script>
|
||||
@ -601,7 +602,7 @@
|
||||
}
|
||||
|
||||
// 只有epc和泳道图显示切换按钮
|
||||
if (methodId !== 'process.epc' && methodId !== 'process.flowchart' && methodId !== 'process.oaApprove') {
|
||||
if (methodId !== 'process.epc' && methodId !== 'process.flowchart') {
|
||||
$("#switchMRViews").css('display', 'none');
|
||||
}
|
||||
|
||||
@ -1228,8 +1229,7 @@
|
||||
$("#dock").css("right", 0);
|
||||
openWpsOaApprovalUrl();
|
||||
} else {
|
||||
//先判断是否要更新管理办法的生效状态
|
||||
updateMrStatus();
|
||||
|
||||
$("#wpsPage").css('display', 'none');
|
||||
$("#shape_panel").css('display', 'block');
|
||||
$("#shape_panel_more_shape").css('display', 'block');
|
||||
@ -1366,7 +1366,7 @@
|
||||
url: "./jd?sid=" + sid + "&cmd=com.awspaas.user.apps.yiliwps.previewUrl_oaApproval&palId=" + ruuid,
|
||||
type: 'GET',
|
||||
success: function (data) {
|
||||
mrStatus = data.data.mrStatus;
|
||||
apprivalStatus = data.data.approvalStatus;
|
||||
if (data.data.content.code === 200) {
|
||||
//换一种打开方式
|
||||
console.log('引入后可以开始使用 JSSDK 了~');
|
||||
|
||||
@ -1806,7 +1806,7 @@
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
//新增 打开wps文件逻辑
|
||||
if(methodId === 'control.policy'|| methodId ==='engineering.standard' || methodId ==='process.scheme' || methodId ==='control.oaApprove'){
|
||||
if(methodId === 'control.policy'|| methodId ==='engineering.standard' || methodId ==='process.scheme' || methodId ==='process.oaApprove'){
|
||||
//执行切换显示按钮
|
||||
switchWpsDisplay(true);
|
||||
}else{
|
||||
@ -1814,7 +1814,7 @@
|
||||
$("#textFileShow").css('display','none');
|
||||
}
|
||||
// 只有epc和泳道图显示切换按钮
|
||||
if (methodId !== 'process.epc' && methodId !== 'process.flowchart') {
|
||||
if (methodId !== 'process.epc' && methodId !== 'process.flowchart' && methodId !== 'process.oaApprove') {
|
||||
$("#switchMRViews").css('display', 'none');
|
||||
}
|
||||
|
||||
@ -1938,7 +1938,7 @@
|
||||
|
||||
|
||||
function openWpsUrl(){
|
||||
debugger;
|
||||
|
||||
$.ajax({
|
||||
url: "./jd?sid=" + sid + "&cmd=com.awspaas.user.apps.yiliwps.readOnlyUrl&palId=" + ruuid +"&fileName="+updatedPolicyFileList,
|
||||
type: 'GET',
|
||||
@ -1986,6 +1986,38 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function openWpsOAApprovalUrl() {
|
||||
$.ajax({
|
||||
url: "./jd?sid=" + sid + "&cmd=com.awspaas.user.apps.yiliwps.previewUrl_oaApproval_read&palId=" + ruuid,
|
||||
type: 'GET',
|
||||
success: function (data) {
|
||||
if(data.result=="ok"){
|
||||
if (data.data.content.code === 200) {
|
||||
//换一种打开方式
|
||||
console.log('引入后可以开始使用 JSSDK 了~');
|
||||
jssdk = WebOfficeSDK.config({
|
||||
url: data.data.content.data.link, // 该地址需要对接方服务端提供,形如 https://wwo.wps.cn/office/p/xxx
|
||||
mount: document.querySelector('#wpsPage')
|
||||
})
|
||||
|
||||
jssdk.on('fileOpen', (data) => {
|
||||
console.log('打开文档成功: ', data)
|
||||
})
|
||||
}else{
|
||||
$.simpleAlert(data.data.msg, "info", 2000);
|
||||
}
|
||||
}else{
|
||||
$.simpleAlert(data.msg, "info", 2000);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@ -432,6 +432,8 @@ public class Report1Gener {
|
||||
dataMap.put("CNAMEFONTSIZE",changeValueToDouble(bo.getString("CNAMEFONTSIZE")));
|
||||
dataMap.put("HEADERFONT",bo.getString("HEADERFONT"));
|
||||
dataMap.put("FOOTERFONT",bo.getString("FOOTERFONT"));
|
||||
//dataMap.put("HEADERBOTTOMLINE1","───────────────────────────────────────────────────");
|
||||
//dataMap.put("HEADERBOTTOMLINE1","───────────────────────────────────────────────────────────────────────────────────────────────────────────────");
|
||||
List<FormFile> headerlogo = SDK.getBOAPI().getFiles(bo.getId(), "HEADERLOGO");
|
||||
if(headerlogo.size()>0){
|
||||
FormFile formFile = headerlogo.get(0);
|
||||
|
||||
@ -2955,7 +2955,7 @@
|
||||
<w:hdr w:type="odd">
|
||||
<w:tbl>
|
||||
<w:tblPr>
|
||||
<w:tblW w:w="8520" w:type="dxa"/>
|
||||
<w:tblW w:w="100%" w:type="pct"/>
|
||||
<w:jc w:val="center"/>
|
||||
<w:tblInd w:w="0" w:type="dxa"/>
|
||||
<w:tblBorders>
|
||||
@ -2969,8 +2969,8 @@
|
||||
<w:tblLayout w:type="Fixed"/>
|
||||
</w:tblPr>
|
||||
<w:tblGrid>
|
||||
<w:gridCol w:w="4260"/>
|
||||
<w:gridCol w:w="4260"/>
|
||||
<w:gridCol w:w="5000"/>
|
||||
<w:gridCol w:w="5000"/>
|
||||
</w:tblGrid>
|
||||
<w:tr wsp:rsidR="002737AF" wsp:rsidTr="00F7324A">
|
||||
<w:trPr>
|
||||
@ -2979,7 +2979,7 @@
|
||||
</w:trPr>
|
||||
<w:tc>
|
||||
<w:tcPr>
|
||||
<w:tcW w:w="4260" w:type="dxa"/>
|
||||
<w:tcW w:w="0" w:type="auto"/>
|
||||
<w:tcBorders>
|
||||
<w:top w:val="single" w:sz="6" wx:bdrwidth="15" w:space="0" w:color="FFFFFF"/>
|
||||
<w:left w:val="single" w:sz="6" wx:bdrwidth="15" w:space="0" w:color="FFFFFF"/>
|
||||
@ -3005,7 +3005,7 @@
|
||||
</w:tc>
|
||||
<w:tc>
|
||||
<w:tcPr>
|
||||
<w:tcW w:w="4260" w:type="dxa"/>
|
||||
<w:tcW w:w="0" w:type="auto"/>
|
||||
<w:tcBorders>
|
||||
<w:top w:val="single" w:sz="6" wx:bdrwidth="15" w:space="0" w:color="FFFFFF"/>
|
||||
<w:left w:val="single" w:sz="6" wx:bdrwidth="15" w:space="0" w:color="FFFFFF"/>
|
||||
|
||||
Binary file not shown.
@ -27,4 +27,13 @@ public class YiliWpsConst {
|
||||
public static final String APP_ACT_COE_PAL_UPFILE = "APP_ACT_COE_PAL_UPFILE";
|
||||
|
||||
|
||||
public static final String BO_EU_OA_APPROVAL_TEMPLATE = "BO_EU_OA_APPROVAL_TEMPLATE";
|
||||
|
||||
public static final String BO_EU_OA_APPROVAL_TEMPLATE_TJ = "BO_EU_OA_APPROVAL_TEMPLATE_TJ";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -41,6 +41,21 @@ public class YiliWpsController {
|
||||
return web.getWPSMROnlineFilePreviewUrl(palId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 打开可编辑的页面(oa审批流程)
|
||||
* @param me
|
||||
* @param palId
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Mapping("com.awspaas.user.apps.yiliwps.previewUrl_oaApproval")
|
||||
public String getWPSOnlineFilePreviewUrloaApproval(UserContext me,String palId) throws Exception{
|
||||
WpsWeb web =new WpsWeb(me);
|
||||
return web.getWPSOaApprovalOnlineFilePreviewUrl(palId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 打开只读的页面(epc)
|
||||
* @param me
|
||||
@ -54,6 +69,21 @@ public class YiliWpsController {
|
||||
return web.getWPSMROnlineFilePreviewReadUrl(palId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 打开只读的页面(oaapproval)
|
||||
* @param me
|
||||
* @param palId
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Mapping("com.awspaas.user.apps.yiliwps.previewUrl_oaApproval_read")
|
||||
public String getWPSOnlineFilePreviewUrlOaApprovalRead(UserContext me,String palId) throws Exception{
|
||||
WpsWeb web =new WpsWeb(me);
|
||||
return web.getWPSMROnlineFilePreviewOaApprovalReadUrl(palId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 打开制度的页面
|
||||
* @param me
|
||||
|
||||
@ -97,9 +97,13 @@ public class WpsWeb extends ActionWeb {
|
||||
JSONObject user = new JSONObject();
|
||||
JSONObject user_acl = new JSONObject();
|
||||
JSONObject watermark = new JSONObject();
|
||||
|
||||
if("1".equals(isEPC)){
|
||||
sourceDc = getFileDCContext(fileId,isEPC);
|
||||
file.put("id", fileId);
|
||||
}else if("2".equals(isEPC)) {
|
||||
sourceDc = getFileOAApprovalDCContext(fileId);
|
||||
file.put("id", fileId);
|
||||
}else if(UtilString.isEmpty(filePreview)){
|
||||
sourceDc = getFileDCContext(fileId);
|
||||
file.put("id", fileId.equals("")?"1":fileId);
|
||||
@ -174,6 +178,13 @@ public class WpsWeb extends ActionWeb {
|
||||
List<FormFile> systemfile = SDK.getBOAPI().getFiles(mrBO.getId(), "SYSTEMFILE");
|
||||
FormFile formFile = systemfile.get(0);
|
||||
SDK.getBOAPI().upFile(formFile,fileInputStream);
|
||||
}else if("2".equals(isEPC)){
|
||||
sourceDc = getFileOAApprovalDCContext(fileId);
|
||||
sourceDc.setSession(me);
|
||||
BO mrBO = SDK.getBOAPI().getByKeyField(YiliWpsConst.BO_EU_OA_APPROVAL_TEMPLATE_TJ, "FILEUUID", fileId);
|
||||
List<FormFile> processfile = SDK.getBOAPI().getFiles(mrBO.getId(), "PROCESSFILE");
|
||||
FormFile formFile = processfile.get(0);
|
||||
SDK.getBOAPI().upFile(formFile,fileInputStream);
|
||||
}else{//制度图
|
||||
sourceDc = getFileDCContext(fileId);
|
||||
//在重新获取下fileId
|
||||
@ -318,6 +329,24 @@ public class WpsWeb extends ActionWeb {
|
||||
return fileDCContext;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取附件的附件ID(流程图相关的逻辑)
|
||||
* @param fileId
|
||||
* @return
|
||||
*/
|
||||
public DCContext getFileOAApprovalDCContext(String fileId){
|
||||
//查询模版记录文件
|
||||
BO approvalBO = SDK.getBOAPI().getByKeyField(YiliWpsConst.BO_EU_OA_APPROVAL_TEMPLATE_TJ, "FILEUUID", fileId);
|
||||
List<FormFile> processfile = SDK.getBOAPI().getFiles(approvalBO.getId(), "PROCESSFILE");
|
||||
FormFile formFile = processfile.get(0);
|
||||
DCContext fileDCContext = SDK.getBOAPI().getFileDCContext(formFile);
|
||||
fileDCContext.setSession(this.getContext());
|
||||
return fileDCContext;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取附件的附件ID
|
||||
* @return
|
||||
@ -451,9 +480,51 @@ public class WpsWeb extends ActionWeb {
|
||||
ResponseObject ro = ResponseObject.newOkResponse();
|
||||
ro.put("mrStatus",mrStatus);
|
||||
ro.put("content",content);
|
||||
System.out.println("content1111111"+content);
|
||||
return ro.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* (编辑)打开OA审批流程图wps在线
|
||||
* @param palId
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public String getWPSOaApprovalOnlineFilePreviewUrl(String palId) throws Exception{
|
||||
//先判断流程是否已经编辑过 //先判断流程是否已经编辑过
|
||||
BO approvalBO = SDK.getBOAPI().getByKeyField(YiliWpsConst.BO_EU_OA_APPROVAL_TEMPLATE_TJ, "FILEUUID", palId);
|
||||
if(null == approvalBO){//如果为空
|
||||
approvalBO = new BO();
|
||||
approvalBO.set("FILEUUID",palId);
|
||||
approvalBO.set("STATUS","1");//默认无效
|
||||
ProcessInstance processInstance = SDK.getProcessAPI().createProcessInstance("obj_f400aa120f0a4bceb31f0a354ea73fd7", this.getContext().getUID(), "新建OA审批流程文件");
|
||||
SDK.getBOAPI().create(YiliWpsConst.BO_EU_OA_APPROVAL_TEMPLATE_TJ, approvalBO, processInstance, this.getContext());
|
||||
//创建完BO后,把模版附件copy进去
|
||||
//先获取模版文件
|
||||
BO tplBO = SDK.getBOAPI().query(YiliWpsConst.BO_EU_OA_APPROVAL_TEMPLATE).addQuery("FILESTATE=", true).detail();
|
||||
SDK.getBOAPI().copyFileTo(tplBO.getId(),"PROCESSFILE",approvalBO.getId(),YiliWpsConst.BO_EU_OA_APPROVAL_TEMPLATE_TJ,"PROCESSFILE",processInstance.getId(),null);
|
||||
}
|
||||
String approvalStatus = approvalBO.getString("STATUS");//获取管理办法状态
|
||||
DCContext sourceDc = getFileOAApprovalDCContext(palId);
|
||||
WPS4Util.initAppInfo(YiliWpsConst.AK, YiliWpsConst.SK);
|
||||
String url = String.format("/api/edit/v1/files/%s/link?type=%s&_w_third_sid=%s&_w_third_palId=%s&_w_third_queryFileId=%s&_w_third_fname=%s&_w_third_isEPC=%s",palId,"w",this.getContext().getSessionId(),palId,palId,URLEncoder.encode(sourceDc.getFileName()),"2");
|
||||
Map<String,String> headers = WPS4Util.getSignatureHeaders(url, HttpMethod.GET,null, YiliWpsConst.CONTENT_TYPE);
|
||||
logAPI.consoleInfo(">>>>>headers"+headers);
|
||||
String content = HttpPostUtil.sendGetRequest(YiliWpsConst.HOST + "/open" + url, headers);
|
||||
ResponseObject ro = ResponseObject.newOkResponse();
|
||||
ro.put("approvalStatus",approvalStatus);
|
||||
ro.put("content",content);
|
||||
return ro.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* (只读)打开流程图管理要求wps在线
|
||||
* @param palId
|
||||
@ -481,6 +552,39 @@ public class WpsWeb extends ActionWeb {
|
||||
return ro.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* (只读)打开流程图管理要求wps在线
|
||||
* @param palId
|
||||
* @return
|
||||
*/
|
||||
public String getWPSMROnlineFilePreviewOaApprovalReadUrl(String palId) throws Exception {
|
||||
//先判断流程是否已经编辑过
|
||||
BO mrBO = SDK.getBOAPI().getByKeyField(YiliWpsConst.BO_EU_OA_APPROVAL_TEMPLATE_TJ, "FILEUUID", palId);
|
||||
if(null == mrBO) {//如果为空
|
||||
return ResponseObject.newErrResponse("未创建管理要求文件").toString();
|
||||
}
|
||||
String approvalStatus = mrBO.getString("STATUS");//获取管理办法状态
|
||||
if("0".equals(approvalStatus)){
|
||||
return ResponseObject.newErrResponse("OA审批文件未生效").toString();
|
||||
}
|
||||
DCContext sourceDc = getFileDCContext(palId,"1");
|
||||
WPS4Util.initAppInfo(YiliWpsConst.AK, YiliWpsConst.SK);
|
||||
String url = String.format("/api/preview/v1/files/%s/link?type=%s&_w_third_sid=%s&_w_third_palId=%s&_w_third_queryFileId=%s&_w_third_fname=%s&_w_third_isEPC=%s",palId,"w",this.getContext().getSessionId(),palId,palId,URLEncoder.encode(sourceDc.getFileName()),"2");
|
||||
Map<String,String> headers = WPS4Util.getSignatureHeaders(url, HttpMethod.GET,null, YiliWpsConst.CONTENT_TYPE);
|
||||
logAPI.consoleInfo(">>>>>headers"+headers);
|
||||
String content = HttpPostUtil.sendGetRequest(YiliWpsConst.HOST + "/open" + url, headers);
|
||||
ResponseObject ro = ResponseObject.newOkResponse();
|
||||
ro.put("approvalStatus",approvalStatus);
|
||||
ro.put("content",content);
|
||||
return ro.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 更新MR管理办法状态
|
||||
* @param palId
|
||||
|
||||
Loading…
Reference in New Issue
Block a user