| | |
| | | package com.xiaopeng.order.controller; |
| | | |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.xiaopeng.api.dto.account.UcUserInfo; |
| | | import com.xiaopeng.api.dto.vehicleConvoy.ServiceVehicleListDto; |
| | | import com.xiaopeng.api.feignClient.account.UserResourcesClient; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient; |
| | | import com.xiaopeng.api.model.map.XpGeoFencingPolygon; |
| | | import com.xiaopeng.api.model.order.XpOrder; |
| | | import com.xiaopeng.api.model.vehicleConvoy.XpVehicle; |
| | | import com.xiaopeng.api.vo.automaticPilot.AppUserPosition; |
| | | import com.xiaopeng.api.vo.automaticPilot.VehiclePosition; |
| | | import com.xiaopeng.api.vo.vehicleConvoy.VehicleDoorStatusVo; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.utils.StringUtils; |
| | | import com.xiaopeng.order.dto.UserOrderListDto; |
| | | import com.xiaopeng.order.mangodb.model.OrderTrajectory; |
| | | import com.xiaopeng.api.model.order.OrderTrajectory; |
| | | import com.xiaopeng.order.service.IXpOrderService; |
| | | import com.xiaopeng.order.vo.*; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.data.mongodb.core.geo.GeoJsonPoint; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | return R.ok(); |
| | | } |
| | | AppUserLocationVo vo = new AppUserLocationVo(); |
| | | AppUserPosition userPosition = mongoTemplate.findOne(Query.query(Criteria.where("appUserId").is(xpOrder.getAppUserId())), AppUserPosition.class); |
| | | if(null != userPosition){ |
| | | vo.setPassengerLng(userPosition.getPoint().getX()); |
| | | vo.setPassengerLat(userPosition.getPoint().getY()); |
| | | return R.ok(vo); |
| | | } |
| | | return R.ok(); |
| | | vo.setPassengerLng(104.5165135); |
| | | vo.setPassengerLat(30.2566515); |
| | | return R.ok(vo); |
| | | // TODO 后期放开,临时mock |
| | | // AppUserPosition userPosition = mongoTemplate.findOne(Query.query(Criteria.where("appUserId").is(xpOrder.getAppUserId())), AppUserPosition.class); |
| | | // if(null != userPosition){ |
| | | // vo.setPassengerLng(userPosition.getPoint().getX()); |
| | | // vo.setPassengerLat(userPosition.getPoint().getY()); |
| | | // return R.ok(vo); |
| | | // } |
| | | // return R.ok(); |
| | | } |
| | | |
| | | |
| | |
| | | if(null == xpOrder){ |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | return R.ok(); |
| | | // TODO 后期放开,临时mock |
| | | // R<VehicleDoorStatusVo> vehicleDoorStatus = xpVehicleClient.getVehicleDoorStatus(orderId); |
| | | // if(200 != vehicleDoorStatus.getCode()){ |
| | | // return R.fail(vehicleDoorStatus.getMsg()); |
| | | // } |
| | | // VehicleDoorStatusVo data = vehicleDoorStatus.getData(); |
| | | VehicleSeatStatusVo vo = new VehicleSeatStatusVo(); |
| | | //主驾 |
| | | VehicleSeatStatus frontLeft = new VehicleSeatStatus(); |
| | | // frontLeft.setSeatOccupied(data.getDriverSeatState() + ""); |
| | | // frontLeft.setSeatbeltFastened(data.getDrvSeatBeltBuckleSt() + ""); |
| | | frontLeft.setSeatOccupied("0"); |
| | | frontLeft.setSeatbeltFastened("0"); |
| | | vo.setFrontLeft(frontLeft); |
| | | //副驾 |
| | | VehicleSeatStatus frontRight = new VehicleSeatStatus(); |
| | | // frontRight.setSeatOccupied(data.getPsngrSeatOccupancyStatus() + ""); |
| | | // frontRight.setSeatbeltFastened(data.getPsngrSeatBeltBuckleSt() + ""); |
| | | frontRight.setSeatOccupied("1"); |
| | | frontRight.setSeatbeltFastened("0"); |
| | | vo.setFrontRight(frontRight); |
| | | //左后 |
| | | VehicleSeatStatus rearLeft = new VehicleSeatStatus(); |
| | | // rearLeft.setSeatOccupied(data.getSecRowLeftSeatOccupancyStatus() + ""); |
| | | // rearLeft.setSeatbeltFastened(data.getSecRowLtSeatBeltBuckleSt() + ""); |
| | | rearLeft.setSeatOccupied("1"); |
| | | rearLeft.setSeatbeltFastened("1"); |
| | | vo.setRearLeft(rearLeft); |
| | | //右后 |
| | | VehicleSeatStatus rearRight = new VehicleSeatStatus(); |
| | | // rearRight.setSeatOccupied(data.getSecRowRightSeatOccupancyStatus() + ""); |
| | | // rearRight.setSeatbeltFastened(data.getSecRowRtSeatBeltBuckleSt() + ""); |
| | | rearRight.setSeatOccupied("0"); |
| | | rearRight.setSeatbeltFastened("0"); |
| | | vo.setRearRight(rearRight); |
| | | return R.ok(vo); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | /** |
| | | * 10. 根据 VIN 查询剩余电量及预估续航 |
| | | * @param vin |
| | | * @return |
| | | */ |
| | | @GetMapping("/getVehicleRange/{vin}") |
| | | @ApiOperation(value = "根据 VIN 查询剩余电量及预估续航", notes = "客服系统对接") |
| | | @ApiImplicitParam(name = "vin", value = "vin码", required = true, dataType = "string", paramType = "path") |
| | | public R<VehicleRangeVo> getVehicleRange(@PathVariable String vin){ |
| | | VehiclePosition vehiclePositions = mongoTemplate.findOne(Query.query(Criteria.where("vin").is(vin)), VehiclePosition.class); |
| | | if(null == vehiclePositions){ |
| | | return R.ok(); |
| | | } |
| | | @GetMapping("/getVehicleRange/{orderId}") |
| | | @ApiOperation(value = "根据 订单id 查询剩余电量及预估续航", notes = "客服系统对接") |
| | | @ApiImplicitParam(name = "orderId", value = "订单id", required = true, dataType = "string", paramType = "path") |
| | | public R<VehicleRangeVo> getVehicleRange(@PathVariable String orderId){ |
| | | XpOrder xpOrder = xpOrderService.getById(orderId); |
| | | VehicleRangeVo vo = new VehicleRangeVo(); |
| | | vo.setBatteryLevel(vehiclePositions.getCurrentElectricity()); |
| | | vo.setEstimatedRange(Double.valueOf(vehiclePositions.getMileageRange())); |
| | | // TODO 后期放开,临时mock |
| | | // if(null != xpOrder.getVehicleId()){ |
| | | // XpVehicle xpVehicle = xpVehicleClient.queryById(xpOrder.getVehicleId()).getData(); |
| | | // VehiclePosition vehiclePositions = mongoTemplate.findOne(Query.query(Criteria.where("vin").is(xpVehicle.getVehicleVin())), VehiclePosition.class); |
| | | // if(null == vehiclePositions){ |
| | | // return R.ok(); |
| | | // } |
| | | // vo.setBatteryLevel(vehiclePositions.getCurrentElectricity()); |
| | | // vo.setEstimatedRange(Double.valueOf(vehiclePositions.getMileageRange())); |
| | | // } |
| | | vo.setBatteryLevel(85); |
| | | vo.setEstimatedRange(580D); |
| | | return R.ok(vo); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "根据 订单查询四门三盖状态", notes = "客服系统对接") |
| | | @ApiImplicitParam(name = "orderId", value = "订单ID", required = true, dataType = "Long", paramType = "path") |
| | | public R<VehicleDoorStatusVo> getVehicleDoorStatus(@PathVariable Long orderId){ |
| | | VehicleDoorStatusVo data = xpVehicleClient.getVehicleDoorStatus(orderId).getData(); |
| | | // VehicleDoorStatusVo data = xpVehicleClient.getVehicleDoorStatus(orderId).getData(); |
| | | // TODO 后期放开,临时mock |
| | | VehicleDoorStatusVo data = new VehicleDoorStatusVo(); |
| | | data.setFrontLeftDoor(0); |
| | | data.setFrontRightDoor(0); |
| | | data.setRearLeftDoor(0); |
| | | data.setRearRightDoor(0); |
| | | data.setTrunk(1); |
| | | data.setFrunk(1); |
| | | data.setHvacOn(0); |
| | | data.setHvacInnerTempFloat(28.5); |
| | | data.setHvacTempFloat(29.5); |
| | | data.setRearLeftHvacTempFloat(29.5); |
| | | data.setPassengerHvacTempFloat(29.5); |
| | | data.setDriverSeatState(1); |
| | | data.setPsngrSeatOccupancyStatus(0); |
| | | data.setSecRowLeftSeatOccupancyStatus(0); |
| | | data.setSecRowMidSeatOccupancyStatus(0); |
| | | data.setSecRowRightSeatOccupancyStatus(0); |
| | | data.setThirdRowLeftSeatOccupancyStatus(1); |
| | | data.setThirdRowMidSeatOccupancyStatus(0); |
| | | data.setThirdRowRightSeatOccupancyStatus(0); |
| | | data.setDrvSeatBeltBuckleSt(1); |
| | | data.setPsngrSeatBeltBuckleSt(0); |
| | | data.setSecRowLtSeatBeltBuckleSt(0); |
| | | data.setSecRowMidSeatBeltBuckleSt(0); |
| | | data.setSecRowRtSeatBeltBuckleSt(0); |
| | | data.setTrdRowLtSeatBeltBuckleSt(0); |
| | | data.setTrdRowMidSeatBeltBuckleSt(0); |
| | | data.setTrdRowRtSeatBeltBuckleSt(0); |
| | | data.setSlowChargePortStatus(2); |
| | | data.setFastChargePortStatus(2); |
| | | return R.ok(data); |
| | | } |
| | | |
| | |
| | | return R.ok(); |
| | | } |
| | | VehicleFenceInformationVo vo = new VehicleFenceInformationVo(); |
| | | vo.setVehicleLng(vehiclePositions.getPoint().getX()); |
| | | vo.setVehicleLat(vehiclePositions.getPoint().getY()); |
| | | XpGeoFencingPolygon fencingPolygon = mongoTemplate.findOne(Query.query(Criteria.where("areaId").is(xpOrder.getXpElectronicFenceAreaId())), XpGeoFencingPolygon.class); |
| | | List<FenceVo> collect = fencingPolygon.getPoints().getPoints().stream().map(point -> { |
| | | // TODO 后期放开,临时mock |
| | | // vo.setVehicleLng(vehiclePositions.getPoint().getX()); |
| | | // vo.setVehicleLat(vehiclePositions.getPoint().getY()); |
| | | vo.setVehicleLng(104.5313); |
| | | vo.setVehicleLat(30.26335); |
| | | // XpGeoFencingPolygon fencingPolygon = mongoTemplate.findOne(Query.query(Criteria.where("areaId").is(xpOrder.getXpElectronicFenceAreaId())), XpGeoFencingPolygon.class); |
| | | // List<FenceVo> collect = fencingPolygon.getPoints().getPoints().stream().map(point -> { |
| | | // FenceVo fenceVo = new FenceVo(); |
| | | // fenceVo.setLng(point.getX()); |
| | | // fenceVo.setLat(point.getY()); |
| | | // return fenceVo; |
| | | // }).collect(Collectors.toList()); |
| | | List<FenceVo> collect = new ArrayList<FenceVo>(){{ |
| | | FenceVo fenceVo = new FenceVo(); |
| | | fenceVo.setLng(point.getX()); |
| | | fenceVo.setLat(point.getY()); |
| | | return fenceVo; |
| | | }).collect(Collectors.toList()); |
| | | fenceVo.setLng(104.5313); |
| | | fenceVo.setLat(30.26335); |
| | | add(fenceVo); |
| | | fenceVo = new FenceVo(); |
| | | fenceVo.setLng(104.5323); |
| | | fenceVo.setLat(30.26325); |
| | | add(fenceVo); |
| | | fenceVo = new FenceVo(); |
| | | fenceVo.setLng(104.5353); |
| | | fenceVo.setLat(30.26365); |
| | | add(fenceVo); |
| | | fenceVo = new FenceVo(); |
| | | fenceVo.setLng(104.5343); |
| | | fenceVo.setLat(30.26375); |
| | | add(fenceVo); |
| | | fenceVo = new FenceVo(); |
| | | fenceVo.setLng(104.5373); |
| | | fenceVo.setLat(30.26395); |
| | | add(fenceVo); |
| | | fenceVo = new FenceVo(); |
| | | fenceVo.setLng(104.5323); |
| | | fenceVo.setLat(30.26375); |
| | | add(fenceVo); |
| | | fenceVo = new FenceVo(); |
| | | fenceVo.setLng(104.5343); |
| | | fenceVo.setLat(30.26345); |
| | | add(fenceVo); |
| | | }}; |
| | | vo.setGeofenceBoundary(collect); |
| | | |
| | | GeoJsonPoint point = new GeoJsonPoint(vehiclePositions.getPoint().getX(), vehiclePositions.getPoint().getY()); |
| | | List<XpGeoFencingPolygon> polygon = mongoTemplate.find(Query.query(Criteria.where("points").intersects(point)), XpGeoFencingPolygon.class); |
| | | Set<String> collect1 = polygon.stream().map(XpGeoFencingPolygon::getAreaId).collect(Collectors.toSet()); |
| | | vo.setIsOutOfGeofence(collect1.contains(xpOrder.getXpElectronicFenceAreaId())); |
| | | // GeoJsonPoint point = new GeoJsonPoint(vehiclePositions.getPoint().getX(), vehiclePositions.getPoint().getY()); |
| | | // List<XpGeoFencingPolygon> polygon = mongoTemplate.find(Query.query(Criteria.where("points").intersects(point)), XpGeoFencingPolygon.class); |
| | | // Set<String> collect1 = polygon.stream().map(XpGeoFencingPolygon::getAreaId).collect(Collectors.toSet()); |
| | | // vo.setIsOutOfGeofence(collect1.contains(xpOrder.getXpElectronicFenceAreaId())); |
| | | vo.setIsOutOfGeofence(false); |
| | | return R.ok(vo); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "根据订单号查询订单日志", notes = "客服系统对接") |
| | | @ApiImplicitParam(name = "orderId", value = "订单ID", required = true, dataType = "Long", paramType = "path") |
| | | public R<UserOrderInfoVo> getOrderInfo(@PathVariable Long orderId){ |
| | | return R.ok(new UserOrderInfoVo()); |
| | | UserOrderInfoVo orderHistoryInfo = xpOrderService.getOrderHistoryInfo(orderId); |
| | | return R.ok(orderHistoryInfo); |
| | | } |
| | | } |