package com.steering.mes.mcp.heatTreatment;

import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;
import CoreFS.SC01.CoreConstantData;
import com.steering.comm.converter.EntityTool;
import com.steering.comm.db.DBCommon;
import com.steering.comm.tools.StringTool;
import com.steering.mes.mcp.common.PlanService;
import com.steering.mes.mcp.entity.*;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 探伤实绩
 * 
 * @author TJG 2016-05-13
 */
public class FrmHttCrackDetectResult extends DBCommon {
	/**
	 * 查询探伤实绩
	 * 
	 * @param planNo
	 * @param seqNo
	 * @return
	 */
	public CoreReturnObject getQueryCrackDetection(String heatNo) {
		return this.getDataBySqlID(
				"FrmHttCrackDetectResult.getQueryCrackDetection",
				new Object[] { heatNo });
	}


	public CoreReturnObject getResultData(String resultNo) {
		return this.getDataBySqlID(
				"FrmHttCrackDetectResult.getResultData",
				new Object[] { resultNo });
	}
	

	public CoreReturnObject getResultParaData(String resultNo) {
		return this.getDataBySqlID(
				"FrmHttCrackDetectResult.getResultParaData",
				new Object[] { resultNo });
	}
	
	
	public CoreReturnObject getResultProbeData(String probeId) {
		return this.getDataBySqlID(
				"FrmHttCrackDetectResult.getResultProbeData",
				new Object[] { probeId });
	}
	
	public CoreReturnObject getResultStandData(String standId) {
		return this.getDataBySqlID(
				"FrmHttCrackDetectResult.getResultStandData",
				new Object[] { standId });
	}
	
	/**
	 * 
	 * 根据合同号查询已存在的样槽信息
	 */
	public CoreReturnObject QueryNotchInfo(String OrderNo) {
		return this.getDataBySqlID("FrmHttCrackDetectResult.QueryNotchInfo",
				new Object[] { OrderNo });
	}

	/**
	 * 废品支数为0删除缺陷实绩
	 */
	public CoreReturnObject getqueryfailnum(String resultno) {
		CoreReturnObject core = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		try {
			String addPlnInfo = CoreXmlSqlParsersFactory
					.getSql("FrmHttCrackDetectResult.getqueryfailnum");//
			PreparedStatement patsPlan = connection
					.prepareStatement(addPlnInfo);
			patsPlan.setObject(1, resultno);
			patsPlan.addBatch();
			patsPlan.executeBatch();

			core.setResult(1);
			connection.commit();
		} catch (Exception e) {
			core.setV_errMsg(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return core;
	}

	/**
	 * 查询相同炉计划ID下探伤
	 */
	public CoreReturnObject getQueryExpandResultStuts(String heatNo,
			String plinCode) {
		return this.getDataBySqlID(
				"FrmHttCrackDetectResult.getQueryExpandResultStuts",
				new Object[] { heatNo, plinCode });
	}

	/**
	 * 查询探伤合格支数的和
	 */
	public CoreReturnObject getQueryExpandResult1(String heatNo) {
		return this.getDataBySqlID(
				"FrmHttCrackDetectResult.getQueryExpandResult1",
				new Object[] { heatNo });
	}

	/**
	 * 查询探伤废品原因
	 * 
	 * @param resultNo
	 * @return
	 */
	public CoreReturnObject getQuerybase(String resultNo) {
		return this.getDataBySqlID("FrmHttCrackDetectResult.getQuerybase",
				new Object[] { resultNo });
	}

	/**
	 * 保存
	 * 
	 * @param load
	 * @return
	 */
	public CoreReturnObject saveCrackDetection(String loadStr,
			ArrayList<String> ScrappedList, ArrayList<String> SuspiciousList,
			ArrayList<String> UnpassList, String CrackParaStr,
			ArrayList<String> ProbeString, ArrayList<String> StandString,
			String gx) {
		CoreReturnObject core = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		PreparedStatement psta = null;
		Date now = new Date();
		SimpleDateFormat dateFormat = new SimpleDateFormat(
				"yyyy-MM-dd HH:mm:ss", Locale.CHINA);
		String systime = dateFormat.format(now);
		SimpleDateFormat matter1 = new SimpleDateFormat("yyMMdd");
		SimpleDateFormat dateFormat1 = new SimpleDateFormat(
				"yyyy/MM/dd HH:mm:ss", Locale.CHINA);

		try {
			connection.setAutoCommit(false); //

			String sqlupdate = CoreXmlSqlParsersFactory
					.getSql("AppearanceService.updatePlnZyRclM");// 修改热处理计划表
			PreparedStatement patupdate = connection
					.prepareStatement(sqlupdate);
			String addPlnInfo = CoreXmlSqlParsersFactory
					.getSql("HttLoadingService.AddComInfoResult");// 新增公共信息
			PreparedStatement patsPlan = connection
					.prepareStatement(addPlnInfo);

			HttCrackDetectionEtEntity Load = EntityTool.getEntityByJSONStr(
					loadStr, HttCrackDetectionEtEntity.class);
			HttCrackDetectionParaEntity Para = EntityTool.getEntityByJSONStr(
					CrackParaStr, HttCrackDetectionParaEntity.class);

			Load.setColUser(Para.getOperatorName());
			Para.setColGroup(Load.getColGroup());
			Para.setShift(Load.getColShift());

			if (Load.getTestingType().equals("")) {
				core.setV_errMsg("探伤种类不能为空！");
				return core;
			}

			if (Load.getTestingGrade().equals("")
					&& !Para.getAccpetanceLevel().equals("")) {
				Load.setTestingGrade(Para.getAccpetanceLevel());
			}

			if (Load.getTestingGrade().equals("")
					&& !Load.getTestingType().equals("MT")) {
				core.setV_errMsg("探伤等级不能为空！");
				return core;
			}

			// 获取热处理计划实体了
			PlnZyRclMEntity pln = PlanService.getSendHttPlanCInfo(connection,
					Load.getHeatPlanNo());

			SimpleDateFormat matter2 = new SimpleDateFormat("yyyyMMddHHmm");
			SimpleDateFormat matter3 = new SimpleDateFormat("yyyyMM");
			SimpleDateFormat matter4 = new SimpleDateFormat("yyyyMMdd");

			Date colDate = GetDateByStr(Load.getColTime());
			Date colEndDate = GetDateByStr(Load.getColEndTime());

			if (colDate.after(colEndDate)) {
				core.setV_errMsg("结束时间不能早于开始时间");
				return core;
			}

			if (pln == null)
				return core;

			if (pln.getPlanstatus().equals("30")) {
				core.setV_errMsg("炉计划已经生产完成,请先撤销下线结炉！");
				return core;
			}

			if (pln.getPlanstatus().equals("40")) {
				core.setV_errMsg("该计划已关闭，请撤销申请判定！");
				return core;
			}

			if (Load.getReportNo().equals("0")) {

				if (Integer.parseInt(Load.getEpassNum())
						+ Integer.parseInt(Load.getEwasteNum())
						+ Integer.parseInt(Load.getPendingNum()) != Integer
						.parseInt(Load.getTestingNum())) {
					core.setV_errMsg("最终合格支数+最终废品支数+待判支数不等于检测支数,请检查!");
					return core;
				}

				if (Integer.parseInt(Load.getPassNum())
						+ Integer.parseInt(Load.getDubiousNum()) != Integer
						.parseInt(Load.getTestingNum())) {
					core.setV_errMsg("合格支数+可疑品支数不等于检测支数,请检查!");
					return core;
				}

				// if(Integer.parseInt(load.getFpassNum())
				// +Integer.parseInt(load.getEwasteNum()) !=
				// Integer.parseInt(load.getDubiousNum())){

				if (Integer.parseInt(Load.getFpassNum())
						+ Integer.parseInt(Load.getEwasteNum())
						+ Integer.parseInt(Load.getPendingNum()) != Integer
						.parseInt(Load.getDubiousNum())) {
					core.setV_errMsg("复探合格支数+最终废品支数 + 待判支数不等于可疑品支数,请检查!");
					return core;
				}
			}

			// endregion

			int count = 0;
			int detCount = 0;

			if (StringTool.isInteger(Load.getEwasteNum())) {
				detCount += Integer.parseInt(Load.getEwasteNum());
			}
			if (StringTool.isInteger(Load.getEwasteNumEt())) {
				detCount += Integer.parseInt(Load.getEwasteNumEt());
			}
			if (StringTool.isInteger(Load.getRejectNum())) {
				detCount += Integer.parseInt(Load.getRejectNum());
			}
			if (StringTool.isInteger(Load.getTestingNum())) {
				count = Integer.parseInt(Load.getTestingNum());
			}

			if (count <= 0) {
				core.setV_errMsg("请输入正确的探伤支数！");
				return core;
			}

			if (count < detCount) {
				core.setV_errMsg("废品支数不能大于探伤支数！");
				return core;
			}

			String sql = "";
			String resultNo = "";
			Date dt = new Date();
			String sqlloading = CoreXmlSqlParsersFactory
					.getSql("FrmHttCrackDetectResult.queryLoadRESULT");// 查询最大实绩编号
			psta = connection.prepareStatement(sqlloading);
			psta.setObject(1, pln.getPlineCode() + gx + matter1.format(dt));
			psta.setObject(2, pln.getPlineCode() + gx + matter1.format(dt));

			ResultSet rs1 = psta.executeQuery();
			if (rs1.next()) {
				resultNo = rs1.getString("RESULT_NO");
			}
			rs1.close();
			psta.close();

			String sqlAdd = CoreXmlSqlParsersFactory
					.getSql("FrmHttCrackDetectResult.AddCrackDetection");// 新增探伤
			Load.setZyBatchId(pln.getZyBatchId());
			Load.setProPlanId(pln.getProPlanId());
			Load.setGxPlanNo(pln.getGxPlanNo());
			Load.setResultNo(resultNo);
			sqlAdd = com.steering.common.EntityTool.fillSqlByEntity(sqlAdd,
					Load);
			PreparedStatement patAdd = connection.prepareStatement(sqlAdd);
			patAdd.addBatch();

			String ProbeID = "";
			if (ProbeString.size() > 0) {
				sql = CoreXmlSqlParsersFactory
						.getSql("FrmHttCrackDetectResult.getMaxProbeId");
				psta = connection.prepareStatement(sql);
				psta.setObject(1, pln.getJudgeStoveNo() + Load.getBatchNo());
				psta.setObject(2, pln.getJudgeStoveNo() + Load.getBatchNo());

				rs1 = psta.executeQuery();
				if (rs1.next()) {
					ProbeID = rs1.getString("PROBE_ID");
				}
				rs1.close();
				psta.close();

			}

			String StandID = "";

			if (StandString.size() > 0) {
				sql = CoreXmlSqlParsersFactory
						.getSql("FrmHttCrackDetectResult.getMaxStandID");
				psta = connection.prepareStatement(sql);
				psta.setObject(1, pln.getJudgeStoveNo() + Load.getBatchNo());
				psta.setObject(2, pln.getJudgeStoveNo() + Load.getBatchNo());

				rs1 = psta.executeQuery();
				if (rs1.next()) {
					StandID = rs1.getString("STANDARD_ID");
				}
				rs1.close();
				psta.close();

			}

			String sqlAddPara = CoreXmlSqlParsersFactory
					.getSql("FrmHttCrackDetectResult.AddCrackDetectionPara");
			Para.setResultNo(resultNo);
			Para.setReportNo(Load.getReportNo());
			Para.setProbeId(ProbeID);
			Para.setStandardId(StandID);
			Para.setHeatPlanNo(pln.getHeatPlanNo());
			Para.setBatchNo(Load.getBatchNo());
			Para.setJudgeStoveNo(pln.getJudgeStoveNo());
			Para.setShift(Load.getColShift());
			Para.setProDate(Load.getColTime());
			Para.setColGroup(Load.getColGroup());
			sqlAddPara = com.steering.common.EntityTool.fillSqlByEntity(
					sqlAddPara, Para);
			PreparedStatement patAddPara = connection
					.prepareStatement(sqlAddPara);
			patAddPara.addBatch();
			patAddPara.executeBatch();

			for (int i = 0; i < ProbeString.size(); i++) {
				HttCrackDetectionProbeEntity probeEntity = EntityTool
						.getEntityByJSONStr(ProbeString.get(i),
								HttCrackDetectionProbeEntity.class);

				String sqlAddProbe = CoreXmlSqlParsersFactory
						.getSql("FrmHttCrackDetectResult.AddCrackDetectionProbe");
				probeEntity.setProbeId(ProbeID);
				probeEntity.setProbeSeq((i + 1) + "");
				sqlAddProbe = com.steering.common.EntityTool.fillSqlByEntity(
						sqlAddProbe, probeEntity);
				PreparedStatement patAddProbe = connection
						.prepareStatement(sqlAddProbe);
				patAddProbe.addBatch();
				patAddProbe.executeBatch();
			}

			for (int i = 0; i < StandString.size(); i++) {
				HttCrackDetectionStandardEntity probeEntity = EntityTool
						.getEntityByJSONStr(StandString.get(i),
								HttCrackDetectionStandardEntity.class);

				String sqlAddStand = CoreXmlSqlParsersFactory
						.getSql("FrmHttCrackDetectResult.AddCrackDetectionStandard");
				probeEntity.setStandardId(StandID);
				probeEntity.setStandardSeq((i + 1) + "");
				sqlAddStand = com.steering.common.EntityTool.fillSqlByEntity(
						sqlAddStand, probeEntity);
				PreparedStatement patAddStand = connection
						.prepareStatement(sqlAddStand);
				patAddStand.addBatch();
				patAddStand.executeBatch();
			}

			// 新增探伤公共信息
			patsPlan.setObject(1, resultNo);
			patsPlan.setObject(2, pln.getZyBatchId());
			// patsPlan.setObject(3, pln.getProdIndex());
			patsPlan.setObject(3, pln.getProPlanId());
			patsPlan.setObject(4, pln.getGxPlanNo());
			patsPlan.setObject(5, pln.getOrderSource());
			patsPlan.setObject(6, pln.getOrderNo());
			patsPlan.setObject(7, pln.getOrderSeq());
			patsPlan.setObject(8, pln.getReqBlId());
			patsPlan.setObject(9, pln.getPlineCode());
			patsPlan.setObject(10, pln.getPlineName());
			patsPlan.setObject(11, gx);
			patsPlan.setObject(12, "探伤");
			patsPlan.setObject(13, pln.getGradecode());
			patsPlan.setObject(14, pln.getGradename());
			patsPlan.setObject(15, pln.getSteelcode());
			patsPlan.setObject(16, pln.getSteelname());
			patsPlan.setObject(17, pln.getOutdiameterIn());
			patsPlan.setObject(18, pln.getWallthickIn());
			patsPlan.setObject(19, "");
			patsPlan.setObject(20, "");
			patsPlan.setObject(21, "");
			patsPlan.setObject(22, "");
			patsPlan.setObject(23, "");
			patsPlan.setObject(24, "");
			patsPlan.setObject(25, "");
			patsPlan.setObject(26, "");
			patsPlan.setObject(27, pln.getOutwlId());
			patsPlan.setObject(28, pln.getOutwlDesc());
			patsPlan.setObject(29, pln.getInwlId());
			patsPlan.setObject(30, pln.getInwlDesc());
			patsPlan.setObject(31, pln.getMonitorPoint());
			patsPlan.setObject(32, "");
			patsPlan.setObject(33, pln.getPrdcrNo());
			patsPlan.setObject(34, "");
			patsPlan.setObject(35, "");
			patsPlan.setObject(36, pln.getStationRoad());
			patsPlan.setObject(37, pln.getCraftFileNo());
			patsPlan.setObject(38, pln.getCraftFileMan());
			patsPlan.setObject(39, pln.getCraftSeq());
			patsPlan.setObject(40, Load.getTestingNum());
			patsPlan.setObject(41, Load.getTestingWt());
			patsPlan.setObject(42, detCount);
			patsPlan.setObject(43, resultNo);
			patsPlan.setObject(44, "");
			patsPlan.setObject(45, "");
			patsPlan.setObject(46, "");
			patsPlan.setObject(47, "");
			patsPlan.setObject(48, "1");
			patsPlan.setObject(49, Load.getColTime());
			patsPlan.setObject(50, "");
			patsPlan.setObject(51, Load.getColUser());
			patsPlan.setObject(52, Load.getColShift());
			patsPlan.setObject(53, Load.getColGroup());
			patsPlan.setObject(54, "1");
			patsPlan.setObject(55, systime);
			patsPlan.setObject(56, "");
			patsPlan.setObject(57, Load.getHeatPlanNo());
			patsPlan.setObject(58, pln.getJudgeStoveNo());
			patsPlan.setObject(59, pln.getBatchNo());
			patsPlan.setObject(60, "");
			patsPlan.setObject(61, pln.getProduccode());
			patsPlan.setObject(62, pln.getProducname());
			patsPlan.setObject(63, pln.getSpecCode());
			patsPlan.setObject(64, pln.getSpecName());
			patsPlan.setObject(65, Load.getProcessSeq());
			patsPlan.addBatch();

			patupdate.setObject(1, "80");
			patupdate.setObject(2, Load.getHeatPlanNo());
			patupdate.addBatch();
			patupdate.executeBatch();

			String sqlAddHead = CoreXmlSqlParsersFactory
					.getSql("FrmHttCrackDetectResult.AddCrackHead");// 新增探伤
			PreparedStatement patAddHead = connection
					.prepareStatement(sqlAddHead);
			patAddHead.setObject(1, resultNo);
			patAddHead.setObject(2, Load.getBatchNo());
			patAddHead.setObject(3, Load.getHeatPlanNo());
			patAddHead.addBatch();

			patAddHead.executeBatch();

			patAdd.executeBatch();
			patsPlan.executeBatch();
			patupdate.executeBatch();

			FrmHttBugD.AddHttWaste(connection, Load.getHeatPlanNo(), resultNo,
					pln.getPlineCode(), Load.getColUser(),
					Load.getProcessSeq(), gx, SuspiciousList, ScrappedList,
					UnpassList);

			String addHttControlLog = CoreXmlSqlParsersFactory
					.getSql("HeatTreatmentService.addHttControlLog"); // 增加调度日志
			// 仅探伤才增加
			PreparedStatement pastaddHttControlLog = connection
					.prepareStatement(addHttControlLog);

			// if (pln.getProcessCodeC().equals("B024")) {
			Date procDate = colDate;
			if (Load.getColShift().equals("3")) {
				Calendar date = Calendar.getInstance();
				date.setTime(colDate);
				date.set(Calendar.HOUR_OF_DAY,
						date.get(Calendar.HOUR_OF_DAY) + 12);
				procDate = dateFormat.parse(dateFormat.format(date.getTime()));
			}

			int acount = 0;
			String sql1 = CoreXmlSqlParsersFactory
					.getSql("FrmHttControlLog.qureyConfirmFlag");// 查询录入时间是否调度已确认.
			psta = connection.prepareStatement(sql1);
			psta.setString(1, matter2.format(colDate));
			psta.setObject(2, matter2.format(colDate));
			psta.setObject(3, matter2.format(colEndDate));
			psta.setObject(4, matter2.format(colEndDate));
			psta.setObject(5, Load.getPlineCode());
			psta.setObject(6, "1");
			rs1 = psta.executeQuery();
			if (rs1.next()) {
				acount = Integer.parseInt(rs1.getString("ACOUT"));
			}
			if (acount > 0) {
				core.setV_errMsg("该时间段,调度已确认或已审核,请联系调度取消确认或取消审核!");
				return core;
			}
			rs1.close();
			psta.close();

			if (Load.getTestingPosition().equals("0")) {
				pastaddHttControlLog.setObject(1, matter2.format(colDate));
				pastaddHttControlLog.setObject(2, matter2.format(colEndDate));
				pastaddHttControlLog.setObject(3, resultNo);
				// patAdd.setObject(3, pln.getProdIndex());
				pastaddHttControlLog.setObject(4, Load.getColShift());
				pastaddHttControlLog.setObject(5, Load.getColGroup());
				pastaddHttControlLog.setObject(6, Load.getTestingNum());
				pastaddHttControlLog.setObject(7, Load.getTestingWt());
				pastaddHttControlLog.setObject(8, systime);
				pastaddHttControlLog.setObject(9, Load.getColUser());
				pastaddHttControlLog.setObject(10, matter3.format(procDate));
				pastaddHttControlLog.setObject(11, matter4.format(procDate));
				pastaddHttControlLog.setObject(12, "1");
				pastaddHttControlLog.setObject(13, Load.getHeatPlanNo());
				pastaddHttControlLog.addBatch();
				pastaddHttControlLog.executeBatch();
			}
			
			// }

			core.setV_errMsg("新增探伤成功！");
			core.setResult(1);
			connection.commit();
		} catch (Exception e) {
			core.setV_errMsg(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return core;
	}

	/**
	 * 保存
	 * 
	 * @param load
	 * @return
	 */
	public CoreReturnObject saveCrackDetection(ArrayList<String> loadStrs,
			ArrayList<String> ScrappedList, ArrayList<String> SuspiciousList,
			ArrayList<String> UnpassList, String CrackParaStr,
			ArrayList<String> ProbeString, ArrayList<String> StandString,
			String gx) {
		CoreReturnObject core = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		PreparedStatement psta = null;
		Date now = new Date();
		SimpleDateFormat dateFormat = new SimpleDateFormat(
				"yyyy-MM-dd HH:mm:ss", Locale.CHINA);
		String systime = dateFormat.format(now);
		SimpleDateFormat matter1 = new SimpleDateFormat("yyMMdd");
		SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm",
				Locale.CHINA);

		try {
			connection.setAutoCommit(false); //

			for (int j = 0; j < loadStrs.size(); j++) {
				String sqlupdate = CoreXmlSqlParsersFactory
						.getSql("AppearanceService.updatePlnZyRclM");// 修改热处理计划表
				PreparedStatement patupdate = connection
						.prepareStatement(sqlupdate);
				String addPlnInfo = CoreXmlSqlParsersFactory
						.getSql("HttLoadingService.AddComInfoResult");// 新增公共信息
				PreparedStatement patsPlan = connection
						.prepareStatement(addPlnInfo);

				String loadStr = loadStrs.get(j);

				HttCrackDetectionEtEntity Load = EntityTool.getEntityByJSONStr(
						loadStr, HttCrackDetectionEtEntity.class);
				HttCrackDetectionParaEntity Para = EntityTool
						.getEntityByJSONStr(CrackParaStr,
								HttCrackDetectionParaEntity.class);

				Load.setColUser(Para.getOperatorName());
				Para.setColGroup(Load.getColGroup());
				Para.setShift(Load.getColShift());

				if (Load.getTestingType().equals("")) {
					core.setV_errMsg("探伤种类不能为空！");
					return core;
				}

				if (Load.getTestingGrade().equals("")
						&& !Load.getTestingType().equals("MT")) {
					core.setV_errMsg("探伤等级不能为空！");
					return core;
				}

				// 获取热处理计划实体了
				PlnZyRclMEntity pln = PlanService.getSendHttPlanCInfo(
						connection, Load.getHeatPlanNo());

				SimpleDateFormat matter2 = new SimpleDateFormat("yyyyMMddHHmm");
				SimpleDateFormat matter3 = new SimpleDateFormat("yyyyMM");
				SimpleDateFormat matter4 = new SimpleDateFormat("yyyyMMdd");

				Date colDate = GetDateByStr(Load.getColTime());
				Date colEndDate = GetDateByStr(Load.getColEndTime());

				if (colDate.after(colEndDate)) {
					core.setV_errMsg("结束时间不能早于开始时间");
					return core;
				}

				if (pln == null)
					return core;
				if (pln.getPlanstatus().equals("30")) {
					core.setV_errMsg("炉计划已经生产完成,请先撤销下线结炉！");
					return core;
				}

				if (pln.getPlanstatus().equals("40")) {
					core.setV_errMsg("该计划已关闭，请撤销申请判定！");
					return core;
				}

				if (Load.getReportNo().equals("0")) {

					if (Integer.parseInt(Load.getEpassNum())
							+ Integer.parseInt(Load.getEwasteNum())
							+ Integer.parseInt(Load.getPendingNum()) != Integer
							.parseInt(Load.getTestingNum())) {
						core.setV_errMsg("最终合格支数+最终废品支数+待判支数不等于检测支数,请检查!");
						return core;
					}

					if (Integer.parseInt(Load.getPassNum())
							+ Integer.parseInt(Load.getDubiousNum()) != Integer
							.parseInt(Load.getTestingNum())) {
						core.setV_errMsg("合格支数+可疑品支数不等于检测支数,请检查!");
						return core;
					}

					// if(Integer.parseInt(load.getFpassNum())
					// +Integer.parseInt(load.getEwasteNum()) !=
					// Integer.parseInt(load.getDubiousNum())){

					if (Integer.parseInt(Load.getFpassNum())
							+ Integer.parseInt(Load.getEwasteNum())
							+ Integer.parseInt(Load.getPendingNum()) != Integer
							.parseInt(Load.getDubiousNum())) {
						core.setV_errMsg("复探合格支数+最终废品支数 + 待判支数不等于可疑品支数,请检查!");
						return core;
					}
				}

				// endregion

				int count = 0;
				int detCount = 0;

				if (StringTool.isInteger(Load.getEwasteNum())) {
					detCount += Integer.parseInt(Load.getEwasteNum());
				}
				if (StringTool.isInteger(Load.getEwasteNumEt())) {
					detCount += Integer.parseInt(Load.getEwasteNumEt());
				}
				if (StringTool.isInteger(Load.getRejectNum())) {
					detCount += Integer.parseInt(Load.getRejectNum());
				}
				if (StringTool.isInteger(Load.getTestingNum())) {
					count = Integer.parseInt(Load.getTestingNum());
				}

				if (count <= 0) {
					core.setV_errMsg("请输入正确的探伤支数！");
					return core;
				}

				if (count < detCount) {
					core.setV_errMsg("废品支数不能大于探伤支数！");
					return core;
				}

				String sql = "";
				String resultNo = "";
				Date dt = new Date();
				String sqlloading = CoreXmlSqlParsersFactory
						.getSql("FrmHttCrackDetectResult.queryLoadRESULT");// 查询最大实绩编号
				psta = connection.prepareStatement(sqlloading);
				psta.setObject(1, pln.getPlineCode() + gx + matter1.format(dt));
				psta.setObject(2, pln.getPlineCode() + gx + matter1.format(dt));

				ResultSet rs1 = psta.executeQuery();
				if (rs1.next()) {
					resultNo = rs1.getString("RESULT_NO");
				}
				rs1.close();
				psta.close();

				String sqlAdd = CoreXmlSqlParsersFactory
						.getSql("FrmHttCrackDetectResult.AddCrackDetection");// 新增探伤
				Load.setZyBatchId(pln.getZyBatchId());
				Load.setProPlanId(pln.getProPlanId());
				Load.setGxPlanNo(pln.getGxPlanNo());
				Load.setResultNo(resultNo);
				sqlAdd = com.steering.common.EntityTool.fillSqlByEntity(sqlAdd,
						Load);
				PreparedStatement patAdd = connection.prepareStatement(sqlAdd);
				patAdd.addBatch();

				String ProbeID = "";
				if (ProbeString.size() > 0) {
					sql = CoreXmlSqlParsersFactory
							.getSql("FrmHttCrackDetectResult.getMaxProbeId");
					psta = connection.prepareStatement(sql);
					psta
							.setObject(1, pln.getJudgeStoveNo()
									+ Load.getBatchNo());
					psta
							.setObject(2, pln.getJudgeStoveNo()
									+ Load.getBatchNo());

					rs1 = psta.executeQuery();
					if (rs1.next()) {
						ProbeID = rs1.getString("PROBE_ID");
					}
					rs1.close();
					psta.close();

				}

				String StandID = "";

				if (StandString.size() > 0) {
					sql = CoreXmlSqlParsersFactory
							.getSql("FrmHttCrackDetectResult.getMaxStandID");
					psta = connection.prepareStatement(sql);
					psta
							.setObject(1, pln.getJudgeStoveNo()
									+ Load.getBatchNo());
					psta
							.setObject(2, pln.getJudgeStoveNo()
									+ Load.getBatchNo());

					rs1 = psta.executeQuery();
					if (rs1.next()) {
						StandID = rs1.getString("STANDARD_ID");
					}
					rs1.close();
					psta.close();

				}

				String sqlAddPara = CoreXmlSqlParsersFactory
						.getSql("FrmHttCrackDetectResult.AddCrackDetectionPara");
				Para.setResultNo(resultNo);
				Para.setReportNo(Load.getReportNo());
				Para.setProbeId(ProbeID);
				Para.setStandardId(StandID);
				Para.setHeatPlanNo(pln.getHeatPlanNo());
				Para.setBatchNo(Load.getBatchNo());
				Para.setJudgeStoveNo(pln.getJudgeStoveNo());
				Para.setShift(Load.getColShift());
				Para.setProDate(Load.getColTime());
				Para.setColGroup(Load.getColGroup());
				sqlAddPara = com.steering.common.EntityTool.fillSqlByEntity(
						sqlAddPara, Para);
				PreparedStatement patAddPara = connection
						.prepareStatement(sqlAddPara);
				patAddPara.addBatch();
				patAddPara.executeBatch();
				patAddPara.close();

				for (int i = 0; i < ProbeString.size(); i++) {
					HttCrackDetectionProbeEntity probeEntity = EntityTool
							.getEntityByJSONStr(ProbeString.get(i),
									HttCrackDetectionProbeEntity.class);

					String sqlAddProbe = CoreXmlSqlParsersFactory
							.getSql("FrmHttCrackDetectResult.AddCrackDetectionProbe");
					probeEntity.setProbeId(ProbeID);
					probeEntity.setProbeSeq((i + 1) + "");
					sqlAddProbe = com.steering.common.EntityTool
							.fillSqlByEntity(sqlAddProbe, probeEntity);
					PreparedStatement patAddProbe = connection
							.prepareStatement(sqlAddProbe);
					patAddProbe.addBatch();
					patAddProbe.executeBatch();
					patAddProbe.close();
				}

				for (int i = 0; i < StandString.size(); i++) {
					HttCrackDetectionStandardEntity probeEntity = EntityTool
							.getEntityByJSONStr(StandString.get(i),
									HttCrackDetectionStandardEntity.class);

					String sqlAddStand = CoreXmlSqlParsersFactory
							.getSql("FrmHttCrackDetectResult.AddCrackDetectionStandard");
					probeEntity.setStandardId(StandID);
					probeEntity.setStandardSeq((i + 1) + "");
					sqlAddStand = com.steering.common.EntityTool
							.fillSqlByEntity(sqlAddStand, probeEntity);
					PreparedStatement patAddStand = connection
							.prepareStatement(sqlAddStand);
					patAddStand.addBatch();
					patAddStand.executeBatch();
					patAddStand.close();
				}

				// 新增探伤公共信息
				patsPlan.setObject(1, resultNo);
				patsPlan.setObject(2, pln.getZyBatchId());
				// patsPlan.setObject(3, pln.getProdIndex());
				patsPlan.setObject(3, pln.getProPlanId());
				patsPlan.setObject(4, pln.getGxPlanNo());
				patsPlan.setObject(5, pln.getOrderSource());
				patsPlan.setObject(6, pln.getOrderNo());
				patsPlan.setObject(7, pln.getOrderSeq());
				patsPlan.setObject(8, pln.getReqBlId());
				patsPlan.setObject(9, pln.getPlineCode());
				patsPlan.setObject(10, pln.getPlineName());
				patsPlan.setObject(11, gx);
				patsPlan.setObject(12, "探伤");
				patsPlan.setObject(13, pln.getGradecode());
				patsPlan.setObject(14, pln.getGradename());
				patsPlan.setObject(15, pln.getSteelcode());
				patsPlan.setObject(16, pln.getSteelname());
				patsPlan.setObject(17, pln.getOutdiameterIn());
				patsPlan.setObject(18, pln.getWallthickIn());
				patsPlan.setObject(19, "");
				patsPlan.setObject(20, "");
				patsPlan.setObject(21, "");
				patsPlan.setObject(22, "");
				patsPlan.setObject(23, "");
				patsPlan.setObject(24, "");
				patsPlan.setObject(25, "");
				patsPlan.setObject(26, "");
				patsPlan.setObject(27, pln.getOutwlId());
				patsPlan.setObject(28, pln.getOutwlDesc());
				patsPlan.setObject(29, pln.getInwlId());
				patsPlan.setObject(30, pln.getInwlDesc());
				patsPlan.setObject(31, pln.getMonitorPoint());
				patsPlan.setObject(32, "");
				patsPlan.setObject(33, pln.getPrdcrNo());
				patsPlan.setObject(34, "");
				patsPlan.setObject(35, "");
				patsPlan.setObject(36, pln.getStationRoad());
				patsPlan.setObject(37, pln.getCraftFileNo());
				patsPlan.setObject(38, pln.getCraftFileMan());
				patsPlan.setObject(39, pln.getCraftSeq());
				patsPlan.setObject(40, Load.getTestingNum());
				patsPlan.setObject(41, Load.getTestingWt());
				patsPlan.setObject(42, detCount);
				patsPlan.setObject(43, resultNo);
				patsPlan.setObject(44, "");
				patsPlan.setObject(45, "");
				patsPlan.setObject(46, "");
				patsPlan.setObject(47, "");
				patsPlan.setObject(48, "1");
				patsPlan.setObject(49, Load.getColTime());
				patsPlan.setObject(50, "");
				patsPlan.setObject(51, Load.getColUser());
				patsPlan.setObject(52, Load.getColShift());
				patsPlan.setObject(53, Load.getColGroup());
				patsPlan.setObject(54, "1");
				patsPlan.setObject(55, systime);
				patsPlan.setObject(56, "");
				patsPlan.setObject(57, Load.getHeatPlanNo());
				patsPlan.setObject(58, pln.getJudgeStoveNo());
				patsPlan.setObject(59, pln.getBatchNo());
				patsPlan.setObject(60, "");
				patsPlan.setObject(61, pln.getProduccode());
				patsPlan.setObject(62, pln.getProducname());
				patsPlan.setObject(63, pln.getSpecCode());
				patsPlan.setObject(64, pln.getSpecName());
				patsPlan.setObject(65, Load.getProcessSeq());
				patsPlan.addBatch();

				patupdate.setObject(1, "80");
				patupdate.setObject(2, Load.getHeatPlanNo());
				patupdate.addBatch();
				patupdate.executeBatch();
				patupdate.close();

				String sqlAddHead = CoreXmlSqlParsersFactory
						.getSql("FrmHttCrackDetectResult.AddCrackHead");// 新增探伤
				PreparedStatement patAddHead = connection
						.prepareStatement(sqlAddHead);
				patAddHead.setObject(1, resultNo);
				patAddHead.setObject(2, Load.getBatchNo());
				patAddHead.setObject(3, Load.getHeatPlanNo());
				patAddHead.addBatch();

				patAddHead.executeBatch();

				patAdd.executeBatch();
				patsPlan.executeBatch();

				patAddHead.close();

				patAdd.close();
				patsPlan.close();

				FrmHttBugD.AddHttWaste(connection, Load.getHeatPlanNo(),
						resultNo, pln.getPlineCode(), Load.getColUser(), Load
								.getProcessSeq(), gx, SuspiciousList,
						ScrappedList, UnpassList);

				String addHttControlLog = CoreXmlSqlParsersFactory
						.getSql("HeatTreatmentService.addHttControlLog"); // 增加调度日志
				// 仅探伤才增加
				PreparedStatement pastaddHttControlLog = connection
						.prepareStatement(addHttControlLog);

				if (pln.getProcessCodeC().equals("B024")) {

					Date procDate = colDate;
					if (Load.getColShift().equals("3")) {
						Calendar date = Calendar.getInstance();
						date.setTime(colDate);
						date.set(Calendar.HOUR_OF_DAY, date
								.get(Calendar.HOUR_OF_DAY) + 12);
						procDate = dateFormat.parse(dateFormat.format(date
								.getTime()));
					}

					if (Load.getTestingPosition().equals("0")) {
						pastaddHttControlLog.setObject(1, matter2.format(colDate));
						pastaddHttControlLog.setObject(2, matter2
								.format(colEndDate));
						pastaddHttControlLog.setObject(3, resultNo);
						// patAdd.setObject(3, pln.getProdIndex());
						pastaddHttControlLog.setObject(4, Load.getColShift());
						pastaddHttControlLog.setObject(5, Load.getColGroup());
						pastaddHttControlLog.setObject(6, Load.getTestingNum());
						pastaddHttControlLog.setObject(7, Load.getTestingWt());
						pastaddHttControlLog.setObject(8, systime);
						pastaddHttControlLog.setObject(9, Load.getColUser());
						pastaddHttControlLog
								.setObject(10, matter3.format(procDate));
						pastaddHttControlLog
								.setObject(11, matter4.format(procDate));
						pastaddHttControlLog.setObject(12, "1");
						pastaddHttControlLog.setObject(13, Load.getHeatPlanNo());
						pastaddHttControlLog.addBatch();
						pastaddHttControlLog.executeBatch();
						pastaddHttControlLog.close();
					}
					
				}
			}

			core.setV_errMsg("新增探伤成功！");
			core.setResult(1);
			connection.commit();
		} catch (Exception e) {
			core.setV_errMsg(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return core;
	}

	/**
	 * 保存
	 * 
	 * @param load
	 * @return
	 */
	public CoreReturnObject saveCrackDetection(String loadStr,
			String crackDetectionPatameter1, ArrayList<String> ProbeString1,
			ArrayList<String> StandString1, String crackDetectionPatameter2,
			ArrayList<String> ProbeString2, ArrayList<String> StandString2,
			String crackDetectionPatameter3, ArrayList<String> ProbeString3,
			ArrayList<String> StandString3, String PlanNo, String slgx,
			ArrayList<String> list1Str, ArrayList<String> list2Str,
			ArrayList<String> list3Str) {
		CoreReturnObject core = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		PreparedStatement psta = null;
		Date dt = new Date();
		SimpleDateFormat matter1 = new SimpleDateFormat("yyMMdd");
		SimpleDateFormat matter = new SimpleDateFormat("yyyy-MM-dd");

		Calendar ca = Calendar.getInstance();
		ca.set(Calendar.DATE, ca.getActualMaximum(Calendar.DATE));
		Date now = new Date();
		SimpleDateFormat dateFormat = new SimpleDateFormat(
				"yyyy-MM-dd HH:mm:ss", Locale.CHINA);
		SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm",
				Locale.CHINA);
		String systime = dateFormat.format(now);
		try {
			connection.setAutoCommit(false); // 取消自动提交事务

			String sqlupdate = CoreXmlSqlParsersFactory
					.getSql("AppearanceService.updatePlnZyRclM");// 修改热处理计划表
			PreparedStatement patupdate = connection
					.prepareStatement(sqlupdate);
			String addPlnInfo = CoreXmlSqlParsersFactory
					.getSql("HttLoadingService.AddComInfoResult");// 新增公共信息
			PreparedStatement patsPlan = connection
					.prepareStatement(addPlnInfo);
			String addPlnInfo1 = CoreXmlSqlParsersFactory
					.getSql("HeatTreatmentService.AddComInfoResult1");// 修改队列表材料，工序状态
			PreparedStatement patsPlan1 = connection
					.prepareStatement(addPlnInfo1);
			String updatePath = CoreXmlSqlParsersFactory
					.getSql("FrmHttCrackDetectResult.UpdatePath");// 修改队列表工艺路径
			PreparedStatement pastupdatePath = connection
					.prepareStatement(updatePath);

			String addHttControlLog = CoreXmlSqlParsersFactory
					.getSql("HeatTreatmentService.addHttControlLog"); // 增加调度日志
			// 仅探伤才增加
			PreparedStatement pastaddHttControlLog = connection
					.prepareStatement(addHttControlLog);

			HttCrackDetectionEtEntity load = EntityTool.getEntityByJSONStr(
					loadStr, HttCrackDetectionEtEntity.class);

			HttCrackDetectionParaEntity Para1 = ""
					.equals(crackDetectionPatameter1) ? null : EntityTool
					.getEntityByJSONStr(crackDetectionPatameter1,
							HttCrackDetectionParaEntity.class);
			HttCrackDetectionParaEntity Para2 = ""
					.equals(crackDetectionPatameter2) ? null : EntityTool
					.getEntityByJSONStr(crackDetectionPatameter2,
							HttCrackDetectionParaEntity.class);
			HttCrackDetectionParaEntity Para3 = ""
					.equals(crackDetectionPatameter3) ? null : EntityTool
					.getEntityByJSONStr(crackDetectionPatameter3,
							HttCrackDetectionParaEntity.class);

			load.setProcessCode("F");

			if ("".equals(crackDetectionPatameter1)) {
				load.setPassNum("0");
				load.setDubiousNum("0");
				load.setFtestingNum("0");
				load.setFpassNum("0");
				load.setEwasteNum("0");
				load.setEpassNum("0");
				load.setTestingTime("0");

			} else {
				load.setTestingType("UT");
				load.setReportNo("0");
				if (Para1.getLongitudinalExternal().equals("")) {
					core.setV_errMsg("请输入探伤等级");
					return core;
				}
				load.setTestingPosition("0");
				load.setTestingGrade(Para1.getLongitudinalExternal());

				if (load.getTestingStandard().equals("")) {
					if (!Para1.getStandardDefect().equals("")
							&& !Para1.getStandardDefect().equals("/")) {
						load.setTestingStandard((load.getTestingStandard()
								.equals("") ? ""
								: (load.getTestingStandard() + ";"))
								+ Para1.getStandardDefect());
					}

					if (!Para1.getStandardWall().equals("")
							&& !Para1.getStandardWall().equals("/")) {
						load.setTestingStandard((load.getTestingStandard()
								.equals("") ? ""
								: (load.getTestingStandard() + ";"))
								+ Para1.getStandardWall());
					}

					if (!Para1.getStandardLam().equals("")
							&& !Para1.getStandardLam().equals("/")) {
						load.setTestingStandard((load.getTestingStandard()
								.equals("") ? ""
								: (load.getTestingStandard() + ";"))
								+ Para1.getStandardLam());
					}

					if (!Para1.getStandardOblique().equals("")
							&& !Para1.getStandardOblique().equals("/")) {
						load.setTestingStandard((load.getTestingStandard()
								.equals("") ? ""
								: (load.getTestingStandard() + ";"))
								+ Para1.getStandardOblique());
					}
				}
			}

			if ("".equals(crackDetectionPatameter2)) {
				load.setManualFtestingNum("0");
				load.setManualPassNum("0");
				load.setRejectedNum("0");
				load.setRejectNum("0");
				load.setFinalNum("0");

			} else {
				load.setReportNo("1");
				load.setTestingType("UT");
				if (Para2.getLongitudinalExternal().equals("")) {
					core.setV_errMsg("请输入探伤等级");
					return core;
				}
				load.setTestingPosition("1");
				load.setTestingGrade(Para2.getLongitudinalExternal());

				if (load.getTestingStandard().equals("")) {
					if (!Para2.getStandardDefect().equals("")
							&& !Para2.getStandardDefect().equals("/")) {
						load.setTestingStandard((load.getTestingStandard()
								.equals("") ? ""
								: (load.getTestingStandard() + ";"))
								+ Para2.getStandardDefect());
					}

					if (!Para2.getStandardWall().equals("")
							&& !Para2.getStandardWall().equals("/")) {
						load.setTestingStandard((load.getTestingStandard()
								.equals("") ? ""
								: (load.getTestingStandard() + ";"))
								+ Para2.getStandardWall());
					}

					if (!Para2.getStandardLam().equals("")
							&& !Para2.getStandardLam().equals("/")) {
						load.setTestingStandard((load.getTestingStandard()
								.equals("") ? ""
								: (load.getTestingStandard() + ";"))
								+ Para2.getStandardLam());
					}

					if (!Para2.getStandardOblique().equals("")
							&& !Para2.getStandardOblique().equals("/")) {
						load.setTestingStandard((load.getTestingStandard()
								.equals("") ? ""
								: (load.getTestingStandard() + ";"))
								+ Para2.getStandardOblique());
					}
				}
			}

			if ("".equals(crackDetectionPatameter3)) {
				load.setPassNumEt("0");
				load.setDubiousNumEt("0");
				load.setFtestingNumEt("0");
				load.setFpassNumEt("0");
				load.setEwasteNumEt("0");
				load.setEpassNumEt("0");

			} else {
				load.setTestingType("ET");
				load.setReportNo("4");

				if (Para3.getAccpetanceLevel().equals("")) {
					core.setV_errMsg("请输入等级");
					return core;
				}
				load.setTestingPosition("1`");

				load.setTestingGrade(Para3.getAccpetanceLevel());

				if (load.getTestingStandard().equals("")) {
					if (!Para2.getStandardDefect().equals("")
							&& !Para2.getStandardDefect().equals("/")) {
						load.setTestingStandard((load.getTestingStandard()
								.equals("") ? ""
								: (load.getTestingStandard() + ";"))
								+ Para2.getStandardDefect());
					}
				}
			}

			if (load.getMachineNo().equals(""))
				load.setMachineNo("1");

			load.setColUser(Para1 != null ? Para1.getOperatorName()
					: Para2 != null ? Para2.getOperatorName() : Para3
							.getOperatorName());

			// 获取热处理计划实体了
			PlnZyRclMEntity pln = PlanService.getSendHttPlanCInfo(connection,
					PlanNo);

			SimpleDateFormat matter2 = new SimpleDateFormat("yyyyMMddHHmm");
			SimpleDateFormat matter3 = new SimpleDateFormat("yyyyMM");
			SimpleDateFormat matter4 = new SimpleDateFormat("yyyyMMdd");

			Date colDate = load.getColTime().length() == 17 ? dateFormat1
					.parse(load.getColTime()) : dateFormat.parse(load
					.getColTime());
			Date colEndDate = load.getColEndTime().length() == 17 ? dateFormat1
					.parse(load.getColEndTime()) : dateFormat.parse(load
					.getColEndTime());

			if (colDate.after(colEndDate)) {
				core.setV_errMsg("结束时间不能早于开始时间");
				return core;
			}

			if (pln == null)
				return core;
			if (pln.getPlanstatus().equals("3")) {
				core.setV_errMsg("该计划已关闭！");
				return core;
			}
			String ifMonitNo = "";
			if (pln.getIfMonitor().equals("是")) {
				ifMonitNo = "1";
			} else {
				ifMonitNo = "0";
			}

			load.setJudgeStoveNo(pln.getJudgeStoveNo());

			String cutFalg = "";
			String sql = CoreXmlSqlParsersFactory
					.getSql("HttLoadingService.qureyGxComInfo");// 查询工序是否是结炉状态
			psta = connection.prepareStatement(sql);
			psta.setString(1, load.getHeatPlanNo());
			// psta.setString(2, load.getPlineCode());
			psta.setString(2, slgx);
			psta.setObject(3, pln.getRealProcessSeq());
			ResultSet rs = psta.executeQuery();
			if (rs.next()) {
				cutFalg = rs.getString("STATION_STATUS");
			}
			if (cutFalg.equals("2")) {
				core.setV_errMsg("已结炉,不允许此操作！");
				return core;
			}
			rs.close();
			psta.close();

			int ProNum = 0;
			int FailNum = 0;

			if (StringTool.isInteger(load.getTestingNum())) {
				ProNum = Integer.parseInt(load.getTestingNum());

			}

			if (StringTool.isInteger(load.getEwasteNum())) {
				FailNum = Integer.parseInt(load.getEwasteNum());
			}

			if (ProNum <= 0) {
				core.setV_errMsg("检查支数不能为0！");
				return core;
			}

			if (ProNum < FailNum) {
				core.setV_errMsg("作业支数不能小于废品支数！");
				return core;
			}

			String resultNo = "";
			String sqlloading = CoreXmlSqlParsersFactory
					.getSql("FrmHttCrackDetectResult.queryLoadRESULT");// 查询最大实绩编号
			psta = connection.prepareStatement(sqlloading);
			psta.setObject(1, pln.getPlineCode() + slgx + matter1.format(dt));
			psta.setObject(2, pln.getPlineCode() + slgx + matter1.format(dt));

			ResultSet rs1 = psta.executeQuery();
			if (rs1.next()) {
				resultNo = rs1.getString("RESULT_NO");
			}
			rs1.close();
			psta.close();

			String sqlAdd = CoreXmlSqlParsersFactory
					.getSql("FrmHttCrackDetectResult.AddCrackDetection");// 新增探伤

			load.setResultNo(resultNo);
			load.setZyBatchId(pln.getZyBatchId());
			load.setProPlanId(pln.getProPlanId());
			load.setGxPlanNo(pln.getGxPlanNo());
			load.setPlineCode(pln.getPlineCode());
			load.setPlineName(pln.getPlineName());
			sqlAdd = com.steering.common.EntityTool.fillSqlByEntity(sqlAdd,
					load);
			PreparedStatement patAdd = connection.prepareStatement(sqlAdd);
			patAdd.addBatch();

			String sqlAddHead = CoreXmlSqlParsersFactory
					.getSql("FrmHttCrackDetectResult.AddCrackHead");// 新增探伤
			PreparedStatement patAddHead = connection
					.prepareStatement(sqlAddHead);
			patAddHead.setObject(1, resultNo);
			patAddHead.setObject(2, load.getBatchNo());
			patAddHead.setObject(3, PlanNo);
			patAddHead.addBatch();

			// 新增探伤公共信息
			patsPlan.setObject(1, resultNo);
			patsPlan.setObject(2, pln.getZyBatchId());
			// patsPlan.setObject(3, pln.getProdIndex());
			patsPlan.setObject(3, pln.getProPlanId());
			patsPlan.setObject(4, pln.getGxPlanNo());
			patsPlan.setObject(5, pln.getOrderSource());
			patsPlan.setObject(6, pln.getOrderNo());
			patsPlan.setObject(7, pln.getOrderSeq());
			patsPlan.setObject(8, pln.getReqBlId());
			patsPlan.setObject(9, pln.getPlineCode());
			patsPlan.setObject(10, pln.getPlineName());
			patsPlan.setObject(11, slgx);
			patsPlan.setObject(12, "探伤");
			patsPlan.setObject(13, pln.getGradecode());
			patsPlan.setObject(14, pln.getGradename());
			patsPlan.setObject(15, pln.getSteelcode());
			patsPlan.setObject(16, pln.getSteelname());
			patsPlan.setObject(17, pln.getOutdiameterIn());
			patsPlan.setObject(18, pln.getWallthickIn());
			patsPlan.setObject(19, "");
			patsPlan.setObject(20, "");
			patsPlan.setObject(21, "");
			patsPlan.setObject(22, "");
			patsPlan.setObject(23, "");
			patsPlan.setObject(24, "");
			patsPlan.setObject(25, "");
			patsPlan.setObject(26, "");
			patsPlan.setObject(27, pln.getOutwlId());
			patsPlan.setObject(28, pln.getOutwlDesc());
			patsPlan.setObject(29, pln.getInwlId());
			patsPlan.setObject(30, pln.getInwlDesc());
			patsPlan.setObject(31, pln.getMonitorPoint());
			patsPlan.setObject(32, ifMonitNo);
			patsPlan.setObject(33, pln.getPrdcrNo());
			patsPlan.setObject(34, "");
			patsPlan.setObject(35, "");
			patsPlan.setObject(36, pln.getStationRoad());
			patsPlan.setObject(37, pln.getCraftFileNo());
			patsPlan.setObject(38, pln.getCraftFileMan());
			patsPlan.setObject(39, pln.getCraftSeq());
			patsPlan.setObject(40, load.getTestingNum());
			patsPlan.setObject(41, load.getTestingWt());
			patsPlan.setObject(42, load.getEwasteNum());
			patsPlan.setObject(43, resultNo);
			patsPlan.setObject(44, "");
			patsPlan.setObject(45, "");
			patsPlan.setObject(46, "");
			patsPlan.setObject(47, "");
			patsPlan.setObject(48, "1");
			patsPlan.setObject(49, load.getColTime());
			patsPlan.setObject(50, "");
			patsPlan.setObject(51, load.getColUser());
			patsPlan.setObject(52, load.getColShift());
			patsPlan.setObject(53, load.getColGroup());
			patsPlan.setObject(54, "1");
			patsPlan.setObject(55, systime);
			patsPlan.setObject(56, "");
			patsPlan.setObject(57, load.getHeatPlanNo());
			patsPlan.setObject(58, pln.getJudgeStoveNo());
			patsPlan.setObject(59, pln.getBatchNo());
			patsPlan.setObject(60, "");
			patsPlan.setObject(61, pln.getProduccode());
			patsPlan.setObject(62, pln.getProducname());
			patsPlan.setObject(63, pln.getSpecCode());
			patsPlan.setObject(64, pln.getSpecName());
			patsPlan.setObject(65, load.getProcessSeq());
			patsPlan.addBatch();

			FrmHttBugD.AddHttWaste(connection, load.getHeatPlanNo(), resultNo,
					pln.getPlineCode(), load.getColUser(),
					load.getProcessSeq(), slgx, list1Str, list2Str, list3Str);

			patAddHead.executeBatch();
			patAdd.executeBatch();
			patsPlan.executeBatch();

			if (Para1 != null) {

				/*
				 * 1、【最终合格支数+最终废品支数+待判支数=检测支数】 2、【合格支数+可疑品支数=检测支数】
				 * 3、【复探合格支数+最终废品支数=可疑品支数】
				 */

				if (Integer.parseInt(load.getEpassNum())
						+ Integer.parseInt(load.getEwasteNum())
						+ Integer.parseInt(load.getPendingNum()) != Integer
						.parseInt(load.getTestingNum())) {
					core.setV_errMsg("最终合格支数+最终废品支数+待判支数不等于检测支数,请检查!");
					return core;
				}

				if (Integer.parseInt(load.getPassNum())
						+ Integer.parseInt(load.getDubiousNum()) != Integer
						.parseInt(load.getTestingNum())) {
					core.setV_errMsg("合格支数+可疑品支数不等于检测支数,请检查!");
					return core;
				}

				// if(Integer.parseInt(load.getFpassNum())
				// +Integer.parseInt(load.getEwasteNum()) !=
				// Integer.parseInt(load.getDubiousNum())){

				if (Integer.parseInt(load.getFpassNum())
						+ Integer.parseInt(load.getEwasteNum())
						+ Integer.parseInt(load.getPendingNum()) != Integer
						.parseInt(load.getDubiousNum())) {
					core.setV_errMsg("复探合格支数+最终废品支数 + 待判支数不等于可疑品支数,请检查!");
					return core;
				}
				// }

				String ProbeID = "";
				if (ProbeString1.size() > 0) {
					sql = CoreXmlSqlParsersFactory
							.getSql("FrmHttCrackDetectResult.getMaxProbeId");
					psta = connection.prepareStatement(sql);
					psta
							.setObject(1, pln.getJudgeStoveNo()
									+ load.getBatchNo());
					psta
							.setObject(2, pln.getJudgeStoveNo()
									+ load.getBatchNo());

					rs1 = psta.executeQuery();
					if (rs1.next()) {
						ProbeID = rs1.getString("PROBE_ID");
					}
					rs1.close();
					psta.close();

				}

				String StandID = "";

				if (StandString1.size() > 0) {
					sql = CoreXmlSqlParsersFactory
							.getSql("FrmHttCrackDetectResult.getMaxStandID");
					psta = connection.prepareStatement(sql);
					psta
							.setObject(1, pln.getJudgeStoveNo()
									+ load.getBatchNo());
					psta
							.setObject(2, pln.getJudgeStoveNo()
									+ load.getBatchNo());

					rs1 = psta.executeQuery();
					if (rs1.next()) {
						StandID = rs1.getString("STANDARD_ID");
					}
					rs1.close();
					psta.close();

				}
				if (load.getBatchNo() == null || load.getBatchNo().equals("")) {
					core.setV_errMsg("请先分批再探伤!");
					return core;
				}

				String sqlAddPara = CoreXmlSqlParsersFactory
						.getSql("FrmHttCrackDetectResult.AddCrackDetectionPara");
				Para1.setResultNo(resultNo);
				Para1.setReportNo("0");
				Para1.setProbeId(ProbeID);
				Para1.setStandardId(StandID);
				Para1.setHeatPlanNo(pln.getHeatPlanNo());
				Para1.setBatchNo(load.getBatchNo());
				Para1.setJudgeStoveNo(pln.getJudgeStoveNo());
				Para1.setShift(load.getColShift());
				Para1.setProDate(load.getColTime());
				Para1.setColGroup(load.getColGroup());
				sqlAddPara = com.steering.common.EntityTool.fillSqlByEntity(
						sqlAddPara, Para1);
				PreparedStatement patAddPara = connection
						.prepareStatement(sqlAddPara);
				patAddPara.addBatch();
				patAddPara.executeBatch();

				for (int i = 0; i < ProbeString1.size(); i++) {
					HttCrackDetectionProbeEntity probeEntity = EntityTool
							.getEntityByJSONStr(ProbeString1.get(i),
									HttCrackDetectionProbeEntity.class);

					String sqlAddProbe = CoreXmlSqlParsersFactory
							.getSql("FrmHttCrackDetectResult.AddCrackDetectionProbe");
					probeEntity.setProbeId(ProbeID);
					probeEntity.setProbeSeq((i + 1) + "");
					sqlAddProbe = com.steering.common.EntityTool
							.fillSqlByEntity(sqlAddProbe, probeEntity);
					PreparedStatement patAddProbe = connection
							.prepareStatement(sqlAddProbe);
					patAddProbe.addBatch();
					patAddProbe.executeBatch();
				}

				for (int i = 0; i < StandString1.size(); i++) {
					HttCrackDetectionStandardEntity probeEntity = EntityTool
							.getEntityByJSONStr(StandString1.get(i),
									HttCrackDetectionStandardEntity.class);

					String sqlAddStand = CoreXmlSqlParsersFactory
							.getSql("FrmHttCrackDetectResult.AddCrackDetectionStandard");
					probeEntity.setStandardId(StandID);
					probeEntity.setStandardSeq((i + 1) + "");
					sqlAddStand = com.steering.common.EntityTool
							.fillSqlByEntity(sqlAddStand, probeEntity);
					PreparedStatement patAddStand = connection
							.prepareStatement(sqlAddStand);
					patAddStand.addBatch();
					patAddStand.executeBatch();
				}
			}

			if (Para2 != null) {

				String ProbeID2 = "";
				if (ProbeString2.size() > 0) {
					sql = CoreXmlSqlParsersFactory
							.getSql("FrmHttCrackDetectResult.getMaxProbeId");
					psta = connection.prepareStatement(sql);
					psta
							.setObject(1, pln.getJudgeStoveNo()
									+ load.getBatchNo());
					psta
							.setObject(2, pln.getJudgeStoveNo()
									+ load.getBatchNo());

					rs1 = psta.executeQuery();
					if (rs1.next()) {
						ProbeID2 = rs1.getString("PROBE_ID");
					}
					rs1.close();
					psta.close();

				}

				String StandID2 = "";

				if (StandString2.size() > 0) {
					sql = CoreXmlSqlParsersFactory
							.getSql("FrmHttCrackDetectResult.getMaxStandID");
					psta = connection.prepareStatement(sql);
					psta
							.setObject(1, pln.getJudgeStoveNo()
									+ load.getBatchNo());
					psta
							.setObject(2, pln.getJudgeStoveNo()
									+ load.getBatchNo());

					rs1 = psta.executeQuery();
					if (rs1.next()) {
						StandID2 = rs1.getString("STANDARD_ID");
					}
					rs1.close();
					psta.close();

				}
				if (load.getBatchNo() == null || load.getBatchNo().equals("")) {
					core.setV_errMsg("请先分批再探伤!");
					return core;
				}
				String sqlAddPara2 = CoreXmlSqlParsersFactory
						.getSql("FrmHttCrackDetectResult.AddCrackDetectionPara");
				Para2.setResultNo(resultNo);
				Para2.setReportNo("1");
				Para2.setProbeId(ProbeID2);
				Para2.setStandardId(StandID2);
				Para2.setHeatPlanNo(pln.getHeatPlanNo());
				Para2.setBatchNo(load.getBatchNo());
				Para2.setJudgeStoveNo(pln.getJudgeStoveNo());
				Para2.setShift(load.getColShift());
				Para2.setProDate(load.getColTime());
				Para2.setColGroup(load.getColGroup());
				sqlAddPara2 = com.steering.common.EntityTool.fillSqlByEntity(
						sqlAddPara2, Para2);
				PreparedStatement patAddPara2 = connection
						.prepareStatement(sqlAddPara2);
				patAddPara2.addBatch();
				patAddPara2.executeBatch();

				for (int i = 0; i < ProbeString2.size(); i++) {
					HttCrackDetectionProbeEntity probeEntity = EntityTool
							.getEntityByJSONStr(ProbeString2.get(i),
									HttCrackDetectionProbeEntity.class);

					String sqlAddProbe = CoreXmlSqlParsersFactory
							.getSql("FrmHttCrackDetectResult.AddCrackDetectionProbe");
					probeEntity.setProbeId(ProbeID2);
					probeEntity.setProbeSeq((i + 1) + "");
					sqlAddProbe = com.steering.common.EntityTool
							.fillSqlByEntity(sqlAddProbe, probeEntity);
					PreparedStatement patAddProbe = connection
							.prepareStatement(sqlAddProbe);
					patAddProbe.addBatch();
					patAddProbe.executeBatch();
				}

				for (int i = 0; i < StandString2.size(); i++) {
					HttCrackDetectionStandardEntity probeEntity = EntityTool
							.getEntityByJSONStr(StandString2.get(i),
									HttCrackDetectionStandardEntity.class);

					String sqlAddStand = CoreXmlSqlParsersFactory
							.getSql("FrmHttCrackDetectResult.AddCrackDetectionStandard");
					probeEntity.setStandardId(StandID2);
					probeEntity.setStandardSeq((i + 1) + "");
					sqlAddStand = com.steering.common.EntityTool
							.fillSqlByEntity(sqlAddStand, probeEntity);
					PreparedStatement patAddStand = connection
							.prepareStatement(sqlAddStand);
					patAddStand.addBatch();
					patAddStand.executeBatch();
				}
			}

			if (Para3 != null) {
				String ProbeID3 = "";
				if (ProbeString3.size() > 0) {
					sql = CoreXmlSqlParsersFactory
							.getSql("FrmHttCrackDetectResult.getMaxProbeId");
					psta = connection.prepareStatement(sql);
					psta
							.setObject(1, pln.getJudgeStoveNo()
									+ load.getBatchNo());
					psta
							.setObject(2, pln.getJudgeStoveNo()
									+ load.getBatchNo());

					rs1 = psta.executeQuery();
					if (rs1.next()) {
						ProbeID3 = rs1.getString("PROBE_ID");
					}
					rs1.close();
					psta.close();

				}

				String StandID3 = "";

				if (StandString3.size() > 0) {
					sql = CoreXmlSqlParsersFactory
							.getSql("FrmHttCrackDetectResult.getMaxStandID");
					psta = connection.prepareStatement(sql);
					psta
							.setObject(1, pln.getJudgeStoveNo()
									+ load.getBatchNo());
					psta
							.setObject(2, pln.getJudgeStoveNo()
									+ load.getBatchNo());

					rs1 = psta.executeQuery();
					if (rs1.next()) {
						StandID3 = rs1.getString("STANDARD_ID");
					}
					rs1.close();
					psta.close();

				}
				if (load.getBatchNo() == null || load.getBatchNo().equals("")) {
					core.setV_errMsg("请先分批再探伤!");
					return core;
				}
				String sqlAddPara = CoreXmlSqlParsersFactory
						.getSql("FrmHttCrackDetectResult.AddCrackDetectionPara");
				Para3.setResultNo(resultNo);
				Para3.setReportNo("4");
				Para3.setProbeId(ProbeID3);
				Para3.setStandardId(StandID3);
				Para3.setHeatPlanNo(pln.getHeatPlanNo());
				Para3.setBatchNo(load.getBatchNo());
				Para3.setJudgeStoveNo(pln.getJudgeStoveNo());
				Para3.setShift(load.getColShift());
				Para3.setProDate(load.getColTime());
				Para3.setColGroup(load.getColGroup());
				sqlAddPara = com.steering.common.EntityTool.fillSqlByEntity(
						sqlAddPara, Para3);
				PreparedStatement patAddPara = connection
						.prepareStatement(sqlAddPara);
				patAddPara.addBatch();
				patAddPara.executeBatch();

				for (int i = 0; i < ProbeString3.size(); i++) {
					HttCrackDetectionProbeEntity probeEntity = EntityTool
							.getEntityByJSONStr(ProbeString3.get(i),
									HttCrackDetectionProbeEntity.class);

					String sqlAddProbe = CoreXmlSqlParsersFactory
							.getSql("FrmHttCrackDetectResult.AddCrackDetectionProbe");
					probeEntity.setProbeId(ProbeID3);
					probeEntity.setProbeSeq((i + 1) + "");
					sqlAddProbe = com.steering.common.EntityTool
							.fillSqlByEntity(sqlAddProbe, probeEntity);
					PreparedStatement patAddProbe = connection
							.prepareStatement(sqlAddProbe);
					patAddProbe.addBatch();
					patAddProbe.executeBatch();
				}

				for (int i = 0; i < StandString3.size(); i++) {
					HttCrackDetectionStandardEntity probeEntity = EntityTool
							.getEntityByJSONStr(StandString3.get(i),
									HttCrackDetectionStandardEntity.class);

					String sqlAddStand = CoreXmlSqlParsersFactory
							.getSql("FrmHttCrackDetectResult.AddCrackDetectionStandard");
					probeEntity.setStandardId(StandID3);
					probeEntity.setStandardSeq((i + 1) + "");
					sqlAddStand = com.steering.common.EntityTool
							.fillSqlByEntity(sqlAddStand, probeEntity);
					PreparedStatement patAddStand = connection
							.prepareStatement(sqlAddStand);
					patAddStand.addBatch();
					patAddStand.executeBatch();
				}
			}

			// 修改工艺路径
			pastupdatePath.setObject(1, "1");
			pastupdatePath.setObject(2, load.getHeatPlanNo());
			pastupdatePath.addBatch();
			pastupdatePath.executeBatch();
			// 修改计划表
			patupdate.setObject(1, "80");
			patupdate.setObject(2, load.getHeatPlanNo());
			patupdate.addBatch();
			patupdate.executeBatch();

			if (load.getTestingPosition().equals("0")) {
				// if (pln.getProcessCodeC().equals("B024")) {
				Date procDate = colDate;
				if (load.getColShift().equals("3")) {
					Calendar date = Calendar.getInstance();
					date.setTime(colDate);
					date.set(Calendar.HOUR_OF_DAY, date
							.get(Calendar.HOUR_OF_DAY) + 12);
					procDate = dateFormat.parse(dateFormat.format(date
							.getTime()));
				}
				int acount = 0;
				String sql1 = CoreXmlSqlParsersFactory
						.getSql("FrmHttControlLog.qureyConfirmFlag");// 查询录入时间是否调度已确认.
				psta = connection.prepareStatement(sql1);
				psta.setString(1, matter2.format(colDate));
				psta.setObject(2, matter2.format(colDate));
				psta.setObject(3, matter2.format(colEndDate));
				psta.setObject(4, matter2.format(colEndDate));
				psta.setObject(5, load.getPlineCode());
				psta.setObject(6, "1");
				rs1 = psta.executeQuery();
				if (rs1.next()) {
					acount = Integer.parseInt(rs1.getString("ACOUT"));
				}
				if (acount > 0) {
					core.setV_errMsg("该时间段,调度已确认或已审核,请联系调度取消确认或取消审核!");
					return core;
				}
				rs1.close();
				psta.close();
				pastaddHttControlLog.setObject(1, matter2.format(colDate));
				pastaddHttControlLog.setObject(2, matter2.format(colEndDate));
				pastaddHttControlLog.setObject(3, resultNo);
				// patAdd.setObject(3, pln.getProdIndex());
				pastaddHttControlLog.setObject(4, load.getColShift());
				pastaddHttControlLog.setObject(5, load.getColGroup());
				pastaddHttControlLog.setObject(6, load.getTestingNum());
				pastaddHttControlLog.setObject(7, load.getTestingWt());
				pastaddHttControlLog.setObject(8, systime);
				pastaddHttControlLog.setObject(9, load.getColUser());
				pastaddHttControlLog.setObject(10, com.steering.common.StringTool.GetBalYear(procDate,com.steering.common.StringTool.GetSupplyUnit(load.getPlineCode()))); //改25号结转
				pastaddHttControlLog.setObject(11, matter4.format(procDate));
				pastaddHttControlLog.setObject(12, "1");
				pastaddHttControlLog.setObject(13, PlanNo);
				pastaddHttControlLog.addBatch();
				pastaddHttControlLog.executeBatch();
				// }
			}

			core.setV_errMsg("新增探伤成功！");
			core.setResult(1);
			connection.commit();
		} catch (Exception e) {
			core.setV_errMsg(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return core;
	}

	/**
	 * 批量保存
	 * 
	 * @param load
	 * @return
	 */
	public CoreReturnObject saveCrackDetection(ArrayList<String> loadStrs,
			String crackDetectionPatameter1, ArrayList<String> ProbeString1,
			ArrayList<String> StandString1, String crackDetectionPatameter2,
			ArrayList<String> ProbeString2, ArrayList<String> StandString2,
			String crackDetectionPatameter3, ArrayList<String> ProbeString3,
			ArrayList<String> StandString3, String PlanNo, String slgx,
			ArrayList<String> list1Str, ArrayList<String> list2Str,
			ArrayList<String> list3Str) {
		CoreReturnObject core = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		PreparedStatement psta = null;
		Date dt = new Date();
		SimpleDateFormat matter1 = new SimpleDateFormat("yyMMdd");
		SimpleDateFormat matter = new SimpleDateFormat("yyyy-MM-dd");

		Calendar ca = Calendar.getInstance();
		ca.set(Calendar.DATE, ca.getActualMaximum(Calendar.DATE));
		Date now = new Date();
		SimpleDateFormat dateFormat = new SimpleDateFormat(
				"yyyy-MM-dd HH:mm:ss", Locale.CHINA);
		SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm",
				Locale.CHINA);
		String systime = dateFormat.format(now);
		try {
			connection.setAutoCommit(false); // 取消自动提交事务

			String sqlupdate = CoreXmlSqlParsersFactory
					.getSql("AppearanceService.updatePlnZyRclM");// 修改热处理计划表
			PreparedStatement patupdate = connection
					.prepareStatement(sqlupdate);
			String addPlnInfo = CoreXmlSqlParsersFactory
					.getSql("HttLoadingService.AddComInfoResult");// 新增公共信息
			PreparedStatement patsPlan = connection
					.prepareStatement(addPlnInfo);
			String addPlnInfo1 = CoreXmlSqlParsersFactory
					.getSql("HeatTreatmentService.AddComInfoResult1");// 修改队列表材料，工序状态
			PreparedStatement patsPlan1 = connection
					.prepareStatement(addPlnInfo1);
			String updatePath = CoreXmlSqlParsersFactory
					.getSql("FrmHttCrackDetectResult.UpdatePath");// 修改队列表工艺路径
			PreparedStatement pastupdatePath = connection
					.prepareStatement(updatePath);

			String addHttControlLog = CoreXmlSqlParsersFactory
					.getSql("HeatTreatmentService.addHttControlLog"); // 增加调度日志
			// 仅探伤才增加
			PreparedStatement pastaddHttControlLog = connection
					.prepareStatement(addHttControlLog);

			for (int j = 0; j < loadStrs.size(); j++) {
				String loadStr = loadStrs.get(j);

				HttCrackDetectionEtEntity load = EntityTool.getEntityByJSONStr(
						loadStr, HttCrackDetectionEtEntity.class);

				HttCrackDetectionParaEntity Para1 = ""
						.equals(crackDetectionPatameter1) ? null : EntityTool
						.getEntityByJSONStr(crackDetectionPatameter1,
								HttCrackDetectionParaEntity.class);
				HttCrackDetectionParaEntity Para2 = ""
						.equals(crackDetectionPatameter2) ? null : EntityTool
						.getEntityByJSONStr(crackDetectionPatameter2,
								HttCrackDetectionParaEntity.class);
				HttCrackDetectionParaEntity Para3 = ""
						.equals(crackDetectionPatameter3) ? null : EntityTool
						.getEntityByJSONStr(crackDetectionPatameter3,
								HttCrackDetectionParaEntity.class);

				load.setProcessCode("F");

				if ("".equals(crackDetectionPatameter1)) {
					load.setPassNum("0");
					load.setDubiousNum("0");
					load.setFtestingNum("0");
					load.setFpassNum("0");
					load.setEwasteNum("0");
					load.setEpassNum("0");
					load.setTestingTime("0");

				} else {
					load.setTestingType("UT");
					load.setReportNo("0");
					if (Para1.getLongitudinalExternal().equals("")) {
						core.setV_errMsg("请输入探伤等级");
						return core;
					}
					load.setTestingPosition("0");
					load.setTestingGrade(Para1.getLongitudinalExternal());

					if (load.getTestingStandard().equals("")) {
						if (!Para1.getStandardDefect().equals("")
								&& !Para1.getStandardDefect().equals("/")) {
							load.setTestingStandard((load.getTestingStandard()
									.equals("") ? "" : (load
									.getTestingStandard() + ";"))
									+ Para1.getStandardDefect());
						}

						if (!Para1.getStandardWall().equals("")
								&& !Para1.getStandardWall().equals("/")) {
							load.setTestingStandard((load.getTestingStandard()
									.equals("") ? "" : (load
									.getTestingStandard() + ";"))
									+ Para1.getStandardWall());
						}

						if (!Para1.getStandardLam().equals("")
								&& !Para1.getStandardLam().equals("/")) {
							load.setTestingStandard((load.getTestingStandard()
									.equals("") ? "" : (load
									.getTestingStandard() + ";"))
									+ Para1.getStandardLam());
						}

						if (!Para1.getStandardOblique().equals("")
								&& !Para1.getStandardOblique().equals("/")) {
							load.setTestingStandard((load.getTestingStandard()
									.equals("") ? "" : (load
									.getTestingStandard() + ";"))
									+ Para1.getStandardOblique());
						}
					}
				}

				if ("".equals(crackDetectionPatameter2)) {
					load.setManualFtestingNum("0");
					load.setManualPassNum("0");
					load.setRejectedNum("0");
					load.setRejectNum("0");
					load.setFinalNum("0");

				} else {
					load.setReportNo("1");
					load.setTestingType("UT");
					if (Para2.getLongitudinalExternal().equals("")) {
						core.setV_errMsg("请输入探伤等级");
						return core;
					}
					load.setTestingPosition("1");
					load.setTestingGrade(Para2.getLongitudinalExternal());

					if (load.getTestingStandard().equals("")) {
						if (!Para2.getStandardDefect().equals("")
								&& !Para2.getStandardDefect().equals("/")) {
							load.setTestingStandard((load.getTestingStandard()
									.equals("") ? "" : (load
									.getTestingStandard() + ";"))
									+ Para2.getStandardDefect());
						}

						if (!Para2.getStandardWall().equals("")
								&& !Para2.getStandardWall().equals("/")) {
							load.setTestingStandard((load.getTestingStandard()
									.equals("") ? "" : (load
									.getTestingStandard() + ";"))
									+ Para2.getStandardWall());
						}

						if (!Para2.getStandardLam().equals("")
								&& !Para2.getStandardLam().equals("/")) {
							load.setTestingStandard((load.getTestingStandard()
									.equals("") ? "" : (load
									.getTestingStandard() + ";"))
									+ Para2.getStandardLam());
						}

						if (!Para2.getStandardOblique().equals("")
								&& !Para2.getStandardOblique().equals("/")) {
							load.setTestingStandard((load.getTestingStandard()
									.equals("") ? "" : (load
									.getTestingStandard() + ";"))
									+ Para2.getStandardOblique());
						}
					}
				}

				if ("".equals(crackDetectionPatameter3)) {
					load.setPassNumEt("0");
					load.setDubiousNumEt("0");
					load.setFtestingNumEt("0");
					load.setFpassNumEt("0");
					load.setEwasteNumEt("0");
					load.setEpassNumEt("0");

				} else {
					load.setTestingType("ET");
					load.setReportNo("4");

					if (Para3.getAccpetanceLevel().equals("")) {
						core.setV_errMsg("请输入等级");
						return core;
					}
					load.setTestingPosition("1`");

					load.setTestingGrade(Para3.getAccpetanceLevel());

					if (load.getTestingStandard().equals("")) {
						if (!Para2.getStandardDefect().equals("")
								&& !Para2.getStandardDefect().equals("/")) {
							load.setTestingStandard((load.getTestingStandard()
									.equals("") ? "" : (load
									.getTestingStandard() + ";"))
									+ Para2.getStandardDefect());
						}
					}
				}

				if (load.getMachineNo().equals(""))
					load.setMachineNo("1");

				load.setColUser(Para1 != null ? Para1.getOperatorName()
						: Para2 != null ? Para2.getOperatorName() : Para3
								.getOperatorName());

				// 获取热处理计划实体了
				PlnZyRclMEntity pln = PlanService.getSendHttPlanCInfo(
						connection, PlanNo);

				SimpleDateFormat matter2 = new SimpleDateFormat("yyyyMMddHHmm");
				SimpleDateFormat matter3 = new SimpleDateFormat("yyyyMM");
				SimpleDateFormat matter4 = new SimpleDateFormat("yyyyMMdd");

				Date colDate = load.getColTime().length() == 17 ? dateFormat1
						.parse(load.getColTime()) : dateFormat.parse(load
						.getColTime());
				Date colEndDate = load.getColEndTime().length() == 17 ? dateFormat1
						.parse(load.getColEndTime())
						: dateFormat.parse(load.getColEndTime());

				if (colDate.after(colEndDate)) {
					core.setV_errMsg("结束时间不能早于开始时间");
					return core;
				}

				if (pln == null)
					return core;
				if (pln.getPlanstatus().equals("3")) {
					core.setV_errMsg("该计划已关闭！");
					return core;
				}
				String ifMonitNo = "";
				if (pln.getIfMonitor().equals("是")) {
					ifMonitNo = "1";
				} else {
					ifMonitNo = "0";
				}

				load.setJudgeStoveNo(pln.getJudgeStoveNo());

				String cutFalg = "";
				String sql = CoreXmlSqlParsersFactory
						.getSql("HttLoadingService.qureyGxComInfo");// 查询工序是否是结炉状态
				psta = connection.prepareStatement(sql);
				psta.setString(1, load.getHeatPlanNo());
				// psta.setString(2, load.getPlineCode());
				psta.setString(2, slgx);
				psta.setObject(3, pln.getRealProcessSeq());
				ResultSet rs = psta.executeQuery();
				if (rs.next()) {
					cutFalg = rs.getString("STATION_STATUS");
				}
				if (cutFalg.equals("2")) {
					core.setV_errMsg("已结炉,不允许此操作！");
					return core;
				}
				rs.close();
				psta.close();

				int ProNum = 0;
				int FailNum = 0;

				if (StringTool.isInteger(load.getTestingNum())) {
					ProNum = Integer.parseInt(load.getTestingNum());

				}

				if (StringTool.isInteger(load.getEwasteNum())) {
					FailNum = Integer.parseInt(load.getEwasteNum());
				}

				if (ProNum <= 0) {
					core.setV_errMsg("检查支数不能为0！");
					return core;
				}

				if (ProNum < FailNum) {
					core.setV_errMsg("作业支数不能小于废品支数！");
					return core;
				}

				String resultNo = "";
				String sqlloading = CoreXmlSqlParsersFactory
						.getSql("FrmHttCrackDetectResult.queryLoadRESULT");// 查询最大实绩编号
				psta = connection.prepareStatement(sqlloading);
				psta.setObject(1, pln.getPlineCode() + slgx
						+ matter1.format(dt));
				psta.setObject(2, pln.getPlineCode() + slgx
						+ matter1.format(dt));

				ResultSet rs1 = psta.executeQuery();
				if (rs1.next()) {
					resultNo = rs1.getString("RESULT_NO");
				}
				rs1.close();
				psta.close();

				String sqlAdd = CoreXmlSqlParsersFactory
						.getSql("FrmHttCrackDetectResult.AddCrackDetection");// 新增探伤

				load.setResultNo(resultNo);
				load.setZyBatchId(pln.getZyBatchId());
				load.setProPlanId(pln.getProPlanId());
				load.setGxPlanNo(pln.getGxPlanNo());
				load.setPlineCode(pln.getPlineCode());
				load.setPlineName(pln.getPlineName());
				sqlAdd = com.steering.common.EntityTool.fillSqlByEntity(sqlAdd,
						load);
				PreparedStatement patAdd = connection.prepareStatement(sqlAdd);
				patAdd.addBatch();

				String sqlAddHead = CoreXmlSqlParsersFactory
						.getSql("FrmHttCrackDetectResult.AddCrackHead");// 新增探伤
				PreparedStatement patAddHead = connection
						.prepareStatement(sqlAddHead);
				patAddHead.setObject(1, resultNo);
				patAddHead.setObject(2, load.getBatchNo());
				patAddHead.setObject(3, PlanNo);
				patAddHead.addBatch();

				// 新增探伤公共信息
				patsPlan.setObject(1, resultNo);
				patsPlan.setObject(2, pln.getZyBatchId());
				// patsPlan.setObject(3, pln.getProdIndex());
				patsPlan.setObject(3, pln.getProPlanId());
				patsPlan.setObject(4, pln.getGxPlanNo());
				patsPlan.setObject(5, pln.getOrderSource());
				patsPlan.setObject(6, pln.getOrderNo());
				patsPlan.setObject(7, pln.getOrderSeq());
				patsPlan.setObject(8, pln.getReqBlId());
				patsPlan.setObject(9, pln.getPlineCode());
				patsPlan.setObject(10, pln.getPlineName());
				patsPlan.setObject(11, slgx);
				patsPlan.setObject(12, "探伤");
				patsPlan.setObject(13, pln.getGradecode());
				patsPlan.setObject(14, pln.getGradename());
				patsPlan.setObject(15, pln.getSteelcode());
				patsPlan.setObject(16, pln.getSteelname());
				patsPlan.setObject(17, pln.getOutdiameterIn());
				patsPlan.setObject(18, pln.getWallthickIn());
				patsPlan.setObject(19, "");
				patsPlan.setObject(20, "");
				patsPlan.setObject(21, "");
				patsPlan.setObject(22, "");
				patsPlan.setObject(23, "");
				patsPlan.setObject(24, "");
				patsPlan.setObject(25, "");
				patsPlan.setObject(26, "");
				patsPlan.setObject(27, pln.getOutwlId());
				patsPlan.setObject(28, pln.getOutwlDesc());
				patsPlan.setObject(29, pln.getInwlId());
				patsPlan.setObject(30, pln.getInwlDesc());
				patsPlan.setObject(31, pln.getMonitorPoint());
				patsPlan.setObject(32, ifMonitNo);
				patsPlan.setObject(33, pln.getPrdcrNo());
				patsPlan.setObject(34, "");
				patsPlan.setObject(35, "");
				patsPlan.setObject(36, pln.getStationRoad());
				patsPlan.setObject(37, pln.getCraftFileNo());
				patsPlan.setObject(38, pln.getCraftFileMan());
				patsPlan.setObject(39, pln.getCraftSeq());
				patsPlan.setObject(40, load.getTestingNum());
				patsPlan.setObject(41, load.getTestingWt());
				patsPlan.setObject(42, load.getEwasteNum());
				patsPlan.setObject(43, resultNo);
				patsPlan.setObject(44, "");
				patsPlan.setObject(45, "");
				patsPlan.setObject(46, "");
				patsPlan.setObject(47, "");
				patsPlan.setObject(48, "1");
				patsPlan.setObject(49, load.getColTime());
				patsPlan.setObject(50, "");
				patsPlan.setObject(51, load.getColUser());
				patsPlan.setObject(52, load.getColShift());
				patsPlan.setObject(53, load.getColGroup());
				patsPlan.setObject(54, "1");
				patsPlan.setObject(55, systime);
				patsPlan.setObject(56, "");
				patsPlan.setObject(57, load.getHeatPlanNo());
				patsPlan.setObject(58, pln.getJudgeStoveNo());
				patsPlan.setObject(59, pln.getBatchNo());
				patsPlan.setObject(60, "");
				patsPlan.setObject(61, pln.getProduccode());
				patsPlan.setObject(62, pln.getProducname());
				patsPlan.setObject(63, pln.getSpecCode());
				patsPlan.setObject(64, pln.getSpecName());
				patsPlan.setObject(65, load.getProcessSeq());
				patsPlan.addBatch();

				FrmHttBugD.AddHttWaste(connection, load.getHeatPlanNo(),
						resultNo, pln.getPlineCode(), load.getColUser(), load
								.getProcessSeq(), slgx, list1Str, list2Str,
						list3Str);

				patAddHead.executeBatch();
				patAdd.executeBatch();
				patsPlan.executeBatch();

				if (Para1 != null) {

					/*
					 * 1、【最终合格支数+最终废品支数+待判支数=检测支数】 2、【合格支数+可疑品支数=检测支数】
					 * 3、【复探合格支数+最终废品支数=可疑品支数】
					 */

					if (Integer.parseInt(load.getEpassNum())
							+ Integer.parseInt(load.getEwasteNum())
							+ Integer.parseInt(load.getPendingNum()) != Integer
							.parseInt(load.getTestingNum())) {
						core.setV_errMsg("最终合格支数+最终废品支数+待判支数不等于检测支数,请检查!");
						return core;
					}

					if (Integer.parseInt(load.getPassNum())
							+ Integer.parseInt(load.getDubiousNum()) != Integer
							.parseInt(load.getTestingNum())) {
						core.setV_errMsg("合格支数+可疑品支数不等于检测支数,请检查!");
						return core;
					}

					// if(Integer.parseInt(load.getFpassNum())
					// +Integer.parseInt(load.getEwasteNum()) !=
					// Integer.parseInt(load.getDubiousNum())){

					if (Integer.parseInt(load.getFpassNum())
							+ Integer.parseInt(load.getEwasteNum())
							+ Integer.parseInt(load.getPendingNum()) != Integer
							.parseInt(load.getDubiousNum())) {
						core.setV_errMsg("复探合格支数+最终废品支数 + 待判支数不等于可疑品支数,请检查!");
						return core;
					}
					// }

					String ProbeID = "";
					if (ProbeString1.size() > 0) {
						sql = CoreXmlSqlParsersFactory
								.getSql("FrmHttCrackDetectResult.getMaxProbeId");
						psta = connection.prepareStatement(sql);
						psta.setObject(1, pln.getJudgeStoveNo()
								+ load.getBatchNo());
						psta.setObject(2, pln.getJudgeStoveNo()
								+ load.getBatchNo());

						rs1 = psta.executeQuery();
						if (rs1.next()) {
							ProbeID = rs1.getString("PROBE_ID");
						}
						rs1.close();
						psta.close();

					}

					String StandID = "";

					if (StandString1.size() > 0) {
						sql = CoreXmlSqlParsersFactory
								.getSql("FrmHttCrackDetectResult.getMaxStandID");
						psta = connection.prepareStatement(sql);
						psta.setObject(1, pln.getJudgeStoveNo()
								+ load.getBatchNo());
						psta.setObject(2, pln.getJudgeStoveNo()
								+ load.getBatchNo());

						rs1 = psta.executeQuery();
						if (rs1.next()) {
							StandID = rs1.getString("STANDARD_ID");
						}
						rs1.close();
						psta.close();

					}
					if (load.getBatchNo() == null
							|| load.getBatchNo().equals("")) {
						core.setV_errMsg("请先分批再探伤!");
						return core;
					}

					String sqlAddPara = CoreXmlSqlParsersFactory
							.getSql("FrmHttCrackDetectResult.AddCrackDetectionPara");
					Para1.setResultNo(resultNo);
					Para1.setReportNo("0");
					Para1.setProbeId(ProbeID);
					Para1.setStandardId(StandID);
					Para1.setHeatPlanNo(pln.getHeatPlanNo());
					Para1.setBatchNo(load.getBatchNo());
					Para1.setJudgeStoveNo(pln.getJudgeStoveNo());
					Para1.setShift(load.getColShift());
					Para1.setProDate(load.getColTime());
					Para1.setColGroup(load.getColGroup());
					sqlAddPara = com.steering.common.EntityTool
							.fillSqlByEntity(sqlAddPara, Para1);
					PreparedStatement patAddPara = connection
							.prepareStatement(sqlAddPara);
					patAddPara.addBatch();
					patAddPara.executeBatch();

					for (int i = 0; i < ProbeString1.size(); i++) {
						HttCrackDetectionProbeEntity probeEntity = EntityTool
								.getEntityByJSONStr(ProbeString1.get(i),
										HttCrackDetectionProbeEntity.class);

						String sqlAddProbe = CoreXmlSqlParsersFactory
								.getSql("FrmHttCrackDetectResult.AddCrackDetectionProbe");
						probeEntity.setProbeId(ProbeID);
						probeEntity.setProbeSeq((i + 1) + "");
						sqlAddProbe = com.steering.common.EntityTool
								.fillSqlByEntity(sqlAddProbe, probeEntity);
						PreparedStatement patAddProbe = connection
								.prepareStatement(sqlAddProbe);
						patAddProbe.addBatch();
						patAddProbe.executeBatch();
					}

					for (int i = 0; i < StandString1.size(); i++) {
						HttCrackDetectionStandardEntity probeEntity = EntityTool
								.getEntityByJSONStr(StandString1.get(i),
										HttCrackDetectionStandardEntity.class);

						String sqlAddStand = CoreXmlSqlParsersFactory
								.getSql("FrmHttCrackDetectResult.AddCrackDetectionStandard");
						probeEntity.setStandardId(StandID);
						probeEntity.setStandardSeq((i + 1) + "");
						sqlAddStand = com.steering.common.EntityTool
								.fillSqlByEntity(sqlAddStand, probeEntity);
						PreparedStatement patAddStand = connection
								.prepareStatement(sqlAddStand);
						patAddStand.addBatch();
						patAddStand.executeBatch();
					}
				}

				if (Para2 != null) {

					String ProbeID2 = "";
					if (ProbeString2.size() > 0) {
						sql = CoreXmlSqlParsersFactory
								.getSql("FrmHttCrackDetectResult.getMaxProbeId");
						psta = connection.prepareStatement(sql);
						psta.setObject(1, pln.getJudgeStoveNo()
								+ load.getBatchNo());
						psta.setObject(2, pln.getJudgeStoveNo()
								+ load.getBatchNo());

						rs1 = psta.executeQuery();
						if (rs1.next()) {
							ProbeID2 = rs1.getString("PROBE_ID");
						}
						rs1.close();
						psta.close();

					}

					String StandID2 = "";

					if (StandString2.size() > 0) {
						sql = CoreXmlSqlParsersFactory
								.getSql("FrmHttCrackDetectResult.getMaxStandID");
						psta = connection.prepareStatement(sql);
						psta.setObject(1, pln.getJudgeStoveNo()
								+ load.getBatchNo());
						psta.setObject(2, pln.getJudgeStoveNo()
								+ load.getBatchNo());

						rs1 = psta.executeQuery();
						if (rs1.next()) {
							StandID2 = rs1.getString("STANDARD_ID");
						}
						rs1.close();
						psta.close();

					}
					if (load.getBatchNo() == null
							|| load.getBatchNo().equals("")) {
						core.setV_errMsg("请先分批再探伤!");
						return core;
					}
					String sqlAddPara2 = CoreXmlSqlParsersFactory
							.getSql("FrmHttCrackDetectResult.AddCrackDetectionPara");
					Para2.setResultNo(resultNo);
					Para2.setReportNo("1");
					Para2.setProbeId(ProbeID2);
					Para2.setStandardId(StandID2);
					Para2.setHeatPlanNo(pln.getHeatPlanNo());
					Para2.setBatchNo(load.getBatchNo());
					Para2.setJudgeStoveNo(pln.getJudgeStoveNo());
					Para2.setShift(load.getColShift());
					Para2.setProDate(load.getColTime());
					Para2.setColGroup(load.getColGroup());
					sqlAddPara2 = com.steering.common.EntityTool
							.fillSqlByEntity(sqlAddPara2, Para2);
					PreparedStatement patAddPara2 = connection
							.prepareStatement(sqlAddPara2);
					patAddPara2.addBatch();
					patAddPara2.executeBatch();

					for (int i = 0; i < ProbeString2.size(); i++) {
						HttCrackDetectionProbeEntity probeEntity = EntityTool
								.getEntityByJSONStr(ProbeString2.get(i),
										HttCrackDetectionProbeEntity.class);

						String sqlAddProbe = CoreXmlSqlParsersFactory
								.getSql("FrmHttCrackDetectResult.AddCrackDetectionProbe");
						probeEntity.setProbeId(ProbeID2);
						probeEntity.setProbeSeq((i + 1) + "");
						sqlAddProbe = com.steering.common.EntityTool
								.fillSqlByEntity(sqlAddProbe, probeEntity);
						PreparedStatement patAddProbe = connection
								.prepareStatement(sqlAddProbe);
						patAddProbe.addBatch();
						patAddProbe.executeBatch();
					}

					for (int i = 0; i < StandString2.size(); i++) {
						HttCrackDetectionStandardEntity probeEntity = EntityTool
								.getEntityByJSONStr(StandString2.get(i),
										HttCrackDetectionStandardEntity.class);

						String sqlAddStand = CoreXmlSqlParsersFactory
								.getSql("FrmHttCrackDetectResult.AddCrackDetectionStandard");
						probeEntity.setStandardId(StandID2);
						probeEntity.setStandardSeq((i + 1) + "");
						sqlAddStand = com.steering.common.EntityTool
								.fillSqlByEntity(sqlAddStand, probeEntity);
						PreparedStatement patAddStand = connection
								.prepareStatement(sqlAddStand);
						patAddStand.addBatch();
						patAddStand.executeBatch();
					}
				}

				if (Para3 != null) {
					String ProbeID3 = "";
					if (ProbeString3.size() > 0) {
						sql = CoreXmlSqlParsersFactory
								.getSql("FrmHttCrackDetectResult.getMaxProbeId");
						psta = connection.prepareStatement(sql);
						psta.setObject(1, pln.getJudgeStoveNo()
								+ load.getBatchNo());
						psta.setObject(2, pln.getJudgeStoveNo()
								+ load.getBatchNo());

						rs1 = psta.executeQuery();
						if (rs1.next()) {
							ProbeID3 = rs1.getString("PROBE_ID");
						}
						rs1.close();
						psta.close();

					}

					String StandID3 = "";

					if (StandString3.size() > 0) {
						sql = CoreXmlSqlParsersFactory
								.getSql("FrmHttCrackDetectResult.getMaxStandID");
						psta = connection.prepareStatement(sql);
						psta.setObject(1, pln.getJudgeStoveNo()
								+ load.getBatchNo());
						psta.setObject(2, pln.getJudgeStoveNo()
								+ load.getBatchNo());

						rs1 = psta.executeQuery();
						if (rs1.next()) {
							StandID3 = rs1.getString("STANDARD_ID");
						}
						rs1.close();
						psta.close();

					}
					if (load.getBatchNo() == null
							|| load.getBatchNo().equals("")) {
						core.setV_errMsg("请先分批再探伤!");
						return core;
					}
					String sqlAddPara = CoreXmlSqlParsersFactory
							.getSql("FrmHttCrackDetectResult.AddCrackDetectionPara");
					Para3.setResultNo(resultNo);
					Para3.setReportNo("4");
					Para3.setProbeId(ProbeID3);
					Para3.setStandardId(StandID3);
					Para3.setHeatPlanNo(pln.getHeatPlanNo());
					Para3.setBatchNo(load.getBatchNo());
					Para3.setJudgeStoveNo(pln.getJudgeStoveNo());
					Para3.setShift(load.getColShift());
					Para3.setProDate(load.getColTime());
					Para3.setColGroup(load.getColGroup());
					sqlAddPara = com.steering.common.EntityTool
							.fillSqlByEntity(sqlAddPara, Para3);
					PreparedStatement patAddPara = connection
							.prepareStatement(sqlAddPara);
					patAddPara.addBatch();
					patAddPara.executeBatch();

					for (int i = 0; i < ProbeString3.size(); i++) {
						HttCrackDetectionProbeEntity probeEntity = EntityTool
								.getEntityByJSONStr(ProbeString3.get(i),
										HttCrackDetectionProbeEntity.class);

						String sqlAddProbe = CoreXmlSqlParsersFactory
								.getSql("FrmHttCrackDetectResult.AddCrackDetectionProbe");
						probeEntity.setProbeId(ProbeID3);
						probeEntity.setProbeSeq((i + 1) + "");
						sqlAddProbe = com.steering.common.EntityTool
								.fillSqlByEntity(sqlAddProbe, probeEntity);
						PreparedStatement patAddProbe = connection
								.prepareStatement(sqlAddProbe);
						patAddProbe.addBatch();
						patAddProbe.executeBatch();
					}

					for (int i = 0; i < StandString3.size(); i++) {
						HttCrackDetectionStandardEntity probeEntity = EntityTool
								.getEntityByJSONStr(StandString3.get(i),
										HttCrackDetectionStandardEntity.class);

						String sqlAddStand = CoreXmlSqlParsersFactory
								.getSql("FrmHttCrackDetectResult.AddCrackDetectionStandard");
						probeEntity.setStandardId(StandID3);
						probeEntity.setStandardSeq((i + 1) + "");
						sqlAddStand = com.steering.common.EntityTool
								.fillSqlByEntity(sqlAddStand, probeEntity);
						PreparedStatement patAddStand = connection
								.prepareStatement(sqlAddStand);
						patAddStand.addBatch();
						patAddStand.executeBatch();
					}
				}

				// 修改工艺路径
				pastupdatePath.setObject(1, "1");
				pastupdatePath.setObject(2, load.getHeatPlanNo());
				pastupdatePath.addBatch();
				pastupdatePath.executeBatch();
				// 修改计划表
				patupdate.setObject(1, "80");
				patupdate.setObject(2, load.getHeatPlanNo());
				patupdate.addBatch();
				patupdate.executeBatch();

				if (load.getTestingPosition().equals("0")) {
					// if (pln.getProcessCodeC().equals("B024")) {
					Date procDate = colDate;
					if (load.getColShift().equals("3")) {
						Calendar date = Calendar.getInstance();
						date.setTime(colDate);
						date.set(Calendar.HOUR_OF_DAY, date
								.get(Calendar.HOUR_OF_DAY) + 12);
						procDate = dateFormat.parse(dateFormat.format(date
								.getTime()));
					}
					int acount = 0;
					String sql1 = CoreXmlSqlParsersFactory
							.getSql("FrmHttControlLog.qureyConfirmFlag");// 查询录入时间是否调度已确认.
					psta = connection.prepareStatement(sql1);
					psta.setString(1, matter2.format(colDate));
					psta.setObject(2, matter2.format(colDate));
					psta.setObject(3, matter2.format(colEndDate));
					psta.setObject(4, matter2.format(colEndDate));
					psta.setObject(5, load.getPlineCode());
					psta.setObject(6, "1");
					rs1 = psta.executeQuery();
					if (rs1.next()) {
						acount = Integer.parseInt(rs1.getString("ACOUT"));
					}
					if (acount > 0) {
						core.setV_errMsg("该时间段,调度已确认或已审核,请联系调度取消确认或取消审核!");
						return core;
					}
					rs1.close();
					psta.close();
					pastaddHttControlLog.setObject(1, matter2.format(colDate));
					pastaddHttControlLog.setObject(2, matter2.format(colEndDate));
					pastaddHttControlLog.setObject(3, resultNo);
					// patAdd.setObject(3, pln.getProdIndex());
					pastaddHttControlLog.setObject(4, load.getColShift());
					pastaddHttControlLog.setObject(5, load.getColGroup());
					pastaddHttControlLog.setObject(6, load.getTestingNum());
					pastaddHttControlLog.setObject(7, load.getTestingWt());
					pastaddHttControlLog.setObject(8, systime);
					pastaddHttControlLog.setObject(9, load.getColUser());
					pastaddHttControlLog.setObject(10, matter3.format(procDate));
					pastaddHttControlLog.setObject(11, matter4.format(procDate));
					pastaddHttControlLog.setObject(12, "1");
					pastaddHttControlLog.setObject(13, PlanNo);
					pastaddHttControlLog.addBatch();
					pastaddHttControlLog.executeBatch();
					// }
				}
				
			}

			core.setV_errMsg("新增探伤成功！");
			core.setResult(1);
			connection.commit();
		} catch (Exception e) {
			core.setV_errMsg(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return core;
	}

	/**
	 * 撤销探伤
	 * 
	 * @param planNo
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public CoreReturnObject deleteHttCrackResult(String heratNo, String rentNo,
			String slgx) {
		CoreReturnObject core = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		PreparedStatement psta = null;
		int acount = 0;
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String sqlDelete = CoreXmlSqlParsersFactory
					.getSql("FrmHttCrackDetectResult.deleteHttCrackResult");// 删除上探伤实绩
			PreparedStatement patDelete = connection
					.prepareStatement(sqlDelete);
			String sqlDeleteHead = CoreXmlSqlParsersFactory
					.getSql("FrmHttCrackDetectResult.deleteHttCrackResultHead");// 删除上探伤实绩
			PreparedStatement patDeleteHead = connection
					.prepareStatement(sqlDeleteHead);

			String sqlDeletePara = CoreXmlSqlParsersFactory
					.getSql("FrmHttCrackDetectResult.deleteHttCrackResultPara");// 删除上探伤参数
			PreparedStatement patDeletepara = connection
					.prepareStatement(sqlDeletePara);

			String sqlDeleteProbe = CoreXmlSqlParsersFactory
					.getSql("FrmHttCrackDetectResult.deleteHttCrackResultProbe");// 删除上探伤探头
			PreparedStatement patDeleteProbe = connection
					.prepareStatement(sqlDeleteProbe);

			String sqlDeleteStandard = CoreXmlSqlParsersFactory
					.getSql("FrmHttCrackDetectResult.deleteHttCrackResultStandard");// 删除上探伤标准
			PreparedStatement patDeleteStandard = connection
					.prepareStatement(sqlDeleteStandard);

			String sqlDeletepln = CoreXmlSqlParsersFactory
					.getSql("AppearanceService.updatePlnZyRclM");// 删除时修改热处理计划表
			PreparedStatement patDeletepln = connection
					.prepareStatement(sqlDeletepln);
			String updatePlnInfo = CoreXmlSqlParsersFactory
					.getSql("HttLoadingService.deleteComInfoResult");// 删除公共信息
			PreparedStatement patsupdatePlan = connection
					.prepareStatement(updatePlnInfo);

			String addPlnInfo1 = CoreXmlSqlParsersFactory
					.getSql("HeatTreatmentService.AddComInfoResult1");// 查询材料状态和工序点编码
			PreparedStatement patsPlan1 = connection
					.prepareStatement(addPlnInfo1);
			String updatePath2 = CoreXmlSqlParsersFactory
					.getSql("FrmHttCrackDetectResult.UpdatePath");// 修改队列表工艺路径
			PreparedStatement pastupdatePath = connection
					.prepareStatement(updatePath2);

			String DeleteHttControl = CoreXmlSqlParsersFactory
					.getSql("HeatTreatmentService.deleteHttControlLog");
			PreparedStatement pastDeleteHttControl = connection
					.prepareStatement(DeleteHttControl);

			// 获取热处理计划实体了
			PlnZyRclMEntity pln = PlanService.getSendHttPlanCInfo(connection,
					heratNo);

			if (pln == null)
				return core;
			if (pln.getPlanstatus().equals("30")) {
				core.setV_errMsg("炉计划已经生产完成,请先撤销下线结炉！");
				return core;
			}

			if (pln.getPlanstatus().equals("40")) {
				core.setV_errMsg("该计划已关闭，请撤销申请判定！");
				return core;
			}

			String Sql = CoreXmlSqlParsersFactory
					.getSql("FrmHttCrackDetectResult.GetCrackResult");
			Sql += " WHERE RESULT_NO = '" + rentNo + "'";
			HttCrackDetectionEtEntity result = EntityTool
					.getEntityBySqlNoClsCon(Sql, connection,
							HttCrackDetectionEtEntity.class);

			if (result == null || result.getResultNo().equals("")) {
				core.setV_errMsg("数据发生改变,请先刷新！");
				return core;
			}

			if (!pln.getPlineCode().equals(result.getPlineCode())) {
				core.setV_errMsg("不允许删除其他产线实绩,若需删除,请离线委内回原产线进行删除！");
				return core;
			}

			if (!pln.getRealProcessSeq().equals(result.getProcessSeq())) {
				core.setV_errMsg("该记录是上次热处理的实绩,无法删除！");
				return core;
			}

			String cutFalg = "";
			String sql = CoreXmlSqlParsersFactory
					.getSql("HttLoadingService.qureyGxComInfo");// 查询工序是否是结炉状态
			psta = connection.prepareStatement(sql);
			psta.setString(1, result.getHeatPlanNo());
			// psta.setString(2, result.getPlineCode());
			psta.setString(2, slgx);
			psta.setObject(3, result.getProcessSeq());
			ResultSet rs = psta.executeQuery();
			if (rs.next()) {
				cutFalg = rs.getString("STATION_STATUS");
			}
			if (cutFalg.equals("2")) {
				core.setV_errMsg("已结炉,不允许此操作！");
				return core;
			}
			rs.close();
			psta.close();

			sql = CoreXmlSqlParsersFactory
					.getSql("HeatTreatmentService.qureyIsConfirm");// 查询调度是否确认
			psta = connection.prepareStatement(sql);
			psta.setString(1, rentNo);
			rs = psta.executeQuery();
			if (rs.next()) {
				acount = Integer.parseInt(rs.getString("acout"));
			}
			if (acount > 0) {
				core.setV_errMsg("调度已确认，不能删除！");
				return core;
			}
			rs.close();
			psta.close();

			int detCount = 0;

			if (StringTool.isInteger(result.getEwasteNum())) {
				detCount += Integer.parseInt(result.getEwasteNum());
			}

			if (StringTool.isInteger(result.getEwasteNumEt())) {
				detCount += Integer.parseInt(result.getEwasteNumEt());
			}

			if (StringTool.isInteger(result.getRejectNum())) {
				detCount += Integer.parseInt(result.getRejectNum());
			}

			FrmHttBugD.DeleteHttWaste(connection, heratNo, rentNo, pln
					.getPlineCode(), result.getProcessSeq(), slgx, detCount);

			patDelete.setObject(1, rentNo);
			patDelete.addBatch();
			patDelete.executeBatch();

			patDeleteHead.setObject(1, rentNo);
			patDeleteHead.addBatch();
			patDeleteHead.executeBatch();

			patDeleteProbe.setObject(1, rentNo);
			patDeleteProbe.addBatch();
			patDeleteProbe.executeBatch();

			patDeleteStandard.setObject(1, rentNo);
			patDeleteStandard.addBatch();
			patDeleteStandard.executeBatch();

			patDeletepara.setObject(1, rentNo);
			patDeletepara.addBatch();
			patDeletepara.executeBatch();

			// 删除探伤公共实绩
			patsupdatePlan.setObject(1, rentNo);
			patsupdatePlan.addBatch();
			patsupdatePlan.executeBatch();

			// 修改工艺路径
			pastupdatePath.setObject(1, "0");
			pastupdatePath.setObject(2, heratNo);
			pastupdatePath.addBatch();
			pastupdatePath.executeBatch();
			// 修改计划表
			patDeletepln.setObject(1, "70");
			patDeletepln.setObject(2, heratNo);
			patDeletepln.addBatch();
			patDeletepln.executeBatch();

			pastDeleteHttControl.setObject(1, rentNo);
			pastDeleteHttControl.addBatch();
			pastDeleteHttControl.executeBatch();

			core.setV_errMsg("删除探伤成功！");
			core.setResult(1);
			connection.commit();
		} catch (Exception e) {
			core.setV_errMsg(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return core;
	}

	/**
	 * 修改探伤
	 * 
	 * @param planNo
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public CoreReturnObject updateHttCrackResult(
			HttCrackDetectionEtEntity load, String rentNo, String plineCode,
			String SlGx) {
		CoreReturnObject core = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		PreparedStatement psta = null;
		Date now = new Date();
		SimpleDateFormat dateFormat = new SimpleDateFormat(
				"yyyy-MM-dd HH:mm:ss", Locale.CHINA);
		String systime = dateFormat.format(now);
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String sqlDelete = CoreXmlSqlParsersFactory
					.getSql("FrmHttCrackDetectResult.updateHttCrackResult");// 修改探伤实绩
			PreparedStatement patDelete = connection
					.prepareStatement(sqlDelete);
			String updatePlnInfo = CoreXmlSqlParsersFactory
					.getSql("AppearanceService.updateComInfoResult");// 修改公共信息
			PreparedStatement patsupdatePlan = connection
					.prepareStatement(updatePlnInfo);
			String addPlnInfo1 = CoreXmlSqlParsersFactory
					.getSql("HeatTreatmentService.AddComInfoResult1");// 查询材料状态和工序点编码
			PreparedStatement patsPlan1 = connection
					.prepareStatement(addPlnInfo1);

			/*
			 * // 修改探伤实绩 patDelete.setObject(1, load.getTestingType());
			 * patDelete.setObject(2, load.getTestingStandard1());
			 * patDelete.setObject(3, load.getTestingStandard2());
			 * patDelete.setObject(4, load.getTestingStandard3());
			 * patDelete.setObject(5, load.getTestingStandard4());
			 * patDelete.setObject(6, load.getTestingStandard5());
			 * patDelete.setObject(7, load.getTestingStandard6());
			 * patDelete.setObject(8, load.getTestingStandard7());
			 * patDelete.setObject(9, load.getTestingStandard8());
			 * patDelete.setObject(10, load.getLexternalLvl());
			 * patDelete.setObject(11, load.getLinternalLvl());
			 * patDelete.setObject(12, load.getTexternalLvl());
			 * patDelete.setObject(13, load.getTinternalLvl());
			 * patDelete.setObject(14, load.getWallThickMin());
			 * patDelete.setObject(15, load.getWallThickMax());
			 * patDelete.setObject(16, load.getProbeRunSpeed());
			 * patDelete.setObject(17, load.getPipeRotSpeed());
			 * patDelete.setObject(18, load.getTestingNum());
			 * patDelete.setObject(19, load.getPassNum());
			 * patDelete.setObject(20, load.getDubiousNum());
			 * patDelete.setObject(21, load.getFtestingNum());
			 * patDelete.setObject(22, load.getFpassNum());
			 * patDelete.setObject(23, load.getFtestingReason());
			 * patDelete.setObject(24, load.getEpassNum());
			 * patDelete.setObject(25, load.getEwasteNum());
			 * patDelete.setObject(26, load.getEwasteReason());
			 * patDelete.setObject(27, load.getTecLevel());
			 * patDelete.setObject(28, load.getColTime());
			 * patDelete.setObject(29, load.getColShift());
			 * patDelete.setObject(30, load.getColGroup());
			 * patDelete.setObject(31, load.getSignIssued());
			 * patDelete.setObject(32, systime); patDelete.setObject(33,
			 * load.getColUser()); patDelete.setObject(34, rentNo);
			 * patDelete.addBatch();
			 */

			// 修改探伤公共实绩
			patsupdatePlan.setObject(1, load.getEpassNum());
			patsupdatePlan.setObject(2, "");
			patsupdatePlan.setObject(3, load.getEwasteNum());
			patsupdatePlan.setObject(4, "");
			patsupdatePlan.setObject(5, load.getColTime());
			patsupdatePlan.setObject(6, load.getColShift());
			patsupdatePlan.setObject(7, load.getColGroup());
			patsupdatePlan.setObject(8, rentNo);
			patsupdatePlan.addBatch();

			patDelete.executeBatch();
			patsupdatePlan.executeBatch();

			int count = 0;
			int num = 0;
			int FAIL = 0;
			String sqlloading1 = CoreXmlSqlParsersFactory
					.getSql("HeatTreatmentService.queryExpandFailNUM");// 查询管号队列表里废品数量
			psta = connection.prepareStatement(sqlloading1);
			psta.setObject(1, load.getHeatPlanNo());
			psta.setObject(2, SlGx);
			ResultSet rs2 = psta.executeQuery();
			if (rs2.next()) {
				count = Integer.parseInt(rs2.getString("ACT_COUNT"));
			}
			rs2.close();
			psta.close();
			String sqlloading2 = CoreXmlSqlParsersFactory
					.getSql("FrmHttCrackDetectResult.queryExpandFailNUM1");// 查询工序废品数量
			psta = connection.prepareStatement(sqlloading2);
			psta.setObject(1, load.getHeatPlanNo());
			ResultSet rs3 = psta.executeQuery();
			if (rs3.next()) {
				FAIL = Integer.parseInt(rs3.getString("FAIL_NUM"));
			}
			rs3.close();
			psta.close();
			if (count > FAIL) {
				num = count - FAIL;
				ArrayList<String> matNo = new ArrayList<String>();
				String sqlloading3 = CoreXmlSqlParsersFactory
						.getSql("HeatTreatmentService.queryExpandNUM2");// 查询管号队列表里废品材料号
				psta = connection.prepareStatement(sqlloading3);
				psta.setObject(1, load.getHeatPlanNo());
				psta.setObject(2, SlGx);
				psta.setObject(3, num + 1);
				ResultSet rs4 = psta.executeQuery();
				while (rs4.next()) {
					matNo.add(rs4.getString("MAT_NO"));
				}
				rs4.close();
				psta.close();
				for (num = 0; num < matNo.size(); num++) {
					patsPlan1.setObject(1, "00");
					patsPlan1.setObject(2, "600209");
					patsPlan1.setObject(3, load.getHeatPlanNo());
					patsPlan1.setObject(4, matNo.get(num));
					patsPlan1.addBatch();

					PlanService.DeleteOffLineMat(connection, matNo.get(num));
				}
				patsPlan1.executeBatch();
			} else if (count < FAIL) {
				num = FAIL - count;
				ArrayList<String> matNo1 = new ArrayList<String>();
				String sqlloading4 = CoreXmlSqlParsersFactory
						.getSql("HeatTreatmentService.queryExpandNUM");// 查询管号队列表里合格材料号
				psta = connection.prepareStatement(sqlloading4);
				psta.setObject(1, load.getHeatPlanNo());
				psta.setObject(2, num + 1);
				ResultSet rs5 = psta.executeQuery();
				while (rs5.next()) {
					matNo1.add(rs5.getString("MAT_NO"));
				}
				rs5.close();
				psta.close();
				for (num = 0; num < matNo1.size(); num++) {
					patsPlan1.setObject(1, "10");
					patsPlan1.setObject(2, "600209");
					patsPlan1.setObject(3, load.getHeatPlanNo());
					patsPlan1.setObject(4, matNo1.get(num));
					patsPlan1.addBatch();

					PlanService.AddOffLineMat(connection, "F", load
							.getColUser(), "22", matNo1.get(num), SlGx, load
							.getHeatPlanNo());
				}
				patsPlan1.executeBatch();
			}
			core.setV_errMsg("修改探伤成功！");
			core.setResult(1);
			connection.commit();
		} catch (Exception e) {
			core.setV_errMsg(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return core;
	}

	/***
	 * 结炉
	 * 
	 * @param zYgNo
	 * @return
	 */
	public CoreReturnObject updateDoBeside(ArrayList<String> parm) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String updateSql = CoreXmlSqlParsersFactory
					.getSql("HttLoadingService.doBeside");// 修改工序状态为结炉
			PreparedStatement updateSqlPsta = connection
					.prepareStatement(updateSql);
			String updatePln = CoreXmlSqlParsersFactory
					.getSql("HttLoadingService.doPlnBeside");// 修改计划表结炉状态
			PreparedStatement updatePlnPsta = connection
					.prepareStatement(updatePln);
			// int count = 0;

			String AllFailUpdatePlanStatus = CoreXmlSqlParsersFactory
					.getSql("HttLoadingService.updateAllFailStatus");//
			PreparedStatement psAllFailUpdatePlanStatus = connection
					.prepareStatement(AllFailUpdatePlanStatus);

			String UpdateControlEnd = CoreXmlSqlParsersFactory
					.getSql("HeatTreatmentService.UpdateHttControlLog2");//
			PreparedStatement psUpdateControlEnd = connection
					.prepareStatement(UpdateControlEnd);

			// 获取热处理计划实体了
			PlnZyRclMEntity pln = PlanService.getSendHttPlanCInfo(connection,
					parm.get(0));

			if (pln == null) {
				cro.setV_errMsg("无炉计划数据,,不允许此操作！");
				return cro;
			}

			String cutFalg = "";
			sql = CoreXmlSqlParsersFactory
					.getSql("HttLoadingService.qureyGxComInfo");// 查询工序是否是结炉状态
			psta = connection.prepareStatement(sql);
			psta.setString(1, parm.get(0));
			// psta.setString(2, parm.get(1));
			psta.setString(2, parm.get(2));
			psta.setObject(3, pln.getRealProcessSeq());
			rs = psta.executeQuery();
			if (rs.next()) {
				cutFalg = rs.getString("STATION_STATUS");
			} else {
				cro.setV_errMsg("无当前工序实绩,无法进行结炉!");
				return cro;
			}
			if (cutFalg.equals("2")) {
				cro.setV_errMsg("已结炉,不允许此操作！");
				return cro;
			}
			rs.close();
			psta.close();

			if (pln.getPlineCode().equals("C015")
					&& !pln.getProcessCodeC().equals("B024")) {

				String cutFalg1 = "1";
				sql = CoreXmlSqlParsersFactory
						.getSql("HeatTreatmentService.qureyGxComInfoNew");// 上一工序没结炉，无法结炉
				psta = connection.prepareStatement(sql);
				psta.setString(1, parm.get(0));
				psta.setObject(2, 600205);
				psta.setObject(3, 600206);
				psta.setObject(4, 600207);
				psta.setObject(5, pln.getRealProcessSeq());
				rs = psta.executeQuery();
				if (rs.next()) {
					cutFalg1 = rs.getString("STATION_STATUS");
				} else if ((pln.getIfMatchOdd().equals("2") || pln
						.getIfMatchOdd().equals("4"))
						&& pln.getBesideStatus().equals("60")) {
					cutFalg1 = "2";
				} else {
					cro.setV_errMsg("上一工序没结炉,不允许结炉!");
					return cro;
				}

				if (cutFalg1 == null || cutFalg1.equals("null")
						|| cutFalg1.equals("")) {
					if (pln.getIfMatchOdd().equals("2")
							&& pln.getBesideStatus().equals("60")) {
						cutFalg1 = "2";
					}
				}

				if (cutFalg1 == null || cutFalg1.equals("1")) {
					cro.setV_errMsg("上一工序没结炉,不允许结炉!");
					return cro;
				}
				rs.close();
				psta.close();
			} else {

				if (!pln.getBesideStatus().equals("70")) {
					String cutFalg1 = "";
					sql = CoreXmlSqlParsersFactory
							.getSql("HttLoadingService.qureyGxComInfo");// 上一工序没结炉，无法结炉
					psta = connection.prepareStatement(sql);
					psta.setString(1, parm.get(0));
					// psta.setString(2, parm.get(1));
					psta.setObject(2,
							pln.getProcessCodeC().equals("B024") ? "600201"
									: Integer.parseInt(parm.get(2)) - 1);
					psta.setObject(3, pln.getRealProcessSeq());
					rs = psta.executeQuery();
					if (rs.next()) {
						cutFalg1 = rs.getString("STATION_STATUS");
					} else if (pln.getIfMatchOdd().equals("2")
							&& pln.getBesideStatus().equals("70")) {
						cutFalg1 = "2";

					} else if (pln.getIfMatchOdd().equals("2")
							&& pln.getProcessCodeC().equals("B024")
							&& pln.getBesideStatus().equals("00")) {
						cutFalg1 = "2";
					} else {
						cro.setV_errMsg("上一工序没结炉,不允许结炉!");
						return cro;

					}

					if (cutFalg1 == null || cutFalg1.equals("null")
							|| cutFalg1.equals("")) {
						if ((pln.getIfMatchOdd().equals("2") || pln
								.getIfMatchOdd().equals("4"))
								&& pln.getBesideStatus().equals("70")) {
							cutFalg1 = "2";
						}
					}

					if (cutFalg1.equals("1")) {
						cro.setV_errMsg("上一工序没结炉,不允许结炉!");
						return cro;
					}
					rs.close();
					psta.close();
				}
			}

			int lxCount = 0;
			sql = CoreXmlSqlParsersFactory
					.getSql("AppearanceService.qureyGxLxCount");// 查询是否离线
			psta = connection.prepareStatement(sql);
			psta.setString(1, parm.get(0));
			// psta.setString(2, parm.get(1));
			psta.setString(2, parm.get(2));
			rs = psta.executeQuery();
			if (rs.next()) {
				lxCount = Integer.parseInt(rs.getString("COUNT"));
			}
			rs.close();
			psta.close();
			if (lxCount != 0) {
				cro.setV_errMsg("该工序点有离线记录,不允许此操作！");
				return cro;
			}

			updateSqlPsta.setString(1, parm.get(0));
			// updateSqlPsta.setString(2, parm.get(1));
			updateSqlPsta.setString(2, parm.get(2));
			updateSqlPsta.setString(3, pln.getRealProcessSeq());
			updateSqlPsta.addBatch();

			// 修改计划结炉状态
			updatePlnPsta.setObject(1, "80");
			updatePlnPsta.setObject(2, parm.get(0));
			updatePlnPsta.addBatch();

			psAllFailUpdatePlanStatus.setString(1, parm.get(0));
			psAllFailUpdatePlanStatus.addBatch();
			psAllFailUpdatePlanStatus.executeBatch();

			updateSqlPsta.executeBatch();
			updatePlnPsta.executeBatch();

			psUpdateControlEnd.setObject(1, "1");
			psUpdateControlEnd.setObject(2, pln.getHeatPlanNo());
			psUpdateControlEnd.addBatch();
			psUpdateControlEnd.executeBatch();

			cro.setV_errMsg("结炉成功！");
			connection.commit();
		} catch (Exception e) {
			System.out.println(e.getMessage());
			if (connection != null) {
				try {
					cro.setV_errMsg(e.getMessage());
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}

	/***
	 * 撤销结炉
	 * 
	 * @param zYgNo
	 * @return
	 */
	public CoreReturnObject undoBeside(ArrayList<String> parm) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String updateSql = CoreXmlSqlParsersFactory
					.getSql("HttLoadingService.deleteBeside");// 修改工序状态撤销结炉
			PreparedStatement updateSqlPsta = connection
					.prepareStatement(updateSql);
			String updatePln = CoreXmlSqlParsersFactory
					.getSql("HttLoadingService.doPlnBeside");// 修改计划表结炉状态
			PreparedStatement updatePlnPsta = connection
					.prepareStatement(updatePln);

			String AllFailUpdatePlanStatus = CoreXmlSqlParsersFactory
					.getSql("HttLoadingService.CancelAllFailStatus");
			PreparedStatement psAllFailUpdatePlanStatus = connection
					.prepareStatement(AllFailUpdatePlanStatus);

			String UpdateHttControl = CoreXmlSqlParsersFactory
					.getSql("HeatTreatmentService.UpdateHttControlLog2");
			PreparedStatement psUpdateHttControl = connection
					.prepareStatement(UpdateHttControl);

			// 获取热处理计划实体了
			PlnZyRclMEntity pln = PlanService.getSendHttPlanCInfo(connection,
					parm.get(0));

			if (pln == null) {
				cro.setV_errMsg("无炉计划数据,,不允许此操作！");
				return cro;
			}

			String cutFalg = "";
			sql = CoreXmlSqlParsersFactory
					.getSql("HttLoadingService.qureyGxComInfo");// 查询工序是否是结炉状态
			psta = connection.prepareStatement(sql);
			psta.setString(1, parm.get(0));
			// psta.setString(2, parm.get(1));
			psta.setString(2, parm.get(2));
			psta.setObject(3, pln.getRealProcessSeq());
			rs = psta.executeQuery();
			if (rs.next()) {
				cutFalg = rs.getString("STATION_STATUS");
			} else {
				cro.setV_errMsg("无当前工序实绩,无法进行!");
				return cro;
			}
			if (cutFalg.equals("1")) {
				cro.setV_errMsg("未结炉,不允许此操作！");
				return cro;
			}
			rs.close();
			psta.close();

			String cutFalg1 = "";
			sql = CoreXmlSqlParsersFactory
					.getSql("HeatTreatmentService.qureyGxComInfoNew");// 查询工序是否是结炉状态
			psta = connection.prepareStatement(sql);
			psta.setString(1, parm.get(0));
			psta.setObject(2, 600211);
			psta.setObject(3, 600211);
			psta.setObject(4, 600211);
			psta.setObject(5, pln.getRealProcessSeq());
			rs = psta.executeQuery();
			if (rs.next()) {
				cutFalg1 = rs.getString("STATION_STATUS");
			} else {
				cro.setV_errMsg("下一道工序没有撤销结炉,不允许此工序撤销结炉!");
				return cro;
			}

			if (cutFalg1 != null && cutFalg1.equals("2")) {
				cro.setV_errMsg("下一道工序没有撤销结炉,不允许此工序撤销结炉!");
				return cro;
			}
			rs.close();
			psta.close();

			updateSqlPsta.setString(1, parm.get(0));
			// updateSqlPsta.setString(2, parm.get(1));
			updateSqlPsta.setString(2, parm.get(2));
			updateSqlPsta.setString(3, pln.getRealProcessSeq());
			updateSqlPsta.addBatch();

			// 修改计划结炉状态
			updatePlnPsta.setObject(1, pln.getPlineCode().equals("C015") ? "60"
					: pln.getProcessCodeC().equals("B024") ? "00" : "70");
			updatePlnPsta.setObject(2, parm.get(0));
			updatePlnPsta.addBatch();
			updatePlnPsta.executeBatch();
			updateSqlPsta.executeBatch();

			psAllFailUpdatePlanStatus.setString(1, parm.get(0));
			psAllFailUpdatePlanStatus.addBatch();
			psAllFailUpdatePlanStatus.executeBatch();

			psUpdateHttControl.setObject(1, "0");
			psUpdateHttControl.setObject(2, parm.get(0));
			psUpdateHttControl.addBatch();
			psUpdateHttControl.executeBatch();

			cro.setV_errMsg("撤销结炉成功!");
			connection.commit();
		} catch (Exception e) {
			System.out.println(e.getMessage());
			if (connection != null) {
				try {
					cro.setV_errMsg(e.getMessage());
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}

	/**
	 * 离线
	 * 
	 * @param load
	 * @return
	 */
	public CoreReturnObject offLineExpandResult(
			ArrayList<HttOfflineResultDentity> list1,
			HttCrackDetectionEtEntity load, ArrayList<String> list,
			String plinCode, String storageNo, String groudno) {
		CoreReturnObject core = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		PreparedStatement psta = null;
		Date dt = new Date();
		SimpleDateFormat matter1 = new SimpleDateFormat("yyMMdd");
		SimpleDateFormat matter = new SimpleDateFormat("yyyyMMdd");
		Calendar ca = Calendar.getInstance();
		ca.set(Calendar.DATE, ca.getActualMaximum(Calendar.DATE));
		Date now = new Date();
		SimpleDateFormat dateFormat = new SimpleDateFormat(
				"yyyy-MM-dd HH:mm:ss", Locale.CHINA);
		String systime = dateFormat.format(now);
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String addOff = CoreXmlSqlParsersFactory
					.getSql("AppearanceService.AddOffLine");// 新增离线实绩
			PreparedStatement patAdd = connection.prepareStatement(addOff);
			String addOffD = CoreXmlSqlParsersFactory
					.getSql("AppearanceService.AddOffLineD");// 新增离线实绩从表
			PreparedStatement patAddD = connection.prepareStatement(addOffD);

			// String addIn = CoreXmlSqlParsersFactory
			// .getSql("AppearanceService.AddYdmInList");// 新增入库信息
			// PreparedStatement patIn = connection.prepareStatement(addIn);
			String updateMat = CoreXmlSqlParsersFactory
					.getSql("AppearanceService.UpdateMatNo");// 修改材料状态
			PreparedStatement patMatNo = connection.prepareStatement(updateMat);

			String updatePath = CoreXmlSqlParsersFactory
					.getSql("AppearanceService.UpdatePathPortVrp");// 修改队列表工艺路径,材料，工序状态
			PreparedStatement pastupdatePath = connection
					.prepareStatement(updatePath);

			String heatPlanNo = list.get(0);
			String slgx = list.get(1);
			String slgxname = list.get(2);
			String name = list.get(3);
			String time = list.get(4);
			String bc = list.get(5);
			String bz = list.get(6);
			String count = list.get(7);

			int num = 0;
			int num1 = 0;
			int num2 = 0;
			if (slgx.equals("600202")) {
				num = 1;
				num1 = 2;
				num2 = 4;
			} else if (slgx.equals("600203")) {
				num = 1;
				num1 = 4;
				num2 = 6;
			} else if (slgx.equals("600204")) {
				num = 1;
				num1 = 6;
				num2 = 8;
			} else if (slgx.equals("600205")) {
				num = 1;
				num1 = 8;
				num2 = 10;
			} else if (slgx.equals("600206")) {
				num = 1;
				num1 = 10;
				num2 = 12;
			} else if (slgx.equals("600207")) {
				num = 1;
				num1 = 12;
				num2 = 14;
			} else if (slgx.equals("600208")) {
				num = 1;
				num1 = 16;
				num2 = 18;
			} else if (slgx.equals("600209")) {
				num = 1;
				num1 = 18;
				num2 = 20;
			} else if (slgx.equals("600210")) {
				num = 1;
				num1 = 20;
				num2 = 22;
			} else if (slgx.equals("600211")) {
				num = 1;
				num1 = 22;
				num2 = 24;
			}

			// 获取墩拔扩计划实体类
			PlnZyRclMEntity pln = PlanService.getSendHttPlanCInfo(connection,
					heatPlanNo);
			// 获取墩拔扩计划从表实体类
			PlnZyRclCEntity plnC = PlanService.getSendHttPlanCInfoC(connection,
					heatPlanNo);
			if (pln == null)
				return core;
			String cutFalg = "";
			String sql = CoreXmlSqlParsersFactory
					.getSql("AppearanceService.qureyGxComInfo");// 查询工序结炉状态
			PreparedStatement psta1 = connection.prepareStatement(sql);
			psta1.setString(1, heatPlanNo);
			psta1.setString(2, plinCode);
			psta1.setString(3, slgx);
			ResultSet rs = psta1.executeQuery();
			if (rs.next()) {
				cutFalg = rs.getString("STATION_STATUS");
			}
			if (cutFalg.equals("2")) {
				core.setV_errMsg("已结炉,不允许此操作！");
				return core;
			}
			rs.close();
			psta1.close();
			List<PortHttBatchSampleResultEntity> matNo = new ArrayList<PortHttBatchSampleResultEntity>();
			String sqlloading1 = CoreXmlSqlParsersFactory
					.getSql("AppearanceService.queryPortVrpHg");// 查询管号队列里合格的材料号
			psta = connection.prepareStatement(sqlloading1);
			psta.setObject(1, heatPlanNo);
			psta.setObject(2, groudno);
			psta.setObject(3, Integer.parseInt(count) + 1);
			ResultSet rs2 = psta.executeQuery();
			matNo = EntityTool.getEntitysByRs(rs2,
					PortHttBatchSampleResultEntity.class);
			rs2.close();
			psta.close();
			if (matNo == null) {
				core.setV_errMsg("管号队列全为样管，不能离线！");
				return core;
			}
			int batchCount = 0;
			sqlloading1 = CoreXmlSqlParsersFactory
					.getSql("AppearanceService.queryPortVrpBatchHg");// 查询管号队列里不是样管的合格支
			psta = connection.prepareStatement(sqlloading1);
			psta.setObject(1, heatPlanNo);
			rs2 = psta.executeQuery();
			if (rs2.next()) {
				batchCount = Integer.parseInt(rs2.getString("ACT_COUNT"));
			}
			rs2.close();
			psta.close();
			if (batchCount < Integer.parseInt(count)) {
				core.setV_errMsg("管号队列材料合格支数不足,请重新输入离线支数！");
				return core;
			}
			String inListDoc = querySendSqlDoc(connection, "800708", "LX");// 入库单号
			String A = querySendSql(connection, inListDoc);
			int g = Integer.parseInt(A.substring(A.length() - 4, A.length()));

			String judge = "";
			String batch = "";
			String procode = "";
			String proname = "";
			String stecode = "";
			String stename = "";
			String gracode = "";
			String graname = "";
			String modecode = "";
			String modedesc = "";
			String stdcode = "";
			String stdname = "";
			String stdstyle = "";
			String stdstyledesc = "";
			String actdimater = "";
			String actheight = "";
			String actlen = "";
			String actlenmin = "";
			String actlenmax = "";

			int countNum = 0;
			double weightNum = 0;
			for (PortHttBatchSampleResultEntity prot : matNo) {
				countNum += Integer.parseInt(prot.getActCount());
				weightNum += Double.parseDouble(prot.getActWeight());
				// 修改管号队列状态
				pastupdatePath.setObject(1, num);
				pastupdatePath.setObject(2, num1);
				pastupdatePath.setObject(3, "2");
				pastupdatePath.setObject(4, num2);
				pastupdatePath.setObject(5, "20");
				pastupdatePath.setObject(6, "10");
				pastupdatePath.setObject(7, slgx);
				pastupdatePath.setObject(8, heatPlanNo);
				pastupdatePath.setObject(9, prot.getMatNo());
				pastupdatePath.addBatch();

				// 修改材料表状态
				patMatNo.setObject(1, "80150104");
				// patMatNo.setObject(2, "11");
				patMatNo.setObject(2, prot.getMatNo());
				patMatNo.addBatch();
				judge = prot.getJudgeStoveNo();
				batch = prot.getBatchNo();
				actdimater = prot.getActDimater();
				actheight = prot.getActHeight();
				actlen = prot.getActLen();
				actlenmin = prot.getActLenMin();
				actlenmax = prot.getActLenMax();
			}
			pastupdatePath.executeBatch();

			patMatNo.executeBatch();

			String ifMonitNo = "";
			if (pln.getIfMonitor().equals("是")) {
				ifMonitNo = "1";
			} else {
				ifMonitNo = "0";
			}
			String resultNo = "";
			String sqlloading = CoreXmlSqlParsersFactory
					.getSql("AppearanceService.queryOffMaxRESULT");// 查询离线最大实绩编号
			psta = connection.prepareStatement(sqlloading);
			psta.setObject(1, plinCode + slgx + "L" + matter1.format(dt));
			psta.setObject(2, matter.format(dt));
			psta.setObject(3, pln.getPlineCode());
			ResultSet rs1 = psta.executeQuery();
			if (rs1.next()) {
				resultNo = rs1.getString("RESULT_NO");
			}
			rs1.close();
			psta.close();

			// 新增离线实绩
			for (PortHttBatchSampleResultEntity lvMat : matNo) {
				patAdd.setObject(1, resultNo);
				patAdd.setObject(2, pln.getPlineCode());
				patAdd.setObject(3, pln.getPlineName());
				patAdd.setObject(4, slgx);
				patAdd.setObject(5, slgx);
				patAdd.setObject(6, heatPlanNo);
				patAdd.setObject(7, pln.getZyBatchId());
				patAdd.setObject(8, pln.getIndexSeq());
				patAdd.setObject(9, pln.getProPlanId());
				patAdd.setObject(10, pln.getGxPlanNo());

				patAdd.setObject(11, judge);
				patAdd.setObject(12, batch);
				patAdd.setObject(13, groudno);
				patAdd.setObject(14, pln.getProduccode());
				patAdd.setObject(15, pln.getProducname());
				patAdd.setObject(16, pln.getSteelcode());
				patAdd.setObject(17, pln.getSteelname());
				patAdd.setObject(18, pln.getGradecode());
				patAdd.setObject(19, pln.getGradename());
				patAdd.setObject(20, pln.getModelCode());
				patAdd.setObject(21, pln.getModelDesc());
				patAdd.setObject(22, pln.getStdCode());
				patAdd.setObject(23, pln.getStdName());
				patAdd.setObject(24, pln.getStdStyle());
				patAdd.setObject(25, pln.getStdStyleDesc());
				patAdd.setObject(26, actdimater);
				patAdd.setObject(27, actheight);
				patAdd.setObject(28, actlen);
				patAdd.setObject(29, actlenmin);
				patAdd.setObject(30, actlenmax);
				patAdd.setObject(31, pln.getOrdLnDlyPk());
				patAdd.setObject(32, pln.getOrderNo());
				patAdd.setObject(33, pln.getOrderSeq());
				patAdd.setObject(34, pln.getDeliveryNo());
				patAdd.setObject(35, countNum);
				patAdd.setObject(36, weightNum);
				patAdd.setObject(37, name);
				patAdd.setObject(38, bc);
				patAdd.setObject(39, bz);
				patAdd.setObject(40, time);
				// 如果有离线新增到材料表
				if (!count.equals("") && !count.equals("0")) {
					PlanService.AddOffLineMat(connection, "F", load
							.getColUser(), "11", lvMat.getMatNo(), slgx,
							heatPlanNo);
				}
			}
			// 新增离线从表
			for (int i = 0; i < list1.size(); i++) {
				String resultsqe = "";
				sqlloading = CoreXmlSqlParsersFactory
						.getSql("AppearanceService.querymaxsqe");// 查询从表最大序号
				psta = connection.prepareStatement(sqlloading);
				psta.setObject(1, matter1.format(now));
				psta.setObject(2, heatPlanNo);
				psta.setObject(3, plinCode);
				ResultSet rs3 = psta.executeQuery();
				if (rs3.next()) {
					resultsqe = rs3.getString("RESULT_SQE");
				}

				rs3.close();
				psta.close();
				HttOfflineResultDentity resultD = list1.get(i);
				patAddD.setObject(1, resultNo);
				patAddD.setObject(2, resultsqe);
				patAddD.setObject(3, heatPlanNo);
				patAddD.setObject(4, plinCode);
				patAddD.setObject(5, pln.getPlineName());
				patAddD.setObject(6, count);
				patAddD.setObject(7, resultD.getGowhereCode());
				patAddD.setObject(8, resultD.getGowhereName());
				patAddD.setObject(9, time);
				patAddD.setObject(10, slgx);
				patAddD.setObject(11, slgx);
				patAddD.addBatch();
				patAddD.executeBatch();
			}
			patAdd.addBatch();
			patAdd.executeBatch();
			core.setV_errMsg("离线成功！");
			core.setResult(1);
			connection.commit();
		} catch (Exception e) {
			core.setV_errMsg(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return core;
	}

	/**
	 * 每支材料对应的入库单号
	 * 
	 * @param conn
	 *            c
	 * @param strlist
	 *            传递参数
	 * @return obj
	 * @throws Exception
	 *             异常处理
	 */
	public String querySendSqlDoc(Connection conn, String strlist, String memo)
			throws Exception {
		String seq = "";
		PreparedStatement psta = null;
		Date dt = new Date();
		SimpleDateFormat matter1 = new SimpleDateFormat("yyyy-MM-dd");
		SimpleDateFormat matter2 = new SimpleDateFormat("yyMMdd");
		String sqlLovsqe = CoreXmlSqlParsersFactory
				.getSql("AppearanceService.getInListDoc");
		psta = conn.prepareStatement(sqlLovsqe);
		psta.setString(1, memo);
		psta.setString(2, matter2.format(dt));
		psta.setString(3, matter1.format(dt));
		psta.setString(4, strlist);
		ResultSet rs = psta.executeQuery();
		if (rs.next()) {
			seq = rs.getString("INSTOCK_DOC");
		}
		rs.close();
		psta.close();
		return seq;
	}

	/**
	 * 每支材料对应的入库流水号
	 * 
	 * @param conn
	 *            c
	 * @param strlist
	 *            传递参数
	 * @return obj
	 * @throws Exception
	 *             异常处理
	 */
	public String querySendSql(Connection conn, String strlist)
			throws Exception {
		String seq = "";
		PreparedStatement psta = null;
		String sqlLovsqe = CoreXmlSqlParsersFactory
				.getSql("AppearanceService.getInListDoc1");
		psta = conn.prepareStatement(sqlLovsqe);
		psta.setString(1, strlist);
		ResultSet rs = psta.executeQuery();
		if (rs.next()) {
			seq = rs.getString("INSTOCK_SQE");
		}
		rs.close();
		psta.close();
		return seq;
	}

	/**
	 * 查询探伤合格支数的和
	 */
	public CoreReturnObject getCrackStand(String ORD_LN_DLY_PK,
			String CRAFT_SEQ, String DIC, String SIC, String MSC_PLINE,
			String PROCESS_CODE) {
		return this.getDataBySqlID("FrmHttCrackDetectResult.getCrackStand",
				new Object[] { ORD_LN_DLY_PK, CRAFT_SEQ, MSC_PLINE, DIC });
	}

	/**
	 * 查询探伤合格支数的和
	 */
	public CoreReturnObject getCrackStand(String DesignKey, String DIC,
			String SIC, String MSC_PLINE, String PROCESS_CODE) {
		return this.getDataBySqlID("FrmHttCrackDetectResult.getCrackStand1",
				new Object[] { DesignKey, DIC, MSC_PLINE });
	}

	public CoreReturnObject getCrackPara(String ResultNo, Integer ReportNo) {
		return this.getDataBySqlID("FrmHttCrackDetectResult.getCrackPara",
				new Object[] { ResultNo, ReportNo });
	}

	public CoreReturnObject getReportDeafault(String plineCode, Integer ReportNo) {
		return getReportDeafault(plineCode, ReportNo, "1");
	}

	public CoreReturnObject getReportDeafault(String plineCode,
			Integer ReportNo, String MACHINE_NO) {
		return this.getDataBySqlID("FrmHttCrackDetectResult.getReportDeafault",
				new Object[] { plineCode, ReportNo, MACHINE_NO });
	}

	public CoreReturnObject getReportType(String plineCode) {
		return this.getDataBySqlID("FrmHttCrackDetectResult.getReportType",
				new Object[] { plineCode });
	}

	public CoreReturnObject getHttSign(String plineCode, String PROCESS_NO) {
		return this.getDataBySqlID("FrmHttCrackDetectResult.getHttSign",
				new Object[] { plineCode, PROCESS_NO });
	}

	public CoreReturnObject UpdateReportUrl(String ResultNo, String ReportNo,
			String Url) {
		return this.setDataBySqlID("FrmHttCrackDetectResult.UpdateReportUrl",
				new Object[] { Url, ResultNo, ReportNo });
	}

	public Date GetDateByStr(String Data) throws ParseException {
		SimpleDateFormat matter1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		SimpleDateFormat matter2 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		SimpleDateFormat matter3 = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
		SimpleDateFormat matter4 = new SimpleDateFormat("yyyy/MM/dd HH:mm");

		if (Data.split(":").length == 2) {
			if (Data.contains("/")) {
				return matter4.parse(Data);
			} else {
				return matter2.parse(Data);
			}
		} else {
			if (Data.contains("/")) {
				return matter3.parse(Data);
			} else {
				return matter1.parse(Data);
			}
		}

	}

	
	
	public CoreReturnObject updatePara(String loadStr,
			String CrackParaStr,
			ArrayList<String> ProbeString, ArrayList<String> StandString) {
		CoreReturnObject core = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		PreparedStatement psta = null;


		try {
			connection.setAutoCommit(false); //

			

			HttCrackDetectionEtEntity Load = EntityTool.getEntityByJSONStr(
					loadStr, HttCrackDetectionEtEntity.class);
			HttCrackDetectionParaEntity Para = EntityTool.getEntityByJSONStr(
					CrackParaStr, HttCrackDetectionParaEntity.class);
			Para.setResultNo(Load.getResultNo());
			
			if (Load.getTestingType().equals("")) {
				core.setV_errMsg("探伤种类不能为空！");
				return core;
			}

			if (Load.getTestingGrade().equals("")
					&& !Para.getAccpetanceLevel().equals("")) {
				Load.setTestingGrade(Para.getAccpetanceLevel());
			}

			if (Load.getTestingGrade().equals("")
					&& !Load.getTestingType().equals("MT")) {
				core.setV_errMsg("探伤等级不能为空！");
				return core;
			}

			



			String sql = CoreXmlSqlParsersFactory
					.getSql("FrmHttCrackDetectResult.updateResultData");
			
			sql = com.steering.common.EntityTool.fillSqlByEntity(sql,
					Load);
			psta = connection.prepareStatement(sql);
			psta.executeUpdate();
			psta.close();
			
			
			String probeId = Para.getProbeId();
			
			if(!"".equals(Para.getProbeId())){
				sql = CoreXmlSqlParsersFactory
						.getSql("FrmHttCrackDetectResult.deleteHttCrackResultProbe");
				psta = connection.prepareStatement(sql);
				psta.setObject(1, Load.getResultNo());
				psta.executeUpdate();
				psta.close();
			}
			
			if (ProbeString.size() > 0) {
				
				if("".endsWith(probeId)){
					
					sql = CoreXmlSqlParsersFactory
							.getSql("FrmHttCrackDetectResult.getMaxProbeId");
					psta = connection.prepareStatement(sql);
					psta.setObject(1, Load.getJudgeStoveNo() + Load.getBatchNo());
					psta.setObject(2, Load.getJudgeStoveNo() + Load.getBatchNo());

					ResultSet rs1 = psta.executeQuery();
					if (rs1.next()) {
						probeId = rs1.getString("PROBE_ID");
					}
					rs1.close();
					psta.close();
				}
				

				for (int i = 0; i < ProbeString.size(); i++) {
					HttCrackDetectionProbeEntity probeEntity = EntityTool
							.getEntityByJSONStr(ProbeString.get(i),
									HttCrackDetectionProbeEntity.class);

					sql = CoreXmlSqlParsersFactory
							.getSql("FrmHttCrackDetectResult.AddCrackDetectionProbe");
					probeEntity.setProbeId(probeId);
					probeEntity.setProbeSeq((i + 1) + "");
					sql = com.steering.common.EntityTool.fillSqlByEntity(
							sql, probeEntity);
					psta = connection
							.prepareStatement(sql);
					psta.executeUpdate();
					psta.close();
				}
				
				
			}
			
			Para.setProbeId(probeId);

			String StandID = Para.getStandardId();
			
			if(!"".equals(Para.getStandardId())){
				sql = CoreXmlSqlParsersFactory
						.getSql("FrmHttCrackDetectResult.deleteHttCrackResultStandard");
				psta = connection.prepareStatement(sql);
				psta.setObject(1, Load.getResultNo());
				psta.executeUpdate();
				psta.close();
			}
			

			if (StandString.size() > 0) {
				
				
				if("".endsWith(StandID)){
					
				sql = CoreXmlSqlParsersFactory
						.getSql("FrmHttCrackDetectResult.getMaxStandID");
				psta = connection.prepareStatement(sql);
				psta.setObject(1, Load.getJudgeStoveNo() + Load.getBatchNo());
				psta.setObject(2, Load.getJudgeStoveNo() + Load.getBatchNo());

				ResultSet rs1 = psta.executeQuery();
				if (rs1.next()) {
					StandID = rs1.getString("STANDARD_ID");
				}
				rs1.close();
				psta.close();
				}
				
				
				for (int i = 0; i < StandString.size(); i++) {
					HttCrackDetectionStandardEntity probeEntity = EntityTool
							.getEntityByJSONStr(StandString.get(i),
									HttCrackDetectionStandardEntity.class);

					 sql = CoreXmlSqlParsersFactory
							.getSql("FrmHttCrackDetectResult.AddCrackDetectionStandard");
					probeEntity.setStandardId(StandID);
					probeEntity.setStandardSeq((i + 1) + "");
					sql = com.steering.common.EntityTool.fillSqlByEntity(
							sql, probeEntity);
					psta = connection
							.prepareStatement(sql);
					psta.executeUpdate();
					psta.close();
				}
			}

			
			Para.setStandardId(StandID);
			
			sql = CoreXmlSqlParsersFactory
					.getSql("FrmHttCrackDetectResult.UpdateCrackDetectionPara");
			
			sql = com.steering.common.EntityTool.fillSqlByEntity(sql,
					Para);
			psta = connection.prepareStatement(sql);
			psta.executeUpdate();
			psta.close();
			
		
		
			core.setV_errMsg("保存成功！");
			core.setResult(1);
			connection.commit();
		} catch (Exception e) {
			core.setV_errMsg(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return core;
	}

}
