瀏覽代碼

智能仓房气象站增加查询条件

mengy 3 年之前
父節點
當前提交
fd823d3c67

+ 2 - 0
src/main/java/com/chinaitop/depot/intelligent/utils/RemoteControlUtil.java

@@ -35,6 +35,8 @@ public class RemoteControlUtil {
35 35
     public static final String sendOrder = "/intelligents/monitorWarning/sendNumberMonitor";
36 36
     // 粮温检测-手动选仓
37 37
     public static final String chooseCFCode = "/intelligents/temperatureRecord/sendTemperatureDetection";
38
+    // 气象实时检测
39
+    public static final String wertherinfo = "/intelligents/wertherinfo/sendNowWeatherDetection";
38 40
     // 粮情全仓检测
39 41
     public static final String foodAll = "/intelligents/temperatureRecord/sendTemperatureDetectionAll";
40 42
     // 粮情单仓检测

+ 5 - 3
src/main/java/com/chinaitop/depot/intelligent/weather/controller/WeatherManagerController.java

@@ -7,6 +7,7 @@ import com.chinaitop.depot.intelligent.weather.model.TWertherinfo;
7 7
 import com.chinaitop.depot.intelligent.weather.service.WeatherManagerService;
8 8
 import com.github.pagehelper.PageHelper;
9 9
 import com.github.pagehelper.PageInfo;
10
+import com.sun.istack.NotNull;
10 11
 import com.unissoft.model.ResponseEntity;
11 12
 import io.swagger.annotations.Api;
12 13
 import io.swagger.annotations.ApiImplicitParam;
@@ -36,15 +37,16 @@ public class WeatherManagerController {
36 37
             @ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query"),
37 38
             @ApiImplicitParam(name = "vqxzname", value = "气象站名称", paramType = "query"),
38 39
             @ApiImplicitParam(name = "searchStartDate", value = "开始时间", paramType = "query"),
39
-            @ApiImplicitParam(name = "searchEndDate", value = "结束时间", paramType = "query")
40
+            @ApiImplicitParam(name = "searchEndDate", value = "结束时间", paramType = "query"),
41
+            @ApiImplicitParam(name = "orgId", value = "库id", paramType = "query")
40 42
     })
41
-    public ResponseEntity<PageInfo<TWeatherhsitory>> getList(Integer pageNum, Integer pageSize, String vqxzname, String searchStartDate, String searchEndDate) {
43
+    public ResponseEntity<PageInfo<TWeatherhsitory>> getList(Integer pageNum, Integer pageSize, String vqxzname, String searchStartDate, String searchEndDate, @NotNull String orgId) {
42 44
         List<TWeatherhsitory> list = null;
43 45
         try {
44 46
             if (null != pageNum && null != pageSize) {
45 47
                 PageHelper.startPage(pageNum, pageSize);
46 48
             }
47
-            list = weatherManagerService.getList(vqxzname,searchStartDate,searchEndDate);
49
+            list = weatherManagerService.getList(vqxzname,searchStartDate,searchEndDate,orgId);
48 50
         } catch (Exception e) {
49 51
             e.printStackTrace();
50 52
             return ResponseEntity.failed("查询气象列表失败");

+ 52 - 32
src/main/java/com/chinaitop/depot/intelligent/weather/controller/WertherinfoController.java

@@ -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)

+ 1 - 1
src/main/java/com/chinaitop/depot/intelligent/weather/service/WeatherManagerService.java

@@ -5,5 +5,5 @@ import com.chinaitop.depot.intelligent.weather.model.TWeatherhsitory;
5 5
 import java.util.List;
6 6
 
7 7
 public interface WeatherManagerService {
8
-    List<TWeatherhsitory> getList(String vqxzname,String searchStartDate,String searchEndDate);
8
+    List<TWeatherhsitory> getList(String vqxzname,String searchStartDate,String searchEndDate,String orgId);
9 9
 }

+ 2 - 2
src/main/java/com/chinaitop/depot/intelligent/weather/service/WertherinfoService.java

@@ -7,7 +7,7 @@ import java.util.Date;
7 7
 import java.util.List;
8 8
 
9 9
 public interface WertherinfoService {
10
-    List<TWertherinfo> getList(String vqxzname, String searchStartDate, String searchEndDate);
10
+    List<TWertherinfo> getList(String vqxzname, String searchStartDate, String searchEndDate, String orgId);
11 11
 
12 12
     TWertherinfo getById(String id);
13 13
 
@@ -15,7 +15,7 @@ public interface WertherinfoService {
15 15
 
16 16
     int deleteById(String id,String wertherinfojson);
17 17
 
18
-    boolean getBycfCode(String vdevcode, String vdevname);
18
+    boolean getBycfCode(String vdevcode, String vdevname, String orgId);
19 19
 
20 20
     List<TWeatherhsitory> getByCodeAndTimes(List<String> cDcsCodes, List<Date> cTimes);
21 21
 

+ 4 - 1
src/main/java/com/chinaitop/depot/intelligent/weather/service/impl/WeatherManagerServiceImpl.java

@@ -17,7 +17,7 @@ public class WeatherManagerServiceImpl implements WeatherManagerService {
17 17
     private TWeatherhsitoryMapper tWeatherhsitoryMapper;
18 18
 
19 19
     @Override
20
-    public List<TWeatherhsitory> getList(String vqxzname,String searchStartDate,String searchEndDate) {
20
+    public List<TWeatherhsitory> getList(String vqxzname,String searchStartDate,String searchEndDate,String orgId) {
21 21
         TWeatherhsitoryExample example = new TWeatherhsitoryExample();
22 22
         TWeatherhsitoryExample.Criteria criteria = example.createCriteria();
23 23
         if (StringUtils.isNotBlank(vqxzname)){
@@ -26,6 +26,9 @@ public class WeatherManagerServiceImpl implements WeatherManagerService {
26 26
         if (StringUtils.isNotBlank(searchStartDate) && StringUtils.isNotBlank(searchEndDate)) {
27 27
             criteria.andUpdateTimeBetween(DateUtils.stringToData(searchStartDate + DateUtils.startTime), DateUtils.stringToData(searchEndDate + DateUtils.endTime));
28 28
         }
29
+        if (StringUtils.isNotBlank(orgId)){
30
+            criteria.andOrgIdEqualTo(orgId);
31
+        }
29 32
         example.setOrderByClause("update_time desc");
30 33
         List<TWeatherhsitory> tWeatherhsitories = tWeatherhsitoryMapper.selectByExample(example);
31 34
         return tWeatherhsitories;

+ 8 - 2
src/main/java/com/chinaitop/depot/intelligent/weather/service/impl/WertherinfoServiceImpl.java

@@ -39,7 +39,7 @@ public class WertherinfoServiceImpl implements WertherinfoService {
39 39
     private UuidUtils uUidUtils;
40 40
     
41 41
     @Override
42
-    public List<TWertherinfo> getList(String vqxzname, String searchStartDate, String searchEndDate) {
42
+    public List<TWertherinfo> getList(String vqxzname, String searchStartDate, String searchEndDate, String orgId) {
43 43
         TWertherinfoExample example = new TWertherinfoExample();
44 44
         TWertherinfoExample.Criteria criteria = example.createCriteria();
45 45
         if (StringUtils.isNotBlank(vqxzname)) {
@@ -48,6 +48,9 @@ public class WertherinfoServiceImpl implements WertherinfoService {
48 48
         if (StringUtils.isNotBlank(searchStartDate) && StringUtils.isNotBlank(searchEndDate)) {
49 49
             criteria.andUpdatetimeBetween(DateUtils.stringToData(searchStartDate + DateUtils.startTime), DateUtils.stringToData(searchEndDate + DateUtils.endTime));
50 50
         }
51
+        if (StringUtils.isNotBlank(orgId)){
52
+            criteria.andOrgIdEqualTo(orgId);
53
+        }
51 54
         criteria.andDelFlagEqualTo(1);//未删除
52 55
         example.setOrderByClause("updatetime desc");
53 56
         return tWertherinfoMapper.selectByExample(example);
@@ -106,7 +109,7 @@ public class WertherinfoServiceImpl implements WertherinfoService {
106 109
     }
107 110
 
108 111
     @Override
109
-    public boolean getBycfCode(String vdevcode, String vdevname) {
112
+    public boolean getBycfCode(String vdevcode, String vdevname, String orgId) {
110 113
         TWertherinfoExample example = new TWertherinfoExample();
111 114
         TWertherinfoExample.Criteria criteria = example.createCriteria();
112 115
         if (StringUtils.isNotEmpty(vdevcode)) {
@@ -115,6 +118,9 @@ public class WertherinfoServiceImpl implements WertherinfoService {
115 118
         if (StringUtils.isNotEmpty(vdevname)) {
116 119
             criteria.andVqxznameEqualTo(vdevname);
117 120
         }
121
+        if (StringUtils.isNotBlank(orgId)){
122
+            criteria.andOrgIdEqualTo(orgId);
123
+        }
118 124
         List<TWertherinfo> tWertherinfos = tWertherinfoMapper.selectByExample(example);
119 125
         if (tWertherinfos.size() > 0) {
120 126
             return true;