package com.steering.pss.sale.order.qualityDesign.server.iserver;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

import com.steering.pss.sale.order.model.ComMscEntity;
import com.steering.pss.sale.order.qualityDesign.Dao.factory.FactoryDao;
import com.steering.pss.sale.order.qualityDesign.Dao.imp.CustSpecialAskDaoImp;
import com.steering.pss.sale.order.qualityDesign.Dao.imp.MscDaoImp;
import com.steering.pss.sale.order.qualityDesign.server.imp.CustSpecialAskImp;

/**
 * 客户特殊要求业务类
 * 
 * @author Administrator
 * 
 */
public class ICustSpecialAsk implements CustSpecialAskImp {
	/**
	 * 验证客户特殊要求
	 * 
	 * @param con
	 *            连接字符串
	 * @param designEntity
	 * @return String
	 * @throws SQLException
	 */
	public String checkCustSpecialAsk(Connection con, String custAlphyNo,
			String msc, String finallerCode, String finallerDesc)
			throws SQLException {
		MscDaoImp mscDaoImp = FactoryDao.getMscDaoImp();
		CustSpecialAskDaoImp custSpecialAskDaoImp = FactoryDao
				.getCustSpecialAskDaoImp();
		String message = "";
		// 如果客户Alpha编号不存在
		if (custAlphyNo.equals("")) {
			// 没有引用冶金规范码,则代表这个冶金规范码是基础冶金规范码
			ComMscEntity mscInfo = mscDaoImp.getMsc(con, msc);
			if (mscInfo.getMscSeq().equals("")) {
				message = "";
			} else {
				String userCode = mscInfo.getUseCode();
				if (userCode.equals("")) {
					message = msc + " 用途码不存在";
				} else {
					List<String> useCodes = custSpecialAskDaoImp.getFinalCusts(
							con, userCode);
					if (useCodes == null || useCodes.size() == 0) {
						message = msc + " 用途码不适用任何客户,请确认是否新增适用客户:"
								+ finallerDesc;
					} else if (useCodes.contains("0000000000")) {
						message = "";
					} else if (useCodes.contains(finallerCode)) {
						message = "";
					} else {
						message = msc + " 不适用  " + finallerDesc
								+ "  客户,请确认是否新增适用此客户!";
					}
				}
			}
		} else {
			message = "合同有客户技术特殊要求,待人工确认";
		}
		return message;
	}
}
