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

import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;

import com.steering.pss.sale.order.model.DesignMscPlEntity;
import com.steering.pss.sale.order.model.DesignMscPlStiEntity;
import com.steering.pss.sale.order.model.DesignStatusEntity;
import com.steering.pss.sale.order.model.MscProcessEntity;
import com.steering.pss.sale.order.qualityDesign.Dao.factory.FactoryDao;
import com.steering.pss.sale.order.qualityDesign.Dao.imp.MscDeteDaoImp;
import com.steering.pss.sale.order.qualityDesign.Dao.imp.OperationDaoImp;
import com.steering.pss.sale.order.qualityDesign.Dao.imp.OperationPointDaoImp;
import com.steering.pss.sale.order.qualityDesign.Dao.imp.ProDucDaoImp;
import com.steering.pss.sale.order.qualityDesign.Dao.imp.StatusDaoImp;
import com.steering.pss.sale.order.qualityDesign.ReturnsModel.DesignEntity;
import com.steering.pss.sale.order.qualityDesign.ReturnsModel.ProDucEntity;
import com.steering.pss.sale.order.qualityDesign.model.ComBasePhyRStationEntity;
import com.steering.pss.sale.order.qualityDesign.model.SlmOrdDesignStdDicEntity;
import com.steering.pss.sale.order.qualityDesign.server.imp.ProDucImp;

/**
 * 制程业务类(更改要求,如何将制程不通过时所有的制程信息全部显示出来)
 * 
 * @author Administrator PDY 2015-06-05
 */
public class ProDuc implements ProDucImp {
	private static StatusDaoImp statusDaoImp = FactoryDao.getStatusDaoImp();
	private static OperationPointDaoImp operationPointDaoImp = FactoryDao
			.getOperationPointDaoImp();
	private static ProDucDaoImp proDucDaoImp = FactoryDao.getProDucDaoImp();
	private static OperationDaoImp operationDaoImp = FactoryDao
			.getOperationDaoImp();
	private static List<DesignMscPlStiEntity> pointsList = null;

	// 验证制程流程：
	// 1、查询合同行冶金规格码的制程,如果没有制程,结束验证
	// 2、验证制程合理性
	// (1)有轧制和炼钢工序,则必须维护铸造工序
	// (2)有轧制前工序和后工序,必须有轧制工序
	// (3)制程全程途径码与工序的选择要对应(如:全程途径码:A-B-C-D,工序必须选择A、B、C、D))
	// (4)、根据成品规格判断制程的合理性
	// 3、制程包含某个工序,这个工序必须包含工序点
	// 4、制程工序点类型与基础冶金规范码存在交互标准类型相互校验
	// 5、附加要求工序点与制程工序点校验
	// 6、只要有一个制程通过验证,则制程通过验证
	/**
	 * 验证制程
	 * 
	 * @param con
	 *            连接字符串
	 * @param design
	 *            主键
	 * @param errMessages
	 *            提示信息
	 * @param setProDucs
	 *            设定制程
	 * @return List<DesignMscPlEntity>
	 * @throws SQLException
	 */
	public List<DesignMscPlEntity> checkProDuc(Connection con,
			DesignEntity design, List<String> errMessages,
			List<DesignMscPlEntity> setProDucs) throws SQLException {
		DesignStatusEntity status = null;
		List<DesignMscPlEntity> proDucs = null;
		if (setProDucs == null || setProDucs.size() == 0) {
			// 查询冶金规范码的制程
			proDucs = proDucDaoImp.getProcess(con, design.getOrderLineMsc());
		} else {
			proDucs = setProDucs;
		}
		// 第一步分析存在制程
		if (proDucs == null || proDucs.size() == 0) {
			status = statusDaoImp.setDesignStatus(design,
					design.getOrderLineMsc(), "制程", "F", "90", "冶金规范码("
							+ design.getOrderLineMsc() + ")缺少制程!",
					design.getOrderLineMsc(), design.getMscDunitCode(),
					design.getMscDunitDesc());
			status.setMsc(design.getOrderLineMsc());
			statusDaoImp.updateDesignStatus(con, status);
			return null;
		}
		// 验证制程
		List<DesignMscPlEntity> checkedProDucs = new ArrayList<DesignMscPlEntity>();
		List<ProDucEntity> proInfos = new ArrayList<ProDucEntity>();
		ProDucEntity proInfo = null;
		for (DesignMscPlEntity proDuc : proDucs) {
			// 设置合同行号
			proDuc.setOrdLnPk(design.getOrdLnPk());
			pointsList = new ArrayList<DesignMscPlStiEntity>();
			// 验证制程合理性
			String errMessage = ProDuc.checkProDuc(con, proDuc,
					design.getOrderLineMsc(), design.getOrderLineMscStyle(),
					design.getSpecStyle(), design.getAsselFl(),
					design.getOutsStlPileFl(), design.getModelCode(),
					design.getModelDesc());
			if (!errMessage.equals("")) {
				proInfo = new ProDucEntity();
				proInfo.setMsc(design.getOrderLineMsc());
				proInfo.setMscPline(proDuc.getMscPline());
				proInfo.setListItem("制程");
				proInfo.setDesignSts("F");
				proInfo.setDesignStsRs("92");
				proInfo.setDesignStsDesc(errMessage);
				proInfo.setUnitCode(design.getMscDunitCode());
				proInfo.setUnitDesc(design.getMscDunitDesc());
				proInfos.add(proInfo);
				// 如果是设定制程
				if (setProDucs != null && setProDucs.size() > 0) {
					break;
				}
				continue;
			}

			// 3、如果 产品对交付标准有要求,则要校验交付标准与制程工序点的完整性(例如:如果成分类型的工序点,则必须有交付成分标准)
			if (!design.getOrderLineMscStyle().equals("C")
					&& !design.getOrderLineMscStyle().equals("D")
					&& !design.getOrderLineMscStyle().equals("E")) {
				proInfo = ProDuc.checkChem(con, design.getMscValig(), design,
						pointsList, proDuc.getMscPline(), errMessages.get(0));
				if (proInfo != null) {
					proInfos.add(proInfo);
					// 如果是设定制程
					if (setProDucs != null && setProDucs.size() > 0) {
						break;
					}
					continue;
				}
				proInfo = ProDuc.checkPhy(con, design.getMscValig(), design,
						pointsList, proDuc.getMscPline(), errMessages.get(1));
				if (proInfo != null) {
					proInfos.add(proInfo);
					// 如果是设定制程
					if (setProDucs != null && setProDucs.size() > 0) {
						break;
					}
					continue;
				}
				proInfo = ProDuc.checkSpec(con, design.getMscValig(), design,
						pointsList, proDuc.getMscPline(), errMessages.get(2));
				if (proInfo != null) {
					proInfos.add(proInfo);
					// 如果是设定制程
					if (setProDucs != null && setProDucs.size() > 0) {
						break;
					}
					continue;
				}
				proInfo = ProDuc.checkDete(con, design.getMscValig(), design,
						pointsList, proDuc.getMscPline(), errMessages.get(3));
				if (proInfo != null) {
					proInfos.add(proInfo);
					// 如果是设定制程
					if (setProDucs != null && setProDucs.size() > 0) {
						break;
					}
					continue;
				}
				proInfo = ProDuc.checkWater(con, design.getMscValig(), design,
						pointsList, proDuc.getMscPline(), errMessages.get(4));
				if (proInfo != null) {
					proInfos.add(proInfo);
					// 如果是设定制程
					if (setProDucs != null && setProDucs.size() > 0) {
						break;
					}
					continue;
				}
				proInfo = ProDuc.checkProcess(con, design.getMscValig(),
						design, pointsList, proDuc.getMscPline(),
						errMessages.get(5));
				if (proInfo != null) {
					proInfos.add(proInfo);
					// 如果是设定制程
					if (setProDucs != null && setProDucs.size() > 0) {
						break;
					}
					continue;
				}
			}

			// 验证制程工序点与探伤工序点对应
			String message = ProDuc.checkDeteAndProDuc(con,
					design.getDesignKey(), pointsList, proDuc.getMscPline());
			if (!message.equals("")) {
				proInfo = new ProDucEntity();
				proInfo.setMsc(design.getOrderLineMsc());
				proInfo.setMscPline(proDuc.getMscPline());
				proInfo.setListItem("制程");
				proInfo.setDesignSts("F");
				proInfo.setDesignStsRs("92");
				proInfo.setDesignStsDesc(message);
				proInfo.setUnitCode(design.getMscDunitCode());
				proInfo.setUnitDesc(design.getMscDunitDesc());
				proInfos.add(proInfo);
				if (setProDucs != null && setProDucs.size() > 0) {
					break;
				}
				continue;
			}
			// 4、如果合同有附加要求,则制程的工序点要包含合同附加要求的工序点
			List<String[]> addStations = proDucDaoImp.getAddAskNoStation(con,
					design.getAddAskNo());
			boolean flag = true;
			if (addStations != null) {
				List<String> stationCodes = new ArrayList<String>();
				for (DesignMscPlStiEntity point : pointsList) {
					stationCodes.add(point.getStationCode());
				}
				for (String[] stationCode : addStations) {
					if (!stationCodes.contains(stationCode[0])) {
						proInfo = new ProDucEntity();
						proInfo.setMsc(design.getOrderLineMsc());
						proInfo.setMscPline(proDuc.getMscPline());
						proInfo.setListItem("制程");
						proInfo.setDesignSts("F");
						proInfo.setDesignStsRs("92");
						proInfo.setDesignStsDesc("制程(" + proDuc.getMscPline()
								+ ")找不到工序点(" + stationCode[1] + ")![合同附加要求("
								+ stationCode[2] + ")此工序点有要求]");
						proInfo.setUnitCode(design.getMscDunitCode());
						proInfo.setUnitDesc(design.getMscDunitDesc());
						proInfos.add(proInfo);
						flag = false;
						break;
					}
				}
			}
			if (!flag) {
				// 如果是设定制程
				if (setProDucs != null && setProDucs.size() > 0) {
					break;
				}
				continue;
			}
			checkedProDucs.add(proDuc);
			status = statusDaoImp.setDesignStatus(design,
					design.getOrderLineMsc(), "制程", "S", "11", "制程通过验证",
					design.getOrderLineMsc(), design.getMscDunitCode(),
					design.getMscDunitDesc());
			status.setMsc(design.getOrderLineMsc());
			statusDaoImp.updateDesignStatus(con, status);
		}
		if (checkedProDucs == null || checkedProDucs.size() == 0) {
			status = ProDuc.checkProDucInfos(proInfos, design);
			statusDaoImp.updateDesignStatus(con, status);
		}
		return checkedProDucs;
	}

	/**
	 * 验证工序点是否包含某个标准类型
	 * 
	 * @param stationType
	 * @param stationList
	 * @return
	 */
	public static boolean checkContainStationType(String stationType,
			List<DesignMscPlStiEntity> stationList) {
		if (stationList == null || stationList.size() == 0) {
			return false;
		}
		for (DesignMscPlStiEntity stationEntity : stationList) {
			if (stationEntity.getStationType().equals(stationType)) {
				return true;
			}
		}
		return false;
	}

	/**
	 * 验证成分与制程的关系
	 * 
	 * @param con
	 *            连接字符串
	 * @param valid
	 *            基础冶金规范码状态
	 * @param design
	 *            质量设计类
	 * @param stationList
	 *            工序点集合
	 * @param mscPline
	 *            全程产线号
	 * @return DesignStatusEntity
	 * @throws SQLException
	 */
	public static ProDucEntity checkChem(Connection con, String valid,
			DesignEntity design, List<DesignMscPlStiEntity> stationList,
			String mscPline, String errMessage) throws SQLException {
		int num = proDucDaoImp.getDesignChem(con, design.getDesignKey());
		if (valid.equals("C")) {
			if (num != 0) {
				if (ProDuc.checkContainStationType("403201", stationList)) {
					return null;
				} else {
					ProDucEntity proInfo = new ProDucEntity();
					proInfo.setMsc(design.getOrderLineMsc());
					proInfo.setMscPline(mscPline);
					proInfo.setListItem("制程");
					proInfo.setDesignSts("F");
					proInfo.setDesignStsRs("90");
					proInfo.setDesignStsDesc("制程(" + mscPline
							+ ")没有成分类工序点,但合同有成分标准!");
					proInfo.setUnitCode(design.getMscDunitCode());
					proInfo.setUnitDesc(design.getMscDunitDesc());
					return proInfo;
				}
			} else {
				if (ProDuc.checkContainStationType("403201", stationList)) {
					ProDucEntity proInfo = new ProDucEntity();
					proInfo.setMsc(design.getOrderLineMsc());
					proInfo.setMscPline(mscPline);
					proInfo.setListItem("制程");
					proInfo.setDesignSts("F");
					proInfo.setDesignStsRs("90");
					proInfo.setDesignStsDesc("制程(" + mscPline
							+ ")有成分类工序点,但合同没有成分标准!");
					proInfo.setUnitCode(design.getMscDunitCode());
					proInfo.setUnitDesc(design.getMscDunitDesc());
					return proInfo;
				} else {
					return null;
				}
			}
		} else {
			if (num != 0) {
				if (ProDuc.checkContainStationType("403201", stationList)) {
					return null;
				} else {
					ProDucEntity proInfo = new ProDucEntity();
					proInfo.setMsc(design.getOrderLineMsc());
					proInfo.setMscPline(mscPline);
					proInfo.setListItem("制程");
					proInfo.setDesignSts("F");
					proInfo.setDesignStsRs("90");
					proInfo.setDesignStsDesc("制程(" + mscPline
							+ ")没有成分类工序点,但合同有成分标准!");
					proInfo.setUnitCode(design.getMscDunitCode());
					proInfo.setUnitDesc(design.getMscDunitDesc());
					return proInfo;

				}
			} else {
				if (ProDuc.checkContainStationType("403201", stationList)) {
					ProDucEntity proInfo = new ProDucEntity();
					proInfo.setMsc(design.getMsc());
					proInfo.setMscPline(mscPline);
					proInfo.setListItem("成分标准");
					proInfo.setDesignSts("F");
					proInfo.setDesignStsRs("90");
					proInfo.setDesignStsDesc("制程(" + mscPline + ")有成分类工序点,"
							+ errMessage);
					proInfo.setUnitCode(design.getDunitCode());
					proInfo.setUnitDesc(design.getDunitDesc());
					return proInfo;
				} else {
					return null;
				}
			}
		}
	}

	/**
	 * 验证理化与制程的关系
	 * 
	 * @param con
	 *            连接字符串
	 * @param valid
	 *            基础冶金规范码状态
	 * @param design
	 *            质量设计类
	 * @param stationList
	 *            工序点集合
	 * @param mscPline
	 *            全程产线号
	 * @return DesignStatusEntity
	 * @throws SQLException
	 */
	public static ProDucEntity checkPhy(Connection con, String valid,
			DesignEntity design, List<DesignMscPlStiEntity> stationList,
			String mscPline, String errMessage) throws SQLException {
		int num = proDucDaoImp.getDesignPhy(con, design.getDesignKey());
		if (valid.equals("C")) {
			if (num != 0) {
				if (ProDuc.checkContainStationType("403202", stationList)) {
					return null;
				} else {
					ProDucEntity proInfo = new ProDucEntity();
					proInfo.setMsc(design.getOrderLineMsc());
					proInfo.setMscPline(mscPline);
					proInfo.setListItem("制程");
					proInfo.setDesignSts("F");
					proInfo.setDesignStsRs("90");
					proInfo.setDesignStsDesc("制程(" + mscPline
							+ ")没有理化类工序点,但合同有理化标准!");
					proInfo.setUnitCode(design.getMscDunitCode());
					proInfo.setUnitDesc(design.getMscDunitDesc());
					return proInfo;

				}
			} else {
				if (ProDuc.checkContainStationType("403202", stationList)) {
					ProDucEntity proInfo = new ProDucEntity();
					proInfo.setMsc(design.getOrderLineMsc());
					proInfo.setMscPline(mscPline);
					proInfo.setListItem("制程");
					proInfo.setDesignSts("F");
					proInfo.setDesignStsRs("90");
					proInfo.setDesignStsDesc("制程(" + mscPline
							+ ")有理化类工序点,但合同没有理化标准!");
					proInfo.setUnitCode(design.getMscDunitCode());
					proInfo.setUnitDesc(design.getMscDunitDesc());
					return proInfo;
				} else {
					return null;
				}
			}
		} else {
			if (num != 0) {
				if (ProDuc.checkContainStationType("403202", stationList)) {
					return null;
				} else {
					ProDucEntity proInfo = new ProDucEntity();
					proInfo.setMsc(design.getOrderLineMsc());
					proInfo.setMscPline(mscPline);
					proInfo.setListItem("制程");
					proInfo.setDesignSts("F");
					proInfo.setDesignStsRs("90");
					proInfo.setDesignStsDesc("制程(" + mscPline
							+ ")没有理化类工序点,但合同有理化标准!");
					proInfo.setUnitCode(design.getMscDunitCode());
					proInfo.setUnitDesc(design.getMscDunitDesc());
					return proInfo;
				}
			} else {
				if (ProDuc.checkContainStationType("403202", stationList)) {
					ProDucEntity proInfo = new ProDucEntity();
					proInfo.setMsc(design.getMsc());
					proInfo.setMscPline(mscPline);
					proInfo.setListItem("理化标准");
					proInfo.setDesignSts("F");
					proInfo.setDesignStsRs("90");
					proInfo.setDesignStsDesc("制程(" + mscPline + ")有理化类工序点,"
							+ errMessage);
					proInfo.setUnitCode(design.getDunitCode());
					proInfo.setUnitDesc(design.getDunitDesc());
					return proInfo;
				} else {
					return null;
				}
			}
		}
	}

	/**
	 * 验证公差与制程的关系
	 * 
	 * @param con
	 *            连接字符串
	 * @param valid
	 *            基础冶金规范码状态
	 * @param design
	 *            质量设计类
	 * @param stationList
	 *            工序点集合
	 * @param mscPline
	 *            全程产线号
	 * @return DesignStatusEntity
	 * @throws SQLException
	 */
	public static ProDucEntity checkSpec(Connection con, String valid,
			DesignEntity design, List<DesignMscPlStiEntity> stationList,
			String mscPline, String errMessage) throws SQLException {
		int num = proDucDaoImp.getDesignSpec(con, design.getDesignKey());
		if (valid.equals("C")) {
			if (num != 0) {
				if (ProDuc.checkContainStationType("403203", stationList)) {
					return null;
				} else {
					ProDucEntity proInfo = new ProDucEntity();
					proInfo.setMsc(design.getOrderLineMsc());
					proInfo.setMscPline(mscPline);
					proInfo.setListItem("制程");
					proInfo.setDesignSts("F");
					proInfo.setDesignStsRs("90");
					proInfo.setDesignStsDesc("制程(" + mscPline
							+ ")没有公差类工序点,但合同有公差标准!");
					proInfo.setUnitCode(design.getMscDunitCode());
					proInfo.setUnitDesc(design.getMscDunitDesc());
					return proInfo;
				}
			} else {
				if (ProDuc.checkContainStationType("403203", stationList)) {
					ProDucEntity proInfo = new ProDucEntity();
					proInfo.setMsc(design.getOrderLineMsc());
					proInfo.setMscPline(mscPline);
					proInfo.setListItem("制程");
					proInfo.setDesignSts("F");
					proInfo.setDesignStsRs("90");
					proInfo.setDesignStsDesc("制程(" + mscPline
							+ ")有公差类工序点,但合同没有公差标准!");
					proInfo.setUnitCode(design.getMscDunitCode());
					proInfo.setUnitDesc(design.getMscDunitDesc());
					return proInfo;
				} else {
					return null;
				}
			}
		} else {
			if (num != 0) {
				if (ProDuc.checkContainStationType("403203", stationList)) {
					return null;
				} else {
					ProDucEntity proInfo = new ProDucEntity();
					proInfo.setMsc(design.getOrderLineMsc());
					proInfo.setMscPline(mscPline);
					proInfo.setListItem("制程");
					proInfo.setDesignSts("F");
					proInfo.setDesignStsRs("90");
					proInfo.setDesignStsDesc("制程(" + mscPline
							+ ")没有公差类工序点,但合同公差标准!");
					proInfo.setUnitCode(design.getMscDunitCode());
					proInfo.setUnitDesc(design.getMscDunitDesc());
					return proInfo;

				}
			} else {
				if (ProDuc.checkContainStationType("403203", stationList)) {
					ProDucEntity proInfo = new ProDucEntity();
					proInfo.setMsc(design.getMsc());
					proInfo.setMscPline(mscPline);
					proInfo.setListItem("公差标准");
					proInfo.setDesignSts("F");
					proInfo.setDesignStsRs("90");
					proInfo.setDesignStsDesc("制程(" + mscPline + ")有公差类工序点,"
							+ errMessage);
					proInfo.setUnitCode(design.getDunitCode());
					proInfo.setUnitDesc(design.getDunitDesc());
					return proInfo;
				} else {
					return null;
				}
			}
		}
	}

	/**
	 * 验证探伤与制程的关系
	 * 
	 * @param con
	 *            连接字符串
	 * @param valid
	 *            基础冶金规范码状态
	 * @param design
	 *            质量设计类
	 * @param stationList
	 *            工序点集合
	 * @param mscPline
	 *            全程产线号
	 * @return DesignStatusEntity
	 * @throws SQLException
	 */
	public static ProDucEntity checkDete(Connection con, String valid,
			DesignEntity design, List<DesignMscPlStiEntity> stationList,
			String mscPline, String errMessage) throws SQLException {
		int num = proDucDaoImp.getDesignDete(con, design.getDesignKey());
		if (valid.equals("C")) {
			if (num != 0) {
				if (ProDuc.checkContainStationType("403204", stationList)) {
					return null;
				} else {
					ProDucEntity proInfo = new ProDucEntity();
					proInfo.setMsc(design.getOrderLineMsc());
					proInfo.setMscPline(mscPline);
					proInfo.setListItem("制程");
					proInfo.setDesignSts("F");
					proInfo.setDesignStsRs("90");
					proInfo.setDesignStsDesc("制程(" + mscPline
							+ ")没有探伤类工序点,但合同有探伤标准!");
					proInfo.setUnitCode(design.getMscDunitCode());
					proInfo.setUnitDesc(design.getMscDunitDesc());
					return proInfo;
				}
			} else {
				if (ProDuc.checkContainStationType("403204", stationList)) {
					ProDucEntity proInfo = new ProDucEntity();
					proInfo.setMsc(design.getOrderLineMsc());
					proInfo.setMscPline(mscPline);
					proInfo.setListItem("制程");
					proInfo.setDesignSts("F");
					proInfo.setDesignStsRs("90");
					proInfo.setDesignStsDesc("制程(" + mscPline
							+ ")有探伤类工序点,但合同没有探伤标准!");
					proInfo.setUnitCode(design.getMscDunitCode());
					proInfo.setUnitDesc(design.getMscDunitDesc());
					return proInfo;
				} else {
					return null;
				}
			}
		} else {
			if (num != 0) {
				if (ProDuc.checkContainStationType("403204", stationList)) {
					return null;
				} else {
					ProDucEntity proInfo = new ProDucEntity();
					proInfo.setMsc(design.getOrderLineMsc());
					proInfo.setMscPline(mscPline);
					proInfo.setListItem("制程");
					proInfo.setDesignSts("F");
					proInfo.setDesignStsRs("90");
					proInfo.setDesignStsDesc("制程(" + mscPline
							+ ")没有探伤类工序点,但合同有探伤标准!");
					proInfo.setUnitCode(design.getMscDunitCode());
					proInfo.setUnitDesc(design.getMscDunitDesc());
					return proInfo;
				}
			} else {
				if (ProDuc.checkContainStationType("403204", stationList)) {
					ProDucEntity proInfo = new ProDucEntity();
					proInfo.setMsc(design.getMsc());
					proInfo.setMscPline(mscPline);
					proInfo.setListItem("探伤标准");
					proInfo.setDesignSts("F");
					proInfo.setDesignStsRs("90");
					proInfo.setDesignStsDesc("制程(" + mscPline + ")有探伤类工序点,"
							+ errMessage);
					proInfo.setUnitCode(design.getDunitCode());
					proInfo.setUnitDesc(design.getDunitDesc());
					return proInfo;
				} else {
					return null;
				}
			}
		}
	}

	/**
	 * 验证水压与制程的关系
	 * 
	 * @param con
	 *            连接字符串
	 * @param valid
	 *            基础冶金规范码状态
	 * @param design
	 *            质量设计类
	 * @param stationList
	 *            工序点集合
	 * @param mscPline
	 *            全程产线号
	 * @return DesignStatusEntity
	 * @throws SQLException
	 */
	public static ProDucEntity checkWater(Connection con, String valid,
			DesignEntity design, List<DesignMscPlStiEntity> stationList,
			String mscPline, String errMessage) throws SQLException {
		int num = proDucDaoImp.getDesignWater(con, design.getDesignKey());
		if (valid.equals("C")) {
			if (num != 0) {
				if (ProDuc.checkContainStationType("403205", stationList)) {
					return null;
				} else {
					ProDucEntity proInfo = new ProDucEntity();
					proInfo.setMsc(design.getOrderLineMsc());
					proInfo.setMscPline(mscPline);
					proInfo.setListItem("制程");
					proInfo.setDesignSts("F");
					proInfo.setDesignStsRs("90");
					proInfo.setDesignStsDesc("制程(" + mscPline
							+ ")没有水压类工序点,但合同有水压标准!");
					proInfo.setUnitCode(design.getMscDunitCode());
					proInfo.setUnitDesc(design.getMscDunitDesc());
					return proInfo;

				}
			} else {
				if (ProDuc.checkContainStationType("403205", stationList)) {
					ProDucEntity proInfo = new ProDucEntity();
					proInfo.setMsc(design.getOrderLineMsc());
					proInfo.setMscPline(mscPline);
					proInfo.setListItem("制程");
					proInfo.setDesignSts("F");
					proInfo.setDesignStsRs("90");
					proInfo.setDesignStsDesc("制程(" + mscPline
							+ ")有水压类工序点类,但合同没有水压标准!");
					proInfo.setUnitCode(design.getMscDunitCode());
					proInfo.setUnitDesc(design.getMscDunitDesc());
					return proInfo;
				} else {
					return null;
				}
			}
		} else {
			if (num != 0) {
				if (ProDuc.checkContainStationType("403205", stationList)) {
					return null;
				} else {
					ProDucEntity proInfo = new ProDucEntity();
					proInfo.setMsc(design.getOrderLineMsc());
					proInfo.setMscPline(mscPline);
					proInfo.setListItem("制程");
					proInfo.setDesignSts("F");
					proInfo.setDesignStsRs("90");
					proInfo.setDesignStsDesc("制程(" + mscPline
							+ ")没有水压类工序点,但合同有水压标准!");
					proInfo.setUnitCode(design.getMscDunitCode());
					proInfo.setUnitDesc(design.getMscDunitDesc());
					return proInfo;
				}
			} else {
				if (ProDuc.checkContainStationType("403205", stationList)) {
					ProDucEntity proInfo = new ProDucEntity();
					proInfo.setMsc(design.getMsc());
					proInfo.setMscPline(mscPline);
					proInfo.setListItem("水压标准");
					proInfo.setDesignSts("F");
					proInfo.setDesignStsRs("90");
					proInfo.setDesignStsDesc("制程(" + mscPline + ")有水压类工序点,"
							+ errMessage);
					proInfo.setUnitCode(design.getDunitCode());
					proInfo.setUnitDesc(design.getDunitDesc());
					return proInfo;
				} else {
					return null;
				}
			}
		}
	}

	/**
	 * 验证加工与制程的关系
	 * 
	 * @param con
	 *            连接字符串
	 * @param valid
	 *            基础冶金规范码状态
	 * @param design
	 *            质量设计类
	 * @param stationList
	 *            工序点集合
	 * @param mscPline
	 *            全程产线号
	 * @return DesignStatusEntity
	 * @throws SQLException
	 */
	public static ProDucEntity checkProcess(Connection con, String valid,
			DesignEntity design, List<DesignMscPlStiEntity> stationList,
			String mscPline, String errMessage) throws SQLException {
		int num = proDucDaoImp.getDesignGic(con, design.getDesignKey());
		if (valid.equals("C")) {
			if (num != 0) {
				if (ProDuc.checkContainStationType("403208", stationList)) {
					return null;
				} else {
					ProDucEntity proInfo = new ProDucEntity();
					proInfo.setMsc(design.getOrderLineMsc());
					proInfo.setMscPline(mscPline);
					proInfo.setListItem("制程");
					proInfo.setDesignSts("F");
					proInfo.setDesignStsRs("90");
					proInfo.setDesignStsDesc("制程(" + mscPline
							+ ")没有(端部)加工类工序点,但合同有加工标准!");
					proInfo.setUnitCode(design.getMscDunitCode());
					proInfo.setUnitDesc(design.getMscDunitDesc());
					return proInfo;
				}
			} else {
				if (ProDuc.checkContainStationType("403208", stationList)) {
					ProDucEntity proInfo = new ProDucEntity();
					proInfo.setMsc(design.getOrderLineMsc());
					proInfo.setMscPline(mscPline);
					proInfo.setListItem("制程");
					proInfo.setDesignSts("F");
					proInfo.setDesignStsRs("90");
					proInfo.setDesignStsDesc("制程(" + mscPline
							+ ")有(端部)加工类工序点,但合同没有加工标准!");
					proInfo.setUnitCode(design.getMscDunitCode());
					proInfo.setUnitDesc(design.getMscDunitDesc());
					return proInfo;
				} else {
					return null;
				}
			}
		} else {
			if (num != 0) {
				if (ProDuc.checkContainStationType("403208", stationList)) {
					return null;
				} else {
					ProDucEntity proInfo = new ProDucEntity();
					proInfo.setMsc(design.getOrderLineMsc());
					proInfo.setMscPline(mscPline);
					proInfo.setListItem("制程");
					proInfo.setDesignSts("F");
					proInfo.setDesignStsRs("90");
					proInfo.setDesignStsDesc("制程(" + mscPline
							+ ")没有(端部)加工类工序点,但合同有加工标准!");
					proInfo.setUnitCode(design.getMscDunitCode());
					proInfo.setUnitDesc(design.getMscDunitDesc());
					return proInfo;
				}
			} else {
				if (ProDuc.checkContainStationType("403208", stationList)) {
					ProDucEntity proInfo = new ProDucEntity();
					proInfo.setMsc(design.getMsc());
					proInfo.setMscPline(mscPline);
					proInfo.setListItem("加工标准");
					proInfo.setDesignSts("F");
					proInfo.setDesignStsRs("90");
					proInfo.setDesignStsDesc("制程(" + mscPline + ")有(端部)加工类工序点,"
							+ errMessage);
					proInfo.setUnitCode(design.getDunitCode());
					proInfo.setUnitDesc(design.getDunitDesc());
					return proInfo;
				} else {
					return null;
				}
			}
		}
	}

	/**
	 * 验证制程的合理性
	 * 
	 * @param con
	 *            连接字符串
	 * @param proDuc
	 *            制程
	 * @param msc
	 *            冶金规范码
	 * @param mscStyle
	 *            冶金规范码类型
	 * @param specCode
	 *            产品规格类型
	 * @return String(提示信息)
	 * @throws SQLException
	 */
	public static String checkProDuc(Connection con, DesignMscPlEntity proDuc,
			String msc, String mscStyle, String specStyle, String assel,
			String outsStlPileFl, String modelCode, String modelName)
			throws SQLException {
		String errMessage = "";
		String wholeBacklog = proDuc.getWholeBacklog();
		String[] processCodes = wholeBacklog.split("-");
		// 1、制程全程途径码不能为空
		if (processCodes == null || processCodes.length == 0) {
			errMessage = "制程(" + proDuc.getMscPline() + ")全程途径码为空,没有工序!";
			return errMessage;
		}
		// 2、制程包含某个工序,但工序没有选择这个工序
		for (String processCode : processCodes) {
			MscProcessEntity processInfo = operationDaoImp.getOperation(con,
					msc, proDuc.getMscPline(), processCode);
			if (processInfo == null) {
				errMessage = "制程(" + proDuc.getMscPline() + ")/ 全程途径码("
						+ proDuc.getWholeBacklog() + ")包含工序(" + processCode
						+ "),但没有维护此工序!";
				return errMessage;
			}
			// 3、工序没有选择工序点
			List<DesignMscPlStiEntity> points = operationPointDaoImp
					.getDesignPoint(con, msc, proDuc.getMscPline(), processCode);
			if (points == null || points.size() == 0) {
				errMessage = "制程(" + proDuc.getMscPline() + ")/工序("
						+ processCode + ")没有维护工序点!";
				return errMessage;
			}
			// 4、工序点没有顺序号
			for (DesignMscPlStiEntity point : points) {
				if (point.getStationId().equals("")
						|| point.getProcessCodeC().equals("")) {
					errMessage = "制程(" + proDuc.getMscPline() + ") /工序("
							+ processCode + ")/工序点(" + point.getStationDesc()
							+ ")顺序号不能为空!";
					return errMessage;
				}
				pointsList.add(point);
			}
		}
		
		if((mscStyle.contains("A") || mscStyle.contains("B")) &&  (!outsStlPileFl.equals("121902") && !outsStlPileFl.equals("121903"))){
			if(!wholeBacklog.contains("A") || !wholeBacklog.contains("B")){
				errMessage = "非外购管并且产品类型为钢管的产品，其制程(" + proDuc.getMscPline()
				+ ")必须包含炼钢和铸造工序！";
				return errMessage;
			}
		}
		
		// 5、制程的合理性
		if (wholeBacklog.contains("D") && wholeBacklog.contains("A")
				&& !wholeBacklog.contains("B") && !outsStlPileFl.equals("121902") && !outsStlPileFl.equals("121903")) {
			// 5.1 有炼钢、轧制工序,必需有铸造工序
			errMessage = "制程(" + proDuc.getMscPline() + ")有炼钢、轧制工序,必须维护铸造工序!";
			return errMessage;
		}
		// 5.2 轧制工序是连接轧制前后工序的桥梁
		if (!wholeBacklog.contains("D")
				&& (wholeBacklog.contains("A") || wholeBacklog.contains("B") || wholeBacklog
						.contains("C"))
				&& (wholeBacklog.contains("E") || wholeBacklog.contains("F")
						|| wholeBacklog.contains("G") || wholeBacklog
							.contains("H"))) {
			errMessage = "制程(" + proDuc.getMscPline()
					+ ")没有轧制工序,但有轧制前工序与后工序![有轧制前后工序,必须维护轧制工序]";
			return errMessage;
		}
		// 5.3 制程不能只有炼钢工序,或者只有铸造工序
		if (wholeBacklog.equals("A") || wholeBacklog.equals("B")) {
			errMessage = "制程(" + proDuc.getMscPline() + ")不能仅维护炼钢或者铸造工序!";
			return errMessage;
		}
		// 6 产品对制程的约束
		// 6.1 对接箍有要求的产品,必需有加工 工序
		if ((mscStyle.equals("B") || mscStyle.equals("C"))
				&& !wholeBacklog.contains("G")) {
			errMessage = "制程(" + proDuc.getMscPline()
					+ " )产品对接箍有要求,制程必须维护加工工序!";
			return errMessage;
		}
		if ((mscStyle.equals("A") || mscStyle.equals("E"))
				&& wholeBacklog.contains("H")) {
			errMessage = "制程(" + proDuc.getMscPline()
					+ " )产品对接箍没有要求,制程不能维护接箍加工工序!";
			return errMessage;
		}
		// 6.2 管坯产品的制程只有以下几种可能性：炼钢-铸造(连铸)、炼钢-铸造-锻造、锻造
		if (specStyle.equals("B")) {
			if (wholeBacklog.equals("A-B") || wholeBacklog.equals("A-B-C")
					|| wholeBacklog.equals("C")) {
				if (wholeBacklog.equals("A-B")) {
					MscProcessEntity process = operationDaoImp.getOperation(
							con, msc, proDuc.getMscPline(), "B");
					if (!process.getProcessCodeC().equals("B002")) {

						errMessage = "制程(" + proDuc.getMscPline()
								+ ")  管坯产品合理制程:炼钢->铸造(连铸)、炼钢->铸造->锻造、锻造!";
						return errMessage;
					}
				}
			} else {
				errMessage = "制程(" + proDuc.getMscPline()
						+ ")  管坯产品合理制程:炼钢->铸造(连铸)、炼钢->铸造->锻造、锻造!";
				return errMessage;
			}
		}
		// 6.3 钢管必须经过轧制工序或者轧制后工序
		else if (specStyle.equals("A")) {
			if (wholeBacklog.equals("A-B") || wholeBacklog.equals("A-B-C")
					|| wholeBacklog.equals("C")) {
				errMessage = "制程(" + proDuc.getMscPline()
						+ ")  钢管必须经过轧制工序或者轧制后工序!";
				return errMessage;
			}
		}
		// 、接箍、附件产品只经过接箍加工或者加工加序
		else if (specStyle.equals("C")) {
			if (wholeBacklog.contains("A") || wholeBacklog.contains("B")
					|| wholeBacklog.contains("C") || wholeBacklog.contains("D")
					|| wholeBacklog.contains("E") || wholeBacklog.contains("F")) {
				errMessage = "制程(" + proDuc.getMscPline()
						+ "  )接箍、附件产品只经过加工/加箍加工工序!";
				return errMessage;
			}
		}
		// 6.4 钢锭产品只经过炼钢、铸造(模铸)工序
		else {
			if (wholeBacklog.equals("A-B")) {
				MscProcessEntity process = operationDaoImp.getOperation(con,
						msc, proDuc.getMscPline(), "B");
				if (!process.getProcessCodeC().equals("B003")) {
					errMessage = "制程(" + proDuc.getMscPline()
							+ ")  钢锭产品只经过炼钢、铸造(模铸)工序!";
					return errMessage;
				}
			} else {
				errMessage = "制程(" + proDuc.getMscPline()
						+ " ) 钢锭产品只经过炼钢、铸造(模铸)工序!";
				return errMessage;
			}
		}
		// 制程经过铸造->轧制,铸造二级工序不能为模铸
		if (wholeBacklog.contains("B-D")) {
			MscProcessEntity process = operationDaoImp.getOperation(con, msc,
					proDuc.getMscPline(), "B");
			if (process.getProcessCodeC().equals("B003")) {
				errMessage = "制程(" + proDuc.getMscPline()
						+ ")  经过铸造->轧制工序,铸造二级工序不能为模铸!";
				return errMessage;
			}
		}
		// Assel 2015/07/05
		if (assel.equals("1") && !wholeBacklog.contains("D")) {
			errMessage = "制程(" + proDuc.getMscPline()
					+ ")必须维护轧制工序![合同对Assel有要求,制程必须维护轧制工序]";
			return errMessage;
		}
		// 专对外购管
//		if ((mscStyle.contains("A") || mscStyle.contains("B")) && (outsStlPileFl.equals("121902") || outsStlPileFl.equals("121903"))) {
//			if (wholeBacklog.contains("A") || wholeBacklog.contains("B")
//					|| wholeBacklog.contains("C")) {
//				errMessage = "制程(" + proDuc.getMscPline()
//						+ ")不能维护轧制之前的工序![合同是外购管]";
//				return errMessage;
//			}
//			if(!wholeBacklog.contains("D")){
//				errMessage = "制程(" + proDuc.getMscPline()
//				+ ")必须包含轧制工序[外购管合同制程必须含轧制工序]!";
//				return errMessage;
//			}
//		}
		if ((mscStyle.contains("A") || mscStyle.contains("B")) && (outsStlPileFl.equals("121902") || outsStlPileFl.equals("121903"))) {
			if (!wholeBacklog.contains("A")) {
				errMessage = "制程(" + proDuc.getMscPline()
						+ ")必须包含炼钢工序[外购管合同制程必须包含炼钢工序]!";
						return errMessage;
			}
			if(wholeBacklog.contains("B") || wholeBacklog.contains("C")){
				errMessage = "制程(" + proDuc.getMscPline()
						+ ")不能包含铸造或锻造工序[外购管合同制程不能包含铸造或锻造工序]!";
						return errMessage;
			}
			if(!wholeBacklog.contains("D")){
				errMessage = "制程(" + proDuc.getMscPline()
				+ ")必须包含轧制工序[外购管合同制程必须包含轧制工序]!";
				return errMessage;
			}
		}
		
		//镦拔扩
		String mscStyleDesc = "";
		if(mscStyle.equals("A") ) mscStyleDesc = "钢管（管坯）";
		else if(mscStyle.equals("B")) mscStyleDesc = "钢管+接箍";
		if(mscStyle.equals("A") || mscStyle.equals("B")){
			MscProcessEntity processInfo = operationDaoImp.getOperation(con,
					msc, proDuc.getMscPline(), "E");
			if(operationDaoImp.isExistEMeterialCode(modelCode, con)){
				if(processInfo == null || !processInfo.getProcessCodeC().equals("B008")){
					return "制程(" + proDuc.getMscPline() + ")必须维护镦粗二级工序! [冶金规范类型:" + mscStyleDesc +
							" 扣型:" + modelName + " 该扣型存在镦拔扩物料字母"
							+ "，制程必须维护镦粗二级工序]";
				}
			}else{
				if(processInfo != null && processInfo.getProcessCodeC().equals("B008")){
					return "制程(" + proDuc.getMscPline() + ")不能维护镦粗二级工序! [冶金规范类型:" + mscStyleDesc +
							" 扣型:" + modelName + " 该扣型不存在镦拔扩物料字母"
							+ "，制程不能维护镦粗二级工序]";
				}
			}
		}
		
		
		// 扣型分类对制程的约束:
		// 1.通用扣型( / ) 不约束
		// 2.扣型分类：热轧 制程不能包含加工 其它分类 制程必须包含加工
		// 3.扣型分类 :不车丝、倒棱 加工二级工序为 倒棱
		// 车丝(..) 加工二级工序为 车丝
		// 不车丝、不倒棱 加工二级工序为 不车丝、不倒棱
		// 查询加工二级工序
		MscProcessEntity processG = operationDaoImp.getOperation(
				con, msc, proDuc.getMscPline(), "G");
		if(processG != null){
			boolean processCIsValid = operationDaoImp.BaseProcessCIsValid(con, processG.getProcessCodeC());
			if(!processCIsValid){
				return "制程(" + proDuc.getMscPline() + ")加工工序的二级工序无效，请重新选择二级工序！";
			}
		}
		
		// !(mscStyle.equals("C") || mscStyle.equals("D"))
		if (!mscStyle.equals("D")) {
			String[] modelStyles = proDucDaoImp.getModelStyle(con, modelCode);
			String modelStyle = modelStyles[0];
			String modelStyleDesc = modelStyles[1];
			if (!modelStyle.equals("")) {
//				if (!wholeBacklog.contains("G")) {
//					return  "制程(" + proDuc.getMscPline() + ")" + "[非接箍类型产品的制程必须包含加工工序！]";
//				}
//				if (modelStyle.equals("405106") && wholeBacklog.contains("G")) {
//					return "制程(" + proDuc.getMscPline() + ")不能维护加工工序![扣型("
//							+ modelName + ")的类型为" + modelStyleDesc
//							+ ",制程不能维护加工工序]";
//				}
//				if (modelStyle.equals("405106")
//						&& !processG.getProcessCodeC().equals("B022")) {
//					String processDescC = proDucDaoImp.getProcessDescC(con, "B022");
//					return "制程(" + proDuc.getMscPline() + ")加工工序的二级工序为"
//							+ processG.getProcessDescC() + "![合同扣型("
//							+ modelName + ")的类型为" + modelStyleDesc
//							+ ",制程加工二级必须为" + processDescC
//							+ "]";
//				}
				if(!modelStyle.equals("405106") && !wholeBacklog.contains("G")){
					return "制程(" + proDuc.getMscPline() + ")[合同扣型("
							+ modelName + ")的类型为" + modelStyleDesc
							+ ",制程必须包含加工工序]";
				}
				// 如果扣型分类:不车丝、倒棱 ,加工二级工序必为倒棱
				if (modelStyle.equals("405101")
						&& !processG.getProcessCodeC().equals("B021")) {
					String processDescC = proDucDaoImp.getProcessDescC(con, "B021");
					return "制程(" + proDuc.getMscPline() + ")加工工序的二级工序不能维护成"
							+ processG.getProcessDescC() + "![ 扣型("
							+ modelName + ")的类型为" + modelStyleDesc
							+ ",加工二级工序必须为"+ processDescC +"]";
				}
				// 如果扣型分类:车丝,加工二级工序必为车丝
				if ((modelStyle.equals("405102")
						|| modelStyle.equals("405104") || modelStyle
							.equals("405105"))
						&& !processG.getProcessCodeC().equals("B020")){
					String processDescC = proDucDaoImp.getProcessDescC(con, "B020");
					return "制程(" + proDuc.getMscPline() + ")加工工序的二级工序不能维护成"
							+ processG.getProcessDescC() + "![ 扣型("
							+ modelName + ")的类型为" + modelStyleDesc
							+ ",加工二级工序必须为"+ processDescC +"]";
				}
				// 如果扣型分类：不车丝、不倒棱，加工二级工序 不车丝、不倒棱
				if (modelStyle.equals("405107")
						&& !processG.getProcessCodeC().equals("B027")) {
					String processDescC = proDucDaoImp.getProcessDescC(con, "B027");
					return "制程(" + proDuc.getMscPline() + ")加工工序的二级工序不能维护成"
							+ processG.getProcessDescC() + "![ 扣型("
							+ modelName + ")的类型为" + modelStyleDesc
							+ ",加工二级工序必须为"+ processDescC +"]";
				}
			}
		}
		
		// 冶金规范码类型对制程的约束
		if (mscStyle.equals("B") && !wholeBacklog.contains("G")) {
			return "制程(" + proDuc.getMscPline()
					+ ")缺少加工工序![冶金规范码类型是钢管+接箍 类型,制程必须包含加工工序]";
		}
		return "";
	}

	public static DesignStatusEntity checkProDucInfos(
			List<ProDucEntity> proInfos, DesignEntity design) {
		DesignStatusEntity status = new DesignStatusEntity();
		if (proInfos.size() == 1) {
			ProDucEntity proInfo = proInfos.get(0);
			status = statusDaoImp.setDesignStatus(design, proInfo.getMsc(),
					proInfo.getListItem(), proInfo.getDesignSts(),
					proInfo.getDesignStsRs(), proInfo.getDesignStsDesc(),
					proInfo.getMscPline(), proInfo.getUnitCode(),
					proInfo.getUnitDesc());
			return status;
		} else {
			List<String> listItems = new ArrayList<String>();
			String message = "";
			for (ProDucEntity proInfo : proInfos) {
				listItems.add(proInfo.getListItem());
				message += "{" + proInfo.getDesignStsDesc() + "}";
			}
			if (listItems.contains("制程")) {
				status = statusDaoImp.setDesignStatus(design,
						design.getOrderLineMsc(), "制程", "F", "91", message, "",
						design.getMscDunitCode(), design.getMscDunitDesc());
				return status;
			} else {
				ProDucEntity proInfo = proInfos.get(proInfos.size() - 1);
				status = statusDaoImp.setDesignStatus(design, proInfo.getMsc(),
						proInfo.getListItem(), proInfo.getDesignSts(),
						proInfo.getDesignStsRs(), proInfo.getDesignStsDesc(),
						proInfo.getMscPline(), proInfo.getUnitCode(),
						proInfo.getUnitDesc());
				return status;
			}
		}
	}

	/**
	 * 验证制程与探伤检验项的完整性
	 * 
	 * @throws SQLException
	 */
	public static String checkDeteAndProDuc(Connection con, String designKey,
			List<DesignMscPlStiEntity> stationList, String mscPline)
			throws SQLException {
		String message = "";
		List<SlmOrdDesignStdDicEntity> dicEntitys = proDucDaoImp.getDeteInfo(
				con, designKey);
		if (dicEntitys == null) {
			return "";
		}
		List<String> stationCodes = new ArrayList<String>();
		for (DesignMscPlStiEntity station : stationList) {
			stationCodes.add(station.getStationCode());
		}
		MscDeteDaoImp deteDaoImp = FactoryDao.getDeteDaoImp();
		// 分两部分处理
		HashMap<String, List<ComBasePhyRStationEntity>> map = new HashMap<String, List<ComBasePhyRStationEntity>>();
		for (SlmOrdDesignStdDicEntity dicEntity : dicEntitys) {
			// 查询检验项的对应工序点
			List<ComBasePhyRStationEntity> stationEntitys = deteDaoImp
					.getStationByPhyCode(con, dicEntity.getPhyCode());
			if (stationEntitys == null || stationEntitys.size() == 0) {
				return "制程(" + mscPline + ")" + "探伤标准(" + dicEntity.getDic()
						+ ")检验项(" + dicEntity.getPhyName()
						+ ")是无损检验项,需要维护检验项的工序点";
			}
			// 如果检验项没有分组序号,直接验证
			if (dicEntity.getGroupSeq().equals("")) {
				if (!ProDuc.checkStation(stationCodes, stationEntitys)) {
					String stations = "";
					for (ComBasePhyRStationEntity entity : stationEntitys) {
						stations += entity.getStationDesc() + " ";
					}
					return "制程(" + mscPline + ")/探伤标准(" + dicEntity.getDic()
							+ ")/检验项(" + dicEntity.getPhyName() + ")存在工序点("
							+ stations + "),制程工序点必须维护检验项对应一个或者多个工序点!";
				}
			} else {
				if (map.containsKey(dicEntity.getGroupSeq())) {
					List<ComBasePhyRStationEntity> groupList = map
							.get(dicEntity.getGroupSeq());
					for (ComBasePhyRStationEntity entity : stationEntitys) {
						groupList.add(entity);
					}
					map.put(dicEntity.getGroupSeq(), groupList);
				} else {
					map.put(dicEntity.getGroupSeq(), stationEntitys);
				}
			}
		}
		// 遍历(有分组序号的探伤标准,多条探伤标准的工序点取一个)
		Iterator<?> iter = map.entrySet().iterator();
		while (iter.hasNext()) {
			@SuppressWarnings("rawtypes")
			Entry entry = (Entry) iter.next();
			@SuppressWarnings("unchecked")
			List<ComBasePhyRStationEntity> list = (List<ComBasePhyRStationEntity>) entry
					.getValue();
			if (!ProDuc.checkStation(stationCodes, list)) {
				String stations = "";
				for (ComBasePhyRStationEntity entity : list) {
					stations += entity.getStationDesc() + " ";
				}
				return "制程(" + mscPline + ")" + "探伤标准 分组序号("
						+ String.valueOf(entry.getKey()) + ")存在工序点(" + stations
						+ "),制程工序点必须包含检验项中一项或者多项工序点";
			}
		}
		return message;
	}

	/**
	 * 验证制程工序点与检验项工序点
	 * 
	 * @param stations
	 * @param stationEntitys
	 * @return
	 */
	public static boolean checkStation(List<String> stations,
			List<ComBasePhyRStationEntity> stationEntitys) {
		boolean flag = false;
		for (ComBasePhyRStationEntity comBasePhyRStationEntity : stationEntitys) {
			if (stations.contains(comBasePhyRStationEntity.getStationCode())) {
				flag = true;
				break;
			}
		}
		return flag;
	}
}
