|
|
@@ -40,6 +40,8 @@ import java.nio.file.Path;
|
|
|
import java.nio.file.Paths;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@@ -121,28 +123,36 @@ public class DealExcelServiceImpl {
|
|
|
String batchApprovalNum = batch.get("批复文号");
|
|
|
String reportDate = batch.get("报批日期");
|
|
|
String approvalDate = batch.get("批复日期");
|
|
|
+ approvalDate = this.parseChineseDate(approvalDate);
|
|
|
|
|
|
//todo 这里继续完善数据添加逻辑,目前先打印日志
|
|
|
log.info("项目名称:{},报征状态:{},批复文号:{},报批日期:{},批复日期:{}", projectName, reportStatus, batchApprovalNum, reportDate, approvalDate);
|
|
|
|
|
|
+ if(StringUtils.isBlank(projectName)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
YdbpDataVo ydbpDataVo = new YdbpDataVo();
|
|
|
- ydbpDataVo.setName(projectName + System.currentTimeMillis());
|
|
|
+ ydbpDataVo.setName("bp2_"+projectName);
|
|
|
+ ydbpDataVo.setPfDate(approvalDate);
|
|
|
ydbpDataVo.setPfwh(batchApprovalNum);
|
|
|
- ydbpDataVo.setBpDate(approvalDate);
|
|
|
|
|
|
String nodeId = ydbpDataService.add(ydbpDataVo);
|
|
|
+ ydbpDataService.updateHasOnchain(nodeId,true);
|
|
|
|
|
|
- String shpFileName = projectName + "shp.zip";
|
|
|
+ String shpFileName = projectName + ".zip";
|
|
|
//数据治理文件名
|
|
|
if (StringUtils.isNotBlank(projectName)) {
|
|
|
Path filePath = Paths.get(rootPathZip + "\\" + shpFileName);
|
|
|
- if (Files.exists(filePath) || !Files.isDirectory(filePath)) {
|
|
|
+ if (Files.exists(filePath) && !Files.isDirectory(filePath)) {
|
|
|
String fullFilePath = copyFileToDirectory(rootPathZip + "\\", targectDir, shpFileName);
|
|
|
R<TGeomDb> saveGeomRes = remoteSpatialFilesDbService.readShp(shpFileName, fullFilePath, "excel", SecurityConstants.INNER);
|
|
|
TGeomDb tGeomDb = saveGeomRes.getData();
|
|
|
log.info("远程调用geom保存,返回结果:{}", tGeomDb);
|
|
|
//这里保存geom映射关系
|
|
|
nodeLandService.createNodeLand(nodeId, tGeomDb.getId());
|
|
|
+ }else {
|
|
|
+ log.info("数据治理文件不存在--找不到矢量zip,路径:{}", filePath.toString());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -151,6 +161,8 @@ public class DealExcelServiceImpl {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 检查excel数据到数据库
|
|
|
*
|
|
|
@@ -462,10 +474,61 @@ public class DealExcelServiceImpl {
|
|
|
if (StringUtils.isBlank(dateStr)) {
|
|
|
return false;
|
|
|
}
|
|
|
- // 正则匹配:YYYY年MM月DD日 或 YYYY年M月D日
|
|
|
- return dateStr.matches("^\\d{4}年\\d{1,2}月\\d{1,2}日$");
|
|
|
+ // 匹配中文格式:2019年9月4日 或 2019年09月04日
|
|
|
+ // 斜杠格式:2019/9/10 或 2019/09/10
|
|
|
+ return dateStr.matches("^\\d{4}年\\d{1,2}月\\d{1,2}日$")
|
|
|
+ || dateStr.matches("^\\d{4}/\\d{1,2}/\\d{1,2}$");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验并格式化日期字符串(Excel 中读取)
|
|
|
+ * 支持格式:
|
|
|
+ * - 中文格式:2019年9月4日 / 2019年09月04日
|
|
|
+ * - 斜杠格式:2019/9/10 / 2019/09/10
|
|
|
+ *
|
|
|
+ * @param dateStr 原始日期字符串
|
|
|
+ * @return 格式化后的 yyyy-MM-dd,若格式不合法则返回 null
|
|
|
+ */
|
|
|
+ private String parseChineseDate(String dateStr) {
|
|
|
+ if (StringUtils.isBlank(dateStr)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 匹配中文格式:2019年9月4日
|
|
|
+ Pattern chinesePattern = Pattern.compile("^(\\d{4})年(\\d{1,2})月(\\d{1,2})日$");
|
|
|
+ // 匹配斜杠格式:2019/9/10
|
|
|
+ Pattern slashPattern = Pattern.compile("^(\\d{4})/(\\d{1,2})/(\\d{1,2})$");
|
|
|
+
|
|
|
+ Matcher matcher;
|
|
|
+ int year, month, day;
|
|
|
+
|
|
|
+ if ((matcher = chinesePattern.matcher(dateStr)).matches()) {
|
|
|
+ year = Integer.parseInt(matcher.group(1));
|
|
|
+ month = Integer.parseInt(matcher.group(2));
|
|
|
+ day = Integer.parseInt(matcher.group(3));
|
|
|
+ } else if ((matcher = slashPattern.matcher(dateStr)).matches()) {
|
|
|
+ year = Integer.parseInt(matcher.group(1));
|
|
|
+ month = Integer.parseInt(matcher.group(2));
|
|
|
+ day = Integer.parseInt(matcher.group(3));
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 二次校验:月/日范围合法性
|
|
|
+ if (month < 1 || month > 12 || day < 1 || day > 31) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 格式化输出 yyyy-MM-dd(零填充)
|
|
|
+ return String.format("%04d-%02d-%02d", year, month, day);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 校验面积单位(用于addExcelDataToDb)
|
|
|
*/
|
|
|
@@ -870,7 +933,7 @@ public class DealExcelServiceImpl {
|
|
|
|
|
|
if (StringUtils.isBlank(fullFilePath)) {
|
|
|
filePath = Paths.get(rootPath2020 + "\\" + projectFileName);
|
|
|
- if (Files.exists(filePath) || Files.isDirectory(filePath)) {
|
|
|
+ if (Files.exists(filePath) && Files.isDirectory(filePath)) {
|
|
|
fullFilePath = copyFileToDirectory(rootPath2019 + "\\" + projectFileName, targectDir + "\\" + projectFileName, nodeFileName);
|
|
|
}
|
|
|
}
|
|
|
@@ -879,8 +942,11 @@ public class DealExcelServiceImpl {
|
|
|
//这里进行文件关联
|
|
|
String nodeAttachmentId = associationFile(fullFilePath, projectId, nodeId);
|
|
|
log.info("关于项目{}的土地供应环节,文件{}关联结果{}", projectId, nodeFileName, nodeAttachmentId);
|
|
|
+ }else {
|
|
|
+ log.warn("未找到数据治理文件名称--附件材料:{},请确认文件是否存在于路径{}或{}", projectFileName, rootPath2019, rootPath2020);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|