package com.ruoyi.web.controller.tool;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.utils.R;
import com.ruoyi.system.domain.BerthingPoint;
import com.ruoyi.system.domain.TaskResult;
import com.ruoyi.system.domain.WaterLevel;
import com.ruoyi.system.dto.TaskResultSortDTO;
import com.ruoyi.system.dto.WaterLevelDTO;
import com.ruoyi.system.paramet.AchievementQuery;
import com.ruoyi.system.paramet.BerthingPointQuery;
import com.ruoyi.system.paramet.ScattperPlotQuery;
import com.ruoyi.system.paramet.WaterLevelQuery;
import com.ruoyi.system.service.AchievementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.Date;
import java.util.List;


/**
 * @author ifei
 */
@RestController
@RequestMapping("/achievement")
@Api(tags = "成果报告")
@Anonymous
public class AchievementController {

    @Resource
    private AchievementService achievementService;


    @PostMapping(value = "/queryAchievement")
    @ApiOperation("查询成果报告")
    public R<Page<TaskResult>> queryAchievement(@Valid @RequestBody AchievementQuery achievementQuery) {
        return R.ok(achievementService.queryAchievement(achievementQuery));
    }

    @GetMapping(value = "/queryAchievement/{taskid}")
    @ApiOperation("查询成果报告")
    public R<TaskResult> queryAchievementByTaskid(@PathVariable String taskid) {
        return R.ok(achievementService.queryAchievementByTaskid(taskid));
    }

    @GetMapping(value = "/downAchievement")
    @ApiOperation(value = "导出成果报告")
    public void downAchievement(Long resultId, HttpServletResponse response) {
        achievementService.downAchievement(resultId, response);
    }

    //水位趋势
    @PostMapping(value = "/getWaterLevelList")
    @ApiOperation("获取水位趋势")
    public R<Page<WaterLevelDTO>> getWaterLevelList(@Valid @RequestBody WaterLevelQuery waterLevelQuery) {
        return R.ok(achievementService.getWaterLevelList(waterLevelQuery));
    }
    //导出水位趋势
    @GetMapping(value = "/downWaterLevel")
    @ApiOperation(value = "导出水位趋势")
    public void downWaterLevel(Long siteId, Long type, String startTime, String endTime, HttpServletResponse response) {
        achievementService.downWaterLevel(siteId,type,startTime,endTime, response);
    }

    //散点图
    @PostMapping(value = "/getScatterPlot")
    @ApiOperation("测流结果散点图")
    public R<List<TaskResultSortDTO>> getScatterPlot(@Valid @RequestBody ScattperPlotQuery scattperPlotQuery) {
        return R.ok(achievementService.getScatterPlot(scattperPlotQuery));
    }

    //导出散点图
    @GetMapping(value = "/downScatterPlot")
    @ApiOperation(value = "导出测流结果散点图")
    public void downScatterPlot(Long siteId, String startTime, String endTime, HttpServletResponse response) {
        achievementService.downScatterPlot(siteId,startTime,endTime, response);
    }

}
