瀏覽代碼

智能仓房气象跳转

hanqingsong 3 年之前
父節點
當前提交
af31d58e36

+ 17 - 65
src/main/java/com/chinaitop/depot/intelligent/weather/controller/WertherinfoController.java

@@ -1,7 +1,6 @@
1 1
 package com.chinaitop.depot.intelligent.weather.controller;
2 2
 
3 3
 import com.chinaitop.depot.intelligent.grainsituation.service.TemperatureRecordService;
4
-import com.chinaitop.depot.intelligent.socket.SocketClient;
5 4
 import com.chinaitop.depot.intelligent.utils.RemoteControlUtil;
6 5
 import com.chinaitop.depot.intelligent.weather.model.TWertherinfo;
7 6
 import com.chinaitop.depot.intelligent.weather.service.WertherinfoService;
@@ -16,7 +15,6 @@ import org.apache.commons.lang3.StringUtils;
16 15
 import org.springframework.beans.factory.annotation.Autowired;
17 16
 import org.springframework.http.MediaType;
18 17
 import org.springframework.util.LinkedMultiValueMap;
19
-import org.springframework.util.MultiValueMap;
20 18
 import org.springframework.web.bind.annotation.RequestMapping;
21 19
 import org.springframework.web.bind.annotation.RequestMethod;
22 20
 import org.springframework.web.bind.annotation.RequestParam;
@@ -24,7 +22,9 @@ import org.springframework.web.bind.annotation.RestController;
24 22
 
25 23
 import javax.annotation.Resource;
26 24
 import javax.validation.constraints.NotNull;
25
+import java.util.HashMap;
27 26
 import java.util.List;
27
+import java.util.Map;
28 28
 
29 29
 @RestController
30 30
 @RequestMapping(value = "/intelligents/wertherinfo")
@@ -36,8 +36,6 @@ public class WertherinfoController {
36 36
     private WertherinfoService wertherinfoService;
37 37
     @Resource
38 38
     private RemoteControlUtil remoteControlUtil;
39
-    @Autowired
40
-    private SocketClient socketClient;
41 39
 
42 40
     @RequestMapping(value = "/getList", method = RequestMethod.GET)
43 41
     @ApiOperation(value = "查询 气象站设备 信息列表", notes = "查询 气象站设备 信息列表")
@@ -55,7 +53,7 @@ public class WertherinfoController {
55 53
             if (null != pageNum && null != pageSize) {
56 54
                 PageHelper.startPage(pageNum, pageSize);
57 55
             }
58
-            list = wertherinfoService.getList(vqxzname,searchStartDate,searchEndDate,orgId);
56
+            list = wertherinfoService.getList(vqxzname, searchStartDate, searchEndDate, orgId);
59 57
         } catch (Exception e) {
60 58
             e.printStackTrace();
61 59
             return ResponseEntity.failed("查询气象站列表失败");
@@ -100,9 +98,9 @@ public class WertherinfoController {
100 98
             @ApiImplicitParam(name = "id", value = "气体象站数据id", paramType = "query"),
101 99
             @ApiImplicitParam(name = "wertherinfojson", value = "气体象站数据json", paramType = "form")
102 100
     })
103
-    public ResponseEntity deleteById(String id,String wertherinfojson) {
101
+    public ResponseEntity deleteById(String id, String wertherinfojson) {
104 102
         if (StringUtils.isNotBlank(id)) {
105
-            int count = wertherinfoService.deleteById(id,wertherinfojson);
103
+            int count = wertherinfoService.deleteById(id, wertherinfojson);
106 104
             if (count > 0) {
107 105
                 ResponseEntity.ok();
108 106
                 return ResponseEntity.ok();
@@ -112,6 +110,7 @@ public class WertherinfoController {
112 110
         }
113 111
         return ResponseEntity.failed("ID数据有误!");
114 112
     }
113
+
115 114
     @RequestMapping(value = "/getBycfCode", method = RequestMethod.GET)
116 115
     @ApiOperation(value = "校验是否重复", notes = "校验是否重复")
117 116
     @ApiImplicitParams({
@@ -119,8 +118,8 @@ public class WertherinfoController {
119 118
             @ApiImplicitParam(name = "vdevname", value = "设备名称", paramType = "query"),
120 119
             @ApiImplicitParam(name = "orgId", value = "库id", paramType = "query")
121 120
     })
122
-    public ResponseEntity getBycfCode(String vdevcode,String vdevname,String orgId) {
123
-        boolean bycfCode = wertherinfoService.getBycfCode(vdevcode, vdevname,orgId);
121
+    public ResponseEntity getBycfCode(String vdevcode, String vdevname, String orgId) {
122
+        boolean bycfCode = wertherinfoService.getBycfCode(vdevcode, vdevname, orgId);
124 123
         return ResponseEntity.ok(bycfCode);
125 124
     }
126 125
 
@@ -129,76 +128,29 @@ public class WertherinfoController {
129 128
     public ResponseEntity sendNowWeatherDetection(@RequestParam @NotNull String orgId) {
130 129
         // 1.获取库端url
131 130
         String url = temperatureRecordService.getRemoteUrl(orgId);
132
-        if (org.apache.commons.lang.StringUtils.isBlank(url))
131
+        if (StringUtils.isBlank(url))
133 132
             return ResponseEntity.failed("库端硬件地址未配置!");
134
-        // 2.封装请求数据
135
-        MultiValueMap<String, String> requestEntity = new LinkedMultiValueMap<>();
136
-        //requestEntity.add("storeCode", storeCode);
137 133
         return remoteControlUtil.remoteScan(
138
-                String.format("%s%s", url, remoteControlUtil.wertherinfo),
139
-                requestEntity, "POST", null
134
+                String.format("%s%s", url, RemoteControlUtil.wertherinfo),
135
+                new LinkedMultiValueMap<>()
140 136
         );
141
-       //7E 0005 06 0101 0000000000
142
-//        byte[] b = new byte[11];
143
-//        b[0] = 0x7E;
144
-//        b[1] = 0x00;
145
-//        b[2] = 0x05;
146
-//        b[3] = 0X06;
147
-//        b[4] = 0x01;
148
-//        b[5] = 0x01;
149
-//        b[6] = 0x00;
150
-//        b[7] = 0x00;
151
-//        b[8] = 0x00;
152
-//        b[9] = 0x00;
153
-//        b[10] = 0x00;
154
-//        String result = "";
155
-//        // 发送指令
156
-//        try {
157
-//            String s = socketClient.startClient(b);
158
-//            // 0:失败;1:成功;2:设备通讯异常;3:设备故障;4:未知原因; 5: 本地模式(有的设备有本地模式,即无法远程控制)
159
-//            result = TypeEnum.resultDispose(s);
160
-//        } catch (Exception e) {
161
-//            e.printStackTrace();
162
-//            return ResponseEntity.ok("设备连接异常!");
163
-//        }
164
-//        return ResponseEntity.ok(result);
165 137
     }
166 138
 
167 139
     @RequestMapping(value = "/synchronizationAll", method = RequestMethod.GET)
168 140
     @ApiOperation(value = "与智远同步气象站信息基础数据", notes = "与智远同步气象站信息基础数据")
169 141
     @ApiImplicitParam(name = "orgId", value = "库房编码", paramType = "query")
170 142
     public ResponseEntity synchronizationAll(String orgId) {
171
-        //wertherzhiyuan
172 143
         // 1.获取库端url
173 144
         String url = temperatureRecordService.getRemoteUrl(orgId);
174
-        if (org.apache.commons.lang.StringUtils.isBlank(url))
145
+        if (StringUtils.isBlank(url))
175 146
             return ResponseEntity.failed("库端硬件地址未配置!");
176 147
         // 2.封装请求数据
177
-        MultiValueMap<String, String> requestEntity = new LinkedMultiValueMap<>();
178
-        String msg = null;
179
-        try {
180
-            msg = wertherinfoService.synchronizationAll(orgId);
181
-        } catch (Exception e) {
182
-            e.printStackTrace();
183
-            return ResponseEntity.ok("同步失败!");
184
-        }
185
-        requestEntity.add("msg", msg);
148
+        Map<String, String> requestEntity = new HashMap<>();
149
+        requestEntity.put("orgId", orgId);
186 150
         return remoteControlUtil.remoteScan(
187
-                String.format("%s%s", url, remoteControlUtil.wertherzhiyuan),
188
-                requestEntity, "POST", null
151
+                String.format("%s%s", url, RemoteControlUtil.wertherzhiyuan),
152
+                requestEntity
189 153
         );
190
-
191
-//        if (StringUtils.isBlank(orgId)){
192
-//            return ResponseEntity.ok("库房编码不能为空!");
193
-//        }
194
-//
195
-//        String msg = null;
196
-//        try {
197
-//            msg = wertherinfoService.synchronizationAll(orgId);
198
-//        } catch (Exception e) {
199
-//            e.printStackTrace();
200
-//            return ResponseEntity.ok("同步失败!");
201
-//        }
202
-//        return ResponseEntity.ok(msg);
203 154
     }
155
+
204 156
 }