liutao 2 nedēļas atpakaļ
vecāks
revīzija
b04a8e4700

+ 16 - 5
YHYZT/client/src/views/DataManage/Gd.vue

@@ -291,7 +291,7 @@ export default {
     },
     doInput(file){
       let params = new FormData();
-      params.append("file",file);
+      params.append("file", file);
       const loading = this.$loading({
         lock: true,
         text: '正在导入中',
@@ -300,10 +300,21 @@ export default {
       });
       this.$ajax.post('/api/stgddk/upload', params, this).then(res => {
         loading.close();
-         if (res) {
-          this.$Message.success("导入成功!")
-         }
-      })
+        if (res.success) {
+          this.$Message.success("导入成功!");
+          this.queryByPage && this.queryByPage(); // 成功后刷新数据
+        } else {
+          if (res.data && Array.isArray(res.data)) {
+            res.data.forEach(msg => this.$Message.error(msg));
+          } else {
+            this.$Message.error(res.message || "导入失败!");
+          }
+        }
+      }).catch(error => {
+        loading.close();
+        this.$Message.error("上传失败,请重试!");
+        console.error(error);
+      });
     },
     saveDataset(dataset, type = 'shapefile') {
       const fileContent = exportFileContent(dataset, { format: type })

+ 16 - 5
YHYZT/client/src/views/DataManage/Lsyd.vue

@@ -273,19 +273,30 @@ export default {
     },
     doInput(file){
       let params = new FormData();
-      params.append("file",file);
+      params.append("file", file);
       const loading = this.$loading({
         lock: true,
         text: '正在导入中',
         spinner: 'el-icon-loading',
         background: 'rgba(0, 0, 0, 0.7)'
       });
-      this.$ajax.post('/api/data/upload/lsyd/zip', params, this).then(res => {
+      this.$ajax.post('/api/templand/upload', params, this).then(res => {
         loading.close();
-         if (res) {
-          this.$Message.error("导入成功!")
+        if (res.success) {
+          this.$Message.success("导入成功!");
+          this.queryByPage && this.queryByPage(); // 成功后刷新数据
+        } else {
+          if (res.data && Array.isArray(res.data)) {
+            res.data.forEach(msg => this.$Message.error(msg));
+          } else {
+            this.$Message.error(res.message || "导入失败!");
+          }
         }
-      })
+      }).catch(error => {
+        loading.close();
+        this.$Message.error("上传失败,请重试!");
+        console.error(error);
+      });
     },
   }
 }

+ 18 - 7
YHYZT/client/src/views/DataManage/Nzy.vue

@@ -281,19 +281,30 @@ export default {
     },
     doInput(file){
       let params = new FormData();
-       params.append("file",file);
+      params.append("file", file);
       const loading = this.$loading({
         lock: true,
         text: '正在导入中',
         spinner: 'el-icon-loading',
         background: 'rgba(0, 0, 0, 0.7)'
       });
-       this.$ajax.post('/api/stnzy/upload', params, this).then(res => {
-         loading.close();
-         if (res) {
-          this.$Message.success("导入成功!")
-         }
-       })
+      this.$ajax.post('/api/stnzy/upload', params, this).then(res => {
+        loading.close();
+        if (res.success) {
+          this.$Message.success("导入成功!");
+          this.queryByPage && this.queryByPage(); // 成功后刷新数据
+        } else {
+          if (res.data && Array.isArray(res.data)) {
+            res.data.forEach(msg => this.$Message.error(msg));
+          } else {
+            this.$Message.error(res.message || "导入失败!");
+          }
+        }
+      }).catch(error => {
+        loading.close();
+        this.$Message.error("上传失败,请重试!");
+        console.error(error);
+      });
     },
     saveDataset(dataset, type = 'shapefile') {
       const fileContent = exportFileContent(dataset, { format: type })

+ 16 - 6
YHYZT/client/src/views/DataManage/Ssnyd.vue

@@ -292,20 +292,30 @@ export default {
     },
     doInput(file){
       let params = new FormData();
-      params.append("file",file);
-      let _this = this;
+      params.append("file", file);
       const loading = this.$loading({
         lock: true,
         text: '正在导入中',
         spinner: 'el-icon-loading',
         background: 'rgba(0, 0, 0, 0.7)'
       });
-      this.$ajax.post('/api/data/upload/ssnyd/zip', params, this).then(res => {
+      this.$ajax.post('/api/ssnyd/upload', params, this).then(res => {
         loading.close();
-         if (res) {
-          this.$Message.error("导入成功!")
+        if (res.success) {
+          this.$Message.success("导入成功!");
+          this.queryByPage && this.queryByPage(); // 成功后刷新数据
+        } else {
+          if (res.data && Array.isArray(res.data)) {
+            res.data.forEach(msg => this.$Message.error(msg));
+          } else {
+            this.$Message.error(res.message || "导入失败!");
+          }
         }
-      })
+      }).catch(error => {
+        loading.close();
+        this.$Message.error("上传失败,请重试!");
+        console.error(error);
+      });
     },
     saveFileContent(fileContent) {
       var zip = new JSZip()

+ 36 - 1
YHYZT/server/src/main/java/com/zjugis/yzt/service/impl/StNzydkServiceImpl.java

@@ -18,6 +18,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
 import java.util.*;
 
 
@@ -178,7 +179,22 @@ public class StNzydkServiceImpl extends ServiceImpl<StNzydkMapper, StNzydk> impl
             stNzydk.setPch(batchInfo.containsKey("批次名称") ? String.valueOf(batchInfo.get("批次名称")) : null);
             stNzydk.setLx(batchInfo.containsKey("类型") ? String.valueOf(batchInfo.get("类型")) : null);
             stNzydk.setPwh(batchInfo.containsKey("批准文号") ? String.valueOf(batchInfo.get("批准文号")) : null);
-            stNzydk.setPzrq(batchInfo.containsKey("批准日期") ? String.valueOf(batchInfo.get("批准日期")) : null);
+            // 解析批准日期为Date并格式化为yyyy-MM-dd字符串
+            String pzrqStr = batchInfo.containsKey("批准日期") ? String.valueOf(batchInfo.get("批准日期")) : null;
+            if (pzrqStr != null && !pzrqStr.isEmpty()) {
+                try {
+                    Date pzrqDate = parseDate(pzrqStr);
+                    java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd");
+                    stNzydk.setPzrq(sdf.format(pzrqDate));
+                } catch (Exception e) {
+                    String msg = String.format("批准日期格式化失败: %s,错误:%s", pzrqStr, e.getMessage());
+                    log.warn(msg);
+                    errorList.add(msg);
+                    stNzydk.setPzrq(pzrqStr); // 回退为原始字符串
+                }
+            } else {
+                stNzydk.setPzrq(null);
+            }
             stNzydk.setPzMj(parseBigDecimal(batchInfo.containsKey("批次总面积(公顷)") ? String.valueOf(batchInfo.get("批次总面积(公顷)")) : null));
             stNzydk.setNmjf(batchInfo.containsKey("是否农民建房") ? String.valueOf(batchInfo.get("是否农民建房")) : null);
         } else {
@@ -235,4 +251,23 @@ public class StNzydkServiceImpl extends ServiceImpl<StNzydkMapper, StNzydk> impl
             return null;
         }
     }
+        /**
+     * 解析时间字段
+     * @param dateStr
+     * @return
+     * @throws java.text.ParseException
+     */
+    private static Date parseDate(String dateStr) throws java.text.ParseException {
+        List<SimpleDateFormat> formats = Arrays.asList(
+            new SimpleDateFormat("yyyy/MM/dd"),
+            new SimpleDateFormat("yyyy-MM-dd"),
+            new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH)
+        );
+        for (SimpleDateFormat sdf : formats) {
+            try {
+                return sdf.parse(dateStr);
+            } catch (java.text.ParseException ignored) {}
+        }
+        throw new java.text.ParseException("Unparseable date: \"" + dateStr + "\"", 0);
+    }
 } 

+ 1 - 1
YHYZT/server/src/main/resources/application-tinker.yml

@@ -58,5 +58,5 @@ tinker:
       token-header: ZJUGIS-Authorization
       header-prefix:
       # 过期时间 2 小时
-      expiration: 7200
+      expiration: 86400
       secret: sdewecdwqewecxc&1adas