package com.ruoyi.ss.equipment.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.ruoyi.ss.device.domain.vo.DeviceVO;
import com.ruoyi.ss.device.service.DeviceService;
import com.ruoyi.ss.equipment.domain.EquipmentVO;
import com.ruoyi.ss.equipment.service.IEquipmentAssembler;
import com.ruoyi.ss.feeRule.service.IFeeRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 设施组织器
 *
 * @author qzz
 * @date 2024-12-21
 */
@Service
public class EquipmentAssemblerImpl implements IEquipmentAssembler {

    @Autowired
    private DeviceService deviceService;

    @Autowired
    private IFeeRuleService feeRuleService;

    /**
     * 拼接设施下所有设备
     * @param equipment 房间对象
     */
    @Override
    public void assembleDeviceInfo(EquipmentVO equipment){
        if(equipment == null){
            return;
        }
        DeviceVO vo = deviceService.selectById(equipment.getDeviceId());
        if(ObjectUtil.isNotNull(vo)){
            equipment.setDevice(deviceService.selectById(equipment.getDeviceId()));
        }
    }

    @Override
    public void assembleDeviceInfo(List<EquipmentVO> equipment) {
        if(equipment.isEmpty()){
            return;
        }
        for (EquipmentVO equipmentVO : equipment){
            DeviceVO vo = deviceService.selectById(equipmentVO.getDeviceId());
            if(ObjectUtil.isNotNull(vo)){
                equipmentVO.setDevice(deviceService.selectById(equipmentVO.getDeviceId()));
            }
        }
    }


//    /**
//     * 拼接设施下所有套餐
//     * @param equipmentVO 房间对象
//     */
//    @Override
//    public void assembleRuleInfo(EquipmentVO equipmentVO) {
//        if(equipmentVO == null || equipmentVO.getRuleIds().isEmpty()){
//            return;
//        }
//        equipmentVO.setFeeRuleVOS(feeRuleService.selectEFeeRuleListByRuleIds(equipmentVO.getRuleIds()));
//    }

//    /**
//     * 拼接设施下所有套餐
//     * @param equipments 房间对象
//     */
//    @Override
//    public void assembleRuleInfo(List<EquipmentVO> equipments) {
//        if(equipments.isEmpty()){
//            return;
//        }
//        for (EquipmentVO equipmentVO : equipments){
//            equipmentVO.setFeeRuleVOS(feeRuleService.selectEFeeRuleListByRuleIds(equipmentVO.getRuleIds()));
//        }
//    }
}
