package com.nantian.cloud.jljc.mapper;

import com.baomidou.mybatisplus.annotation.SqlParser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nantian.cloud.jljc.entity.TReport;
import com.nantian.cloud.jljc.entity.TReportEnergysTructure;
import com.nantian.cloud.jljc.vo.Query;
import com.nantian.cloud.jljc.vo.QueryCustomReportSummaryVo;
import com.nantian.cloud.jljc.vo.ReportModifyVo;
import com.nantian.cloud.jljc.vo.TReportUnitenergy;
import com.nantian.cloud.jljc.vo.comAnalysis.EnergyInfoVo;
import com.nantian.sc.cloud.common.data.datascope.DataScope;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

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

/**
 * 能源报表信息 Mapper 接口
 * @since 2020-09-16
 * @author stz
 */
@Mapper
public interface TReportMapper extends BaseMapper<TReport> {

    //超期申请查询(带数据权限)
    IPage<ReportModifyVo> getModifyRecords(Page page, @Param("cmpName") String cmpName, @Param("status") String status, DataScope dataScope);

    //查询能源报表信息
    TReport getInfoByType(@Param("epc") String enterpriseCode,@Param("year") String year,@Param("type") String type);

    //新增报表信息，返回主键id
    boolean addTReport(TReport addReport);

    @SqlParser(filter = true)
    IPage<Map<String, Object>> getListPage(Page page, @Param("query") Query query,@Param("list") String[] list, DataScope dataScope);

    //自定义报表查询
    IPage<Map<String, Object>> queryCustom(Page page, @Param("query")Query query, DataScope dataScope,@Param("list") String[] list);


    //按企业维度获取综合能耗
    IPage<Map<String,Object>> getEnergyConsumptionByCom(Page page,@Param("query") Query query, DataScope dataScope);
    //按地区维度获取综合能耗
    List<Map<String,Object>> getEnergyConsumptionByArea(@Param("query") Query query);
    //按行业维度获取综合能耗
    List<Map<String,Object>> getEnergyConsumptionByTrade(@Param("query") Query query);

    //按年份、产品编码获取 单位产品能耗排名
    IPage<Map<String, Object>> unitConsumptionRanking(Page page, @Param("year") String year, @Param("productCode") String productCode);
    //按年份、产品编码获取 单位产品能耗的前三名
    List<Map<String, Object>> unitConsumptionTop3(@Param("year") String year, @Param("productCode") String productCode);

    //自定义查询能报、监察、在线监测数据
    IPage<Map<String, Object>> queryCustomReport(Page page, @Param("query") Query query, DataScope dataScope);

    //根据多行业、多地区 自定义查询能报、监察、在线监测汇总数据
    List<QueryCustomReportSummaryVo> queryCustomReportSummary(@Param("query") Query query);

    //自定义查询 16地州数据
    List<QueryCustomReportSummaryVo> queryCustomReportSummaryByAllArea(@Param("query") Query query);

    //获取节能首页的获取综合能源消费  state 1省，2州市，3区县
    List<Map<String, Object>> energyConsumptionByAreas(@Param("state") String state, @Param("year") String year,@Param("area") String area);

   //能源利用状况报告上报情况汇总
    Map<String, Object> totalByReport(@Param("year") String year,@Param("area") String area);

    //获取能源消费结构的综合能源消费
    List<TReportEnergysTructure> energyConsumptionByEnergy(@Param("query") Query query);

    IPage<Map<String, Object>> comAnalysisList(@Param("page") Page page,@Param("query") Query query);

    //分页获取能效对标企业名单
    IPage<Map<String, Object>> energyBenchmarkingPage(@Param("page") Page page,@Param("year") String year,@Param("energyId") String energyId, DataScope dataScope);

    //获取能效对标饼图
    Map<String, String> energyBenchmarkingGov(@Param("year") String year,@Param("energyId") String energyId,@Param("area") Integer area);
    Map<String, String> energyBenchmarkingLocal(@Param("year") String year,@Param("energyId") String energyId,@Param("area") Integer area);

    //地区未审核报表记录
    int noProvStatusLog();

    //滞留在州市级的报表上送至省级
    int upProvStatus(@Param("date") String date);

    //获取能报情况首页通知（加数据权限）
    List<Map<String, Object>> noticeListByReport(@Param("query") Query query, @Param("deptId") String deptId, DataScope dataScope);


    //获取能报报表1的异常情况
    List<Map<String, Object>> exceptionInfoByReport1(@Param("query") Query query, @Param("deptId") String deptId);

    //获取能报报表2的异常情况
    List<Map<String, Object>> exceptionInfoByReport2(@Param("query") Query query, @Param("deptId") String deptId);

    List<Map<String, Object>> reportSummaryAndAudit(@Param("query") Query query);

    List<Map<String, Object>> queryCustomRank61_1(@Param("query") Query query, @Param("list") String[] list);
    List<Map<String, Object>> queryCustomRank61_2(@Param("query") Query query, @Param("list") String[] list);
    IPage<Map<String, Object>> queryCustomRank61_3(Page page,@Param("query") Query query, @Param("list") String[] list);
    Map<String, Object> queryCustomRank61_4(@Param("query") Query query, @Param("list") String[] list);

    List<Map<String, Object>> queryCustomRank31_1(@Param("query") Query query, @Param("list") String[] list);
    List<Map<String, Object>> queryCustomRank31_2(@Param("query") Query query, @Param("list") String[] list);
    IPage<Map<String, Object>> queryCustomRank31_3(Page page,@Param("query") Query query, @Param("list") String[] list);
    Map<String, Object> queryCustomRank31_4(@Param("query") Query query, @Param("list") String[] list);

    List<Map<String, Object>> queryCustomRank32_1(@Param("query") Query query, @Param("list") String[] list);
    List<Map<String, Object>> queryCustomRank32_2(@Param("query") Query query, @Param("list") String[] list);
    IPage<Map<String, Object>> queryCustomRank32_3(Page page,@Param("query") Query query, @Param("list") String[] list);
    Map<String, Object> queryCustomRank32_4(@Param("query") Query query, @Param("list") String[] list);

    List<Map<String, Object>> queryCustomRank42_1(@Param("query") Query query, @Param("list") String[] list);
    List<Map<String, Object>> queryCustomRank42_2(@Param("query") Query query, @Param("list") String[] list);
    IPage<Map<String, Object>> queryCustomRank42_3(Page page,@Param("query") Query query, @Param("list") String[] list);
    Map<String, Object> queryCustomRank42_4(@Param("query") Query query, @Param("list") String[] list);

    List<Map<String, Object>> queryCustomRank44_1(@Param("query") Query query, @Param("list") String[] list,@Param("code") String code);
    List<Map<String, Object>> queryCustomRank44_2(@Param("query") Query query, @Param("list") String[] list,@Param("code") String code);
    IPage<Map<String, Object>> queryCustomRank44_3(Page page,@Param("query") Query query, @Param("list") String[] list);
    Map<String, Object> queryCustomRank44_4(@Param("query") Query query, @Param("list") String[] list,@Param("code") String code);

    List<Map<String, Object>> queryCustomRank43_1(@Param("query") Query query, @Param("list") String[] list,@Param("code") String code);
    List<Map<String, Object>> queryCustomRank43_2(@Param("query") Query query, @Param("list") String[] list,@Param("code") String code);
    IPage<Map<String, Object>> queryCustomRank43_3(Page page,@Param("query") Query query, @Param("list") String[] list);
    Map<String, Object> queryCustomRank43_4(@Param("query") Query query, @Param("list") String[] list,@Param("code") String code);

    List<Map<String, Object>> queryCustomRank48_1(@Param("query") Query query, @Param("list") String[] list);
    List<Map<String, Object>> queryCustomRank48_2(@Param("query") Query query, @Param("list") String[] list);
    IPage<Map<String, Object>> queryCustomRank48_3(Page page,@Param("query") Query query, @Param("list") String[] list);
    Map<String, Object> queryCustomRank48_4(@Param("query") Query query, @Param("list") String[] list);

    List<TReportUnitenergy> queryCustomRank51_1(@Param("query") Query query, @Param("split") String[] split);
    List<TReportUnitenergy> queryCustomRank51_2(@Param("query") Query query,@Param("split") String[] split);
    List<Map<String, Object>> queryCustomRank51_3(@Param("query") Query query,@Param("split") String[] split);
    List<TReportUnitenergy> queryCustomRank52_1(@Param("query") Query query,@Param("split") String[] split);
    List<TReportUnitenergy> queryCustomRank52_2(@Param("query") Query query,@Param("split") String[] split);
    List<Map<String, Object>> queryCustomRank52_3(@Param("query") Query query,@Param("split") String[] split);

    List<Map<String, Object>> queryCustomRank71_1(@Param("query") Query query, @Param("list") String[] list,@Param("projectType") String projectType);
    List<Map<String, Object>> queryCustomRank71_2(@Param("query") Query query, @Param("list") String[] list,@Param("projectType") String projectType);
    IPage<Map<String, Object>> queryCustomRank71_3(Page page,@Param("query") Query query, @Param("list") String[] list);
    Map<String, Object> queryCustomRank71_4(@Param("query") Query query, @Param("list") String[] list,@Param("projectType") String projectType);

    List<Map<String, Object>> queryCustomRank21_1(@Param("query") Query query, @Param("years") String[] years,@Param("split") String[] split);
    List<Map<String, Object>> queryCustomRank21_2(@Param("query") Query query, @Param("years") String[] years,@Param("split") String[] split);
    List<Map<String, Object>> queryCustomRank21_3(@Param("query") Query query, @Param("years") String[] years,@Param("split") String[] split);
    List<Map<String, Object>> queryCustomRank22_1(@Param("query") Query query, @Param("years") String[] years,@Param("split") String[] split);
    List<Map<String, Object>> queryCustomRank22_2(@Param("query") Query query, @Param("years") String[] years,@Param("split") String[] split);
    List<Map<String, Object>> queryCustomRank22_3(@Param("query") Query query, @Param("years") String[] years,@Param("split") String[] split);

    IPage<Map<String, Object>> getNoAuditPage(Page page,@Param("query") Query query, DataScope dataScope);

    List<TReport> listByAuditorJudge(@Param("query")TReport tReport);

    List<EnergyInfoVo> getEnergyData();

    List<Map<String, Object>> getReturnDetail(@Param("epc") String epc,@Param("year") String year);

    //更新能报企业和报表所属地区
    void renewReportRegion(@Param("enterpriseCode") String enterpriseCode, @Param("regionCode") String regionCode);
}
