package com.steering.pss.sale.order;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import net.sf.json.JSONObject;
import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;
import CoreFS.SC01.CoreConstantData;
import com.steering.comm.db.DBCommon;
import com.steering.comm.tools.EntityTool;
import com.steering.comm.tools.StringTool;
import com.steering.pss.qcm.model.GenericEntity;
import com.steering.pss.qcm.model.MscEntity;
import com.steering.pss.sale.order.ReviewForm.CoreOrderReviewTechnology;
import com.steering.pss.sale.order.model.BaseStdRCustEntity;
import com.steering.pss.sale.order.model.SlmCustAlphaEntity;
import com.steering.pss.sale.order.model.SlmCustChemObject;
import com.steering.pss.sale.order.model.SlmCustDetectionObject;
import com.steering.pss.sale.order.model.SlmCustPhyObject;
import com.steering.pss.sale.order.model.SlmCustProcessEntity;
import com.steering.pss.sale.order.model.SlmCustSpecObject;
import com.steering.pss.sale.order.model.SlmCustWaterObject;
import com.steering.pss.sale.order.model.SlmCustalPhaProObject;

/**
 * 产品技术特殊要求类
 * 
 * @author Administrator PDY 2015-02-02
 * 
 */
public class CoreOrderSpecialInfo extends DBCommon {

	/**
	 * 查询冶金规范码及Alpha引用
	 * 
	 * @param msc
	 *            冶金规范码
	 * @return 数据集
	 */
	public CoreReturnObject queryMsc(String msc) {
		Object[] params = new Object[] { msc,msc };
		return this.getDataBySqlID("CoreOrderSpecialInfo.queryMsc", params);
	}

	/**
	 * 查询客户Alpha
	 * 
	 * @param custerCode
	 *            最终客户代码
	 * @return 数据集
	 */
	public CoreReturnObject queryAlpha(String custerCode, String custAlphaNo, String custAlphaSts) {
		Object[] params = new Object[] { custerCode, custAlphaNo, custAlphaNo, custAlphaNo, custAlphaSts, custAlphaSts, custAlphaSts};
		return this.getDataBySqlID("CoreOrderSpecialInfo.queryAlpha", params);
	}

	/**
	 * 查询附加要求
	 * 
	 * @param custerCode
	 *            最终客户代码
	 * @return 数据集
	 */
	public CoreReturnObject queryAskAdd(String custerCode) {
		Object[] params = new Object[] { custerCode };
		return this.getDataBySqlID("CoreOrderSpecialInfo.queryAskAddCode",
				params);
	}

	/**
	 * 查询 成分标准
	 * 
	 * @param mscOrAlphaNo
	 *           基础 冶金规范码
	 * @param flag
	 *            标识
	 * @return 数据集
	 */
	public CoreReturnObject queryMscCic(String mscOrAlphaNo, String modelCode, String modelDesc, String flag,
			String dimater, String height, String specCode, String specStyle) {
		try{
    		dimater = String.valueOf(Double.parseDouble(dimater));
    	}catch(Exception ex){
    		dimater = "";
    	}
    	try{
    		height = String.valueOf(Double.parseDouble(height));
    	}catch(Exception ex){
    		dimater = "";
    	}
    	if(specStyle.equals("C")){
    		dimater = "";
    		height = "";
    	}else{
    		specCode = "";
    	}
    	String dDivH = dimater.equals("") ? "" : String.valueOf(Double.parseDouble(dimater) / Double.parseDouble(height));
    	String hDivD = dimater.equals("") ? "" : String.valueOf(Double.parseDouble(height) / Double.parseDouble(dimater));
    	String dSubH = dimater.equals("") ? "" : String.valueOf(Double.parseDouble(dimater) - Double.parseDouble(height));
    	
		if (flag.equals("a")) {
			Connection con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			String cic = "";
			String sql1 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryCic1");
			sql1 = StringTool.ReplaceAll(sql1, "#MSC#", mscOrAlphaNo);
			sql1 = StringTool.ReplaceAll(sql1, "#MODEL_CODE#", modelCode);
			sql1 = StringTool.ReplaceAll(sql1, "#MODEL_DESC#", modelDesc);
			sql1 = StringTool.ReplaceAll(sql1, "#DIMATER#", dimater);
			sql1 = StringTool.ReplaceAll(sql1, "#HEIGHT#", height);
			sql1 = StringTool.ReplaceAll(sql1, "#DIMATER/HEIGHT#", dDivH);
			sql1 = StringTool.ReplaceAll(sql1, "#HEIGHT/DIMATER#", hDivD);
			sql1 = StringTool.ReplaceAll(sql1, "#DIMATER-HEIGHT#", dSubH);
			sql1 = StringTool.ReplaceAll(sql1, "#SPEC_JG#", specCode);
			ArrayList<GenericEntity> list1 = EntityTool.getEntitysBySql(sql1, con, GenericEntity.class);
			if(list1.size() > 0){
				cic = list1.get(0).getValue();
			}
			
//			if(cic.equals("")){
//				con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
//				String sql2 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryCic2");
//				sql2 = StringTool.ReplaceAll(sql2, "#MSC#", mscOrAlphaNo);
//				sql2 = StringTool.ReplaceAll(sql2, "#MODEL_CODE#", modelCode);
//				ArrayList<GenericEntity> list2 = EntityTool.getEntitysBySql(sql2, con, GenericEntity.class);
//				if(list2.size() > 0){
//					cic = list2.get(0).getValue();
//				}
//			}
//			
//			if(cic.equals("")){
//				con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
//				String sql3 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryCic3");
//				sql3 = StringTool.ReplaceAll(sql3, "#MSC#", mscOrAlphaNo);
//				sql3 = StringTool.ReplaceAll(sql3, "#MODEL_CODE#", modelCode);
//				sql3 = StringTool.ReplaceAll(sql3, "#MODEL_DESC#", modelDesc);
//				sql3 = StringTool.ReplaceAll(sql3, "#DIMATER#", dimater);
//				sql3 = StringTool.ReplaceAll(sql3, "#HEIGHT#", height);
//				sql3 = StringTool.ReplaceAll(sql3, "#DIMATER/HEIGHT#", dDivH);
//				sql3 = StringTool.ReplaceAll(sql3, "#HEIGHT/DIMATER#", hDivD);
//				sql3 = StringTool.ReplaceAll(sql3, "#DIMATER-HEIGHT#", dSubH);
//				ArrayList<GenericEntity> list3 = EntityTool.getEntitysBySql(sql3, con, GenericEntity.class);
//				if(list3.size() > 0){
//					cic = list3.get(0).getValue();
//				}
//			}
			
			String sql4 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryCic4");
			sql4 = StringTool.ReplaceAll(sql4, "#CIC#", cic);
			return this.getData(sql4);
		} else {
			String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryAlphaCic");
			sql = StringTool.ReplaceAll(sql, "#CUST_ALPHA_NO#", mscOrAlphaNo);
			return this.getData(sql);
		}
	}

	/**
	 * 查询 理化标准
	 * 
	 * @param msc
	 *            冶金规范码
	 * @param stdCode
	 *            标准代码
	 * @param flag
	 *            标识
	 * @return 数据集
	 */
	public CoreReturnObject queryMscPic(String mscOrAlphaNo, String modelCode, String modelDesc, String flag,
			String dimater, String height, String specCode, String specStyle) {
		try{
    		dimater = String.valueOf(Double.parseDouble(dimater));
    	}catch(Exception ex){
    		dimater = "";
    	}
    	try{
    		height = String.valueOf(Double.parseDouble(height));
    	}catch(Exception ex){
    		dimater = "";
    	}
    	if(specStyle.equals("C")){
    		dimater = "";
    		height = "";
    	}else{
    		specCode = "";
    	}
    	String dDivH = dimater.equals("") ? "" : String.valueOf(Double.parseDouble(dimater) / Double.parseDouble(height));
    	String hDivD = dimater.equals("") ? "" : String.valueOf(Double.parseDouble(height) / Double.parseDouble(dimater));
    	String dSubH = dimater.equals("") ? "" : String.valueOf(Double.parseDouble(dimater) - Double.parseDouble(height));
    	
		if (flag.equals("a")) {
			Connection con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			String pic = "";
			String sql1 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryPic1");
			sql1 = StringTool.ReplaceAll(sql1, "#MSC#", mscOrAlphaNo);
			sql1 = StringTool.ReplaceAll(sql1, "#MODEL_CODE#", modelCode);
			sql1 = StringTool.ReplaceAll(sql1, "#MODEL_DESC#", modelDesc);
			sql1 = StringTool.ReplaceAll(sql1, "#DIMATER#", dimater);
			sql1 = StringTool.ReplaceAll(sql1, "#HEIGHT#", height);
			sql1 = StringTool.ReplaceAll(sql1, "#DIMATER/HEIGHT#", dDivH);
			sql1 = StringTool.ReplaceAll(sql1, "#HEIGHT/DIMATER#", hDivD);
			sql1 = StringTool.ReplaceAll(sql1, "#DIMATER-HEIGHT#", dSubH);
			sql1 = StringTool.ReplaceAll(sql1, "#SPEC_JG#", specCode);
			ArrayList<GenericEntity> list1 = EntityTool.getEntitysBySql(sql1, con, GenericEntity.class);
			if(list1.size() > 0){
				pic = list1.get(0).getValue();
			}
			
//			if(pic.equals("")){
//				con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
//				String sql2 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryPic2");
//				sql2 = StringTool.ReplaceAll(sql2, "#MSC#", mscOrAlphaNo);
//				sql2 = StringTool.ReplaceAll(sql2, "#MODEL_CODE#", modelCode);
//				ArrayList<GenericEntity> list2 = EntityTool.getEntitysBySql(sql2, con, GenericEntity.class);
//				if(list2.size() > 0){
//					pic = list2.get(0).getValue();
//				}
//			}
//			
//			if(pic.equals("")){
//				con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
//				String sql3 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryPic3");
//				sql3 = StringTool.ReplaceAll(sql3, "#MSC#", mscOrAlphaNo);
//				sql3 = StringTool.ReplaceAll(sql3, "#MODEL_CODE#", modelCode);
//				sql3 = StringTool.ReplaceAll(sql3, "#MODEL_DESC#", modelDesc);
//				sql3 = StringTool.ReplaceAll(sql3, "#DIMATER#", dimater);
//				sql3 = StringTool.ReplaceAll(sql3, "#HEIGHT#", height);
//				sql3 = StringTool.ReplaceAll(sql3, "#DIMATER/HEIGHT#", dDivH);
//				sql3 = StringTool.ReplaceAll(sql3, "#HEIGHT/DIMATER#", hDivD);
//				sql3 = StringTool.ReplaceAll(sql3, "#DIMATER-HEIGHT#", dSubH);
//				ArrayList<GenericEntity> list3 = EntityTool.getEntitysBySql(sql3, con, GenericEntity.class);
//				if(list3.size() > 0){
//					pic = list3.get(0).getValue();
//				}
//			}
			
			String sql4 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryPic4");
			sql4 = StringTool.ReplaceAll(sql4, "#PIC#", pic);
			return this.getData(sql4);
		} else {
			String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryAlphaPic");
			sql = StringTool.ReplaceAll(sql, "#CUST_ALPHA_NO#", mscOrAlphaNo);
			return this.getData(sql);
		}
	}

	/**
	 * 查询 公差标准
	 * 
	 * @param msc
	 *            冶金规范码
	 * @param stdCode
	 *            标准代码
	 * @param flag
	 *            标识
	 * @return 数据集
	 */
	public CoreReturnObject queryMscSic(String mscOrAlphaNo, String modelCode, String modelDesc, String flag,
			String dimater, String height) {
		try{
    		dimater = String.valueOf(Double.parseDouble(dimater));
    	}catch(Exception ex){
    		dimater = "";
    	}
    	try{
    		height = String.valueOf(Double.parseDouble(height));
    	}catch(Exception ex){
    		dimater = "";
    	}
    	String dDivH = dimater.equals("") ? "" : String.valueOf(Double.parseDouble(dimater) / Double.parseDouble(height));
    	String hDivD = dimater.equals("") ? "" : String.valueOf(Double.parseDouble(height) / Double.parseDouble(dimater));
    	String dSubH = dimater.equals("") ? "" : String.valueOf(Double.parseDouble(dimater) - Double.parseDouble(height));
		
		if (flag.equals("a")) {
			Connection con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			String sic = "";
			String sql1 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.querySic1");
			sql1 = StringTool.ReplaceAll(sql1, "#MSC#", mscOrAlphaNo);
			sql1 = StringTool.ReplaceAll(sql1, "#MODEL_CODE#", modelCode);
			sql1 = StringTool.ReplaceAll(sql1, "#MODEL_DESC#", modelDesc);
			sql1 = StringTool.ReplaceAll(sql1, "#DIMATER#", dimater);
			sql1 = StringTool.ReplaceAll(sql1, "#HEIGHT#", height);
			sql1 = StringTool.ReplaceAll(sql1, "#DIMATER/HEIGHT#", dDivH);
			sql1 = StringTool.ReplaceAll(sql1, "#HEIGHT/DIMATER#", hDivD);
			sql1 = StringTool.ReplaceAll(sql1, "#DIMATER-HEIGHT#", dSubH);
			ArrayList<GenericEntity> list1 = EntityTool.getEntitysBySql(sql1, con, GenericEntity.class);
			if(list1.size() > 0){
				sic = list1.get(0).getValue();
			}
			
//			if(sic.equals("")){
//				con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
//				String sql2 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.querySic2");
//				sql2 = StringTool.ReplaceAll(sql2, "#MSC#", mscOrAlphaNo);
//				sql2 = StringTool.ReplaceAll(sql2, "#MODEL_CODE#", modelCode);
//				ArrayList<GenericEntity> list2 = EntityTool.getEntitysBySql(sql2, con, GenericEntity.class);
//				if(list2.size() > 0){
//					sic = list2.get(0).getValue();
//				}
//			}
//			
//			if(sic.equals("")){
//				con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
//				String sql3 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.querySic3");
//				sql3 = StringTool.ReplaceAll(sql3, "#MSC#", mscOrAlphaNo);
//				sql3 = StringTool.ReplaceAll(sql3, "#DIMATER#", dimater);
//				sql3 = StringTool.ReplaceAll(sql3, "#HEIGHT#", height);
//				sql3 = StringTool.ReplaceAll(sql3, "#DIMATER/HEIGHT#", dDivH);
//				sql3 = StringTool.ReplaceAll(sql3, "#HEIGHT/DIMATER#", hDivD);
//				sql3 = StringTool.ReplaceAll(sql3, "#DIMATER-HEIGHT#", dSubH);
//				ArrayList<GenericEntity> list3 = EntityTool.getEntitysBySql(sql3, con, GenericEntity.class);
//				if(list3.size() > 0){
//					sic = list3.get(0).getValue();
//				}
//			}
			
			String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.querySic4");
			sql = StringTool.ReplaceAll(sql, "#SIC#", sic);
			return this.getData(sql);
		} else {
			String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryAlphaSic");
			sql = StringTool.ReplaceAll(sql, "#CUST_ALPHA_NO#", mscOrAlphaNo);
			return this.getData(sql);
		}

	}

	/**
	 * 查询 探伤标准
	 * 
	 * @param msc
	 *            冶金规范码
	 * @param stdCode
	 *            标准代码
	 * @param flag
	 *            标识
	 * @return 数据集
	 */
	public CoreReturnObject queryMscDic(String mscOrAlphaNo, String modelCode, String modelDesc, String flag,
			String dimater, String height) {
		try{
    		dimater = String.valueOf(Double.parseDouble(dimater));
    	}catch(Exception ex){
    		dimater = "";
    	}
    	try{
    		height = String.valueOf(Double.parseDouble(height));
    	}catch(Exception ex){
    		dimater = "";
    	}
    	String dDivH = dimater.equals("") ? "" : String.valueOf(Double.parseDouble(dimater) / Double.parseDouble(height));
    	String hDivD = dimater.equals("") ? "" : String.valueOf(Double.parseDouble(height) / Double.parseDouble(dimater));
    	String dSubH = dimater.equals("") ? "" : String.valueOf(Double.parseDouble(dimater) - Double.parseDouble(height));
		
		if (flag.equals("a")) {
			Connection con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			String dic = "";
			
			String sql1 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryDic1");
			sql1 = StringTool.ReplaceAll(sql1, "#MSC#", mscOrAlphaNo);
			sql1 = StringTool.ReplaceAll(sql1, "#MODEL_CODE#", modelCode);
			sql1 = StringTool.ReplaceAll(sql1, "#MODEL_DESC#", modelDesc);
			sql1 = StringTool.ReplaceAll(sql1, "#DIMATER#", dimater);
			sql1 = StringTool.ReplaceAll(sql1, "#HEIGHT#", height);
			sql1 = StringTool.ReplaceAll(sql1, "#DIMATER/HEIGHT#", dDivH);
			sql1 = StringTool.ReplaceAll(sql1, "#HEIGHT/DIMATER#", hDivD);
			sql1 = StringTool.ReplaceAll(sql1, "#DIMATER-HEIGHT#", dSubH);
			ArrayList<GenericEntity> list1 = EntityTool.getEntitysBySql(sql1, con, GenericEntity.class);
			if(list1.size() > 0){
				dic = list1.get(0).getValue();
			}
			
//			if(dic.equals("")){
//				con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
//				String sql2 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryDic2");
//				sql2 = StringTool.ReplaceAll(sql2, "#MSC#", mscOrAlphaNo);
//				sql2 = StringTool.ReplaceAll(sql2, "#MODEL_CODE#", modelCode);
//				ArrayList<GenericEntity> list2 = EntityTool.getEntitysBySql(sql2, con, GenericEntity.class);
//				if(list2.size() > 0){
//					dic = list2.get(0).getValue();
//				}
//			}
//			
//			if(dic.equals("")){
//				con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
//				String sql3 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryDic3");
//				sql3 = StringTool.ReplaceAll(sql3, "#MSC#", mscOrAlphaNo);
//				sql3 = StringTool.ReplaceAll(sql3, "#DIMATER#", dimater);
//				sql3 = StringTool.ReplaceAll(sql3, "#HEIGHT#", height);
//				sql3 = StringTool.ReplaceAll(sql3, "#DIMATER/HEIGHT#", dDivH);
//				sql3 = StringTool.ReplaceAll(sql3, "#HEIGHT/DIMATER#", hDivD);
//				sql3 = StringTool.ReplaceAll(sql3, "#DIMATER-HEIGHT#", dSubH);
//				ArrayList<GenericEntity> list3 = EntityTool.getEntitysBySql(sql3, con, GenericEntity.class);
//				if(list3.size() > 0){
//					dic = list3.get(0).getValue();
//				}
//			}
			
			String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryDic4");
			sql = StringTool.ReplaceAll(sql, "#DIC#", dic);
			return this.getData(sql);
		} else {
			String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryAlphaDic");
			sql = StringTool.ReplaceAll(sql, "#CUST_ALPHA_NO#", mscOrAlphaNo);
			return this.getData(sql);
		}
	}

	/**
	 * 查询水压标准
	 * 
	 * @param msc
	 *            冶金规范码
	 * @param stdCode
	 *            标准代码或者客户编码
	 * @param flag
	 *            标识
	 * @return 数据集
	 */
	public CoreReturnObject queryMscWic(String mscOrAlphaNo, String modelCode, String modelDesc, String flag,
			String dimater, String height, String specCode, String specStyle) {
		try{
    		dimater = String.valueOf(Double.parseDouble(dimater));
    	}catch(Exception ex){
    		dimater = "";
    	}
    	try{
    		height = String.valueOf(Double.parseDouble(height));
    	}catch(Exception ex){
    		dimater = "";
    	}
    	if(specStyle.equals("C")){
    		dimater = "";
    		height = "";
    	}else{
    		specCode = "";
    	}
    	String dDivH = dimater.equals("") ? "" : String.valueOf(Double.parseDouble(dimater) / Double.parseDouble(height));
    	String hDivD = dimater.equals("") ? "" : String.valueOf(Double.parseDouble(height) / Double.parseDouble(dimater));
    	String dSubH = dimater.equals("") ? "" : String.valueOf(Double.parseDouble(dimater) - Double.parseDouble(height));
		
		if (flag.equals("a")) {
			Connection con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			String wic = "";
			String sql1 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryWic1");
			sql1 = StringTool.ReplaceAll(sql1, "#MSC#", mscOrAlphaNo);
			sql1 = StringTool.ReplaceAll(sql1, "#MODEL_CODE#", modelCode);
			sql1 = StringTool.ReplaceAll(sql1, "#MODEL_DESC#", modelDesc);
			sql1 = StringTool.ReplaceAll(sql1, "#DIMATER#", dimater);
			sql1 = StringTool.ReplaceAll(sql1, "#HEIGHT#", height);
			sql1 = StringTool.ReplaceAll(sql1, "#DIMATER/HEIGHT#", dDivH);
			sql1 = StringTool.ReplaceAll(sql1, "#HEIGHT/DIMATER#", hDivD);
			sql1 = StringTool.ReplaceAll(sql1, "#DIMATER-HEIGHT#", dSubH);
			sql1 = StringTool.ReplaceAll(sql1, "#SPEC_JG#", specCode);
			ArrayList<GenericEntity> list1 = EntityTool.getEntitysBySql(sql1, con, GenericEntity.class);
			if(list1.size() > 0){
				wic = list1.get(0).getValue();
			}
			
//			if(wic.equals("")){
//				con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
//				String sql2 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryWic2");
//				sql2 = StringTool.ReplaceAll(sql2, "#MSC#", mscOrAlphaNo);
//				sql2 = StringTool.ReplaceAll(sql2, "#MODEL_CODE#", modelCode);
//				ArrayList<GenericEntity> list2 = EntityTool.getEntitysBySql(sql2, con, GenericEntity.class);
//				if(list2.size() > 0){
//					wic = list2.get(0).getValue();
//				}
//			}
//			
//			if(wic.equals("")){
//				con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
//				String sql3 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryWic3");
//				sql3 = StringTool.ReplaceAll(sql3, "#MSC#", mscOrAlphaNo);
//				sql3 = StringTool.ReplaceAll(sql3, "#MODEL_CODE#", modelCode);
//				sql3 = StringTool.ReplaceAll(sql3, "#MODEL_DESC#", modelDesc);
//				sql3 = StringTool.ReplaceAll(sql3, "#DIMATER#", dimater);
//				sql3 = StringTool.ReplaceAll(sql3, "#HEIGHT#", height);
//				sql3 = StringTool.ReplaceAll(sql3, "#DIMATER/HEIGHT#", dDivH);
//				sql3 = StringTool.ReplaceAll(sql3, "#HEIGHT/DIMATER#", hDivD);
//				sql3 = StringTool.ReplaceAll(sql3, "#DIMATER-HEIGHT#", dSubH);
//				ArrayList<GenericEntity> list3 = EntityTool.getEntitysBySql(sql3, con, GenericEntity.class);
//				if(list3.size() > 0){
//					wic = list3.get(0).getValue();
//				}
//			}
			
			String sql4 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryWic4");
			sql4 = StringTool.ReplaceAll(sql4, "#WIC#", wic);
			return this.getData(sql4);
		} else {
			String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryAlphaWic");
			sql = StringTool.ReplaceAll(sql, "#CUST_ALPHA_NO#", mscOrAlphaNo);
			return this.getData(sql);
		}
	}
	
   public CoreReturnObject queryMscGic(String mscOrAlphaNo, String modelCode, String modelDesc, String flag) {
	   try
	   {
	        if (flag.equals("a")) {
	        	Connection con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
	        	String gic = "";
	        	String sql1 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryGic1");
	        	sql1 = StringTool.ReplaceAll(sql1, "#MSC#", mscOrAlphaNo);
	        	sql1 = StringTool.ReplaceAll(sql1, "#MODEL_CODE#", modelCode);
	        	sql1 = StringTool.ReplaceAll(sql1, "#MODEL_DESC#", modelDesc);
	        	ArrayList<GenericEntity> list1 = EntityTool.getEntitysBySql(sql1, con, GenericEntity.class);
	        	if(list1.size() > 0){
	        		gic = list1.get(0).getValue();
	        	}
	        	
	        	String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryGic4");
	        	sql = StringTool.ReplaceAll(sql, "#GIC#", gic);
	        	return this.getData(sql);
	        } else {
	        	String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryAlphaGic");
	        	sql = StringTool.ReplaceAll(sql, "#CUST_ALPHA_NO#", mscOrAlphaNo);
	        	return this.getData(sql);
	        }
	   }catch(Exception ex){
		   CoreReturnObject cro = new CoreReturnObject();
		   return cro;
	   }
    }

	/**
	 * 查询附加要求
	 * 
	 * @param msc
	 *            冶金规范码
	 * @param stdCode
	 *            客户编码
	 * @param flag
	 *            标识
	 * @return 数据集
	 */
	public CoreReturnObject queryAddAsk(String msc, String stdCode, String flag) {

		Object[] params = new Object[] { msc, stdCode };
		return this.getDataBySqlID("CoreOrderSpecialInfo.queryAlphaAskAdd",
				params);

	}

	/**
	 * 保存
	 * 
	 * @param ChemAlphaNo
	 *            最终客户编码
	 * @param custAlphaDesc
	 *            最终客户描述
	 * @param userName
	 *            操作人
	 * @param custNo
	 *            客户Alpha编码
	 * @param standData
	 *            标准数据
	 * @return 操作行数
	 */
	@SuppressWarnings("unchecked")
    public CoreReturnObject saveSpecialInfo(ArrayList<Object> strData,
			ArrayList<Object> standData) {
		// 最终客户编码
		String ChemAlphaNo = strData.get(0).toString();
		// 最终客户描述
		String custAlphaDesc = strData.get(1).toString();
		// 操作人姓名
		String userName = strData.get(2).toString();
		// 用户Alpha编码
		String custAlphaNo = strData.get(3).toString();
		// SQL
		ArrayList<String> sqlIdList = new ArrayList<String>();
		
		ArrayList<Object> chemList = (ArrayList<Object>) standData.get(0);
		ArrayList<Object> phyList = (ArrayList<Object>) standData.get(1);
		ArrayList<Object> specList = (ArrayList<Object>) standData.get(2);
		ArrayList<Object> deteList = (ArrayList<Object>) standData.get(3);
		ArrayList<Object> waterList = (ArrayList<Object>) standData.get(4);
		ArrayList<Object> ProCessList = (ArrayList<Object>) standData.get(5);
		
		// 新增
		int numPart = 0;
		try {
			String sql = CoreXmlSqlParsersFactory
					.getSql("CoreOrderSpecialInfo.getMaxCustAlpha");
			Object[] obj = new Object[] { ChemAlphaNo };
			ResultSet rs = this.getDao("TgDao").ExceuteQueryForResultSet(
					sql, obj);
			if (rs.next()) {
				numPart = Integer.parseInt(rs.getString(1)
						.substring(10));
			}
			rs.close();
		} catch (SQLException e) {
			return new CoreReturnObject();
		}
		DecimalFormat df = new DecimalFormat("00000");
		custAlphaNo = ChemAlphaNo + df.format(numPart + 1);
		// 增加客户Alpha要求管理
		
		String sqlAddCustAlpha = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.addCustAlpha");
		sqlAddCustAlpha = StringTool.ReplaceAll(sqlAddCustAlpha, "#CUST_ALPHA_NO#", custAlphaNo);
		sqlAddCustAlpha = StringTool.ReplaceAll(sqlAddCustAlpha, "#CUST_ALPHA_DESC#", custAlphaDesc);
		sqlAddCustAlpha = StringTool.ReplaceAll(sqlAddCustAlpha, "#CREATE_NAME#", userName);
		sqlIdList.add(sqlAddCustAlpha);
		// 增加客户Alpha要求适用客户
		
		String sqlAddCustAlphaUse = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.addCustAlphaUse");
		sqlAddCustAlphaUse = StringTool.ReplaceAll(sqlAddCustAlphaUse, "#CUST_ALPHA_NO#", custAlphaNo);
		sqlAddCustAlphaUse = StringTool.ReplaceAll(sqlAddCustAlphaUse, "#CHEM_ALPHA_NO#", ChemAlphaNo);
		sqlAddCustAlphaUse = StringTool.ReplaceAll(sqlAddCustAlphaUse, "#CREATE_NAME#", userName);
		sqlIdList.add(sqlAddCustAlphaUse);
		
		// 标准数据处理
		addChem(sqlIdList, chemList, custAlphaNo, userName);
		addPhy(sqlIdList, phyList, custAlphaNo, userName);
		addSpec(sqlIdList, specList, custAlphaNo, userName);
		addDetection(sqlIdList, deteList, custAlphaNo, userName);
		addWater(sqlIdList, waterList, custAlphaNo, userName);
		addProCess(sqlIdList, ProCessList, custAlphaNo, userName);
		
		CoreReturnObject obj = this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(sqlIdList);
		obj.setResult(custAlphaNo);
		return obj;
	}

	/**
	 * 成分标准
	 * 
	 * @param sqlIdList
	 *            SQL
	 * @param params
	 *            操作数据
	 * @param chemList
	 *            数据
	 * @param custAlphaNo
	 *            客户编码
	 * @param userName
	 *            操作人
	 */
	private void addChem(ArrayList<String> sqlIdList, ArrayList<Object> chemList,
			String custAlphaNo, String userName) {
		for (int i = 0; i < chemList.size(); i++) {
			String chemStr = chemList.get(i).toString();
			JSONObject json = JSONObject.fromObject(chemStr);
			SlmCustChemObject com = (SlmCustChemObject) JSONObject.toBean(json,
					SlmCustChemObject.class);
			com.setCreateName(userName);
			com.setUpdateName(userName);
			
			if (com.getCic().length() == 0) {
				com.setCic("SalesIndexCic");
			}
			com.setCustAlphaNo(custAlphaNo);
			String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.addAlphaChem");
			sql = EntityTool.fillSqlByEntity(sql, com);
			sqlIdList.add(sql);
		}
	}

	private void addPhy(ArrayList<String> sqlIdList, ArrayList<Object> phyList,
			String custAlphaNo, String userName) {
		for (int i = 0; i < phyList.size(); i++) {
			String phyStr = phyList.get(i).toString();
			JSONObject json = JSONObject.fromObject(phyStr);
			SlmCustPhyObject com = (SlmCustPhyObject) JSONObject.toBean(json,
					SlmCustPhyObject.class);
			com.setCreateName(userName);
			com.setUpdateName(userName);
			
			if (com.getPic().length() == 0) {
				com.setPic("SalesIndexPic");
			}
			com.setCustAlphaNo(custAlphaNo);
			String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.addAlphaPhy");
			sql = EntityTool.fillSqlByEntity(sql, com);
			sqlIdList.add(sql);
		}
	}

	/**
	 * 公差
	 * 
	 * @param sqlIdList
	 * @param params
	 * @param specList
	 * @param custAlphaNo
	 * @param userName
	 * @param flag
	 */
	private void addSpec(ArrayList<String> sqlIdList, ArrayList<Object> specList,
			String custAlphaNo, String userName) {
		for (int i = 0; i < specList.size(); i++) {
			String specStr = specList.get(i).toString();
			JSONObject json = JSONObject.fromObject(specStr);
			SlmCustSpecObject com = (SlmCustSpecObject) JSONObject.toBean(json,
					SlmCustSpecObject.class);
			com.setCreateName(userName);
			com.setUpdateName(userName);
			
			if (com.getSic().length() == 0) {
				com.setSic("SalesIndexSic");
			}
			com.setCustAlphaNo(custAlphaNo);
			String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.addAlphaSpec");
			sql = EntityTool.fillSqlByEntity(sql, com);
			sqlIdList.add(sql);
		}
	}

	/**
	 * 探伤
	 * 
	 * @param sqlIdList
	 * @param params
	 * @param deteList
	 * @param custAlphaNo
	 * @param userName
	 * @param flag
	 */
	private void addDetection(ArrayList<String> sqlIdList, ArrayList<Object> deteList,
			String custAlphaNo, String userName) {
		for (int i = 0; i < deteList.size(); i++) {
			String deteStr = deteList.get(i).toString();
			JSONObject json = JSONObject.fromObject(deteStr);
			SlmCustDetectionObject com = (SlmCustDetectionObject) JSONObject
					.toBean(json, SlmCustDetectionObject.class);
			com.setCreateName(userName);
			com.setUpdateName(userName);
			
			if (com.getDic().length() == 0) {
				com.setDic("SalesIndexDic");
			}
			com.setCustAlphaNo(custAlphaNo);
			String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.addAlphaDetection");
			sql = EntityTool.fillSqlByEntity(sql, com);
			sqlIdList.add(sql);
		}
	}

	/**
	 * 水压
	 * 
	 * @param sqlIdList
	 * @param params
	 * @param waterList
	 * @param custAlphaNo
	 * @param userName
	 * @param flag
	 */
	private void addWater(ArrayList<String> sqlIdList,  ArrayList<Object> waterList,
			String custAlphaNo, String userName) {
		for (int i = 0; i < waterList.size(); i++) {
			String waterStr = waterList.get(i).toString();
			JSONObject json = JSONObject.fromObject(waterStr);
			SlmCustWaterObject com = (SlmCustWaterObject) JSONObject.toBean(
					json, SlmCustWaterObject.class);
			com.setCreateName(userName);
			com.setUpdateName(userName);
			
			if (com.getWic().length() == 0) {
				com.setWic("SalesIndexWic");
			}
			com.setCustAlphaNo(custAlphaNo);
			String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.addAlphaWater");
			sql = EntityTool.fillSqlByEntity(sql, com);
			sqlIdList.add(sql);
		}
	}
	
	/**
	 * 加工标准
	 * 
	 * @param sqlIdList
	 *            SQL
	 * @param params
	 *            操作数据
	 * @param chemList
	 *            数据
	 * @param custAlphaNo
	 *            客户编码
	 * @param userName
	 *            操作人
	 */
	private void addProCess(ArrayList<String> sqlIdList, ArrayList<Object> chemList,
			String custAlphaNo, String userName) {
		for (int i = 0; i < chemList.size(); i++) {
			String chemStr = chemList.get(i).toString();
			JSONObject json = JSONObject.fromObject(chemStr);
			SlmCustalPhaProObject com = (SlmCustalPhaProObject) JSONObject.toBean(json,
					SlmCustalPhaProObject.class);
			com.setCreateName(userName);
			com.setUpdateName(userName);
			
			com.setCustAlphaNo(custAlphaNo);
			String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.addCustAlphaProCess");
			sql = EntityTool.fillSqlByEntity(sql, com);
			sqlIdList.add(sql);
		}
	}

	/**
	 * 验证Alpha是否通过审批
	 * 
	 * @param alphaNo
	 * @return 没通过则返回null，通过返回1
	 */
	public CoreReturnObject checkAlphaNoPass(String alphaNo) {
		Object[] params = new Object[] { alphaNo };
		return this.getDataBySqlID("CoreOrderSpecialInfo.checkAlphaNoPass",
				params);
	}
	/**
	 * 查询加工标准
	 * 
	 * @param msc 冶金规范码
	 *        PSC 品名代码
	 *        MODEL_CODE 扣型
	 * @return 数据集
	 */
	public CoreReturnObject queryMscPscPro(String alple,String msc,String psc,String model_code) {
		Object[] params = new Object[] {alple,alple,alple,alple,alple,alple,msc,psc,model_code};
		return this.getDataBySqlID("CoreOrderSpecialInfo.queryMscStdPro", params);
	}
	/**
	 * 查询加工标准
	 * 
	 * @param msc 冶金规范码
	 *        PSC 品名代码 
	 * @return 数据集
	 */
	public CoreReturnObject queryPSCMSCModel(String msc,String psc) {
		Object[] params = new Object[] { msc ,psc};
		return this.getDataBySqlID("CoreOrderSpecialInfo.queryPSCMSCModel", params);
	}
	/**
	 * 查询所有加工标准
	 * 
	 * @param 客户Aple编码
	 *        PSC 品名代码 
	 * @return 数据集
	 */
	public CoreReturnObject queryPROALL(String psc,String aple) {
		Object[] params = new Object[] { aple,aple,aple,aple,aple,aple,psc};
		return this.getDataBySqlID("CoreOrderSpecialInfo.queryPROALL", params);
	} 
	
	/**
	 * 根据PSC查询所有水压标准
	 * 
	 * @param 客户Aple编码
	 *        PSC 品名代码 
	 * @return 数据集
	 */
	public CoreReturnObject queryWICALL(String psc,String aple) {
		Object[] params = new Object[] { psc,aple};
		return this.getDataBySqlID("CoreOrderSpecialInfo.queryWICALL", params);
	} 
	
	/**
	 * 根据PSC查询所有探伤标准
	 * 
	 * @param 客户Aple编码
	 *        PSC 品名代码 
	 * @return 数据集
	 */
	public CoreReturnObject queryDICALL(String psc,String aple) {
		Object[] params = new Object[] { psc,aple};
		return this.getDataBySqlID("CoreOrderSpecialInfo.queryDICALL", params);
	} 
	
	/**
	 * 根据PSC查询所有公差标准
	 * 
	 * @param 客户Aple编码
	 *        PSC 品名代码 
	 * @return 数据集
	 */
	public CoreReturnObject querySICALL(String psc,String aple) {
		Object[] params = new Object[] { psc,aple};
		return this.getDataBySqlID("CoreOrderSpecialInfo.querySICALL", params);
	} 
	
	/**
	 * 根据PSC查询所有材质标准
	 * 
	 * @param 客户Aple编码
	 *        PSC 品名代码 
	 * @return 数据集
	 */
	public CoreReturnObject queryPICALL(String psc,String aple) {
		Object[] params = new Object[] { psc,aple};
		return this.getDataBySqlID("CoreOrderSpecialInfo.queryPICALL", params);
	} 
	
	/**
	 * 根据alpha查询所有加工标准
	 * 
	 * @param 客户Aple编码
	 *        PSC 品名代码 
	 * @return 数据集
	 */
	public CoreReturnObject queryMscAlphaStdPro(String aple) {
		Object[] params = new Object[] {aple};
		return this.getDataBySqlID("CoreOrderSpecialInfo.queryMscAlphaStdPro", params);
	} 
	
	/**
	 * 根据PSC查询所有成分标准
	 * 
	 * @param 客户Aple编码
	 *        PSC 品名代码 
	 * @return 数据集
	 */
	public CoreReturnObject queryCICALL(String psc,String aple) {
		Object[] params = new Object[] { psc,aple};
		return this.getDataBySqlID("CoreOrderSpecialInfo.queryCICALL", params);
	}
	
	/**
	 * 查询加工工序点名称
	 *  
	 */
	public CoreReturnObject queryStationCode() { 
		return this.getDataBySqlID("CoreOrderSpecialInfo.queryStationCode");
	}
	/**
	 * 查询加工工序点名称
	 *  
	 */
	public CoreReturnObject queryStationCodeId(String id) { 
		Object[] params = new Object[] { id };
		return this.getDataBySqlID("CoreOrderSpecialInfo.queryStationCodeId",params);
	}
	
	/**
	 * 获取描述
	 * @param user
	 * @param psc
	 * @param model
	 * @return
	 */
	public CoreReturnObject getDesc(String user, String psc, String model){
		String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getDesc");
		sql = StringTool.ReplaceAll(sql, "#CUSTOMER_NO#", user);
		sql = StringTool.ReplaceAll(sql, "#PSC#", psc);
		sql = StringTool.ReplaceAll(sql, "#MODEL_CODE#", model);
		
		return this.getData(sql);
	}
	
	/**
	 * 获取更新客户要求主表状态SQL
	 * @param custAlphaEntity
	 * @return
	 */
	public String getUpdateCustAlphaStateSql(SlmCustAlphaEntity custAlphaEntity){
		String sql = CoreXmlSqlParsersFactory.getSql("QualityMsc.updateCustAlphaState");
		return EntityTool.fillSqlByEntity(sql, custAlphaEntity);
	}
	
	
	/**
	 * 修改客户要求主表。
	 * @param strJSON
	 * @return
	 */
	public CoreReturnObject updateCustAlphaStateSql(String strJSON, ArrayList<String[]> list,
			String userDept){
		JSONObject obj = JSONObject.fromObject(strJSON);
		SlmCustAlphaEntity custAlphaEntity = (SlmCustAlphaEntity)JSONObject.toBean(obj, SlmCustAlphaEntity.class);
		
		String sqlUpdateCustAlphaState = getUpdateCustAlphaStateSql(custAlphaEntity);
		
		CoreReturnObject core = new CoreReturnObject();
        Connection con = this.getDao(CoreConstantData.sysbeanstr)
                .getConnection();
        try {
            con.setAutoCommit(false);
            CoreOrderReviewTechnology technology = new CoreOrderReviewTechnology();
            core = technology.doCommit(list, userDept, custAlphaEntity.getCreateName(),
            		custAlphaEntity.getReviewFRs(), "0", con);
            if(!core.getV_errMsg().equals("")){
            	con.rollback();
            	core.setResult(0);
            	return core;
            }
            PreparedStatement ps = con.prepareStatement(sqlUpdateCustAlphaState);
            ps.executeUpdate();
            con.commit();
        }
        catch (SQLException e) {
            try {
                con.rollback();
                core.setV_errMsg(e.getMessage());
            }
            catch (SQLException e1) {
                e1.printStackTrace();
            }
            e.printStackTrace();
        }
        finally {
            try {
                con.close();
            }
            catch (Exception ex) {

            }
        }
        core.setResult(0);
        return core;
	}
	
	/**
     * 查询PSC中的科室
     * @param psc psc
     * @return obj
     */
    public CoreReturnObject queryUnitCodeByPsc(String psc){
    	String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryUnitCodeByPsc");
    	sql = StringTool.ReplaceAll(sql, "#PSC#", psc);
    	
    	return this.getData(sql);
    }
    
    private MscEntity queryMscRow(String msc){
    	Connection con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
    	String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryMscRow");
    	sql = StringTool.ReplaceAll(sql, "#MSC#", msc);
    	ArrayList<MscEntity> mscList = EntityTool.getEntitysBySql(sql, con, MscEntity.class);
    	
    	return mscList.get(0);
    }
    
    public CoreReturnObject setAlphaRCust(String msc, String userCode, String userDesc, String createName){
    	Connection con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
    	String sqlAlphaCustCnt = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryAlphaRCustCnt");
    	sqlAlphaCustCnt = StringTool.ReplaceAll(sqlAlphaCustCnt, "#MSC#", msc);
    	sqlAlphaCustCnt = StringTool.ReplaceAll(sqlAlphaCustCnt, "#CUST_CODE#", userCode);
    	GenericEntity alphaRCustCnt = EntityTool.getEntityBySql(sqlAlphaCustCnt, con, GenericEntity.class);
    	if(alphaRCustCnt.getCount().equals("0") == false){
    		CoreReturnObject cro = new CoreReturnObject();
    		cro.setResult(1);
    		cro.setV_errCode(1);
    		return cro;
    	}
    	MscEntity mscRow = queryMscRow(msc);
    	BaseStdRCustEntity custRow = new BaseStdRCustEntity();
    	custRow.setCreateName(createName);
    	custRow.setCustCode(userCode);
    	custRow.setCustName(userDesc);
    	custRow.setStdCode(mscRow.getUseCode());
    	custRow.setStdName(mscRow.getUseDesc());
    	
    	String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.insertAlphaRCust");
    	sql = EntityTool.fillSqlByEntity(sql, custRow);
    	return this.setData(sql);
    }
    
    /**
     * 验证技术特殊要求是否完全重复（6项要求完全一致）
     * @param allData
     * @param custNo
     * @param psc
     * @param tmpCustAlphaNo
     * @return
     */
    public CoreReturnObject isExistSameData(ArrayList<ArrayList<String>> allData, ArrayList<String> list2){
    	String custNo = list2.get(0);
    	String psc = list2.get(1);
    	String tmpCustAlphaNo = list2.get(2);
    	String isCheckAlpha = list2.get(3);
    	String dimater = "";
    	try{
    		dimater = String.valueOf(Double.parseDouble(list2.get(4)));
    	}catch(Exception ex){
    		dimater = "";
    	}
    	String height = "";
    	try{
    		height = String.valueOf(Double.parseDouble(list2.get(5)));
    	}catch(Exception ex){
    		dimater = "";
    	}
    	String model = list2.get(6);
    	String specStyle = list2.get(7);
    	String specCode = list2.get(8);
    	String specName = list2.get(9);
    	if(specStyle.equals("C")){
    		dimater = "";
    		height = "";
    	}else{
    		specCode = "";
    		specName = "";
    	}
    	String dDivH = dimater.equals("") ? "" : String.valueOf(Double.parseDouble(dimater) / Double.parseDouble(height));
    	String hDivD = dimater.equals("") ? "" : String.valueOf(Double.parseDouble(height) / Double.parseDouble(dimater));
    	String dSubH = dimater.equals("") ? "" : String.valueOf(Double.parseDouble(dimater) - Double.parseDouble(height));
    	CoreReturnObject cro = new CoreReturnObject();
    	boolean result = false;
    	String mscOrCustAlphaNo = "";
    	String cic = "";
    	String pic = "";
    	String sic = "";
    	String dic = "";
    	String wic = "";
    	String gic = "";
    	ArrayList<Object> chemData = new ArrayList<Object>();
    	ArrayList<Object> phyData = new ArrayList<Object>();
    	ArrayList<Object> specData = new ArrayList<Object>();
    	ArrayList<Object> detectionData = new ArrayList<Object>();
    	ArrayList<Object> waterData = new ArrayList<Object>();
    	ArrayList<Object> processData = new ArrayList<Object>();
    	int flag = 0; // 0完全新增（新增MSC）1新增索引码  2融合MSCn, 3完全一致
    	
    	int allCount = 0;
    	for(ArrayList<String> data : allData){
    			allCount += data.size();
    	}
    	
    	
    	//比较产品下的所有交付标准
    	String sqlGetMscs = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscByPsc");
    	sqlGetMscs = StringTool.ReplaceAll(sqlGetMscs, "#PSC#", psc);
    	sqlGetMscs = StringTool.ReplaceAll(sqlGetMscs, "#DIMATER#", dimater);
    	sqlGetMscs = StringTool.ReplaceAll(sqlGetMscs, "#HEIGHT#", height);
    	sqlGetMscs = StringTool.ReplaceAll(sqlGetMscs, "#DIMATER/HEIGHT#", dDivH);
    	sqlGetMscs = StringTool.ReplaceAll(sqlGetMscs, "#HEIGHT/DIMATER#", hDivD);
    	sqlGetMscs = StringTool.ReplaceAll(sqlGetMscs, "#DIMATER-HEIGHT#", dSubH);
    	Connection con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
    	ArrayList<GenericEntity> listMscs = EntityTool.getEntitysBySql(sqlGetMscs, con, GenericEntity.class);
    	for(GenericEntity msc : listMscs){
    		//if(Integer.parseInt(msc.getCount()) != allCount) continue;
    		//boolean isSameDataWithNoSpec = true;
    		
    		flag = 0;// 0:完全新增  1：在指定的MSCn下新增一个索引码  2:在现有的索引码下新增记录  -1:没有相同的项目。
    		result = false;
			chemData.clear();
			phyData.clear();
			specData.clear();
			detectionData.clear();
			waterData.clear();
			processData.clear();
			cic = "";
			pic = "";
			sic = "";
			dic = "";
			wic = "";
			gic = "";
    		
    		//成分
    		String sqlGetMscCics = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscCic");
			sqlGetMscCics = StringTool.ReplaceAll(sqlGetMscCics, "#MSC#", msc.getValue());
			sqlGetMscCics = StringTool.ReplaceAll(sqlGetMscCics, "#MODEL_CODE#", model);
			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			ArrayList<GenericEntity> listMscCics = EntityTool.getEntitysBySql(sqlGetMscCics, con, GenericEntity.class);
			if((listMscCics.size() == 0 && allData.get(0).size() != 0) 
					|| (listMscCics.size() != 0 && allData.get(0).size() == 0)){
				flag = 0;
				continue;
			} 
			for(GenericEntity mscCics : listMscCics){
				chemData.clear();
				//当合同扣型选择/，如果没有找到/或者扣型为空的，则完全新增。
//	        	if(model.equals("C001") && !mscCics.getValue2().equals("") && mscCics.getValue2().indexOf("C001") < 0){
//	        		flag = 0;
//	        		break;
//	        	}
	        	
				if(Integer.parseInt(mscCics.getCount()) == allData.get(0).size()){
					
					//不带规格、值查询
					for(String strJSON : allData.get(0)){
						SlmCustChemObject chemEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustChemObject.class);
		    			String sqlGetMscChem = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscChem1");
		    			sqlGetMscChem = StringTool.ReplaceAll(sqlGetMscChem, "#CIC#", mscCics.getValue());
		    			sqlGetMscChem = EntityTool.fillSqlByEntity(sqlGetMscChem, chemEntity);
		    			Connection con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
		    			ArrayList<GenericEntity> listMscChem = EntityTool.getEntitysBySql(sqlGetMscChem, con2, GenericEntity.class);
		    			if(Integer.parseInt(listMscChem.get(0).getCount()) == 0){
		    				flag = 0;
		    				break;
		    			}else{
		    				flag = 2;
		    			}
					}
					
					if(flag == 0) continue;
					//带规格、值查询
		    		for(String strJSON : allData.get(0)){
						SlmCustChemObject chemEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustChemObject.class);
						//带规格、值查询
		    			String sqlGetMscChem = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscChem2");
		    			sqlGetMscChem = StringTool.ReplaceAll(sqlGetMscChem, "#CIC#", mscCics.getValue());
		    			sqlGetMscChem = StringTool.ReplaceAll(sqlGetMscChem, "#DIMATER#", dimater);
		    			sqlGetMscChem = StringTool.ReplaceAll(sqlGetMscChem, "#HEIGHT#", height);
		    			sqlGetMscChem = StringTool.ReplaceAll(sqlGetMscChem, "#DIMATER/HEIGHT#", dDivH);
		    			sqlGetMscChem = StringTool.ReplaceAll(sqlGetMscChem, "#HEIGHT/DIMATER#", hDivD);
		    			sqlGetMscChem = StringTool.ReplaceAll(sqlGetMscChem, "#DIMATER-HEIGHT#", dSubH);
		    			sqlGetMscChem = StringTool.ReplaceAll(sqlGetMscChem, "#SPEC_JG#", specCode);
		    			sqlGetMscChem = EntityTool.fillSqlByEntity(sqlGetMscChem, chemEntity);
		    			Connection con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
		    			ArrayList<GenericEntity> listMscChem = EntityTool.getEntitysBySql(sqlGetMscChem, con2, GenericEntity.class);
		    			int mscChemCnt = Integer.parseInt(listMscChem.get(0).getCount());
		    			
		    			if(mscChemCnt > 0){
		    				cic = mscCics.getValue();
		    				flag = 3;
		    			}else{
		    				cic = "";
		    				flag = 2;
		    				break;
		    			}
		    		}
		    		if(!cic.equals("")){
		    			break;
		    		}
				}else{
					flag = 0;
				}
			}
			
			if(flag == 0 && (listMscCics.size() != 0 || allData.get(0).size() != 0)) continue;
			
			if(cic.equals("")){
				for(GenericEntity mscCics : listMscCics){
					chemData.clear();
					//当合同扣型选择/，如果没有找到/或者扣型为空的，则完全新增。
//		        	if(model.equals("C001") && !mscCics.getValue2().equals("") && mscCics.getValue2().indexOf("C001") < 0){
//		        		flag = 0;
//		        		break;
//		        	}
					
					if(Integer.parseInt(mscCics.getCount()) == allData.get(0).size()){
						
						//不带规格、值查询
						for(String strJSON : allData.get(0)){
							SlmCustChemObject chemEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustChemObject.class);
			    			String sqlGetMscChem = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscChem1");
			    			sqlGetMscChem = StringTool.ReplaceAll(sqlGetMscChem, "#CIC#", mscCics.getValue());
			    			sqlGetMscChem = EntityTool.fillSqlByEntity(sqlGetMscChem, chemEntity);
			    			Connection con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			    			ArrayList<GenericEntity> listMscChem = EntityTool.getEntitysBySql(sqlGetMscChem, con2, GenericEntity.class);
			    			if(Integer.parseInt(listMscChem.get(0).getCount()) == 0){
			    				flag = 0;
			    				break;
			    			}else{
			    				flag = 2;
			    			}
						}
						
						if(flag == 0) continue;
						
			    		for(String strJSON : allData.get(0)){
							SlmCustChemObject chemEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustChemObject.class);
							
			    			String sqlGetMscChem = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscChem6");
			    			sqlGetMscChem = StringTool.ReplaceAll(sqlGetMscChem, "#CIC#", mscCics.getValue());
			    			sqlGetMscChem = StringTool.ReplaceAll(sqlGetMscChem, "#DIMATER#", dimater);
			    			sqlGetMscChem = StringTool.ReplaceAll(sqlGetMscChem, "#HEIGHT#", height);
			    			sqlGetMscChem = StringTool.ReplaceAll(sqlGetMscChem, "#DIMATER/HEIGHT#", dDivH);
			    			sqlGetMscChem = StringTool.ReplaceAll(sqlGetMscChem, "#HEIGHT/DIMATER#", hDivD);
			    			sqlGetMscChem = StringTool.ReplaceAll(sqlGetMscChem, "#DIMATER-HEIGHT#", dSubH);
			    			sqlGetMscChem = StringTool.ReplaceAll(sqlGetMscChem, "#MODEL_CODE#", model);
			    			sqlGetMscChem = StringTool.ReplaceAll(sqlGetMscChem, "#SPEC_JG#", specCode);
			    			sqlGetMscChem = EntityTool.fillSqlByEntity(sqlGetMscChem, chemEntity);
			    			Connection con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			    			ArrayList<GenericEntity> listMscChem = EntityTool.getEntitysBySql(sqlGetMscChem, con2, GenericEntity.class);
			    			int mscChemCnt = Integer.parseInt(listMscChem.get(0).getCount());
			    			
			    			String sqlGetMscChem2 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscChem2");
			    			sqlGetMscChem2 = StringTool.ReplaceAll(sqlGetMscChem2, "#CIC#", mscCics.getValue());
			    			sqlGetMscChem2 = StringTool.ReplaceAll(sqlGetMscChem2, "#DIMATER#", dimater);
			    			sqlGetMscChem2 = StringTool.ReplaceAll(sqlGetMscChem2, "#HEIGHT#", height);
			    			sqlGetMscChem2 = StringTool.ReplaceAll(sqlGetMscChem2, "#DIMATER/HEIGHT#", dDivH);
			    			sqlGetMscChem2 = StringTool.ReplaceAll(sqlGetMscChem2, "#HEIGHT/DIMATER#", hDivD);
			    			sqlGetMscChem2 = StringTool.ReplaceAll(sqlGetMscChem2, "#DIMATER-HEIGHT#", dSubH);
			    			sqlGetMscChem2 = StringTool.ReplaceAll(sqlGetMscChem2, "#SPEC_JG#", specCode);
			    			sqlGetMscChem2 = EntityTool.fillSqlByEntity(sqlGetMscChem2, chemEntity);
			    			con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			    			ArrayList<GenericEntity> listMscChem2 = EntityTool.getEntitysBySql(sqlGetMscChem2, con2, GenericEntity.class);
			    			int mscChemCnt2 = Integer.parseInt(listMscChem2.get(0).getCount());
			    			
			    			if(mscChemCnt == 0){
			    				cic = mscCics.getValue();
			    				chemData.add(chemEntity);
			    			}else{
			    				if(mscChemCnt2 == 0){
				    				cic = "";
				    				chemData.clear();
				    				flag = 0;
				    				break;
			    				}else{
			    					cic = mscCics.getValue();
			    				}
			    			}
			    		}
			    		if(!cic.equals("") || flag == 0){
			    			break;
			    		}
					}else{
						flag = 0;
					}
				}
				}
			
			//if()
    		if(flag == 0  && (listMscCics.size() != 0 || allData.get(0).size() != 0)) continue;
			
    		//理化
    		String sqlGetMscPics = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscPic");
			sqlGetMscPics = StringTool.ReplaceAll(sqlGetMscPics, "#MSC#", msc.getValue());
			sqlGetMscPics = StringTool.ReplaceAll(sqlGetMscPics, "#MODEL_CODE#", model);
			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			ArrayList<GenericEntity> listMscPics = EntityTool.getEntitysBySql(sqlGetMscPics, con, GenericEntity.class);
			if((listMscPics.size() == 0 && allData.get(1).size() != 0) 
					|| (listMscPics.size() != 0 && allData.get(1).size() == 0)){
				flag = 0;
				continue;
			}
			for(GenericEntity mscPics : listMscPics){
				if(Integer.parseInt(mscPics.getCount()) == allData.get(1).size()){
					phyData.clear();
					//当合同扣型选择/，如果没有找到/或者扣型为空的，则完全新增。
//		        	if(model.equals("C001") && !mscPics.getValue2().equals("") && mscPics.getValue2().indexOf("C001") < 0){
//		        		flag = 0;
//		        		break;
//		        	}
					
					for(String strJSON : allData.get(1)){
						SlmCustPhyObject phyEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustPhyObject.class);
		    			String sqlGetMscPhy = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscPhy1");
		    			sqlGetMscPhy = StringTool.ReplaceAll(sqlGetMscPhy, "#PIC#", mscPics.getValue());
		    			sqlGetMscPhy = EntityTool.fillSqlByEntity(sqlGetMscPhy, phyEntity);
		    			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
		    			ArrayList<GenericEntity> listMscPhy = EntityTool.getEntitysBySql(sqlGetMscPhy, con, GenericEntity.class);
		    			if(listMscPhy.get(0).getCount().equals("0")){
		    				flag = 0;
		    				break;
		    			}else{
		    				flag = 2;
		    			}
		    		}
					
					if(flag == 0) continue;
		    		for(String strJSON : allData.get(1)){
						SlmCustPhyObject phyEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustPhyObject.class);
		    			String sqlGetMscPhy = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscPhy2");
		    			sqlGetMscPhy = StringTool.ReplaceAll(sqlGetMscPhy, "#PIC#", mscPics.getValue());
		    			sqlGetMscPhy = StringTool.ReplaceAll(sqlGetMscPhy, "#DIMATER#", dimater);
		    			sqlGetMscPhy = StringTool.ReplaceAll(sqlGetMscPhy, "#HEIGHT#", height);
		    			sqlGetMscPhy = StringTool.ReplaceAll(sqlGetMscPhy, "#DIMATER/HEIGHT#", dDivH);
		    			sqlGetMscPhy = StringTool.ReplaceAll(sqlGetMscPhy, "#HEIGHT/DIMATER#", hDivD);
		    			sqlGetMscPhy = StringTool.ReplaceAll(sqlGetMscPhy, "#DIMATER-HEIGHT#", dSubH);
		    			sqlGetMscPhy = StringTool.ReplaceAll(sqlGetMscPhy, "#SPEC_JG#", specCode);
		    			sqlGetMscPhy = EntityTool.fillSqlByEntity(sqlGetMscPhy, phyEntity);
		    			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
		    			ArrayList<GenericEntity> listMscPhy = EntityTool.getEntitysBySql(sqlGetMscPhy, con, GenericEntity.class);
		    			int mscPhyCnt = Integer.parseInt(listMscPhy.get(0).getCount());
		    			
		    			if(mscPhyCnt > 0){
		    				pic = mscPics.getValue();
		    				flag = 3;
		    			}else{
		    				pic = "";
		    				flag = 2;
		    				break;
		    			}
		    		}
		    		if(!pic.equals("")){
		    			break;
		    		}
				}else{
					flag = 0;
				}
			}
			
			
			
			if(flag == 0 && (listMscPics.size() != 0 || allData.get(1).size() != 0)) continue;
			
			if(pic.equals("")){
				for(GenericEntity mscPics : listMscPics){
					if(Integer.parseInt(mscPics.getCount()) == allData.get(1).size()){
						phyData.clear();
						//当合同扣型选择/，如果没有找到/或者扣型为空的，则完全新增。
//			        	if(model.equals("C001") && !mscPics.getValue2().equals("") && mscPics.getValue2().indexOf("C001") < 0){
//			        		flag = 0;
//			        		break;
//			        	}
						
						for(String strJSON : allData.get(1)){
							SlmCustPhyObject phyEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustPhyObject.class);
			    			String sqlGetMscPhy = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscPhy1");
			    			sqlGetMscPhy = StringTool.ReplaceAll(sqlGetMscPhy, "#PIC#", mscPics.getValue());
			    			sqlGetMscPhy = EntityTool.fillSqlByEntity(sqlGetMscPhy, phyEntity);
			    			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			    			ArrayList<GenericEntity> listMscPhy = EntityTool.getEntitysBySql(sqlGetMscPhy, con, GenericEntity.class);
			    			if(listMscPhy.get(0).getCount().equals("0")){
			    				flag = 0;
			    				break;
			    			}else{
			    				flag = 2;
			    			}
			    		}
						
						if(flag == 0) continue;
			    		for(String strJSON : allData.get(1)){
							SlmCustPhyObject phyEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustPhyObject.class);
			    			String sqlGetMscPhy = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscPhy6");
			    			sqlGetMscPhy = StringTool.ReplaceAll(sqlGetMscPhy, "#PIC#", mscPics.getValue());
			    			sqlGetMscPhy = StringTool.ReplaceAll(sqlGetMscPhy, "#DIMATER#", dimater);
			    			sqlGetMscPhy = StringTool.ReplaceAll(sqlGetMscPhy, "#HEIGHT#", height);
			    			sqlGetMscPhy = StringTool.ReplaceAll(sqlGetMscPhy, "#DIMATER/HEIGHT#", dDivH);
			    			sqlGetMscPhy = StringTool.ReplaceAll(sqlGetMscPhy, "#HEIGHT/DIMATER#", hDivD);
			    			sqlGetMscPhy = StringTool.ReplaceAll(sqlGetMscPhy, "#DIMATER-HEIGHT#", dSubH);
			    			sqlGetMscPhy = StringTool.ReplaceAll(sqlGetMscPhy, "#SPEC_JG#", specCode);
			    			sqlGetMscPhy = EntityTool.fillSqlByEntity(sqlGetMscPhy, phyEntity);
			    			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			    			ArrayList<GenericEntity> listMscPhy = EntityTool.getEntitysBySql(sqlGetMscPhy, con, GenericEntity.class);
			    			int mscPhyCnt = Integer.parseInt(listMscPhy.get(0).getCount());
			    			
			    			String sqlGetMscPhy2 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscPhy2");
			    			sqlGetMscPhy2 = StringTool.ReplaceAll(sqlGetMscPhy2, "#PIC#", mscPics.getValue());
			    			sqlGetMscPhy2 = StringTool.ReplaceAll(sqlGetMscPhy2, "#DIMATER#", dimater);
			    			sqlGetMscPhy2 = StringTool.ReplaceAll(sqlGetMscPhy2, "#HEIGHT#", height);
			    			sqlGetMscPhy2 = StringTool.ReplaceAll(sqlGetMscPhy2, "#DIMATER/HEIGHT#", dDivH);
			    			sqlGetMscPhy2 = StringTool.ReplaceAll(sqlGetMscPhy2, "#HEIGHT/DIMATER#", hDivD);
			    			sqlGetMscPhy2 = StringTool.ReplaceAll(sqlGetMscPhy2, "#DIMATER-HEIGHT#", dSubH);
			    			sqlGetMscPhy2 = StringTool.ReplaceAll(sqlGetMscPhy2, "#SPEC_JG#", specCode);
			    			sqlGetMscPhy2 = EntityTool.fillSqlByEntity(sqlGetMscPhy2, phyEntity);
			    			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			    			ArrayList<GenericEntity> listMscPhy2 = EntityTool.getEntitysBySql(sqlGetMscPhy2, con, GenericEntity.class);
			    			int mscPhyCnt2 = Integer.parseInt(listMscPhy2.get(0).getCount());
			    			
			    			if(mscPhyCnt == 0){
			    				pic = mscPics.getValue();
			    				phyData.add(phyEntity);
			    			}else{
			    				if(mscPhyCnt2 == 0){
			    					pic = "";
				    				phyData.clear();
				    				flag = 0;
				    				break;
			    				}else{
			    					pic = mscPics.getValue();
			    				}
			    			}
			    		}
			    		if(!pic.equals("")){
			    			break;
			    		}
					}else{
						flag = 0;
					}
				}
			}
			
			if(flag == 0 && (listMscPics.size() != 0 || allData.get(1).size() != 0)) continue;
			
    		//公差
    		String sqlGetMscSics = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscSic");
			sqlGetMscSics = StringTool.ReplaceAll(sqlGetMscSics, "#MSC#", msc.getValue());
			sqlGetMscSics = StringTool.ReplaceAll(sqlGetMscSics, "#MODEL_CODE#", model);
			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			ArrayList<GenericEntity> listMscSics = EntityTool.getEntitysBySql(sqlGetMscSics, con, GenericEntity.class);
			if((listMscSics.size() == 0 && allData.get(2).size() != 0) 
					|| (listMscSics.size() != 0 && allData.get(2).size() == 0)){
				flag = 0;
				continue;
			}
			for(GenericEntity mscSics : listMscSics){
				if(Integer.parseInt(mscSics.getCount()) == allData.get(2).size()){
					specData.clear();
					//当合同扣型选择/，如果没有找到/或者扣型为空的，则完全新增。
//		        	if(model.equals("C001") && !mscSics.getValue2().equals("") && mscSics.getValue2().indexOf("C001") < 0){
//		        		flag = 0;
//		        		break;
//		        	}
					
					for(String strJSON : allData.get(2)){
	    				SlmCustSpecObject specEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustSpecObject.class);
	        			String sqlGetMscSpec = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscSpec1");
	        			sqlGetMscSpec = StringTool.ReplaceAll(sqlGetMscSpec, "#SIC#", mscSics.getValue());
	        			sqlGetMscSpec = EntityTool.fillSqlByEntity(sqlGetMscSpec, specEntity);
	        			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
	        			ArrayList<GenericEntity> listMscSpec = EntityTool.getEntitysBySql(sqlGetMscSpec, con, GenericEntity.class);
	        			if(listMscSpec.get(0).getCount().equals("0")){
	        				flag = 0;
	        				break;
	        			}else{
	        				flag = 2;
	        			}
		    		}
					if(flag == 0) continue;
		    		for(String strJSON : allData.get(2)){
	    				SlmCustSpecObject specEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustSpecObject.class);
	        			String sqlGetMscSpec = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscSpec2");
	        			sqlGetMscSpec = StringTool.ReplaceAll(sqlGetMscSpec, "#MSC#", msc.getValue());
	        			sqlGetMscSpec = StringTool.ReplaceAll(sqlGetMscSpec, "#DIMATER#", dimater);
	        			sqlGetMscSpec = StringTool.ReplaceAll(sqlGetMscSpec, "#HEIGHT#", height);
	        			sqlGetMscSpec = StringTool.ReplaceAll(sqlGetMscSpec, "#DIMATER/HEIGHT#", dDivH);
	        			sqlGetMscSpec = StringTool.ReplaceAll(sqlGetMscSpec, "#HEIGHT/DIMATER#", hDivD);
	        			sqlGetMscSpec = StringTool.ReplaceAll(sqlGetMscSpec, "#DIMATER-HEIGHT#", dSubH);
	        			sqlGetMscSpec = StringTool.ReplaceAll(sqlGetMscSpec, "#SIC#", mscSics.getValue());
	        			sqlGetMscSpec = EntityTool.fillSqlByEntity(sqlGetMscSpec, specEntity);
	        			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
	        			ArrayList<GenericEntity> listMscSpec = EntityTool.getEntitysBySql(sqlGetMscSpec, con, GenericEntity.class);
	        			int mscSpecCnt = Integer.parseInt(listMscSpec.get(0).getCount());
	        			
	        			if(mscSpecCnt > 0){
		    				sic = mscSics.getValue();
		    				flag = 3;
		    			}else{
		    				sic = "";
		    				flag = 2;
		    				break;
		    			}
		    		}
		    		if(!sic.equals("")){
		    			break;
		    		}
				}else{
					flag = 0;
				}
			}
			
			if(flag == 0 && (listMscSics.size() != 0 || allData.get(2).size() != 0)) continue;
			
			if(sic.equals("")){
				for(GenericEntity mscSics : listMscSics){
					if(Integer.parseInt(mscSics.getCount()) == allData.get(2).size()){
						specData.clear();
						//当合同扣型选择/，如果没有找到/或者扣型为空的，则完全新增。
//			        	if(model.equals("C001") && !mscSics.getValue2().equals("") && mscSics.getValue2().indexOf("C001") < 0){
//			        		flag = 0;
//			        		break;
//			        	}
						
						for(String strJSON : allData.get(2)){
		    				SlmCustSpecObject specEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustSpecObject.class);
		        			String sqlGetMscSpec = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscSpec1");
		        			sqlGetMscSpec = StringTool.ReplaceAll(sqlGetMscSpec, "#SIC#", mscSics.getValue());
		        			sqlGetMscSpec = EntityTool.fillSqlByEntity(sqlGetMscSpec, specEntity);
		        			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
		        			ArrayList<GenericEntity> listMscSpec = EntityTool.getEntitysBySql(sqlGetMscSpec, con, GenericEntity.class);
		        			if(listMscSpec.get(0).getCount().equals("0")){
		        				flag = 0;
		        				break;
		        			}else{
		        				flag = 2;
		        			}
			    		}
						
						if(flag == 0) continue;
			    		for(String strJSON : allData.get(2)){
		    				SlmCustSpecObject specEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustSpecObject.class);
		        			String sqlGetMscSpec = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscSpec6");
		        			sqlGetMscSpec = StringTool.ReplaceAll(sqlGetMscSpec, "#MSC#", msc.getValue());
		        			sqlGetMscSpec = StringTool.ReplaceAll(sqlGetMscSpec, "#DIMATER#", dimater);
		        			sqlGetMscSpec = StringTool.ReplaceAll(sqlGetMscSpec, "#HEIGHT#", height);
		        			sqlGetMscSpec = StringTool.ReplaceAll(sqlGetMscSpec, "#DIMATER/HEIGHT#", dDivH);
		        			sqlGetMscSpec = StringTool.ReplaceAll(sqlGetMscSpec, "#HEIGHT/DIMATER#", hDivD);
		        			sqlGetMscSpec = StringTool.ReplaceAll(sqlGetMscSpec, "#DIMATER-HEIGHT#", dSubH);
		        			sqlGetMscSpec = StringTool.ReplaceAll(sqlGetMscSpec, "#MODEL_CODE#", model);
		        			sqlGetMscSpec = StringTool.ReplaceAll(sqlGetMscSpec, "#SIC#", mscSics.getValue());
		        			sqlGetMscSpec = EntityTool.fillSqlByEntity(sqlGetMscSpec, specEntity);
		        			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
		        			ArrayList<GenericEntity> listMscSpec = EntityTool.getEntitysBySql(sqlGetMscSpec, con, GenericEntity.class);
		        			int mscSpecCnt = Integer.parseInt(listMscSpec.get(0).getCount());
		        			
		        			String sqlGetMscSpec2 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscSpec2");
		        			sqlGetMscSpec2 = StringTool.ReplaceAll(sqlGetMscSpec2, "#MSC#", msc.getValue());
		        			sqlGetMscSpec2 = StringTool.ReplaceAll(sqlGetMscSpec2, "#DIMATER#", dimater);
		        			sqlGetMscSpec2 = StringTool.ReplaceAll(sqlGetMscSpec2, "#HEIGHT#", height);
		        			sqlGetMscSpec2 = StringTool.ReplaceAll(sqlGetMscSpec2, "#DIMATER/HEIGHT#", dDivH);
		        			sqlGetMscSpec2 = StringTool.ReplaceAll(sqlGetMscSpec2, "#HEIGHT/DIMATER#", hDivD);
		        			sqlGetMscSpec2 = StringTool.ReplaceAll(sqlGetMscSpec2, "#DIMATER-HEIGHT#", dSubH);
		        			sqlGetMscSpec2 = StringTool.ReplaceAll(sqlGetMscSpec2, "#SIC#", mscSics.getValue());
		        			sqlGetMscSpec2 = EntityTool.fillSqlByEntity(sqlGetMscSpec2, specEntity);
		        			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
		        			ArrayList<GenericEntity> listMscSpec2 = EntityTool.getEntitysBySql(sqlGetMscSpec2, con, GenericEntity.class);
		        			int mscSpecCnt2 = Integer.parseInt(listMscSpec2.get(0).getCount());
		        			
		        			if(mscSpecCnt == 0){
			    				sic = mscSics.getValue();
			    				specData.add(specEntity);
			    			}else{
			    				if(mscSpecCnt2 == 0){
			    					sic = "";
				    				specData.clear();
				    				flag = 0;
				    				break;
			    				}else{
			    					sic = mscSics.getValue();
			    				}
			    			}
			    		}
			    		if(flag == 0){
			    			break;
			    		}
					}else{
						flag = 0;
					}
				}
			}
			
			if(flag == 0 && (listMscSics.size() != 0 || allData.get(2).size() != 0)) continue;
    		
    		//探伤
    		String sqlGetMscDics = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscDic");
			sqlGetMscDics = StringTool.ReplaceAll(sqlGetMscDics, "#MSC#", msc.getValue());
			sqlGetMscDics = StringTool.ReplaceAll(sqlGetMscDics, "#MODEL_CODE#", model);
			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			ArrayList<GenericEntity> listMscDics = EntityTool.getEntitysBySql(sqlGetMscDics, con, GenericEntity.class);
			if((listMscDics.size() == 0 && allData.get(3).size() != 0) 
					|| (listMscDics.size() != 0 && allData.get(3).size() == 0)){
				flag = 0;
				continue;
			}
			for(GenericEntity mscDics : listMscDics){
				if(Integer.parseInt(mscDics.getCount()) == allData.get(3).size()){
					detectionData.clear();
					//当合同扣型选择/，如果没有找到/或者扣型为空的，则完全新增。
//		        	if(model.equals("C001") && !mscDics.getValue2().equals("") && mscDics.getValue2().indexOf("C001") < 0){
//		        		flag = 0;
//		        		break;
//		        	}
					
					for(String strJSON : allData.get(3)){
						SlmCustDetectionObject detectionEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustDetectionObject.class);
		    			String sqlGetMscDetection = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscDetection1");
		    			sqlGetMscDetection = StringTool.ReplaceAll(sqlGetMscDetection, "#DIC#", mscDics.getValue());
		    			sqlGetMscDetection = EntityTool.fillSqlByEntity(sqlGetMscDetection, detectionEntity);
		    			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
		    			ArrayList<GenericEntity> listMscDetection = EntityTool.getEntitysBySql(sqlGetMscDetection, con, GenericEntity.class);
		    			if(listMscDetection.get(0).getCount().equals("0")){
		    				flag = 0;
		    				break;
		    			}else{
		    				flag = 2;
		    			}
		    		}
					
					if(flag == 0) continue;
		    		for(String strJSON : allData.get(3)){
						SlmCustDetectionObject detectionEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustDetectionObject.class);
		    			String sqlGetMscDetection = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscDetection2");
		    			sqlGetMscDetection = StringTool.ReplaceAll(sqlGetMscDetection, "#DIC#", mscDics.getValue());
		    			sqlGetMscDetection = StringTool.ReplaceAll(sqlGetMscDetection, "#DIMATER#", dimater);
		    			sqlGetMscDetection = StringTool.ReplaceAll(sqlGetMscDetection, "#HEIGHT#", height);
		    			sqlGetMscDetection = EntityTool.fillSqlByEntity(sqlGetMscDetection, detectionEntity);
		    			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
		    			ArrayList<GenericEntity> listMscDetection = EntityTool.getEntitysBySql(sqlGetMscDetection, con, GenericEntity.class);
		    			int mscDetectionCnt = Integer.parseInt(listMscDetection.get(0).getCount());
		    			
		    			if(mscDetectionCnt > 0){
		    				dic = mscDics.getValue();
		    				flag = 3;
		    			}else{
		    				dic = "";
		    				flag = 2;
		    				break;
		    			}
		    		}
		    		if(!dic.equals("")){
		    			break;
		    		}
				}else{
					flag = 0;
				}
			}
			
			
//			if(dic.equals("")){
//				for(GenericEntity mscDics : listMscDics){
//					if(Integer.parseInt(mscDics.getCount()) == allData.get(3).size()){
//						detectionData.clear();
//						
//						for(String strJSON : allData.get(3)){
//							SlmCustDetectionObject detectionEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustDetectionObject.class);
//			    			String sqlGetMscDetection = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscDetection1");
//			    			sqlGetMscDetection = StringTool.ReplaceAll(sqlGetMscDetection, "#DIC#", mscDics.getValue());
//			    			sqlGetMscDetection = EntityTool.fillSqlByEntity(sqlGetMscDetection, detectionEntity);
//			    			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
//			    			ArrayList<GenericEntity> listMscDetection = EntityTool.getEntitysBySql(sqlGetMscDetection, con, GenericEntity.class);
//			    			if(listMscDetection.get(0).getCount().equals("0")){
//			    				flag = 0;
//			    				break;
//			    			}else{
//			    				flag = 2;
//			    			}
//			    		}
//						
//						if(flag == 0) continue;
//			    		for(String strJSON : allData.get(3)){
//							SlmCustDetectionObject detectionEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustDetectionObject.class);
//			    			String sqlGetMscDetection = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscDetection4");
//			    			sqlGetMscDetection = StringTool.ReplaceAll(sqlGetMscDetection, "#DIC#", mscDics.getValue());
//			    			sqlGetMscDetection = StringTool.ReplaceAll(sqlGetMscDetection, "#DIMATER#", dimater);
//			    			sqlGetMscDetection = StringTool.ReplaceAll(sqlGetMscDetection, "#HEIGHT#", height);
//			    			sqlGetMscDetection = StringTool.ReplaceAll(sqlGetMscDetection, "#MODEL_CODE#", model);
//			    			sqlGetMscDetection = EntityTool.fillSqlByEntity(sqlGetMscDetection, detectionEntity);
//			    			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
//			    			ArrayList<GenericEntity> listMscDetection = EntityTool.getEntitysBySql(sqlGetMscDetection, con, GenericEntity.class);
//			    			int mscDetectionCnt = Integer.parseInt(listMscDetection.get(0).getCount());
//			    			
//			    			if(mscDetectionCnt > 0){
//			    				flag = 0;
//			    				break;
//			    			}
//			    		}
//			    		if(flag == 0){
//			    			break;
//			    		}
//					}else{
//						flag = 0;
//					}
//				}
//				}
			
			if(flag == 0 && (listMscDics.size() != 0 || allData.get(3).size() != 0)) continue;
			
			if(dic.equals("")){
				for(GenericEntity mscDics : listMscDics){
					if(Integer.parseInt(mscDics.getCount()) == allData.get(3).size()){
						detectionData.clear();
						//当合同扣型选择/，如果没有找到/或者扣型为空的，则完全新增。
//			        	if(model.equals("C001") && !mscDics.getValue2().equals("") && mscDics.getValue2().indexOf("C001") < 0){
//			        		flag = 0;
//			        		break;
//			        	}
						
						for(String strJSON : allData.get(3)){
							SlmCustDetectionObject detectionEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustDetectionObject.class);
			    			String sqlGetMscDetection = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscDetection1");
			    			sqlGetMscDetection = StringTool.ReplaceAll(sqlGetMscDetection, "#DIC#", mscDics.getValue());
			    			sqlGetMscDetection = EntityTool.fillSqlByEntity(sqlGetMscDetection, detectionEntity);
			    			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			    			ArrayList<GenericEntity> listMscDetection = EntityTool.getEntitysBySql(sqlGetMscDetection, con, GenericEntity.class);
			    			if(listMscDetection.get(0).getCount().equals("0")){
			    				flag = 0;
			    				break;
			    			}else{
			    				flag = 2;
			    			}
			    		}
						
						if(flag == 0) continue;
			    		for(String strJSON : allData.get(3)){
							SlmCustDetectionObject detectionEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustDetectionObject.class);
			    			String sqlGetMscDetection = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscDetection6");
			    			sqlGetMscDetection = StringTool.ReplaceAll(sqlGetMscDetection, "#DIC#", mscDics.getValue());
			    			sqlGetMscDetection = StringTool.ReplaceAll(sqlGetMscDetection, "#DIMATER#", dimater);
			    			sqlGetMscDetection = StringTool.ReplaceAll(sqlGetMscDetection, "#HEIGHT#", height);
			    			sqlGetMscDetection = EntityTool.fillSqlByEntity(sqlGetMscDetection, detectionEntity);
			    			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			    			ArrayList<GenericEntity> listMscDetection = EntityTool.getEntitysBySql(sqlGetMscDetection, con, GenericEntity.class);
			    			int mscDetectionCnt = Integer.parseInt(listMscDetection.get(0).getCount());
			    			
			    			String sqlGetMscDetection2 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscDetection2");
			    			sqlGetMscDetection2 = StringTool.ReplaceAll(sqlGetMscDetection2, "#DIC#", mscDics.getValue());
			    			sqlGetMscDetection2 = StringTool.ReplaceAll(sqlGetMscDetection2, "#DIMATER#", dimater);
			    			sqlGetMscDetection2 = StringTool.ReplaceAll(sqlGetMscDetection2, "#HEIGHT#", height);
			    			sqlGetMscDetection2 = EntityTool.fillSqlByEntity(sqlGetMscDetection2, detectionEntity);
			    			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			    			ArrayList<GenericEntity> listMscDetection2 = EntityTool.getEntitysBySql(sqlGetMscDetection2, con, GenericEntity.class);
			    			int mscDetectionCnt2 = Integer.parseInt(listMscDetection2.get(0).getCount());
			    			
			    			if(mscDetectionCnt == 0){
			    				dic = mscDics.getValue();
			    				detectionData.add(detectionEntity);
			    			}else{
			    				if(mscDetectionCnt2 == 0){
			    					dic = "";
				    				detectionData.clear();
				    				flag = 0;
				    				break;
			    				}else{
			    					dic = mscDics.getValue();
			    				}
			    			}
			    		}
			    		if(!dic.equals("")){
			    			break;
			    		}
					}else{
						flag = 0;
					}
				}
			}
			
			if(flag == 0 && (listMscDics.size() != 0 || allData.get(3).size() != 0)) continue;
    		
    		//水压
    		String sqlGetMscWics = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscWic");
			sqlGetMscWics = StringTool.ReplaceAll(sqlGetMscWics, "#MSC#", msc.getValue());
			sqlGetMscWics = StringTool.ReplaceAll(sqlGetMscWics, "#MODEL_CODE#", model);
			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			ArrayList<GenericEntity> listMscWics = EntityTool.getEntitysBySql(sqlGetMscWics, con, GenericEntity.class);
			if((listMscWics.size() == 0 && allData.get(4).size() != 0) 
					|| (listMscWics.size() != 0 && allData.get(4).size() == 0)){
				flag = 0;
				continue;
			}
			for(GenericEntity mscWics : listMscWics){
				waterData.clear();
				//当合同扣型选择/，如果没有找到/或者扣型为空的，则完全新增。
//	        	if(model.equals("C001") && !mscWics.getValue2().equals("") && mscWics.getValue2().indexOf("C001") < 0){
//	        		flag = 0;
//	        		break;
//	        	}
				
				if(Integer.parseInt(mscWics.getCount()) == allData.get(4).size()){
					//水压记录只有一条
					if(allData.get(4).size() > 0){
						String strJSON = allData.get(4).get(0);
						SlmCustWaterObject waterEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustWaterObject.class);
		    			String sqlGetMscWater = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscWater1");
		    			sqlGetMscWater = StringTool.ReplaceAll(sqlGetMscWater, "#WIC#", mscWics.getValue());
		    			sqlGetMscWater = StringTool.ReplaceAll(sqlGetMscWater, "#DIMATER#", dimater);
		    			sqlGetMscWater = StringTool.ReplaceAll(sqlGetMscWater, "#HEIGHT#", height);
		    			sqlGetMscWater = StringTool.ReplaceAll(sqlGetMscWater, "#SPEC_JG#", specCode);
		    			sqlGetMscWater = EntityTool.fillSqlByEntity(sqlGetMscWater, waterEntity);
		    			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
		    			ArrayList<GenericEntity> listMscWater = EntityTool.getEntitysBySql(sqlGetMscWater, con, GenericEntity.class);
		    			int mscWater = Integer.parseInt(listMscWater.get(0).getCount());
		    			
		    			if(mscWater > 0){
		    				wic = mscWics.getValue();
		    				flag = 3;
		    			}else{
		    				wic = "";
		    				flag = 1;
		    			}
					}
					if(!wic.equals("")){
						break;
					}
				}else{
					flag = 0;
				}
			}
			
			if(flag == 0 && (listMscWics.size() != 0 || allData.get(4).size() != 0)) continue;
			
			if(wic.equals("")){
			for(GenericEntity mscWics : listMscWics){
				waterData.clear();
				//当合同扣型选择/，如果没有找到/或者扣型为空的，则完全新增。
//	        	if(model.equals("C001") && !mscWics.getValue2().equals("") && mscWics.getValue2().indexOf("C001") < 0){
//	        		flag = 0;
//	        		break;
//	        	}
				
				if(Integer.parseInt(mscWics.getCount()) == allData.get(4).size()){
					//水压记录只有一条
					if(allData.get(4).size() > 0){
						String strJSON = allData.get(4).get(0);
						SlmCustWaterObject waterEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustWaterObject.class);
		    			String sqlGetMscWater = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscWater1");
		    			sqlGetMscWater = StringTool.ReplaceAll(sqlGetMscWater, "#WIC#", mscWics.getValue());
		    			sqlGetMscWater = StringTool.ReplaceAll(sqlGetMscWater, "#DIMATER#", dimater);
		    			sqlGetMscWater = StringTool.ReplaceAll(sqlGetMscWater, "#HEIGHT#", height);
		    			sqlGetMscWater = StringTool.ReplaceAll(sqlGetMscWater, "#SPEC_JG#", specCode);
		    			sqlGetMscWater = EntityTool.fillSqlByEntity(sqlGetMscWater, waterEntity);
		    			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
		    			ArrayList<GenericEntity> listMscWater = EntityTool.getEntitysBySql(sqlGetMscWater, con, GenericEntity.class);
		    			int mscWater = Integer.parseInt(listMscWater.get(0).getCount());
		    			
		    			String sqlGetMscWater3 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscWater3");
		    			sqlGetMscWater3 = StringTool.ReplaceAll(sqlGetMscWater3, "#WIC#", mscWics.getValue());
		    			sqlGetMscWater3 = StringTool.ReplaceAll(sqlGetMscWater3, "#DIMATER#", dimater);
		    			sqlGetMscWater3 = StringTool.ReplaceAll(sqlGetMscWater3, "#HEIGHT#", height);
		    			sqlGetMscWater3 = StringTool.ReplaceAll(sqlGetMscWater3, "#SPEC_JG#", specCode);
		    			sqlGetMscWater3 = EntityTool.fillSqlByEntity(sqlGetMscWater3, waterEntity);
		    			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
		    			ArrayList<GenericEntity> listMscWater3 = EntityTool.getEntitysBySql(sqlGetMscWater3, con, GenericEntity.class);
		    			int mscWater3 = Integer.parseInt(listMscWater3.get(0).getCount());
		    			
		    			if(mscWater3 > 0){
		    				if(mscWater == 0){
			    				wic = "";
			    				waterData.clear();
			    				flag = 0;
			    				break;
		    				}else{
		    					wic = mscWics.getValue();
		    					flag = 3;
		    					waterData.clear();
		    					break;
		    				}
		    			}else{
		    				wic = "";
		    				flag = 1;
		    				waterData.add(waterEntity);
		    			}
					}
					if(!wic.equals("")){
						break;
					}
				}else{
					flag = 0;
				}
			}
			}
			
//			if(flag == 0) continue;
//			
//			if(wic.equals("")){
//				for(GenericEntity mscWics : listMscWics){
//					waterData.clear();
//					if(Integer.parseInt(mscWics.getCount()) == allData.get(4).size()){
//						//水压记录只有一条
//						if(allData.get(4).size() > 0){
//							String strJSON = allData.get(4).get(0);
//							SlmCustWaterObject waterEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustWaterObject.class);
//							waterData.add(waterEntity);
//						}
//						break;
//					}else{
//						flag = 0;
//					}
//				}
//			}
			
			if(flag == 0 && (listMscWics.size() != 0 || allData.get(4).size() != 0)) continue;
    		
    		//加工
    		String sqlGetMscGics = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscGic");
			sqlGetMscGics = StringTool.ReplaceAll(sqlGetMscGics, "#MSC#", msc.getValue());
			sqlGetMscGics = StringTool.ReplaceAll(sqlGetMscGics, "#MODEL_CODE#", model);
			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			ArrayList<GenericEntity> listMscGics = EntityTool.getEntitysBySql(sqlGetMscGics, con, GenericEntity.class);
			if((listMscGics.size() == 0 && allData.get(5).size() != 0) 
					|| (listMscGics.size() != 0 && allData.get(5).size() == 0)){
				flag = 0;
				continue;
			}
			for(GenericEntity mscGics : listMscGics){
				if(Integer.parseInt(mscGics.getCount()) == allData.get(5).size()){
					//processData.clear();
					//当合同扣型选择/，如果没有找到/或者扣型为空的，则完全新增。
//		        	if(model.equals("C001") && !mscGics.getValue2().equals("") && mscGics.getValue2().indexOf("C001") < 0){
//		        		flag = 0;
//		        		break;
//		        	}
					
					for(String strJSON : allData.get(5)){
						SlmCustProcessEntity processEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustProcessEntity.class);
		    			String sqlGetMscProcess = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscProcess1");
		    			sqlGetMscProcess = StringTool.ReplaceAll(sqlGetMscProcess, "#GIC#", mscGics.getValue());
		    			sqlGetMscProcess = EntityTool.fillSqlByEntity(sqlGetMscProcess, processEntity);
		    			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
		    			ArrayList<GenericEntity> listMscProcess = EntityTool.getEntitysBySql(sqlGetMscProcess, con, GenericEntity.class);
		    			int mscProcess = Integer.parseInt(listMscProcess.get(0).getCount());
		    			
		    			if(mscProcess > 0){
		    				gic = mscGics.getValue();
		    				flag = 3;
		    			}else{
		    				gic = "";
		    				flag = 0;
		    				break;
		    			}
		    		}
					if(!gic.equals("")){
						break;
					}
				}else{
					flag = 0;
				}
			}
			
			if(flag == 0 && (listMscGics.size() != 0 || allData.get(5).size() != 0)) continue;
			
			int noSameCnt = chemData.size() + phyData.size() + specData.size() + detectionData.size() + waterData.size() + processData.size();
			if(msc.getValue().substring(10).equals("000")){
				if(noSameCnt == 0){
					result = true;
					mscOrCustAlphaNo = msc.getValue();
					break;
				}
				else{
					continue;
				}
			}
			
			result = true;
			mscOrCustAlphaNo = msc.getValue();
			break;
    	}
    	
    	if(flag == 0){
    		result = false;
			chemData.clear();
			phyData.clear();
			specData.clear();
			detectionData.clear();
			waterData.clear();
			processData.clear();
			cic = "";
			pic = "";
			sic = "";
			dic = "";
			wic = "";
			gic = "";
    	}
    	
    	int noSameCnt = chemData.size() + phyData.size() + specData.size() + detectionData.size() + waterData.size() + processData.size();
    	//比较最终用户下的技术要求
    	if((result == false || (result == true && noSameCnt > 0)) && isCheckAlpha.equals("True")){
	    	String sqlGetCustAlphaNos = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getCustAlphaNos");
	    	sqlGetCustAlphaNos = StringTool.ReplaceAll(sqlGetCustAlphaNos, "#CHEM_ALPHA_NO#", custNo);
	    	Connection con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
	    	ArrayList<GenericEntity> listCustAlphaNos = EntityTool.getEntitysBySql(sqlGetCustAlphaNos, con2, GenericEntity.class);
	    	for(GenericEntity custAlphaNo : listCustAlphaNos){
	    		if(Integer.parseInt(custAlphaNo.getCount()) != allCount) continue;
	    		int sameCount = 0;
	    		
	    		//成分
	    		String sqlGetChemCustAlphas = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getChemCustAlphas");
	    		sqlGetChemCustAlphas = StringTool.ReplaceAll(sqlGetChemCustAlphas, "#CUST_ALPHA_NO#", custAlphaNo.getValue());
	    		con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
	    		ArrayList<GenericEntity> listChemCustAlphas = EntityTool.getEntitysBySql(sqlGetChemCustAlphas, con2, GenericEntity.class);
	    		if(listChemCustAlphas.size() > 0){
		    		if(Integer.parseInt(listChemCustAlphas.get(0).getCount()) == allData.get(0).size()){
			    		for(String strJSON : allData.get(0)){
			    			SlmCustChemObject chemEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustChemObject.class);
			    			String sqlGetCustChem = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getCustChem");
			    			sqlGetCustChem = StringTool.ReplaceAll(sqlGetCustChem, "#CUST_ALPHA_NO2#", custAlphaNo.getValue());
			    			sqlGetCustChem = StringTool.ReplaceAll(sqlGetCustChem, "#CUST_ALPHA_NO#", tmpCustAlphaNo);
			    			sqlGetCustChem = EntityTool.fillSqlByEntity(sqlGetCustChem, chemEntity);
			    			con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			    			ArrayList<GenericEntity> listCustChem = EntityTool.getEntitysBySql(sqlGetCustChem, con2, GenericEntity.class);
			    			if(listCustChem.get(0).getCount().equals("0") == false){
			    				sameCount++;
			    			}else{
			    				sameCount = -1;
			    				break;
			    			}
			    		}
		    		}
	    		}else{
					if(allData.get(0).size() > 0){
						sameCount = -1;
					}
				}
	    		if(sameCount == -1) continue;
	    		
	    		//理化
	    		String sqlGetPhyCustAlphas = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getPhyCustAlphas");
	    		sqlGetPhyCustAlphas = StringTool.ReplaceAll(sqlGetPhyCustAlphas, "#CUST_ALPHA_NO#", custAlphaNo.getValue());
	    		con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
	    		ArrayList<GenericEntity> listPhyCustAlphas = EntityTool.getEntitysBySql(sqlGetPhyCustAlphas, con2, GenericEntity.class);
	    		if(listPhyCustAlphas.size() > 0){
		    		if(Integer.parseInt(listPhyCustAlphas.get(0).getCount()) == allData.get(1).size()){
			    		for(String strJSON : allData.get(1)){
			    			SlmCustPhyObject phyEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustPhyObject.class);
			    			String sqlGetCustPhy = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getCustPhy");
			    			sqlGetCustPhy = StringTool.ReplaceAll(sqlGetCustPhy, "#CUST_ALPHA_NO2#", custAlphaNo.getValue());
			    			sqlGetCustPhy = StringTool.ReplaceAll(sqlGetCustPhy, "#CUST_ALPHA_NO#", tmpCustAlphaNo);
			    			sqlGetCustPhy = EntityTool.fillSqlByEntity(sqlGetCustPhy, phyEntity);
			    			con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			    			ArrayList<GenericEntity> listCustPhy = EntityTool.getEntitysBySql(sqlGetCustPhy, con2, GenericEntity.class);
			    			if(listCustPhy.get(0).getCount().equals("0") == false){
			    				sameCount++;
			    			}else{
			    				sameCount = -1;
			    				break;
			    			}
			    		}
		    		}
	    		}else{
					if(allData.get(1).size() > 0){
						sameCount = -1;
					}
				}
	    		if(sameCount == -1) continue;
	    		
	    		//公差
	    		String sqlGetSpecCustAlphas = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getSpecCustAlphas");
	    		sqlGetSpecCustAlphas = StringTool.ReplaceAll(sqlGetSpecCustAlphas, "#CUST_ALPHA_NO#", custAlphaNo.getValue());
	    		con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
	    		ArrayList<GenericEntity> listSpecCustAlphas = EntityTool.getEntitysBySql(sqlGetSpecCustAlphas, con2, GenericEntity.class);
	    		if(listSpecCustAlphas.size() > 0){
		    		if(Integer.parseInt(listSpecCustAlphas.get(0).getCount()) == allData.get(2).size()){
			    		for(String strJSON : allData.get(2)){
			    			SlmCustSpecObject phyEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustSpecObject.class);
			    			String sqlGetCustSpec = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getCustSpec");
			    			sqlGetCustSpec = StringTool.ReplaceAll(sqlGetCustSpec, "#CUST_ALPHA_NO2#", custAlphaNo.getValue());
			    			sqlGetCustSpec = StringTool.ReplaceAll(sqlGetCustSpec, "#CUST_ALPHA_NO#", tmpCustAlphaNo);
			    			sqlGetCustSpec = EntityTool.fillSqlByEntity(sqlGetCustSpec, phyEntity);
			    			con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			    			ArrayList<GenericEntity> listCustSpec = EntityTool.getEntitysBySql(sqlGetCustSpec, con2, GenericEntity.class);
			    			if(listCustSpec.get(0).getCount().equals("0") == false){
			    				sameCount++;
			    			}else{
			    				sameCount = -1;
			    				break;
			    			}
			    		}
		    		}
	    		}else{
					if(allData.get(2).size() > 0){
						sameCount = -1;
					}
				}
	    		if(sameCount == -1) continue;
	    		
	    		//探伤
	    		String sqlGetDetectionCustAlphas = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getDetectionCustAlphas");
	    		sqlGetDetectionCustAlphas = StringTool.ReplaceAll(sqlGetDetectionCustAlphas, "#CUST_ALPHA_NO#", custAlphaNo.getValue());
	    		con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
	    		ArrayList<GenericEntity> listDetectionCustAlphas = EntityTool.getEntitysBySql(sqlGetDetectionCustAlphas, con2, GenericEntity.class);
	    		if(listDetectionCustAlphas.size() > 0){
		    		if(Integer.parseInt(listDetectionCustAlphas.get(0).getCount()) == allData.get(3).size()){
			    		for(String strJSON : allData.get(3)){
			    			SlmCustDetectionObject phyEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustDetectionObject.class);
			    			String sqlGetCustDetection = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getCustDetection");
			    			sqlGetCustDetection = StringTool.ReplaceAll(sqlGetCustDetection, "#CUST_ALPHA_NO2#", custAlphaNo.getValue());
			    			sqlGetCustDetection = StringTool.ReplaceAll(sqlGetCustDetection, "#CUST_ALPHA_NO#", tmpCustAlphaNo);
			    			sqlGetCustDetection = EntityTool.fillSqlByEntity(sqlGetCustDetection, phyEntity);
			    			con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			    			ArrayList<GenericEntity> listCustDetection = EntityTool.getEntitysBySql(sqlGetCustDetection, con2, GenericEntity.class);
			    			if(listCustDetection.get(0).getCount().equals("0") == false) {
			    				sameCount++;
			    			}else{
			    				sameCount = -1;
			    				break;
			    			}
			    		}
		    		}
	    		}else{
					if(allData.get(3).size() > 0){
						sameCount = -1;
					}
				}
	    		if(sameCount == -1) continue;
	    		
	    		//水压
	    		String sqlGetWaterCustAlphas = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getWaterCustAlphas");
	    		sqlGetWaterCustAlphas = StringTool.ReplaceAll(sqlGetWaterCustAlphas, "#CUST_ALPHA_NO#", custAlphaNo.getValue());
	    		con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
	    		ArrayList<GenericEntity> listWaterCustAlphas = EntityTool.getEntitysBySql(sqlGetWaterCustAlphas, con2, GenericEntity.class);
	    		if(listWaterCustAlphas.size() > 0){
		    		if(Integer.parseInt(listWaterCustAlphas.get(0).getCount()) == allData.get(4).size()){
			    		for(String strJSON : allData.get(4)){
			    			SlmCustWaterObject waterEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustWaterObject.class);
			    			String sqlGetCustWater = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getCustWater");
			    			sqlGetCustWater = StringTool.ReplaceAll(sqlGetCustWater, "#CUST_ALPHA_NO2#", custAlphaNo.getValue());
			    			sqlGetCustWater = StringTool.ReplaceAll(sqlGetCustWater, "#CUST_ALPHA_NO#", tmpCustAlphaNo);
			    			sqlGetCustWater = EntityTool.fillSqlByEntity(sqlGetCustWater, waterEntity);
			    			con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			    			ArrayList<GenericEntity> listCustWater = EntityTool.getEntitysBySql(sqlGetCustWater, con2, GenericEntity.class);
			    			if(listCustWater.get(0).getCount().equals("0") == false){
			    				sameCount++;
			    			}else{
			    				sameCount = -1;
			    				break;
			    			}
			    		}
		    		}
	    		}else{
					if(allData.get(4).size() > 0){
						sameCount = -1;
					}
				}
	    		if(sameCount == -1) continue;
	    		
	    		//加工
	    		String sqlGetProcessCustAlphas = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getProcessCustAlphas");
	    		sqlGetProcessCustAlphas = StringTool.ReplaceAll(sqlGetProcessCustAlphas, "#CUST_ALPHA_NO#", custAlphaNo.getValue());
	    		con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
	    		ArrayList<GenericEntity> listProcessCustAlphas = EntityTool.getEntitysBySql(sqlGetProcessCustAlphas, con2, GenericEntity.class);
	    		if(listProcessCustAlphas.size() > 0){
		    		if(Integer.parseInt(listProcessCustAlphas.get(0).getCount()) == allData.get(5).size()){
			    		for(String strJSON : allData.get(5)){
			    			SlmCustProcessEntity processEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustProcessEntity.class);
			    			String sqlGetCustProcess = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getCustProcess");
			    			sqlGetCustProcess = StringTool.ReplaceAll(sqlGetCustProcess, "#CUST_ALPHA_NO2#", custAlphaNo.getValue());
			    			sqlGetCustProcess = StringTool.ReplaceAll(sqlGetCustProcess, "#CUST_ALPHA_NO#", tmpCustAlphaNo);
			    			sqlGetCustProcess = EntityTool.fillSqlByEntity(sqlGetCustProcess, processEntity);
			    			con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			    			ArrayList<GenericEntity> listCustProcess = EntityTool.getEntitysBySql(sqlGetCustProcess, con2, GenericEntity.class);
			    			if(listCustProcess.get(0).getCount().equals("0") == false){
			    				sameCount++;
			    			}else{
			    				sameCount = -1;
			    				break;
			    			}
			    		}
		    		}
	    		}else{
					if(allData.get(5).size() > 0){
						sameCount = -1;
					}
				}
	    		if(sameCount == -1) continue;
	    		
	    		if(sameCount == Integer.parseInt(custAlphaNo.getCount()))
	    		{
	    			result = true;
	    			flag = 3;
	    			chemData.clear();
	    			phyData.clear();
	    			specData.clear();
	    			detectionData.clear();
	    			waterData.clear();
	    			processData.clear();
	    			mscOrCustAlphaNo = custAlphaNo.getValue();
	    			break;
	    		}
	    	}
    	}
    	
    	Object[] objs = new Object[]{result, mscOrCustAlphaNo, cic, pic, sic, dic, wic, gic, chemData, phyData,
    			specData, detectionData, waterData, processData, flag};
    	cro.setResult(objs);
    	return cro;
    }
    	
//    private int getMscChem1(String cic){
//    	
//    }
    
    /**
     * 是否存在相同的成分
     * @param listJSON 新增或者修改的一套成分
     * @param custNo 客户码
     * @param psc 客户码
     * @return obj
     */
    public CoreReturnObject isExistSameChem(ArrayList<String> listJSON, String custNo,
    		String psc, String tmpCustAlphaNo){
    	CoreReturnObject cro = new CoreReturnObject();
    	boolean result = false;
    	String mscOrCustAlphaNo = "";
    	
    	String sqlGetMscCics = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscCic");
    	sqlGetMscCics = StringTool.ReplaceAll(sqlGetMscCics, "#PSC#", psc);
    	Connection con3 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
    	ArrayList<GenericEntity> listMscCics = EntityTool.getEntitysBySql(sqlGetMscCics, con3, GenericEntity.class);
    	for(GenericEntity mscCic : listMscCics){
    		if(Integer.parseInt(mscCic.getCount()) != listJSON.size()) continue;
    		int sameCount = 0;
    		for(String strJSON : listJSON){
    			SlmCustChemObject chemEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustChemObject.class);
    			String sqlGetMscChem = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscChem");
    			sqlGetMscChem = StringTool.ReplaceAll(sqlGetMscChem, "#CIC#", mscCic.getValue());
    			sqlGetMscChem = EntityTool.fillSqlByEntity(sqlGetMscChem, chemEntity);
    			Connection con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
    			ArrayList<GenericEntity> listMscChem = EntityTool.getEntitysBySql(sqlGetMscChem, con2, GenericEntity.class);
    			if(listMscChem.get(0).getCount().equals("0") == false) sameCount++;
    		}
    		if(sameCount == Integer.parseInt(mscCic.getCount()))
    		{
    			result = true;
    			mscOrCustAlphaNo = mscCic.getValue2();
    			break;
    		}
    	}
    	
    	if(result == false){
	    	String sqlGetCustAlphaNos = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getChemCustAlphaNos");
	    	sqlGetCustAlphaNos = StringTool.ReplaceAll(sqlGetCustAlphaNos, "#CHEM_ALPHA_NO#", custNo);
	    	Connection con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
	    	ArrayList<GenericEntity> listCustAlphaNos = EntityTool.getEntitysBySql(sqlGetCustAlphaNos, con, GenericEntity.class);
	    	for(GenericEntity custAlphaNo : listCustAlphaNos){
	    		if(Integer.parseInt(custAlphaNo.getCount()) != listJSON.size()) continue;
	    		int sameCount = 0;
	    		for(String strJSON : listJSON){
	    			SlmCustChemObject chemEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustChemObject.class);
	    			String sqlGetCustChem = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getCustChem");
	    			sqlGetCustChem = StringTool.ReplaceAll(sqlGetCustChem, "#CUST_ALPHA_NO2#", custAlphaNo.getValue());
	    			sqlGetCustChem = StringTool.ReplaceAll(sqlGetCustChem, "#CUST_ALPHA_NO#", tmpCustAlphaNo);
	    			sqlGetCustChem = EntityTool.fillSqlByEntity(sqlGetCustChem, chemEntity);
	    			Connection con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
	    			ArrayList<GenericEntity> listCustChem = EntityTool.getEntitysBySql(sqlGetCustChem, con2, GenericEntity.class);
	    			if(listCustChem.get(0).getCount().equals("0") == false) sameCount++;
	    		}
	    		if(sameCount == Integer.parseInt(custAlphaNo.getCount()))
	    		{
	    			result = true;
	    			mscOrCustAlphaNo = custAlphaNo.getValue();
	    			break;
	    		}
	    	}
    	}
    	
    	Object[] objs = new Object[]{result, mscOrCustAlphaNo};
    	cro.setResult(objs);
    	return cro;
    }
    
    /**
     * 是否存在相同的理化
     * @param listJSON 新增或者修改的一套理化
     * @param custNo 客户码
     * @param psc 客户码
     * @return obj
     */
    public CoreReturnObject isExistSamePhy(ArrayList<String> listJSON, String custNo,
    		String psc, String tmpCustAlphaNo){
    	CoreReturnObject cro = new CoreReturnObject();
    	boolean result = false;
    	String mscOrCustAlphaNo = "";
    	
    	String sqlGetMscPics = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscPic");
    	sqlGetMscPics = StringTool.ReplaceAll(sqlGetMscPics, "#PSC#", psc);
    	Connection con3 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
    	ArrayList<GenericEntity> listMscPics = EntityTool.getEntitysBySql(sqlGetMscPics, con3, GenericEntity.class);
    	for(GenericEntity mscPic : listMscPics){
    		if(Integer.parseInt(mscPic.getCount()) != listJSON.size()) continue;
    		int sameCount = 0;
    		for(String strJSON : listJSON){
    			SlmCustPhyObject phyEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustPhyObject.class);
    			String sqlGetMscPhy = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscPhy");
    			sqlGetMscPhy = StringTool.ReplaceAll(sqlGetMscPhy, "#PIC#", mscPic.getValue());
    			sqlGetMscPhy = EntityTool.fillSqlByEntity(sqlGetMscPhy, phyEntity);
    			Connection con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
    			ArrayList<GenericEntity> listMscPhy = EntityTool.getEntitysBySql(sqlGetMscPhy, con2, GenericEntity.class);
    			if(listMscPhy.get(0).getCount().equals("0") == false) sameCount++;
    		}
    		if(sameCount == Integer.parseInt(mscPic.getCount()))
    		{
    			result = true;
    			mscOrCustAlphaNo = mscPic.getValue2();
    			break;
    		}
    	}
    	
    	if(result == false){
	    	String sqlGetCustAlphaNos = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getPhyCustAlphaNos");
	    	sqlGetCustAlphaNos = StringTool.ReplaceAll(sqlGetCustAlphaNos, "#CHEM_ALPHA_NO#", custNo);
	    	Connection con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
	    	ArrayList<GenericEntity> listCustAlphaNos = EntityTool.getEntitysBySql(sqlGetCustAlphaNos, con, GenericEntity.class);
	    	for(GenericEntity custAlphaNo : listCustAlphaNos){
	    		if(Integer.parseInt(custAlphaNo.getCount()) != listJSON.size()) continue;
	    		int sameCount = 0;
	    		for(String strJSON : listJSON){
	    			SlmCustPhyObject phyEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustPhyObject.class);
	    			String sqlGetCustPhy = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getCustPhy");
	    			sqlGetCustPhy = StringTool.ReplaceAll(sqlGetCustPhy, "#CUST_ALPHA_NO2#", custAlphaNo.getValue());
	    			sqlGetCustPhy = StringTool.ReplaceAll(sqlGetCustPhy, "#CUST_ALPHA_NO#", tmpCustAlphaNo);
	    			sqlGetCustPhy = EntityTool.fillSqlByEntity(sqlGetCustPhy, phyEntity);
	    			Connection con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
	    			ArrayList<GenericEntity> listCustPhy = EntityTool.getEntitysBySql(sqlGetCustPhy, con2, GenericEntity.class);
	    			if(listCustPhy.get(0).getCount().equals("0") == false) sameCount++;
	    		}
	    		if(sameCount == Integer.parseInt(custAlphaNo.getCount()))
	    		{
	    			result = true;
	    			mscOrCustAlphaNo = custAlphaNo.getValue();
	    			break;
	    		}
	    	}
    	}
    	
    	Object[] objs = new Object[]{result, mscOrCustAlphaNo};
    	cro.setResult(objs);
    	return cro;
    }
    
    /**
     * 是否存在相同的公差
     * @param listJSON 新增或者修改的一套公差
     * @param custNo 客户码
     * @param psc 客户码
     * @return obj
     */
    public CoreReturnObject isExistSameSpec(ArrayList<String> listJSON, String custNo,
    		String psc, String tmpCustAlphaNo){
    	CoreReturnObject cro = new CoreReturnObject();
    	boolean result = false;
    	String mscOrCustAlphaNo = "";
    	
    	String sqlGetMscSics = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscSic");
    	sqlGetMscSics = StringTool.ReplaceAll(sqlGetMscSics, "#PSC#", psc);
    	Connection con3 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
    	ArrayList<GenericEntity> listMscSics = EntityTool.getEntitysBySql(sqlGetMscSics, con3, GenericEntity.class);
    	for(GenericEntity mscSic : listMscSics){
    		if(Integer.parseInt(mscSic.getCount()) != listJSON.size()) continue;
    		int sameCount = 0;
    		for(String strJSON : listJSON){
    			SlmCustSpecObject specEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustSpecObject.class);
    			String sqlGetMscSpec = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscSpec");
    			sqlGetMscSpec = StringTool.ReplaceAll(sqlGetMscSpec, "#SIC#", mscSic.getValue());
    			sqlGetMscSpec = EntityTool.fillSqlByEntity(sqlGetMscSpec, specEntity);
    			Connection con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
    			ArrayList<GenericEntity> listMscSpec = EntityTool.getEntitysBySql(sqlGetMscSpec, con2, GenericEntity.class);
    			if(listMscSpec.get(0).getCount().equals("0") == false) sameCount++;
    		}
    		if(sameCount == Integer.parseInt(mscSic.getCount()))
    		{
    			result = true;
    			mscOrCustAlphaNo = mscSic.getValue2();
    			break;
    		}
    	}
    	
    	if(result == false){
    		String sqlGetCustAlphaNos = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getSpecCustAlphaNos");
        	sqlGetCustAlphaNos = StringTool.ReplaceAll(sqlGetCustAlphaNos, "#CHEM_ALPHA_NO#", custNo);
        	Connection con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
        	ArrayList<GenericEntity> listCustAlphaNos = EntityTool.getEntitysBySql(sqlGetCustAlphaNos, con, GenericEntity.class);
        	for(GenericEntity custAlphaNo : listCustAlphaNos){
        		if(Integer.parseInt(custAlphaNo.getCount()) != listJSON.size()) continue;
        		int sameCount = 0;
        		for(String strJSON : listJSON){
        			SlmCustSpecObject specEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustSpecObject.class);
        			String sqlGetCustSpec = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getCustSpec");
        			sqlGetCustSpec = StringTool.ReplaceAll(sqlGetCustSpec, "#CUST_ALPHA_NO2#", custAlphaNo.getValue());
        			sqlGetCustSpec = StringTool.ReplaceAll(sqlGetCustSpec, "#CUST_ALPHA_NO#", tmpCustAlphaNo);
        			sqlGetCustSpec = EntityTool.fillSqlByEntity(sqlGetCustSpec, specEntity);
        			Connection con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
        			ArrayList<GenericEntity> listCustSpec = EntityTool.getEntitysBySql(sqlGetCustSpec, con2, GenericEntity.class);
        			if(listCustSpec.get(0).getCount().equals("0") == false) sameCount++;
        		}
        		if(sameCount == Integer.parseInt(custAlphaNo.getCount()))
        		{
        			result = true;
        			mscOrCustAlphaNo = custAlphaNo.getValue();
        			break;
        		}
        	}
    	}
    	
    	Object[] objs = new Object[]{result, mscOrCustAlphaNo};
    	cro.setResult(objs);
    	return cro;
    }
    
    /**
     * 是否存在相同的探伤
     * @param listJSON 新增或者修改的一套探伤
     * @param custNo 客户码
     * @param psc 客户码
     * @return obj
     */
    public CoreReturnObject isExistSameDetection(ArrayList<String> listJSON, String custNo,
    		String psc, String tmpCustAlphaNo){
    	CoreReturnObject cro = new CoreReturnObject();
    	boolean result = false;
    	String mscOrCustAlphaNo = "";
    	
    	String sqlGetMscDics = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscDic");
    	sqlGetMscDics = StringTool.ReplaceAll(sqlGetMscDics, "#PSC#", psc);
    	Connection con3 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
    	ArrayList<GenericEntity> listMscDics = EntityTool.getEntitysBySql(sqlGetMscDics, con3, GenericEntity.class);
    	for(GenericEntity mscDic : listMscDics){
    		if(Integer.parseInt(mscDic.getCount()) != listJSON.size()) continue;
    		int sameCount = 0;
    		for(String strJSON : listJSON){
    			SlmCustDetectionObject detectionEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustDetectionObject.class);
    			String sqlGetMscDetection = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscDetection");
    			sqlGetMscDetection = StringTool.ReplaceAll(sqlGetMscDetection, "#DIC#", mscDic.getValue());
    			sqlGetMscDetection = EntityTool.fillSqlByEntity(sqlGetMscDetection, detectionEntity);
    			Connection con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
    			ArrayList<GenericEntity> listMscDetection = EntityTool.getEntitysBySql(sqlGetMscDetection, con2, GenericEntity.class);
    			if(listMscDetection.get(0).getCount().equals("0") == false) sameCount++;
    		}
    		if(sameCount == Integer.parseInt(mscDic.getCount()))
    		{
    			result = true;
    			mscOrCustAlphaNo = mscDic.getValue2();
    			break;
    		}
    	}
    	
    	if(result == false)
    	{
    		String sqlGetCustAlphaNos = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getDetectionCustAlphaNos");
        	sqlGetCustAlphaNos = StringTool.ReplaceAll(sqlGetCustAlphaNos, "#CHEM_ALPHA_NO#", custNo);
        	Connection con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
        	ArrayList<GenericEntity> listCustAlphaNos = EntityTool.getEntitysBySql(sqlGetCustAlphaNos, con, GenericEntity.class);
        	for(GenericEntity custAlphaNo : listCustAlphaNos){
        		if(Integer.parseInt(custAlphaNo.getCount()) != listJSON.size()) continue;
        		int sameCount = 0;
        		for(String strJSON : listJSON){
        			SlmCustDetectionObject detectionEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustDetectionObject.class);
        			String sqlGetCustDetection = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getCustDetection");
        			sqlGetCustDetection = StringTool.ReplaceAll(sqlGetCustDetection, "#CUST_ALPHA_NO2#", custAlphaNo.getValue());
        			sqlGetCustDetection = StringTool.ReplaceAll(sqlGetCustDetection, "#CUST_ALPHA_NO#", tmpCustAlphaNo);
        			sqlGetCustDetection = EntityTool.fillSqlByEntity(sqlGetCustDetection, detectionEntity);
        			Connection con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
        			ArrayList<GenericEntity> listCustDetection = EntityTool.getEntitysBySql(sqlGetCustDetection, con2, GenericEntity.class);
        			if(listCustDetection.get(0).getCount().equals("0") == false) sameCount++;
        		}
        		if(sameCount == Integer.parseInt(custAlphaNo.getCount()))
        		{
        			result = true;
        			mscOrCustAlphaNo = custAlphaNo.getValue();
        			break;
        		}
        	}
    	}
    	
    	Object[] objs = new Object[]{result, mscOrCustAlphaNo};
    	cro.setResult(objs);
    	return cro;
    }
    
    /**
     * 是否存在相同的水压
     * @param listJSON 新增或者修改的一套水压
     * @param custNo 客户码
     * @param psc 客户码
     * @return obj
     */
    public CoreReturnObject isExistSameWater(ArrayList<String> listJSON, String custNo, 
    		String psc, String tmpCustAlphaNo){
    	CoreReturnObject cro = new CoreReturnObject();
    	boolean result = false;
    	String mscOrCustAlphaNo = "";
    	
    	String sqlGetMscWics = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscWic");
    	sqlGetMscWics = StringTool.ReplaceAll(sqlGetMscWics, "#PSC#", psc);
    	Connection con3 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
    	ArrayList<GenericEntity> listMscWics = EntityTool.getEntitysBySql(sqlGetMscWics, con3, GenericEntity.class);
    	for(GenericEntity mscWic : listMscWics){
    		if(Integer.parseInt(mscWic.getCount()) != listJSON.size()) continue;
    		int sameCount = 0;
    		for(String strJSON : listJSON){
    			SlmCustWaterObject waterEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustWaterObject.class);
    			String sqlGetMscWater = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscWater");
    			sqlGetMscWater = StringTool.ReplaceAll(sqlGetMscWater, "#WIC#", mscWic.getValue());
    			sqlGetMscWater = EntityTool.fillSqlByEntity(sqlGetMscWater, waterEntity);
    			Connection con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
    			ArrayList<GenericEntity> listMscWater = EntityTool.getEntitysBySql(sqlGetMscWater, con2, GenericEntity.class);
    			if(listMscWater.get(0).getCount().equals("0") == false) sameCount++;
    		}
    		if(sameCount == Integer.parseInt(mscWic.getCount()))
    		{
    			result = true;
    			mscOrCustAlphaNo = mscWic.getValue2();
    			break;
    		}
    	}
    	
    	if(result == false){
	    	String sqlGetCustAlphaNos = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getWaterCustAlphaNos");
	    	sqlGetCustAlphaNos = StringTool.ReplaceAll(sqlGetCustAlphaNos, "#CHEM_ALPHA_NO#", custNo);
	    	Connection con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
	    	ArrayList<GenericEntity> listCustAlphaNos = EntityTool.getEntitysBySql(sqlGetCustAlphaNos, con, GenericEntity.class);
	    	for(GenericEntity custAlphaNo : listCustAlphaNos){
	    		if(Integer.parseInt(custAlphaNo.getCount()) != listJSON.size()) continue;
	    		int sameCount = 0;
	    		for(String strJSON : listJSON){
	    			SlmCustWaterObject waterEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustWaterObject.class);
	    			String sqlGetCustWater = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getCustWater");
	    			sqlGetCustWater = StringTool.ReplaceAll(sqlGetCustWater, "#CUST_ALPHA_NO2#", custAlphaNo.getValue());
	    			sqlGetCustWater = StringTool.ReplaceAll(sqlGetCustWater, "#CUST_ALPHA_NO#", tmpCustAlphaNo);
	    			sqlGetCustWater = EntityTool.fillSqlByEntity(sqlGetCustWater, waterEntity);
	    			Connection con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
	    			ArrayList<GenericEntity> listCustWater = EntityTool.getEntitysBySql(sqlGetCustWater, con2, GenericEntity.class);
	    			if(listCustWater.get(0).getCount().equals("0") == false) sameCount++;
	    		}
	    		if(sameCount == Integer.parseInt(custAlphaNo.getCount()))
	    		{
	    			result = true;
	    			mscOrCustAlphaNo = custAlphaNo.getValue();
	    			break;
	    		}
	    	}
    	}
    	
    	Object[] objs = new Object[]{result, mscOrCustAlphaNo};
    	cro.setResult(objs);
    	return cro;
    }
    
    /**
     * 是否存在相同的加工
     * @param listJSON 新增或者修改的一套加工
     * @param custNo 客户码
     * @param psc 客户码
     * @return obj
     */
    public CoreReturnObject isExistSameProcess(ArrayList<String> listJSON, String custNo,
    		String psc, String tmpCustAlphaNo){
    	CoreReturnObject cro = new CoreReturnObject();
    	boolean result = false;
    	String mscOrCustAlphaNo = "";
    	
    	String sqlGetMscGics = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscGic");
    	sqlGetMscGics = StringTool.ReplaceAll(sqlGetMscGics, "#PSC#", psc);
    	Connection con3 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
    	ArrayList<GenericEntity> listMscGics = EntityTool.getEntitysBySql(sqlGetMscGics, con3, GenericEntity.class);
    	for(GenericEntity mscGic : listMscGics){
    		if(Integer.parseInt(mscGic.getCount()) != listJSON.size()) continue;
    		int sameCount = 0;
    		for(String strJSON : listJSON){
    			SlmCustProcessEntity processEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustProcessEntity.class);
    			String sqlGetMscProcess = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMscProcess");
    			sqlGetMscProcess = StringTool.ReplaceAll(sqlGetMscProcess, "#GIC#", mscGic.getValue());
    			sqlGetMscProcess = EntityTool.fillSqlByEntity(sqlGetMscProcess, processEntity);
    			Connection con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
    			ArrayList<GenericEntity> listMscProcess = EntityTool.getEntitysBySql(sqlGetMscProcess, con2, GenericEntity.class);
    			if(listMscProcess.get(0).getCount().equals("0") == false) sameCount++;
    		}
    		if(sameCount == Integer.parseInt(mscGic.getCount()))
    		{
    			result = true;
    			mscOrCustAlphaNo = mscGic.getValue2();
    			break;
    		}
    	}
    	
    	if(result == false){
	    	String sqlGetCustAlphaNos = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getProcessCustAlphaNos");
	    	sqlGetCustAlphaNos = StringTool.ReplaceAll(sqlGetCustAlphaNos, "#CHEM_ALPHA_NO#", custNo);
	    	Connection con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
	    	ArrayList<GenericEntity> listCustAlphaNos = EntityTool.getEntitysBySql(sqlGetCustAlphaNos, con, GenericEntity.class);
	    	for(GenericEntity custAlphaNo : listCustAlphaNos){
	    		if(Integer.parseInt(custAlphaNo.getCount()) != listJSON.size()) continue;
	    		int sameCount = 0;
	    		for(String strJSON : listJSON){
	    			SlmCustProcessEntity processEntity = EntityTool.getEntityByJSONStr(strJSON, SlmCustProcessEntity.class);
	    			String sqlGetCustProcess = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getCustProcess");
	    			sqlGetCustProcess = StringTool.ReplaceAll(sqlGetCustProcess, "#CUST_ALPHA_NO2#", custAlphaNo.getValue());
	    			sqlGetCustProcess = StringTool.ReplaceAll(sqlGetCustProcess, "#CUST_ALPHA_NO#", tmpCustAlphaNo);
	    			sqlGetCustProcess = EntityTool.fillSqlByEntity(sqlGetCustProcess, processEntity);
	    			Connection con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
	    			ArrayList<GenericEntity> listCustProcess = EntityTool.getEntitysBySql(sqlGetCustProcess, con2, GenericEntity.class);
	    			if(listCustProcess.get(0).getCount().equals("0") == false) sameCount++;
	    		}
	    		if(sameCount == Integer.parseInt(custAlphaNo.getCount()))
	    		{
	    			result = true;
	    			mscOrCustAlphaNo = custAlphaNo.getValue();
	    			break;
	    		}
	    	}
    	}
    	
    	Object[] objs = new Object[]{result, mscOrCustAlphaNo};
    	cro.setResult(objs);
    	return cro;
    }
    
    /**
     * 获取技术要求状态
     * @param custAlphaNo
     * @return obj
     */
    public CoreReturnObject getCustAlphaState(String custAlphaNo){
		String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getCustAlphaState");
    	sql = StringTool.ReplaceAll(sql, "#CUST_ALPHA_NO#", custAlphaNo);
    	
    	return this.getData(sql);
    }
    
    public CoreReturnObject getCustAlphaUseCount(String custAlphaNo, String ordLnPk){
    	String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getCustAlphaUseCount");
    	sql = StringTool.ReplaceAll(sql, "#CUST_ALPHA_NO#", custAlphaNo);
    	sql = StringTool.ReplaceAll(sql, "#ORD_LN_PK#", ordLnPk);
    	
    	return this.getData(sql);
    }
    
    /**
     * 通过产品码和客户要求码获取冶金规范表
     * @param psc
     * @param custAlphaNo
     * @return obj
     */
    public CoreReturnObject getComMscByPscCstAlpNo(String psc, String custAlphaNo){
    	String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getComMscByPscCstAlpNo");
    	sql = StringTool.ReplaceAll(sql, "#PSC#", psc);
    	sql = StringTool.ReplaceAll(sql, "#CUST_ALPHA_NO#", custAlphaNo);
    	return this.getData(sql);
    }
    
    /**
     * 通过产品码和客户要求码获取冶金规范表
     * @param msc
     * @return obj
     */
    public CoreReturnObject getComMscByMsc(String msc){
    	String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getComMscByMsc");
    	sql = StringTool.ReplaceAll(sql, "#MSC#", msc);
    	return this.getData(sql);
    }
    
    /**
     * 查询用途码与客户关系数目
     * @param msc
     * @param custCode
     * @return
     */
    public CoreReturnObject getStdRCustCnt(String msc, String custCode){
    	String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getStdRCustCnt");
    	sql = StringTool.ReplaceAll(sql, "#MSC#", msc);
    	sql = StringTool.ReplaceAll(sql, "#CUST_CODE#", custCode);
    	return this.getData(sql);
    }
    
    /**
     * 新增客户与用途码关系
     * @param msc
     * @param user
     * @param name
     * @return
     */
    public CoreReturnObject insertStdRCust(String msc, String user, String name, String custAlphaNo){
    	String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.insertStdRCust");
    	sql = StringTool.ReplaceAll(sql, "#MSC#", msc);
    	sql = StringTool.ReplaceAll(sql, "#CUSTOMER_NO#", user);
    	sql = StringTool.ReplaceAll(sql, "#CREATE_NAME#", name);
    	
//    	String sqlUpdateComPscRMsc = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.updateComPscRMsc");
//    	sqlUpdateComPscRMsc = StringTool.ReplaceAll(sqlUpdateComPscRMsc, "#MSC#", msc);
//    	sqlUpdateComPscRMsc = StringTool.ReplaceAll(sqlUpdateComPscRMsc, "#CUST_ALPHA_NO#", custAlphaNo);
    	
    	ArrayList<String> sqlList = new ArrayList<String>();
    	sqlList.add(sql);
    	//sqlList.add(sqlUpdateComPscRMsc);
    	return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(sqlList);
    }
    
    /**
     * 通过产品码获取标准表
     * @param psc
     * @return obj
     */
    public CoreReturnObject getBaseStdByPsc(String psc){
    	String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getBaseStdByPsc");
    	sql = StringTool.ReplaceAll(sql, "#PSC#", psc);
    	return this.getData(sql);
    }
    
    /**
     * 通过规格代码获取规格表
     * @param specCode
     * @return obj
     */
    public CoreReturnObject getSpecBySpecCode(String specCode){
    	String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getSpecBySpecCode");
    	sql = StringTool.ReplaceAll(sql, "#SPEC_CODE#", specCode);
    	return this.getData(sql);
    }
    
    /**
     * 修改扣型
     * @return
     */
    public CoreReturnObject setPscRMscCustAlphaNo(String msc, String custAlphaNo, String name,
    		String modelCode, String modelDesc, String cic, String pic, String dic, String sic, String wic, String gic){
    	String sqlUpdateComPscRMsc = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.updateComPscRMsc");
    	sqlUpdateComPscRMsc = StringTool.ReplaceAll(sqlUpdateComPscRMsc, "#MSC#", msc);
    	sqlUpdateComPscRMsc = StringTool.ReplaceAll(sqlUpdateComPscRMsc, "#CUST_ALPHA_NO#", custAlphaNo);
    	sqlUpdateComPscRMsc = StringTool.ReplaceAll(sqlUpdateComPscRMsc, "#UPDATE_NAME#", name);
    	
    	String sqlUpdateCustAlphaState = CoreXmlSqlParsersFactory.getSql("QualityMsc.updateCustAlphaState");
    	sqlUpdateCustAlphaState = StringTool.ReplaceAll(sqlUpdateCustAlphaState, "#CUST_ALPHA_STS#", "S");
    	sqlUpdateCustAlphaState = StringTool.ReplaceAll(sqlUpdateCustAlphaState, "#UPDATE_NAME#", name);
    	sqlUpdateCustAlphaState = StringTool.ReplaceAll(sqlUpdateCustAlphaState, "#REVIEW_F_RS#", "");
    	sqlUpdateCustAlphaState = StringTool.ReplaceAll(sqlUpdateCustAlphaState, "#CUST_ALPHA_NO#", custAlphaNo);
    	
    	String sqlSetCicModel = CoreXmlSqlParsersFactory.getSql("QualityMsc.setModeToChem");
    	sqlSetCicModel = StringTool.ReplaceAll(sqlSetCicModel, "#MODEL_CODE#", modelCode);
    	sqlSetCicModel = StringTool.ReplaceAll(sqlSetCicModel, "#MODEL_DESC#", modelDesc);
    	sqlSetCicModel = StringTool.ReplaceAll(sqlSetCicModel, "#UPDATE_NAME#", name);
    	sqlSetCicModel = StringTool.ReplaceAll(sqlSetCicModel, "#CIC#", cic);
    	
    	String sqlSetPicModel = CoreXmlSqlParsersFactory.getSql("QualityMsc.setModeToPhy");
    	sqlSetPicModel = StringTool.ReplaceAll(sqlSetPicModel, "#MODEL_CODE#", modelCode);
    	sqlSetPicModel = StringTool.ReplaceAll(sqlSetPicModel, "#MODEL_DESC#", modelDesc);
    	sqlSetPicModel = StringTool.ReplaceAll(sqlSetPicModel, "#UPDATE_NAME#", name);
    	sqlSetPicModel = StringTool.ReplaceAll(sqlSetPicModel, "#PIC#", pic);
    	
    	String sqlSetDicModel = CoreXmlSqlParsersFactory.getSql("QualityMsc.setModeToDetection");
    	sqlSetDicModel = StringTool.ReplaceAll(sqlSetDicModel, "#MODEL_CODE#", modelCode);
    	sqlSetDicModel = StringTool.ReplaceAll(sqlSetDicModel, "#MODEL_DESC#", modelDesc);
    	sqlSetDicModel = StringTool.ReplaceAll(sqlSetDicModel, "#UPDATE_NAME#", name);
    	sqlSetDicModel = StringTool.ReplaceAll(sqlSetDicModel, "#DIC#", dic);
    	
    	String sqlSetSicModel = CoreXmlSqlParsersFactory.getSql("QualityMsc.setModeToSpec");
    	sqlSetSicModel = StringTool.ReplaceAll(sqlSetSicModel, "#MODEL_CODE#", modelCode);
    	sqlSetSicModel = StringTool.ReplaceAll(sqlSetSicModel, "#MODEL_DESC#", modelDesc);
    	sqlSetSicModel = StringTool.ReplaceAll(sqlSetSicModel, "#UPDATE_NAME#", name);
    	sqlSetSicModel = StringTool.ReplaceAll(sqlSetSicModel, "#SIC#", sic);
    	
    	String sqlSetWicModel = CoreXmlSqlParsersFactory.getSql("QualityMsc.setModeToWater");
    	sqlSetWicModel = StringTool.ReplaceAll(sqlSetWicModel, "#MODEL_CODE#", modelCode);
    	sqlSetWicModel = StringTool.ReplaceAll(sqlSetWicModel, "#MODEL_DESC#", modelDesc);
    	sqlSetWicModel = StringTool.ReplaceAll(sqlSetWicModel, "#UPDATE_NAME#", name);
    	sqlSetWicModel = StringTool.ReplaceAll(sqlSetWicModel, "#WIC#", wic);
    	
    	String sqlSetGicModel = CoreXmlSqlParsersFactory.getSql("QualityMsc.setModeToProcess");
    	sqlSetGicModel = StringTool.ReplaceAll(sqlSetGicModel, "#MODEL_CODE#", modelCode);
    	sqlSetGicModel = StringTool.ReplaceAll(sqlSetGicModel, "#MODEL_DESC#", modelDesc);
    	sqlSetGicModel = StringTool.ReplaceAll(sqlSetGicModel, "#UPDATE_NAME#", name);
    	sqlSetGicModel = StringTool.ReplaceAll(sqlSetGicModel, "#GIC#", gic);
    	ArrayList<String> sqllist = new ArrayList<String>();
    	sqllist.add(sqlUpdateComPscRMsc);
    	sqllist.add(sqlUpdateCustAlphaState);
    	sqllist.add(sqlSetCicModel);
    	sqllist.add(sqlSetPicModel);
    	sqllist.add(sqlSetDicModel);
    	sqllist.add(sqlSetSicModel);
    	sqllist.add(sqlSetWicModel);
    	sqllist.add(sqlSetGicModel);
    	return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(sqllist);
    }
    
    /**
     * 修改特殊要求状态
     * @return
     */
    public CoreReturnObject setCustAlphaNoState(String custAlphaNo, String name){
    	String sqlUpdateCustAlphaState = CoreXmlSqlParsersFactory.getSql("QualityMsc.updateCustAlphaState");
    	sqlUpdateCustAlphaState = StringTool.ReplaceAll(sqlUpdateCustAlphaState, "#CUST_ALPHA_STS#", "S");
    	sqlUpdateCustAlphaState = StringTool.ReplaceAll(sqlUpdateCustAlphaState, "#UPDATE_NAME#", name);
    	sqlUpdateCustAlphaState = StringTool.ReplaceAll(sqlUpdateCustAlphaState, "#REVIEW_F_RS#", "");
    	sqlUpdateCustAlphaState = StringTool.ReplaceAll(sqlUpdateCustAlphaState, "#CUST_ALPHA_NO#", custAlphaNo);
    	ArrayList<String> sqllist = new ArrayList<String>();
    	sqllist.add(sqlUpdateCustAlphaState);
    	return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(sqllist);
    }
    
    /**
     * 获取交付标准项目数
     * @param msc
     * @return
     */
    public CoreReturnObject getStdPayItemCnt(String msc){
    	String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getStdPayItemCnt");
    	sql = StringTool.ReplaceAll(sql, "#MSC#", msc);
    	return this.getData(sql);
    }
    
    /**
	 * 作废特殊要求
	 * @param alphaNo
	 * @param userName
	 * @return
	 */
	public CoreReturnObject deleteSlmCustAlpha(String alphaNo, String userName){
		String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.deleteSlmCustAlpha");
		sql = StringTool.ReplaceAll(sql, "#DELETE_NAME#", userName);
		sql = StringTool.ReplaceAll(sql, "#CUST_ALPHA_NO#", alphaNo);
		return this.setData(sql);
	}
	
	/**
	 * 查询使用特殊要求码的合同数量
	 * @param alphaNo
	 * @return
	 */
	public CoreReturnObject getSlmOrdLineCntByAlphaNo(String alphaNo){
		String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getSlmOrdLineCntByAlphaNo");
		sql = StringTool.ReplaceAll(sql, "#CUST_ALPHA_NO#", alphaNo);
		return this.getData(sql);
	}
	
	/**
	 * 查询产品表
	 * @param psc
	 * @return
	 */
	public CoreReturnObject getComPsc(String psc){
		String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getComPsc");
		sql = StringTool.ReplaceAll(sql, "#PSC#", psc);
		return this.getData(sql);
	}

	/**
	 * 获取扣型类型
	 * @param modelCode
	 * @return
	 */
	public CoreReturnObject getModelStyle(String modelCode){
		String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getModelStyleByModelCode");
		sql = StringTool.ReplaceAll(sql, "#MODEL_CODE#", modelCode);

		return this.getData(sql);
	}
}
