ソースを参照

设备分页查询

李进 2 年 前
コミット
400b166c99

+ 5 - 0
device-api-service/src/main/java/com/xy/entity/DeviceInfo.java

@@ -71,6 +71,11 @@ public class DeviceInfo {
      */
     private Integer busyState;
 
+    /**
+     * 显示状态
+     */
+    private Integer showStatus;
+
     /**
      * 设备图片
      */

+ 12 - 0
device-api-service/src/main/java/com/xy/mapper/DeviceInfoMapper.java

@@ -1,7 +1,11 @@
 package com.xy.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.xy.dto.DeviceInfoDto;
 import com.xy.entity.DeviceInfo;
+import com.xy.mapper.entity.DeviceInfoQueryPage;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * <p>
@@ -13,4 +17,12 @@ import com.xy.entity.DeviceInfo;
  */
 public interface DeviceInfoMapper extends BaseMapper<DeviceInfo> {
 
+    /**
+     * 分页查询
+     *
+     * @param page
+     * @param queryPage
+     * @return
+     */
+    IPage<DeviceInfoQueryPage> queryPage(IPage page, @Param("queryPage") DeviceInfoDto.Page queryPage);
 }

+ 45 - 0
device-api-service/src/main/java/com/xy/mapper/entity/DeviceInfoQueryPage.java

@@ -0,0 +1,45 @@
+package com.xy.mapper.entity;
+
+import com.xy.entity.DeviceInfo;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+@Data
+@Accessors(chain = true)
+public class DeviceInfoQueryPage extends DeviceInfo {
+
+    /**
+     * 安卓版本号
+     */
+    private String androidVersion;
+
+    /**
+     * sn号
+     */
+    private String deviceSn;
+
+    /**
+     * 联网状态
+     */
+    private Integer netState;
+
+    /**
+     * 商户名称
+     */
+    private String mercName;
+
+    /**
+     * 联网类型
+     */
+    private String netType;
+
+    /**
+     * 信号强度
+     */
+    private Integer netDbm;
+
+    /**
+     * 锁机状态
+     */
+    private Integer deviceState;
+}

+ 10 - 1
device-api-service/src/main/java/com/xy/service/DeviceInfoServiceImpl.java

@@ -1,6 +1,7 @@
 package com.xy.service;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.xy.collections.list.JArrayList;
 import com.xy.collections.list.JList;
@@ -12,6 +13,7 @@ import com.xy.dto.DeviceSysinfoDto;
 import com.xy.entity.DeviceInfo;
 import com.xy.entity.SysDictRedis;
 import com.xy.mapper.DeviceInfoMapper;
+import com.xy.mapper.entity.DeviceInfoQueryPage;
 import com.xy.utils.*;
 import com.xy.utils.enums.DeviceEnum;
 import io.swagger.annotations.Api;
@@ -25,7 +27,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import java.util.ArrayList;
 import java.util.List;
 
-import static com.xy.utils.PlusBeans.copy;
+import static com.xy.utils.PlusBeans.*;
 
 /**
  * <p>
@@ -126,4 +128,11 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
         updateById(deviceInfo);
         return R.ok();
     }
+
+    @ApiOperation("分页查询")
+    @PostMapping("page")
+    public R<PageBean<DeviceInfoDto.Vo2>> page(@RequestBody DeviceInfoDto.Page page) {
+        IPage<DeviceInfoQueryPage> iPage = baseMapper.queryPage(toIPage(page.getPage()), page);
+        return R.ok(toPageBean(DeviceInfoDto.Vo2.class, iPage));
+    }
 }

+ 55 - 0
device-api-service/src/main/resources/mapper/DeviceInfoMapper.xml

@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.xy.mapper.DeviceInfoMapper">
+
+    <!-- 分页查询 -->
+    <select id="queryPage" resultType="com.xy.mapper.entity.DeviceInfoQueryPage">
+        select
+        info.*,
+        sysinfo.android_version, sysinfo.device_sn,
+        status.net_state, status.net_type, status.net_dbm, status.device_state
+        mr.merc_name
+        from device_info info
+        join device_sysinfo sysinfo on(info.device_id = sysinfo.device_id)
+        join device_status status on(info.device_id = status.device_id)
+        left join merc_register mr on(info.merc_id = mr.merc_id)
+        where
+        info.show_status = #{queryPage.showStatus}
+        <if test="queryPage.no != null and queryPage.no != ''">
+            and (
+                LOCATE(#{queryPage.no}, info.device_id) > 0 or LOCATE(#{queryPage.no}, info.merc_device_code) > 0 or LOCATE(#{queryPage.no}, sysinfo.device_sn) > 0
+            )
+        </if>
+        <if test="queryPage.activeState != null">
+            and info.active_state = #{queryPage.activeState}
+        </if>
+        <if test="queryPage.netState != null">
+            and status.net_state = #{queryPage.netState}
+        </if>
+        <if test="queryPage.busyState != null">
+            and info.busy_state = #{queryPage.busyState}
+        </if>
+        <if test="queryPage.deviceType != null">
+            and info.device_type = #{queryPage.deviceType}
+        </if>
+        <if test="queryPage.merc != null and queryPage.merc != ''">
+            and (
+            info.merc_id = #{queryPage.merc} or info.merc_code = #{queryPage.merc} or LOCATE(#{queryPage.merc}, mr.merc_name) > 0
+            )
+        </if>
+        <if test="queryPage.appUpmVersion != null and queryPage.appUpmVersion != ''">
+            and sysinfo.app_upm_version = #{appUpmVersion}
+        </if>
+        <if test="queryPage.appDownmVersion != null and queryPage.appDownmVersion != ''">
+            and sysinfo.app_downm_version = #{queryPage.appDownmVersion}
+        </if>
+        <if test="queryPage.beginActiveTime != null and queryPage.beginActiveTime != ''">
+            and info.active_time >= #{queryPage.beginActiveTime}
+        </if>
+        <if test="queryPage.endActiveTime != null and queryPage.endActiveTime != ''">
+            and info.active_time &lt;= #{queryPage.endActiveTime}
+        </if>
+        order by create_time desc
+    </select>
+
+</mapper>

+ 36 - 3
device-api/src/main/java/com/xy/dto/DeviceInfoDto.java

@@ -53,9 +53,6 @@ public class DeviceInfoDto {
         @ApiModelProperty("下位机版本号")
         private String appDownmVersion;
 
-        @ApiModelProperty("质量状态")
-        private Integer qualityState;
-
         @JsonFormat(pattern = "yyyy-MM-dd")
         @ApiModelProperty(value = "激活时间-起")
         private LocalDate beginActiveTime;
@@ -72,6 +69,14 @@ public class DeviceInfoDto {
             return endActiveTime == null ? null : endActiveTime.atTime(23, 59, 59);
         }
 
+        @ApiModelProperty(value = "系统信息", hidden = true)
+        private DeviceSysinfoDto.Vo deviceSysinfo;
+
+        @ApiModelProperty(value = "状态信息", hidden = true)
+        private DeviceStatusDto.Vo deviceStatus;
+
+        @ApiModelProperty(value = "注册信息", hidden = true)
+        private DeviceRegisterDto.Vo deviceRegister;
     }
 
     @Data
@@ -112,6 +117,9 @@ public class DeviceInfoDto {
         @ApiModelProperty("运营状态")
         private Integer busyState;
 
+        @ApiModelProperty("显示状态")
+        private Integer showStatus;
+
         @ApiModelProperty("设备图片")
         private String deviceImg;
 
@@ -133,4 +141,29 @@ public class DeviceInfoDto {
         private DeviceRegisterDto.Vo deviceRegister;
     }
 
+    @Data
+    @Accessors(chain = true)
+    public static class Vo2 extends Vo {
+
+        @ApiModelProperty("安卓版本号")
+        private String androidVersion;
+
+        @ApiModelProperty("sn号")
+        private String deviceSn;
+
+        @ApiModelProperty("联网状态")
+        private Integer netState;
+
+        @ApiModelProperty("商户名称")
+        private String mercName;
+
+        @ApiModelProperty("联网类型")
+        private String netType;
+
+        @ApiModelProperty("信号强度")
+        private Integer netDbm;
+
+        @ApiModelProperty("锁机状态")
+        private Integer deviceState;
+    }
 }