Your Name 2 년 전
부모
커밋
4953c5753f

+ 18
- 19
src/main/java/com/yunzhi/nanyang/controller/TdDeviceController.java 파일 보기

@@ -52,25 +52,24 @@ public class TdDeviceController extends BaseController {
52 52
     @Autowired
53 53
     public ITaMachineryService iTaMachineryService;
54 54
 
55
-//
56
-//    /**
57
-//     * 分页查询列表
58
-//     * @param pageNum
59
-//     * @param pageSize
60
-//     * @return
61
-//     */
62
-//    @RequestMapping(value="/tdDevice",method= RequestMethod.GET)
63
-//    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
64
-//    public ResponseBean tdDeviceList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
65
-//									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
66
-//
67
-//		    IPage<TdDevice> pg = new Page<>(pageNum, pageSize);
68
-//            QueryWrapper<TdDevice> queryWrapper = new QueryWrapper<>();
69
-//            queryWrapper.orderByDesc("create_date");
70
-//
71
-//            IPage<TdDevice> result = iTdDeviceService.page(pg, queryWrapper);
72
-//            return ResponseBean.success(result);
73
-//    }
55
+
56
+    /**
57
+     * 分页查询列表
58
+     * @param pageNum
59
+     * @param pageSize
60
+     * @return
61
+     */
62
+    @RequestMapping(value="/admin/device",method= RequestMethod.GET)
63
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
64
+    public ResponseBean tdDeviceList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
65
+									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
66
+                                     @ApiParam("设备分类") @RequestParam(value ="deviceType", required = false) String deviceType,
67
+                                     @ApiParam("在线状态") @RequestParam(value ="onlineStatus", required = false) Integer onlineStatus) throws Exception{
68
+
69
+		    IPage<TdDevice> pg = new Page<>(pageNum, pageSize);
70
+            IPage<TdDevice> result = iTdDeviceService.getPageBy(pg, deviceType, onlineStatus);
71
+            return ResponseBean.success(result);
72
+    }
74 73
 
75 74
     /**
76 75
      * 保存对象

+ 23
- 23
src/main/java/com/yunzhi/nanyang/controller/TdRawDeviceController.java 파일 보기

@@ -43,29 +43,29 @@ public class TdRawDeviceController extends BaseController {
43 43
 //        return ResponseBean.success(tdRawDeviceService.getById(id));
44 44
 //    }
45 45
 
46
-    /**
47
-     * 分页查询
48
-     *
49
-     * @param pageNum  当前页码
50
-     * @param pageSize 每页条数
51
-     * @return 查询结果
52
-     */
53
-    @ApiOperation("分页查询")
54
-    @GetMapping("/admin/raw-device")
55
-    public ResponseBean list(@ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
56
-                             @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
57
-                             @ApiParam("设备分类") @RequestParam(value = "deviceKind", required = false) String deviceKind,
58
-                             @ApiParam("设备状态") @RequestParam(value = "deviceStatus", required = false) Integer deviceStatus) throws Exception {
59
-
60
-        IPage<TdRawDevice> pg = new Page<>(pageNum, pageSize);
61
-        QueryWrapper<TdRawDevice> queryWrapper = new QueryWrapper<>();
62
-        queryWrapper.eq(!StringUtils.isEmpty(deviceKind), "device_kind", deviceKind);
63
-        queryWrapper.eq(null != deviceStatus, "device_status", deviceStatus);
64
-        queryWrapper.orderByDesc("create_date");
65
-        IPage<TdRawDevice> result = tdRawDeviceService.page(pg);
66
-
67
-        return ResponseBean.success(result);
68
-    }
46
+//    /**
47
+//     * 分页查询
48
+//     *
49
+//     * @param pageNum  当前页码
50
+//     * @param pageSize 每页条数
51
+//     * @return 查询结果
52
+//     */
53
+//    @ApiOperation("分页查询")
54
+//    @GetMapping("/admin/raw-device")
55
+//    public ResponseBean list(@ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
56
+//                             @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
57
+//                             @ApiParam("设备分类") @RequestParam(value = "deviceKind", required = false) String deviceKind,
58
+//                             @ApiParam("设备状态") @RequestParam(value = "deviceStatus", required = false) Integer deviceStatus) throws Exception {
59
+//
60
+//        IPage<TdRawDevice> pg = new Page<>(pageNum, pageSize);
61
+//        QueryWrapper<TdRawDevice> queryWrapper = new QueryWrapper<>();
62
+//        queryWrapper.eq(!StringUtils.isEmpty(deviceKind), "device_kind", deviceKind);
63
+//        queryWrapper.eq(null != deviceStatus, "device_status", deviceStatus);
64
+//        queryWrapper.orderByDesc("create_date");
65
+//        IPage<TdRawDevice> result = tdRawDeviceService.page(pg);
66
+//
67
+//        return ResponseBean.success(result);
68
+//    }
69 69
 
70 70
 //    /** 
71 71
 //     * 新增数据

+ 15
- 0
src/main/java/com/yunzhi/nanyang/entity/TdDevice.java 파일 보기

@@ -2,6 +2,8 @@ package com.yunzhi.nanyang.entity;
2 2
 
3 3
 import com.baomidou.mybatisplus.annotation.IdType;
4 4
 import java.time.LocalDateTime;
5
+
6
+import com.baomidou.mybatisplus.annotation.TableField;
5 7
 import com.baomidou.mybatisplus.annotation.TableId;
6 8
 import java.io.Serializable;
7 9
 import io.swagger.annotations.ApiModel;
@@ -39,9 +41,19 @@ public class TdDevice implements Serializable {
39 41
     @ApiModelProperty(value = "农机ID")
40 42
     private String machineryId;
41 43
 
44
+    @ApiModelProperty(value = "农机名称")
45
+    @TableField(exist = false)
46
+    private String machineryName;
47
+
42 48
     @ApiModelProperty(value = "接口配置")
43 49
     private String apiConfig;
44 50
 
51
+    @ApiModelProperty(value = "定位")
52
+    private String location;
53
+
54
+    @ApiModelProperty(value = "在线状态")
55
+    private Integer onlineStatus;
56
+
45 57
     @ApiModelProperty(value = "状态")
46 58
     private Integer status;
47 59
 
@@ -52,4 +64,7 @@ public class TdDevice implements Serializable {
52 64
     private LocalDateTime createDate;
53 65
 
54 66
 
67
+    @ApiModelProperty(value = "更新时间")
68
+    private LocalDateTime updateDate;
69
+
55 70
 }

+ 3
- 0
src/main/java/com/yunzhi/nanyang/mapper/TdDeviceMapper.java 파일 보기

@@ -1,8 +1,10 @@
1 1
 package com.yunzhi.nanyang.mapper;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 4
 import com.yunzhi.nanyang.entity.TdDevice;
4 5
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 6
 import org.apache.ibatis.annotations.Mapper;
7
+import org.apache.ibatis.annotations.Param;
6 8
 
7 9
 /**
8 10
  * <p>
@@ -15,4 +17,5 @@ import org.apache.ibatis.annotations.Mapper;
15 17
 @Mapper
16 18
 public interface TdDeviceMapper extends BaseMapper<TdDevice> {
17 19
 
20
+    IPage<TdDevice> getPageBy(IPage<TdDevice> pg, @Param("deviceType") String deviceType,@Param("onlineStatus") Integer onlineStatus);
18 21
 }

+ 2
- 0
src/main/java/com/yunzhi/nanyang/service/ITdDeviceService.java 파일 보기

@@ -1,5 +1,6 @@
1 1
 package com.yunzhi.nanyang.service;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 4
 import com.yunzhi.nanyang.entity.TdDevice;
4 5
 import com.baomidou.mybatisplus.extension.service.IService;
5 6
 
@@ -13,4 +14,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
13 14
  */
14 15
 public interface ITdDeviceService extends IBaseService<TdDevice> {
15 16
 
17
+    IPage<TdDevice> getPageBy(IPage<TdDevice> pg, String deviceType, Integer onlineStatus);
16 18
 }

+ 5
- 0
src/main/java/com/yunzhi/nanyang/service/impl/TdDeviceServiceImpl.java 파일 보기

@@ -1,5 +1,6 @@
1 1
 package com.yunzhi.nanyang.service.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 4
 import com.yunzhi.nanyang.entity.TdDevice;
4 5
 import com.yunzhi.nanyang.mapper.TdDeviceMapper;
5 6
 import com.yunzhi.nanyang.service.ITdDeviceService;
@@ -17,4 +18,8 @@ import org.springframework.stereotype.Service;
17 18
 @Service
18 19
 public class TdDeviceServiceImpl extends BaseServiceImpl<TdDeviceMapper, TdDevice> implements ITdDeviceService {
19 20
 
21
+    @Override
22
+    public IPage<TdDevice> getPageBy(IPage<TdDevice> pg, String deviceType, Integer onlineStatus) {
23
+        return baseMapper.getPageBy(pg, deviceType, onlineStatus);
24
+    }
20 25
 }

+ 23
- 0
src/main/resources/mapper/TdDeviceMapper.xml 파일 보기

@@ -2,4 +2,27 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.yunzhi.nanyang.mapper.TdDeviceMapper">
4 4
 
5
+    <select id="getPageBy" resultType="com.yunzhi.nanyang.entity.TdDevice">
6
+        SELECT
7
+            t.device_no,
8
+            t.device_kind AS device_type,
9
+            s.machinery_id,
10
+            m.`name` AS machinery_name,
11
+            s.api_config,
12
+            s.`status`,
13
+            t.location,
14
+            t.device_status AS online_status,
15
+            t.create_date,
16
+            t.update_date
17
+        FROM
18
+            td_raw_device t
19
+                LEFT JOIN td_device s ON t.device_kind = s.device_type
20
+                AND t.device_no = s.device_no
21
+                LEFT JOIN ta_machinery m ON s.machinery_id = m.machinery_id
22
+        WHERE
23
+            t.device_kind = #{deviceType}
24
+          AND t.device_status = #{onlineStatus}
25
+        ORDER BY
26
+            t.create_date DESC
27
+    </select>
5 28
 </mapper>