package com.steering.pss.sale.order;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
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.SqlBuilder;
import com.steering.comm.tools.StringTool;
import com.steering.comm.tools.TransctionTool;
import com.steering.pss.qcm.model.GenericEntity;
import com.steering.pss.sale.order.ReviewForm.CoreOrderReviewTechnology;
import com.steering.pss.sale.order.model.BaseAdditionalEntity;
import com.steering.pss.sale.order.model.SlmOrderAddAskObject;

/**
 * 特殊附加要求
 * 
 * @author Administrator PDY 2015/03/18
 * 
 */
public class CoreOrderAddAsk extends DBCommon {

	
	
	/**
	 * 查询附加要求代码
	 * 
	 * @param custerCode
	 *            最终客户代码
	 * @return 数据集
	 */
	public CoreReturnObject UpdateAskAddStatus(String askAddNo,Boolean b) {
		String strStatus="";
		if(b)
		{
			strStatus="S";
		}
		else
		{
			strStatus="F";
		}
		Object[] params = new Object[] { strStatus,askAddNo };
		return this.setDataBySqlID("CoreOrderSpecialInfo.UpdateAskAddStatus",
				params);
	}
	
	
	/**
	 * 查询附加要求代码
	 * 
	 * @param custerCode
	 *            最终客户代码
	 * @return 数据集
	 */
	public CoreReturnObject queryAddAskCode(String custerCode, String addAskNo) {
		Object[] params = new Object[] { custerCode, addAskNo, addAskNo, addAskNo};
		return this.getDataBySqlID("CoreOrderSpecialInfo.queryAskAddCode",
				params);
	}
	
	/**
	 * 查询附加要求Tree最大值
	 * 
	 * @param custerCode
	 *            最终客户代码
	 * @return 数据集
	 */
	public CoreReturnObject queryAskItmeOrderMax(String custerCode,String psc) {
		Object[] params = new Object[] { custerCode,psc };
		return this.getDataBySqlID("CoreOrderSpecialInfo.queryAskItmeOrderMax",
				params);
	}
	
	/**
	 * 查询二大规范附加要求代码
	 * 
	 * @param custerCode
	 *            最终客户代码
	 * @return 数据集
	 */
	public CoreReturnObject queryBaseAskAddCode(String custerCode) {
		Object[] params = new Object[] { custerCode };
		return this.getDataBySqlID("CoreOrderSpecialInfo.queryBaseAskAddCode",
				params);
	}
	
	/**
	 * 查询附加要求数据
	 * 
	 * @param msc
	 *            冶金规范码
	 * @param flag
	 *            标识
	 * @return 数据集
	 */
	public CoreReturnObject queryAddAsk(String stdCode, String addAskNo) {
		String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryUnionAsk");
		sql = StringTool.ReplaceAll(sql, "#STD_CODE#", stdCode);
		
		return this.getData(sql);

	}
	
	/**
	 * 查询客户要求之外的标准附加要求数据
	 * 
	 * @param msc
	 *            冶金规范码
	 * @param flag
	 *            标识
	 * @return 数据集
	 */
	public CoreReturnObject queryOtherStdAsk(String stdCode, String addAskNo) {
		String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryOtherStdAsk");
		sql = StringTool.ReplaceAll(sql, "#STD_CODE#", stdCode);
		sql = StringTool.ReplaceAll(sql, "#ADD_ASK_NO#", addAskNo);
		
		return this.getData(sql);

	}
	
	/**
	 * 查询附加要求数据
	 * 
	 * @param msc
	 *            冶金规范码
	 * @param flag
	 *            标识
	 * @return 数据集
	 */
	public CoreReturnObject queryAddOrderAsk(String stdcode, String addAskNo) {
		String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.queryUnionOrderAsk");
		sql = StringTool.ReplaceAll(sql, "#ADD_ASK_NO#", addAskNo);
		sql = StringTool.ReplaceAll(sql, "#STD_CODE#", stdcode);
		return this.getData(sql);

	}
	
	/**
	 * 查询客户附加要求项目数量
	 * 
	 * @param askItem
	 *            附加要求客户编码
	 */
	public CoreReturnObject queryAskItmeCount(String askItem) { 
		Object[] params = new Object[] { askItem};
		return this.getDataBySqlID("CoreOrderSpecialInfo.queryAskItmeCount",params); 
	}
	
	/**
	 * 查询客户附加要求
	 * 
	 * @param askItem
	 *            附加要求客户编码
	 */
	public CoreReturnObject queryAskItmeOrder(String askItem) { 
		Object[] params = new Object[] { askItem};
		return this.getDataBySqlID("CoreOrderSpecialInfo.queryAskItmeOrder",params); 
	}
	
	/**
	 * 查询客户附加要求
	 * 
	 * @param askItem
	 *            附加要求客户编码
	 */
	public CoreReturnObject getADDASK(String askItemID) { 
		Object[] params = new Object[] { askItemID,askItemID};
		return this.getDataBySqlID("CoreOrderSpecialInfo.getADDASK",params); 
	}
	
	/**
	 * 附加要求。
	 * @param askAddList
	 * @param askAddNoId
	 * @return
	 */
	public CoreReturnObject addAskAdd(ArrayList<Object> askAddList, String askAddNoId,
			String oldAskAddNo, String stdCode) {
		TransctionTool transction = new TransctionTool();
		Connection con = transction.getCon();
		boolean result = true;
		try{
			String addAskState = "W";
			if(isStdData(askAddList, stdCode) == true){
				addAskState = "S";
			}
			
			ArrayList<SlmOrderAddAskObject> askAddObjList = new ArrayList<SlmOrderAddAskObject>();
			for (int i = 0; i < askAddList.size(); i++) {
				String askAddtr = askAddList.get(i).toString();
				SlmOrderAddAskObject com = EntityTool.getEntityByGson(askAddtr, SlmOrderAddAskObject.class);
				askAddObjList.add(com);
			}
			
			for (int i = 0; i < askAddObjList.size(); i++) {
				SlmOrderAddAskObject com = askAddObjList.get(i);
				com.setAddAskStatus(addAskState);
				String sqlGetBaseAddAskCnt = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getBaseAddAskCnt");
				sqlGetBaseAddAskCnt = EntityTool.fillSqlByEntity(sqlGetBaseAddAskCnt, com);
				ArrayList<GenericEntity> listBaseAddAskCnt = EntityTool.getEntitysBySqlNoClsCon(sqlGetBaseAddAskCnt, con, GenericEntity.class);
				String maxAskItemNo = "";
				if(listBaseAddAskCnt.get(0).getCount().equals("0")){
					String sqlGetMaxAskItemNo = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getMaxAskItemNo");
					sqlGetMaxAskItemNo = EntityTool.fillSqlByEntity(sqlGetMaxAskItemNo, com);
					ArrayList<GenericEntity> listMaxAskItemNo = EntityTool.getEntitysBySqlNoClsCon(sqlGetMaxAskItemNo, con, GenericEntity.class);
					String sqlInsertBaseAddAsk = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.insertBaseAddAsk");
					sqlInsertBaseAddAsk = StringTool.ReplaceAll(sqlInsertBaseAddAsk, "#ASK_ITEM_NO#", listMaxAskItemNo.get(0).getMaxValue());
					sqlInsertBaseAddAsk = EntityTool.fillSqlByEntity(sqlInsertBaseAddAsk, com);
					result = transction.ExcuteTransction(sqlInsertBaseAddAsk);
					if(result == false) break;
					maxAskItemNo = listMaxAskItemNo.get(0).getMaxValue();
				}else{
					maxAskItemNo = listBaseAddAskCnt.get(0).getMaxValue();
				}
				
				//三个条件比对，如果一致则为标准项
				String sqlGetBseAddtionalCnt = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getBseAddtionalCnt");
				sqlGetBseAddtionalCnt = EntityTool.fillSqlByEntity(sqlGetBseAddtionalCnt, com);
				sqlGetBseAddtionalCnt = StringTool.ReplaceAll(sqlGetBseAddtionalCnt, "#STD_CODE#", stdCode);
				ArrayList<GenericEntity> listBseAddtionalCnt = EntityTool.getEntitysBySqlNoClsCon(sqlGetBseAddtionalCnt, con, GenericEntity.class);
				
				//二个条件比对，如果一致则为修改项
				String sqlGetBseAddtionalCnt3 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getBseAddtionalCnt3");
				sqlGetBseAddtionalCnt3 = EntityTool.fillSqlByEntity(sqlGetBseAddtionalCnt3, com);
				sqlGetBseAddtionalCnt3 = StringTool.ReplaceAll(sqlGetBseAddtionalCnt3, "#STD_CODE#", stdCode);
				ArrayList<GenericEntity> listBseAddtionalCnt3 = EntityTool.getEntitysBySqlNoClsCon(sqlGetBseAddtionalCnt3, con, GenericEntity.class);
				if(listBseAddtionalCnt.get(0).getCount().equals("0") == false){
					com.setAddAskType("0");//标准
				}
				else if(listBseAddtionalCnt3.get(0).getCount().equals("0") == false){
					com.setAddAskType("1");//修改
				}
				else{
					com.setAddAskType("2");//新增
				}
				
				String sqlInsertOrderAddAsk = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.insertOrderAddAsk");
				sqlInsertOrderAddAsk = StringTool.ReplaceAll(sqlInsertOrderAddAsk, "#ASK_SUB_ITME_VAL#", maxAskItemNo);
				sqlInsertOrderAddAsk = StringTool.ReplaceAll(sqlInsertOrderAddAsk, "#ADD_ASK_NO#", askAddNoId);
				sqlInsertOrderAddAsk = EntityTool.fillSqlByEntity(sqlInsertOrderAddAsk, com);
				result = transction.ExcuteTransction(sqlInsertOrderAddAsk);
				if(result == false) break;
			}
		}catch(Exception ex){
			return transction.rollBack();
		}
		if(result == false){
			return transction.rollBack();
		}else{
			return transction.commit();
		}
	}
	
	/**
	 * 是否和标准的附加要求完全一致，如果都一致，则状态直接为评审通过的状态。
	 * @param askAddList
	 * @param stdCode
	 * @return
	 */
	private boolean isStdData(ArrayList<Object> askAddList, String stdCode){
		String sqlGetBseAddtionalCnt2 = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getBseAddtionalCnt2");
		sqlGetBseAddtionalCnt2 = StringTool.ReplaceAll(sqlGetBseAddtionalCnt2, "#STD_CODE#", stdCode);
		Connection con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
		ArrayList<GenericEntity> listBseAddtionalCnt2 = EntityTool.getEntitysBySql(sqlGetBseAddtionalCnt2, con, GenericEntity.class);
		if(listBseAddtionalCnt2.get(0).getCount().equals(String.valueOf(askAddList.size())) == false){
			return false;
		}
		
		int sameCnt = 0;
		for (int i = 0; i < askAddList.size(); i++) {
			SlmOrderAddAskObject ordAddAskEntity = EntityTool.getEntityByJSONStr(
					askAddList.get(i).toString(), SlmOrderAddAskObject.class);
			String sqlGetBseAddtionalCnt = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getBseAddtionalCnt");
			sqlGetBseAddtionalCnt = EntityTool.fillSqlByEntity(sqlGetBseAddtionalCnt, ordAddAskEntity);
			sqlGetBseAddtionalCnt = StringTool.ReplaceAll(sqlGetBseAddtionalCnt, "#STD_CODE#", stdCode);
			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			ArrayList<GenericEntity> listBseAddtionalCnt = EntityTool.getEntitysBySql(sqlGetBseAddtionalCnt, con, GenericEntity.class);
			if(listBseAddtionalCnt.get(0).getCount().equals("0") == false){
				sameCnt++;
			}else{
				break;
			}
		}
		
		if(sameCnt == Integer.parseInt(listBseAddtionalCnt2.get(0).getCount())){
			return true;
		}else{
			return false;
		}
	}
	
	public CoreReturnObject addAskAddRow(ArrayList<Object> askAddList,
			String custCode, String custDesc, String askAddNo) {
		ArrayList<String> sqlIdList = new ArrayList<String>();
		ArrayList<Object[]> params = new ArrayList<Object[]>();
		for (int i = 0; i < askAddList.size(); i++) {
			String askAddtr = askAddList.get(i).toString();
			JSONObject json = JSONObject.fromObject(askAddtr);
			SlmOrderAddAskObject com = (SlmOrderAddAskObject) JSONObject
					.toBean(json, SlmOrderAddAskObject.class);
			Object[] param = null;
			if (com.getAddAskNo().equals("") || com.getAddAskNo().length() == 0) {
				sqlIdList.add("CoreOrderSpecialInfo.addAlphaAskAddRow");
				param = new Object[] {custCode, com.getAskItme(),
						com.getAskItmeDesc(), com.getAskSubItme(),
						com.getAskSubItmeDesc(), com.getAskSubItmeVal(),
						com.getAskSubItmeValDesc(), com.getPic(), custCode,
						custDesc, com.getPsc(), com.getPscDesc(),
						com.getCreateName() };
			} else {
				sqlIdList.add("CoreOrderSpecialInfo.updateAlphaAddAsk");
				param = new Object[] { com.getAskItme(), com.getAskItmeDesc(),
						com.getAskSubItme(), com.getAskSubItmeDesc(),
						com.getAskSubItmeVal(), com.getAskSubItmeValDesc(),
						com.getPic(), com.getUpdateName(), askAddNo };
			}
			params.add(param);
		}
		return this.setDataById(sqlIdList, params);
	}
	
	/**
	 * 获取标准代码
	 * @return
	 */
	public CoreReturnObject getStdCode(String psc, String user){
		String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getStdCode");
		sql = StringTool.ReplaceAll(sql, "#PSC#", psc);
		sql = StringTool.ReplaceAll(sql, "#CUSTOMER_NO#", user);
		
		return this.getData(sql);
	}
	
	/**
	 * 获取附加要求状态
	 * @param addAskNo
	 * @return
	 */
	public CoreReturnObject getAddAskState(String addAskNo){
		String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getAddAskState");
		sql = StringTool.ReplaceAll(sql, "#ADD_ASK_NO#", addAskNo);
		
		return this.getData(sql);
	}
	
	/**
	 * 是否存在附加要求
	 * @return
	 */
	public CoreReturnObject isExistAddAsk(String addAskNo, String askItem, String askSubItem){
		String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.isExistAddAsk");
		sql = StringTool.ReplaceAll(sql, "#ADD_ASK_NO#", addAskNo);
		sql = StringTool.ReplaceAll(sql, "#ASK_ITME#", askItem);
		sql = StringTool.ReplaceAll(sql, "#ASK_SUB_ITME#", askSubItem);
		
		return this.getData(sql);
	}
	
	/**
	 * 新增基础附加要求
	 * @param baseAddAsklList
	 * @param addAskNo
	 * @param strAction
	 * @return
	 */
	public CoreReturnObject insertBaseAdditional(ArrayList<String> baseAdditionallList,
			String addAskNo, String strAction, ArrayList<String[]> list, String userDept,
			String userName, String reviewRs){
//		if(strAction.equals("评审通过")){
//			for(String strJSON : baseAdditionallList){
//				String sqlGetAdditionalCount = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getAddAdditionalCount");
//				JSONObject obj = JSONObject.fromObject(strJSON);
//				BaseAdditionalEntity baseAdditionalEntity = (BaseAdditionalEntity)JSONObject.toBean(obj, BaseAdditionalEntity.class);
//				sqlGetAdditionalCount = EntityTool.fillSqlByEntity(sqlGetAdditionalCount, baseAdditionalEntity);
//				ArrayList<GenericEntity> list = EntityTool.getEntitysBySql(sqlGetAdditionalCount, 
//						this.getDao(CoreConstantData.sysbeanstr).getConnection(), GenericEntity.class);
//				if(list.get(0).getCount().equals("0")){
//					String sqlInsertAdditional = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.insertBaseAdditional");
//					sqllist.add( EntityTool.fillSqlByEntity(sqlInsertAdditional, baseAdditionalEntity));
//				}
//				else{
//					String sqlUpdateAdditional = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.updateAddAdditional");
//					sqllist.add( EntityTool.fillSqlByEntity(sqlUpdateAdditional, baseAdditionalEntity));
//				}
//			}
//		}
		
		CoreReturnObject core = new CoreReturnObject();
		if(baseAdditionallList.size() > 0){
			String strJSON = baseAdditionallList.get(0);
			JSONObject obj = JSONObject.fromObject(strJSON);
			BaseAdditionalEntity baseAdditionalEntity = (BaseAdditionalEntity)JSONObject.toBean(obj, BaseAdditionalEntity.class);
			String sqlUpdateOrderAddAskState = getOrderAddAskStateSql(addAskNo, baseAdditionalEntity.getUpdateName(), strAction, reviewRs);
		
	        Connection con = this.getDao(CoreConstantData.sysbeanstr)
	                .getConnection();
	        try {
	            con.setAutoCommit(false);
	            if(strAction.equals("评审不通过")){
		            CoreOrderReviewTechnology technology = new CoreOrderReviewTechnology();
		            core = technology.doCommit(list, userDept, userName, reviewRs, "0", con);
		            if(!core.getV_errMsg().equals("")){
		            	con.rollback();
		            	core.setResult(0);
		            	return core;
		            }
	            }
	            PreparedStatement ps = con.prepareStatement(sqlUpdateOrderAddAskState);
	            ps.executeUpdate();
	            
	            
	            //修改质量设计评审状态.
	            SqlBuilder b;
	            if(strAction.equals("评审通过")){
	            	String ordLnPk = list.get(0)[1];
	            	b = new SqlBuilder("CoreOrderSpecialInfo.deleteDesignAddAskSts");
	            	b.Fill(new String[]{ ordLnPk });
	            	ps.executeUpdate(b.toString());
	            	
	            	b = new SqlBuilder("CoreOrderSpecialInfo.insertDesignAddAskSts");
		            b.Fill(new String[]{ ordLnPk, "1"});
		            ps.executeUpdate(b.toString());
	            }
	            ps.close();
	            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;
	}
	
	public String getOrderAddAskStateSql(String addAskNo, String updateName, String strAction, String reviewRs){
		String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.updateOrderAddAskState");
		sql = StringTool.ReplaceAll(sql, "#ADD_ASK_NO#", addAskNo);
		sql = StringTool.ReplaceAll(sql, "#UPDATE_NAME#", updateName);
		sql = StringTool.ReplaceAll(sql, "#REVIEW_F_RS#", reviewRs);
		if(strAction.equals("评审通过")){
			sql = StringTool.ReplaceAll(sql, "#ADD_ASK_STATUS#", "S");
		}else{
			sql = StringTool.ReplaceAll(sql, "#ADD_ASK_STATUS#", "F");
		}
		
		return sql;
	}
	
	
	public CoreReturnObject checkIsSameData(ArrayList<String> listJSON, String custNo){
		Object[] results = new Object[]{false, ""};
    	String sqlGetOrdAddAsks = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getOrdAddAsksByCustNo");
    	sqlGetOrdAddAsks = StringTool.ReplaceAll(sqlGetOrdAddAsks, "#CUSTOMER_NO#", custNo);
    	Connection con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
    	ArrayList<GenericEntity> listOrdAddAsks = EntityTool.getEntitysBySql(sqlGetOrdAddAsks, con, GenericEntity.class);
    	for(GenericEntity ordAddAskNo : listOrdAddAsks){
    		if(Integer.parseInt(ordAddAskNo.getCount()) != listJSON.size()) continue;
    		int sameCount = 0;
    		for(String strJSON : listJSON){
    			SlmOrderAddAskObject orderAddAskEntity = EntityTool.getEntityByJSONStr(strJSON, SlmOrderAddAskObject.class);
    			String sqlGetOrdAddAskCnt = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getOrdAddAskCnt");
    			sqlGetOrdAddAskCnt = StringTool.ReplaceAll(sqlGetOrdAddAskCnt, "#ADD_ASK_NO#", ordAddAskNo.getValue());
    			sqlGetOrdAddAskCnt = EntityTool.fillSqlByEntity(sqlGetOrdAddAskCnt, orderAddAskEntity);
    			Connection con2 = this.getDao(CoreConstantData.sysbeanstr).getConnection();
    			ArrayList<GenericEntity> listOrdAddAskCnt = EntityTool.getEntitysBySql(sqlGetOrdAddAskCnt, con2, GenericEntity.class);
    			if(listOrdAddAskCnt.get(0).getCount().equals("0")){
    				break;
    			}else{
    				sameCount++;
    			}
    		}
    		if(sameCount == Integer.parseInt(ordAddAskNo.getCount()))
    		{
    			results[0] = true;
    			results[1] = ordAddAskNo.getValue();
    			break;
    		}
    	}
    	
    	CoreReturnObject cro = new CoreReturnObject();
    	cro.setResult(results);
    	return cro;
	}
	
	/**
	 * 保存图片路径
	 * @param pic
	 * @param AddAskNo
	 * @param AddSubItem
	 * @return
	 */
	public CoreReturnObject setPic(String pic, String AddAskNo, String AddSubItem){
		String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.setPic");
		sql = StringTool.ReplaceAll(sql, "#PIC#", pic);
		sql = StringTool.ReplaceAll(sql, "#ADD_ASK_NO#", AddAskNo);
		sql = StringTool.ReplaceAll(sql, "#ASK_SUB_ITME#", AddSubItem);
		
		return this.setData(sql);
	}
	
	/**
	 * 获取合同行引用的附加要求码的数目
	 * @param addAskNo
	 * @return obj
	 */
	public CoreReturnObject getOrdLnRefAddAskCnt(String addAskNo, String ordLnPk){
		String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getOrdLnRefAddAskCnt");
		sql = StringTool.ReplaceAll(sql, "#ADD_ASK_NO#", addAskNo);
		sql = StringTool.ReplaceAll(sql, "#ORD_LN_PK#", ordLnPk);
		
		return this.getData(sql);
	}
	
	/**
	 * 作废附加要求
	 * @param addAskNo
	 * @param userName
	 * @return
	 */
	public CoreReturnObject deleteSlmOrdAddAsk(String addAskNo, String userName){
		String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.deleteSlmOrdAddAsk");
		sql = StringTool.ReplaceAll(sql, "#DELETE_NAME#", userName);
		sql = StringTool.ReplaceAll(sql, "#ADD_ASK_NO#", addAskNo);
		return this.setData(sql);
	}
	
	/**
	 * 查询使用附加要求码的合同数量
	 * @param addAskNo
	 * @return
	 */
	public CoreReturnObject getSlmOrdLineCntByAskNo(String addAskNo){
		String sql = CoreXmlSqlParsersFactory.getSql("CoreOrderSpecialInfo.getSlmOrdLineCntByAskNo");
		sql = StringTool.ReplaceAll(sql, "#ADD_ASK_NO#", addAskNo);
		return this.getData(sql);
	}
}
