Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/Robotaxi
# Conflicts:
# xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/impl/XpPointServiceImpl.java
| | |
| | | return R.ok(count); |
| | | } |
| | | |
| | | @PostMapping("/api/v1/notification/read") |
| | | @GetMapping("/api/v1/notification/read") |
| | | @ApiOperation(value = "操作已读", tags = "运维APP-消息通知") |
| | | public R<?> readNotification(@RequestParam Long notificationId){ |
| | | notificationService.lambdaUpdate().set(XpOperationsUserNotification::getReadStatus, 1).eq(XpOperationsUserNotification::getId, notificationId).update(); |
| | |
| | | import com.xiaopeng.api.feignClient.operation.XpElectronicClient; |
| | | import com.xiaopeng.api.feignClient.operation.XpOpenCityClient; |
| | | import com.xiaopeng.api.model.operation.XpElectronicFence; |
| | | import com.xiaopeng.api.model.operation.XpOpenCity; |
| | | import com.xiaopeng.api.query.operation.ElectronicPageListQuery; |
| | | import com.xiaopeng.api.vo.operation.ElectronicFenceDetailVo; |
| | | import com.xiaopeng.common.core.domain.R; |
| | |
| | | log.error("获取开通城市列表失败"); |
| | | return R.ok(new ArrayList<>()); |
| | | } |
| | | |
| | | @Override |
| | | public R<XpOpenCity> getXpOpenCity(String provinceCode, String cityCode, String districtCode) { |
| | | log.error("获取开通城市失败"); |
| | | return R.fail("获取开通城市失败"); |
| | | } |
| | | }; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.xiaopeng.api.factory.operation; |
| | | |
| | | |
| | | import com.xiaopeng.api.feignClient.operation.XpRoutePlanClient; |
| | | import com.xiaopeng.api.feignClient.operation.XpTestPlanClient; |
| | | import com.xiaopeng.api.model.operation.XpRoutePlan; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | @Slf4j |
| | | @Component |
| | | public class XpRoutePlanClientFallbackFactory implements FallbackFactory<XpRoutePlanClient> { |
| | | @Override |
| | | public XpRoutePlanClient create(Throwable cause) { |
| | | return new XpRoutePlanClient() { |
| | | @Override |
| | | public R<XpRoutePlan> getXpRoutePlanOpenCityId(Long openCityId) { |
| | | log.error("根据openCityId获取路线规划配置失败:{}", cause.getMessage()); |
| | | return R.fail("根据openCityId获取路线规划配置失败"); |
| | | } |
| | | }; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.xiaopeng.api.factory.operation; |
| | | |
| | | import com.xiaopeng.api.feignClient.operation.XpTestPlanClient; |
| | | import com.xiaopeng.api.model.operation.XpTestPlan; |
| | | import com.xiaopeng.api.model.operation.XpTestPlanPoint; |
| | | import com.xiaopeng.api.model.operation.XpTestPlanVehicle; |
| | | import com.xiaopeng.api.model.operation.XpTestPoint; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | @Component |
| | | public class XpTestPlanClientFallbackFactory implements FallbackFactory<XpTestPlanClient> { |
| | | @Override |
| | | public XpTestPlanClient create(Throwable cause) { |
| | | return new XpTestPlanClient() { |
| | | |
| | | |
| | | @Override |
| | | public R<XpTestPlan> getXpTestPlanById(Long id) { |
| | | log.error("获取测试计划失败:{}", cause.getMessage()); |
| | | return R.fail("获取测试计划失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<XpTestPlanPoint> getXpTestPlanPointById(Long id) { |
| | | log.error("获取测试计划点失败:{}", cause.getMessage()); |
| | | return R.fail("获取测试计划点失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<XpTestPoint> getXpTestPointById(Long id) { |
| | | log.error("获取测试计划点位失败:{}", cause.getMessage()); |
| | | return R.fail("获取测试计划点位失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<List<XpTestPlanVehicle>> getXpTestPlanVehicleByTestPlanId(Long testPlanId) { |
| | | log.error("获取测试计划车辆失败:{}", cause.getMessage()); |
| | | return R.fail("获取测试计划车辆失败"); |
| | | } |
| | | }; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.xiaopeng.api.factory.operation; |
| | | |
| | | import com.xiaopeng.api.dto.map.XpPointExportExcelQuery; |
| | | import com.xiaopeng.api.dto.operation.PointAddDto; |
| | | import com.xiaopeng.api.dto.operation.PointMapQuery; |
| | | import com.xiaopeng.api.dto.operation.PointUpdateDto; |
| | | import com.xiaopeng.api.dto.operation.XpPointEnableDisableDto; |
| | | import com.xiaopeng.api.dto.order.HistoryEndPointsDto; |
| | | import com.xiaopeng.api.dto.order.HistoryStartPointsDto; |
| | | import com.xiaopeng.api.feignClient.operation.XpPointClient; |
| | | import com.xiaopeng.api.feignClient.operation.XpTestPointClient; |
| | | import com.xiaopeng.api.model.operation.XpElectronicFenceArea; |
| | | import com.xiaopeng.api.model.operation.XpTestPoint; |
| | | import com.xiaopeng.api.query.operation.PointListQuery; |
| | | import com.xiaopeng.api.query.operation.PointPageListListQuery; |
| | | import com.xiaopeng.api.vo.order.XpHistoryEndPointsVo; |
| | | import com.xiaopeng.api.vo.order.XpHistoryStartPointsVo; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.web.page.PageInfo; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | @Slf4j |
| | | @Component |
| | | public class XpTestPointClientFallbackFactory implements FallbackFactory<XpTestPointClient> { |
| | | @Override |
| | | public XpTestPointClient create(Throwable cause) { |
| | | return new XpTestPointClient() { |
| | | |
| | | @Override |
| | | public R<XpTestPoint> queryById(Long id) { |
| | | log.error("获取点位详情失败:{}", cause.getMessage()); |
| | | return R.fail("获取点位详情失败"); |
| | | } |
| | | @Override |
| | | public R<Boolean> nowInTimePoint(Long pointId) { |
| | | log.error("判断点位是在有效期内失败:{}", cause.getMessage()); |
| | | return R.fail("判断点位是在有效期内失败"); |
| | | } |
| | | }; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.xiaopeng.api.factory.order; |
| | | |
| | | |
| | | import com.xiaopeng.api.feignClient.order.XpTestOrderClient; |
| | | import com.xiaopeng.api.model.order.XpTestOrder; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | @Slf4j |
| | | @Component |
| | | public class XpTestOrderClientFallbackFactory implements FallbackFactory<XpTestOrderClient> { |
| | | @Override |
| | | public XpTestOrderClient create(Throwable cause) { |
| | | return new XpTestOrderClient(){ |
| | | |
| | | |
| | | @Override |
| | | public R<XpTestOrder> queryOrderById(Long orderId) { |
| | | log.error("通过订单id查询订单信息失败:{}", cause.getMessage()); |
| | | return R.fail("通过订单id查询订单信息失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<String> updateOrderStatus(Long orderId, Integer status) { |
| | | log.error("更新订单状态失败:{}", cause.getMessage()); |
| | | return R.fail("更新订单状态失败"); |
| | | } |
| | | }; |
| | | } |
| | | } |
| | |
| | | * @param dto |
| | | * @return |
| | | */ |
| | | @PostMapping("/base/v1/mini-program/map/getDistanceAndDuration") |
| | | @PostMapping("/base/v1/map/getDistanceAndDuration") |
| | | R<RouteVo> getDistanceAndDuration(@RequestBody RouteAndFareDto dto); |
| | | |
| | | /** |
| | |
| | | * @param dto |
| | | * @return |
| | | */ |
| | | @PostMapping("/base/v1/mini-program/map/getOrderDistanceAndDuration") |
| | | @PostMapping("/base/v1/map/getOrderDistanceAndDuration") |
| | | R<RouteVo> getOrderDistanceAndDuration(@RequestBody OrderRouteAndFareDto dto); |
| | | |
| | | |
| | |
| | | * @param routedID |
| | | * @return |
| | | */ |
| | | @PostMapping("/base/v1/mini-program/map/queryRouted") |
| | | @PostMapping("/base/v1/map/queryRouted") |
| | | R<String> queryRouted(@RequestParam("routedID") String routedID); |
| | | |
| | | |
| | |
| | | * @param dto |
| | | * @return |
| | | */ |
| | | @PostMapping("/base/v1/mini-program/fence/diagnosisArea") |
| | | @PostMapping("/base/v1/fence/diagnosisArea") |
| | | R<Boolean> diagnosisArea(@RequestBody RouteAndFareDto dto); |
| | | |
| | | |
| | |
| | | package com.xiaopeng.api.feignClient.operation; |
| | | |
| | | import com.xiaopeng.api.factory.operation.XpOpenCityClientFallbackFactory; |
| | | import com.xiaopeng.api.model.operation.XpOpenCity; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.dto.ServiceNameConstantsEnum; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.List; |
| | |
| | | @FeignClient(contextId = "XpOpenCityClient", value = ServiceNameConstantsEnum.XP_OPERATION_SERVICE, fallbackFactory = XpOpenCityClientFallbackFactory.class) |
| | | public interface XpOpenCityClient { |
| | | |
| | | @GetMapping("/base/v1/mini-program/api/v1/openCity/nameList") |
| | | |
| | | |
| | | @GetMapping("/base/v1/openCity/nameList") |
| | | R<List<String>> pageList(@RequestParam String cityIds); |
| | | |
| | | |
| | | /** |
| | | * 根据省市区获取开通城市数据 |
| | | * @param provinceCode |
| | | * @param cityCode |
| | | * @param districtCode |
| | | * @return |
| | | */ |
| | | @PostMapping("/inner/v1/openCity/getXpOpenCity") |
| | | R<XpOpenCity> getXpOpenCity(@RequestParam("provinceCode") String provinceCode, |
| | | @RequestParam("cityCode") String cityCode, |
| | | @RequestParam("districtCode") String districtCode); |
| | | } |
| | |
| | | public interface XpPointClient { |
| | | |
| | | |
| | | @PostMapping("/base/v1/mini-program/xp-point/getHistoryStartPoints") |
| | | @PostMapping("/base/v1/xp-point/getHistoryStartPoints") |
| | | R<List<XpHistoryStartPointsVo>> getHistoryStartPoints(@RequestBody HistoryStartPointsDto historyStartPointsDto); |
| | | |
| | | @PostMapping("/base/v1/mini-program/xp-point/getHistoryEndPoints") |
| | | @PostMapping("/base/v1/xp-point/getHistoryEndPoints") |
| | | R<List<XpHistoryEndPointsVo>> getHistoryEndPoints(@RequestBody HistoryEndPointsDto historyEndPointsDto); |
| | | |
| | | |
| | |
| | | R<List<XpPoint>> pointMap(@RequestBody PointMapQuery query); |
| | | |
| | | |
| | | @PostMapping("/base/v1/mini-program/inner/point/getPointsInfo") |
| | | @PostMapping("/inner/v1/point/getPointsInfo") |
| | | R<List<XpPoint>> getPointsInfo(@RequestBody Set<Long> points); |
| | | |
| | | /** |
| | |
| | | * @param pointId |
| | | * @return |
| | | */ |
| | | @GetMapping("/base/v1/mini-program/inner/point/nowInTimePoint") |
| | | @GetMapping("/inner/v1/point/nowInTimePoint") |
| | | R<Boolean> nowInTimePoint(@RequestParam Long pointId); |
| | | } |
| | |
| | | /** |
| | | * 获取等待时间 |
| | | */ |
| | | @PostMapping("/base/v1/mini-program/pricing/getWaitTime") |
| | | @PostMapping("/inner/v1/pricing/getWaitTime") |
| | | R<Integer> getWaitTime(@RequestBody LonLatDto dto); |
| | | |
| | | // 根据开通城市 获取定价 |
| | | @GetMapping("/base/v1/mini-program/getPricingByCid") |
| | | @GetMapping("/inner/v1/getPricingByCid") |
| | | R<XpPricing> getPricingByCid(@RequestParam Long cityId); |
| | | |
| | | /** |
| New file |
| | |
| | | package com.xiaopeng.api.feignClient.operation; |
| | | |
| | | import com.xiaopeng.api.factory.operation.XpRoutePlanClientFallbackFactory; |
| | | import com.xiaopeng.api.model.operation.XpRoutePlan; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.dto.ServiceNameConstantsEnum; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | @FeignClient(contextId = "XpRoutePlanClient", value = ServiceNameConstantsEnum.XP_OPERATION_SERVICE, fallbackFactory = XpRoutePlanClientFallbackFactory.class) |
| | | public interface XpRoutePlanClient { |
| | | |
| | | |
| | | /** |
| | | * 根据openCityId获取路线规划配置 |
| | | * @param openCityId |
| | | * @return |
| | | */ |
| | | @PostMapping("/inner/v1/routePlan/getXpRoutePlanOpenCityId") |
| | | R<XpRoutePlan> getXpRoutePlanOpenCityId(@RequestParam Long openCityId); |
| | | } |
| | |
| | | public interface XpSystemSettingClient { |
| | | |
| | | |
| | | @GetMapping("/base/v1/mini-program/support/getOrderDistance") |
| | | @GetMapping("/base/v1/support/getOrderDistance") |
| | | R getOrderDistance(); |
| | | |
| | | /** |
| | | * 获取自动结束行程时间 |
| | | * @return |
| | | */ |
| | | @GetMapping("/api/v1/mini-program/support/getOrderFinishTime") |
| | | @GetMapping("/api/v1/support/getOrderFinishTime") |
| | | R<Integer> getOrderFinishTime(); |
| | | |
| | | /** |
| | | * 获取反馈类型 |
| | | * @return |
| | | */ |
| | | @GetMapping("/base/v1/mini-program/getFeedbackTypeById/{id}") |
| | | @GetMapping("/base/v1/getFeedbackTypeById/{id}") |
| | | R<XpFeedbackType> getFeedbackTypeById(@PathVariable("id")Long id); |
| | | } |
| New file |
| | |
| | | package com.xiaopeng.api.feignClient.operation; |
| | | |
| | | import com.xiaopeng.api.factory.operation.XpTestPlanClientFallbackFactory; |
| | | import com.xiaopeng.api.model.operation.XpTestPlan; |
| | | import com.xiaopeng.api.model.operation.XpTestPlanPoint; |
| | | import com.xiaopeng.api.model.operation.XpTestPlanVehicle; |
| | | import com.xiaopeng.api.model.operation.XpTestPoint; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.dto.ServiceNameConstantsEnum; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.List; |
| | | |
| | | @FeignClient(contextId = "XpTestPlanClient", value = ServiceNameConstantsEnum.XP_OPERATION_SERVICE, fallbackFactory = XpTestPlanClientFallbackFactory.class) |
| | | public interface XpTestPlanClient { |
| | | |
| | | |
| | | /** |
| | | * 根据id获取测试计划 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @PostMapping("/inner/v1/xp-test-plan/getXpTestPlanById") |
| | | R<XpTestPlan> getXpTestPlanById(@RequestParam Long id); |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据id获取测试计划点 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @PostMapping("/inner/v1/xp-test-plan/getXpTestPlanPointById") |
| | | R<XpTestPlanPoint> getXpTestPlanPointById(@RequestParam Long id); |
| | | |
| | | |
| | | /** |
| | | * 根据id获取测试计划点位 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @PostMapping("/inner/v1/xp-test-plan/getXpTestPointById") |
| | | R<XpTestPoint> getXpTestPointById(@RequestParam Long id); |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据测试计划获取车辆信息 |
| | | * @param testPlanId |
| | | * @return |
| | | */ |
| | | @PostMapping("/inner/v1/xp-test-plan/getXpTestPlanVehicleByTestPlanId") |
| | | R<List<XpTestPlanVehicle>> getXpTestPlanVehicleByTestPlanId(@RequestParam Long testPlanId); |
| | | } |
| New file |
| | |
| | | package com.xiaopeng.api.feignClient.operation; |
| | | |
| | | import com.xiaopeng.api.factory.operation.XpTestPointClientFallbackFactory; |
| | | import com.xiaopeng.api.model.operation.XpTestPoint; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.dto.ServiceNameConstantsEnum; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | @FeignClient(contextId = "XpTestPointClient", value = ServiceNameConstantsEnum.XP_OPERATION_SERVICE, fallbackFactory = XpTestPointClientFallbackFactory.class) |
| | | public interface XpTestPointClient { |
| | | |
| | | |
| | | |
| | | /** |
| | | * 点位详情 |
| | | */ |
| | | @GetMapping("/api/v1/testPoint/queryPointById") |
| | | R<XpTestPoint> queryById(@RequestParam Long id); |
| | | |
| | | |
| | | |
| | | /** |
| | | * 判断点位是在有效期内 |
| | | * |
| | | * @param pointId |
| | | * @return |
| | | */ |
| | | @GetMapping("/inner/v1/testPoint/nowInTimePoint") |
| | | R<Boolean> nowInTimePoint(@RequestParam Long pointId); |
| | | } |
| New file |
| | |
| | | package com.xiaopeng.api.feignClient.order; |
| | | |
| | | import com.xiaopeng.api.factory.order.XpTestOrderClientFallbackFactory; |
| | | import com.xiaopeng.api.model.order.XpTestOrder; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.dto.ServiceNameConstantsEnum; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | |
| | | @FeignClient(contextId = "XpTestOrderClient", |
| | | value = ServiceNameConstantsEnum.XP_ORDER_SERVICE, |
| | | fallbackFactory = XpTestOrderClientFallbackFactory.class) |
| | | public interface XpTestOrderClient { |
| | | |
| | | /** |
| | | * 通过订单id查询订单信息 |
| | | * |
| | | * @param orderId 订单id |
| | | * @return 订单详情 |
| | | */ |
| | | @PostMapping("/inner/v1/testOrder/queryOrderById") |
| | | R<XpTestOrder> queryOrderById(@RequestParam Long orderId); |
| | | |
| | | |
| | | /** |
| | | * 修改订单状态 |
| | | * @param orderId |
| | | * @param status |
| | | * @return |
| | | */ |
| | | @PostMapping("/inner/v1/testOrder/updateOrderStatus") |
| | | R<String> updateOrderStatus(@RequestParam Long orderId, |
| | | @RequestParam Integer status); |
| | | } |
| | |
| | | @ApiModelProperty(value = "测试计划ID") |
| | | private Long testPlanId; |
| | | |
| | | @ApiModelProperty(value = "点位ID") |
| | | private Long testPointId; |
| | | @ApiModelProperty(value = "测试起点id") |
| | | private Long startTestPointId; |
| | | |
| | | @ApiModelProperty(value = "排序") |
| | | private Integer sortOrder; |
| | | @ApiModelProperty(value = "测试终点id") |
| | | private Long endTestPointId; |
| | | |
| | | @ApiModelProperty(value = "是否停车 0-否 1-是") |
| | | private Integer stopFlag; |
| | | |
| | | @ApiModelProperty(value = "测试订单id") |
| | | private Long testOrderId; |
| | | |
| | | @ApiModelProperty(value = "测试订单类型(1=测试单,2=巡游单)") |
| | | private Long testOrderType; |
| | | |
| | | } |
| | |
| | | package com.xiaopeng.api.model.order; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.xiaopeng.common.core.web.domain.BaseModel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "用户id") |
| | | @TableField(updateStrategy = FieldStrategy.NEVER) |
| | | private Long appUserId; |
| | | @ApiModelProperty(value = "用户id") |
| | | private Long cityId; |
| | |
| | | * 乘客订单 |
| | | */ |
| | | String USER_ORDER = "user_order"; |
| | | /** |
| | | * 测试订单 |
| | | */ |
| | | String TEST_ORDER = "test_order"; |
| | | } |
| | |
| | | * 订单id |
| | | */ |
| | | private Long orderId; |
| | | /** |
| | | * 总里程 |
| | | */ |
| | | private Float totalOdometer; |
| | | } |
| | |
| | | com.xiaopeng.api.factory.maintenance.XpTaskRuleClientFallbackFactory |
| | | com.xiaopeng.api.factory.maintenance.XpWorkOrderClientFallbackFactory |
| | | com.xiaopeng.api.factory.pushMessage.XpAliPushMessageClientFallbackFactory |
| | | com.xiaopeng.api.factory.maintenance.XpVehicleRepairClientFallbackFactory |
| | | com.xiaopeng.api.factory.maintenance.XpVehicleRepairClientFallbackFactory |
| | | com.xiaopeng.api.factory.operation.XpTestPointClientFallbackFactory |
| | | com.xiaopeng.api.factory.operation.XpTestPlanClientFallbackFactory |
| | | com.xiaopeng.api.factory.operation.XpRoutePlanClientFallbackFactory |
| | | com.xiaopeng.api.factory.order.XpTestOrderClientFallbackFactory |
| | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.xiaopeng.api.dto.automaticPilot.MqttPublishDto; |
| | | import com.xiaopeng.api.dto.automaticPilot.PushOrderDto; |
| | | import com.xiaopeng.api.dto.automaticPilot.VehicleEventDTO; |
| | | import com.xiaopeng.api.dto.map.OrderRouteAndFareDto; |
| | | import com.xiaopeng.api.dto.operation.LonLatDto; |
| | | import com.xiaopeng.api.dto.order.PopOrderDto; |
| | | import com.xiaopeng.api.dto.pushMessage.PushOrderRouteDTO; |
| | | import com.xiaopeng.api.dto.pushMessage.SendMessageDTO; |
| | | import com.xiaopeng.api.dto.vehicleConvoy.UpdateVehicleStateDto; |
| | | import com.xiaopeng.api.feignClient.automaticPilot.VehicleBuriedPointClient; |
| | | import com.xiaopeng.api.feignClient.map.XpMapClient; |
| | | import com.xiaopeng.api.feignClient.order.XpOrderClient; |
| | | import com.xiaopeng.api.feignClient.pushMessage.XpPushMessageClient; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient; |
| | | import com.xiaopeng.api.model.order.XpOrder;import com.xiaopeng.api.model.vehicleConvoy.XpVehicle; |
| | | import com.xiaopeng.api.vo.OrderType; |
| | | import com.xiaopeng.api.vo.SystemEventType; |
| | | import com.xiaopeng.api.vo.automaticPilot.VehiclePosition; |
| | | import com.xiaopeng.api.vo.automaticPilot.protobuf.*; |
| | |
| | | private RedisService redisService; |
| | | @Resource |
| | | private XpVehicleClient xpVehicleClient; |
| | | @Resource |
| | | private VehicleBuriedPointClient vehicleBuriedPointClient; |
| | | @Resource(name = "hutoolSnowflake") |
| | | private Snowflake snowflake; |
| | | |
| | |
| | | taskBuilder.setSequence(1); |
| | | taskBuilder.addOrderPhase(OrderPhase.ROUTE_TO_CRUISE); |
| | | taskListBuilder.addTasks(taskBuilder.build()); |
| | | }else{ |
| | | }else if(dto.getOrderType().equals(com.xiaopeng.api.vo.OrderType.USER_ORDER)){ |
| | | for (int i = 1; i < 3; i++) { |
| | | RtTask.Builder taskBuilder = RtTask.newBuilder(); |
| | | taskBuilder.setOrderId(dto.getOrderId().toString()); |
| | | taskBuilder.setTaskId(snowflake.nextId() + ""); |
| | | taskBuilder.setTaskType(OrderType.ORDER_TYPE_ROBOTAXI); |
| | | if(i == 1){ |
| | | VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(dto.getVin())), VehiclePosition.class); |
| | | //构建车辆当前位置数据 |
| | | pointBuilderStart.setWaypointId(dto.getOrderId() + "-JJ-001"); |
| | | pointBuilderStart.setPointType(PointType.START_POINT); |
| | | pointBuilderStart.setActionType(ActionType.ACTION_UNSPECIFIED); |
| | | pointBuilderStart.setSequence(1); |
| | | GeoPoint.Builder geoPointBuilder = GeoPoint.newBuilder(); |
| | | geoPointBuilder.setLatitude(vehiclePosition.getPoint().getY()); |
| | | geoPointBuilder.setLongitude(vehiclePosition.getPoint().getX()); |
| | | pointBuilderStart.setPoint(geoPointBuilder.build()); |
| | | taskBuilder.addPoints(pointBuilderStart); |
| | | |
| | | //构建上车点位置信息 |
| | | pointBuilderEnd.setWaypointId(dto.getOrderId() + "-JJ-002"); |
| | | pointBuilderEnd.setPointType(PointType.PICK_UP_POINT); |
| | | pointBuilderEnd.setActionType(ActionType.PICK_UP); |
| | | pointBuilderEnd.setSequence(2); |
| | | geoPointBuilder = GeoPoint.newBuilder(); |
| | | geoPointBuilder.setLatitude(dto.getStartLatitude()); |
| | | geoPointBuilder.setLongitude(dto.getStartLongitude()); |
| | | pointBuilderEnd.setPoint(geoPointBuilder.build()); |
| | | taskBuilder.addPoints(pointBuilderEnd); |
| | | taskBuilder.setSequence(i); |
| | | taskBuilder.addOrderPhase(OrderPhase.ROUTE_TO_PICKUP); |
| | | }else{ |
| | | //构建上车点位置信息 |
| | | pointBuilderStart.setWaypointId(dto.getOrderId() + "-SD-001"); |
| | | pointBuilderStart.setPointType(PointType.PICK_UP_POINT); |
| | | pointBuilderStart.setActionType(ActionType.PICK_UP); |
| | | pointBuilderStart.setSequence(1); |
| | | GeoPoint.Builder geoPointBuilder = GeoPoint.newBuilder(); |
| | | geoPointBuilder.setLatitude(dto.getStartLatitude()); |
| | | geoPointBuilder.setLongitude(dto.getStartLongitude()); |
| | | pointBuilderStart.setPoint(geoPointBuilder.build()); |
| | | taskBuilder.addPoints(pointBuilderStart); |
| | | |
| | | //构建下车点位置信息 |
| | | pointBuilderEnd.setWaypointId(dto.getOrderId() + "-SD-002"); |
| | | pointBuilderEnd.setPointType(PointType.END_POINT); |
| | | pointBuilderEnd.setActionType(ActionType.DROP_OFF); |
| | | pointBuilderEnd.setSequence(2); |
| | | geoPointBuilder = GeoPoint.newBuilder(); |
| | | geoPointBuilder.setLatitude(dto.getEndLatitude()); |
| | | geoPointBuilder.setLongitude(dto.getEndLongitude()); |
| | | pointBuilderEnd.setPoint(geoPointBuilder.build()); |
| | | taskBuilder.addPoints(pointBuilderEnd); |
| | | taskBuilder.setSequence(i); |
| | | taskBuilder.addOrderPhase(OrderPhase.ROUTE_TO_DESTINATION); |
| | | } |
| | | taskListBuilder.addTasks(taskBuilder.build()); |
| | | } |
| | | }else if(dto.getOrderType().equals(com.xiaopeng.api.vo.OrderType.TEST_ORDER)){ |
| | | for (int i = 1; i < 3; i++) { |
| | | RtTask.Builder taskBuilder = RtTask.newBuilder(); |
| | | taskBuilder.setOrderId(dto.getOrderId().toString()); |
| | |
| | | // 修改车子为接单状态 |
| | | xpVehicleClient.updateVehicleStatus(new UpdateVehicleStateDto(dto.getVin(), 1)); |
| | | } |
| | | |
| | | if(null != mqttPublishDto && mqttPublishDto.getCode() == 200){ |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("event", SystemEventType.CREATE_ORDER); |
| | | jsonObject.put("orderType", dto.getOrderId().contains("XU") ? com.xiaopeng.api.vo.OrderType.CRUISE_ORDER : com.xiaopeng.api.vo.OrderType.USER_ORDER); |
| | | if(dto.getOrderId().contains("XU")){ |
| | | jsonObject.put("orderType", com.xiaopeng.api.vo.OrderType.CRUISE_ORDER); |
| | | }else if(dto.getOrderId().contains("TEST")){ |
| | | jsonObject.put("orderType", com.xiaopeng.api.vo.OrderType.TEST_ORDER); |
| | | }else { |
| | | jsonObject.put("orderType", com.xiaopeng.api.vo.OrderType.USER_ORDER); |
| | | } |
| | | jsonObject.put("orderId", dto.getOrderId()); |
| | | jsonObject.put("vin", dto.getVin()); |
| | | redisService.setCacheObject("CREATE_ORDER:" + dto.getOrderId().toString(), jsonObject.toJSONString(),30L, TimeUnit.MINUTES); |
| | |
| | | import com.google.protobuf.InvalidProtocolBufferException; |
| | | import com.google.protobuf.util.JsonFormat; |
| | | import com.xiaopeng.api.dto.automaticPilot.MqttPublishDto; |
| | | import com.xiaopeng.api.dto.automaticPilot.VehicleEventDTO; |
| | | 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.pushMessage.PushOrderRouteDTO; |
| | | import com.xiaopeng.api.dto.pushMessage.SendMessageDTO; |
| | | import com.xiaopeng.api.dto.vehicleConvoy.UpdateVehicleStateDto; |
| | | import com.xiaopeng.api.feignClient.automaticPilot.VehicleBuriedPointClient; |
| | | import com.xiaopeng.api.feignClient.maintenance.XpTaskClient; |
| | | import com.xiaopeng.api.feignClient.map.XpMapClient; |
| | | import com.xiaopeng.api.feignClient.operation.ReassignOrderClient; |
| | | import com.xiaopeng.api.feignClient.operation.XpCruisePlanClient; |
| | | import com.xiaopeng.api.feignClient.order.XpCruiseOrderClient; |
| | | import com.xiaopeng.api.feignClient.order.XpOrderClient; |
| | | import com.xiaopeng.api.feignClient.order.XpTestOrderClient; |
| | | import com.xiaopeng.api.feignClient.pushMessage.XpPushMessageClient; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.UserVehicleClient; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient; |
| | | import com.xiaopeng.api.model.order.XpCruiseOrder; |
| | | import com.xiaopeng.api.model.order.XpOrder; |
| | | import com.xiaopeng.api.model.order.XpTestOrder; |
| | | import com.xiaopeng.api.model.vehicleConvoy.XpVehicle; |
| | | import com.xiaopeng.api.vo.OrderType; |
| | | import com.xiaopeng.api.vo.automaticPilot.VehiclePosition; |
| | |
| | | |
| | | @Resource |
| | | private XpTaskClient xpTaskClient; |
| | | @Resource |
| | | private VehicleBuriedPointClient vehicleBuriedPointClient; |
| | | |
| | | @Resource |
| | | private XpTestOrderClient testOrderClient; |
| | | |
| | | private static final JsonFormat.Printer jsonPrinter = JsonFormat.printer() |
| | | .printingEnumsAsInts() |
| | |
| | | String vin = jsonObject.getString("vin"); |
| | | String orderType = jsonObject.getString("orderType"); |
| | | PopOrderDto dto = new PopOrderDto(); |
| | | dto.setOrderId(Long.valueOf(orderId.contains("XU") ? orderId.substring(2) : orderId)); |
| | | if(orderId.contains("XU")){ |
| | | dto.setOrderId(Long.valueOf(orderId.substring(2))); |
| | | }else if(orderId.contains("TEST")){ |
| | | dto.setOrderId(Long.valueOf(orderId.substring(4))); |
| | | }else{ |
| | | dto.setOrderId(Long.valueOf(orderId)); |
| | | } |
| | | dto.setXpVehicleVin(vin); |
| | | dto.setOrderType(orderType); |
| | | xpOrderClient.popOrder(dto); |
| | |
| | | if (order_id.contains("XU")) { |
| | | hasOrder = 1; |
| | | orderId = Long.parseLong(order_id.substring(2)); |
| | | } else { |
| | | } else if(order_id.contains("TEST")) { |
| | | orderId = Long.parseLong(order_id.substring(4)); |
| | | }else{ |
| | | orderId = Long.parseLong(order_id); |
| | | } |
| | | } |
| | |
| | | vehiclePosition.setCurrentElectricity(dynamicStatus.getBmsSocDisp()); |
| | | vehiclePosition.setMileageRange(dynamicStatus.getDstBatDisp()); |
| | | vehiclePosition.setOrderId(orderId); |
| | | vehiclePosition.setTotalOdometer(dynamicStatus.getTotalOdometer()); |
| | | mongoTemplate.save(vehiclePosition); |
| | | }else{ |
| | | vehiclePosition.setOrderId(orderId); |
| | |
| | | .set("currentElectricity", dynamicStatus.getBmsSocDisp()) |
| | | .set("mileageRange", dynamicStatus.getDstBatDisp()) |
| | | .set("hasOrder", hasOrder) |
| | | .set("orderId", orderId); |
| | | .set("orderId", orderId) |
| | | .set("totalOdometer", dynamicStatus.getTotalOdometer()); |
| | | mongoTemplate.updateFirst(new Query(Criteria.where("vin").is(vin)), update, VehiclePosition.class); |
| | | } |
| | | //调用推送服务接口 |
| | | if (null != orderId && !order_id.contains("XU")) { |
| | | if (null != orderId && !order_id.contains("XU") && !order_id.contains("TEST")) { |
| | | RtTripInfo rtTripInfo = systemRuntimeStatus.getRtTripInfo(); |
| | | PushOrderRouteDTO dto = new PushOrderRouteDTO(); |
| | | dto.setOrderId(orderId); |
| | |
| | | } |
| | | //添加车辆异常任务和发送消息 |
| | | xpTaskClient.saveVehicleAccidentError(vehicle.getId()); |
| | | |
| | | // 封装埋点消息实体 |
| | | VehicleEventDTO vehicleEventDTO = new VehicleEventDTO(); |
| | | vehicleEventDTO.setVin(vehicle.getVehicleVin()); |
| | | vehicleEventDTO.setXpuId(""); |
| | | vehicleEventDTO.setOrderId(""); |
| | | vehicleEventDTO.setEventKey("RT_web_vehicle_status_changed"); |
| | | vehicleEventDTO.setEventTime(System.currentTimeMillis()); |
| | | Map<String,Object> attributes = new HashMap<>(); |
| | | attributes.put("vin",vehicle.getVehicleVin()); |
| | | attributes.put("order_id",""); |
| | | attributes.put("timestamp",vehicleEventDTO.getEventTime()); |
| | | attributes.put("main_status","OFFLINE"); |
| | | // TODO 预留位置 目前无状态 |
| | | attributes.put("sub_status",""); |
| | | attributes.put("prev_sub_status",""); |
| | | vehicleEventDTO.setAttributes(attributes); |
| | | vehicleBuriedPointClient.sendVehicleEvent(vehicleEventDTO); |
| | | } |
| | | } |
| | | |
| | |
| | | XpVehicle xpVehicle = xpVehicleClient.queryById(xpOrder.getVehicleId()).getData(); |
| | | //驶往上车点的行程 |
| | | if (3 == xpOrder.getStatus()) { |
| | | redisService.deleteObject("ORDER_NAVIGATION_START_DATA:" + xpOrder.getAppUserId()); |
| | | //查询司机当前位置到起点的线路 |
| | | origin.setLongitude(longitude); |
| | | origin.setLatitude(latitude); |
| | |
| | | |
| | | vehicleId = xpCruiseOrder.getVehicleId(); |
| | | } |
| | | } else { |
| | | } else if(orderId.contains("TEST")){ |
| | | orderType = OrderType.TEST_ORDER; |
| | | //正常单 |
| | | R<XpTestOrder> xpOrderR = testOrderClient.queryOrderById(Long.parseLong(orderId.substring(4))); |
| | | if (200 != xpOrderR.getCode()) { |
| | | throw new RuntimeException("订单不存在 " + orderId); |
| | | } |
| | | XpTestOrder xpOrder = xpOrderR.getData(); |
| | | XpVehicle xpVehicle = xpVehicleClient.queryById(xpOrder.getVehicleId()).getData(); |
| | | //驶往上车点的行程 |
| | | if (orderPhase.equals(OrderPhase.ROUTE_TO_PICKUP)) { |
| | | //查询车辆位置 |
| | | VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(xpVehicle.getVehicleVin())), VehiclePosition.class); |
| | | if (Objects.isNull(vehiclePosition)) { |
| | | throw new RuntimeException("车辆位置信息不存在"); |
| | | } |
| | | //查询司机当前位置到起点的线路 |
| | | origin.setLongitude(vehiclePosition.getPoint().getX()); |
| | | origin.setLatitude(vehiclePosition.getPoint().getY()); |
| | | destination.setLongitude(xpOrder.getStartLon()); |
| | | destination.setLatitude(xpOrder.getStartLat()); |
| | | |
| | | OrderRouteAndFareDto dto = new OrderRouteAndFareDto(); |
| | | dto.setOrderId(Long.parseLong(orderId)); |
| | | dto.setOrigin(origin); |
| | | dto.setDestination(destination); |
| | | dto.setRouteType(1); |
| | | R<RouteVo> routeVoR = xpMapClient.getOrderDistanceAndDuration(dto); |
| | | if (200 != routeVoR.getCode()) { |
| | | throw new RuntimeException("获取订单线路和运费失败"); |
| | | } |
| | | RouteVo routeVo = routeVoR.getData(); |
| | | routeID = routeVo.getRouteID(); |
| | | //缓存数据,用于后续推给乘客导航线路 |
| | | redisService.setCacheObject("TEST_ORDER_NAVIGATION_START_DATA:" + xpOrder.getVehicleId(), JSON.toJSONString(routeVo), 24L, TimeUnit.HOURS); |
| | | } |
| | | //驶往下车点的行程 |
| | | if (orderPhase.equals(OrderPhase.ROUTE_TO_DESTINATION)) { |
| | | //直接取缓存中的导航数据推送给车端和乘客 |
| | | Object cacheObject = redisService.getCacheObject("TEST_ORDER_NAVIGATION_END_DATA:" + xpOrder.getVehicleId()); |
| | | if(null == cacheObject){ |
| | | //没有缓存数据,重新规划线路 |
| | | //查询起点到终点的线路 |
| | | origin.setLongitude(xpOrder.getStartLon()); |
| | | origin.setLatitude(xpOrder.getStartLat()); |
| | | destination.setLongitude(xpOrder.getEndLon()); |
| | | destination.setLatitude(xpOrder.getEndLat()); |
| | | OrderRouteAndFareDto dto = new OrderRouteAndFareDto(); |
| | | dto.setOrderId(Long.parseLong(orderId)); |
| | | dto.setOrigin(origin); |
| | | dto.setDestination(destination); |
| | | dto.setRouteType(2); |
| | | R<RouteVo> routeVoR = xpMapClient.getOrderDistanceAndDuration(dto); |
| | | if (200 != routeVoR.getCode()) { |
| | | throw new RuntimeException("获取订单线路和运费失败"); |
| | | } |
| | | RouteVo routeVo = routeVoR.getData(); |
| | | routeID = routeVo.getRouteID(); |
| | | //缓存导航数据,用于后面的逻辑中给乘客端推送导航数据 |
| | | redisService.setCacheObject("TEST_ORDER_NAVIGATION_END_DATA:" + xpOrder.getVehicleId(), JSON.toJSONString(routeVo), 24L, TimeUnit.HOURS); |
| | | }else{ |
| | | RouteVo routeVo = JSON.parseObject(cacheObject.toString(), RouteVo.class); |
| | | routeID = routeVo.getRouteID(); |
| | | } |
| | | } |
| | | vehicleId = xpOrder.getVehicleId(); |
| | | }else{ |
| | | orderType = OrderType.USER_ORDER; |
| | | //正常单 |
| | | R<XpOrder> xpOrderR = xpOrderClient.queryOrderById(Long.parseLong(orderId)); |
| | |
| | | if (Objects.isNull(vehiclePosition)) { |
| | | throw new RuntimeException("车辆位置信息不存在"); |
| | | } |
| | | redisService.deleteObject("ORDER_NAVIGATION_START_DATA:" + xpOrder.getAppUserId()); |
| | | //查询司机当前位置到起点的线路 |
| | | origin.setLongitude(vehiclePosition.getPoint().getX()); |
| | | origin.setLatitude(vehiclePosition.getPoint().getY()); |
| | |
| | | case ORDER_RECEIVED: |
| | | //收到订单 |
| | | if(!orderId.contains("XU")){ |
| | | buildPushOrderStatus(orderId, OrderStatusEnum.READY_DEPART, sequence); |
| | | xpOrderClient.updateOrderStatus(Long.parseLong(orderId), OrderStatusEnum.READY_DEPART.getCode()); |
| | | if(orderId.contains("TEST")){ |
| | | testOrderClient.updateOrderStatus(Long.parseLong(orderId.substring(4)), OrderStatusEnum.READY_DEPART.getCode()); |
| | | }else{ |
| | | buildPushOrderStatus(orderId, OrderStatusEnum.READY_DEPART, sequence); |
| | | xpOrderClient.updateOrderStatus(Long.parseLong(orderId), OrderStatusEnum.READY_DEPART.getCode()); |
| | | } |
| | | } |
| | | break; |
| | | case ORDER_STARTED: |
| | |
| | | case ORDER_EN_ROUTE_TO_PICKUP: |
| | | //前往上车点 |
| | | if(!orderId.contains("XU")){ |
| | | buildPushOrderStatus(orderId, OrderStatusEnum.PICK_UP, sequence); |
| | | xpOrderClient.updateOrderStatus(Long.parseLong(orderId), OrderStatusEnum.PICK_UP.getCode()); |
| | | if(orderId.contains("TEST")){ |
| | | testOrderClient.updateOrderStatus(Long.parseLong(orderId.substring(4)), OrderStatusEnum.PICK_UP.getCode()); |
| | | }else{ |
| | | buildPushOrderStatus(orderId, OrderStatusEnum.PICK_UP, sequence); |
| | | xpOrderClient.updateOrderStatus(Long.parseLong(orderId), OrderStatusEnum.PICK_UP.getCode()); |
| | | } |
| | | } |
| | | break; |
| | | case ORDER_ARRIVED_AT_PICKUP: |
| | |
| | | case ORDER_WAITING_FOR_PICKUP: |
| | | //等待乘客上车 |
| | | if(!orderId.contains("XU")){ |
| | | buildPushOrderStatus(orderId, OrderStatusEnum.PICK_UP_GUESTS, sequence); |
| | | xpOrderClient.updateOrderStatus(Long.parseLong(orderId), OrderStatusEnum.PICK_UP_GUESTS.getCode()); |
| | | if(orderId.contains("TEST")){ |
| | | testOrderClient.updateOrderStatus(Long.parseLong(orderId.substring(4)), OrderStatusEnum.PICK_UP_GUESTS.getCode()); |
| | | }else{ |
| | | buildPushOrderStatus(orderId, OrderStatusEnum.PICK_UP_GUESTS, sequence); |
| | | xpOrderClient.updateOrderStatus(Long.parseLong(orderId), OrderStatusEnum.PICK_UP_GUESTS.getCode()); |
| | | } |
| | | } |
| | | break; |
| | | case ORDER_PASSENGER_ONBOARD: |
| | | //乘客已上车 |
| | | if(!orderId.contains("XU")){ |
| | | buildPushOrderStatus(orderId, OrderStatusEnum.PASSENGER_BOARDED, sequence); |
| | | xpOrderClient.updateOrderStatus(Long.parseLong(orderId), OrderStatusEnum.PASSENGER_BOARDED.getCode()); |
| | | if(orderId.contains("TEST")){ |
| | | testOrderClient.updateOrderStatus(Long.parseLong(orderId.substring(4)), OrderStatusEnum.PASSENGER_BOARDED.getCode()); |
| | | }else{ |
| | | buildPushOrderStatus(orderId, OrderStatusEnum.PASSENGER_BOARDED, sequence); |
| | | xpOrderClient.updateOrderStatus(Long.parseLong(orderId), OrderStatusEnum.PASSENGER_BOARDED.getCode()); |
| | | } |
| | | } |
| | | break; |
| | | case ORDER_EN_ROUTE_TO_DESTINATION: |
| | | //前往目的地 |
| | | if(!orderId.contains("XU")){ |
| | | buildPushOrderStatus(orderId, OrderStatusEnum.IN_SERVICE, sequence); |
| | | xpOrderClient.updateOrderStatus(Long.parseLong(orderId), OrderStatusEnum.IN_SERVICE.getCode()); |
| | | if(orderId.contains("TEST")){ |
| | | testOrderClient.updateOrderStatus(Long.parseLong(orderId.substring(4)), OrderStatusEnum.IN_SERVICE.getCode()); |
| | | }else{ |
| | | buildPushOrderStatus(orderId, OrderStatusEnum.IN_SERVICE, sequence); |
| | | xpOrderClient.updateOrderStatus(Long.parseLong(orderId), OrderStatusEnum.IN_SERVICE.getCode()); |
| | | } |
| | | } |
| | | break; |
| | | case ORDER_ARRIVED_AT_DESTINATION: |
| | |
| | | case ORDER_WAITING_FOR_DROPOFF: |
| | | //等待乘客下车,开始倒计时发下巡游单 |
| | | if(!orderId.contains("XU")){ |
| | | buildPushOrderStatus(orderId, OrderStatusEnum.SEE_OFF_GUESTS, sequence); |
| | | xpOrderClient.updateOrderStatus(Long.parseLong(orderId), OrderStatusEnum.SEE_OFF_GUESTS.getCode()); |
| | | if(orderId.contains("TEST")){ |
| | | testOrderClient.updateOrderStatus(Long.parseLong(orderId.substring(4)), OrderStatusEnum.SEE_OFF_GUESTS.getCode()); |
| | | }else{ |
| | | buildPushOrderStatus(orderId, OrderStatusEnum.SEE_OFF_GUESTS, sequence); |
| | | xpOrderClient.updateOrderStatus(Long.parseLong(orderId), OrderStatusEnum.SEE_OFF_GUESTS.getCode()); |
| | | } |
| | | } |
| | | break; |
| | | case ORDER_DROPOFF_COMPLETED: |
| | |
| | | case ORDER_COMPLETED: |
| | | //已完成 |
| | | log.info("已完成,不做任何处理:{}", orderId); |
| | | if(!orderId.contains("XU")){ |
| | | XpOrder xpOrder = xpOrderClient.queryOrderById(Long.valueOf(orderId)).getData(); |
| | | if (Objects.nonNull(xpOrder)){ |
| | | // 查询车辆 |
| | | XpVehicle xpVehicle = xpVehicleClient.queryById(xpOrder.getVehicleId()).getData(); |
| | | if (Objects.nonNull(xpVehicle)){ |
| | | String vin = xpVehicle.getVehicleVin(); |
| | | // 封装埋点消息实体 |
| | | VehicleEventDTO vehicleEventDTO = new VehicleEventDTO(); |
| | | vehicleEventDTO.setVin(vin); |
| | | vehicleEventDTO.setXpuId(""); |
| | | vehicleEventDTO.setOrderId(orderId); |
| | | vehicleEventDTO.setEventKey("RT_xpu_vehicle_trace_upload"); |
| | | vehicleEventDTO.setEventTime(System.currentTimeMillis()); |
| | | Map<String,Object> attributes = new HashMap<>(); |
| | | attributes.put("vin",vin); |
| | | attributes.put("order_id",vehicleEventDTO.getOrderId()); |
| | | attributes.put("order_type","user_order"); |
| | | attributes.put("timestamp",vehicleEventDTO.getEventTime()); |
| | | attributes.put("current_main_status",OrderStatus.ORDER_COMPLETED); |
| | | attributes.put("current_sub_status",""); |
| | | VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(vin)), VehiclePosition.class); |
| | | if(Objects.nonNull(vehiclePosition)){ |
| | | attributes.put("odometer_km",vehiclePosition.getTotalOdometer()); |
| | | }else { |
| | | attributes.put("odometer_km",""); |
| | | } |
| | | vehicleEventDTO.setAttributes(attributes); |
| | | vehicleBuriedPointClient.sendVehicleEvent(vehicleEventDTO); |
| | | log.info("已完成,推送埋点:{}", orderId); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | case ORDER_CANCELLED: |
| | | //已取消 |
| | | if(!orderId.contains("XU")){ |
| | | //判断订单状态,已经取消的不作处理 |
| | | Object cacheObject = redisService.getCacheObject("ORDER_STATUS:" + orderId); |
| | | if(null != cacheObject){ |
| | | int order_status = Integer.parseInt(cacheObject.toString()); |
| | | if(0 == order_status){ |
| | | return; |
| | | if(orderId.contains("TEST")){ |
| | | //判断订单状态,已经取消的不作处理 |
| | | Object cacheObject = redisService.getCacheObject("ORDER_STATUS:" + orderId.substring(4)); |
| | | if(null != cacheObject){ |
| | | int order_status = Integer.parseInt(cacheObject.toString()); |
| | | if(0 == order_status){ |
| | | return; |
| | | } |
| | | } |
| | | //行程中取消订单,按照行程结束处理 |
| | | testOrderClient.updateOrderStatus(Long.parseLong(orderId.substring(4)), OrderStatusEnum.SEE_OFF_GUESTS.getCode()); |
| | | }else{ |
| | | //判断订单状态,已经取消的不作处理 |
| | | Object cacheObject = redisService.getCacheObject("ORDER_STATUS:" + orderId); |
| | | if(null != cacheObject){ |
| | | int order_status = Integer.parseInt(cacheObject.toString()); |
| | | if(0 == order_status){ |
| | | return; |
| | | } |
| | | } |
| | | //行程中取消订单,按照行程结束处理 |
| | | buildPushOrderStatus(orderId, OrderStatusEnum.SEE_OFF_GUESTS, sequence); |
| | | xpOrderClient.updateOrderStatus(Long.parseLong(orderId), OrderStatusEnum.SEE_OFF_GUESTS.getCode()); |
| | | } |
| | | //行程中取消订单,按照行程结束处理 |
| | | buildPushOrderStatus(orderId, OrderStatusEnum.SEE_OFF_GUESTS, sequence); |
| | | xpOrderClient.updateOrderStatus(Long.parseLong(orderId), OrderStatusEnum.SEE_OFF_GUESTS.getCode()); |
| | | } |
| | | break; |
| | | case ORDER_ARRIVED_AT_CRUISE_DESTINATION: |
| | | //到达巡游终点 |
| | | if(orderId.contains("XU")){ |
| | | buildPushOrderStatus(orderId, OrderStatusEnum.COMPLETED, sequence); |
| | | String cruiseOrderId = orderId.substring(2); |
| | | XpCruiseOrder xpCruiseOrder = xpCruiseOrderClient.getCruiseOrder(Long.parseLong(cruiseOrderId)).getData(); |
| | | if (Objects.nonNull(xpCruiseOrder)){ |
| | | // 查询车辆 |
| | | XpVehicle xpVehicle = xpVehicleClient.queryById(xpCruiseOrder.getVehicleId()).getData(); |
| | | if (Objects.nonNull(xpVehicle)){ |
| | | String vin = xpVehicle.getVehicleVin(); |
| | | // 封装埋点消息实体 |
| | | VehicleEventDTO vehicleEventDTO = new VehicleEventDTO(); |
| | | vehicleEventDTO.setVin(vin); |
| | | vehicleEventDTO.setXpuId(""); |
| | | vehicleEventDTO.setOrderId(cruiseOrderId); |
| | | vehicleEventDTO.setEventKey("RT_xpu_vehicle_trace_upload"); |
| | | vehicleEventDTO.setEventTime(System.currentTimeMillis()); |
| | | Map<String,Object> attributes = new HashMap<>(); |
| | | attributes.put("vin",vin); |
| | | attributes.put("order_id",vehicleEventDTO.getOrderId()); |
| | | attributes.put("order_type","cruise_order"); |
| | | attributes.put("timestamp",vehicleEventDTO.getEventTime()); |
| | | attributes.put("current_main_status",OrderStatus.ORDER_ARRIVED_AT_CRUISE_DESTINATION); |
| | | attributes.put("current_sub_status",""); |
| | | VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(vin)), VehiclePosition.class); |
| | | if(Objects.nonNull(vehiclePosition)){ |
| | | attributes.put("odometer_km",vehiclePosition.getTotalOdometer()); |
| | | }else { |
| | | attributes.put("odometer_km",""); |
| | | } |
| | | vehicleEventDTO.setAttributes(attributes); |
| | | vehicleBuriedPointClient.sendVehicleEvent(vehicleEventDTO); |
| | | log.info("到达巡游终点,推送埋点:{}", orderId); |
| | | } |
| | | } |
| | | }else if(orderId.contains("TEST")){ |
| | | //测试巡游单处理逻辑 |
| | | testOrderClient.updateOrderStatus(Long.parseLong(orderId.substring(4)), OrderStatusEnum.COMPLETED.getCode()); |
| | | } |
| | | break; |
| | | case ORDER_PAUSED: |
| | |
| | | * 令牌前缀 |
| | | */ |
| | | public static final String PREFIX = "Bearer "; |
| | | |
| | | /** |
| | | * 令牌秘钥 |
| | | */ |
| | | public final static String SECRET = "abcdefghijklmnopqrstuvwxyz"; |
| | | |
| | | /** |
| | | * 参数签名 |
| | |
| | | */ |
| | | public class JwtUtils |
| | | { |
| | | public static String secret = TokenConstants.SECRET; |
| | | |
| | | /** |
| | | * 从数据声明生成令牌 |
| | |
| | | * @param claims 数据声明 |
| | | * @return 令牌 |
| | | */ |
| | | public static String createToken(Map<String, Object> claims) |
| | | public static String createToken(Map<String, Object> claims, String secret) |
| | | { |
| | | String token = Jwts.builder().setClaims(claims).signWith(SignatureAlgorithm.HS512, secret).compact(); |
| | | return token; |
| | |
| | | * @param token 令牌 |
| | | * @return 数据声明 |
| | | */ |
| | | public static Claims parseToken(String token) |
| | | public static Claims parseToken(String token, String secret) |
| | | { |
| | | return Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody(); |
| | | } |
| | |
| | | * @param token 令牌 |
| | | * @return 用户ID |
| | | */ |
| | | public static String getUserKey(String token) |
| | | public static String getUserKey(String token, String secret) |
| | | { |
| | | Claims claims = parseToken(token); |
| | | Claims claims = parseToken(token, secret); |
| | | return getValue(claims, SecurityConstants.USER_KEY); |
| | | } |
| | | /** |
| | |
| | | * @param token 令牌 |
| | | * @return 用户ID |
| | | */ |
| | | public static String getOperationUserKey(String token) |
| | | public static String getOperationUserKey(String token, String secret) |
| | | { |
| | | Claims claims = parseToken(token); |
| | | Claims claims = parseToken(token, secret); |
| | | return getValue(claims, SecurityConstants.OPERATION_USER_KEY); |
| | | } |
| | | |
| | |
| | | * @param token 令牌 |
| | | * @return 用户类型 |
| | | */ |
| | | public static String getUserType(String token) |
| | | public static String getUserType(String token, String secret) |
| | | { |
| | | Claims claims = parseToken(token); |
| | | Claims claims = parseToken(token, secret); |
| | | return getValue(claims, SecurityConstants.USER_TYPE); |
| | | } |
| | | |
| | |
| | | * @param token 令牌 |
| | | * @return 用户ID |
| | | */ |
| | | public static String getUserKeyApplet(String token) |
| | | public static String getUserKeyApplet(String token, String secret) |
| | | { |
| | | Claims claims = parseToken(token); |
| | | Claims claims = parseToken(token, secret); |
| | | return getValue(claims, SecurityConstants.USER_APPLET_KEY); |
| | | } |
| | | /** |
| | |
| | | * @param token 令牌 |
| | | * @return 用户ID |
| | | */ |
| | | public static String getUserId(String token) |
| | | public static String getUserId(String token, String secret) |
| | | { |
| | | Claims claims = parseToken(token); |
| | | Claims claims = parseToken(token, secret); |
| | | return getValue(claims, SecurityConstants.DETAILS_USER_ID); |
| | | } |
| | | |
| | |
| | | * @param token 令牌 |
| | | * @return 用户名 |
| | | */ |
| | | public static String getUserName(String token) |
| | | public static String getUserName(String token, String secret) |
| | | { |
| | | Claims claims = parseToken(token); |
| | | Claims claims = parseToken(token, secret); |
| | | return getValue(claims, SecurityConstants.DETAILS_USERNAME); |
| | | } |
| | | |
| | |
| | | { |
| | | throw new NotLoginException("未提供token"); |
| | | } |
| | | Claims claims = JwtUtils.parseToken(token); |
| | | Claims claims = JwtUtils.parseToken(token, tokenService.getSecret()); |
| | | String userType = JwtUtils.getUserType(claims); |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | if (loginUser == null && "system".equals(userType)) |
| | |
| | | public AjaxResult handleRuntimeException(RuntimeException e, HttpServletRequest request) { |
| | | String requestURI = request.getRequestURI(); |
| | | log.error("请求地址'{}',发生未知异常.", requestURI, e); |
| | | return AjaxResult.error(e.getMessage()); |
| | | return AjaxResult.error("系统繁忙,请稍后重试"); |
| | | } |
| | | |
| | | /** |
| | |
| | | public AjaxResult handleException(Exception e, HttpServletRequest request) { |
| | | String requestURI = request.getRequestURI(); |
| | | log.error("请求地址'{}',发生系统异常.", requestURI, e); |
| | | return AjaxResult.error(e.getMessage()); |
| | | return AjaxResult.error("系统繁忙,请稍后重试"); |
| | | } |
| | | |
| | | /** |
| | |
| | | import com.xiaopeng.common.core.exception.auth.NotLoginException; |
| | | import com.xiaopeng.api.vo.account.LoginUser; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Component; |
| | | import com.xiaopeng.common.core.constant.CacheConstants; |
| | | import com.xiaopeng.common.core.constant.SecurityConstants; |
| | |
| | | public class TokenService { |
| | | @Autowired |
| | | private RedisService redisService; |
| | | |
| | | @Value("${token.secret}") |
| | | private String secret; |
| | | |
| | | protected static final long MILLIS_SECOND = 1000; |
| | | |
| | |
| | | claimsMap.put(SecurityConstants.DETAILS_USERNAME, userName); |
| | | // 接口返回信息 |
| | | Map<String, Object> rspMap = new HashMap<String, Object>(); |
| | | rspMap.put("access_token", JwtUtils.createToken(claimsMap)); |
| | | rspMap.put("access_token", JwtUtils.createToken(claimsMap, secret)); |
| | | rspMap.put("expires_in", expireTime); |
| | | return rspMap; |
| | | } |
| | |
| | | claimsMap.put(SecurityConstants.DETAILS_USERNAME, userName); |
| | | // 接口返回信息 |
| | | Map<String, Object> rspMap = new HashMap<String, Object>(); |
| | | rspMap.put("access_token", JwtUtils.createToken(claimsMap)); |
| | | rspMap.put("access_token", JwtUtils.createToken(claimsMap, secret)); |
| | | rspMap.put("expires_in", expireTime); |
| | | return rspMap; |
| | | } |
| | |
| | | LoginUser user = null; |
| | | try { |
| | | if (StringUtils.isNotEmpty(token)) { |
| | | String userkey = JwtUtils.getUserKey(token); |
| | | String userkey = JwtUtils.getUserKey(token, secret); |
| | | user = redisService.getCacheObject(getTokenKey(userkey)); |
| | | return user; |
| | | } |
| | |
| | | LoginOperationUser user = null; |
| | | try { |
| | | if (StringUtils.isNotEmpty(token)) { |
| | | String userkey = JwtUtils.getOperationUserKey(token); |
| | | String userkey = JwtUtils.getOperationUserKey(token, secret); |
| | | user = redisService.getCacheObject(getTokenKey(userkey)); |
| | | return user; |
| | | } |
| | |
| | | */ |
| | | public void delLoginUser(String token) { |
| | | if (StringUtils.isNotEmpty(token)) { |
| | | String userkey = JwtUtils.getUserKey(token); |
| | | String userkey = JwtUtils.getUserKey(token, secret); |
| | | redisService.deleteObject(getTokenKey(userkey)); |
| | | } |
| | | } |
| | |
| | | private String getUserKey(Long userid) { |
| | | return ACCESS_TOKEN + userid; |
| | | } |
| | | |
| | | public String getSecret() { |
| | | return secret; |
| | | } |
| | | } |
| | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.cloud.gateway.filter.GatewayFilterChain; |
| | | import org.springframework.cloud.gateway.filter.GlobalFilter; |
| | | import org.springframework.core.Ordered; |
| | |
| | | |
| | | @Autowired |
| | | private RedisService redisService; |
| | | |
| | | @Value("${token.secret}") |
| | | private String secret; |
| | | |
| | | |
| | | |
| | |
| | | |
| | | |
| | | String token = getToken(request); |
| | | Claims claims = JwtUtils.parseToken(token); |
| | | Claims claims = JwtUtils.parseToken(token, secret); |
| | | String userkey = JwtUtils.getUserKey(claims); |
| | | String userid = JwtUtils.getUserId(claims); |
| | | String username = JwtUtils.getUserName(claims); |
| | |
| | | if (StringUtils.isEmpty(token)) { |
| | | throw new NotLoginException("令牌不能为空"); |
| | | } |
| | | Claims claims = JwtUtils.parseToken(token); |
| | | Claims claims = JwtUtils.parseToken(token, secret); |
| | | if (claims == null) { |
| | | throw new NotLoginException("令牌已过期或验证不正确!"); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | @PostMapping("/inner/v1/pricing/getWaitTime") |
| | | public R<Integer> getWaitTime1(@RequestBody LonLatDto dto) { |
| | | return R.ok(xpPricingService.getWaitTime(dto.getLongitude(), dto.getLatitude())); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 播单 |
| | |
| | | |
| | | |
| | | |
| | | @GetMapping("/base/v1/mini-program/order/testOrder") |
| | | public R testOrder(Long orderId, Integer status){ |
| | | xpPricingService.testOrder(orderId, status); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | */ |
| | | String saveOrder(XpOrderDto dto, String uid); |
| | | |
| | | void testOrder(Long orderId, Integer status); |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | // 判断当天取消的次数 后台配置 redis 查询 |
| | | // Object cancelOrder = redisService.getCacheObject("CANCEL_ORDER_" + uid); |
| | | // log.info("取消次数:{}", cancelOrder); |
| | | // // 静默处理 |
| | | // boolean isSilent = false; |
| | | // if (cancelOrder != null) { |
| | | // Integer num = Integer.valueOf(cancelOrder.toString()); |
| | | // if (num >= cancelCount) { |
| | | // isSilent = true; |
| | | // } |
| | | // } |
| | | Object cancelOrder = redisService.getCacheObject("CANCEL_ORDER_" + uid); |
| | | log.info("取消次数:{}", cancelOrder); |
| | | // 静默处理 |
| | | boolean isSilent = false; |
| | | if (cancelOrder != null) { |
| | | Integer num = Integer.valueOf(cancelOrder.toString()); |
| | | if (num >= cancelCount) { |
| | | isSilent = true; |
| | | } |
| | | } |
| | | |
| | | |
| | | // 获取起步里程 |
| | |
| | | |
| | | // 生成订单数据 |
| | | XpOrder xpOrder = new XpOrder(); |
| | | |
| | | xpOrder.setMileageKilometers(0.0); |
| | | |
| | | // xpOrder.setVehicleId(1l); |
| | | |
| | | // xpOrder.setStartMileage(Double.valueOf(startMileage)); |
| | | |
| | | xpOrder.setAppUserId(Long.valueOf(uid)); |
| | | xpOrder.setOrderNumber("XP" + System.currentTimeMillis()); |
| | | xpOrder.setPlacementLon(dto.getPlacementLon()); |
| | |
| | | xpOrder.setId(orderId); |
| | | |
| | | // 静默处理 不推单 |
| | | // if (isSilent) { |
| | | // log.info("订单取消次数达到上限,执行静默处理,不推单。"); |
| | | // return orderId.toString(); |
| | | // } |
| | | if (isSilent) { |
| | | log.info("订单取消次数达到上限,执行静默处理,不推单。"); |
| | | return orderId.toString(); |
| | | } |
| | | |
| | | // 最大距离 |
| | | Object maxPushDistanceObj = redisService.getCacheObject(CacheConstants.MAX_PUSH_DISTANCE); |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 测试阶段用于自动完成小程序的整个流程数据状态流转 |
| | | * @param orderId |
| | | */ |
| | | public void testOrder(Long orderId, Integer status) { |
| | | XpOrder xpOrder = xpOrderClient.queryOrderById(orderId).getData(); |
| | | Long appUserId = xpOrder.getAppUserId(); |
| | | if (2 == status) { |
| | | if (xpOrder.getStatus() == 0) { |
| | | return; |
| | | } |
| | | xpOrder.setAppUserId(null); |
| | | xpOrder.setStatus(2); |
| | | xpOrder.setVehicleId(1L); |
| | | xpOrder.setFleetId(2L); |
| | | xpOrderClient.updateOrder(xpOrder); |
| | | } |
| | | if (3 == status) { |
| | | //修改状态为接驾中 |
| | | xpOrder = xpOrderClient.queryOrderById(orderId).getData(); |
| | | if (xpOrder.getStatus() == 0) { |
| | | return; |
| | | } |
| | | xpOrder.setAppUserId(null); |
| | | xpOrder.setStatus(3); |
| | | xpOrderClient.updateOrder(xpOrder); |
| | | //发送订单状态 |
| | | SendMessageDTO dto = new SendMessageDTO(); |
| | | dto.setAppUserId(appUserId.toString()); |
| | | dto.setMessage("{\"type\":\"ORDER_STATUS\",\"content\":\"{\\\"orderId\\\":\\\"" + orderId + "\\\",\\\"status\\\":3}\",\"timestamp\":\"176569945845456\"}"); |
| | | xpPushMessageClient.sendStatus(dto); |
| | | //推送车辆位置 |
| | | dto.setAppUserId(appUserId.toString()); |
| | | dto.setMessage("{\"type\":\"VEHICLE_LOCATION\",\"content\":\"{\\\"orderId\\\":\\\"" + orderId + "\\\",\\\"lon\\\":113.385848,\\\"lat\\\":23.156841}\",\"timestamp\":\"176569945845456\"}"); |
| | | xpPushMessageClient.sendVehicleLocation(dto); |
| | | //发送车辆到达起点的轨迹 |
| | | OrderRouteAndFareDto routeAndFareDto = new OrderRouteAndFareDto(); |
| | | LonLatDto destination = new LonLatDto(); |
| | | destination.setLongitude(xpOrder.getStartLon()); |
| | | destination.setLatitude(xpOrder.getStartLat()); |
| | | routeAndFareDto.setDestination(destination); |
| | | LonLatDto origin = new LonLatDto(); |
| | | origin.setLongitude(113.385848); |
| | | origin.setLatitude(23.156841); |
| | | routeAndFareDto.setOrigin(origin); |
| | | routeAndFareDto.setRouteType(1); |
| | | routeAndFareDto.setOrderId(orderId); |
| | | RouteVo routeVo = xpMapClient.getOrderDistanceAndDuration(routeAndFareDto).getData(); |
| | | com.alibaba.fastjson2.JSONObject jsonObject = new com.alibaba.fastjson2.JSONObject(); |
| | | jsonObject.put("type", "ORDER_ROUTE"); |
| | | jsonObject.put("timestamp", System.currentTimeMillis()); |
| | | com.alibaba.fastjson2.JSONObject content = new com.alibaba.fastjson2.JSONObject(); |
| | | content.put("orderId", orderId.toString()); |
| | | content.put("routeType", 1); |
| | | com.alibaba.fastjson2.JSONObject route = new com.alibaba.fastjson2.JSONObject(); |
| | | route.put("distance", routeVo.getDistance()); |
| | | route.put("duration", routeVo.getDuration()); |
| | | route.put("routeID", routeVo.getRouteID()); |
| | | |
| | | List<com.alibaba.fastjson2.JSONObject> collect = routeVo.getPolyline().stream().map(item -> { |
| | | com.alibaba.fastjson2.JSONObject point = new com.alibaba.fastjson2.JSONObject(); |
| | | point.put("latitude", item.getLatitude()); |
| | | point.put("longitude", item.getLongitude()); |
| | | return point; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | route.put("polyline", JSON.toJSONString(collect)); |
| | | content.put("route", route.toJSONString()); |
| | | jsonObject.put("content", content.toJSONString()); |
| | | SendMessageDTO messageDTO = new SendMessageDTO(); |
| | | messageDTO.setAppUserId(appUserId.toString()); |
| | | messageDTO.setMessage(jsonObject.toJSONString()); |
| | | xpPushMessageClient.sendRoute(messageDTO); |
| | | } |
| | | if (4 == status) { |
| | | //司机到达起点 |
| | | xpOrder = xpOrderClient.queryOrderById(orderId).getData(); |
| | | if (xpOrder.getStatus() == 0) { |
| | | return; |
| | | } |
| | | xpOrder.setAppUserId(null); |
| | | xpOrder.setStatus(4); |
| | | xpOrderClient.updateOrder(xpOrder); |
| | | SendMessageDTO dto = new SendMessageDTO(); |
| | | dto.setAppUserId(appUserId.toString()); |
| | | dto.setMessage("{\"type\":\"ORDER_STATUS\",\"content\":\"{\\\"orderId\\\":\\\"" + orderId + "\\\",\\\"status\\\":4}\",\"timestamp\":\"176569945845456\"}"); |
| | | xpPushMessageClient.sendStatus(dto); |
| | | //推送车辆位置到起点 |
| | | dto.setAppUserId(appUserId.toString()); |
| | | dto.setMessage("{\"type\":\"VEHICLE_LOCATION\",\"content\":\"{\\\"orderId\\\":\\\"" + orderId + "\\\",\\\"lon\\\":" + xpOrder.getStartLon() + ",\\\"lat\\\":" + xpOrder.getStartLat() + "}\",\"timestamp\":\"176569945845456\"}"); |
| | | xpPushMessageClient.sendVehicleLocation(dto); |
| | | } |
| | | if (5 == status) { |
| | | //乘客上车 |
| | | xpOrder = xpOrderClient.queryOrderById(orderId).getData(); |
| | | if (xpOrder.getStatus() == 0) { |
| | | return; |
| | | } |
| | | xpOrder.setAppUserId(null); |
| | | xpOrder.setStatus(5); |
| | | xpOrder.setBoardingTime(LocalDateTime.now()); |
| | | xpOrder.setBoardingLat(xpOrder.getStartLat()); |
| | | xpOrder.setBoardingLon(xpOrder.getStartLon()); |
| | | xpOrder.setBoardingAddress(xpOrder.getStartAddress()); |
| | | xpOrderClient.updateOrder(xpOrder); |
| | | SendMessageDTO dto = new SendMessageDTO(); |
| | | dto.setAppUserId(appUserId.toString()); |
| | | dto.setMessage("{\"type\":\"ORDER_STATUS\",\"content\":\"{\\\"orderId\\\":\\\"" + orderId + "\\\",\\\"status\\\":5}\",\"timestamp\":\"176569945845456\"}"); |
| | | xpPushMessageClient.sendStatus(dto); |
| | | //推送起点到终点的行驶轨迹 |
| | | OrderRouteAndFareDto routeAndFareDto = new OrderRouteAndFareDto(); |
| | | routeAndFareDto.setDestination(new LonLatDto(xpOrder.getEndLon(), xpOrder.getEndLat())); |
| | | routeAndFareDto.setOrigin(new LonLatDto(xpOrder.getStartLon(), xpOrder.getStartLat())); |
| | | routeAndFareDto.setRouteType(2); |
| | | routeAndFareDto.setOrderId(orderId); |
| | | RouteVo routeVo = xpMapClient.getOrderDistanceAndDuration(routeAndFareDto).getData(); |
| | | com.alibaba.fastjson2.JSONObject jsonObject = new com.alibaba.fastjson2.JSONObject(); |
| | | jsonObject.put("type", "ORDER_ROUTE"); |
| | | jsonObject.put("timestamp", System.currentTimeMillis()); |
| | | com.alibaba.fastjson2.JSONObject content = new com.alibaba.fastjson2.JSONObject(); |
| | | content.put("orderId", orderId.toString()); |
| | | content.put("routeType", 2); |
| | | com.alibaba.fastjson2.JSONObject route = new com.alibaba.fastjson2.JSONObject(); |
| | | route.put("distance", routeVo.getDistance()); |
| | | route.put("duration", routeVo.getDuration()); |
| | | route.put("routeID", routeVo.getRouteID()); |
| | | List<com.alibaba.fastjson2.JSONObject> collect = routeVo.getPolyline().stream().map(item -> { |
| | | com.alibaba.fastjson2.JSONObject point = new com.alibaba.fastjson2.JSONObject(); |
| | | point.put("latitude", item.getLatitude()); |
| | | point.put("longitude", item.getLongitude()); |
| | | return point; |
| | | }).collect(Collectors.toList()); |
| | | route.put("polyline", JSON.toJSONString(collect)); |
| | | content.put("route", route.toJSONString()); |
| | | jsonObject.put("content", content.toJSONString()); |
| | | SendMessageDTO messageDTO = new SendMessageDTO(); |
| | | messageDTO.setAppUserId(appUserId.toString()); |
| | | messageDTO.setMessage(jsonObject.toJSONString()); |
| | | xpPushMessageClient.sendRoute(messageDTO); |
| | | } |
| | | if (6 == status) { |
| | | //开始服务中 |
| | | xpOrder.setAppUserId(null); |
| | | xpOrder.setStatus(6); |
| | | xpOrder.setTripBegin(LocalDateTime.now()); |
| | | xpOrderClient.updateOrder(xpOrder); |
| | | SendMessageDTO dto = new SendMessageDTO(); |
| | | dto.setAppUserId(appUserId.toString()); |
| | | dto.setMessage("{\"type\":\"ORDER_STATUS\",\"content\":\"{\\\"orderId\\\":\\\"" + orderId + "\\\",\\\"status\\\":6}\",\"timestamp\":\"176569945845456\"}"); |
| | | xpPushMessageClient.sendStatus(dto); |
| | | } |
| | | |
| | | if (7 == status) { |
| | | //乘客待下车 |
| | | xpOrder.setAppUserId(null); |
| | | xpOrder.setStatus(7); |
| | | xpOrder.setTripEnd(LocalDateTime.now()); |
| | | xpOrder.setGetoffLat(xpOrder.getEndLat()); |
| | | xpOrder.setGetoffLon(xpOrder.getEndLon()); |
| | | xpOrder.setGetoffAddress(xpOrder.getEndAddress()); |
| | | xpOrder.setGetoffTime(LocalDateTime.now()); |
| | | xpOrder.setOrderMoney(new BigDecimal(50)); |
| | | xpOrder.setStartMileage(5D); |
| | | xpOrder.setStartMoney(new BigDecimal(10)); |
| | | xpOrder.setMileageKilometers(10D); |
| | | xpOrder.setMileageMoney(new BigDecimal(25)); |
| | | xpOrder.setDuration(20D); |
| | | xpOrder.setDurationMoney(new BigDecimal(5)); |
| | | xpOrder.setWait(0D); |
| | | xpOrder.setWaitMoney(new BigDecimal(0)); |
| | | xpOrder.setLongDistance(10D); |
| | | xpOrder.setLongDistanceType(1); |
| | | xpOrder.setLongDistancemoney(new BigDecimal(10)); |
| | | xpOrderClient.updateOrder(xpOrder); |
| | | //推送车辆位置到起点 |
| | | SendMessageDTO dto = new SendMessageDTO(); |
| | | dto.setAppUserId(appUserId.toString()); |
| | | dto.setMessage("{\"type\":\"VEHICLE_LOCATION\",\"content\":\"{\\\"orderId\\\":\\\"" + orderId + "\\\",\\\"lon\\\":" + xpOrder.getEndLon() + ",\\\"lat\\\":" + xpOrder.getEndLat() + "}\",\"timestamp\":\"176569945845456\"}"); |
| | | xpPushMessageClient.sendVehicleLocation(dto); |
| | | dto.setAppUserId(appUserId.toString()); |
| | | dto.setMessage("{\"type\":\"ORDER_STATUS\",\"content\":\"{\\\"orderId\\\":\\\"" + orderId + "\\\",\\\"status\\\":7}\",\"timestamp\":\"176569945845456\"}"); |
| | | xpPushMessageClient.sendStatus(dto); |
| | | } |
| | | //添加费用明细 |
| | | // XpOrderDetail detail = new XpOrderDetail(); |
| | | // detail.setDetailType(1); |
| | | // detail.setOrderId(orderId); |
| | | // detail.setType(1); |
| | | // detail.setTime(""); |
| | | // detail.setDuration(20D); |
| | | // detail.setMileage(new BigDecimal(10)); |
| | | // detail.setMoney(); |
| | | // detail.setIsDeleted(false); |
| | | // detail.setCreateTime(LocalDateTime.now()); |
| | | // detail.setUpdateTime(LocalDateTime.now()); |
| | | // xpOrder |
| | | |
| | | |
| | | if (8 == status) { |
| | | //乘客待支付 |
| | | xpOrder.setAppUserId(null); |
| | | xpOrder.setStatus(8); |
| | | xpOrderClient.updateOrder(xpOrder); |
| | | SendMessageDTO dto = new SendMessageDTO(); |
| | | dto.setAppUserId(appUserId.toString()); |
| | | dto.setMessage("{\"type\":\"ORDER_STATUS\",\"content\":\"{\\\"orderId\\\":\\\"" + orderId + "\\\",\\\"status\\\":8}\",\"timestamp\":\"176569945845456\"}"); |
| | | xpPushMessageClient.sendStatus(dto); |
| | | } |
| | | |
| | | if (9 == status) { |
| | | //乘客支付成功 |
| | | xpOrder.setAppUserId(null); |
| | | xpOrder.setStatus(9); |
| | | xpOrderClient.updateOrder(xpOrder); |
| | | SendMessageDTO dto = new SendMessageDTO(); |
| | | dto.setAppUserId(appUserId.toString()); |
| | | dto.setMessage("{\"type\":\"ORDER_STATUS\",\"content\":\"{\\\"orderId\\\":\\\"" + orderId + "\\\",\\\"status\\\":9}\",\"timestamp\":\"176569945845456\"}"); |
| | | xpPushMessageClient.sendStatus(dto); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (vehiclePictures != null && !vehiclePictures.isEmpty()) { |
| | | JSONObject jsonObject = JSONObject.parseObject(vehiclePictures); |
| | | // 2 |
| | | String downloadUrl = jsonObject.getString("url");; |
| | | String downloadUrl = jsonObject.getString("url"); |
| | | try { |
| | | downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | } catch (UnsupportedEncodingException e) { |
| | |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | // 1 |
| | | String downloadUrl = jsonObject.getString("url");; |
| | | String downloadUrl = jsonObject.getString("url"); |
| | | try { |
| | | downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | } catch (UnsupportedEncodingException e) { |
| | |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | // 1 |
| | | String downloadUrl = jsonObject.getString("url");; |
| | | String downloadUrl = jsonObject.getString("url"); |
| | | try { |
| | | downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | } catch (UnsupportedEncodingException e) { |
| | |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | // 1 |
| | | String downloadUrl = jsonObject.getString("url");; |
| | | String downloadUrl = jsonObject.getString("url"); |
| | | try { |
| | | downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | } catch (UnsupportedEncodingException e) { |
| | |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | // 1 |
| | | String downloadUrl = jsonObject.getString("url");; |
| | | String downloadUrl = jsonObject.getString("url"); |
| | | try { |
| | | downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | } catch (UnsupportedEncodingException e) { |
| | |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | // 1 |
| | | String downloadUrl = jsonObject.getString("url");; |
| | | String downloadUrl = jsonObject.getString("url"); |
| | | try { |
| | | downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | } catch (UnsupportedEncodingException e) { |
| | |
| | | package com.xiaopeng.maintenance.controller; |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.xiaopeng.api.dto.automaticPilot.VehicleEventDTO; |
| | | import com.xiaopeng.api.dto.operation.NewCruiseOrderDto; |
| | | import com.xiaopeng.api.feignClient.automaticPilot.VehicleBuriedPointClient; |
| | | import com.xiaopeng.api.feignClient.operation.XpCruisePlanClient; |
| | | import com.xiaopeng.api.feignClient.order.XpCruiseOrderClient; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private AliOssService aliOssService; |
| | | @Autowired |
| | | private XpCruisePlanClient xpCruisePlanClient; |
| | | @Autowired |
| | | private VehicleBuriedPointClient vehicleBuriedPointClient; |
| | | |
| | | /** |
| | | * 车辆详情-车辆调度-发车 收车 |
| | |
| | | if(vehiclePosition==null || vehiclePosition.getPoint()==null){ |
| | | return R.fail("车辆位置信息不存在"); |
| | | } |
| | | |
| | | Integer departureStatus = dto.getDepartureStatus(); |
| | | XpVehicle vehicle1 = new XpVehicle(); |
| | | vehicle1.setOperatingStatus(dto.getDepartureStatus()); |
| | | vehicle1.setOperatingStatus(departureStatus); |
| | | vehicle1.setId(xpVehicle.getId()); |
| | | xpVehicleClient.updateVehicleById(vehicle1); |
| | | |
| | | // 封装埋点消息实体 |
| | | VehicleEventDTO vehicleEventDTO = new VehicleEventDTO(); |
| | | vehicleEventDTO.setVin(xpVehicle.getVehicleVin()); |
| | | vehicleEventDTO.setXpuId(""); |
| | | vehicleEventDTO.setOrderId(""); |
| | | vehicleEventDTO.setEventKey("RT_web_vehicle_status_changed"); |
| | | vehicleEventDTO.setEventTime(System.currentTimeMillis()); |
| | | Map<String,Object> attributes = new HashMap<>(); |
| | | attributes.put("vin",xpVehicle.getVehicleVin()); |
| | | attributes.put("order_id",""); |
| | | attributes.put("timestamp",vehicleEventDTO.getEventTime()); |
| | | if(departureStatus == 1){ |
| | | attributes.put("main_status","ONLINE"); |
| | | // TODO 预留位置 目前无状态 |
| | | attributes.put("sub_status",""); |
| | | attributes.put("prev_sub_status",""); |
| | | |
| | | }else { |
| | | attributes.put("main_status","OFFLINE"); |
| | | // TODO 预留位置 目前无状态 |
| | | attributes.put("sub_status",""); |
| | | attributes.put("prev_sub_status",""); |
| | | } |
| | | vehicleEventDTO.setAttributes(attributes); |
| | | vehicleBuriedPointClient.sendVehicleEvent(vehicleEventDTO); |
| | | |
| | | // 发车 |
| | | if(dto.getDepartureStatus()==1){ |
| | | // 找车辆的任务 生成巡游单子 下发命令 |
| | |
| | | if(returnCruisePoint!=null){ |
| | | xpCruiseOrderClient.addCruiseOrder(returnCruisePoint); |
| | | } |
| | | |
| | | } |
| | | return R.ok(); |
| | | } |
| | |
| | | jsonObject.put("url", downloadUrl); |
| | | xpVehiclePreparationVO.setVehiclePictures(jsonObject.toJSONString()); |
| | | } |
| | | |
| | | |
| | | |
| | | return R.ok(xpVehiclePreparationVO); |
| | | } |
| | | |
| | |
| | | if (StringUtils.isNotBlank(vehiclePictures)) { |
| | | JSONObject jsonObject = JSONObject.parseObject(vehiclePictures); |
| | | // 1 |
| | | String downloadUrl = jsonObject.getString("url");; |
| | | String downloadUrl = jsonObject.getString("url"); |
| | | try { |
| | | downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | } catch (UnsupportedEncodingException e) { |
| | |
| | | continue; |
| | | } |
| | | // 1 |
| | | String downloadUrl = jsonObject.getString("url");; |
| | | String downloadUrl = jsonObject.getString("url"); |
| | | try { |
| | | downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | } catch (UnsupportedEncodingException e) { |
| | |
| | | } |
| | | xpVehicleRepairVO.setStartRepairPicture(JSONArray.toJSONString(jsonArray)); |
| | | } |
| | | |
| | | String repairMoneyDetail = xpVehicleRepairVO.getRepairMoneyDetail(); |
| | | if (StringUtils.isNotBlank(repairMoneyDetail)) { |
| | | JSONObject jsonObject = JSONObject.parseObject(repairMoneyDetail); |
| | | if(jsonObject!=null){ |
| | | String downloadUrl = null; |
| | | try { |
| | | downloadUrl= aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | jsonObject.put("url", downloadUrl); |
| | | xpVehicleRepairVO.setRepairMoneyDetail(jsonObject.toJSONString()); |
| | | } |
| | | } |
| | | |
| | | return R.ok(xpVehicleRepairVO); |
| | | } |
| | |
| | | XpVehicle xpVehicle = xpVehicleClient.queryById(xpChargingRecord.getVehicleId()).getData(); |
| | | if (Objects.nonNull(xpVehicle)) { |
| | | xpChargingRecordVO.setPlateNumber(xpVehicle.getPlateNumber()); |
| | | |
| | | |
| | | |
| | | String vehiclePictures =xpVehicle.getVehiclePictures(); |
| | | if (StringUtils.isNotBlank(vehiclePictures)) { |
| | | JSONObject jsonObject = JSONObject.parseObject(vehiclePictures); |
| | |
| | | jsonObject.put("url", downloadUrl); |
| | | xpChargingRecordVO.setVehiclePictures(jsonObject.toJSONString()); |
| | | } |
| | | |
| | | |
| | | xpChargingRecordVO.setAcceptOrTest(xpVehicle.getAcceptOrTest()); |
| | | xpChargingRecordVO.setVehicleColor(xpVehicle.getVehicleColor()); |
| | | } |
| | |
| | | } |
| | | xpChargingRecordVO.setStartMileageRange(Objects.nonNull(xpChargingRecord.getStartMileageRange()) ? xpChargingRecord.getStartMileageRange() : 0F); |
| | | xpChargingRecordVO.setEndMileageRange(Objects.nonNull(xpChargingRecord.getEndMileageRange()) ? xpChargingRecord.getEndMileageRange() : 0F); |
| | | |
| | | // 图片封装 |
| | | try { |
| | | // 开始 |
| | | String startChargingPicture = xpChargingRecordVO.getStartChargingPicture(); |
| | | if (StringUtils.isNotBlank(startChargingPicture)) { |
| | | JSONArray jsonArray = JSONArray.parseArray(startChargingPicture); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | if (Objects.isNull(jsonObject)) { |
| | | continue; |
| | | } |
| | | String downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | jsonObject.put("url", downloadUrl); |
| | | } |
| | | xpChargingRecordVO.setStartChargingPicture(JSONArray.toJSONString(jsonArray)); |
| | | } |
| | | // 结束 |
| | | String endChargingPicture = xpChargingRecordVO.getEndChargingPicture(); |
| | | if (StringUtils.isNotBlank(endChargingPicture)) { |
| | | JSONArray jsonArray = JSONArray.parseArray(endChargingPicture); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | if (Objects.isNull(jsonObject)) { |
| | | continue; |
| | | } |
| | | String downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | jsonObject.put("url", downloadUrl); |
| | | } |
| | | xpChargingRecordVO.setEndChargingPicture(JSONArray.toJSONString(jsonArray)); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return xpChargingRecordVO; |
| | | } |
| | | |
| | |
| | | res.setStatus(task.getStatus()); |
| | | res.setTaskDescription(task.getTaskDescription()); |
| | | |
| | | String taskImage = res.getTaskImage(); |
| | | String taskImage = task.getTaskImage(); |
| | | if (StringUtils.isNotBlank(taskImage)) { |
| | | JSONArray jsonArray = JSONArray.parseArray(taskImage); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | |
| | | package com.xiaopeng.maintenance.service.impl; |
| | | |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xiaopeng.api.feignClient.account.XpOperationUserClient; |
| | |
| | | import com.xiaopeng.api.model.maintenance.XpVehiclePreparation; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xiaopeng.api.vo.automaticPilot.VehiclePosition; |
| | | import com.xiaopeng.evi.oss.service.AliOssService; |
| | | import com.xiaopeng.maintenance.model.query.XpVehiclePreparationPageQuery; |
| | | import com.xiaopeng.api.model.vehicleConvoy.XpVehicle; |
| | | import com.xiaopeng.api.vo.maintenance.XpVehiclePreparationDetailVO; |
| | |
| | | private XpVehicleClient xpVehicleClient; |
| | | @Autowired |
| | | private MongoTemplate mongoTemplate; |
| | | |
| | | @Autowired |
| | | private AliOssService aliOssService; |
| | | |
| | | @Override |
| | | public PageInfo<OperationRecordsVO> operationRecords(OperationRecordsQuery query) { |
| | |
| | | if (Objects.nonNull(operationsUserStart)) { |
| | | xpVehiclePreparationVO.setOperatorStartName(operationsUserStart.getNickName()); |
| | | } |
| | | |
| | | // 图片封装 |
| | | try { |
| | | // 大灯 |
| | | String headLight = xpVehiclePreparation.getHeadLight(); |
| | | if (StringUtils.isNotBlank(headLight)) { |
| | | JSONArray jsonArray = JSONArray.parseArray(headLight); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | if (Objects.isNull(jsonObject)) { |
| | | continue; |
| | | } |
| | | String downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | jsonObject.put("url", downloadUrl); |
| | | } |
| | | xpVehiclePreparationVO.setHeadLight(JSONArray.toJSONString(jsonArray)); |
| | | } |
| | | // 转向灯 |
| | | String turnSignal = xpVehiclePreparation.getTurnSignal(); |
| | | if (StringUtils.isNotBlank(turnSignal)) { |
| | | JSONArray jsonArray = JSONArray.parseArray(turnSignal); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | if (Objects.isNull(jsonObject)) { |
| | | continue; |
| | | } |
| | | String downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | jsonObject.put("url", downloadUrl); |
| | | } |
| | | xpVehiclePreparationVO.setTurnSignal(JSONArray.toJSONString(jsonArray)); |
| | | } |
| | | // 刹车灯 |
| | | String brakeLight = xpVehiclePreparation.getBrakeLight(); |
| | | if (StringUtils.isNotBlank(brakeLight)) { |
| | | JSONArray jsonArray = JSONArray.parseArray(brakeLight); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | if (Objects.isNull(jsonObject)) { |
| | | continue; |
| | | } |
| | | String downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | jsonObject.put("url", downloadUrl); |
| | | } |
| | | xpVehiclePreparationVO.setBrakeLight(JSONArray.toJSONString(jsonArray)); |
| | | } |
| | | // 雾灯 |
| | | String fogLight = xpVehiclePreparation.getFogLight(); |
| | | if (StringUtils.isNotBlank(fogLight)) { |
| | | JSONArray jsonArray = JSONArray.parseArray(fogLight); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | if (Objects.isNull(jsonObject)) { |
| | | continue; |
| | | } |
| | | String downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | jsonObject.put("url", downloadUrl); |
| | | } |
| | | xpVehiclePreparationVO.setFogLight(JSONArray.toJSONString(jsonArray)); |
| | | } |
| | | // 舱内清洁 |
| | | String cabinCleaning = xpVehiclePreparation.getCabinCleaning(); |
| | | if (StringUtils.isNotBlank(cabinCleaning)) { |
| | | JSONArray jsonArray = JSONArray.parseArray(cabinCleaning); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | if (Objects.isNull(jsonObject)) { |
| | | continue; |
| | | } |
| | | String downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | jsonObject.put("url", downloadUrl); |
| | | } |
| | | xpVehiclePreparationVO.setCabinCleaning(JSONArray.toJSONString(jsonArray)); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return xpVehiclePreparationVO; |
| | | } |
| | | |
| | |
| | | * @param dto |
| | | * @return |
| | | */ |
| | | @PostMapping("/base/v1/mini-program/fence/diagnosisArea") |
| | | @PostMapping("/base/v1/fence/diagnosisArea") |
| | | public R<Boolean> diagnosisArea(@RequestBody RouteAndFareDto dto){ |
| | | return R.ok(xpElectronicFenceAreaService.diagnosisArea(dto)); |
| | | } |
| | |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/base/v1/mini-program") |
| | | @RequestMapping("") |
| | | @Api(tags = "地图调用服务") |
| | | public class XpMapController { |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | @PostMapping("/map/getDistanceAndDuration") |
| | | @PostMapping("/base/v1/map/getDistanceAndDuration") |
| | | public R<RouteVo> getDistanceAndDuration(@RequestBody RouteAndFareDto dto){ |
| | | // 获取电子围栏的禁行区域点位 |
| | | GeoPoint startPoint = new GeoPoint(dto.getOrigin().getLongitude(),dto.getOrigin().getLatitude()); |
| | |
| | | * @param dto |
| | | * @return |
| | | */ |
| | | @PostMapping("/map/getOrderDistanceAndDuration") |
| | | @PostMapping("/base/v1/map/getOrderDistanceAndDuration") |
| | | public R<RouteVo> getOrderDistanceAndDuration(@Validated @RequestBody OrderRouteAndFareDto dto){ |
| | | // 获取电子围栏的禁行区域点位 |
| | | GeoPoint startPoint = new GeoPoint(dto.getOrigin().getLongitude(),dto.getOrigin().getLatitude()); |
| | |
| | | * @param routedID |
| | | * @return |
| | | */ |
| | | @PostMapping("/map/queryRouted") |
| | | @PostMapping("/base/v1/map/queryRouted") |
| | | public R<String> getOrderDistanceAndDuration(@RequestParam("routedID") String routedID){ |
| | | return R.ok(gdMapGeocodingUtil.routed(routedID)); |
| | | } |
| | |
| | | * 根据ip获取点位 |
| | | */ |
| | | @ApiOperation(value = "根据ip获取点位", tags = {"小程序-站点导航"}) |
| | | @GetMapping("/point/getPointByIp") |
| | | @GetMapping("/base/v1/mini-program/point/getPointByIp") |
| | | public R<PointByIpVo> getPointByIp(HttpServletRequest request) throws IOException { |
| | | String ip = request.getRemoteAddr(); |
| | | PointByIpVo pointByIpVo = AmapWalkingRouteUtil.ipLocation(ip); |
| | |
| | | public R<XpCruiseOrder> findReturnCruisePoint(@RequestBody XpCruiseOrder xpCruiseOrder) { |
| | | // 先找计划 |
| | | XpCruisePlanVehicle plan = xpCruisePlanVehicleService.getOne(new LambdaQueryWrapper<XpCruisePlanVehicle>().eq(XpCruisePlanVehicle::getVehicleId, xpCruiseOrder.getVehicleId())); |
| | | if(null == plan){ |
| | | return R.fail("没有巡游计划,执行收车失败"); |
| | | } |
| | | // 找对应的多个点位 |
| | | List<XpCruisePlanPoint> planPointList = xpCruisePlanPointService.list(new LambdaQueryWrapper<XpCruisePlanPoint>().eq(XpCruisePlanPoint::getCruisePlanId, plan.getCruisePlanId()).orderByAsc(XpCruisePlanPoint::getSortOrder)); |
| | | |
| | |
| | | * |
| | | * @return |
| | | */ |
| | | @GetMapping("/base/v1/mini-program/getFeedbackTypeById/{id}") |
| | | @GetMapping("/base/v1/getFeedbackTypeById/{id}") |
| | | public R<XpFeedbackType> getFeedbackTypeById(@PathVariable("id") Long id) { |
| | | return R.ok(xpFeedbackTypeService.getById(id)); |
| | | } |
| | |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/base/v1/mini-program") |
| | | @RequestMapping("") |
| | | @Api(tags = "开通城市模块") |
| | | public class XpOpenCityController extends BaseController { |
| | | |
| | |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "获取开通城市列表",tags = {"小程序-开通城市列表"},response = XpOpenCityVo.class) |
| | | @GetMapping("/cities/list") |
| | | @GetMapping("/base/v1/mini-program/cities/list") |
| | | public R<XpOpenCityVo> citiesList() { |
| | | return R.ok(xpOpenCityService.citiesList()); |
| | | } |
| | |
| | | /** |
| | | * 获取开通城市名称列表 |
| | | */ |
| | | @GetMapping("/api/v1/openCity/nameList") |
| | | @GetMapping("/base/v1/openCity/nameList") |
| | | public R<List<String>> getOpenCityNameList(String openCityIds) { |
| | | List<XpOpenCity> list = xpOpenCityService.listByIds(Arrays.asList(openCityIds.split(","))); |
| | | ArrayList<String> nameLists = new ArrayList<>(list.size()); |
| | |
| | | xpOpenCityService.upDown(id, status); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据省市区获取开通城市数据 |
| | | * @param provinceCode |
| | | * @param cityCode |
| | | * @param districtCode |
| | | * @return |
| | | */ |
| | | @PostMapping("/inner/v1/openCity/getXpOpenCity") |
| | | public R<XpOpenCity> getXpOpenCity(@RequestParam("provinceCode") String provinceCode, |
| | | @RequestParam("cityCode") String cityCode, |
| | | @RequestParam("districtCode") String districtCode){ |
| | | XpOpenCity xpOpenCity = xpOpenCityService.getXpOpenCity(provinceCode, cityCode, districtCode); |
| | | return R.ok(xpOpenCity); |
| | | } |
| | | } |
| | |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/base/v1/mini-program") |
| | | @RequestMapping("") |
| | | @Api(tags = "点位模块") |
| | | public class XpPointController extends BaseController { |
| | | |
| | |
| | | * 获取附近上车站点 |
| | | */ |
| | | @ApiOperation(value = "获取附近上车站点",tags = {"小程序-附近上车站点"},response = XpPoint.class) |
| | | @PostMapping("/pickup/nearest") |
| | | @PostMapping("/base/v1/mini-program/pickup/nearest") |
| | | public R<NearestVo> nearest(@RequestBody @Valid NearestDto dto) { |
| | | return R.ok(xpPointService.nearest(dto)); |
| | | } |
| | |
| | | * @param historyStartPointsDto |
| | | * @return |
| | | */ |
| | | @PostMapping("/xp-point/getHistoryStartPoints") |
| | | @PostMapping("/base/v1/xp-point/getHistoryStartPoints") |
| | | public R<List<XpHistoryStartPointsVo>> getHistoryStartPoints(@RequestBody HistoryStartPointsDto historyStartPointsDto){ |
| | | List<XpHistoryStartPointsVo> xpPoints = xpPointService.getHistoryStartPoints(historyStartPointsDto); |
| | | return R.ok(xpPoints); |
| | |
| | | * @param historyEndPointsDto |
| | | * @return |
| | | */ |
| | | @PostMapping("/xp-point/getHistoryEndPoints") |
| | | @PostMapping("/base/v1/xp-point/getHistoryEndPoints") |
| | | public R<List<XpHistoryEndPointsVo>> getHistoryEndPoints(@RequestBody HistoryEndPointsDto historyEndPointsDto){ |
| | | List<XpHistoryEndPointsVo> xpPoints = xpPointService.getHistoryEndPoints(historyEndPointsDto); |
| | | return R.ok(xpPoints); |
| | |
| | | * 根据名称获取点位列表 |
| | | */ |
| | | @ApiOperation(value = "根据名称poi获取点位列表",tags = {"小程序-根据名称获取点位列表"},response = XpPoint.class) |
| | | @PostMapping("/xp-point/queryPointByName") |
| | | @PostMapping("/base/v1/mini-program/xp-point/queryPointByName") |
| | | public R<XpPointsSearchVo> listAll(@RequestBody @Valid PointByNameQuery query) { |
| | | XpPointsSearchVo vo = xpPointService.queryPointByName(query); |
| | | return R.ok(vo); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/inner/point/getPointsInfo") |
| | | @PostMapping("/inner/v1/point/getPointsInfo") |
| | | public R<List<XpPoint>> getPointsInfo(@RequestBody Set<Long> points){ |
| | | List<XpPoint> xpPoints = xpPointService.listByIds(points); |
| | | return R.ok(xpPoints); |
| | |
| | | * 获取下单最大距离 最小距离 |
| | | */ |
| | | @ApiOperation(value = "获取可下单最大距离 最小距离",tags = {"小程序-获取可下单最大距离 最小距离"},response = XpPoint.class) |
| | | @GetMapping("/xp-point/getOrderDistance") |
| | | @GetMapping("/base/v1/mini-program/xp-point/getOrderDistance") |
| | | public R<OrderDistanceVo> getOrderDistance() { |
| | | OrderDistanceVo vo = xpPointService.getOrderDistance(); |
| | | return R.ok(vo); |
| | |
| | | * @param pointId |
| | | * @return |
| | | */ |
| | | @GetMapping("/inner/point/nowInTimePoint") |
| | | @GetMapping("/inner/v1/point/nowInTimePoint") |
| | | public R<Boolean> nowInTimePoint(@RequestParam Long pointId){ |
| | | return R.ok(xpPointService.nowInTimePoint(pointId)); |
| | | } |
| | |
| | | return R.ok(pricing); |
| | | } |
| | | // 根据开通城市 获取定价 |
| | | @GetMapping("/base/v1/mini-program/getPricingByCid") |
| | | @GetMapping("/inner/v1/getPricingByCid") |
| | | public R<XpPricing> getPricingByCid(@RequestParam Long cityId) { |
| | | XpPricing pricing = xpPricingService.lambdaQuery().eq(XpPricing::getCityId, cityId).last("limit 1").one(); |
| | | return R.ok(pricing); |
| | |
| | | package com.xiaopeng.operation.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.xiaopeng.api.model.operation.XpRoutePlan; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.web.page.PageInfo; |
| | |
| | | * @since 2026-02-03 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/api/v1/routePlan") |
| | | @RequestMapping("") |
| | | @Api(tags = "路线规划配置管理") |
| | | @Slf4j |
| | | public class XpRoutePlanController { |
| | |
| | | * 分页查询路线规划配置列表 |
| | | */ |
| | | @ApiOperation(value = "路线规划配置分页列表", tags = {"管理后台-交易管理-导航及路线规划"}, response = XpRoutePlan.class) |
| | | @PostMapping("/pageList") |
| | | @PostMapping("/api/v1/routePlan/pageList") |
| | | public R<PageInfo<XpRoutePlan>> pageList(@RequestBody RoutePlanPageListQuery query) { |
| | | PageInfo<XpRoutePlan> pageInfo = routePlanService.pageList(query); |
| | | return R.ok(pageInfo); |
| | |
| | | * 新增路线规划配置 |
| | | */ |
| | | @ApiOperation(value = "新增路线规划配置", tags = {"管理后台-交易管理-导航及路线规划"}) |
| | | @PostMapping("/add") |
| | | @PostMapping("/api/v1/routePlan/add") |
| | | public R<?> add(@Validated @RequestBody RoutePlanAddDTO dto) { |
| | | routePlanService.add(dto); |
| | | return R.ok(); |
| | |
| | | * 编辑路线规划配置 |
| | | */ |
| | | @ApiOperation(value = "编辑路线规划配置", tags = {"管理后台-交易管理-导航及路线规划"}) |
| | | @PostMapping("/edit") |
| | | @PostMapping("/api/v1/routePlan/edit") |
| | | public R<?> edit(@Validated @RequestBody RoutePlanEditDTO dto) { |
| | | routePlanService.edit(dto); |
| | | return R.ok(); |
| | |
| | | * 删除路线规划配置 |
| | | */ |
| | | @ApiOperation(value = "删除路线规划配置", tags = {"管理后台-交易管理-导航及路线规划"}) |
| | | @DeleteMapping("/deleteById/{id}") |
| | | @DeleteMapping("/api/v1/routePlan/deleteById/{id}") |
| | | public R<?> deleteById(@ApiParam(name = "id", value = "线路ID") @PathVariable Long id) { |
| | | routePlanService.deleteById(id); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据openCityId获取路线规划配置 |
| | | * @param openCityId |
| | | * @return |
| | | */ |
| | | @PostMapping("/inner/v1/routePlan/getXpRoutePlanOpenCityId") |
| | | public R<XpRoutePlan> getXpRoutePlanOpenCityId(@RequestParam Long openCityId) { |
| | | XpRoutePlan routePlan = routePlanService.getOne(new QueryWrapper<XpRoutePlan>().eq("open_city_id", openCityId).eq("auth_status", 2)); |
| | | return R.ok(routePlan); |
| | | } |
| | | } |
| | |
| | | return R.ok(xpSystemSettingService.getOrderDistance()); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/base/v1/support/getOrderDistance") |
| | | @ApiOperation(value = "获取下单距离",tags = {"小程序首页-服务调用获取下单距离"},response = Integer.class) |
| | | public R getOrderDistance1() { |
| | | return R.ok(xpSystemSettingService.getOrderDistance()); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "获取自动结束行程时间",tags = {"小程序-业务流程"},response = Integer.class) |
| | | @GetMapping("/api/v1/mini-program/support/getOrderFinishTime") |
| | | public R<Integer> getOrderFinishTime() { |
| | | return R.ok(xpSystemSettingService.getOrderFinishTime()); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/api/v1/support/getOrderFinishTime") |
| | | public R<Integer> getOrderFinishTime1() { |
| | | return R.ok(xpSystemSettingService.getOrderFinishTime()); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/base/v1/support/phone") |
| | | @ApiOperation(value = "获取客服电话", tags = {"运维APP-个人中心"}, response = String.class) |
| | | public R<CustomerServicePhoneVo> getCustomerPhone() { |
| | |
| | | package com.xiaopeng.operation.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.xiaopeng.api.dto.operation.CruisePointDto; |
| | | import com.xiaopeng.api.dto.operation.NewCruiseOrderDto; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient; |
| | | import com.xiaopeng.api.model.operation.XpTestPlan; |
| | | import com.xiaopeng.api.model.operation.XpTestPlanPoint; |
| | | import com.xiaopeng.api.model.operation.XpTestPlanVehicle; |
| | | import com.xiaopeng.api.model.operation.XpTestPoint; |
| | | import com.xiaopeng.api.model.order.XpCruiseOrder; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.web.page.PageInfo; |
| | | import com.xiaopeng.operation.dto.XpTestPlanAddDTO; |
| | |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.data.mongodb.core.geo.GeoJsonPoint; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @RequiredArgsConstructor(onConstructor_ = @Lazy) |
| | | public class XpTestPlanController { |
| | | private final IXpTestPlanService xpTestPlanService; |
| | | private final IXpTestPlanVehicleService xpTestPlanVehicleService; |
| | | private final IXpTestPlanPointService xpTestPlanPointService; |
| | | private final XpTestPointService testPointService; |
| | | private final XpVehicleClient xpVehicleClient; |
| | | private final IXpTestPlanPointService xpTestPlanPointService; |
| | | private final XpTestPointService xpTestPointService; |
| | | private final IXpTestPlanVehicleService xpTestPlanVehicleService; |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "获取测试计划分页列表", tags = {"管理后台-测试计划"}) |
| | | @PostMapping(value = {"/api/v1/xp-test-plan/pageList"}) |
| | |
| | | |
| | | |
| | | /** |
| | | * 获取车辆下个点位 |
| | | * 根据id获取测试计划 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @PostMapping("/inner/cruise/getCruisePoint") |
| | | public R<XpTestOrder> getCruisePoint(@RequestBody CruisePointDto dto) { |
| | | // 先找计划 |
| | | XpTestPlanVehicle plan = xpTestPlanVehicleService.getOne(new LambdaQueryWrapper<XpTestPlanVehicle>().eq(XpTestPlanVehicle::getVehicleId, dto.getVehicleId())); |
| | | if (plan == null) { |
| | | return R.fail("没有找到对应的计划"); |
| | | } |
| | | // 找对应的多个点位 |
| | | List<XpTestPlanPoint> planPointList = xpTestPlanPointService.list(new LambdaQueryWrapper<XpTestPlanPoint>().eq(XpTestPlanPoint::getTestPlanId, plan.getTestPlanId()).orderByAsc(XpTestPlanPoint::getSortOrder)); |
| | | // 找到现在这个点位 |
| | | // 根据dto的pointId 是第几个 |
| | | int index = 0; |
| | | for (int i = 0; i < planPointList.size(); i++) { |
| | | if (planPointList.get(i).getTestPointId().equals(dto.getPointId())) { |
| | | index = i; |
| | | break; |
| | | } |
| | | } |
| | | XpCruiseOrder newXpCruiseOrder = dto.getNewXpCruiseOrder(); |
| | | XpTestPlanPoint xpCruisePlanPoint = null; |
| | | // 判断是否是最后一个 是则往前一个 否找下一个 |
| | | if (index == planPointList.size() - 1) { |
| | | // 最后一个 找上一个 |
| | | xpCruisePlanPoint = planPointList.get(index - 1); |
| | | newXpCruiseOrder.setOrderReverse(2); |
| | | } else if (index == 0) { |
| | | // 第一个 找下一个 |
| | | xpCruisePlanPoint = planPointList.get(index + 1); |
| | | newXpCruiseOrder.setOrderReverse(1); |
| | | } else { |
| | | // 中间点位 |
| | | if (dto.getOrderReverse() == 1) { |
| | | // 正向 找下一个 |
| | | xpCruisePlanPoint = planPointList.get(index + 1); |
| | | newXpCruiseOrder.setOrderReverse(1); |
| | | } else { |
| | | // 反向找上一个 |
| | | xpCruisePlanPoint = planPointList.get(index - 1); |
| | | newXpCruiseOrder.setOrderReverse(2); |
| | | } |
| | | } |
| | | Long pointId = xpCruisePlanPoint.getTestPointId(); |
| | | XpTestPoint point = testPointService.getById(pointId); |
| | | |
| | | newXpCruiseOrder.setEndPointId(pointId); |
| | | newXpCruiseOrder.setEndPointName(point.getPointName()); |
| | | newXpCruiseOrder.setEndLon(point.getPointLon()); |
| | | newXpCruiseOrder.setEndLat(point.getPointLat()); |
| | | newXpCruiseOrder.setMissionId(xpCruisePlanPoint.getTestPlanId()); |
| | | |
| | | |
| | | return R.ok(newXpCruiseOrder); |
| | | } |
| | | |
| | | /** |
| | | * 获取测试计划 |
| | | * @param vehicleId |
| | | * @return |
| | | */ |
| | | @PostMapping("/inner/cruise/getCruisePlan") |
| | | public R<XpTestPlanVehicle> getCruisePlan(@RequestParam Long vehicleId) { |
| | | XpTestPlanVehicle plan = xpTestPlanVehicleService.getOne(new LambdaQueryWrapper<XpTestPlanVehicle>().eq(XpTestPlanVehicle::getVehicleId, vehicleId)); |
| | | return R.ok(plan); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取测试计划点位列表 |
| | | * @param vehicleId |
| | | * @return |
| | | */ |
| | | @PostMapping("/inner/cruise/getCruisePlanPointList") |
| | | public R<List<XpTestPlanPoint>> getCruisePlanPointList(@RequestParam Long vehicleId) { |
| | | // 先找计划 |
| | | XpTestPlanVehicle plan = xpTestPlanVehicleService.getOne(new LambdaQueryWrapper<XpTestPlanVehicle>().eq(XpTestPlanVehicle::getVehicleId, vehicleId)); |
| | | // 找对应的多个点位 |
| | | List<XpTestPlanPoint> planPointList = xpTestPlanPointService.list(new LambdaQueryWrapper<XpTestPlanPoint>().eq(XpTestPlanPoint::getTestPlanId, plan.getTestPlanId()).orderByAsc(XpTestPlanPoint::getSortOrder)); |
| | | return R.ok(planPointList); |
| | | @PostMapping("/inner/v1/xp-test-plan/getXpTestPlanById") |
| | | public R<XpTestPlan> getXpTestPlanById(@RequestParam Long id){ |
| | | XpTestPlan xpTestPlan = xpTestPlanService.getById(id); |
| | | return R.ok(xpTestPlan); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取测试订单数据 |
| | | * 根据id获取测试计划点 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @PostMapping("/inner/cruise/getNewCruiseOrder") |
| | | public R<XpCruiseOrder> getNewCruiseOrder(@RequestBody NewCruiseOrderDto dto) { |
| | | |
| | | // 先找计划 |
| | | XpTestPlanVehicle plan = xpTestPlanVehicleService.getOne(new LambdaQueryWrapper<XpTestPlanVehicle>().eq(XpTestPlanVehicle::getVehicleId, dto.getVehicleId())); |
| | | // 找对应的多个点位 |
| | | List<XpTestPlanPoint> planPointList = xpTestPlanPointService.list(new LambdaQueryWrapper<XpTestPlanPoint>().eq(XpTestPlanPoint::getTestPlanId, plan.getTestPlanId()).orderByAsc(XpTestPlanPoint::getSortOrder)); |
| | | @PostMapping("/inner/v1/xp-test-plan/getXpTestPlanPointById") |
| | | public R<XpTestPlanPoint> getXpTestPlanPointById(@RequestParam Long id){ |
| | | XpTestPlanPoint xpTestPlanPoint = xpTestPlanPointService.getById(id); |
| | | return R.ok(xpTestPlanPoint); |
| | | } |
| | | |
| | | |
| | | |
| | | XpCruiseOrder newXpCruiseOrder = new XpCruiseOrder(); |
| | | newXpCruiseOrder.setFleetId(dto.getFleetId()); |
| | | newXpCruiseOrder.setVehicleId(dto.getVehicleId()); |
| | | newXpCruiseOrder.setVehicleVin(dto.getVehicleVin()); |
| | | newXpCruiseOrder.setOrderType(1); |
| | | newXpCruiseOrder.setMissionId(plan.getTestPlanId()); |
| | | newXpCruiseOrder.setStatus(1); |
| | | newXpCruiseOrder.setOrderReverse(1); |
| | | GeoJsonPoint point = dto.getPoint(); |
| | | |
| | | // 起点 |
| | | newXpCruiseOrder.setStartLon(point.getX()); |
| | | newXpCruiseOrder.setStartLat(point.getY()); |
| | | |
| | | // 终点 |
| | | XpTestPlanPoint endCruisePlanPoint = planPointList.get(0); |
| | | Long endPointId = endCruisePlanPoint.getPointId(); |
| | | XpTestPoint endPoint = testPointService.getById(endPointId); |
| | | newXpCruiseOrder.setEndPointId(endPointId); |
| | | newXpCruiseOrder.setEndPointName(endPoint.getPointName()); |
| | | newXpCruiseOrder.setEndLon(endPoint.getPointLon()); |
| | | newXpCruiseOrder.setEndLat(endPoint.getPointLat()); |
| | | |
| | | |
| | | |
| | | return R.ok(newXpCruiseOrder); |
| | | /** |
| | | * 根据id获取测试计划点位 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @PostMapping("/inner/v1/xp-test-plan/getXpTestPointById") |
| | | public R<XpTestPoint> getXpTestPointById(@RequestParam Long id){ |
| | | XpTestPoint xpTestPoint = xpTestPointService.getById(id); |
| | | return R.ok(xpTestPoint); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取车辆返回点位 |
| | | * @param xpCruiseOrder |
| | | * 根据测试计划获取车辆信息 |
| | | * @param testPlanId |
| | | * @return |
| | | */ |
| | | @PostMapping("/inner/cruise/findReturnCruisePoint") |
| | | public R<XpCruiseOrder> findReturnCruisePoint(@RequestBody XpCruiseOrder xpCruiseOrder) { |
| | | // 先找计划 |
| | | XpTestPlanVehicle plan = xpTestPlanVehicleService.getOne(new LambdaQueryWrapper<XpTestPlanVehicle>().eq(XpTestPlanVehicle::getVehicleId, xpCruiseOrder.getVehicleId())); |
| | | // 找对应的多个点位 |
| | | List<XpTestPlanPoint> planPointList = xpTestPlanPointService.list(new LambdaQueryWrapper<XpTestPlanPoint>().eq(XpTestPlanPoint::getTestPlanId, plan.getTestPlanId()).orderByAsc(XpTestPlanPoint::getSortOrder)); |
| | | |
| | | XpTestPoint xpPoint = testPointService.list(new LambdaQueryWrapper<XpTestPoint>().eq(XpTestPoint::getParkingPoint, 1).in(XpTestPoint::getId, planPointList.stream().map(XpTestPlanPoint::getPointId).collect(Collectors.toList()))).get(0); |
| | | xpCruiseOrder.setEndPointId(xpPoint.getId()); |
| | | xpCruiseOrder.setEndPointName(xpPoint.getPointName()); |
| | | xpCruiseOrder.setEndLon(xpPoint.getPointLon()); |
| | | xpCruiseOrder.setEndLat(xpPoint.getPointLat()); |
| | | xpCruiseOrder.setMissionId(plan.getTestPlanId()); |
| | | return R.ok(xpCruiseOrder); |
| | | } |
| | | |
| | | /** |
| | | * 判断点位ID列表是否存在关联的测试计划点位(内部接口) |
| | | */ |
| | | @PostMapping("/inner/cruise/existsCruisePlanPointByPointIds") |
| | | public R<Boolean> existsCruisePlanPointByPointIds(@RequestBody List<Long> pointIds) { |
| | | List<Long> distinctPointIds = pointIds == null |
| | | ? java.util.Collections.emptyList() |
| | | : pointIds.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList()); |
| | | if (distinctPointIds.isEmpty()) { |
| | | return R.ok(Boolean.FALSE); |
| | | } |
| | | XpTestPlanPoint exists = xpTestPlanPointService.getOne( |
| | | new LambdaQueryWrapper<XpTestPlanPoint>() |
| | | .in(XpTestPlanPoint::getPointId, distinctPointIds) |
| | | .last("limit 1") |
| | | ); |
| | | return R.ok(exists != null); |
| | | @PostMapping("/inner/v1/xp-test-plan/getXpTestPlanVehicleByTestPlanId") |
| | | public R<List<XpTestPlanVehicle>> getXpTestPlanVehicleByTestPlanId(@RequestParam Long testPlanId){ |
| | | List<XpTestPlanVehicle> xpTestPlanVehicleList = xpTestPlanVehicleService.lambdaQuery() |
| | | .eq(XpTestPlanVehicle::getTestPlanId, testPlanId) |
| | | .list(); |
| | | return R.ok(xpTestPlanVehicleList); |
| | | } |
| | | } |
| | |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/api/v1/testPoint") |
| | | @RequestMapping("") |
| | | @Api(tags = "测试demo-点位管理") |
| | | public class XpTestPointManagementController extends BaseController { |
| | | |
| | |
| | | |
| | | |
| | | @ApiOperation(value = "获取所有运营中的区域", response = XpElectronicFenceArea.class) |
| | | @PostMapping("/listElectronicFenceArea") |
| | | @PostMapping("/api/v1/testPoint/listElectronicFenceArea") |
| | | public R<List<XpElectronicFenceArea>> listElectronicFenceArea() { |
| | | // 获取所有启用的电子围栏 |
| | | List<XpElectronicFence> electronicFences = xpElectronicFenceService.lambdaQuery().eq(XpElectronicFence::getStatus, 2).list(); |
| | |
| | | } |
| | | |
| | | @ApiOperation(value = "点位管理列表", response = XpTestPoint.class) |
| | | @PostMapping("/listPoint") |
| | | @PostMapping("/api/v1/testPoint/listPoint") |
| | | public R<List<XpTestPoint>> list(@RequestBody PointListQuery query) { |
| | | List<XpTestPoint> pageList = xpTestPointService.listAll(query); |
| | | return R.ok(pageList); |
| | | } |
| | | |
| | | @ApiOperation(value = "点位管理分页列表", response = XpTestPoint.class) |
| | | @PostMapping("/pageList") |
| | | @PostMapping("/api/v1/testPoint/pageList") |
| | | public R<PageInfo<XpTestPoint>> pageList(@RequestBody PointPageListListQuery query) { |
| | | PageInfo<XpTestPoint> pageList = xpTestPointService.pageList(query); |
| | | return R.ok(pageList); |
| | | } |
| | | |
| | | @PostMapping("/getByIds") |
| | | @PostMapping("/api/v1/testPoint/getByIds") |
| | | public R<List<XpTestPoint>> getByIds(@RequestBody XpPointExportExcelQuery query) { |
| | | List<XpTestPoint> list = xpTestPointService.lambdaQuery().in(XpTestPoint::getId, query.getPointIds()).list(); |
| | | return R.ok(list); |
| | |
| | | /** |
| | | * 新增点位 |
| | | */ |
| | | @PostMapping("/addPoint") |
| | | @PostMapping("/api/v1/testPoint/addPoint") |
| | | @ResponseBody |
| | | @ApiOperation(value = "新增点位") |
| | | public R add(@Validated @RequestBody PointAddDto pointAddDto) { |
| | |
| | | /** |
| | | * 批量删除点位 |
| | | */ |
| | | @GetMapping("/deletePoint") |
| | | @GetMapping("/api/v1/testPoint/deletePoint") |
| | | @ResponseBody |
| | | @ApiOperation(value = "删除点位") |
| | | public R deletePoint(@RequestParam("ids") String ids) { |
| | |
| | | /** |
| | | * 编辑点位 |
| | | */ |
| | | @PostMapping("/editPoint") |
| | | @PostMapping("/api/v1/testPoint/editPoint") |
| | | @ApiOperation(value = "编辑点位") |
| | | public R edit(@Validated @RequestBody PointUpdateDto pointAddDto) { |
| | | XpTestPoint xpPoint = new XpTestPoint(); |
| | |
| | | /** |
| | | * 点位详情 |
| | | */ |
| | | @GetMapping("/queryPointById") |
| | | @GetMapping("/api/v1/testPoint/queryPointById") |
| | | @ApiOperation(value = "点位详情") |
| | | public R<XpTestPoint> queryById(@RequestParam Long id) { |
| | | return R.ok(xpTestPointService.getById(id)); |
| | |
| | | /** |
| | | * 启用/禁用 |
| | | */ |
| | | @PostMapping("/enableDisablePoint") |
| | | @PostMapping("/api/v1/testPoint/enableDisablePoint") |
| | | @ApiOperation(value = "启用/禁用") |
| | | public R enableDisable(@RequestBody XpPointEnableDisableDto dto) { |
| | | XpTestPoint xpPoint = xpTestPointService.getById(dto.getId()); |
| | |
| | | /** |
| | | * 设置特殊点位 |
| | | */ |
| | | @PostMapping("/setSpecialPoint") |
| | | @PostMapping("/api/v1/testPoint/setSpecialPoint") |
| | | @ApiOperation(value = "设置特殊点位", tags = "后台管理-特殊点位") |
| | | public R setSpecialPoint(@RequestBody XpPointSpecialDto dto) { |
| | | xpTestPointService.update(new LambdaUpdateWrapper<XpTestPoint>().set(XpTestPoint::getChargePoint, 0) |
| | |
| | | } |
| | | |
| | | |
| | | @GetMapping("/listSpecialPoint") |
| | | @GetMapping("/api/v1/testPoint/listSpecialPoint") |
| | | @ApiOperation(value = "获取特殊点位", tags = "后台管理-特殊点位") |
| | | public R<SpecialPointVo> getSpecialPoint() { |
| | | List<XpTestPoint> chargePoints = xpTestPointService.list(new LambdaQueryWrapper<XpTestPoint>().eq(XpTestPoint::getChargePoint, 1)); |
| | |
| | | |
| | | return R.ok(specialPointVo); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 判断点位是在有效期内 |
| | | * @param pointId |
| | | * @return |
| | | */ |
| | | @GetMapping("/inner/v1/testPoint/nowInTimePoint") |
| | | public R<Boolean> nowInTimePoint(@RequestParam Long pointId){ |
| | | return R.ok(xpTestPointService.nowInTimePoint(pointId)); |
| | | } |
| | | } |
| | |
| | | @Data |
| | | @Accessors(chain = true) |
| | | public static class TestPlanPointDTO{ |
| | | |
| | | @ApiModelProperty(value = "点位ID") |
| | | private Long pointId; |
| | | private Long startTestPointId; |
| | | |
| | | @ApiModelProperty(value = "排序") |
| | | private Integer sortOrder; |
| | | |
| | | @ApiModelProperty(value = "是否停车 0-否 1-是") |
| | | private Integer stopFlag; |
| | | @ApiModelProperty(value = "点位ID") |
| | | private Long endTestPointId; |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | List<XpPointsListVo> queryPointByName(@Param("query") PointByNameQuery query); |
| | | |
| | | List<XpTestPoint> pageList(@Param("pageInfo") PageInfo<XpPoint> pageInfo, @Param("query") PointPageListListQuery query); |
| | | List<XpTestPoint> pageList(@Param("pageInfo") PageInfo<XpTestPoint> pageInfo, @Param("query") PointPageListListQuery query); |
| | | } |
| | |
| | | import com.xiaopeng.operation.query.OpenCityPageQuery; |
| | | import com.xiaopeng.operation.vo.OpenCityListVO; |
| | | import com.xiaopeng.operation.vo.XpOpenCityVo; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.List; |
| | |
| | | * @return |
| | | */ |
| | | String getNameWithCityName(Long cityId); |
| | | |
| | | |
| | | /** |
| | | * 获取开通城市数据 |
| | | * @param provinceCode |
| | | * @param cityCode |
| | | * @param districtCode |
| | | * @return |
| | | */ |
| | | XpOpenCity getXpOpenCity(String provinceCode, String cityCode, String districtCode); |
| | | } |
| | |
| | | List<XpHistoryEndPointsVo> getHistoryEndPoints(HistoryEndPointsDto historyEndPointsDto); |
| | | |
| | | |
| | | /** |
| | | * 根据名称获取点位列表 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | XpPointsSearchVo queryPointByName(@Valid PointByNameQuery query); |
| | | |
| | | |
| | | /** |
| | | * 获取可下单距离 |
| | |
| | | } |
| | | return cityName; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据省、市、区县编码查询开通城市 |
| | | * @param provinceCode |
| | | * @param cityCode |
| | | * @param districtCode |
| | | * @return |
| | | */ |
| | | @Override |
| | | public XpOpenCity getXpOpenCity(String provinceCode, String cityCode, String districtCode) { |
| | | //先根据区编码获取,没有再根据市编码获取,没有再根据省编码获取 |
| | | XpOpenCity xpOpenCity = this.baseMapper.selectOne(new LambdaQueryWrapper<XpOpenCity>() |
| | | .eq(XpOpenCity::getDistrictCode, districtCode)); |
| | | if (Objects.isNull(xpOpenCity)) { |
| | | xpOpenCity = this.baseMapper.selectOne(new LambdaQueryWrapper<XpOpenCity>() |
| | | .eq(XpOpenCity::getCityCode, cityCode).isNull(XpOpenCity::getDistrictCode)); |
| | | } |
| | | if (Objects.isNull(xpOpenCity)) { |
| | | xpOpenCity = this.baseMapper.selectOne(new LambdaQueryWrapper<XpOpenCity>() |
| | | .eq(XpOpenCity::getProvinceCode, provinceCode) |
| | | .isNull(XpOpenCity::getCityCode).isNull(XpOpenCity::getDistrictCode)); |
| | | } |
| | | return xpOpenCity; |
| | | } |
| | | } |
| | |
| | | } |
| | | List<XpTestPlanPoint> planPoints = xpTestPlanPointService.lambdaQuery() |
| | | .eq(XpTestPlanPoint::getTestPlanId, id) |
| | | .orderByAsc(XpTestPlanPoint::getSortOrder) |
| | | .list(); |
| | | List<Long> pointIds = planPoints.stream() |
| | | .map(XpTestPlanPoint::getTestPointId) |
| | | .map(XpTestPlanPoint::getStartTestPointId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toList()); |
| | | List<Long> pointIds1 = planPoints.stream() |
| | | .map(XpTestPlanPoint::getEndTestPointId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toList()); |
| | | pointIds.addAll(pointIds1); |
| | | Map<Long, XpTestPoint> pointMap = CollUtil.isNotEmpty(pointIds) |
| | | ? xpTestPointService.listByIds(pointIds).stream() |
| | | .collect(Collectors.toMap(XpTestPoint::getId, v -> v)) |
| | | : Collections.emptyMap(); |
| | | List<XpTestPlanPointVO> pointList = planPoints.stream().map(planPoint -> { |
| | | XpTestPlanPointVO vo = new XpTestPlanPointVO(); |
| | | vo.setPointId(planPoint.getTestPointId()); |
| | | vo.setSortOrder(planPoint.getSortOrder()); |
| | | XpTestPoint point = pointMap.get(planPoint.getTestPointId() == null ? null : planPoint.getTestPointId().longValue()); |
| | | vo.setStartTestPointId(planPoint.getStartTestPointId()); |
| | | vo.setEndTestPointId(planPoint.getEndTestPointId()); |
| | | vo.setStopFlag(planPoint.getStopFlag()); |
| | | vo.setTestOrderType(planPoint.getTestOrderType()); |
| | | XpTestPoint point = pointMap.get(planPoint.getStartTestPointId() == null ? null : planPoint.getStartTestPointId().longValue()); |
| | | if (point != null) { |
| | | vo.setPointName(point.getPointName()); |
| | | vo.setPointAddress(point.getPointAddress()); |
| | | vo.setStartTestPointName(point.getPointName()); |
| | | vo.setStartTestPointAddress(point.getPointAddress()); |
| | | } |
| | | XpTestPoint point1 = pointMap.get(planPoint.getEndTestPointId() == null ? null : planPoint.getEndTestPointId().longValue()); |
| | | if (point != null) { |
| | | vo.setEndTestPointName(point1.getPointName()); |
| | | vo.setEndTestPointAddress(point1.getPointAddress()); |
| | | } |
| | | return vo; |
| | | }).collect(Collectors.toList()); |
| | |
| | | } |
| | | Set<Long> pointIdSet = new HashSet<>(); |
| | | for (XpTestPlanAddDTO.TestPlanPointDTO pointDTO : pointList) { |
| | | if (pointDTO.getPointId() == null || pointDTO.getSortOrder() == null || pointDTO.getStopFlag() == null) { |
| | | if (pointDTO.getStartTestPointId() == null || pointDTO.getEndTestPointId() == null) { |
| | | throw new ServiceException("点位参数不完整", I18nKeyConstant.CRUISE_PLAN_POINT_INCOMPLETE); |
| | | } |
| | | if (pointDTO.getStopFlag() != 0 && pointDTO.getStopFlag() != 1) { |
| | | throw new ServiceException("点位停车标识不合法", I18nKeyConstant.CRUISE_PLAN_STOP_FLAG_INVALID); |
| | | } |
| | | if (!pointIdSet.add(pointDTO.getPointId())) { |
| | | if (!pointIdSet.add(pointDTO.getStartTestPointId()) || !pointIdSet.add(pointDTO.getEndTestPointId())) { |
| | | throw new ServiceException("点位ID重复", I18nKeyConstant.CRUISE_PLAN_POINT_DUPLICATE); |
| | | } |
| | | } |
| | |
| | | for (XpTestPlanAddDTO.TestPlanPointDTO pointDTO : pointList) { |
| | | XpTestPlanPoint point = new XpTestPlanPoint(); |
| | | point.setTestPlanId(planId); |
| | | point.setTestPlanId(pointDTO.getPointId()); |
| | | point.setSortOrder(pointDTO.getSortOrder()); |
| | | point.setStopFlag(pointDTO.getStopFlag()); |
| | | point.setStartTestPointId(pointDTO.getStartTestPointId()); |
| | | point.setEndTestPointId(pointDTO.getEndTestPointId()); |
| | | result.add(point); |
| | | } |
| | | return result; |
| | |
| | | return resultList; |
| | | } |
| | | |
| | | @Override |
| | | public XpPointsSearchVo queryPointByName(PointByNameQuery query) { |
| | | XpPointsSearchVo searchVo = new XpTestPointsSearchVo(); |
| | | List<XpPointsListVo> list = this.baseMapper.queryPointByName(query); |
| | | if (list.isEmpty()) { |
| | | return searchVo; |
| | | } |
| | | |
| | | LocalTime now = LocalTime.now(); |
| | | List<Long> areaIds = list.stream().map(XpPointsListVo::getElectronicAreaId).collect(Collectors.toList()); |
| | | List<XpElectronicFenceArea> xpElectronicFenceAreas = xpElectronicFenceAreaService.listByIds(areaIds); |
| | | List<Long> fenceIds = xpElectronicFenceAreas.stream().map(XpElectronicFenceArea::getElectronicId).collect(Collectors.toList()); |
| | | |
| | | List<XpElectronicFence> xpElectronicFences = new ArrayList<>(); |
| | | if (CollUtil.isNotEmpty(fenceIds)) { |
| | | xpElectronicFences = xpElectronicFenceService.listByIds(fenceIds); |
| | | } |
| | | for (XpPointsListVo xpPointsListVo : list) { |
| | | Integer operationType = xpPointsListVo.getOperationType(); |
| | | if(1 == operationType){ |
| | | //与运营区同步 |
| | | XpElectronicFenceArea xpElectronicFenceArea = xpElectronicFenceAreas.stream().filter(s -> s.getId().equals(xpPointsListVo.getElectronicAreaId())).findFirst().orElse(null); |
| | | if(null == xpElectronicFenceArea){ |
| | | // 不在运营段 |
| | | xpPointsListVo.setState(0); |
| | | } |
| | | XpElectronicFence xpElectronicFence = xpElectronicFences.stream().filter(s -> s.getId().equals(xpElectronicFenceArea.getElectronicId())).findFirst().orElse(null); |
| | | if(null == xpElectronicFence){ |
| | | // 不在运营段 |
| | | xpPointsListVo.setState(0); |
| | | } |
| | | //失效类型 1=永不失效 2=定时失效 |
| | | Integer failureType = xpElectronicFence.getFailureType(); |
| | | //永不失效,但是还未到开始时间 |
| | | if(1 == failureType && LocalDateTime.now().isBefore(xpElectronicFence.getEffectTime())){ |
| | | xpPointsListVo.setState(0); |
| | | }else if(2 == failureType && (LocalDateTime.now().isBefore(xpElectronicFence.getEffectTime()) || LocalDateTime.now().isAfter(xpElectronicFence.getFailureTime()))){ |
| | | //定时失效,但是当前时间不在时间范围内 |
| | | xpPointsListVo.setState(0); |
| | | } |
| | | }else{ |
| | | //自定义时间段 |
| | | // 判断是否在时间段内 |
| | | boolean intime = getInTime(now, xpPointsListVo.getEffectivePeriod(), xpPointsListVo.getEffectiveTimePeriod()); |
| | | if (!intime) { |
| | | // 不在运营段 |
| | | xpPointsListVo.setState(0); |
| | | } |
| | | } |
| | | } |
| | | // 组装数据 并排序 剔除不在运营段的 数据 |
| | | List<XpPointsListVo> resultList = list.stream() |
| | | .peek(vo -> vo.setDistance(BigDecimal.valueOf(FastDistanceCalculator.distanceFast(query.getLat(), query.getLon(), vo.getLatitude(), vo.getLongitude())).setScale(2, RoundingMode.HALF_UP).doubleValue())) |
| | | .filter(vo -> vo.getState() == 1).collect(Collectors.toList()); |
| | | |
| | | // 可用点位 |
| | | List<XpPointsListVo> availablePoints = resultList.stream().filter(e -> query.getElectronicAreaId() != null && e.getElectronicAreaId().equals(query.getElectronicAreaId())).sorted(Comparator.comparing(XpPointsListVo::getDistance)).collect(Collectors.toList());// |
| | | |
| | | // 不可用点位 |
| | | List<XpPointsListVo> unavailablePoints = resultList.stream().filter(e -> query.getElectronicAreaId() == null || !e.getElectronicAreaId().equals(query.getElectronicAreaId())).sorted(Comparator.comparing(XpPointsListVo::getDistance)).collect(Collectors.toList()); |
| | | searchVo.setAvailablePoints(availablePoints); |
| | | searchVo.setUnavailablePoints(unavailablePoints); |
| | | return searchVo; |
| | | } |
| | | |
| | | @Override |
| | | public OrderDistanceVo getOrderDistance() { |
| | |
| | | @ApiModel(value = "测试计划点位VO", description = "测试计划点位响应对象") |
| | | public class XpTestPlanPointVO { |
| | | |
| | | @ApiModelProperty(value = "点位ID") |
| | | private Long pointId; |
| | | @ApiModelProperty(value = "起点点位ID") |
| | | private Long startTestPointId; |
| | | |
| | | @ApiModelProperty(value = "点位名称") |
| | | private String pointName; |
| | | @ApiModelProperty(value = "起点点位名称") |
| | | private String startTestPointName; |
| | | |
| | | @ApiModelProperty(value = "详细地址") |
| | | private String pointAddress; |
| | | @ApiModelProperty(value = "起点详细地址") |
| | | private String startTestPointAddress; |
| | | |
| | | @ApiModelProperty(value = "排序") |
| | | private Integer sortOrder; |
| | | @ApiModelProperty(value = "终点点位ID") |
| | | private Long endTestPointId; |
| | | |
| | | @ApiModelProperty(value = "终点点位名称") |
| | | private String endTestPointName; |
| | | |
| | | @ApiModelProperty(value = "终点详细地址") |
| | | private String endTestPointAddress; |
| | | |
| | | @ApiModelProperty(value = "是否停车 0-否 1-是") |
| | | private Integer stopFlag; |
| | | |
| | | @ApiModelProperty(value = "测试订单类型(1=测试单,2=巡游单)") |
| | | private Long testOrderType; |
| | | |
| | | } |
| | |
| | | String ORDER_CHANGE_AMOUNT_STATUS_INVALID = "order.change.amount.status.invalid"; |
| | | String ORDER_CHANGE_AMOUNT_FAILED = "order.change.amount.failed"; |
| | | String VEHICLE_NOT_EXISTS = "vehicle.not.exists"; |
| | | String NO_CURRENT_POINT = "no.current.point"; |
| | | String NO_CURRENT_REGION = "no.current.region"; |
| | | String PATH_NOT_FOUND = "path.not.found"; |
| | | } |
| | |
| | | import com.xiaopeng.api.dto.statistics.OrderStatisticsDTO; |
| | | import com.xiaopeng.api.dto.statistics.StatisticsQueryDTO; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient; |
| | | import com.xiaopeng.api.model.order.XpOrder; |
| | | import com.xiaopeng.api.model.order.XpTestOrder; |
| | | import com.xiaopeng.api.model.vehicleConvoy.XpVehicle; |
| | | import com.xiaopeng.api.vo.automaticPilot.VehiclePosition; |
| | | import com.xiaopeng.api.vo.operation.RouteVo; |
| | |
| | | public class XpTestOrderController { |
| | | |
| | | private final IXpTestOrderService xpTestOrderService; |
| | | private final RedisService redisService; |
| | | @Autowired |
| | | private MongoTemplate mongoTemplate; |
| | | @Autowired |
| | | private XpVehicleClient xpVehicleClient; |
| | | |
| | | |
| | | /** |
| | | * 通过订单id查询订单信息 |
| | | * |
| | | * @param orderId 订单id |
| | | * @return 订单详情 |
| | | */ |
| | | @PostMapping("/inner/testOrder/queryOrderById") |
| | | public R<XpTestOrder> queryOrderById(@RequestParam Long orderId){ |
| | | XpTestOrder xpTestOrder = xpTestOrderService.getById(orderId); |
| | | return R.ok(xpTestOrder); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 修改订单状态 |
| | | * @param orderId |
| | | * @param status |
| | | * @return |
| | | */ |
| | | @PostMapping("/inner/v1/testOrder/updateOrderStatus") |
| | | public R<String> updateOrderStatus(@RequestParam Long orderId, |
| | | @RequestParam Integer status){ |
| | | xpTestOrderService.updateOrderStatus(orderId, status); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 生成订单 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "生成订单", tags = {"管理后台-测试计划"}) |
| | | @PostMapping("/api/v1/testOrder/addTestOrder") |
| | | public R<?> addTestOrder(@RequestBody AddTestOrderVo query){ |
| | | xpTestOrderService.addTestOrder(query); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | * @return 订单详情 |
| | | */ |
| | | @ApiOperation(value = "订单详情", tags = {"管理后台-测试计划"}) |
| | | @GetMapping("/api/v1/order/queryById") |
| | | @GetMapping("/api/v1/testOrder/queryById") |
| | | public R<XpTestOrderDetailVO> queryById(@ApiParam(value = "订单id", required = true) @RequestParam Long id) { |
| | | XpTestOrderDetailVO detail = xpTestOrderService.getOrderDetail(id); |
| | | return R.ok(detail); |
| | |
| | | * @return 操作结果 |
| | | */ |
| | | @ApiOperation(value = "删除订单", tags = {"管理后台-测试计划"}) |
| | | @DeleteMapping("/api/v1/order/deleteById") |
| | | @DeleteMapping("/api/v1/testOrder/deleteById") |
| | | public R<?> deleteById(@ApiParam(value = "订单id", required = true) @RequestParam Long id) { |
| | | xpTestOrderService.deleteOrder(id); |
| | | return R.ok(); |
| | |
| | | * @return 操作结果 |
| | | */ |
| | | @ApiOperation(value = "取消/关闭订单", tags = {"管理后台-测试计划"}) |
| | | @PostMapping("/api/v1/order/cancelAndCloseById") |
| | | @PostMapping("/api/v1/testOrder/cancelAndCloseById") |
| | | public R<?> cancelAndCloseById(@Validated @RequestBody XpOrderOperateDTO dto) { |
| | | xpTestOrderService.cancelOrCloseOrder(dto.getOrderId(), dto.getType()); |
| | | return R.ok(); |
| | |
| | | * @param dto 改派请求参数 |
| | | * @return 操作结果 |
| | | */ |
| | | @ApiOperation(value = "改派订单", tags = {"管理后台-交易管理-订单管理"}, notes = "车辆列表在vehicleConvoy服务") |
| | | @PostMapping("/api/v1/order/reassignById") |
| | | @ApiOperation(value = "改派订单", tags = {"管理后台-测试计划"}, notes = "车辆列表在vehicleConvoy服务") |
| | | @PostMapping("/api/v1/testOrder/reassignById") |
| | | public R<?> reassignById(@Validated @RequestBody XpOrderReassignDTO dto) { |
| | | xpOrderService.reassignOrder( |
| | | xpTestOrderService.reassignOrder( |
| | | dto.getOrderId(), |
| | | dto.getVehicleId(), |
| | | dto.getReassignReason() |
| | |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "订单改价", tags = {"管理后台-交易管理-订单管理"}) |
| | | @PostMapping("/api/v1/order/changeAmount") |
| | | @ApiOperation(value = "订单改价", tags = {"管理后台-测试计划"}) |
| | | @PostMapping("/api/v1/testOrder/changeAmount") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "订单ID", required = true, dataType = "Long"), |
| | | @ApiImplicitParam(name = "amount", value = "新的订单金额", required = true, dataType = "BigDecimal") |
| | | }) |
| | | public R<?> changeAmount(@RequestParam("id") Long id, @RequestParam("amount") BigDecimal amount) { |
| | | xpOrderService.changeAmount(id, amount); |
| | | xpTestOrderService.changeAmount(id, amount); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户快捷胶囊 历史 时段 终点高点 |
| | | */ |
| | | @ApiOperation(value = "获取用户快捷胶囊 历史 时段 终点高点", tags = {"小程序-获取用户快捷胶囊 历史 时段 终点高点"}) |
| | | @GetMapping("/api/v1/mini-program/order/getUserQuickCapsule") |
| | | @XpClientCheck(checkToken = false, checkOtpToken = true) |
| | | public R<XpPointInfoVo> getUserQuickCapsule(HttpServletRequest request) { |
| | | // uid已通过拦截器otp校验,可以直接使用 |
| | | String uid = request.getHeader("XP-Uid"); |
| | | return R.ok(xpOrderService.getUserQuickCapsule(uid)); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 获取订单详情 |
| | | */ |
| | | @PutMapping("/api/v1/mini-program/order/orderDetail/{orderId}") |
| | | @ApiOperation(value = "获取订单详情", tags = {"小程序-获取订单详情"}) |
| | | @XpClientCheck(checkToken = false, checkOtpToken = true) |
| | | public R<OrderDetailVo> orderDetail(@PathVariable("orderId") Long orderId, HttpServletRequest request) { |
| | | // uid已通过拦截器otp校验,可以直接使用 |
| | | String uid = request.getHeader("XP-Uid"); |
| | | OrderDetailVo orderDetailVo = xpOrderService.orderDetail(orderId, uid); |
| | | BigDecimal orderMoney = orderDetailVo.getOrderMoney(); |
| | | if(orderMoney==null){ |
| | | orderDetailVo.setOrderMoneyStr("0.00"); |
| | | }else { |
| | | orderDetailVo.setOrderMoneyStr(orderMoney.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | } |
| | | return R.ok(orderDetailVo); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取历史下单成功起点10条数据列表 |
| | | */ |
| | | @ApiOperation(value = "获取历史下单成功起点10条数据列表", tags = {"小程序-获取历史下单成功起点10条数据列表"}) |
| | | @GetMapping("/base/v1/mini-program/history/startPoints") |
| | | @XpClientCheck(checkToken = false, checkOtpToken = true) |
| | | public R<List<XpHistoryStartPointsVo>> getHistoryStartPoints(double lon, double lat,Long electronicAreaId, HttpServletRequest request) { |
| | | // uid已通过拦截器otp校验,可以直接使用 |
| | | String uid = request.getHeader("XP-Uid"); |
| | | return R.ok(xpOrderService.getHistoryStartPoints(uid, lon, lat,electronicAreaId)); |
| | | } |
| | | |
| | | /** |
| | | * 获取历史下单成功终点点10条数据列表 |
| | | */ |
| | | @ApiOperation(value = "获取历史下单成功终点10条数据列表", tags = {"小程序-获取历史下单成功终点10条数据列表"}) |
| | | @GetMapping("/base/v1/mini-program/history/endPoints") |
| | | @XpClientCheck(checkToken = false, checkOtpToken = true) |
| | | public R<List<XpHistoryEndPointsVo>> getHistoryEndPoints(double lon, double lat,Long electronicAreaId, HttpServletRequest request) { |
| | | // uid已通过拦截器otp校验,可以直接使用 |
| | | String uid = request.getHeader("XP-Uid"); |
| | | return R.ok(xpOrderService.getHistoryEndPoints(uid, lon, lat,electronicAreaId)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取正在进行中的订单 |
| | | */ |
| | | @ApiOperation(value = "获取正在进行中的订单", tags = {"小程序-获取正在进行中的订单"}) |
| | | @GetMapping("/api/v1/mini-program/order/active") |
| | | @XpClientCheck(checkToken = false, checkOtpToken = true) |
| | | public R<XpOrderDetailVO> getActiveOrder(HttpServletRequest request) { |
| | | // uid已通过拦截器otp校验,可以直接使用 |
| | | String uid = request.getHeader("XP-Uid"); |
| | | return R.ok(xpOrderService.getActiveOrder(uid)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询历史订单列表 |
| | | */ |
| | | @ApiOperation(value = "查询历史订单列表", tags = {"小程序-查询历史订单列表"}) |
| | | @PostMapping("/api/v1/mini-program/order/history/list") |
| | | @XpClientCheck(checkToken = false, checkOtpToken = true) |
| | | public R<XpOrderHistoryVO> getHistoryOrderList(@RequestBody XpHistoryOrderListQuery query, HttpServletRequest request) { |
| | | // uid已通过拦截器otp校验,可以直接使用 |
| | | String uid = request.getHeader("XP-Uid"); |
| | | return R.ok(xpOrderService.getHistoryOrderList(query, uid)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * + |
| | | * 取消订单 |
| | | */ |
| | | |
| | | @PutMapping("/api/v1/mini-program/order/cancel/{orderId}") |
| | | @ApiOperation(value = "取消订单", tags = {"小程序-取消订单"}) |
| | | @XpClientCheck(checkToken = false, checkOtpToken = true) |
| | | public R cancelOrder(@PathVariable("orderId") Long orderId, HttpServletRequest request) { |
| | | // uid已通过拦截器otp校验,可以直接使用 |
| | | String uid = request.getHeader("XP-Uid"); |
| | | xpOrderService.cancelOrder(orderId, uid); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * + |
| | | * 手动结束订单 |
| | | */ |
| | | |
| | | @PutMapping("/api/v1/mini-program/order/endTrip/{orderId}") |
| | | @ApiOperation(value = "结束行程", tags = {"小程序-结束行程"}) |
| | | @XpClientCheck(checkToken = false, checkOtpToken = true) |
| | | public R<?> endTrip(@PathVariable("orderId") Long orderId, HttpServletRequest request) { |
| | | // uid已通过拦截器otp校验,可以直接使用 |
| | | String uid = request.getHeader("XP-Uid"); |
| | | try { |
| | | Boolean b = xpOrderService.endTrip(orderId, uid); |
| | | return R.ok(b); |
| | | |
| | | } catch (Exception e) { |
| | | return R.ok(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * + |
| | | * 获取行程费用明细 |
| | | */ |
| | | @PutMapping("/api/v1/mini-program/order/fare-breakdown/{orderId}") |
| | | @ApiOperation(value = "获取行程费用明细", tags = {"小程序-获取行程费用明细"}) |
| | | @XpClientCheck(checkToken = false, checkOtpToken = true) |
| | | public R<FareBreakdownVo> fareBreakdown(@PathVariable("orderId") Long orderId, HttpServletRequest request) { |
| | | // uid已通过拦截器otp校验,可以直接使用 |
| | | String uid = request.getHeader("XP-Uid"); |
| | | return xpOrderService.fareBreakdown(orderId, uid); |
| | | } |
| | | |
| | | /** |
| | | * + |
| | | * 获取行程费用明细 |
| | | */ |
| | | @PutMapping("/api/v1/mini-program/order/feeDescription/{orderId}") |
| | | @ApiOperation(value = "获取费用说明", tags = {"小程序-获取费用说明"}) |
| | | @XpClientCheck(checkToken = false, checkOtpToken = true) |
| | | public R<String> feeDescription(@PathVariable("orderId") Long orderId, HttpServletRequest request) { |
| | | // uid已通过拦截器otp校验,可以直接使用 |
| | | String uid = request.getHeader("XP-Uid"); |
| | | return xpOrderService.feeDescription(orderId, uid); |
| | | } |
| | | |
| | | /** |
| | | * 订单评价 |
| | | */ |
| | | @PostMapping("/api/v1/mini-program/order/payment") |
| | | @ApiOperation(value = "发起支付", tags = {"小程序-发起支付"}) |
| | | @XpClientCheck(checkToken = false, checkOtpToken = true) |
| | | public R payment(@Validated @RequestBody XpOrderPayDto dto, HttpServletRequest request) { |
| | | // uid已通过拦截器otp校验,可以直接使用 |
| | | String uid = request.getHeader("XP-Uid"); |
| | | return xpOrderService.payment(dto, uid); |
| | | } |
| | | |
| | | /** |
| | | * 订单评价 |
| | | */ |
| | | @PostMapping("/api/v1/mini-program/order/comment") |
| | | @ApiOperation(value = "订单评价", tags = {"小程序-订单评价"}) |
| | | @XpClientCheck(checkToken = false, checkOtpToken = true) |
| | | public R comment(@Validated @RequestBody XpOrderCommentDto dto, HttpServletRequest request) { |
| | | // uid已通过拦截器otp校验,可以直接使用 |
| | | String uid = request.getHeader("XP-Uid"); |
| | | xpOrderService.comment(dto, uid); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 订单状态修改-车控消息推送我方调用(内部接口) |
| | | */ |
| | | @ApiOperation(value = "订单状态推送修改") |
| | | @PostMapping("/inner/v1/order/updateOrderStatus") |
| | | public R<String> updateOrderStatus(@RequestParam Long orderId, |
| | | @RequestParam Integer status) { |
| | | return xpOrderService.updateOrderStatus(orderId, status); |
| | | } |
| | | |
| | | /** |
| | | * 业务流程-通过订单id查询车辆信息 |
| | | */ |
| | | @ApiOperation(value = "通过订单id查询车辆信息", tags = {"小程序-业务流程"}) |
| | | @XpClientCheck(checkToken = false, checkOtpToken = true) |
| | | @GetMapping("/api/v1/mini-program/order/queryVehicleByOrderId") |
| | | public R<XpVehicle> queryVehicleByOrderId(@RequestParam Long orderId, HttpServletRequest request) { |
| | | String uid = request.getHeader("XP-Uid"); |
| | | return R.ok(xpOrderService.queryVehicleByOrderId(orderId, uid)); |
| | | } |
| | | |
| | | /** |
| | | * 订单车辆定位实时存储-订单车辆定位实时存储(内部接口) |
| | | */ |
| | | @ApiOperation(value = "订单车辆定位实时存储") |
| | | @PostMapping("/inner/v1/order/saveVehicleLocation") |
| | | @PostMapping("/inner/v1/testOrder/saveVehicleLocation") |
| | | public R<String> saveVehicleLocation(@RequestBody OrderTrajectoryVo vo) { |
| | | OrderTrajectory orderTrajectory = new OrderTrajectory(); |
| | | BeanUtils.copyProperties(vo, orderTrajectory); |
| | | xpOrderService.saveVehicleLocation(orderTrajectory); |
| | | xpTestOrderService.saveVehicleLocation(orderTrajectory); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 订单查询实时轨迹路线 |
| | | */ |
| | | @ApiOperation(value = "订单查询实时轨迹路线") |
| | | @PostMapping("/api/v1/mini-program/order/queryOrderRoute") |
| | | public R<RouteVo> queryOrderRoute(@Validated @RequestBody QueryOrderRouteDTO dto, HttpServletRequest request) { |
| | | String uid = request.getHeader("XP-Uid"); |
| | | // 查询订单信息 |
| | | XpOrder xpOrder = xpOrderService.getById(dto.getOrderId()); |
| | | // 获取路线规划 |
| | | // RouteVo routeVo = redisService.getCacheObject(CacheConstants.ORDER_ROUTE_CAPTURE + "_" + dto.getOrderId() + "_" +dto.getRouteType()); |
| | | |
| | | String key = ""; |
| | | //接驾情况,获取车辆位置到起点的导航 |
| | | if (xpOrder.getStatus() < 5) { |
| | | key = "ORDER_NAVIGATION_START_DATA:" + xpOrder.getAppUserId(); |
| | | } |
| | | //服务中,获取起点到终点的导航数据 |
| | | if (xpOrder.getStatus() >= 5) { |
| | | key = "ORDER_NAVIGATION_END_DATA:" + xpOrder.getAppUserId(); |
| | | } |
| | | Object cacheObject = redisService.getCacheObject(key); |
| | | RouteVo routeVo = JSON.parseObject(cacheObject.toString(), RouteVo.class); |
| | | XpVehicle xpVehicle = xpVehicleClient.queryById(xpOrder.getVehicleId()).getData(); |
| | | VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(xpVehicle.getVehicleVin())), VehiclePosition.class); |
| | | routeVo.setDirection(null != vehiclePosition ? vehiclePosition.getCourse() : 90); |
| | | return R.ok(routeVo); |
| | | } |
| | | /** |
| | | * 订单查询轨迹路线 |
| | | */ |
| | | @ApiOperation(value = "订单查询轨迹路线") |
| | | @GetMapping("/api/v1/mini-program/order/queryOrderTrajectory") |
| | | public R<RouteVo> queryOrderTrajectory(@RequestParam String orderId, HttpServletRequest request) { |
| | | String uid = request.getHeader("XP-Uid"); |
| | | List<OrderTrajectory> trajectories = mongoTemplate.find( |
| | | new Query(Criteria.where("orderId").is(Long.valueOf(orderId))) |
| | | .with(Sort.by(Sort.Direction.ASC, "locatetime")), |
| | | OrderTrajectory.class |
| | | ); |
| | | // 封装信息 |
| | | RouteVo routeVo = new RouteVo(); |
| | | List<LonLatDto> polyline = new ArrayList<>(); |
| | | if(!CollectionUtils.isEmpty(trajectories)){ |
| | | for (OrderTrajectory trajectory : trajectories) { |
| | | LonLatDto lonLatDto = new LonLatDto(); |
| | | String[] split = trajectory.getLocation().split(","); |
| | | lonLatDto.setLongitude(Double.valueOf(split[0])); |
| | | lonLatDto.setLatitude(Double.valueOf(split[1])); |
| | | polyline.add(lonLatDto); |
| | | } |
| | | } |
| | | routeVo.setPolyline(polyline); |
| | | return R.ok(routeVo); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | @Excel(name = "下单时间", width = 20, exportFormat = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime createTime; |
| | | |
| | | @Excel(name = "订单来源", width = 15, replace = {"小鹏小程序_1"}) |
| | | private String orderSource; |
| | | |
| | | @Excel(name = "起点", width = 30) |
| | | private String startAddress; |
| | | private String startPointName; |
| | | |
| | | @Excel(name = "终点", width = 30) |
| | | private String endAddress; |
| | | private String endPointName; |
| | | |
| | | @Excel(name = "接单车辆", width = 15) |
| | | private String plateNumber; |
| New file |
| | |
| | | package com.xiaopeng.order.model.vo; |
| | | |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @ApiModel |
| | | public class AddTestOrderVo { |
| | | @ApiModelProperty("测试计划id") |
| | | private Long testPlanId; |
| | | |
| | | @ApiModelProperty("测试计划点位id") |
| | | private Long testPlanPointId; |
| | | |
| | | @ApiModelProperty("订单类型(1=测试单,2=巡游单)") |
| | | private Integer orderType; |
| | | |
| | | @ApiModelProperty("是否停车(0=否,1=是)") |
| | | private Integer stopFlag; |
| | | } |
| | |
| | | import com.xiaopeng.order.model.query.XpTestOrderPageQuery; |
| | | import com.xiaopeng.order.model.vo.*; |
| | | import com.xiaopeng.order.vo.OrderDetailVo; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | |
| | | public interface IXpTestOrderService extends IService<XpTestOrder> { |
| | | |
| | | /** |
| | | * 获取订单统计数据 |
| | | * |
| | | * @param query 查询参数 |
| | | * @return 订单统计数据 |
| | | * 添加测试单 |
| | | * @param query |
| | | */ |
| | | OrderStatisticsDTO getOrderStatistics(StatisticsQueryDTO query); |
| | | void addTestOrder(AddTestOrderVo query); |
| | | |
| | | |
| | | /** |
| | | * 订单分页列表 |
| | |
| | | */ |
| | | void deleteOrder(Long id); |
| | | |
| | | /** |
| | | * 导出订单列表 |
| | | * |
| | | * @param query 查询参数 |
| | | * @return 订单列表 |
| | | */ |
| | | List<XpOrderPageVO> exportList(XpOrderExcelQuery query); |
| | | |
| | | /** |
| | | * 取消或关闭订单 |
| | |
| | | */ |
| | | void reassignOrder(Long orderId, Long newVehicleId, String reassignReason); |
| | | |
| | | /** |
| | | * 获取用户快捷胶囊 |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | XpPointInfoVo getUserQuickCapsule(String uid); |
| | | |
| | | /** |
| | | * 获取历史下单成功起点10条数据列表 |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | List<XpHistoryStartPointsVo> getHistoryStartPoints(String uid,double lon,double lat,Long electronicAreaId); |
| | | |
| | | |
| | | /** |
| | | * 获取正在进行中的订单 |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | XpOrderDetailVO getActiveOrder(String uid); |
| | | |
| | | /** |
| | | * 获取历史下单成功终点10条数据列表 |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | List<XpHistoryEndPointsVo> getHistoryEndPoints(String uid, double lon, double lat,Long electronicAreaId); |
| | | |
| | | /** |
| | | * 获取历史订单列表 |
| | | * @param query |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | XpOrderHistoryVO getHistoryOrderList(XpHistoryOrderListQuery query, String uid); |
| | | |
| | | /** |
| | | * 取消订单 |
| | | * @param orderId |
| | | * @param uid |
| | | */ |
| | | void cancelOrder(Long orderId,String uid); |
| | | |
| | | /** |
| | | * 取消订单 |
| | | * @param orderId |
| | | */ |
| | | XpOrder cancelOrder(String orderId); |
| | | |
| | | /** |
| | | * 评价订单 |
| | | * @param dto |
| | | * @param uid |
| | | */ |
| | | void comment(XpOrderCommentDto dto, String uid); |
| | | |
| | | /** |
| | | * 修改订单状态 |
| | |
| | | */ |
| | | R<String> updateOrderStatus(Long orderId, Integer status); |
| | | |
| | | Boolean endTrip(Long orderId, String uid); |
| | | |
| | | |
| | | /** |
| | | * 添加巡游任务 下发命令 |
| | | * @param vehicle |
| | | * @param order |
| | | */ |
| | | void addCruiseMission(Long vehicleId, XpTestOrder order); |
| | | Boolean endTrip(Long orderId); |
| | | |
| | | /** |
| | | * 取消订单后的继续巡游任务 |
| | | */ |
| | | void addCruiseMission(Long vehicleId); |
| | | |
| | | R<FareBreakdownVo> fareBreakdown(Long orderId, String uid); |
| | | |
| | | R payment(XpOrderPayDto dto, String uid); |
| | | |
| | | /** |
| | | * 添加订单 |
| | | * @param xpOrder |
| | | * @return |
| | | */ |
| | | boolean addOrder(XpTestOrder xpOrder); |
| | | |
| | | /** |
| | | * 根据订单ID查询车辆信息 |
| | | * @param orderId 订单ID |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | XpVehicle queryVehicleByOrderId(Long orderId, String uid); |
| | | /** |
| | | * 获取订单数量 |
| | | * @return |
| | | */ |
| | | Integer getOrderNum(GetOrderNumDto dto); |
| | | |
| | | /** |
| | | * 查询指定城市进行中的订单数量(status=1) |
| | | * |
| | | * @param cityId 开通城市ID |
| | | * @return 进行中订单数量 |
| | | */ |
| | | Integer countActiveOrdersByCityId(Long cityId); |
| | | |
| | | /** |
| | | * 保存车辆位置信息 |
| | |
| | | */ |
| | | void saveVehicleLocation(OrderTrajectory orderTrajectory); |
| | | |
| | | /** |
| | | * 成功操作下发命令后调用 用于弹出redis队列的获取成功的数据 |
| | | * @param dto |
| | | */ |
| | | void popOrder(PopOrderDto dto); |
| | | |
| | | OrderDetailVo orderDetail(Long orderId, String uid); |
| | | |
| | | R<String> feeDescription(Long orderId, String uid); |
| | | |
| | | /** |
| | | * 订单改价 |
| | |
| | | import com.xiaopeng.api.dto.account.UcUserInfo; |
| | | import com.xiaopeng.api.dto.account.UseUserCouponDto; |
| | | import com.xiaopeng.api.dto.automaticPilot.PushOrderDto; |
| | | import com.xiaopeng.api.dto.automaticPilot.VehicleEventDTO; |
| | | import com.xiaopeng.api.dto.operation.CruisePointDto; |
| | | import com.xiaopeng.api.dto.operation.LonLatDto; |
| | | import com.xiaopeng.api.dto.order.GetOrderNumDto; |
| | |
| | | import com.xiaopeng.api.feignClient.account.UserResourcesClient; |
| | | import com.xiaopeng.api.feignClient.account.XpAppUserCouponClient; |
| | | import com.xiaopeng.api.feignClient.automaticPilot.OrderMissionClient; |
| | | import com.xiaopeng.api.feignClient.automaticPilot.VehicleBuriedPointClient; |
| | | import com.xiaopeng.api.feignClient.maintenance.XpTaskRuleClient; |
| | | import com.xiaopeng.api.feignClient.operation.XpCruisePlanClient; |
| | | import com.xiaopeng.api.feignClient.operation.XpPointClient; |
| | |
| | | import com.xiaopeng.order.model.query.XpOrderExcelQuery; |
| | | import com.xiaopeng.order.model.query.XpOrderPageQuery; |
| | | import com.xiaopeng.order.model.vo.*; |
| | | import com.xiaopeng.order.service.IXpOrderCancelService; |
| | | import com.xiaopeng.order.service.IXpOrderEvaluateService; |
| | | import com.xiaopeng.order.service.IXpOrderReassignService; |
| | | import com.xiaopeng.order.service.IXpOrderService; |
| | | import com.xiaopeng.order.service.*; |
| | | import com.xiaopeng.order.utils.GDMapGeocodingUtil; |
| | | import com.xiaopeng.order.utils.TaxiPricingDemoService; |
| | | import com.xiaopeng.order.utils.RegionCodeFilterUtil; |
| | |
| | | private final XpCruisePlanClient xpCruisePlanClient; |
| | | private final XpPricingUtil xpPricingUtil; |
| | | private final GDMapGeocodingUtil gdMapGeocodingUtil; |
| | | private final VehicleBuriedPointClient vehicleBuriedPointClient; |
| | | private final IXpTestOrderService xpTestOrderService; |
| | | |
| | | |
| | | @Autowired |
| | |
| | | log.info("已将原车辆状态设为空闲,车辆ID: {}", oldVehicleId); |
| | | |
| | | // 6.1.4 为原车辆创建返程巡游订单 |
| | | -------------- |
| | | createReturnCruiseOrder(oldVehicle.getId(), order); |
| | | } else { |
| | | log.warn("查询原车辆信息失败,车辆ID: {}", oldVehicleId); |
| | |
| | | xpVehicleClient.updateVehicleById(vehicle1); |
| | | //找到车辆的收车点位 更新终点点位 |
| | | R<XpCruiseOrder> returnCruisePoint = xpCruisePlanClient.findReturnCruisePoint(xpCruiseOrder); |
| | | xpCruiseOrder = returnCruisePoint.getData(); |
| | | xpCruiseOrder.setOrderType(2); |
| | | xpCruiseOrder.setOrderReverse(1); |
| | | if(200 != returnCruisePoint.getCode()){ |
| | | xpCruiseOrder = returnCruisePoint.getData(); |
| | | xpCruiseOrder.setOrderType(2); |
| | | xpCruiseOrder.setOrderReverse(1); |
| | | } |
| | | } |
| | | } |
| | | xpCruiseOrderMapper.insert(xpCruiseOrder); |
| | |
| | | |
| | | /** |
| | | * 取消订单后的继续巡游任务 |
| | | * @param vehicle |
| | | * @param vehicleId |
| | | */ |
| | | public void addCruiseMission(Long vehicleId) { |
| | | XpVehicle vehicle = xpVehicleClient.queryById(vehicleId).getData(); |
| | |
| | | xpVehicleClient.updateVehicleById(vehicle1); |
| | | //找到车辆的收车点位 更新终点点位 |
| | | R<XpCruiseOrder> returnCruisePoint = xpCruisePlanClient.findReturnCruisePoint(xpCruiseOrder); |
| | | xpCruiseOrder = returnCruisePoint.getData(); |
| | | xpCruiseOrder.setOrderType(2); |
| | | xpCruiseOrder.setOrderReverse(1); |
| | | if(200 != returnCruisePoint.getCode()){ |
| | | xpCruiseOrder = returnCruisePoint.getData(); |
| | | xpCruiseOrder.setOrderType(2); |
| | | xpCruiseOrder.setOrderReverse(1); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | xpCruiseOrder.setVehicleId(null); |
| | | xpCruiseOrderMapper.updateById(xpCruiseOrder); |
| | | log.info("修改巡游单状态,开始执行巡游单 {}", dto.getOrderId()); |
| | | // 封装埋点消息实体 |
| | | VehicleEventDTO vehicleEventDTO = new VehicleEventDTO(); |
| | | vehicleEventDTO.setVin(dto.getXpVehicleVin()); |
| | | vehicleEventDTO.setXpuId(""); |
| | | vehicleEventDTO.setOrderId(String.valueOf(dto.getOrderId())); |
| | | vehicleEventDTO.setEventKey("RT_xpu_vehicle_trace_upload"); |
| | | vehicleEventDTO.setEventTime(System.currentTimeMillis()); |
| | | Map<String,Object> attributes = new HashMap<>(); |
| | | attributes.put("vin",vehicleEventDTO.getVin()); |
| | | attributes.put("order_id",vehicleEventDTO.getOrderId()); |
| | | attributes.put("order_type","cruise_order"); |
| | | attributes.put("timestamp",vehicleEventDTO.getEventTime()); |
| | | attributes.put("current_main_status",OrderStatus.ORDER_STARTED); |
| | | attributes.put("current_sub_status",""); |
| | | VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(dto.getXpVehicleVin())), VehiclePosition.class); |
| | | if(Objects.nonNull(vehiclePosition)){ |
| | | attributes.put("odometer_km",vehiclePosition.getTotalOdometer()); |
| | | }else { |
| | | attributes.put("odometer_km",""); |
| | | } |
| | | vehicleEventDTO.setAttributes(attributes); |
| | | vehicleBuriedPointClient.sendVehicleEvent(vehicleEventDTO); |
| | | log.info("巡游单埋点消息,开始执行推送: {}", dto.getOrderId()); |
| | | } |
| | | } |
| | | //乘客单处理逻辑 |
| | |
| | | //推送乘客车辆到达预约点的导航数据 |
| | | sendRoute(addTaxiPassengerVo.getUid(), orderId, "ORDER_NAVIGATION_START_DATA", dto.getXpVehicleVin()); |
| | | } |
| | | |
| | | if(order.getStatus() == 2){ |
| | | // 封装埋点消息实体 |
| | | VehicleEventDTO vehicleEventDTO = new VehicleEventDTO(); |
| | | vehicleEventDTO.setVin(dto.getXpVehicleVin()); |
| | | vehicleEventDTO.setXpuId(""); |
| | | vehicleEventDTO.setOrderId(String.valueOf(dto.getOrderId())); |
| | | vehicleEventDTO.setEventKey("RT_xpu_vehicle_trace_upload"); |
| | | vehicleEventDTO.setEventTime(System.currentTimeMillis()); |
| | | Map<String,Object> attributes = new HashMap<>(); |
| | | attributes.put("vin",vehicleEventDTO.getVin()); |
| | | attributes.put("order_id",vehicleEventDTO.getOrderId()); |
| | | attributes.put("order_type","user_order"); |
| | | attributes.put("timestamp",vehicleEventDTO.getEventTime()); |
| | | attributes.put("current_main_status",OrderStatus.ORDER_EN_ROUTE_TO_PICKUP); |
| | | attributes.put("current_sub_status",""); |
| | | VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(dto.getXpVehicleVin())), VehiclePosition.class); |
| | | if(Objects.nonNull(vehiclePosition)){ |
| | | attributes.put("odometer_km",vehiclePosition.getTotalOdometer()); |
| | | }else { |
| | | attributes.put("odometer_km",""); |
| | | } |
| | | vehicleEventDTO.setAttributes(attributes); |
| | | vehicleBuriedPointClient.sendVehicleEvent(vehicleEventDTO); |
| | | log.info("用户单埋点消息,开始执行推送: {}", dto.getOrderId()); |
| | | } |
| | | |
| | | } |
| | | //测试订单 |
| | | if (OrderType.TEST_ORDER.equals(orderType)) { |
| | | XpTestOrder xpTestOrder = xpTestOrderService.getById(orderId); |
| | | //订单为待接单状态 |
| | | if (xpTestOrder.getStatus() < 4) { |
| | | xpTestOrder.setAcceptanceTime(LocalDateTime.now()); |
| | | R<XpVehicle> byVehicleVin = xpVehicleClient.findByVehicleVin(dto.getXpVehicleVin()); |
| | | XpVehicle vehicle = null; |
| | | if (byVehicleVin.getCode() == 200) { |
| | | vehicle = byVehicleVin.getData(); |
| | | xpTestOrder.setVehicleId(vehicle.getId()); |
| | | xpTestOrder.setFleetId(vehicle.getFleetId()); |
| | | } |
| | | xpTestOrder.setStatus(2); |
| | | |
| | | // 修改车辆信息 |
| | | XpVehicle vehicle1 = new XpVehicle(); |
| | | vehicle1.setId(vehicle.getId()); |
| | | vehicle1.setState(1); |
| | | xpVehicleClient.updateVehicleById(vehicle1); |
| | | |
| | | xpTestOrder.setVehicleId(null); |
| | | xpTestOrderService.updateById(xpTestOrder); |
| | | redisService.setCacheObject("ORDER_STATUS:" + xpTestOrder.getId(), 2, 24L, TimeUnit.HOURS); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | // 令牌秘钥 |
| | | // @Value("${token.secret}") |
| | | private String secret = "abcdefghijklmnopqrstuvwxyz"; |
| | | private String secret = "iymGhx1XkAAHrex2Zf4ASbiD9P2ksTam"; |
| | | |
| | | /** |
| | | * 验证用户认证信息 |
| | |
| | | xpVehicleVO.setMileageRange(0F); |
| | | xpVehicleVO.setCurrentElectricity(0); |
| | | } |
| | | if (StringUtils.isNotBlank(xpVehicleVO.getVehiclePictures())) { |
| | | JSONObject jsonObject = JSONObject.parseObject(xpVehicleVO.getVehiclePictures()); |
| | | if(jsonObject!=null){ |
| | | String downloadUrl = null; |
| | | try { |
| | | downloadUrl= aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | jsonObject.put("url", downloadUrl); |
| | | xpVehicleVO.setVehiclePictures(jsonObject.toJSONString()); |
| | | } |
| | | } |
| | | // 判断车辆维修状态 |
| | | Integer maintenanceStatus = xpVehicleRepairClient.getMaintenanceStatus(xpVehicleVO.getId()).getData(); |
| | | xpVehicleVO.setMaintenanceStatus(maintenanceStatus); |