| | |
| | | |
| | | import cn.hutool.core.lang.Snowflake; |
| | | import cn.hutool.core.util.IdUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.xiaopeng.api.dto.map.OrderRouteAndFareDto; |
| | | import com.xiaopeng.api.dto.operation.CruisePointDto; |
| | | import com.xiaopeng.api.dto.operation.LonLatDto; |
| | | import com.xiaopeng.api.dto.operation.NewCruiseOrderDto; |
| | | import com.xiaopeng.api.feignClient.map.XpMapClient; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient; |
| | | import com.xiaopeng.api.model.operation.XpCruisePlan; |
| | | import com.xiaopeng.api.model.operation.XpCruisePlanPoint; |
| | | import com.xiaopeng.api.model.operation.XpCruisePlanVehicle; |
| | | import com.xiaopeng.api.model.operation.XpPoint; |
| | | import com.xiaopeng.api.model.operation.*; |
| | | import com.xiaopeng.api.model.order.XpCruiseOrder; |
| | | import com.xiaopeng.api.vo.operation.RouteVo; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.web.page.PageInfo; |
| | | import com.xiaopeng.common.log.annotation.AdminOperationLog; |
| | | import com.xiaopeng.common.log.enums.AdminBusinessType; |
| | | import com.xiaopeng.common.log.enums.AdminOperationType; |
| | | import com.xiaopeng.common.redis.service.RedisService; |
| | | import com.xiaopeng.operation.dto.XpCruisePlanAddDTO; |
| | | import com.xiaopeng.operation.dto.XpCruisePlanEditDTO; |
| | | import com.xiaopeng.operation.query.CruisePlanQuery; |
| | | import com.xiaopeng.operation.service.IXpCruisePlanPointService; |
| | | import com.xiaopeng.operation.service.IXpCruisePlanService; |
| | | import com.xiaopeng.operation.service.IXpCruisePlanVehicleService; |
| | | import com.xiaopeng.operation.service.XpPointService; |
| | | import com.xiaopeng.operation.service.*; |
| | | import com.xiaopeng.operation.vo.XpCruisePlanDetailVO; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | import com.xiaopeng.common.log.annotation.AdminOperationLog; |
| | | import com.xiaopeng.common.log.enums.AdminBusinessType; |
| | |
| | | private final IXpCruisePlanPointService xpCruisePlanPointService; |
| | | private final XpPointService pointService; |
| | | private final XpVehicleClient xpVehicleClient; |
| | | |
| | | @Resource |
| | | private XpTargetedServiceVehicleService xpTargetedServiceVehicleService; |
| | | |
| | | @Resource |
| | | private XpTargetedServiceService xpTargetedServiceService; |
| | | |
| | | @Resource |
| | | private XpMapClient xpMapClient; |
| | | |
| | | @Resource |
| | | private RedisService redisService; |
| | | |
| | | @Resource(name = "hutoolSnowflake") |
| | | private Snowflake snowflake; |
| | |
| | | public R<XpCruiseOrder> getCruisePoint(@RequestBody CruisePointDto dto) { |
| | | // 先找计划 |
| | | XpCruisePlanVehicle plan = xpCruisePlanVehicleService.getOne(new LambdaQueryWrapper<XpCruisePlanVehicle>().eq(XpCruisePlanVehicle::getVehicleId, dto.getVehicleId())); |
| | | Long cruisePlanId = null; |
| | | if (plan == null) { |
| | | return R.fail("没有找到对应的计划"); |
| | | //没有巡游计划,判断是否在定向服务里面 |
| | | List<XpTargetedService> targetedServices = xpTargetedServiceService.list(new QueryWrapper<XpTargetedService>().eq("status", 1)); |
| | | if(targetedServices.isEmpty()){ |
| | | return R.fail("没有巡游计划"); |
| | | } |
| | | List<Long> collect1 = targetedServices.stream().map(XpTargetedService::getId).collect(Collectors.toList()); |
| | | List<XpTargetedServiceVehicle> list = xpTargetedServiceVehicleService.list(new QueryWrapper<XpTargetedServiceVehicle>().in("targeted_service_id", collect1) |
| | | .eq("vehicle_id", dto.getVehicleId())); |
| | | if(list.isEmpty()){ |
| | | return R.fail("没有巡游计划"); |
| | | } |
| | | cruisePlanId = list.get(0).getCruisePlanId(); |
| | | }else{ |
| | | cruisePlanId = plan.getCruisePlanId(); |
| | | } |
| | | // 找对应的多个点位 |
| | | List<XpCruisePlanPoint> planPointList = xpCruisePlanPointService.list(new LambdaQueryWrapper<XpCruisePlanPoint>().eq(XpCruisePlanPoint::getCruisePlanId, plan.getCruisePlanId()).orderByAsc(XpCruisePlanPoint::getSortOrder)); |
| | | List<XpCruisePlanPoint> planPointList = xpCruisePlanPointService.list(new LambdaQueryWrapper<XpCruisePlanPoint>().eq(XpCruisePlanPoint::getCruisePlanId, cruisePlanId).orderByAsc(XpCruisePlanPoint::getSortOrder)); |
| | | // 找到现在这个点位 |
| | | // 根据dto的pointId 是第几个 |
| | | int index = 0; |
| | |
| | | newXpCruiseOrder.setEndLat(point.getPointLat()); |
| | | newXpCruiseOrder.setMissionId(xpCruisePlanPoint.getCruisePlanId()); |
| | | |
| | | |
| | | //获取巡游导航数据,如果无法获取到有效的导航,则继续用下一个点位作为终点 |
| | | LonLatDto destination = new LonLatDto(); |
| | | LonLatDto origin = new LonLatDto(); |
| | | boolean ROUTE_FLAG = false; |
| | | boolean start = false; |
| | | if(newXpCruiseOrder.getOrderReverse() == 1){ |
| | | for (XpCruisePlanPoint xpCruisePlanPoint1 : planPointList) { |
| | | if (start || xpCruisePlanPoint1.getPointId().equals(newXpCruiseOrder.getEndPointId())) { |
| | | start = true; |
| | | origin.setLongitude(newXpCruiseOrder.getStartLon()); |
| | | origin.setLatitude(newXpCruiseOrder.getStartLat()); |
| | | XpPoint xpPoint1 = pointService.getById(xpCruisePlanPoint1.getPointId()); |
| | | destination.setLongitude(xpPoint1.getPointLon()); |
| | | destination.setLatitude(xpPoint1.getPointLat()); |
| | | OrderRouteAndFareDto dto1 = new OrderRouteAndFareDto(); |
| | | dto1.setOrigin(origin); |
| | | dto1.setDestination(destination); |
| | | dto1.setRouteType(3); |
| | | R<RouteVo> routeVoR = xpMapClient.getOrderDistanceAndDuration(dto1); |
| | | if (200 != routeVoR.getCode()) { |
| | | continue; |
| | | } |
| | | RouteVo routeVo = routeVoR.getData(); |
| | | redisService.setCacheObject("CRUISE_ROUTE:" + newXpCruiseOrder.getVehicleId(), JSON.toJSONString(routeVo), 24L, TimeUnit.DAYS); |
| | | ROUTE_FLAG = true; |
| | | break; |
| | | } |
| | | } |
| | | }else{ |
| | | for (int i = planPointList.size() - 1; i >= 0; i--) { |
| | | XpCruisePlanPoint xpCruisePlanPoint1 = planPointList.get(i); |
| | | if(start || xpCruisePlanPoint1.getPointId().equals(newXpCruiseOrder.getEndPointId())){ |
| | | start = true; |
| | | origin.setLongitude(newXpCruiseOrder.getStartLon()); |
| | | origin.setLatitude(newXpCruiseOrder.getStartLat()); |
| | | XpPoint xpPoint1 = pointService.getById(xpCruisePlanPoint1.getPointId()); |
| | | destination.setLongitude(xpPoint1.getPointLon()); |
| | | destination.setLatitude(xpPoint1.getPointLat()); |
| | | OrderRouteAndFareDto dto1 = new OrderRouteAndFareDto(); |
| | | dto1.setOrigin(origin); |
| | | dto1.setDestination(destination); |
| | | dto1.setRouteType(3); |
| | | R<RouteVo> routeVoR = xpMapClient.getOrderDistanceAndDuration(dto1); |
| | | if (200 != routeVoR.getCode()) { |
| | | continue; |
| | | } |
| | | RouteVo routeVo = routeVoR.getData(); |
| | | redisService.setCacheObject("CRUISE_ROUTE:" + newXpCruiseOrder.getVehicleId(), JSON.toJSONString(routeVo), 24L, TimeUnit.DAYS); |
| | | ROUTE_FLAG = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if(!ROUTE_FLAG){ |
| | | return R.fail("巡游计划获取导航信息失败"); |
| | | } |
| | | return R.ok(newXpCruiseOrder); |
| | | } |
| | | |
| | |
| | | public R<List<XpCruisePlanPoint>> getCruisePlanPointList(@RequestParam Long vehicleId) { |
| | | // 先找计划 |
| | | XpCruisePlanVehicle plan = xpCruisePlanVehicleService.getOne(new LambdaQueryWrapper<XpCruisePlanVehicle>().eq(XpCruisePlanVehicle::getVehicleId, vehicleId)); |
| | | Long cruisePlanId = null; |
| | | if(null == plan){ |
| | | //没有巡游计划,判断是否在定向服务里面 |
| | | List<XpTargetedService> targetedServices = xpTargetedServiceService.list(new QueryWrapper<XpTargetedService>().eq("status", 1)); |
| | | if(targetedServices.isEmpty()){ |
| | | return R.fail("没有巡游计划,执行收车失败"); |
| | | } |
| | | List<Long> collect1 = targetedServices.stream().map(XpTargetedService::getId).collect(Collectors.toList()); |
| | | List<XpTargetedServiceVehicle> list = xpTargetedServiceVehicleService.list(new QueryWrapper<XpTargetedServiceVehicle>().in("targeted_service_id", collect1) |
| | | .eq("vehicle_id", vehicleId)); |
| | | if(list.isEmpty()){ |
| | | return R.fail("没有巡游计划,执行收车失败"); |
| | | } |
| | | cruisePlanId = list.get(0).getCruisePlanId(); |
| | | }else{ |
| | | cruisePlanId = plan.getCruisePlanId(); |
| | | } |
| | | |
| | | // 找对应的多个点位 |
| | | List<XpCruisePlanPoint> planPointList = xpCruisePlanPointService.list(new LambdaQueryWrapper<XpCruisePlanPoint>().eq(XpCruisePlanPoint::getCruisePlanId, plan.getCruisePlanId()).orderByAsc(XpCruisePlanPoint::getSortOrder)); |
| | | List<XpCruisePlanPoint> planPointList = xpCruisePlanPointService.list(new LambdaQueryWrapper<XpCruisePlanPoint>() |
| | | .eq(XpCruisePlanPoint::getCruisePlanId, cruisePlanId).orderByAsc(XpCruisePlanPoint::getSortOrder)); |
| | | return R.ok(planPointList); |
| | | } |
| | | |
| | |
| | | */ |
| | | @PostMapping("/logan/inner/cruise/getNewCruiseOrder") |
| | | public R<XpCruiseOrder> getNewCruiseOrder(@RequestBody NewCruiseOrderDto dto) { |
| | | |
| | | // 先找计划 |
| | | XpCruisePlanVehicle plan = xpCruisePlanVehicleService.getOne(new LambdaQueryWrapper<XpCruisePlanVehicle>().eq(XpCruisePlanVehicle::getVehicleId, dto.getVehicleId())); |
| | | if(null == plan){ |
| | | //没有巡游计划,判断是否在定向服务里面 |
| | | List<XpTargetedService> targetedServices = xpTargetedServiceService.list(new QueryWrapper<XpTargetedService>().eq("status", 1)); |
| | | if(targetedServices.isEmpty()){ |
| | | return R.ok(null); |
| | | } |
| | | List<Long> collect1 = targetedServices.stream().map(XpTargetedService::getId).collect(Collectors.toList()); |
| | | List<XpTargetedServiceVehicle> list = xpTargetedServiceVehicleService.list(new QueryWrapper<XpTargetedServiceVehicle>().in("targeted_service_id", collect1) |
| | | .eq("vehicle_id", dto.getVehicleId())); |
| | | if(list.isEmpty()){ |
| | | return R.ok(null); |
| | | } |
| | | plan = xpCruisePlanVehicleService.getOne(new LambdaQueryWrapper<XpCruisePlanVehicle>() |
| | | .eq(XpCruisePlanVehicle::getCruisePlanId, list.get(0).getCruisePlanId()).eq(XpCruisePlanVehicle::getVehicleId, dto.getVehicleId())); |
| | | } |
| | | // 找对应的多个点位 |
| | | List<XpCruisePlanPoint> planPointList = xpCruisePlanPointService.list(new LambdaQueryWrapper<XpCruisePlanPoint>().eq(XpCruisePlanPoint::getCruisePlanId, plan.getCruisePlanId()).orderByAsc(XpCruisePlanPoint::getSortOrder)); |
| | | |
| | | |
| | | |
| | | XpCruiseOrder newXpCruiseOrder = new XpCruiseOrder(); |
| | | newXpCruiseOrder.setFleetId(dto.getFleetId()); |
| | |
| | | newXpCruiseOrder.setEndLon(endPoint.getPointLon()); |
| | | newXpCruiseOrder.setEndLat(endPoint.getPointLat()); |
| | | |
| | | //获取巡游导航数据,如果无法获取到有效的导航,则继续用下一个点位作为终点 |
| | | LonLatDto destination = new LonLatDto(); |
| | | LonLatDto origin = new LonLatDto(); |
| | | boolean ROUTE_FLAG = false; |
| | | boolean start = false; |
| | | if(newXpCruiseOrder.getOrderReverse() == 1){ |
| | | for (XpCruisePlanPoint xpCruisePlanPoint1 : planPointList) { |
| | | if (start || xpCruisePlanPoint1.getPointId().equals(newXpCruiseOrder.getEndPointId())) { |
| | | start = true; |
| | | origin.setLongitude(newXpCruiseOrder.getStartLon()); |
| | | origin.setLatitude(newXpCruiseOrder.getStartLat()); |
| | | XpPoint xpPoint1 = pointService.getById(xpCruisePlanPoint1.getPointId()); |
| | | destination.setLongitude(xpPoint1.getPointLon()); |
| | | destination.setLatitude(xpPoint1.getPointLat()); |
| | | OrderRouteAndFareDto dto1 = new OrderRouteAndFareDto(); |
| | | dto1.setOrigin(origin); |
| | | dto1.setDestination(destination); |
| | | dto1.setRouteType(3); |
| | | R<RouteVo> routeVoR = xpMapClient.getOrderDistanceAndDuration(dto1); |
| | | if (200 != routeVoR.getCode()) { |
| | | continue; |
| | | } |
| | | RouteVo routeVo = routeVoR.getData(); |
| | | redisService.setCacheObject("CRUISE_ROUTE:" + newXpCruiseOrder.getVehicleId(), JSON.toJSONString(routeVo), 24L, TimeUnit.DAYS); |
| | | ROUTE_FLAG = true; |
| | | break; |
| | | } |
| | | } |
| | | }else{ |
| | | for (int i = planPointList.size() - 1; i >= 0; i--) { |
| | | XpCruisePlanPoint xpCruisePlanPoint1 = planPointList.get(i); |
| | | if(start || xpCruisePlanPoint1.getPointId().equals(newXpCruiseOrder.getEndPointId())){ |
| | | start = true; |
| | | origin.setLongitude(newXpCruiseOrder.getStartLon()); |
| | | origin.setLatitude(newXpCruiseOrder.getStartLat()); |
| | | XpPoint xpPoint1 = pointService.getById(xpCruisePlanPoint1.getPointId()); |
| | | destination.setLongitude(xpPoint1.getPointLon()); |
| | | destination.setLatitude(xpPoint1.getPointLat()); |
| | | OrderRouteAndFareDto dto1 = new OrderRouteAndFareDto(); |
| | | dto1.setOrigin(origin); |
| | | dto1.setDestination(destination); |
| | | dto1.setRouteType(3); |
| | | R<RouteVo> routeVoR = xpMapClient.getOrderDistanceAndDuration(dto1); |
| | | if (200 != routeVoR.getCode()) { |
| | | continue; |
| | | } |
| | | RouteVo routeVo = routeVoR.getData(); |
| | | redisService.setCacheObject("CRUISE_ROUTE:" + newXpCruiseOrder.getVehicleId(), JSON.toJSONString(routeVo), 24L, TimeUnit.DAYS); |
| | | ROUTE_FLAG = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if(!ROUTE_FLAG){ |
| | | return R.fail("巡游计划获取导航信息失败"); |
| | | } |
| | | |
| | | |
| | | return R.ok(newXpCruiseOrder); |
| | |
| | | // 先找计划 |
| | | XpCruisePlanVehicle plan = xpCruisePlanVehicleService.getOne(new LambdaQueryWrapper<XpCruisePlanVehicle>().eq(XpCruisePlanVehicle::getVehicleId, xpCruiseOrder.getVehicleId())); |
| | | if(null == plan){ |
| | | return R.fail("没有巡游计划,执行收车失败"); |
| | | //没有巡游计划,判断是否在定向服务里面 |
| | | List<XpTargetedService> targetedServices = xpTargetedServiceService.list(new QueryWrapper<XpTargetedService>().eq("status", 1)); |
| | | if(targetedServices.isEmpty()){ |
| | | return R.fail("没有巡游计划,执行收车失败"); |
| | | } |
| | | List<Long> collect1 = targetedServices.stream().map(XpTargetedService::getId).collect(Collectors.toList()); |
| | | List<XpTargetedServiceVehicle> list = xpTargetedServiceVehicleService.list(new QueryWrapper<XpTargetedServiceVehicle>().in("targeted_service_id", collect1) |
| | | .eq("vehicle_id", xpCruiseOrder.getVehicleId())); |
| | | if(list.isEmpty()){ |
| | | return R.fail("没有巡游计划,执行收车失败"); |
| | | } |
| | | plan = xpCruisePlanVehicleService.getOne(new LambdaQueryWrapper<XpCruisePlanVehicle>() |
| | | .eq(XpCruisePlanVehicle::getCruisePlanId, list.get(0).getCruisePlanId()).eq(XpCruisePlanVehicle::getVehicleId, xpCruiseOrder.getVehicleId())); |
| | | } |
| | | // 找对应的多个点位 |
| | | List<XpCruisePlanPoint> planPointList = xpCruisePlanPointService.list(new LambdaQueryWrapper<XpCruisePlanPoint>().eq(XpCruisePlanPoint::getCruisePlanId, plan.getCruisePlanId()).orderByAsc(XpCruisePlanPoint::getSortOrder)); |
| | |
| | | xpCruiseOrder.setEndLon(xpPoint.getPointLon()); |
| | | xpCruiseOrder.setEndLat(xpPoint.getPointLat()); |
| | | xpCruiseOrder.setMissionId(plan.getCruisePlanId()); |
| | | |
| | | //获取巡游导航数据,如果无法获取到有效的导航,则继续用下一个点位作为终点 |
| | | LonLatDto destination = new LonLatDto(); |
| | | LonLatDto origin = new LonLatDto(); |
| | | boolean ROUTE_FLAG = false; |
| | | boolean start = false; |
| | | if(xpCruiseOrder.getOrderReverse() == 1){ |
| | | for (XpCruisePlanPoint xpCruisePlanPoint1 : planPointList) { |
| | | if (start || xpCruisePlanPoint1.getPointId().equals(xpCruiseOrder.getEndPointId())) { |
| | | start = true; |
| | | origin.setLongitude(xpCruiseOrder.getStartLon()); |
| | | origin.setLatitude(xpCruiseOrder.getStartLat()); |
| | | XpPoint xpPoint1 = pointService.getById(xpCruisePlanPoint1.getPointId()); |
| | | destination.setLongitude(xpPoint1.getPointLon()); |
| | | destination.setLatitude(xpPoint1.getPointLat()); |
| | | OrderRouteAndFareDto dto1 = new OrderRouteAndFareDto(); |
| | | dto1.setOrigin(origin); |
| | | dto1.setDestination(destination); |
| | | dto1.setRouteType(3); |
| | | R<RouteVo> routeVoR = xpMapClient.getOrderDistanceAndDuration(dto1); |
| | | if (200 != routeVoR.getCode()) { |
| | | continue; |
| | | } |
| | | RouteVo routeVo = routeVoR.getData(); |
| | | redisService.setCacheObject("CRUISE_ROUTE:" + xpCruiseOrder.getVehicleId(), JSON.toJSONString(routeVo), 24L, TimeUnit.DAYS); |
| | | ROUTE_FLAG = true; |
| | | break; |
| | | } |
| | | } |
| | | }else{ |
| | | for (int i = planPointList.size() - 1; i >= 0; i--) { |
| | | XpCruisePlanPoint xpCruisePlanPoint1 = planPointList.get(i); |
| | | if(start || xpCruisePlanPoint1.getPointId().equals(xpCruiseOrder.getEndPointId())){ |
| | | start = true; |
| | | origin.setLongitude(xpCruiseOrder.getStartLon()); |
| | | origin.setLatitude(xpCruiseOrder.getStartLat()); |
| | | XpPoint xpPoint1 = pointService.getById(xpCruisePlanPoint1.getPointId()); |
| | | destination.setLongitude(xpPoint1.getPointLon()); |
| | | destination.setLatitude(xpPoint1.getPointLat()); |
| | | OrderRouteAndFareDto dto1 = new OrderRouteAndFareDto(); |
| | | dto1.setOrigin(origin); |
| | | dto1.setDestination(destination); |
| | | dto1.setRouteType(3); |
| | | R<RouteVo> routeVoR = xpMapClient.getOrderDistanceAndDuration(dto1); |
| | | if (200 != routeVoR.getCode()) { |
| | | continue; |
| | | } |
| | | RouteVo routeVo = routeVoR.getData(); |
| | | redisService.setCacheObject("CRUISE_ROUTE:" + xpCruiseOrder.getVehicleId(), JSON.toJSONString(routeVo), 24L, TimeUnit.DAYS); |
| | | ROUTE_FLAG = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if(!ROUTE_FLAG){ |
| | | return R.fail("巡游计划获取导航信息失败"); |
| | | } |
| | | return R.ok(xpCruiseOrder); |
| | | } |
| | | |