瀏覽代碼

变量导出4

jichaobo 3 年之前
父節點
當前提交
2dafecaf13

+ 6 - 3
fiveep-service/src/main/java/com/bizmatics/service/impl/DeviceAnalogVariableListServiceImpl.java

@@ -125,6 +125,7 @@ public class DeviceAnalogVariableListServiceImpl extends AbstractCrudService<Dev
     public String variableListExport( Integer siteId,String variableName,Integer dataArea) {
         Workbook workbook = null;
         File file = null;
+        final String[] err1 = {"导出文件失败"};
         try {
             ExportParams params = new ExportParams(null, "变量列表");
             workbook = ExcelExportUtil.exportBigExcel(params, DeviceAnalogVariableListExportVO.class,
@@ -132,7 +133,8 @@ public class DeviceAnalogVariableListServiceImpl extends AbstractCrudService<Dev
                         Page<DeviceAnalogVariableListOneVo> page = new Page<>(i, 30);
                         page = baseMapper.variableListExport(page,siteId, variableName, dataArea);
                         if (page.getRecords().isEmpty()){
-                            throw new BusinessException("表格数据为空");
+                            err1[0] ="导出失败,请填写监控设备";
+                            throw new BusinessException(err1[0]);
                         }
                         return new ArrayList<>(BeanMapperUtils.mapList(page.getRecords(), DeviceAnalogVariableListOneVo.class, DeviceAnalogVariableListExportVO.class));
                     }, null);
@@ -142,11 +144,12 @@ public class DeviceAnalogVariableListServiceImpl extends AbstractCrudService<Dev
                 FileOutputStream allListingFileOutputStream = new FileOutputStream(file);
                 workbook.write(allListingFileOutputStream);
             } else {
-                throw new BusinessException("表格数据为空");
+                err1[0] ="表格数据为空";
+                throw new BusinessException(err1[0]);
             }
         } catch (Exception e) {
             log.error("导出文件失败", e);
-            throw new BusinessException("导出文件失败");
+            throw new BusinessException(err1[0]);
         } finally {
             if (workbook != null) {
                 try {