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.FhzgPlanPowerCut;
import com.hdkj.lt.bf.entity.dto.FhzgPlanTransferSchemeFinalSegmentCurrentDetailDTO;
import com.hdkj.lt.bf.mapper.FhzgPlanTransferSchemeFinalSegmentCurrentDetailMapper;
import com.hdkj.lt.bf.service.FhzgPlanTransferSchemeFinalSegmentCurrentDetailService;
import com.hdkj.lt.core.bizms.modle.po.plan.FhzgPlanTransferSchemeFinalSegmentCurrentDetail;
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 FhzgPlanTransferSchemeFinalSegmentCurrentDetailServiceImpl implements FhzgPlanTransferSchemeFinalSegmentCurrentDetailService {

    @Autowired
    FhzgPlanTransferSchemeFinalSegmentCurrentDetailMapper fhzgPlanTransferSchemeFinalSegmentCurrentDetailMapper;
    @Override
    public Page<FhzgPlanTransferSchemeFinalSegmentCurrentDetailDTO> getTransferSchemeFinalSegmentCurrentDetailByIdPage(FhzgPlanTransferSchemeFinalSegmentCurrentDetail fhzgPlanTransferSchemeFinalSegmentCurrentDetail) {
        if (Objects.isNull(fhzgPlanTransferSchemeFinalSegmentCurrentDetail.getSwitchingId())) {
            throw new BusinessException("switchingId为空");
        }
        if (Objects.isNull(fhzgPlanTransferSchemeFinalSegmentCurrentDetail.getPageNum())) {
            throw new BusinessException("分页页码为空");
        }
        if (Objects.isNull(fhzgPlanTransferSchemeFinalSegmentCurrentDetail.getPageSize())) {
            throw new BusinessException("分页长度为空");
        }
        Page page = new Page(fhzgPlanTransferSchemeFinalSegmentCurrentDetail.getPageNum(), fhzgPlanTransferSchemeFinalSegmentCurrentDetail.getPageSize());
        Page<FhzgPlanTransferSchemeFinalSegmentCurrentDetailDTO> fhzgPlanTransferSchemeFinalSegmentCurrentDetailDTOIPage = fhzgPlanTransferSchemeFinalSegmentCurrentDetailMapper.getTransferSchemeFinalSegmentCurrentDetailByIdPage(page,fhzgPlanTransferSchemeFinalSegmentCurrentDetail.getSwitchingId());
        return fhzgPlanTransferSchemeFinalSegmentCurrentDetailDTOIPage;
    }

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

    @Override
    public FhzgPlanPowerCut getPlanInfoBySwitchingId(Long switchingId) {
        FhzgPlanPowerCut fhzgPlanPowerCut = fhzgPlanTransferSchemeFinalSegmentCurrentDetailMapper.getPlanInfoBySwitchingId(switchingId);
        return fhzgPlanPowerCut;
    }

}
