package com.tofly.xrtygis.custom.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.xrtygis.custom.entity.dto.ItemDto;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.ResultSetType;
import org.springframework.data.repository.query.Param;
import org.springframework.security.core.parameters.P;

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

/**
 * 综合展示-专题图
 *
 * @author 陈浩
 * @date 2021/4/15
 */
public interface CustomTheMapMapper {

    /**
     * 获取区域用水量
     */
    Page<Map> getAreaUseWater(Page page, @Param("strTime") String strTime, @Param("endTime") String endTime);

    /**
     * 同期水量对比
     */
    Page<Map> getContrastWater(Page page, @Param("month") String month, @Param("strTime") String strTime, @Param("endTime") String endTime);

    /*List<Map> returnHisInfo(@Param("itcd") String itcd,@Param("start") String start,@Param("end") String end);*/

    List<Date> groupByCreateTime(@Param("start") String start, @Param("end") String end);

    Double getItVal(@Param("date") Date time, @P("tycd") String tycd, @Param("itcd") String itcd);

    @Options(resultSetType = ResultSetType.FORWARD_ONLY, fetchSize = 10000)
    @Select("select itval,\n" +
            "               s.id          itid,\n" +
            "               i.CREATE_TIME time\n" +
            "        from TF_YWPN_ITEMRATO_W_VIEW i,\n" +
            "             TF_YWPN_SCADASTAITEM_W s\n" +
            "        where i.ITCD = s.ITCD\n" +
            "          and i.TYCD = s.TYCD\n" +
            "          and i.TYCD = #{tycd}\n" +
            "          and to_char(i.CREATE_TIME, 'yyyy-mm-dd hh24:mi:ss') between #{start} and #{end}")
    List<ItemDto> viewItemInfo(@Param("tycd") String tycd, @Param("start") String start, @Param("end") String end);

    Date getStartTime(@Param("list") List<String> list, @Param("start") String start, @Param("end") String end);

    List<Map> getPartition(@Param("level") String level);

    List<Map> getAllUseWater(@Param("sql") String sql);
}
