package com.njcn.harmonic.mapper;

import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.harmonic.pojo.dto.PublicDTO;
import com.njcn.harmonic.pojo.po.RMpPollutionDPO;
import java.util.List;
import org.apache.ibatis.annotations.Param;import org.apache.ibatis.annotations.Select;

/**
 * Description:
 * 接口文档访问地址：http://serverIP:port/swagger-ui.html
 * Date: 2022/11/4  15:29【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
public interface RMpPollutionDPOMapper extends BaseMapper<RMpPollutionDPO> {
    int updateBatch(List<RMpPollutionDPO> list);

    int batchInsert(@Param("list") List<RMpPollutionDPO> list);

    int insertOrUpdate(RMpPollutionDPO record);

    int insertOrUpdateSelective(RMpPollutionDPO record);

    @Select({"<script>",
            "SELECT\n",
            "    l.line_id,\n",
            "    max(l.value) as value\n",
            "FROM\n" +
                    "    r_mp_pollution_d l\n",
            "where line_id in\n",
            "<foreach item='item' index='index' collection='items' open='(' separator=',' close=')'>",
            "#{item}",
            "</foreach>",
            "\tand DATE_FORMAT( data_date ,'%Y-%m-%d')  like #{searchBeginTime}\n",
            "and pollution_type =#{pollutionType}",
            "GROUP BY\n",
            "    l.line_id",
            "</script>"

    })
    List<RMpPollutionDPO> selectMaxList(@Param("items") List<String> line, @Param("pollutionType") String pollutionType, @Param("searchBeginTime") String searchBeginTime);

    List<PublicDTO> getTop10Line(@Param("list") List<String> lineList, @Param("start") DateTime searchBeginTime, @Param("end") DateTime searchEndTime, @Param("pollutionType") String id);
}