From 4d6e91bb87787a24b4febfe7bfb9f20d0804f22f Mon Sep 17 00:00:00 2001 From: rengp Date: Tue, 25 Jun 2024 14:42:53 +0800 Subject: [PATCH] no message --- ...rstBranchReceivingPushArchivesService.java | 23 +++++++++++++++---- ...ondBranchReceivingPushArchivesService.java | 20 ++++++++++++---- .../custom/archives/util/ArchivesUtil.java | 14 +++++++---- 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/com/engine/custom/archives/service/firstBranch/FirstBranchReceivingPushArchivesService.java b/com/engine/custom/archives/service/firstBranch/FirstBranchReceivingPushArchivesService.java index 2ef9245..2e06d31 100644 --- a/com/engine/custom/archives/service/firstBranch/FirstBranchReceivingPushArchivesService.java +++ b/com/engine/custom/archives/service/firstBranch/FirstBranchReceivingPushArchivesService.java @@ -532,11 +532,17 @@ public class FirstBranchReceivingPushArchivesService implements KeyWord { StringBuilder context = new StringBuilder(); try { - String swrq = Util.null2String(requesData.get("swrq")); + String swrq = Util.null2String(requesData.get("lwrq")); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - LocalDate date = LocalDate.parse(swrq, formatter); - int year = date.getYear(); - context.append(year).append("|"); + if (StringUtil.isEmpty(swrq)){ + context.append("").append("|"); + }else { + LocalDate date = LocalDate.parse(swrq, formatter); + int year = date.getYear(); + context.append(year).append("|"); + } + + String jghwt = Util.null2String(requesData.get("jghwt")); context.append(jghwt).append("|"); // String swh = Util.null2String(requesData.get("swh")); @@ -592,7 +598,14 @@ public class FirstBranchReceivingPushArchivesService implements KeyWord { //TODO context.append(ArchivesUtil.getAssociatedPersons(requestid,false)).append("|"); // 28 相关人员 -> 参与人员 context.append("智慧OA").append("|"); // 29 数据来源 -> 数据来源 - context.append(year).append("|"); // 30 形成年度 -> 年份 + if (StringUtil.isEmpty(swrq)){ + context.append("").append("|"); // 30 形成年度 -> 年份 + }else { + LocalDate date = LocalDate.parse(swrq, formatter); + int year = date.getYear(); + context.append(year).append("|"); // 30 形成年度 -> 年份 + } + context.append(String.join("&&", zwFileName)).append("|"); // 31 正文名称 context.append(String.join("&&", fjFileName)).append("|"); // 32 附件名称 context.append("togd"+requestid).append("|"); // 33 主键 diff --git a/com/engine/custom/archives/service/secondBranch/SecondBranchReceivingPushArchivesService.java b/com/engine/custom/archives/service/secondBranch/SecondBranchReceivingPushArchivesService.java index f05b285..76a7475 100644 --- a/com/engine/custom/archives/service/secondBranch/SecondBranchReceivingPushArchivesService.java +++ b/com/engine/custom/archives/service/secondBranch/SecondBranchReceivingPushArchivesService.java @@ -532,11 +532,15 @@ public class SecondBranchReceivingPushArchivesService implements KeyWord { StringBuilder context = new StringBuilder(); try { - String swrq = Util.null2String(requesData.get("swrq")); + String swrq = Util.null2String(requesData.get("lwrq")); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - LocalDate date = LocalDate.parse(swrq, formatter); - int year = date.getYear(); - context.append(year).append("|"); + if (StringUtil.isEmpty(swrq)){ + context.append("").append("|"); + }else { + LocalDate date = LocalDate.parse(swrq, formatter); + int year = date.getYear(); + context.append(year).append("|"); + } String jghwt = Util.null2String(requesData.get("jghwt")); context.append(jghwt).append("|"); // String swh = Util.null2String(requesData.get("swh")); @@ -594,7 +598,13 @@ public class SecondBranchReceivingPushArchivesService implements KeyWord { //TODO context.append(ArchivesUtil.getAssociatedPersons(requestid,false)).append("|"); // 28 相关人员 -> 参与人员 context.append("智慧OA").append("|"); // 29 数据来源 -> 数据来源 - context.append(year).append("|"); // 30 形成年度 -> 年份 + if (StringUtil.isEmpty(swrq)){ + context.append("").append("|"); // 30 形成年度 -> 年份 + }else { + LocalDate date = LocalDate.parse(swrq, formatter); + int year = date.getYear(); + context.append(year).append("|"); // 30 形成年度 -> 年份 + } context.append(String.join("&&", zwFileName)).append("|"); // 31 正文名称 context.append(String.join("&&", fjFileName)).append("|"); // 32 附件名称 context.append("togd"+requestid).append("|"); // 33 主键 diff --git a/com/engine/custom/archives/util/ArchivesUtil.java b/com/engine/custom/archives/util/ArchivesUtil.java index eff25d8..852d254 100644 --- a/com/engine/custom/archives/util/ArchivesUtil.java +++ b/com/engine/custom/archives/util/ArchivesUtil.java @@ -195,10 +195,16 @@ public class ArchivesUtil { System.out.println("父目录已存在,无需创建."); } - FileOutputStream fos = new FileOutputStream(GenerateFilename); - Writer out = new OutputStreamWriter(fos, StandardCharsets.UTF_8); - temp.process(root, out); - out.flush();//可不手动调用 + // FileOutputStream fos = new FileOutputStream(GenerateFilename); + // Writer out = new OutputStreamWriter(fos, StandardCharsets.UTF_8); + // temp.process(root, out); + // out.flush();//可不手动调用 + // 使用 try-with-resources 确保流被正确关闭 + try (FileOutputStream fos = new FileOutputStream(GenerateFilename); + Writer out = new OutputStreamWriter(fos, StandardCharsets.UTF_8)) { + temp.process(root, out); + out.flush(); + } return GenerateFilename; }