|
|
@@ -12,10 +12,12 @@ import com.platform.entity.VehicleData;
|
|
|
import com.platform.entity.VehicleTimeSeriesData;
|
|
|
import com.platform.enums.ErrorCodeEnum;
|
|
|
import com.platform.exception.IotException;
|
|
|
-import com.platform.exception.PageResult;
|
|
|
import com.platform.mapper.TaosMapper;
|
|
|
+import com.platform.service.TaosService;
|
|
|
import com.platform.service.VehicleDataService;
|
|
|
+import jakarta.annotation.Resource;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeansException;
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
import org.springframework.context.ApplicationContextAware;
|
|
|
@@ -35,18 +37,22 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
|
|
|
|
@Service
|
|
|
-@RequiredArgsConstructor
|
|
|
+@Slf4j
|
|
|
public class TransferVehicleManage implements ApplicationContextAware {
|
|
|
|
|
|
- private final TaosMapper taosMapper;
|
|
|
+ @Resource
|
|
|
+ private TaosService taosService;
|
|
|
|
|
|
- private final VehicleDataService vehicleDataService;
|
|
|
+ @Resource
|
|
|
+ private VehicleDataService vehicleDataService;
|
|
|
|
|
|
/**
|
|
|
* 队列
|
|
|
*/
|
|
|
- private final VehicleDataQueue vehicleDataQueue;
|
|
|
+ @Resource
|
|
|
+ private VehicleDataQueue vehicleDataQueue;
|
|
|
|
|
|
+ @Resource
|
|
|
private ApplicationContext applicationContext;
|
|
|
|
|
|
@Override
|
|
|
@@ -84,7 +90,7 @@ public class TransferVehicleManage implements ApplicationContextAware {
|
|
|
}
|
|
|
|
|
|
// 批量保存到时序数据库
|
|
|
- taosMapper.batchInsertVehicleData(vehicleDataList);
|
|
|
+ taosService.batchInsertVehicleData(vehicleDataList);
|
|
|
} catch (Exception e) {
|
|
|
throw new IotException(ErrorCodeEnum.TD_SAVE_FAIL, "批量保存车辆数据到时序数据库失败", e);
|
|
|
}
|
|
|
@@ -106,6 +112,8 @@ public class TransferVehicleManage implements ApplicationContextAware {
|
|
|
.stream()
|
|
|
.map(VehicleData::getCarNo)
|
|
|
.collect(Collectors.toList());
|
|
|
+ log.info("查询关系数据库中已存在的车牌,结果:{}",existCarNos);
|
|
|
+
|
|
|
|
|
|
// 3. 筛选出需要新增的车辆
|
|
|
return vehicleDataList.stream()
|
|
|
@@ -138,11 +146,15 @@ public class TransferVehicleManage implements ApplicationContextAware {
|
|
|
List<VehicleTimeSeriesData> timeSeriesData;
|
|
|
//通过运单号查询车辆信息
|
|
|
if (StringUtils.isNotEmpty(request.getWOrderNo())) {
|
|
|
- timeSeriesData = taosMapper.selectByWOrderNo(request.getWOrderNo(), request.getStartTime(), request.getEndTime());
|
|
|
+ timeSeriesData = taosService.selectByWOrderNo(request);
|
|
|
+ log.info("按运单号查询, 运单号:{}, 时间范围:{}~{}, 结果条数:{}", request.getWOrderNo(), request.getStartTime(),
|
|
|
+ request.getEndTime(), timeSeriesData.size());
|
|
|
} else {
|
|
|
//通过车牌查询车辆信息
|
|
|
String subTableName = "vehicle_data_" + request.getCarNo().trim();
|
|
|
- timeSeriesData = taosMapper.selectByCarNo(subTableName, request.getCarNo(), request.getStartTime(), request.getEndTime());
|
|
|
+ timeSeriesData = taosService.selectByCarNo(subTableName, request);
|
|
|
+ log.info("按车牌查询, 运单号:{}, 时间范围:{}~{}, 结果条数:{}", request.getCarNo(), request.getStartTime(),
|
|
|
+ request.getEndTime(), timeSeriesData.size());
|
|
|
}
|
|
|
|
|
|
//参数转换
|
|
|
@@ -156,12 +168,8 @@ public class TransferVehicleManage implements ApplicationContextAware {
|
|
|
* 通过车牌查询实时经纬度
|
|
|
*/
|
|
|
public VehicleDataResp queryRealTimeLocation(String carNo) {
|
|
|
- if (StringUtils.isEmpty(carNo)) {
|
|
|
- throw new IotException(ErrorCodeEnum.ILLEGAL_PARAM, "接口参数为null!");
|
|
|
- }
|
|
|
-
|
|
|
String subTableName = "vehicle_data_" + carNo.trim();
|
|
|
- VehicleTimeSeriesData realTimeLocation = taosMapper.selectRealTimeLocation(subTableName, carNo);
|
|
|
+ VehicleTimeSeriesData realTimeLocation = taosService.selectRealTimeLocation(subTableName, carNo);
|
|
|
|
|
|
//参数转换
|
|
|
return VehicleDataResp.toIotPageResp(realTimeLocation);
|