ソースを参照

修复批量导入BUG

lin 4 年 前
コミット
088b1924ae

+ 5 - 2
smart-city-platform/src/main/java/com/bz/smart_city/excel/AbstractResolverExcelTemplate.java

@@ -1,5 +1,6 @@
 package com.bz.smart_city.excel;
 
+import com.alibaba.fastjson.JSON;
 import com.bz.smart_city.commom.util.FileUtil;
 import com.bz.smart_city.commom.util.Util;
 import com.bz.smart_city.entity.Import;
@@ -11,6 +12,7 @@ import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Component;
 
 import java.io.FileInputStream;
@@ -24,6 +26,7 @@ import java.util.concurrent.atomic.AtomicInteger;
  */
 @Slf4j
 @Component
+@Scope("prototype")
 public abstract class AbstractResolverExcelTemplate {
 
     @Value("${files.path}")
@@ -75,7 +78,6 @@ public abstract class AbstractResolverExcelTemplate {
             failFile();
             recordMessage();
         } catch (Exception e) {
-            e.printStackTrace();
             messageContent.append("导入失败,读取文件错误。");
             Message message = new Message();
             message.setSiteId(record.getUserId());
@@ -86,7 +88,7 @@ public abstract class AbstractResolverExcelTemplate {
             message.setObjId(record.getId());
             message.setRead(0);
             messageService.insertSelective(message);
-            log.error("read excel error = " + e.getMessage());
+            log.error("read excel error = {} {}" , e.getMessage(), JSON.toJSON(e));
         }finally {
             FileUtil.deleteFile(record.getImportFilePath());
             try {
@@ -118,6 +120,7 @@ public abstract class AbstractResolverExcelTemplate {
                 os.close();
                 record.setFailFilePath(FailFilePath);
             }catch (Exception e){
+                log.error("failFile error = {} {}" , e.getMessage(), JSON.toJSON(e));
                 e.printStackTrace();
             }