From 1e33f1f4fa9999cf1b21e21a4e492fe9c7f59ba8 Mon Sep 17 00:00:00 2001 From: chengli <783535094@qq.com> Date: Mon, 11 Jul 2022 11:08:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E5=BC=82=E5=B8=B8~?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../util/readword/ReadWordUtil.java | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readword/ReadWordUtil.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readword/ReadWordUtil.java index 3c07664b..07e1c433 100644 --- a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readword/ReadWordUtil.java +++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readword/ReadWordUtil.java @@ -168,7 +168,7 @@ public class ReadWordUtil { String fileNewPath = dcContextpdf.getFilePath(); String docname = fileName.replace(".docx", ".doc"); String docxname = fileName; - + boolean iscreatemap = true; if (fileName.endsWith(".docx")) { docname = dcContextpdf.getFileName().replace(".docx", ".doc"); docxname = dcContextpdf.getFileName(); @@ -191,6 +191,7 @@ public class ReadWordUtil { Document doc = new Document(filepath); doc.save(outputStream, SaveFormat.DOCX); } catch (Exception e) { + iscreatemap = false; e.printStackTrace(); } } @@ -220,9 +221,11 @@ public class ReadWordUtil { return; } //创建图形 - DCContext dcContextpdf1 = new DCContext(userContext, dcProfilepdfdoc, "com.actionsoft.apps.coe.pal.datamigration", groupValue, fileValue, docxname); - InputStream docxfile = SDK.getDCAPI().read(dcContextpdf1); - new CreateMaps().updateMaps(userContext, wsId, docxfile, title); + if(iscreatemap){ + DCContext dcContextpdf1 = new DCContext(userContext, dcProfilepdfdoc, "com.actionsoft.apps.coe.pal.datamigration", groupValue, fileValue, docxname); + InputStream docxfile = SDK.getDCAPI().read(dcContextpdf1); + new CreateMaps().updateMaps(userContext, wsId, docxfile, title); + } } @@ -378,9 +381,17 @@ public class ReadWordUtil { //取文件名名称即可 Table table = range.getTable(paragraph); Map> verticalTableText = this.getVerticalTableText(table); - List strings = verticalTableText.get("文件"); - fileMap.put(wordAttribute.getTitle(), strings); - fileFieldMap.put(wordAttribute.getTitle(), new WordField<>(strings)); + List strings = null; + if(verticalTableText.get("文件") != null){ + strings = verticalTableText.get("文件"); + } + if(verticalTableText.get("文件名称") != null){ + strings = verticalTableText.get("文件名称"); + } + if(strings != null){ + fileMap.put(wordAttribute.getTitle(), strings); + fileFieldMap.put(wordAttribute.getTitle(), new WordField<>(strings)); + } i += table.numParagraphs(); } }