فهرست منبع

导出文件异常返回

zhoutg 6 سال پیش
والد
کامیت
7d1fa51e44
1فایلهای تغییر یافته به همراه8 افزوده شده و 8 حذف شده
  1. 8 8
      common/src/main/java/com/diagbot/util/ExportBeanExcelUtil.java

+ 8 - 8
common/src/main/java/com/diagbot/util/ExportBeanExcelUtil.java

@@ -1,6 +1,8 @@
 package com.diagbot.util;
 
 import com.diagbot.dto.RespDTO;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
 import org.apache.poi.hssf.usermodel.HSSFCell;
 import org.apache.poi.hssf.usermodel.HSSFCellStyle;
 import org.apache.poi.hssf.usermodel.HSSFRow;
@@ -122,27 +124,25 @@ public class ExportBeanExcelUtil<T> {
                 }
             }
         }
-        RespDTO resultMode = new RespDTO();
         try {
-
-
             FileOutputStream exportXls = new FileOutputStream(lujing + fileName + ".xls");
             wb.write(exportXls);
             exportXls.close();
 /*		            resultMode.setResult(true);
 		            resultMode.setMessage(MSG_SUCCESS);*/
-            return resultMode.onSuc(MSG_SUCCESS);
+            return RespDTO.onSuc(MSG_SUCCESS);
         } catch (FileNotFoundException e) {
 /*		            System.out.println("导出失败!");
 		            resultMode.setResult(false);
 			        resultMode.setMessage(MSG_ERROR);*/
             e.printStackTrace();
-            return resultMode.onSuc(MSG_ERROR);
-
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "导出失败");
         } catch (IOException e) {
             e.printStackTrace();
-            return resultMode.onSuc(MSG_ERROR);
-
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "导出失败");
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "导出失败");
         }
 
         // return resultMode;