表单/流程手册附件按名称排序优化
This commit is contained in:
parent
b3a9c3eab9
commit
de12e4fad1
@ -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<String> isNumberAscArray = new ArrayList<String>();
|
||||
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
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修订记录
|
||||
|
||||
Loading…
Reference in New Issue
Block a user