GpsController.java 3.55 KB
package com.bsth.controller.gps;

import com.bsth.data.BasicData;
import com.bsth.data.gpsdata.GpsEntity;
import com.bsth.data.gpsdata.GpsRealData;
import com.bsth.service.gps.GpsService;
import com.google.common.base.Splitter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

@RestController
@RequestMapping("gps")
public class GpsController {

    @Autowired
    GpsRealData gpsRealData;

    @Autowired
    GpsService gpsService;

    @RequestMapping(value = "/real/all")
    public Map<String, Object> search(@RequestParam Map<String, Object> map,
                                      @RequestParam(defaultValue = "0") int page,
                                      @RequestParam(defaultValue = "15") int size,
                                      @RequestParam(defaultValue = "timestamp") String order,
                                      @RequestParam(defaultValue = "DESC") String direction) {


        return gpsService.search(map, page, size, order, direction);
    }

    @RequestMapping(value = "/real/line/{lineCode}")
    public List<GpsEntity> findByLineCode(@PathVariable("lineCode") String lineCode) {
        return gpsRealData.getByLine(lineCode);
    }

    @RequestMapping(value = "/real/line")
    public List<GpsEntity> findByLineCodes(@RequestParam String lineCodes) {
        return gpsRealData.get(Splitter.on(",").splitToList(lineCodes));
    }

    @RequestMapping(value = "/allDevices")
    public Iterable<String> allDevices() {
        return gpsRealData.allDevices();
    }

    @RequestMapping(value = "/removeRealGps", method = RequestMethod.POST)
    public Map<String, Object> removeRealGps(@RequestParam String device) {
        return gpsService.removeRealGps(device);
    }

    /**
     * @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 gpsService.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 gpsService.history(nbbmArray, st, et);
    }

	/*@RequestMapping(value = "/analyse/ram")
    public List<ArrivalInfo> ramData(@RequestParam String nbbm) {
		return ArrivalDataBuffer.allMap.get(nbbm);
	}*/

    @RequestMapping(value = "/Car2DeviceId")
    public Map<String, String> findCarDeviceIdMap() {
        return BasicData.deviceId2NbbmMap.inverse();
    }

    @RequestMapping(value = "/buffAera")
    public Map<String, Object> findBuffAeraByCode(@RequestParam String code, @RequestParam String type) {
        return gpsService.findBuffAeraByCode(code, type);
    }

    @RequestMapping(value = "/findRoadSpeed")
    public Map<String, Object> findRoadSpeed(@RequestParam String lineCode) {
        return gpsService.findRoadSpeed(lineCode);
    }

    /**
     * gps补全
     * @return
     */
    @RequestMapping(value = "/gpsCompletion", method = RequestMethod.POST)
    public Map<String, Object> gpsCompletion(@RequestParam long schId) {
        return gpsService.gpsCompletion(schId);
    }
}