package com.zcxk.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zcxk.dto.*;
import com.zcxk.entity.AlarmDetailsEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

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

/**
 * @description
 * @auto wangli
 * @data 2020-11-17 14:40
 */
@Mapper
public interface AlarmDetailMapper {
    /**
     * 查询单个设备报警
     * @return
     */
    AlarmDetailsDto selectById(Integer id);

    /**
     * 按设备ID查询报警信息
     * @param deviceId
     * @return
     */
    List<AlarmDetailsDto> selectByDeviceId(@Param("sceneId")Long sceneId,@Param("deviceId")Integer deviceId);


    /**
     * 查询设备报警
     * @return
     */
    List<AlarmDetailsRealTimeDto> selectRealTimeByIds(@Param("ids") List<Integer> ids);
    List<AlarmDetailsHistoryDto> selectHistoryByIds(@Param("ids") List<Integer> ids);
    /**
     * 添加设备报警
     * @return
     */
    Integer insert(AlarmDetailsEntity alarmDetailsEntity);

    /**
     * 批量插入设备报警信息
     * @param alarmDetails
     * @return
     */
    Integer batchInsert(@Param("alarmDetails") List<AlarmDetailsEntity> alarmDetails);

    /**
     * 单条删除设备报警
     * @return
     */
    Integer deleteById(Integer id);

    /**
     * 设备报警
     * @return
     */
    Integer batchDelete(@Param("ids") List<Integer> ids);
    /**
     * 挂起、恢复设备报警
     * @return
     */
    Integer suspendedById(@Param("id") Integer id, @Param("opState") Integer opState, @Param("dateUpdate") Date dateUpdate, @Param("updateBy") String updateBy);

    /**
     * 修改设备报警信息
     * @return
     */
    Integer update(AlarmDetailsEntity alarmDetailsEntity);

    /**
     * 查询设备报警信息
     * @return
     */
    List<AlarmDetailsDto> selectList(@Param("alarmDetailsDto") AlarmDetailsDto alarmDetailsDto);

    /**
     * 分页查询
     * @return
     */
    IPage<AlarmDetailsDto> selectPage(@Param("page") IPage<AlarmDetailsDto> page, @Param("alarmDetailsDto") AlarmDetailsDto alarmDetailsDto);


    /**
     * 查询实时设备报警信息
     * @return
     */
    List<AlarmDetailsRealTimeDto> selectRealTimeList(@Param("alarmDetailsDto") AlarmDetailsDto alarmDetailsDto);

    /**
     * 查询历史设备报警信息
     * @return
     */
    List<AlarmDetailsHistoryDto> selectHistoryList(@Param("alarmDetailsDto") AlarmDetailsDto alarmDetailsDto);



    /**
     * 分页查询实时数据
     * @return
     */
    IPage<AlarmDetailsRealTimeDto> selectRealTimePage(@Param("page") IPage<AlarmDetailsRealTimeDto> page, @Param("alarmDetailsDto") AlarmDetailsDto alarmDetailsDto);


    /**
     * 分页查询历史数据
     * @return
     */
    IPage<AlarmDetailsHistoryDto> selectHistoryPage(@Param("page") IPage<AlarmDetailsHistoryDto> page, @Param("alarmDetailsDto") AlarmDetailsDto alarmDetailsDto);


    /**
     * 查询报警规则数据
     * @return
     */
    List<DeviceCheckAlarmDto> selectDeviceForCheckAlarm(@Param("deviceId") Integer deviceId, @Param("alarmType") String alarmType);

    /**
     * 查询设备报警信息
     * @return
     */
    List<AlarmDetailsDto> selectStateAlarm(@Param("deviceId") Integer deviceId, @Param("alarmType") String alarmType,@Param("alarmSettingIds") List<Long> alarmSettingIds);


    Integer udpateLastUpdateTime(@Param("deviceId") Integer deviceId, @Param("lastUpdateTime") Date lastUpdateTime);

    List<DeviceAlarmInfoForOrder> getAlarmInfoForWorkOrderManage();

    Integer updateAlarmSendMessageState(List<DeviceAlarmInfoForOrder> list);

    List<AlarmDetailsDto> selectBySceneId(@Param("sceneId") Integer sceneId);

    List<AlarmDetailsDto> selectByDeviceAttributeId(@Param("sceneId")Long sceneId,@Param("deviceId")Integer deviceId, @Param("attributeId")Integer attributeId);
}
