xuhy
2026-04-23 15f44249df76bea5508c5b26d176f1f3fbea878b
[fix] 天气动态调价修改,处理xp_operations_user不能连表的问题
4个文件已修改
71 ■■■■■ 已修改文件
xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/utils/XpPricingUtil.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/mapper/XpCruiseCheckInRecordMapper.java 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpCruiseCheckInRecordServiceImpl.java 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-maintenance-boot/src/main/resources/mapper/maintenance/XpCruiseCheckInRecordMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/utils/XpPricingUtil.java
@@ -113,17 +113,17 @@
                                // 当前费率+(费率*上升百分比)
                                priceRate =  new BigDecimal(priceRate).multiply(divide).add(new BigDecimal(priceRate)).setScale(2, RoundingMode.HALF_UP).doubleValue();
                            }
                            JSONObject jsonObject1 = jsonObject.getJSONObject("weather");
                            if(null != jsonObject1){
                            JSONArray ws = jsonObject.getJSONArray("weather");
                            if(null != ws){
                                XpOpenCity openCity = openCityClient.getXpOpenCityById(openCityId).getData();
                                WeatherDTO data = xpMapClient.wether(openCity.getCityCode()).getData();
                                List<WeatherDTO.Lives> lives = data.getLives();
                                if(lives!=null && !lives.isEmpty()){
                                    String w = lives.get(0).getWeather();
                                    Set<String> weather = jsonObject1.keySet();
                                    for (String k : weather) {
                                        if(w.contains(k)){
                                            double floatRate = jsonObject.getDouble(k);
                                    for (Object o : ws) {
                                        JSONObject ele = JSONObject.parseObject(o.toString());
                                        if(w.contains(ele.getString("weatherType"))){
                                            double floatRate = jsonObject.getDouble("ratio");
                                            priceRate = new BigDecimal(priceRate).add(new BigDecimal(floatRate)).doubleValue();
                                            break;
                                        }
xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/mapper/XpCruiseCheckInRecordMapper.java
@@ -14,7 +14,7 @@
    List<XpCruiseCheckInRecordVO> selectCruiseCheckInRecordList(@Param("pageInfo") PageInfo<XpCruiseCheckInRecordVO> pageInfo, @Param("query") XpCruiseCheckInRecordQuery query);
    XpCruiseCheckInRecordVO detail(Long id);
    XpCruiseCheckInRecordVO detail(@Param("id")Long id);
    XpCruiseCheckInRecordVO selectCruiseCheckInStatistics(XpCruiseCheckInStatisticsQuery query);
    XpCruiseCheckInRecordVO selectCruiseCheckInStatistics(@Param("userIds") XpCruiseCheckInStatisticsQuery query);
}
xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpCruiseCheckInRecordServiceImpl.java
@@ -1,6 +1,8 @@
package com.xiaopeng.maintenance.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiaopeng.api.feignClient.account.XpOperationsUserClient;
import com.xiaopeng.api.model.account.XpOperationsUser;
import com.xiaopeng.api.model.maintenance.XpCruiseCheckInRecord;
import com.xiaopeng.common.core.web.page.PageInfo;
import com.xiaopeng.maintenance.mapper.XpCruiseCheckInRecordMapper;
@@ -11,7 +13,11 @@
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
@Service
public class XpCruiseCheckInRecordServiceImpl extends ServiceImpl<XpCruiseCheckInRecordMapper, XpCruiseCheckInRecord> implements IXpCruiseCheckInRecordService {
@@ -19,21 +25,63 @@
    @Resource
    private XpCruiseCheckInRecordMapper xpCruiseCheckInRecordMapper;
    @Resource
    private XpOperationsUserClient xpOperationsUserClient;
    @Override
    public PageInfo<XpCruiseCheckInRecordVO> pageList(XpCruiseCheckInRecordQuery query) {
        PageInfo<XpCruiseCheckInRecordVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<XpCruiseCheckInRecordVO> list = xpCruiseCheckInRecordMapper.selectCruiseCheckInRecordList(pageInfo, query);
        pageInfo.setRecords(list);
        List<Long> ids = list.stream().map(XpCruiseCheckInRecordVO::getOperationsUserId).collect(Collectors.toList());
        List<XpOperationsUser> xpOperationsUsers = xpOperationsUserClient.listByIds(ids).getData();
        Map<Long, XpOperationsUser> userMap = xpOperationsUsers.stream().collect(Collectors.toMap(XpOperationsUser::getId, Function.identity()));
        list.forEach(record -> {
            XpOperationsUser user = userMap.get(record.getOperationsUserId());
            if (user != null) {
                record.setOperationsUserId(user.getId());
                record.setOperationsUserName(user.getNickName());
                record.setPhoneNumber(user.getPhoneNumber());
            }
        });
        return pageInfo;
    }
    @Override
    public XpCruiseCheckInRecordVO detail(Long id) {
        XpCruiseCheckInRecordVO vo = xpCruiseCheckInRecordMapper.detail(id);
        List<Long> ids = Collections.singletonList(vo.getOperationsUserId());
        List<XpOperationsUser> xpOperationsUsers = xpOperationsUserClient.listByIds(ids).getData();
        Map<Long, XpOperationsUser> userMap = xpOperationsUsers.stream().collect(Collectors.toMap(XpOperationsUser::getId, Function.identity()));
        XpOperationsUser user = userMap.get(vo.getOperationsUserId());
        if (user != null) {
            vo.setOperationsUserId(user.getId());
            vo.setOperationsUserName(user.getNickName());
            vo.setPhoneNumber(user.getPhoneNumber());
        }
        return xpCruiseCheckInRecordMapper.detail(id);
    }
    @Override
    public XpCruiseCheckInRecordVO statistics(XpCruiseCheckInStatisticsQuery query) {
        return xpCruiseCheckInRecordMapper.selectCruiseCheckInStatistics(query);
        XpCruiseCheckInRecordVO vo = xpCruiseCheckInRecordMapper.selectCruiseCheckInStatistics(query);
        List<Long> ids = Collections.singletonList(vo.getOperationsUserId());
        List<XpOperationsUser> xpOperationsUsers = xpOperationsUserClient.listByIds(ids).getData();
        Map<Long, XpOperationsUser> userMap = xpOperationsUsers.stream().collect(Collectors.toMap(XpOperationsUser::getId, Function.identity()));
        XpOperationsUser user = userMap.get(vo.getOperationsUserId());
        if (user != null) {
            vo.setOperationsUserId(user.getId());
            vo.setOperationsUserName(user.getNickName());
            vo.setPhoneNumber(user.getPhoneNumber());
        }
        return vo;
    }
}
xp-robotaxi-maintenance-boot/src/main/resources/mapper/maintenance/XpCruiseCheckInRecordMapper.xml
@@ -42,7 +42,6 @@
            r.scene_photo,
            r.scene_description
        FROM xp_cruise_check_in_record r
        LEFT JOIN xp_operations_user u ON r.operations_user_id = u.id AND u.is_deleted = '0'
        LEFT JOIN xp_check_location cl ON r.check_location_id = cl.id AND cl.is_deleted = '0'
        LEFT JOIN xp_cruise_check_in_rule cr ON r.cruise_check_in_rule_id = cr.id AND cr.is_deleted = '0'
        WHERE r.is_deleted = '0'
@@ -80,8 +79,6 @@
        SELECT
            r.id,
            r.operations_user_id,
            u.nick_name AS operations_user_name,
            u.phone_number,
            r.check_location_id,
            cl.location_address,
            r.cruise_check_in_rule_id,
@@ -92,7 +89,6 @@
            r.scene_photo,
            r.scene_description
        FROM xp_cruise_check_in_record r
        LEFT JOIN xp_operations_user u ON r.operations_user_id = u.id AND u.is_deleted = '0'
        LEFT JOIN xp_check_location cl ON r.check_location_id = cl.id AND cl.is_deleted = '0'
        LEFT JOIN xp_cruise_check_in_rule cr ON r.cruise_check_in_rule_id = cr.id AND cr.is_deleted = '0'
        WHERE r.id = #{id}
@@ -108,7 +104,6 @@
        COUNT(CASE WHEN r.field_situation = 2 THEN 1 END) AS traffic
        FROM xp_cruise_check_in_record r
        LEFT JOIN xp_cruise_check_in_rule cr ON r.cruise_check_in_rule_id = cr.id AND cr.is_deleted = '0'
        LEFT JOIN xp_operations_user u ON r.operations_user_id = u.id AND u.is_deleted = '0'
        LEFT JOIN xp_fleet_operations fo ON u.id = fo.operationsUserId
        LEFT JOIN xp_fleet f ON fo.fleetId = f.id
        WHERE r.is_deleted = '0'