提交 36b3f719 authored 作者: 刘海泉's avatar 刘海泉

提交通过位置自动更改运单状态的逻辑

上级 0f1937be
...@@ -579,19 +579,11 @@ public class OrderChildServiceImpl implements OrderChildService { ...@@ -579,19 +579,11 @@ public class OrderChildServiceImpl implements OrderChildService {
PerformanceResultEnum.DATA_NOT_FIND); PerformanceResultEnum.DATA_NOT_FIND);
OrderGoods orderGoods = orderGoodsDao.getByOrderGoodsNo(orderChild.getOrderGoodsNo()).orElseThrow( OrderGoods orderGoods = orderGoodsDao.getByOrderGoodsNo(orderChild.getOrderGoodsNo()).orElseThrow(
PerformanceResultEnum.DATA_NOT_FIND); PerformanceResultEnum.DATA_NOT_FIND);
double longitude;
double latitude;
//首先获取中交的车来那个经纬度信息,不存在则使用app传过来的经纬度 double [] currentTruckPosition = getCurrentTruckPosition(orderChild.getTruckNo(),param);
BigDecimal[] currentTruckPosition = truckTraceService.getCurrentTruckPosition(orderChild.getTruckNo());
if(ArrayUtils.isNotEmpty(currentTruckPosition)){
longitude = currentTruckPosition[0].doubleValue();
latitude = currentTruckPosition[1].doubleValue();
}else{
longitude = param.getLongitude().doubleValue();
latitude = param.getLatitude().doubleValue();
}
double distance = GpsUtil.distance(orderGoods.getSendLongitude().doubleValue(), double distance = GpsUtil.distance(orderGoods.getSendLongitude().doubleValue(),
orderGoods.getSendLatitude().doubleValue(), longitude, latitude) / 1000; orderGoods.getSendLatitude().doubleValue(), currentTruckPosition[0], currentTruckPosition[1]) / 1000;
if (distance > orderInfo.getSendDriverArriveRange().doubleValue()) { if (distance > orderInfo.getSendDriverArriveRange().doubleValue()) {
throw new ServiceSystemException(PerformanceResultEnum.ORDER_CHILD_ARRIVE_SEND_ADDRESS_DISTANCE_ERROR); throw new ServiceSystemException(PerformanceResultEnum.ORDER_CHILD_ARRIVE_SEND_ADDRESS_DISTANCE_ERROR);
} }
...@@ -607,6 +599,22 @@ public class OrderChildServiceImpl implements OrderChildService { ...@@ -607,6 +599,22 @@ public class OrderChildServiceImpl implements OrderChildService {
orderChildMqService.orderChildArriveSendAddress(orderChild.getChildNo()); orderChildMqService.orderChildArriveSendAddress(orderChild.getChildNo());
} }
//首先获取中交的车来那个经纬度信息,不存在则使用app传过来的经纬度
private double[] getCurrentTruckPosition(String truckNo,PositionParam param) {
double longitude;
double latitude;
//首先获取中交的车来那个经纬度信息,不存在则使用app传过来的经纬度
BigDecimal[] currentTruckPosition = truckTraceService.getCurrentTruckPosition(truckNo);
if(ArrayUtils.isNotEmpty(currentTruckPosition)){
longitude = currentTruckPosition[0].doubleValue();
latitude = currentTruckPosition[1].doubleValue();
}else{
longitude = param.getLongitude().doubleValue();
latitude = param.getLatitude().doubleValue();
}
return new double[]{longitude, latitude};
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
...@@ -669,9 +677,13 @@ public class OrderChildServiceImpl implements OrderChildService { ...@@ -669,9 +677,13 @@ public class OrderChildServiceImpl implements OrderChildService {
PerformanceResultEnum.DATA_NOT_FIND); PerformanceResultEnum.DATA_NOT_FIND);
OrderGoods orderGoods = orderGoodsDao.getByOrderGoodsNo(orderChild.getOrderGoodsNo()).orElseThrow( OrderGoods orderGoods = orderGoodsDao.getByOrderGoodsNo(orderChild.getOrderGoodsNo()).orElseThrow(
PerformanceResultEnum.DATA_NOT_FIND); PerformanceResultEnum.DATA_NOT_FIND);
double [] currentTruckPosition = getCurrentTruckPosition(orderChild.getTruckNo(),param);
double distance = GpsUtil.distance(orderGoods.getReceiveLongitude().doubleValue(), double distance = GpsUtil.distance(orderGoods.getReceiveLongitude().doubleValue(),
orderGoods.getReceiveLatitude().doubleValue(), param.getLongitude().doubleValue(), orderGoods.getReceiveLatitude().doubleValue(),currentTruckPosition[0],
param.getLatitude().doubleValue()) / 1000; currentTruckPosition[1]) / 1000;
if (distance > orderInfo.getReveiveDriverArriveRange().doubleValue()) { if (distance > orderInfo.getReveiveDriverArriveRange().doubleValue()) {
throw new ServiceSystemException(PerformanceResultEnum.ORDER_CHILD_ARRIVE_RECEIVE_ADDRESS_DISTANCE_ERROR); throw new ServiceSystemException(PerformanceResultEnum.ORDER_CHILD_ARRIVE_RECEIVE_ADDRESS_DISTANCE_ERROR);
} }
......
package com.clx.performance.struct.trace;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.clx.performance.esplus.model.DriverTraceESPlus;
import com.clx.performance.vo.pc.trace.DriverTraceVO;
import com.msl.common.utils.DateStructUtil;
import com.msl.common.utils.DateUtils;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import java.math.BigDecimal;
import java.util.List;
@Mapper(componentModel = "spring", uses = DateStructUtil.class, imports = {DateUtils.class, BigDecimal.class})
public interface DriverTraceStruct {
@Mapping(target = "longitude", expression = "java(item.getLocation()[0])")
@Mapping(target = "latitude", expression = "java(item.getLocation()[1])")
@Mapping(target = "gpsTime", source = "positionTime")
DriverTraceVO convert(DriverTraceESPlus item);
List<DriverTraceVO> convert(List<DriverTraceESPlus> list);
Page<DriverTraceVO> convertPage(IPage<DriverTraceESPlus> page);
}
package com.clx.performance.struct.trace;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.clx.performance.esplus.model.TruckTraceESPlus;
import com.clx.performance.vo.pc.trace.DriverTruckTraceVO;
import com.msl.common.utils.DateStructUtil;
import com.msl.common.utils.DateUtils;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import java.util.List;
@Mapper(componentModel = "spring", uses = DateStructUtil.class, imports = {DateUtils.class})
public interface TruckTraceStruct {
@Mapping(target = "longitude", expression = "java(item.getLocation()[0])")
@Mapping(target = "latitude", expression = "java(item.getLocation()[1])")
DriverTruckTraceVO convert(TruckTraceESPlus item);
List<DriverTruckTraceVO> convert(List<TruckTraceESPlus> list);
Page<DriverTruckTraceVO> convertPage(IPage<TruckTraceESPlus> page);
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论