Преглед изворни кода

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

mengy пре 3 година
родитељ
комит
fd823d3c67

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

@@ -35,6 +35,8 @@ public class RemoteControlUtil {
35
     public static final String sendOrder = "/intelligents/monitorWarning/sendNumberMonitor";
35
     public static final String sendOrder = "/intelligents/monitorWarning/sendNumberMonitor";
36
     // 粮温检测-手动选仓
36
     // 粮温检测-手动选仓
37
     public static final String chooseCFCode = "/intelligents/temperatureRecord/sendTemperatureDetection";
37
     public static final String chooseCFCode = "/intelligents/temperatureRecord/sendTemperatureDetection";
38
+    // 气象实时检测
39
+    public static final String wertherinfo = "/intelligents/wertherinfo/sendNowWeatherDetection";
38
     // 粮情全仓检测
40
     // 粮情全仓检测
39
     public static final String foodAll = "/intelligents/temperatureRecord/sendTemperatureDetectionAll";
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
 import com.chinaitop.depot.intelligent.weather.service.WeatherManagerService;
7
 import com.chinaitop.depot.intelligent.weather.service.WeatherManagerService;
8
 import com.github.pagehelper.PageHelper;
8
 import com.github.pagehelper.PageHelper;
9
 import com.github.pagehelper.PageInfo;
9
 import com.github.pagehelper.PageInfo;
10
+import com.sun.istack.NotNull;
10
 import com.unissoft.model.ResponseEntity;
11
 import com.unissoft.model.ResponseEntity;
11
 import io.swagger.annotations.Api;
12
 import io.swagger.annotations.Api;
12
 import io.swagger.annotations.ApiImplicitParam;
13
 import io.swagger.annotations.ApiImplicitParam;
@@ -36,15 +37,16 @@ public class WeatherManagerController {
36
             @ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query"),
37
             @ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query"),
37
             @ApiImplicitParam(name = "vqxzname", value = "气象站名称", paramType = "query"),
38
             @ApiImplicitParam(name = "vqxzname", value = "气象站名称", paramType = "query"),
38
             @ApiImplicitParam(name = "searchStartDate", value = "开始时间", paramType = "query"),
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
         List<TWeatherhsitory> list = null;
44
         List<TWeatherhsitory> list = null;
43
         try {
45
         try {
44
             if (null != pageNum && null != pageSize) {
46
             if (null != pageNum && null != pageSize) {
45
                 PageHelper.startPage(pageNum, pageSize);
47
                 PageHelper.startPage(pageNum, pageSize);
46
             }
48
             }
47
-            list = weatherManagerService.getList(vqxzname,searchStartDate,searchEndDate);
49
+            list = weatherManagerService.getList(vqxzname,searchStartDate,searchEndDate,orgId);
48
         } catch (Exception e) {
50
         } catch (Exception e) {
49
             e.printStackTrace();
51
             e.printStackTrace();
50
             return ResponseEntity.failed("查询气象列表失败");
52
             return ResponseEntity.failed("查询气象列表失败");

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

@@ -1,11 +1,14 @@
1
 package com.chinaitop.depot.intelligent.weather.controller;
1
 package com.chinaitop.depot.intelligent.weather.controller;
2
 
2
 
3
+import com.chinaitop.depot.intelligent.grainsituation.service.TemperatureRecordService;
3
 import com.chinaitop.depot.intelligent.socket.SocketClient;
4
 import com.chinaitop.depot.intelligent.socket.SocketClient;
4
 import com.chinaitop.depot.intelligent.utils.HexConvertUtils;
5
 import com.chinaitop.depot.intelligent.utils.HexConvertUtils;
6
+import com.chinaitop.depot.intelligent.utils.RemoteControlUtil;
5
 import com.chinaitop.depot.intelligent.weather.model.TWertherinfo;
7
 import com.chinaitop.depot.intelligent.weather.model.TWertherinfo;
6
 import com.chinaitop.depot.intelligent.weather.service.WertherinfoService;
8
 import com.chinaitop.depot.intelligent.weather.service.WertherinfoService;
7
 import com.github.pagehelper.PageHelper;
9
 import com.github.pagehelper.PageHelper;
8
 import com.github.pagehelper.PageInfo;
10
 import com.github.pagehelper.PageInfo;
11
+import com.sun.istack.NotNull;
9
 import com.unissoft.model.ResponseEntity;
12
 import com.unissoft.model.ResponseEntity;
10
 import com.unissoft.model.TypeEnum;
13
 import com.unissoft.model.TypeEnum;
11
 import io.swagger.annotations.Api;
14
 import io.swagger.annotations.Api;
@@ -15,6 +18,8 @@ import io.swagger.annotations.ApiOperation;
15
 import org.apache.commons.lang3.StringUtils;
18
 import org.apache.commons.lang3.StringUtils;
16
 import org.springframework.beans.factory.annotation.Autowired;
19
 import org.springframework.beans.factory.annotation.Autowired;
17
 import org.springframework.http.MediaType;
20
 import org.springframework.http.MediaType;
21
+import org.springframework.util.LinkedMultiValueMap;
22
+import org.springframework.util.MultiValueMap;
18
 import org.springframework.web.bind.annotation.RequestMapping;
23
 import org.springframework.web.bind.annotation.RequestMapping;
19
 import org.springframework.web.bind.annotation.RequestMethod;
24
 import org.springframework.web.bind.annotation.RequestMethod;
20
 import org.springframework.web.bind.annotation.RestController;
25
 import org.springframework.web.bind.annotation.RestController;
@@ -28,10 +33,12 @@ import java.util.Map;
28
 @RequestMapping(value = "/intelligents/wertherinfo")
33
 @RequestMapping(value = "/intelligents/wertherinfo")
29
 @Api(value = "WertherinfoController", description = "气象站设备控制类")
34
 @Api(value = "WertherinfoController", description = "气象站设备控制类")
30
 public class WertherinfoController {
35
 public class WertherinfoController {
31
-
36
+    @Autowired
37
+    private TemperatureRecordService temperatureRecordService;
32
     @Resource
38
     @Resource
33
     private WertherinfoService wertherinfoService;
39
     private WertherinfoService wertherinfoService;
34
-
40
+    @Resource
41
+    private RemoteControlUtil remoteControlUtil;
35
     @Autowired
42
     @Autowired
36
     private SocketClient socketClient;
43
     private SocketClient socketClient;
37
 
44
 
@@ -42,15 +49,16 @@ public class WertherinfoController {
42
             @ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query"),
49
             @ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query"),
43
             @ApiImplicitParam(name = "vqxzname", value = "气象站名称", paramType = "query"),
50
             @ApiImplicitParam(name = "vqxzname", value = "气象站名称", paramType = "query"),
44
             @ApiImplicitParam(name = "searchStartDate", value = "开始时间", paramType = "query"),
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
         List<TWertherinfo> list = null;
56
         List<TWertherinfo> list = null;
49
         try {
57
         try {
50
             if (null != pageNum && null != pageSize) {
58
             if (null != pageNum && null != pageSize) {
51
                 PageHelper.startPage(pageNum, pageSize);
59
                 PageHelper.startPage(pageNum, pageSize);
52
             }
60
             }
53
-            list = wertherinfoService.getList(vqxzname,searchStartDate,searchEndDate);
61
+            list = wertherinfoService.getList(vqxzname,searchStartDate,searchEndDate,orgId);
54
         } catch (Exception e) {
62
         } catch (Exception e) {
55
             e.printStackTrace();
63
             e.printStackTrace();
56
             return ResponseEntity.failed("查询气象站列表失败");
64
             return ResponseEntity.failed("查询气象站列表失败");
@@ -111,40 +119,52 @@ public class WertherinfoController {
111
     @ApiOperation(value = "校验是否重复", notes = "校验是否重复")
119
     @ApiOperation(value = "校验是否重复", notes = "校验是否重复")
112
     @ApiImplicitParams({
120
     @ApiImplicitParams({
113
             @ApiImplicitParam(name = "vdevcode", value = "设备编码", paramType = "query"),
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
         return ResponseEntity.ok(bycfCode);
127
         return ResponseEntity.ok(bycfCode);
119
     }
128
     }
120
 
129
 
121
     @RequestMapping(value = "/sendNowWeatherDetection", method = RequestMethod.POST)
130
     @RequestMapping(value = "/sendNowWeatherDetection", method = RequestMethod.POST)
122
     @ApiOperation(value = "气象实时检测", notes = "气象实时检测")
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
        //7E 0005 06 0101 0000000000
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
     @RequestMapping(value = "/synchronizationAll", method = RequestMethod.GET)
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
 import java.util.List;
5
 import java.util.List;
6
 
6
 
7
 public interface WeatherManagerService {
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
 import java.util.List;
7
 import java.util.List;
8
 
8
 
9
 public interface WertherinfoService {
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
     TWertherinfo getById(String id);
12
     TWertherinfo getById(String id);
13
 
13
 
@@ -15,7 +15,7 @@ public interface WertherinfoService {
15
 
15
 
16
     int deleteById(String id,String wertherinfojson);
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
     List<TWeatherhsitory> getByCodeAndTimes(List<String> cDcsCodes, List<Date> cTimes);
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
     private TWeatherhsitoryMapper tWeatherhsitoryMapper;
17
     private TWeatherhsitoryMapper tWeatherhsitoryMapper;
18
 
18
 
19
     @Override
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
         TWeatherhsitoryExample example = new TWeatherhsitoryExample();
21
         TWeatherhsitoryExample example = new TWeatherhsitoryExample();
22
         TWeatherhsitoryExample.Criteria criteria = example.createCriteria();
22
         TWeatherhsitoryExample.Criteria criteria = example.createCriteria();
23
         if (StringUtils.isNotBlank(vqxzname)){
23
         if (StringUtils.isNotBlank(vqxzname)){
@@ -26,6 +26,9 @@ public class WeatherManagerServiceImpl implements WeatherManagerService {
26
         if (StringUtils.isNotBlank(searchStartDate) && StringUtils.isNotBlank(searchEndDate)) {
26
         if (StringUtils.isNotBlank(searchStartDate) && StringUtils.isNotBlank(searchEndDate)) {
27
             criteria.andUpdateTimeBetween(DateUtils.stringToData(searchStartDate + DateUtils.startTime), DateUtils.stringToData(searchEndDate + DateUtils.endTime));
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
         example.setOrderByClause("update_time desc");
32
         example.setOrderByClause("update_time desc");
30
         List<TWeatherhsitory> tWeatherhsitories = tWeatherhsitoryMapper.selectByExample(example);
33
         List<TWeatherhsitory> tWeatherhsitories = tWeatherhsitoryMapper.selectByExample(example);
31
         return tWeatherhsitories;
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
     private UuidUtils uUidUtils;
39
     private UuidUtils uUidUtils;
40
     
40
     
41
     @Override
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
         TWertherinfoExample example = new TWertherinfoExample();
43
         TWertherinfoExample example = new TWertherinfoExample();
44
         TWertherinfoExample.Criteria criteria = example.createCriteria();
44
         TWertherinfoExample.Criteria criteria = example.createCriteria();
45
         if (StringUtils.isNotBlank(vqxzname)) {
45
         if (StringUtils.isNotBlank(vqxzname)) {
@@ -48,6 +48,9 @@ public class WertherinfoServiceImpl implements WertherinfoService {
48
         if (StringUtils.isNotBlank(searchStartDate) && StringUtils.isNotBlank(searchEndDate)) {
48
         if (StringUtils.isNotBlank(searchStartDate) && StringUtils.isNotBlank(searchEndDate)) {
49
             criteria.andUpdatetimeBetween(DateUtils.stringToData(searchStartDate + DateUtils.startTime), DateUtils.stringToData(searchEndDate + DateUtils.endTime));
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
         criteria.andDelFlagEqualTo(1);//未删除
54
         criteria.andDelFlagEqualTo(1);//未删除
52
         example.setOrderByClause("updatetime desc");
55
         example.setOrderByClause("updatetime desc");
53
         return tWertherinfoMapper.selectByExample(example);
56
         return tWertherinfoMapper.selectByExample(example);
@@ -106,7 +109,7 @@ public class WertherinfoServiceImpl implements WertherinfoService {
106
     }
109
     }
107
 
110
 
108
     @Override
111
     @Override
109
-    public boolean getBycfCode(String vdevcode, String vdevname) {
112
+    public boolean getBycfCode(String vdevcode, String vdevname, String orgId) {
110
         TWertherinfoExample example = new TWertherinfoExample();
113
         TWertherinfoExample example = new TWertherinfoExample();
111
         TWertherinfoExample.Criteria criteria = example.createCriteria();
114
         TWertherinfoExample.Criteria criteria = example.createCriteria();
112
         if (StringUtils.isNotEmpty(vdevcode)) {
115
         if (StringUtils.isNotEmpty(vdevcode)) {
@@ -115,6 +118,9 @@ public class WertherinfoServiceImpl implements WertherinfoService {
115
         if (StringUtils.isNotEmpty(vdevname)) {
118
         if (StringUtils.isNotEmpty(vdevname)) {
116
             criteria.andVqxznameEqualTo(vdevname);
119
             criteria.andVqxznameEqualTo(vdevname);
117
         }
120
         }
121
+        if (StringUtils.isNotBlank(orgId)){
122
+            criteria.andOrgIdEqualTo(orgId);
123
+        }
118
         List<TWertherinfo> tWertherinfos = tWertherinfoMapper.selectByExample(example);
124
         List<TWertherinfo> tWertherinfos = tWertherinfoMapper.selectByExample(example);
119
         if (tWertherinfos.size() > 0) {
125
         if (tWertherinfos.size() > 0) {
120
             return true;
126
             return true;