package com.clx.performance.controller.temp;

import com.clx.performance.param.temp.DriverTraceAddParam;
import com.clx.performance.param.temp.TruckTraceAddParam;
import com.clx.performance.service.trace.TruckTraceService;
import com.clx.performance.vo.pc.trace.DriverTraceVO;
import com.clx.performance.vo.pc.trace.DriverTruckTraceVO;
import com.msl.common.result.Result;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;


/**
 * @Author: aiqingguo
 * @Description: 临时接口
 * @Date: 2023-8-21 12:10:16
 * @Version: 1.0
 */
@Slf4j
@RestController
@RequestMapping(value="/temp/trace")
public class TempTraceController {

    @Autowired
    private TruckTraceService truckTraceService;

    @ApiOperation(value = "车辆轨迹同步", notes = "<br>By:艾庆国")
    @PostMapping("/truckTraceSync")
    public Result truckTraceSync(@RequestBody TruckTraceAddParam param) {

        truckTraceService.truckTraceSave(param);

        return Result.ok();
    }

    @ApiOperation(value = "查询车辆轨迹", notes = "<br>By:艾庆国")
    @PostMapping("/listTruckTraceByTime")
    public Result<List<DriverTruckTraceVO>> listTruckTraceByTime(String truckNo, String beginTime, String endTime) {

        return Result.ok(truckTraceService.listTruckTraceByTime(truckNo,beginTime,endTime));
    }

    @ApiOperation(value = "司机轨迹同步", notes = "<br>By:艾庆国")
    @PostMapping("/driverTraceSync")
    public Result driverTraceSync(@RequestBody DriverTraceAddParam param) {

        truckTraceService.driverTraceSave(param);

        return Result.ok();
    }

    @ApiOperation(value = "查询司机轨迹", notes = "<br>By:艾庆国")
    @PostMapping("/listDriverTraceByTime")
    public Result<List<DriverTraceVO>> listDriverTraceByTime(Long userNo, String beginTime, String endTime) {

        return Result.ok(truckTraceService.listDriverTraceByTime(userNo,beginTime,endTime));
    }


    @ApiOperation(value = "查询车辆5分钟内的最新位置", notes = "<br>By:刘海泉")
    @PostMapping("/getTruckPosition")
    public Result<BigDecimal[]> getTruckPosition(String truckNo) {
        return Result.ok(truckTraceService.getCurrentTruckPosition(truckNo));
    }

}
