| | |
| | | import com.xiaopeng.api.model.operation.XpTargetedServiceWhitelist; |
| | | import com.xiaopeng.api.model.vehicleConvoy.XpVehicle; |
| | | import com.xiaopeng.api.query.operation.XpTargetedServiceQuery; |
| | | import com.xiaopeng.api.vo.operation.XpTargetedServiceVehicleVo; |
| | | import com.xiaopeng.api.vo.operation.XpTargetedServiceVo; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.exception.ServiceException; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | |
| | | List<XpTargetedServiceVehicle> list = xpTargetedServiceMapper.listVehicle(targetedServiceId); |
| | | |
| | | if(!list.isEmpty()){ |
| | | List<Long> ids = new ArrayList<>(); |
| | | List<Long> vehicleIds = new ArrayList<>(); |
| | | for (XpTargetedServiceVehicle xpTargetedServiceVehicle : list) { |
| | | ids.add(xpTargetedServiceVehicle.getVehicleId()); |
| | | vehicleIds.add(xpTargetedServiceVehicle.getVehicleId()); |
| | | } |
| | | R<List<XpVehicle>> listR = xpVehicleClient.listByIds(ids); |
| | | R<List<XpVehicle>> listR = xpVehicleClient.listByIds(vehicleIds); |
| | | if(!listR.getData().isEmpty()){ |
| | | List<XpVehicle> vehicleList = listR.getData(); |
| | | Map<Long, XpVehicle> vehicleMap = vehicleList.stream() |
| | |
| | | removeBatchByIds(ids); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 定向服务 根据 用户id 和 城市编码 查询 定向服务的 数据和 车辆信息 |
| | | * @param appUserId |
| | | * @param cityCode |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<String> findSetVehicleVinByUserIdAndCityCode(Long appUserId, String cityCode) { |
| | | List<XpTargetedServiceVehicleVo> list = findListByUserIdAndCityCode(appUserId, cityCode); |
| | | if(list.isEmpty()){ |
| | | return null; |
| | | } |
| | | return list.stream() |
| | | .map(XpTargetedServiceVehicleVo::getVehicleVin) |
| | | .filter(Objects::nonNull) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public List<XpTargetedServiceVehicleVo> findListByUserIdAndCityCode(Long appUserId, String cityCode) { |
| | | |
| | | List<XpTargetedServiceVehicleVo> listInfoVehicle = baseMapper.findListInfoVehicle(appUserId, cityCode, LocalDateTime.now()); |
| | | |
| | | if(!listInfoVehicle.isEmpty()){ |
| | | // 提取车辆ID列表 |
| | | List<Long> vehicleIds = listInfoVehicle.stream() |
| | | .map(XpTargetedServiceVehicleVo::getVehicleId) |
| | | .filter(Objects::nonNull) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | |
| | | R<List<XpVehicle>> listR = xpVehicleClient.listByIds(vehicleIds); |
| | | if(!listR.getData().isEmpty()){ |
| | | List<XpVehicle> vehicleList = listR.getData(); |
| | | Map<Long, XpVehicle> vehicleMap = vehicleList.stream() |
| | | .collect(Collectors.toMap(XpVehicle::getId, vehicle -> vehicle)); |
| | | |
| | | for (XpTargetedServiceVehicleVo beanVo : listInfoVehicle) { |
| | | XpVehicle remoteVehicle = vehicleMap.get(beanVo.getVehicleId()); |
| | | if (remoteVehicle != null) { |
| | | beanVo.setVehicleVin(remoteVehicle.getVehicleVin()); |
| | | } |
| | | } |
| | | } |
| | | return listInfoVehicle; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |