| | |
| | | package com.sinata.system.service.impl; |
| | | |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.sinata.common.utils.StringUtils; |
| | | import com.sinata.system.domain.MwTransitCarCollectPoint; |
| | | import com.sinata.system.domain.SysDepartment; |
| | | import com.sinata.system.domain.vo.CarDistributionVO; |
| | | import com.sinata.system.domain.vo.CarTrackVO; |
| | | import com.sinata.system.mapper.MwTransitCarCollectPointMapper; |
| | | import com.sinata.system.service.MwTransitCarCollectPointService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.sinata.system.service.SysDepartmentService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2025-01-01 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class MwTransitCarCollectPointServiceImpl extends ServiceImpl<MwTransitCarCollectPointMapper, MwTransitCarCollectPoint> implements MwTransitCarCollectPointService { |
| | | |
| | | private final SysDepartmentService sysDepartmentService; |
| | | |
| | | /** |
| | | * 查询车辆分布列表 |
| | | * |
| | | * @param treeCode |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<CarDistributionVO> queryCarListByTreeCode(String treeCode) { |
| | | return baseMapper.queryCarListByTreeCode(treeCode); |
| | | } |
| | | |
| | | /** |
| | | * 车辆分布详情 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public CarDistributionVO queryCarDistributionDetail(Long id) { |
| | | CarDistributionVO carDistributionVO = baseMapper.queryCarDistributionDetail(id); |
| | | String pointList = carDistributionVO.getPointList(); |
| | | if (StringUtils.isNotBlank(pointList)) { |
| | | List<Long> departmentIdList = JSONArray.parseArray(pointList, Long.class); |
| | | // 查询部门数据 |
| | | List<SysDepartment> list = sysDepartmentService.lambdaQuery() |
| | | .in(SysDepartment::getId, departmentIdList) |
| | | .list(); |
| | | // 重新排序 |
| | | Map<Long, SysDepartment> departmentMap = list.stream() |
| | | .collect(Collectors.toMap(SysDepartment::getId, dept -> dept)); |
| | | List<SysDepartment> sortedList = departmentIdList.stream() |
| | | .map(departmentMap::get) |
| | | .collect(Collectors.toList()); |
| | | Set<CarTrackVO> carTrackVOSet = sortedList.stream().map(item -> { |
| | | CarTrackVO vo = new CarTrackVO(); |
| | | vo.setLatitude(item.getLatitude()); |
| | | vo.setLongitude(item.getLongitude()); |
| | | return vo; |
| | | }).collect(Collectors.toSet()); |
| | | carDistributionVO.setLineSet(carTrackVOSet); |
| | | } |
| | | return carDistributionVO; |
| | | } |
| | | } |