Commit 9f27c927 authored by caotao's avatar caotao

对于收到的消息进行坐标校验,避免大量的无效坐标

parent 9d5b881b
......@@ -104,7 +104,7 @@ public class CarIotNewListener extends EmqxListener {
Date startTime = new Date(jsonObject.getLong("time"));
wlCarMileage.setStartTime(startTime);
wlCarMileage.setStartName(getAddress(startLongitude, startLatitude));
wlCarMileage.setStartSpeed(jsonObject.getIntValue("FireCar_Speed"));
wlCarMileage.setStartSpeed(Double.valueOf(jsonObject.getDoubleValue("FireCar_Speed")).intValue());
try {
iWlCarMileageService.save(wlCarMileage);
} catch (Exception e) {
......
......@@ -50,7 +50,7 @@ public class ThreadCar extends Thread {
JSONObject lastObj = null;
WlCarMileage last = null;
try {
TimeUnit.MILLISECONDS.sleep(Long.valueOf((long) (clippingTime)));
this.sleep(clippingTime);
//业务处理
//如果十分钟没有坐标,则需要设置结束标记
// 获取结束坐标
......@@ -94,7 +94,7 @@ public class ThreadCar extends Thread {
// 230215180624
// Date endTime =UTCToCST(lastObj.getString("time"));
Date endTime = new Date();
Date endTime = new Date(jsonObject.getLong("time"));
long takeTime = (endTime.getTime() / 1000 * 1000) - (last.getStartTime().getTime() / 1000 * 1000);
last.setEndLongitude(endLongitude);
last.setEndLatitude(endLatitude);
......@@ -114,10 +114,13 @@ public class ThreadCar extends Thread {
last.setTravel(new BigDecimal(travel / 1000).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
iWlCarMileageService.updateById(last);
this.pushCarInfoToMap(jsonObject, topic);
System.out.println("============================================================更新结束坐标成功==========:"+topic);
this.interrupt();
}
} catch (Exception exception) {
if (last != null) {
iWlCarMileageService.updateById(last);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment