package com.ltgk.boat.controller;

import com.ltgk.boat.domain.dto.*;
import com.ltgk.boat.domain.vo.BoatTrajectoryVo;
import com.ltgk.boat.domain.vo.ExportBoatTrajectoryVO;
import com.ltgk.boat.service.BoatDynamicWakeService;
import com.ltgk.common.core.domain.AjaxResult;
import com.ltgk.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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 javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * @Author: wan kun
 * @Description: 获取船舶尾迹数据
 * @Date: 2025/2/26 11:11
 * @Version: 1.0
 */
@RestController
@RequestMapping("/boatDynamicWake")
@Api(tags = "船舶尾迹数据")
@Slf4j
@Validated
public class BoatDynamicWakeController {
    @Autowired
    private BoatDynamicWakeService boatDynamicWakeService;

    @PostMapping("/getWakeData")
    @ApiOperation(value = "获取船舶尾迹")
    public AjaxResult getWakeData(@RequestBody @Valid GetWakeDataReq getWakeDataReq) {
        return boatDynamicWakeService.getWakeData(getWakeDataReq);
    }

    @PostMapping("/getRadarWakeData")
    @ApiOperation(value = "获取雷达尾迹")
    public AjaxResult getRadarWakeData(@RequestBody @Valid GetRadarWakeDataReq getRadarWakeDataReq) {
        return boatDynamicWakeService.getRadarWakeData(getRadarWakeDataReq);
    }

    /**
     * 渔船统计
     *
     * @return {@link ArrayList<BoatTrajectoryVo>}
     */
    @PostMapping("/getBoatTrajectory")
    @ApiOperation(value = "获取轨迹回放数据")
    public AjaxResult getBoatTrajectory(@RequestBody @Valid GetBoatTrajectoryReq getBoatTrajectoryReq) {
        return boatDynamicWakeService.getBoatTrajectory(getBoatTrajectoryReq);
    }

    /**
     * 渔船轨迹数据导出功能
     *
     * @param response:
     * @param req:
     * @author Qi ChengBin
     * @date 2025/7/25
     */
    @PostMapping("/exportBoatTrajectory")
    @ApiOperation(value = "渔船轨迹数据导出")
    public void exportBoatTrajectory(HttpServletResponse response, GetBoatTrajectoryReq req) {

        List<ExportBoatTrajectoryVO> exportBoatTrajectoryVOList = boatDynamicWakeService.exportBoatTrajectoryVO(req);

        ExcelUtil<ExportBoatTrajectoryVO> util = new ExcelUtil<>(ExportBoatTrajectoryVO.class);
        util.exportExcel(response, exportBoatTrajectoryVOList, "渔船轨迹数据");
    }


    @PostMapping("/getBoatInfoByCondition")
    @ApiOperation(value = "根据相应的条件获取渔船信息")
    public AjaxResult getBoatInfoByCondition(@RequestBody @Valid GetBoatInfoByConditionReq getBoatInfoByConditionReq) {
        return boatDynamicWakeService.getBoatInfoByCondition(getBoatInfoByConditionReq);
    }

    /**
     * 渔船统计
     *
     * @return {@link HashMap<String,ArrayList<BoatTrajectoryVo>>}
     */
    @PostMapping("/getBoatsTrajectory")
    @ApiOperation(value = "获取多条轨迹回放数据")
    public AjaxResult getBoatsTrajectory(@RequestBody @Valid GetBoatsTrajectoryReq getBoatsTrajectoryReq) {
        return boatDynamicWakeService.getBoatsTrajectory(getBoatsTrajectoryReq);
    }
}
