| | |
| | | log.error("根据用户ID和城市编码获取失败:{}", cause.getMessage()); |
| | | return R.fail("根据用户ID和城市编码获取失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<Integer> getTargetedServiceWeight(Long appUserId, String cityCode) { |
| | | log.error("获取定向服务权限失败:" + cause.getMessage()); |
| | | return R.fail("获取定向服务权限失败"); |
| | | } |
| | | |
| | | |
| | | }; |
| | | |
| | | } |
| | | } |
| | |
| | | @GetMapping("/logan/inner/v1/targetedService/findListByUserIdAndCityCode") |
| | | R<List<XpTargetedServiceVehicleVo>> findListByUserIdAndCityCode(@RequestParam("appUserId") Long appUserId, @RequestParam("cityCode") String cityCode); |
| | | |
| | | |
| | | /** |
| | | * 获取定向服务权限 |
| | | * @param appUserId |
| | | * @param cityCode |
| | | * @return |
| | | */ |
| | | @GetMapping("/logan/inner/v1/targetedService/getTargetedServiceWeight") |
| | | R<Integer> getTargetedServiceWeight(@RequestParam("appUserId") Long appUserId, @RequestParam("cityCode") String cityCode); |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | //获取定向服务配置 |
| | | R<List<XpTargetedServiceVehicleVo>> targetedServiceUserR = xpTargetedServiceClient.findListByUserIdAndCityCode(xpOrder.getAppUserId(), xpOrder.getCityCode()); |
| | | if(targetedServiceUserR.getCode() == R.SUCCESS && CollUtil.isNotEmpty(targetedServiceUserR.getData()) ){ |
| | | R<Integer> targetedServiceWeight = xpTargetedServiceClient.getTargetedServiceWeight(xpOrder.getAppUserId(), xpOrder.getCityCode()); |
| | | if(targetedServiceWeight.getCode() == R.SUCCESS && null != targetedServiceWeight.getData()){ |
| | | log.info("添加定向服务订单:{}", xpOrder.getOrderNumber()); |
| | | XpTargetedServiceVehicleVo xpTargetedServiceVehicleVo = targetedServiceUserR.getData().get(0); |
| | | return addSpOrderPush(xpOrder, xpPoint, xpRoutePlan, maxPushDistance, xpTargetedServiceVehicleVo, orderId, currentTimeSlot, distance, duration, uid); |
| | | return addSpOrderPush(xpOrder, xpPoint, xpRoutePlan, maxPushDistance, targetedServiceWeight.getData(), orderId, currentTimeSlot, distance, duration, uid); |
| | | }else{ |
| | | log.info("添加普通订单:{}", xpOrder.getOrderNumber()); |
| | | return addOrderPush(xpOrder, xpPoint, xpRoutePlan, maxPushDistance, isPriorityDispatch, orderId, currentTimeSlot, distance, duration, uid); |
| | |
| | | * @param xpPoint |
| | | * @param xpRoutePlan |
| | | * @param maxPushDistance |
| | | * @param xpTargetedServiceVehicleVo |
| | | * @param weight |
| | | * @param orderId |
| | | * @param currentTimeSlot |
| | | * @param distance |
| | |
| | | * @return |
| | | */ |
| | | private String addSpOrderPush(XpOrder xpOrder, XpPoint xpPoint, XpRoutePlan xpRoutePlan, double maxPushDistance, |
| | | XpTargetedServiceVehicleVo xpTargetedServiceVehicleVo, Long orderId, String currentTimeSlot, Integer distance, Integer duration, String uid){ |
| | | Integer weight, Long orderId, String currentTimeSlot, Integer distance, Integer duration, String uid){ |
| | | // 找出现在所有的队列 通过计算距离 算出目前应该放在那个队列 如果没有符合的新增一个队列 符合后看是否白名单账号 是则直接放在队列前端 |
| | | Set<String> quoteMatchName = redisService.getQuoteMatchName(CacheConstants.SP_QUEUE_POINT_ID); |
| | | log.info("当前队列(定向服务):{}", quoteMatchName); |
| | |
| | | redisQueuePointIdVo.setDistance(distance.toString()); |
| | | redisQueuePointIdVo.setDuration(duration.toString()); |
| | | redisQueuePointIdVo.setPlanRuleForQueue(xpRoutePlan.getRoutePlanRule().toString()); |
| | | redisQueuePointIdVo.setTargetedVal(xpTargetedServiceVehicleVo.getWeight()); |
| | | redisQueuePointIdVo.setTargetedVal(weight); |
| | | ll.add(redisQueuePointIdVo); |
| | | //排序 |
| | | ll.sort((o1, o2) -> o2.getTargetedVal() - o1.getTargetedVal()); |
| | |
| | | |
| | | String key = CacheConstants.SP_QUEUE_POINT_ID + "-" + xpPoint.getId() + "-" + xpPoint.getPointLon() + "," + xpPoint.getPointLat(); |
| | | if(xpRoutePlan==null){ |
| | | redisService.setCacheList(key, Arrays.asList(orderId + "_" + xpPoint.getPointLon() + "," + xpPoint.getPointLat() + "_0" + "_" + uid + "_" + xpOrder.getOrderNumber() + "_" + distance + "_" + duration + "_" + null + "_" + xpTargetedServiceVehicleVo.getWeight())); |
| | | redisService.setCacheList(key, Arrays.asList(orderId + "_" + xpPoint.getPointLon() + "," + xpPoint.getPointLat() + "_0" + "_" + uid + "_" + xpOrder.getOrderNumber() + "_" + distance + "_" + duration + "_" + null + "_" + weight)); |
| | | }else { |
| | | redisService.setCacheList(key, Arrays.asList(orderId + "_" + xpPoint.getPointLon() + "," + xpPoint.getPointLat() + "_0" + "_" + uid + "_" + xpOrder.getOrderNumber() + "_" + distance + "_" + duration + "_" + xpRoutePlan.getRoutePlanRule() + "_" + xpTargetedServiceVehicleVo.getWeight())); |
| | | redisService.setCacheList(key, Arrays.asList(orderId + "_" + xpPoint.getPointLon() + "," + xpPoint.getPointLat() + "_0" + "_" + uid + "_" + xpOrder.getOrderNumber() + "_" + distance + "_" + duration + "_" + xpRoutePlan.getRoutePlanRule() + "_" + weight)); |
| | | } |
| | | log.info("订单推单:{} {}", key, redisService.getCacheList(key)); |
| | | xpOrder.setQueueName(key); |
| | |
| | | LambdaQueryWrapper<XpPoint> pendingEnableQuery = new LambdaQueryWrapper<>(); |
| | | pendingEnableQuery.eq(XpPoint::getElectronicAreaId, operationAreaIdToEnable) |
| | | .eq(XpPoint::getPointType, 1) |
| | | .isNotNull(XpPoint::getOperationType) |
| | | .eq(XpPoint::getOperationStatus, 3); |
| | | List<XpPoint> pendingEnablePoints = xpPointMapper.selectList(pendingEnableQuery); |
| | | int pendingCount = pendingEnablePoints == null ? 0 : pendingEnablePoints.size(); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取定向服务权限 |
| | | * @param appUserId |
| | | * @param cityCode |
| | | * @return |
| | | */ |
| | | @GetMapping("/logan/inner/v1/targetedService/getTargetedServiceWeight") |
| | | public R<Integer> getTargetedServiceWeight(@RequestParam("appUserId") Long appUserId, @RequestParam("cityCode") String cityCode){ |
| | | Integer targetedServiceWeight = xpTargetedServiceService.getTargetedServiceWeight(appUserId, cityCode); |
| | | return R.ok(targetedServiceWeight); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.web.page.PageInfo; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | |
| | | List<XpTargetedServiceVehicleVo> findListByUserIdAndCityCode(Long appUserId, String cityCode); |
| | | |
| | | List<String> findSetVehicleVinByUserIdAndCityCode(Long appUserId, String cityCode); |
| | | |
| | | |
| | | /** |
| | | * 获取定向服务权重 |
| | | * @param appUserId |
| | | * @param cityCode |
| | | * @return |
| | | */ |
| | | Integer getTargetedServiceWeight(Long appUserId, String cityCode); |
| | | } |
| | |
| | | package com.xiaopeng.operation.service.impl; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient; |
| | | import com.xiaopeng.api.model.account.SysUser; |
| | | import com.xiaopeng.api.model.operation.XpTargetedService; |
| | | import com.xiaopeng.api.model.operation.XpTargetedServiceVehicle; |
| | | import com.xiaopeng.api.model.operation.XpTargetedServiceWhitelist; |
| | | import com.xiaopeng.api.model.operation.XpWhitelist; |
| | | import com.xiaopeng.api.model.vehicleConvoy.XpVehicle; |
| | | import com.xiaopeng.api.query.operation.XpTargetedServiceQuery; |
| | | import com.xiaopeng.api.vo.operation.XpTargetedServiceVehicleVo; |
| | |
| | | import com.xiaopeng.common.core.utils.SensitiveDataCryptoUtil; |
| | | import com.xiaopeng.common.core.web.page.PageInfo; |
| | | import com.xiaopeng.operation.mapper.XpTargetedServiceMapper; |
| | | import com.xiaopeng.operation.service.IXpWhitelistService; |
| | | import com.xiaopeng.operation.service.XpTargetedServiceService; |
| | | import com.xiaopeng.operation.service.XpTargetedServiceVehicleService; |
| | | import com.xiaopeng.operation.service.XpTargetedServiceWhitelistService; |
| | |
| | | XpVehicleClient xpVehicleClient; |
| | | @Resource |
| | | XpTargetedServiceMapper xpTargetedServiceMapper; |
| | | |
| | | @Resource |
| | | private IXpWhitelistService xpWhitelistService; |
| | | |
| | | |
| | | public List<XpTargetedServiceVehicle> listByTargetedServiceId(Long targetedServiceId) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public Integer getTargetedServiceWeight(Long appUserId, String cityCode) { |
| | | List<XpWhitelist> one = xpWhitelistService.list(new QueryWrapper<XpWhitelist>().eq("app_user_id", appUserId).eq("status", 1) |
| | | .eq("is_deleted", 0).last(" and expire_time >= DATE(NOW()) or expire_time is null")); |
| | | if(!one.isEmpty()){ |
| | | List<Long> collect = one.stream().map(XpWhitelist::getId).collect(Collectors.toList()); |
| | | List<XpTargetedServiceWhitelist> xpTargetedServiceWhitelists = xpTargetedServiceWhitelistService.list(new QueryWrapper<XpTargetedServiceWhitelist>().in("whitelist_id", collect)); |
| | | for (XpTargetedServiceWhitelist xpTargetedServiceWhitelist : xpTargetedServiceWhitelists) { |
| | | XpTargetedService targetedServiceVo = this.getOne(new QueryWrapper<XpTargetedService>().eq("id", xpTargetedServiceWhitelist.getTargetedServiceId()) |
| | | .eq("status", 1).eq("is_deleted", 0).eq("city_code", cityCode) |
| | | .last(" and (is_long_valid = 1 or now() between start_time and end_time)")); |
| | | if(null != targetedServiceVo){ |
| | | return xpTargetedServiceWhitelist.getWeight(); |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |