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

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.google.protobuf.ServiceException;
import com.yuchen.saas.park.api.entity.device.PmgBatSmartEquipment;
import com.yuchen.saas.park.api.vo.park.*;
import com.yuchen.saas.park.api.vo.park.energy.DeviceStatisticVO;
import com.yuchen.saas.park.api.vo.park.fire.DeviceGeneralVO;
import com.yuchen.saas.park.api.vo.park.security.DeviceListVO;
import com.yuchen.saas.park.api.vo.park.security.OnlineStatisticVO;
import org.nest.springwrap.core.mp.base.BaseService;
import org.nest.springwrap.core.mp.support.Query;

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

/**
 * @author 刘通
 * @date 2020/12/30 14:36
 */
public interface PmgBatSmartEquipmentService extends BaseService<PmgBatSmartEquipment> {
    DeviceAndParkingVo getDeviceAndParking(String productKey, String deviceName);
    PmgBatSmartEquipment getDetails(String productKey, String deviceName);
    PmgBatSmartEquipmentVo getDetailsByPkAndDN(String productKey, String deviceName);
    List<PmgBatSmartEquipment> getDevices(String productKey)
            throws ServiceException;

    List<PmgBatSmartEquipmentVo> getDetailAll();
    List<PmgBatSmartEquipmentVo> getDetailAll(String parkId);
    int getAllDevice();
    /**
     * 根据 productKey 获取设备列表
     * @param productKey 可以用逗号隔开
     * @return
     */
    public List<PmgBatSmartEquipment> getDevicesListByKey(String productKey);

    public List<PmgBatSmartEquipment> getDevicesListByKey(String parkId,String productKey);

    /**
     * 获取设备在离线
     * @return
     */
    public DeviceOnLineCountVo getOnLineCount();



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


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

    /**
     * 首页设备详情信息统一接口
     * @param parkId
     * @param buildingId
     * @param floorId
     * @return
     */
    Map<String,Object> getEquipmentAll(Long parkId,Long buildingId, Long floorId);

    /**
     *设备总数、在线设备数、告警设备数
     * @param parkId
     * @param buildingId
     * @param floorId
     * @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);

    /**
     * 设备分布
     * 园区场景传 parkId
     * 楼栋场景传 parkId、buildingId
     * 楼层场景传 parkId、buildingId、floorId
     * @param parkId
     * @param buildingId
     * @param floorId
     * @return
     */
    List<GetEnvironmentInfo> getDevicePart(Long parkId, Long buildingId, Long floorId);

    /**
     * 设备故障信息 四个指标 今日
     * @param parkId
     * @param buildingId
     * @param floorId
     * @return
     */
    EnvironmentVo getToDayInfo(Long parkId, Long buildingId, Long floorId);

    /**
     * 设备故障信息 四个指标 本月
     * @param parkId
     * @param buildingId
     * @param floorId
     * @return
     */
    EnvironmentVo getToMonthInfo(Long parkId, Long buildingId, Long floorId);

    /**
     * 设备故障趋势-今日
     * @param parkId
     * @param buildingId
     * @param floorId
     * @return
     */
    Map<String,List<GetEnvironmentInfo>> getToDayInfoTrend(Long parkId, Long buildingId, Long floorId);

    /**
     * 设备故障趋势-本月
     * @param parkId
     * @param buildingId
     * @param floorId
     * @return
     */
    Map<String,List<GetEnvironmentInfo>> getToMonthInfoTrend(Long parkId, Long buildingId, Long floorId);

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

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

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

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

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

    /**
     *根据categoryCode获取 设备总数、在线设备数、离线设备数、故障设备数 -大类
     * @param parkId 园区Id
     * @param buildingId 楼栋Id
     * @param floorId 楼层Id
     * @return DeviceOnLineCount
     */
    DeviceOnLineCount getDeviceCountByCategoryCode(Long parkId, Long buildingId, Long floorId,
                                                          String categoryCode);

    /**
     * 根据categoryCode获取设备分布
     * @param parkId
     * @param buildingId
     * @param floorId
     * @param categoryCode
     * @return
     */
    List<GetEnvironmentInfo> getDeviceDistributionByCategoryCode(Long parkId, Long buildingId, Long floorId,
                                                                   String categoryCode);

    /**
     * 查询设备
     * @param pmgBatSmartEquipment
     * @param query
     * @return
     */
    IPage<PmgEquipmentPropertyVO> searchDevice(PmgBatSmartEquipment pmgBatSmartEquipment, Query query);

    /*********************************火炬广场 Start*************************************/
    /**
     * 设备在线统计
     * @param parkId
     * @param categoryCode
     * @return
     */
    OnlineStatisticVO onlineStatistic(Long parkId, Integer categoryCode);

    /**
     * 设备列表查询
     * @param parkId
     * @param categoryCode
     * @param name
     * @return
     */
    List<DeviceListVO> deviceList(Long parkId, Integer categoryCode, String name);

    /**
     * 设备概况统计
     * @param parkId
     * @param categoryCode
     * @return
     */
    List<DeviceGeneralVO> deviceGeneral(Long parkId, Integer categoryCode);

    /**
     * 能耗设备统计
     * @param parkId
     * @return
     */
    DeviceStatisticVO energyDeviceStatisticVO(Long parkId);

    /**
     * 根据分类分页查询设备数据
     * @param parkId 园区ID
     * @param name 设备名称
     * @param categoryName 设备分类
     * @param isOnline 设备是否在线
     * @param current 当前页码
     * @param size 每页数量
     * @return
     */
    IPage<PmgBatSmartEquipment> getDeviceByCode(Long parkId, String name, String categoryName, Integer isOnline,
                                                Integer current, Integer size);

    /**
     * 根据分类查询设备分类统计数据
     * @param parkId 园区ID
     * @return
     */
    Map<String,Integer> getDeviceCountByCode(Long parkId);

    /**
     * 根据 productKey 分页查询设备数据
     * @param parkId 园区ID
     * @param name 设备名称
     * @param categoryName 设备分类
     * @param productKeys 设备 productKey 逗号分割
     * @param isOnline 设备是否在线(1:在线，0:离线)
     * @param current 当前页码
     * @param size 每页数量
     * @return
     */
    IPage<PmgBatSmartEquipment> getDeviceByProductKey(Long parkId, String name, String categoryName, String productKeys, Integer isOnline, Integer current, Integer size);

    /**
     * 获取设备在离线
     * @return
     */
    DeviceOnLineCountVo getOnLineCountByParkIdAndProductKey(Long parkId,String productKey);

    /**
     * 根据分类id获取所有的父级
     * @return
     */
    List getDeviceTreeByCategoryId(Long categoryId);

    /*********************************火炬广场 End*************************************/

    /**
     * 获取没有被绑定的人脸识别设备
     * @param idList
     * @param productKey
     * @return
     */
    List<PmgBatSmartEquipment> getListNotBindByIds(List<Long> idList,String productKey, String parkId);
}
