|
|
@@ -7,6 +7,7 @@ import com.chinaitop.depot.intelligent.grainsituation.service.TemperatureRecordS
|
|
7
|
7
|
import com.chinaitop.depot.intelligent.socket.SocketClient;
|
|
8
|
8
|
import com.chinaitop.depot.intelligent.utils.ConstUtils;
|
|
9
|
9
|
import com.chinaitop.depot.intelligent.utils.HexConvertUtils;
|
|
|
10
|
+import com.chinaitop.depot.intelligent.utils.RemoteControlUtil;
|
|
10
|
11
|
import com.github.pagehelper.PageHelper;
|
|
11
|
12
|
import com.github.pagehelper.PageInfo;
|
|
12
|
13
|
import com.unissoft.model.ResponseEntity;
|
|
|
@@ -19,12 +20,16 @@ import org.apache.commons.lang.StringUtils;
|
|
19
|
20
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
20
|
21
|
import org.springframework.beans.factory.annotation.Value;
|
|
21
|
22
|
import org.springframework.http.MediaType;
|
|
|
23
|
+import org.springframework.util.LinkedMultiValueMap;
|
|
|
24
|
+import org.springframework.util.MultiValueMap;
|
|
22
|
25
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
23
|
26
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
24
|
27
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
25
|
28
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
29
|
+import org.springframework.web.client.RestTemplate;
|
|
26
|
30
|
|
|
27
|
31
|
import javax.annotation.Resource;
|
|
|
32
|
+import javax.validation.constraints.NotNull;
|
|
28
|
33
|
import java.util.*;
|
|
29
|
34
|
|
|
30
|
35
|
@RestController
|
|
|
@@ -50,7 +55,7 @@ public class TemperatureRecordController {
|
|
50
|
55
|
@ApiImplicitParam(name = "vCfCode", value = "仓库名称", paramType = "query"),
|
|
51
|
56
|
@ApiImplicitParam(name = "tType", value = "检测类型0测温,1粮油,2测水分", paramType = "query")
|
|
52
|
57
|
})
|
|
53
|
|
- public ResponseEntity<PageInfo<TTestdata>> getList(Integer pageNum, Integer pageSize, String vCfCode, String vDatatime, String startTime, String endTime, String tType,String orgId) {
|
|
|
58
|
+ public ResponseEntity<PageInfo<TTestdata>> getList(Integer pageNum, Integer pageSize, String vCfCode, String vDatatime, String startTime, String endTime, String tType, String orgId) {
|
|
54
|
59
|
List<TTestdata> list = null;
|
|
55
|
60
|
try {
|
|
56
|
61
|
if (null != pageNum && null != pageSize) {
|
|
|
@@ -91,11 +96,10 @@ public class TemperatureRecordController {
|
|
91
|
96
|
}
|
|
92
|
97
|
|
|
93
|
98
|
/**
|
|
94
|
|
- *
|
|
95
|
99
|
* @param lqId
|
|
96
|
100
|
* @param vCfCode
|
|
97
|
101
|
* @param vDatatime
|
|
98
|
|
- * @param viewFlag true: 表格数据,false: 3D三温图数据
|
|
|
102
|
+ * @param viewFlag true: 表格数据,false: 3D三温图数据
|
|
99
|
103
|
* @return
|
|
100
|
104
|
*/
|
|
101
|
105
|
@RequestMapping(value = "/findByHouseAndTimes", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
|
|
|
@@ -232,54 +236,26 @@ public class TemperatureRecordController {
|
|
232
|
236
|
private SocketClient socketClient;
|
|
233
|
237
|
@Autowired
|
|
234
|
238
|
private ConstUtils constUtils;
|
|
|
239
|
+ @Resource
|
|
|
240
|
+ private RemoteControlUtil remoteControlUtil;
|
|
235
|
241
|
|
|
236
|
242
|
@RequestMapping(value = "/sendTemperatureDetection", method = RequestMethod.POST)
|
|
237
|
243
|
@ApiOperation(value = "粮情实时检测", notes = "粮情实时检测")
|
|
238
|
244
|
@ApiImplicitParams({
|
|
239
|
245
|
@ApiImplicitParam(name = "storeCode", defaultValue = "001", value = "仓库编号", paramType = "query")
|
|
240
|
246
|
})
|
|
241
|
|
- public ResponseEntity<Map<String, String>> sendTemperatureDetection(String storeCode) {
|
|
242
|
|
- Map<String, String> map = new LinkedHashMap<>();
|
|
243
|
|
- if (StringUtils.isNotBlank(storeCode)) {
|
|
244
|
|
- String sTemp = storeCode.substring(0, storeCode.length());
|
|
245
|
|
- String[] sArray = sTemp.split(",");
|
|
246
|
|
- for (String cfCode : sArray) {
|
|
247
|
|
- // 0X02粮情数据采集,仓房号,设备编号若为0则控全部
|
|
248
|
|
- String dir = constUtils.directiveJoint(constUtils.F_EXTENT, constUtils.F_SUB_P, constUtils.GRAIN_TYPE, cfCode, "");
|
|
249
|
|
- // 16进制字符串转byte数组
|
|
250
|
|
- byte[] bytes = HexConvertUtils.hexStringToByte(dir);
|
|
251
|
|
- // 发送指令
|
|
252
|
|
- String s = socketClient.startClient(bytes);
|
|
253
|
|
- // 0:失败;1:成功;2:设备通讯异常;3:设备故障;4:未知原因; 5: 本地模式(有的设备有本地模式,即无法远程控制)
|
|
254
|
|
- if (s.contains("7E")) {
|
|
255
|
|
- String substring = s.substring(s.length() - 2, s.length());
|
|
256
|
|
- if ("00".equals(substring))
|
|
257
|
|
- map.put(cfCode, TypeEnum.S_NUL.getDesc()); // 失败
|
|
258
|
|
- else if ("01".equals(substring))
|
|
259
|
|
- map.put(cfCode, TypeEnum.S_SOH.getDesc()); // 成功
|
|
260
|
|
- else if ("02".equals(substring))
|
|
261
|
|
- map.put(cfCode, TypeEnum.S_STX.getDesc()); // 设备通讯异常
|
|
262
|
|
- else if ("03".equals(substring))
|
|
263
|
|
- map.put(cfCode, TypeEnum.S_ETX.getDesc()); // 设备故障
|
|
264
|
|
- else if ("04".equals(substring))
|
|
265
|
|
- map.put(cfCode, TypeEnum.S_EOT.getDesc()); // 未知原因
|
|
266
|
|
- else if ("05".equals(substring))
|
|
267
|
|
- map.put(cfCode, TypeEnum.S_2D_SOH.getDesc()); // 本地模式,无法远程控制
|
|
268
|
|
- else if ("06".equals(substring))
|
|
269
|
|
- map.put(cfCode, TypeEnum.SM.getDesc()); // 设备正忙
|
|
270
|
|
- } else {
|
|
271
|
|
- if (s.contains("323230")) { // 220-FileZilla Server 0.9.60 beta
|
|
272
|
|
- map.put("error", "无法连接到服务器!");
|
|
273
|
|
- } else {
|
|
274
|
|
- map.put("error", s);
|
|
275
|
|
- }
|
|
276
|
|
- return ResponseEntity.failed(s);
|
|
277
|
|
- }
|
|
278
|
|
- }
|
|
279
|
|
- } else {
|
|
280
|
|
- return ResponseEntity.failed(TypeEnum.S_EM.getDesc()); // 仓房号为空
|
|
281
|
|
- }
|
|
282
|
|
- return ResponseEntity.ok(map);
|
|
|
247
|
+ public ResponseEntity<Map<String, String>> sendTemperatureDetection(String storeCode, @NotNull String orgId) {
|
|
|
248
|
+ // 1.获取库端url
|
|
|
249
|
+ String url = temperatureRecordService.getRemoteUrl(orgId);
|
|
|
250
|
+ if (StringUtils.isBlank(url))
|
|
|
251
|
+ return ResponseEntity.failed("库端硬件地址未配置!");
|
|
|
252
|
+ // 2.封装请求数据
|
|
|
253
|
+ MultiValueMap<String, String> requestEntity = new LinkedMultiValueMap<>();
|
|
|
254
|
+ requestEntity.add("storeCode", storeCode);
|
|
|
255
|
+ return remoteControlUtil.remoteScan(
|
|
|
256
|
+ String.format("%s%s", url, remoteControlUtil.chooseCFCode),
|
|
|
257
|
+ requestEntity, "POST", null
|
|
|
258
|
+ );
|
|
283
|
259
|
}
|
|
284
|
260
|
|
|
285
|
261
|
@RequestMapping(value = "/sendTemperatureDetectionAll", method = RequestMethod.GET)
|