package com.steering.mes.zgmil.coup;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Pattern;

import com.steering.comm.db.DBCommon;

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

import com.steering.comm.tools.StringTool;
import com.steering.common.EntityTool;
import com.steering.mes.signature.MeanValueCalculation;
import com.steering.mes.zgmil.entity.FeedRowPlan;
import com.steering.mes.zgmil.entity.MilPlanEntity;
import com.steering.mes.zgmil.entity.FeedSawResultEntity;
import com.steering.mes.zgmil.entity.MilSlabScrapSeqEntity;
import com.steering.mes.zgmil.entity.MilBaseAddressEntity;

/**
 * 上料锯切实绩业务类
 * 
 * @author lr 2015/05/28
 * @version v1.0
 */
public class FeedSawResult extends DBCommon {

	/**
	 * 查询简单作业计划（上料锯切在下面单独查询）
	 * 
	 * @param MilPlan
	 *            作业计划实体类
	 * @param ProcessNo
	 *            工序号 1-锯切 2-环形加热炉 3-穿孔 4-连轧 5-再加热炉 6-定径 7-管排锯 8-矫直 9-ET探伤...
	 *            11-涡流探伤 12-人工质检
	 * @return CoreReturnObject
	 * @Return 0-未开始 1-工序已开始
	 */
	public CoreReturnObject getSingleMainPlan(
			com.steering.mes.zgmil.entity.MilPlan MilPlan, Integer ProcessNo) {
		String[] TableNameList = new String[] { "MIL_FEEDSAW_RESULT",
				"MIL_FUR_Result", "MIL_PERFORATION_Result",
				"MIL_ROLLING_Result", "MIL_REFUR_Result", "MIL_SIZING_Result",
				"MIL_SAW_Result", "MIL_STRAIGHTENING_RESULT", "MIL_ET_RESULT",
				"MIL_SURFACE_RESULT", "MIL_MT_RESULT", "MIL_UL_RESUL" };
		String TableName = TableNameList[ProcessNo - 1];
		// String Judge_Stove_No = "Judge_Stove_No";
		String BackFlag = "0,1,5";
		int opProcess = 0;
		if (ProcessNo.equals(1)) {
			opProcess = 0;
		} else if (ProcessNo.equals(3)) {
			opProcess = 3;
		} else if (ProcessNo.equals(4)) {
			opProcess = 4;
		} else if (ProcessNo.equals(6)) {
			opProcess = 6;
		} else if (ProcessNo.equals(7)) {
			opProcess = 7;
		} else if (ProcessNo.equals(8)) {
			opProcess = 9;
		} else if (ProcessNo.equals(9) || ProcessNo.equals(11)
				|| ProcessNo.equals(12)) {
			opProcess = 10;
		} else if (ProcessNo.equals(10)) {
			opProcess = 11;
		}

		if (ProcessNo.equals(6)) {
			BackFlag = "0,1,5";
		} else if (ProcessNo.equals(8)) {
			BackFlag = "0,1,5,7";
		} else if (ProcessNo > 8 && !ProcessNo.equals(10)) {
			BackFlag = "0,1,5,7,8";
		}
		if (ProcessNo.equals(10)) {
			BackFlag = "0,1,5,7,8,9";
		}
		String Sql = "SELECT T1.* FROM (";
		Sql += "SELECT b.CUT_NUM,a.ID,a.SEQ,a.STOVE_NO,a.JUDGE_STOVE_NO,REGEXP_REPLACE(a.JUDGE_STOVE_NO, '-.*', '') as JUDGE_NO,a.LOT_NO,a.CONTRACT_NO,a.IMP_PROCESS,a.PLINE_CODE,a.BACK_PLAN_FLAG,a.ORD_LN_DLY_PK,";
		Sql += "CASE a.STATUS WHEN ";
		Sql += "'00' THEN '上料' WHEN '05' THEN '开始锯切' WHEN  '10'	THEN '锯切完成' WHEN  '15' THEN '入炉' WHEN '20'	THEN '出炉' WHEN '25' THEN '开始穿孔' WHEN '30'	THEN '穿孔完成' WHEN ";
		Sql += " '35' THEN '开始连轧' WHEN  '40'	THEN '连轧完成' WHEN '45' THEN '入再加热炉' WHEN '50'	THEN '出再加热炉' WHEN '55' THEN '开始定径' WHEN '60'	THEN '定径完成' WHEN ";
		Sql += " '65' THEN '开始分切' WHEN '70'	THEN '分切完成' WHEN '75' THEN '开始矫直' WHEN '80'	THEN '矫直完成 ' WHEN '85' THEN '开始探伤' WHEN '90'	THEN '探伤完成' WHEN	 '95' THEN '人工质检开始' WHEN ";
		Sql += "  '99'	THEN '入库' END AS STATUS,";
		Sql += " a.PRODUCER, a.PROCESS_STATUS, a.DB_LENGTH, a.DB_HEIGHT, a.ROLL_LENGTH, a.SAW_NUM, a.TARGET_LENGTH, a.FINISH_USER, a.TARGET_LIABRARY, a.VARIETIES, a.PIPE_SIZE, ";
		Sql += " a.BUCKLE_TYPE, a.LENGTH_RANGE, a.ROLL_STANDRAD,a.PIPE_SECTION, a.STEELCODE, a.STEELNAME, a.GRADECODE,  a.GRADENAME, a.STEEL_STANDRAD, a.TARGET, BRANCH,";
		Sql += "a.TON, a.CUT_TARGET,a.CUT_LENGTH, a.CUT_WEIGHT, a.DB_NUM, CASE a.NODE_STATUS WHEN  '00' THEN '' WHEN '10'	THEN '锯切完成' WHEN '15' THEN '入炉' WHEN '20'	THEN '出炉' WHEN ";
		Sql += " '25' THEN '开始穿孔' WHEN '30'	THEN '穿孔完成' WHEN '35' THEN '开始连轧' WHEN '40'	THEN '连轧完成' WHEN '45' THEN '入再加热炉' WHEN '50'	THEN '出再加热炉' WHEN '55' THEN '开始定径' WHEN ";
		Sql += " '60'	THEN '定径完成' WHEN '65' THEN '开始分切' WHEN '70'	THEN '分切完成' WHEN '75' THEN '开始矫直' WHEN '80'	THEN '矫直完成 ' WHEN '85' THEN '开始探伤' WHEN '90'	THEN '探伤完成' WHEN	 '96' THEN '人工质检完成' WHEN '99' THEN '交库'";
		Sql += " END AS NODE_STATUS,A.PRO_PLAN_ID,A.GX_PLAN_NO,";
		if (ProcessNo.equals(2) || ProcessNo.equals(5)) {
			Sql += " Nvl((select max(b.IS_START) FROM "
					+ TableName
					+ " b where b.judge_stove_no = a.judge_Stove_no) ,4)AS IS_START, ";
		} else {
			Sql += " Nvl((select  b.NODE_FUR_FLAG from "
					+ TableName
					+ " b where b.judge_stove_no = a.judge_Stove_no) ,3)AS IS_START ,";
		}
		Sql += " ((select count(*) from PORT_MIL_BATCH_SAMPLE_RESULT t where t.judge_stove_no = a.JUDGE_STOVE_NO and t.status = '0') +(select count(*) from PORT_MIL_BATCH_SAMPLE_RESULT t where t.judge_stove_no = a.JUDGE_STOVE_NO and trim(t.op_process) >= "
				+ opProcess + "))PLAN_COUNT,";
		Sql += " TO_CHAR(a.START_TIME, 'YYYY-MM-DD HH24:MI:SS') START_TIME, TO_CHAR(a.END_TIME, 'YYYY-MM-DD HH24:MI:SS') END_TIME, TO_CHAR(a.TOM, 'YYYY-MM-DD HH24:MI:SS') TOM, TO_CHAR(a.TOC, 'YYYY-MM-DD HH24:MI:SS') TOC ";
		Sql += "   FROM MIL_PLAN   a  ,MIL_FEEDSAW_RESULT b";

		Sql += "  WHERE a.LOT_NO || '&' LIKE '%' || '" + MilPlan.getLotNo()
				+ "' || '%' ";
		Sql += "  AND a.JUDGE_STOVE_NO || '&' LIKE '%' || '"
				+ MilPlan.getJudgeStoveNo() + "' || '%' ";
		Sql += "  and  a.NODE_STATUS between " + MilPlan.getStartStatus()
				+ " and " + MilPlan.getStatus() + " ";
		Sql += " AND a.PLINE_CODE = '" + MilPlan.getPlineCode() + "'";
		Sql += "   and a.BACK_PLAN_FLAG in ( " + BackFlag + ")";
		Sql += " and a.judge_stove_no = b.judge_stove_no(+)";
		Sql += " and a.id = b.Result_NO(+) AND A.BACK_SLAB_FLAG <> '2' and a.IS_LOAD = '1' ";
		if (ProcessNo > 1) {
			Sql += " AND STATUS>'00'   ";
		}
		// if (ProcessNo > 1) {
		// Sql += " AND a.rolling_status in ('0','1')";
		// }
		Sql += "  order by   a.FEED_TIME  ,a.START_TIME)T1";
		Sql += " WHERE (T1.PLAN_COUNT > 0 OR T1.STATUS = '上料')";
		return this.getData(Sql);
	}

	/**
	 * 查询简单作业计划（上料锯切）
	 * 
	 * @param MilPlan
	 * @return
	 */
	public CoreReturnObject getSingleMainPlan(
			com.steering.mes.zgmil.entity.MilPlan MilPlan) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FeedResult.getSingleMainPlan");
		String sql1 = "";
		if (!MilPlan.getJudgeStoveNo().equals("")) {
			sql1 += " AND a.JUDGE_STOVE_NO like '" + MilPlan.getJudgeStoveNo()
					+ "%'";
		}
		if (!MilPlan.getLotNo().equals("")) {
			sql1 += " AND a.LOT_NO like '" + MilPlan.getLotNo() + "%'";
		}
		//if (!MilPlan.getPlineCode().equals("")) {
			sql1 += " AND a.PLINE_CODE = '" + MilPlan.getPlineCode() + "'";
		//}
		sql1 += " and a.NODE_STATUS between " + MilPlan.getStartStatus()
				+ " and " + MilPlan.getStatus();
		return this.getData(sql.replace("#something#", sql1));

	}

	/**
	 * 查询简单作业计划
	 * 
	 * @param MilPlan
	 *            作业计划实体类
	 * @param
	 * @return CoreReturnObject
	 */
	public CoreReturnObject getSingleMainPlanForHeatNo(
			com.steering.mes.zgmil.entity.MilPlan MilPlan) {
		return this.getDataBySqlID("FeedResult.PlanQueryForHeatNo",
				new Object[] { MilPlan.getJudgeStoveNo(),
						MilPlan.getProPlanId(), MilPlan.getGxPlanNo() });

	}

	/**
	 * 查询该炉进程表的投入量是否写入
	 * 
	 * @param judgeStoveNo
	 * @return
	 */
	public CoreReturnObject getInputWeigtht(String judgeStoveNo) {
		return this.getDataBySqlID("FeedResult.getInputWeigtht",
				new Object[] { judgeStoveNo });

	}

	/**
	 * 查询简单上料计划已定径
	 * 
	 * @param FeedRowPlan
	 *            上料计划实体类
	 * @return CoreReturnObject
	 */
	public CoreReturnObject getSingleFeedPlan(
			com.steering.mes.zgmil.entity.FeedRowPlan FeedRowPlan) {
		return this.getDataBySqlID("FeedResult.FeedPlanQuery", new Object[] {
				FeedRowPlan.getStartStatus(), FeedRowPlan.getSawFalg(),
				FeedRowPlan.getLotNo(), FeedRowPlan.getJudgeStoveNo(),
				FeedRowPlan.getFeedRowNo(), FeedRowPlan.getPlineCode() });
	}

	/**
	 * 查询简单上料计划已定径
	 * 
	 * @param FeedRowPlan
	 *            上料计划实体类
	 * @return CoreReturnObject
	 */
	public CoreReturnObject getSingleFeedPlanForFeedRowNo(String JudgeStoveNo,
			String FeedRowNo, String proPlanId, String gxPlanNo) {
		return this.getDataBySqlID("FeedResult.FeedPlanQueryForFeedRowNo",
				new Object[] { JudgeStoveNo, FeedRowNo, proPlanId, gxPlanNo });
	}

	/**
	 * 查询上料管号队列
	 * 
	 * @param JudgeStoveNo
	 *            --炉号 FeedRowNo--上料行号
	 * @return CoreReturnObject
	 */
	public CoreReturnObject getFeedRackSeq(String JudgeStoveNo, String FeedRowNo) {
		return this.getDataBySqlID("FeedResult.FeedRackSeqQuery", new Object[] {
				JudgeStoveNo, FeedRowNo });
	}

	/**
	 * 查询流通卡信息
	 * 
	 * @param JudgeStoveNo
	 *            炉号
	 * @return CoreReturnObject
	 */
	public CoreReturnObject getRollingCard(String JudgeStoveNo,
			String proPlanId, String gxPlanNo) {
		return this.getDataBySqlID("FeedResult.RollingCardQuery", new Object[] {
				JudgeStoveNo, proPlanId, gxPlanNo });
	}

	/**
	 * 查询流通卡信息
	 * 
	 * @param JudgeStoveNo
	 *            炉号
	 * @return CoreReturnObject
	 */
	public CoreReturnObject getRollingCardBackLine(String JudgeStoveNo,
			String proPlanId, String gxPlanNo) {
		return this.getDataBySqlID("FeedResult.getRollingCardBackLine",
				new Object[] { JudgeStoveNo, proPlanId, gxPlanNo });
	}

	/**
	 * 查询该炉号结炉状态
	 * 
	 */
	public CoreReturnObject getNodeStatus(String JudgeStoveNo, String ResultNo,
			String proPlanId, String gxPlanNo) {
		String Sql = " SELECT NODE_STATUS FROM MIL_PLAN WHERE JUDGE_STOVE_NO = '"
				+ JudgeStoveNo
				+ "' and ID = '"
				+ ResultNo
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
				+ proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
				+ gxPlanNo
				+ "','/')";
		return this.getData(Sql);
	}

	/**
	 * 最后一支入炉 交班取消
	 * 
	 * @param JudgeStoveNo
	 *            炉号
	 * @return CoreReturnObject
	 */
	public CoreReturnObject ChangeShiftBackForLastInFur(String JudgeStoveNo,
			String ResultNo, String PLineCode, String Shift, String Group,
			Integer process, Integer changnumhas, Integer changnumhasInfur,
			String colno, String proPlanId, String gxPlanNo) {
		ArrayList<String> sqllist = new ArrayList<String>();
		String[] TableRackList = new String[] { "MIL_FEED_RACK",
				"MIL_FUR_RACK", "MIL_PERFORATION_RACK", "MIL_ROLLING_RACK",
				"MIL_REFUR_RACK", "MIL_SIZING_RACK", "MIL_SAW_RACK",
				"MIL_STRAIGH_RACK", "MIL_TESTING_RACK", "MIL_QA_RACK" };
		String[] TableNameList = new String[] { "MIL_FEEDSAW_RESULT",
				"MIL_FUR_Result", "MIL_PERFORATION_Result",
				"MIL_ROLLING_Result", "MIL_REFUR_Result", "MIL_SIZING_Result",
				"MIL_SAW_Result", "MIL_STRAIGHTENING_RESULT", "MIL_ET_RESULT",
				"MIL_MT_RESULT", "MIL_UL_RESUL", "MIL_SURFACE_RESULT" };
		String[] StartTimeList = new String[] { "FEED_TIME", "IN_FUR_TIME",
				"START_PERFORATION_TIME", "START_ROLLING_TIME",
				"IN_REFUR_TIME", "START_SIZING_TIME", "START_SAW_TIME",
				"START_STRAIGHTENING_TIME", "START_INSPECTION_TIME",
				"START_TIME" };
		String[] EndTimeList = new String[] { "END_TIME", "OUT_FUR_TIME",
				"END_PERFORATION_TIME", "END_ROLLING_TIME", "OUT_REFUR_TIME",
				"END_SIZING_TIME", "END_SAW_TIME", "END_STRAIGHTENING_TIME",
				"END_INSPECTION_TIME", "END_TIME" };
		String changstring = "";
		String starttime = StartTimeList[process];
		String endtime = EndTimeList[process];
		String tablerack = TableRackList[process];
		String tableresult = "";
		if (process.equals(1)) {
			tableresult = "MIL_FUR_RESULT";
		} else {
			tableresult = "MIL_REFUR_RESULT";
		}

		// 修改实绩主表
		String sql1 = "update " + tableresult
				+ "  set OUT_CHANGE_NUM = OUT_CHANGE_NUM -" + changnumhas
				+ " where JUDGE_STOVE_NO = '" + JudgeStoveNo
				+ "' and RESULT_NO = '" + ResultNo
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
				+ "','/')";

		// 修改跟踪表
		String sql2 = "update  "
				+ tablerack
				+ " T set T.COL_SHIFT = ''  , T.COL_GROUP = '' , T.COL_USER='',T."
				+ endtime
				+ " = '', t.OUT_CHANGE_FLAG = '0' WHERE T.JUDGE_STOVE_NO = '"
				+ JudgeStoveNo + "' and T.RESULT_NO = '" + ResultNo
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
				+ "','/')";
		sql2 += " AND T.COL_SHIFT =" + Shift + " AND T.COL_GROUP=" + Group;
		sqllist.add(sql1);
		sqllist.add(sql2);
		return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(
				sqllist);
	}

	/**
	 * 查询生产批号最大流水号
	 * 
	 * @param LotNo
	 *            生产批号
	 * @return CoreReturnObject
	 */
	public CoreReturnObject getLotSeq(String LotNo) {
		return this.getDataBySqlID("FeedResult.getLotSeq",
				new Object[] { LotNo });
	}

	/**
	 * 查询流通卡信息
	 * 
	 * @param JudgeStoveNo
	 *            炉号
	 * @return CoreReturnObject
	 */
	public CoreReturnObject getRollingCard1(String JudgeStoveNo,
			String proPlanId, String gxPlanNo) {
		return this.getDataBySqlID("FeedResult.RollingCardQuery1",
				new Object[] { JudgeStoveNo, proPlanId, gxPlanNo });
	}

	/**
	 * 查询流通卡信息
	 * 
	 * @param JudgeStoveNo
	 *            炉号
	 * @return CoreReturnObject
	 */
	public CoreReturnObject getRollingStaCard1(String JudgeStoveNo,
			String proPlanId, String gxPlanNo) {
		return this.getDataBySqlID("FeedResult.getRollingStaCard1",
				new Object[] { JudgeStoveNo, proPlanId, gxPlanNo });
	}

	/***
	 * 查询返线流通卡
	 * 
	 * @param JudgeStoveNo
	 * @return
	 */
	public CoreReturnObject getRollingCard1BackLine(String JudgeStoveNo,
			String proPlanId, String gxPlanNo) {
		return this.getDataBySqlID("FeedResult.getRollingCard1BackLine",
				new Object[] { JudgeStoveNo, proPlanId, gxPlanNo });
	}

	/**
	 * 查询单倍重 加热炉烧损率 再加热炉烧损率
	 * 
	 * @param JudgeStoveNo
	 *            炉号
	 * @return CoreReturnObject
	 */
	public CoreReturnObject getDbHeight(String JudgeStoveNo, String ResultNo,
			String proPlanId, String gxPlanNo) {
		return this.getDataBySqlID("FeedResult.getDbHeight", new Object[] {
				JudgeStoveNo, ResultNo, proPlanId, gxPlanNo });
	}
	
//	TZH 24.4.24 注销物流接口
//	/**
//	 * 修改msql表中的计划状态 上料
//	 * 
//	 * @param JudgeStoveNo
//	 *            炉号
//	 * @return CoreReturnObject
//	 */
//	public CoreReturnObject updateMSQLStartStatus(ArrayList FeedRowID) {
//
//		ArrayList<String> sqllist = new ArrayList<String>();
//		String sql = "";
//		for (int i = 0; i < FeedRowID.size(); i++) {
//			sql = "Update  [TPCO_CXPLAN].[dbo].[tabcxslsj] set cxstu = '20'  where  [id] = '"
//					+ FeedRowID.get(i) + "'";
//			sqllist.add(sql);
//		}
//
//		return this.getDao("MSSQL1Dao").ExcuteTransction(sqllist);
//
//	}

//	TZH 24.4.24 注销物流接口
//	/**
//	 * 修改msql表中的计划状态 上料回退
//	 * 
//	 * @param JudgeStoveNo
//	 *            炉号
//	 * @return CoreReturnObject
//	 */
//	public CoreReturnObject updateMSQLStartBackStatus(ArrayList FeedRowID) {
//
//		ArrayList<String> sqllist = new ArrayList<String>();
//		String sql = "";
//		for (int i = 0; i < FeedRowID.size(); i++) {
//			sql = "Update  [TPCO_CXPLAN].[dbo].[tabcxslsj] set cxstu = '00'  where  [id] = '"
//					+ FeedRowID.get(i) + "'";
//			sqllist.add(sql);
//		}
//
//		return this.getDao("MSSQL1Dao").ExcuteTransction(sqllist);
//
//	}

	/**
	 * 新增上料跟踪、加热炉跟踪、轧区跟踪、精整跟踪记录
	 * 
	 * @param FeedRowPlan
	 *            上料计划实体类
	 * @return CoreReturnObject
	 */
	public CoreReturnObject AddRack(
			com.steering.mes.zgmil.entity.FeedRowPlan FeedRowPlan, String Status) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection conn = null;
		PreparedStatement psta = null;
		PreparedStatement psta1 = null;
		String MatNo = "";
		String ColGroup = FeedRowPlan.getColGroup();
		String ColShift = FeedRowPlan.getColShift();
		String ColUser = FeedRowPlan.getColUser();
		try {
			conn = this.getDao("TgDao").getConnection();
			conn.setAutoCommit(false);
			String sql = "";
			ResultSet rs = null;
			ResultSet rs1 = null;
			String JundgeStoveNo = FeedRowPlan.getJudgeStoveNo();
			String JudgeStoveNoForMat = "";
			if (JundgeStoveNo.length() > 6) {
				JudgeStoveNoForMat = JundgeStoveNo.replaceFirst("-.*", "");
			} else {
				JudgeStoveNoForMat = JundgeStoveNo;
			}
			sql = CoreXmlSqlParsersFactory.getSql("FeedResult.FeedPlanQuery");
			psta1 = conn.prepareStatement(sql);
			psta1.setString(1, "00");
			psta1.setString(2, "96");
			psta1.setString(3, "");
			psta1.setString(4, JundgeStoveNo);
			psta1.setString(5, "");
			psta1.setString(6, FeedRowPlan.getPlineCode());
			rs = psta1.executeQuery();

			sql = CoreXmlSqlParsersFactory.getSql("FeedResult.SinglePlanQuery");
			psta = conn.prepareStatement(sql);
			psta.setString(1, JundgeStoveNo);
			psta.setString(2, FeedRowPlan.getProPlanId());
			psta.setString(3, FeedRowPlan.getGxPlanNo());
			rs1 = psta.executeQuery();
			int x = 0;
			int feedSeq = 0;
			int rollSeq = 0;
			int finishSeq = 0;
			while (rs1.next()) {
				// double DBHeight = rs1.getDouble(1); //单倍重量
				// double RollLength = rs1.getDouble(2);
				int SawNum = rs1.getInt(3);
				// double TargetLength = rs1.getDouble(4);
				// String TargetLiabrary = rs1.getString(5);
				// String PipeSize = rs1.getString(6);//成品规格
				double PipeSection = rs1.getDouble(7);
				String ProcessStatue = rs1.getString(9);
				String ResultNo = rs1.getString(10);

				while (rs.next()) {
					String FeedRowNo = rs.getString(1);
					// String Seq = rs.getString(2);
					String LotNo = rs.getString(3);
					String StoveNo = rs.getString(4);
					String PlineCode = rs.getString(6);
					int DBNum = rs.getInt(7);
					double DBLength = rs.getDouble(8);
					double MatHeight = rs.getDouble(9);// 上料重量
					int FeedNum = rs.getInt(12);
					double FeedLength = rs.getDouble(14);

					// 添加上料跟踪表记录
					for (int i = 0; i < FeedNum; i++) {
						int SEQ = 1 + i + feedSeq;
						int No = 1 + feedSeq;
						DecimalFormat df = new DecimalFormat("000");
						MatNo = JudgeStoveNoForMat + df.format(No + i);

						sql = CoreXmlSqlParsersFactory
								.getSql("FeedResult.AddFeedRack");
						psta = conn.prepareStatement(sql);
						psta.setString(1, MatNo);
						psta.setString(2, LotNo);
						psta.setString(3, StoveNo);
						psta.setString(4, JundgeStoveNo);
						psta.setString(5, PlineCode);
						psta.setDouble(6, PipeSection);
						psta.setDouble(7, FeedLength);
						psta.setDouble(8, MatHeight);
						psta.setInt(9, DBNum);
						psta.setDouble(10, DBLength);
						psta.setString(11, "1");
						psta.setString(12, "");
						psta.setString(13, "");
						psta.setString(14, "");
						psta.setString(15, FeedRowNo);
						psta.setString(16, "1");
						psta.setInt(17, SEQ);
						psta.setString(18, ResultNo);
						psta.setString(19, FeedRowPlan.getProPlanId());
						psta.setString(20, FeedRowPlan.getGxPlanNo());
						int AddFeedCount = psta.executeUpdate();
						psta.close();

						/*
						 * sql =CoreXmlSqlParsersFactory.getSql(
						 * "FeedResult.AddFeedHistory"); psta =
						 * conn.prepareStatement(sql); psta.setString(1, MatNo);
						 * psta.setString(2, LotNo); psta.setString(3, StoveNo);
						 * psta.setString(4, JundgeStoveNo); psta.setString(5,
						 * PlineCode); psta.setDouble(6, PipeSection);
						 * psta.setDouble(7, FeedLength); psta.setDouble(8,
						 * MatHeight); psta.setInt(9, DBNum); psta.setDouble(10,
						 * DBLength); psta.setString(11, "1");
						 * psta.setString(12, ColUser); psta.setString(13,
						 * ColShift); psta.setString(14, ColGroup);
						 * psta.setString(15,FeedRowNo); psta.setString(16,"1");
						 * psta.setInt(17,SEQ); psta.setString(18,"0"); int
						 * AddFeedHistoryCount = psta.executeUpdate();
						 * psta.close();
						 */
						// 添加加热炉跟踪表、轧区跟踪表记录
						for (int j = 0; j < DBNum; j++) {
							SEQ = (i * DBNum) + (1 + j) + rollSeq;
							String No1 = "1";
							int temp = Integer.parseInt(No1) + j;
							No1 = temp + "";
							String RollMatNo = MatNo + No1;

							sql = CoreXmlSqlParsersFactory
									.getSql("FeedResult.AddFurRack");
							psta = conn.prepareStatement(sql);
							psta.setString(1, "");
							psta.setString(2, LotNo);
							psta.setString(3, StoveNo);
							psta.setString(4, JundgeStoveNo);
							psta.setString(5, PlineCode);
							psta.setString(6, "0");
							psta.setString(7, "");
							psta.setString(8, "");
							psta.setString(9, "");
							psta.setString(10, "0");
							psta.setInt(11, SEQ);
							psta.setString(12, ResultNo);
							psta.setString(13, FeedRowPlan.getProPlanId());
							psta.setString(14, FeedRowPlan.getGxPlanNo());
							int AddFurCount = psta.executeUpdate();
							psta.close();

							/*
							 * sql =CoreXmlSqlParsersFactory.getSql(
							 * "FeedResult.AddFurHistory"); psta =
							 * conn.prepareStatement(sql); psta.setString(1,
							 * RollMatNo); psta.setString(2, LotNo);
							 * psta.setString(3, StoveNo); psta.setString(4,
							 * JundgeStoveNo); psta.setString(5, PlineCode);
							 * psta.setString(6, "0"); psta.setString(7,
							 * ColUser); psta.setString(8, ColShift);
							 * psta.setString(9, ColGroup); psta.setString(10,
							 * "0"); psta.setInt(11,SEQ);
							 * psta.setString(12,"0"); int AddFurHistoryCount =
							 * psta.executeUpdate(); psta.close();
							 */

							sql = CoreXmlSqlParsersFactory
									.getSql("FeedResult.AddPerRack");
							psta = conn.prepareStatement(sql);
							psta.setString(1, "");
							psta.setString(2, LotNo);
							psta.setString(3, StoveNo);
							psta.setString(4, JundgeStoveNo);
							psta.setString(5, PlineCode);
							psta.setString(6, "0");
							psta.setString(7, "");
							psta.setString(8, "");
							psta.setString(9, "");
							psta.setString(10, "0");
							psta.setInt(11, SEQ);
							psta.setString(12, ResultNo);
							psta.setString(13, FeedRowPlan.getProPlanId());
							psta.setString(14, FeedRowPlan.getGxPlanNo());
							int AddPerCount = psta.executeUpdate();
							psta.close();

							/*
							 * sql =CoreXmlSqlParsersFactory.getSql(
							 * "FeedResult.AddPerHistory"); psta =
							 * conn.prepareStatement(sql); psta.setString(1,
							 * RollMatNo); psta.setString(2, LotNo);
							 * psta.setString(3, StoveNo); psta.setString(4,
							 * JundgeStoveNo); psta.setString(5, PlineCode);
							 * psta.setString(6, "0"); psta.setString(7,
							 * ColUser); psta.setString(8, ColShift);
							 * psta.setString(9, ColGroup); psta.setString(10,
							 * "0"); psta.setInt(11,SEQ);
							 * psta.setString(12,"0"); int AddPerHistoryCount =
							 * psta.executeUpdate(); psta.close();
							 */

							sql = CoreXmlSqlParsersFactory
									.getSql("FeedResult.AddRollRack");
							psta = conn.prepareStatement(sql);
							psta.setString(1, "");
							psta.setString(2, LotNo);
							psta.setString(3, StoveNo);
							psta.setString(4, JundgeStoveNo);
							psta.setString(5, PlineCode);
							psta.setString(6, "0");
							psta.setString(7, "");
							psta.setString(8, "");
							psta.setString(9, "");
							psta.setString(10, "0");
							psta.setInt(11, SEQ);
							psta.setString(12, ResultNo);
							psta.setString(13, FeedRowPlan.getProPlanId());
							psta.setString(14, FeedRowPlan.getGxPlanNo());
							int AddRollCount = psta.executeUpdate();
							psta.close();

							/*
							 * sql =CoreXmlSqlParsersFactory.getSql(
							 * "FeedResult.AddRollHistory"); psta =
							 * conn.prepareStatement(sql); psta.setString(1,
							 * RollMatNo); psta.setString(2, LotNo);
							 * psta.setString(3, StoveNo); psta.setString(4,
							 * JundgeStoveNo); psta.setString(5, PlineCode);
							 * psta.setString(6, "0"); psta.setString(7,
							 * ColUser); psta.setString(8, ColShift);
							 * psta.setString(9, ColGroup); psta.setString(10,
							 * "0"); psta.setInt(11,SEQ);
							 * psta.setString(12,"0"); int AddRollHistoryCount =
							 * psta.executeUpdate(); psta.close();
							 */
							// if(ProcessStatue.equals("常化") ||
							// ProcessStatue.equals("升温旁通") ||
							// ProcessStatue.equals("快速入炉"))
							// {
							sql = CoreXmlSqlParsersFactory
									.getSql("FeedResult.AddReFurRack");
							psta = conn.prepareStatement(sql);
							psta.setString(1, "");
							psta.setString(2, LotNo);
							psta.setString(3, StoveNo);
							psta.setString(4, JundgeStoveNo);
							psta.setString(5, PlineCode);
							psta.setString(6, "0");
							psta.setString(7, "");
							psta.setString(8, "");
							psta.setString(9, "");
							psta.setString(10, "0");
							psta.setInt(11, SEQ);
							psta.setString(12, ResultNo);
							psta.setString(13, FeedRowPlan.getProPlanId());
							psta.setString(14, FeedRowPlan.getGxPlanNo());
							int AddReFurCount = psta.executeUpdate();
							psta.close();

							/*
							 * sql =CoreXmlSqlParsersFactory.getSql(
							 * "FeedResult.AddReFurHistory"); psta =
							 * conn.prepareStatement(sql); psta.setString(1,
							 * RollMatNo); psta.setString(2, LotNo);
							 * psta.setString(3, StoveNo); psta.setString(4,
							 * JundgeStoveNo); psta.setString(5, PlineCode);
							 * psta.setString(6, "0"); psta.setString(7,
							 * ColUser); psta.setString(8, ColShift);
							 * psta.setString(9, ColGroup); psta.setString(10,
							 * "0"); psta.setInt(11,SEQ);
							 * psta.setString(12,"0"); int AddReFurHistoryCount
							 * = psta.executeUpdate(); psta.close();
							 */
							// }

							sql = CoreXmlSqlParsersFactory
									.getSql("FeedResult.AddSizingRack");
							psta = conn.prepareStatement(sql);
							psta.setString(1, "");
							psta.setString(2, LotNo);
							psta.setString(3, StoveNo);
							psta.setString(4, JundgeStoveNo);
							psta.setString(5, PlineCode);
							psta.setString(6, "0");
							psta.setString(7, "");
							psta.setString(8, "");
							psta.setString(9, "");
							psta.setString(10, "0");
							psta.setInt(11, SEQ);
							psta.setString(12, ResultNo);
							psta.setString(13, FeedRowPlan.getProPlanId());
							psta.setString(14, FeedRowPlan.getGxPlanNo());
							int AddSizingRackCount = psta.executeUpdate();
							psta.close();

							/*
							 * sql =CoreXmlSqlParsersFactory.getSql(
							 * "FeedResult.AddSizingHistory"); psta =
							 * conn.prepareStatement(sql); psta.setString(1,
							 * ""); psta.setString(2, LotNo); psta.setString(3,
							 * StoveNo); psta.setString(4, JundgeStoveNo);
							 * psta.setString(5, PlineCode); psta.setString(6,
							 * "0"); psta.setString(7, ColUser);
							 * psta.setString(8, ColShift); psta.setString(9,
							 * ColGroup); psta.setString(10, "0");
							 * psta.setInt(11,SEQ); psta.setString(12,"0"); int
							 * AddSizingHistoryCount = psta.executeUpdate();
							 * psta.close();
							 */

							sql = CoreXmlSqlParsersFactory
									.getSql("FeedResult.AddSawRack");
							psta = conn.prepareStatement(sql);
							psta.setString(1, "");
							psta.setString(2, LotNo);
							psta.setString(3, StoveNo);
							psta.setString(4, JundgeStoveNo);
							psta.setString(5, PlineCode);
							psta.setString(6, "0");
							psta.setString(7, "");
							psta.setString(8, "");
							psta.setString(9, "");
							psta.setString(10, "0");
							psta.setInt(11, SEQ);
							psta.setString(12, ResultNo);
							psta.setString(13, FeedRowPlan.getProPlanId());
							psta.setString(14, FeedRowPlan.getGxPlanNo());
							int AddawRackCount = psta.executeUpdate();
							psta.close();
							/*
							 * sql =CoreXmlSqlParsersFactory.getSql(
							 * "FeedResult.AddSawHistory"); psta =
							 * conn.prepareStatement(sql); psta.setString(1,
							 * ""); psta.setString(2, LotNo); psta.setString(3,
							 * StoveNo); psta.setString(4, JundgeStoveNo);
							 * psta.setString(5, PlineCode); psta.setString(6,
							 * "0"); psta.setString(7, ColUser);
							 * psta.setString(8, ColShift); psta.setString(9,
							 * ColGroup); psta.setString(10, "0");
							 * psta.setInt(11,SEQ); psta.setString(12,"0"); int
							 * AddSawHistoryCount = psta.executeUpdate();
							 * psta.close();
							 */
							// 添加精整区跟踪表记录
							for (int k = 0; k < SawNum; k++) {

								SEQ = (i) * DBNum * SawNum + (j * SawNum)
										+ (1 + k) + finishSeq;
								String No2 = "1";
								No2 = Integer.parseInt(No2) + k + "";
								String FinishMatNo = RollMatNo + No2;

								sql = CoreXmlSqlParsersFactory
										.getSql("FeedResult.AddStraighRack");
								psta = conn.prepareStatement(sql);
								psta.setString(1, "");
								psta.setString(2, LotNo);
								psta.setString(3, StoveNo);
								psta.setString(4, JundgeStoveNo);
								psta.setString(5, PlineCode);
								psta.setString(6, "0");
								psta.setString(7, "");
								psta.setString(8, "");
								psta.setString(9, "");
								psta.setString(10, "0");
								psta.setInt(11, SEQ);
								psta.setString(12, ResultNo);
								psta.setString(13, FeedRowPlan.getProPlanId());
								psta.setString(14, FeedRowPlan.getGxPlanNo());
								int AddStraighCount = psta.executeUpdate();
								psta.close();

								/*
								 * sql =CoreXmlSqlParsersFactory.getSql(
								 * "FeedResult.AddStraighHistory"); psta =
								 * conn.prepareStatement(sql); psta.setString(1,
								 * FinishMatNo); psta.setString(2, LotNo);
								 * psta.setString(3, StoveNo); psta.setString(4,
								 * JundgeStoveNo); psta.setString(5, PlineCode);
								 * psta.setString(6, "0"); psta.setString(7,
								 * ColUser); psta.setString(8, ColShift);
								 * psta.setString(9, ColGroup);
								 * psta.setString(10, "0"); psta.setInt(11,SEQ);
								 * psta.setString(12,"0"); int
								 * AddStraighHistoryCount =
								 * psta.executeUpdate(); psta.close();
								 */

								sql = CoreXmlSqlParsersFactory
										.getSql("FeedResult.AddTestingRack");
								psta = conn.prepareStatement(sql);
								psta.setString(1, "");
								psta.setString(2, LotNo);
								psta.setString(3, StoveNo);
								psta.setString(4, JundgeStoveNo);
								psta.setString(5, PlineCode);
								psta.setString(6, "0");
								psta.setString(7, "");
								psta.setString(8, "");
								psta.setString(9, "");
								psta.setString(10, "0");
								psta.setInt(11, SEQ);
								psta.setString(12, ResultNo);
								psta.setString(13, FeedRowPlan.getProPlanId());
								psta.setString(14, FeedRowPlan.getGxPlanNo());
								int AddTestingCount = psta.executeUpdate();
								psta.close();

								/*
								 * sql =CoreXmlSqlParsersFactory.getSql(
								 * "FeedResult.AddTestingHistory"); psta =
								 * conn.prepareStatement(sql); psta.setString(1,
								 * FinishMatNo); psta.setString(2, LotNo);
								 * psta.setString(3, StoveNo); psta.setString(4,
								 * JundgeStoveNo); psta.setString(5, PlineCode);
								 * psta.setString(6, "0"); psta.setString(7,
								 * ColUser); psta.setString(8, ColShift);
								 * psta.setString(9, ColGroup);
								 * psta.setString(10, "0"); psta.setInt(11,SEQ);
								 * psta.setString(12,"0"); int
								 * AddTestingHistoryCount =
								 * psta.executeUpdate(); psta.close();
								 */
								sql = CoreXmlSqlParsersFactory
										.getSql("FeedResult.AddQARack");
								psta = conn.prepareStatement(sql);
								psta.setString(1, "");
								psta.setString(2, LotNo);
								psta.setString(3, StoveNo);
								psta.setString(4, JundgeStoveNo);
								psta.setString(5, PlineCode);
								psta.setString(6, "0");
								psta.setString(7, "");
								psta.setString(8, "");
								psta.setString(9, "");
								psta.setString(10, "0");
								psta.setInt(11, SEQ);
								psta.setString(12, ResultNo);
								psta.setString(13, FeedRowPlan.getProPlanId());
								psta.setString(14, FeedRowPlan.getGxPlanNo());
								int AddQACount = psta.executeUpdate();
								psta.close();
							}
						}
					}

					feedSeq += FeedNum;
					rollSeq += FeedNum * DBNum;
					finishSeq += FeedNum * DBNum * SawNum;
				}

			}
			rs1.close();
			rs.close();
			psta1.close();
			psta.close();
			conn.commit();
		}

		catch (SQLException sqle) {
			sqle.printStackTrace();
			try {
				conn.rollback();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} finally {
			try {
				if (conn != null && !conn.isClosed()) {
					conn.close();
				}
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		cro.setResult(0);
		return cro;
	}

	/**
	 * 删除原来的精整跟踪记录，再新增精整跟踪记录 （修改了分切数）
	 * 
	 * @param FeedRowPlan
	 *            上料计划实体类
	 * @return CoreReturnObject
	 */
	public CoreReturnObject AddRackJZ(String JundgeStoveNo, String plinCode,
			String proPlanId, String gxPlanNo) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection conn = null;
		PreparedStatement psta = null;
		PreparedStatement psta1 = null;
		PreparedStatement psta2 = null;
		String MatNo = "";
		try {
			conn = this.getDao("TgDao").getConnection();
			conn.setAutoCommit(false);
			String sql = "";
			ResultSet rs = null;
			ResultSet rs1 = null;

			// 删除原来的精整跟踪记录
			ArrayList<String> sqllist = new ArrayList<String>();
			String sql1 = "DELETE FROM MIL_STRAIGH_RACK T WHERE T.JUDGE_STOVE_NO = '"
					+ JundgeStoveNo + "' AND T.PLINE_CODE = '" + plinCode + "'";
			String sql2 = "DELETE FROM MIL_TESTING_RACK T WHERE T.JUDGE_STOVE_NO = '"
					+ JundgeStoveNo + "' AND T.PLINE_CODE = '" + plinCode + "'";
			String sql3 = "DELETE FROM MIL_QA_RACK T WHERE T.JUDGE_STOVE_NO = '"
					+ JundgeStoveNo + "' AND T.PLINE_CODE = '" + plinCode + "'";
			sqllist.add(sql1);
			sqllist.add(sql2);
			sqllist.add(sql3);
			this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(sqllist);
			/*
			 * psta2 = conn.prepareStatement(sql); psta2.executeUpdate();
			 * psta2.close();
			 */

			// String JundgeStoveNo = FeedRowPlan.getJudgeStoveNo();
			String JudgeStoveNoForMat = "";
			if (JundgeStoveNo.length() > 6) {
				JudgeStoveNoForMat = JundgeStoveNo.replaceFirst("-.*", "");
			} else {
				JudgeStoveNoForMat = JundgeStoveNo;
			}
			sql = CoreXmlSqlParsersFactory.getSql("FeedResult.FeedPlanQuery");
			psta1 = conn.prepareStatement(sql);
			psta1.setString(1, "00");
			psta1.setString(2, "96");
			psta1.setString(3, "");
			psta1.setString(4, JundgeStoveNo);
			psta1.setString(5, "");
			psta1.setString(6, plinCode);
			rs = psta1.executeQuery();

			sql = CoreXmlSqlParsersFactory.getSql("FeedResult.SinglePlanQuery");
			psta = conn.prepareStatement(sql);
			psta.setString(1, JundgeStoveNo);
			psta.setString(2, proPlanId);
			psta.setString(3, gxPlanNo);
			rs1 = psta.executeQuery();
			int feedSeq = 0;
			int rollSeq = 0;
			int finishSeq = 0;
			while (rs1.next()) {
				int SawNum = rs1.getInt(3);
				String ResultNo = rs1.getString(10);

				while (rs.next()) {
					String LotNo = rs.getString(3);
					String StoveNo = rs.getString(4);
					String PlineCode = rs.getString(6);
					int DBNum = rs.getInt(7);
					int FeedNum = rs.getInt(12);

					// 添加上料跟踪表记录
					for (int i = 0; i < FeedNum; i++) {
						int SEQ = 1 + i + feedSeq;
						int No = 1 + feedSeq;
						DecimalFormat df = new DecimalFormat("000");
						MatNo = JudgeStoveNoForMat + df.format(No + i);

						// 添加加热炉跟踪表、轧区跟踪表记录
						for (int j = 0; j < DBNum; j++) {
							SEQ = (i * DBNum) + (1 + j) + rollSeq;
							String No1 = "1";
							int temp = Integer.parseInt(No1) + j;
							No1 = temp + "";

							// 添加精整区跟踪表记录
							for (int k = 0; k < SawNum; k++) {

								SEQ = (i) * DBNum * SawNum + (j * SawNum)
										+ (1 + k) + finishSeq;
								String No2 = "1";
								No2 = Integer.parseInt(No2) + k + "";

								sql = CoreXmlSqlParsersFactory
										.getSql("FeedResult.AddStraighRack");
								psta = conn.prepareStatement(sql);
								psta.setString(1, "");
								psta.setString(2, LotNo);
								psta.setString(3, StoveNo);
								psta.setString(4, JundgeStoveNo);
								psta.setString(5, PlineCode);
								psta.setString(6, "0");
								psta.setString(7, "");
								psta.setString(8, "");
								psta.setString(9, "");
								psta.setString(10, "0");
								psta.setInt(11, SEQ);
								psta.setString(12, ResultNo);
								psta.setString(13, proPlanId);
								psta.setString(14, gxPlanNo);
								psta.executeUpdate();
								psta.close();

								sql = CoreXmlSqlParsersFactory
										.getSql("FeedResult.AddTestingRack");
								psta = conn.prepareStatement(sql);
								psta.setString(1, "");
								psta.setString(2, LotNo);
								psta.setString(3, StoveNo);
								psta.setString(4, JundgeStoveNo);
								psta.setString(5, PlineCode);
								psta.setString(6, "0");
								psta.setString(7, "");
								psta.setString(8, "");
								psta.setString(9, "");
								psta.setString(10, "0");
								psta.setInt(11, SEQ);
								psta.setString(12, ResultNo);
								psta.setString(13, proPlanId);
								psta.setString(14, gxPlanNo);
								psta.executeUpdate();
								psta.close();

								sql = CoreXmlSqlParsersFactory
										.getSql("FeedResult.AddQARack");
								psta = conn.prepareStatement(sql);
								psta.setString(1, "");
								psta.setString(2, LotNo);
								psta.setString(3, StoveNo);
								psta.setString(4, JundgeStoveNo);
								psta.setString(5, PlineCode);
								psta.setString(6, "0");
								psta.setString(7, "");
								psta.setString(8, "");
								psta.setString(9, "");
								psta.setString(10, "0");
								psta.setInt(11, SEQ);
								psta.setString(12, ResultNo);
								psta.setString(13, proPlanId);
								psta.setString(14, gxPlanNo);
								psta.executeUpdate();
								psta.close();
							}
						}
					}

					feedSeq += FeedNum;
					rollSeq += FeedNum * DBNum;
					finishSeq += FeedNum * DBNum * SawNum;
				}

			}
			rs1.close();
			rs.close();
			psta1.close();
			psta.close();
			conn.commit();
		}

		catch (SQLException sqle) {
			sqle.printStackTrace();
			try {
				conn.rollback();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} finally {
			try {
				if (conn != null && !conn.isClosed()) {
					conn.close();
				}
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		cro.setResult(0);
		return cro;
	}

	/**
	 * 查询上料实绩
	 * 
	 * @param FeedSawResult
	 *            上料实绩实体类
	 * @return CoreReturnObject
	 */
	public CoreReturnObject GetSingleFeedResult(String JudgeStoveNo,
			String proPlanId, String gxPlanNo) {
		return this.getDataBySqlID("FeedResult.SingleFeedSawResult",
				new Object[] { JudgeStoveNo, proPlanId, gxPlanNo });
	}

	/**
	 * 查询已结炉上料实绩
	 * 
	 * @param
	 * @return CoreReturnObject
	 */
	public CoreReturnObject GetSingleFeedNodeResult(String PlineCode,
			String Shift, String Group, String StartTime, String EndTime) {
		return this.getDataBySqlID("FeedResult.SingleFeedSawNodeResult",
				new Object[] { PlineCode, Shift, Group, StartTime, EndTime });
	}

	/**
	 * 修改上料实绩
	 * 
	 * @param FeedSawResult
	 *            上料行计划实绩实体类
	 * @return CoreReturnObject
	 */
	public CoreReturnObject UpdateFeedResult(
			com.steering.mes.zgmil.entity.FeedRowPlan FeedRowPlan) {
		ArrayList<String> sqllist = new ArrayList<String>();
		// 保存上料行信息
		String sql = CoreXmlSqlParsersFactory
				.getSql("FeedResult.UpdateFeedRowResult");
		// 修改上料锯切实绩开始时间
		String sql1 = CoreXmlSqlParsersFactory
				.getSql("FeedResult.UpdateFeedSawStartTime");
		// 修改上料跟踪表
		String sql2 = CoreXmlSqlParsersFactory
				.getSql("FeedResult.UpdateFeedRackStatue");
		sql = EntityTool.fillSqlByEntity(sql, FeedRowPlan);
		sql1 = EntityTool.fillSqlByEntity(sql1, FeedRowPlan);
		sql2 = EntityTool.fillSqlByEntity(sql2, FeedRowPlan);
		sqllist.add(sql);
		sqllist.add(sql1);
		sqllist.add(sql2);
		return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(
				sqllist);
	}

	/**
	 * 查询所有上料
	 * 
	 * @param JudgeStoveNo
	 *            上料行炉号
	 * @return CoreReturnObject
	 */
	public CoreReturnObject getToltalFeedPlan(String JudgeStoveNo) {
		return this.getDataBySqlID("FeedResult.FeedPlanTotalQuery",
				new Object[] { JudgeStoveNo });

	}

	/**
	 * 锯切结炉
	 * 
	 * @param FeedSawResult
	 *            上料行计划实绩实体类
	 * @return CoreReturnObject
	 */
	public CoreReturnObject FeedSawResultNode(FeedSawResultEntity feedSawResult) {
		ArrayList<String> sqllist = new ArrayList<String>();
		// 修改实绩信息
		String sql = CoreXmlSqlParsersFactory
				.getSql("FeedResult.FeedResultNode");
		// 修改主计划状态
		String sql1 = CoreXmlSqlParsersFactory
				.getSql("FeedResult.UpdateMainPlanStatue");
		// 修改跟踪表班次班组、结炉时间
		String sql2 = CoreXmlSqlParsersFactory
				.getSql("FeedResult.UpdateNodeRack");
		// 回写PLN_ORDER_ZG_S 轧管订单排产顺序耗时表的 炉计划已排支数、重量
		String sql3 = CoreXmlSqlParsersFactory
				.getSql("FeedResult.UpdatePlnOrderZgS");
		// 回写计划表中预计支吨
		String sql4 = CoreXmlSqlParsersFactory
				.getSql("FeedResult.UpdatePlanPredict");
		// 回写虚拟炉计划表中生产状态(生产完成)
		String sql5 = CoreXmlSqlParsersFactory
				.getSql("FeedResult.UpdatePlnZyZgM");
		// 更新进程表mil_processes数据
		String updateProcess = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.insertMilProcess2");

		sql = EntityTool.fillSqlByEntity(sql, feedSawResult);
		sql1 = EntityTool.fillSqlByEntity(sql1, feedSawResult);
		sql2 = EntityTool.fillSqlByEntity(sql2, feedSawResult);
		sql3 = EntityTool.fillSqlByEntity(sql3, feedSawResult);
		sql4 = EntityTool.fillSqlByEntity(sql4, feedSawResult);
		sql5 = EntityTool.fillSqlByEntity(sql5, feedSawResult);
		updateProcess = EntityTool
				.fillSqlByEntity(updateProcess, feedSawResult);
		sqllist.add(sql);
		sqllist.add(sql1);
		sqllist.add(sql2);
		sqllist.add(sql3);
		sqllist.add(sql4);
		sqllist.add(sql5);
		sqllist.add(updateProcess);
		return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(
				sqllist);

	}

	/**
	 * 实绩修改
	 * 
	 * @param ColumnName
	 *            字段名
	 * @param ColumnValue
	 *            字段值
	 * @param ProcessNo
	 *            工序号 1-锯切 2-加热炉 3-穿孔 4-连轧 5-再加热炉 6-定径 7-ET探伤 8-人工质检 9-分切 10-矫直
	 *            11-MT 12-UT
	 * @param Flag
	 *            字段类型 （0-默认 1-时间）
	 * @return
	 */
	public CoreReturnObject updateResult(String JudgeStoveNo, String ResultNo,
			String ColumnName, String ColumnValue, Integer ProcessNo,
			Integer Flag) {
		ArrayList<String> sqllist = new ArrayList<String>();
		String[] TableNameList = new String[] { "MIL_FEEDSAW_RESULT",
				"MIL_FUR_Result", "MIL_PERFORATION_Result",
				"MIL_ROLLING_Result", "MIL_REFUR_Result", "MIL_SIZING_Result",
				"MIL_ET_RESULT", "MIL_SURFACE_RESULT", "MIL_SAW_Result",
				"MIL_STRAIGHTENING_RESULT", "MIL_MT_RESULT", "MIL_UL_RESUL" };
		String sql = "";
		if (Flag.equals(1)) {
			sql = "UPDATE " + TableNameList[ProcessNo - 1] + " set  "
					+ ColumnName + " = to_date('" + ColumnValue
					+ "','yyyy-mm-dd hh24:mi:ss') where  ";
			sql += "  JUDGE_STOVE_NO =  '" + JudgeStoveNo
					+ "' and RESULT_NO = '" + ResultNo + "'";
		} else {
			sql = "UPDATE " + TableNameList[ProcessNo - 1] + " set  "
					+ ColumnName + " = '" + ColumnValue + "' where  ";
			sql += "  JUDGE_STOVE_NO =  '" + JudgeStoveNo
					+ "' and RESULT_NO = '" + ResultNo + "'";
		}
		sqllist.add(sql);
		return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(
				sqllist);
	}

	/**
	 * 上料开始 - 修改上料行状态 ，新增上料锯切实绩信息
	 * 
	 * @param FeedRowPlan
	 *            上料计划实体类
	 * @return CoreReturnObject
	 */
	public CoreReturnObject UpdateFeedRowStatue(
			com.steering.mes.zgmil.entity.FeedRowPlan FeedRowPlan) {
		ArrayList<String> sqllist = new ArrayList<String>();
		// ArrayList<Object[]> parmlist = new ArrayList<Object[]>();
		String sql = CoreXmlSqlParsersFactory
				.getSql("FeedResult.UpdateFeedRowStatue");
		String sql1 = CoreXmlSqlParsersFactory
				.getSql("FeedResult.AddFeedSawResult");
		String sql2 = CoreXmlSqlParsersFactory.getSql("FeedResult.UpdatePlan");
		String sql3 = CoreXmlSqlParsersFactory.getSql("FeedResult.InsertRack");// 生成进程表管号队列
		sql1 = EntityTool.fillSqlByEntity(sql1, FeedRowPlan);
		sql = EntityTool.fillSqlByEntity(sql, FeedRowPlan);
		sql2 = EntityTool.fillSqlByEntity(sql2, FeedRowPlan);
		sqllist.add(sql);
		sqllist.add(sql1);
		sqllist.add(sql2);
		return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(
				sqllist);
	}

	/**
	 * 上料开始 - 修改上料行状态 ，新增上料锯切实绩信息
	 * 
	 * @param FeedRowPlan
	 *            上料计划实体类
	 * @return CoreReturnObject
	 */
	public CoreReturnObject UpdateFeedRowStatue1(
			com.steering.mes.zgmil.entity.FeedRowPlan FeedRowPlan1) {
		// ArrayList<String> sqllist = new ArrayList<String>();
		// //ArrayList<Object[]> parmlist = new ArrayList<Object[]>();
		// String sql =
		// CoreXmlSqlParsersFactory.getSql("FeedResult.UpdateFeedRowStatue");
		// String sql1 =
		// CoreXmlSqlParsersFactory.getSql("FeedResult.AddFeedSawResult");
		// String sql2 =
		// CoreXmlSqlParsersFactory.getSql("FeedResult.UpdatePlan");
		// String sql3 =
		// CoreXmlSqlParsersFactory.getSql("FeedResult.InsertRack");//生成进程表管号队列
		// sql1 = EntityTool.fillSqlByEntity(sql1,FeedRowPlan);
		// sql = EntityTool.fillSqlByEntity(sql, FeedRowPlan);
		// sql2 = EntityTool.fillSqlByEntity(sql2, FeedRowPlan);
		// sqllist.add(sql);
		// sqllist.add(sql1);
		// sqllist.add(sql2);
		// return
		// this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(sqllist);
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		PreparedStatement psta = null;
		String sql = "";
		ResultSet rs = null;
		Date now = new Date();
		SimpleDateFormat dateFormat = new SimpleDateFormat(
				"yyyy-MM-dd HH:mm:ss");
		SimpleDateFormat df = new SimpleDateFormat("yyyyMM");
		String systime = dateFormat.format(now);
		String yearMoth = df.format(now);
		int macount = 0;
		int acount = 0;
		String sawNum = "";
		int seq = 1;
		String[] arr = null;
		double strWgt = 0;
		double inPutWgt = 0;// 上料量
		int inPutNum = 0;// 总支数
		int m = 0;
		String proPlanID = ""; // 轧管订单编号
		String gxPlanNO = ""; // 工序排产序号
		String backSlabFlag = "0"; // 回炉坯标识
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String updateFlagSql = CoreXmlSqlParsersFactory
					.getSql("FeedResult.UpdateFeedRowStatue1");// 上料修改什么标志位什么的
			updateFlagSql = EntityTool.fillSqlByEntity(updateFlagSql,
					FeedRowPlan1);
			PreparedStatement updateFlagPsta = connection
					.prepareStatement(updateFlagSql);
			updateFlagPsta.addBatch();
			/*String insertProcessSql = CoreXmlSqlParsersFactory
					.getSql("FeedResult.insertProcess");// 上料生成进程管号队列
			PreparedStatement insertProcessPsta = connection
					.prepareStatement(insertProcessSql);*/

			String updateBalYearMonth = CoreXmlSqlParsersFactory
					.getSql("FeedResult.updateBalYearMonth"); // 修改回炉坯炉号进程表结转年月
			PreparedStatement updateBalYearMonthPsta = connection
					.prepareStatement(updateBalYearMonth);

			String insertProcess = CoreXmlSqlParsersFactory
					.getSql("FeedResult.insertMilProcess");// 生成进程表mil_processes数据
			PreparedStatement insertMilProcess = connection
					.prepareStatement(insertProcess);

			sql = CoreXmlSqlParsersFactory.getSql("FeedResult.SelectFeedNum");
			sql = EntityTool.fillSqlByEntity(sql, FeedRowPlan1);
			psta = connection.prepareStatement(sql);
			rs = psta.executeQuery();
			List<FeedRowPlan> list = EntityTool.getEntitysByRs(rs,
					FeedRowPlan.class);

			rs.close();
			psta.close();
			arr = new String[2];
			sql = CoreXmlSqlParsersFactory
					.getSql("FeedResult.SelectContractNo");
			psta = connection.prepareStatement(sql);
			psta.setString(1, FeedRowPlan1.getJudgeStoveNo());
			rs = psta.executeQuery();
			if (rs.next()) {
				arr[0] = rs.getString("OUTDIAMETER");
				arr[1] = rs.getString("AIMWALLTHICK");
			}
			rs.close();
			psta.close();
			if (arr[0] == null || arr[1] == null) {
				// cro.setV_errMsg("外径/控制壁厚为空,请联系系统管理员!");
				// return cro;
				arr = list.get(0).getPipeSize().split("[*]");
			}

			

			sql = CoreXmlSqlParsersFactory
					.getSql("FeedResult.SelectProPlanId1"); // 查询轧管订单编号
			sql = EntityTool.fillSqlByEntity(sql, FeedRowPlan1);
			psta = connection.prepareStatement(sql);
			rs = psta.executeQuery();
			if (rs.next()) {
				proPlanID = rs.getString("PRO_PLAN_ID");
				gxPlanNO = rs.getString("GX_PLAN_NO");
				backSlabFlag = rs.getString("BACK_SLAB_FLAG");
			}
			rs.close();
			psta.close();

			

			/*ArrayList<String> wgtList = new ArrayList<String>();
			List<double[]> lenList = null;
			if(!"".equals(FeedRowPlan1.getMatTotalHeight())){
				sql = CoreXmlSqlParsersFactory
						.getSql("FeedResult.SelectFeedToalWgt");
				sql = EntityTool.fillSqlByEntity(sql, FeedRowPlan1);
				psta = connection.prepareStatement(sql);
				rs = psta.executeQuery();
				if (rs.next()) {
					inPutWgt = Double.parseDouble(rs.getString("MAT_TOTAL_HEIGHT"));
				}
				rs.close();
				psta.close();

				sql = CoreXmlSqlParsersFactory
						.getSql("FeedResult.SelectFeedToalNum");
				sql = EntityTool.fillSqlByEntity(sql, FeedRowPlan1);
				psta = connection.prepareStatement(sql);
				rs = psta.executeQuery();
				if (rs.next()) {
					inPutNum = Integer.parseInt(rs.getString("ACT_COUNT"));
				}
				rs.close();
				psta.close();
				
				lenList = MeanValueCalculation.MeanCalculation(
						inPutWgt, inPutNum);
				for (int k = 0; k < lenList.size(); k++) {
					double[] conLen = lenList.get(k);
					if ((int) conLen[0] > 0) {
						for (int x = 0; x < (int) conLen[0]; x++) {
							DecimalFormat dt = new DecimalFormat("0.000");
							wgtList.add(dt.format(conLen[1]));
						}
					}
				}
			}*/
			


			String mMatNo = queryMatNoM(connection, FeedRowPlan1
					.getJudgeStoveNo(), FeedRowPlan1.getLotNo(), FeedRowPlan1
					.getResultNo()); // 母坯材料号
			int g = Integer.parseInt(mMatNo.substring(mMatNo.length() - 3,
					mMatNo.length()));
			String year = "";
			int result = comPareTime(systime,
					new SimpleDateFormat("yyyy-MM-dd").format(now)
							+ " 21:00:00");
			if (result > 0) {
				yearMoth = getBalYearMoth(systime);

			}
			/*for (int k = 0; k < list.size(); k++) {
				FeedRowPlan feedPlan = list.get(k);
				for (int s = 0; s < Integer.parseInt(feedPlan.getFeedNum()); s++) {
					// arr = feedPlan.getPipeSize().split("[*]");
					strWgt = 0.02466
							* Double.parseDouble(arr[1])
							* (Double.parseDouble(arr[0]) - Double
									.parseDouble(arr[1]))
							* Double.parseDouble(feedPlan.getTargetLength())
							/ 1000;
					for (int i = 1; i < Integer.parseInt(feedPlan.getDbNum()) + 1; i++) {
						for (int j = 1; j < Integer.parseInt(feedPlan
								.getSawNum()) + 1; j++) {
							// 上料生成进程管号队列
							insertProcessPsta.setString(1, FeedRowPlan1
									.getResultNo());
							insertProcessPsta.setString(2, FeedRowPlan1
									.getLotNo());
							insertProcessPsta.setString(3, FeedRowPlan1
									.getStoveNo());
							insertProcessPsta.setString(4, FeedRowPlan1
									.getJudgeStoveNo());
							insertProcessPsta.setString(5, FeedRowPlan1
									.getPlineCode());
							insertProcessPsta.setString(6, String.valueOf(seq));
							insertProcessPsta.setString(7, (FeedRowPlan1
									.getJudgeStoveNo().replaceFirst("-.*", ""))
									+ StringTool.formatDecimal(g, "000")
									+ i
									+ j);// 子管材料号
							insertProcessPsta.setString(8, "");// 定尺长度
							// new DecimalFormat("0.000").format(strWgt)
							insertProcessPsta.setString(9, "");// 重量
							insertProcessPsta.setString(10, systime);
							insertProcessPsta.setString(11, (FeedRowPlan1
									.getJudgeStoveNo().replaceFirst("-.*", ""))
									+ StringTool.formatDecimal(g, "000") + i);// 母管材料号
							insertProcessPsta.setString(12, (FeedRowPlan1
									.getJudgeStoveNo().replaceFirst("-.*", ""))
									+ StringTool.formatDecimal(g, "000"));// 母坯材料号
							if(!"".equals(FeedRowPlan1.getMatTotalHeight())){
								insertProcessPsta.setString(13, String
										.valueOf(wgtList.get(m)));// 投料量
							}else{
								insertProcessPsta.setString(13, "0");// 投料量
							}
							
							insertProcessPsta.setString(14, yearMoth);
							insertProcessPsta.setString(15, proPlanID); // 轧管订单编号
							insertProcessPsta.setString(16, gxPlanNO); // 工序排产序号

							insertProcessPsta.addBatch();
							seq++;
							m++;
						}
					}
					g++;
				}
			}*/

			// 修改回炉坯炉号进程表结转年月
			if (backSlabFlag.equals("1")) {
				updateBalYearMonthPsta.setString(1, FeedRowPlan1
						.getJudgeStoveNo());
				updateBalYearMonthPsta
						.setString(2, FeedRowPlan1.getPlineCode());
				updateBalYearMonthPsta
						.setString(3, FeedRowPlan1.getProPlanId());
				updateBalYearMonthPsta.setString(4, FeedRowPlan1.getGxPlanNo());
				updateBalYearMonthPsta.addBatch();
			}

			// 生成进程表mil_processes数据
			insertMilProcess.setString(1, FeedRowPlan1.getJudgeStoveNo());
			insertMilProcess.setString(2, FeedRowPlan1.getLotNo());
			insertMilProcess.setString(3, FeedRowPlan1.getPlineCode());
			insertMilProcess.setString(4, FeedRowPlan1.getProPlanId());
			insertMilProcess.setString(5, FeedRowPlan1.getGxPlanNo());
			insertMilProcess.setString(6, yearMoth);
			insertMilProcess.addBatch();

			updateFlagPsta.executeBatch();
			// insertProcessPsta.executeBatch(); //生成进程表，转到上料确认点
			insertMilProcess.executeBatch();
			if (backSlabFlag.equals("1")) {
				updateBalYearMonthPsta.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 yearMoth
	 * @return
	 */
	private String getBalYearMoth(String systime) {
		String year = "";
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		SimpleDateFormat sdfS = new SimpleDateFormat("yyyyMM");
		try {
			Date date = sdf.parse(systime);
			Calendar calender = Calendar.getInstance();
			calender.setTime(date);
			calender.add(Calendar.DATE, 1);
			year = sdfS.format(calender.getTime());
		} catch (ParseException e) {
			e.printStackTrace();
		}

		return year;

	}

	/***
	 * 比较时间大小
	 * 
	 * @return
	 * @throws ParseException
	 */
	public static Integer comPareTime(String sysTim, String plnTim)
			throws ParseException {
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Calendar c1 = Calendar.getInstance();
		Calendar c2 = Calendar.getInstance();
		c1.setTime(df.parse(sysTim));
		c2.setTime(df.parse(plnTim));
		int result = c1.compareTo(c2);
		/***
		 * result = 0 c1=c2 result > 0 c1>c2 result < 0 c1<c2
		 */
		return result;
	}

	/***
	 * 结炉写进程表
	 * 
	 * @param JudgeStoveNo
	 * @param ProcessNo
	 * @param opProcessNo
	 * @return
	 */
	public CoreReturnObject updateProcess(String JudgeStoveNo,
			String ProcessNo, String opProcessNo, String proPlanId,
			String gxPlanNo) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		PreparedStatement psta = null;
		String sql = "";
		ResultSet rs = null;
		Date now = new Date();
		SimpleDateFormat dateFormat = new SimpleDateFormat(
				"yyyy-MM-dd HH:mm:ss");
		String systime = dateFormat.format(now);
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String updateProcessSql = CoreXmlSqlParsersFactory
					.getSql("insertProcess1.UpdateFlag");// 结炉剔除进程表中数据
			PreparedStatement updateProcessPsta = connection
					.prepareStatement(updateProcessSql);

			sql = CoreXmlSqlParsersFactory.getSql("insertProcess1.selectScrap");
			psta = connection.prepareStatement(sql);
			psta.setString(1, JudgeStoveNo);
			psta.setString(2, proPlanId);
			psta.setString(3, gxPlanNo);
			rs = psta.executeQuery();
			List<MilSlabScrapSeqEntity> list = EntityTool.getEntitysByRs(rs,
					MilSlabScrapSeqEntity.class);

			rs.close();
			psta.close();
			for (int i = 0; i < list.size(); i++) {
				MilSlabScrapSeqEntity milSlabSeq = list.get(i);
				updateProcessPsta.setInt(1, Integer.parseInt(milSlabSeq
						.getProcessNo()));
				updateProcessPsta.setString(2, milSlabSeq.getJudgeStoveNo());
				updateProcessPsta.setString(3, proPlanId);
				updateProcessPsta.setString(4, gxPlanNo);

				updateProcessPsta.setString(5, milSlabSeq.getMatNo());
				updateProcessPsta.setString(6, opProcessNo);
				updateProcessPsta.setString(7, milSlabSeq.getJudgeStoveNo());
				updateProcessPsta.setInt(8, Integer.parseInt(milSlabSeq
						.getProcessNo()));
				updateProcessPsta.setString(9, milSlabSeq.getJudgeStoveNo());
				updateProcessPsta.setString(10, proPlanId);
				updateProcessPsta.setString(11, gxPlanNo);

				updateProcessPsta.setString(12, milSlabSeq.getSeq());
				updateProcessPsta.setString(13, opProcessNo);
				updateProcessPsta.setString(14, milSlabSeq.getJudgeStoveNo());

				updateProcessPsta.addBatch();

			}

			updateProcessPsta.executeBatch();

			int a = 0;
			// 验证热轧各工序 的进程表状态标识修改是否成功
			if (opProcessNo.equals("0")) {
				// 验证上料锯切工序 的进程表状态标识修改是否成功
				sql = CoreXmlSqlParsersFactory
						.getSql("FeedResult.selectFeedRackAndProcess");
				psta = connection.prepareStatement(sql);
				psta.setString(1, JudgeStoveNo);
				psta.setString(2, proPlanId);
				psta.setString(3, gxPlanNo);
				psta.setString(4, JudgeStoveNo);
				psta.setString(5, proPlanId);
				psta.setString(6, gxPlanNo);
				rs = psta.executeQuery();
				if (rs.next()) {
					a = Integer.parseInt(rs.getString("ACT_COUNT"));
				}
				rs.close();
				psta.close();
				if (a != 0) {
					cro.setV_errMsg("结炉失败，请退回，重新操作!");
					return cro;
				}
			}
			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 conn
	 *            c
	 * @param strLcode
	 *            传递参数
	 * @return obj
	 * @throws Exception
	 *             异常处理
	 */
	public String queryMatNoM(Connection conn, String strLcode, String lotNo,
			String resultNo) throws Exception {
		int count = 0;
		PreparedStatement psta = null;
		String sqlLovsqe = CoreXmlSqlParsersFactory
				.getSql("FeedResult.queryMatNoM");
		psta = conn.prepareStatement(sqlLovsqe);
		psta.setString(1, strLcode);
		psta.setString(2, lotNo);
		psta.setString(3, resultNo);
		ResultSet rs = psta.executeQuery();
		if (rs.next()) {
			String res = rs.getString(1);
			if (res == null) {
				res = strLcode.replaceFirst("-.*", "") + "001";
			} else {
				count = Integer.parseInt(res.substring(res.length() - 3, res
						.length()));
			}
		}
		rs.close();
		psta.close();
		return (strLcode.replaceFirst("-.*", ""))
				+ StringTool.formatDecimal(++count, "000");
	}

	/**
	 * 开始状态回退 1-删除实绩表 2-修改管号队列开始状态
	 * 
	 * @param JudgeStoveNo
	 *            炉号
	 * @param ResultNo
	 *            实绩编号
	 * @param Status
	 *            下线状态
	 * @param ProcessNo
	 *            0-上料 1-加热炉 2-穿孔 3-连轧 4-再加热 5-定径 6-分切 7-矫直 8-探伤 9-质检
	 * @return CoreReturnObject
	 */
	public CoreReturnObject startBack(String JudgeStoveNo, String ResultNo,
			Integer ProcessNo, String PlineCode, String proPlanId,
			String gxPlanNo) {
		ArrayList<String> sqllist = new ArrayList<String>();
		String[] TableRackList = new String[] { "MIL_FEED_RACK",
				"MIL_FUR_RACK", "MIL_PERFORATION_RACK", "MIL_ROLLING_RACK",
				"MIL_REFUR_RACK", "MIL_SIZING_RACK", "MIL_SAW_RACK",
				"MIL_STRAIGH_RACK", "MIL_TESTING_RACK", "MIL_QA_RACK" };
		String[] TableNameList = new String[] { "MIL_FEEDSAW_RESULT",
				"MIL_FUR_Result", "MIL_PERFORATION_Result",
				"MIL_ROLLING_Result", "MIL_REFUR_Result", "MIL_SIZING_Result",
				"MIL_SAW_Result", "MIL_STRAIGHTENING_RESULT", "MIL_ET_RESULT",
				"MIL_MT_RESULT", "MIL_UL_RESUL", "MIL_SURFACE_RESULT" };
		String[] StartTimeList = new String[] { "FEED_TIME", "IN_FUR_TIME",
				"START_PERFORATION_TIME", "START_ROLLING_TIME",
				"IN_REFUR_TIME", "START_SIZING_TIME", "START_SAW_TIME",
				"START_STRAIGHTENING_TIME", "START_INSPECTION_TIME",
				"START_TIME" };
		String[] EndTimeList = new String[] { "END_TIME", "OUT_FUR_TIME",
				"END_PERFORATION_TIME", "END_ROLLING_TIME", "OUT_REFUR_TIME",
				"END_SIZING_TIME", "END_SAW_TIME", "END_STRAIGHTENING_TIME",
				"END_INSPECTION_TIME", "END_TIME" };
		String[] Status = new String[] { "00", "05", "15", "25", "35", "45",
				"55", "65", "75", "85", "95" };
		String TableName = TableNameList[ProcessNo];
		if (ProcessNo.equals(8)) {
			if (PlineCode.equals("C008") || PlineCode.equals("C009")
					|| PlineCode.equals("C012")) {
				TableName = "MIL_MT_RESULT";
			} else if (PlineCode.equals("C010")) {
				TableName = "MIL_ET_RESULT";
			} else {
				TableName = "MIL_UL_RESUL";
			}
		}
		// 删除实绩表
		String sql = "delete from  " + TableName + "  where JUDGE_STOVE_NO = '"
				+ JudgeStoveNo + "'  AND RESULT_NO = '" + ResultNo
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
				+ "','/')";
		// 修改跟踪表状态 交接班状态
		String sql1 = "";

		sql1 = "UPDATE  "
				+ TableRackList[ProcessNo]
				+ " set status = '0'  , scrap_time = '' , "
				+ EndTimeList[ProcessNo]
				+ " ='' , COL_SHIFT = '',COL_GROUP='',COL_USER='',CHANGE_FLAG = 0 where JUDGE_STOVE_NO = '"
				+ JudgeStoveNo + "'  AND RESULT_NO = '" + ResultNo
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
				+ "','/')";
		if (ProcessNo.equals(1) || ProcessNo.equals(4)) {
			sql1 = "UPDATE  " + TableRackList[ProcessNo]
					+ " set status = '0'  , scrap_time = '' , "
					+ EndTimeList[ProcessNo] + " ='' , ";
			sql1 += " IN_CHANGE_FLAG =0,IN_SHIFT='',IN_GROUP='',IN_USER='' ,";
			sql1 += " COL_SHIFT = '', COL_GROUP='',COL_USER='',OUT_CHANGE_FLAG = 0 where JUDGE_STOVE_NO = '"
					+ JudgeStoveNo
					+ "'  AND RESULT_NO = '"
					+ ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo
					+ "','/')";
		}
		// 删除坯料剔除序号表
		String sql2 = "";
		sql2 = "delete MIL_SLAB_SCRAP_SEQ where JUDGE_STOVE_NO = '"
				+ JudgeStoveNo + "' and PROCESS_NO ='" + (ProcessNo + 1)
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
				+ "','/')";
		if (ProcessNo.equals(0)) {
			sql2 = "delete MIL_SLAB_SCRAP_SEQ where JUDGE_STOVE_NO = '"
					+ JudgeStoveNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')" + " and PROCESS_NO in ('0','1') ";
		}

		if (ProcessNo.equals(6)) {
			sql2 = "delete MIL_SLAB_SCRAP_SEQ where JUDGE_STOVE_NO = '"
					+ JudgeStoveNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')" + " and PROCESS_NO IN ('7','8') ";
		}
		if (ProcessNo > 6) {
			sql2 = "delete MIL_SLAB_SCRAP_SEQ where JUDGE_STOVE_NO = '"
					+ JudgeStoveNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')" + " and PROCESS_NO ='"
					+ (ProcessNo + 2) + "' ";
		}

		// 清空剔除原因
		String sql3 = "";
		String sqle1 = "update  " + TableRackList[ProcessNo]
				+ "  set SCRAP_REASON = ''  where JUDGE_STOVE_NO = '"
				+ JudgeStoveNo + "'  AND RESULT_NO = '" + ResultNo
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
				+ "','/')";
		String sqle2 = "update  "
				+ TableRackList[ProcessNo]
				+ "  set SCRAP_REASON = '',   SCRAP_LOC = '0' where JUDGE_STOVE_NO = '"
				+ JudgeStoveNo + "'  AND RESULT_NO = '" + ResultNo
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
				+ "','/')";

		if (ProcessNo.equals(5)) {
			sql3 = sqle2;
		} else {

			sql3 = sqle1;
		}

		String sql4 = "update MIL_PLAN set STATUS = '" + Status[ProcessNo]
				+ "'  where JUDGE_STOVE_NO = '" + JudgeStoveNo
				+ "'  AND ID = '" + ResultNo
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
				+ "','/')";
		sqllist.add(sql);
		sqllist.add(sql1);
		sqllist.add(sql2);
		sqllist.add(sql3);
		sqllist.add(sql4);

		return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(
				sqllist);
	}

	/**
	 * 上料回退 - 修改上料行状态 ，新增上料锯切实绩信息
	 * 
	 * @param FeedRowPlan
	 *            上料计划实体类
	 * @return CoreReturnObject
	 */
	public CoreReturnObject feedBack(String JudgeStoveNo, String ResultNo,
			ArrayList FeedRow, ArrayList FeedNum, String proPlanId,
			String gxPlanNo) {
		ArrayList<String> sqllist = new ArrayList<String>();
		// ArrayList<Object[]> parmlist = new ArrayList<Object[]>();

		// 修改上料行上料支数=计划上料支数
		/*
		 * String sql5 = ""; for (int i = 0; i < FeedRow.size(); i++) { sql5 =
		 * "update MIL_FEED_PLAN set FEED_NUM = '" + FeedNum.get(i) +
		 * "' where FEED_ROW_NO = '" + FeedRow.get(i) + "'"; sqllist.add(sql5);
		 * }
		 */

		// 修改上料行计划信息
		String sql = "  UPDATE MIL_FEED_PLAN SET  SCRAP_DBNUM = 0, QUALIFIED_NUM = 0,  ACT_CUT_LENGTH = 0, ";
		sql += "ACT_CUT_WEIGHT = 0, SCRAP_FEEDNUM = 0, SAW_FALG = '0',  CHANGE_NUM = 0, FEED_NUM = FEED_NUM_PLAN   ";
		sql += "WHERE 	JUDGE_STOVE_NO = '" + JudgeStoveNo
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
				+ "','/')";

		// 删除所有管号队列
		String[] TableRackList = new String[] { "MIL_FEED_RACK",
				"MIL_FUR_RACK", "MIL_PERFORATION_RACK", "MIL_ROLLING_RACK",
				"MIL_REFUR_RACK", "MIL_SIZING_RACK", "MIL_SAW_RACK",
				"MIL_STRAIGH_RACK", "MIL_TESTING_RACK", "MIL_QA_RACK" };
		// 删除所有实绩表
		String[] TableNameList = new String[] { "MIL_FEEDSAW_RESULT",
				"MIL_FUR_Result", "MIL_PERFORATION_Result",
				"MIL_ROLLING_Result", "MIL_REFUR_Result", "MIL_SIZING_Result",
				"MIL_SAW_Result", "MIL_STRAIGHTENING_RESULT", "MIL_ET_RESULT",
				"MIL_MT_RESULT", "MIL_UL_RESUL", "MIL_SURFACE_RESULT" };
		String sql6 = "";
		for (int i = 0; i < TableNameList.length; i++) {
			sql6 = "delete " + TableNameList[i] + " where JUDGE_STOVE_NO = '"
					+ JudgeStoveNo + "'";/*
										 * "' AND RESULT_NO = '" + ResultNo +
										 * "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
										 * + proPlanId +
										 * "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
										 * + gxPlanNo + "','/')";
										 */
			sqllist.add(sql6);
		}
		String sql1 = "";
		for (int i = 0; i < TableRackList.length; i++) {
			sql1 = "delete " + TableRackList[i] + " where JUDGE_STOVE_NO = '"
					+ JudgeStoveNo + "'";/*
										 * "' AND RESULT_NO = '" + ResultNo +
										 * "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
										 * + proPlanId +
										 * "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
										 * + gxPlanNo + "','/')";
										 */
			sqllist.add(sql1);
		}
		// 修改主计划信息 清空上料顺序号 FEED_SEQ 清空流动卡轧批流水好

		String sql2 = "update mil_plan set STATUS = '00' ,FEED_SEQ = '',LOT_SEQ = '' where JUDGE_STOVE_NO = '"
				+ JudgeStoveNo
				+ "' AND ID = '"
				+ ResultNo
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
				+ proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
				+ gxPlanNo
				+ "','/')";

		// 删除剔除管序号信息
		String sql4 = "delete MIL_SLAB_SCRAP_SEQ where JUDGE_STOVE_NO = '"
				+ JudgeStoveNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
				+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
				+ gxPlanNo + "','/')";

		// 删除进程表管号队列
		String sql7 = "DELETE FROM PORT_MIL_BATCH_SAMPLE_RESULT T WHERE T.PLAN_ID = '"
				+ ResultNo
				+ "' AND T.JUDGE_STOVE_NO = '"
				+ JudgeStoveNo
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
				+ proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
				+ gxPlanNo
				+ "','/')";

		// 删除进程表mil_processes数据
		String sql8 = "DELETE FROM MIL_PROCESSES T WHERE T.ID = '" + ResultNo
				+ "' AND T.JUDGE_STOVE_NO = REGEXP_REPLACE( '" + JudgeStoveNo
				+ "', '-.*', '')  AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
				+ "','/')  AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
				+ "','/')";
		// 删除表面检验抽检管尺寸实绩表
		String sql9 = "delete FROM MIL_SIZE_CHECK_DEATIL where JUDGE_STOVE_NO = '"
				+ JudgeStoveNo + "'";

		sqllist.add(sql);
		sqllist.add(sql2);
		sqllist.add(sql4);
		// sqllist.add(sql7); //转到上料回退点
		sqllist.add(sql8);
		sqllist.add(sql9);
		return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(
				sqllist);
	}
	
	

	/**
	 * 上料剔除 - 新增剔除表 修改管坯状态
	 * 
	 * @param MilScrapSlab
	 *            MIL_SLAB_SCRAP_SEQ实体类
	 * @param Flag
	 *            0-切前剔除，1-切后剔除
	 * @return CoreReturnObject
	 */
	public CoreReturnObject scrapFeedMat(MilSlabScrapSeqEntity MilScrapSlab,
			String Flag) {

		ArrayList<String> sqllist = new ArrayList<String>();
		// 新增剔除管号序列
		String sql = CoreXmlSqlParsersFactory
				.getSql("FeedResult.AddScrapSlabSeq");
		// 修改上料表物料状态
		String sql1 = "";
		// 修改上料行剔除支数合格支数
		String sql2 = "";
		// 上料剔除
		if (Flag.equals("0")) {
			sql1 = CoreXmlSqlParsersFactory
					.getSql("FeedResult.UpdateFeedFeedNumStatue");
			sql2 = CoreXmlSqlParsersFactory
					.getSql("FeedResult.UpdateFeedRowFeedNum");
		} else {
			// 修改上料表物料状态 修改剔除支数
			sql1 = CoreXmlSqlParsersFactory
					.getSql("FeedResult.UpdateFeedDBNumStatue");
			sql2 = CoreXmlSqlParsersFactory
					.getSql("FeedResult.UpdateFeedRowDBNum");
		}
		sql = EntityTool.fillSqlByEntity(sql, MilScrapSlab);
		sql1 = EntityTool.fillSqlByEntity(sql1, MilScrapSlab);
		sql2 = EntityTool.fillSqlByEntity(sql2, MilScrapSlab);
		sqllist.add(sql);
		sqllist.add(sql1);
		sqllist.add(sql2);
		return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(
				sqllist);
	}

	/**
	 * 结炉时修改剔料序号表对应管坯
	 * 
	 * @param JudgeStoveNo
	 *            上料计划实体类
	 * @param ProcessNo
	 *            工序代码 (1-锯切 2-加热炉 3-穿孔 4-连轧 5-再加热炉 6-定径 7-分切 8-矫直 9-探伤 )
	 * @param TableName
	 *            当前工序跟踪表名
	 * @param NextTableName
	 *            下道工序跟踪表名
	 * @param OffLineFlag
	 *            0-正常轧制 1-下线 2-矫直返线 3-探伤返线
	 * @return CoreReturnObject
	 */
	public CoreReturnObject scrapNodeMat(String JudgeStoveNo,
			Integer ProcessNo, Integer OffLineFlag, String plineCode,
			String proPlanId, String gxPlanNo) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection conn = null;
		PreparedStatement psta = null;
		PreparedStatement psta1 = null;
		PreparedStatement psta2 = null;
		PreparedStatement psta3 = null;
		try {
			String[] TableNameList = new String[] { "MIL_FEED_RACK",
					"MIL_FUR_RACK", "MIL_PERFORATION_RACK", "MIL_ROLLING_RACK",
					"MIL_REFUR_RACK", "MIL_SIZING_RACK", "MIL_SAW_RACK",
					"MIL_STRAIGH_RACK", "MIL_TESTING_RACK", "MIL_QA_RACK" };
			String TableName = TableNameList[ProcessNo - 1];
			String NextTableName = TableNameList[ProcessNo];
			conn = this.getDao("TgDao").getConnection();
			conn.setAutoCommit(false);

			String sql = "";

			ResultSet rs = null;
			ResultSet rs1 = null;
			ResultSet rs2 = null;
			ResultSet rs3 = null;

			double PipeLength = 0;
			double LastPipeLength = 0;
			sql = CoreXmlSqlParsersFactory.getSql("FeedResult.SinglePlanQuery");
			psta = conn.prepareStatement(sql);
			psta.setString(1, JudgeStoveNo);
			psta.setString(2, proPlanId);
			psta.setString(3, gxPlanNo);

			rs = psta.executeQuery();
			while (rs.next()) {
				int SawNum = rs.getInt(3); // 分切数
				int DBNum = 0;

				String sqlUpdate = "";

				int ScrapNum = 0; // 切后剔除支数
				int Seq = 1; // 序号
				if (ProcessNo.equals(1)) {
					sql = " SELECT  SEQ,MAT_NO,JUDGE_STOVE_NO,STATUS,  DB_NUM,SCRAP_DBNUM FROM "
							+ TableName
							+ " WHERE JUDGE_STOVE_NO = '"
							+ JudgeStoveNo
							+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
							+ proPlanId
							+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
							+ gxPlanNo
							+ "','/')"
							+ "  AND MAT_NO IS NOT NULL order by SEQ";
					psta1 = conn.prepareStatement(sql);
					rs1 = psta1.executeQuery();
					while (rs1.next()) {

						String MatNo = rs1.getString(2);

						String Status = rs1.getString(4);
						ScrapNum = rs1.getInt(6);
						sql = "select DB_NUM from mil_feed_plan where feed_row_no = (select feed_row_no from mil_feed_rack where mat_no = '"
								+ MatNo + "')";
						psta2 = conn.prepareStatement(sql);

						rs2 = psta2.executeQuery();
						while (rs2.next()) {
							DBNum = rs2.getInt(1);
						}
						rs2.close();
						psta2.close();
						// 正常轧制
						if (Status.equals("2")) {
							for (int i = 0; i < DBNum; i++) {
								String Temp = "0";
								Temp = (Integer.parseInt(Temp) + i + 1) + "";
								String MatNo1 = MatNo + Temp;
								sqlUpdate = "Update mil_fur_rack set MAT_NO = '"
										+ MatNo1
										+ "' WHERE SEQ = "
										+ Seq
										+ " AND Judge_stove_no = '"
										+ JudgeStoveNo + "'";
								Seq++;
								psta2 = conn.prepareStatement(sqlUpdate);
								psta2.executeUpdate();
								psta2.close();
							}
						}
						// 切前剔除
						else if (Status.equals("3")) {
							sqlUpdate = "insert into mil_slab_scrap (judge_stove_no,process_no,mat_no,seq,PLINE_CODE,PRO_PLAN_ID,GX_PLAN_NO)";
							sqlUpdate += "values ( '" + JudgeStoveNo;
							sqlUpdate += "', '0'";
							sqlUpdate += ",'" + MatNo + "' ," + Seq + ",'"
									+ plineCode + "' ,'" + proPlanId + "' ,'"
									+ gxPlanNo + "')";
							psta2 = conn.prepareStatement(sqlUpdate);
							psta2.executeUpdate();
							psta2.close();
						}
						// 切后剔除
						else if (Status.equals("4")) {
							for (int i = 0; i < ScrapNum; i++) {
								String Temp = "0";
								Temp = (Integer.parseInt(Temp) + i + 1) + "";
								String MatNo1 = MatNo + Temp;
								sqlUpdate = "insert into mil_slab_scrap (judge_stove_no,process_no,mat_no,PLINE_CODE,PRO_PLAN_ID,GX_PLAN_NO)";
								sqlUpdate += "values ( '" + JudgeStoveNo;
								sqlUpdate += "', '1'";
								sqlUpdate += ",'" + MatNo1 + "','" + plineCode
										+ "' ,'" + proPlanId + "' ,'"
										+ gxPlanNo + "')";
								psta2 = conn.prepareStatement(sqlUpdate);
								psta2.executeUpdate();
								psta2.close();
							}

							for (int i = 0; i < DBNum - ScrapNum; i++) {
								String Temp = "0";

								// Temp = (Integer.parseInt(Temp)+i+1)+"";
								Temp = (Integer.parseInt(Temp) + ScrapNum + i + 1)
										+ "";
								String MatNo1 = MatNo + Temp;
								sqlUpdate = "Update mil_fur_rack set MAT_NO = '"
										+ MatNo1
										+ "' WHERE SEQ = "
										+ Seq
										+ " AND Judge_stove_no = '"
										+ JudgeStoveNo + "'";
								Seq++;
								psta2 = conn.prepareStatement(sqlUpdate);
								psta2.executeUpdate();
								psta2.close();

							}
						}

					}

				} else if (ProcessNo.equals(7)) {

					// 非返线管赋管号
					if (OffLineFlag.equals(0)) {
						// for(int k=1;k<4;k++)
						// {
						//						  

						int j = 1; // 用于被赋值的管号队列中ROWNUM 自增
						// 分台查询管号队列
						// and COL_NO = "+k+"
						sql = " SELECT  SEQ,MAT_NO,JUDGE_STOVE_NO,STATUS,  SCRAP_DBNUM FROM "
								+ TableName
								+ " WHERE  JUDGE_STOVE_NO = '"
								+ JudgeStoveNo
								+ "' AND MAT_NO IS NOT NULL order by SEQ";
						psta1 = conn.prepareStatement(sql);
						rs1 = psta1.executeQuery();
						while (rs1.next()) {

							String MatNo = rs1.getString(2);

							String Status = rs1.getString(4);
							ScrapNum = rs1.getInt(5);
							sql = "select ORDER_LENGTH ,LAST_ORDER_LENGTH from MIL_SAW_RACK WHERE MAT_NO = '"
									+ MatNo + "'";
							psta2 = conn.prepareStatement(sql);
							rs2 = psta2.executeQuery();
							while (rs2.next()) {
								PipeLength = rs2.getDouble(1);
								LastPipeLength = rs2.getDouble(2);

							}
							rs2.close();
							psta2.close();
							// 正常轧制
							if (Status.equals("0")) {
								for (int i = 0; i < SawNum; i++) {
									String Temp = "0";
									Temp = (Integer.parseInt(Temp) + i + 1)
											+ "";
									String MatNo1 = MatNo + Temp;

									if (i == SawNum - 1) {
										sqlUpdate = "Update mil_straigh_rack set MAT_NO = '"
												+ MatNo1
												+ "' ,PIPE_LENGTH = '"
												+ LastPipeLength
												+ "' WHERE  Judge_stove_no = '"
												+ JudgeStoveNo + "' AND SEQ = ";
										sqlUpdate += " (select seq from (select seq,rownum rno from mil_straigh_rack where   Judge_stove_no = '"
												+ JudgeStoveNo + "'  ";
										sqlUpdate += "   order by seq) where rno = "
												+ j + "  ) ";
									}
									// and col_no = "+k+"
									else {
										sqlUpdate = "Update mil_straigh_rack set MAT_NO = '"
												+ MatNo1
												+ "' ,PIPE_LENGTH = '"
												+ PipeLength
												+ "' WHERE  Judge_stove_no = '"
												+ JudgeStoveNo + "' AND SEQ = ";
										sqlUpdate += " (select seq from (select seq,rownum rno from mil_straigh_rack where   Judge_stove_no = '"
												+ JudgeStoveNo + "'  ";
										sqlUpdate += "  order by seq) where rno = "
												+ j + "  ) ";
									}
									// and col_no = "+k+"
									psta2 = conn.prepareStatement(sqlUpdate);
									psta2.executeUpdate();
									psta2.close();
									j++;

								}
								// conn.commit();
							}
							// 切前剔除
							/*
							 * else if (Status.equals("3")) { sqlUpdate =
							 * "insert into mil_slab_scrap (judge_stove_no,process_no,mat_no)"
							 * ; sqlUpdate += "values ( '"+JudgeStoveNo;
							 * sqlUpdate += "', '7'" ; sqlUpdate +=",'" +
							 * MatNo+"' )"; psta2 =
							 * conn.prepareStatement(sqlUpdate);
							 * psta2.executeUpdate(); psta2.close();
							 * System.out.println(sqlUpdate); conn.commit(); }
							 */
							// 切后剔除
							else if (Status.equals("4")) {
								for (int i = SawNum - ScrapNum; i < SawNum; i++) {
									String Temp = "0";
									Temp = (Integer.parseInt(Temp) + i + 1)
											+ "";
									String MatNo1 = MatNo + Temp;
									sqlUpdate = "insert into mil_slab_scrap (judge_stove_no,process_no,mat_no,PLINE_CODE,PRO_PLAN_ID,GX_PLAN_NO)";
									sqlUpdate += "values ( '" + JudgeStoveNo;
									sqlUpdate += "', '8'";
									sqlUpdate += ",'" + MatNo1 + "','"
											+ plineCode + "' ,'" + proPlanId
											+ "' ,'" + gxPlanNo + "')";
									psta2 = conn.prepareStatement(sqlUpdate);
									psta2.executeUpdate();
									psta2.close();
									// System.out.println(sqlUpdate);

									conn.commit();
								}

								for (int i = 0; i < SawNum - ScrapNum; i++) {
									String Temp = "0";

									// Temp = (Integer.parseInt(Temp)+i+1)+"";
									Temp = (Integer.parseInt(Temp) + ScrapNum
											+ i + 1)
											+ "";
									String MatNo1 = MatNo + Temp;
									sqlUpdate = "Update mil_straigh_rack set MAT_NO = '"
											+ MatNo1
											+ "',PIPE_LENGTH = '"
											+ PipeLength
											+ "' WHERE  Judge_stove_no = '"
											+ JudgeStoveNo + "' AND SEQ = ";
									sqlUpdate += " (select seq from (select seq,rownum rno from mil_straigh_rack where   Judge_stove_no = '"
											+ JudgeStoveNo + "'  ";
									sqlUpdate += "   order by seq) where rno = "
											+ j + "  ) ";
									// and col_no = "+k+"
									psta2 = conn.prepareStatement(sqlUpdate);
									psta2.executeUpdate();
									psta2.close();
									j++;
								}
							}

						}
						// conn.commit();
						// }
						rs1.close();
						psta1.close();
						// 查询切前剔除的坯料 未赋台号
						sql = " SELECT  SEQ,MAT_NO,JUDGE_STOVE_NO,STATUS,  SCRAP_DBNUM FROM "
								+ TableName
								+ " WHERE  JUDGE_STOVE_NO = '"
								+ JudgeStoveNo
								+ "'    AND MAT_NO IS NOT NULL AND STATUS = '3' order by SEQ";
						psta3 = conn.prepareStatement(sql);
						rs3 = psta3.executeQuery();
						while (rs3.next()) {
							String MatNo = rs3.getString(2);
							sqlUpdate = "insert into mil_slab_scrap (judge_stove_no,process_no,mat_no,PLINE_CODE,PRO_PLAN_ID,GX_PLAN_NO)";
							sqlUpdate += "values ( '" + JudgeStoveNo;
							sqlUpdate += "', '7'";
							sqlUpdate += ",'" + MatNo + "','" + plineCode
									+ "' ,'" + proPlanId + "' ,'" + gxPlanNo
									+ "')";
							psta2 = conn.prepareStatement(sqlUpdate);
							psta2.executeUpdate();
							psta2.close();
						}
						rs3.close();
						psta3.close();
					}
					// 返线管赋值
					/*
					 * else if (OffLineFlag.equals(2)) { for(int k=1;k<4;k++) {
					 * int j = 1 ; //用于被赋值的管号队列中ROWNUM 自增 //分台查询管号队列 sql =
					 * " SELECT  SEQ,MAT_NO,JUDGE_STOVE_NO,STATUS,  SCRAP_DBNUM FROM "
					 * + TableName +" WHERE  JUDGE_STOVE_NO = '"+
					 * JudgeStoveNo+"' and COL_NO = "
					 * +k+" and OFFLINE_FLAG = '2'  AND MAT_NO IS NOT NULL";
					 * psta1 = conn.prepareStatement(sql); rs1 =
					 * psta1.executeQuery(); while(rs1.next()) {
					 * 
					 * String MatNo = rs1.getString(2);
					 * 
					 * String Status = rs1.getString(4); ScrapNum =
					 * rs1.getInt(5);
					 * 
					 * //正常轧制 if (Status.equals("0")) { for (int i = 0;i <
					 * SawNum;i++) { String Temp = "0"; Temp =
					 * (Integer.parseInt(Temp)+i+1)+""; String MatNo1
					 * =MatNo+Temp; sqlUpdate =
					 * "Update mil_straigh_rack set MAT_NO = '"
					 * +MatNo1+"' WHERE  Judge_stove_no = '"
					 * +JudgeStoveNo+"' AND SEQ = "; sqlUpdate+=
					 * " (select seq from (select seq,rownum rno from mil_straigh_rack where   Judge_stove_no = '"
					 * +JudgeStoveNo+"'  "; sqlUpdate +=
					 * "and offline_flag = '2' and col_no = "
					 * +k+" ) where rno = "+j+"  ) "; j++; psta2 =
					 * conn.prepareStatement(sqlUpdate); psta2.executeUpdate();
					 * psta2.close(); } } //切前剔除 else if (Status.equals("3")) {
					 * sqlUpdate =
					 * "insert into mil_slab_scrap (judge_stove_no,process_no,mat_no)"
					 * ; sqlUpdate += "values ( '"+JudgeStoveNo; sqlUpdate +=
					 * "', '7'" ; sqlUpdate +=",'" + MatNo+"' )"; psta2 =
					 * conn.prepareStatement(sqlUpdate); psta2.executeUpdate();
					 * psta2.close(); } //切后剔除 else if (Status.equals("4")) {
					 * for(int i = SawNum-ScrapNum;i<SawNum;i++) { String Temp =
					 * "0"; Temp = (Integer.parseInt(Temp)+i+1)+""; String
					 * MatNo1 =MatNo+Temp; sqlUpdate =
					 * "insert into mil_slab_scrap (judge_stove_no,process_no,mat_no)"
					 * ; sqlUpdate += "values ( '"+JudgeStoveNo; sqlUpdate +=
					 * "', '8'" ; sqlUpdate +=",'" + MatNo1+"')"; psta2 =
					 * conn.prepareStatement(sqlUpdate); psta2.executeUpdate();
					 * psta2.close(); } for (int i = 0;i < SawNum-ScrapNum;i++)
					 * { String Temp = "0"; Temp =
					 * (Integer.parseInt(Temp)+i+1)+""; String MatNo1
					 * =MatNo+Temp; sqlUpdate =
					 * "Update mil_straigh_rack set MAT_NO = '"
					 * +MatNo1+"' WHERE  Judge_stove_no = '"
					 * +JudgeStoveNo+"' AND SEQ = "; sqlUpdate+=
					 * " (select seq from (select seq,rownum rno from mil_straigh_rack where   Judge_stove_no = '"
					 * +JudgeStoveNo+"'  "; sqlUpdate +=
					 * "and offline_flag = '2' and col_no = "
					 * +k+" ) where rno = "+j+"  ) "; j++; psta2 =
					 * conn.prepareStatement(sqlUpdate); psta2.executeUpdate();
					 * psta2.close();
					 * 
					 * } }
					 * 
					 * } } }
					 */

				} else if (ProcessNo.equals(8)) // 8矫直
				{

					// 非返线管
					if (OffLineFlag.equals(0)) {

						// for(int k=1;k<4;k++)
						// {
						// and COL_NO = "+k+"
						int j = 1; // 用于被赋值的管号队列中ROWNUM 自增
						// sql =
						// " SELECT  SEQ,MAT_NO,JUDGE_STOVE_NO,STATUS FROM "+
						// TableName +" WHERE  JUDGE_STOVE_NO = '"+
						// JudgeStoveNo+"' and OFFLINE_FLAG = '0'  AND MAT_NO IS NOT NULL order by SEQ";
						sql = " SELECT T.SEQ, T.MAT_NO, T.JUDGE_STOVE_NO, T.STATUS FROM "
								+ TableName
								+ " T,PORT_MIL_BATCH_SAMPLE_RESULT S WHERE T.MAT_NO = S.MAT_NO AND T.JUDGE_STOVE_NO = '"
								+ JudgeStoveNo
								+ "'AND T.OFFLINE_FLAG = '0'AND T.MAT_NO IS NOT NULL ORDER BY S.IS_SAMPLE_PIPE,S.MAT_NO ASC";
						psta1 = conn.prepareStatement(sql);
						rs1 = psta1.executeQuery();
						while (rs1.next()) {
							String MatNo = rs1.getString(2);
							String Status = rs1.getString(4);

							sql = "select PIPE_LENGTH  from MIL_STRAIGH_RACK WHERE MAT_NO = '"
									+ MatNo + "'";
							psta2 = conn.prepareStatement(sql);
							rs2 = psta2.executeQuery();
							while (rs2.next()) {
								PipeLength = rs2.getDouble(1);

							}
							rs2.close();
							psta2.close();
							// 正常轧制
							if (Status.equals("0")) {

								sqlUpdate = "Update mil_testing_rack set MAT_NO = '"
										+ MatNo
										+ "',PIPE_LENGTH = '"
										+ PipeLength
										+ "' WHERE  Judge_stove_no = '"
										+ JudgeStoveNo + "' AND SEQ = ";
								sqlUpdate += " (select seq from (select seq,rownum rno from mil_testing_rack where   Judge_stove_no = '"
										+ JudgeStoveNo + "'  ";
								sqlUpdate += "  order by seq ) where rno = "
										+ j + "  ) ";
								// and col_no = "+k+"
								psta2 = conn.prepareStatement(sqlUpdate);
								psta2.executeUpdate();
								psta2.close();
								j++;
							}
							// 剔除
							else if (Status.equals("1")) {
								sqlUpdate = "insert into mil_slab_scrap (judge_stove_no,process_no,mat_no,pline_code,PRO_PLAN_ID,GX_PLAN_NO)";
								sqlUpdate += "values ( '" + JudgeStoveNo;
								sqlUpdate += "', '9'";
								sqlUpdate += ",'" + MatNo + "','" + plineCode
										+ "' ,'" + proPlanId + "' ,'"
										+ gxPlanNo + "')";
								psta2 = conn.prepareStatement(sqlUpdate);
								psta2.executeUpdate();
								psta2.close();
							}
						}
						// }
					}
					// 返线管
					else if (OffLineFlag.equals(2)) {

						for (int k = 1; k < 4; k++) {
							int j = 1; // 用于被赋值的管号队列中ROWNUM 自增
							sql = " SELECT  SEQ,MAT_NO,JUDGE_STOVE_NO,STATUS,  SCRAP_DBNUM FROM "
									+ TableName
									+ " WHERE  JUDGE_STOVE_NO = '"
									+ JudgeStoveNo
									+ "' and COL_NO = "
									+ k
									+ " and OFFLINE_FLAG = '2'  AND MAT_NO IS NOT NULL order by SEQ";
							psta1 = conn.prepareStatement(sql);
							rs1 = psta1.executeQuery();
							while (rs1.next()) {
								String MatNo = rs1.getString(2);
								String Status = rs1.getString(4);
								sql = "select PIPE_LENGTH  from MIL_STRAIGH_RACK WHERE MAT_NO = '"
										+ MatNo + "'";
								psta2 = conn.prepareStatement(sql);
								rs2 = psta2.executeQuery();
								while (rs2.next()) {
									PipeLength = rs2.getDouble(1);

								}
								rs2.close();
								psta2.close();

								// 正常轧制
								if (Status.equals("0")) {

									sqlUpdate = "Update mil_testing_rack set MAT_NO = '"
											+ MatNo
											+ "',PIPE_LENGTH = '"
											+ PipeLength
											+ "'  WHERE  Judge_stove_no = '"
											+ JudgeStoveNo + "' AND SEQ = ";
									sqlUpdate += " (select seq from (select seq,rownum rno from mil_testing_rack where   Judge_stove_no = '"
											+ JudgeStoveNo + "'  ";
									sqlUpdate += "and offline_flag = '2'  and col_no = "
											+ k
											+ "  order by seq) where rno = "
											+ j + "  ) ";

									psta2 = conn.prepareStatement(sqlUpdate);
									psta2.executeUpdate();
									psta2.close();
									j++;
								}
								// 剔除
								else if (Status.equals("1")) {
									sqlUpdate = "insert into mil_slab_scrap (judge_stove_no,process_no,mat_no,PRO_PLAN_ID,GX_PLAN_NO)";
									sqlUpdate += "values ( '" + JudgeStoveNo;
									sqlUpdate += "', '9'";
									sqlUpdate += ",'" + MatNo + "' ,'"
											+ proPlanId + "' ,'" + gxPlanNo
											+ "')";
									psta2 = conn.prepareStatement(sqlUpdate);
									psta2.executeUpdate();
									psta2.close();
								}
							}
						}
					}
				} else if (ProcessNo.equals(9)) // 探伤
				{

					// 非返线管
					if (OffLineFlag.equals(0)) {
						int j = 1; // 用于被赋值的管号队列中ROWNUM 自增

						// sql =
						// " SELECT  SEQ,MAT_NO,JUDGE_STOVE_NO,STATUS FROM "+
						// TableName +" WHERE  JUDGE_STOVE_NO = '"+
						// JudgeStoveNo+"'  and OFFLINE_FLAG = '0' AND SAMPLE_FLAG = '0' AND STATUS NOT IN('1','3') AND MAT_NO IS NOT NULL order by SEQ";
						sql = "SELECT T.SEQ, T.MAT_NO, T.JUDGE_STOVE_NO, T.STATUS FROM "
								+ TableName
								+ " T,PORT_MIL_BATCH_SAMPLE_RESULT S WHERE T.MAT_NO = S.MAT_NO AND T.JUDGE_STOVE_NO = '"
								+ JudgeStoveNo
								+ "'AND T.OFFLINE_FLAG = '0' AND T.STATUS NOT IN('1','3') AND T.MAT_NO IS NOT NULL ORDER BY S.IS_SAMPLE_PIPE,S.MAT_NO ASC";
						psta1 = conn.prepareStatement(sql);
						rs1 = psta1.executeQuery();
						while (rs1.next()) {
							String MatNo = rs1.getString(2);
							String Status = rs1.getString(4);
							sql = "select PIPE_LENGTH  from MIL_TESTING_RACK WHERE MAT_NO = '"
									+ MatNo + "'";
							psta2 = conn.prepareStatement(sql);
							rs2 = psta2.executeQuery();
							while (rs2.next()) {
								PipeLength = rs2.getDouble(1);

							}
							rs2.close();
							psta2.close();

							// 正常轧制
							if (Status.equals("0") || Status.equals("2")) {

								sqlUpdate = "Update mil_qa_rack set MAT_NO = '"
										+ MatNo + "' ,PIPE_LENGTH = '"
										+ PipeLength
										+ "' WHERE  Judge_stove_no = '"
										+ JudgeStoveNo + "' AND SEQ = ";
								sqlUpdate += " (select seq from (select seq,rownum rno from mil_qa_rack where   Judge_stove_no = '"
										+ JudgeStoveNo + "'  ";
								sqlUpdate += " order by seq ) where rno = " + j
										+ "  ) ";
								// and offline_flag = '0'
								psta2 = conn.prepareStatement(sqlUpdate);
								psta2.executeUpdate();
								psta2.close();
								j++;
							}
							// 剔除
							else if (Status.equals("1")) {
								// sqlUpdate =
								// "insert into mil_slab_scrap (judge_stove_no,process_no,mat_no)";
								// sqlUpdate += "values ( '"+JudgeStoveNo;
								// sqlUpdate += "', '9'" ;
								// sqlUpdate +=",'" + MatNo+"' )";
								// psta2 = conn.prepareStatement(sqlUpdate);
								// psta2.executeUpdate();
								// psta2.close();
							}
						}

					}
					// 探伤返线管赋材料号
					else if (OffLineFlag.equals(2)) {
						int j = 1; // 用于被赋值的管号队列中ROWNUM 自增

						sql = " SELECT  SEQ,MAT_NO,JUDGE_STOVE_NO,STATUS,  SCRAP_DBNUM FROM "
								+ TableName
								+ " WHERE  JUDGE_STOVE_NO = '"
								+ JudgeStoveNo
								+ "'  and OFFLINE_FLAG = '2'   AND MAT_NO IS NOT NULL order by SEQ";
						psta1 = conn.prepareStatement(sql);
						rs1 = psta1.executeQuery();
						while (rs1.next()) {
							String MatNo = rs1.getString(2);
							String Status = rs1.getString(4);

							sql = "select PIPE_LENGTH  from MIL_TESTING_RACK WHERE MAT_NO = '"
									+ MatNo + "'";
							psta2 = conn.prepareStatement(sql);
							rs2 = psta2.executeQuery();
							while (rs2.next()) {
								PipeLength = rs2.getDouble(1);

							}
							rs2.close();
							psta2.close();
							// 正常轧制
							if (Status.equals("0")) {

								sqlUpdate = "Update mil_qa_rack set MAT_NO = '"
										+ MatNo + "',PIPE_LENGTH = '"
										+ PipeLength
										+ "'  WHERE  Judge_stove_no = '"
										+ JudgeStoveNo + "' AND SEQ = ";
								sqlUpdate += " (select seq from (select seq,rownum rno from mil_qa_rack where   Judge_stove_no = '"
										+ JudgeStoveNo + "'  ";
								sqlUpdate += "and offline_flag = '2'  order by seq) where rno = "
										+ j + "  ) ";

								psta2 = conn.prepareStatement(sqlUpdate);
								psta2.executeUpdate();
								psta2.close();
								j++;
							}
							// 剔除
							else if (Status.equals("1")) {
								sqlUpdate = "insert into mil_slab_scrap (judge_stove_no,process_no,mat_no,PRO_PLAN_ID,GX_PLAN_NO)";
								sqlUpdate += "values ( '" + JudgeStoveNo;
								sqlUpdate += "', '9'";
								sqlUpdate += ",'" + MatNo + "' ,'" + proPlanId
										+ "' ,'" + gxPlanNo + "')";
								psta2 = conn.prepareStatement(sqlUpdate);
								psta2.executeUpdate();
								psta2.close();
							}
						}
					}
					// 探伤返线管赋材料号
					else if (OffLineFlag.equals(3)) {
						int j = 1; // 用于被赋值的管号队列中ROWNUM 自增

						sql = " SELECT  SEQ,MAT_NO,JUDGE_STOVE_NO,STATUS,  SCRAP_DBNUM FROM "
								+ TableName
								+ " WHERE  JUDGE_STOVE_NO = '"
								+ JudgeStoveNo
								+ "'  and OFFLINE_FLAG = '2'  and  AND MAT_NO IS NOT NULL order by SEQ";
						psta1 = conn.prepareStatement(sql);
						rs1 = psta1.executeQuery();
						while (rs1.next()) {
							String MatNo = rs1.getString(2);
							String Status = rs1.getString(4);

							sql = "select PIPE_LENGTH  from MIL_TESTING_RACK WHERE MAT_NO = '"
									+ MatNo + "'";
							psta2 = conn.prepareStatement(sql);
							rs2 = psta2.executeQuery();
							while (rs2.next()) {
								PipeLength = rs2.getDouble(1);

							}
							rs2.close();
							psta2.close();
							// 正常轧制
							if (Status.equals("0")) {

								sqlUpdate = "Update mil_qa_rack set MAT_NO = '"
										+ MatNo + "',PIPE_LENGTH = '"
										+ PipeLength
										+ "'  WHERE  Judge_stove_no = '"
										+ JudgeStoveNo + "' AND SEQ = ";
								sqlUpdate += " (select seq from (select seq,rownum rno from mil_qa_rack where   Judge_stove_no = '"
										+ JudgeStoveNo + "'  ";
								sqlUpdate += "and offline_flag = '2'   order by seq) where rno = "
										+ j + "  ) ";

								psta2 = conn.prepareStatement(sqlUpdate);
								psta2.executeUpdate();
								psta2.close();
								j++;
							}
							// 剔除
							else if (Status.equals("1")) {
								sqlUpdate = "insert into mil_slab_scrap (judge_stove_no,process_no,mat_no,PRO_PLAN_ID,GX_PLAN_NO)";
								sqlUpdate += "values ( '" + JudgeStoveNo;
								sqlUpdate += "', '9'";
								sqlUpdate += ",'" + MatNo + "' ,'" + proPlanId
										+ "' ,'" + gxPlanNo + "')";
								psta2 = conn.prepareStatement(sqlUpdate);
								psta2.executeUpdate();
								psta2.close();
							}
						}
					}
				} else // 2加热炉 3穿孔 4连轧 5再加热炉 6定径
				{
					int ScrapProcessNo = 0; // 工序号 -用于插入剔除坯料表的工序
					if (ProcessNo < 7) {
						ScrapProcessNo = ProcessNo;
					} else {
						ScrapProcessNo = ProcessNo + 1;

					}
					if (ProcessNo.equals(5)) {
						// 清除定径管号队列MAT_NO
						sqlUpdate = " UPDATE " + NextTableName
								+ " set MAT_NO = '' WHERE JUDGE_STOVE_NO = '"
								+ JudgeStoveNo + "' ";
						psta2 = conn.prepareStatement(sqlUpdate);
						psta2.executeUpdate();
						psta2.close();
					}
					sql = " SELECT  SEQ,MAT_NO,JUDGE_STOVE_NO,STATUS FROM "
							+ TableName + " WHERE JUDGE_STOVE_NO = '"
							+ JudgeStoveNo
							+ "'  AND MAT_NO IS NOT NULL order by SEQ";
					psta1 = conn.prepareStatement(sql);
					rs1 = psta1.executeQuery();
					while (rs1.next()) {
						String MatNo = rs1.getString(2);
						String Status = rs1.getString(4);

						// 正常轧制
						if (Status.equals("0")) {

							sqlUpdate = "Update " + NextTableName
									+ " set MAT_NO = '" + MatNo
									+ "' WHERE SEQ = " + Seq
									+ " AND Judge_stove_no = '" + JudgeStoveNo
									+ "'";
							Seq++;
							psta2 = conn.prepareStatement(sqlUpdate);
							psta2.executeUpdate();
							psta2.close();

						}
						// 剔除
						else if (Status.equals("1")) {
							sqlUpdate = "insert into mil_slab_scrap (judge_stove_no,process_no,mat_no,pline_code,PRO_PLAN_ID,GX_PLAN_NO)";
							sqlUpdate += "values ( '" + JudgeStoveNo;
							sqlUpdate += "', '" + ScrapProcessNo + "'";
							sqlUpdate += ",'" + MatNo + "','" + plineCode
									+ "' ,'" + proPlanId + "' ,'" + gxPlanNo
									+ "')";
							psta2 = conn.prepareStatement(sqlUpdate);
							psta2.executeUpdate();
							psta2.close();
						}

					}

				}

			}

			String updateSlabScrapWeitgh = CoreXmlSqlParsersFactory
					.getSql("FeedResult.updateSlabScrapWeitgh");
			PreparedStatement updateSlabScrapWeitghPsta = conn
					.prepareStatement(updateSlabScrapWeitgh);
			updateSlabScrapWeitghPsta.setString(1, JudgeStoveNo);
			updateSlabScrapWeitghPsta.setString(2, plineCode);
			updateSlabScrapWeitghPsta.setString(3, proPlanId);
			updateSlabScrapWeitghPsta.setString(4, gxPlanNo);
			updateSlabScrapWeitghPsta.addBatch();
			updateSlabScrapWeitghPsta.executeBatch();
			// 修改上料历史表状态为0 的坯料状态为2
			conn.commit();
			rs1.close();
			psta1.close();
			rs.close();

			conn.close();
		} catch (SQLException sqle) {
			sqle.printStackTrace();
			try {
				conn.rollback();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} finally {
			try {
				if (conn != null && !conn.isClosed()) {
					conn.close();
				}
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		cro.setResult(1);
		return cro;
	}

	/**
	 * 得到实绩编号
	 * 
	 * @param JudgeStoveNo
	 *            炉号
	 * @param ProcessNo
	 *            工序号 0-锯切 1-加热炉 2-穿孔 3-连轧 4-再加热炉 5-定径 6-分切 7-矫直 8-涡流探伤 9-漏磁探伤
	 *            10-超声探伤 11-人工质检
	 * @return CoreReturnObject
	 */
	public CoreReturnObject getResultNo(String JudgeStoveNo, Integer ProcessNo) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection conn = null;
		PreparedStatement psta = null;
		try {
			conn = this.getDao("TgDao").getConnection();
			conn.setAutoCommit(false);
			ResultSet rs = null;
			String[] TableName = new String[] { "MIL_FEEDSAW_RESULT",
					"MIL_FUR_RESULT", "MIL_PERFORATION_RESULT",
					"MIL_ROLLING_RESULT", "MIL_REFUR_RESULT",
					"MIL_SIZING_RESULT", "MIL_SAW_RESULT",
					"MIL_STRAIGHTENING_RESULT", "MIL_ET_RESULT",
					"MIL_MT_RESULT", "MIL_UL_RESUL", "MIL_SURFACE_RESULT" };

			java.util.Calendar c = java.util.Calendar.getInstance();
			java.text.SimpleDateFormat f = new java.text.SimpleDateFormat(
					"yyyyMMDD");

			String DateTime = f.format(c.getTime());
			// String ResultNo = JudgeStoveNo +DateTime+ "001";

		}

		catch (SQLException sqle) {
			sqle.printStackTrace();
			try {
				conn.rollback();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} finally {
			try {
				if (conn != null && !conn.isClosed()) {
					conn.close();
				}
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		cro.setResult(0);
		return cro;
	}

	/**
	 * 剔除坯料检验
	 * 
	 * @param JudgeStoveNo
	 *            炉号
	 * @param ProcessNo
	 *            工序号
	 * @return CoreReturnObject
	 */
	public CoreReturnObject scrapMatCheck(String JudgeStoveNo,
			Integer ProcessNo, String proPlanId, String gxPlanNo) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection conn = null;
		PreparedStatement psta = null;
		PreparedStatement psta1 = null;
		try {

			String sql = "";
			String SqlWhere = " (";

			conn = this.getDao("TgDao").getConnection();
			ResultSet rs = null;
			ResultSet rs1 = null;
			conn.setAutoCommit(false);
			sql = "select DB_NUM FROM MIL_FEED_RACK WHERE STATUS = '3' AND JUDGE_STOVE_NO ='"
					+ JudgeStoveNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')";
			psta = conn.prepareStatement(sql);
			rs = psta.executeQuery();
			int DBNum = 0;
			int ScrapFeedNum = 0;
			int ScrapNum = 0;
			int ScrapTotalNum = 0;
			while (rs.next()) {
				DBNum = rs.getInt(1);
				ScrapFeedNum += DBNum;
			}

			for (int i = 1; i < ProcessNo; i++) {
				SqlWhere += i + ",";
			}
			SqlWhere += "'')";
			// sql =
			// "SELECT SUM(Process_no) FROM (SELECT DECODE(Process_no, 0, COUNT(*) * "+
			// DBNum +", COUNT(*)) Process_no";
			sql = "SELECT  COUNT(*) ";
			sql += "   from mil_slab_scrap_seq";
			sql += "  WHERE judge_stove_no = '" + JudgeStoveNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
					+ "','/')";
			sql += "  and Process_no in " + SqlWhere;
			psta1 = conn.prepareStatement(sql);
			rs1 = psta1.executeQuery();
			while (rs1.next()) {
				ScrapNum = rs1.getInt(1);
			}
			ScrapTotalNum = ScrapNum + ScrapFeedNum;
			psta.close();
			psta1.close();
			rs.close();
			rs1.close();

			String Num = ScrapTotalNum + "";
			cro.setV_errMsg(Num.trim());

		} catch (SQLException sqle) {
			sqle.printStackTrace();
			try {
				conn.rollback();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} finally {
			try {
				if (conn != null && !conn.isClosed()) {
					conn.close();
				}
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		cro.setResult(0);
		return cro;
	}

	public int GetDBNum(String JudgeStoveNo) {
		Connection conn = null;
		return 0;
	}

	/**
	 * 判断该炉是否进行了该工序 工序号状态( 0-开始锯切 1-入炉 2-开始穿孔 3-开始连轧 4-入再加热炉 5-开始定径 6-开始分切
	 * 7-开始矫直 8-涡流探伤 9-漏磁探伤 10-超声波探伤 11-人工质检)
	 */
	public CoreReturnObject isBegineNode(String JUDGE_STOVE_NO, Integer Node) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection conn = null;
		PreparedStatement psta = null;
		int result = 0;
		try {

			String[] TableNameList = new String[] { "MIL_FEEDSAW_RESULT",
					"MIL_FUR_RESULT", "MIL_PERFORATION_RESULT",
					"MIL_ROLLING_RESULT", "MIL_REFUR_RESULT",
					"MIL_SIZING_RESULT", "MIL_SAW_RESULT",
					"MIL_STRAIGHTENING_RESULT", "MIL_ET_RESULT",
					"MIL_MT_RESULT", "MIL_UL_RESUL", "MIL_SURFACE_RESULT" };
			String tablename = TableNameList[Node];

			conn = this.getDao("TgDao").getConnection();
			conn.setAutoCommit(false);

			String sql = "Select JUDGE_STOVE_NO from ";
			sql += tablename;
			sql += " where judge_stove_no = '";
			sql += JUDGE_STOVE_NO;
			sql += "'";
			psta = conn.prepareStatement(sql);
			ResultSet rs = null;
			rs = psta.executeQuery();
			while (rs.next()) {
				if (rs.getString(1).length() > 0) {
					result = 1;
				}
			}
			// cro.s(String.valueOf(result).trim());
			psta.close();
		} catch (SQLException sqle) {
			sqle.printStackTrace();
			try {
				conn.rollback();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} finally {
			try {
				if (conn != null && !conn.isClosed()) {
					conn.close();
				}
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		cro.setResult(result);
		return cro;
	}

	/**
	 * 向对应工序的跟踪记录表里的相应记录插入开始时间 工序号状态( 0-开始锯切 1-入炉 2-开始穿孔 3-开始连轧 4-入再加热炉 5-开始定径
	 * 6-开始分切 7-开始矫直 8-开始探伤 9-开始质检) status 0,插入开始时间，1，插入结束时间
	 */
	public CoreReturnObject InsertSTToRack(String JUDGE_STOVE_NO, Integer Node,
			String status, String proPlanId, String gxPlanNo) {
		String[] TableNameList = new String[] { "MIL_FEED_RACK",
				"MIL_FUR_RACK", "MIL_PERFORATION_RACK", "MIL_ROLLING_RACK",
				"MIL_REFUR_RACK", "MIL_SIZING_RACK", "MIL_SAW_RACK",
				"MIL_STRAIGH_RACK", "MIL_TESTING_RACK", "MIL_QA_RACK" };
		String[] StartTimeList = new String[] { "FEED_TIME", "IN_FUR_TIME",
				"START_PERFORATION_TIME", "START_ROLLING_TIME",
				"IN_REFUR_TIME", "START_SIZING_TIME", "START_SAW_TIME",
				"START_STRAIGHTENING_TIME", "START_INSPECTION_TIME",
				"START_TIME" };
		String[] EndTimeList = new String[] { "END_TIME", "OUT_FUR_TIME",
				"END_PERFORATION_TIME", "END_ROLLING_TIME", "OUT_REFUR_TIME",
				"END_SIZING_TIME", "END_SAW_TIME", "END_STRAIGHTENING_TIME",
				"END_INSPECTION_TIME", "END_TIME" };

		String TableName = TableNameList[Node];
		String StartTime = StartTimeList[Node];
		String EndTime = EndTimeList[Node];
		String sql = "Update ";
		sql += TableName;
		sql += " SET ";
		if (status.equals("0"))// 插入开始时间
		{
			sql += StartTime;
			sql += " = SYSDATE   WHERE ";
			sql += "  JUDGE_STOVE_NO = '";
			sql += JUDGE_STOVE_NO;
			sql += "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
					+ "','/')";
		}
		if (status.equals("1")) {
			sql += EndTime;
			sql += " = SYSDATE    WHERE ";
			sql += "  JUDGE_STOVE_NO = '";
			sql += JUDGE_STOVE_NO;
			sql += "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
					+ "','/')";
		}
		return this.setData(sql);
	}

	/**
	 * 修改管号剔除原因 备注 工序号状态( 0-开始锯切 1-入炉 2-开始穿孔 3-开始连轧 4-入再加热炉 5-开始定径 6-开始分切 7-开始矫直
	 * 8-开始探伤 9-开始质检)
	 * 
	 */
	public CoreReturnObject UpdateMatNoPro(String JudgeStoveNo,
			String ResultNo, Integer ProcessNo, String Seq, String ScrapReason,
			String Remark) {
		ArrayList<String> sqllist = new ArrayList<String>();
		String[] TableNameList = new String[] { "MIL_FEED_RACK",
				"MIL_FUR_RACK", "MIL_PERFORATION_RACK", "MIL_ROLLING_RACK",
				"MIL_REFUR_RACK", "MIL_SIZING_RACK", "MIL_SAW_RACK",
				"MIL_STRAIGH_RACK", "MIL_TESTING_RACK", "MIL_QA_RACK" };

		String TableName = TableNameList[ProcessNo];
		String sql = "update " + TableName + " set SCRAP_REASON = '"
				+ ScrapReason + "' , REMARK = '" + Remark
				+ "' where JUDGE_STOVE_NO = '" + JudgeStoveNo
				+ "' and RESULT_NO = '" + ResultNo + "' and Seq = '" + Seq
				+ "'";
		sqllist.add(sql);
		return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(
				sqllist);
	}

	/**
	 * 获取操作台名称
	 * 
	 * @param strip
	 * @return
	 */
	public CoreReturnObject GetOperateResult(String strip) {
		return this.getDataBySqlID("FeedResult.GetOperateResult", new Object[] {
				strip, strip, strip, strip });
	}

	/**
	 * 获取PCODE
	 */
	public CoreReturnObject GetPCode(String Department) {
		String sql = CoreXmlSqlParsersFactory.getSql("FeedResult.GetPCode");
		return this.getData(sql, new Object[] { Department });
	}

	public CoreReturnObject GetRackScrpNum(String heatno, String seq) {
		String sql = "Select t.SCRAP_DBNUM   from MIL_FEED_RACK t WHERE  t.judge_stove_no=  '"
				+ heatno + "' ";
		sql += " AND t.seq= ";
		sql += seq;
		return this.getData(sql);
	}

	/**
	 * 管号队列剔除回退功能 逆向1、插入MIL_SLAB_SCRAP_SEQ表，2、管排锯跟踪记录表状态，3、修改加管排锯实绩表剔除支数
	 * 
	 * @param heatno
	 *            炉号
	 * @param seq
	 *            序号
	 * @param processno
	 *            工序号 0-锯切前 1-锯切后 2-环形加热炉 3-穿孔 4-连轧 5-再加热炉 6-定径 7-分切前 8-分切后
	 *            9-矫直1 10-矫直2 11-矫直3 12-ET探伤 13-涡流探伤 14-超声波探伤 15-人工质检
	 * @param Num
	 *            回退支数(锯切后，分切后需要支数)
	 * @param DBNum
	 *            (倍尺数或分切数)
	 * @param Colno
	 *            (台号--针对探伤1,2,3，其他工序为0，)
	 * @return
	 */
	public CoreReturnObject DeleteSlabSeq(String heatno, String seq,
			Integer processno, Integer Num, Integer DBNum, String Colno,
			String proPlanId, String gxPlanNo) {
		String[] TableNameListRACK = new String[] { "MIL_FEED_RACK",
				"MIL_FUR_RACK", "MIL_PERFORATION_RACK", "MIL_ROLLING_RACK",
				"MIL_REFUR_RACK", "MIL_SIZING_RACK", "MIL_SAW_RACK",
				"MIL_STRAIGH_RACK", "MIL_TESTING_RACK", "MIL_QA_RACK" };

		String[] TableNameListRESULT = new String[] { "MIL_FEEDSAW_RESULT",
				"MIL_FUR_RESULT", "MIL_PERFORATION_RESULT",
				"MIL_ROLLING_RESULT", "MIL_REFUR_RESULT", "MIL_SIZING_RESULT",
				"MIL_SAW_RESULT", "MIL_STRAIGHTENING_RESULT", "MIL_ET_RESULT",
				"MIL_MT_RESULT", "MIL_UL_RESUL" };

		String[] FildeNameListRESULT = new String[] { "BEFORE_SCRAP_NUM",
				"AFTER_SCRAP_NUM", };

		String tablefeed = "MIL_FEED_PLAN";
		String tablerack = "";
		String tableresult = "";
		String sql1 = "";// 剔除序列表
		String sql2 = "";// 实绩表
		String sql3 = "";// 跟踪记录表
		String sqltemp = "";// 额外增加
		ArrayList<String> sqllist = new ArrayList<String>();
		// -----更新MIL_SLAB_SCRAP_SEQ 表--------
		sql1 = "delete from MIL_SLAB_SCRAP_SEQ t WHERE t.judge_stove_no='";
		sql1 += heatno + "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
				+ "','/')";
		if (processno.equals(1) || processno.equals(8)) {
			sql1 += " AND t.SEQ in (";
			for (int i = 0; i < Num; i++) {
				sql1 += String
						.valueOf(((Integer.parseInt(seq) - 1) * DBNum + i + 1))
						+ ",";
			}
			sql1 = sql1.substring(0, sql1.length() - 1);
			sql1 += ")";

		} else {
			sql1 += " AND  t.SEQ = '";
			sql1 += seq;
			sql1 += "'";
		}
		sql1 += " AND t.process_no='";
		if (processno > 8 && processno < 12) {
			sql1 += 9;
		} else if (processno > 11 && processno < 15) {
			sql1 += 10;
		} else {
			sql1 += processno;
		}
		sql1 += "'";

		// -----------更新实绩表-------
		sql2 = " UPDATE ";
		if (processno.equals(0) || processno.equals(1))// 0-1
		{
			tableresult = TableNameListRESULT[0];
		}
		if (processno > 1 && processno < 7)// 2-6
		{
			tableresult = TableNameListRESULT[processno - 1];
		}
		if (processno.equals(7) || processno.equals(8))// 7-8
		{
			tableresult = TableNameListRESULT[6];
		}
		if (processno.equals(9) || processno.equals(10) || processno.equals(11))// 9-11
		{
			tableresult = TableNameListRESULT[7];
		}
		if (processno > 11 && processno < 15)// 12-14
		{
			tableresult = TableNameListRESULT[processno - 4];
		}
		sql2 += tableresult;
		if (processno.equals(0)) {
			sql2 += " t  SET t.BEFORE_SCRAP_NUM = t.BEFORE_SCRAP_NUM-1";
		}
		if (processno.equals(1)) {
			sql2 += " t  SET t.AFTER_SCRAP_NUM = t.AFTER_SCRAP_NUM-1";
		}
		if (processno > 1 && processno < 7)// 2,3,4,5,6,
		{
			sql2 += " t SET t.SCRAP_NUM=t.SCRAP_NUM-1, t.SCRAP_REASON='' ";
		}
		if (processno.equals(7)) {
			sql2 += " t SET t.SCRAP_NUM=t.SCRAP_NUM-1";
		}
		if (processno.equals(8)) {
			sql2 += " t SET t.SCRAP_DBNUM=t.SCRAP_DBNUM-";
			sql2 += Num;
		}
		if (processno.equals(9)) {
			sql2 += " t SET t.SCRAP_NUM=t.SCRAP_NUM-1, t.SCRAP_NUM1=t.SCRAP_NUM1-1";
		}
		if (processno.equals(10)) {
			sql2 += " t SET t.SCRAP_NUM=t.SCRAP_NUM-1,t.SCRAP_NUM2=t.SCRAP_NUM2-1";
		}
		if (processno.equals(11)) {
			sql2 += " t SET t.SCRAP_NUM=t.SCRAP_NUM-1,t.SCRAP_NUM3=t.SCRAP_NUM3-1";
		}
		if (processno > 11 && processno < 15)// 12-13-14
		{
			sql2 += " t SET t.SCRAP_NUM=t.SCRAP_NUM-1,t.SCRAP_REASON=''";
			if (Colno.equals("1")) {
				sql2 += " , t.SCRAP_NUM1=t.SCRAP_NUM1-1";
			}
			if (Colno.equals("2")) {
				sql2 += " , t.SCRAP_NUM2=t.SCRAP_NUM2-1";
			}
			if (Colno.equals("3")) {
				sql2 += " , t.SCRAP_NUM3=t.SCRAP_NUM3-1";
			}
		}
		if (processno.equals(0) || processno.equals(1)) {
			sql2 += " , t.CUT_NUM= (case nvl(CUT_NUM, 0) when 0 then 0 else t.CUT_NUM + 1 end)";// 合格支数字段
		}
		if (processno.equals(2)) {
			sql2 += " , t.OUT_FUR_NUM= (case nvl(OUT_FUR_NUM, 0) when 0 then 0 else t.OUT_FUR_NUM + 1 end)";// 合格支数字段
		}
		if (processno.equals(3)) {
			sql2 += " , t.PERFORATION_NUM= (case nvl(PERFORATION_NUM, 0) when 0 then 0 else t.PERFORATION_NUM + 1 end)";// 合格支数字段
		}
		if (processno.equals(4)) {
			sql2 += " , t.QUALIFIED_NUM= (case nvl(QUALIFIED_NUM, 0) when 0 then 0 else t.QUALIFIED_NUM + 1 end)";// 合格支数字段
		}
		if (processno.equals(5)) {
			sql2 += " , t.OUT_FUR_NUM= (case nvl(OUT_FUR_NUM, 0) when 0 then 0 else t.OUT_FUR_NUM + 1 end)";// 合格支数字段
		}
		if (processno.equals(6)) {
			sql2 += " , t.PRODUCT_NUM= (case nvl(PRODUCT_NUM, 0) when 0 then 0 else t.PRODUCT_NUM + 1 end)";// 合格支数字段
		}
		if (processno.equals(7)) {
			sql2 += " , t.CUT_NUM= (case nvl(CUT_NUM, 0) when 0 then 0 else t.CUT_NUM + 1 end)";// 合格支数字段
		}
		if (processno.equals(8)) {
			sql2 += " , t.CUT_DBNUM= (case nvl(CUT_DBNUM, 0) when 0 then 0 else t.CUT_DBNUM +";
			sql2 += Num;
			sql2 += "  end)";// 合格支数字段
		}
		if (processno.equals(9)) {
			sql2 += " , t.QUALIFIED_NUM1= (case nvl(QUALIFIED_NUM1, 0) when 0 then 0 else t.QUALIFIED_NUM1 + 1 end)";// 合格支数字段
			sql2 += " , t.QUALIFIED_NUM= (case nvl(QUALIFIED_NUM, 0) when 0 then 0 else t.QUALIFIED_NUM + 1 end)";// 合格支数字段
		}
		if (processno.equals(10)) {
			sql2 += " , t.QUALIFIED_NUM2= (case nvl(QUALIFIED_NUM2, 0) when 0 then 0 else t.QUALIFIED_NUM2 + 1 end)";// 合格支数字段
			sql2 += " , t.QUALIFIED_NUM= (case nvl(QUALIFIED_NUM, 0) when 0 then 0 else t.QUALIFIED_NUM + 1 end)";// 合格支数字段
		}
		if (processno.equals(11)) {
			sql2 += " , t.QUALIFIED_NUM3= (case nvl(QUALIFIED_NUM3, 0) when 0 then 0 else t.QUALIFIED_NUM3 + 1 end)";// 合格支数字段
			sql2 += " , t.QUALIFIED_NUM= (case nvl(QUALIFIED_NUM, 0) when 0 then 0 else t.QUALIFIED_NUM + 1 end)";// 合格支数字段
		}
		if (processno.equals(12) || processno.equals(13)
				|| processno.equals(14)) {
			sql2 += " , t.QUALIFIED_NUM= (case nvl(QUALIFIED_NUM, 0) when 0 then 0 else t.QUALIFIED_NUM + 1 end)";// 合格支数字段
			if (Colno.equals("1")) {
				sql2 += " , t.QUALIFIED_NUM1=(case nvl(QUALIFIED_NUM1, 0) when 0 then 0 else t.QUALIFIED_NUM1 + 1 end)";
			}
			if (Colno.equals("2")) {
				sql2 += " , t.QUALIFIED_NUM2=(case nvl(QUALIFIED_NUM2, 0) when 0 then 0 else t.QUALIFIED_NUM2 + 1 end)";
			}
			if (Colno.equals("3")) {
				sql2 += " , t.QUALIFIED_NUM3=(case nvl(QUALIFIED_NUM3, 0) when 0 then 0 else t.QUALIFIED_NUM3 + 1 end)";
			}
		}
		// if(processno.equals(13))
		// {
		// sql2+=" , t.QUALIFIED_NUM= (case nvl(QUALIFIED_NUM, 0) when 0 then 0 else t.QUALIFIED_NUM - 1 end)";//合格支数字段
		// }
		// if(processno.equals(14))
		// {
		// sql2+=" , t.QUALIFIED_NUM= (case nvl(QUALIFIED_NUM, 0) when 0 then 0 else t.QUALIFIED_NUM - 1 end)";//合格支数字段
		// }

		sql2 += " where t.judge_stove_no='";
		sql2 += heatno + "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
				+ "','/')";
		// ------------更新跟踪记录表-------------
		sql3 = " UPDATE ";
		if (processno.equals(0) || processno.equals(1))// 0-1
		{
			tablerack = TableNameListRACK[0];
		}
		if (processno > 1 && processno < 7)// 2-6
		{
			tablerack = TableNameListRACK[processno - 1];
		}
		if (processno.equals(7) || processno.equals(8)) {
			tablerack = TableNameListRACK[6];
		}
		if (processno > 8 && processno < 12)// 9-11
		{
			tablerack = TableNameListRACK[7];
		}
		if (processno > 11 && processno < 15)// 12-14
		{
			tablerack = TableNameListRACK[8];
		}
		sql3 += tablerack;
		if (processno.equals(0) || processno.equals(1)) {
			sql3 += " t SET t.STATUS=(select b.saw_falg from mil_feed_plan b where t.judge_stove_no = b.judge_stove_no and t.feed_row_no = b.feed_row_no)";
			sql3 += " , t.SCRAP_TIME='' ";
		} else {
			sql3 += " t SET t.STATUS=(SELECT (CASE   WHEN a.RETEST_NUM = 0 THEN  0 WHEN a.RETEST_NUM > 0 THEN 2  END) AS RETEST_NUM  FROM MIL_TESTING_RACK a  WHERE a.judge_stove_no = t.judge_stove_no AND a.SEQ=t.SEQ)";
			sql3 += " , t.SCRAP_TIME='' ";
		}
		if (processno > 1) {
			sql3 += ", t.SCRAP_REASON='' ";
		}
		if (processno.equals(1) || processno.equals(8)) {// 锯切后及分切后增加回退支数
			sql3 += " ,	SCRAP_DBNUM = '' ";
			// sql3 += Num;
		}
		sql3 += "  WHERE t.judge_stove_no='";
		sql3 += heatno + "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
				+ "','/')";
		sql3 += " AND  t.SEQ='";
		sql3 += seq;
		sql3 += "'";
		// -----------额外增加-------
		if (processno.equals(0)) {
			sqltemp = "UPDATE MIL_FEED_PLAN t SET t.SCRAP_FEEDNUM=t.SCRAP_FEEDNUM-1";
			sqltemp += " , t.FEED_NUM=t.FEED_NUM+1 ";
			sqltemp += " , t.QUALIFIED_NUM=t.QUALIFIED_NUM +";
			sqltemp += DBNum;
			sqltemp += " WHERE t.judge_stove_no='";
			sqltemp += heatno + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')";
		}
		if (processno.equals(1)) {
			sqltemp = "UPDATE MIL_FEED_PLAN t SET t.SCRAP_DBNUM=t.SCRAP_DBNUM-";
			sqltemp += Num;
			sqltemp += " , t.QUALIFIED_NUM =t.QUALIFIED_NUM+";
			sqltemp += Num;
			sqltemp += " WHERE t.judge_stove_no='";
			sqltemp += heatno + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')";

		}

		if (processno.equals(0) || processno.equals(1)) {
			sqllist.add(sql1);
			sqllist.add(sql3);
		} else {
			sqllist.add(sql1);
			sqllist.add(sql2);
			sqllist.add(sql3);
		}
		if (!sqltemp.equals("")) {
			sqllist.add(sqltemp);
		}
		if (processno.equals(6)) {
			String sqlSizing = "update mil_sizing_rack set SCRAP_LOC = '0' WHERE judge_stove_no = '"
					+ heatno
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo
					+ "','/')" + " and seq = " + seq + "";
			sqllist.add(sqlSizing);
		}
		if (processno.equals(12) || processno.equals(13)
				|| processno.equals(14)) {
			String sqlnew = "UPDATE " + tableresult + " T ";
			sqlnew += " SET T.REINSPECTION_QUALIFIED_NUM =(CASE (SELECT A.STATUS FROM MIL_TESTING_RACK A WHERE A.JUDGE_STOVE_NO='"
					+ heatno
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo
					+ "','/')"
					+ " AND A.SEQ="
					+ seq
					+ ")  WHEN '2' THEN T.REINSPECTION_QUALIFIED_NUM+1 END)";
			if (Colno.equals("1")) {
				sqlnew += " , T.REINSPECTION_QUALIFIED_NUM1=(CASE (SELECT A.STATUS FROM MIL_TESTING_RACK A WHERE A.JUDGE_STOVE_NO='"
						+ heatno
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
						+ proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
						+ gxPlanNo
						+ "','/')"
						+ " AND A.SEQ="
						+ seq
						+ ")  WHEN '2' THEN T.REINSPECTION_QUALIFIED_NUM1+1 END)";
			}
			if (Colno.equals("2")) {
				sqlnew += " , T.REINSPECTION_QUALIFIED_NUM2=(CASE (SELECT A.STATUS FROM MIL_TESTING_RACK A WHERE A.JUDGE_STOVE_NO='"
						+ heatno
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
						+ proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
						+ gxPlanNo
						+ "','/')"
						+ " AND A.SEQ="
						+ seq
						+ ")  WHEN '2' THEN T.REINSPECTION_QUALIFIED_NUM2+1 END)";
			}
			if (Colno.equals("3")) {
				sqlnew += " , T.REINSPECTION_QUALIFIED_NUM3=(CASE (SELECT A.STATUS FROM MIL_TESTING_RACK A WHERE A.JUDGE_STOVE_NO='"
						+ heatno
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
						+ proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
						+ gxPlanNo
						+ "','/')"
						+ " AND A.SEQ="
						+ seq
						+ ")  WHEN '2' THEN T.REINSPECTION_QUALIFIED_NUM2+1 END)";
			}
			sqlnew += " WHERE T.judge_stove_no= '" + heatno
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
					+ "','/')";
			sqllist.add(sqlnew);
		}
		return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(
				sqllist);
	}

	/**
	 * 管号队列剔除回退功能 逆向1、插入MIL_SLAB_SCRAP_SEQ表，2、管排锯跟踪记录表状态，3、修改加管排锯实绩表剔除支数
	 * 
	 * @param heatno
	 *            炉号
	 * @param seq
	 *            序号
	 * @param processno
	 *            工序号 0-锯切前 1-锯切后 2-环形加热炉 3-穿孔 4-连轧 5-再加热炉 6-定径 7-分切前 8-分切后
	 *            9-矫直1 10-矫直2 11-矫直3 12-ET探伤 13-涡流探伤 14-超声波探伤 15-人工质检
	 * @param Num
	 *            回退支数(锯切后，分切后需要支数)
	 * @param DBNum
	 *            (倍尺数或分切数)
	 * @param Colno
	 *            (台号--针对探伤1,2,3，其他工序为0，)
	 * @return
	 */
	public CoreReturnObject DeleteFeedSlabSeq(String heatno, String feedrowno,
			String seq, Integer processno, Integer Num, Integer DBNum,
			String Colno, String proPlanId, String gxPlanNo) {
		String[] TableNameListRACK = new String[] { "MIL_FEED_RACK",
				"MIL_FUR_RACK", "MIL_PERFORATION_RACK", "MIL_ROLLING_RACK",
				"MIL_REFUR_RACK", "MIL_SIZING_RACK", "MIL_SAW_RACK",
				"MIL_STRAIGH_RACK", "MIL_TESTING_RACK", "MIL_QA_RACK" };

		String[] TableNameListRESULT = new String[] { "MIL_FEEDSAW_RESULT",
				"MIL_FUR_RESULT", "MIL_PERFORATION_RESULT",
				"MIL_ROLLING_RESULT", "MIL_REFUR_RESULT", "MIL_SIZING_RESULT",
				"MIL_SAW_RESULT", "MIL_STRAIGHTENING_RESULT", "MIL_ET_RESULT",
				"MIL_MT_RESULT", "MIL_UL_RESUL" };

		String[] FildeNameListRESULT = new String[] { "BEFORE_SCRAP_NUM",
				"AFTER_SCRAP_NUM", };

		String tablefeed = "MIL_FEED_PLAN";
		String tablerack = "";
		String tableresult = "";
		String sql1 = "";// 剔除序列表
		String sql2 = "";// 实绩表
		String sql3 = "";// 跟踪记录表
		String sqltemp = "";// 额外增加
		ArrayList<String> sqllist = new ArrayList<String>();
		// -----更新MIL_SLAB_SCRAP_SEQ 表--------
		sql1 = "delete from MIL_SLAB_SCRAP_SEQ t WHERE t.judge_stove_no='";
		sql1 += heatno + "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
				+ "','/')";
		if (processno.equals(1) || processno.equals(8)) {
			sql1 += " AND t.SEQ in (";
			for (int i = 0; i < Num; i++) {
				sql1 += String
						.valueOf(((Integer.parseInt(seq) - 1) * DBNum + i + 1))
						+ ",";
			}
			sql1 = sql1.substring(0, sql1.length() - 1);
			sql1 += ")";

		} else {
			sql1 += " AND  t.SEQ = '";
			sql1 += seq;
			sql1 += "'";
		}
		sql1 += " AND t.process_no='";
		if (processno > 8 && processno < 12) {
			sql1 += 9;
		} else if (processno > 11 && processno < 15) {
			sql1 += 10;
		} else {
			sql1 += processno;
		}
		sql1 += "'";

		// -----------更新实绩表-------
		sql2 = " UPDATE ";
		if (processno.equals(0) || processno.equals(1))// 0-1
		{
			tableresult = TableNameListRESULT[0];
		}
		if (processno > 1 && processno < 7)// 2-6
		{
			tableresult = TableNameListRESULT[processno - 1];
		}
		if (processno.equals(7) || processno.equals(8))// 7-8
		{
			tableresult = TableNameListRESULT[6];
		}
		if (processno.equals(9) || processno.equals(10) || processno.equals(11))// 9-11
		{
			tableresult = TableNameListRESULT[7];
		}
		if (processno > 11 && processno < 15)// 12-14
		{
			tableresult = TableNameListRESULT[processno - 4];
		}
		sql2 += tableresult;
		if (processno.equals(0)) {
			sql2 += " t  SET t.BEFORE_SCRAP_NUM = t.BEFORE_SCRAP_NUM-1";
		}
		if (processno.equals(1)) {
			sql2 += " t  SET t.AFTER_SCRAP_NUM = t.AFTER_SCRAP_NUM-1";
		}
		if (processno > 1 && processno < 7)// 2,3,4,5,6,
		{
			sql2 += " t SET t.SCRAP_NUM=t.SCRAP_NUM-1, t.SCRAP_REASON='' ";
		}
		if (processno.equals(7)) {
			sql2 += " t SET t.SCRAP_NUM=t.SCRAP_NUM-1";
		}
		if (processno.equals(8)) {
			sql2 += " t SET t.SCRAP_DBNUM=t.SCRAP_DBNUM-";
			sql2 += Num;
		}
		if (processno.equals(9)) {
			sql2 += " t SET t.SCRAP_NUM=t.SCRAP_NUM-1, t.SCRAP_NUM1=t.SCRAP_NUM1-1";
		}
		if (processno.equals(10)) {
			sql2 += " t SET t.SCRAP_NUM=t.SCRAP_NUM-1,t.SCRAP_NUM2=t.SCRAP_NUM2-1";
		}
		if (processno.equals(11)) {
			sql2 += " t SET t.SCRAP_NUM=t.SCRAP_NUM-1,t.SCRAP_NUM3=t.SCRAP_NUM3-1";
		}
		if (processno > 11 && processno < 15)// 12-13-14
		{
			sql2 += " t SET t.SCRAP_NUM=t.SCRAP_NUM-1,t.SCRAP_REASON=''";
			if (Colno.equals("1")) {
				sql2 += " , t.SCRAP_NUM1=t.SCRAP_NUM1-1";
			}
			if (Colno.equals("2")) {
				sql2 += " , t.SCRAP_NUM2=t.SCRAP_NUM2-1";
			}
			if (Colno.equals("3")) {
				sql2 += " , t.SCRAP_NUM3=t.SCRAP_NUM3-1";
			}
		}
		if (processno.equals(0) || processno.equals(1)) {
			sql2 += " , t.CUT_NUM= (case nvl(CUT_NUM, 0) when 0 then 0 else t.CUT_NUM + 1 end)";// 合格支数字段
		}
		if (processno.equals(2)) {
			sql2 += " , t.OUT_FUR_NUM= (case nvl(OUT_FUR_NUM, 0) when 0 then 0 else t.OUT_FUR_NUM + 1 end)";// 合格支数字段
		}
		if (processno.equals(3)) {
			sql2 += " , t.PERFORATION_NUM= (case nvl(PERFORATION_NUM, 0) when 0 then 0 else t.PERFORATION_NUM + 1 end)";// 合格支数字段
		}
		if (processno.equals(4)) {
			sql2 += " , t.QUALIFIED_NUM= (case nvl(QUALIFIED_NUM, 0) when 0 then 0 else t.QUALIFIED_NUM + 1 end)";// 合格支数字段
		}
		if (processno.equals(5)) {
			sql2 += " , t.OUT_FUR_NUM= (case nvl(OUT_FUR_NUM, 0) when 0 then 0 else t.OUT_FUR_NUM + 1 end)";// 合格支数字段
		}
		if (processno.equals(6)) {
			sql2 += " , t.PRODUCT_NUM= (case nvl(PRODUCT_NUM, 0) when 0 then 0 else t.PRODUCT_NUM + 1 end)";// 合格支数字段
		}
		if (processno.equals(7)) {
			sql2 += " , t.CUT_NUM= (case nvl(CUT_NUM, 0) when 0 then 0 else t.CUT_NUM + 1 end)";// 合格支数字段
		}
		if (processno.equals(8)) {
			sql2 += " , t.CUT_DBNUM= (case nvl(CUT_DBNUM, 0) when 0 then 0 else t.CUT_DBNUM +";
			sql2 += Num;
			sql2 += "  end)";// 合格支数字段
		}
		if (processno.equals(9)) {
			sql2 += " , t.QUALIFIED_NUM1= (case nvl(QUALIFIED_NUM1, 0) when 0 then 0 else t.QUALIFIED_NUM1 + 1 end)";// 合格支数字段
			sql2 += " , t.QUALIFIED_NUM= (case nvl(QUALIFIED_NUM, 0) when 0 then 0 else t.QUALIFIED_NUM + 1 end)";// 合格支数字段
		}
		if (processno.equals(10)) {
			sql2 += " , t.QUALIFIED_NUM2= (case nvl(QUALIFIED_NUM2, 0) when 0 then 0 else t.QUALIFIED_NUM2 + 1 end)";// 合格支数字段
			sql2 += " , t.QUALIFIED_NUM= (case nvl(QUALIFIED_NUM, 0) when 0 then 0 else t.QUALIFIED_NUM + 1 end)";// 合格支数字段
		}
		if (processno.equals(11)) {
			sql2 += " , t.QUALIFIED_NUM3= (case nvl(QUALIFIED_NUM3, 0) when 0 then 0 else t.QUALIFIED_NUM3 + 1 end)";// 合格支数字段
			sql2 += " , t.QUALIFIED_NUM= (case nvl(QUALIFIED_NUM, 0) when 0 then 0 else t.QUALIFIED_NUM + 1 end)";// 合格支数字段
		}
		if (processno.equals(12) || processno.equals(13)
				|| processno.equals(14)) {
			sql2 += " , t.QUALIFIED_NUM= (case nvl(QUALIFIED_NUM, 0) when 0 then 0 else t.QUALIFIED_NUM + 1 end)";// 合格支数字段
			if (Colno.equals("1")) {
				sql2 += " , t.QUALIFIED_NUM1=(case nvl(QUALIFIED_NUM1, 0) when 0 then 0 else t.QUALIFIED_NUM1 + 1 end)";
			}
			if (Colno.equals("2")) {
				sql2 += " , t.QUALIFIED_NUM2=(case nvl(QUALIFIED_NUM2, 0) when 0 then 0 else t.QUALIFIED_NUM2 + 1 end)";
			}
			if (Colno.equals("3")) {
				sql2 += " , t.QUALIFIED_NUM3=(case nvl(QUALIFIED_NUM3, 0) when 0 then 0 else t.QUALIFIED_NUM3 + 1 end)";
			}
		}
		// if(processno.equals(13))
		// {
		// sql2+=" , t.QUALIFIED_NUM= (case nvl(QUALIFIED_NUM, 0) when 0 then 0 else t.QUALIFIED_NUM - 1 end)";//合格支数字段
		// }
		// if(processno.equals(14))
		// {
		// sql2+=" , t.QUALIFIED_NUM= (case nvl(QUALIFIED_NUM, 0) when 0 then 0 else t.QUALIFIED_NUM - 1 end)";//合格支数字段
		// }

		sql2 += " where t.judge_stove_no='";
		sql2 += heatno + "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
				+ "','/')";

		// ------------更新跟踪记录表-------------
		sql3 = " UPDATE ";
		if (processno.equals(0) || processno.equals(1))// 0-1
		{
			tablerack = TableNameListRACK[0];
		}
		if (processno > 1 && processno < 7)// 2-6
		{
			tablerack = TableNameListRACK[processno - 1];
		}
		if (processno.equals(7) || processno.equals(8)) {
			tablerack = TableNameListRACK[6];
		}
		if (processno > 8 && processno < 12)// 9-11
		{
			tablerack = TableNameListRACK[7];
		}
		if (processno > 11 && processno < 15)// 12-14
		{
			tablerack = TableNameListRACK[8];
		}
		sql3 += tablerack;
		if (processno.equals(0) || processno.equals(1)) {
			sql3 += " t SET t.STATUS=(select b.saw_falg from mil_feed_plan b where t.judge_stove_no = b.judge_stove_no and t.feed_row_no = b.feed_row_no)";
			sql3 += " , t.SCRAP_TIME='' ";
		} else {
			sql3 += " t SET t.STATUS=(SELECT (CASE   WHEN a.RETEST_NUM = 0 THEN  0 WHEN a.RETEST_NUM > 0 THEN 2  END) AS RETEST_NUM  FROM MIL_TESTING_RACK a  WHERE a.judge_stove_no = t.judge_stove_no AND a.SEQ=t.SEQ)";
			sql3 += " , t.SCRAP_TIME='' ";
		}
		if (processno > 1) {
			sql3 += ", t.SCRAP_REASON='' ";
		}
		if (processno.equals(1) || processno.equals(8)) {// 锯切后及分切后增加回退支数
			sql3 += " ,	SCRAP_DBNUM = '' ";
			// sql3 += Num;
		}
		sql3 += "  WHERE t.judge_stove_no='";
		sql3 += heatno + "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
				+ "','/')";
		sql3 += " AND  t.SEQ='";
		sql3 += seq;
		sql3 += "'";
		// -----------额外增加-------
		if (processno.equals(0)) {
			sqltemp = "UPDATE MIL_FEED_PLAN t SET t.SCRAP_FEEDNUM=t.SCRAP_FEEDNUM-1";
			sqltemp += " , t.FEED_NUM=t.FEED_NUM+1 ";
			sqltemp += " , t.QUALIFIED_NUM=t.QUALIFIED_NUM +";
			sqltemp += DBNum;
			sqltemp += " WHERE t.judge_stove_no='";
			sqltemp += heatno + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')";
			sqltemp += " and t.FEED_ROW_NO = '" + feedrowno + "' ";
		}
		if (processno.equals(1)) {
			sqltemp = "UPDATE MIL_FEED_PLAN t SET t.SCRAP_DBNUM=t.SCRAP_DBNUM-";
			sqltemp += Num;
			sqltemp += " , t.QUALIFIED_NUM =t.QUALIFIED_NUM+";
			sqltemp += Num;
			sqltemp += " WHERE t.judge_stove_no='";
			sqltemp += heatno + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')";
			sqltemp += " and t.FEED_ROW_NO = '" + feedrowno + "' ";

		}

		if (processno.equals(0) || processno.equals(1)) {
			sqllist.add(sql1);
			sqllist.add(sql3);
		} else {
			sqllist.add(sql1);
			sqllist.add(sql2);
			sqllist.add(sql3);
		}
		if (!sqltemp.equals("")) {
			sqllist.add(sqltemp);
		}
		if (processno.equals(6)) {
			String sqlSizing = "update mil_sizing_rack set SCRAP_LOC = '0' WHERE judge_stove_no = '"
					+ heatno
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo
					+ "','/')" + " and seq = " + seq + "";
			sqllist.add(sqlSizing);
		}
		if (processno.equals(12) || processno.equals(13)
				|| processno.equals(14)) {
			String sqlnew = "UPDATE " + tableresult + " T ";
			sqlnew += " SET T.REINSPECTION_QUALIFIED_NUM =(CASE (SELECT A.STATUS FROM MIL_TESTING_RACK A WHERE A.JUDGE_STOVE_NO='"
					+ heatno
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo
					+ "','/')"
					+ " AND A.SEQ="
					+ seq
					+ ")  WHEN '2' THEN T.REINSPECTION_QUALIFIED_NUM+1 END)";
			if (Colno.equals("1")) {
				sqlnew += " , T.REINSPECTION_QUALIFIED_NUM1=(CASE (SELECT A.STATUS FROM MIL_TESTING_RACK A WHERE A.JUDGE_STOVE_NO='"
						+ heatno
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
						+ proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
						+ gxPlanNo
						+ "','/')"
						+ " AND A.SEQ="
						+ seq
						+ ")  WHEN '2' THEN T.REINSPECTION_QUALIFIED_NUM1+1 END)";
			}
			if (Colno.equals("2")) {
				sqlnew += " , T.REINSPECTION_QUALIFIED_NUM2=(CASE (SELECT A.STATUS FROM MIL_TESTING_RACK A WHERE A.JUDGE_STOVE_NO='"
						+ heatno
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
						+ proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
						+ gxPlanNo
						+ "','/')"
						+ " AND A.SEQ="
						+ seq
						+ ")  WHEN '2' THEN T.REINSPECTION_QUALIFIED_NUM2+1 END)";
			}
			if (Colno.equals("3")) {
				sqlnew += " , T.REINSPECTION_QUALIFIED_NUM3=(CASE (SELECT A.STATUS FROM MIL_TESTING_RACK A WHERE A.JUDGE_STOVE_NO='"
						+ heatno
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
						+ proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
						+ gxPlanNo
						+ "','/')"
						+ " AND A.SEQ="
						+ seq
						+ ")  WHEN '2' THEN T.REINSPECTION_QUALIFIED_NUM2+1 END)";
			}
			sqlnew += " WHERE T.judge_stove_no= '" + heatno
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
					+ "','/')";
			sqllist.add(sqlnew);
		}
		return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(
				sqllist);
	}

	/**
	 * 查询IP表对应记录
	 * 
	 * @param MilBase
	 * @return
	 */
	public CoreReturnObject CheckIpAddress(MilBaseAddressEntity MilBase) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FeedResult.CheckIpAddress");
		sql = EntityTool.fillSqlByEntity(sql, MilBase);
		return this.getData(sql);
	}

	/**
	 * 查询服务器时间
	 * 
	 * @param MilBase
	 * @return
	 */
	public CoreReturnObject GetSeverTime() {
		String sql = "select to_char(sysdate,'yyyy-MM-DD HH24:mi:ss') from dual";

		return this.getData(sql);
	}

	/**
	 * 查询服务器时间
	 * 
	 * @param MilBase
	 * @return
	 */
	public CoreReturnObject SaveRemark(String JudgeStoveNo, String ResultNo,
			String Remark, String StartTime, String EndTime, String proPlanId,
			String gxPlanNo) {
		String sql = "update mil_feedsaw_result set remark = '" + Remark
				+ "' ,  START_TIME=to_date('" + StartTime
				+ "','yyyy-mm-dd hh24:mi:ss'),  END_TIME=to_date('" + EndTime
				+ "','yyyy-mm-dd hh24:mi:ss') where JUDGE_STOVE_NO = '"
				+ JudgeStoveNo + "' and RESULT_NO = '" + ResultNo
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
				+ "','/')";

		return this.setData(sql);
	}

	/**
	 * 结炉时剔除剔料序号表对应管坯
	 * 
	 * @param ProcessNo
	 *            工序号 0-上 料锯切 1-加热炉 2-穿孔 3-连轧 4-再加热 5-定径 6-分切 7-矫直 8-探伤 9-质检
	 * @return CoreReturnObject
	 */
	public CoreReturnObject NodeCheckMat(String JudgeStoveNo,
			Integer ProcessNo, String proPlanId, String gxPlanNo) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection conn = null;
		PreparedStatement psta = null;
		String[] TableNameList = new String[] { "MIL_FEED_RACK",
				"MIL_FUR_RACK", "MIL_PERFORATION_RACK", "MIL_ROLLING_RACK",
				"MIL_REFUR_RACK", "MIL_SIZING_RACK", "MIL_SAW_RACK",
				"MIL_STRAIGH_RACK", "MIL_TESTING_RACK", "MIL_QA_RACK" };

		try {
			conn = this.getDao("TgDao").getConnection();
			conn.setAutoCommit(false);

			String sql = "";
			ResultSet rs = null;
			// 热轧
			if (ProcessNo < 6 || ProcessNo == 7) {
				int UnusualNum = 0;
				sql = "select count(*) from " + TableNameList[ProcessNo]
						+ " where mat_no is null and judge_stove_no = '"
						+ JudgeStoveNo + "' union all select  count(*) from "
						+ TableNameList[ProcessNo]
						+ " where mat_no = 'null' and judge_stove_no = '"
						+ JudgeStoveNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
						+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
						+ gxPlanNo + "','/')";
				psta = conn.prepareStatement(sql);
				rs = psta.executeQuery();
				while (rs.next()) {
					UnusualNum += rs.getInt(1);
				}
				rs.close();
				psta.close();
				if (UnusualNum > 0) {
					sql = "update " + TableNameList[ProcessNo]
							+ " set status = '1' where judge_stove_no = '"
							+ JudgeStoveNo + "' and seq in";
					sql += "(select seq from  " + TableNameList[ProcessNo]
							+ " where rownum <= " + UnusualNum + ")";
					sql += " and judge_stove_no = '" + JudgeStoveNo
							+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
							+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
							+ gxPlanNo + "','/')"
							+ " and status = '0' order by seq desc )";

					// 将材料号为空 或者NULL的材料状态从1改为0
					sql = "update "
							+ TableNameList[ProcessNo]
							+ " set status = '0' where mat_no is null and judge_stove_no = '"
							+ JudgeStoveNo
							+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
							+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
							+ gxPlanNo + "','/')";
					psta = conn.prepareStatement(sql);
					psta.executeUpdate(sql);
					psta.close();

					sql = "update "
							+ TableNameList[ProcessNo]
							+ " set status = '0' where mat_no ='null' and judge_stove_no = '"
							+ JudgeStoveNo
							+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
							+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
							+ gxPlanNo + "','/')";
					psta = conn.prepareStatement(sql);
					psta.executeUpdate(sql);
					psta.close();
				}
			}
			// 分切
			else if (ProcessNo == 6) {
				int UnusualNum = 0;
				// 切前剔除处理
				sql = "select count(*) from " + TableNameList[ProcessNo]
						+ " where mat_no is null and judge_stove_no = '"
						+ JudgeStoveNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
						+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
						+ gxPlanNo + "','/')"
						+ " and status = '3' union all select  count(*) from "
						+ TableNameList[ProcessNo]
						+ " where mat_no = 'null' and judge_stove_no = '"
						+ JudgeStoveNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
						+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
						+ gxPlanNo + "','/')" + " and status = '3'";
				psta = conn.prepareStatement(sql);
				rs = psta.executeQuery();
				while (rs.next()) {
					UnusualNum += rs.getInt(1);
				}
				rs.close();
				psta.close();
				if (UnusualNum > 0) {
					sql = "update " + TableNameList[ProcessNo]
							+ " set status = '3' where judge_stove_no = '"
							+ JudgeStoveNo
							+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
							+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
							+ gxPlanNo + "','/')" + " and seq in";
					sql += "(select seq from  " + TableNameList[ProcessNo]
							+ " where rownum <= " + UnusualNum + ")";
					sql += " and judge_stove_no = '" + JudgeStoveNo
							+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
							+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
							+ gxPlanNo + "','/')"
							+ " and status = '0' order by seq desc )";

					// 将材料号为空 或者NULL的材料状态从1改为0
					sql = "update "
							+ TableNameList[ProcessNo]
							+ " set status = '0' where mat_no is null and judge_stove_no = '"
							+ JudgeStoveNo
							+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
							+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
							+ gxPlanNo + "','/')";
					psta = conn.prepareStatement(sql);
					psta.executeUpdate(sql);
					psta.close();

					sql = "update "
							+ TableNameList[ProcessNo]
							+ " set status = '0' where mat_no ='null' and judge_stove_no = '"
							+ JudgeStoveNo
							+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
							+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
							+ gxPlanNo + "','/')";
					psta = conn.prepareStatement(sql);
					psta.executeUpdate(sql);
					psta.close();
				}
				// 切后剔除处理
				// int UnusualNum1 = 0;
				sql = "select SCRAP_DBNUM from "
						+ TableNameList[ProcessNo]
						+ " where mat_no is null and judge_stove_no = '"
						+ JudgeStoveNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
						+ proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
						+ gxPlanNo
						+ "','/')"
						+ " and status = '4' union all select  SCRAP_DBNUM from "
						+ TableNameList[ProcessNo]
						+ " where mat_no = 'null' and judge_stove_no = '"
						+ JudgeStoveNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
						+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
						+ gxPlanNo + "','/')" + " and status = '4'";
				psta = conn.prepareStatement(sql);
				rs = psta.executeQuery();
				while (rs.next()) {
					int ScrapDBNum = rs.getInt(1);
					sql = "update " + TableNameList[ProcessNo]
							+ " set status = '3' and SCRAP_DBNUM ="
							+ ScrapDBNum + " where judge_stove_no = '"
							+ JudgeStoveNo
							+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
							+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
							+ gxPlanNo + "','/')" + " and seq in";
					sql += "(select seq from  " + TableNameList[ProcessNo]
							+ " where rownum = 1)";
					sql += " and judge_stove_no = '" + JudgeStoveNo
							+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
							+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
							+ gxPlanNo + "','/')" + " order by seq desc )";
				}
				sql = "update "
						+ TableNameList[ProcessNo]
						+ " set status = '0' where mat_no is null and judge_stove_no = '"
						+ JudgeStoveNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
						+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
						+ gxPlanNo + "','/')";
				psta = conn.prepareStatement(sql);
				psta.executeUpdate(sql);
				psta.close();

				sql = "update "
						+ TableNameList[ProcessNo]
						+ " set status = '0' where mat_no ='null' and judge_stove_no = '"
						+ JudgeStoveNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
						+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
						+ gxPlanNo + "','/')";
				psta = conn.prepareStatement(sql);
				psta.executeUpdate(sql);
				psta.close();
			}
			// 探伤
			else if (ProcessNo == 8) {
				// 剔除
				int UnusualNum = 0;
				// 切前剔除处理
				sql = "select count(*) from " + TableNameList[ProcessNo]
						+ " where mat_no is null and judge_stove_no = '"
						+ JudgeStoveNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
						+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
						+ gxPlanNo + "','/')"
						+ " and status = '1' union all select  count(*) from "
						+ TableNameList[ProcessNo]
						+ " where mat_no = 'null' and judge_stove_no = '"
						+ JudgeStoveNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
						+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
						+ gxPlanNo + "','/')" + " and status = '1'";
				psta = conn.prepareStatement(sql);
				rs = psta.executeQuery();
				while (rs.next()) {
					UnusualNum += rs.getInt(1);
				}
				rs.close();
				psta.close();
				if (UnusualNum > 0) {
					sql = "update " + TableNameList[ProcessNo]
							+ " set status = '1' where judge_stove_no = '"
							+ JudgeStoveNo
							+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
							+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
							+ gxPlanNo + "','/')" + " and seq in";
					sql += "(select seq from  " + TableNameList[ProcessNo]
							+ " where rownum <= " + UnusualNum + ")";
					sql += " and judge_stove_no = '" + JudgeStoveNo
							+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
							+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
							+ gxPlanNo + "','/')"
							+ " and status = '0' order by seq desc )";

					// 将材料号为空 或者NULL的材料状态从1改为0
					sql = "update "
							+ TableNameList[ProcessNo]
							+ " set status = '0' where mat_no is null and judge_stove_no = '"
							+ JudgeStoveNo
							+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
							+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
							+ gxPlanNo + "','/')";
					psta = conn.prepareStatement(sql);
					psta.executeUpdate(sql);
					psta.close();

					sql = "update "
							+ TableNameList[ProcessNo]
							+ " set status = '0' where mat_no ='null' and judge_stove_no = '"
							+ JudgeStoveNo
							+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
							+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
							+ gxPlanNo + "','/')";
					psta = conn.prepareStatement(sql);
					psta.executeUpdate(sql);
					psta.close();
				}
				// 复探
				sql = "select RETEST_NUM from "
						+ TableNameList[ProcessNo]
						+ " where mat_no is null and judge_stove_no = '"
						+ JudgeStoveNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
						+ proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
						+ gxPlanNo
						+ "','/')"
						+ " and status = '4' union all select  RETEST_NUM from "
						+ TableNameList[ProcessNo]
						+ " where mat_no = 'null' and judge_stove_no = '"
						+ JudgeStoveNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
						+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
						+ gxPlanNo + "','/')" + " and status = '4'";
				psta = conn.prepareStatement(sql);
				rs = psta.executeQuery();
				while (rs.next()) {
					int Rtsest = rs.getInt(1);
					sql = "update " + TableNameList[ProcessNo]
							+ " set status = '2' and RETEST_NUM =" + Rtsest
							+ " where judge_stove_no = '" + JudgeStoveNo
							+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
							+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
							+ gxPlanNo + "','/')" + "  and seq in";
					sql += "(select seq from  " + TableNameList[ProcessNo]
							+ " where rownum = 1)";
					sql += " and judge_stove_no = '" + JudgeStoveNo
							+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
							+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
							+ gxPlanNo + "','/')" + " order by seq desc )";
				}
				sql = "update "
						+ TableNameList[ProcessNo]
						+ " set status = '0' where mat_no is null and judge_stove_no = '"
						+ JudgeStoveNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
						+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
						+ gxPlanNo + "','/')";
				psta = conn.prepareStatement(sql);
				psta.executeUpdate(sql);
				psta.close();

				sql = "update "
						+ TableNameList[ProcessNo]
						+ " set status = '0' where mat_no ='null' and judge_stove_no = '"
						+ JudgeStoveNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
						+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
						+ gxPlanNo + "','/')";
				psta = conn.prepareStatement(sql);
				psta.executeUpdate(sql);
				psta.close();
			}
		} catch (SQLException sqle) {
			sqle.printStackTrace();
			try {
				conn.rollback();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} finally {
			try {
				if (conn != null && !conn.isClosed()) {
					conn.close();
				}
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		cro.setResult(0);
		return cro;
	}

	/**
	 * 判断当前炉次是否允许结炉回退
	 * 
	 * @param ProcessNo
	 *            工序号 0-锯切 1-环形加热炉 2-穿孔 3-连轧 4-再加热炉 5-定径 6-管排锯 7-矫直 8-探伤 9-质检
	 * @param PLineCode
	 *            产线代码
	 * @param JudgeStoveNo
	 *            炉号
	 * @param ResultNo
	 *            实绩编号
	 * @return
	 */
	public CoreReturnObject doNodeBackCheck(String JudgeStvoeNo,
			String ResultNo, String proPlanId, String gxPlanNo) {
		/*
		 * String[] TableNameList = new String[]{"MIL_FEEDSAW_RESULT",
		 * "MIL_FUR_Result", "MIL_PERFORATION_Result", "MIL_ROLLING_Result",
		 * "MIL_REFUR_Result", "MIL_SIZING_Result", "MIL_SAW_Result",
		 * "MIL_STRAIGHTENING_RESULT", "MIL_ET_RESULT"
		 * ,"MIL_MT_RESULT","MIL_UL_RESUL","MIL_SURFACE_RESULT"}; String
		 * TableName = ""; if(ProcessNo<8) { TableName
		 * =TableNameList[ProcessNo+1]; }
		 */
		String sql = "select NODE_STATUS FROM MIL_PLAN WHERE JUDGE_STOVE_NO = '"
				+ JudgeStvoeNo
				+ "' AND ID = '"
				+ ResultNo
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
				+ proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
				+ gxPlanNo
				+ "','/')";
		return this.getData(sql);
	}

	/**
	 * 判断当前炉次结炉班组
	 * 
	 * @param ProcessNo
	 *            工序号 0-锯切 1-环形加热炉 2-穿孔 3-连轧 4-再加热炉 5-定径 6-管排锯 7-矫直 8-探伤 11-质检
	 * @param PLineCode
	 *            产线代码
	 * @param JudgeStoveNo
	 *            炉号
	 * @param ResultNo
	 *            实绩编号
	 * @return
	 */
	public CoreReturnObject doNodeBackCheck(String JudgeStvoeNo,
			String ResultNo, Integer ProcessNo, String proPlanId,
			String gxPlanNo) {
		String[] TableNameList = new String[] { "MIL_FEEDSAW_RESULT",
				"MIL_FUR_Result", "MIL_PERFORATION_Result",
				"MIL_ROLLING_Result", "MIL_REFUR_Result", "MIL_SIZING_Result",
				"MIL_SAW_Result", "MIL_STRAIGHTENING_RESULT", "MIL_ET_RESULT",
				"MIL_MT_RESULT", "MIL_UL_RESUL", "MIL_SURFACE_RESULT" };
		String TableName = "";

		TableName = TableNameList[ProcessNo];

		String sql = "select COL_SHIFT,COL_GROUP FROM " + TableName
				+ " WHERE JUDGE_STOVE_NO = '" + JudgeStvoeNo
				+ "' AND RESULT_NO = '" + ResultNo
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
				+ "','/')";
		return this.getData(sql);
	}

	/**
	 * 判断当前炉次是否允许结炉回退
	 * 
	 * @param ProcessNo
	 *            工序号 0-锯切 1-环形加热炉 2-穿孔 3-连轧 4-再加热炉 5-定径 6-管排锯 7-矫直 8-探伤 9-质检
	 * @param PLineCode
	 *            产线代码
	 * @param JudgeStoveNo
	 *            炉号
	 * @param ResultNo
	 *            实绩编号
	 * @return
	 */
	public CoreReturnObject changeFlagQuery(String JudgeStvoeNo,
			String ResultNo, Integer ProcessNo, String proPlanId,
			String gxPlanNo) {
		String[] TableRackList = new String[] { "MIL_FEED_RACK",
				"MIL_FUR_RACK", "MIL_PERFORATION_RACK", "MIL_ROLLING_RACK",
				"MIL_REFUR_RACK", "MIL_SIZING_RACK", "MIL_SAW_RACK",
				"MIL_STRAIGH_RACK", "MIL_TESTING_RACK", "MIL_QA_RACK" };

		String sql = "select NVL(MAX(SEQ),0)  FROM " + TableRackList[ProcessNo]
				+ " WHERE JUDGE_STOVE_NO = '" + JudgeStvoeNo
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
				+ "','/')" + " AND CHANGE_FLAG = '1' ";
		if (ProcessNo.equals(1) || ProcessNo.equals(4)) {
			sql = "select SEQ,  IN_CHANGE_FLAG, OUT_CHANGE_FLAG FROM "
					+ TableRackList[ProcessNo] + " WHERE JUDGE_STOVE_NO = '"
					+ JudgeStvoeNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')"
					+ " AND IN_CHANGE_FLAG = '1'  union all";
			sql += " select SEQ,  IN_CHANGE_FLAG, OUT_CHANGE_FLAG FROM "
					+ TableRackList[ProcessNo] + " WHERE JUDGE_STOVE_NO = '"
					+ JudgeStvoeNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')" + " AND OUT_CHANGE_FLAG = '1' ";
		}
		return this.getData(sql);
	}

	/**
	 * 结炉回退 用于结炉后物流支数异常 1-修改炉次主计划状态 2-修改实绩表结炉状态 结束时间 合格支数 合格吨 3-删除材料表剔除材料记录
	 * 4-清空下道工序材料号赋值 5-清空结炉班次班组
	 * 
	 * @param ProcessNo
	 *            工序号 0-锯切 1-环形加热炉 2-穿孔 3-连轧 4-再加热炉 5-定径 6-管排锯 7-矫直 8-探伤 9-质检
	 * @param PLineCode
	 *            产线代码
	 * @param JudgeStoveNo
	 *            炉号
	 * @param ResultNo
	 *            实绩编号
	 * @param Seq
	 *            交班支数
	 * @param OutSeq
	 *            出炉交班支数
	 * @return CoreReturnObject
	 */
	public CoreReturnObject nodeBack(String JudgeStoveNo, String ResultNo,
			Integer ProcessNo, String PLineCode, Integer Seq, Integer OutSeq,
			Integer bProcessNo, String proPlanId, String gxPlanNo, String lotNo) {
		ArrayList<String> sqllist = new ArrayList<String>();
		String[] TableNameList = new String[] { "MIL_FEEDSAW_RESULT",
				"MIL_FUR_Result", "MIL_PERFORATION_Result",
				"MIL_ROLLING_Result", "MIL_REFUR_Result", "MIL_SIZING_Result",
				"MIL_SAW_Result", "MIL_STRAIGHTENING_RESULT", "MIL_ET_RESULT",
				"MIL_MT_RESULT", "MIL_UL_RESUL", "MIL_SURFACE_RESULT" };
		String[] NodeStaus = new String[] { "00", "10", "20", "30", "40", "50",
				"60", "70", "80", "90", "96" };
		String[] Staus = new String[] { "00", "05", "15", "25", "35", "45",
				"55", "65", "75", "85", "95" };
		String[] ScrapProcessList = new String[] { "1", "2", "3", "4", "5",
				"6", "7", "8", "9", "10", "11" };
		String[] TableRackList = new String[] { "MIL_FEED_RACK",
				"MIL_FUR_RACK", "MIL_PERFORATION_RACK", "MIL_ROLLING_RACK",
				"MIL_REFUR_RACK", "MIL_SIZING_RACK", "MIL_SAW_RACK",
				"MIL_STRAIGH_RACK", "MIL_TESTING_RACK", "MIL_QA_RACK" };
		String[] QANumList = new String[] { "CUT_NUM", "OUT_FUR_NUM",
				"PERFORATION_NUM", "QUALIFIED_NUM", "OUT_FUR_NUM",
				"PRODUCT_NUM", "CUT_NUM   ", "QUALIFIED_NUM1 ",
				"QUALIFIED_NUM1  ", "QUALIFIED_BRANCH" };
		String TableName = "";
		String ScrapProcess = "";
		String QANum = "";

		// 锯切结炉回退,清空PLN_ORDER_ZG_S 轧管订单排产顺序耗时表的 炉计划已排支数、重量
		if (ProcessNo.equals(0)) {
			String sqlzg = CoreXmlSqlParsersFactory
					.getSql("FeedResult.UpdatePlnOrderZgSBack");
			String sql7 = sqlzg.replace("#JUDGE_STOVE_NO#", JudgeStoveNo)
					.replace("#PRO_PLAN_ID#", proPlanId).replace(
							"#GX_PLAN_NO#", gxPlanNo);
			sqllist.add(sql7);
		}

		// 修改炉次主计划状态
		String sql = "update MIL_PLAN set NODE_STATUS = '"
				+ NodeStaus[ProcessNo] + "',STATUS = '" + Staus[ProcessNo]
				+ "'   where JUDGE_STOVE_NO = '" + JudgeStoveNo
				+ "'  AND ID = '" + ResultNo
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
				+ "','/')";

		QANum = QANumList[ProcessNo];
		// 修改实绩表结炉状态
		if (ProcessNo < 8) {
			TableName = TableNameList[ProcessNo];
		} else if (ProcessNo.equals(8)) {
			if (PLineCode.equals("C010")) // 涡流探伤 -168产线
			{
				TableName = "MIL_ET_RESULT";
			} else if (PLineCode.equals("C012")) // 人工超声探伤 - Assrel产线
			{
				TableName = "MIL_UL_RESUL";
			} else {
				TableName = "MIL_MT_RESULT";
			}
		} else {
			TableName = "MIL_SURFACE_RESULT";
		}
		String sql1 = "";
		if (ProcessNo.equals(9)) {
			// sql1 =
			// "update "+TableName+" set NODE_FUR_FLAG = '0' ,END_TIME = '',QUALIFIED_TONS=0  , "+QANum+"=0 WHERE JUDGE_STOVE_NO = '"+JudgeStoveNo+"'  AND RESULT_NO = '"+ResultNo+"' ";
			sql1 = "update "
					+ TableName
					+ " set NODE_FUR_FLAG = '0' ,END_TIME = '' WHERE JUDGE_STOVE_NO = '"
					+ JudgeStoveNo + "'  AND RESULT_NO = '" + ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
					+ "','/')";
		} else {
			sql1 = "update " + TableName
					+ " set NODE_FUR_FLAG = '0' ,END_TIME = ''  ,QA_TON=0  , "
					+ QANum + "=0   WHERE JUDGE_STOVE_NO = '" + JudgeStoveNo
					+ "'  AND RESULT_NO = '" + ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
					+ "','/')";
		}
		// 加热炉 再加热炉
		if (ProcessNo.equals(1) || ProcessNo.equals(4)) {
			sql1 = "update "
					+ TableName
					+ " set  IS_START = '2', NODE_FUR_FLAG = '0' ,END_TIME = '' , LAST_OUT_TIME = '' ，OUT_FUR_NUM=0, QA_TON=0  WHERE JUDGE_STOVE_NO = '"
					+ JudgeStoveNo + "'  AND RESULT_NO = '" + ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
					+ "','/')";
		}
		// 锯切
		if (ProcessNo.equals(0)) {
			sql1 = "update "
					+ TableName
					+ " set  NODE_FUR_FLAG = '0' ,END_TIME = '' , BEFORE_QUALIFIED_NUM  =0, CUT_NUM=0,QA_TON=0  WHERE JUDGE_STOVE_NO = '"
					+ JudgeStoveNo + "'  AND RESULT_NO = '" + ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
					+ "','/')";
		}
		// 管排锯
		if (ProcessNo.equals(6)) {
			sql1 = "update "
					+ TableName
					+ " set NODE_FUR_FLAG = '0' ,END_TIME = '' , CUT_DBNUM  =0, CUT_NUM=0,QA_TON=0  WHERE JUDGE_STOVE_NO = '"
					+ JudgeStoveNo + "'  AND RESULT_NO = '" + ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
					+ "','/')";
		}
		// 矫直
		if (ProcessNo.equals(7)) {
			sql1 = "update "
					+ TableName
					+ " set NODE_FUR_FLAG = '0' ,END_TIME = '' , QUALIFIED_NUM1 =0, QUALIFIED_NUM2=0,QUALIFIED_NUM3=0,QUALIFIED_NUM =0,IN_MAT_NUM=0,QA_TON=0  WHERE JUDGE_STOVE_NO = '"
					+ JudgeStoveNo + "'  AND RESULT_NO = '" + ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
					+ "','/')";
		}
		// 探伤
		if (ProcessNo.equals(8)) {

			sql1 = "update "
					+ TableName
					+ " set NODE_FUR_FLAG = '0' ,END_TIME = '' , QA_TON=0,QUALIFIED_NUM1  =0, QUALIFIED_NUM2 =0,";
			sql1 += " QUALIFIED_NUM = 0,DETECTION_NUM1 = 0,DETECTION_NUM2 = 0 ,DETECTION_NUM =0 ";
			if (PLineCode.equals("C010")) {
				sql1 += ",DETECTION_NUM3 =0,QUALIFIED_NUM3 =0 ";
			}
			sql1 += " WHERE JUDGE_STOVE_NO = '" + JudgeStoveNo
					+ "'  AND RESULT_NO = '" + ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
					+ "','/')";

		}

		// 删除材料表剔除材料记录
		if (ProcessNo < 6 && ProcessNo > 0) {
			ScrapProcess = ScrapProcessList[ProcessNo];
		}
		if (ProcessNo > 6) {
			ScrapProcess = ScrapProcessList[ProcessNo + 1];
		}
		// String sql2 =
		// "DELETE MIL_SLAB_SCRAP WHERE WHERE JUDGE_STOVE_NO = '"+JudgeStoveNo+"'  AND RESULT_NO = '"+ResultNo+"' AND PROCESS_NO = '"+ScrapProcess+"'";
		String sql2 = "DELETE MIL_SLAB_SCRAP  WHERE JUDGE_STOVE_NO = '"
				+ JudgeStoveNo + "'  AND PROCESS_NO = '" + ScrapProcess
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
				+ "','/')";
		if (ProcessNo.equals(6)) {
			// sql2 =
			// "DELETE MIL_SLAB_SCRAP WHERE WHERE JUDGE_STOVE_NO = '"+JudgeStoveNo+"'  AND RESULT_NO = '"+ResultNo+"' AND PROCESS_NO in('7','8' )";
			sql2 = "DELETE MIL_SLAB_SCRAP  WHERE JUDGE_STOVE_NO = '"
					+ JudgeStoveNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')" + "   AND PROCESS_NO in('7','8' )";
		}
		if (ProcessNo.equals(0)) {
			// sql2 =
			// "DELETE MIL_SLAB_SCRAP WHERE WHERE JUDGE_STOVE_NO = '"+JudgeStoveNo+"'  AND RESULT_NO = '"+ResultNo+"' AND PROCESS_NO in('7','8' )";
			sql2 = "DELETE MIL_SLAB_SCRAP  WHERE JUDGE_STOVE_NO = '"
					+ JudgeStoveNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')" + "   AND PROCESS_NO in('0','1' )";
		}
		String sql3 = "";
		// 清空材料号
		if (ProcessNo <= 8) {

			// sql3 =
			// "update "+TableRackList[ProcessNo]+" set MAT_NO = ''  where JUDGE_STOVE_NO = '"+JudgeStoveNo+"'  AND RESULT_NO = '"+ResultNo+"'  ";
			sql3 = "update " + TableRackList[ProcessNo + 1]
					+ " set MAT_NO = ''  where JUDGE_STOVE_NO = '"
					+ JudgeStoveNo + "' AND RESULT_NO = '" + ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
					+ "','/')";
		}
		String sqlLen = "";
		if (ProcessNo > 5 && ProcessNo <= 8) {
			sqlLen = "update " + TableRackList[ProcessNo + 1]
					+ " set PIPE_LENGTH = ''  where JUDGE_STOVE_NO = '"
					+ JudgeStoveNo + "' AND RESULT_NO = '" + ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
					+ "','/')";
		} else {
			sqlLen = "select 1 from dual";
		}
		if (ProcessNo.equals(4)) {
			if (PLineCode.equals("C012") || PLineCode.equals("C009")
					|| PLineCode.equals("C017")) {
				sql3 = "select 1 from dual";
			}
		}
		String[] EndTimeList = new String[] { "END_TIME", "OUT_FUR_TIME",
				"END_PERFORATION_TIME", "END_ROLLING_TIME", "OUT_REFUR_TIME",
				"END_SIZING_TIME", "END_SAW_TIME", "END_STRAIGHTENING_TIME",
				"END_INSPECTION_TIME", "END_TIME" };

		String EndTine = EndTimeList[ProcessNo];
		String InFurTime = "IN_FUR_TIME";
		// 清空结炉班次班组 结炉时间
		String sql4 = " update " + TableRackList[ProcessNo]
				+ "  set COL_SHIFT = '' , COL_GROUP = '' ,"
				+ EndTimeList[ProcessNo]
				+ " = '' ,COL_USER = '' WHERE   JUDGE_STOVE_NO = '"
				+ JudgeStoveNo + "'  and RESULT_NO = '" + ResultNo
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
				+ "','/')" + "  and seq > " + Seq;
		if (ProcessNo.equals(1) || ProcessNo.equals(4)) {
			if (ProcessNo.equals(4)) {
				InFurTime = "IN_REFUR_TIME";
			}

			sql4 = "update "
					+ TableRackList[ProcessNo]
					+ "  set IN_SHIFT = '' , IN_GROUP = '' ,IN_USER='' WHERE   JUDGE_STOVE_NO = '"
					+ JudgeStoveNo + "'  and RESULT_NO = '" + ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
					+ "','/')" + "  and seq > " + Seq;
			String sql5 = "update " + TableRackList[ProcessNo]
					+ "  set COL_SHIFT = '' , COL_GROUP = '' , COL_USER = '', "
					+ EndTimeList[ProcessNo]
					+ " = '' WHERE   JUDGE_STOVE_NO = '" + JudgeStoveNo
					+ "'  and RESULT_NO = '" + ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
					+ "','/')" + "  and  seq > " + OutSeq;
			sqllist.add(sql5);
		}
		String sql15 = "UPDATE PORT_MIL_BATCH_SAMPLE_RESULT T SET T.STATUS = '0',T.OP_PROCESS = '' WHERE T.JUDGE_STOVE_NO = '"
				+ JudgeStoveNo
				+ "' AND T.PLAN_ID = '"
				+ ResultNo
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
				+ proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
				+ gxPlanNo
				+ "','/')"
				+ " AND T.OP_PROCESS = '"
				+ String.valueOf(bProcessNo) + "'";
		sqllist.add(sql);
		sqllist.add(sql1);
		sqllist.add(sql2);
		sqllist.add(sql15);
		if (ProcessNo <= 8) {
			sqllist.add(sql3);
		}
		sqllist.add(sql4);
		if (ProcessNo >= 5 && ProcessNo <= 8) {
			sqllist.add(sqlLen);
		}
		// 质检结炉回退清除质检的离线实绩数据
		/*
		 * if (ProcessNo.equals(9)) { String sql6 =
		 * " delete from MIL_OFFLINE_RESLUT t where t.judge_stove_no = '"
		 * +JudgeStoveNo+"' and t.offline_pro = 'ZJ'"; sqllist.add(sql6); }
		 */

		// 更新进程表mil_processes数据
		String updateProcess = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.insertMilProcess2");
		updateProcess = updateProcess.replace("#JUDGE_STOVE_NO#", JudgeStoveNo)
				.replace("#LOT_NO#", lotNo).replace("#PLINE_CODE#", PLineCode)
				.replace("#PRO_PLAN_ID#", proPlanId).replace("#GX_PLAN_NO#",
						gxPlanNo);
		sqllist.add(updateProcess);

		// 回写虚拟炉计划表中生产状态(生产中)
		String updatePlnZyZgMBack = " UPDATE PLN_ZY_ZG_M T SET T.PLANSTATUS = '20' WHERE T.HEAT_PLAN_NO = '"
				+ ResultNo
				+ "' AND T.FEED_HEAT_NO = REGEXP_REPLACE('"
				+ JudgeStoveNo
				+ "', '-.*', '')";
		sqllist.add(updatePlnZyZgMBack);

		return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(
				sqllist);
	}

	/**
	 * 查询上个班 交班标识为1的最大Seq
	 * 
	 * @param ProcessNo
	 *            工序号 0-锯切 1-环形加热炉 2-穿孔 3-连轧 4-再加热炉 5-定径 6-管排锯 7-矫直 8-探伤 9-质检
	 * @param PLineCode
	 *            产线代码
	 * @param JudgeStoveNo
	 *            炉号
	 * @param ResultNo
	 *            实绩编号
	 * @return
	 */
	public CoreReturnObject getChangeSeq(String JudgeStvoeNo, String ResultNo,
			Integer ProcessNo, String PlineCode, String Shift, String Group,
			String proPlanId, String gxPlanNo) {
		String[] TableRackList = new String[] { "MIL_FEED_RACK",
				"MIL_FUR_RACK", "MIL_PERFORATION_RACK", "MIL_ROLLING_RACK",
				"MIL_REFUR_RACK", "MIL_SIZING_RACK", "MIL_SAW_RACK",
				"MIL_STRAIGH_RACK", "MIL_TESTING_RACK", "MIL_QA_RACK" };

		String sql = "select max(Seq) FROM  " + TableRackList[ProcessNo]
				+ " WHERE JUDGE_STOVE_NO = '" + JudgeStvoeNo
				+ "' AND Result_no = '" + ResultNo + "' ";
		sql += " and ( COL_SHIFT != '" + Shift + "' or COL_GROUP != '" + Group
				+ "' ) and CHANGE_FLAG = 1";
		if (ProcessNo.equals(1) || ProcessNo.equals(4)) {
			sql = "select max(Seq) FROM  " + TableRackList[ProcessNo]
					+ " WHERE JUDGE_STOVE_NO = '" + JudgeStvoeNo
					+ "' AND Result_no = '" + ResultNo + "' ";
			sql += " and (IN_SHIFT != '" + Shift + "' or IN_GROUP != '" + Group
					+ "' ) and IN_CHANGE_FLAG = 1  ";
			sql += "union all ";
			sql += "select max(Seq) FROM  " + TableRackList[ProcessNo]
					+ " WHERE JUDGE_STOVE_NO = '" + JudgeStvoeNo
					+ "' AND Result_no = '" + ResultNo + "' ";
			sql += " and (COL_SHIFT != '" + Shift + "' or COL_GROUP != '"
					+ Group + "'  )and OUT_CHANGE_FLAG = 1  ";
		}
		return this.getData(sql);
	}

	/**
	 * 查询上个班 交班标识为1的最大Seq
	 * 
	 * @param ProcessNo
	 *            工序号 0-锯切 1-环形加热炉 2-穿孔 3-连轧 4-再加热炉 5-定径 6-管排锯 7-矫直 8-探伤 9-质检
	 * @param PLineCode
	 *            产线代码
	 * @param JudgeStoveNo
	 *            炉号
	 * @param ResultNo
	 *            实绩编号
	 * @return
	 */
	public CoreReturnObject getChangeSeq(String JudgeStvoeNo, String ResultNo,
			String FeedRowNo, Integer ProcessNo, String PlineCode,
			String Shift, String Group, String proPlanId, String gxPlanNo) {
		String[] TableRackList = new String[] { "MIL_FEED_RACK",
				"MIL_FUR_RACK", "MIL_PERFORATION_RACK", "MIL_ROLLING_RACK",
				"MIL_REFUR_RACK", "MIL_SIZING_RACK", "MIL_SAW_RACK",
				"MIL_STRAIGH_RACK", "MIL_TESTING_RACK", "MIL_QA_RACK" };

		String sql = "select max(Seq) AS SEQ  ,max(FEED_ROW_NO) AS FEED_ROW_NO FROM  "
				+ TableRackList[ProcessNo]
				+ " WHERE JUDGE_STOVE_NO = '"
				+ JudgeStvoeNo
				+ "' AND Result_no = '"
				+ ResultNo
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
				+ proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
				+ gxPlanNo
				+ "','/')";
		sql += " and ( COL_SHIFT != '" + Shift + "' or COL_GROUP != '" + Group
				+ "' ) and CHANGE_FLAG = 1  group by feed_row_no";

		return this.getData(sql);
	}

	/**
	 * 交班 1- 修改实绩表交接班支数 2-修改跟踪表班次班组 3-修改跟踪表交班标识
	 * 
	 * @param ProcessNo
	 *            1-锯切 2-加热炉 3-穿孔 4-连轧 5-再加热炉 6-定径
	 * @param FurFlag
	 *            出入炉标识 0-默认 1-入炉交班 2-出炉交班
	 * @param Seq
	 *            点击交班的序号
	 * @param BeforSeq
	 *            上个班交班点（2 5 时为入炉交班点）
	 * @param BeforSeqOutFur
	 *            （2 5 时为出炉交班点）
	 * @return CoreReturnObject
	 */
	public CoreReturnObject changeNum(String JudgeStoveNo, String ResultNo,
			Integer Seq, Integer BeforSeq, Integer BeforSeqOutFur,
			String PLineCode, String Shift, String Class, String User,
			Integer ProcessNo, Integer FurFlag, String proPlanId,
			String gxPlanNo) {
		ArrayList<String> sqllist = new ArrayList<String>();
		// ArrayList<String> sqllist1 = new ArrayList<String>();
		String sql = ""; // 交班前清空班次 班组
		String sql1 = ""; // 修改实绩表交接班支数
		String sql2 = ""; // 修改跟踪表班次班组
		String sql3 = ""; // 修改跟踪表交班标识
		String sql4 = ""; // 修改管号队列开始时间

		// 锯切
		if (ProcessNo.equals(1)) {
			sqllist.clear();
			// 交班前 清空班次班组
			sql = "update MIL_FEED_RACK  set COL_SHIFT = ''  , COL_GROUP = ''  , COL_USER = '' , END_TIME = '',  CHANGE_FLAG = 0 where  ";
			sql += "JUDGE_STOVE_NO = '" + JudgeStoveNo + "' and RESULT_NO = '"
					+ ResultNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')" + "  and seq > " + (BeforSeq) + " ";

			// 修改锯切交接班支数
			sql1 = "update  MIL_FEEDSAW_RESULT  set  CHANGE_NUM = " + Seq
					+ " where ";
			sql1 += "JUDGE_STOVE_NO = '" + JudgeStoveNo + "' and RESULT_NO = '"
					+ ResultNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')";

			// 修改锯切跟踪表班次班组
			sql2 = "update MIL_FEED_RACK  set COL_SHIFT = '" + Shift
					+ "'  , COL_GROUP = '" + Class + "'  , COL_USER = '" + User
					+ "', END_TIME = sysdate where ";
			sql2 += "JUDGE_STOVE_NO = '" + JudgeStoveNo + "' and RESULT_NO = '"
					+ ResultNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')" + "  and seq between  "
					+ (BeforSeq + 1) + " and " + Seq + " ";

			// 修改跟踪表交班标识
			sql3 = "update MIL_FEED_RACK set  CHANGE_FLAG = '1' where JUDGE_STOVE_NO = '"
					+ JudgeStoveNo
					+ "' and RESULT_NO = '"
					+ ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo
					+ "','/')" + "  and seq =" + Seq;

			sqllist.add(sql);
			sqllist.add(sql1);
			sqllist.add(sql2);
			sqllist.add(sql3);
			/*
			 * //交班前 清空班次班组 sql =
			 * "update MIL_FEED_RACK  set COL_SHIFT = ''  , COL_GROUP = ''  , COL_USER = '' , END_TIME = '',  CHANGE_FLAG = 0 where  "
			 * ; sql += "JUDGE_STOVE_NO = '"+JudgeStoveNo+"' and RESULT_NO = '"+
			 * ResultNo+"'  and seq > "+(BeforSeq)+" ";
			 * 
			 * //修改锯切交接班支数 sql1 =
			 * "update  MIL_FEEDSAW_RESULT  set  CHANGE_NUM = "+Seq+" where ";
			 * sql1+= "JUDGE_STOVE_NO = '"+JudgeStoveNo+"' and RESULT_NO = '"+
			 * ResultNo+"'";
			 * 
			 * //修改锯切跟踪表班次班组 sql2 =
			 * "update MIL_FEED_RACK  set COL_SHIFT = '"+Shift
			 * +"'  , COL_GROUP = '"+ Class+"'  , COL_USER = '"+
			 * User+"', END_TIME = sysdate where "; sql2 +=
			 * "JUDGE_STOVE_NO = '"+JudgeStoveNo+"' and RESULT_NO = '"+
			 * ResultNo+"'  and seq between  "+(BeforSeq+1)+" and "+Seq+" ";
			 * 
			 * //修改跟踪表交班标识 sql3 =
			 * "update MIL_FEED_RACK set  CHANGE_FLAG = '1' where JUDGE_STOVE_NO = '"
			 * +JudgeStoveNo+"' and RESULT_NO = '"+ ResultNo+"'  and seq ="+Seq;
			 * sqllist.add(sql); sqllist.add(sql1); sqllist.add(sql2);
			 * sqllist.add(sql3);
			 */
		}

		// 加热炉交班
		if (ProcessNo.equals(2)) {
			sqllist.clear();
			// 入炉交班 1-锯切交班 2-
			if (FurFlag.equals(1)) {
				// 清空班次班组
				sql = "update MIL_FUR_RACK set IN_SHIFT = ''  , IN_USER='', IN_GROUP = ''  ,IN_CHANGE_FLAG = 0  where ";
				sql += "JUDGE_STOVE_NO = '" + JudgeStoveNo
						+ "' and RESULT_NO = '" + ResultNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
						+ "','/')" + " and seq > " + (BeforSeq) + " ";

				// 修改加热炉交接班支数
				sql1 = "update  MIL_FUR_RESULT  set  CHANGE_NUM = " + Seq
						+ " where ";
				sql1 += "JUDGE_STOVE_NO = '" + JudgeStoveNo
						+ "' and RESULT_NO = '" + ResultNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
						+ "','/')";

				// 修改加热炉跟踪表班次班组
				sql2 = "update MIL_FUR_RACK set IN_SHIFT = '" + Shift
						+ "'  , IN_GROUP = '" + Class + "'  ,IN_USER = '"
						+ User + "'  where ";
				sql2 += "JUDGE_STOVE_NO = '" + JudgeStoveNo
						+ "' and RESULT_NO = '" + ResultNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
						+ "','/')" + "  and seq between  " + (BeforSeq + 1)
						+ " and " + Seq + "";

				// 修改跟踪表交班标识
				sql3 = "update MIL_FUR_RACK set  IN_CHANGE_FLAG = '1' where JUDGE_STOVE_NO = '"
						+ JudgeStoveNo
						+ "' and RESULT_NO = '"
						+ ResultNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
						+ proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
						+ gxPlanNo
						+ "','/')" + "  and seq =" + Seq;

				// 修改入炉时间
				sql4 = "update MIL_FUR_RACK set IN_FUR_TIME = sysdate where  JUDGE_STOVE_NO = '"
						+ JudgeStoveNo
						+ "' and RESULT_NO = '"
						+ ResultNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
						+ proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
						+ gxPlanNo
						+ "','/')" + " and seq > " + Seq + "";
				sqllist.add(sql);
				sqllist.add(sql1);
				sqllist.add(sql2);
				sqllist.add(sql3);
				sqllist.add(sql4);

			}
			// 出炉交班
			else if (FurFlag.equals(2)) {
				sqllist.clear();
				// 清空班次班组
				sql = "update MIL_FUR_RACK set COL_SHIFT = ''  , COL_GROUP = ''  ,COL_USER='' ,OUT_FUR_TIME = '',OUT_CHANGE_FLAG = 0 where ";
				sql += "JUDGE_STOVE_NO = '" + JudgeStoveNo
						+ "' and RESULT_NO = '" + ResultNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
						+ "','/')" + " and seq > " + (BeforSeqOutFur) + " ";

				// 修改加热炉交接班支数
				sql1 = "update  MIL_FUR_RESULT  set  OUT_CHANGE_NUM = " + Seq
						+ " where ";
				sql1 += "JUDGE_STOVE_NO = '" + JudgeStoveNo
						+ "' and RESULT_NO = '" + ResultNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
						+ "','/')";

				// 修改加热炉跟踪表班次班组
				sql2 = "update MIL_FUR_RACK set COL_SHIFT = '" + Shift
						+ "'  , COL_GROUP = '" + Class + "'  , COL_USER = '"
						+ User + "',OUT_FUR_TIME = sysdate where ";
				sql2 += "JUDGE_STOVE_NO = '" + JudgeStoveNo
						+ "' and RESULT_NO = '" + ResultNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
						+ "','/')" + "  and seq between  "
						+ (BeforSeqOutFur + 1) + " and " + Seq + "";

				sql3 = "update MIL_FUR_RACK set  OUT_CHANGE_FLAG = '1' where JUDGE_STOVE_NO = '"
						+ JudgeStoveNo
						+ "' and RESULT_NO = '"
						+ ResultNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
						+ proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
						+ gxPlanNo
						+ "','/')" + "  and seq =" + Seq;
				sqllist.add(sql);
				sqllist.add(sql1);
				sqllist.add(sql2);
				sqllist.add(sql3);

			}
		}

		// 穿孔
		if (ProcessNo.equals(3)) {
			sqllist.clear();
			sql = "update mil_perforation_rack  set COL_SHIFT = ''  , COL_GROUP = ''  , COL_USER='',END_PERFORATION_TIME = '' ,CHANGE_FLAG = 0 where ";
			sql += "JUDGE_STOVE_NO = '" + JudgeStoveNo + "' and RESULT_NO = '"
					+ ResultNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')" + "  and seq > " + (BeforSeq) + "  ";

			// 修改穿孔交接班支数
			sql1 = "update  MIL_PERFORATION_RESULT  set  JZB_NUM = " + Seq
					+ " where ";
			sql1 += "JUDGE_STOVE_NO = '" + JudgeStoveNo + "' and RESULT_NO = '"
					+ ResultNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')";

			// 修改穿孔跟踪表班次班组
			sql2 = "update mil_perforation_rack  set COL_SHIFT = '" + Shift
					+ "'  , COL_GROUP = '" + Class + "'  , COL_USER ='" + User
					+ "', END_PERFORATION_TIME = sysdate where ";
			sql2 += "JUDGE_STOVE_NO = '" + JudgeStoveNo + "' and RESULT_NO = '"
					+ ResultNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')" + "  and  seq between  "
					+ (BeforSeq + 1) + " and " + Seq + "";

			sql3 = "update mil_perforation_rack set  CHANGE_FLAG = '1' where JUDGE_STOVE_NO = '"
					+ JudgeStoveNo
					+ "' and RESULT_NO = '"
					+ ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo
					+ "','/')" + "  and seq =" + Seq;

			// 修改跟踪表开始时间
			sql4 = " update mil_perforation_rack set START_PERFORATION_TIME = sysdate where JUDGE_STOVE_NO = '"
					+ JudgeStoveNo
					+ "' and RESULT_NO = '"
					+ ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo
					+ "','/')" + "  and seq >" + Seq;
			sqllist.add(sql);
			sqllist.add(sql1);
			sqllist.add(sql2);
			sqllist.add(sql3);
			sqllist.add(sql4);
		}

		// 连轧
		if (ProcessNo.equals(4)) {
			sqllist.clear();
			sql = "update MIL_ROLLING_RACK  set COL_SHIFT = ''  , COL_GROUP = ''  ,COL_USER='', END_ROLLING_TIME = '',CHANGE_FLAG = 0  where ";
			sql += "JUDGE_STOVE_NO = '" + JudgeStoveNo + "' and RESULT_NO = '"
					+ ResultNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')" + " and seq > " + (BeforSeq) + "  ";
			// 修改连轧交接班支数
			sql1 = "update  MIL_ROLLING_RESULT  set  CHANGECLASSNUM = " + Seq
					+ " where ";
			sql1 += "JUDGE_STOVE_NO = '" + JudgeStoveNo + "' and RESULT_NO = '"
					+ ResultNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')";

			// 修改连轧跟踪表班次班组
			sql2 = "update MIL_ROLLING_RACK  set COL_SHIFT = '" + Shift
					+ "'  , COL_GROUP = '" + Class + "'  , COL_USER='" + User
					+ "',END_ROLLING_TIME = sysdate where ";
			sql2 += "JUDGE_STOVE_NO = '" + JudgeStoveNo + "' and RESULT_NO = '"
					+ ResultNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')" + "  and  seq between  "
					+ (BeforSeq + 1) + " and " + Seq + "";

			sql3 = "update MIL_ROLLING_RACK set  CHANGE_FLAG = '1' where JUDGE_STOVE_NO = '"
					+ JudgeStoveNo
					+ "' and RESULT_NO = '"
					+ ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo
					+ "','/')" + "  and seq =" + Seq;

			// 修改跟踪表开始时间
			sql4 = " update MIL_ROLLING_RACK set START_ROLLING_TIME = sysdate where JUDGE_STOVE_NO = '"
					+ JudgeStoveNo
					+ "' and RESULT_NO = '"
					+ ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo
					+ "','/')" + "  and seq >" + Seq;
			sqllist.add(sql);
			sqllist.add(sql1);
			sqllist.add(sql2);
			sqllist.add(sql3);
			sqllist.add(sql4);
		}
		// 再加热炉交班
		if (ProcessNo.equals(5)) {
			sqllist.clear();
			// 入炉交班 1-穿孔 2-连轧
			if (FurFlag.equals(1)) {

				sql = "update MIL_REFUR_RACK set IN_SHIFT = ''  , IN_GROUP = '' ,IN_USER='', IN_CHANGE_FLAG = 0  where ";
				sql += "JUDGE_STOVE_NO = '" + JudgeStoveNo
						+ "' and RESULT_NO = '" + ResultNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
						+ "','/')" + "  and seq > " + (BeforSeq) + "";
				// 修改再加热炉交接班支数
				sql1 = "update  MIL_REFUR_RESULT  set  CHANGECLASSNUM = " + Seq
						+ " where ";
				sql1 += "JUDGE_STOVE_NO = '" + JudgeStoveNo
						+ "' and RESULT_NO = '" + ResultNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
						+ "','/')";

				// 修改再加热炉跟踪表班次班组
				sql2 = "update MIL_REFUR_RACK set IN_SHIFT = '" + Shift
						+ "'  ,IN_USER='" + User + "', IN_GROUP = '" + Class
						+ "'   where ";
				sql2 += "JUDGE_STOVE_NO = '" + JudgeStoveNo
						+ "' and RESULT_NO = '" + ResultNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
						+ "','/')" + "  and seq between  " + (BeforSeq + 1)
						+ " and " + Seq + "";

				sql3 = "update MIL_REFUR_RACK set  IN_CHANGE_FLAG = '1' where JUDGE_STOVE_NO = '"
						+ JudgeStoveNo
						+ "' and RESULT_NO = '"
						+ ResultNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
						+ proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
						+ gxPlanNo
						+ "','/')" + "  and seq =" + Seq;

				// 修改入炉时间
				sql4 = "update MIL_REFUR_RACK set IN_REFUR_TIME = sysdate where JUDGE_STOVE_NO = '"
						+ JudgeStoveNo
						+ "' and RESULT_NO = '"
						+ ResultNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
						+ proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
						+ gxPlanNo
						+ "','/')" + " and seq > " + BeforSeq + "";
				sqllist.add(sql);
				sqllist.add(sql1);
				sqllist.add(sql2);
				sqllist.add(sql3);
				sqllist.add(sql4);

			}
			// 出炉交班
			else if (FurFlag.equals(2)) {

				sql = "update MIL_REFUR_RACK set COL_SHIFT = ''  , COL_GROUP = ''  , OUT_REFUR_TIME = '', COL_USER = '',OUT_CHANGE_FLAG = 0 where ";
				sql += "JUDGE_STOVE_NO = '" + JudgeStoveNo
						+ "' and RESULT_NO = '" + ResultNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
						+ "','/')" + "  and seq > " + (BeforSeq) + " ";
				// 修改加热炉交接班支数
				sql1 = "update  MIL_REFUR_RESULT  set  OUT_CHANGE_NUM = " + Seq
						+ " where ";
				sql1 += "JUDGE_STOVE_NO = '" + JudgeStoveNo
						+ "' and RESULT_NO = '" + ResultNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
						+ "','/')";

				// 修改加热炉跟踪表班次班组
				sql2 = "update MIL_REFUR_RACK set COL_SHIFT = '" + Shift
						+ "'  , COL_GROUP = '" + Class + "'  , COL_USER = '"
						+ User + "',OUT_REFUR_TIME = sysdate where ";
				sql2 += "JUDGE_STOVE_NO = '" + JudgeStoveNo
						+ "' and RESULT_NO = '" + ResultNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
						+ "','/')" + "  and seq between  "
						+ (BeforSeqOutFur + 1) + " and " + Seq + "";

				sql3 = "update MIL_REFUR_RACK set  OUT_CHANGE_FLAG = '2' where JUDGE_STOVE_NO = '"
						+ JudgeStoveNo
						+ "' and RESULT_NO = '"
						+ ResultNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
						+ proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
						+ gxPlanNo
						+ "','/')" + "  and seq =" + Seq;
				sqllist.add(sql);
				sqllist.add(sql1);
				sqllist.add(sql2);
				sqllist.add(sql3);
			}
		}
		// 定径交班
		if (ProcessNo.equals(6)) {
			// 无再加热炉 修改穿孔、连轧、定径交班支数
			/*
			 * if(PLineCode.equals("C009") ||PLineCode.equals("C012")
			 * ||PLineCode.equals("C017") ) { String[] TableResultList = new
			 * String
			 * []{"MIL_PERFORATION_RESULT","MIL_ROLLING_RESULT","MIL_SIZING_RESULT"
			 * }; String[] TableRackList = new
			 * String[]{"mil_perforation_rack","MIL_ROLLING_RACK"
			 * ,"mil_sizing_rack"}; String[] ChangeNumList = new
			 * String[]{"JZB_NUM","CHANGECLASSNUM","CHANGE_NUM"}; String[]
			 * EndTimeList = new
			 * String[]{"END_PERFORATION_TIME","END_ROLLING_TIME"
			 * ,"END_SIZING_TIME"};
			 * 
			 * for (int i=0;i<3;i++) { //修改交接班支数 sql1 =
			 * "update "+TableResultList
			 * [i]+" set  "+ChangeNumList[i]+" = "+Seq+" where "; sql1+=
			 * "JUDGE_STOVE_NO = '"+JudgeStoveNo+"' and RESULT_NO = '"+
			 * ResultNo+"'";
			 * 
			 * //修改跟踪表班次班组 sql2 =
			 * "update "+TableRackList[i]+" set COL_SHIFT = '"
			 * +Shift+"'  , COL_GROUP = '"+
			 * Class+"'  ,  "+EndTimeList[i]+" = sysdate where "; sql2 +=
			 * "JUDGE_STOVE_NO = '"+JudgeStoveNo+"' and RESULT_NO = '"+
			 * ResultNo+"'  and seq <"+(Seq+1)+"";
			 * 
			 * sql3 ="update "+TableRackList[i]+
			 * " set CHANGE_FLAG = '1' JUDGE_STOVE_NO = '"
			 * +JudgeStoveNo+"' and RESULT_NO = '"+ ResultNo+"'  and seq ="+Seq;
			 * sqllist.add(sql1); sqllist.add(sql2); sqllist.add(sql3); }
			 */
			sqllist.clear();
			sql = "update mil_sizing_rack set COL_SHIFT = ''  , COL_GROUP = ''  , END_SIZING_TIME = '' ,COL_USER='',CHANGE_FLAG = 0 where ";
			sql += "JUDGE_STOVE_NO = '" + JudgeStoveNo + "' and RESULT_NO = '"
					+ ResultNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')" + " and seq > " + (BeforSeq) + " ";

			sql1 = "update MIL_SIZING_RESULT set  CHANGE_NUM = " + Seq
					+ " where ";
			sql1 += "JUDGE_STOVE_NO = '" + JudgeStoveNo + "' and RESULT_NO = '"
					+ ResultNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')";

			sql2 = "update mil_sizing_rack set COL_SHIFT = '" + Shift
					+ "'  , COL_GROUP = '" + Class + "'  , COL_USER='" + User
					+ "',END_SIZING_TIME = sysdate where ";
			sql2 += "JUDGE_STOVE_NO = '" + JudgeStoveNo + "' and RESULT_NO = '"
					+ ResultNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')" + "  and  seq between  "
					+ (BeforSeq + 1) + " and " + Seq + "";

			sql3 = "update mil_sizing_rack set CHANGE_FLAG = '1'  WHERE  JUDGE_STOVE_NO = '"
					+ JudgeStoveNo
					+ "' and RESULT_NO = '"
					+ ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo
					+ "','/')" + "  and seq =" + Seq;
			// 修改跟踪表开始时间
			sql4 = " update mil_sizing_rack set START_SIZING_TIME = sysdate where JUDGE_STOVE_NO = '"
					+ JudgeStoveNo
					+ "' and RESULT_NO = '"
					+ ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo
					+ "','/')" + "  and seq >" + Seq;
			sqllist.add(sql);
			sqllist.add(sql1);
			sqllist.add(sql2);
			sqllist.add(sql3);
			sqllist.add(sql4);

		}
		if (ProcessNo.equals(8)) {
			sql = "update mil_testing_rack set COL_SHIFT = ''  , COL_GROUP = ''  , END_INSPECTION_TIME = '' ,COL_USER='',CHANGE_FLAG = 0 where ";
			sql += "JUDGE_STOVE_NO = '" + JudgeStoveNo + "' and RESULT_NO = '"
					+ ResultNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')" + " and seq > " + (BeforSeq) + " ";

			if (PLineCode.equals("C009") || PLineCode.equals("C008")
					|| PLineCode.equals("C017")) {
				sql1 = "update mil_mt_result set  CHANGE_NUM = " + Seq
						+ " where ";
				sql1 += "JUDGE_STOVE_NO = '" + JudgeStoveNo
						+ "' and RESULT_NO = '" + ResultNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
						+ "','/')";
			} else if (PLineCode.equals("C010")) {
				sql1 = "update mil_et_result set  CHANGE_NUM = " + Seq
						+ " where ";
				sql1 += "JUDGE_STOVE_NO = '" + JudgeStoveNo
						+ "' and RESULT_NO = '" + ResultNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
						+ "','/')";
			}

			sql2 = "update mil_testing_rack set COL_SHIFT = '" + Shift
					+ "'  , COL_GROUP = '" + Class + "'  , COL_USER='" + User
					+ "',END_INSPECTION_TIME = sysdate where ";
			sql2 += "JUDGE_STOVE_NO = '" + JudgeStoveNo + "' and RESULT_NO = '"
					+ ResultNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')" + "  and  seq between  "
					+ (BeforSeq + 1) + " and " + Seq + "";

			sql3 = "update mil_testing_rack set CHANGE_FLAG = '1'  WHERE  JUDGE_STOVE_NO = '"
					+ JudgeStoveNo
					+ "' and RESULT_NO = '"
					+ ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo
					+ "','/')" + "  and seq =" + Seq;
			// 修改跟踪表开始时间
			sql4 = " update mil_testing_rack set START_INSPECTION_TIME = sysdate where JUDGE_STOVE_NO = '"
					+ JudgeStoveNo
					+ "' and RESULT_NO = '"
					+ ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo
					+ "','/')" + "  and seq >" + Seq;
			sqllist.add(sql);
			sqllist.add(sql1);
			sqllist.add(sql2);
			sqllist.add(sql3);
			sqllist.add(sql4);
		}
		if (ProcessNo.equals(9)) {

			sql = "update MIL_QA_RACK set COL_SHIFT = ''  , COL_GROUP = ''  , END_TIME = '' ,COL_USER='',CHANGE_FLAG = 0 where ";
			sql += "JUDGE_STOVE_NO = '" + JudgeStoveNo + "' and RESULT_NO = '"
					+ ResultNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')" + " and seq > " + (BeforSeq) + " ";

			sql1 = "update MIL_SURFACE_RESULT set  CHANGE_NUM = " + Seq
					+ " where ";
			sql1 += "JUDGE_STOVE_NO = '" + JudgeStoveNo + "' and RESULT_NO = '"
					+ ResultNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')";

			sql2 = "update MIL_QA_RACK set COL_SHIFT = '" + Shift
					+ "'  , COL_GROUP = '" + Class + "'  , COL_USER='" + User
					+ "',END_TIME = sysdate where ";
			sql2 += "JUDGE_STOVE_NO = '" + JudgeStoveNo + "' and RESULT_NO = '"
					+ ResultNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')" + "  and  seq between  "
					+ (BeforSeq + 1) + " and " + Seq + "";

			sql3 = "update MIL_QA_RACK set CHANGE_FLAG = '1'  WHERE  JUDGE_STOVE_NO = '"
					+ JudgeStoveNo
					+ "' and RESULT_NO = '"
					+ ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo
					+ "','/')" + "  and seq =" + Seq;
			// 修改跟踪表开始时间
			sql4 = " update MIL_QA_RACK set START_TIME = sysdate where JUDGE_STOVE_NO = '"
					+ JudgeStoveNo
					+ "' and RESULT_NO = '"
					+ ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo
					+ "','/')" + "  and seq >" + Seq;
			sqllist.add(sql);
			sqllist.add(sql1);
			sqllist.add(sql2);
			sqllist.add(sql3);
			sqllist.add(sql4);
		}

		return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(
				sqllist);
	}

	/**
	 * 锯切上料行交班 1- 修改实绩表交接班支数 2-修改跟踪表班次班组 3-修改跟踪表交班标识
	 * 
	 * @param ProcessNo
	 *            1-锯切
	 * @param FurFlag
	 *            出入炉标识 0-默认 1-入炉交班 2-出炉交班
	 * @param Seq
	 *            点击交班的序号
	 * @param BeforSeq
	 *            上个班交班点（2 5 时为入炉交班点）
	 * @param FeedStartSeq
	 *            上料行起始Seq
	 * @return CoreReturnObject
	 */
	public CoreReturnObject changeNum(String JudgeStoveNo, String ResultNo,
			String FeedRowNo, Integer Seq, Integer BeforSeq,
			Integer FeedStartSeq, String PLineCode, String Shift, String Class,
			String User, Integer ProcessNo, Integer FurFlag, String proPlanId,
			String gxPlanNo) {
		ArrayList<String> sqllist = new ArrayList<String>();
		ArrayList<String> sqllist1 = new ArrayList<String>();
		String sql = ""; // 交班前清空班次 班组
		String sql1 = ""; // 修改实绩表交接班支数
		String sql2 = ""; // 修改上料行交接班支数
		String sql3 = ""; // 修改跟踪表班次班组
		String sql4 = ""; // 修改跟踪表交班标识
		// 锯切
		if (ProcessNo.equals(1)) {
			// 交班前 清空班次班组
			sql = "update MIL_FEED_RACK  set COL_SHIFT = ''  , COL_GROUP = ''  , COL_USER = '' , END_TIME = '',  CHANGE_FLAG = 0 where  ";
			sql += "JUDGE_STOVE_NO = '" + JudgeStoveNo + "' and RESULT_NO = '"
					+ ResultNo + "'  and seq > " + (BeforSeq)
					+ " and FEED_ROW_NO = '" + FeedRowNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
					+ "','/')";

			// 修改锯切交接班支数
			sql1 = "update  MIL_FEEDSAW_RESULT  set  CHANGE_NUM = CHANGE_NUM-(SELECT CHANGE_NUM FROM MIL_FEED_PLAN WHERE FEED_ROW_NO = '"
					+ FeedRowNo + "')+" + (Seq + 1 - FeedStartSeq) + " where ";
			sql1 += "JUDGE_STOVE_NO = '" + JudgeStoveNo + "' and RESULT_NO = '"
					+ ResultNo + "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId + "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo + "','/')";

			// 修改上料行交接班支数
			sql2 = "update  MIL_FEED_PLAN  set  CHANGE_NUM = "
					+ (Seq + 1 - FeedStartSeq) + " where ";
			sql2 += "JUDGE_STOVE_NO = '" + JudgeStoveNo
					+ "' and FEED_ROW_NO = '" + FeedRowNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
					+ "','/')";

			// 修改锯切跟踪表班次班组
			sql3 = "update MIL_FEED_RACK  set COL_SHIFT = '" + Shift
					+ "'  , COL_GROUP = '" + Class + "'  , COL_USER = '" + User
					+ "', END_TIME = sysdate where ";
			sql3 += "JUDGE_STOVE_NO = '" + JudgeStoveNo + "' and RESULT_NO = '"
					+ ResultNo + "'  and seq between  " + (BeforSeq + 1)
					+ " and " + Seq + " AND FEED_ROW_NO = '" + FeedRowNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
					+ "','/')";

			// 修改跟踪表交班标识
			sql4 = "update MIL_FEED_RACK set  CHANGE_FLAG = '1' where JUDGE_STOVE_NO = '"
					+ JudgeStoveNo
					+ "' and RESULT_NO = '"
					+ ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo
					+ "','/')" + "  and seq =" + Seq;
			sqllist.add(sql);
			sqllist.add(sql1);
			sqllist.add(sql2);
			sqllist.add(sql3);
			sqllist.add(sql4);
		}

		return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(
				sqllist);
	}

	/**
	 * 锯切上料行交班取消 1- 修改实绩表交接班支数 2-修改上料表交班支数 3-修改跟踪表班次班组 4-修改跟踪表交班标识
	 * 
	 * @param ProcessNo
	 *            1-锯切
	 * @param FeedRowNoList
	 *            上料行ID
	 * @param BeforeSeqList
	 *            前道工序交班支数
	 * @param FeedStartSeqLsit
	 *            上料行起始序号
	 * @param ChangeCancelCount
	 *            交班取消总支数
	 * @param Flag
	 *            上个班是否有交班 标识 0 无 1有
	 * @return CoreReturnObject
	 */
	public CoreReturnObject changeCancel(String JudgeStoveNo, String ResultNo,
			ArrayList FeedRowNoList, ArrayList BeforeSeqList,
			ArrayList FeedStartSeqLsit, Integer ChangeCancelCount, Integer Flag) {
		ArrayList<String> sqllist = new ArrayList<String>();

		String sql = ""; // 清空当班交接班班次 班组
		String sql1 = ""; // 修改实绩表交接班支数
		String sql2 = ""; // 修改上料行交接班支数

		for (int i = 0; i < FeedRowNoList.size(); i++) {

			// 清空班次班组
			sql = "update MIL_FEED_RACK  set COL_SHIFT = ''  , COL_GROUP = ''  , COL_USER = '' , END_TIME = '',  CHANGE_FLAG = 0 where  ";
			sql += "JUDGE_STOVE_NO = '" + JudgeStoveNo + "' and RESULT_NO = '"
					+ ResultNo + "'  and FEED_ROW_NO = '"
					+ FeedRowNoList.get(i) + "' and seq > "
					+ (BeforeSeqList.get(i)) + " ";

			if (Flag.equals(1)) {
				// 修改上料行交接班支数
				sql2 = "update  MIL_FEED_PLAN  set  CHANGE_NUM = "
						+ BeforeSeqList.get(i) + "-" + FeedStartSeqLsit.get(i)
						+ " +1  where ";
				sql2 += "JUDGE_STOVE_NO = '" + JudgeStoveNo
						+ "' and FEED_ROW_NO = '" + FeedRowNoList.get(i) + "'";
			} else {
				sql2 = "update  MIL_FEED_PLAN  set  CHANGE_NUM = 0  where ";
				sql2 += "JUDGE_STOVE_NO = '" + JudgeStoveNo
						+ "' and FEED_ROW_NO = '" + FeedRowNoList.get(i) + "'";
			}

			sqllist.add(sql2);
			sqllist.add(sql);

		}
		// 修改锯切交接班支数
		sql1 = "update  MIL_FEEDSAW_RESULT  set  CHANGE_NUM = CHANGE_NUM-"
				+ ChangeCancelCount + " where ";
		sql1 += "JUDGE_STOVE_NO = '" + JudgeStoveNo + "' and RESULT_NO = '"
				+ ResultNo + "'";
		sqllist.add(sql1);
		return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(
				sqllist);
	}

	/**
	 * 查询上料行起始Seq
	 * 
	 * 
	 * @param JudgeStoveNo
	 *            炉号
	 * @param FeedRowNo
	 *            上料行号
	 * @return
	 */
	public CoreReturnObject getStartSeq(String JudgeStvoeNo, String FeedRowNo) {

		String sql = "select  min(seq) as SEQ ,min(FEED_ROW_NO) AS FEED_ROW_NO FROM MIL_FEED_RACK WHERE JUDGE_STOVE_NO = '"
				+ JudgeStvoeNo + "' GROUP BY FEED_ROW_NO  ";

		return this.getData(sql);
	}

	/**
	 * 查询上料行交班支数
	 * 
	 * 
	 * @param JudgeStoveNo
	 *            炉号
	 * @param FeedRowNo
	 *            上料行号
	 * @return
	 */
	public CoreReturnObject getFeedChangeNum(String JudgeStvoeNo) {

		String sql = "select CHANGE_NUM FROM MIL_FEED_PLAN WHERE JUDGE_STOVE_NO = '"
				+ JudgeStvoeNo + "' order by feed_row_no ";

		return this.getData(sql);
	}

	/**
	 * 查询上工序 合格支数
	 * 
	 * @param ProcessNo
	 *            工序号 0-锯切 1-环形加热炉 2-穿孔 3-连轧 4-再加热炉 5-定径 6-管排锯 7-矫直 8-探伤 9-质检
	 * @param PLineCode
	 *            产线代码
	 * @param JudgeStoveNo
	 *            炉号
	 * @param ResultNo
	 *            实绩编号
	 * @return
	 */
	public CoreReturnObject getQANumBefore(String JudgeStvoeNo,
			String ResultNo, Integer ProcessNo, String PlineCode,
			String proPlanId, String gxPlanNo) {
		String[] TableNameList = new String[] { "MIL_FEEDSAW_RESULT",
				"MIL_FUR_Result", "MIL_PERFORATION_Result",
				"MIL_ROLLING_Result", "MIL_REFUR_Result", "MIL_SIZING_Result",
				"MIL_SAW_Result", "MIL_STRAIGHTENING_RESULT", "MIL_ET_RESULT",
				"MIL_MT_RESULT", "MIL_UL_RESUL", "MIL_SURFACE_RESULT" };
		String[] QANumList = new String[] { "CUT_NUM", "OUT_FUR_NUM",
				"PERFORATION_NUM", "QUALIFIED_NUM", "OUT_FUR_NUM",
				"PRODUCT_NUM", "CUT_NUM   ", "QUALIFIED_NUM1 ",
				"QUALIFIED_NUM1  ", "QUALIFIED_BRANCH" };

		String sql = "select  " + QANumList[ProcessNo - 1] + " FROM  "
				+ TableNameList[ProcessNo - 1] + " WHERE JUDGE_STOVE_NO = '"
				+ JudgeStvoeNo + "' AND Result_no = '" + ResultNo
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
				+ "','/')";

		if (ProcessNo.equals(9)) {
			if (PlineCode.equals("C009") || PlineCode.equals("C008")
					|| PlineCode.equals("C017") || PlineCode.equals("C072")) {
				sql = "select  " + QANumList[ProcessNo] + " FROM  "
						+ TableNameList[11] + " WHERE JUDGE_STOVE_NO = '"
						+ JudgeStvoeNo + "' AND Result_no = '" + ResultNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
						+ "','/')";

			}
		}

		return this.getData(sql);
	}

	/**
	 * 查询上个班 班次班组
	 * 
	 * @param ProcessNo
	 *            工序号 0-锯切 1-环形加热炉 2-穿孔 3-连轧 4-再加热炉 5-定径 6-管排锯 7-矫直 8-探伤 9-质检
	 * @param PLineCode
	 *            产线代码
	 * @param JudgeStoveNo
	 *            炉号
	 * @param ResultNo
	 *            实绩编号
	 * @return
	 */
	public CoreReturnObject GetShiftBefore(String Shift, String Group,
			String PlineCode, Integer ProcessNo) {
		String[] TableNameList = new String[] { "MIL_FEEDSAW_RESULT",
				"MIL_FUR_Result", "MIL_PERFORATION_Result",
				"MIL_ROLLING_Result", "MIL_REFUR_Result", "MIL_SIZING_Result",
				"MIL_SAW_Result", "MIL_STRAIGHTENING_RESULT", "MIL_ET_RESULT",
				"MIL_MT_RESULT", "MIL_UL_RESUL", "MIL_SURFACE_RESULT" };
		String[] EndTimeList = new String[] { "END_TIME", "OUT_FUR_TIME",
				"END_PERFORATION_TIME", "END_ROLLING_TIME", "OUT_REFUR_TIME",
				"END_SIZING_TIME", "END_SAW_TIME", "END_STRAIGHTENING_TIME",
				"END_INSPECTION_TIME", "END_INSPECTION_TIME",
				"END_INSPECTION_TIME", "END_TIME" };

		String sql = "select  COL_SHIFT,COL_GROUP FROM  "
				+ TableNameList[ProcessNo] + " WHERE " + EndTimeList[ProcessNo]
				+ " = ";
		sql += " (select  MAX( " + EndTimeList[ProcessNo] + " ) from "
				+ TableNameList[ProcessNo] + " where col_shift != '" + Shift
				+ "' and col_group !='" + Group + "' )";

		if (ProcessNo.equals(9)) {
			if (PlineCode.equals("C009") || PlineCode.equals("C008")
					|| PlineCode.equals("C017")) {
				sql = "select  COL_SHIFT,COL_GROUP FROM  " + TableNameList[11]
						+ " WHERE " + EndTimeList[11] + " = ";
				sql += " (select  MAX( " + EndTimeList[11] + " ) from "
						+ TableNameList[11] + " where col_shift != '" + Shift
						+ "' and col_group !='" + Group + "' )";
				// sql =
				// "select  "+QANumList[ProcessNo]+" FROM  "+TableNameList[11]+" WHERE JUDGE_STOVE_NO = '"+JudgeStvoeNo+"' AND Result_no = '"+ResultNo+"' ";

			}
		}

		return this.getData(sql);
	}

	/**
	 * 查询本工序该炉当前剔除支数
	 * 
	 * @param ProcessNo
	 *            工序号 0-锯切 1-环形加热炉 2-穿孔 3-连轧 4-再加热炉 5-定径 6-管排锯 7-矫直 8-探伤 9-质检
	 * @param PLineCode
	 *            产线代码
	 * @param JudgeStoveNo
	 *            炉号
	 * @param ResultNo
	 *            实绩编号
	 * @return
	 */
	public CoreReturnObject getScrapNum(String JudgeStvoeNo, String ResultNo,
			Integer ProcessNo, String PlineCode, String proPlanId,
			String gxPlanNo) {
		String[] TableNameList = new String[] { "MIL_FEEDSAW_RESULT",
				"MIL_FUR_Result", "MIL_PERFORATION_Result",
				"MIL_ROLLING_Result", "MIL_REFUR_Result", "MIL_SIZING_Result",
				"MIL_SAW_Result", "MIL_STRAIGHTENING_RESULT", "MIL_ET_RESULT",
				"MIL_MT_RESULT", "MIL_UL_RESUL", "MIL_SURFACE_RESULT" };
		String[] QANumList = new String[] { "CUT_NUM", "OUT_FUR_NUM",
				"PERFORATION_NUM", "QUALIFIED_NUM", "OUT_FUR_NUM",
				"PRODUCT_NUM", "CUT_NUM   ", "QUALIFIED_NUM1 ",
				"QUALIFIED_NUM1  ", "QUALIFIED_BRANCH" };

		String sql = "select  SCRAP_NUM FROM  " + TableNameList[ProcessNo]
				+ " WHERE JUDGE_STOVE_NO = '" + JudgeStvoeNo
				+ "' AND Result_no = '" + ResultNo
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
				+ "','/')";

		if (ProcessNo.equals(9)) {
			if (PlineCode.equals("C009") || PlineCode.equals("C008")
					|| PlineCode.equals("C017")|| PlineCode.equals("C072")) {
				sql = "select  SCRAP_NUM FROM  " + TableNameList[ProcessNo + 2]
						+ " WHERE JUDGE_STOVE_NO = '" + JudgeStvoeNo
						+ "' AND Result_no = '" + ResultNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
						+ "','/')";

			}
		}

		return this.getData(sql);
	}

	/**
	 * 管排锯切前判断当前管坯序号是否已剔除
	 * 
	 * @param JudgeStvoeNo
	 *            炉号
	 * @param seq
	 *            管坯序号
	 * @return
	 */
	public CoreReturnObject getScrapSeq(String JudgeStvoeNo, String seq,
			String proPlanId, String gxPlanNo) {
		String sql = "select decode(t.process_no,'0','锯切前','1','锯切后','2','加热炉','3','穿孔','4','连轧','5','再加热炉','6','定径') from MIL_SLAB_SCRAP_SEQ t where t.judge_stove_no = '"
				+ JudgeStvoeNo
				+ "' AND T.SEQ = '"
				+ seq
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
				+ proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
				+ gxPlanNo
				+ "','/')";
		sql += " and t.PROCESS_NO < 7";
		return this.getData(sql);
	}

	/**
	 * 查询上料行锯切状态
	 * 
	 * @return
	 */
	public CoreReturnObject getSawFlag(String FeedRowNo) {

		String sql = "select saw_falg from mil_feed_plan where feed_row_no = '"
				+ FeedRowNo + "'";
		return this.getData(sql);
	}

	/**
	 * 查询本工序该炉当前剔除支数
	 * 
	 * @param ProcessNo
	 *            工序号 0-锯切 1-环形加热炉 2-穿孔 3-连轧 4-再加热炉 5-定径 6-管排锯 7-矫直 8-探伤 9-质检
	 * @param PLineCode
	 *            产线代码
	 * @param JudgeStoveNo
	 *            炉号
	 * @param ResultNo
	 *            实绩编号
	 * @return
	 */
	public CoreReturnObject isNode(String JudgeStvoeNo, String ResultNo,
			Integer ProcessNo, String PlineCode) {
		String[] TableNameList = new String[] { "MIL_FEEDSAW_RESULT",
				"MIL_FUR_Result", "MIL_PERFORATION_Result",
				"MIL_ROLLING_Result", "MIL_REFUR_Result", "MIL_SIZING_Result",
				"MIL_SAW_Result", "MIL_STRAIGHTENING_RESULT", "MIL_ET_RESULT",
				"MIL_MT_RESULT", "MIL_UL_RESUL", "MIL_SURFACE_RESULT" };

		String sql = "select  NODE_FUR_FLAG FROM  " + TableNameList[ProcessNo]
				+ " WHERE JUDGE_STOVE_NO = '" + JudgeStvoeNo
				+ "' AND Result_no = '" + ResultNo + "' ";

		if (ProcessNo.equals(9)) {
			if (PlineCode.equals("C009") || PlineCode.equals("C008")
					|| PlineCode.equals("C017")) {
				sql = "select  NODE_FUR_FLAG FROM  "
						+ TableNameList[ProcessNo + 2]
						+ " WHERE JUDGE_STOVE_NO = '" + JudgeStvoeNo
						+ "' AND Result_no = '" + ResultNo + "' ";

			}
		}

		return this.getData(sql);
	}

	/**
	 * 修改交班标识
	 * 
	 * @param ProcessNo
	 *            工序号 0-锯切 1-环形加热炉 2-穿孔 3-连轧 4-再加热炉 5-定径 6-管排锯 7-矫直 8-探伤 9-质检
	 * @param PLineCode
	 *            产线代码
	 * @param JudgeStoveNo
	 *            炉号
	 * @param ResultNo
	 *            实绩编号
	 * @return
	 */
	public CoreReturnObject UpdateChangeFlag(String JudgeStvoeNo,
			String ResultNo, String FeedRowNo, Integer ProcessNo, Integer Seq,
			Integer FurFlag) {
		ArrayList<String> sqllist = new ArrayList<String>();
		String[] TableRackList = new String[] { "MIL_FEED_RACK",
				"MIL_FUR_RACK", "MIL_PERFORATION_RACK", "MIL_ROLLING_RACK",
				"MIL_REFUR_RACK", "MIL_SIZING_RACK", "MIL_SAW_RACK",
				"MIL_STRAIGH_RACK", "MIL_TESTING_RACK", "MIL_QA_RACK" };

		String sql1 = "update    " + TableRackList[ProcessNo]
				+ "  set CHANGE_FLAG = '0'  WHERE JUDGE_STOVE_NO = '"
				+ JudgeStvoeNo + "' AND Result_no = '" + ResultNo
				+ "' AND CHANGE_FLAG = '2' ";
		String sql = "update    " + TableRackList[ProcessNo]
				+ "  set CHANGE_FLAG = '2'  WHERE JUDGE_STOVE_NO = '"
				+ JudgeStvoeNo + "' AND Result_no = '" + ResultNo
				+ "' AND SEQ = '" + Seq + "' ";
		if (ProcessNo.equals(0)) {
			sql1 = "update    " + TableRackList[ProcessNo]
					+ "  set CHANGE_FLAG = '0'  WHERE JUDGE_STOVE_NO = '"
					+ JudgeStvoeNo + "' AND Result_no = '" + ResultNo
					+ "' AND CHANGE_FLAG = '2' AND FEED_ROW_NO = '" + FeedRowNo
					+ "'";
			sql = "update    " + TableRackList[ProcessNo]
					+ "  set CHANGE_FLAG = '2'  WHERE JUDGE_STOVE_NO = '"
					+ JudgeStvoeNo + "' AND Result_no = '" + ResultNo
					+ "' AND SEQ = '" + Seq + "' AND FEED_ROW_NO = '"
					+ FeedRowNo + "' ";
		}
		if (ProcessNo.equals(1) || ProcessNo.equals(4)) {
			if (FurFlag.equals(0)) // 入炉
			{
				sql1 = "update    "
						+ TableRackList[ProcessNo]
						+ "  set IN_CHANGE_FLAG = '0'  WHERE JUDGE_STOVE_NO = '"
						+ JudgeStvoeNo + "' AND Result_no = '" + ResultNo
						+ "' AND IN_CHANGE_FLAG = '2' ";
				sql = "UPDATE  " + TableRackList[ProcessNo]
						+ "  SET IN_CHANGE_FLAG = '2' WHERE JUDGE_STOVE_NO = '"
						+ JudgeStvoeNo + "' AND Result_no = '" + ResultNo
						+ "' AND SEQ = '" + Seq + "' ";
			} else {
				sql1 = "update    "
						+ TableRackList[ProcessNo]
						+ "  set OUT_CHANGE_FLAG = '0'  WHERE JUDGE_STOVE_NO = '"
						+ JudgeStvoeNo + "' AND Result_no = '" + ResultNo
						+ "' AND OUT_CHANGE_FLAG = '2' ";
				sql = "UPDATE  "
						+ TableRackList[ProcessNo]
						+ "  SET OUT_CHANGE_FLAG = '2' WHERE JUDGE_STOVE_NO = '"
						+ JudgeStvoeNo + "' AND Result_no = '" + ResultNo
						+ "' AND SEQ = '" + Seq + "' ";
			}
		}

		sqllist.add(sql1);
		sqllist.add(sql);
		return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(
				sqllist);
	}

	/**
	 * 查询已交班但未确认的上料行号
	 * 
	 * @param JudgeStoveNo
	 *            炉号
	 * @param ResultNo
	 *            实绩编号
	 * @return
	 */
	public CoreReturnObject ChangeQuery(String JudgeStvoeNo, String ResultNo,
			String FeedRowNo, String proPlanId, String gxPlanNo) {

		String sql = "SELECT FEED_ROW_NO FROM MIL_FEED_RACK WHERE CHANGE_FLAG = '2'  AND  JUDGE_STOVE_NO = '"
				+ JudgeStvoeNo
				+ "' AND Result_no = '"
				+ ResultNo
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
				+ proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
				+ gxPlanNo
				+ "','/')";

		return this.getData(sql);
	}

	/**
	 * 查询已交班但未确认入炉or出炉管
	 * 
	 * @param JudgeStoveNo
	 *            炉号
	 * @param ResultNo
	 *            实绩编号
	 *@param FurFlag
	 *            0-入炉 1-出炉
	 * @return
	 */
	public CoreReturnObject ChangeQuery(String JudgeStvoeNo, String ResultNo,
			Integer FurFlag) {

		String sql = "";
		// 查询入炉
		if (FurFlag.equals(0)) {
			sql = "SELECT JUDGE_STOVE_NO FROM MIL_FUR_RACK WHERE IN_CHANGE_FLAG = '2'  AND  JUDGE_STOVE_NO = '"
					+ JudgeStvoeNo + "' AND Result_no = '" + ResultNo + "' ";
		}
		// 查询出炉
		if (FurFlag.equals(1)) {
			sql = "SELECT JUDGE_STOVE_NO FROM MIL_FUR_RACK WHERE OUT_CHANGE_FLAG = '2'  AND  JUDGE_STOVE_NO = '"
					+ JudgeStvoeNo + "' AND Result_no = '" + ResultNo + "' ";
		}
		return this.getData(sql);
	}

	/**
	 * 查询已交班但未确认入炉or出炉管
	 * 
	 * @param JudgeStoveNo
	 *            炉号
	 * @param ResultNo
	 *            实绩编号
	 *@param FurFlag
	 *            0-入炉 1-出炉
	 * @return
	 */
	public CoreReturnObject ChangeQueryReFur(String JudgeStvoeNo,
			String ResultNo, Integer FurFlag, String proPlanId, String gxPlanNo) {

		String sql = "";
		// 查询入炉
		if (FurFlag.equals(0)) {
			sql = "SELECT JUDGE_STOVE_NO FROM MIL_REFUR_RACK WHERE IN_CHANGE_FLAG = '2'  AND  JUDGE_STOVE_NO = '"
					+ JudgeStvoeNo
					+ "' AND Result_no = '"
					+ ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo
					+ "','/')";
		}
		// 查询出炉
		if (FurFlag.equals(1)) {
			sql = "SELECT JUDGE_STOVE_NO FROM MIL_REFUR_RACK WHERE OUT_CHANGE_FLAG = '2'  AND  JUDGE_STOVE_NO = '"
					+ JudgeStvoeNo
					+ "' AND Result_no = '"
					+ ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('"
					+ proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('"
					+ gxPlanNo
					+ "','/')";
		}
		return this.getData(sql);
	}

	/**
	 * 交班登陆
	 * 
	 * @param JudgeStoveNo
	 *            炉号
	 * @param ResultNo
	 *            实绩编号
	 * @return
	 */
	public CoreReturnObject getUser(String UserID, String PassWord) {

		String sql = "SELECT DEPTID FROM core_app_user WHERE   USERID = '"
				+ UserID + "' AND PASSWD = '" + PassWord + "' ";

		return this.getData(sql);
	}

	/**
	 * 是否交班登陆
	 * 
	 * @param ProcessNo
	 *            工序号 工序(0-锯切 1-加热炉 2-穿孔 3-连轧 4-再加热炉 5-定径 6-分切 7矫直 8-探伤 9-人工质检)
	 * @param ResultNo
	 *            实绩编号
	 * @return
	 */
	public CoreReturnObject GetIsChanged(String StartTime, String EndTime,
			String Shift, String Group, String ProcessNo, String PlineCode) {

		String sql = "SELECT col_shift,col_group FROM MIL_CHANGE_RESUME WHERE COL_TIME between  to_date('"
				+ StartTime
				+ "', 'yyyy-mm-dd hh24:mi:ss') AND to_date('"
				+ EndTime + "' , 'yyyy-mm-dd hh24:mi:ss') ";
		sql += " and  COL_SHIFT = '" + Shift + "' AND COL_GROUP = '" + Group
				+ "' AND PROCESS_NO = '" + ProcessNo + "' AND PLINE_CODE = '"
				+ PlineCode + "'";

		return this.getData(sql);
	}

	/**
	 * 接班登录后插入接班履历
	 * 
	 * @param ProcessNo
	 *            工序号 工序(0-锯切 1-加热炉 2-穿孔 3-连轧 4-再加热炉 5-定径 6-分切 7矫直 8-探伤 9-人工质检)
	 * @param ResultNo
	 *            实绩编号
	 * @return
	 */
	public CoreReturnObject InsertChangeRemuse(ArrayList arry) {

		String sql = " insert INTO MIL_CHANGE_RESUME (PLINE_CODE,COL_SHIFT,COL_GROUP,COL_USER,PROCESS_NO,COL_TIME) values ";
		sql += " ('" + arry.get(4) + "', '" + arry.get(0) + "' ,'"
				+ arry.get(1) + "', '" + arry.get(2) + "', '" + arry.get(3)
				+ "',sysdate)";

		return this.setData(sql);
	}

	/**
	 * 查询前道班次UserID
	 * 
	 * @param ProcessNo
	 *            工序号 工序(0-锯切 1-加热炉 2-穿孔 3-连轧 4-再加热炉 5-定径 6-分切 7矫直 8-探伤 9-人工质检)
	 * @param ResultNo
	 *            实绩编号
	 * @return
	 */
	public CoreReturnObject GetUserIDBefore(String StartTime, String EndTime,
			String Shift, String Group, Integer ProcessNo, String PlineCode) {

		String[] TableNameList = new String[] { "MIL_FEEDSAW_RESULT",
				"MIL_FUR_Result", "MIL_PERFORATION_Result",
				"MIL_ROLLING_Result", "MIL_REFUR_Result", "MIL_SIZING_Result",
				"MIL_SAW_Result", "MIL_STRAIGHTENING_RESULT", "MIL_ET_RESULT",
				"MIL_MT_RESULT", "MIL_UL_RESUL", "MIL_SURFACE_RESULT" };
		String[] EndTimeList = new String[] { "END_TIME", "OUT_FUR_TIME",
				"END_PERFORATION_TIME", "END_ROLLING_TIME", "OUT_REFUR_TIME",
				"END_SIZING_TIME", "END_SAW_TIME", "END_STRAIGHTENING_TIME",
				"END_INSPECTION_TIME", "END_INSPECTION_TIME",
				"END_INSPECTION_TIME", "END_TIME" };
		String TableName = TableNameList[ProcessNo];
		String EndTimeName = EndTimeList[ProcessNo];
		if (ProcessNo.equals(8)) {

		}
		if (ProcessNo.equals(9)) {
			TableName = "MIL_SURFACE_RESULT";
			EndTimeName = "END_TIME";
		}
		String sql = "SELECT USER_ID FROM " + TableName
				+ " WHERE  END_TIME = (SELECT  max(END_TIME) FROM " + TableName
				+ " WHERE ";
		sql += " END_TIME between  to_date('" + StartTime
				+ "', 'yyyy-mm-dd hh24:mi:ss') AND to_date('" + EndTime
				+ "' , 'yyyy-mm-dd hh24:mi:ss') ";
		sql += " and  COL_SHIFT = '" + Shift + "' AND COL_GROUP = '" + Group
				+ "'  AND PLINE_CODE = '" + PlineCode
				+ "' and USER_ID is not null)";

		return this.getData(sql);
	}

	/**
	 * 上料插入上料顺序
	 * 
	 * @param SeqNo
	 *            年月日+产线代码
	 * @return CoreReturnObject
	 */
	public CoreReturnObject InsertFeedSeq(String JudgeStoveNo, String ResultNo,
			String SeqNo) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection conn = null;
		PreparedStatement psta = null;

		try {
			conn = this.getDao("TgDao").getConnection();
			conn.setAutoCommit(false);

			String sql = "";

			ResultSet rs = null;
			String FeedNo = "";
			int Seq = 0;
			sql = "SELECT MAX(FEED_SEQ) FROM MIL_PLAN WHERE FEED_SEQ LIKE '"
					+ SeqNo + "%'";
			psta = conn.prepareStatement(sql);
			rs = psta.executeQuery();
			while (rs.next()) {
				FeedNo = rs.getString(1);
				if (!(FeedNo == null)) {
					Seq = Integer.parseInt(FeedNo.substring(
							FeedNo.length() - 3, FeedNo.length())) + 1;
					DecimalFormat df = new DecimalFormat("000");
					FeedNo = SeqNo + df.format(Seq);
				} else {
					FeedNo = SeqNo + "001";
				}
			}
			rs.close();
			psta.close();
			sql = "update MIL_PLAN set FEED_SEQ = '" + FeedNo
					+ "' where JUDGE_STOVE_NO = '" + JudgeStoveNo
					+ "' AND ID = '" + ResultNo + "'";
			psta = conn.prepareStatement(sql);
			psta.execute();
			conn.commit();
			psta.close();
			conn.close();
		} catch (SQLException sqle) {
			sqle.printStackTrace();
			try {
				conn.rollback();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} finally {
			try {
				if (conn != null && !conn.isClosed()) {
					conn.close();
				}
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		cro.setResult(0);
		return cro;
	}

	/**
	 * 查询待接班确认Seq
	 * 
	 * @param ProcessNo
	 *            工序号 0-锯切 1-环形加热炉 2-穿孔 3-连轧 4-再加热炉 5-定径 6-管排锯 7-矫直 8-探伤 9-质检
	 * @param PLineCode
	 *            产线代码
	 * @param JudgeStoveNo
	 *            炉号
	 * @param ResultNo
	 *            实绩编号
	 * @return
	 */
	public CoreReturnObject GetWaitChangeSeq(String JudgeStvoeNo,
			String ResultNo, String FeedRowNo, Integer ProcessNo,
			Integer FurFlag, String proPlanId, String gxPlanNo) {

		String[] TableRackList = new String[] { "MIL_FEED_RACK",
				"MIL_FUR_RACK", "MIL_PERFORATION_RACK", "MIL_ROLLING_RACK",
				"MIL_REFUR_RACK", "MIL_SIZING_RACK", "MIL_SAW_RACK",
				"MIL_STRAIGH_RACK", "MIL_TESTING_RACK", "MIL_QA_RACK" };
		String sql = "";
		sql = "SELECT SEQ FROM    " + TableRackList[ProcessNo]
				+ " WHERE JUDGE_STOVE_NO = '" + JudgeStvoeNo
				+ "'  AND Result_no = '" + ResultNo
				+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
				+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
				+ "','/')" + " AND CHANGE_FLAG = '2' ";

		if (ProcessNo.equals(0)) {
			sql = "SELECT SEQ FROM    " + TableRackList[ProcessNo]
					+ " WHERE JUDGE_STOVE_NO = '" + JudgeStvoeNo
					+ "'  AND FEED_ROW_NO = '" + FeedRowNo
					+ "' AND Result_no = '" + ResultNo
					+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
					+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
					+ "','/')" + " AND CHANGE_FLAG = '2' ";
		}
		if (ProcessNo.equals(1) || ProcessNo.equals(4)) {
			if (FurFlag.equals(0)) // 入炉
			{
				sql = "SELECT SEQ FROM    " + TableRackList[ProcessNo]
						+ " WHERE JUDGE_STOVE_NO = '" + JudgeStvoeNo
						+ "'   AND Result_no = '" + ResultNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
						+ "','/')" + " AND IN_CHANGE_FLAG = '2' ";
			} else {
				sql = "SELECT SEQ FROM    " + TableRackList[ProcessNo]
						+ " WHERE JUDGE_STOVE_NO = '" + JudgeStvoeNo
						+ "'   AND Result_no = '" + ResultNo
						+ "' AND NVL(PRO_PLAN_ID,'/') = NVL('" + proPlanId
						+ "','/') AND NVL(GX_PLAN_NO,'/') = NVL('" + gxPlanNo
						+ "','/')  AND OUT_CHANGE_FLAG = '2' ";
			}
		}

		return this.getData(sql);
	}

	/**
	 * 查询待接班确认Seq
	 * 
	 * @param ProcessNo
	 *            工序号 0-锯切 1-环形加热炉 2-穿孔 3-连轧 4-再加热炉 5-定径 6-管排锯 7-矫直 8-探伤 9-质检
	 * @param JudgeStoveNo
	 *            炉号
	 * @param ResultNo
	 *            实绩编号
	 * @return
	 */
	public CoreReturnObject NodeGetWaitChangeMat(String JudgeStvoeNo,
			String ResultNo, Integer ProcessNo) {

		String[] TableRackList = new String[] { "MIL_FEED_RACK",
				"MIL_FUR_RACK", "MIL_PERFORATION_RACK", "MIL_ROLLING_RACK",
				"MIL_REFUR_RACK", "MIL_SIZING_RACK", "MIL_SAW_RACK",
				"MIL_STRAIGH_RACK", "MIL_TESTING_RACK", "MIL_QA_RACK" };
		String sql = "";
		sql = "SELECT SEQ FROM    " + TableRackList[ProcessNo]
				+ " WHERE JUDGE_STOVE_NO = '" + JudgeStvoeNo
				+ "'  AND Result_no = '" + ResultNo
				+ "' AND CHANGE_FLAG = '2' ";

		if (ProcessNo.equals(1) || ProcessNo.equals(4)) {

			sql = "SELECT SEQ FROM    " + TableRackList[ProcessNo]
					+ " WHERE JUDGE_STOVE_NO = '" + JudgeStvoeNo
					+ "'   AND Result_no = '" + ResultNo
					+ "' AND IN_CHANGE_FLAG = '2' ";
			sql += "union all SELECT SEQ FROM    " + TableRackList[ProcessNo]
					+ " WHERE JUDGE_STOVE_NO = '" + JudgeStvoeNo
					+ "'   AND Result_no = '" + ResultNo
					+ "' AND OUT_CHANGE_FLAG = '2' ";

		}

		return this.getData(sql);
	}

	/**
	 * 查询回炉坯计划
	 * 
	 * @param milPlan
	 * @return
	 */
	public CoreReturnObject getBackSlabFlag(MilPlanEntity milPlan) {

		String sql = "SELECT * FROM MIL_PLAN T WHERE T.BACK_SLAB_FLAG = '1' AND  T.JUDGE_STOVE_NO = '"
				+ milPlan.getJudgeStoveNo() + "' ";
		return this.getData(sql);
	}

//	TZH 24.4.24 注销物流接口
//	/***
//	 * 同步炉计划的坯类型、坯来源
//	 * 
//	 * @return
//	 */
//	public CoreReturnObject updateTubeType() {
//		CoreReturnObject cro = new CoreReturnObject();
//		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
//				.getConnection();
//		Connection conSQL = this.getDao("MSSQL1Dao").getConnection();
//		PreparedStatement psta = null;
//		PreparedStatement psta1 = null;
//		ResultSet rs = null;
//		String sql = "";
//		String updateSql = "";
//		try {
//			connection.setAutoCommit(false); // 取消自动提交事务
//			sql = "SELECT [产出炉号]AS JUDGE_STOVE_NO,[坯类型] AS TUBE_TYPE,[坯来源]AS TUBE_SUORCE FROM tabcxslsj  WHERE changedate > '2017-06-01 00:00:00.000' AND [坯类型] IS NOT NULL GROUP BY [产出炉号],[坯类型],[坯来源]";
//			psta = conSQL.prepareStatement(sql);
//			rs = psta.executeQuery();
//			while (rs.next()) {
//				updateSql = "UPDATE MIL_PLAN T SET T.TUBE_TYPE = '"
//						+ rs.getString("TUBE_TYPE") + "',T.TUBE_SUORCE = '"
//						+ rs.getString("TUBE_SUORCE")
//						+ "' WHERE REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') = '"
//						+ rs.getString("JUDGE_STOVE_NO") + "'";
//				psta1 = connection.prepareStatement(updateSql);
//				psta1.executeUpdate();
//				psta1.close();
//			}
//			rs.close();
//			psta.close();
//			cro.setV_errMsg("同步成功!");
//			connection.commit();
//		} catch (SQLException e) {
//			System.out.println(e.getMessage());
//			if (connection != null) {
//				try {
//					connection.rollback(); // 回滚事务
//				} catch (Exception e2) {
//				}
//			}
//		} finally {
//			try {
//				if (connection != null && !connection.isClosed()) {
//					connection.close();
//				}
//			} catch (Exception e2) {
//			}
//		}
//		return cro;
//	}
}

/**
 * 结炉时剔除剔料序号表对应管坯
 * 
 * @param JudgeStoveNo
 *            上料计划实体类
 * @return CoreReturnObject
 */
/*
 * public CoreReturnObject scrapNodeMat(String JudgeStoveNo){ CoreReturnObject
 * cro = new CoreReturnObject(); Connection conn = null; PreparedStatement psta
 * = null; PreparedStatement psta1 = null; PreparedStatement psta2 = null; try {
 * conn = this.getDao("TgDao").getConnection(); conn.setAutoCommit(false);
 * 
 * String sql = "";
 * 
 * ResultSet rs = null; ResultSet rs1 = null; ResultSet rs2 = null; ResultSet
 * rs3 = null; ResultSet rs4 = null; ArrayList<int[]> seqlist = new
 * ArrayList<int[]>(); sql =
 * CoreXmlSqlParsersFactory.getSql("FeedResult.SinglePlanQuery"); psta =
 * conn.prepareStatement(sql); psta.setString(1, JudgeStoveNo); rs =
 * psta.executeQuery(); while(rs.next()) { int SawNum = rs.getInt(3); //分切数 int
 * DBNum = rs.getInt(8); //倍尺数 sql =
 * CoreXmlSqlParsersFactory.getSql("FeedResult.ScrapSlabSeqQuery"); psta1 =
 * conn.prepareStatement(sql); psta1.setString(1, JudgeStoveNo);
 * psta1.setString(2, "0"); //锯切前 rs1 = psta1.executeQuery(); sql =
 * CoreXmlSqlParsersFactory.getSql("FeedResult.ScrapSlabSeqQuery"); psta2 =
 * conn.prepareStatement(sql); psta2.setString(1, JudgeStoveNo);
 * psta2.setString(2, "1"); //锯切后 rs2 = psta2.executeQuery(); int Seq = 0;
 * String ScrapTime = ""; String Remark = ""; String ScrapUser = ""; String
 * ScrapGroup = ""; String ScrapShift = ""; String TableName = ""; int ScrapNum
 * = 0; //切后剔除支数 String MatNo = ""; String[] TableNameList = new
 * String[]{"MIL_FUR_HISTORY", "MIL_PERFORATION_HISTORY","MIL_ROLLING_HISTORY",
 * "MIL_REFUR_HISTORY","MIL_SIZING_HISTORY","MIL_SAW_HISTORY",
 * "MIL_STRAIGH_HISTORY","MIL_TESTING_HISTORY"}; //切前剔除 while(rs1.next()) { Seq
 * = rs1.getInt(1); ScrapTime = rs1.getString(2); Remark = rs1.getString(4);
 * ScrapUser = rs1.getString(5); ScrapShift = rs1.getString(6); ScrapGroup =
 * rs1.getString(7); //查询剔除序号对应的管号 sql = " SELECT MAT_NO FROM "+
 * " (SELECT ROWNUM AS ROW_NO ,SEQ,MAT_NO FROM MIL_FEED_HISTORY T WHERE DELETE_FLAG ='0' "
 * + " AND T.JUDGE_STOVE_NO = '"+ JudgeStoveNo+"' ORDER BY SEQ)WHERE row_no = "+
 * Seq; psta = conn.prepareStatement(sql); rs3 = psta.executeQuery();
 * while(rs3.next()) { MatNo = rs3.getString(1); } psta.close();
 * 
 * //修改上料历史表对应序号的管坯 为 3-上料剔除 sql =
 * CoreXmlSqlParsersFactory.getSql("FeedResult.UpdateFeedHistory"); psta =
 * conn.prepareStatement(sql); psta.setString(1, "3"); psta.setInt(2, 0);
 * psta.setInt(3, Seq); psta.setString(4,JudgeStoveNo); int
 * UpdateFeedHistoryCount = psta.executeUpdate(); psta.close();
 * 
 * 
 * //新增坯料剔除表 sql = CoreXmlSqlParsersFactory.getSql("FeedResult.AddScrapSlab");
 * psta = conn.prepareStatement(sql); psta.setString(1, JudgeStoveNo);
 * psta.setInt(2, Seq); psta.setString(3, "0"); psta.setString(4, MatNo);
 * psta.setString(5, "0"); psta.setString(6, ScrapUser); psta.setString(7,
 * ScrapTime); psta.setString(8, ScrapShift); psta.setString(9, ScrapGroup); int
 * AddScrapSlabCount = psta.executeUpdate(); psta.close();
 * 
 * //修改历史表对应序号管坯状态为 1-剔除
 * 
 * for(int i = 0; i < TableNameList.length ; i++) { TableName =
 * TableNameList[i];
 * 
 * sql = "UPDATE " +TableName
 * +" SET STATUS = '1'  WHERE JUDGE_STOVE_NO ='"+JudgeStoveNo+"'AND " +
 * "SEQ IN (SELECT SEQ FROM (SELECT ROWNUM AS ROW_NO , SEQ FROM "+ TableName
 * +" T WHERE  T.DELETE_FLAG = '0'" +
 * "  AND T.JUDGE_STOVE_NO ='"+JudgeStoveNo+"' ORDER BY SEQ )WHERE ";
 * 
 * String sqllistRollUpdate = " ROW_NO in (" ;
 * 
 * String sqlWhere = ""; if(i < 6) { for(int j = 1 ;j < DBNum ; j++) { //
 * （序号-1）*dbnum + j sqlWhere += ((Seq-1)*DBNum+j) + "" + ",";
 * 
 * } sqlWhere = sqlWhere + ((Seq*DBNum)+"" +"))"); sqllistRollUpdate =
 * sqllistRollUpdate + sqlWhere; sql = sql + sqllistRollUpdate;
 * 
 * } else { for(int k = 1 ; k < SawNum * DBNum; k++) { sqlWhere +=
 * ((Seq-1)*DBNum*SawNum+k) + "" + ","; } sqlWhere = sqlWhere +
 * ((Seq*DBNum*SawNum)+"" +"))"); sqllistRollUpdate = sqllistRollUpdate +
 * sqlWhere; sql = sql + sqllistRollUpdate; }
 * 
 * psta = conn.prepareStatement(sql);
 * 
 * psta.executeUpdate(sql); psta.close(); }
 * 
 * } //切后剔除 while(rs2.next()) { Seq = rs2.getInt(1); ScrapTime =
 * rs2.getString(2); Remark = rs2.getString(4); ScrapUser = rs2.getString(5);
 * ScrapShift = rs2.getString(6); ScrapGroup = rs2.getString(7); //查询上料坯剔除的单倍坯数量
 * sql =
 * " SELECT T.MAT_NO,T.SCRAP_DBNUM FROM MIL_FEED_RACK T WHERE T.JUDGE_STOVE_NO = '"
 * + JudgeStoveNo +"'AND T.SEQ ='"+ Seq +"'"; psta = conn.prepareStatement(sql);
 * rs3 = psta.executeQuery(); while(rs3.next()) { ScrapNum = rs3.getInt(2); }
 * psta.close(); //查询剔除序号对应的坯料号 sql = " SELECT MAT_NO FROM "+
 * " (SELECT ROWNUM AS ROW_NO ,SEQ,MAT_NO FROM MIL_FEED_HISTORY T WHERE  DELETE_FLAG ='0' "
 * + " AND T.JUDGE_STOVE_NO = '"+ JudgeStoveNo+"' ORDER BY SEQ)WHERE row_no = "+
 * Seq; psta = conn.prepareStatement(sql); rs4 = psta.executeQuery();
 * while(rs4.next()) { MatNo = rs4.getString(1); } psta.close();
 * //修改上料历史表对应序号的管坯 为 4-切后剔除 并插入剔除支数 sql =
 * CoreXmlSqlParsersFactory.getSql("FeedResult.UpdateFeedHistory"); psta =
 * conn.prepareStatement(sql); psta.setString(1, "4"); psta.setInt(2, ScrapNum);
 * psta.setInt(3, Seq); psta.setString(4,JudgeStoveNo); int
 * UpdateFeedHistoryCount = psta.executeUpdate(); psta.close();
 * 
 * 
 * 
 * 
 * //新增坯料剔除表 sql = CoreXmlSqlParsersFactory.getSql("FeedResult.AddScrapSlab");
 * psta = conn.prepareStatement(sql); psta.setString(1, JudgeStoveNo);
 * psta.setInt(2, Seq); psta.setString(3, "1"); psta.setString(4, MatNo);
 * psta.setString(5, "0"); psta.setString(6, ScrapUser); psta.setString(7,
 * ScrapTime); psta.setString(8, ScrapShift); psta.setString(9, ScrapGroup); int
 * AddScrapSlabCount = psta.executeUpdate(); psta.close(); //修改历史表对应序号管坯状态为 1-剔除
 * 
 * for(int i = 0; i < TableNameList.length ; i++) { TableName =
 * TableNameList[i]; sql = "UPDATE " +TableName
 * +" SET STATUS = '1'  WHERE JUDGE_STOVE_NO ='"+JudgeStoveNo+"'AND " +
 * "SEQ IN (SELECT SEQ FROM (SELECT ROWNUM AS ROW_NO , SEQ FROM "+ TableName
 * +" T WHERE  T.DELETE_FLAG = '0'" +
 * "  AND T.JUDGE_STOVE_NO ='"+JudgeStoveNo+"' ORDER BY SEQ )WHERE "; String
 * sqllistRollUpdate = " ROW_NO in (" ;
 * 
 * String sqlWhere = ""; if(i < 6) { sqlWhere = Seq + ""+"))"; sqllistRollUpdate
 * = sqllistRollUpdate + sqlWhere; sql = sql + sqllistRollUpdate; }
 * 
 * else { for(int j = 1 ;j < SawNum ; j++) { sqlWhere += ((Seq-1)*SawNum+j) + ""
 * + ",";
 * 
 * } sqlWhere = sqlWhere + ((Seq*SawNum)+"" +"))"); sqllistRollUpdate =
 * sqllistRollUpdate + sqlWhere; sql = sql + sqllistRollUpdate;
 * 
 * }
 * 
 * psta = conn.prepareStatement(sql); psta.executeUpdate(sql); psta.close(); }
 * 
 * 
 * 
 * } //修改上料之后所有工序历史表status=1的管 delete_flag = 1 for(int i = 0; i <
 * TableNameList.length ; i++) { TableName = TableNameList[i]; sql =
 * "update  "+TableName +"  set delete_flag = '1' where status = '1'"; psta =
 * conn.prepareStatement(sql); psta.executeUpdate(sql); psta.close(); }
 * 
 * } //修改上料历史表状态为0 的坯料状态为2 conn.commit(); rs3.close(); rs4.close(); rs1.close();
 * rs2.close(); psta1.close(); psta2.close(); rs.close();
 * 
 * conn.close(); } catch(SQLException sqle){ sqle.printStackTrace(); try {
 * conn.rollback(); } catch (SQLException e) { e.printStackTrace(); } } finally{
 * try { if(conn != null && !conn.isClosed()){ conn.close(); } } catch
 * (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); }
 * } cro.setResult(0); return cro; }
 */

