package com.hdkj.lt.bf.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hdkj.lt.base.exception.BusinessException;
import com.hdkj.lt.bf.entity.dto.FaultTransferSchemeOppositeLineLoadFactorDTO;
import com.hdkj.lt.bf.entity.dto.FhzgFaultTransferSchemeOppositeLineLoadFactorDTO;
import com.hdkj.lt.bf.mapper.FaultTransferSchemeOppositeLineLoadFactorMapper;
import com.hdkj.lt.bf.service.IFaultTransferSchemeOppositeLineLoadFactorService;
import com.hdkj.lt.core.bizms.modle.po.fault.FaultTransferSchemeOppositeLineLoadFactor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;
/**
 * <p>
 * 故障停电转供方案对侧线路负载率明细表 服务实现类
 * </p>
 *
 * @author luorui
 * @since 2025-05-29
 */
@Service
public class FaultTransferSchemeOppositeLineLoadFactorServiceImpl extends ServiceImpl<FaultTransferSchemeOppositeLineLoadFactorMapper, FaultTransferSchemeOppositeLineLoadFactor> implements IFaultTransferSchemeOppositeLineLoadFactorService {
    @Autowired
    FaultTransferSchemeOppositeLineLoadFactorMapper mapper;



    /**
     * @author luorui
     * @date 2025/5/29 21:26
     * @discription 查询对侧线路情况
     **/
    @Override
    public List<FaultTransferSchemeOppositeLineLoadFactorDTO> getTransferSchemeOppositeLineLoadFactorBySchemeId(FaultTransferSchemeOppositeLineLoadFactor fhzgFaultTransferSchemeOppositeLineLoadFactor) {
        if (fhzgFaultTransferSchemeOppositeLineLoadFactor.getSchemeId() == null) {
            throw new BusinessException("方案编码为空schemeId");
        }
        return baseMapper.getTransferSchemeOppositeLineLoadFactorBySchemeId(fhzgFaultTransferSchemeOppositeLineLoadFactor);
    }

    @Override
    public Page<FhzgFaultTransferSchemeOppositeLineLoadFactorDTO> getTransferSchemeOppositeLineLoadFactorByIdPage(FaultTransferSchemeOppositeLineLoadFactor faultTransferSchemeOppositeLineLoadFactor) {
        if (Objects.isNull(faultTransferSchemeOppositeLineLoadFactor.getId())) {
            throw new BusinessException("组合方案id为空");
        }
        if (Objects.isNull(faultTransferSchemeOppositeLineLoadFactor.getPageNum())) {
            throw new BusinessException("分页页码为空");
        }
        if (Objects.isNull(faultTransferSchemeOppositeLineLoadFactor.getPageSize())) {
            throw new BusinessException("分页长度为空");
        }
        Page<FaultTransferSchemeOppositeLineLoadFactor> page = new Page(faultTransferSchemeOppositeLineLoadFactor.getPageNum(), faultTransferSchemeOppositeLineLoadFactor.getPageSize());
        Page<FhzgFaultTransferSchemeOppositeLineLoadFactorDTO> fhzgPlanTransferSchemeOppositeLineLoadFactorDTOList = mapper.getTransferSchemeOppositeLineLoadFactorByIdPage(page, faultTransferSchemeOppositeLineLoadFactor.getId());
        return fhzgPlanTransferSchemeOppositeLineLoadFactorDTOList;
    }}
