package com.tofly.xrtygis.custom.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.xrtygis.custom.entity.dto.IndexInfoDto;
import com.tofly.xrtygis.custom.entity.dto.RelationshipCostDto;
import com.tofly.xrtygis.custom.entity.dto.WisdomDisplayDto;
import com.tofly.xrtygis.entity.Scadahistory;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

public interface CustomDisplayMapper {

    /**
     * 查看历史记录
     *
     * @param page      page
     * @param itcd      指标编号
     * @param startTime 开始时间
     * @param endTime   结束时间
     * @return page
     */
    Page<Map> viewHistory(Page page, @Param("itcd") String itcd, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("outlier") String outlier);

    /**
     * 查看历史记录
     *
     * @param itcd      指标编号
     * @param startTime 开始时间
     * @param endTime   结束时间
     * @return page
     */
    List<Map> viewHistory2(@Param("itcd") String itcd, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("outlier") String outlier);

    /**
     * 查询指标值
     *
     * @param itcd      指标编号
     * @param startTime 开始时间
     * @param endTime   结束时间
     * @return list
     */
    List<Scadahistory> viewItValue(@Param("itcd") String itcd, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("outlier") String outlier);


    /**
     * 获取实时监测值
     *
     * @param itcdList 指标编号集合
     * @return list
     */
    List<IndexInfoDto> getRealtime(@Param("itcdList") List<String> itcdList);

    /**
     * 最大历史值
     *
     * @param itcdList 编号集合
     * @return double
     */
    List<IndexInfoDto> getMaxHistoryVal(@Param("itcdList") List<String> itcdList, @Param("tableName") String tableName);

    /**
     * 按小时查询取供水趋势
     *
     * @param page  page
     * @param scid  厂id
     * @param start 开始时间
     * @param end   结束时间
     * @return page
     */
    Page<Map> waterByHour(Page page, @Param("scid") Long scid, @Param("start") String start, @Param("end") String end);


    /**
     * 按天查询取供水趋势
     *
     * @param page  page
     * @param scid  厂id
     * @param start 开始时间
     * @param end   结束时间
     * @return page
     */
    Page<Map> waterByDay(Page page, @Param("scid") Long scid, @Param("start") String start, @Param("end") String end);

    /**
     * 按月查询供取水趋势
     *
     * @param page  page
     * @param scid  厂id
     * @param start 开始时间
     * @param end   结束时间
     * @return page
     */
    Page<Map> waterByMonth(Page page, @Param("scid") Long scid, @Param("start") String start, @Param("end") String end);

    /**
     * 取供水同期比对
     *
     * @param page
     * @return
     */
    Page<Map> waterContrast(Page page, @Param("scid") Long scid, @Param("list") List<String> list);

    /**
     * 获取水表坐标
     *
     * @param numList 编号集合
     * @return list
     */
    List<Map> getCoordinate(List numList);

    List<Map<String, Object>> getPrimaryInfo(@Param("list") List list, @Param("start") String start, @Param("end") String end);

    List<Map<String, Object>> getPacDensity(@Param("start") String start, @Param("end") String end, @Param("param") String param);

    List<Map<String, Object>> totalConsumption(@org.apache.ibatis.annotations.Param("dto") RelationshipCostDto dto);

    List<Map<String, Object>> getCostAndWater(@Param("param") String param, @Param("start") String start, @Param("end") String end);

    Map<String, Double> getCoordinateInfo(@Param("sbbh") String sbbh);

    List<Map<String, Object>> getWaterVolume(@Param("code") String code, @Param("start") String start, @Param("end") String end);


    List<Map<String, Object>> getCodeInfo(@Param("pcid") List pcid);

    @Select("select distinct ccode, cname\n" +
            "from TF_YWPN_SYSCHILDCODE_D\n" +
            "where pcid = 403")
    List<Map> getIndexType();

    @Select("select STNM, i.ITCD, i.ITNM\n" +
            "        from TF_YWPN_SCADASTAITEM_W i\n" +
            "                 left join TF_YWPN_SCADASTATION_B s on i.STATION_ID = s.ID\n" +
            "        where (UP_LIMIT is not null\n" +
            "           or DOWN_LIMIT is not null\n" +
            "           or QUALITY_STANDARD is not null)" +
            "           and s.STATE = 1" +
            "           and i.state = 1")
    List<Map> getStationItemInfo();

    List<Map<String, Object>> getItvalHistory(@Param("itcdList") List itcdList, @Param("start") String start, @Param("end") String end, @Param("itidList") List itidList, @Param("outlier") String outlier);

    List<Map<String, Object>> getItvalHistoryAll(@Param("itcdList") List itcdList, @Param("start") String start, @Param("end") String end, @Param("itidList") List itidList);

    List<Map<String, Object>> itemValInfo(@Param("itcdList") List itcdList, @Param("start") String start, @Param("end") String end, @Param("outlier") String outlier);

    Page<Map<String,Object>> reportFormCensusY(@org.apache.ibatis.annotations.Param("page") Page page, @org.apache.ibatis.annotations.Param("dto") WisdomDisplayDto wisdomDisplayDto);

    Page<Map<String,Object>> reportFormCensusM(@org.apache.ibatis.annotations.Param("page") Page page, @org.apache.ibatis.annotations.Param("dto") WisdomDisplayDto wisdomDisplayDto);

    Page<Map<String,Object>> reportFormCensusD(@org.apache.ibatis.annotations.Param("page") Page page, @org.apache.ibatis.annotations.Param("dto") WisdomDisplayDto wisdomDisplayDto);

    BigDecimal getYesterdaySupplyWater(@org.apache.ibatis.annotations.Param("codes")List<String> codes, @org.apache.ibatis.annotations.Param("waterType")String waterType);

    int getWaterAmount(@org.apache.ibatis.annotations.Param("waterType") String waterType);

    List<Map<String,Double>> getNearYearStatistical(@org.apache.ibatis.annotations.Param("startDate") String startDate, @org.apache.ibatis.annotations.Param("endDate") String endDate);

    /**
     * 查询用户数量
     * @return
     */
    Integer getTableUserListNum();

    BigDecimal getDesignProcessCapacity(String name);

    List<Map<String, Object>> getDmaStatisticalList(@org.apache.ibatis.annotations.Param("startDate") String startDate,
                                                    @org.apache.ibatis.annotations.Param("endDate") String endDate,
                                                    @org.apache.ibatis.annotations.Param("dmaIdList") List<Long> dmaIdList,
                                                    @org.apache.ibatis.annotations.Param("statisticsType") Integer statisticsType);

    List<Map<String,Object>> getSomeDayWater(@org.apache.ibatis.annotations.Param("day") String day, @org.apache.ibatis.annotations.Param("indexType") String indexType);

}
