package com.sckw.slope.detection.dao.mysql;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sckw.slope.detection.model.dos.mysql.KwsAlarm;
import com.sckw.slope.detection.model.param.AlarmLogThresholdExport;
import com.sckw.slope.detection.model.param.AlarmLogThresholdQuery;
import com.sckw.slope.detection.model.vo.AlarmLogThresholdVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

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

@Mapper
@DS("mysql")
public interface KwsAlarmMapper extends BaseMapper<KwsAlarm> {
    int deleteByPrimaryKey(Long id);

    int insertSelective(KwsAlarm record);

    KwsAlarm selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(KwsAlarm record);

    int updateByPrimaryKey(KwsAlarm record);

    List<Map<String, Long>> selectByDevicesId(@Param("devicesId") List<Long> devicesId);

    List<Map<String, Object>> selectDataByDevicesId(@Param("devicesId") List<Long> devicesId);

    /**
     * 统计
     *
     * @param startTime  开始时间
     * @param endTime    结束时间
     * @param projectId  项目
     * @param mountainId 矿山
     * @param level      等级
     * @param type       告警类型
     * @return
     */
    List<Map<String, Object>> getDataAlarmToDay(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("level") String level,
                                                @Param("projectId") String projectId, @Param("mountainId") String mountainId,@Param("companyId")  String companyId,
                                                @Param("type") Integer type);

    List<Map<String, Object>> getDataAlarmToWeek(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("level") String level,
                                                 @Param("projectId") String projectId, @Param("mountainId") String mountainId,
                                                 @Param("companyId") String companyId,
                                                 @Param("dateTimeFormat") String dateTimeFormat, @Param("type") Integer type);

    List<Map<String, Object>> getDataAlarmToYear(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("level") String level,
                                                 @Param("projectId") String projectId, @Param("mountainId") String mountainId,@Param("companyId") String companyId, @Param("type") Integer type);

    List<Map<String, Object>> getProjectAlarmList(@Param("startTime") String startTime, @Param("endTime") String endTime,
                                                  @Param("level") String level, @Param("projectId") String projectId,
                                                  @Param("companyId") String companyId, @Param("type") Integer type);

    List<AlarmLogThresholdVO> selectDetailList(@Param("page") Integer page, @Param("pageSize") Integer pageSize);

    int selectDetailCount();

    List<KwsAlarm> selectListByQuery(@Param("query") AlarmLogThresholdQuery query, @Param("mountainId") String mountainId, @Param("companyId") String companyId);

    List<KwsAlarm> selectExportListByQuery(@Param("query") AlarmLogThresholdExport query, @Param("mountainId") String mountainId, @Param("idsList") List<Long> idsList);
}