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

import com.yuchen.saas.park.api.entity.park.PmgBatPointLocationInfo;
import com.yuchen.saas.park.api.vo.park.PmgEquipmentPointVo;
import com.yuchen.saas.park.service.mapper.PmgBatPointLocationInfoMapper;
import com.yuchen.saas.park.service.service.PmgBatPointLocationInfoService;
import org.nest.springwrap.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * (PmgBatPointLocationInfo)表服务实现类
 * @author 任业政
 * @since 2021-09-13 11:36:15
 */
//@Service("pmgBatPointLocationInfoService")
@Service("pmgBatPointLocationInfoServiceImpl")
public class PmgBatPointLocationInfoServiceImpl extends BaseServiceImpl<PmgBatPointLocationInfoMapper, PmgBatPointLocationInfo> implements PmgBatPointLocationInfoService {
    
    @Resource
    private PmgBatPointLocationInfoMapper pmgBatPointLocationInfoMapper;

    @Override
    public List<PmgEquipmentPointVo> selectByAllEquipmentPoint(Long parkId, Long buildingId, Long floorId, Long roomId) {
        return pmgBatPointLocationInfoMapper.selectByAllEquipmentPoint(parkId,buildingId,floorId,roomId);
    }

    @Override
    public List<PmgBatPointLocationInfo> selectAllLocationPoint(Long parkId, Long buildingId, Long floorId, Long roomId) {
        return pmgBatPointLocationInfoMapper.selectAllLocationPoint(parkId,buildingId,floorId,roomId);
    }
    @Override
    public List<String> getProductKeyList(Long parkId, Long buildingId, Long floorId, Long roomId,
                                          String categoryCode) {
        // 获取对应场景的所有设备
        List<PmgEquipmentPointVo> list = selectByAllEquipmentPoint(parkId, buildingId, floorId, null);
        // 根据categoryCode筛选得到对应设备productKey集合
        List<String> productKeyList =
                list.stream().filter(p -> categoryCode.equals(p.getCategoryCode()))
                        .map(PmgEquipmentPointVo::getProductKey).distinct().collect(Collectors.toList());
        return productKeyList;
    }

    @Override
    public List<String> getProductNameList(Long parkId, Long buildingId, Long floorId, Long roomId,
                                           String categoryCode) {

        // 获取对应场景的所有设备
        List<PmgEquipmentPointVo> list = selectByAllEquipmentPoint(parkId, buildingId, floorId, null);
        // 根据categoryCode筛选得到对应设备productName集合
        List<String> productNameList =
                list.stream().filter(p -> categoryCode.equals(p.getCategoryCode()))
                        .map(PmgEquipmentPointVo::getDeviceName).distinct().collect(Collectors.toList());
        return productNameList;
    }
}