StationRouteServiceImpl.java 2.94 KB
package com.bsth.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bsth.entity.StationRoute;
import com.bsth.repository.StationRouteRepository;
import com.bsth.service.StationRouteService;

/**
 * 
 * @ClassName: StationRouteServiceImpl(站点路由service业务层实现类)
 * 
 * @Extends : BaseService
 * 
 * @Description: TODO(站点路由service业务层)
 * 
 * @Author bsth@lq
 * 
 * @Date 2016年5月03日 上午9:21:17
 *
 * @Version 公交调度系统BS版 0.1
 * 
 */

@Service
public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integer> implements StationRouteService{
	
	@Autowired
	private StationRouteRepository repository;
	
	@Override
	public List<Map<String, Object>> findPoints(Map<String, Object> map) {
		
		String lineStr = map.get("line.id_eq").equals("") ? "0" : map.get("line.id_eq").toString();
		
		String directionsStr = map.get("directions_eq").equals("") ? "0" : map.get("directions_eq").toString();
		
		int line = Integer.parseInt(lineStr);
		
		int directions= Integer.parseInt(directionsStr);
		 
		List<Object[]> list =  repository.findPoints(line, directions);
		
		List<Map<String,Object>> resultList = new ArrayList<Map<String,Object>>();
		
		List<Map<String, Object>> children = new ArrayList<Map<String,Object>>();
		
		Map<String, Object> listMap = new HashMap<String,Object>();
		
		listMap.put("container", "pjax-container");
		
		listMap.put("enable", true);
		
		listMap.put("groupType", "1");
		
		listMap.put("icon", "");
		
		listMap.put("id", 100);
		
		listMap.put("pId", null);
		
		listMap.put("name", "途径站点");
		
		listMap.put("text", "途径站点");
		
		
		
		if(list.size()>0) {
			
			for(int i = 0 ; i < list.size(); i++) {
				
				Map<String, Object> tempM = new HashMap<String, Object>();
				
				tempM.put("id", list.get(i)[0]);
				
				//tempM.put("id", 2);
				
				tempM.put("line", list.get(i)[1]);
				
				tempM.put("station", list.get(i)[2]);
				
				tempM.put("station_name", list.get(i)[3]);
				
				tempM.put("name", list.get(i)[3]);
				
				tempM.put("text", list.get(i)[3]);
				
				tempM.put("station_route_code", list.get(i)[4]);
				
				tempM.put("station_mark", list.get(i)[7]);
				
				tempM.put("b_jwpoints", list.get(i)[8]);
				
				tempM.put("g_polygon_grid", list.get(i)[11]);
				
				tempM.put("radius", list.get(i)[12]);
				
				tempM.put("shapes_type", list.get(i)[13]);
				
				tempM.put("icon", "fa fa-bus");
				
				tempM.put("pId", 100);
				
				tempM.put("groupType", "2");
				
				tempM.put("enable", true);
				
				children.add(tempM);
			}
			
		}
		
		listMap.put("children", children);
		
		resultList.add(listMap);
		
		return resultList;
	}

}