package com.aidex.web.controller.gps;

import com.aidex.common.core.controller.BaseController;
import com.aidex.common.core.domain.R;
import com.aidex.common.gps.domain.LocationEntity;
import com.aidex.common.gps.domain.MileageEntity;
import com.aidex.common.gps.server.IGpsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Gps相关查询接口
 */
@RestController
@RequestMapping("/monit/gps")
public class GpsController extends BaseController {

    @Autowired
    private IGpsService gpsService;

    /**
     * 查询报警信息列表
     */
    @PreAuthorize("@ss.hasPermi('monit:gps:location')")
    @GetMapping("/location/web")
    public R<String> localtionWeb(String shipId) {
        return R.data(gpsService.getLocationUrl(shipId));
    }

    @PreAuthorize("@ss.hasPermi('monit:gps:location')")
    @GetMapping("/location/play")
    public R<String> localtionPlay(String shipId) {
        return R.data(gpsService.getPlayUrl(shipId));
    }

    @PreAuthorize("@ss.hasPermi('monit:gps:location')")
    @GetMapping("/location")
    public R<LocationEntity> localtion(String shipId) {
        return R.data(gpsService.getLocation(shipId));
    }

    @PreAuthorize("@ss.hasPermi('monit:gps:location')")
    @GetMapping("/location/batch")
    public R<List<LocationEntity>> localtionBatch() {
        return R.data(gpsService.getLocationBatch());
    }


    @PreAuthorize("@ss.hasPermi('monit:gps:location')")
    @GetMapping("/mileage")
    public R<List<MileageEntity>> mileageStatisics(@RequestParam(defaultValue = "",name = "startTime") String startTime, @RequestParam(defaultValue = "",name = "endTime") String endTime) {
        return R.data(gpsService.getMileageStatisics(startTime,endTime));
    }
}
