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

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

import com.steering.pss.sale.order.bomGeneration.daoImp.BomCheckDaoImp;
import com.steering.pss.sale.order.bomGeneration.model.DesignBomEntity;

import CoreFS.SA08.CoreXmlSqlParsersFactory;

public class IBomCheckDao implements BomCheckDaoImp {
	/**
	 * 验证基础物料-电炉是否存在相同记录
	 * 
	 * @param con
	 *            连接字符串
	 * @param inMaterialNo
	 *            投入物料编码
	 * @param outMaterialNo
	 *            产出物料编码
	 * @return int
	 * @throws SQLException
	 */
	public int checkBaseMaterialA(Connection con, String inMaterialNo,
			String outMaterialNo) throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkBaseMaterialA");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, inMaterialNo);
		ps.setObject(2, outMaterialNo);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	/**
	 * 验证基础物料-铸造是否存在相同记录
	 * 
	 * @param con
	 *            连接字符串
	 * @param inMaterialNo
	 *            投入物料编码
	 * @param outMaterialNo
	 *            产出物料编码
	 * @return int
	 * @throws SQLException
	 */
	public int checkBaseMaterialB(Connection con, String inMaterialNo,
			String outMaterialNo) throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkBaseMaterialB");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, inMaterialNo);
		ps.setObject(2, outMaterialNo);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	/**
	 * 验证基础物料-锻造是否存在相同记录
	 * 
	 * @param con
	 *            连接字符串
	 * @param inMaterialNo
	 *            投入物料编码
	 * @param outMaterialNo
	 *            产出物料编码
	 * @return int
	 * @throws SQLException
	 */
	public int checkBaseMaterialC(Connection con, String inMaterialNo,
			String outMaterialNo) throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkBaseMaterialC");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, inMaterialNo);
		ps.setObject(2, outMaterialNo);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	/**
	 * 验证基础物料-轧管是否存在相同记录
	 * 
	 * @param con
	 *            连接字符串
	 * @param inMaterialNo
	 *            投入物料编码
	 * @param outMaterialNo
	 *            产出物料编码
	 * @return int
	 * @throws SQLException
	 */
	public int checkBaseMaterialD(Connection con, String inMaterialNo,
			String outMaterialNo) throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkBaseMaterialD");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, inMaterialNo);
		ps.setObject(2, outMaterialNo);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	/**
	 * 验证基础物料-墩拔扩是否存在相同记录
	 * 
	 * @param con
	 *            连接字符串
	 * @param inMaterialNo
	 *            投入物料编码
	 * @param outMaterialNo
	 *            产出物料编码
	 * @return int
	 * @throws SQLException
	 */
	public int checkBaseMaterialE(Connection con, String inMaterialNo,
			String outMaterialNo) throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkBaseMaterialE");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, inMaterialNo);
		ps.setObject(2, outMaterialNo);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	/**
	 * 验证基础物料-热处理是否存在相同记录
	 * 
	 * @param con
	 *            连接字符串
	 * @param inMaterialNo
	 *            投入物料编码
	 * @param outMaterialNo
	 *            产出物料编码
	 * @return int
	 * @throws SQLException
	 */
	public int checkBaseMaterialF(Connection con, String inMaterialNo,
			String outMaterialNo) throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkBaseMaterialF");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, inMaterialNo);
		ps.setObject(2, outMaterialNo);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	/**
	 * 验证基础物料-加工产出是否存在相同记录
	 * 
	 * @param con
	 *            连接字符串
	 * @param inMaterialNo
	 *            投入物料编码
	 * @param outMaterialNo
	 *            产出物料编码
	 * @return int
	 * @throws SQLException
	 */
	public int checkBaseMaterialI(Connection con, String inMaterialSet,
			String outMaterialNo) throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkBaseMaterialI");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, inMaterialSet);
		ps.setObject(2, outMaterialNo);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	/**
	 * 验证基础物料-加工投入是否存在相同记录
	 * 
	 * @param con
	 *            连接字符串
	 * @param inMaterialNo
	 *            投入物料编码
	 * @param outMaterialNo
	 *            产出物料编码
	 * @return int
	 * @throws SQLException
	 */
	public int checkBaseMaterialIn(Connection con, String inMaterialSet,
			String inMaterialNo) throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkBaseMaterialIn");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, inMaterialSet);
		ps.setObject(2, inMaterialNo);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	/**
	 * 验证是否存在BOM
	 * 
	 * @param con
	 * @param bom
	 * @return
	 * @throws SQLException
	 */
	public String checkBomCommon(Connection con, DesignBomEntity bom)
			throws SQLException {
		if (bom == null) {
			return null;
		}
		String bomNo = "";
		String specCodeC = bom.getSpecCodeC();
		if (specCodeC.equals("")) {
			specCodeC = "/";
		}
		String specCodeR = bom.getSpecCodeR();
		if (specCodeR.equals("")) {
			specCodeR = "/";
		}
		String specCodeD = bom.getSpecCodeD();
		if (specCodeD.equals("")) {
			specCodeD = "/";
		}
		String specCodeZ = bom.getSpecCodeZ();
		if (specCodeZ.equals("")) {
			specCodeZ = "/";
		}
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkBomCommon");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, bom.getMaterialNo());
		ps.setObject(2, bom.getMscPline());
		ps.setObject(3, bom.getWholeBacklog());
		ps.setObject(4, bom.getMsc());
		ps.setObject(5, bom.getGradecode());
		ps.setObject(6, specCodeC);
		ps.setObject(7, specCodeR);
		ps.setObject(8, specCodeD);
		ps.setObject(9, specCodeZ);
		ps.setObject(10, bom.getProcessCodeCs());
		ps.setObject(11, bom.getWholeBacklog());
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {

			bomNo = rs.getString("BOM");
		}
		rs.close();
		ps.close();
		return bomNo;
	}

	/**
	 * 验证基础物料编码是否重复
	 * 
	 * @param con
	 *            连接字符串
	 * @param materialNo
	 *            物料编码
	 * @return int
	 * @throws SQLException
	 */
	public int checkBaseMaterial(Connection con, String materialNo)
			throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkBaseMaterial");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, materialNo);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	/**
	 * 验证基础物料-接箍是否存在相同记录
	 * 
	 * @param con
	 *            连接字符串
	 * @param inMaterialNo
	 *            投入物料编码
	 * @param outMaterialNo
	 *            产出物料编码
	 * @return int
	 * @throws SQLException
	 */
	public int checkBaseMaterialJ(Connection con, String inMaterialNo,
			String outMaterialNo) throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkBaseMaterialJ");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, inMaterialNo);
		ps.setObject(2, outMaterialNo);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	// ------------------------基础数据 产线与投入产出验证------------------------
	/**
	 * 验证 基础数据-电炉投入产出-产线能力
	 * 
	 * @param con
	 *            连接字符串
	 * @param inMaterialNo
	 *            投入物料编码
	 * @param outMaterialNo
	 *            产出物料编码
	 * @param plineCode
	 *            产线编码
	 * @return int
	 * @throws SQLException
	 */
	public int checkBaseMaterialAPl(Connection con, String inMaterialNo,
			String outMaterialNo, String plineCode) throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkBaseMaterialAPl");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, inMaterialNo);
		ps.setObject(2, outMaterialNo);
		ps.setObject(3, plineCode);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	/**
	 * 验证 基础数据-铸造投入产出-产线能力
	 * 
	 * @param con
	 *            连接字符串
	 * @param inMaterialNo
	 *            投入物料编码
	 * @param outMaterialNo
	 *            产出物料编码
	 * @param plineCode
	 *            产线编码
	 * @return int
	 * @throws SQLException
	 */
	public int checkBaseMaterialBPl(Connection con, String inMaterialNo,
			String outMaterialNo, String plineCode) throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkBaseMaterialBPl");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, inMaterialNo);
		ps.setObject(2, outMaterialNo);
		ps.setObject(3, plineCode);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	/**
	 * 验证 基础数据-锻造投入产出-产线能力
	 * 
	 * @param con
	 *            连接字符串
	 * @param inMaterialNo
	 *            投入物料编码
	 * @param outMaterialNo
	 *            产出物料编码
	 * @param plineCode
	 *            产线编码
	 * @return int
	 * @throws SQLException
	 */
	public int checkBaseMaterialCPl(Connection con, String inMaterialNo,
			String outMaterialNo, String plineCode) throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkBaseMaterialCPl");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, inMaterialNo);
		ps.setObject(2, outMaterialNo);
		ps.setObject(3, plineCode);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	/**
	 * 验证 基础数据-轧管投入产出-产线能力
	 * 
	 * @param con
	 *            连接字符串
	 * @param inMaterialNo
	 *            投入物料编码
	 * @param outMaterialNo
	 *            产出物料编码
	 * @param plineCode
	 *            产线编码
	 * @return int
	 * @throws SQLException
	 */
	public int checkBaseMaterialDPl(Connection con, String inMaterialNo,
			String outMaterialNo, String plineCode) throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkBaseMaterialDPl");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, inMaterialNo);
		ps.setObject(2, outMaterialNo);
		ps.setObject(3, plineCode);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	/**
	 * 验证 基础数据-墩拔扩投入产出-产线能力
	 * 
	 * @param con
	 *            连接字符串
	 * @param inMaterialNo
	 *            投入物料编码
	 * @param outMaterialNo
	 *            产出物料编码
	 * @param plineCode
	 *            产线编码
	 * @return int
	 * @throws SQLException
	 */
	public int checkBaseMaterialEPl(Connection con, String inMaterialNo,
			String outMaterialNo, String plineCode) throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkBaseMaterialEPl");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, inMaterialNo);
		ps.setObject(2, outMaterialNo);
		ps.setObject(3, plineCode);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	/**
	 * 验证 基础数据-热处理投入产出-产线能力
	 * 
	 * @param con
	 *            连接字符串
	 * @param inMaterialNo
	 *            投入物料编码
	 * @param outMaterialNo
	 *            产出物料编码
	 * @param plineCode
	 *            产线编码
	 * @return int
	 * @throws SQLException
	 */
	public int checkBaseMaterialFPl(Connection con, String inMaterialNo,
			String outMaterialNo, String plineCode) throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkBaseMaterialFPl");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, inMaterialNo);
		ps.setObject(2, outMaterialNo);
		ps.setObject(3, plineCode);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	/**
	 * 验证 基础数据-接箍投入产出-产线能力
	 * 
	 * @param con
	 *            连接字符串
	 * @param inMaterialNo
	 *            投入物料编码
	 * @param outMaterialNo
	 *            产出物料编码
	 * @param plineCode
	 *            产线编码
	 * @return int
	 * @throws SQLException
	 */
	public int checkBaseMaterialJPl(Connection con, String inMaterialNo,
			String outMaterialNo, String plineCode) throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkBaseMaterialJPl");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, inMaterialNo);
		ps.setObject(2, outMaterialNo);
		ps.setObject(3, plineCode);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	/**
	 * 验证 基础数据-加工投入产出-产线能力
	 * 
	 * @param con
	 *            连接字符串
	 * @param outMaterialNo
	 *            产出物料编码
	 * @param plineCode
	 *            产线编码
	 * @return int
	 * @throws SQLException
	 */
	public int checkBaseMaterialIPl(Connection con, String outMaterialNo,
			String plineCode) throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkBaseMaterialIPl");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, outMaterialNo);
		ps.setObject(2, plineCode);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	/**
	 * 验证质量设计-合同行生产BOM
	 * 
	 * @param con
	 * @param designKey
	 * @param bom
	 * @return
	 * @throws SQLException
	 */
	public int checkSlmOrdLineBom(Connection con, String designKey, String bom)
			throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkSlmOrdLineBom");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, designKey);
		ps.setObject(2, bom);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	/**
	 * 验证质量设计-合同行生产-接箍BOM
	 * 
	 * @param con
	 * @param designKey
	 * @param bom
	 * @param jgCode
	 * @return
	 * @throws SQLException
	 */
	public int checkSlmOrdLineBomJG(Connection con, String designKey,
			String bom, String jgCode) throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkSlmOrdLineBomJG");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, designKey);
		ps.setObject(2, bom);
		ps.setObject(3, jgCode);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	public boolean checkBomA(Connection con, String bom, String inMaterialNo,
			String outMaterialNo) throws SQLException {
		String sql = CoreXmlSqlParsersFactory.getSql("IBomCheckDao.checkBomA");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, bom);
		ps.setObject(2, inMaterialNo);
		ps.setObject(3, outMaterialNo);
		int count = 0;
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = rs.getInt("COUNT");
		}
		rs.close();
		ps.close();
		if (count > 0) {
			return false;
		} else {
			return true;
		}
	}

	public boolean checkBomB(Connection con, String bom, String inMaterialNo,
			String outMaterialNo) throws SQLException {
		String sql = CoreXmlSqlParsersFactory.getSql("IBomCheckDao.checkBomB");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, bom);
		ps.setObject(2, inMaterialNo);
		ps.setObject(3, outMaterialNo);
		int count = 0;
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = rs.getInt("COUNT");
		}
		rs.close();
		ps.close();
		if (count > 0) {
			return false;
		} else {
			return true;
		}
	}

	public boolean checkBomC(Connection con, String bom, String inMaterialNo,
			String outMaterialNo) throws SQLException {
		String sql = CoreXmlSqlParsersFactory.getSql("IBomCheckDao.checkBomC");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, bom);
		ps.setObject(2, inMaterialNo);
		ps.setObject(3, outMaterialNo);
		int count = 0;
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = rs.getInt("COUNT");
		}
		rs.close();
		ps.close();
		if (count > 0) {
			return false;
		} else {
			return true;
		}
	}

	public boolean checkBomD(Connection con, String bom, String inMaterialNo,
			String outMaterialNo) throws SQLException {
		String sql = CoreXmlSqlParsersFactory.getSql("IBomCheckDao.checkBomD");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, bom);
		ps.setObject(2, inMaterialNo);
		ps.setObject(3, outMaterialNo);
		int count = 0;
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = rs.getInt("COUNT");
		}
		rs.close();
		ps.close();
		if (count > 0) {
			return false;
		} else {
			return true;
		}
	}

	public boolean checkBomE(Connection con, String bom, String inMaterialNo,
			String outMaterialNo) throws SQLException {
		String sql = CoreXmlSqlParsersFactory.getSql("IBomCheckDao.checkBomE");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, bom);
		ps.setObject(2, inMaterialNo);
		ps.setObject(3, outMaterialNo);
		int count = 0;
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = rs.getInt("COUNT");
		}
		rs.close();
		ps.close();
		if (count > 0) {
			return false;
		} else {
			return true;
		}
	}

	public boolean checkBomF(Connection con, String bom, String inMaterialNo,
			String outMaterialNo) throws SQLException {
		String sql = CoreXmlSqlParsersFactory.getSql("IBomCheckDao.checkBomF");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, bom);
		ps.setObject(2, inMaterialNo);
		ps.setObject(3, outMaterialNo);
		int count = 0;
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = rs.getInt("COUNT");
		}
		rs.close();
		ps.close();
		if (count > 0) {
			return false;
		} else {
			return true;
		}
	}

	public boolean checkBomG(Connection con, String bom, String inMaterialNo,
			String outMaterialNo) throws SQLException {
		String sql = CoreXmlSqlParsersFactory.getSql("IBomCheckDao.checkBomG");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, bom);
		ps.setObject(2, inMaterialNo);
		ps.setObject(3, outMaterialNo);
		int count = 0;
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = rs.getInt("COUNT");
		}
		rs.close();
		ps.close();
		if (count > 0) {
			return false;
		} else {
			return true;
		}
	}

	public boolean checkBomI(Connection con, String bom, String inMaterialNo,
			String outMaterialNo) throws SQLException {
		String sql = CoreXmlSqlParsersFactory.getSql("IBomCheckDao.checkBomI");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, bom);
		ps.setObject(2, inMaterialNo);
		ps.setObject(3, outMaterialNo);
		int count = 0;
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = rs.getInt("COUNT");
		}
		rs.close();
		ps.close();
		if (count > 0) {
			return false;
		} else {
			return true;
		}
	}

	/**
	 * 验证加工基础物料
	 * 
	 * @param con
	 * @param inMaterialNo
	 * @param outMaterialNo
	 * @return
	 * @throws SQLException
	 */
	public int checkBaseMaterialK(Connection con, String inMaterialNo,
			String outMaterialNo) throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkBaseMaterialK");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, inMaterialNo);
		ps.setObject(2, outMaterialNo);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	public boolean checkBomK(Connection con, String bom, String inMaterialNo,
			String outMaterialNo, String groupNum) throws SQLException {
		String sql = CoreXmlSqlParsersFactory.getSql("IBomCheckDao.checkBomK");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, bom);
		ps.setObject(2, inMaterialNo);
		ps.setObject(3, outMaterialNo);
		ps.setObject(4, groupNum);
		int count = 0;
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = rs.getInt("COUNT");
		}
		rs.close();
		ps.close();
		if (count > 0) {
			return false;
		} else {
			return true;
		}
	}

	/**
	 * 验证 基础数据-加工投入产出-产线能力
	 * 
	 * @param con
	 *            连接字符串
	 * @param inMaterialNo
	 *            投入物料编码
	 * @param outMaterialNo
	 *            产出物料编码
	 * @param plineCode
	 *            产线编码
	 * @return int
	 * @throws SQLException
	 */
	public int checkBaseMaterialKPl(Connection con, String inMaterialNo,
			String outMaterialNo, String plineCode) throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkBaseMaterialKPl");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, inMaterialNo);
		ps.setObject(2, outMaterialNo);
		ps.setObject(3, plineCode);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	/**
	 * 验证接箍加工基础物料
	 * 
	 * @param con
	 * @param inMaterialNo
	 * @param outMaterialNo
	 * @return
	 * @throws SQLException
	 */
	public int checkBaseMaterialH(Connection con, String inMaterialNo,
			String outMaterialNo) throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkBaseMaterialH");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, inMaterialNo);
		ps.setObject(2, outMaterialNo);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	/**
	 * 验证接箍加工BOM
	 * 
	 * @param con
	 * @param bom
	 * @param inMaterialNo
	 * @param outMaterialNo
	 * @return
	 * @throws SQLException
	 */
	public boolean checkBomH(Connection con, String bom, String inMaterialNo,
			String outMaterialNo) throws SQLException {
		String sql = CoreXmlSqlParsersFactory.getSql("IBomCheckDao.checkBomH");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, bom);
		ps.setObject(2, inMaterialNo);
		ps.setObject(3, outMaterialNo);
		int count = 0;
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = rs.getInt("COUNT");
		}
		rs.close();
		ps.close();
		if (count > 0) {
			return false;
		} else {
			return true;
		}
	}

	/**
	 * 验证 基础数据-接箍加工-产线能力
	 * 
	 * @param con
	 *            连接字符串
	 * @param inMaterialNo
	 *            投入物料编码
	 * @param outMaterialNo
	 *            产出物料编码
	 * @param plineCode
	 *            产线编码
	 * @return int
	 * @throws SQLException
	 */
	public int checkBaseMaterialHPl(Connection con, String inMaterialNo,
			String outMaterialNo, String plineCode) throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkBaseMaterialHPl");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, inMaterialNo);
		ps.setObject(2, outMaterialNo);
		ps.setObject(3, plineCode);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	/**
	 * 验证产线
	 * 
	 * @param con
	 * @param plineCode
	 * @param specCode
	 * @param dimater
	 * @param height
	 * @return
	 * @throws SQLException
	 */
	public int checkPlineSpec(Connection con, String plineCode,
			String specCode, String dimater, String height) throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IBomCheckDao.checkPlineSpec");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, plineCode);
		ps.setObject(2, specCode);
		ps.setObject(3, dimater);
		ps.setObject(4, dimater);
		ps.setObject(5, height);
		ps.setObject(6, height);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	/**
	 * 验证产线
	 * 
	 * @param con
	 * @param plineCode
	 * @param specCode
	 * @return
	 * @throws SQLException
	 */
	public String[] getSpecDH(Connection con, String specCode)
			throws SQLException {
		String[] arr = new String[2];
		String sql = CoreXmlSqlParsersFactory.getSql("IBomCheckDao.getSpecDH");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, specCode);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			arr[0] = rs.getString("DIMATER");
			arr[1] = rs.getString("HEIGHT");
		}
		rs.close();
		ps.close();
		return arr;
	}
}
