package com.ningdatech.carapi.industry.controller;


import com.ningdatech.basic.model.PageVo;
import com.ningdatech.carapi.car.trips.model.dto.VehicleTripsParamDTO;
import com.ningdatech.carapi.common.util.ExcelDownUtil;
import com.ningdatech.carapi.industry.manage.DataQualityMonitorManage;
import com.ningdatech.carapi.industry.model.dto.DataQualityMonitorDynamicsPageParamDTO;
import com.ningdatech.carapi.industry.model.dto.DataQualityMonitorGpsPageParamDTO;
import com.ningdatech.carapi.industry.model.dto.DataQualityMonitorStaticPageParamDTO;
import com.ningdatech.carapi.industry.model.vo.DataQualityMonitorDynamicsVO;
import com.ningdatech.carapi.industry.model.vo.DataQualityMonitorGpsVO;
import com.ningdatech.carapi.industry.model.vo.DataQualityMonitorStaticVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * <p>
 * 数据质量监控 前端控制器
 * </p>
 *
 * @author PoffyZhang
 * @since 2022-11-07
 */
@RequestMapping("/api/industry/data-quality-monitor")
@Slf4j
@Validated
@RestController
@Api(value = "DataQualityMonitor", tags = "行业服务-数据质量监控")
@RequiredArgsConstructor
public class DataQualityMonitorController {

    private final DataQualityMonitorManage dataQualityMonitorManage;

    @ApiOperation(value = "静态数据采集监控", notes = "静态数据采集监控")
    @GetMapping("/list-static")
    public PageVo<DataQualityMonitorStaticVO> staticList(@Valid @ModelAttribute DataQualityMonitorStaticPageParamDTO param) {
        return dataQualityMonitorManage.staticList(param);
    }

    @ApiOperation(value = "静态数据采集监控详情", notes = "静态数据采集监控详情")
    @GetMapping("/details-static/{id}")
    public DataQualityMonitorStaticVO staticDeatils(@Valid @PathVariable Long id) {
        return dataQualityMonitorManage.staticDetails(id);
    }

    @ApiOperation(value = "静态数据采集监控导出", notes = "静态数据采集监控导出")
    @GetMapping("/export-static")
    public void exportStatic(DataQualityMonitorStaticPageParamDTO param, HttpServletResponse response) {
        ExcelDownUtil.downXls(response, param, dataQualityMonitorManage::exportStatic);
    }

    @ApiOperation(value = "动态数据采集监控", notes = "动态数据采集监控")
    @GetMapping("/list-dynamics")
    public PageVo<DataQualityMonitorDynamicsVO> dynamicsList(@Valid @ModelAttribute DataQualityMonitorDynamicsPageParamDTO param) {
        return dataQualityMonitorManage.dynamicsList(param);
    }

    @ApiOperation(value = "动态数据采集监控详情", notes = "动态数据采集监控详情")
    @GetMapping("/details-dynamics/{id}")
    public DataQualityMonitorDynamicsVO dynamicsDetails(@Valid @PathVariable Long id) {
        return dataQualityMonitorManage.dynamicsDetails(id);
    }

    @ApiOperation(value = "动态数据采集监控导出", notes = "动态数据采集监控导出")
    @GetMapping("/export-dynamics")
    public void exportDynamics(DataQualityMonitorDynamicsPageParamDTO param, HttpServletResponse response) {
        ExcelDownUtil.downXls(response, param, dataQualityMonitorManage::exportDynamics);
    }

    @ApiOperation(value = "异常GPS数据查询报警", notes = "异常GPS数据查询报警")
    @GetMapping("/list-gps")
    public PageVo<DataQualityMonitorGpsVO> gpsList(@Valid @ModelAttribute DataQualityMonitorGpsPageParamDTO param) {
        return dataQualityMonitorManage.gpsList(param);
    }

    @ApiOperation(value = "异常GPS数据查询报警详情", notes = "异常GPS数据查询报警详情")
    @GetMapping("/details-gps/{id}")
    public DataQualityMonitorGpsVO gpsDetails(@Valid @PathVariable Long id) {
        return dataQualityMonitorManage.gpsDetails(id);
    }

    @ApiOperation(value = "异常GPS数据查询报警导出", notes = "异常GPS数据查询报警导出")
    @GetMapping("/export-gps")
    public void exportGps(DataQualityMonitorGpsPageParamDTO param, HttpServletResponse response) {
        ExcelDownUtil.downXls(response, param, dataQualityMonitorManage::exportGps);
    }
}
