From de12e4fad1c5fa417582ad1f86a4aae1364a0ebb Mon Sep 17 00:00:00 2001 From: lihongyu <504404568@qq.com> Date: Mon, 13 Feb 2023 17:25:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E5=8D=95/=E6=B5=81=E7=A8=8B=E6=89=8B?= =?UTF-8?q?=E5=86=8C=E9=99=84=E4=BB=B6=E6=8C=89=E5=90=8D=E7=A7=B0=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pal/output/pr/report1/Report1Gener.java | 67 ++++++++++++++++++- .../pal/output/bd/report1/Report1Gener.java | 37 +++++++++- 2 files changed, 100 insertions(+), 4 deletions(-) diff --git a/com.actionsoft.apps.coe.pal.output.pr/src/com/actionsoft/apps/coe/pal/output/pr/report1/Report1Gener.java b/com.actionsoft.apps.coe.pal.output.pr/src/com/actionsoft/apps/coe/pal/output/pr/report1/Report1Gener.java index 51622456..3647317f 100644 --- a/com.actionsoft.apps.coe.pal.output.pr/src/com/actionsoft/apps/coe/pal/output/pr/report1/Report1Gener.java +++ b/com.actionsoft.apps.coe.pal.output.pr/src/com/actionsoft/apps/coe/pal/output/pr/report1/Report1Gener.java @@ -45,6 +45,7 @@ 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; @@ -313,6 +314,7 @@ public class Report1Gener { //文件属性附件处理 int fileIndex = 1; + ArrayList isNumberAscArray = new ArrayList(); if (search != null && search.size() > 0) { // 复制附件 for (UpfileModel upfileModel : search) { @@ -334,6 +336,29 @@ public class Report1Gener { e.printStackTrace(); } JSONObject object = new JSONObject(); + //按照附件编号排序 + String fileNamel= upfileModel.getFileName(); + if(UtilString.isNotEmpty(fileNamel)&&fileNamel.contains("附件")&&fileNamel.length()>2&&(fileNamel.contains(":")||fileNamel.contains(":"))) { + if(fileNamel.indexOf("附件")==0) { + int indexOf2 = 3; + if(fileNamel.contains(":")) { + indexOf2 = fileNamel.indexOf(":"); + }else if(fileNamel.contains(":")) { + indexOf2 = fileNamel.indexOf(":"); + } + String numberStr = fileNamel.substring(2,indexOf2); + if(isNumeric(numberStr)) { + isNumberAscArray.add("true"); + int fileNumber = Integer.parseInt(numberStr); + object.put("file_number", fileNumber); + } + } + + }else { + isNumberAscArray.add("false"); + } + + object.put("file_name", upfileModel.getFileName()); String link = fileName + File.separator + upfileModel.getFileName(); object.put("link", link); @@ -366,7 +391,6 @@ public class Report1Gener { _tr.put(OutputWordUtil.SERIAL_NUMBER, shape.get("number")); }*/ /**序号改为流程编号**/ - // 节点的附件处理 JSONArray shapeFileTable = new JSONArray(); //流程节点附件Table if (search != null && search.size() > 0) { @@ -393,10 +417,30 @@ public class Report1Gener { e.printStackTrace(); } JSONObject object = new JSONObject(); + //按照附件编号排序 + String fileNamel= upfileModel.getFileName(); + if(UtilString.isNotEmpty(fileNamel)&&fileNamel.contains("附件")&&fileNamel.length()>2&&(fileNamel.contains(":")||fileNamel.contains(":"))) { + if(fileNamel.indexOf("附件")==0) { + int indexOf2 = 3; + if(fileNamel.contains(":")) { + indexOf2 = fileNamel.indexOf(":"); + }else if(fileNamel.contains(":")) { + indexOf2 = fileNamel.indexOf(":"); + } + String numberStr = fileNamel.substring(2,indexOf2); + if(isNumeric(numberStr)) { + isNumberAscArray.add("true"); + int fileNumber = Integer.parseInt(numberStr); + object.put("file_number", fileNumber); + } + } + + }else { + isNumberAscArray.add("false"); + } object.put("file_name", upfileModel.getFileName()); String link = fileName + File.separator + upfileModel.getFileName(); object.put("link", link); - fileTable.add(object); fileIndex++; } } @@ -657,6 +701,16 @@ public class Report1Gener { dataMap.put(OutputWordUtil.TABLE_REPOSITORY_SHAPE, repositoryShapeTable); dataMap.put("TABLE_REPOSITORY_SHAPE_COUNT", repositoryShapeTable.size()); + boolean contains = isNumberAscArray.contains("false"); + if(contains) { + fileTable.sort(Comparator.comparing(obj -> ((JSONObject) obj).getString("file_name"))); + }else { + try { + fileTable.sort(Comparator.comparing(obj -> ((JSONObject) obj).getInteger("file_number"))); + } catch (Exception e) { + throw new AWSQuotaException("附件格式请以:《附件1:XXXXXX》格式命名"); + } + } dataMap.put("file_table", fileTable); dataMap.put("file_table_count", fileTable.size()); dataMap.put(OutputWordUtil.TABLE_DANGER, dangerTable); @@ -669,7 +723,14 @@ public class Report1Gener { } 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 diff --git a/com.awspaas.user.apps.coe.pal.output.bd/src/com/awspaas/apps/coe/pal/output/bd/report1/Report1Gener.java b/com.awspaas.user.apps.coe.pal.output.bd/src/com/awspaas/apps/coe/pal/output/bd/report1/Report1Gener.java index 1605c12b..2e5d6f3f 100644 --- a/com.awspaas.user.apps.coe.pal.output.bd/src/com/awspaas/apps/coe/pal/output/bd/report1/Report1Gener.java +++ b/com.awspaas.user.apps.coe.pal.output.bd/src/com/awspaas/apps/coe/pal/output/bd/report1/Report1Gener.java @@ -297,6 +297,7 @@ public class Report1Gener { /**序号改为流程编号**/ // 节点的附件处理 + boolean isNumberAsc = false; JSONArray shapeFileTable = new JSONArray(); //流程节点附件Table if (search != null && search.size() > 0) { // 复制附件 @@ -322,6 +323,27 @@ public class Report1Gener { e.printStackTrace(); } JSONObject object = new JSONObject(); + //按照附件编号排序 + String fileNamel= upfileModel.getFileName(); + if(UtilString.isNotEmpty(fileNamel)&&fileNamel.contains("附件")&&fileNamel.length()>2&&(fileNamel.contains(":")||fileNamel.contains(":"))) { + if(fileNamel.indexOf("附件")==0) { + int indexOf2 = 3; + if(fileNamel.contains(":")) { + indexOf2 = fileNamel.indexOf(":"); + }else if(fileNamel.contains(":")) { + indexOf2 = fileNamel.indexOf(":"); + } + String numberStr = fileNamel.substring(2,indexOf2); + if(isNumeric(numberStr)) { + isNumberAsc = true; + int fileNumber = Integer.parseInt(numberStr); + object.put("file_number", fileNumber); + } + } + + }else { + isNumberAsc = false; + } object.put("file_name", upfileModel.getFileName()); String link = fileName + File.separator + upfileModel.getFileName(); object.put("link", link); @@ -329,7 +351,11 @@ public class Report1Gener { fileIndex++; } } - fileTable.sort(Comparator.comparing(obj -> ((JSONObject) obj).getString("file_name"))); + if(isNumberAsc) { + fileTable.sort(Comparator.comparing(obj -> ((JSONObject) obj).getString("file_number"))); + }else { + fileTable.sort(Comparator.comparing(obj -> ((JSONObject) obj).getString("file_name"))); + } if(shapeFileTable.size() == 0) {// 没有附件时给空值,不然使用office打开会解析错误 JSONObject object = new JSONObject(); object.put("shape_file_name", ""); @@ -530,6 +556,15 @@ public class Report1Gener { return index; } + + 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; + } /** * 修订记录