增加相关文件、支持文件排序

This commit is contained in:
zhal 2023-12-01 09:00:29 +08:00
parent f3a41e1b27
commit 7e05891a29
2 changed files with 41 additions and 3 deletions

View File

@ -585,14 +585,36 @@ public class OutputWordUtil {
//保存结果文档
document.saveToFile(outFile.getPath(), FileFormat.Docx_2013);
} else if (suffix.equals("doc") || suffix.equals("docx")) {
document.insertTextFromFile(path + fileName, FileFormat.Docx_2013);
/*document.insertTextFromFile(path + fileName, FileFormat.Docx_2013);
//保存结果文档
document.saveToFile(outFile.getPath(), FileFormat.Docx_2013);
document.saveToFile(outFile.getPath(), FileFormat.Docx_2013);*/
Document docs1 = new Document();
docs1.loadFromFile(outFile.getPath());
// 加载文档2
Document docs2 = new Document();
docs2.loadFromFile(path + fileName);
SectionCollection sections2 = docs2.getSections();
sections2.insert(0, docs1.getSections().get(1).deepClone());
sections2.insert(0, docs1.getSections().get(0).deepClone());
// 保存文档2
docs2.saveToFile(outFile.getPath(), FileFormat.Docx_2013);
docs2.dispose();
} else if (suffix.equals("pptx")) {
isPPT = true;
}
if (isPPT == false) {
@ -703,13 +725,18 @@ public class OutputWordUtil {
//相关文件 R_relevant_flies
JSONArray relevant_flies = new JSONArray(); //组织职责Table
List<DesignerShapeRelationModel> relationList2 = DesignerShapeRelationCache.getListByAttrId(repositoryModel.getId(), "", "related_files");
relationList2.sort(Comparator.comparing(DesignerShapeRelationModel::getShapeText));
int count = 0;
if (relationList2.size() > 0) {
for (DesignerShapeRelationModel relation : relationList2) {
String relationFileId = relation.getRelationFileId();// 支持或相关文件的ID
System.out.println("relationFileId============="+relationFileId);
PALRepositoryModel model = PALRepositoryCache.getCache().get(relationFileId);
if (model != null) {
String name = null;
List<PALRepositoryModel> models = PALRepositoryCache.getByVersionId(relationFileId);
if (models != null && models.size() > 0) {
@ -726,6 +753,14 @@ public class OutputWordUtil {
tmp.put("desc", count);
relevant_flies.add(tmp);
}
if(relationFileId.equals("079c0c2e-fc24-4d92-a13f-6987492bfc5d")){
//String name = model.getName();
JSONObject tmp = new JSONObject();
tmp.put("name", "液奶产品无菌试验标准");
tmp.put("desc", 1);
relevant_flies.add(tmp);
}
}
CharacterFormat format = new CharacterFormat();
@ -927,6 +962,9 @@ public class OutputWordUtil {
//支持文件
JSONArray supportfiles = new JSONArray(); //组织职责Table
List<DesignerShapeRelationModel> relationList = DesignerShapeRelationCache.getListByAttrId(repositoryModel.getId(), "", "support_files");
relationList.sort(Comparator.comparing(DesignerShapeRelationModel::getShapeText));
int index = 0;
if (relationList.size() > 0) {
for (DesignerShapeRelationModel relation : relationList) {