| | |
| | | package com.xiaopeng.maintenance.schedule; |
| | | |
| | | import cn.hutool.core.util.IdUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.xiaopeng.api.dto.automaticPilot.PushOrderDto; |
| | | import com.xiaopeng.api.feignClient.automaticPilot.OrderMissionClient; |
| | | import com.xiaopeng.api.feignClient.operation.XpCruisePlanClient; |
| | | import com.xiaopeng.api.feignClient.order.XpCruiseOrderClient; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient; |
| | | import com.xiaopeng.api.model.maintenance.XpTaskRule; |
| | | import com.xiaopeng.api.model.order.XpCruiseOrder; |
| | | import com.xiaopeng.api.model.vehicleConvoy.XpVehicle; |
| | | import com.xiaopeng.api.vo.automaticPilot.VehiclePosition; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.maintenance.mapper.XpTaskRuleMapper; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | |
| | | |
| | | @Autowired |
| | | private XpVehicleClient xpVehicleClient; |
| | | |
| | | @Autowired |
| | | private XpCruiseOrderClient xpCruiseOrderClient; |
| | | |
| | | @Autowired |
| | | private MongoTemplate mongoTemplate; |
| | | |
| | | @Autowired |
| | | private OrderMissionClient orderMissionClient; |
| | | |
| | | @Autowired |
| | | private XpCruisePlanClient xpCruisePlanClient; |
| | | |
| | | /** |
| | | * 每分钟检查一次是否需要执行收车任务 |
| | |
| | | return result.getData().stream() |
| | | .filter(v -> v.getVehicleType() != null && v.getVehicleType() == 2) |
| | | .filter(v -> v.getOperatingStatus() != null && v.getOperatingStatus() == 1) |
| | | .filter(v -> v.getState() != null && v.getState() == 0) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | * 2. 更新车辆状态为"已收车" |
| | | * </p> |
| | | * |
| | | * @param vehicle 车辆信息 |
| | | * @param xpVehicle 车辆信息 |
| | | */ |
| | | private void sendCollectionCommand(XpVehicle vehicle) { |
| | | // TODO: 具体发送收车指令的实现 |
| | | log.info("向车辆[{}]发送收车指令", vehicle.getPlateNumber()); |
| | | private void sendCollectionCommand(XpVehicle xpVehicle) { |
| | | // 收车 关闭当前巡游单子 生成新的返程单子 找到收车站点 |
| | | R<String> r = xpCruiseOrderClient.updateCruiseOrder(xpVehicle.getVehicleVin()); |
| | | |
| | | // redis 获取当前最新经纬度位置 |
| | | VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(xpVehicle.getVehicleVin())), VehiclePosition.class); |
| | | XpCruiseOrder xpCruiseOrder = new XpCruiseOrder(); |
| | | if(vehiclePosition!=null){ |
| | | double x = vehiclePosition.getPoint().getX(); |
| | | double y = vehiclePosition.getPoint().getY(); |
| | | xpCruiseOrder.setStartLon(x); |
| | | xpCruiseOrder.setStartLat(y); |
| | | } |
| | | |
| | | xpCruiseOrder.setId("XU"+ IdUtil.fastUUID()); |
| | | xpCruiseOrder.setVehicleId(xpVehicle.getId()); |
| | | xpCruiseOrder.setFleetId(xpVehicle.getFleetId()); |
| | | xpCruiseOrder.setOrderType(2); |
| | | xpCruiseOrder.setStatus(1); |
| | | xpCruiseOrder.setOrderReverse(1); |
| | | xpCruiseOrder.setLastOrderId(r.getData()); |
| | | |
| | | // 找到收车站点 |
| | | R<XpCruiseOrder> returnCruisePoint = xpCruisePlanClient.findReturnCruisePoint(xpCruiseOrder); |
| | | if(returnCruisePoint!=null){ |
| | | xpCruiseOrderClient.addCruiseOrder(returnCruisePoint.getData()); |
| | | // 下发命令 |
| | | orderMissionClient.pushOrder(new PushOrderDto( xpCruiseOrder.getVehicleVin(),xpCruiseOrder.getId(),null)); |
| | | } |
| | | log.info("向车辆[{}]发送收车指令", xpVehicle.getPlateNumber()); |
| | | } |
| | | } |