test
This commit is contained in:
@@ -152,6 +152,35 @@ public class ImportService {
|
||||
return pathConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* 安全地拼接路径,避免路径分隔符重复
|
||||
* @param basePath 基础路径
|
||||
* @param additionalPath 要追加的路径
|
||||
* @return 拼接后的路径
|
||||
*/
|
||||
private String combinePath(String basePath, String additionalPath) {
|
||||
if (basePath == null || basePath.trim().isEmpty()) {
|
||||
return additionalPath;
|
||||
}
|
||||
if (additionalPath == null || additionalPath.trim().isEmpty()) {
|
||||
return basePath;
|
||||
}
|
||||
|
||||
// 确保basePath不以分隔符结尾
|
||||
String normalizedBasePath = basePath;
|
||||
if (basePath.endsWith("/") || basePath.endsWith("\\")) {
|
||||
normalizedBasePath = basePath.substring(0, basePath.length() - 1);
|
||||
}
|
||||
|
||||
// 确保additionalPath不以分隔符开头
|
||||
String normalizedAdditionalPath = additionalPath;
|
||||
if (additionalPath.startsWith("/") || additionalPath.startsWith("\\")) {
|
||||
normalizedAdditionalPath = additionalPath.substring(1);
|
||||
}
|
||||
|
||||
return normalizedBasePath + File.separator + normalizedAdditionalPath;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> insert(Map<String, Object> params) throws IOException {
|
||||
Integer entityId = (Integer)params.get("entityId");
|
||||
@@ -1012,7 +1041,7 @@ public class ImportService {
|
||||
Map<String,Object> map = (Map<String, Object>) list.get(0);
|
||||
int id = (Integer) map.get("id");
|
||||
// String saveUrl = request.getRealPath("/") + "uploadFile" + File.separator ;
|
||||
String saveUrl = uploadPath + File.separator + "uploadFile" + File.separator ;
|
||||
String saveUrl = combinePath(uploadPath, "uploadFile") + File.separator ;
|
||||
String replace=archiveNo;
|
||||
// if(archiveNo.contains("·")){
|
||||
// replace = archiveNo.replace("·", ".");
|
||||
@@ -1155,7 +1184,7 @@ public class ImportService {
|
||||
}
|
||||
Map<String,Object> map = (Map<String, Object>) list.get(0);
|
||||
int id = (Integer) map.get("id");
|
||||
String saveUrl = uploadPath + File.separator + "uploadFile" + File.separator ;
|
||||
String saveUrl = combinePath(uploadPath, "uploadFile") + File.separator ;
|
||||
String replace=archiveNo;
|
||||
String dir1 = saveUrl +"/"+ replace + '/';
|
||||
String dir = "uploadFile" +"/"+ replace + '/';
|
||||
@@ -1322,7 +1351,7 @@ public class ImportService {
|
||||
Map<String,Object> map = (Map<String, Object>) list.get(0);
|
||||
int id = (Integer) map.get("id");
|
||||
// String saveUrl = request.getRealPath("/") + "uploadFile" + File.separator ;
|
||||
String saveUrl = uploadPath + File.separator + "uploadFile" + File.separator ;
|
||||
String saveUrl = combinePath(uploadPath, "uploadFile") + File.separator ;
|
||||
String replace=archiveNo;
|
||||
// if(archiveNo.contains("·")){
|
||||
// replace = archiveNo.replace("·", ".");
|
||||
@@ -1465,7 +1494,7 @@ public class ImportService {
|
||||
|
||||
int id = (Integer) map.get("id");
|
||||
// String saveUrl = request.getRealPath("/") + "uploadFile" + File.separator ;
|
||||
String saveUrl = uploadPath + File.separator + "uploadFile" + File.separator ;
|
||||
String saveUrl = combinePath(uploadPath, "uploadFile") + File.separator ;
|
||||
String replace=(String) map.get("archive_no");
|
||||
// if(archiveNo.contains("·")){
|
||||
// replace = archiveNo.replace("·", ".");
|
||||
@@ -1835,7 +1864,7 @@ public class ImportService {
|
||||
List list = docSimpleMapper.selectObject(mapThree);
|
||||
Map<String,Object> map = (Map<String, Object>) list.get(0);
|
||||
int id = (Integer) map.get("id");
|
||||
String saveUrl = uploadPath + File.separator + "uploadFile" + File.separator ;
|
||||
String saveUrl = combinePath(uploadPath, "uploadFile") + File.separator ;
|
||||
String dir1 = saveUrl +"/"+ archiveNo + '/';
|
||||
String dir = "uploadFile" +"/"+ archiveNo + '/';
|
||||
File[] files1 = file.listFiles();
|
||||
@@ -1946,7 +1975,7 @@ public class ImportService {
|
||||
int i = 1;
|
||||
String pieceNo = file1.getName();
|
||||
String archiveNo = folderNo + "-" + pieceNo;
|
||||
String saveUrl = uploadPath + File.separator + "uploadFile" + File.separator ;
|
||||
String saveUrl = combinePath(uploadPath, "uploadFile") + File.separator ;
|
||||
String replace=archiveNo;
|
||||
// if(archiveNo.contains("·")){
|
||||
// replace = archiveNo.replace("·", ".");
|
||||
@@ -2092,7 +2121,7 @@ public class ImportService {
|
||||
int i = 1;
|
||||
String pieceNo = file1.getName();
|
||||
String archiveNo = folderNo + "-" + pieceNo;
|
||||
String saveUrl = uploadPath + File.separator + "uploadFile" + File.separator ;
|
||||
String saveUrl = combinePath(uploadPath, "uploadFile") + File.separator ;
|
||||
String replace=archiveNo;
|
||||
String dir1 = saveUrl +"/"+ replace + '/';
|
||||
String dir = "uploadFile" +"/"+ replace + '/';
|
||||
@@ -2595,7 +2624,7 @@ public class ImportService {
|
||||
//获取档号
|
||||
String[] split1 = picName.split("\\.");
|
||||
String archiveNo = split1[0];
|
||||
String saveUrl = uploadPath + File.separator + "uploadFile" + File.separator ;
|
||||
String saveUrl = combinePath(uploadPath, "uploadFile") + File.separator ;
|
||||
String dir1 = saveUrl +"/"+ archiveNo + '/';
|
||||
String dir = "uploadFile" +"/"+ archiveNo + '/';
|
||||
|
||||
@@ -2675,7 +2704,7 @@ public class ImportService {
|
||||
//获取档号
|
||||
String[] split1 = picName.split("\\.");
|
||||
String archiveNo = split1[0];
|
||||
String saveUrl = uploadPath + File.separator + "uploadFile" + File.separator ;
|
||||
String saveUrl = combinePath(uploadPath, "uploadFile") + File.separator ;
|
||||
String dir1 = saveUrl +"/"+ archiveNo + '/';
|
||||
String dir = "uploadFile" +"/"+ archiveNo + '/';
|
||||
|
||||
@@ -2754,7 +2783,7 @@ public class ImportService {
|
||||
//获取档号
|
||||
String[] split1 = picName.split("\\.");
|
||||
String archiveNo = split1[0];
|
||||
String saveUrl = uploadPath + File.separator + "uploadFile" + File.separator ;
|
||||
String saveUrl = combinePath(uploadPath, "uploadFile") + File.separator ;
|
||||
String dir1 = saveUrl +"/"+ archiveNo + '/';
|
||||
String dir = "uploadFile" +"/"+ archiveNo + '/';
|
||||
|
||||
@@ -2853,7 +2882,7 @@ public class ImportService {
|
||||
//获取档号
|
||||
String[] split1 = picName.split("\\.");
|
||||
String archiveNo = split1[0];
|
||||
String saveUrl = uploadPath + File.separator + "uploadFile" + File.separator ;
|
||||
String saveUrl = combinePath(uploadPath, "uploadFile") + File.separator ;
|
||||
String dir1 = saveUrl +"/"+ archiveNo + '/';
|
||||
String dir = "uploadFile" +"/"+ archiveNo + '/';
|
||||
|
||||
@@ -2923,7 +2952,7 @@ public class ImportService {
|
||||
//获取档号
|
||||
String[] split1 = picName.split("\\.");
|
||||
String archiveNo = split1[0];
|
||||
String saveUrl = uploadPath + File.separator + "uploadFile" + File.separator ;
|
||||
String saveUrl = combinePath(uploadPath, "uploadFile") + File.separator ;
|
||||
String dir1 = saveUrl +"/"+ archiveNo + '/';
|
||||
String dir = "uploadFile" +"/"+ archiveNo + '/';
|
||||
|
||||
@@ -3003,7 +3032,7 @@ public class ImportService {
|
||||
//获取档号
|
||||
String[] split1 = picName.split("\\.");
|
||||
String archiveNo = split1[0];
|
||||
String saveUrl = uploadPath + File.separator + "uploadFile" + File.separator ;
|
||||
String saveUrl = combinePath(uploadPath, "uploadFile") + File.separator ;
|
||||
String dir1 = saveUrl +"/"+ archiveNo + '/';
|
||||
String dir = "uploadFile" +"/"+ archiveNo + '/';
|
||||
|
||||
@@ -3083,7 +3112,7 @@ public class ImportService {
|
||||
//获取档号
|
||||
String[] split1 = picName.split("\\.");
|
||||
String archiveNo = split1[0];
|
||||
String saveUrl = uploadPath + File.separator + "uploadFile" + File.separator ;
|
||||
String saveUrl = combinePath(uploadPath, "uploadFile") + File.separator ;
|
||||
String dir1 = saveUrl +"/"+ archiveNo + '/';
|
||||
String dir = "uploadFile" +"/"+ archiveNo + '/';
|
||||
|
||||
@@ -3168,7 +3197,7 @@ public class ImportService {
|
||||
// //获取档号
|
||||
// String[] split1 = picName.split("\\.");
|
||||
// String archiveNo = split1[0];
|
||||
// String saveUrl = uploadPath + File.separator + "uploadFile" + File.separator ;
|
||||
// String saveUrl = combinePath(uploadPath, "uploadFile") + File.separator ;
|
||||
// String dir1 = saveUrl +"/"+ archiveNo + '/';
|
||||
// String dir = "uploadFile" +"/"+ archiveNo + '/';
|
||||
//
|
||||
@@ -3281,7 +3310,7 @@ public class ImportService {
|
||||
// //获取档号
|
||||
// String[] split1 = picName.split("\\.");
|
||||
// String archiveNo = split1[0];
|
||||
// String saveUrl = uploadPath + File.separator + "uploadFile" + File.separator ;
|
||||
// String saveUrl = combinePath(uploadPath, "uploadFile") + File.separator ;
|
||||
// String dir1 = saveUrl +"/"+ archiveNo + '/';
|
||||
// String dir = "uploadFile" +"/"+ archiveNo + '/';
|
||||
//
|
||||
@@ -3402,7 +3431,7 @@ public class ImportService {
|
||||
// //获取档号
|
||||
// String[] split1 = picName.split("\\.");
|
||||
// String archiveNo = split1[0];
|
||||
// String saveUrl = uploadPath + File.separator + "uploadFile" + File.separator ;
|
||||
// String saveUrl = combinePath(uploadPath, "uploadFile") + File.separator ;
|
||||
// String dir1 = saveUrl +"/"+ archiveNo + '/';
|
||||
// String dir = "uploadFile" +"/"+ archiveNo + '/';
|
||||
//
|
||||
@@ -3522,7 +3551,7 @@ public class ImportService {
|
||||
// //获取档号
|
||||
// String[] split1 = picName.split("\\.");
|
||||
// String archiveNo = split1[0];
|
||||
// String saveUrl = uploadPath + File.separator + "uploadFile" + File.separator ;
|
||||
// String saveUrl = combinePath(uploadPath, "uploadFile") + File.separator ;
|
||||
// String dir1 = saveUrl +"/"+ archiveNo + '/';
|
||||
// String dir = "uploadFile" +"/"+ archiveNo + '/';
|
||||
//
|
||||
@@ -3652,7 +3681,7 @@ public class ImportService {
|
||||
for (File file1 : files1) {
|
||||
String pieceNo = file1.getName();
|
||||
String archiveNo = folderNo + "-" + pieceNo;
|
||||
String saveUrl = uploadPath + File.separator + "uploadFile" + File.separator ;
|
||||
String saveUrl = combinePath(uploadPath, "uploadFile") + File.separator ;
|
||||
String dir1 = saveUrl +"/"+ archiveNo + '/';
|
||||
String dir = "uploadFile" +"/"+ archiveNo + '/';
|
||||
//获取id
|
||||
@@ -3944,7 +3973,7 @@ public class ImportService {
|
||||
// }
|
||||
// }
|
||||
// }.start();
|
||||
String fullPath = uploadPath + File.separator + dir;
|
||||
String fullPath = combinePath(uploadPath, dir);
|
||||
fieldName.append("page_no,"+"rec_id," + "file_name,"+ "file_type," + "file_len," + "file_path,"+ "file_des,"+"file_status," + "file_name_server");
|
||||
valueName.append(pageNo + "," + recId + "," +"'"+imgName+"'" + "," + "'"+type+"'" + "," + length + "," + "'"+dir+"'"+ "," + "'"+fullPath+"'" + "," + 1 + "," + "'"+imgName+"'");
|
||||
mapTwo.put("tableName", tableName);
|
||||
|
||||
@@ -65,6 +65,7 @@ archiveXML:
|
||||
generate: ${ARCHIVE_XML_GENERATE:false}
|
||||
|
||||
# 生产环境文件路径配置(Docker环境安全路径)
|
||||
# 注意:所有路径都不应该以斜杠结尾,避免路径拼接时出现双斜杠问题
|
||||
upload:
|
||||
path: ${UPLOAD_PATH:/app/data/upload}
|
||||
temp:
|
||||
@@ -72,9 +73,9 @@ temp:
|
||||
unzip:
|
||||
path: ${UNZIP_PATH:/app/data/unzip}
|
||||
img:
|
||||
upload: ${IMG_UPLOAD_PATH:/app/data/images}
|
||||
upload: ${IMG_UPLOAD_PATH:/app/data/images} # 注意:不以斜杠结尾
|
||||
report:
|
||||
path: ${REPORT_PATH:/app/data/reports}
|
||||
path: ${REPORT_PATH:/app/data/reports} # 注意:不以斜杠结尾
|
||||
|
||||
# 网络上传文件临时路径配置(Docker环境安全路径)
|
||||
net:
|
||||
|
||||
Reference in New Issue
Block a user