Commit 21d68d52f858f05a6ff9c0435a03998cbfc59a2c

Authored by Liu Haoyu
1 parent 46d1c007

代码重构;

问题处理;
src/main/java/com/objecteye/service/impl/LocusOrbitServiceImpl.java
... ... @@ -124,6 +124,9 @@ public class LocusOrbitServiceImpl implements ILocusOrbitService {
124 124 Criteria criteria = new Criteria();
125 125 // 车牌
126 126 criteria.and("vehicle_plate_hphm").is(locusOrbitQueryParams.getPlateNumber());
  127 + // 坐标值不能为空
  128 + criteria.and("longitude").ne(null);
  129 + criteria.and("latitude").ne(null);
127 130 // 开始时间
128 131 // 结束时间
129 132 Long startTime = locusOrbitQueryParams.getStartTime();
... ... @@ -161,26 +164,18 @@ public class LocusOrbitServiceImpl implements ILocusOrbitService {
161 164 // 倒序排列
162 165 rabbitMqVehicles.sort((o1, o2) -> (int) (o2.getPictime() - o1.getPictime()));
163 166  
164   - // 时间游标
165   - Long lastPictime = Long.MAX_VALUE;
166   -
167 167 for (RabbitMQVehicle rabbitMqVehicle : rabbitMqVehicles) {
168 168 if (null == rabbitMqVehicle || null == rabbitMqVehicle.getPictime()) {
169 169 continue;
170 170 }
171   - Long currentPictime = rabbitMqVehicle.getPictime();
172   - // 更新时间游标
173   - if (lastPictime - currentPictime > DISTINCT_TIME_INTERVAL) {
174   - lastPictime = currentPictime;
175   - LocusOrbitResultParams locusOrbitResultParams = new LocusOrbitResultParams();
176   - locusOrbitResultParams.setId(rabbitMqVehicle.getId());
177   - locusOrbitResultParams.setPlateNumber(rabbitMqVehicle.getVehicle_plate_hphm());
178   - locusOrbitResultParams.setPictime(DateUtil.format(new Date(currentPictime), "yyyy-MM-dd HH:mm:ss"));
179   - locusOrbitResultParams.setLongitude(rabbitMqVehicle.getLongitude());
180   - locusOrbitResultParams.setLatitude(rabbitMqVehicle.getLatitude());
181   - locusOrbitResultParams.setSnapshotUrl(rabbitMqVehicle.getSnapshoturl());
182   - resultList.add(locusOrbitResultParams);
183   - }
  171 + LocusOrbitResultParams locusOrbitResultParams = new LocusOrbitResultParams();
  172 + locusOrbitResultParams.setId(rabbitMqVehicle.getId());
  173 + locusOrbitResultParams.setPlateNumber(rabbitMqVehicle.getVehicle_plate_hphm());
  174 + locusOrbitResultParams.setPictime(DateUtil.format(new Date(rabbitMqVehicle.getPictime()), "yyyy-MM-dd HH:mm:ss"));
  175 + locusOrbitResultParams.setLongitude(rabbitMqVehicle.getLongitude());
  176 + locusOrbitResultParams.setLatitude(rabbitMqVehicle.getLatitude());
  177 + locusOrbitResultParams.setSnapshotUrl(rabbitMqVehicle.getSnapshoturl());
  178 + resultList.add(locusOrbitResultParams);
184 179 }
185 180 // 重新排序
186 181 resultList.sort((o1, o2) -> {
... ...
src/main/java/com/objecteye/service/impl/UploadFileServiceImpl.java
... ... @@ -6,12 +6,12 @@ import com.objecteye.config.RabbitmqConfig;
6 6 import com.objecteye.entity.ResponseParam;
7 7 import com.objecteye.entity.UploadVehicleResult;
8 8 import com.objecteye.entity.VpAnalysisParam;
  9 +import com.objecteye.exception.CustomXException;
9 10 import com.objecteye.service.IUploadFileService;
10 11 import com.objecteye.utils.GlobalUtil;
11 12 import org.springframework.amqp.rabbit.core.RabbitTemplate;
12 13 import org.springframework.beans.factory.annotation.Autowired;
13 14 import org.springframework.beans.factory.annotation.Value;
14   -import org.springframework.data.redis.core.RedisTemplate;
15 15 import org.springframework.stereotype.Component;
16 16 import org.springframework.web.multipart.MultipartFile;
17 17  
... ... @@ -21,12 +21,10 @@ import java.io.IOException;
21 21 @Component
22 22 public class UploadFileServiceImpl implements IUploadFileService {
23 23 @Autowired
24   - private RedisTemplate redisTemplate;
25   - @Autowired
26 24 private RabbitTemplate rabbitTemplate;
27 25  
28 26 @Value("${picture.storePath}")
29   - private String path2;
  27 + private String storePath;
30 28 @Value("${picture.http}")
31 29 private String http;
32 30 @Value("${requestFile}")
... ... @@ -42,8 +40,10 @@ public class UploadFileServiceImpl implements IUploadFileService {
42 40 public JSONObject uploadFile2Mongo(MultipartFile multipartFile) throws IOException {
43 41 // 格式化文件名由format开头, e.g. format-15321354564-12.12654_15.156567.jpg
44 42 String fileName = multipartFile.getOriginalFilename();
45   - String picPath = GlobalUtil.dbPath1() + File.separator + "export" + File.separator + "vehicleProject"
46   - + File.separator + "picture" + File.separator + fileName;
  43 + if (fileName == null || "".equals(fileName)) {
  44 + throw new CustomXException("文件名不能不能为空", "201");
  45 + }
  46 + String picPath = storePath + File.separator + fileName;
47 47 File newFile = new File(picPath);
48 48 multipartFile.transferTo(newFile);
49 49  
... ...
src/main/java/com/objecteye/service/impl/VehicleCurrencyServiceImpl.java
... ... @@ -118,7 +118,6 @@ public class VehicleCurrencyServiceImpl implements VehicleCurrencyService {
118 118 c.and("vehicle_pendant_detect_njbnumber").is(njbgs);
119 119 }
120 120  
121   -
122 121 //号牌类型检索
123 122 if (hplx != null) {
124 123 c.and("vehicleplatetype").is(hplx);
... ...
src/main/java/com/objecteye/utils/HttpClientUtils.java
... ... @@ -26,8 +26,7 @@ public class HttpClientUtils {
26 26 private VehicleEngine vehicleEngine;
27 27  
28 28 public String VehicleAnalysis(String TPXX) {
29   - String result = VehicleAnalysis("", TPXX, "", "");
30   - return result;
  29 + return VehicleAnalysis("", TPXX, "", "");
31 30  
32 31 }
33 32  
... ... @@ -41,7 +40,7 @@ public class HttpClientUtils {
41 40  
42 41 Map<String, String> uriVariables = new HashMap<>();
43 42 uriVariables.put("GCXH", GCXH);
44   - if (TPXX != null || TPXX.length() > 0) {
  43 + if (TPXX != null && TPXX.length() > 0) {
45 44 uriVariables.put("TPXX", TPXX);
46 45 } else {
47 46 uriVariables.put("TPXX", "/software/sy/vehicle-socket/c++/image/test.jpg");
... ... @@ -49,14 +48,12 @@ public class HttpClientUtils {
49 48 uriVariables.put("MRHPT", MRHPT);
50 49 uriVariables.put("HPHM", HPHM);
51 50 ResponseEntity<String> responseEntity = restTemplate.postForEntity(requestUrl, uriVariables, String.class);
52   - String body = responseEntity.getBody();
53   - return body;
  51 + return responseEntity.getBody();
54 52 }
55 53  
56 54 //获取临时上传的图片数据信息
57 55 public String VehicleAnalysisTmp(MultipartFile TPXX) {
58   - String analysis = VehicleAnalysisTmp("", TPXX, "", "");
59   - return analysis;
  56 + return VehicleAnalysisTmp("", TPXX, "", "");
60 57 }
61 58  
62 59 //获取临时上传的图片数据信息
... ...
src/main/java/com/objecteye/utils/RabbitMQVehicleTools.java
... ... @@ -238,7 +238,7 @@ public class RabbitMQVehicleTools {
238 238  
239 239 // vehicle_illegal_driver_person_status;
240 240 int vehicle_illegal_driver_person_status = rabbitMQVehicle.getVehicle_illegal_driver_person_status();
241   - String vehicleIllegalStatus3 = nullStatus;
  241 + String vehicleIllegalStatus3;
242 242 if (vehicle_illegal_driver_person_status == 1003) {
243 243 vehicleIllegalStatus3 = "无人";
244 244 } else if (vehicle_illegal_driver_person_status == 1004) {
... ... @@ -251,7 +251,7 @@ public class RabbitMQVehicleTools {
251 251 if ("有人".equals(vehicleIllegalStatus3)) {
252 252 // vehicle_illegal_driver_smoke_status;
253 253 int vehicle_illegal_driver_smoke_status = rabbitMQVehicle.getVehicle_illegal_driver_smoke_status();
254   - String vehicleIllegalStatus = nullStatus;
  254 + String vehicleIllegalStatus;
255 255 if (vehicle_illegal_driver_smoke_status == 1000) {
256 256 vehicleIllegalStatus = "吸烟";
257 257 } else if (vehicle_illegal_driver_smoke_status == 1001) {
... ... @@ -263,7 +263,7 @@ public class RabbitMQVehicleTools {
263 263  
264 264 // vehicle_illegal_driver_belt_status;
265 265 int vehicle_illegal_driver_belt_status = rabbitMQVehicle.getVehicle_illegal_driver_belt_status();
266   - String vehicleIllegalStatus1 = nullStatus;
  266 + String vehicleIllegalStatus1;
267 267 if (vehicle_illegal_driver_belt_status == 1000) {
268 268 vehicleIllegalStatus1 = "未系安全带";
269 269 } else if (vehicle_illegal_driver_belt_status == 1001) {
... ... @@ -275,7 +275,7 @@ public class RabbitMQVehicleTools {
275 275  
276 276 // vehicle_illegal_driver_phone_status;
277 277 int vehicle_illegal_driver_phone_status = rabbitMQVehicle.getVehicle_illegal_driver_phone_status();
278   - String vehicleIllegalStatus2 = nullStatus;
  278 + String vehicleIllegalStatus2;
279 279 if (vehicle_illegal_driver_phone_status == 1000) {
280 280 vehicleIllegalStatus2 = "打电话";
281 281 } else if (vehicle_illegal_driver_phone_status == 1001) {
... ... @@ -293,7 +293,7 @@ public class RabbitMQVehicleTools {
293 293  
294 294 // vehicle_illegal_copilot_person_status;
295 295 int vehicle_illegal_copilot_person_status = rabbitMQVehicle.getVehicle_illegal_copilot_person_status();
296   - String vehicleIllegalStatus7 = nullStatus;
  296 + String vehicleIllegalStatus7;
297 297 if (vehicle_illegal_copilot_person_status == 1003) {
298 298 vehicleIllegalStatus7 = "无人";
299 299 } else if (vehicle_illegal_copilot_person_status == 1004) {
... ... @@ -308,7 +308,7 @@ public class RabbitMQVehicleTools {
308 308 // vehicle_illegal_copilot_smoke_status;
309 309 int vehicle_illegal_copilot_smoke_status = rabbitMQVehicle.getVehicle_illegal_copilot_smoke_status();
310 310 System.out.println("副驾驶吸烟" + vehicle_illegal_copilot_smoke_status);
311   - String vehicleIllegalStatus4 = nullStatus;
  311 + String vehicleIllegalStatus4;
312 312 if (vehicle_illegal_copilot_smoke_status == 1000) {
313 313 vehicleIllegalStatus4 = "吸烟";
314 314 } else if (vehicle_illegal_copilot_smoke_status == 1001) {
... ... @@ -320,7 +320,7 @@ public class RabbitMQVehicleTools {
320 320  
321 321 // vehicle_illegal_copilot_belt_status;
322 322 int vehicle_illegal_copilot_belt_status = rabbitMQVehicle.getVehicle_illegal_copilot_belt_status();
323   - String vehicleIllegalStatus5 = nullStatus;
  323 + String vehicleIllegalStatus5;
324 324 if (vehicle_illegal_copilot_belt_status == 1000) {
325 325 vehicleIllegalStatus5 = "未系安全带";
326 326 } else if (vehicle_illegal_copilot_belt_status == 1001) {
... ... @@ -332,7 +332,7 @@ public class RabbitMQVehicleTools {
332 332  
333 333 // vehicle_illegal_copilot_phone_status;
334 334 int vehicle_illegal_copilot_phone_status = rabbitMQVehicle.getVehicle_illegal_copilot_phone_status();
335   - String vehicleIllegalStatus6 = nullStatus;
  335 + String vehicleIllegalStatus6;
336 336 if (vehicle_illegal_copilot_phone_status == 1000) {
337 337 vehicleIllegalStatus6 = "打电话";
338 338 } else if (vehicle_illegal_copilot_phone_status == 1001) {
... ... @@ -470,30 +470,13 @@ public class RabbitMQVehicleTools {
470 470  
471 471 }
472 472  
473   -
474   - /*public List<FaceInfoParam> sdkToRabbitPeople(JSONObject jsonObject) {
475   - List<FaceInfoParam> rabbitMQPeoples = new ArrayList<>();
476   - try {
477   - JSONArray peopleVehicleArr = jsonObject.containsKey("info") ? jsonObject.getJSONArray("info") : null;
478   - for (int i = 0; i < peopleVehicleArr.size(); i++) {
479   - JSONObject peopleVehicleSingle = peopleVehicleArr.getJSONObject(i);
480   - FaceInfoParam faceInfoParam = faceUtils.rabbitToFaceInfo(peopleVehicleSingle, nullStatus);
481   - rabbitMQPeoples.add(faceInfoParam);
482   - }
483   - return rabbitMQPeoples;
484   - } catch (Exception e) {
485   - System.out.println("不是规则的JSON格式");
486   - return null;
487   - }
488   - }*/
489   -
490 473 public RabbitMQVehicle sdkToOnlyVehicle(JSONObject vehicleSingleInfo) {
491 474 int count = 0;//在档案中的位置
492 475 String longitude = nullStatus;
493 476 String latitude = nullStatus;
494 477 String picurl = nullStatus; //图片的路径
495 478 int recordid = 0; //车辆档案id
496   - Long pictime = 0l; //抓拍时间
  479 + Long pictime = 0L; //抓拍时间
497 480 int flag = 0; //是否报警
498 481 int tag = 0; //是否确认
499 482 String personid = nullStatus; //人像id
... ... @@ -556,12 +539,10 @@ public class RabbitMQVehicleTools {
556 539 } catch (Exception e) {
557 540 RuntimeException exe = new RuntimeException("文件夹创建失败");
558 541 e.printStackTrace();
559   -
560 542 }
561 543  
562 544 JSONObject colorRes = vehicleSingleInfo.containsKey("vehicle_color_res") ? vehicleSingleInfo.getJSONObject("vehicle_color_res") : null;
563 545 if (colorRes != null) {
564   -
565 546 vehicle_color_index = colorRes.getInteger("index");
566 547 vehicle_color_score = colorRes.getFloat("score");
567 548 }
... ... @@ -600,7 +581,7 @@ public class RabbitMQVehicleTools {
600 581 vehicle_illegal_driver_person_confidence = person.getFloat("confidence");
601 582 vehicle_illegal_driver_person_status = person.getInteger("status");
602 583 }
603   - if (vehicle_illegal_copilot_person_status == 1004) {
  584 + if (vehicle_illegal_driver_person_status == 1004) {
604 585 JSONObject belt = driver.containsKey("belt") ? driver.getJSONObject("belt") : null;
605 586 if (belt != null) {
606 587 vehicle_illegal_driver_belt_confidence = belt.getFloat("confidence");
... ... @@ -654,47 +635,48 @@ public class RabbitMQVehicleTools {
654 635 if (vehicle_pendant_det_res != null) {
655 636 vehicle_pendant_count = vehicle_pendant_det_res.getInteger("count");
656 637 JSONArray vehiclePendantDetectInfoParams = vehicle_pendant_det_res.getJSONArray("vehiclePendantDetectInfoParams");
657   - int size = vehiclePendantDetectInfoParams.size();
658   - if (vehiclePendantDetectInfoParams != null && size > 0) {
659   - for (int i = 0; i < vehiclePendantDetectInfoParams.size(); i++) {
660   - //获取到其中的一个车辆属性
661   - JSONObject vehiclePendantOne = vehiclePendantDetectInfoParams.getJSONObject(i);
662   - Integer index = vehiclePendantOne.getInteger("index");
663   - switch (index) {
664   - case 3:
665   - //是否有遮阳板
666   - vehicle_pendant_detect_zybexis = 1;
667   - break;
668   - case 4:
669   - //获取年检标个数
670   - vehicle_pendant_detect_njbnumber++;
671   - break;
672   - case 5:
673   - //是否有挂件
674   - vehicle_pendant_detect_gjexis = 1;
675   - break;
676   - default:
  638 + if (vehiclePendantDetectInfoParams != null) {
  639 + int size = vehiclePendantDetectInfoParams.size();
  640 + if (vehiclePendantDetectInfoParams.size() > 0) {
  641 + for (int i = 0; i < vehiclePendantDetectInfoParams.size(); i++) {
  642 + //获取到其中的一个车辆属性
  643 + JSONObject vehiclePendantOne = vehiclePendantDetectInfoParams.getJSONObject(i);
  644 + Integer index = vehiclePendantOne.getInteger("index");
  645 + switch (index) {
  646 + case 3:
  647 + //是否有遮阳板
  648 + vehicle_pendant_detect_zybexis = 1;
  649 + break;
  650 + case 4:
  651 + //获取年检标个数
  652 + vehicle_pendant_detect_njbnumber++;
  653 + break;
  654 + case 5:
  655 + //是否有挂件
  656 + vehicle_pendant_detect_gjexis = 1;
  657 + break;
  658 + default:
  659 + }
677 660 }
678 661  
679   - }
680   -
681   - vehicle_pendant_Params = new PendantParams[size];
682   - for (int i = 0; i < size; i++) {
683   - JSONObject jsonObject = vehiclePendantDetectInfoParams.getJSONObject(i);
684   - float confidence = jsonObject.getFloat("confidence");
685   - Integer index = jsonObject.getInteger("index");
686   - int[] ints = new int[4];
687   - JSONObject syRectParam = jsonObject.getJSONObject("syRectParam");
688   - Integer height = syRectParam.getInteger("height");
689   - Integer left = syRectParam.getInteger("left");
690   - Integer top = syRectParam.getInteger("top");
691   - Integer width = syRectParam.getInteger("width");
692   - ints[0] = height;
693   - ints[1] = left;
694   - ints[2] = top;
695   - ints[3] = width;
696   - PendantParams pp = new PendantParams(index, ints, confidence);
697   - vehicle_pendant_Params[i] = pp;
  662 + vehicle_pendant_Params = new PendantParams[size];
  663 + for (int i = 0; i < size; i++) {
  664 + JSONObject jsonObject = vehiclePendantDetectInfoParams.getJSONObject(i);
  665 + float confidence = jsonObject.getFloat("confidence");
  666 + Integer index = jsonObject.getInteger("index");
  667 + int[] ints = new int[4];
  668 + JSONObject syRectParam = jsonObject.getJSONObject("syRectParam");
  669 + Integer height = syRectParam.getInteger("height");
  670 + Integer left = syRectParam.getInteger("left");
  671 + Integer top = syRectParam.getInteger("top");
  672 + Integer width = syRectParam.getInteger("width");
  673 + ints[0] = height;
  674 + ints[1] = left;
  675 + ints[2] = top;
  676 + ints[3] = width;
  677 + PendantParams pp = new PendantParams(index, ints, confidence);
  678 + vehicle_pendant_Params[i] = pp;
  679 + }
698 680 }
699 681 }
700 682 }
... ... @@ -718,7 +700,7 @@ public class RabbitMQVehicleTools {
718 700 JSONArray plateNumParams = vehicle_plate_det_recg_res.getJSONArray("plateNumParams");
719 701 int size = plateNumParams.size();
720 702 if (size > 0) {
721   - StringBuffer sb = new StringBuffer();
  703 + StringBuilder sb = new StringBuilder();
722 704 vehicle_plate_plateNumParams = new PlatePlateNumParams[size];
723 705 for (int i = 0; i < size; i++) {
724 706 JSONObject jsonObject = plateNumParams.getJSONObject(i);
... ...