Przeglądaj źródła

添加非空效验

hanqingsong 3 lat temu
rodzic
commit
e5507337a9

+ 10 - 12
src/main/java/com/chinaitop/depot/intelligent/grainsituation/controller/TemperatureRecordController.java

@@ -23,10 +23,7 @@ import org.springframework.http.MediaType;
23 23
 import org.springframework.util.LinkedMultiValueMap;
24 24
 import org.springframework.util.MultiValueMap;
25 25
 import org.springframework.validation.annotation.Validated;
26
-import org.springframework.web.bind.annotation.RequestBody;
27
-import org.springframework.web.bind.annotation.RequestMapping;
28
-import org.springframework.web.bind.annotation.RequestMethod;
29
-import org.springframework.web.bind.annotation.RestController;
26
+import org.springframework.web.bind.annotation.*;
30 27
 import org.springframework.web.client.RestTemplate;
31 28
 
32 29
 import javax.annotation.Resource;
@@ -58,7 +55,7 @@ public class TemperatureRecordController {
58 55
             @ApiImplicitParam(name = "vCfCode", value = "仓库名称", paramType = "query"),
59 56
             @ApiImplicitParam(name = "tType", value = "检测类型0测温,1粮油,2测水分", paramType = "query")
60 57
     })
61
-    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, @RequestParam @NotNull String orgId) {
62 59
         List<TTestdata> list = null;
63 60
         try {
64 61
             if (null != pageNum && null != pageSize) {
@@ -87,7 +84,7 @@ public class TemperatureRecordController {
87 84
             @ApiImplicitParam(name = "vCfCode", value = "库房编码", paramType = "query"),
88 85
             @ApiImplicitParam(name = "vDatatime", value = "测温时间", paramType = "query")
89 86
     })
90
-    public ResponseEntity findByHouseAndTime(String lqId, String vCfCode, String vDatatime, String orgId) {
87
+    public ResponseEntity findByHouseAndTime(String lqId, String vCfCode, String vDatatime, @RequestParam @NotNull String orgId) {
91 88
         List<TTestdataLayer> tTestdataLayer = null;
92 89
         try {
93 90
             tTestdataLayer = temperatureRecordService.findByHouseAndTime(lqId, vCfCode, vDatatime, orgId);
@@ -145,7 +142,7 @@ public class TemperatureRecordController {
145 142
             @ApiImplicitParam(name = "tType", value = "检测类型0测温,1粮油,2测水分", paramType = "query")
146 143
     })
147 144
     public ResponseEntity<PageInfo<TTestdata>> getComparisonLeft(Integer pageNum, Integer pageSize, String vCfCodeLeft,
148
-                                                                 String startTimeLeft, String endTimeLeft, String tType, String orgId) {
145
+                                                                 String startTimeLeft, String endTimeLeft, String tType,@RequestParam @NotNull String orgId) {
149 146
         List<TTestdata> list = null;
150 147
         try {
151 148
             if (null != pageNum && null != pageSize) {
@@ -181,7 +178,7 @@ public class TemperatureRecordController {
181 178
             @ApiImplicitParam(name = "tType", value = "检测类型0测温,1粮油,2测水分", paramType = "query")
182 179
     })
183 180
     public ResponseEntity<PageInfo<TTestdata>> getComparisonRight(Integer pageNum, Integer pageSize, String vCfCodeRight,
184
-                                                                  String startTimeRight, String endTimeRight, String tType,String orgId) {
181
+                                                                  String startTimeRight, String endTimeRight, String tType,@RequestParam @NotNull String orgId) {
185 182
 
186 183
         List<TTestdata> list = null;
187 184
         try {
@@ -215,7 +212,7 @@ public class TemperatureRecordController {
215 212
             @ApiImplicitParam(name = "storehouse", value = "仓库编号", paramType = "query"),
216 213
             @ApiImplicitParam(name = "id", value = "粮情,水分id", paramType = "query")
217 214
     })
218
-    public ResponseEntity<PageInfo<Map<String, Object>>> getGrainPointAll(Integer pageNum, Integer pageSize, String storehouse, String time, String id, String orgId) {
215
+    public ResponseEntity<PageInfo<Map<String, Object>>> getGrainPointAll(Integer pageNum, Integer pageSize, String storehouse, String time, String id,@RequestParam @NotNull String orgId) {
219 216
         List<Map<String, Object>> list = null;
220 217
         try {
221 218
             if (null != pageNum && null != pageSize) {
@@ -248,7 +245,7 @@ public class TemperatureRecordController {
248 245
     @ApiImplicitParams({
249 246
             @ApiImplicitParam(name = "storeCode", defaultValue = "001", value = "仓库编号", paramType = "query")
250 247
     })
251
-    public ResponseEntity<Map<String, String>> sendTemperatureDetection(String storeCode, @NotNull String orgId) {
248
+    public ResponseEntity<Map<String, String>> sendTemperatureDetection(String storeCode,@RequestParam @NotNull String orgId) {
252 249
         // 1.获取库端url
253 250
         String url = temperatureRecordService.getRemoteUrl(orgId);
254 251
         if (StringUtils.isBlank(url))
@@ -267,7 +264,7 @@ public class TemperatureRecordController {
267 264
     @ApiImplicitParams({
268 265
             @ApiImplicitParam(name = "tType", value = "检测类型0测温,1粮油,2测水分", paramType = "query")
269 266
     })
270
-    public ResponseEntity sendTemperatureDetectionAll(String tType, @NotNull String orgId) {
267
+    public ResponseEntity sendTemperatureDetectionAll(String tType,@RequestParam @NotNull String orgId) {
271 268
         // 1.获取库端url
272 269
         String url = temperatureRecordService.getRemoteUrl(orgId);
273 270
         if (StringUtils.isBlank(url))
@@ -293,7 +290,7 @@ public class TemperatureRecordController {
293 290
             @ApiImplicitParam(name = "storeCode", defaultValue = "001", value = "仓库编号", paramType = "query"),
294 291
             @ApiImplicitParam(name = "tType", value = "检测类型0测温,1粮油,2测水分", paramType = "query")
295 292
     })
296
-    public ResponseEntity sendOnlyStoreDetection(String storeCode, String tType, @NotNull String orgId) {
293
+    public ResponseEntity sendOnlyStoreDetection(String storeCode, String tType,@RequestParam @NotNull String orgId) {
297 294
         // 1.获取库端url
298 295
         String url = temperatureRecordService.getRemoteUrl(orgId);
299 296
         if (StringUtils.isBlank(url))
@@ -323,4 +320,5 @@ public class TemperatureRecordController {
323 320
         }
324 321
         return ResponseEntity.ok(byId);
325 322
     }
323
+
326 324
 }

+ 4 - 3
src/main/java/com/chinaitop/depot/intelligent/utils/RemoteControlUtil.java

@@ -8,6 +8,7 @@ import org.springframework.util.StringUtils;
8 8
 import org.springframework.web.client.RestTemplate;
9 9
 
10 10
 import javax.annotation.Resource;
11
+import javax.validation.Valid;
11 12
 import javax.validation.constraints.NotNull;
12 13
 import java.util.Iterator;
13 14
 import java.util.Map;
@@ -70,7 +71,7 @@ public class RemoteControlUtil {
70 71
      * @param requestMap    get请求参数 无参数传入 new HashMap<>()
71 72
      * @return string
72 73
      */
73
-    public ResponseEntity remoteScan(@NotNull String url, MultiValueMap requestEntity, @NotNull String httpType, Map requestMap) {
74
+    public ResponseEntity remoteScan(@Valid @NotNull String url, MultiValueMap requestEntity,@Valid  @NotNull String httpType, Map requestMap) {
74 75
         httpType = httpType.toUpperCase();
75 76
         ResponseEntity responseEntity = null;
76 77
         try {
@@ -91,7 +92,7 @@ public class RemoteControlUtil {
91 92
      * @param requestEntity 参数对象
92 93
      * @return ResponseEntity
93 94
      */
94
-    public ResponseEntity remoteScan(@NotNull String url, MultiValueMap requestEntity) {
95
+    public ResponseEntity remoteScan(@Valid @NotNull String url, MultiValueMap requestEntity) {
95 96
         return restTemplate.postForObject(url, requestEntity, ResponseEntity.class);
96 97
     }
97 98
 
@@ -101,7 +102,7 @@ public class RemoteControlUtil {
101 102
      * @param requestMap 参数对象
102 103
      * @return ResponseEntity
103 104
      */
104
-    public ResponseEntity remoteScan(@NotNull String url, Map requestMap) {
105
+    public ResponseEntity remoteScan(@Valid @NotNull String url, Map requestMap) {
105 106
         return restTemplate.getForObject(getForObject(url, requestMap), ResponseEntity.class);
106 107
     }
107 108
 

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

@@ -1,25 +1,21 @@
1 1
 package com.chinaitop.depot.intelligent.weather.controller;
2 2
 
3
-import com.chinaitop.depot.intelligent.basicdata.model.TNtinfo;
4
-import com.chinaitop.depot.intelligent.basicdata.service.GasService;
5 3
 import com.chinaitop.depot.intelligent.weather.model.TWeatherhsitory;
6
-import com.chinaitop.depot.intelligent.weather.model.TWertherinfo;
7 4
 import com.chinaitop.depot.intelligent.weather.service.WeatherManagerService;
8 5
 import com.github.pagehelper.PageHelper;
9 6
 import com.github.pagehelper.PageInfo;
10
-import com.sun.istack.NotNull;
11 7
 import com.unissoft.model.ResponseEntity;
12 8
 import io.swagger.annotations.Api;
13 9
 import io.swagger.annotations.ApiImplicitParam;
14 10
 import io.swagger.annotations.ApiImplicitParams;
15 11
 import io.swagger.annotations.ApiOperation;
16
-import org.apache.commons.lang3.StringUtils;
17
-import org.springframework.http.MediaType;
18 12
 import org.springframework.web.bind.annotation.RequestMapping;
19 13
 import org.springframework.web.bind.annotation.RequestMethod;
14
+import org.springframework.web.bind.annotation.RequestParam;
20 15
 import org.springframework.web.bind.annotation.RestController;
21 16
 
22 17
 import javax.annotation.Resource;
18
+import javax.validation.constraints.NotNull;
23 19
 import java.util.List;
24 20
 
25 21
 @RestController
@@ -40,7 +36,7 @@ public class WeatherManagerController {
40 36
             @ApiImplicitParam(name = "searchEndDate", value = "结束时间", paramType = "query"),
41 37
             @ApiImplicitParam(name = "orgId", value = "库id", paramType = "query")
42 38
     })
43
-    public ResponseEntity<PageInfo<TWeatherhsitory>> getList(Integer pageNum, Integer pageSize, String vqxzname, String searchStartDate, String searchEndDate, @NotNull String orgId) {
39
+    public ResponseEntity<PageInfo<TWeatherhsitory>> getList(Integer pageNum, Integer pageSize, String vqxzname, String searchStartDate, String searchEndDate,@RequestParam @NotNull String orgId) {
44 40
         List<TWeatherhsitory> list = null;
45 41
         try {
46 42
             if (null != pageNum && null != pageSize) {

+ 4 - 7
src/main/java/com/chinaitop/depot/intelligent/weather/controller/WertherinfoController.java

@@ -2,15 +2,12 @@ package com.chinaitop.depot.intelligent.weather.controller;
2 2
 
3 3
 import com.chinaitop.depot.intelligent.grainsituation.service.TemperatureRecordService;
4 4
 import com.chinaitop.depot.intelligent.socket.SocketClient;
5
-import com.chinaitop.depot.intelligent.utils.HexConvertUtils;
6 5
 import com.chinaitop.depot.intelligent.utils.RemoteControlUtil;
7 6
 import com.chinaitop.depot.intelligent.weather.model.TWertherinfo;
8 7
 import com.chinaitop.depot.intelligent.weather.service.WertherinfoService;
9 8
 import com.github.pagehelper.PageHelper;
10 9
 import com.github.pagehelper.PageInfo;
11
-import com.sun.istack.NotNull;
12 10
 import com.unissoft.model.ResponseEntity;
13
-import com.unissoft.model.TypeEnum;
14 11
 import io.swagger.annotations.Api;
15 12
 import io.swagger.annotations.ApiImplicitParam;
16 13
 import io.swagger.annotations.ApiImplicitParams;
@@ -22,12 +19,12 @@ import org.springframework.util.LinkedMultiValueMap;
22 19
 import org.springframework.util.MultiValueMap;
23 20
 import org.springframework.web.bind.annotation.RequestMapping;
24 21
 import org.springframework.web.bind.annotation.RequestMethod;
22
+import org.springframework.web.bind.annotation.RequestParam;
25 23
 import org.springframework.web.bind.annotation.RestController;
26 24
 
27 25
 import javax.annotation.Resource;
28
-import java.util.LinkedHashMap;
26
+import javax.validation.constraints.NotNull;
29 27
 import java.util.List;
30
-import java.util.Map;
31 28
 
32 29
 @RestController
33 30
 @RequestMapping(value = "/intelligents/wertherinfo")
@@ -52,7 +49,7 @@ public class WertherinfoController {
52 49
             @ApiImplicitParam(name = "searchEndDate", value = "结束时间", paramType = "query"),
53 50
             @ApiImplicitParam(name = "orgId", value = "库id", paramType = "query")
54 51
     })
55
-    public ResponseEntity<PageInfo<TWertherinfo>> getList(Integer pageNum, Integer pageSize, String vqxzname, String searchStartDate, String searchEndDate, @NotNull String orgId) {
52
+    public ResponseEntity<PageInfo<TWertherinfo>> getList(Integer pageNum, Integer pageSize, String vqxzname, String searchStartDate, String searchEndDate, @RequestParam @NotNull String orgId) {
56 53
         List<TWertherinfo> list = null;
57 54
         try {
58 55
             if (null != pageNum && null != pageSize) {
@@ -129,7 +126,7 @@ public class WertherinfoController {
129 126
 
130 127
     @RequestMapping(value = "/sendNowWeatherDetection", method = RequestMethod.POST)
131 128
     @ApiOperation(value = "气象实时检测", notes = "气象实时检测")
132
-    public ResponseEntity sendNowWeatherDetection( @NotNull String orgId) {
129
+    public ResponseEntity sendNowWeatherDetection(@RequestParam @NotNull String orgId) {
133 130
         // 1.获取库端url
134 131
         String url = temperatureRecordService.getRemoteUrl(orgId);
135 132
         if (org.apache.commons.lang.StringUtils.isBlank(url))