/*
 * Copyright [2022] [https://www.xiaonuo.vip]
 *
 * Snowy采用APACHE LICENSE 2.0开源协议，您在使用过程中，需要注意以下几点：
 *
 * 1.请不要删除和修改根目录下的LICENSE文件。
 * 2.请不要删除和修改Snowy源码头部的版权声明。
 * 3.本项目代码可免费商业使用，商业使用请保留源码和相关描述文件的项目出处，作者声明等。
 * 4.分发源码时候，请注明软件出处 https://www.xiaonuo.vip
 * 5.不可二次分发开源参与同类竞品，如有想法可联系团队xiaonuobase@qq.com商议合作。
 * 6.若您的项目无法满足以上几点，需要更多功能代码，获取Snowy商业授权许可，请在官网购买授权，地址为 https://www.xiaonuo.vip
 */
package com.unis.dataQualityAssessmen.info.modular.dqaDataAnalysis.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.unis.basic.info.modular.reportpricemonitor.entity.ReportPriceMonitor;
import com.unis.basic.info.modular.unReporCity.controller.UnReporCityController;
import com.unis.common.util.CommonTimeFormatUtil;
import com.unis.dataQualityAssessmen.info.modular.dqaDataAnalysis.entity.vo.DqaDataAnalysisVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.unis.common.annotation.CommonLog;
import com.unis.common.pojo.CommonResult;
import com.unis.common.pojo.CommonValidList;
import com.unis.dataQualityAssessmen.info.modular.dqaDataAnalysis.entity.DqaDataAnalysis;
import com.unis.dataQualityAssessmen.info.modular.dqaDataAnalysis.param.DqaDataAnalysisAddParam;
import com.unis.dataQualityAssessmen.info.modular.dqaDataAnalysis.param.DqaDataAnalysisEditParam;
import com.unis.dataQualityAssessmen.info.modular.dqaDataAnalysis.param.DqaDataAnalysisIdParam;
import com.unis.dataQualityAssessmen.info.modular.dqaDataAnalysis.param.DqaDataAnalysisPageParam;
import com.unis.dataQualityAssessmen.info.modular.dqaDataAnalysis.service.DqaDataAnalysisService;

import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * 数据质量考核-统计分析-数据分析表表控制器
 *
 * @author TS
 * @date  2024/05/21 15:21
 */
@Api(tags = "数据质量考核-统计分析-数据分析表表控制器")
@ApiSupport(author = "UNIS_TEAM", order = 1)
@RestController
@Validated
public class DqaDataAnalysisController {

    @Resource
    private DqaDataAnalysisService dqaDataAnalysisService;

    @Resource
    private UnReporCityController unReporCityController;

    /**
     * 获取数据质量考核-统计分析-数据量自定义分页
     *
     * @author TS
     * @date  2024/05/21 15:21
     */
//    @ApiOperationSupport(order = 1)
//    @ApiOperation("获取数据质量考核-统计分析-数据分析表表分页")
////    @SaCheckPermission("/dataQualityAssessmen.info/dqaDataAnalysis/page")
//    @GetMapping("/dataQualityAssessmen.info/dqaDataAnalysis/page")
//    public CommonResult<Page<DqaDataAnalysis>> page(DqaDataAnalysisPageParam dqaDataAnalysisPageParam) {
//        return CommonResult.data(dqaDataAnalysisService.page(dqaDataAnalysisPageParam));
//    }
    /**
     * 获取数据质量考核-统计分析-数据量自定义分页
     *
     * @author TS
     * @date  2024/05/21 15:21
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("获取数据质量考核-统计分析-数据量自定义分页")
//    @SaCheckPermission("/dataQualityAssessmen.info/dqaDataAnalysis/findCountPage")
    @GetMapping("/dataQualityAssessmen.info/dqaDataAnalysis/findCountPage")
    public CommonResult<IPage<DqaDataAnalysisVo>> findCountPage(DqaDataAnalysisPageParam dqaDataAnalysisPageParam) {
        return CommonResult.data(dqaDataAnalysisService.findCountPage(dqaDataAnalysisPageParam));
    }
    /**
     * 获取数据质量考核-统计分析-数据量详情自定义分页
     *
     * @author TS
     * @date  2024/05/21 15:21
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("获取数据质量考核-统计分析-数据量详情自定义分页")
//    @SaCheckPermission("/dataQualityAssessmen.info/dqaDataAnalysis/findCountDetailPage")
    @GetMapping("/dataQualityAssessmen.info/dqaDataAnalysis/findCountDetailPage")
    public CommonResult<IPage<DqaDataAnalysisVo>> findCountDetailPage(DqaDataAnalysisPageParam dqaDataAnalysisPageParam) {
        return CommonResult.data(dqaDataAnalysisService.findCountDetailPage(dqaDataAnalysisPageParam));
    }
    /**
     * 获取数据质量考核-统计分析-完整性自定义分页
     *
     * @author TS
     * @date  2024/05/21 15:21
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("获取数据质量考核-统计分析-完整性自定义分页")
//    @SaCheckPermission("/dataQualityAssessmen.info/dqaDataAnalysis/findCountPage")
    @GetMapping("/dataQualityAssessmen.info/dqaDataAnalysis/findComplePage")
    public CommonResult<IPage<DqaDataAnalysisVo>> findComplePage(DqaDataAnalysisPageParam dqaDataAnalysisPageParam) {
        return CommonResult.data(dqaDataAnalysisService.findComplePage(dqaDataAnalysisPageParam));
    }
    /**
     * 获取数据质量考核-统计分析-完整性详情自定义分页
     *
     * @author TS
     * @date  2024/05/21 15:21
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("获取数据质量考核-统计分析-完整性详情自定义分页")
//    @SaCheckPermission("/dataQualityAssessmen.info/dqaDataAnalysis/findCompleDetailPage")
    @GetMapping("/dataQualityAssessmen.info/dqaDataAnalysis/findCompleDetailPage")
    public CommonResult<IPage<DqaDataAnalysisVo>> findCompleDetailPage(DqaDataAnalysisPageParam dqaDataAnalysisPageParam) {
        return CommonResult.data(dqaDataAnalysisService.findCompleDetailPage(dqaDataAnalysisPageParam));
    }
    /**
     * 获取数据质量考核-统计分析-正确性详情自定义分页
     *
     * @author TS
     * @date  2024/05/21 15:21
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("获取数据质量考核-统计分析-正确性详情自定义分页")
//    @SaCheckPermission("/dataQualityAssessmen.info/dqaDataAnalysis/findAccuracyPage")
    @GetMapping("/dataQualityAssessmen.info/dqaDataAnalysis/findAccuracyPage")
    public CommonResult<IPage<DqaDataAnalysisVo>> findAccuracyPage(DqaDataAnalysisPageParam dqaDataAnalysisPageParam) {
        return CommonResult.data(dqaDataAnalysisService.findAccuracyPage(dqaDataAnalysisPageParam));
    }
    /**
     * 获取数据质量考核-统计分析-正确性详情自定义分页
     *
     * @author TS
     * @date  2024/05/21 15:21
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("获取数据质量考核-统计分析-正确性详情自定义分页")
//    @SaCheckPermission("/dataQualityAssessmen.info/dqaDataAnalysis/findAccuracyDetailPage")
    @GetMapping("/dataQualityAssessmen.info/dqaDataAnalysis/findAccuracyDetailPage")
    public CommonResult<IPage<DqaDataAnalysisVo>> findAccuracyDetailPage(DqaDataAnalysisPageParam dqaDataAnalysisPageParam) {
        return CommonResult.data(dqaDataAnalysisService.findAccuracyDetailPage(dqaDataAnalysisPageParam));
    }

    /**
     * 获取数据质量考核-统计分析-自动考核自定义分页
     *
     * @author TS
     * @date  2024/05/21 15:21
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("获取数据质量考核-统计分析-自动考核自定义分页")
//    @SaCheckPermission("/dataQualityAssessmen.info/dqaDataAnalysis/findAtuoPage")
    @GetMapping("/dataQualityAssessmen.info/dqaDataAnalysis/findAtuoPage")
    public CommonResult<IPage<DqaDataAnalysisVo>> findAtuoPage(DqaDataAnalysisPageParam dqaDataAnalysisPageParam) {
        return CommonResult.data(dqaDataAnalysisService.findAtuoPage(dqaDataAnalysisPageParam));
    }
    /**
     * 获取数据质量考核-统计分析-自动考核详情自定义分页
     *
     * @author TS
     * @date  2024/05/21 15:21
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("获取数据质量考核-统计分析-自动考核详情自定义分页")
//    @SaCheckPermission("/dataQualityAssessmen.info/dqaDataAnalysis/findAtuoDetailPage")
    @GetMapping("/dataQualityAssessmen.info/dqaDataAnalysis/findAtuoDetailPage")
    public CommonResult<IPage<DqaDataAnalysisVo>> findAtuoDetailPage(DqaDataAnalysisPageParam dqaDataAnalysisPageParam) {
        return CommonResult.data(dqaDataAnalysisService.findAtuoDetailPage(dqaDataAnalysisPageParam));
    }

   /* *//**
     * 添加数据质量考核-统计分析-数据分析表表
     *
     * @author TS
     * @date  2024/05/21 15:21
     *//*
    @ApiOperationSupport(order = 2)
    @ApiOperation("添加数据质量考核-统计分析-数据分析表表")
    @CommonLog("添加数据质量考核-统计分析-数据分析表表")
//    @SaCheckPermission("/dataQualityAssessmen.info/dqaDataAnalysis/add")
    @PostMapping("/dataQualityAssessmen.info/dqaDataAnalysis/add")
    public CommonResult<String> add(@RequestBody @Valid DqaDataAnalysisAddParam dqaDataAnalysisAddParam) {
        dqaDataAnalysisService.add(dqaDataAnalysisAddParam);
        return CommonResult.ok();
    }

    *//**
     * 编辑数据质量考核-统计分析-数据分析表表
     *
     * @author TS
     * @date  2024/05/21 15:21
     *//*
    @ApiOperationSupport(order = 3)
    @ApiOperation("编辑数据质量考核-统计分析-数据分析表表")
    @CommonLog("编辑数据质量考核-统计分析-数据分析表表")
//    @SaCheckPermission("/dataQualityAssessmen.info/dqaDataAnalysis/edit")
    @PostMapping("/dataQualityAssessmen.info/dqaDataAnalysis/edit")
    public CommonResult<String> edit(@RequestBody @Valid DqaDataAnalysisEditParam dqaDataAnalysisEditParam) {
        dqaDataAnalysisService.edit(dqaDataAnalysisEditParam);
        return CommonResult.ok();
    }

    *//**
     * 删除数据质量考核-统计分析-数据分析表表
     *
     * @author TS
     * @date  2024/05/21 15:21
     *//*
    @ApiOperationSupport(order = 4)
    @ApiOperation("删除数据质量考核-统计分析-数据分析表表")
    @CommonLog("删除数据质量考核-统计分析-数据分析表表")
//    @SaCheckPermission("/dataQualityAssessmen.info/dqaDataAnalysis/delete")
    @PostMapping("/dataQualityAssessmen.info/dqaDataAnalysis/delete")
    public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空")
                                                   CommonValidList<DqaDataAnalysisIdParam> dqaDataAnalysisIdParamList) {
        dqaDataAnalysisService.delete(dqaDataAnalysisIdParamList);
        return CommonResult.ok();
    }

    *//**
     * 获取数据质量考核-统计分析-数据分析表表详情
     *
     * @author TS
     * @date  2024/05/21 15:21
     *//*
    @ApiOperationSupport(order = 5)
    @ApiOperation("获取数据质量考核-统计分析-数据分析表表详情")
//    @SaCheckPermission("/dataQualityAssessmen.info/dqaDataAnalysis/detail")
    @GetMapping("/dataQualityAssessmen.info/dqaDataAnalysis/detail")
    public CommonResult<DqaDataAnalysis> detail(@Valid DqaDataAnalysisIdParam dqaDataAnalysisIdParam) {
        return CommonResult.data(dqaDataAnalysisService.detail(dqaDataAnalysisIdParam));
    }*/

    @ApiOperation("自动考核导出")
    @PostMapping(value = "/dataQualityAssessmen.info/dqaDataAnalysis/exportByEntity",produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
    public void exportByEntity(
            @Valid DqaDataAnalysisPageParam dqaDataAnalysisPageParam
            , HttpServletResponse response)throws IOException {
        dqaDataAnalysisService.exportByEntity(dqaDataAnalysisPageParam,response);

    }
/*
    @ApiOperation("自动考核导出")
    @PostMapping(value = "/dataQualityAssessmen.info/dqaDataAnalysis/exportByEntity",produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
    public void exportByEntity(
            @Valid DqaDataAnalysisPageParam dqaDataAnalysisPageParam
            , HttpServletResponse response) {

        try {

            List<Map<String,Object>> data= dqaDataAnalysisService.exportByEntity(dqaDataAnalysisPageParam);

            LinkedHashMap<String, String> columnName = new LinkedHashMap<>();

            columnName.put("number","序号");
            columnName.put("unitName","单位名称");
            columnName.put("noDataCount","空数据接口数");
            columnName.put("dateRecordCount","数据总条数");
            columnName.put("lastUpdateDate","更新时间");

            // 输出Excel文件

            response.reset();
            String fileName = "自动考核统计表";
            response.setHeader("content-disposition", "attachment;filename="
                    + new String(CommonTimeFormatUtil.getDate()) + ".xlsx");

            response.setContentType("application/vnd.ms-excel;charset=gb2312");
            ServletOutputStream output = response.getOutputStream();
            unReporCityController.pojo3Excel(data, output, columnName,fileName);

            output.close();

        } catch (Exception e) {
            e.printStackTrace();

        }
    }
*/
}
