Commit 46d1c007db671131c01b0414f8b821f58e1df883

Authored by Liu Haoyu
1 parent 00762fb4

sun.misc.BASE64Decoder依赖取消, 使用commons-codec.jar 的Base64

src/main/java/com/objecteye/controller/HumanVehicleAssociationController.java
... ... @@ -35,7 +35,7 @@ public class HumanVehicleAssociationController {
35 35 if (pageResult == null || pageResult.getRow().size() == 0) {
36 36 return CommonResult.success(201, "没有符合要求的数据", null);
37 37 }
38   - return CommonResult.success(pageResult, "数据查询成功!!");
  38 + return CommonResult.success(pageResult);
39 39 } catch (Exception e) {
40 40 e.printStackTrace();
41 41 return CommonResult.failed();
... ... @@ -53,7 +53,7 @@ public class HumanVehicleAssociationController {
53 53 if (row == null || row.size() == 0) {
54 54 return CommonResult.success(201, "没有符合要求的数据", searchPeopleOfhphmResult);
55 55 }
56   - return CommonResult.success(searchPeopleOfhphmResult, "数据查询成功!!");
  56 + return CommonResult.success(searchPeopleOfhphmResult);
57 57 } catch (Exception e) {
58 58 e.printStackTrace();
59 59 return CommonResult.failed();
... ... @@ -69,7 +69,7 @@ public class HumanVehicleAssociationController {
69 69 if (faceInfoParam == null || faceInfoParam.size() == 0) {
70 70 return CommonResult.success(201, "没有符合要求的数据", faceInfoParam);
71 71 }
72   - return CommonResult.success(faceInfoParam, "数据查询成功!!");
  72 + return CommonResult.success(faceInfoParam);
73 73 } catch (Exception e) {
74 74 e.printStackTrace();
75 75 return CommonResult.failed();
... ...
src/main/java/com/objecteye/controller/SpecialtyVehicleController.java
... ... @@ -33,8 +33,7 @@ public class SpecialtyVehicleController {
33 33 @RequestMapping("/slagCar/findByCondition")
34 34 public JSONObject findByCondition(@RequestBody VehicleCondition vehicleCondition) {
35 35 //渣土车查询
36   - JSONObject by = mongoTemplates.findBy(vehicleCondition, 2);
37   - return by;
  36 + return mongoTemplates.findBy(vehicleCondition, 2);
38 37 }
39 38  
40 39  
... ... @@ -47,8 +46,7 @@ public class SpecialtyVehicleController {
47 46 @RequestMapping("/slagCar/findCoordinateByPic")
48 47 public JSONObject siteByPic(@RequestParam("picfile") MultipartFile picfile, Integer vehicle_special_type_number) {
49 48 //渣土车坐标 vehicle_special_type_number
50   - JSONObject coordinateByPic = specialtyServices.findCoordinateByPic(picfile, vehicle_special_type_number);
51   - return coordinateByPic;
  49 + return specialtyServices.findCoordinateByPic(picfile, vehicle_special_type_number);
52 50  
53 51  
54 52 }
... ... @@ -72,8 +70,7 @@ public class SpecialtyVehicleController {
72 70 */
73 71 @RequestMapping("/slagCar/findById")
74 72 public JSONObject findById(@RequestBody Map<String, String> map) {
75   - JSONObject byPic = specialtyServices.findById(map.get("id"));
76   - return byPic;
  73 + return specialtyServices.findById(map.get("id"));
77 74 }
78 75  
79 76 /**
... ... @@ -83,15 +80,9 @@ public class SpecialtyVehicleController {
83 80 */
84 81 @RequestMapping("/slagCar/findByGcxh")
85 82 public JSONObject findByGcxh(int gcxh, MultipartFile picfile) {
86   - JSONObject coordinateByPic = specialtyServices.findByGcxh(gcxh, picfile);
87   - return coordinateByPic;
88   - /*
89   - //老接口
90   - JSONObject byPic = specialtyServices.findByGcxh1(gcxh, picfile);
91   - return byPic;*/
  83 + return specialtyServices.findByGcxh(gcxh, picfile);
92 84 }
93 85  
94   -
95 86 /**
96 87 * 危化品车
97 88 * 通过车牌(支持模糊)、多条件查询车辆信息(平铺)
... ... @@ -101,8 +92,7 @@ public class SpecialtyVehicleController {
101 92 @RequestMapping("/chemistryCar/findByCondition")
102 93 public JSONObject chemistryFindByCondition(@RequestBody VehicleCondition vehicleCondition) {
103 94 //危化品车查询
104   - JSONObject vehicleInfoRes = mongoTemplates.findBy(vehicleCondition, 1);
105   - return vehicleInfoRes;
  95 + return mongoTemplates.findBy(vehicleCondition, 1);
106 96 }
107 97  
108 98 /**
... ... @@ -119,7 +109,6 @@ public class SpecialtyVehicleController {
119 109  
120 110 }
121 111  
122   -
123 112 /**
124 113 * 测试
125 114 *
... ... @@ -129,12 +118,10 @@ public class SpecialtyVehicleController {
129 118 public JSONObject test(Integer gcxh, @RequestParam("picfile") MultipartFile picfile) {
130 119  
131 120  
132   - JSONObject coordinateByPic = specialtyServices.findByGcxh(gcxh, picfile);
133   - return coordinateByPic;
  121 + return specialtyServices.findByGcxh(gcxh, picfile);
134 122  
135 123 }
136 124  
137   -
138 125 /**
139 126 * 测试
140 127 *
... ... @@ -142,11 +129,8 @@ public class SpecialtyVehicleController {
142 129 */
143 130 @RequestMapping("/getResult")
144 131 public Object getResult(@RequestBody Map<String, Object> body) {
145   - //CustomAssert.checkHeader(header);
146 132 CustomAssert.checkField(body, CustomParamCollections.VEHICLE_SINGLE_PARAM);
147 133 CustomAssert.checkSimpleMapParam(body, CustomParamCollections.VEHICLE_SINGLE_PARAM);
148   - Map<String, Object> colorAndBrand = specialtyServices.getColorAndBrand(body);
149   -
150   - return colorAndBrand;
  134 + return specialtyServices.getColorAndBrand(body);
151 135 }
152 136 }
... ...
src/main/java/com/objecteye/entity/SyVehicleForbiddenTaskOutput.java
... ... @@ -25,8 +25,6 @@ public class SyVehicleForbiddenTaskOutput implements Serializable {
25 25  
26 26 private String forbiddenDetailTime;
27 27  
28   - private String equipment;
29   -
30 28 private String status;
31 29  
32 30 private String warningNumber;
... ...
src/main/java/com/objecteye/service/SpecialtyServices.java
... ... @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject;
4 4 import com.objecteye.pojo.VehicleCondition;
5 5 import com.objecteye.pojo.VehicleInfoRes;
6 6 import org.springframework.stereotype.Service;
7   -import org.springframework.web.bind.annotation.RequestMapping;
8 7 import org.springframework.web.multipart.MultipartFile;
9 8  
10 9 import java.util.Map;
... ... @@ -28,24 +27,6 @@ public interface SpecialtyServices {
28 27 */
29 28 JSONObject findByPic(int number, double threshold, int currentpage, int pagevolume, MultipartFile picfile, Long starttime, Long endtime, Integer vehicle_special_type_number) throws InterruptedException;
30 29  
31   -
32   - /**
33   - * 危化品车
34   - * 通过车牌(支持模糊)、多条件查询车辆信息(平铺)
35   - *
36   - * @return
37   - */
38   - VehicleInfoRes chemistryFindByCondition(VehicleCondition vehicleCondition);
39   -
40   - /**
41   - * 危化品车
42   - * 通通过车辆特征码、时间、地点范围进行搜索
43   - *
44   - * @return
45   - */
46   - @RequestMapping("/chemistryCar/findByPic")
47   - VehicleInfoRes chemistryFindByPic(int number, double threshold, int currentpage, int pagevolume, MultipartFile picfile, String starttime, String endtime);
48   -
49 30 /**
50 31 * 通过图片返回每辆车的坐标
51 32 *
... ...
src/main/java/com/objecteye/service/impl/SpecialtyServicesImpl.java
... ... @@ -9,6 +9,7 @@ import com.objecteye.exception.CustomXException;
9 9 import com.objecteye.pojo.*;
10 10 import com.objecteye.service.SpecialtyServices;
11 11 import com.objecteye.utils.*;
  12 +import org.apache.commons.codec.binary.Base64;
12 13 import org.slf4j.Logger;
13 14 import org.slf4j.LoggerFactory;
14 15 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -16,7 +17,6 @@ import org.springframework.beans.factory.annotation.Value;
16 17 import org.springframework.data.redis.core.RedisTemplate;
17 18 import org.springframework.stereotype.Service;
18 19 import org.springframework.web.multipart.MultipartFile;
19   -import sun.misc.BASE64Decoder;
20 20  
21 21 import javax.imageio.ImageIO;
22 22 import java.awt.image.BufferedImage;
... ... @@ -184,18 +184,6 @@ public class SpecialtyServicesImpl implements SpecialtyServices {
184 184 return result;
185 185 }
186 186  
187   - @Override
188   - public VehicleInfoRes chemistryFindByCondition(VehicleCondition vehicleCondition) {
189   -
190   - return null;
191   - }
192   -
193   - @Override
194   - public VehicleInfoRes chemistryFindByPic(int number, double threshold, int currentpage, int pagevolume, MultipartFile picfile, String starttime, String endtime) {
195   -
196   - return null;
197   - }
198   -
199 187 //通过转Base64的方式运行
200 188 @Override
201 189 public JSONObject findCoordinateByPic(MultipartFile picfile, Integer vehicleSpecialTypeNumber) {
... ... @@ -322,10 +310,9 @@ public class SpecialtyServicesImpl implements SpecialtyServices {
322 310 * @param base64String base64码字符串
323 311 **/
324 312 public BufferedImage changeBase64StringtoImage(String base64String) {
325   - BASE64Decoder decoder = new BASE64Decoder();
326 313 BufferedImage buffer = null;
327 314 try {
328   - byte[] bytes = decoder.decodeBuffer(base64String);
  315 + byte[] bytes = Base64.decodeBase64(base64String);
329 316 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
330 317 buffer = ImageIO.read(bais);
331 318 } catch (IOException e) {
... ...
src/main/java/com/objecteye/utils/GlobalUtil.java
... ... @@ -14,7 +14,6 @@ import org.apache.http.util.EntityUtils;
14 14 import org.slf4j.Logger;
15 15 import org.slf4j.LoggerFactory;
16 16 import org.springframework.boot.system.ApplicationHome;
17   -import sun.misc.BASE64Decoder;
18 17  
19 18 import javax.imageio.ImageIO;
20 19 import java.awt.image.BufferedImage;
... ... @@ -30,8 +29,6 @@ import java.util.regex.Pattern;
30 29 public class GlobalUtil {
31 30 private static Logger logger = LoggerFactory.getLogger(GlobalUtil.class);
32 31  
33   - public final static String IPWITHDEPLOYLIST = "IpWithDeployList";
34   - public final static String EQUIPMENTIPANDID = "equipmentIpAndId";
35 32 public final static String PREVIEWIPLISTLIST = "previewIpList";
36 33 public final static String ALARMMSG = "alarmMsg";
37 34 public final static String DEPLOYIDANDENDTIME = "deployIdAndTime";
... ... @@ -324,12 +321,12 @@ public class GlobalUtil {
324 321 }
325 322  
326 323 public static boolean base64StrToImage(String imgStr, String path) {
327   - if (imgStr == null)
  324 + if (imgStr == null) {
328 325 return false;
329   - BASE64Decoder decoder = new BASE64Decoder();
  326 + }
330 327 try {
331 328 // 解密
332   - byte[] b = decoder.decodeBuffer(imgStr);
  329 + byte[] b = org.apache.commons.codec.binary.Base64.decodeBase64(imgStr);
333 330 // 处理数据
334 331 for (int i = 0; i < b.length; ++i) {
335 332 if (b[i] < 0) {
... ... @@ -423,7 +420,9 @@ public class GlobalUtil {
423 420 e.printStackTrace();
424 421 } finally {
425 422 try {
426   - response.close();
  423 + if (response != null) {
  424 + response.close();
  425 + }
427 426 } catch (IOException e) {
428 427 e.printStackTrace();
429 428 }
... ...
src/main/java/com/objecteye/utils/HttpClientUtils.java
... ... @@ -7,7 +7,6 @@ import org.springframework.http.ResponseEntity;
7 7 import org.springframework.stereotype.Component;
8 8 import org.springframework.web.client.RestTemplate;
9 9 import org.springframework.web.multipart.MultipartFile;
10   -import sun.misc.BASE64Decoder;
11 10  
12 11 import javax.imageio.ImageIO;
13 12 import java.awt.image.BufferedImage;
... ... @@ -119,10 +118,9 @@ public class HttpClientUtils {
119 118 * @param base64String base64码字符串
120 119 **/
121 120 public BufferedImage changeBase64StringtoImage(String base64String) {
122   - BASE64Decoder decoder = new BASE64Decoder();
123 121 BufferedImage buffer = null;
124 122 try {
125   - byte[] bytes = decoder.decodeBuffer(base64String);
  123 + byte[] bytes = Base64.decodeBase64(base64String);
126 124 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
127 125 buffer = ImageIO.read(bais);
128 126 } catch (IOException e) {
... ...
src/main/java/com/objecteye/utils/VehicleDetailsUtils.java
... ... @@ -3,9 +3,9 @@ package com.objecteye.utils;
3 3 import com.alibaba.fastjson.JSONArray;
4 4 import com.alibaba.fastjson.JSONObject;
5 5 import com.objecteye.pojo.VehicleDetails;
  6 +import org.apache.commons.codec.binary.Base64;
6 7 import org.springframework.beans.factory.annotation.Value;
7 8 import org.springframework.stereotype.Component;
8   -import sun.misc.BASE64Encoder;
9 9  
10 10 import javax.imageio.ImageIO;
11 11 import java.awt.image.BufferedImage;
... ... @@ -402,20 +402,18 @@ public class VehicleDetailsUtils {
402 402 * 从全景图中获取到抓拍车辆图的base64
403 403 */
404 404 public static String picToSnapshot(String url, int left, int top, int width, int height) {
405   -
406 405 // String path = "http://192.168.10.153:8880/192.168.10.78_01_20190927092803811_FACE_ALARM104.jpg";
407 406 String snapshotBase64 = null;
408 407 ByteArrayOutputStream baos = null;
409 408 try {
410 409 URL path = new URL(url);
411   - BufferedImage image = (BufferedImage) ImageIO.read(path);
  410 + BufferedImage image = ImageIO.read(path);
412 411 BufferedImage subimage = image.getSubimage(left, top, width, height);
413 412 baos = new ByteArrayOutputStream();
414 413 ImageIO.write(subimage, "jpg", baos);
415 414  
416 415 byte[] bytes = baos.toByteArray();
417   - BASE64Encoder encoder = new BASE64Encoder();
418   - String encode = encoder.encode(bytes);
  416 + String encode = Base64.encodeBase64String(bytes);
419 417 snapshotBase64 = "data:image/jpeg;base64," + encode.replaceAll("\n", "").replaceAll("\r", "");
420 418 } catch (Exception e) {
421 419 e.printStackTrace();
... ...