package com.steering.pss.sale.order.craftDesign.server;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

import com.steering.pss.sale.order.craftDesign.dao.MscSpecDao;
import com.steering.pss.sale.order.craftDesign.model.ComBaseSpecEntity;
import com.steering.pss.sale.order.craftDesign.model.CraftEntity;
import com.steering.pss.sale.order.craftDesign.model.CraftOrdDesignStdSicEntity;
import com.steering.pss.sale.order.craftDesign.model.StdEntity;
import com.steering.pss.sale.order.craftDesign.tool.CraftTool;
import com.steering.pss.sale.order.qualityDesign.Dao.idao.IMscSpecDao;
import com.steering.pss.sale.order.qualityDesign.model.ComBaseProductEntity;

/**
 * 公差标准
 * 
 * @author Administrator
 * 
 */
public class MscSpec {

	/**
	 * 查询公差索引号
	 * 
	 * @param con
	 * @param msc
	 * @param modelCode
	 * @param mscValig
	 * @return
	 * @throws SQLException
	 */
	public List<String> getSicByMscAndModel(Connection con, String msc,
			String modelCode, String mscValig) throws SQLException {
		MscSpecDao specDaoImp = new MscSpecDao();
		List<String> sics = null;
		if (mscValig.equals("C")) {
			sics = specDaoImp.getExamineSic(con, msc, modelCode);
		} else {
			sics = specDaoImp.getvalidSic(con, msc, modelCode);
		}
		return sics;
	}

	/**
	 * 验证公差标准
	 * 
	 * @param con
	 *            连接字符串
	 * @param design
	 *            质量设计类
	 * @return boolean
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	public StdEntity checkSpec(Connection con, CraftEntity design, String flag,
			List<String> sics, String process, ComBaseSpecEntity baseSpec) throws Exception {
		String message = "";
		StdEntity stdEntity = new StdEntity();
		MscSpecDao specDaoImp = new MscSpecDao();
		for (String sic : sics) {
			List<CraftOrdDesignStdSicEntity> specs = specDaoImp.getSpecBySic(
					con, sic);
			if (specs == null) {
				message = "公差索引号(" + sic + ")不存在公差标准";
				continue;
			}
			// 过滤公差标准
			List<CraftOrdDesignStdSicEntity> specAs = null;
			if (design.getSpecStyle().equals("A")) {
				// 钢管
				// 径壁比
				String dh = String.valueOf(Double.parseDouble(baseSpec.getDimater())
						/ Double.parseDouble(baseSpec.getHeight()));
				// 壁径比
				String hd = String.valueOf(Double.parseDouble(baseSpec.getHeight())
						/ Double.parseDouble(baseSpec.getDimater()));
				// 内径
				String in = String.valueOf(Double.parseDouble(baseSpec.getDimater()) - 2
						* Double.parseDouble(baseSpec.getHeight()));
				specAs = MscSpec.fiterSpecA(specs, baseSpec.getDimater(), baseSpec.getHeight(), dh, hd, in,
						design.getLengthMax(), design.getLengthMin());
			} else if (design.getSpecStyle().equals("B")) {
				// 管坯
				specAs = MscSpec.fiterSpecB(specs, baseSpec.getDimater());
			} else {
				//其他
				specAs = MscSpec.fiterSpecD(specs, baseSpec.getDimater());
			}
			Object[] info = MscSpec.fiterSpec(specAs, specs, baseSpec.getDimater(), baseSpec.getHeight(),
					design.getSpecName(), design.getSpecStyle(), flag,
					process, design.getProducCode(), con);
			message = (String) info[1];
			specAs = (ArrayList<CraftOrdDesignStdSicEntity>) info[0];
			if (message.length() > 0) {
				message = "公差索引号:" + sic + "," + message;
				continue;
			}
			// 保存公差标准
			for (CraftOrdDesignStdSicEntity spec : specAs) {
				spec.setMscPline("Y");
				spec.setProcessCode("Y");
				// 是否特殊要求(0否;1是)
				spec.setSpeclFl(flag);
				spec.setDesginKey(design.getDesignKey());
				if (flag.equals("1")) {
					spec.setUseCode(design.getUseCode());
					spec.setUseDesc(design.getUseDesc());
				}
			}
			stdEntity.setFlag(true);
			message = "公差标准通过验证!";
			stdEntity.setObjM(specAs);
			stdEntity.setObjKey(sic);
			return stdEntity;
		}
		stdEntity.setFlag(false);
		stdEntity.setMessage(message);
		return stdEntity;
	}

	/**
	 * 过滤公差标准(钢管)
	 * 
	 * @param specs
	 *            公差标准集合
	 * @param dimater
	 *            外径
	 * @param height
	 *            壁厚
	 * @return List<DesignStdSicEntity>
	 * @throws Exception
	 */
	public static List<CraftOrdDesignStdSicEntity> fiterSpecA(
			List<CraftOrdDesignStdSicEntity> specs, String dimater,
			String height, String DHProportion, String HDProportion,
			String innerProportion, String lengthMax, String lengthMin)
			throws Exception {
		if (specs == null || specs.size() == 0) {
			return null;
		}
		List<CraftOrdDesignStdSicEntity> specAs = new ArrayList<CraftOrdDesignStdSicEntity>();
		for (int i = 0; i < specs.size(); i++) {
			CraftOrdDesignStdSicEntity spec = specs.get(i);
			if (spec.getBiasCodeZ().equals("")
					&& spec.getBiasCodeC().equals("")
					&& spec.getBiasCodeS().equals("")) {
				specAs.add(spec);
				continue;
			}
			// 针对公式约束项进行处理
			// 约束1下限值
			String zmin = spec.getZmin();
			if (!zmin.equals("")
					&& (zmin.contains("t") || zmin.contains("D") || zmin
							.contains("L"))) {
				zmin = zmin.replace("t", height);
				zmin = zmin.replace("D", dimater);
				zmin = zmin.replace("t", lengthMin);
				double zminValue = CraftTool.countFormula(zmin);
				spec.setZmin(String.valueOf(zminValue));
			}
			// 约束1上限值
			String zmax = spec.getZmax();
			if (!zmax.equals("")
					&& (zmax.contains("t") || zmax.contains("D") || zmax
							.contains("L"))) {
				zmax = zmax.replace("t", height);
				zmax = zmax.replace("D", dimater);
				zmax = zmax.replace("t", lengthMin);
				double zmaxValue = CraftTool.countFormula(zmax);
				spec.setZmax(String.valueOf(zmaxValue));
			}
			// 约束2下限值
			String smin = spec.getSmin();
			if (!smin.equals("")
					&& (smin.contains("t") || smin.contains("D") || smin
							.contains("L"))) {
				smin = smin.replace("t", height);
				smin = smin.replace("D", dimater);
				smin = smin.replace("t", lengthMin);
				double sminValue = CraftTool.countFormula(smin);
				spec.setSmin(String.valueOf(sminValue));
			}
			// 约束2上限值
			String smax = spec.getSmax();
			if (!smax.equals("")
					&& (smax.contains("t") || smax.contains("D") || smax
							.contains("L"))) {
				smax = smax.replace("t", height);
				smax = smax.replace("D", dimater);
				smax = smax.replace("t", lengthMin);
				double smaxValue = CraftTool.countFormula(smax);
				spec.setSmax(String.valueOf(smaxValue));
			}
			// 约束3下限值
			String cmin = spec.getCmin();
			if (!cmin.equals("")
					&& (cmin.contains("t") || cmin.contains("D") || cmin
							.contains("L"))) {
				cmin = cmin.replace("t", height);
				cmin = cmin.replace("D", dimater);
				cmin = cmin.replace("t", lengthMin);
				double cminValue = CraftTool.countFormula(cmin);
				spec.setCmin(String.valueOf(cminValue));
			}
			// 约束3上限值
			String cmax = spec.getCmax();
			if (!cmax.equals("")
					&& (cmax.contains("t") || cmax.contains("D") || cmax
							.contains("L"))) {
				cmax = cmax.replace("t", height);
				cmax = cmax.replace("D", dimater);
				cmax = cmax.replace("t", lengthMin);
				double cmaxValue = CraftTool.countFormula(cmax);
				spec.setCmax(String.valueOf(cmaxValue));
			}
			// 外径 :400301 壁厚:400302 径壁比:400303 壁径比 400304 内径 400305 长度 400306
			if (spec.getBiasCodeZ().equals("400301")) {
				if (!(CraftTool.checkStr(dimater, spec.getZminSign(),
						spec.getZmin()))
						|| (!CraftTool.checkStr(dimater, spec.getZmaxSign(),
								spec.getZmax()))) {
					continue;
				}
			}
			if (spec.getBiasCodeZ().equals("400302")) {
				if (!(CraftTool.checkStr(height, spec.getZminSign(),
						spec.getZmin()))
						|| (!CraftTool.checkStr(height, spec.getZmaxSign(),
								spec.getZmax()))) {
					continue;
				}
			}
			if (spec.getBiasCodeZ().equals("400303")) {
				if (!(CraftTool.checkStr(DHProportion, spec.getZminSign(),
						spec.getZmin()))
						|| (!CraftTool.checkStr(DHProportion,
								spec.getZmaxSign(), spec.getZmax()))) {
					continue;
				}
			}
			if (spec.getBiasCodeZ().equals("400304")) {
				if (!(CraftTool.checkStr(HDProportion, spec.getZminSign(),
						spec.getZmin()))
						|| (!CraftTool.checkStr(HDProportion,
								spec.getZmaxSign(), spec.getZmax()))) {
					continue;
				}
			}
			if (spec.getBiasCodeZ().equals("400305")) {
				if (!(CraftTool.checkStr(innerProportion, spec.getZminSign(),
						spec.getZmin()))
						|| (!CraftTool.checkStr(innerProportion,
								spec.getZmaxSign(), spec.getZmax()))) {
					continue;
				}
			}
			if (spec.getBiasCodeZ().equals("400306")) {
				if (!(CraftTool.checkStr(lengthMax, spec.getZminSign(),
						spec.getZmin()))
						|| (!CraftTool.checkStr(lengthMax, spec.getZmaxSign(),
								spec.getZmax()))) {
					continue;
				}
			}
			if (spec.getBiasCodeZ().equals("400306")) {
				if (!(CraftTool.checkStr(lengthMin, spec.getZminSign(),
						spec.getZmin()))
						|| (!CraftTool.checkStr(lengthMin, spec.getZmaxSign(),
								spec.getZmax()))) {
					continue;
				}
			}
			if (spec.getBiasCodeC().equals("400301")) {
				if (!(CraftTool.checkStr(dimater, spec.getCminSign(),
						spec.getCmin()))
						|| (!CraftTool.checkStr(dimater, spec.getCmaxSign(),
								spec.getCmax()))) {
					continue;
				}
			}
			if (spec.getBiasCodeC().equals("400302")) {
				if (!(CraftTool.checkStr(height, spec.getCminSign(),
						spec.getCmin()))
						|| (!CraftTool.checkStr(height, spec.getCmaxSign(),
								spec.getCmax()))) {
					continue;
				}
			}
			if (spec.getBiasCodeC().equals("400303")) {
				if (!(CraftTool.checkStr(DHProportion, spec.getCminSign(),
						spec.getCmin()))
						|| (!CraftTool.checkStr(DHProportion,
								spec.getCmaxSign(), spec.getCmax()))) {
					continue;
				}
			}
			if (spec.getBiasCodeC().equals("400304")) {
				if (!(CraftTool.checkStr(HDProportion, spec.getCminSign(),
						spec.getCmin()))
						|| (!CraftTool.checkStr(HDProportion,
								spec.getCmaxSign(), spec.getCmax()))) {
					continue;
				}
			}
			if (spec.getBiasCodeC().equals("400305")) {
				if (!(CraftTool.checkStr(innerProportion, spec.getCminSign(),
						spec.getCmin()))
						|| (!CraftTool.checkStr(innerProportion,
								spec.getCmaxSign(), spec.getCmax()))) {
					continue;
				}
			}
			if (spec.getBiasCodeC().equals("400306")) {
				if (!(CraftTool.checkStr(lengthMax, spec.getCminSign(),
						spec.getCmin()))
						|| (!CraftTool.checkStr(lengthMax, spec.getCmaxSign(),
								spec.getCmax()))) {
					continue;
				}
			}
			if (spec.getBiasCodeC().equals("400306")) {
				if (!(CraftTool.checkStr(lengthMin, spec.getCminSign(),
						spec.getCmin()))
						|| (!CraftTool.checkStr(lengthMin, spec.getCmaxSign(),
								spec.getCmax()))) {
					continue;
				}
			}
			if (spec.getBiasCodeS().equals("400301")) {
				if (!(CraftTool.checkStr(dimater, spec.getSminSign(),
						spec.getSmin()))
						|| (!CraftTool.checkStr(dimater, spec.getSmaxSign(),
								spec.getSmax()))) {
					continue;
				}
			}
			if (spec.getBiasCodeS().equals("400302")) {
				if (!(CraftTool.checkStr(height, spec.getSminSign(),
						spec.getSmin()))
						|| (!CraftTool.checkStr(height, spec.getSmaxSign(),
								spec.getSmax()))) {
					continue;
				}
			}
			if (spec.getBiasCodeS().equals("400303")) {
				if (!(CraftTool.checkStr(DHProportion, spec.getSminSign(),
						spec.getSmin()))
						|| (!CraftTool.checkStr(DHProportion,
								spec.getSmaxSign(), spec.getSmax()))) {
					continue;
				}
			}
			if (spec.getBiasCodeS().equals("400304")) {
				if (!(CraftTool.checkStr(HDProportion, spec.getSminSign(),
						spec.getSmin()))
						|| (!CraftTool.checkStr(HDProportion,
								spec.getSmaxSign(), spec.getSmax()))) {
					continue;
				}
			}
			if (spec.getBiasCodeS().equals("400305")) {
				if (!(CraftTool.checkStr(innerProportion, spec.getSminSign(),
						spec.getSmin()))
						|| (!CraftTool.checkStr(innerProportion,
								spec.getSmaxSign(), spec.getSmax()))) {
					continue;
				}
			}
			if (spec.getBiasCodeS().equals("400306")) {
				if (!(CraftTool.checkStr(lengthMax, spec.getSminSign(),
						spec.getSmin()))
						|| (!CraftTool.checkStr(lengthMax, spec.getSmaxSign(),
								spec.getSmax()))) {
					continue;
				}
			}
			if (spec.getBiasCodeS().equals("400306")) {
				if (!(CraftTool.checkStr(lengthMin, spec.getSminSign(),
						spec.getSmin()))
						|| (!CraftTool.checkStr(lengthMin, spec.getSmaxSign(),
								spec.getSmax()))) {
					continue;
				}
			}
			specAs.add(spec);
		}
		return specAs;
	}

	/**
	 * 过滤公差标准 (管坯)
	 * 
	 * @param specs
	 * @param dimater
	 * @return
	 */
	public static List<CraftOrdDesignStdSicEntity> fiterSpecB(
			List<CraftOrdDesignStdSicEntity> specs, String dimater) {
		List<CraftOrdDesignStdSicEntity> specAs = new ArrayList<CraftOrdDesignStdSicEntity>();
		for (int i = 0; i < specs.size(); i++) {
			CraftOrdDesignStdSicEntity spec = specs.get(i);
			if (spec.getBiasCodeZ().equals("")
					&& spec.getBiasCodeC().equals("")
					&& spec.getBiasCodeS().equals("")) {
				specAs.add(spec);
				continue;
			}
			// 外径 :400301 壁厚:400302 径壁比:400303 壁径比 400304 内径 400305 长度 400306
			if (spec.getBiasCodeZ().equals("400301")) {
				if (!(CraftTool.checkStr(dimater, spec.getZminSign(),
						spec.getZmin()))
						|| (!CraftTool.checkStr(dimater, spec.getZmaxSign(),
								spec.getZmax()))) {
					continue;
				}
			}
			if (spec.getBiasCodeC().equals("400301")) {
				if (!(CraftTool.checkStr(dimater, spec.getCminSign(),
						spec.getCmin()))
						|| (!CraftTool.checkStr(dimater, spec.getCmaxSign(),
								spec.getCmax()))) {
					continue;
				}
			}
			if (spec.getBiasCodeS().equals("400301")) {
				if (!(CraftTool.checkStr(dimater, spec.getSminSign(),
						spec.getSmin()))
						|| (!CraftTool.checkStr(dimater, spec.getSmaxSign(),
								spec.getSmax()))) {
					continue;
				}
			}
			specAs.add(spec);
		}
		return specAs;
	}

	/**
	 * 过滤公差标准 (其他)
	 *
	 * @param specs
	 * @param dimater
	 * @return
	 */
	public static List<CraftOrdDesignStdSicEntity> fiterSpecD(
			List<CraftOrdDesignStdSicEntity> specs, String dimater) {
		List<CraftOrdDesignStdSicEntity> specAs = new ArrayList<CraftOrdDesignStdSicEntity>();
		for (int i = 0; i < specs.size(); i++) {
			CraftOrdDesignStdSicEntity spec = specs.get(i);
			if(!spec.getZminSign().equals("") || !spec.getZmaxSign().equals("")
			  || !spec.getSminSign().equals("") || !spec.getCmaxSign().equals("")
			  || !spec.getSminSign().equals("") || !spec.getSmaxSign().equals("")){
				continue;
			}
			specAs.add(spec);
		}
		return specAs;
	}

	/**
	 * 验证公差标准
	 * 
	 * @param specs
	 * @param specAlls
	 * @param dimater
	 * @param height
	 * @param specName
	 * @param specStyle
	 * @return
	 * @throws SQLException 
	 */
	public static Object[] fiterSpec(List<CraftOrdDesignStdSicEntity> specs,
			List<CraftOrdDesignStdSicEntity> specAlls, String dimater,
			String height, String specName, String specStyle, String flag,
			String process, String productCode, Connection con) throws SQLException {
		Object[] arr = new Object[2];
		if (specs == null || specs.size() == 0 || specAlls == null
				|| specAlls.size() == 0) {
			arr[0] = null;
			if (specStyle.equals("A") || specStyle.equals("B")) {
				arr[1] = "满足外径(" + dimater + ")、壁厚(" + height + ")等约束公差标准不存在";
			} else {
				arr[1] = "满足规格(" + specName + ")约束公差标准不存在";
			}
			return arr;
		}
		List<CraftOrdDesignStdSicEntity> specYs = new ArrayList<CraftOrdDesignStdSicEntity>();
		List<String> specYKeys = new ArrayList<String>();
		List<CraftOrdDesignStdSicEntity> specNs = new ArrayList<CraftOrdDesignStdSicEntity>();
		List<String> specNKeys = new ArrayList<String>();
		for (CraftOrdDesignStdSicEntity spec : specs) {
			String keyCode = spec.getBiasCode();
			String keyName = spec.getBiasName();
			if (spec.getBiasCodeZ().equals("")
					&& spec.getBiasCodeC().equals("")
					|| spec.getBiasCodeS().equals("")) {
				if (specNKeys.contains(keyCode)) {
					arr[0] = null;
					arr[1] = "公差项(" + keyName + ")存在多条公差标准,并且不存在公差约束项!";
				}
				specNKeys.add(keyCode);
				specNs.add(spec);
			} else {
				if (specYKeys.contains(keyCode)) {
					arr[0] = null;
					arr[1] = "公差项(" + keyName + ")存在多条满足外径(" + dimater
							+ ")、壁厚(" + height + ")公差标准!";
					return arr;
				}
				specYKeys.add(keyCode);
				specYs.add(spec);
			}
		}
		for (int i = 0; i < specNs.size(); i++) {
			CraftOrdDesignStdSicEntity spec = specNs.get(i);
			String keyCode = spec.getBiasCode();
			if (!specYKeys.contains(keyCode)) {
				specYKeys.add(keyCode);
				specYs.add(spec);
			}
		}
		
		//内控公差必须包含:管体壁厚+（外径或者管体外径）
		ComBaseProductEntity product = new IMscSpecDao().getProduct(con, productCode);
		boolean productTypeA = product.getProducType().equals("A") && (product.getProducHead().equals("404901")
				|| product.getProducHead().equals("404902") || product.getProducHead().equals("404903"));
		boolean productTypeB = product.getProducType().equals("B");
		
		if(flag.equals("2") && (process.equals("D") || process.equals("E"))
				&& (productTypeA || productTypeB)){
			if (!specYKeys.contains("404001") && !specYKeys.contains("404012")) {
				arr[0] = null;
				arr[1] = "公差标准满足外径(" + dimater + "),壁厚(" + height
						+ ")的公差项没有外径(或管体外径)项,公差项目必须维护外径(或管体外径)公差项!";
				return arr;
			}
			if (!specYKeys.contains("404019")) {
				arr[0] = null;
				arr[1] = "公差标准满足外径(" + dimater + "),壁厚(" + height
						+ ")的公差项没有管体壁厚项,公差项目必须维护管体壁厚公差项!";
				return arr;
			}
		}
		
		// 公差项必须维护壁厚
		if (flag.equals("0") && (productTypeA || productTypeB)) {
			if (!specYKeys.contains("404019")) {
				arr[0] = null;
				arr[1] = "公差标准满足外径(" + dimater + "),壁厚(" + height
						+ ")的公差项没有管体壁厚项,公差项目必须维护管体壁厚公差项!";
				return arr;
			}
		}
//		List<String> keyCodes = MscSpec.getSpecSize(specYs);
//		List<String> keyAllCodes = MscSpec.getSpecSize(specAlls);
//		if (keyCodes.size() != keyAllCodes.size()) {
//			for (int i = 0; i < keyAllCodes.size(); i++) {
//				String keyCode = keyAllCodes.get(i);
//				if (!keyCodes.contains(keyCode)) {
//					arr[0] = null;
//					arr[1] = "公差维护项目:" + keyAllCodes.size() + "项,但满足外径("
//							+ dimater + ")、壁厚(" + height + ") "
//							+ keyCodes.size() + "项,公差项("
//							+ keyCode.substring(keyCode.indexOf("&") + 1)
//							+ ")不满足约束!";
//					return arr;
//				}
//			}
//		} else {
//			for (int i = 0; i < keyCodes.size(); i++) {
//				if (!keyCodes.get(i).equals(keyAllCodes.get(i))) {
//					arr[0] = null;
//					arr[1] = "公差维护项目:"
//							+ keyAllCodes.size()
//							+ "项,但满足外径("
//							+ dimater
//							+ ")、壁厚("
//							+ height
//							+ ")"
//							+ keyCodes.size()
//							+ "项,公差项("
//							+ keyCodes.get(i).substring(
//									keyCodes.get(i).indexOf("&") + 1)
//							+ ")不满足约束!";
//					return arr;
//				}
//			}
//		}
		arr[0] = specYs;
		arr[1] = "";
		return arr;
	}

	/**
	 * 公差标准维护项目
	 * 
	 * @param specs
	 * @return
	 */
	public static List<String> getSpecSize(
			List<CraftOrdDesignStdSicEntity> specs) {
		if (specs == null || specs.size() == 0) {
			return null;
		}
		List<String> keys = new ArrayList<String>();
		for (CraftOrdDesignStdSicEntity spec : specs) {
			String key = spec.getBiasCode() + "&" + spec.getBiasName();
			if (!keys.contains(key)) {
				keys.add(key);
			}
		}
		// 升序排序
		Collections.sort(keys);
		return keys;
	}

	/**
	 * 分组
	 * 
	 * @param specs
	 */
	static HashMap<String, List<CraftOrdDesignStdSicEntity>> groupSpec(
			List<CraftOrdDesignStdSicEntity> specs) {
		HashMap<String, List<CraftOrdDesignStdSicEntity>> map = new HashMap<String, List<CraftOrdDesignStdSicEntity>>();
		for (CraftOrdDesignStdSicEntity spec : specs) {
			// 不是分组序号里的公差标准
			if (spec.getGroupSeq().equals("")) {
				if (!map.containsKey(spec.getBiasCode())) {
					List<CraftOrdDesignStdSicEntity> groupList = new ArrayList<CraftOrdDesignStdSicEntity>();
					groupList.add(spec);
					map.put(spec.getBiasCode(), groupList);
				} else {
					List<CraftOrdDesignStdSicEntity> groupList = map.get(spec
							.getBiasCode());
					groupList.add(spec);
					map.put(spec.getBiasCode(), groupList);
				}
			} else {
				// 分组序号的公差标准
				if (!map.containsKey(spec.getGroupSeq())) {
					List<CraftOrdDesignStdSicEntity> groupList = new ArrayList<CraftOrdDesignStdSicEntity>();
					groupList.add(spec);
					map.put(spec.getGroupSeq(), groupList);
				} else {
					List<CraftOrdDesignStdSicEntity> groupList = map.get(spec
							.getGroupSeq());
					groupList.add(spec);
					map.put(spec.getGroupSeq(), groupList);
				}
			}
		}
		return map;
	}
}
