|
|
@@ -66,6 +66,7 @@ public class TransferVehicleManage {
|
|
|
vehicleDataQueue.add(request);
|
|
|
|
|
|
// 2. 检查是否达到批量阈值,若达到则批量保存
|
|
|
+ log.info("检查是否达到批量阈值");
|
|
|
List<VehicleDataSaveRequest> vehicleDataList = vehicleDataQueue.takeBatchIfReached();
|
|
|
if (CollectionUtils.isEmpty(vehicleDataList)) {
|
|
|
return;
|
|
|
@@ -78,13 +79,14 @@ public class TransferVehicleManage {
|
|
|
*/
|
|
|
public void batchSaveVehicle(List<VehicleDataSaveRequest> vehicleDataList) {
|
|
|
//mock数据
|
|
|
- vehicleDataList.stream().forEach(vehicle -> {
|
|
|
- vehicle.getVehicleDataVO().setCarNo("16939110775088937");
|
|
|
- vehicle.setwOrderNo("W1709780533650");
|
|
|
- });
|
|
|
+// vehicleDataList.stream().forEach(vehicle -> {
|
|
|
+// vehicle.getVehicleDataVO().setCarNo("16939110775088937");
|
|
|
+// vehicle.setwOrderNo("W1709780533650");
|
|
|
+// });
|
|
|
List<VehicleData> newVehicles = checkVehicle(vehicleDataList);
|
|
|
// 批量保存到关系库
|
|
|
if (CollectionUtils.isNotEmpty(newVehicles)) {
|
|
|
+ log.info("批量保存关系数据库");
|
|
|
vehicleDataService.saveBatch(newVehicles);
|
|
|
}
|
|
|
|
|
|
@@ -114,6 +116,7 @@ public class TransferVehicleManage {
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
// 2. 批量查询已存在的车辆id
|
|
|
+ log.info("查询关系数据库中已存在的车牌");
|
|
|
List<String> existCarNos = vehicleDataService.list(Wrappers.<VehicleData>lambdaQuery()
|
|
|
.in(VehicleData::getCarNo, carNoList))
|
|
|
.stream()
|
|
|
@@ -145,7 +148,7 @@ public class TransferVehicleManage {
|
|
|
*/
|
|
|
public List<VehicleDataResp> queryVehicleDataList(VehicleDataRequest request) {
|
|
|
//mock数据
|
|
|
- request.setwOrderNo("W1709780533650");
|
|
|
+ // request.setwOrderNo("W1709780533650");
|
|
|
if (request == null || (StringUtils.isEmpty(request.getCarNo()) && StringUtils.isEmpty(request.getwOrderNo()))) {
|
|
|
throw new IotException(ErrorCodeEnum.ILLEGAL_PARAM, "接口参数为null!");
|
|
|
}
|
|
|
@@ -176,20 +179,25 @@ public class TransferVehicleManage {
|
|
|
*/
|
|
|
public VehicleDataResp queryRealTimeLocation(VehicleDataRequest request) {
|
|
|
//mock数据
|
|
|
- request.setCarNo("16939110775088937");
|
|
|
+ // request.setCarNo("16939110775088937");
|
|
|
if (request == null || (StringUtils.isEmpty(request.getCarNo()))) {
|
|
|
throw new IotException(ErrorCodeEnum.ILLEGAL_PARAM, "车牌carNo不能为空!");
|
|
|
}
|
|
|
+ VehicleTimeSeriesData realTimeLocation = null;
|
|
|
|
|
|
- // 查询车辆id关系数据中是否存在
|
|
|
- VehicleData vehicleData = vehicleDataService.getOne(Wrappers.<VehicleData>lambdaQuery().eq(VehicleData::getCarNo, request.getCarNo()));
|
|
|
- if (vehicleData == null) {
|
|
|
- log.info("子表 {} 不存在,返回空结果", "vehicle_data_" + request.getCarNo().trim());
|
|
|
- return new VehicleDataResp();
|
|
|
- }
|
|
|
+ try {
|
|
|
+ // 查询车辆id关系数据中是否存在
|
|
|
+ VehicleData vehicleData = vehicleDataService.getOne(Wrappers.<VehicleData>lambdaQuery().eq(VehicleData::getCarNo, request.getCarNo()));
|
|
|
+ if (vehicleData == null) {
|
|
|
+ log.info("子表 {} 不存在,返回空结果", "vehicle_data_" + request.getCarNo().trim());
|
|
|
+ return new VehicleDataResp();
|
|
|
+ }
|
|
|
|
|
|
- String subTableName = "vehicle_data_" + request.getCarNo().trim();
|
|
|
- VehicleTimeSeriesData realTimeLocation = taosService.selectRealTimeLocation(subTableName, request.getCarNo());
|
|
|
+ String subTableName = "vehicle_data_" + request.getCarNo().trim();
|
|
|
+ realTimeLocation = taosService.selectRealTimeLocation(subTableName, request.getCarNo());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("查询车辆实时经纬度异常", e);
|
|
|
+ }
|
|
|
|
|
|
//参数转换
|
|
|
return VehicleDataResp.toIotPageResp(realTimeLocation);
|