Yansen 2 years ago
parent
commit
b373df216f

+ 21
- 5
src/main/java/com/yunzhi/nanyang/controller/ScreenDataController.java View File

4
 import com.yunzhi.nanyang.common.BaseController;
4
 import com.yunzhi.nanyang.common.BaseController;
5
 import com.yunzhi.nanyang.common.Constants;
5
 import com.yunzhi.nanyang.common.Constants;
6
 import com.yunzhi.nanyang.common.ResponseBean;
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
 import com.yunzhi.nanyang.service.*;
9
 import com.yunzhi.nanyang.service.*;
12
 import com.yunzhi.nanyang.vo.ChartParam;
10
 import com.yunzhi.nanyang.vo.ChartParam;
13
 import io.swagger.annotations.Api;
11
 import io.swagger.annotations.Api;
43
     @Autowired
41
     @Autowired
44
     ITaWorkMessageService iTaWorkMessageService;
42
     ITaWorkMessageService iTaWorkMessageService;
45
 
43
 
44
+    @Autowired
45
+    ITdDeviceService iTdDeviceService;
46
+
46
 
47
 
47
     @GetMapping("/basic")
48
     @GetMapping("/basic")
48
     @ApiOperation(value="基本数据统计", notes = "基本数据统计", httpMethod = "GET", response = ResponseBean.class)
49
     @ApiOperation(value="基本数据统计", notes = "基本数据统计", httpMethod = "GET", response = ResponseBean.class)
103
         return ResponseBean.success(result);
104
         return ResponseBean.success(result);
104
     }
105
     }
105
 
106
 
106
-
107
     @GetMapping("/machinery/all")
107
     @GetMapping("/machinery/all")
108
     @ApiOperation(value="依据类型查询农机", notes = "依据类型查询农机", httpMethod = "GET", response = ResponseBean.class)
108
     @ApiOperation(value="依据类型查询农机", notes = "依据类型查询农机", httpMethod = "GET", response = ResponseBean.class)
109
     public ResponseBean getMachineryOfType(@ApiParam("农机类型") @RequestParam(value = "typeId", required = false) String typeId) throws Exception {
109
     public ResponseBean getMachineryOfType(@ApiParam("农机类型") @RequestParam(value = "typeId", required = false) String typeId) throws Exception {
118
         List<TaWorkMessage> result = iTaWorkMessageService.listByType(messageType, limit);
118
         List<TaWorkMessage> result = iTaWorkMessageService.listByType(messageType, limit);
119
         return ResponseBean.success(result);
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 View File

6
 import org.apache.ibatis.annotations.Mapper;
6
 import org.apache.ibatis.annotations.Mapper;
7
 import org.apache.ibatis.annotations.Param;
7
 import org.apache.ibatis.annotations.Param;
8
 
8
 
9
+import java.util.List;
10
+
9
 /**
11
 /**
10
  * <p>
12
  * <p>
11
  * 设备表 Mapper 接口
13
  * 设备表 Mapper 接口
20
     IPage<TdDevice> getPageBy(IPage<TdDevice> pg, @Param("deviceType") String deviceType,@Param("onlineStatus") Integer onlineStatus);
22
     IPage<TdDevice> getPageBy(IPage<TdDevice> pg, @Param("deviceType") String deviceType,@Param("onlineStatus") Integer onlineStatus);
21
 
23
 
22
     TdDevice getExistByDevice(@Param("deviceType") String deviceType,@Param("deviceNo") String deviceNo);
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 View File

4
 import com.yunzhi.nanyang.entity.TdDevice;
4
 import com.yunzhi.nanyang.entity.TdDevice;
5
 import com.baomidou.mybatisplus.extension.service.IService;
5
 import com.baomidou.mybatisplus.extension.service.IService;
6
 
6
 
7
+import java.util.List;
8
+
7
 /**
9
 /**
8
  * <p>
10
  * <p>
9
  * 设备表 服务类
11
  * 设备表 服务类
17
     IPage<TdDevice> getPageBy(IPage<TdDevice> pg, String deviceType, Integer onlineStatus);
19
     IPage<TdDevice> getPageBy(IPage<TdDevice> pg, String deviceType, Integer onlineStatus);
18
 
20
 
19
     TdDevice getExistByDevice(String deviceType, String deviceNo);
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 View File

7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8
 import org.springframework.stereotype.Service;
8
 import org.springframework.stereotype.Service;
9
 
9
 
10
+import java.util.List;
11
+
10
 /**
12
 /**
11
  * <p>
13
  * <p>
12
  * 设备表 服务实现类
14
  * 设备表 服务实现类
27
     public TdDevice getExistByDevice(String deviceType, String deviceNo) {
29
     public TdDevice getExistByDevice(String deviceType, String deviceNo) {
28
         return baseMapper.getExistByDevice(deviceType, deviceNo);
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 View File

40
           AND t.device_no = #{deviceNo}
40
           AND t.device_no = #{deviceNo}
41
           AND t.`status` &gt; -1
41
           AND t.`status` &gt; -1
42
     </select>
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
 </mapper>
59
 </mapper>