Kaynağa Gözat

智能仓房添加查询条件-1

hanqingsong 3 yıl önce
ebeveyn
işleme
54df8fd4da

+ 13 - 23
src/main/java/com/chinaitop/depot/intelligent/grainsituation/controller/TemperatureRecordController.java

@@ -289,29 +289,19 @@ public class TemperatureRecordController {
289 289
             @ApiImplicitParam(name = "storeCode", defaultValue = "001", value = "仓库编号", paramType = "query"),
290 290
             @ApiImplicitParam(name = "tType", value = "检测类型0测温,1粮油,2测水分", paramType = "query")
291 291
     })
292
-    public ResponseEntity sendOnlyStoreDetection(String storeCode, String tType) {
293
-        String result = "";
294
-        try {
295
-            if (StringUtils.isNotBlank(storeCode) && StringUtils.isNotBlank(tType)) {
296
-                // 0X02粮情数据采集,仓房号,设备编号若为0则控全部
297
-                String type = "";
298
-                if (tType.equals("0")) {
299
-                    type = constUtils.GRAIN_TYPE;
300
-                } else {
301
-                    type = constUtils.DEW_TYPE;
302
-                }
303
-                String dir = constUtils.directiveJoint(constUtils.F_EXTENT, constUtils.F_SUB_P, type, storeCode, "");
304
-                // 16进制字符串转byte数组
305
-                byte[] bytes = HexConvertUtils.hexStringToByte(dir);
306
-                // 发送指令
307
-                String s = socketClient.startClient(bytes);
308
-                result = TypeEnum.resultDispose(s);
309
-            }
310
-        } catch (Exception e) {
311
-            e.printStackTrace();
312
-            return ResponseEntity.ok("设备连接异常!");
313
-        }
314
-        return ResponseEntity.ok(result);
292
+    public ResponseEntity sendOnlyStoreDetection(String storeCode, String tType, @NotNull String orgId) {
293
+        // 1.获取库端url
294
+        String url = temperatureRecordService.getRemoteUrl(orgId);
295
+        if (StringUtils.isBlank(url))
296
+            return ResponseEntity.failed("库端硬件地址未配置!");
297
+        // 2.封装请求数据
298
+        MultiValueMap<String, String> requestEntity = new LinkedMultiValueMap<>();
299
+        requestEntity.add("storeCode", storeCode);
300
+        requestEntity.add("tType", tType);
301
+        return remoteControlUtil.remoteScan(
302
+                String.format("%s%s", url, remoteControlUtil.foodOnly),
303
+                requestEntity, "POST", null
304
+        );
315 305
     }
316 306
 
317 307
     @RequestMapping(value = "/findById", method = RequestMethod.GET)