From deb49773f332f83dafb78788bc3d9b2b39fa421c Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期一, 23 十二月 2024 09:50:03 +0800
Subject: [PATCH] 项目库上传后端逻辑完善

---
 business/src/main/java/com/ycl/listener/excel/ProjectImportListener.java |    1 
 business/src/main/java/com/ycl/controller/ProjectInfoController.java     |    2 
 business/src/main/java/com/ycl/domain/excel/ProjectExcelTemplate.java    |   81 ++++++++++++++++++++++------------------
 business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java  |   12 +++++-
 start/src/main/resources/application.yml                                 |    4 +-
 5 files changed, 59 insertions(+), 41 deletions(-)

diff --git a/business/src/main/java/com/ycl/controller/ProjectInfoController.java b/business/src/main/java/com/ycl/controller/ProjectInfoController.java
index 375f5ad..5ab6f3c 100644
--- a/business/src/main/java/com/ycl/controller/ProjectInfoController.java
+++ b/business/src/main/java/com/ycl/controller/ProjectInfoController.java
@@ -156,7 +156,7 @@
      * @return
      */
     @PostMapping("/import")
-    public Result importProject(@RequestPart("file") MultipartFile file) {
+    public Result importProject(MultipartFile file) {
         if (file.getSize() > 100 * 1024 * 1024) {
             throw new BaseException("鏂囦欢杩囧ぇ锛屾枃浠朵笉寰楄秴杩�100MB");
         }
diff --git a/business/src/main/java/com/ycl/domain/excel/ProjectExcelTemplate.java b/business/src/main/java/com/ycl/domain/excel/ProjectExcelTemplate.java
index b1fdfa3..510292d 100644
--- a/business/src/main/java/com/ycl/domain/excel/ProjectExcelTemplate.java
+++ b/business/src/main/java/com/ycl/domain/excel/ProjectExcelTemplate.java
@@ -1,12 +1,14 @@
 package com.ycl.domain.excel;
 
 import com.alibaba.excel.annotation.ExcelProperty;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ycl.common.enums.business.ImportanceTypeEnum;
 import com.ycl.common.enums.business.ProjectStatusEnum;
 import com.ycl.common.enums.business.ProjectTypeEnum;
 import com.ycl.common.utils.excel.annotation.ExcelEnumFormat;
 import com.ycl.common.utils.excel.convert.ExcelEnumConvert;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import org.springframework.format.annotation.DateTimeFormat;
 
@@ -90,12 +92,6 @@
     private String competentDepartment;
 
     /**
-     * 椤圭洰褰掑睘鍦�
-     */
-    @ExcelProperty(value = "椤圭洰褰掑睘鍦�")
-    private String projectLocation;
-
-    /**
      * 缁忓害
      */
     @ExcelProperty(value = "缁忓害")
@@ -113,11 +109,11 @@
     @ExcelProperty(value = "绠$悊褰掑彛")
     private String managementCentralization;
 
-    /**
-     * 椤圭洰鐢虫姤闃舵
-     */
-    @ExcelProperty(value = "椤圭洰鐢虫姤闃舵")
-    private String projectApplicationPhase;
+//    /**
+//     * 椤圭洰鐢虫姤闃舵
+//     */
+//    @ExcelProperty(value = "椤圭洰鐢虫姤闃舵")
+//    private String projectApplicationPhase;
 
     /**
      * 椤圭洰瀹℃壒绫诲瀷
@@ -125,11 +121,11 @@
     @ExcelProperty(value = "椤圭洰瀹℃壒绫诲瀷")
     private String projectApprovalType;
 
-    /**
-     * 鎶曡祫鐩綍
-     */
-    @ExcelProperty(value = "鎶曡祫鐩綍")
-    private String investmentCatalogue;
+//    /**
+//     * 鎶曡祫鐩綍
+//     */
+//    @ExcelProperty(value = "鎶曡祫鐩綍")
+//    private String investmentCatalogue;
 
     /**
      * 瀹℃壒璁″垝涔�
@@ -137,25 +133,25 @@
     @ExcelProperty(value = "瀹℃壒璁″垝涔︼紙闄勪欢鍚嶏級")
     private String approvalPlan;
 
-    /**
-     * 鏄惁绔嬮」
-     */
-    @ExcelProperty(value = "鏄惁绔嬮」")
-    private String isSetProject;
+//    /**
+//     * 鏄惁绔嬮」
+//     */
+//    @ExcelProperty(value = "鏄惁绔嬮」")
+//    private String isSetProject;
 
     /**
-     * 鎴愮珛鏃堕棿
+     * 绔嬮」鏃堕棿
      */
-    @ExcelProperty(value = "鎴愮珛鏃堕棿")
+    @ExcelProperty(value = "绔嬮」鏃堕棿")
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    private Date setTime;
+    private Date createProjectTime;
 
-    /**
-     * 璧嬬爜鐘舵��
-     */
-    @ExcelProperty(value = "璧嬬爜鐘舵��")
-    private String assignmentStatus;
+//    /**
+//     * 璧嬬爜鐘舵��
+//     */
+//    @ExcelProperty(value = "璧嬬爜鐘舵��")
+//    private String assignmentStatus;
 
     /**
      * 琛屾斂鍖哄垝
@@ -187,7 +183,7 @@
      * 璇︾粏鍦板潃
      */
     @ExcelProperty(value = "璇︾粏鍦板潃")
-    private String address;
+    private String projectAddress;
 
     /**
      * 寤鸿鍐呭
@@ -231,7 +227,9 @@
     @ExcelProperty(value = "鏈勾璁″垝鎶曡祫")
     private BigDecimal yearInvestAmount;
 
-
+    @ExcelProperty("浣跨敤鐘舵��")
+    /** 浣跨敤鐘舵�侊紙0锛氳崏绋匡紝1锛氭彁浜�,2:瀹℃牳閫氳繃锛�-1锛氶┏鍥烇級 */
+    private Integer usedStatus;
                                         /* 鎶曡祫椤圭洰鍩虹淇℃伅琛� */
 
     /**
@@ -604,37 +602,48 @@
      * 鏄惁灞炰簬銆婁骇涓氱粨鏋勮皟鏁存寚瀵肩洰褰曘�嬩笅鐨勯」鐩�
      */
     @ExcelProperty(value = "灞炰簬銆婁骇涓氱粨鏋勮皟鏁存寚瀵肩洰褰曘�嬩笅鐨勯」鐩�")
-    private String belongsToIndustryAdjustmentDirectory;
+    private Boolean belongsToIndustryAdjustmentDirectory;
 
     /**
      * 鏄惁灞炰簬鏈垪鍏ャ�婁骇涓氱粨鏋勮皟鏁存寚瀵肩洰褰曘�嬬殑鍏佽绫婚」鐩�
      */
     @ExcelProperty(value = "灞炰簬鏈垪鍏ャ�婁骇涓氱粨鏋勮皟鏁存寚瀵肩洰褰曘�嬬殑鍏佽绫婚」鐩�")
-    private String belongsToAllowedProjects;
+    private Boolean belongsToAllowedProjects;
 
     /**
      * 鏄惁灞炰簬銆婅タ閮ㄥ湴鍖洪紦鍔辩被浜т笟鐩綍銆嬬殑椤圭洰
      */
     @ExcelProperty(value = "灞炰簬銆婅タ閮ㄥ湴鍖洪紦鍔辩被浜т笟鐩綍銆嬬殑椤圭洰")
-    private String belongsToWesternEncouragedDirectory;
+    private Boolean belongsToWesternEncouragedDirectory;
 
     /**
      * 鏄惁涓嶅睘浜庝骇涓氭斂绛栫姝㈡姇璧勫缓璁炬垨瀹炶鏍稿噯銆佸鎵圭鐞嗙殑椤圭洰
      */
     @ExcelProperty(value = "涓嶅睘浜庝骇涓氭斂绛栫姝㈡姇璧勫缓璁炬垨瀹炶鏍稿噯銆佸鎵圭鐞嗙殑椤圭洰")
-    private String notBannedOrControlledProject;
+    private Boolean notBannedOrControlledProject;
 
     /**
      * 濉姤淇℃伅鏄惁鐪熷疄
      */
     @ExcelProperty(value = "濉姤淇℃伅鏄惁鐪熷疄")
-    private String informationIsTrue;
+    private Boolean informationIsTrue;
 
     /**
      * 涓撻」瑙勫垝澶嶅悎鎯呭喌
      */
     @ExcelProperty(value = "涓撻」瑙勫垝澶嶅悎鎯呭喌")
     private String specialPlanningCompliance;
+    /**
+     * 鑺傝兘瀹℃煡
+     */
+    @ExcelProperty(value = "鑺傝兘瀹℃煡")
+    private Boolean energyCheck;
+
+    /**
+     * 涓嶅啀鍗曠嫭杩涜鑺傝兘瀹℃煡鐨勭被鍨�
+     */
+    @ExcelProperty("涓嶅啀鍗曠嫭杩涜鑺傝兘瀹℃煡鐨勭被鍨�")
+    private Integer noOnlyCheckType;
 
     /**
      * 椤圭洰鑳借�楁儏鍐�
diff --git a/business/src/main/java/com/ycl/listener/excel/ProjectImportListener.java b/business/src/main/java/com/ycl/listener/excel/ProjectImportListener.java
index b535353..7d38308 100644
--- a/business/src/main/java/com/ycl/listener/excel/ProjectImportListener.java
+++ b/business/src/main/java/com/ycl/listener/excel/ProjectImportListener.java
@@ -85,6 +85,7 @@
         hasData = true;
         //澶勭悊椤圭洰鍩虹淇℃伅
         ProjectInfo projectInfo = BeanUtil.toBean(projectExcelTemplate, ProjectInfo.class);
+        //TODO锛氶」鐩爜鍙兘瑕佸湪杩欓噷琛ュ厖
         projectInfoService.checkProjectNameUnique(projectInfo);
         projectInfoService.save(projectInfo);
         //瀹℃壒璁″垝涔�
diff --git a/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java b/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java
index 0dd853d..7a70638 100644
--- a/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java
+++ b/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java
@@ -1,6 +1,8 @@
 package com.ycl.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.io.IORuntimeException;
+import cn.hutool.core.util.CharsetUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.ZipUtil;
@@ -570,7 +572,13 @@
             }
 
             tempDir = Files.createTempDirectory("temp-dir").toFile();
-            ZipUtil.unzip(tempZip, tempDir, StandardCharsets.ISO_8859_1);
+
+            try {
+                ZipUtil.unzip(tempZip, tempDir, CharsetUtil.CHARSET_UTF_8);
+            }catch (IORuntimeException e){
+                    log.error("瑙e帇澶辫触锛屽皾璇曚娇鐢℅BK缂栫爜瑙e帇...");
+                    ZipUtil.unzip(tempZip, tempDir, CharsetUtil.CHARSET_GBK);
+            }
 
             Path path = tempDir.toPath();
             ProjectImportListener projectImportListener = new ProjectImportListener();
@@ -609,7 +617,7 @@
             files.forEach(attachmentFile -> {
                 try {
                     //涓婁紶
-                    String url = FileUploadUtils.upload(filePath, file);
+                    String url = FileUploadUtils.uploadIOFile(filePath, attachmentFile);
                     //瀛樻斁鐨勬枃浠跺悕浼氬姞涓奯鏃堕棿鎴崇殑鍚庣紑
                     String newName = FileUtils.getName(url);
                     attachments.add(new File()
diff --git a/start/src/main/resources/application.yml b/start/src/main/resources/application.yml
index 462aa1d..3be20ad 100644
--- a/start/src/main/resources/application.yml
+++ b/start/src/main/resources/application.yml
@@ -64,9 +64,9 @@
   servlet:
     multipart:
       # 鍗曚釜鏂囦欢澶у皬
-      max-file-size: 10MB
+      max-file-size: 100MB
       # 璁剧疆鎬讳笂浼犵殑鏂囦欢澶у皬
-      max-request-size: 20MB
+      max-request-size: 100MB
   # 鏈嶅姟妯″潡
   devtools:
     restart:

--
Gitblit v1.8.0