Browse Source

文件版本低,导入失败

liujc 1 year ago
parent
commit
1136a91f5b

+ 9 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/ExcelAnalyseCoreServiceImpl.java

@@ -15,9 +15,11 @@ import com.yonge.cooleshow.biz.dal.service.ExcelAnalyseCoreService;
 import com.yonge.cooleshow.biz.dal.service.FileImportInfoService;
 import com.yonge.cooleshow.biz.dal.service.TenantAccountRecordService;
 import com.yonge.cooleshow.biz.dal.wrapper.FileImportInfoWrapper;
+import com.yonge.toolset.base.exception.BizException;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.openxml4j.exceptions.NotOfficeXmlFileException;
 import org.joda.time.DateTime;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -73,7 +75,9 @@ public class ExcelAnalyseCoreServiceImpl implements ExcelAnalyseCoreService {
                         .build();
                 fileImportInfoService.update(importInfo);
 
-            } catch (Exception e) {
+            }catch (NotOfficeXmlFileException e) {
+                throw new BizException("上传文件格式版本太低");
+            }catch (Exception e) {
                 log.error("asyncAnalyseReadExcelData wrapper={}", wrapper.jsonString(), e);
             }
         });
@@ -100,6 +104,8 @@ public class ExcelAnalyseCoreServiceImpl implements ExcelAnalyseCoreService {
             fileImportInfoService.update(importInfo);
             return fileImportInfoService.getById(wrapper.getId());
 
+        }catch (NotOfficeXmlFileException e) {
+            throw new BizException("上传文件格式版本太低");
         } catch (Exception e) {
             log.error("asyncAnalyseReadExcelData wrapper={}", wrapper.jsonString(), e);
         }
@@ -154,6 +160,8 @@ public class ExcelAnalyseCoreServiceImpl implements ExcelAnalyseCoreService {
                 log.info("createFileImportRecord uploadFile={}, resp={}", uploadFile, context.getResp());
                 // 删除本地缓存文件
                 DownloadManager.getInstance().deleteOnExit(respPath);
+            } else if (StringUtils.isNotEmpty(respPath)) {
+                context.setResp(wrapper.getImportUrl());
             }
         }