|
|
@@ -58,6 +58,7 @@ import org.springframework.stereotype.Service;
|
|
|
import java.time.Duration;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneOffset;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.function.Function;
|
|
|
@@ -102,7 +103,7 @@ public class kwfTruckTraceService {
|
|
|
PaymentDubboService paymentDubboService ;
|
|
|
|
|
|
public PageDataResult<KwfTruckTraceReplayVo> findPage(KwfTruckTraceReplayReq req) {
|
|
|
- log.info("查询历轨迹回放氢气参数:{}", req);
|
|
|
+ log.info("查询历轨迹回放参数:{}", req);
|
|
|
if (StringUtils.isBlank(req.getTruckNo())){
|
|
|
return PageDataResult.empty(req.getPageNum(), req.getPageSize());
|
|
|
}
|
|
|
@@ -231,7 +232,7 @@ public class kwfTruckTraceService {
|
|
|
TruckDto truckDto = JSON.parseObject(location, TruckDto.class);
|
|
|
//如果运单号为空那么返回redis的数据 这个数据是app最后一次上报的数据
|
|
|
if (Objects.nonNull(truckDto)){
|
|
|
- return TruckInfoVo.toTruckInfoVo(truckDto);
|
|
|
+ return getTruckInfoVo(truckId, truckDto);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -245,6 +246,42 @@ public class kwfTruckTraceService {
|
|
|
return getTruckInfoVoByZj(truckNo, wOrderNo,truckId);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private TruckInfoVo getTruckInfoVo(String truckId, TruckDto truckDto) {
|
|
|
+ TruckInfoVo truckInfoVo = TruckInfoVo.toTruckInfoVo(truckDto);
|
|
|
+ truckInfoVo.setGpsStatus(truckDto.getGpsStatus());
|
|
|
+ truckInfoVo.setLongitude(truckDto.getLongitude());
|
|
|
+ truckInfoVo.setLatitude(truckDto.getLatitude());
|
|
|
+ truckInfoVo.setLocationTime(truckDto.getLocationTime());
|
|
|
+ truckInfoVo.setTaskAddress(truckDto.getTaskAddress());
|
|
|
+ KwtWaybillOrder order = kwtWaybillOrderRepository.findOneByTruckId(truckId);
|
|
|
+ if (Objects.nonNull(order)){
|
|
|
+ truckInfoVo.setTruckNo(order.getTruckNo());
|
|
|
+ truckInfoVo.setOrderNo(order.getWOrderNo());
|
|
|
+ truckInfoVo.setDriveId(String.valueOf(order.getDriverId()));
|
|
|
+ truckInfoVo.setDriveName(order.getDriverName());
|
|
|
+ truckInfoVo.setDrivePhone(order.getDriverPhone());
|
|
|
+ truckInfoVo.setTruckId(truckId);
|
|
|
+ truckInfoVo.setTaskStatus(String.valueOf(order.getStatus()));
|
|
|
+ }
|
|
|
+
|
|
|
+ KwtWaybillOrderSubtask subtask = kwtWaybillOrderSubtaskRepository.findOneByWOrderNo(Optional.ofNullable(order)
|
|
|
+ .map(KwtWaybillOrder::getWOrderNo).
|
|
|
+ orElse( null));
|
|
|
+ truckInfoVo.setLogicOrderNo(Objects.isNull(subtask) ? "" : String.valueOf(subtask.getLOrderId()));
|
|
|
+ if (Objects.isNull(subtask)){
|
|
|
+ return truckInfoVo;
|
|
|
+ }
|
|
|
+ truckInfoVo.setLogicOrderNo(String.valueOf(subtask.getLOrderId()));
|
|
|
+ //根据物流订单号查询承运单位 2.代表承运企业
|
|
|
+ KwtLogisticsOrderUnit kwtLogisticsOrderUnit = kwtLogisticsOrderUnitRepository.queryByLOrderIdAndUnitType(subtask.getLOrderId(), 2);
|
|
|
+ if (Objects.nonNull(kwtLogisticsOrderUnit) && Objects.nonNull(kwtLogisticsOrderUnit.getEntId())){
|
|
|
+ EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(kwtLogisticsOrderUnit.getEntId());
|
|
|
+ truckInfoVo.setCarrier(Optional.ofNullable(entCacheResDto).map(EntCacheResDto::getFirmName).orElse(""));
|
|
|
+ }
|
|
|
+ return truckInfoVo;
|
|
|
+ }
|
|
|
+
|
|
|
private void saveRedisCache(String truckId, String wOrderNo, String truckNo, VehicleReturnData vehicleReturnData) {
|
|
|
TruckDto truckDto = new TruckDto();
|
|
|
truckDto.setWOrderNo(vehicleReturnData.getWOrderNo());
|
|
|
@@ -388,6 +425,7 @@ public class kwfTruckTraceService {
|
|
|
//组织返回数据
|
|
|
List<CurrentTaskTraceReqVo.CurrentTaskTrace> currentTaskTraceList = vehicleReturnDataList.stream()
|
|
|
.map(kwfTruckTraceService::getCurrentTaskTrace)
|
|
|
+ .filter(x->StringUtils.isNotBlank(x.getLocationTime()))
|
|
|
.sorted(Comparator.comparing(CurrentTaskTraceReqVo.CurrentTaskTrace::getLocationTime))
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
@@ -396,16 +434,17 @@ public class kwfTruckTraceService {
|
|
|
for (int i = 1; i < currentTaskTraceList.size(); i++) {
|
|
|
CurrentTaskTraceReqVo.CurrentTaskTrace current = currentTaskTraceList.get(i);
|
|
|
CurrentTaskTraceReqVo.CurrentTaskTrace previous = currentTaskTraceList.get(i - 1);
|
|
|
- LocalDateTime currentTime = LocalDateTime.parse(current.getLocationTime());
|
|
|
- LocalDateTime previousTime = LocalDateTime.parse(previous.getLocationTime());
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ LocalDateTime currentTime = LocalDateTime.parse(current.getLocationTime(), formatter);
|
|
|
+ LocalDateTime previousTime = LocalDateTime.parse(previous.getLocationTime(), formatter);
|
|
|
Duration duration = Duration.between(previousTime, currentTime);
|
|
|
current.setDuration(String.valueOf(duration.toMinutes()));
|
|
|
}
|
|
|
CurrentTaskTraceReqVo.CurrentTaskTrace first = currentTaskTraceList.get(0);
|
|
|
CurrentTaskTraceReqVo.CurrentTaskTrace last = currentTaskTraceList.get(currentTaskTraceList.size() - 1);
|
|
|
-
|
|
|
- LocalDateTime firstTime = LocalDateTime.parse(first.getLocationTime());
|
|
|
- LocalDateTime lastTime = LocalDateTime.parse(last.getLocationTime());
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ LocalDateTime firstTime = LocalDateTime.parse(first.getLocationTime(),formatter);
|
|
|
+ LocalDateTime lastTime = LocalDateTime.parse(last.getLocationTime(),formatter);
|
|
|
|
|
|
Duration totalDuration = Duration.between(firstTime, lastTime);
|
|
|
long durationInMinutes = totalDuration.toMinutes();
|