package digital.laboratory.platform.reagent.service.impl;

import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import digital.laboratory.platform.reagent.entity.DetailsOfCentralized;
import digital.laboratory.platform.reagent.entity.ProcurementContent;
import digital.laboratory.platform.reagent.entity.ReagentConsumables;
import digital.laboratory.platform.reagent.mapper.ProcurementContentMapper;
import digital.laboratory.platform.reagent.service.DetailsOfCentralizedService;
import digital.laboratory.platform.reagent.service.ProcurementContentService;
import digital.laboratory.platform.reagent.service.ReagentConsumablesService;
import digital.laboratory.platform.reagent.vo.DetailsOfCentralizedVO;
import digital.laboratory.platform.reagent.vo.ProcurementContentVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (采购内容)服务实现类
 *
 * @author Zhang Xiaolong created at  2023-03-10
 * @describe (采购内容) 服务实现类
 */
@Service
public class ProcurementContentServiceImpl extends ServiceImpl<ProcurementContentMapper, ProcurementContent> implements ProcurementContentService {

    @Autowired
    private ProcurementContentService procurementContentService;

    @Autowired
    private DetailsOfCentralizedService detailsOfCentralizedService;
    @Autowired
    private ReagentConsumablesService reagentConsumablesService;

    @Override
    public List<ProcurementContentVO> getProcurementContentVOList(String purchasingPlanId) {

        List<ProcurementContentVO> procurementContentVOList = baseMapper.getProcurementContentVOList(purchasingPlanId);

        for (ProcurementContentVO procurementContentVO : procurementContentVOList) {

            List<DetailsOfCentralizedVO> detailsOfCentralizedVOList = detailsOfCentralizedService.getDetailsOfCentralizedList(procurementContentVO.getProcurementContentId());

            procurementContentVO.setDetailsOfCentralizedVOS(detailsOfCentralizedVOList);

            ReagentConsumables byId = reagentConsumablesService.getById(detailsOfCentralizedVOList.get(0).getReagentConsumableId());

            procurementContentVO.setBrand(byId.getBrand());

            procurementContentVO.setCategory(byId.getCategory());

            procurementContentVO.setSpecificationAndModel(byId.getSpecificationAndModel());

            procurementContentVO.setPurchaseCatalogueNumber(detailsOfCentralizedVOList.get(0).getPurchaseCatalogueNumber());
        }

        return procurementContentVOList;
    }
}
