|
@@ -1,5 +1,6 @@
|
|
|
package com.sckw.transport.service;
|
|
package com.sckw.transport.service;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Maps;
|
|
@@ -50,7 +51,15 @@ public class VehicleExceptionService {
|
|
|
* @param req 查询请求
|
|
* @param req 查询请求
|
|
|
* @return 分页结果
|
|
* @return 分页结果
|
|
|
*/
|
|
*/
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 分页查询车辆异常图片信息
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param req 查询请求参数
|
|
|
|
|
+ * @return 车辆异常图片分页结果
|
|
|
|
|
+ */
|
|
|
public PageDataResult<VehicleExceptionVo> queryExceptionList(VehicleExceptionQueryReq req) {
|
|
public PageDataResult<VehicleExceptionVo> queryExceptionList(VehicleExceptionQueryReq req) {
|
|
|
|
|
+ log.info("分页查询车辆异常信息,参数:{}", JSON.toJSONString( req));
|
|
|
// 分页查询异常图片数据
|
|
// 分页查询异常图片数据
|
|
|
IPage<KwtVehicleException> page = exceptionImageRepository.queryExceptionImagePage(
|
|
IPage<KwtVehicleException> page = exceptionImageRepository.queryExceptionImagePage(
|
|
|
req.getEntId(),
|
|
req.getEntId(),
|
|
@@ -60,65 +69,85 @@ public class VehicleExceptionService {
|
|
|
req.getPageSize()
|
|
req.getPageSize()
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
|
|
+ // 获取查询结果记录列表
|
|
|
List<KwtVehicleException> records = page.getRecords();
|
|
List<KwtVehicleException> records = page.getRecords();
|
|
|
|
|
+ // 如果记录为空,返回空的分页结果
|
|
|
if (CollectionUtils.isEmpty(records)) {
|
|
if (CollectionUtils.isEmpty(records)) {
|
|
|
return PageDataResult.empty(req.getPageNum(), req.getPageSize());
|
|
return PageDataResult.empty(req.getPageNum(), req.getPageSize());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 如果有定位状态筛选,需要查询车辆实时定位
|
|
|
|
|
|
|
+ // 如果有定位状态筛选条件,需要查询车辆实时定位状态
|
|
|
Map<String, Integer> truckLocationStatusMap = new HashMap<>();
|
|
Map<String, Integer> truckLocationStatusMap = new HashMap<>();
|
|
|
if (req.getLocationStatus() != null) {
|
|
if (req.getLocationStatus() != null) {
|
|
|
|
|
+ // 提取所有不重复的车牌号
|
|
|
List<String> truckNos = records.stream()
|
|
List<String> truckNos = records.stream()
|
|
|
.map(KwtVehicleException::getTruckNo)
|
|
.map(KwtVehicleException::getTruckNo)
|
|
|
.distinct()
|
|
.distinct()
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
+ // 批量查询车辆定位状态
|
|
|
truckLocationStatusMap = queryVehicleLocationStatus(truckNos);
|
|
truckLocationStatusMap = queryVehicleLocationStatus(truckNos);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 提取所有不重复的运单ID
|
|
|
List<Long> waybillOrderNos = records.stream()
|
|
List<Long> waybillOrderNos = records.stream()
|
|
|
.map(KwtVehicleException::getWOrderId)
|
|
.map(KwtVehicleException::getWOrderId)
|
|
|
.distinct()
|
|
.distinct()
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ // 初始化地址和运单信息Map
|
|
|
Map<String, KwtLogisticsOrderAddress> logisticsOrderAddressMap = Maps.newHashMap();
|
|
Map<String, KwtLogisticsOrderAddress> logisticsOrderAddressMap = Maps.newHashMap();
|
|
|
Map<Long, KwtWaybillOrderSubtask> waybillOrderSubtaskMap = Maps.newHashMap();
|
|
Map<Long, KwtWaybillOrderSubtask> waybillOrderSubtaskMap = Maps.newHashMap();
|
|
|
|
|
+
|
|
|
|
|
+ // 如果存在运单ID,则查询相关运单和地址信息
|
|
|
if (CollectionUtils.isNotEmpty(waybillOrderNos)){
|
|
if (CollectionUtils.isNotEmpty(waybillOrderNos)){
|
|
|
- //查询运单
|
|
|
|
|
|
|
+ // 查询运单信息
|
|
|
List<KwtWaybillOrderSubtask> subtasks = waybillOrderSubtaskRepository.queryByWOrderIds(waybillOrderNos);
|
|
List<KwtWaybillOrderSubtask> subtasks = waybillOrderSubtaskRepository.queryByWOrderIds(waybillOrderNos);
|
|
|
List<Long> logisticOrderIds = Lists.newArrayList();
|
|
List<Long> logisticOrderIds = Lists.newArrayList();
|
|
|
|
|
+
|
|
|
|
|
+ // 如果查询到运单信息,则提取物流订单ID
|
|
|
if (CollectionUtils.isNotEmpty(subtasks)){
|
|
if (CollectionUtils.isNotEmpty(subtasks)){
|
|
|
logisticOrderIds = subtasks.stream().map(KwtWaybillOrderSubtask::getLOrderId)
|
|
logisticOrderIds = subtasks.stream().map(KwtWaybillOrderSubtask::getLOrderId)
|
|
|
.distinct()
|
|
.distinct()
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
|
|
+ // 构建运单ID到运单信息的映射关系
|
|
|
waybillOrderSubtaskMap = subtasks.stream()
|
|
waybillOrderSubtaskMap = subtasks.stream()
|
|
|
.collect(Collectors.toMap(KwtWaybillOrderSubtask::getWOrderId, Function.identity(), (k1, k2) -> k1));
|
|
.collect(Collectors.toMap(KwtWaybillOrderSubtask::getWOrderId, Function.identity(), (k1, k2) -> k1));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 如果存在物流订单ID,则查询相关地址信息
|
|
|
if (CollectionUtils.isNotEmpty(logisticOrderIds)){
|
|
if (CollectionUtils.isNotEmpty(logisticOrderIds)){
|
|
|
- //查询地址
|
|
|
|
|
|
|
+ // 查询地址信息
|
|
|
List<KwtLogisticsOrderAddress> logisticOrderAddresses = logisticsOrderAddressRepository.queryByLogOrderIds(logisticOrderIds);
|
|
List<KwtLogisticsOrderAddress> logisticOrderAddresses = logisticsOrderAddressRepository.queryByLogOrderIds(logisticOrderIds);
|
|
|
|
|
+ // 构建物流订单ID+地址类型到地址信息的映射关系
|
|
|
logisticsOrderAddressMap = Optional.ofNullable(logisticOrderAddresses)
|
|
logisticsOrderAddressMap = Optional.ofNullable(logisticOrderAddresses)
|
|
|
.orElse(List.of())
|
|
.orElse(List.of())
|
|
|
.stream().collect(Collectors.toMap(x -> x.getLOrderId() + "_" + x.getAddressType(), Function.identity(), (k1, k2) -> k1));
|
|
.stream().collect(Collectors.toMap(x -> x.getLOrderId() + "_" + x.getAddressType(), Function.identity(), (k1, k2) -> k1));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- // 转换为VO
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 将查询结果转换为VO对象
|
|
|
final Map<String, Integer> finalLocationStatusMap = truckLocationStatusMap;
|
|
final Map<String, Integer> finalLocationStatusMap = truckLocationStatusMap;
|
|
|
Map<String, KwtLogisticsOrderAddress> finalLogisticsOrderAddressMap = logisticsOrderAddressMap;
|
|
Map<String, KwtLogisticsOrderAddress> finalLogisticsOrderAddressMap = logisticsOrderAddressMap;
|
|
|
Map<Long, KwtWaybillOrderSubtask> finalWaybillOrderSubtaskMap = waybillOrderSubtaskMap;
|
|
Map<Long, KwtWaybillOrderSubtask> finalWaybillOrderSubtaskMap = waybillOrderSubtaskMap;
|
|
|
|
|
+
|
|
|
|
|
+ // 遍历异常图片记录,构建VO对象列表
|
|
|
List<VehicleExceptionVo> voList = records.stream()
|
|
List<VehicleExceptionVo> voList = records.stream()
|
|
|
.map(image -> buildVehicleExceptionVo(image, finalLocationStatusMap,finalWaybillOrderSubtaskMap, finalLogisticsOrderAddressMap))
|
|
.map(image -> buildVehicleExceptionVo(image, finalLocationStatusMap,finalWaybillOrderSubtaskMap, finalLogisticsOrderAddressMap))
|
|
|
|
|
+ // 过滤掉空值
|
|
|
.filter(Objects::nonNull)
|
|
.filter(Objects::nonNull)
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
- // 如果有定位状态筛选,过滤结果
|
|
|
|
|
|
|
+ // 如果有定位状态筛选条件,再次过滤结果
|
|
|
if (req.getLocationStatus() != null) {
|
|
if (req.getLocationStatus() != null) {
|
|
|
voList = voList.stream()
|
|
voList = voList.stream()
|
|
|
.filter(vo -> req.getLocationStatus().equals(vo.getLocationStatus()))
|
|
.filter(vo -> req.getLocationStatus().equals(vo.getLocationStatus()))
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 返回分页结果
|
|
|
return PageDataResult.of(page, voList);
|
|
return PageDataResult.of(page, voList);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 构建车辆异常图片VO
|
|
* 构建车辆异常图片VO
|
|
|
*
|
|
*
|
|
@@ -170,6 +199,8 @@ public class VehicleExceptionService {
|
|
|
vo.setUnloadAddress(unLoadAdd.getDetailAddress());
|
|
vo.setUnloadAddress(unLoadAdd.getDetailAddress());
|
|
|
vo.setEndLng(unLoadAdd.getLng());
|
|
vo.setEndLng(unLoadAdd.getLng());
|
|
|
vo.setEndLat(unLoadAdd.getLat());
|
|
vo.setEndLat(unLoadAdd.getLat());
|
|
|
|
|
+ vo.setWaybillId(subtask.getWOrderId());
|
|
|
|
|
+ vo.setWaybillNo(subtask.getWOrderNo());
|
|
|
return vo;
|
|
return vo;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -211,7 +242,15 @@ public class VehicleExceptionService {
|
|
|
return locationStatusMap;
|
|
return locationStatusMap;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 分页查询车辆异常监控列表
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param req 查询请求参数
|
|
|
|
|
+ * @return 车辆异常监控分页结果
|
|
|
|
|
+ */
|
|
|
public PageDataResult<VehicleExceptionVo> exceptionJkList(VehicleExceptionQueryReq req) {
|
|
public PageDataResult<VehicleExceptionVo> exceptionJkList(VehicleExceptionQueryReq req) {
|
|
|
|
|
+ log.info("分页查询车辆异常监控列表, req: {}", JSON.toJSONString( req));
|
|
|
// 分页查询异常图片数据
|
|
// 分页查询异常图片数据
|
|
|
IPage<KwtVehicleException> page = exceptionImageRepository.queryExceptionImagePage1(
|
|
IPage<KwtVehicleException> page = exceptionImageRepository.queryExceptionImagePage1(
|
|
|
req.getEntId(),
|
|
req.getEntId(),
|
|
@@ -221,62 +260,83 @@ public class VehicleExceptionService {
|
|
|
req.getPageSize()
|
|
req.getPageSize()
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
|
|
+ // 获取查询结果记录列表
|
|
|
List<KwtVehicleException> records = page.getRecords();
|
|
List<KwtVehicleException> records = page.getRecords();
|
|
|
|
|
+ // 如果记录为空,返回空的分页结果
|
|
|
if (CollectionUtils.isEmpty(records)) {
|
|
if (CollectionUtils.isEmpty(records)) {
|
|
|
return PageDataResult.empty(req.getPageNum(), req.getPageSize());
|
|
return PageDataResult.empty(req.getPageNum(), req.getPageSize());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 如果有定位状态筛选,需要查询车辆实时定位
|
|
|
|
|
|
|
+ // 如果有定位状态筛选条件,需要查询车辆实时定位状态
|
|
|
Map<String, Integer> truckLocationStatusMap = new HashMap<>();
|
|
Map<String, Integer> truckLocationStatusMap = new HashMap<>();
|
|
|
if (req.getLocationStatus() != null) {
|
|
if (req.getLocationStatus() != null) {
|
|
|
|
|
+ // 提取所有不重复的车牌号
|
|
|
List<String> truckNos = records.stream()
|
|
List<String> truckNos = records.stream()
|
|
|
.map(KwtVehicleException::getTruckNo)
|
|
.map(KwtVehicleException::getTruckNo)
|
|
|
.distinct()
|
|
.distinct()
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
+ // 批量查询车辆定位状态
|
|
|
truckLocationStatusMap = queryVehicleLocationStatus(truckNos);
|
|
truckLocationStatusMap = queryVehicleLocationStatus(truckNos);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 提取所有不重复的运单ID
|
|
|
List<Long> waybillOrderNos = records.stream()
|
|
List<Long> waybillOrderNos = records.stream()
|
|
|
.map(KwtVehicleException::getWOrderId)
|
|
.map(KwtVehicleException::getWOrderId)
|
|
|
.distinct()
|
|
.distinct()
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ // 初始化地址和运单信息Map
|
|
|
Map<String, KwtLogisticsOrderAddress> logisticsOrderAddressMap = Maps.newHashMap();
|
|
Map<String, KwtLogisticsOrderAddress> logisticsOrderAddressMap = Maps.newHashMap();
|
|
|
Map<Long, KwtWaybillOrderSubtask> waybillOrderSubtaskMap = Maps.newHashMap();
|
|
Map<Long, KwtWaybillOrderSubtask> waybillOrderSubtaskMap = Maps.newHashMap();
|
|
|
|
|
+
|
|
|
|
|
+ // 如果存在运单ID,则查询相关运单和地址信息
|
|
|
if (CollectionUtils.isNotEmpty(waybillOrderNos)){
|
|
if (CollectionUtils.isNotEmpty(waybillOrderNos)){
|
|
|
- //查询运单
|
|
|
|
|
|
|
+ // 查询运单信息
|
|
|
List<KwtWaybillOrderSubtask> subtasks = waybillOrderSubtaskRepository.queryByWOrderIds(waybillOrderNos);
|
|
List<KwtWaybillOrderSubtask> subtasks = waybillOrderSubtaskRepository.queryByWOrderIds(waybillOrderNos);
|
|
|
List<Long> logisticOrderIds = Lists.newArrayList();
|
|
List<Long> logisticOrderIds = Lists.newArrayList();
|
|
|
|
|
+
|
|
|
|
|
+ // 如果查询到运单信息,则提取物流订单ID
|
|
|
if (CollectionUtils.isNotEmpty(subtasks)){
|
|
if (CollectionUtils.isNotEmpty(subtasks)){
|
|
|
- logisticOrderIds = subtasks.stream().map(KwtWaybillOrderSubtask::getLOrderId)
|
|
|
|
|
- .distinct()
|
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
|
|
+ logisticOrderIds = subtasks.stream().map(KwtWaybillOrderSubtask::getLOrderId)
|
|
|
|
|
+ .distinct()
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ // 构建运单ID到运单信息的映射关系
|
|
|
waybillOrderSubtaskMap = subtasks.stream()
|
|
waybillOrderSubtaskMap = subtasks.stream()
|
|
|
.collect(Collectors.toMap(KwtWaybillOrderSubtask::getWOrderId, Function.identity(), (k1, k2) -> k1));
|
|
.collect(Collectors.toMap(KwtWaybillOrderSubtask::getWOrderId, Function.identity(), (k1, k2) -> k1));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 如果存在物流订单ID,则查询相关地址信息
|
|
|
if (CollectionUtils.isNotEmpty(logisticOrderIds)){
|
|
if (CollectionUtils.isNotEmpty(logisticOrderIds)){
|
|
|
- //查询地址
|
|
|
|
|
|
|
+ // 查询地址信息
|
|
|
List<KwtLogisticsOrderAddress> logisticOrderAddresses = logisticsOrderAddressRepository.queryByLogOrderIds(logisticOrderIds);
|
|
List<KwtLogisticsOrderAddress> logisticOrderAddresses = logisticsOrderAddressRepository.queryByLogOrderIds(logisticOrderIds);
|
|
|
|
|
+ // 构建物流订单ID+地址类型到地址信息的映射关系
|
|
|
logisticsOrderAddressMap = Optional.ofNullable(logisticOrderAddresses)
|
|
logisticsOrderAddressMap = Optional.ofNullable(logisticOrderAddresses)
|
|
|
.orElse(List.of())
|
|
.orElse(List.of())
|
|
|
.stream().collect(Collectors.toMap(x -> x.getLOrderId() + "_" + x.getAddressType(), Function.identity(), (k1, k2) -> k1));
|
|
.stream().collect(Collectors.toMap(x -> x.getLOrderId() + "_" + x.getAddressType(), Function.identity(), (k1, k2) -> k1));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- // 转换为VO
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 将查询结果转换为VO对象
|
|
|
final Map<String, Integer> finalLocationStatusMap = truckLocationStatusMap;
|
|
final Map<String, Integer> finalLocationStatusMap = truckLocationStatusMap;
|
|
|
Map<String, KwtLogisticsOrderAddress> finalLogisticsOrderAddressMap = logisticsOrderAddressMap;
|
|
Map<String, KwtLogisticsOrderAddress> finalLogisticsOrderAddressMap = logisticsOrderAddressMap;
|
|
|
Map<Long, KwtWaybillOrderSubtask> finalWaybillOrderSubtaskMap = waybillOrderSubtaskMap;
|
|
Map<Long, KwtWaybillOrderSubtask> finalWaybillOrderSubtaskMap = waybillOrderSubtaskMap;
|
|
|
|
|
+
|
|
|
|
|
+ // 遍历异常图片记录,构建VO对象列表
|
|
|
List<VehicleExceptionVo> voList = records.stream()
|
|
List<VehicleExceptionVo> voList = records.stream()
|
|
|
.map(image -> buildVehicleExceptionVo(image, finalLocationStatusMap, finalWaybillOrderSubtaskMap, finalLogisticsOrderAddressMap))
|
|
.map(image -> buildVehicleExceptionVo(image, finalLocationStatusMap, finalWaybillOrderSubtaskMap, finalLogisticsOrderAddressMap))
|
|
|
|
|
+ // 过滤掉空值
|
|
|
.filter(Objects::nonNull)
|
|
.filter(Objects::nonNull)
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
- // 如果有定位状态筛选,过滤结果
|
|
|
|
|
|
|
+ // 如果有定位状态筛选条件,再次过滤结果
|
|
|
if (req.getLocationStatus() != null) {
|
|
if (req.getLocationStatus() != null) {
|
|
|
voList = voList.stream()
|
|
voList = voList.stream()
|
|
|
.filter(vo -> req.getLocationStatus().equals(vo.getLocationStatus()))
|
|
.filter(vo -> req.getLocationStatus().equals(vo.getLocationStatus()))
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 返回分页结果
|
|
|
return PageDataResult.of(page, voList);
|
|
return PageDataResult.of(page, voList);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|