package com.shzg.project.worn.mapper;

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

import com.shzg.project.worn.domain.MqttSensorDevice;
import io.lettuce.core.dynamic.annotation.Param;

/**
 * MQTT设备Mapper接口
 * 
 * @author shzg
 * @date 2026-04-01
 */
public interface MqttSensorDeviceMapper 
{
    /**
     * 查询MQTT设备
     * 
     * @param id MQTT设备主键
     * @return MQTT设备
     */
    public MqttSensorDevice selectMqttSensorDeviceById(Long id);

    /**
     * 查询MQTT设备列表
     * 
     * @param mqttSensorDevice MQTT设备
     * @return MQTT设备集合
     */
    public List<MqttSensorDevice> selectMqttSensorDeviceList(MqttSensorDevice mqttSensorDevice);

    /**
     * 查询 MQTT 缓存专用设备列表（不按在线/离线状态过滤）
     *
     * @return 设备集合
     */
    public List<MqttSensorDevice> selectAllForMqttCache();

    /**
     * 新增MQTT设备
     * 
     * @param mqttSensorDevice MQTT设备
     * @return 结果
     */
    public int insertMqttSensorDevice(MqttSensorDevice mqttSensorDevice);

    /**
     * 修改MQTT设备
     * 
     * @param mqttSensorDevice MQTT设备
     * @return 结果
     */
    public int updateMqttSensorDevice(MqttSensorDevice mqttSensorDevice);

    /**
     * 删除MQTT设备
     * 
     * @param id MQTT设备主键
     * @return 结果
     */
    public int deleteMqttSensorDeviceById(Long id);

    /**
     * 批量删除MQTT设备
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteMqttSensorDeviceByIds(Long[] ids);

    /**
     * 根据devEui查询设备
     * @param
     * @return
     */
    MqttSensorDevice selectByDevEui(@Param("devEui") String devEui);

    /**
     * 设备统计（按权限）
     */
    Map<String, Object> countDeviceStat(@Param("deptIds") List<Long> deptIds);

    /**
     * 更新设备运行状态（0在线 1离线）
     *
     * @param device 设备
     * @return 结果
     */
    int updateRuntimeStatus(MqttSensorDevice device);

    /**
     * 查询超时离线设备
     *
     * @return 设备列表
     */
    List<MqttSensorDevice> selectOfflineDeviceList();
}
