package com.yuchen.saas.park.service.mapper;

import com.baomidou.mybatisplus.annotation.SqlParser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuchen.saas.park.api.entity.device.PmgBatSmartEquipment;
import com.yuchen.saas.park.api.vo.park.*;
import org.nest.springwrap.core.datascope.annotation.DataAuth;
import org.nest.springwrap.core.datascope.enums.DataScopeEnum;

import java.util.List;

/**
 * @author 刘通
 * @date 2020/12/30 14:32
 */
public interface PmgBatSmartEquipmentMapper
        extends BaseMapper<PmgBatSmartEquipment> {
	/**
	 * 根据 productKey 和 deviceName 获取抓拍机设备信息+停车场信息+出入口信息+车道信息
	 * @param productKey
	 * @param deviceName
	 * @return
	 */
	DeviceAndParkingVo getDeviceAndParking(String productKey, String deviceName);
    @DataAuth(type = DataScopeEnum.OWN_DEPT_CHILD)
    PmgBatSmartEquipment getDetails(String productKey, String deviceName);
    @DataAuth(type = DataScopeEnum.OWN_DEPT_CHILD)
	PmgBatSmartEquipmentVo getDetailsByPkAndDN(String productKey, String deviceName);
    @DataAuth(type = DataScopeEnum.OWN_DEPT_CHILD)
    List<PmgBatSmartEquipment> getDevices(String productKey);
    List<PmgBatSmartEquipmentVo> getDetailAll();

	/**
	 *设备总数、在线设备数、告警设备数 老的接口
	 * @return
	 */
	@DataAuth(type = DataScopeEnum.OWN_DEPT_CHILD)
	DeviceOnLineCountVo getOnLineCount();

	/**
	 * 设备总数、在线设备数、告警设备数  新接口
	 * @param parkId
	 * @return
	 */
	DeviceOnLineCountVo getOnLineCountNow(String parkId);


	List<PmgBatSmartEquipmentVo> getDetailAllByParkId(String parkId);

	/**
	 * 通过设备类型获取设备的productKey列表
	 * @param categoryCode
	 * @return
	 */
	List<String> getProductKeyByCategoryCode(String categoryCode, Long parkId, Long buildingId, Long floorId, Long roomId);


	/***************************** 3d/bi start **********************************/


	/**
	 * 设备总数、在线设备数、告警设备数
	 * @param parkId
	 * @return
	 */
	DeviceOnLineCountVo getByOnLineCount(Long parkId,Long buildingId, Long floorId);


	/**
	 *设备分类及数量
	 * @param parkId
	 * @param buildingId
	 * @param floorId
	 * @return
	 */
	List<GetEnvironmentInfo> getGroupType(Long parkId, Long buildingId, Long floorId);


	/**
	 * 设备分布-园区场景
	 * @param parkId
	 * @return
	 */
	List<GetEnvironmentInfo> getParkEquipFound(Long parkId);

	/**
	 * 设备分布-楼栋场景
	 * @param parkId
	 * @param buildingId
	 * @return
	 */
	List<GetEnvironmentInfo> getBuildingEquipFound(Long parkId, Long buildingId);

	/**
	 * 设备分布-楼层场景
	 * @param parkId
	 * @param buildingId
	 * @param floorId
	 * @return
	 */
	List<GetEnvironmentInfo> getFloorEquipFound(Long parkId, Long buildingId, Long floorId);

	/**
	 * 设备列表
	 * @param parkId
	 * @param buildingId
	 * @param floorId
	 * @return
	 */
	List<PmgBatSmartEquipment> getEquipInfo(Long parkId,Long buildingId,Long floorId);

	/**
	 *设备总数、在线设备数、告警设备数(只查询环境设备)
	 * @param parkId
	 * @param buildingId
	 * @param floorId
	 * @return
	 */
	DeviceOnLineCountVo getEnvironmentDeviceCount(Long parkId, Long buildingId, Long floorId);

	/**
	 * 根据categoryCode查看设备分类及数量
	 * @param parkId
	 * @param buildingId
	 * @param floorId
	 * @param categoryCode 分类code
	 * @return
	 */
	List<GetEnvironmentInfo> getEnvironmentGroupCount(Long parkId, Long buildingId, Long floorId, String categoryCode);


	/**
	 * 根据categoryCode查看设备分类及详情
	 * @param parkId
	 * @param buildingId
	 * @param floorId
	 * @param categoryCode
	 * @return
	 */
	List<GetEnvironmentCountInfoVO> getEnvironmentGroupCountInfo(Long parkId, Long buildingId, Long floorId, String categoryCode);


	/**
	 * 设备关联点位信息查询
	 * @param parkId
	 * @return
	 */
	List<PmgBatSmartEquipmentPointVo> selectEquipmentPoint(Long parkId);

	Page<PmgEquipmentPropertyVO> searchDevice(Page<PmgEquipmentPropertyVO> page, PmgBatSmartEquipment equipment);

	/**
	 * 根据园区和产品key统计离线和在线的设备数量
	 * @param parkId
	 * @param productKey
	 * @return {@link DeviceOnLineCountVo}
	 */
	DeviceOnLineCountVo getOnLineCountByParkIdAndProductKey(Long parkId,String productKey);

	/**
	 * 根据whereSql进行查询
	 * @param whereSql
	 * @return
	 */
	List<PmgBatSmartEquipment> selectDeviceByWhereSql(String whereSql);

	/**
	 * 根据分类id获取所有的父级
	 * @return
	 */
	@SqlParser(filter=true)
	List<Long> getDeviceTreeByCategoryId(Long categoryId);

}
