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.KwsDevice;
import com.sckw.slope.detection.model.dto.DeviceDataDTO;
import com.sckw.slope.detection.model.dto.ThresholdSelectDTO;
import com.sckw.slope.detection.model.param.DeviceQuery;
import com.sckw.slope.detection.model.vo.AffiliationDeviceVO;
import com.sckw.slope.detection.model.vo.DeviceVo;
import com.sckw.slope.detection.model.vo.excel.KwsAlarmExportVO;
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 KwsDeviceMapper extends BaseMapper<KwsDevice> {
    int deleteByPrimaryKey(Long id);

    int insertSelective(KwsDevice record);

    KwsDevice selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(KwsDevice record);

    int updateByPrimaryKey(KwsDevice record);

    /**
     * 查询项目中未绑定设备关联关系的设备
     *
     * @param projectId
     * @param companyId
     * @return
     */
    List<DeviceDataDTO> selectDeviceAllNotDeviceRelation(@Param("projectId") String projectId, @Param("companyId") String companyId);

    /**
     * 查询项目中未绑定设备关联关系的设备
     *
     * @param projectId
     * @param companyId
     * @return
     */
    List<DeviceDataDTO> selectDeviceAllByBind(@Param("projectId") String projectId, @Param("companyId") String companyId);

    List<DeviceDataDTO> selectAllDeviceByProject(@Param("projectId") String projectId);

    List<DeviceVo> selectByDeviceParam(@Param("deviceQuery") DeviceQuery deviceQuery);

    List<KwsDevice> selectProjectByDeviceId(@Param("deviceId") String deviceId);

    /**
     * 查询项目绑定的设备
     *
     * @param projectId
     * @return
     */
    List<AffiliationDeviceVO> selectDeviceAllAndProjectData(@Param("projectId") String projectId);

    List<ThresholdSelectDTO> selectDeviceAllByProjectAndMountainId(@Param("projectId") String projectId, @Param("mountainId") String mountainId, @Param("status") List<Integer> status);

    int selectCountByProject(@Param("projectId") String projectId,@Param("companyId") String companyId);

    int selectDeviceOnlineRateCountByProject(@Param("projectId") String projectId,@Param("companyId") String companyId);

    List<Map<String, String>> selectListByModelType(@Param("modelType") String modelType,@Param("companyId") String companyId);

    KwsAlarmExportVO getDataByDeviceIdAndProjectId(@Param("deviceId") Long deviceId, @Param("projectId") String projectId);

    String getMaxDeviceCodeAndSplit(@Param("start") Integer start, @Param("length") Integer length);
}