调度记录增加经纬度保存
This commit is contained in:
parent
9dd4bfed9c
commit
f76f4004b0
@ -5,6 +5,7 @@ import com.mybatisflex.annotation.Id;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class ReqEbikeDispatchRecordDto {
|
||||
@ -20,4 +21,14 @@ public class ReqEbikeDispatchRecordDto {
|
||||
@Column(onInsertValue = "0")
|
||||
private String dispatchState;
|
||||
|
||||
/**
|
||||
* 调度前车辆经度
|
||||
*/
|
||||
private Double startVehicleLng;
|
||||
|
||||
/**
|
||||
* 调度前车辆纬度
|
||||
*/
|
||||
private Double startVehicleLat;
|
||||
|
||||
}
|
||||
@ -90,22 +90,22 @@ public class EbikeDispatchRecords implements Serializable {
|
||||
/**
|
||||
* 调度前车辆纬度
|
||||
*/
|
||||
private BigDecimal startVehicleLat;
|
||||
private Double startVehicleLat;
|
||||
|
||||
/**
|
||||
* 调度前车辆经度
|
||||
*/
|
||||
private BigDecimal startVehicleLng;
|
||||
private Double startVehicleLng;
|
||||
|
||||
/**
|
||||
* 调度后车辆纬度
|
||||
*/
|
||||
private BigDecimal endVehicleLat;
|
||||
private Double endVehicleLat;
|
||||
|
||||
/**
|
||||
* 调度后车辆经度
|
||||
*/
|
||||
private BigDecimal endVehicleLng;
|
||||
private Double endVehicleLng;
|
||||
|
||||
/**
|
||||
* 创建时间,表示记录创建的时间
|
||||
|
||||
@ -1162,6 +1162,7 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
|
||||
* @param eqWorkOrderDispatchDto
|
||||
* @return
|
||||
*/
|
||||
@Transactional // 添加事务注解
|
||||
public String createWorkOrderDispatch(ReqWorkOrderDispatchDto eqWorkOrderDispatchDto) {
|
||||
try {
|
||||
// 获取 token 和用户信息
|
||||
@ -1188,14 +1189,24 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
|
||||
ebikeScheduleWorkOrderExtension.setId(ebikeBikeOrder.getOrderId());
|
||||
ebikeScheduleWorkOrderExtension.setDispatchType(eqWorkOrderDispatchDto.getDispatchType());
|
||||
ebikeScheduleWorkOrderExtension.setSiteId(eqWorkOrderDispatchDto.getSiteId());//站点id
|
||||
ebikeScheduleWorkOrderExtension.setDispatchType(eqWorkOrderDispatchDto.getDispatchType());
|
||||
ebikeScheduleWorkOrderExtensionMapper.insert(ebikeScheduleWorkOrderExtension);
|
||||
// 创建并保存调度记录
|
||||
List<EbikeDispatchRecords> records = new ArrayList<>();
|
||||
for (String bikeCode : eqWorkOrderDispatchDto.getBikeCodes()) {
|
||||
EbikeDispatchRecords dispatchRecord = new EbikeDispatchRecords();
|
||||
//获取经纬度
|
||||
ResEbikeBikeAndEcuCodeDto bikeINfoData = getBikeINfoData(bikeCode);
|
||||
ResGPSDto resGPSDto = bikeINfoData.getResGPSDto();
|
||||
if(resGPSDto!=null){
|
||||
Double latitude = resGPSDto.getLatitude();
|
||||
Double longitude = resGPSDto.getLongitude();
|
||||
dispatchRecord.setStartVehicleLng(latitude);
|
||||
dispatchRecord.setStartVehicleLat(longitude);
|
||||
}
|
||||
dispatchRecord.setOrderId(ebikeBikeOrder.getOrderId());
|
||||
dispatchRecord.setBikeCode(bikeCode);
|
||||
dispatchRecord.setStartStation(eqWorkOrderDispatchDto.getSiteId());
|
||||
dispatchRecord.setStartStationId(eqWorkOrderDispatchDto.getSiteId());
|
||||
records.add(dispatchRecord);
|
||||
}
|
||||
// 批量插入调度记录(如果支持批量插入的话)
|
||||
@ -1210,7 +1221,6 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
|
||||
// 异常处理,记录日志并抛出自定义异常或包装成 RuntimeException
|
||||
// 可以使用日志工具,例如 log4j 或 slf4j,记录错误详细信息
|
||||
log.error("创建工单调度失败", e);
|
||||
|
||||
// 可根据需求抛出更具体的异常
|
||||
throw new RuntimeException("创建工单调度时发生异常", e);
|
||||
}
|
||||
@ -1259,6 +1269,8 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
|
||||
EbikeDispatchRecords ebikeDispatchRecords = new EbikeDispatchRecords();
|
||||
ebikeDispatchRecords.setOrderId(ebikeDispatchRecordDto.getOrderId());
|
||||
ebikeDispatchRecords.setBikeCode(ebikeDispatchRecordDto.getBikeCode());
|
||||
ebikeDispatchRecords.setStartVehicleLng(ebikeDispatchRecordDto.getStartVehicleLng());
|
||||
ebikeDispatchRecords.setStartVehicleLat(ebikeDispatchRecordDto.getStartVehicleLat());
|
||||
ebikeDispatchRecords.setDispatchState(ebikeDispatchRecordDto.getDispatchState());
|
||||
ebikeDispatchRecordsMapper.insert(ebikeDispatchRecords);
|
||||
return ebikeDispatchRecords;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user