Merge remote-tracking branch 'origin/master'
| | |
| | | } |
| | | |
| | | @Override |
| | | public R<Integer> todayCancellationCount(Long userId) { |
| | | log.error("获取当日取消订单次数失败,原因: {}", cause.getMessage()); |
| | | return R.fail("获取当日取消订单次数失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<Integer> countActiveOrdersByCityId(Long cityId) { |
| | | log.error("查询进行中订单数量失败,原因: {}", cause.getMessage()); |
| | | return R.ok(0); |
| | |
| | | @PostMapping("/inner/order/getOrderNum") |
| | | R<Integer> getOrderNum(@RequestBody GetOrderNumDto dto); |
| | | |
| | | |
| | | |
| | | /** |
| | | * 当日取消订单次数 |
| | | * |
| | | * @param |
| | | * @return 订单数量 |
| | | */ |
| | | @PostMapping("/inner/order/todayCancellationCount") |
| | | R<Integer> todayCancellationCount(@RequestParam Long userId); |
| | | |
| | | /** |
| | | * 查询指定城市进行中的订单数量(status=1) |
| | | * |
| | |
| | | </description> |
| | | |
| | | <dependencies> |
| | | |
| | | <dependency> |
| | | <groupId>org.jsoup</groupId> |
| | | <artifactId>jsoup</artifactId> |
| | | <version>1.18.1</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.alibaba.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> |
| | |
| | | <artifactId>snakeyaml</artifactId> |
| | | <version>1.33</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.xiaopeng.logan</groupId> |
| | | <artifactId>xp-evi-oss-sdk</artifactId> |
| | | <version>1.0.1-SNAPSHOT</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
| | |
| | | import com.xiaopeng.itinerary.service.IXpGeoQueryEntityService; |
| | | import com.xiaopeng.itinerary.service.XpPricingService; |
| | | import com.xiaopeng.api.vo.HotFixInfoVo; |
| | | import com.xiaopeng.itinerary.utils.ImageTagProcessor; |
| | | import com.xiaopeng.itinerary.vo.SaveOrderVo; |
| | | import com.xiaopeng.unifiedverification.interceptor.XpClientCheck; |
| | | import io.swagger.annotations.Api; |
| | |
| | | private final XpPricingService xpPricingService; |
| | | private final IXpGeoQueryEntityService xpGeoQueryEntityService; |
| | | private final RedisService redisService; |
| | | private final ImageTagProcessor imageTagProcessor; |
| | | |
| | | |
| | | public XpPricingController(XpPricingService xpPricingService, IXpGeoQueryEntityService xpGeoQueryEntityService, RedisService redisService) { |
| | | public XpPricingController(XpPricingService xpPricingService, IXpGeoQueryEntityService xpGeoQueryEntityService, RedisService redisService, ImageTagProcessor imageTagProcessor) { |
| | | this.xpPricingService = xpPricingService; |
| | | this.xpGeoQueryEntityService = xpGeoQueryEntityService; |
| | | this.redisService = redisService; |
| | | |
| | | this.imageTagProcessor = imageTagProcessor; |
| | | } |
| | | |
| | | |
| | |
| | | @GetMapping("/base/v1/mini-program/pricing/rules/{openCityId}") |
| | | @ApiOperation(value = "获取费用规则", tags = {"小程序-根据开通城市获取费用规则"}, response = String.class) |
| | | public R<?> getPricingRules(@PathVariable Long openCityId) { |
| | | XpPricing xpPricing = xpPricingService.getOne(new LambdaQueryWrapper<XpPricing>().eq(XpPricing::getCityId, openCityId).eq(XpPricing::getPricingType, 1).last("limit 1")); |
| | | XpPricing xpPricing = xpPricingService.getOne(new LambdaQueryWrapper<XpPricing>().eq(XpPricing::getCityId, openCityId).last("limit 1")); |
| | | if (xpPricing != null) { |
| | | return R.ok(xpPricing.getPriceRule()); |
| | | String priceRule = xpPricing.getPriceRule(); |
| | | if (priceRule != null && priceRule.contains("<img")) { |
| | | priceRule = imageTagProcessor.replaceImgSrcWithDownloadUrl(priceRule); |
| | | } |
| | | return R.ok(priceRule); |
| | | } |
| | | return R.ok(""); |
| | | } |
| | |
| | | } |
| | | |
| | | // 判断当天取消的次数 后台配置 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; |
| | | } |
| | | Integer num = xpOrderClient.todayCancellationCount(Long.valueOf(uid)).getData(); |
| | | if (num >= cancelCount) { |
| | | isSilent = true; |
| | | } |
| | | |
| | | |
| New file |
| | |
| | | package com.xiaopeng.itinerary.utils; |
| | | |
| | | import com.xiaopeng.evi.oss.service.AliOssService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.jsoup.Jsoup; |
| | | import org.jsoup.nodes.Document; |
| | | import org.jsoup.nodes.Element; |
| | | import org.jsoup.select.Elements; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | |
| | | @Slf4j |
| | | @Component |
| | | public class ImageTagProcessor { |
| | | |
| | | private final AliOssService aliOssService; |
| | | |
| | | public ImageTagProcessor(AliOssService aliOssService) { |
| | | this.aliOssService = aliOssService; |
| | | } |
| | | |
| | | public String replaceImgSrcWithDownloadUrl(String html) { |
| | | if (!StringUtils.hasText(html)) { |
| | | return html; |
| | | } |
| | | |
| | | Document document = Jsoup.parse(html); |
| | | Elements imgTags = document.select("img"); |
| | | for (Element imgTag : imgTags) { |
| | | String dataId = imgTag.attr("data-id"); |
| | | String dataName = imgTag.attr("data-name"); |
| | | if (!StringUtils.hasText(dataId) || !StringUtils.hasText(dataName)) { |
| | | continue; |
| | | } |
| | | |
| | | try { |
| | | String downloadUrl = aliOssService.getDownloadUrl(dataId, dataName, true); |
| | | if (StringUtils.hasText(downloadUrl)) { |
| | | imgTag.attr("src", downloadUrl); |
| | | } |
| | | } catch (UnsupportedEncodingException e) { |
| | | log.warn("replace image src failed, dataId={}, dataName={}", dataId, dataName, e); |
| | | } |
| | | } |
| | | return document.body().html(); |
| | | } |
| | | } |
| | |
| | | throw new ServiceException("当前点位未开通服务", I18nKeyConstant.NO_CURRENT_REGION); |
| | | } |
| | | |
| | | // 判断当天取消的次数 后台配置 redis 查询 |
| | | Object cancelOrder = redisService.getCacheObject("CANCEL_ORDER_" + uid); |
| | | // 静默处理 |
| | | boolean isSilent = false; |
| | | if (cancelOrder != null) { |
| | | Integer num = Integer.valueOf(cancelOrder.toString()); |
| | | if (num >= cancelCount) { |
| | | isSilent = true; |
| | | } |
| | | Integer num = xpOrderClient.todayCancellationCount(Long.valueOf(uid)).getData(); |
| | | if (num >= cancelCount) { |
| | | isSilent = true; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | // 找出符合条件的 |
| | | availableVehiclesNearby = availableVehiclesNearby.stream().filter(e -> data.contains(e.getVin())).collect(Collectors.toList()); |
| | | |
| | | // List<VehiclePositionVo> availableVehiclesNearby =vehiclePositionVos.getData(); |
| | | |
| | | if (!availableVehiclesNearby.isEmpty()) { |
| | |
| | | vehiclePosition.setDistance(0.0); |
| | | } |
| | | } |
| | | // availableVehiclesNearby = availableVehiclesNearby.stream().sorted(Comparator.comparing(VehiclePositionVo::getDistance)).collect(Collectors.toList()); |
| | | // int size = tendencyDistance; |
| | | // // 做比对的分数 |
| | | // double temp = availableVehiclesNearby.get(0).getDistance(); |
| | | // for (VehiclePositionVo vehiclePosition : availableVehiclesNearby) { |
| | | // vehiclePosition.setDistanceScore(vehiclePosition.getDistanceScore() + size); |
| | | // if (temp != vehiclePosition.getDistance()) { |
| | | // size--; |
| | | // } |
| | | // } |
| | | |
| | | // 分数计算 把时间短的分数调高 |
| | | availableVehiclesNearby = availableVehiclesNearby.stream().sorted(Comparator.comparing(VehiclePositionVo::getDistance)).collect(Collectors.toList()); |
| | | int size = tendencyDistance; |
| | | // 做比对的分数 |
| | | double temp = availableVehiclesNearby.get(0).getDistance(); |
| | | int score = 10; |
| | | for (VehiclePositionVo vehiclePosition : availableVehiclesNearby) { |
| | | vehiclePosition.setDistanceScore(vehiclePosition.getDistanceScore() + size); |
| | | if (temp != vehiclePosition.getDistance()) { |
| | | size--; |
| | | } |
| | | vehiclePosition.setDistanceScore(score); |
| | | score--; |
| | | } |
| | | } |
| | | |
| | |
| | | vehiclePosition.setSecond(0); |
| | | } |
| | | } |
| | | |
| | | // 分数计算 把时间短的分数调高 |
| | | availableVehiclesNearby = availableVehiclesNearby.stream().sorted(Comparator.comparing(VehiclePositionVo::getSecond)).collect(Collectors.toList()); |
| | | int size = tendencyTime; |
| | | // 做比对的分数 |
| | | double temp = availableVehiclesNearby.get(0).getSecond(); |
| | | int score = 10; |
| | | for (VehiclePositionVo vehiclePosition : availableVehiclesNearby) { |
| | | vehiclePosition.setTimeScore(vehiclePosition.getTimeScore() + size); |
| | | if (temp != vehiclePosition.getSecond()) { |
| | | size--; |
| | | } |
| | | vehiclePosition.setTimeScore(score); |
| | | score--; |
| | | } |
| | | // availableVehiclesNearby = availableVehiclesNearby.stream().sorted(Comparator.comparing(VehiclePositionVo::getSecond)).collect(Collectors.toList()); |
| | | // int size = tendencyTime; |
| | | // // 做比对的分数 |
| | | // double temp = availableVehiclesNearby.get(0).getSecond(); |
| | | // for (VehiclePositionVo vehiclePosition : availableVehiclesNearby) { |
| | | // vehiclePosition.setTimeScore(vehiclePosition.getTimeScore() + size); |
| | | // if (temp != vehiclePosition.getSecond()) { |
| | | // size--; |
| | | // } |
| | | // } |
| | | |
| | | } |
| | | |
| | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.xiaopeng.api.dto.QueryOrderRouteDTO; |
| | | import com.xiaopeng.api.dto.operation.LonLatDto; |
| | | import com.xiaopeng.api.dto.order.AddCruiseMissionDto; |
| | |
| | | return R.ok(routeVo); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 当日取消订单次数 |
| | | * |
| | | * @param |
| | | * @return 订单数量 |
| | | */ |
| | | @PostMapping("/inner/order/todayCancellationCount") |
| | | public R<Integer> todayCancellationCount(@RequestParam Long userId){ |
| | | long count = xpOrderService.count(new QueryWrapper<XpOrder>().eq("app_user_id", userId).eq("status", 0) |
| | | .eq("is_deleted", 0).last(" and DATE_FORMAT(create_time, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d")); |
| | | return R.ok((int)count); |
| | | } |
| | | |
| | | } |
| | |
| | | xpOrderCancelService.save(xpOrderCancel); |
| | | |
| | | |
| | | // 设置当天的取消次数缓存 |
| | | Object cacheObject = redisService.getCacheObject("CANCEL_ORDER_" + uid); |
| | | if (cacheObject == null) { |
| | | redisService.setCacheCancelOrder("CANCEL_ORDER_" + uid, 1); |
| | | } else { |
| | | Integer i = Integer.valueOf(cacheObject.toString()); |
| | | redisService.setCacheCancelOrder("CANCEL_ORDER_" + uid, i + 1); |
| | | } |
| | | |
| | | // 移除mongo数据 |
| | | xpPricingClient.deleteXpGeoQueryEntity(order.getId().toString()); |
| | | |
| | |
| | | |
| | | // 移除mongo数据 |
| | | xpPricingClient.deleteXpGeoQueryEntity(order.getId().toString()); |
| | | // 设置当天的取消次数缓存 |
| | | Object cacheObject = redisService.getCacheObject("CANCEL_ORDER_" + appUserId); |
| | | if (cacheObject == null) { |
| | | redisService.setCacheCancelOrder("CANCEL_ORDER_" + appUserId, 1); |
| | | } else { |
| | | Integer i = Integer.valueOf(cacheObject.toString()); |
| | | redisService.setCacheCancelOrder("CANCEL_ORDER_" + appUserId, i + 1); |
| | | } |
| | | return order; |
| | | } |
| | | |
| | |
| | | */ |
| | | @PostMapping("/inner/vehicle/queryVehiclePositionByVin") |
| | | public R<List<String>> queryVehiclePositionByVin(@RequestBody VehiclePositionByVinDto dto){ |
| | | List<XpVehicle> list = xpVehicleService.list(new LambdaQueryWrapper<XpVehicle>().eq(XpVehicle::getState, 0).eq(XpVehicle::getOperatingStatus, 1).eq(XpVehicle::getElectronicId, dto.getFenceId()).in(XpVehicle::getVehicleVin, |
| | | List<XpVehicle> list = xpVehicleService.list(new LambdaQueryWrapper<XpVehicle>().eq(XpVehicle::getState, 0) |
| | | .eq(XpVehicle::getOperatingStatus, 1).eq(XpVehicle::getElectronicId, dto.getFenceId()).in(XpVehicle::getVehicleVin, |
| | | dto.getVinList())); |
| | | if(list.isEmpty()){ |
| | | return R.ok(new ArrayList<>()); |
| | |
| | | String result = vehicleControlUtil.vehiclesCommand(vehiclesCommandVo, xpOrder.getAppUserId()); |
| | | log.info("车辆控制结果:{}", result); |
| | | JSONObject jsonObject = JSONObject.parseObject(result); |
| | | String msgId = jsonObject.getString("msgId"); |
| | | if (StringUtils.isEmpty(msgId)) { |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if (code != 0) { |
| | | return 0; |
| | | }else { |
| | | xpOrderClient.updateOrder(xpOrder); |