/*
 * 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.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.unis.dataQualityAssessmen.info.modular.dqaDataAnalysis.entity.DqaDataAnalysis;
import com.unis.dataQualityAssessmen.info.modular.dqaDataAnalysis.entity.vo.DqaDataAnalysisExportVo;
import com.unis.dataQualityAssessmen.info.modular.dqaDataAnalysis.entity.vo.DqaDataAnalysisVo;
import com.unis.policy.info.modular.alPolicyFileReport.entity.AlPolicyFileReport;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 数据质量考核-统计分析-数据分析表表Mapper接口
 *
 * @author TS
 * @date  2024/05/21 15:21
 **/
public interface DqaDataAnalysisMapper extends BaseMapper<DqaDataAnalysis> {
    /**
     *
     * @param countryTableName
     * @param unitId
     * @return
     */
//    @Select("SELECT COUNT(a.id) as 'conunt',IFNULL(MAX(a.ZHGXSJ),'') 'zhgsxj' FROM up_country_qh.${countryTableName} a inner JOIN depot_qh.org_info b on a.DEP_KQDM = b.org_id where b.unit_info_id = #{unitId}" )
    Map<String,Object> selectCountByTableNameAndUnitId(@Param("countryTableName") String countryTableName, @Param("unitId") String unitId);

    /**
     *
     * @param countryTableName
     * @return
     */
//    @Select("SELECT b.unit_info_id as 'unitId',COUNT(a.id) as 'conunt',IFNULL(MAX(a.ZHGXSJ),'') 'zhgsxj' FROM up_country_qh.${countryTableName} a inner JOIN depot_qh.org_info b on a.DEP_KQDM = b.org_id GROUP BY b.unit_info_id")
    List<Map<String,Object>> selectCountByTableName(@Param("countryTableName")String countryTableName);

    /**
     *
     * @param p
     * @param queryWrapper
     * @return
     */
    IPage<DqaDataAnalysisVo> findCountPage(Page<DqaDataAnalysisVo> p, @Param(Constants.WRAPPER)QueryWrapper<AlPolicyFileReport> queryWrapper);
    /**
     *
     * @param p
     * @param queryWrapper
     * @return
     */
    IPage<DqaDataAnalysisVo> findCountDetailPage(Page<DqaDataAnalysisVo> p, @Param(Constants.WRAPPER)QueryWrapper<AlPolicyFileReport> queryWrapper);

    /**
     *
     * @param p
     * @param queryWrapper
     * @return
     */
    IPage<DqaDataAnalysisVo> findComplePage(Page<DqaDataAnalysisVo> p, @Param(Constants.WRAPPER)QueryWrapper<AlPolicyFileReport> queryWrapper);

    /**
     *
     * @param p
     * @param queryWrapper
     * @return
     */
    IPage<DqaDataAnalysisVo> findCompleDetailPage(Page<DqaDataAnalysisVo> p, @Param(Constants.WRAPPER)QueryWrapper<AlPolicyFileReport> queryWrapper);

    IPage<DqaDataAnalysisVo> findAccuracyPage(Page<DqaDataAnalysisVo> p, @Param(Constants.WRAPPER)QueryWrapper<AlPolicyFileReport> queryWrapper);

    IPage<DqaDataAnalysisVo> findAccuracyDetailPage(Page<DqaDataAnalysisVo> p, @Param(Constants.WRAPPER)QueryWrapper<AlPolicyFileReport> queryWrapper);

    IPage<DqaDataAnalysisVo> findAtuoPage(Page<DqaDataAnalysisVo> p, @Param(Constants.WRAPPER)QueryWrapper<AlPolicyFileReport> queryWrapper);

    IPage<DqaDataAnalysisVo> findAtuoDetailPage(Page<DqaDataAnalysisVo> p, @Param(Constants.WRAPPER)QueryWrapper<AlPolicyFileReport> queryWrapper);

    List<DqaDataAnalysisExportVo> exportByEntity(@Param(Constants.WRAPPER)QueryWrapper<DqaDataAnalysisExportVo> queryWrapper);
}
