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

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

import com.steering.comm.db.DBCommon;
import com.steering.pss.sale.order.bomGeneration.BOMGeneration;
import com.steering.pss.sale.order.model.*;
import com.steering.pss.sale.order.qualityDesign.Dao.factory.FactoryDao;
import com.steering.pss.sale.order.qualityDesign.Dao.idao.IMscSplineDao;
import com.steering.pss.sale.order.qualityDesign.Dao.imp.*;
import com.steering.pss.sale.order.qualityDesign.ReturnsModel.DesignEntity;
import com.steering.pss.sale.order.qualityDesign.ReturnsModel.ProLineEntity;
import com.steering.pss.sale.order.qualityDesign.ReturnsModel.SpecEntity;
import com.steering.pss.sale.order.qualityDesign.server.factory.FactoryServer;
import com.steering.pss.sale.order.qualityDesign.server.imp.*;
import com.steering.pss.sale.order.qualityDesign.server.iserver.ServerDesignTool;

import CoreFS.SA06.CoreReturnObject;
import CoreFS.SC01.CoreConstantData;

public class QualityDesignBL extends DBCommon {
	/**
	 * 备料
	 * 
	 * @param msc
	 * @param userName
	 * @return
	 */
	public CoreReturnObject qualityDesignBL(String blCode, String userName) {
		CoreReturnObject core = new CoreReturnObject();
		core.setResult(false);
		/**
		 * 如果传入的备料为空，停止质量设计
		 */
		if (blCode.length() == 0) {
			core.setV_errMsg("备料码为空,请确认数据完整性");
			return core;
		}

		/**
		 * 获取数据库连接
		 */
		Connection con = null;

		try {
			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			con.setAutoCommit(false);
			/**
			 * 通过备料码查询备料主信息
			 */
			BLQualityPreImp preImp = FactoryServer.getBLQualityPreImp();
			ComMscBlEntity blEntity = preImp.getMscBlEntity(con, blCode);
			/**
			 * 验证备料主记录信息,则停止质量设计
			 */
			String errMessage = preImp.checkMscBlEntity(con, blEntity);
			if (errMessage.length() > 0) {
				core.setV_errMsg(errMessage);
				con.commit();
				return core;
			}

			/**
			 * 一、预处理 （新增技术评审主记录,返回质量主键designKey）
			 */
			String designKey = preImp.initBLCode(con, blEntity, userName);
			// 如果 designKey 为空则停止质量设计
			if (designKey.length() == 0) {
				core.setV_errMsg("技术评审预处理失败");
				con.commit();
				return core;
			}

			/**
			 * 二、初始状态
			 */
			BLQualityPreDaoImp blpreimp = FactoryDao.getBLQualityPreDaoImp();
			ComPscEntity pscEntity = blpreimp.getPsc(con, blEntity);
			StatusImp statusImp = FactoryServer.getStatusImp();
			statusImp.initialStatusBL(con, designKey, blCode,
					pscEntity.getPsc(), "", userName);
			StatusDaoImp statusDaoImp = FactoryDao.getStatusDaoImp();

			/**
			 * 三 、验证基础冶金规范码（如果含有客户特殊要求,则要求冶金规范码状态为审核状态）
			 */
			DesignEntity design = preImp.checkMsc(con, designKey, blEntity);
			if (design == null) {
				statusDaoImp.updateDesignStsTklg(con, designKey, userName, "F",
						"W");
				con.commit();
				return core;
			}

			/**
			 * 四、根据冶金规范码类型 是否验证交付标准( C:短节+附件 D:接箍 没有交付标准）
			 */
			String errMessageC = "";
			String errMessageP = "";
			String errMessageS = "";
			String errMessageD = "";
			String errMessageW = "";
			String errMessageG = "";
			DesignStatusEntity status = null;

			/**
			 * 成分标准
			 */
			MscChemImp chemImp = FactoryServer.getChemImp();
			errMessageC = chemImp.checkChem(con, design.getMsc(), design, "0");
			if (errMessageC.length() > 0) {
				status = statusDaoImp.setDesignStatus(design, design.getMsc(),
						"成分标准", "F", "91", errMessageC, "",
						design.getDunitCode(), design.getDunitDesc());
				statusDaoImp.updateDesignStatus(con, status);
				statusDaoImp.updateDesignStsTklg(con, designKey, "", "F", "W");
				con.commit();
				return core;
			} else {
				status = statusDaoImp.setDesignStatus(design, design.getMsc(),
						"成分标准", "S", "11", "成分标准通过验证", "",
						design.getDunitCode(), design.getDunitDesc());
				statusDaoImp.updateDesignStatus(con, status);
				errMessageC = "找不到成分索引号";
			}

			/**
			 * 理化标准
			 */
			MscPhyImp mscPhyImp = FactoryServer.getMscPhyImp();
			errMessageP = mscPhyImp.checkPhy(con, design.getMsc(), design, "0");
			if (errMessageP.length() > 0) {
				status = statusDaoImp.setDesignStatus(design, design.getMsc(),
						"理化标准", "F", "91", errMessageP, "",
						design.getDunitCode(), design.getDunitDesc());
				statusDaoImp.updateDesignStatus(con, status);
				statusDaoImp.updateDesignStsTklg(con, designKey, "", "F", "W");
				con.commit();
				return core;
			} else {
				status = statusDaoImp.setDesignStatus(design, design.getMsc(),
						"理化标准", "S", "11", "理化标准通过验证", "",
						design.getDunitCode(), design.getDunitDesc());
				statusDaoImp.updateDesignStatus(con, status);
				errMessageP = "找不到理化索引号";
			}

			/**
			 * 公差标准
			 */
			MscSpecImp mscSpecImp = FactoryServer.getMscSpecImp();
			errMessageS = mscSpecImp.checkSpec(con, design.getMsc(), design,
					"0");
			if (errMessageS.length() > 0) {
				status = statusDaoImp.setDesignStatus(design, design.getMsc(),
						"公差标准", "F", "91", errMessageS, "",
						design.getDunitCode(), design.getDunitDesc());
				statusDaoImp.updateDesignStatus(con, status);
				statusDaoImp.updateDesignStsTklg(con, designKey, "", "F", "W");
				con.commit();
				return core;
			} else {
				status = statusDaoImp.setDesignStatus(design, design.getMsc(),
						"公差标准", "S", "11", "理化标准通过验证", "",
						design.getDunitCode(), design.getDunitDesc());
				statusDaoImp.updateDesignStatus(con, status);
				errMessageS = "找不到公差索引号";
			}

			/**
			 * 探伤标准
			 */
			MscDeteImp mscDeteImp = FactoryServer.getMscDeteImp();
			errMessageD = mscDeteImp.checkDete(con, design.getMsc(), design,
					"0");
			if (errMessageD.length() > 0) {
				status = statusDaoImp.setDesignStatus(design, design.getMsc(),
						"探伤标准", "F", "91", errMessageD, "",
						design.getDunitCode(), design.getDunitDesc());
				statusDaoImp.updateDesignStatus(con, status);
				statusDaoImp.updateDesignStsTklg(con, designKey, "", "F", "W");
				con.commit();
				return core;

			} else {
				status = statusDaoImp.setDesignStatus(design, design.getMsc(),
						"探伤标准", "S", "11", "探伤标准通过验证", "",
						design.getDunitCode(), design.getDunitDesc());
				statusDaoImp.updateDesignStatus(con, status);
				errMessageD = "找不到探伤索引号";
			}

			/**
			 * 水压标准
			 */
			MscWaterImp mscWaterImp = FactoryServer.getMscWaterImp();
			String[] waterResults = mscWaterImp.checkWater(con, design.getMsc(), design,
					"0");
			errMessageW = waterResults[0];
			if (errMessageW.length() > 0) {
				if(waterResults[1].equals("MSC(n)")){
					status = statusDaoImp.setDesignStatus(design,
							design.getOrderLineMsc(), "MSC(n)", "F", "91", errMessageW,
							design.getOrdLnPk(), design.getMscUnitCode(), design.getMscUnitDesc());
					statusDaoImp.updateDesignStatus(con, status);
				}else{
					status = statusDaoImp.setDesignStatus(design, design.getMsc(),
							"水压标准", "F", "91", errMessageW, "",
							design.getDunitCode(), design.getDunitDesc());
					statusDaoImp.updateDesignStatus(con, status);
				}
				statusDaoImp.updateDesignStsTklg(con, designKey, "", "F", "W");
				con.commit();
				return core;
			} else {
				status = statusDaoImp.setDesignStatus(design, design.getMsc(),
						"水压标准", "S", "11", "水压标准通过验证", "",
						design.getDunitCode(), design.getDunitDesc());
				statusDaoImp.updateDesignStatus(con, status);
				errMessageW = design.getMsc() + "找不到水压索引号";
			}
			/**
			 * 加工标准
			 */
			MscProcessingImp mscProcessingImp = FactoryServer
					.getMscProcessingImp();
			errMessageG = mscProcessingImp.checkProcess(con, design.getMsc(),
					design, "0");
			if (errMessageG.length() > 0) {
				status = statusDaoImp.setDesignStatus(design, design.getMsc(),
						"加工标准", "F", "91", errMessageG, "",
						design.getDunitCode(), design.getDunitDesc());
				statusDaoImp.updateDesignStatus(con, status);
				statusDaoImp.updateDesignStsTklg(con, designKey, "", "F", "W");
				con.commit();
				return core;
			} else {
				status = statusDaoImp.setDesignStatus(design, design.getMsc(),
						"加工标准", "S", "11", "加工标准通过验证", "",
						design.getDunitCode(), design.getDunitDesc());
				statusDaoImp.updateDesignStatus(con, status);
				errMessageG = design.getMsc() + "找不到加工索引号";
			}

			/**
			 * 七、验证MSC(n)
			 */
			SpecialMscImp specialMscImp = FactoryServer.getSpecialMscImp();
			boolean flagSpec = specialMscImp.checkSpecialMc(con, design);
			if (!flagSpec) {
				statusDaoImp.updateDesignStsTklg(con, designKey, "", "F", "W");
				con.commit();
				return core;
			}

			// 查询指定制程
			ProDucDaoImp proDucDaoImp = FactoryDao.getProDucDaoImp();
			List<DesignMscPlEntity> setProDucs = proDucDaoImp.getMscPlSetFl(
					con, blCode, design.getOrderLineMsc());
			/**
			 * 九、验证制程
			 */
			List<String> errMessages = new ArrayList<String>();
			errMessages.add(errMessageC);
			errMessages.add(errMessageP);
			errMessages.add(errMessageS);
			errMessages.add(errMessageD);
			errMessages.add(errMessageW);
			errMessages.add(errMessageG);
			ProDucImp processImp = FactoryServer.getProcessImp();
			List<DesignMscPlEntity> mscPlEntitys = processImp.checkProDuc(con,
					design, errMessages, setProDucs);
			if (mscPlEntitys == null || mscPlEntitys.size() == 0) {
				statusDaoImp.updateDesignStsTklg(con, designKey, "", "F", "W");
				con.commit();
				return core;
			}

			/**
			 * 十、验证制程向下的钢种、镦拔扩、适用产线等
			 */
			String mscPlineMessage = "**";
			GradeDaoImp gradeDaoImp = FactoryDao.getGradeDaoImp();
			GradeImp gradeImp = FactoryServer.getGradeImp();
			ProDucDaoImp processDaoImp = FactoryDao.getProDucDaoImp();
			InnerStandardImp innerStdImp = FactoryServer.getInnerStandardImp();
			SpecManageImp specManageImp = FactoryServer.getSpecManageImp();
			CreateSpecLineDaoImp specLineDaoImp = FactoryDao
					.getCreateSpecLineDaoImp();
			ProLineManageImp proLineManageImp = FactoryServer
					.getProLineManageImp();
			boolean ducflag = false;
			for (DesignMscPlEntity proDuc : mscPlEntitys) {
				String wholeBacklog = proDuc.getWholeBacklog();

				/**
				 * 1、验证钢种
				 */
				Object[] gradeInfo = gradeImp.checkGrade(con,
						proDuc.getMscPline(), wholeBacklog,
						design.getOrderLineMsc(), design.getDimater(),
						design.getHeight(), design.getSpecStyle(),
						design.getSpecName(), "", design.getOrderLineMscStyle(),
						designKey);
				String errMessageGrade = (String) gradeInfo[0];
				@SuppressWarnings("unchecked")
				List<DesignMscPlGzEntity> grades = (List<DesignMscPlGzEntity>) gradeInfo[1];
				// 如果得到的钢种条数为零，则验证下一个制程
				if (grades == null || grades.size() == 0) {
					mscPlineMessage += errMessageGrade + "**";
					status = statusDaoImp.setDesignStatus(design,
							design.getOrderLineMsc(), "钢种", "F", "91",
							errMessageGrade, proDuc.getMscPline(),
							design.getMscDunitCode(), design.getMscDunitDesc());
					// 如果指定了制程,则每个制程每一步如果验证不通过,都要停止设计
					if (setProDucs != null && setProDucs.size() > 0) {
						statusDaoImp.updateDesignStatus(con, status);
						statusDaoImp.updateDesignStsTklg(con, designKey, "",
								"F", "W");
						con.commit();
						return core;
					}
					continue;
				}
				/**
				 * 2、 验证规格
				 */
				SpecEntity specInfo = specManageImp.analysisSpec(con, proDuc,
						grades, design);
				if (specInfo.getStatus() != null) {
					status = specInfo.getStatus();
					mscPlineMessage += status.getDesignStsDesc() + "**";
					// 如果指定了制程,则每个制程每一步如果验证不通过,都要停止设计
					if (setProDucs != null && setProDucs.size() > 0) {
						statusDaoImp.updateDesignStsTklg(con, designKey, "",
								"F", "W");
						statusDaoImp.updateDesignStatus(con, status);
						con.commit();
						return core;
					}

					continue;
				}

				/**
				 * 3、验证产线
				 */
				ProLineEntity proLineInfo = proLineManageImp.analysisProLine(
						con, design, proDuc, specInfo.getRollSpecs(),
						specInfo.getBlitSpecs(), specInfo.getBlitCSpecs());
				if (proLineInfo.getStatus() != null) {
					status = proLineInfo.getStatus();
					mscPlineMessage += status.getDesignStsDesc() + "**";
					// 如果指定了制程,则每个制程每一步如果验证不通过,都要停止设计
					if (setProDucs != null && setProDucs.size() > 0) {
						statusDaoImp.updateDesignStatus(con, status);
						statusDaoImp.updateDesignStsTklg(con, designKey, "",
								"F", "W");
						con.commit();
						return core;
					}

					continue;
				}
				/**
				 * 4、 验证内控标准
				 */
				Object[] innerInfo = innerStdImp.checkInnerStd(con,
						design.getOrderLineMsc(), proDuc.getMscPline(),
						wholeBacklog, proDuc.getWholeBacklogDesc(), designKey);
				// boolean innerFlag = (Boolean) innerInfo[0];
				String innerMessage = (String) innerInfo[1];
				@SuppressWarnings("unchecked")
				List<DesignMscPlPrcEntity> inners = (List<DesignMscPlPrcEntity>) innerInfo[2];
				DesignStatusEntity statusInner = statusDaoImp.setDesignStatus(
						design, design.getOrderLineMsc(), "内控标准", "S", "91",
						innerMessage, proDuc.getMscPline(),
						design.getMscUnitCode(), design.getMscUnitDesc());
				statusDaoImp.updateDesignStatus(con, statusInner);
				for (DesignMscPlPrcEntity inner : inners) {
					specLineDaoImp.saveInnerStd(con, inner);
				}

				// 保存钢种
				for (DesignMscPlGzEntity grade : specInfo.getGrade()) {
					gradeDaoImp.saveGrade(con, grade, designKey);
				}

				// 保存轧管规格
				List<DesignMscGzGgEntity> rollSpecs = specInfo.getRollSpecs();
				if (rollSpecs != null && rollSpecs.size() != 0) {
					rollSpecs = ServerDesignTool.fiterRollSpec(rollSpecs);
					for (DesignMscGzGgEntity rollSpec : rollSpecs) {
						specLineDaoImp.savePipeRoll(con, rollSpec);
					}
				}
				List<DesignMscBiltEntity> biltSpecs = specInfo.getBlitSpecs();

				// 保存断面规格
				if (biltSpecs != null && biltSpecs.size() != 0) {
					biltSpecs = ServerDesignTool.fiterBiltSpec(biltSpecs);
					if (biltSpecs != null && biltSpecs.size() != 0) {
						for (DesignMscBiltEntity biltSpec : biltSpecs) {
							specLineDaoImp.saveBlankSection(con, biltSpec);
						}
					}
				}
				List<DesignMscBiltCEntity> biltsSpecs = specInfo
						.getBlitCSpecs();

				// 保存坯料规格
				if (biltsSpecs != null && biltsSpecs.size() != 0) {
					biltsSpecs = ServerDesignTool.fiterBiltCSpec(biltsSpecs);
					for (DesignMscBiltCEntity biltsSpec : biltsSpecs) {
						specLineDaoImp.saveStockSpecific(con, biltsSpec);
					}
				}

				// 保存制程适用产线
				List<DesignMscPlGxPrlEntity> proLines = proLineInfo
						.getProLines();
				for (DesignMscPlGxPrlEntity proLine : proLines) {
					specLineDaoImp.saveProLine(con, proLine);
				}

				// 保存铸造产线（含铸造规格）
				List<DesignMscBiltCPlEntity> biltCSpecLines = proLineInfo
						.getBiltCSpecLines();
				if (biltCSpecLines != null && biltCSpecLines.size() != 0) {
					for (DesignMscBiltCPlEntity blitCInLine : biltCSpecLines) {
						specLineDaoImp.saveBlits(con, blitCInLine);
					}
				}
				// 保存轧管产线（含轧管规格）
				List<DesignMscGzGgPlEntity> rollSpecLines = proLineInfo
						.getRollSpecLines();
				if (rollSpecLines != null && rollSpecLines.size() != 0) {
					for (DesignMscGzGgPlEntity specInline : rollSpecLines) {
						specLineDaoImp.saveSpec(con, specInline);
					}
				}

				// 保存锻造产线（含锻造规格）
				List<DesignMscBiltPlEntity> biltSpecLines = proLineInfo
						.getBiltSpecLines();
				if (biltSpecLines != null && biltSpecLines.size() != 0) {
					for (DesignMscBiltPlEntity biltInLine : biltSpecLines) {
						specLineDaoImp.saveBlank(con, biltInLine);
					}
				}

				// 计算压缩比
				if (!wholeBacklog.contains("C")) {
					if (!ServerDesignTool
							.compressioRatio(rollSpecs, biltsSpecs)) {
						proDuc.setWarnDesc("压缩比为≤3，但制程不经过锻造");
					}
				}
				// 保存制程
				if (setProDucs == null || setProDucs.size() == 0) {
					processDaoImp.saveProcess(con, proDuc, designKey);

				} else {
					String ordDesignKey = proDuc.getDesginKey();
					proDuc.setDesginKey(design.getDesignKey());
					processDaoImp.updateSetPl(con, proDuc, ordDesignKey);
				}
				/**
				 * 5、验证工序点(仅取工序点)
				 */
				OperationPointDaoImp operationPointDaoImp = FactoryDao
						.getOperationPointDaoImp();
				String[] processes = wholeBacklog.split("-");
				for (String porcess : processes) {
					List<DesignMscPlStiEntity> points = operationPointDaoImp
							.getDesignPoint(con, design.getOrderLineMsc(),
									proDuc.getMscPline(), porcess);
					if (points != null && points.size() > 0) {
						for (DesignMscPlStiEntity point : points) {
							point.setDesginKey(design.getDesignKey());

							operationPointDaoImp.saveOperationPoint(con, point);
						}
					}
				}
				if (setProDucs == null || setProDucs.size() == 0) {
					DesignStatusEntity statusUpset = null;
					if (proDuc.getWholeBacklog().contains("E")) {
						statusUpset = statusDaoImp.setDesignStatus(design,
								design.getOrderLineMsc(), "镦拔扩", "S", "11",
								"镦拔扩通过验证", proDuc.getMscPline(),
								design.getMscUnitCode(),
								design.getMscUnitDesc());
					} else {
						statusUpset = statusDaoImp.setDesignStatus(design,
								design.getOrderLineMsc(), "镦拔扩", "S", "00",
								"镦拔扩无要求", proDuc.getMscPline(),
								design.getMscUnitCode(),
								design.getMscUnitDesc());
					}
					statusDaoImp.updateDesignStatus(con, statusUpset);
					DesignStatusEntity statusGrade = statusDaoImp
							.setDesignStatus(design, design.getOrderLineMsc(),
									"钢种", "S", "11", "钢种通过验证",
									proDuc.getMscPline(),
									design.getMscDunitCode(),
									design.getMscDunitDesc());
					statusDaoImp.updateDesignStatus(con, statusGrade);
					DesignStatusEntity statusLine = statusDaoImp
							.setDesignStatus(design, design.getOrderLineMsc(),
									"适用产线", "S", "11", "适用产线通过验证",
									proDuc.getMscPline(),
									design.getMscUnitCode(),
									design.getMscUnitDesc());
					statusDaoImp.updateDesignStatus(con, statusLine);
					ducflag = true;
				}

			}
			if (!ducflag) {
				// 如果没有指定制程,有一项没有验证通过,则让操作人制定,指定完之后,就按这个制程走流程
				if (setProDucs == null || setProDucs.size() == 0) {
					String mscPline = "";
					for (DesignMscPlEntity proDuc : mscPlEntitys) {
						mscPline += proDuc.getMscPline() + ",";
					}
					// OBJ_KEY为1,则指定制程
					status = statusDaoImp.setDesignStatus(design, design
							.getOrderLineMsc(), "制程", "F", "91", "制程"
							+ mscPline.substring(0, mscPline.length() - 1)
							+ "交付标准与制程完整性通过验证,但(镦拔扩、规格、适用产线)某项未通过验证(未通过原因:"
							+ mscPlineMessage + "),请设定制程", "1", design
							.getMscDunitCode(), design.getMscDunitDesc());
					statusDaoImp.updateDesignStatus(con, status);
					statusDaoImp.updateDesignStsTklg(con, designKey, "", "F",
							"W");
					con.commit();
					return core;
				} else {
					// 指定制程验证通过录入状态
					status = statusDaoImp.setDesignStatus(design,
							design.getOrderLineMsc(), "钢种", "S", "11",
							"钢种通过验证", "", design.getMscDunitCode(),
							design.getMscDunitDesc());
					statusDaoImp.updateDesignStatus(con, status);
					status = statusDaoImp.setDesignStatus(design,
							design.getOrderLineMsc(), "镦拔扩", "S", "11",
							"镦拔扩通过验证", "", design.getMscUnitCode(),
							design.getMscUnitDesc());
					statusDaoImp.updateDesignStatus(con, status);
					status = statusDaoImp.setDesignStatus(design,
							design.getOrderLineMsc(), "适用产线", "S", "11",
							"适用产线通过验证", "", design.getMscUnitCode(),
							design.getMscUnitDesc());
					statusDaoImp.updateDesignStatus(con, status);

				}

			}

			/**
			 * 十三、物料码
			 */
			try {
				BOMGeneration.generationBomMain(con, designKey, "1", "0");
				DesignStatusEntity statusBom = statusDaoImp.setDesignStatus(
						design, design.getOrderLineMsc(), "投入/产出物料", "S", "11",
						"投入/产出物料通过验证", design.getOrderLineMsc(),
						design.getMscDunitCode(), design.getMscDunitDesc());
				statusDaoImp.updateDesignStatus(con, statusBom);

				statusDaoImp.updateDesignStsTklg(con, designKey, "", "S", "W");
			} catch (Exception e) {
				DesignStatusEntity statusBom = statusDaoImp.setDesignStatus(
						design, design.getOrderLineMsc(), "投入/产出物料", "S", "11",
						"投入/产出物料物料编码生成异常,请确认", design.getOrderLineMsc(),
						design.getMscDunitCode(), design.getMscDunitDesc());
				statusDaoImp.updateDesignStatus(con, statusBom);
				con.commit();
				return core;
			}
			
			//---------------------试样码------------0-MSC0 1-MSCN 2-内控
			IMscSplineDao mscSplineDao = new IMscSplineDao();
			String[] msc0SplineResults = mscSplineDao.CheckSpline(con, design, "0");
			String[] mscnSplineResults = mscSplineDao.CheckSpline(con, design, "1");
			
			if(msc0SplineResults[0].equals("") && mscnSplineResults[0].equals("")){
				status = statusDaoImp.setDesignStatus(design,
						design.getMsc(), "试样码", "S", "11",
						"试样码证通过", mscnSplineResults[1],
						"002001007011", "生产设备科");
				statusDaoImp.updateDesignStatus(con, status);
			}else{
				if(!msc0SplineResults[0].equals("")){
					String objKey = msc0SplineResults[1] + "," + "0";
					status = statusDaoImp.setDesignStatus(design,
							design.getMsc(), "试样码", "S", "91",
							msc0SplineResults[0], objKey,
							"002001007011", "生产设备科");
					statusDaoImp.updateDesignStatus(con, status);
					//statusDaoImp.updateDesignStsTklg(con, designKey, "", "F", "W");
				}else if(!mscnSplineResults[0].equals("")){
					String objKey = mscnSplineResults[1] + "," + "1";
					status = statusDaoImp.setDesignStatus(design,
							design.getOrderLineMsc(), "试样码", "S", "91",
							mscnSplineResults[0], objKey,
							"002001007011", "生产设备科");
					statusDaoImp.updateDesignStatus(con, status);
					//statusDaoImp.updateDesignStsTklg(con, designKey, "", "F", "W");
				}
				//return core;
			}
			
			

			// 质量设计通过验证
			statusDaoImp.updateDesignStsTklg(con, designKey, "", "S", "S");
			core.setResult(true);
			con.commit();
			return core;

		} catch (Exception e) {
			try {
				System.out.println(e.getMessage());
				core.setV_errMsg(e.getMessage());
				con.rollback();
				con.close();
			} catch (SQLException e1) {
			}
		} finally {
			try {
				con.close();
			} catch (SQLException e) {
			}
		}
		core.setResult(true);
		try {
			con.commit();
		} catch (SQLException e) {
			try {
				con.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		}
		return core;
	}
}
