package com.steering.pss.sale.order.bomGeneration.server;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

import com.steering.pss.sale.order.bomGeneration.daoImp.BomBLDaoImp;
import com.steering.pss.sale.order.bomGeneration.daoImp.BomFactoryDao;
import com.steering.pss.sale.order.bomGeneration.model.DesignBomBlEntity;
import com.steering.pss.sale.order.bomGeneration.model.DesignBomEntity;
import com.steering.pss.sale.order.bomGeneration.serverImp.BomBLImp;

public class BomBL implements BomBLImp {

	/**
	 * 备料BOM
	 * 
	 * @param con
	 * @param BLCode
	 *            备料码
	 * @param bomNo
	 *            产品物料码
	 * @throws SQLException
	 */
	public void generationBL(Connection con, String codeBL, String bomNo)
			throws SQLException {
		BomBLDaoImp bomBLDaoImp = BomFactoryDao.getBomBLDaoImp();
		List<DesignBomEntity> blBoms = bomBLDaoImp.getBLBom(con, codeBL);
		if (blBoms == null || blBoms.size() == 0) {
			return;
		}
		for (DesignBomEntity blBom : blBoms) {
			DesignBomBlEntity BLInfo = new DesignBomBlEntity();
			BLInfo.setBom(bomNo);
			BLInfo.setBomBl(blBom.getBom());
			BLInfo.setBlTyp(blBom.getBomTyp());
			BLInfo.setBlMaterialNo(blBom.getMaterialNo());
			BLInfo.setBlMaterialDesc(blBom.getMaterialDesc());
			if (bomBLDaoImp.checkBLInfo(con, BLInfo) == 0) {
				bomBLDaoImp.saveBLInfo(con, BLInfo);
			}
		}

	}
}
