package com.skr.mdm.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.skr.mdm.bean.bo.CompanyOnlineBO;
import com.skr.mdm.bean.bo.EquipmentBO;
import com.skr.mdm.bean.bo.EquipmentNameBO;
import com.skr.mdm.bean.dto.EquipmentExportDTO;
import com.skr.mdm.bean.qo.BaseDaoQO;
import com.skr.mdm.bean.qo.controller.SelectDeviceQO;
import com.skr.mdm.bean.qo.equipment.EquipmentPageQO;
import com.skr.mdm.bean.vo.DeviceDistributionVO;
import com.skr.mdm.bean.vo.TerminalVO;
import com.skr.mdm.bean.vo.equipment.ClientAdminEquipmentVO;
import com.skr.mdm.bean.vo.equipment.DeviceEquipmentInfoVO;
import com.skr.mdm.bean.vo.equipment.DeviceEquipmentVO;
import com.skr.mdm.bean.vo.equipment.EquipmentIssuedVO;
import com.skr.mdm.bean.vo.user.UserEquipmentVO;
import com.skr.mdm.entity.DeviceEquipmentDO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface DeviceEquipmentDao extends BaseMapper<DeviceEquipmentDO> {

	List<UserEquipmentVO> listUserEquipmentVO(@Param("userId") Integer userId);

	List<Integer> selectDeviceEquipmentIdByUserId(@Param("list") List<Integer> userIdList);

	DeviceEquipmentInfoVO getEquipmentInfo(@Param("equipmentId") Integer equipmentId);

	/**
	 * 根据设备id获取在线设备
	 * @param equipmentState
	 * @param list
	 * @return
	 */
	List<String> listOnlineChannelIdByIdList(@Param("equipmentState") Integer equipmentState, @Param("list") List<Integer> list);

	List<DeviceDistributionVO> queryDistributionList(SelectDeviceQO selectDeviceQO);

	/**
	 * 获取设备终端id
	 * @param id
	 * @return
	 */
	Integer getTidById(@Param("id") Integer id);

	/**
	 * 获取轨迹列表终端
	 *
	 * @param departmentId
	 * @return
	 */
	List<TerminalVO> listTerminalByDepartmentId(@Param("departmentId") Integer departmentId, @Param("userName") String userName, @Param("companyId") Integer companyId);

	List<Integer> listEquipmentIdByCompanyId(Integer companyId);

	List<Integer> listEquipmentIdByDepartmentIdList(@Param("list") List<Integer> departmentIdList);

	/**
	 * 设备列表
	 *
	 * @param equipmentPageQO
	 * @return
	 */
	List<DeviceEquipmentVO> listEquipment(EquipmentPageQO equipmentPageQO);

	/**
	 *  获取定位
	 * @param tid
	 * @return
	 */
	String getLocationByTid(Integer tid);

	/**
	 * 获取指定状态设备id
	 * @param equipmentIdList
	 * @param equipmentState 0 未激活 1 在线 2 在线（内网） 3离线
	 * @return
	 */
	List<Integer> selectInactiveDeviceIdList(@Param("list") List<Integer> equipmentIdList, @Param("equipmentState") Integer equipmentState);

	List<CompanyOnlineBO> selectCompanyOnlineList(@Param("nowTime") String nowTime);

	/**
	 * 获取用户id
	 * @param id
	 * @return
	 */
	Integer getUserIdById(@Param("id") Integer id);

	/**
	 * 获取公司id
	 * @param id
	 * @return
	 */
	Integer getCompanyIdById(@Param("id") Integer id);

	/**
	 * 管理员客户端设备列表
	 * @param companyId
	 * @param adminId
	 * @param searchType
	 * @param searchValue
	 * @return
	 */
	List<ClientAdminEquipmentVO> listClientAdminEquipment(@Param("companyId") Integer companyId, @Param("adminId") Integer adminId, @Param("searchType") Integer searchType, @Param("searchValue") String searchValue);

	/**
	 * 获取设备用户名
	 *
	 * @param equipmentIdList
	 * @return
	 */
	List<String> listEquipmentNameByIdList(@Param("list") List<Integer> equipmentIdList);

	List<EquipmentNameBO> listEquipmentNameBO(@Param("list") List<Integer> userIdList);

	Integer getEquipmentStateById(Integer id);

	List<EquipmentIssuedVO> listEquipmentIssuedVO(BaseDaoQO baseDaoQO);

	void insertBatch(@Param("list") List<DeviceEquipmentDO> list);

	List<EquipmentExportDTO> listEquipmentExportDTO(@Param("adminId") Integer adminId,
													@Param("companyId") Integer companyId,
													@Param("deptIdList") List<Integer> deptIdList);

	List<EquipmentBO> listEquipmentBO(@Param("companyId") Integer companyId);

}