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

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hdkj.lt.base.exception.BusinessException;
import com.hdkj.lt.bf.entity.FhzgPlanTransferSchemeTransferSituation;
import com.hdkj.lt.bf.entity.dto.FhzgPlanTransferSchemeTransferSituationDTO;
import com.hdkj.lt.core.bizms.modle.dto.TransferSchemeEvaluationReqDTO;
import com.hdkj.lt.bf.mapper.FhzgPlanTransferSchemeTransferSituationMapper;
import com.hdkj.lt.bf.service.IFhzgPlanTransferSchemeTransferSituationService;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * <p>
 * 转供方案转供情况明细 服务实现类
 * </p>
 *
 * @author luorui
 * @since 2025-05-23
 */
@Service
public class FhzgPlanTransferSchemeTransferSituationServiceImpl extends ServiceImpl<FhzgPlanTransferSchemeTransferSituationMapper, FhzgPlanTransferSchemeTransferSituation> implements IFhzgPlanTransferSchemeTransferSituationService {

    @Override
    public List<FhzgPlanTransferSchemeTransferSituationDTO> getTransferSchemeSituationById(TransferSchemeEvaluationReqDTO transferSchemeEvaluationReqDTO) {
        Long schemeId = transferSchemeEvaluationReqDTO.getSchemeId();
        if(Objects.isNull(schemeId)){
            throw new BusinessException("方案编码为空");
        }
        Map<String, Object> columnMap = new HashMap<>();
        columnMap.put("scheme_id",schemeId);
        List<FhzgPlanTransferSchemeTransferSituation> result = baseMapper.selectByMap(columnMap);
        List<FhzgPlanTransferSchemeTransferSituationDTO> fhzgPlanTransferSchemeTransferSituationDTOS = new ArrayList<>();
        if(CollUtil.isNotEmpty(result)){
            result.forEach(e->{
                FhzgPlanTransferSchemeTransferSituationDTO fhzgPlanTransferSchemeTransferSituationDTO = new FhzgPlanTransferSchemeTransferSituationDTO();
                BeanUtil.copyProperties(e,fhzgPlanTransferSchemeTransferSituationDTO);
                fhzgPlanTransferSchemeTransferSituationDTOS.add(fhzgPlanTransferSchemeTransferSituationDTO);
            });
        }
        return fhzgPlanTransferSchemeTransferSituationDTOS;
    }
}
