فهرست منبع

通信设备-导出1

jichaobo 3 سال پیش
والد
کامیت
6598cc055a

+ 14 - 2
fiveep-controller/src/main/java/com/bizmatics/controller/web/DeviceController.java

@@ -201,20 +201,32 @@ public class DeviceController {
     /**
      * 站点管理-摄像头-导出
      *
-     * @param siteId 站点Id
+     * @param siteId     站点Id
      * @param deviceName 设备名称
      * @param deviceType 1:183用电设备,2:视频监控设备,3:171用电设备,4:173用电设备,5:158智能网关,6:其他
      * @return
      */
     @GetMapping("deviceExport")
-    public ApiResult<String> deviceExport(@RequestParam Integer siteId,
+    public ApiResult<String> deviceExport(@RequestParam(value = "siteId", required = false, defaultValue = "0") Integer siteId,
                                           @RequestParam(required = false) String deviceName,
                                           @RequestParam(value = "deviceType", required = false, defaultValue = "2") Integer deviceType) {
         return ApiResult.success(deviceService.deviceExport(deviceName, deviceType, siteId));
     }
 
+
+    /**
+     * 设备管理-通信设备-导出
+     * @param deviceName 设备名称
+     * @return
+     */
+    @GetMapping("correspondDeviceExport")
+    public ApiResult<String> correspondDeviceExport(@RequestParam(required = false) String deviceName) {
+        return ApiResult.success(deviceService.correspondDeviceExport(deviceName));
+    }
+
     /**
      * 通信设备-导入
+     *
      * @param multipartFile 导入文件
      * @return
      * @throws Exception

+ 84 - 0
fiveep-model/src/main/java/com/bizmatics/model/vo/CorrespondDeviceOneVO.java

@@ -0,0 +1,84 @@
+package com.bizmatics.model.vo;
+
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.util.Date;
+
+/**
+ * @author yq
+ * @date 2021/7/8 14:30
+ * 公用的图标VO
+ */
+@Builder
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class CorrespondDeviceOneVO {
+
+    /**
+     * 设备表主键ID
+     */
+    private Integer id;
+    /**
+     * 设备编号
+     */
+    private String deviceCode;
+    /**
+     * 设备名称
+     */
+    private String deviceName;
+    /**
+     * 设备地址
+     */
+    private String deviceAddress;
+    /**
+     * 安装时间
+     */
+    private Date installTime;
+    /**
+     * 设备状态
+     */
+    private Integer deviceStatus;
+    /**
+     * 最后通信时间
+     */
+    private Date statusTime;
+
+    /**
+     * 站点ID
+     */
+    private int siteId;
+    /**
+     * 站点名称
+     */
+    private String siteName;
+
+    /**
+     * 离线时长
+     */
+    private Integer offlineDuration;
+    /**
+     * 在线时长
+     */
+    private Integer onlineDuration;
+
+    /**
+     * sim卡号
+     */
+    private String sim;
+
+    /**
+     * 楼层
+     */
+    private Integer floor;
+
+    /**
+     * 设备类型
+     */
+    private Integer deviceType;
+
+
+}

+ 2 - 0
fiveep-service/src/main/java/com/bizmatics/service/DeviceService.java

@@ -62,5 +62,7 @@ public interface DeviceService extends CrudService<Device> {
 
     String deviceExport(String deviceName, Integer deviceType, Integer siteId);
 
+    String correspondDeviceExport(String deviceName);
+
     void deviceImport(MultipartFile multipartFile) throws Exception;
 }

+ 40 - 2
fiveep-service/src/main/java/com/bizmatics/service/impl/DeviceServiceImpl.java

@@ -339,10 +339,13 @@ public class DeviceServiceImpl extends AbstractCrudService<DeviceMapper, Device>
             ExportParams params = new ExportParams(null, "通信设备列表");
             workbook = ExcelExportUtil.exportBigExcel(params, DeviceExportVO.class,
                     (o, i) -> {
-
                         Page<Device> page = new Page<>(i, 30);
                         LambdaQueryWrapper<Device> queryWrapper = Wrappers.lambdaQuery();
-                        queryWrapper.eq(Device::getSiteId, siteId).eq(Device::getEnable, 1);
+                        queryWrapper.eq(Device::getEnable, 1);
+                        if (siteId!=0){
+                            queryWrapper.eq(Device::getSiteId, siteId);
+                        }
+
                         if (deviceType != 0) {
                             queryWrapper.eq(Device::getDeviceType, deviceType);
                         }
@@ -377,6 +380,41 @@ public class DeviceServiceImpl extends AbstractCrudService<DeviceMapper, Device>
         return file.getName();
     }
 
+    @Override
+    public String correspondDeviceExport(String deviceName) {
+        Workbook workbook = null;
+        File file = null;
+        try {
+            ExportParams params = new ExportParams(null, "通信设备列表");
+            workbook = ExcelExportUtil.exportBigExcel(params, CorrespondDeviceExportVO.class,
+                    (o, i) -> {
+                        int startCurrent = (i - 1) * 30;
+                        List<CorrespondDeviceVO> correspondDeviceList = baseMapper.CorrespondDeviceList(deviceName, startCurrent, 30);
+                        return new ArrayList<>(BeanMapperUtils.mapList(correspondDeviceList, CorrespondDeviceVO.class, CorrespondDeviceExportVO.class));
+                    }, null);
+            if (null != workbook) {
+                file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "通信设备列表", System.currentTimeMillis() + ""));
+                FileUtils.createFile(file.getAbsolutePath());
+                FileOutputStream allListingFileOutputStream = new FileOutputStream(file);
+                workbook.write(allListingFileOutputStream);
+            } else {
+                throw new BusinessException("表格数据为空");
+            }
+        } catch (Exception e) {
+            log.error("导出文件失败", e);
+            throw new BusinessException("导出文件失败");
+        } finally {
+            if (workbook != null) {
+                try {
+                    workbook.close();
+                } catch (IOException e) {
+                    log.error("===export spec=== 关闭workbook失败", e);
+                }
+            }
+        }
+        return file.getName();
+    }
+
 
     @Override
     public void deviceImport(MultipartFile multipartFile) throws Exception {

+ 80 - 0
fiveep-service/src/main/java/com/bizmatics/service/vo/CorrespondDeviceExportVO.java

@@ -0,0 +1,80 @@
+package com.bizmatics.service.vo;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class CorrespondDeviceExportVO {
+    /**
+     * 设备表主键ID
+     */
+    private Integer id;
+    /**
+     * 设备编号
+     */
+    @Excel(name = "设备编号", height = 6, width = 20)
+    private String deviceCode;
+    /**
+     * 设备名称
+     */
+    @Excel(name = "设备名称", height = 6, width = 20)
+    private String deviceName;
+    /**
+     * 设备地址
+     */
+    @Excel(name = "设备地址", height = 6, width = 20)
+    private String deviceAddress;
+
+    /**
+     * 设备状态
+     */
+    @Excel(name = "设备状态", height = 6, width = 20)
+    private Integer deviceStatus;
+    /**
+     * 最后通信时间
+     */
+    @Excel(name = "最后通信时间", height = 6, width = 20)
+    private Date statusTime;
+
+    /**
+     * 站点ID
+     */
+    @Excel(name = "站点ID", height = 6, width = 20)
+    private int siteId;
+    /**
+     * 站点名称
+     */
+    @Excel(name = "站点名称", height = 6, width = 20)
+    private String siteName;
+
+    /**
+     * 离线时长
+     */
+    @Excel(name = "离线时长", height = 6, width = 20)
+    private Integer offlineDuration;
+    /**
+     * 在线时长
+     */
+    @Excel(name = "在线时长", height = 6, width = 20)
+    private Integer onlineDuration;
+
+    /**
+     * sim卡号
+     */
+    @Excel(name = "sim卡号", height = 6, width = 20)
+    private String sim;
+
+    /**
+     * 楼层
+     */
+    @Excel(name = "楼层", height = 6, width = 20)
+    private Integer floor;
+
+    /**
+     * 设备类型
+     */
+    @Excel(name = "设备类型", height = 6, width = 20)
+    private Integer deviceType;
+}