|
|
@@ -1,11 +1,14 @@
|
|
1
|
1
|
package com.chinaitop.depot.intelligent.weather.controller;
|
|
2
|
2
|
|
|
|
3
|
+import com.chinaitop.depot.intelligent.grainsituation.service.TemperatureRecordService;
|
|
3
|
4
|
import com.chinaitop.depot.intelligent.socket.SocketClient;
|
|
4
|
5
|
import com.chinaitop.depot.intelligent.utils.HexConvertUtils;
|
|
|
6
|
+import com.chinaitop.depot.intelligent.utils.RemoteControlUtil;
|
|
5
|
7
|
import com.chinaitop.depot.intelligent.weather.model.TWertherinfo;
|
|
6
|
8
|
import com.chinaitop.depot.intelligent.weather.service.WertherinfoService;
|
|
7
|
9
|
import com.github.pagehelper.PageHelper;
|
|
8
|
10
|
import com.github.pagehelper.PageInfo;
|
|
|
11
|
+import com.sun.istack.NotNull;
|
|
9
|
12
|
import com.unissoft.model.ResponseEntity;
|
|
10
|
13
|
import com.unissoft.model.TypeEnum;
|
|
11
|
14
|
import io.swagger.annotations.Api;
|
|
|
@@ -15,6 +18,8 @@ import io.swagger.annotations.ApiOperation;
|
|
15
|
18
|
import org.apache.commons.lang3.StringUtils;
|
|
16
|
19
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
17
|
20
|
import org.springframework.http.MediaType;
|
|
|
21
|
+import org.springframework.util.LinkedMultiValueMap;
|
|
|
22
|
+import org.springframework.util.MultiValueMap;
|
|
18
|
23
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
19
|
24
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
20
|
25
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
@@ -28,10 +33,12 @@ import java.util.Map;
|
|
28
|
33
|
@RequestMapping(value = "/intelligents/wertherinfo")
|
|
29
|
34
|
@Api(value = "WertherinfoController", description = "气象站设备控制类")
|
|
30
|
35
|
public class WertherinfoController {
|
|
31
|
|
-
|
|
|
36
|
+ @Autowired
|
|
|
37
|
+ private TemperatureRecordService temperatureRecordService;
|
|
32
|
38
|
@Resource
|
|
33
|
39
|
private WertherinfoService wertherinfoService;
|
|
34
|
|
-
|
|
|
40
|
+ @Resource
|
|
|
41
|
+ private RemoteControlUtil remoteControlUtil;
|
|
35
|
42
|
@Autowired
|
|
36
|
43
|
private SocketClient socketClient;
|
|
37
|
44
|
|
|
|
@@ -42,15 +49,16 @@ public class WertherinfoController {
|
|
42
|
49
|
@ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query"),
|
|
43
|
50
|
@ApiImplicitParam(name = "vqxzname", value = "气象站名称", paramType = "query"),
|
|
44
|
51
|
@ApiImplicitParam(name = "searchStartDate", value = "开始时间", paramType = "query"),
|
|
45
|
|
- @ApiImplicitParam(name = "searchEndDate", value = "结束时间", paramType = "query")
|
|
|
52
|
+ @ApiImplicitParam(name = "searchEndDate", value = "结束时间", paramType = "query"),
|
|
|
53
|
+ @ApiImplicitParam(name = "orgId", value = "库id", paramType = "query")
|
|
46
|
54
|
})
|
|
47
|
|
- public ResponseEntity<PageInfo<TWertherinfo>> getList(Integer pageNum, Integer pageSize, String vqxzname, String searchStartDate, String searchEndDate) {
|
|
|
55
|
+ public ResponseEntity<PageInfo<TWertherinfo>> getList(Integer pageNum, Integer pageSize, String vqxzname, String searchStartDate, String searchEndDate, @NotNull String orgId) {
|
|
48
|
56
|
List<TWertherinfo> list = null;
|
|
49
|
57
|
try {
|
|
50
|
58
|
if (null != pageNum && null != pageSize) {
|
|
51
|
59
|
PageHelper.startPage(pageNum, pageSize);
|
|
52
|
60
|
}
|
|
53
|
|
- list = wertherinfoService.getList(vqxzname,searchStartDate,searchEndDate);
|
|
|
61
|
+ list = wertherinfoService.getList(vqxzname,searchStartDate,searchEndDate,orgId);
|
|
54
|
62
|
} catch (Exception e) {
|
|
55
|
63
|
e.printStackTrace();
|
|
56
|
64
|
return ResponseEntity.failed("查询气象站列表失败");
|
|
|
@@ -111,40 +119,52 @@ public class WertherinfoController {
|
|
111
|
119
|
@ApiOperation(value = "校验是否重复", notes = "校验是否重复")
|
|
112
|
120
|
@ApiImplicitParams({
|
|
113
|
121
|
@ApiImplicitParam(name = "vdevcode", value = "设备编码", paramType = "query"),
|
|
114
|
|
- @ApiImplicitParam(name = "vdevname", value = "设备名称", paramType = "query")
|
|
|
122
|
+ @ApiImplicitParam(name = "vdevname", value = "设备名称", paramType = "query"),
|
|
|
123
|
+ @ApiImplicitParam(name = "orgId", value = "库id", paramType = "query")
|
|
115
|
124
|
})
|
|
116
|
|
- public ResponseEntity getBycfCode(String vdevcode,String vdevname) {
|
|
117
|
|
- boolean bycfCode = wertherinfoService.getBycfCode(vdevcode, vdevname);
|
|
|
125
|
+ public ResponseEntity getBycfCode(String vdevcode,String vdevname,String orgId) {
|
|
|
126
|
+ boolean bycfCode = wertherinfoService.getBycfCode(vdevcode, vdevname,orgId);
|
|
118
|
127
|
return ResponseEntity.ok(bycfCode);
|
|
119
|
128
|
}
|
|
120
|
129
|
|
|
121
|
130
|
@RequestMapping(value = "/sendNowWeatherDetection", method = RequestMethod.POST)
|
|
122
|
131
|
@ApiOperation(value = "气象实时检测", notes = "气象实时检测")
|
|
123
|
|
- public ResponseEntity sendNowWeatherDetection() {
|
|
|
132
|
+ public ResponseEntity sendNowWeatherDetection( @NotNull String orgId) {
|
|
|
133
|
+ // 1.获取库端url
|
|
|
134
|
+ String url = temperatureRecordService.getRemoteUrl(orgId);
|
|
|
135
|
+ if (org.apache.commons.lang.StringUtils.isBlank(url))
|
|
|
136
|
+ return ResponseEntity.failed("库端硬件地址未配置!");
|
|
|
137
|
+ // 2.封装请求数据
|
|
|
138
|
+ MultiValueMap<String, String> requestEntity = new LinkedMultiValueMap<>();
|
|
|
139
|
+ //requestEntity.add("storeCode", storeCode);
|
|
|
140
|
+ return remoteControlUtil.remoteScan(
|
|
|
141
|
+ String.format("%s%s", url, remoteControlUtil.wertherinfo),
|
|
|
142
|
+ requestEntity, "POST", null
|
|
|
143
|
+ );
|
|
124
|
144
|
//7E 0005 06 0101 0000000000
|
|
125
|
|
- byte[] b = new byte[11];
|
|
126
|
|
- b[0] = 0x7E;
|
|
127
|
|
- b[1] = 0x00;
|
|
128
|
|
- b[2] = 0x05;
|
|
129
|
|
- b[3] = 0X06;
|
|
130
|
|
- b[4] = 0x01;
|
|
131
|
|
- b[5] = 0x01;
|
|
132
|
|
- b[6] = 0x00;
|
|
133
|
|
- b[7] = 0x00;
|
|
134
|
|
- b[8] = 0x00;
|
|
135
|
|
- b[9] = 0x00;
|
|
136
|
|
- b[10] = 0x00;
|
|
137
|
|
- String result = "";
|
|
138
|
|
- // 发送指令
|
|
139
|
|
- try {
|
|
140
|
|
- String s = socketClient.startClient(b);
|
|
141
|
|
- // 0:失败;1:成功;2:设备通讯异常;3:设备故障;4:未知原因; 5: 本地模式(有的设备有本地模式,即无法远程控制)
|
|
142
|
|
- result = TypeEnum.resultDispose(s);
|
|
143
|
|
- } catch (Exception e) {
|
|
144
|
|
- e.printStackTrace();
|
|
145
|
|
- return ResponseEntity.ok("设备连接异常!");
|
|
146
|
|
- }
|
|
147
|
|
- return ResponseEntity.ok(result);
|
|
|
145
|
+// byte[] b = new byte[11];
|
|
|
146
|
+// b[0] = 0x7E;
|
|
|
147
|
+// b[1] = 0x00;
|
|
|
148
|
+// b[2] = 0x05;
|
|
|
149
|
+// b[3] = 0X06;
|
|
|
150
|
+// b[4] = 0x01;
|
|
|
151
|
+// b[5] = 0x01;
|
|
|
152
|
+// b[6] = 0x00;
|
|
|
153
|
+// b[7] = 0x00;
|
|
|
154
|
+// b[8] = 0x00;
|
|
|
155
|
+// b[9] = 0x00;
|
|
|
156
|
+// b[10] = 0x00;
|
|
|
157
|
+// String result = "";
|
|
|
158
|
+// // 发送指令
|
|
|
159
|
+// try {
|
|
|
160
|
+// String s = socketClient.startClient(b);
|
|
|
161
|
+// // 0:失败;1:成功;2:设备通讯异常;3:设备故障;4:未知原因; 5: 本地模式(有的设备有本地模式,即无法远程控制)
|
|
|
162
|
+// result = TypeEnum.resultDispose(s);
|
|
|
163
|
+// } catch (Exception e) {
|
|
|
164
|
+// e.printStackTrace();
|
|
|
165
|
+// return ResponseEntity.ok("设备连接异常!");
|
|
|
166
|
+// }
|
|
|
167
|
+// return ResponseEntity.ok(result);
|
|
148
|
168
|
}
|
|
149
|
169
|
|
|
150
|
170
|
@RequestMapping(value = "/synchronizationAll", method = RequestMethod.GET)
|