package com.steering.pss.sale.order.qualityDesign.Dao.idao;

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

import CoreFS.SA08.CoreXmlSqlParsersFactory;

import com.steering.pss.sale.order.model.DesignMscBiltCEntity;
import com.steering.pss.sale.order.model.DesignMscBiltCPlEntity;
import com.steering.pss.sale.order.model.DesignMscBiltEntity;
import com.steering.pss.sale.order.model.DesignMscBiltPlEntity;
import com.steering.pss.sale.order.model.DesignMscGzGgEntity;
import com.steering.pss.sale.order.model.DesignMscGzGgPlEntity;
import com.steering.pss.sale.order.model.DesignMscPlGxPrlEntity;
import com.steering.pss.sale.order.model.DesignMscPlPrcEntity;
import com.steering.pss.sale.order.qualityDesign.Dao.imp.CreateSpecLineDaoImp;

public class ICreateSpecLineDao implements CreateSpecLineDaoImp {

	/**
	 * 保存质量设计-轧管规格-适用产线
	 * 
	 * @param con
	 *            连接字符
	 * @param specInLine
	 *            -轧管规格-适用产线类
	 * @throws SQLException
	 */
	public void saveSpec(Connection con, DesignMscGzGgPlEntity specInLine)
			throws SQLException {
		String sql = CoreXmlSqlParsersFactory
				.getSql("ICreateSpecLineDao.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 saveBlank(Connection con, DesignMscBiltPlEntity blankInLine)
			throws SQLException {
		String sql = CoreXmlSqlParsersFactory
				.getSql("ICreateSpecLineDao.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 saveBlits(Connection con, DesignMscBiltCPlEntity blitInLine)
			throws SQLException {
		String sql = CoreXmlSqlParsersFactory
				.getSql("ICreateSpecLineDao.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, DesignMscPlGxPrlEntity plgxPrlEntity)
			throws SQLException {
		String sql = CoreXmlSqlParsersFactory
				.getSql("ICreateSpecLineDao.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 saveStockSpecific(Connection con, DesignMscBiltCEntity BiltSpecs)
			throws SQLException {
		String sql = CoreXmlSqlParsersFactory
				.getSql("ICreateSpecLineDao.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 saveBlankSection(Connection con,
			DesignMscBiltEntity designMscBiltEntity) throws SQLException {
		String sql = CoreXmlSqlParsersFactory
				.getSql("ICreateSpecLineDao.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 savePipeRoll(Connection con,
			DesignMscGzGgEntity designMscGzGgEntity) throws SQLException {
		String sql = CoreXmlSqlParsersFactory
				.getSql("ICreateSpecLineDao.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();
	}

	/**
	 * 保存内控标准
	 * 
	 * @param con
	 *            连接字符串
	 * @param inner
	 *            内控标准
	 * @throws SQLException
	 */
	public void saveInnerStd(Connection con, DesignMscPlPrcEntity inner)
			throws SQLException {

		String sql = CoreXmlSqlParsersFactory
				.getSql("ICreateSpecLineDao.saveInnerStd");
		sql = sql.replaceAll("#DESGIN_KEY#", inner.getDesginKey());
		sql = sql.replaceAll("#MSC_PLINE#", inner.getMscPline());
		sql = sql.replaceAll("#WHOLE_BACKLOG#", inner.getWholeBacklog());
		sql = sql.replaceAll("#WHOLE_BACKLOG_DESC#",
				inner.getWholeBacklogDesc());
		sql = sql.replaceAll("#BACKLOG_SEQ#", inner.getBacklogSeq());
		sql = sql.replaceAll("#PROCESS_CODE#", inner.getProcessCode());
		sql = sql.replaceAll("#PROCESS_DESC#", inner.getProcessDesc());
		sql = sql.replaceAll("#PROCESS_SEQ#", inner.getProcessSeq());
		sql = sql.replaceAll("#PROCESS_CODE_C#", inner.getProcessCodeC());
		sql = sql.replaceAll("#PROCESS_DESC_C#", inner.getProcessDescC());
		sql = sql.replaceAll("#MINUTE_PRODUCT#", inner.getMinuteProduct());
		sql = sql.replaceAll("#MINUTE_PRODUCT_OUT#",
				inner.getMinuteProductOut());
		sql = sql.replaceAll("#MINUTE_WAITE#", inner.getMinuteWaite());
		sql = sql.replaceAll("#MINUTE_WAITE_OUT#", inner.getMinuteWaiteOut());
		sql = sql.replaceAll("#BATCH_WAITE#", inner.getBatchWaite());
		sql = sql.replaceAll("#BATCH_WAITE_OUT#", inner.getBatchWaiteOut());
		sql = sql.replaceAll("#CIC#", inner.getCic());
		sql = sql.replaceAll("#PIC#", inner.getPic());
		sql = sql.replaceAll("#SIC#", inner.getSic());
		sql = sql.replaceAll("#DIC#", inner.getDic());
		sql = sql.replaceAll("#WIC#", inner.getWic());
		sql = sql.replaceAll("#GIC#", inner.getGic());
		sql = sql.replaceAll("#MEMO#", inner.getMemo());
		PreparedStatement ps = con.prepareStatement(sql);
		ps.executeUpdate();
		ps.close();
	}

}
