xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/controller/OrderMissionController.java
@@ -19,6 +19,7 @@ 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.*; @@ -236,7 +237,7 @@ }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.CRUISE_ORDER); jsonObject.put("orderType", com.xiaopeng.api.vo.OrderType.USER_ORDER); } jsonObject.put("orderId", dto.getOrderId()); jsonObject.put("vin", dto.getVin()); xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/service/KafkaConsumerService.java
@@ -583,6 +583,7 @@ 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); @@ -763,6 +764,7 @@ 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()); xp-robotaxi-common/xp-common-core/src/main/java/com/xiaopeng/common/core/constant/TokenConstants.java
@@ -16,11 +16,6 @@ * 令牌前缀 */ public static final String PREFIX = "Bearer "; /** * 令牌秘钥 */ public final static String SECRET = "iymGhx1XkAAHrex2Zf4ASbiD9P2ksTam"; /** * 参数签名 xp-robotaxi-common/xp-common-core/src/main/java/com/xiaopeng/common/core/utils/JwtUtils.java
@@ -15,7 +15,6 @@ */ public class JwtUtils { public static String secret = TokenConstants.SECRET; /** * 从数据声明生成令牌 @@ -23,7 +22,7 @@ * @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; @@ -35,7 +34,7 @@ * @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(); } @@ -46,9 +45,9 @@ * @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); } /** @@ -57,9 +56,9 @@ * @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); } @@ -91,9 +90,9 @@ * @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); } @@ -116,9 +115,9 @@ * @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); } /** @@ -127,9 +126,9 @@ * @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); } @@ -151,9 +150,9 @@ * @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); } xp-robotaxi-common/xp-common-security/src/main/java/com/xiaopeng/common/security/auth/AuthLogic.java
@@ -81,7 +81,7 @@ { 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)) xp-robotaxi-common/xp-common-security/src/main/java/com/xiaopeng/common/security/handler/GlobalExceptionHandler.java
@@ -106,7 +106,7 @@ public AjaxResult handleRuntimeException(RuntimeException e, HttpServletRequest request) { String requestURI = request.getRequestURI(); log.error("请求地址'{}',发生未知异常.", requestURI, e); return AjaxResult.error(e.getMessage()); return AjaxResult.error("系统繁忙,请稍后重试"); } /** @@ -116,7 +116,7 @@ public AjaxResult handleException(Exception e, HttpServletRequest request) { String requestURI = request.getRequestURI(); log.error("请求地址'{}',发生系统异常.", requestURI, e); return AjaxResult.error(e.getMessage()); return AjaxResult.error("系统繁忙,请稍后重试"); } /** xp-robotaxi-common/xp-common-security/src/main/java/com/xiaopeng/common/security/service/TokenService.java
@@ -9,6 +9,7 @@ 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; @@ -29,6 +30,9 @@ public class TokenService { @Autowired private RedisService redisService; @Value("${token.secret}") private String secret; protected static final long MILLIS_SECOND = 1000; @@ -62,7 +66,7 @@ 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; } @@ -90,7 +94,7 @@ 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; } @@ -150,7 +154,7 @@ 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; } @@ -167,7 +171,7 @@ 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; } @@ -190,7 +194,7 @@ */ public void delLoginUser(String token) { if (StringUtils.isNotEmpty(token)) { String userkey = JwtUtils.getUserKey(token); String userkey = JwtUtils.getUserKey(token, secret); redisService.deleteObject(getTokenKey(userkey)); } } @@ -253,4 +257,8 @@ private String getUserKey(Long userid) { return ACCESS_TOKEN + userid; } public String getSecret() { return secret; } } xp-robotaxi-gateway-boot/src/main/java/com/xiaopeng/gateway/filter/AuthFilter.java
@@ -5,6 +5,7 @@ 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; @@ -46,6 +47,9 @@ @Autowired private RedisService redisService; @Value("${token.secret}") private String secret; @@ -69,7 +73,7 @@ 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); @@ -153,7 +157,7 @@ if (StringUtils.isEmpty(token)) { throw new NotLoginException("令牌不能为空"); } Claims claims = JwtUtils.parseToken(token); Claims claims = JwtUtils.parseToken(token, secret); if (claims == null) { throw new NotLoginException("令牌已过期或验证不正确!"); } xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/service/XpPricingService.java
@@ -45,6 +45,5 @@ */ String saveOrder(XpOrderDto dto, String uid); void testOrder(Long orderId, Integer status); } xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/service/impl/XpPricingServiceImpl.java
@@ -489,16 +489,16 @@ } // 判断当天取消的次数 后台配置 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; } } // 获取起步里程 @@ -522,13 +522,7 @@ // 生成订单数据 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()); @@ -588,10 +582,10 @@ 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); @@ -707,224 +701,5 @@ } /** * 测试阶段用于自动完成小程序的整个流程数据状态流转 * @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); } } } xp-robotaxi-map-boot/pom.xml
@@ -242,6 +242,12 @@ <artifactId>jts-core</artifactId> <version>1.19.0</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> xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/service/serviceimpl/XpPointServiceImpl.java
@@ -2,6 +2,8 @@ import cn.hutool.core.collection.CollUtil; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.xiaopeng.api.dto.operation.PointAddDto; @@ -23,6 +25,7 @@ import com.xiaopeng.common.core.utils.StringUtils; import com.xiaopeng.common.core.web.page.PageInfo; import com.xiaopeng.common.redis.service.RedisService; import com.xiaopeng.evi.oss.service.AliOssService; import com.xiaopeng.map.constant.I18nKeyConstant; import com.xiaopeng.map.dto.NearestDto; import com.xiaopeng.map.mapper.XpPointMapper; @@ -49,6 +52,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.io.UnsupportedEncodingException; import java.time.LocalTime; import java.util.*; import java.util.concurrent.TimeUnit; @@ -89,6 +93,9 @@ @Autowired private RedissonClient redissonClient; @Autowired private AliOssService aliOssService; @Override @Transactional @@ -294,6 +301,28 @@ @Override public List<XpPoint> listAll(PointListQuery query) { List<XpPoint> list = this.baseMapper.listAll(query); for (XpPoint xpPoint : list) { String pointPictures = xpPoint.getPointPictures(); if (org.apache.commons.lang3.StringUtils.isNotBlank(pointPictures)) { JSONArray jsonArray = JSONArray.parseArray(pointPictures); for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); if (Objects.isNull(jsonObject)) { continue; } String downloadUrl = jsonObject.getString("url");; try { downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); } catch (UnsupportedEncodingException e) { log.error("获取图片下载地址失败", e); } jsonObject.put("url", downloadUrl); } xpPoint.setPointPictures(JSONArray.toJSONString(jsonArray)); } } return list; } xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/impl/XpPointServiceImpl.java
@@ -2,6 +2,7 @@ import cn.hutool.core.collection.CollUtil; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -32,19 +33,16 @@ import com.xiaopeng.operation.vo.NearestNextVo; import com.xiaopeng.operation.vo.NearestVo; import com.xiaopeng.operation.vo.OrderDistanceVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; import javax.annotation.Resource; import java.io.UnsupportedEncodingException; import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDateTime; import java.time.LocalTime; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.*; import java.util.stream.Collectors; /** @@ -73,8 +71,10 @@ @Resource private IXpElectronicFenceService xpElectronicFenceService; @Autowired @Resource private AliOssService aliOssService; @Override public NearestVo nearest(NearestDto dto) { @@ -218,6 +218,28 @@ @Override public List<XpPoint> pointMap(PointMapQuery query) { List<XpPoint> list = this.baseMapper.pointMap(query); for (XpPoint xpPoint : list) { String pointPictures = xpPoint.getPointPictures(); if (org.apache.commons.lang3.StringUtils.isNotBlank(pointPictures)) { JSONArray jsonArray = JSONArray.parseArray(pointPictures); for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); if (Objects.isNull(jsonObject)) { continue; } String downloadUrl = jsonObject.getString("url");; try { downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); } catch (UnsupportedEncodingException e) { log.error("获取图片下载地址失败", e); } jsonObject.put("url", downloadUrl); } xpPoint.setPointPictures(JSONArray.toJSONString(jsonArray)); } } return list; } @@ -232,22 +254,31 @@ query.setOperationStatusIds(statusIds); } List<XpPoint> list = this.baseMapper.listAll(query); for (XpPoint xpPoint : list) { if (StringUtils.hasLength(xpPoint.getPointPictures())) { JSONObject jsonObject = JSONObject.parseObject(xpPoint.getPointPictures()); if(jsonObject!=null){ String downloadUrl = null; String pointPictures = xpPoint.getPointPictures(); if (org.apache.commons.lang3.StringUtils.isNotBlank(pointPictures)) { JSONArray jsonArray = JSONArray.parseArray(pointPictures); for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); if (Objects.isNull(jsonObject)) { continue; } String downloadUrl = jsonObject.getString("url");; try { // 1 downloadUrl= aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); } catch (Exception e) { e.printStackTrace(); downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); } catch (UnsupportedEncodingException e) { log.error("获取图片下载地址失败", e); } jsonObject.put("url", downloadUrl); xpPoint.setPointPictures(jsonObject.toJSONString()); } xpPoint.setPointPictures(JSONArray.toJSONString(jsonArray)); } } return list; } xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpOrderServiceImpl.java
@@ -675,6 +675,7 @@ // 1. 更新订单状态为已取消(0) lambdaUpdate().set(XpOrder::getStatus, 0) .eq(XpOrder::getId, order.getId()).update(); redisService.setCacheObject("ORDER_STATUS:" + order.getId(), 0, 24L, TimeUnit.HOURS); // 2. 保存取消记录 XpOrderCancel orderCancel = new XpOrderCancel(); @@ -783,6 +784,7 @@ Long appUserId = order.getAppUserId(); order.setAppUserId(null); this.updateById(order); redisService.setCacheObject("ORDER_STATUS:" + order.getId(), 7, 24L, TimeUnit.HOURS); // 消息推送 Map<String, Object> params1 = new HashMap<>(); @@ -2906,6 +2908,7 @@ addTaxiPassengerVo.setUid(appUserId.toString()); order.setAppUserId(null); this.updateById(order); redisService.setCacheObject("ORDER_STATUS:" + order.getId(), 2, 24L, TimeUnit.HOURS); //构建推送消息 Map<String, Object> params = new HashMap<>(); xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpTestOrderServiceImpl.java
@@ -278,6 +278,7 @@ xpOrder.setVehicleId(datum.getVehicleId()); xpOrder.setFleetId(xpVehicle.getFleetId()); this.save(xpOrder); redisService.setCacheObject("ORDER_STATUS:" + xpOrder.getId(), 1, 24L, TimeUnit.HOURS); //缓存导航数据,用于下单后推送导航给车端和乘客端 redisService.setCacheObject("TEST_ORDER_NAVIGATION_END_DATA:" + datum.getVehicleId(), JSON.toJSONString(routeVo), 24L, TimeUnit.HOURS); //下发XPU消息 @@ -691,7 +692,7 @@ order.setDuration(new BigDecimal(duration).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue()); order.setVehicleId(null); this.updateById(order); redisService.setCacheObject("ORDER_STATUS:" + order.getId(), 7, 24L, TimeUnit.HOURS); //给XPU推送订单取消的报文 PushOrderDto pushOrderDto = new PushOrderDto(); xp-robotaxi-vehicle-convoy-boot/src/main/java/com/xiaopeng/vehicleConvoy/service/impl/XpPolicyApplicationServiceImpl.java
@@ -2,6 +2,7 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -37,6 +38,7 @@ import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.io.UnsupportedEncodingException; import java.time.LocalDateTime; import java.time.LocalTime; import java.util.*; @@ -260,18 +262,23 @@ xpPolicyApplicationVO.setVehicleCode(xpVehicle.getVehicleCode()); xpPolicyApplicationVO.setAuditRemarks(xpPolicyApplication.getAuditRemarks()); if (xpPolicyApplicationVO.getAuditStatus() == 2 && StringUtils.isNotBlank(xpVehicle.getPolicyInformation())) { JSONObject jsonObject = JSONObject.parseObject(xpVehicle.getPolicyInformation()); if(jsonObject!=null){ String downloadUrl = null; try { JSONArray jsonArray = JSONArray.parseArray(xpVehicle.getPolicyInformation()); for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); if (Objects.isNull(jsonObject)) { continue; } // 1 downloadUrl= aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); } catch (Exception e) { e.printStackTrace(); String downloadUrl = jsonObject.getString("url");; try { downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); } catch (UnsupportedEncodingException e) { log.error("获取图片下载地址失败", e); } jsonObject.put("url", downloadUrl); } jsonObject.put("url", downloadUrl); xpPolicyApplicationVO.setPolicyInformation(jsonObject.toJSONString()); } xpPolicyApplicationVO.setPolicyInformation(JSONArray.toJSONString(jsonArray)); } } queryPolicyInfoVO.setStatus(xpPolicyApplication.getAuditStatus());