Selaa lähdekoodia

:hammer: 生成文件并导出zip时增加异常捕获

Twelve615 1 vuosi sitten
vanhempi
commit
f811a68530

+ 16 - 6
airport/jeecg-boot-module-system/src/main/java/org/jeecg/modules/admin_order/service/impl/AdminOrderServiceImpl.java

@@ -47,6 +47,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
 import java.util.List;
+import java.util.concurrent.Future;
 
 /**
  * @Description: 订单管理
@@ -268,17 +269,26 @@ public class AdminOrderServiceImpl extends ServiceImpl<AdminOrderMapper, AdminOr
             adminFileExportService.saveOrUpdateNoInfo(adminFileExport);
             return;
         }
-        JSONArray jsonArray = JSONUtil.parseArray(exportParam);
-        List<String> orderIdList = jsonArray.toList(String.class);
-        // 生成zip文件中的内容
-        List<String> genFileNameList = generatePdfFileByOrderList(orderIdList, outputFolder);
-        // 生成zip文件
+        List<String> orderIdList = null;
+        List<String> genFileNameList = null;
         File zip = null;
         try {
+            JSONArray jsonArray = JSONUtil.parseArray(exportParam);
+            orderIdList = jsonArray.toList(String.class);
+            // 生成zip文件中的内容
+            genFileNameList = generatePdfFileByOrderList(orderIdList, outputFolder);
+            // 生成zip文件
             zip = ZipUtil.zip(outputFolder);
-        } catch (UtilException e) {
+        } catch (Exception e) {
+            adminFileExport.setFileNum(0);
+            adminFileExport.setFileSize(0L);
+            adminFileExport.setExportStatus("2");
+            adminFileExport.setExportDesc("生成文件时出现异常");
+            adminFileExport.setUrl(systemHost + "/sys/common/static/tempFile/" + adminFileExport.getName());
+            adminFileExportService.saveOrUpdateNoInfo(adminFileExport);
             throw new RuntimeException(e);
         }
+
         adminFileExport.setFileNum(genFileNameList.size());
         adminFileExport.setFileSize(zip.length());
         adminFileExport.setUrl(systemHost + "/sys/common/static/tempFile/" + adminFileExport.getName());