package com.steering.pss.sale.order.craftDesign.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import CoreFS.SA08.CoreXmlSqlParsersFactory;

import com.steering.pss.sale.order.craftDesign.model.CraftOrdDesignMscBiltCEntity;
import com.steering.pss.sale.order.craftDesign.model.CraftOrdDesignMscBiltCPlEntity;
import com.steering.pss.sale.order.craftDesign.model.CraftOrdDesignMscBiltEntity;
import com.steering.pss.sale.order.craftDesign.model.CraftOrdDesignMscBiltPlEntity;
import com.steering.pss.sale.order.craftDesign.model.CraftOrdDesignMscGzGgEntity;
import com.steering.pss.sale.order.craftDesign.model.CraftOrdDesignMscGzGgPlEntity;
import com.steering.pss.sale.order.craftDesign.model.CraftOrdDesignMscPlGxPrlEntity;

/**
 * 保存制程向下的规格与产线类
 * 
 * @author Administrator
 * 
 */
public class ProDucSaveDao {
	/**
	 * 保存质量设计-轧管规格-适用产线
	 * 
	 * @param con
	 *            连接字符
	 * @param specInLine
	 *            -轧管规格-适用产线类
	 * @throws SQLException
	 */
	public void saveRollLine(Connection con,
			CraftOrdDesignMscGzGgPlEntity specInLine) throws SQLException {
		String sql = CoreXmlSqlParsersFactory
				.getSql("ProDucSaveDao.saveSpec");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, specInLine.getDesginKey());
		ps.setObject(2, specInLine.getMscPline());
		ps.setObject(3, specInLine.getSpecCode());
		ps.setObject(4, specInLine.getPlineCode());
		ps.setObject(5, specInLine.getPlineName());
		ps.setObject(6, specInLine.getPrdLen());
		ps.setObject(7, specInLine.getLossRate());
		ps.executeUpdate();
		ps.close();
	}

	/**
	 * 质量设计-锻造-适用产线
	 * 
	 * @param con
	 *            连接字符
	 * @param specInLine
	 *            -轧管规格-适用产线类
	 * @throws SQLException
	 */
	public void saveBiltLine(Connection con,
			CraftOrdDesignMscBiltPlEntity blankInLine) throws SQLException {
		String sql = CoreXmlSqlParsersFactory
				.getSql("ProDucSaveDao.saveBlank");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, blankInLine.getDesginKey());
		ps.setObject(2, blankInLine.getMscPline());
		ps.setObject(3, blankInLine.getBSpecCode());
		ps.setObject(4, blankInLine.getPlineCode());
		ps.setObject(5, blankInLine.getPlineName());
		ps.executeUpdate();
		ps.close();
	}

	/**
	 * 质量设计-铸造规格（连铸/模铸）-适用产线
	 * 
	 * @param con
	 *            连接字符
	 * @param specInLine
	 *            -轧管规格-适用产线类
	 * @throws SQLException
	 */
	public void saveBlitcLine(Connection con,
			CraftOrdDesignMscBiltCPlEntity blitInLine) throws SQLException {
		String sql = CoreXmlSqlParsersFactory
				.getSql("ProDucSaveDao.saveBlits");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, blitInLine.getDesginKey());
		ps.setObject(2, blitInLine.getMscPline());
		ps.setObject(3, blitInLine.getCSpecCode());
		ps.setObject(4, blitInLine.getPlineCode());
		ps.setObject(5, blitInLine.getPlineName());
		ps.executeUpdate();
		ps.close();
	}

	/**
	 * 质量设计-适用产线
	 * 
	 * @param con
	 *            连接字符
	 * @param plgxPrlEntity
	 * @throws SQLException
	 */
	public void saveProLine(Connection con,
			CraftOrdDesignMscPlGxPrlEntity plgxPrlEntity) throws SQLException {
		String sql = CoreXmlSqlParsersFactory
				.getSql("ProDucSaveDao.saveProLine");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, plgxPrlEntity.getDesginKey());
		ps.setObject(2, plgxPrlEntity.getMscPline());
		ps.setObject(3, plgxPrlEntity.getBacklogSeq());
		ps.setObject(4, plgxPrlEntity.getProcessCode());
		ps.setObject(5, plgxPrlEntity.getPlineCode());
		ps.setObject(6, plgxPrlEntity.getPlineName());
		ps.setObject(7, plgxPrlEntity.getWellCode());
		ps.setObject(8, plgxPrlEntity.getWellName());
		ps.setObject(9, plgxPrlEntity.getWarnFl());
		ps.setObject(10, plgxPrlEntity.getWarnDesc());
		ps.setObject(11, plgxPrlEntity.getIdentFlag());
		ps.executeUpdate();
		ps.close();
	}

	/**
	 * 保存铸造规格
	 * 
	 * @param con
	 *            连接字符串
	 * @param designMscBiltCEntity
	 *            实体类
	 * @throws SQLException
	 */
	public void saveBiltcSpec(Connection con,
			CraftOrdDesignMscBiltCEntity BiltSpecs) throws SQLException {
		String sql = CoreXmlSqlParsersFactory
				.getSql("ProDucSaveDao.saveBiltCSpec");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, BiltSpecs.getDesginKey());
		ps.setObject(2, BiltSpecs.getMscPline());
		ps.setObject(3, BiltSpecs.getSpecCode());
		ps.setObject(4, BiltSpecs.getBSpecCode());
		ps.setObject(5, BiltSpecs.getCSpecCode());
		ps.setObject(6, BiltSpecs.getCSpecName());
		ps.setObject(7, BiltSpecs.getSpecCode() + BiltSpecs.getBSpecCode()
				+ BiltSpecs.getCSpecCode());
		ps.executeUpdate();
		ps.close();
	}

	/**
	 * 保存锻造规格
	 * 
	 * @param con
	 *            连接字符串
	 * @param designMscBiltEntity
	 *            实体类
	 * @throws SQLException
	 */
	public void savebiltSpec(Connection con,
			CraftOrdDesignMscBiltEntity designMscBiltEntity)
			throws SQLException {
		String sql = CoreXmlSqlParsersFactory
				.getSql("ProDucSaveDao.saveBlankSection");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, designMscBiltEntity.getDesginKey());
		ps.setObject(2, designMscBiltEntity.getMscPline());
		ps.setObject(3, designMscBiltEntity.getSpecCode());
		ps.setObject(4, designMscBiltEntity.getBSpecCode());
		ps.setObject(5, designMscBiltEntity.getBSpecName());
		ps.executeUpdate();
		ps.close();
	}

	/**
	 * 保存轧管规格
	 * 
	 * @param con
	 *            连接字符串
	 * @param designMscGzGgEntity
	 *            实体类
	 * @throws SQLException
	 */
	public void saveRollSpec(Connection con,
			CraftOrdDesignMscGzGgEntity designMscGzGgEntity)
			throws SQLException {
		String sql = CoreXmlSqlParsersFactory
				.getSql("ProDucSaveDao.savePipeRoll");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, designMscGzGgEntity.getDesginKey());
		ps.setObject(2, designMscGzGgEntity.getMscPline());
		ps.setObject(3, designMscGzGgEntity.getGradecode());
		ps.setObject(4, designMscGzGgEntity.getGradename());
		ps.setObject(5, designMscGzGgEntity.getSpecCode());
		ps.setObject(6, designMscGzGgEntity.getSpecName());
		ps.setObject(7, designMscGzGgEntity.getDimater());
		ps.setObject(8, designMscGzGgEntity.getHeight());
		ps.executeUpdate();
		ps.close();
	}

}
