| | |
| | | import com.xiaopeng.api.vo.automaticPilot.proto.down.cloudOrderOperation.OrderOperationType; |
| | | import com.xiaopeng.automaticPilot.util.XPUUtil; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.utils.SnowFlake; |
| | | import com.xiaopeng.common.redis.service.RedisService; |
| | | import io.swagger.annotations.Api; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | private final XPUUtil xpuUtil; |
| | | private final RedisService redisService; |
| | | private final XpVehicleClient xpVehicleClient; |
| | | private final Snowflake snowflake; |
| | | |
| | | public OrderMissionController(XPUUtil xpuUtil, RedisService redisService, XpVehicleClient xpVehicleClient, Snowflake snowflake) { |
| | | this.xpuUtil = xpuUtil; |
| | | this.redisService = redisService; |
| | | this.xpVehicleClient = xpVehicleClient; |
| | | this.snowflake = snowflake; |
| | | } |
| | | |
| | | @PostMapping("/inner/pushOrder") |
| | | public R<Boolean> pushOrder(@RequestBody PushOrderDto dto) { |
| | | RTTask task = new RTTask(); |
| | | //TODO 设置目标地点信息 |
| | | task.setOrder_id(dto.getOrderId().toString()); |
| | | task.setTask_id("MISSION_" + IdUtil.fastUUID()); |
| | | task.setTask_id("MISSION_"+ IdUtil.fastUUID()); |
| | | task.setTask_type(TaskType.ROBOTAXI); |
| | | task.setStatus(TaskStatus.PENDING); |
| | | long sequence = snowflake.nextId(); |
| | | MqttPublishDto mqttPublishDto = xpuUtil.cloudCreateOrder(task, dto.getVin(), sequence); |
| | | if (mqttPublishDto.getCode() == 200) { |
| | | xpVehicleClient.updateVehicleStatus(new UpdateVehicleStateDto(dto.getVin(), 1)); |
| | | SnowFlake snowFlake = new SnowFlake(0, 0); |
| | | snowFlake.withStartTimestamp(1420041600000L); |
| | | long sequence = snowFlake.nextId(); |
| | | MqttPublishDto mqttPublishDto = xpuUtil.cloudCreateOrder(task, dto.getVin(),sequence); |
| | | if (mqttPublishDto.getCode()== 200) { |
| | | // 修改车子为接单状态 |
| | | xpVehicleClient.updateVehicleStatus(new UpdateVehicleStateDto(dto.getVin(),1)); |
| | | |
| | | return R.ok(true); |
| | | } |
| | | return R.ok(false); |
| | |
| | | |
| | | @PostMapping("/inner/cancelOrder") |
| | | R<Boolean> cancelOrder(@RequestBody PushOrderDto dto) { |
| | | OrderOperation operation = new OrderOperation(); |
| | | operation.setOrder_id(dto.getOrderId().toString()); |
| | | operation.setTask_id("CANCEL_MISSION_" + IdUtil.fastUUID()); |
| | | operation.setOperation_type(dto.getOperation_type()); |
| | | long sequence = snowflake.nextId(); |
| | | xpuUtil.cloudOrderOperation(operation, dto.getVin(), sequence); |
| | | redisService.setCacheObject(String.valueOf(sequence), "cancelOrder_" + dto.getOrderId() + "_" + dto.getVin(), 30L, TimeUnit.MINUTES); |
| | | return R.ok(true); |
| | | OrderOperation operation = new OrderOperation(); |
| | | operation.setOrder_id(dto.getOrderId().toString()); |
| | | operation.setTask_id("CANCEL_MISSION_"+ IdUtil.fastUUID()); |
| | | operation.setOperation_type(dto.getOperation_type()); |
| | | SnowFlake snowFlake = new SnowFlake(0, 0); |
| | | snowFlake.withStartTimestamp(1420041600000L); |
| | | long sequence = snowFlake.nextId(); |
| | | xpuUtil.cloudOrderOperation(operation,dto.getVin(),sequence); |
| | | redisService.setCacheObject(String.valueOf(sequence),"cancelOrder_"+dto.getOrderId()+"_"+ dto.getVin(),30l, TimeUnit.MINUTES); |
| | | return R.ok(true); |
| | | } |
| | | } |