GpsDataController.java 2.28 KB
package com.bsth.vehicle.gpsdata.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bsth.vehicle.common.CommonMapped;
import com.bsth.vehicle.gpsdata.buffer.ArrivalDataBuffer;
import com.bsth.vehicle.gpsdata.buffer.GpsRealDataBuffer;
import com.bsth.vehicle.gpsdata.entity.ArrivalInfo;
import com.bsth.vehicle.gpsdata.entity.GpsRealData;
import com.bsth.vehicle.gpsdata.service.GpsDataService;
import com.google.common.base.Splitter;

@RestController
@RequestMapping("gps")
public class GpsDataController {
	
	@Autowired
	GpsRealDataBuffer gpsBuffer;
	
	@Autowired
	GpsDataService gpsDataService;
	
	@RequestMapping(value = "/real/line/{lineCode}")
	public List<GpsRealData> findByLineCode(@PathVariable("lineCode") Integer lineCode){
		return gpsBuffer.getListByLineCode(lineCode);
	}
	
	@RequestMapping(value = "/real/line")
	public List<GpsRealData> findByLineCode(@RequestParam String lineCodes){
		return gpsBuffer.getListByLines(Splitter.on(",").split(lineCodes).iterator());
	}
	
	/**
	 * 
	 * @Title: history 
	 * @Description: TODO(这个方法给测试页面用) 
	 * @throws
	 */
	@RequestMapping(value = "/history/{device}")
	public List<Map<String, Object>> history(@PathVariable("device") String device
			,@RequestParam Long startTime
			,@RequestParam Long endTime,
			@RequestParam int directions){
		
		return gpsDataService.history(device, startTime, endTime, directions);
	}
	
	@RequestMapping(value = "/gpsHistory/multiple")
	public List<Map<String, Object>> gpsHistory(@RequestParam String[] nbbmArray
			,@RequestParam Long st
			,@RequestParam Long et){
		return gpsDataService.history(nbbmArray, st, et);
	}
	
	@RequestMapping(value = "/arrival/ram")
	public List<ArrivalInfo> ramData(@RequestParam String nbbm){
		return ArrivalDataBuffer.allMap.get(nbbm);
	}
	
	@RequestMapping(value = "/Car2DeviceId")
	public Map<String, String> findCarDeviceIdMap(){
		return CommonMapped.vehicDeviceBiMap.inverse();
	}
}