فهرست منبع

Merge remote-tracking branch 'origin/master'

hechunping 2 سال پیش
والد
کامیت
3294f155dc

+ 2 - 1
device-api-service/pom.xml

@@ -76,5 +76,6 @@
             <artifactId>sys-sdk</artifactId>
             <version>1.0</version>
         </dependency>
+
     </dependencies>
-</project>
+</project>

+ 17 - 13
device-api-service/src/main/java/com/xy/service/DeviceInfoServiceImpl.java

@@ -20,6 +20,7 @@ import com.xy.entity.SysDictRedis;
 import com.xy.error.CommRuntimeException;
 import com.xy.mapper.DeviceInfoMapper;
 import com.xy.mapper.entity.DeviceInfoQueryPage;
+import com.xy.util.ExcelUtils;
 import com.xy.utils.*;
 import com.xy.utils.enums.DictEnum;
 import com.xy.utils.enums.DictSonEnum;
@@ -33,6 +34,9 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -213,16 +217,16 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
     @PostMapping("page")
     @ApiOperation("分页查询")
     public R<PageBean<DeviceInfoDto.Vo2>> page(@RequestBody DeviceInfoDto.Page page) {
-        //数据鉴权
-        boolean authByData = AuthorizeUtils.authByData(AuthorizeUtils.getSysId(), AuthorizeUtils.getUri());
-        if (!authByData) {
-            //todo 授权处理
-            boolean deviceAuth = true;
-            if (deviceAuth) {
-                page.setMerc(String.valueOf(AuthorizeUtils.getLoginId(Long.class)));
-            }
-        }
-        return queryPage(page);
+        return R.ok(queryPage(page));
+    }
+
+    @ApiOperation("导出设备列表")
+    @PostMapping("exportDevices")
+    public void exportDevices(HttpServletResponse response, @RequestBody @Valid DeviceInfoDto.Page page) throws IOException {
+        PageBean<DeviceInfoDto.Vo2> pageBean = queryPage(page);
+        List<DeviceInfoDto.Vo2> records = pageBean.getRecords();
+        // 输出
+        ExcelUtils.write(response, "设备列表.xls", "设备列表", DeviceInfoDto.DeviceExcelVO.class, Beans.copy(DeviceInfoDto.DeviceExcelVO.class, records));
     }
 
     @PostMapping("nearbyPage")
@@ -231,7 +235,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
         if (!Emptys.check(page.getLon()) || !Emptys.check(page.getLat())) {
             throw new CommRuntimeException("经纬度不能为空");
         }
-        return queryPage(page);
+        return R.ok(queryPage(page));
     }
 
     @ApiOperation("商户设备授权")
@@ -348,9 +352,9 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
         return list(Wrappers.<DeviceInfo>lambdaQuery().eq(DeviceInfo::getMercId, mercId));
     }
 
-    private R<PageBean<DeviceInfoDto.Vo2>> queryPage(DeviceInfoDto.Page page) {
+    private PageBean<DeviceInfoDto.Vo2> queryPage(DeviceInfoDto.Page page) {
         IPage<DeviceInfoQueryPage> iPage = baseMapper.queryPage(toIPage(page.getPage()), page);
-        return R.ok(toPageBean(DeviceInfoDto.Vo2.class, iPage));
+        return toPageBean(DeviceInfoDto.Vo2.class, iPage);
     }
 
     private <T> void check(T value, T value2, String msg) {

+ 8 - 1
device-api/pom.xml

@@ -23,5 +23,12 @@
             <artifactId>xy-common</artifactId>
             <version>1.0</version>
         </dependency>
+
+        <dependency>
+            <groupId>com.xy</groupId>
+            <artifactId>xy-excel</artifactId>
+            <version>1.0</version>
+        </dependency>
+
     </dependencies>
-</project>
+</project>

+ 38 - 0
device-api/src/main/java/com/xy/consts/DictConsts.java

@@ -0,0 +1,38 @@
+package com.xy.consts;
+
+
+/**
+ * 字典编码常量
+ *
+ * @author 谭斌
+ * @date 2023/02/15
+ */
+public class DictConsts {
+
+
+    /**
+     * 设备类型
+     */
+    public static final String DEVICE_TYPE = "device_type";
+
+    /**
+     * 设备-运营状态
+     */
+    public static final String DEVICE_BUSY_STATUS = "device_busy_status";
+
+    /**
+     * 设备-冻结状态
+     */
+    public static final String DEVICE_FREEZE_STATUS = "device_freeze_status";
+    /**
+     * 设备-激活状态
+     */
+    public static final String DEVICE_ACTIVE_STATUS = "device_active_status";
+
+    /**
+     * 设备故障等级
+     */
+    public static final String DEVICE_FAULT_LEVEL = "device_fault_level";
+
+
+}

+ 114 - 0
device-api/src/main/java/com/xy/dto/DeviceInfoDto.java

@@ -1,6 +1,10 @@
 package com.xy.dto;
 
+import com.alibaba.excel.annotation.ExcelProperty;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.xy.annotate.DictFormat;
+import com.xy.consts.DictConsts;
+import com.xy.convert.DictConvert;
 import com.xy.utils.DataTime;
 import com.xy.utils.PageBean;
 import io.swagger.annotations.ApiModelProperty;
@@ -129,9 +133,25 @@ public class DeviceInfoDto {
     @Accessors(chain = true)
     public static class Page extends Vo {
 
+        @ApiModelProperty("是否导出当前页")
+        private Boolean exportPage = true;
+
         @ApiModelProperty(value = "分页对象", required = true)
         private PageBean page;
 
+        /**
+         * size -1 不分页
+         *
+         * @return
+         */
+        public PageBean getPage() {
+            if (!this.exportPage) {
+                this.page.setSize(-1L);
+            }
+            return page;
+        }
+
+
         @ApiModelProperty("资产/sn/sim号")
         private String no;
 
@@ -174,27 +194,35 @@ public class DeviceInfoDto {
         public String getEndActiveTime() {
             return endActiveTime == null ? null : DataTime.toString(endActiveTime.atTime(23, 59, 59));
         }
+
+
     }
 
     @Data
     @Accessors(chain = true)
     public static class Vo {
 
+        @ExcelProperty("设备编号")
         @ApiModelProperty("设备id")
         private Long deviceId;
 
+        @ExcelProperty("设备名称")
         @ApiModelProperty("设备名称")
         private String deviceName;
 
+        @ExcelProperty(value = "设备类型", converter = DictConvert.class)
+        @DictFormat(DictConsts.DEVICE_TYPE)
         @ApiModelProperty("设备类型")
         private Integer deviceType;
 
+        @ExcelProperty("商户设备资产编号")
         @ApiModelProperty("商户设备资产编号")
         private String mercDeviceCode;
 
         @ApiModelProperty("商户id")
         private Long mercId;
 
+        @ExcelProperty(value = "商户编码")
         @ApiModelProperty("商户编码")
         private String mercCode;
 
@@ -210,6 +238,8 @@ public class DeviceInfoDto {
         @ApiModelProperty("区域id")
         private Long districtId;
 
+        @ExcelProperty(value = "激活状态", converter = DictConvert.class)
+        @DictFormat(DictConsts.DEVICE_ACTIVE_STATUS)
         @ApiModelProperty("激活状态")
         private Integer activeState;
 
@@ -217,12 +247,16 @@ public class DeviceInfoDto {
         @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
         private LocalDateTime activeTime;
 
+        @ExcelProperty(value = "运营状态", converter = DictConvert.class)
+        @DictFormat(DictConsts.DEVICE_BUSY_STATUS)
         @ApiModelProperty("运营状态")
         private Integer busyState;
 
         @ApiModelProperty("显示状态")
         private Boolean showStatus;
 
+        @ExcelProperty(value = "冻结状态", converter = DictConvert.class)
+        @DictFormat(DictConsts.DEVICE_FREEZE_STATUS)
         @ApiModelProperty("冻结状态")
         private Integer freezeStatus;
 
@@ -235,6 +269,8 @@ public class DeviceInfoDto {
         @ApiModelProperty("纬度")
         private String lat;
 
+        @ExcelProperty(value = "故障等级", converter = DictConvert.class)
+        @DictFormat(DictConsts.DEVICE_FAULT_LEVEL)
         @ApiModelProperty("故障等级")
         private Integer faultLevel;
 
@@ -249,6 +285,7 @@ public class DeviceInfoDto {
         @ApiModelProperty("系统信息")
         private DeviceSysinfoDto.Vo deviceSysinfo;
 
+
         @ApiModelProperty("状态信息")
         private DeviceStatusDto.Vo deviceStatus;
 
@@ -260,20 +297,97 @@ public class DeviceInfoDto {
     @Accessors(chain = true)
     public static class Vo2 extends Vo {
 
+        @ExcelProperty("所属商户")
         @ApiModelProperty("商户名称")
         private String mercName;
 
         @ApiModelProperty("距离")
         private Integer m;
 
+        @ExcelProperty("点位")
         @ApiModelProperty("点位名称")
         private String placeName;
 
+        @ExcelProperty("线路")
         @ApiModelProperty("线路名称")
         private String placeLineName;
+        @ExcelProperty("区域")
+        @ApiModelProperty("区域名称")
+        private String districtName;
+
+
+    }
+
+
+    @Data
+    @Accessors(chain = true)
+    public static class DeviceExcelVO {
+
+        @ExcelProperty("所属商户")
+        @ApiModelProperty("商户名称")
+        private String mercName;
+ 
 
+        @ExcelProperty("点位")
+        @ApiModelProperty("点位名称")
+        private String placeName;
+
+        @ExcelProperty("线路")
+        @ApiModelProperty("线路名称")
+        private String placeLineName;
+        @ExcelProperty("区域")
         @ApiModelProperty("区域名称")
         private String districtName;
+
+
+        @ExcelProperty("设备编号")
+        @ApiModelProperty("设备id")
+        private Long deviceId;
+
+        @ExcelProperty("设备名称")
+        @ApiModelProperty("设备名称")
+        private String deviceName;
+
+        @ExcelProperty(value = "设备类型", converter = DictConvert.class)
+        @DictFormat(DictConsts.DEVICE_TYPE)
+        @ApiModelProperty("设备类型")
+        private Integer deviceType;
+
+        @ExcelProperty("商户设备资产编号")
+        @ApiModelProperty("商户设备资产编号")
+        private String mercDeviceCode;
+
+        @ApiModelProperty("商户id")
+        private Long mercId;
+
+        @ExcelProperty(value = "商户编码")
+        @ApiModelProperty("商户编码")
+        private String mercCode;
+
+
+        @ExcelProperty(value = "激活状态", converter = DictConvert.class)
+        @DictFormat(DictConsts.DEVICE_ACTIVE_STATUS)
+        @ApiModelProperty("激活状态")
+        private Integer activeState;
+
+
+        @ExcelProperty(value = "运营状态", converter = DictConvert.class)
+        @DictFormat(DictConsts.DEVICE_BUSY_STATUS)
+        @ApiModelProperty("运营状态")
+        private Integer busyState;
+
+
+        @ExcelProperty(value = "冻结状态", converter = DictConvert.class)
+        @DictFormat(DictConsts.DEVICE_FREEZE_STATUS)
+        @ApiModelProperty("冻结状态")
+        private Integer freezeStatus;
+
+
+        @ExcelProperty(value = "故障等级", converter = DictConvert.class)
+        @DictFormat(DictConsts.DEVICE_FAULT_LEVEL)
+        @ApiModelProperty("故障等级")
+        private Integer faultLevel;
+
     }