| | |
| | | import com.stylefeng.guns.modular.crossCity.model.Line; |
| | | import com.stylefeng.guns.modular.crossCity.server.ILineService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | @Service |
| | |
| | | public List<Map<String, Object>> queryLines(Integer startId, Integer endId, Integer driverId) throws Exception { |
| | | List<Map<String, Object>> list1 = lineMapper.queryLines(startId, 1); |
| | | List<Map<String, Object>> list2 = lineMapper.queryLines(endId, 2); |
| | | // 结束站点为经停站的 |
| | | List<Map<String, Object>> list4 = lineMapper.queryLines(endId, 3); |
| | | if(!CollectionUtils.isEmpty(list4)){ |
| | | List<Integer> stopoverIds = new ArrayList<>(); |
| | | for (Map<String, Object> stopoverStation : list4) { |
| | | Integer stopoverId = Integer.valueOf(stopoverStation.get("id").toString()); |
| | | stopoverIds.add(stopoverId); |
| | | } |
| | | stopoverIds = stopoverIds.stream().distinct().collect(Collectors.toList()); |
| | | // 查询经停站的终点 |
| | | List<Map<String, Object>> endList = lineMapper.queryLinesByStopoverIds(stopoverIds,2); |
| | | list2.addAll(endList); |
| | | } |
| | | list2 = list2.stream().distinct().collect(Collectors.toList()); |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | for(Map<String, Object> map1 : list1){ |
| | | Integer id1 = Integer.valueOf(map1.get("id").toString()); |