package com.sw.mes.yb.plan.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sw.mes.core.base.BaseServiceImpl;
import com.sw.mes.yb.plan.dao.PlanProductionOrderBomDao;
import com.sw.mes.yb.plan.entity.PlanProductionOrderBom;
import com.sw.mes.yb.plan.service.PlanProductionOrderBomService;

import lombok.extern.slf4j.Slf4j;

/**
 * 订单Bom信息Service业务层处理
 * 
 * @author liru
 * @date 2023-12-31
 */
@Slf4j
@Service
@Transactional
public class PlanProductionOrderBomServiceImpl extends BaseServiceImpl<PlanProductionOrderBom> implements PlanProductionOrderBomService
{
    private PlanProductionOrderBomDao dao;

    @Autowired
    public void setDao(PlanProductionOrderBomDao dao) {
        super.setBaseDao(dao);
        this.dao=dao;
    }

    @Override
    public void deleteByPlanProductionOrderId(Long id) {
        dao.deleteByPlanProductionOrderId(id);
    }
    
    @Override
	public PlanProductionOrderBom findByOrderIdAndMatnr(Long orderId, String matnr) {
		List<PlanProductionOrderBom> boms = dao.findByOrderIdAndMatnr(orderId, matnr);
		if(boms.size()>0) {
			return boms.get(0);
		}
		return null;
	}

    @Override
    public PlanProductionOrderBom findByPlanProductionOrderId(Long id) {
        return dao.findByPlanProductionOrderId(id);
    }
}
