|
@@ -60,6 +60,7 @@ import com.sckw.transport.service.zj.VehicleCollectService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
+import org.apache.commons.collections4.MapUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.NotNull;
|
|
@@ -837,13 +838,13 @@ public class kwfTruckTraceService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 获取所有车牌号列表,用于查询实时位置
|
|
// 获取所有车牌号列表,用于查询实时位置
|
|
|
- List<String> truckNos = waybillOrders.stream()
|
|
|
|
|
- .map(KwtWaybillOrder::getTruckNo)
|
|
|
|
|
- .distinct()
|
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ Map<Long, String> truckIdTruckNoMap = waybillOrders.stream()
|
|
|
|
|
+ .filter(x->Objects.nonNull(x.getTruckId()))
|
|
|
|
|
+ .collect(Collectors.toMap(KwtWaybillOrder::getTruckId, KwtWaybillOrder::getTruckNo, (key1, key2) -> key1));
|
|
|
|
|
+
|
|
|
// 批量查询实时位置状态(30分钟内有数据为在线)
|
|
// 批量查询实时位置状态(30分钟内有数据为在线)
|
|
|
- Map<String, Integer> truckLocationStatusMap = getStringIntegerMap(truckNos);
|
|
|
|
|
|
|
+ Map<String, Integer> truckLocationStatusMap = getStringIntegerMap(truckIdTruckNoMap);
|
|
|
|
|
|
|
|
// 转换为 VO 对象并根据状态筛选
|
|
// 转换为 VO 对象并根据状态筛选
|
|
|
return waybillOrders.stream()
|
|
return waybillOrders.stream()
|
|
@@ -855,21 +856,23 @@ public class kwfTruckTraceService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@NotNull
|
|
@NotNull
|
|
|
- private Map<String, Integer> getStringIntegerMap(List<String> truckNos) {
|
|
|
|
|
|
|
+ private Map<String, Integer> getStringIntegerMap(Map<Long, String> truckIdTruckNoMap) {
|
|
|
Map<String, Integer> truckLocationStatusMap = new HashMap<>();
|
|
Map<String, Integer> truckLocationStatusMap = new HashMap<>();
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
LocalDateTime thirtyMinutesAgo = now.minusMinutes(30);
|
|
LocalDateTime thirtyMinutesAgo = now.minusMinutes(30);
|
|
|
-
|
|
|
|
|
- for (String truckNo : truckNos) {
|
|
|
|
|
|
|
+ if (MapUtils.isEmpty(truckIdTruckNoMap)){
|
|
|
|
|
+ return truckLocationStatusMap;
|
|
|
|
|
+ }
|
|
|
|
|
+ truckIdTruckNoMap.forEach((truckId, truckNo) -> {
|
|
|
try {
|
|
try {
|
|
|
VehicleDataDTO vehicleDataDTO = new VehicleDataDTO();
|
|
VehicleDataDTO vehicleDataDTO = new VehicleDataDTO();
|
|
|
- vehicleDataDTO.setCarNo(truckNo);
|
|
|
|
|
|
|
+ vehicleDataDTO.setCarNo(Objects.isNull(truckId) ? "0" : String.valueOf(truckId));
|
|
|
BaseIotResult<VehicleReturnData> result = vehicleTraceClient.queryRealTimeLocation(vehicleDataDTO);
|
|
BaseIotResult<VehicleReturnData> result = vehicleTraceClient.queryRealTimeLocation(vehicleDataDTO);
|
|
|
|
|
|
|
|
if (result == null || !Objects.equals(result.getCode(), "0") || result.getData() == null) {
|
|
if (result == null || !Objects.equals(result.getCode(), "0") || result.getData() == null) {
|
|
|
// 无定位数据,设置为离线
|
|
// 无定位数据,设置为离线
|
|
|
truckLocationStatusMap.put(truckNo, 0);
|
|
truckLocationStatusMap.put(truckNo, 0);
|
|
|
- return truckLocationStatusMap;
|
|
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
VehicleReturnData vehicleData = result.getData();
|
|
VehicleReturnData vehicleData = result.getData();
|
|
@@ -878,7 +881,7 @@ public class kwfTruckTraceService {
|
|
|
if (vehicleData.getTs() == null) {
|
|
if (vehicleData.getTs() == null) {
|
|
|
// 无GPS时间,设置为离线
|
|
// 无GPS时间,设置为离线
|
|
|
truckLocationStatusMap.put(truckNo, 0);
|
|
truckLocationStatusMap.put(truckNo, 0);
|
|
|
- return truckLocationStatusMap;
|
|
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 30分钟内为在线
|
|
// 30分钟内为在线
|
|
@@ -892,7 +895,7 @@ public class kwfTruckTraceService {
|
|
|
log.warn("查询车辆实时位置异常, 车牌号: {}", truckNo, e);
|
|
log.warn("查询车辆实时位置异常, 车牌号: {}", truckNo, e);
|
|
|
truckLocationStatusMap.put(truckNo, 0);
|
|
truckLocationStatusMap.put(truckNo, 0);
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
+ });
|
|
|
return truckLocationStatusMap;
|
|
return truckLocationStatusMap;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1027,13 +1030,12 @@ public class kwfTruckTraceService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 获取车牌号列表,查询定位信息
|
|
// 获取车牌号列表,查询定位信息
|
|
|
- List<String> truckNos = waybillOrders.stream()
|
|
|
|
|
- .map(KwtWaybillOrder::getTruckNo)
|
|
|
|
|
- .distinct()
|
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
-
|
|
|
|
|
|
|
+ Map<Long, String> truckIdAndTruckNoMap = waybillOrders.stream()
|
|
|
|
|
+ .filter(x->Objects.nonNull(x.getTruckId()))
|
|
|
|
|
+ .collect(Collectors.toMap(KwtWaybillOrder::getTruckId, KwtWaybillOrder::getTruckNo, (k1, k2) -> k1));
|
|
|
|
|
+
|
|
|
// 批量查询定位状态和位置信息
|
|
// 批量查询定位状态和位置信息
|
|
|
- Map<String, VehicleLocationInfo> locationInfoMap = queryVehicleLocationBatch(truckNos);
|
|
|
|
|
|
|
+ Map<String, VehicleLocationInfo> locationInfoMap = queryVehicleLocationBatch(truckIdAndTruckNoMap);
|
|
|
|
|
|
|
|
// 批量查询运单轨迹数据,统计异常数量(通过alarmCode判断)
|
|
// 批量查询运单轨迹数据,统计异常数量(通过alarmCode判断)
|
|
|
List<String> wOrderNos = waybillOrders.stream()
|
|
List<String> wOrderNos = waybillOrders.stream()
|
|
@@ -1205,32 +1207,32 @@ public class kwfTruckTraceService {
|
|
|
/**
|
|
/**
|
|
|
* 批量查询车辆定位信息
|
|
* 批量查询车辆定位信息
|
|
|
*/
|
|
*/
|
|
|
- private Map<String, VehicleLocationInfo> queryVehicleLocationBatch(List<String> truckNos) {
|
|
|
|
|
|
|
+ private Map<String, VehicleLocationInfo> queryVehicleLocationBatch(Map<Long, String> truckIdAndTruckNoMap) {
|
|
|
Map<String, VehicleLocationInfo> locationInfoMap = new HashMap<>();
|
|
Map<String, VehicleLocationInfo> locationInfoMap = new HashMap<>();
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
log.info("获取配置时间:{}", urlConfigProperties.getMinute());
|
|
log.info("获取配置时间:{}", urlConfigProperties.getMinute());
|
|
|
LocalDateTime thirtyMinutesAgo = now.minusMinutes(urlConfigProperties.getMinute());
|
|
LocalDateTime thirtyMinutesAgo = now.minusMinutes(urlConfigProperties.getMinute());
|
|
|
- if (CollectionUtils.isEmpty(truckNos)){
|
|
|
|
|
|
|
+ if (MapUtils.isEmpty(truckIdAndTruckNoMap)){
|
|
|
return locationInfoMap;
|
|
return locationInfoMap;
|
|
|
}
|
|
}
|
|
|
- for (String truckNo : truckNos) {
|
|
|
|
|
|
|
+ truckIdAndTruckNoMap.forEach((truckId, truckNo) -> {
|
|
|
try {
|
|
try {
|
|
|
VehicleDataDTO vehicleDataDTO = new VehicleDataDTO();
|
|
VehicleDataDTO vehicleDataDTO = new VehicleDataDTO();
|
|
|
- vehicleDataDTO.setCarNo(truckNo);
|
|
|
|
|
|
|
+ vehicleDataDTO.setCarNo(Objects.isNull(truckId) ? "0" : String.valueOf(truckId));
|
|
|
BaseIotResult<VehicleReturnData> result = vehicleTraceClient.queryRealTimeLocation(vehicleDataDTO);
|
|
BaseIotResult<VehicleReturnData> result = vehicleTraceClient.queryRealTimeLocation(vehicleDataDTO);
|
|
|
log.info("查询车辆数据中台响应定位信息:{}", JSON.toJSONString( result));
|
|
log.info("查询车辆数据中台响应定位信息:{}", JSON.toJSONString( result));
|
|
|
VehicleLocationInfo locationInfo = new VehicleLocationInfo();
|
|
VehicleLocationInfo locationInfo = new VehicleLocationInfo();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (result != null && StringUtils.equals(result.getCode(), "0") && result.getData() != null) {
|
|
if (result != null && StringUtils.equals(result.getCode(), "0") && result.getData() != null) {
|
|
|
VehicleReturnData vehicleData = result.getData();
|
|
VehicleReturnData vehicleData = result.getData();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 判断定位状态
|
|
// 判断定位状态
|
|
|
if (vehicleData.getTs() != null && vehicleData.getTs().toLocalDateTime().isAfter(thirtyMinutesAgo)) {
|
|
if (vehicleData.getTs() != null && vehicleData.getTs().toLocalDateTime().isAfter(thirtyMinutesAgo)) {
|
|
|
locationInfo.setLocationStatus(1);
|
|
locationInfo.setLocationStatus(1);
|
|
|
} else {
|
|
} else {
|
|
|
locationInfo.setLocationStatus(0);
|
|
locationInfo.setLocationStatus(0);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
locationInfo.setLongitude(vehicleData.getLongitude());
|
|
locationInfo.setLongitude(vehicleData.getLongitude());
|
|
|
locationInfo.setLatitude(vehicleData.getLatitude());
|
|
locationInfo.setLatitude(vehicleData.getLatitude());
|
|
|
if (vehicleData.getTs() != null) {
|
|
if (vehicleData.getTs() != null) {
|
|
@@ -1248,7 +1250,7 @@ public class kwfTruckTraceService {
|
|
|
locationInfo.setLocationStatus(0);
|
|
locationInfo.setLocationStatus(0);
|
|
|
locationInfoMap.put(truckNo, locationInfo);
|
|
locationInfoMap.put(truckNo, locationInfo);
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
return locationInfoMap;
|
|
return locationInfoMap;
|
|
|
}
|
|
}
|
|
@@ -1549,13 +1551,15 @@ public class kwfTruckTraceService {
|
|
|
vehiclesTrajectoryReq.setEngineTemp(40.0f);
|
|
vehiclesTrajectoryReq.setEngineTemp(40.0f);
|
|
|
vehiclesTrajectoryReq.setBatteryVoltage(30.0f);
|
|
vehiclesTrajectoryReq.setBatteryVoltage(30.0f);
|
|
|
vehiclesTrajectoryReq.setStatus("0");
|
|
vehiclesTrajectoryReq.setStatus("0");
|
|
|
|
|
+ vehiclesTrajectoryReq.setAlarmCode("0");
|
|
|
if (req.getExceptionType() != null){
|
|
if (req.getExceptionType() != null){
|
|
|
vehiclesTrajectoryReq.setStatus(String.valueOf(req.getExceptionType()));
|
|
vehiclesTrajectoryReq.setStatus(String.valueOf(req.getExceptionType()));
|
|
|
}
|
|
}
|
|
|
vehiclesTrajectoryReq.setWOrderNo(req.getWayOrderNo());
|
|
vehiclesTrajectoryReq.setWOrderNo(req.getWayOrderNo());
|
|
|
|
|
+ vehiclesTrajectoryReq.setWayOrderNo(req.getWayOrderNo());
|
|
|
vehiclesTrajectoryReq.setLOrderNo(Optional.ofNullable(logisticsOrder).map(KwtLogisticsOrder::getLOrderNo).orElse( ""));
|
|
vehiclesTrajectoryReq.setLOrderNo(Optional.ofNullable(logisticsOrder).map(KwtLogisticsOrder::getLOrderNo).orElse( ""));
|
|
|
VehiclesTrajectoryReq.VehicleDataVO vehicleDataVO = new VehiclesTrajectoryReq.VehicleDataVO();
|
|
VehiclesTrajectoryReq.VehicleDataVO vehicleDataVO = new VehiclesTrajectoryReq.VehicleDataVO();
|
|
|
- vehicleDataVO.setCarNo(req.getTruckNo());
|
|
|
|
|
|
|
+ vehicleDataVO.setCarNo(Objects.isNull(order.getTruckId()) ? "0" : String.valueOf(order.getTruckId()));
|
|
|
if (fleetByTruckId != null){
|
|
if (fleetByTruckId != null){
|
|
|
vehicleDataVO.setFleetId(Objects.nonNull(fleetByTruckId.getId())?fleetByTruckId.getId().toString():"");
|
|
vehicleDataVO.setFleetId(Objects.nonNull(fleetByTruckId.getId())?fleetByTruckId.getId().toString():"");
|
|
|
vehicleDataVO.setFleetName(fleetByTruckId.getName());
|
|
vehicleDataVO.setFleetName(fleetByTruckId.getName());
|