Yansen 2 лет назад
Родитель
Сommit
b373df216f

+ 21
- 5
src/main/java/com/yunzhi/nanyang/controller/ScreenDataController.java Просмотреть файл

@@ -4,10 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.yunzhi.nanyang.common.BaseController;
5 5
 import com.yunzhi.nanyang.common.Constants;
6 6
 import com.yunzhi.nanyang.common.ResponseBean;
7
-import com.yunzhi.nanyang.entity.TaMachinery;
8
-import com.yunzhi.nanyang.entity.TaOrg;
9
-import com.yunzhi.nanyang.entity.TaWorkMessage;
10
-import com.yunzhi.nanyang.entity.TdMachineryType;
7
+import com.yunzhi.nanyang.common.StringUtils;
8
+import com.yunzhi.nanyang.entity.*;
11 9
 import com.yunzhi.nanyang.service.*;
12 10
 import com.yunzhi.nanyang.vo.ChartParam;
13 11
 import io.swagger.annotations.Api;
@@ -43,6 +41,9 @@ public class ScreenDataController extends BaseController {
43 41
     @Autowired
44 42
     ITaWorkMessageService iTaWorkMessageService;
45 43
 
44
+    @Autowired
45
+    ITdDeviceService iTdDeviceService;
46
+
46 47
 
47 48
     @GetMapping("/basic")
48 49
     @ApiOperation(value="基本数据统计", notes = "基本数据统计", httpMethod = "GET", response = ResponseBean.class)
@@ -103,7 +104,6 @@ public class ScreenDataController extends BaseController {
103 104
         return ResponseBean.success(result);
104 105
     }
105 106
 
106
-
107 107
     @GetMapping("/machinery/all")
108 108
     @ApiOperation(value="依据类型查询农机", notes = "依据类型查询农机", httpMethod = "GET", response = ResponseBean.class)
109 109
     public ResponseBean getMachineryOfType(@ApiParam("农机类型") @RequestParam(value = "typeId", required = false) String typeId) throws Exception {
@@ -118,4 +118,20 @@ public class ScreenDataController extends BaseController {
118 118
         List<TaWorkMessage> result = iTaWorkMessageService.listByType(messageType, limit);
119 119
         return ResponseBean.success(result);
120 120
     }
121
+
122
+    @GetMapping("/machinery-device")
123
+    @ApiOperation(value="依据类型查询绑定设备农机", notes = "依据类型查询绑定设备农机", httpMethod = "GET", response = ResponseBean.class)
124
+    public ResponseBean getDeviceMachineryList(@ApiParam("设备类型") @RequestParam(value = "deviceType", required = false) String deviceType) throws Exception {
125
+
126
+        List<String> typeList = new ArrayList<>();
127
+        if (StringUtils.isEmpty(deviceType)) {
128
+            typeList.add("shensong");
129
+            typeList.add("feifang");
130
+        } else {
131
+            typeList.add(deviceType);
132
+        }
133
+
134
+        List<TdDevice> result = iTdDeviceService.getListByTypes(typeList);
135
+        return ResponseBean.success(result);
136
+    }
121 137
 }

+ 4
- 0
src/main/java/com/yunzhi/nanyang/mapper/TdDeviceMapper.java Просмотреть файл

@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6 6
 import org.apache.ibatis.annotations.Mapper;
7 7
 import org.apache.ibatis.annotations.Param;
8 8
 
9
+import java.util.List;
10
+
9 11
 /**
10 12
  * <p>
11 13
  * 设备表 Mapper 接口
@@ -20,4 +22,6 @@ public interface TdDeviceMapper extends BaseMapper<TdDevice> {
20 22
     IPage<TdDevice> getPageBy(IPage<TdDevice> pg, @Param("deviceType") String deviceType,@Param("onlineStatus") Integer onlineStatus);
21 23
 
22 24
     TdDevice getExistByDevice(@Param("deviceType") String deviceType,@Param("deviceNo") String deviceNo);
25
+
26
+    List<TdDevice> getListByTypes(@Param("typeList") List<String> typeList);
23 27
 }

+ 4
- 0
src/main/java/com/yunzhi/nanyang/service/ITdDeviceService.java Просмотреть файл

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
4 4
 import com.yunzhi.nanyang.entity.TdDevice;
5 5
 import com.baomidou.mybatisplus.extension.service.IService;
6 6
 
7
+import java.util.List;
8
+
7 9
 /**
8 10
  * <p>
9 11
  * 设备表 服务类
@@ -17,4 +19,6 @@ public interface ITdDeviceService extends IBaseService<TdDevice> {
17 19
     IPage<TdDevice> getPageBy(IPage<TdDevice> pg, String deviceType, Integer onlineStatus);
18 20
 
19 21
     TdDevice getExistByDevice(String deviceType, String deviceNo);
22
+
23
+    List<TdDevice> getListByTypes(List<String> typeList);
20 24
 }

+ 7
- 0
src/main/java/com/yunzhi/nanyang/service/impl/TdDeviceServiceImpl.java Просмотреть файл

@@ -7,6 +7,8 @@ import com.yunzhi.nanyang.service.ITdDeviceService;
7 7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8 8
 import org.springframework.stereotype.Service;
9 9
 
10
+import java.util.List;
11
+
10 12
 /**
11 13
  * <p>
12 14
  * 设备表 服务实现类
@@ -27,4 +29,9 @@ public class TdDeviceServiceImpl extends BaseServiceImpl<TdDeviceMapper, TdDevic
27 29
     public TdDevice getExistByDevice(String deviceType, String deviceNo) {
28 30
         return baseMapper.getExistByDevice(deviceType, deviceNo);
29 31
     }
32
+
33
+    @Override
34
+    public List<TdDevice> getListByTypes(List<String> typeList) {
35
+        return baseMapper.getListByTypes(typeList);
36
+    }
30 37
 }

+ 16
- 0
src/main/resources/mapper/TdDeviceMapper.xml Просмотреть файл

@@ -40,4 +40,20 @@
40 40
           AND t.device_no = #{deviceNo}
41 41
           AND t.`status` &gt; -1
42 42
     </select>
43
+    <select id="getListByTypes" resultType="com.yunzhi.nanyang.entity.TdDevice">
44
+        SELECT
45
+            t.*,
46
+            s.`name` AS machinery_name
47
+        FROM
48
+            td_device t
49
+                INNER JOIN ta_machinery s ON t.machinery_id = s.machinery_id
50
+        WHERE
51
+            t.location IS NOT NULL
52
+          AND t.device_type IN
53
+            <foreach collection="typeList" index="index" item="item" open="(" separator="," close=")">
54
+                #{item}
55
+            </foreach>
56
+        ORDER BY
57
+            t.create_date DESC
58
+    </select>
43 59
 </mapper>