package com.stylefeng.guns.modular.crossCity.server.impl; import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.stylefeng.guns.modular.crossCity.dao.LineMapper; import com.stylefeng.guns.modular.crossCity.model.Line; import com.stylefeng.guns.modular.crossCity.server.ILineService; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; import java.util.Map; @Service public class LineServiceImpl extends ServiceImpl implements ILineService { @Resource private LineMapper lineMapper; /** * 根据站点id获取线路 * @param startId * @param endId * @return * @throws Exception */ @Override public List> queryLines(Integer startId, Integer endId, Integer driverId) throws Exception { List> list1 = lineMapper.queryLines(startId, 1); List> list2 = lineMapper.queryLines(endId, 2); List> list = new ArrayList<>(); for(Map map1 : list1){ Integer id1 = Integer.valueOf(map1.get("id").toString()); for(Map map2 : list2){ Integer id2 = Integer.valueOf(map2.get("id").toString()); if(id1.compareTo(id2) == 0){ map1.put("startAddress", map1.get("siteName")); map1.put("endAddress", map2.get("siteName")); list.add(map1); } } } if(null != driverId){ List> lists = new ArrayList<>(); List> list3 = lineMapper.scanCodeQueryLines(driverId); for(Map map1 : list){ Integer id2 = Integer.valueOf(map1.get("id").toString()); for(Map map : list3){ Integer id1 = Integer.valueOf(map.get("id").toString()); if(id1.compareTo(id2) == 0){ lists.add(map1); } } } list = lists; } return list; } /** * 扫码获取司机的所有线路 * @param driverId * @return * @throws Exception */ @Override public List> scanCodeQueryLines(Integer driverId) throws Exception { return lineMapper.scanCodeQueryLines(driverId); } }