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

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hdkj.lt.base.exception.BusinessException;
import com.hdkj.lt.bf.entity.dto.FhzgFaultTransferSchemeFinalSegmentCurrentDetailDTO;
import com.hdkj.lt.bf.mapper.FhzgFaultTransferSchemeFinalSegmentCurrentDetailMapper;
import com.hdkj.lt.bf.service.FhzgFaultTransferSchemeFinalSegmentCurrentDetailService;
import com.hdkj.lt.core.bizms.modle.po.fault.FaultPowerCut;
import com.hdkj.lt.core.bizms.modle.po.plan.FhzgFaultTransferSchemeFinalSegmentCurrentDetail;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

/**
 * @author luorui
 * @date 2025/5/16 20:13
 * 终态安全校验导线电流明细查询
 */
@Service
@Slf4j
public class FhzgFaultTransferSchemeFinalSegmentCurrentDetailServiceImpl implements FhzgFaultTransferSchemeFinalSegmentCurrentDetailService {

    @Autowired
    FhzgFaultTransferSchemeFinalSegmentCurrentDetailMapper faultTransferSchemeFinalSegmentCurrentDetailMapper;


    @Override
    public Page<FhzgFaultTransferSchemeFinalSegmentCurrentDetailDTO> getTransferSchemeFinalSegmentCurrentDetailByIdPage(FhzgFaultTransferSchemeFinalSegmentCurrentDetail faultTransferSchemeFinalSegmentCurrentDetail) {
        if (Objects.isNull(faultTransferSchemeFinalSegmentCurrentDetail.getSwitchingId())) {
            throw new BusinessException("switchingId为空");
        }
        if (Objects.isNull(faultTransferSchemeFinalSegmentCurrentDetail.getPageNum())) {
            throw new BusinessException("分页页码为空");
        }
        if (Objects.isNull(faultTransferSchemeFinalSegmentCurrentDetail.getPageSize())) {
            throw new BusinessException("分页长度为空");
        }
        Page page = new Page(faultTransferSchemeFinalSegmentCurrentDetail.getPageNum(), faultTransferSchemeFinalSegmentCurrentDetail.getPageSize());
        Page<FhzgFaultTransferSchemeFinalSegmentCurrentDetailDTO> faultTransferSchemeFinalSegmentCurrentDetailDTOPage = faultTransferSchemeFinalSegmentCurrentDetailMapper.getTransferSchemeFinalSegmentCurrentDetailByIdPage(page,faultTransferSchemeFinalSegmentCurrentDetail.getSwitchingId());
        return faultTransferSchemeFinalSegmentCurrentDetailDTOPage;
    }

    @Override
    public List<Map<String, Object>> getListBySwitchingId(Long switchingId) {
        List<Map<String, Object>> dataList = faultTransferSchemeFinalSegmentCurrentDetailMapper.getListBySwitchingId(switchingId);
        return dataList;
    }

    @Override
    public FaultPowerCut getFaultInfoBySwitchingId(Long switchingId) {
        FaultPowerCut faultPowerCut = faultTransferSchemeFinalSegmentCurrentDetailMapper.getFaultInfoBySwitchingId(switchingId);
        return faultPowerCut;
    }


}
