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,7 +35,7 @@ public class HumanVehicleAssociationController {
35 if (pageResult == null || pageResult.getRow().size() == 0) { 35 if (pageResult == null || pageResult.getRow().size() == 0) {
36 return CommonResult.success(201, "没有符合要求的数据", null); 36 return CommonResult.success(201, "没有符合要求的数据", null);
37 } 37 }
38 - return CommonResult.success(pageResult, "数据查询成功!!"); 38 + return CommonResult.success(pageResult);
39 } catch (Exception e) { 39 } catch (Exception e) {
40 e.printStackTrace(); 40 e.printStackTrace();
41 return CommonResult.failed(); 41 return CommonResult.failed();
@@ -53,7 +53,7 @@ public class HumanVehicleAssociationController { @@ -53,7 +53,7 @@ public class HumanVehicleAssociationController {
53 if (row == null || row.size() == 0) { 53 if (row == null || row.size() == 0) {
54 return CommonResult.success(201, "没有符合要求的数据", searchPeopleOfhphmResult); 54 return CommonResult.success(201, "没有符合要求的数据", searchPeopleOfhphmResult);
55 } 55 }
56 - return CommonResult.success(searchPeopleOfhphmResult, "数据查询成功!!"); 56 + return CommonResult.success(searchPeopleOfhphmResult);
57 } catch (Exception e) { 57 } catch (Exception e) {
58 e.printStackTrace(); 58 e.printStackTrace();
59 return CommonResult.failed(); 59 return CommonResult.failed();
@@ -69,7 +69,7 @@ public class HumanVehicleAssociationController { @@ -69,7 +69,7 @@ public class HumanVehicleAssociationController {
69 if (faceInfoParam == null || faceInfoParam.size() == 0) { 69 if (faceInfoParam == null || faceInfoParam.size() == 0) {
70 return CommonResult.success(201, "没有符合要求的数据", faceInfoParam); 70 return CommonResult.success(201, "没有符合要求的数据", faceInfoParam);
71 } 71 }
72 - return CommonResult.success(faceInfoParam, "数据查询成功!!"); 72 + return CommonResult.success(faceInfoParam);
73 } catch (Exception e) { 73 } catch (Exception e) {
74 e.printStackTrace(); 74 e.printStackTrace();
75 return CommonResult.failed(); 75 return CommonResult.failed();
src/main/java/com/objecteye/controller/SpecialtyVehicleController.java
@@ -33,8 +33,7 @@ public class SpecialtyVehicleController { @@ -33,8 +33,7 @@ public class SpecialtyVehicleController {
33 @RequestMapping("/slagCar/findByCondition") 33 @RequestMapping("/slagCar/findByCondition")
34 public JSONObject findByCondition(@RequestBody VehicleCondition vehicleCondition) { 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,8 +46,7 @@ public class SpecialtyVehicleController {
47 @RequestMapping("/slagCar/findCoordinateByPic") 46 @RequestMapping("/slagCar/findCoordinateByPic")
48 public JSONObject siteByPic(@RequestParam("picfile") MultipartFile picfile, Integer vehicle_special_type_number) { 47 public JSONObject siteByPic(@RequestParam("picfile") MultipartFile picfile, Integer vehicle_special_type_number) {
49 //渣土车坐标 vehicle_special_type_number 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,8 +70,7 @@ public class SpecialtyVehicleController {
72 */ 70 */
73 @RequestMapping("/slagCar/findById") 71 @RequestMapping("/slagCar/findById")
74 public JSONObject findById(@RequestBody Map<String, String> map) { 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,15 +80,9 @@ public class SpecialtyVehicleController {
83 */ 80 */
84 @RequestMapping("/slagCar/findByGcxh") 81 @RequestMapping("/slagCar/findByGcxh")
85 public JSONObject findByGcxh(int gcxh, MultipartFile picfile) { 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,8 +92,7 @@ public class SpecialtyVehicleController {
101 @RequestMapping("/chemistryCar/findByCondition") 92 @RequestMapping("/chemistryCar/findByCondition")
102 public JSONObject chemistryFindByCondition(@RequestBody VehicleCondition vehicleCondition) { 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,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,12 +118,10 @@ public class SpecialtyVehicleController {
129 public JSONObject test(Integer gcxh, @RequestParam("picfile") MultipartFile picfile) { 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,11 +129,8 @@ public class SpecialtyVehicleController {
142 */ 129 */
143 @RequestMapping("/getResult") 130 @RequestMapping("/getResult")
144 public Object getResult(@RequestBody Map<String, Object> body) { 131 public Object getResult(@RequestBody Map<String, Object> body) {
145 - //CustomAssert.checkHeader(header);  
146 CustomAssert.checkField(body, CustomParamCollections.VEHICLE_SINGLE_PARAM); 132 CustomAssert.checkField(body, CustomParamCollections.VEHICLE_SINGLE_PARAM);
147 CustomAssert.checkSimpleMapParam(body, CustomParamCollections.VEHICLE_SINGLE_PARAM); 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,8 +25,6 @@ public class SyVehicleForbiddenTaskOutput implements Serializable {
25 25
26 private String forbiddenDetailTime; 26 private String forbiddenDetailTime;
27 27
28 - private String equipment;  
29 -  
30 private String status; 28 private String status;
31 29
32 private String warningNumber; 30 private String warningNumber;
src/main/java/com/objecteye/service/SpecialtyServices.java
@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject; @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject;
4 import com.objecteye.pojo.VehicleCondition; 4 import com.objecteye.pojo.VehicleCondition;
5 import com.objecteye.pojo.VehicleInfoRes; 5 import com.objecteye.pojo.VehicleInfoRes;
6 import org.springframework.stereotype.Service; 6 import org.springframework.stereotype.Service;
7 -import org.springframework.web.bind.annotation.RequestMapping;  
8 import org.springframework.web.multipart.MultipartFile; 7 import org.springframework.web.multipart.MultipartFile;
9 8
10 import java.util.Map; 9 import java.util.Map;
@@ -28,24 +27,6 @@ public interface SpecialtyServices { @@ -28,24 +27,6 @@ public interface SpecialtyServices {
28 */ 27 */
29 JSONObject findByPic(int number, double threshold, int currentpage, int pagevolume, MultipartFile picfile, Long starttime, Long endtime, Integer vehicle_special_type_number) throws InterruptedException; 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,6 +9,7 @@ import com.objecteye.exception.CustomXException;
9 import com.objecteye.pojo.*; 9 import com.objecteye.pojo.*;
10 import com.objecteye.service.SpecialtyServices; 10 import com.objecteye.service.SpecialtyServices;
11 import com.objecteye.utils.*; 11 import com.objecteye.utils.*;
  12 +import org.apache.commons.codec.binary.Base64;
12 import org.slf4j.Logger; 13 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory; 14 import org.slf4j.LoggerFactory;
14 import org.springframework.beans.factory.annotation.Autowired; 15 import org.springframework.beans.factory.annotation.Autowired;
@@ -16,7 +17,6 @@ import org.springframework.beans.factory.annotation.Value; @@ -16,7 +17,6 @@ import org.springframework.beans.factory.annotation.Value;
16 import org.springframework.data.redis.core.RedisTemplate; 17 import org.springframework.data.redis.core.RedisTemplate;
17 import org.springframework.stereotype.Service; 18 import org.springframework.stereotype.Service;
18 import org.springframework.web.multipart.MultipartFile; 19 import org.springframework.web.multipart.MultipartFile;
19 -import sun.misc.BASE64Decoder;  
20 20
21 import javax.imageio.ImageIO; 21 import javax.imageio.ImageIO;
22 import java.awt.image.BufferedImage; 22 import java.awt.image.BufferedImage;
@@ -184,18 +184,6 @@ public class SpecialtyServicesImpl implements SpecialtyServices { @@ -184,18 +184,6 @@ public class SpecialtyServicesImpl implements SpecialtyServices {
184 return result; 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 //通过转Base64的方式运行 187 //通过转Base64的方式运行
200 @Override 188 @Override
201 public JSONObject findCoordinateByPic(MultipartFile picfile, Integer vehicleSpecialTypeNumber) { 189 public JSONObject findCoordinateByPic(MultipartFile picfile, Integer vehicleSpecialTypeNumber) {
@@ -322,10 +310,9 @@ public class SpecialtyServicesImpl implements SpecialtyServices { @@ -322,10 +310,9 @@ public class SpecialtyServicesImpl implements SpecialtyServices {
322 * @param base64String base64码字符串 310 * @param base64String base64码字符串
323 **/ 311 **/
324 public BufferedImage changeBase64StringtoImage(String base64String) { 312 public BufferedImage changeBase64StringtoImage(String base64String) {
325 - BASE64Decoder decoder = new BASE64Decoder();  
326 BufferedImage buffer = null; 313 BufferedImage buffer = null;
327 try { 314 try {
328 - byte[] bytes = decoder.decodeBuffer(base64String); 315 + byte[] bytes = Base64.decodeBase64(base64String);
329 ByteArrayInputStream bais = new ByteArrayInputStream(bytes); 316 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
330 buffer = ImageIO.read(bais); 317 buffer = ImageIO.read(bais);
331 } catch (IOException e) { 318 } catch (IOException e) {
src/main/java/com/objecteye/utils/GlobalUtil.java
@@ -14,7 +14,6 @@ import org.apache.http.util.EntityUtils; @@ -14,7 +14,6 @@ import org.apache.http.util.EntityUtils;
14 import org.slf4j.Logger; 14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory; 15 import org.slf4j.LoggerFactory;
16 import org.springframework.boot.system.ApplicationHome; 16 import org.springframework.boot.system.ApplicationHome;
17 -import sun.misc.BASE64Decoder;  
18 17
19 import javax.imageio.ImageIO; 18 import javax.imageio.ImageIO;
20 import java.awt.image.BufferedImage; 19 import java.awt.image.BufferedImage;
@@ -30,8 +29,6 @@ import java.util.regex.Pattern; @@ -30,8 +29,6 @@ import java.util.regex.Pattern;
30 public class GlobalUtil { 29 public class GlobalUtil {
31 private static Logger logger = LoggerFactory.getLogger(GlobalUtil.class); 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 public final static String PREVIEWIPLISTLIST = "previewIpList"; 32 public final static String PREVIEWIPLISTLIST = "previewIpList";
36 public final static String ALARMMSG = "alarmMsg"; 33 public final static String ALARMMSG = "alarmMsg";
37 public final static String DEPLOYIDANDENDTIME = "deployIdAndTime"; 34 public final static String DEPLOYIDANDENDTIME = "deployIdAndTime";
@@ -324,12 +321,12 @@ public class GlobalUtil { @@ -324,12 +321,12 @@ public class GlobalUtil {
324 } 321 }
325 322
326 public static boolean base64StrToImage(String imgStr, String path) { 323 public static boolean base64StrToImage(String imgStr, String path) {
327 - if (imgStr == null) 324 + if (imgStr == null) {
328 return false; 325 return false;
329 - BASE64Decoder decoder = new BASE64Decoder(); 326 + }
330 try { 327 try {
331 // 解密 328 // 解密
332 - byte[] b = decoder.decodeBuffer(imgStr); 329 + byte[] b = org.apache.commons.codec.binary.Base64.decodeBase64(imgStr);
333 // 处理数据 330 // 处理数据
334 for (int i = 0; i < b.length; ++i) { 331 for (int i = 0; i < b.length; ++i) {
335 if (b[i] < 0) { 332 if (b[i] < 0) {
@@ -423,7 +420,9 @@ public class GlobalUtil { @@ -423,7 +420,9 @@ public class GlobalUtil {
423 e.printStackTrace(); 420 e.printStackTrace();
424 } finally { 421 } finally {
425 try { 422 try {
426 - response.close(); 423 + if (response != null) {
  424 + response.close();
  425 + }
427 } catch (IOException e) { 426 } catch (IOException e) {
428 e.printStackTrace(); 427 e.printStackTrace();
429 } 428 }
src/main/java/com/objecteye/utils/HttpClientUtils.java
@@ -7,7 +7,6 @@ import org.springframework.http.ResponseEntity; @@ -7,7 +7,6 @@ import org.springframework.http.ResponseEntity;
7 import org.springframework.stereotype.Component; 7 import org.springframework.stereotype.Component;
8 import org.springframework.web.client.RestTemplate; 8 import org.springframework.web.client.RestTemplate;
9 import org.springframework.web.multipart.MultipartFile; 9 import org.springframework.web.multipart.MultipartFile;
10 -import sun.misc.BASE64Decoder;  
11 10
12 import javax.imageio.ImageIO; 11 import javax.imageio.ImageIO;
13 import java.awt.image.BufferedImage; 12 import java.awt.image.BufferedImage;
@@ -119,10 +118,9 @@ public class HttpClientUtils { @@ -119,10 +118,9 @@ public class HttpClientUtils {
119 * @param base64String base64码字符串 118 * @param base64String base64码字符串
120 **/ 119 **/
121 public BufferedImage changeBase64StringtoImage(String base64String) { 120 public BufferedImage changeBase64StringtoImage(String base64String) {
122 - BASE64Decoder decoder = new BASE64Decoder();  
123 BufferedImage buffer = null; 121 BufferedImage buffer = null;
124 try { 122 try {
125 - byte[] bytes = decoder.decodeBuffer(base64String); 123 + byte[] bytes = Base64.decodeBase64(base64String);
126 ByteArrayInputStream bais = new ByteArrayInputStream(bytes); 124 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
127 buffer = ImageIO.read(bais); 125 buffer = ImageIO.read(bais);
128 } catch (IOException e) { 126 } catch (IOException e) {
src/main/java/com/objecteye/utils/VehicleDetailsUtils.java
@@ -3,9 +3,9 @@ package com.objecteye.utils; @@ -3,9 +3,9 @@ package com.objecteye.utils;
3 import com.alibaba.fastjson.JSONArray; 3 import com.alibaba.fastjson.JSONArray;
4 import com.alibaba.fastjson.JSONObject; 4 import com.alibaba.fastjson.JSONObject;
5 import com.objecteye.pojo.VehicleDetails; 5 import com.objecteye.pojo.VehicleDetails;
  6 +import org.apache.commons.codec.binary.Base64;
6 import org.springframework.beans.factory.annotation.Value; 7 import org.springframework.beans.factory.annotation.Value;
7 import org.springframework.stereotype.Component; 8 import org.springframework.stereotype.Component;
8 -import sun.misc.BASE64Encoder;  
9 9
10 import javax.imageio.ImageIO; 10 import javax.imageio.ImageIO;
11 import java.awt.image.BufferedImage; 11 import java.awt.image.BufferedImage;
@@ -402,20 +402,18 @@ public class VehicleDetailsUtils { @@ -402,20 +402,18 @@ public class VehicleDetailsUtils {
402 * 从全景图中获取到抓拍车辆图的base64 402 * 从全景图中获取到抓拍车辆图的base64
403 */ 403 */
404 public static String picToSnapshot(String url, int left, int top, int width, int height) { 404 public static String picToSnapshot(String url, int left, int top, int width, int height) {
405 -  
406 // String path = "http://192.168.10.153:8880/192.168.10.78_01_20190927092803811_FACE_ALARM104.jpg"; 405 // String path = "http://192.168.10.153:8880/192.168.10.78_01_20190927092803811_FACE_ALARM104.jpg";
407 String snapshotBase64 = null; 406 String snapshotBase64 = null;
408 ByteArrayOutputStream baos = null; 407 ByteArrayOutputStream baos = null;
409 try { 408 try {
410 URL path = new URL(url); 409 URL path = new URL(url);
411 - BufferedImage image = (BufferedImage) ImageIO.read(path); 410 + BufferedImage image = ImageIO.read(path);
412 BufferedImage subimage = image.getSubimage(left, top, width, height); 411 BufferedImage subimage = image.getSubimage(left, top, width, height);
413 baos = new ByteArrayOutputStream(); 412 baos = new ByteArrayOutputStream();
414 ImageIO.write(subimage, "jpg", baos); 413 ImageIO.write(subimage, "jpg", baos);
415 414
416 byte[] bytes = baos.toByteArray(); 415 byte[] bytes = baos.toByteArray();
417 - BASE64Encoder encoder = new BASE64Encoder();  
418 - String encode = encoder.encode(bytes); 416 + String encode = Base64.encodeBase64String(bytes);
419 snapshotBase64 = "data:image/jpeg;base64," + encode.replaceAll("\n", "").replaceAll("\r", ""); 417 snapshotBase64 = "data:image/jpeg;base64," + encode.replaceAll("\n", "").replaceAll("\r", "");
420 } catch (Exception e) { 418 } catch (Exception e) {
421 e.printStackTrace(); 419 e.printStackTrace();