package com.steering.pss.plnsaleord.planStove;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;

import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;
import CoreFS.SC01.CoreConstantData;
import com.steering.comm.converter.CoreConverter;
import com.steering.comm.db.DBCommon;
import com.steering.comm.tools.EntityTool;
import com.steering.pss.plnsaleord.base.PlnHelper;
import com.steering.pss.plnsaleord.order.CoreOrdLinePrdcrLst;
import com.steering.pss.plnsaleord.order.baseMethod.CoreDefGourp;
import com.steering.pss.plnsaleord.order.baseMethod.CoreOrdBase;
import com.steering.pss.plnsaleord.order.model.*;
import com.steering.pss.plnsaleord.planStove.entity.MilFeedPlanEntity;
import com.steering.pss.plnsaleord.planStove.entity.MilPlanEntity;
import com.steering.pss.plnsaleord.planStove.entity.ProducEntityZyM;
import com.steering.pss.plnsaleord.processOrder.entity.TmsDemandMEntity;
import com.steering.pss.plnsaleord.stove.ComPlanFurnace;
import com.steering.pss.plnsaleord.stove.PlanFurnProduction;
import com.steering.pss.plnsaleord.stove.corePlanFurnProM;
import com.steering.pss.plnsaleord.stove.entity.*;
import com.steering.pss.plnsaleord.processOrder.base.BaseHelper;
import com.steering.pss.plnsaleord.processOrder.entity.PlnOrderZgSEntity;
import com.steering.pss.plnsaleord.stove.entity.PlnOrderJgxSEntity;
import com.steering.pss.plnsaleord.stove.entity.PlnOrderRclSEntity;
import com.steering.pss.sale.order.qualityDesign.QualityDesignTool;

/**
 * 炉计划公共类
 * 
 * @author peng
 */
public class StoveHelper extends DBCommon {
	/**
	 * 计算管子米单重
	 * 
	 * @param dimater
	 *            外径
	 * @param height
	 *            壁厚
	 * @return double
	 */
	public static double caculatePipeSimgleWgt(String dimater, String height) {
		if (dimater.equals("") || height.equals("")) {
			return 0;
		}
		// 米单重=0.02466*壁厚*（外径-壁厚）
		return 0.02466 * Double.parseDouble(height)
				* (Double.parseDouble(dimater) - Double.parseDouble(height));
	}

	/**
	 * 查询工艺评审CIC
	 * 
	 * @return
	 */
	public CoreReturnObject queryCic(String ordLnDlyPk, String indexSeq,
			String carftSeq) {
		String sql = CoreXmlSqlParsersFactory.getSql("StoveHelper.queryCic");
		return this.getData(sql,
				new Object[] { carftSeq, ordLnDlyPk, indexSeq });
	}

	/**
	 * 计算管坯米单重量
	 * 
	 * @param
	 *
	 * @param
	 *
	 * @param
	 *
	 * @return double
	 */
	public static double caculatebBlankSimgleWgt(String dimater) {
		if (dimater.equals("")) {
			return 0;
		}
		// 米单重=0.02466*壁厚*（外径-壁厚）
		return (7.8 * 3.1415926 / 4 * Double.parseDouble(dimater) * Double
				.parseDouble(dimater)) / 1000 / 1000;
	}

	/**
	 * 初始化产线
	 * 
	 * @param processCode
	 * @return
	 */
	public CoreReturnObject initPline(String processCode,
			String[] validDataPurviewIds) {
		String sql = CoreXmlSqlParsersFactory.getSql("StoveHelper.initPline");
		sql += CoreConverter.toSqlConditionString("T.DEPARTMENT_CODE",
				validDataPurviewIds);
		sql += "  ORDER BY T.PLINE_NAME";
		Object[] params = new Object[] { processCode };
		return this.getData(sql, params);
	}

	/**
	 * 排序
	 * 
	 * @param
	 * @param
	 * @param
	 * @return
	 */
	public CoreReturnObject sortPlanOrder(ArrayList<String> jsonstrList,
			String jsonStrM, String processCode, String customInfo) {
		CoreReturnObject core = new CoreReturnObject();
		core.setResult(false);
		Connection con = null;
		try {
			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			con.setAutoCommit(false);
			// 移动行
			List<ProducEntityZyM> entityList = new ArrayList<ProducEntityZyM>();
			for (String jsonStr : jsonstrList) {
				ProducEntityZyM proEntity = genertionProEntity(con, jsonStr,
						processCode);
				entityList.add(proEntity);
			}
			// 定位行
			ProducEntityZyM entityM = genertionProEntity(con, jsonStrM,
					processCode);
			if (entityM == null) {
				return core;
			}
			/**
			 * 1.判断数据
			 */
			// 1.1定位行数据状态
			if (!entityM.getExeStatus().equals("00")) {
				core.setV_errMsg("选中行状态已改变,不是计划状态!");
				return core;
			}
			int gxProSeqM = entityM.getGxProSeq(); // 移至行序号
			int[] intArray = new int[entityList.size()];
			// 1.2移动行数据
			for (int i = 0; i < entityList.size(); i++) {
				ProducEntityZyM entity = entityList.get(i);
				if (entity == null) {
					return core;
				}
				if (!entity.getExeStatus().equals("00")
						|| entity.getGxProSeq() != entity.getOrglgxProSeq()) {
					return core;
				}
				intArray[i] = entity.getGxProSeq();
			}
			// 1.3必须是在调整行的序号中间
			if (gxProSeqM >= intArray[0]
					&& gxProSeqM <= intArray[entityList.size() - 1]) {
				return core;
			}
			Arrays.sort(intArray);
			// 调整行操作
			/**
			 * 2. 前移(需要操作步骤:1.)
			 */
			if (gxProSeqM < intArray[0]) {
				for (int i = 0; i < entityList.size(); i++) {
					// 2.1序号自动调整
					ProducEntityZyM entity = entityList.get(i);
					seqIncreaseZy(con, entity.getPlineCode(), gxProSeqM,
							entity.getGxProSeq(), 1, processCode);
					entity.setGxProSeq(gxProSeqM);
					// 2.2修改移动数据
					updatePlanOrderZy(con, entity, processCode,
							entityM.getProMonth());
					gxProSeqM = gxProSeqM + 1;
				}
			} else {
				/**
				 * 3.后移
				 */
				// 如果不是小于最小序号,那么肯定是大于最大序号,前面加以限制
				int differNum = 0;
				for (int i = 0; i < entityList.size(); i++) {
					ProducEntityZyM entity = entityList.get(i);
					// 3.1序号自动调整
					seqIncreaseZy(con, entity.getPlineCode(),
							entity.getGxProSeq() - differNum, gxProSeqM + 1,
							-1, processCode);
					entity.setGxProSeq(gxProSeqM);
					// 3.2 修改数据
					updatePlanOrderZy(con, entity, processCode,
							entityM.getProMonth());

					differNum++;
				}
			}
			core.setResult(true);
			con.commit();
		} catch (Exception e) {
			e.printStackTrace();
			try {
				if (con != null) {
					con.rollback();
				}
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
		} finally {
			try {
				if (con != null && !con.isClosed()) {
					con.close();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return core;
	}

	/**
	 * 生成公共数据
	 * 
	 * @param con
	 * @param jsonStr
	 * @param processCode
	 * @return
	 * @throws SQLException
	 * @throws Exception
	 */
	public ProducEntityZyM genertionProEntity(Connection con, String jsonStr,
			String processCode) throws SQLException, Exception {
		ProducEntityZyM ducEntity = new ProducEntityZyM();

		if (processCode.equals("C")) {
			// 锻造
			// PlnOrderDzSEntity entity = BaseHelper.jsonToEntity(
			// PlnOrderDzSEntity.class, jsonStr);
			// PlnOrderDzSEntity entity1 = ProducHelperBean.getPlanOrder(con,
			// entity.getProPlanId(), entity.getGxPlanNo(), processCode,
			// PlnOrderDzSEntity.class);
			// if (entity1 != null) {
			// }
		} else if (processCode.equals("D")) {
			// 轧管虚拟炉计划
			PlnZyZgMEntity entity = BaseHelper.jsonToEntity(
					PlnZyZgMEntity.class, jsonStr);
			PlnZyZgMEntity entity1 = getPlanOrderZy(con,
					entity.getHeatPlanNo(), processCode, PlnZyZgMEntity.class);
			if (entity1 != null) {
				ducEntity.setHeatPlanNo(entity1.getHeatPlanNo());
				ducEntity.setGxProSeq(Integer.parseInt(entity1.getGxProSeq()));
				ducEntity.setExeStatus(entity1.getPlanstatus());
				ducEntity.setOrderNo(entity1.getOrderNo());
				ducEntity.setPlineCode(entity1.getPlineCode());
				ducEntity.setPlineName(entity1.getPlineName());
				ducEntity
						.setOrglgxProSeq(Integer.parseInt(entity.getGxProSeq()));
				ducEntity.setOrglPlineCode(entity.getPlineCode());
				ducEntity.setOrglPlineName(entity.getPlineName());
				ducEntity.setObjEntity(entity1);
			}
		} else if (processCode.equals("E")) {
			// 镦拔扩
			// PlnOrderDbkSEntity entity = BaseHelper.jsonToEntity(
			// PlnOrderDbkSEntity.class, jsonStr);
			// PlnOrderDbkSEntity entity1 = ProducHelperBean.getPlanOrder(con,
			// entity.getProPlanId(), entity.getGxPlanNo(), processCode,
			// PlnOrderDbkSEntity.class);
			// if (entity1 != null) {
			// }
		} else if (processCode.equals("F")) {
			// 热处理
			// PlnOrderRclSEntity entity = BaseHelper.jsonToEntity(
			// PlnOrderRclSEntity.class, jsonStr);
			// PlnOrderRclSEntity entity1 = ProducHelperBean.getPlanOrder(con,
			// entity.getProPlanId(), entity.getGxPlanNo(), processCode,
			// PlnOrderRclSEntity.class);
			// if (entity1 != null) {
			// }
		} else if (processCode.equals("G")) {
			// 加工
			// PlnOrderJgxSEntity entity = BaseHelper.jsonToEntity(
			// PlnOrderJgxSEntity.class, jsonStr);
			// PlnOrderJgxSEntity entity1 = ProducHelperBean.getPlanOrder(con,
			// entity.getProPlanId(), entity.getGxPlanNo(), processCode,
			// PlnOrderJgxSEntity.class);
			// if (entity1 != null) {
			// }
		} else if (processCode.equals("H")) {
			// 接箍
			// PlnGxJgPropSEntity entity = BaseHelper.jsonToEntity(
			// PlnGxJgPropSEntity.class, jsonStr);
			// PlnGxJgPropSEntity entity1 = ProducHelperBean.getPlanOrder(con,
			// entity.getProPlanId(), entity.getGxPlanNo(), processCode,
			// PlnGxJgPropSEntity.class);
			// if (entity1 != null) {
			// }
		}
		return ducEntity;
	}

	/**
	 * 查询虚拟炉计划信息
	 * 
	 * @param
	 * @param
	 *
	 * @param
	 *
	 * @return PlnOrderCastSEntity
	 * @throws SQLException
	 */
	public static <T> T getPlanOrderZy(Connection con, String heatPlanNo,
			String processCode, Class<T> cls) throws SQLException {
		String sql = "";
		if (processCode.equals("C")) {
			sql = CoreXmlSqlParsersFactory.getSql("StoveHelper.getPlanZyDzM");
		} else if (processCode.equals("D")) {
			sql = CoreXmlSqlParsersFactory.getSql("StoveHelper.getPlanZyZgM");
		} else if (processCode.equals("E")) {
			sql = CoreXmlSqlParsersFactory.getSql("StoveHelper.getPlanZyDbkM");
		} else if (processCode.equals("F")) {
			sql = CoreXmlSqlParsersFactory.getSql("StoveHelper.getPlanZyRclM");
		} else if (processCode.equals("G")) {
			sql = CoreXmlSqlParsersFactory.getSql("StoveHelper.getPlanZyJgxM");
		} else if (processCode.equals("H")) {
			sql = CoreXmlSqlParsersFactory.getSql("StoveHelper.getPlanZyZgJgM");
		}
		sql += " AND T.HEAT_PLAN_NO = ?";
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, heatPlanNo);
		ResultSet rs = ps.executeQuery();
		T t = EntityTool.getEntityByRs(rs, cls);
		rs.close();
		ps.close();
		return t;
	}

	/**
	 * 序号自增减
	 * 
	 * @param con
	 * @param plineCode
	 * @param gxProSeqB
	 * @param gxProSeqE
	 *            (如果没有上限，请设为负数)
	 * @param num
	 * @param processCode
	 * @throws SQLException
	 */
	public void seqIncreaseZy(Connection con, String plineCode, int gxProSeqB,
			int gxProSeqE, int num, String processCode) throws SQLException {
		String sql = "";
		if (processCode.equals("C")) {
			sql = "update PLN_ZY_DZ_M T ";
		} else if (processCode.equals("D")) {
			sql = "update  PLN_ZY_ZG_M T ";
		} else if (processCode.equals("E")) {
			sql = "update  PLN_ZY_DBK_M T ";
		} else if (processCode.equals("F")) {
			sql = "update  PLN_ZY_RCL_M_S T ";
		} else if (processCode.equals("G")) {
			sql = "update PLN_ZY_JGX_M T";
		}

		sql += " SET T.GX_PRO_SEQ = T.GX_PRO_SEQ + TO_NUMBER(?) WHERE T.PLINE_CODE = ? AND T.GX_PRO_SEQ >= TO_NUMBER(?)";
		if (gxProSeqE > 0) {
			sql += "  AND T.GX_PRO_SEQ < TO_NUMBER(?) ";
		}
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, num);
		ps.setObject(2, plineCode);
		ps.setObject(3, gxProSeqB);
		if (gxProSeqE > 0) {
			ps.setObject(4, gxProSeqE);
		}
		ps.executeUpdate();
		ps.close();
	}

	/**
	 * 修改虚拟炉计划
	 * 
	 * @param con
	 * @param
	 * @throws SQLException
	 */
	public void updatePlanOrderZy(Connection con, ProducEntityZyM proEntity,
			String processCode, String proMonth) throws SQLException {
		String sql = "";
		if (processCode.equals("C")) {
			// sql = CoreXmlSqlParsersFactory
			// .getSql("ProducHelperBean.updatePlanOrderC");
			// PlnOrderDzSEntity entity = (PlnOrderDzSEntity) proEntity
			// .getObjEntity();
			// entity.setPlineCode(proEntity.getPlineCode());
			// entity.setPlineName(proEntity.getPlineName());
			// entity.setGxProSeq(String.valueOf(proEntity.getGxProSeq()));
			// entity.setProMonth(proMonth);
			// sql = EntityTool.fillSqlByEntity(sql, entity);
		} else if (processCode.equals("D")) {
			sql = CoreXmlSqlParsersFactory
					.getSql("StoveHelper.updatePlanZyZgM");
			PlnZyZgMEntity entity = (PlnZyZgMEntity) proEntity.getObjEntity();
			entity.setPlineCode(proEntity.getPlineCode());
			entity.setPlineName(proEntity.getPlineName());
			entity.setGxProSeq(String.valueOf(proEntity.getGxProSeq()));
			entity.setProMonth(proMonth);
			entity.setHeatPlanNo(proEntity.getHeatPlanNo());
			sql = EntityTool.fillSqlByEntity(sql, entity);
		} else if (processCode.equals("E")) {
			// sql = CoreXmlSqlParsersFactory
			// .getSql("ProducHelperBean.updatePlanOrderE");
			// PlnOrderDbkSEntity entity = (PlnOrderDbkSEntity) proEntity
			// .getObjEntity();
			// entity.setPlineCode(proEntity.getPlineCode());
			// entity.setPlineName(proEntity.getPlineName());
			// entity.setGxProSeq(String.valueOf(proEntity.getGxProSeq()));
			// entity.setProMonth(proMonth);
			// sql = EntityTool.fillSqlByEntity(sql, entity);
		} else if (processCode.equals("F")) {
			// sql = CoreXmlSqlParsersFactory
			// .getSql("ProducHelperBean.updatePlanOrderF");
			// PlnOrderRclSEntity entity = (PlnOrderRclSEntity) proEntity
			// .getObjEntity();
			// entity.setPlineCode(proEntity.getPlineCode());
			// entity.setPlineName(proEntity.getPlineName());
			//
			// entity.setGxProSeq(String.valueOf(proEntity.getGxProSeq()));
			//
			// entity.setProMonth(proMonth);
			// sql = EntityTool.fillSqlByEntity(sql, entity);
		} else if (processCode.equals("G")) {
			// sql = CoreXmlSqlParsersFactory
			// .getSql("ProducHelperBean.updatePlanOrderG");
			// PlnOrderJgxSEntity entity = (PlnOrderJgxSEntity) proEntity
			// .getObjEntity();
			// entity.setPlineCode(proEntity.getPlineCode());
			// entity.setPlineName(proEntity.getPlineName());
			// entity.setGxProSeq(String.valueOf(proEntity.getGxProSeq()));
			// entity.setProMonth(proMonth);
			// sql = EntityTool.fillSqlByEntity(sql, entity);
		} else if (processCode.equals("H")) {
			// sql = CoreXmlSqlParsersFactory
			// .getSql("ProducHelperBean.updatePlanOrderH");
			// PlnGxJgPropSEntity entity = (PlnGxJgPropSEntity) proEntity
			// .getObjEntity();
			// entity.setPlineCode(proEntity.getPlineCode());
			// entity.setPlineName(proEntity.getPlineName());
			// entity.setProMonth(proMonth);
			// sql = EntityTool.fillSqlByEntity(sql, entity);
		}
		PreparedStatement ps = con.prepareStatement(sql);
		ps.executeUpdate();
		ps.close();
	}

	/**
	 * 查询虚拟炉计划
	 * 
	 * @param con
	 * @param
	 *
	 * @param
	 *
	 * @return PlnOrderCastSEntity
	 * @throws SQLException
	 */
	public static List<PlnZyZgMEntity> getPlanOrderZyM(Connection con,
			String heatPlanNo, String processCode) throws SQLException {
		String sql = "";
		sql = CoreXmlSqlParsersFactory.getSql("StoveHelper.getPlanZyMD");
		sql += " AND T.HEAT_PLAN_NO = ?";
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, heatPlanNo);
		ResultSet rs = ps.executeQuery();
		List<PlnZyZgMEntity> list = EntityTool.getEntitysByRs(rs,
				PlnZyZgMEntity.class);
		ps.close();
		rs.close();
		if (list == null || list.size() == 0) {
			return null;
		} else {
			for (PlnZyZgMEntity listL : list) {
				QualityDesignTool.nullConverNullString(listL);
			}
			return list;
		}
	}

	/**
	 * 所属权限
	 * 
	 * @param validDataPurviewIds
	 *            数据权限
	 * @return CoreReturnObject
	 */
	public CoreReturnObject getSalgPermissions(String[] validDataPurviewIds) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("StoveHelper.getSalgPermissions");
		sql += CoreConverter.toSqlConditionString("T.DEPARTID",
				validDataPurviewIds);
		sql += " ORDER BY T.DEPARTID,T.DEPARTNAME";
		return this.getData(sql);
	}

	/**
	 * 通过轧管订单号找炉计划
	 * 
	 * @param con
	 * @param
	 *
	 * @throws SQLException
	 */
	public static List<PlnZyZgMEntity> getQureyZyZgM(Connection con,
			String proPlanId, String gxPlanNo) throws SQLException {
		String sql = CoreXmlSqlParsersFactory
				.getSql("StoveHelper.getPlanZyZgM");
		sql += " AND T.PRO_PLAN_ID = ?";
		sql += " AND T.GX_PLAN_NO = ?";
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, proPlanId);
		ps.setObject(2, gxPlanNo);
		ResultSet rs = ps.executeQuery();
		List<PlnZyZgMEntity> list = EntityTool.getEntitysByRs(rs,
				PlnZyZgMEntity.class);
		ps.close();
		rs.close();
		if (list == null || list.size() == 0) {
			return null;
		} else {
			for (PlnZyZgMEntity listL : list) {
				QualityDesignTool.nullConverNullString(listL);
			}
			return list;
		}
	}

	/**
	 * 通过轧管订单号找炉计划
	 * 
	 * @param con
	 * @param
	 *
	 * @throws SQLException
	 */
	public static List<PlnZyZgCEntity> getQureyZyZgC(Connection con,
			String heatPlanNo) throws SQLException {
		String sql = CoreXmlSqlParsersFactory
				.getSql("StoveHelper.getPlanZyZgC");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, heatPlanNo);
		ResultSet rs = ps.executeQuery();
		List<PlnZyZgCEntity> list = EntityTool.getEntitysByRs(rs,
				PlnZyZgCEntity.class);
		ps.close();
		rs.close();
		if (list == null || list.size() == 0) {
			return null;
		} else {
			for (PlnZyZgCEntity listL : list) {
				QualityDesignTool.nullConverNullString(listL);
			}
			return list;
		}
	}

	/**
	 * 根据库存钢种，轧管订单查询投入产出
	 * 
	 * @param con
	 * @throws SQLException
	 */
	public static String[] getQueryMateratBom(Connection con, String gradename,
			String inwlDesc, String diameterGp, String proPlanId,
			String gxPlanNo) throws SQLException {
		String[] param = new String[8];
		String sql = CoreXmlSqlParsersFactory
				.getSql("StoveHelper.queryMrialBom");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, gradename);
		ps.setObject(2, inwlDesc);
		ps.setObject(3, diameterGp);
		// ps.setObject(4, diameterGp);
		ps.setObject(4, proPlanId);
		ps.setObject(5, gxPlanNo);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			param[0] = rs.getString("D_IN_MATERIAL_NO");
			param[1] = rs.getString("D_IN_MATERIAL_DESC");
			param[2] = rs.getString("D_OUT_MATERIAL_NO");
			param[3] = rs.getString("D_OUT_MATERIAL_DESC");
			param[4] = rs.getString("BOM");
			param[5] = rs.getString("MSC");
			param[6] = rs.getString("MSC_PLINE");
			param[7] = rs.getString("SPEC_NAME_R");
		}
		rs.close();
		ps.close();
		return param;
	}

	/**
	 * 查询是否有本工序成品成分点
	 * 
	 * @param con
	 * @throws SQLException
	 */
	public static int getQueryStation(Connection con, String proPlanId,
			String gxPlanNo, String proessCode) throws SQLException {
		int param = 0;
		String sql = "";
		if (proessCode.equals("D")) {
			sql = CoreXmlSqlParsersFactory.getSql("StoveHelper.queryStationD");
		} else if (proessCode.equals("E")) {
			sql = CoreXmlSqlParsersFactory.getSql("StoveHelper.queryStationE");
		} else if (proessCode.equals("F")) {
			sql = CoreXmlSqlParsersFactory.getSql("StoveHelper.queryStationF");
		} else if (proessCode.equals("G")) {
			sql = CoreXmlSqlParsersFactory.getSql("StoveHelper.queryStationG");
		}
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, proPlanId);
		ps.setObject(2, gxPlanNo);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			param = rs.getInt("COUNT");
		}
		rs.close();
		ps.close();
		return param;
	}

	/**
	 * 轧管炉计划下发
	 * 
	 * @param
	 * @param userName
	 *            操作人
	 * @return
	 * @throws ParseException
	 * @throws SQLException
	 */
	public static String updateMilPlan(String proPlanId, String gxPlanNo,
			String userName, String userTime, String flag, Connection conn,
			String zyBatchId, String plineCode/*,Connection tmsCon*/) throws ParseException,
			SQLException {
		String messMemo = "";
		PreparedStatement ps = null;
		ResultSet rs = null;
		SimpleDateFormat dFormat = new SimpleDateFormat("yyyyMMdd");
		List<String> juList = new ArrayList<String>();
		List<PlnZyZgMEntity> listZgM = getQureyZyZgM(conn, proPlanId, gxPlanNo);
		if (listZgM == null) {
			// messMemo = "未找到该轧管订单对应炉计划信息!";
			return messMemo;
		}
		PlnOrderZgSEntity plnOrderS = FrmPlanMaterialSelection.getPlanOrderZg(
				conn, proPlanId, gxPlanNo, PlnOrderZgSEntity.class);
		if (plnOrderS == null) {
			messMemo = "未找到订单(" + proPlanId + "/" + gxPlanNo + ")信息!";
			return messMemo;
		}
		String planstatus = "";
		String gowhereName = "";
		String gowhereCode = "";
		String ifProduct = "0";
		if (flag.equals("0")) {
			// 末工序获取去向
			String gowWhere = ComPlanFurnace.getPlineCodeGroup(conn, plineCode,
					proPlanId, gxPlanNo);
			if (gowWhere != null) {

				// 查询去向
				String sqlGroup = "SELECT T.STORAGE_NO,T.STORAGE_NAME FROM COM_BASE_PLINE_R_GROUP T WHERE T.PLINE_CODE_M=? AND T.PLINE_NAME_C=?";
				ps = conn.prepareStatement(sqlGroup);
				ps.setObject(1, plineCode);
				ps.setObject(2, gowWhere);
				rs = ps.executeQuery();
				if (rs.next()) {
					gowhereName = rs.getString("STORAGE_NAME");
					gowhereCode = rs.getString("STORAGE_NO");
				}
				rs.close();
				ps.close();
			}
			int counnum = getQueryStation(conn, proPlanId, gxPlanNo, "D");
			if (counnum > 0) {
				ifProduct = "1";
			}
		}



		// 循环虚拟炉计划信息
		for (PlnZyZgMEntity plnZgC : listZgM) {
			if (plnZgC.getJudgeStoveNo().equals("")) {
				messMemo = "炼钢计划未下发,轧管订单不能下发";
				return messMemo;
			}
			String judgeStoveNo = plnZgC.getJudgeStoveNo();
			String heatPlanNo = plnZgC.getHeatPlanNo();
			// 查询是否有对应实际炉计划
			List<PlnZyZgCEntity> listZgC = getQureyZyZgC(conn, heatPlanNo);
			if (flag.equals("1")) {// 撤销下发
				if (plnZgC.getPlanstatus().equals("20")) {
					messMemo = "判定炉号(" + plnZgC.getFeedHeatNo()
							+ ")已是生产中,不能撤销下发!";
					return messMemo;
				}
				if (plnZgC.getPlanstatus().equals("30")) {
					messMemo = "判定炉号(" + plnZgC.getFeedHeatNo()
							+ ")已是生产完成,不能撤销下发!";
					return messMemo;
				}
				if (plnZgC.getPlanstatus().equals("40")) {
					messMemo = "判定炉号(" + plnZgC.getFeedHeatNo()
							+ ")已是关闭,不能撤销下发!";
					return messMemo;
				}
				planstatus = "00";
				// 查询炉次接收表状态
				String queryMilPln = "SELECT T.STATUS,T.IS_LOAD FROM MIL_PLAN T WHERE T.ID=?";
				ps = conn.prepareStatement(queryMilPln);
				ps.setObject(1, heatPlanNo);
				// ps.setObject(2, proPlanId + "-" + gxPlanNo);
				// ps.setObject(3, plnZgC.getFeedHeatNo() + "-" + "01");
				rs = ps.executeQuery();
				if (rs.next()) {
					if (!rs.getString("STATUS").equals("00")) {
						messMemo = "判定炉号(" + plnZgC.getFeedHeatNo()
								+ ")该炉已开始锯切,不能撤销!";
						return messMemo;
					}
					if (rs.getString("IS_LOAD").equals("1")) {
						messMemo = "判定炉号(" + plnZgC.getFeedHeatNo()
								+ ")该炉已上料,不能撤销!";
						return messMemo;
					}
				}
				rs.close();
				ps.close();

				// 删除炉计划接收表
				String deleteSqlPln = "DELETE MIL_PLAN T WHERE T.ID=?";
				ps = conn.prepareStatement(deleteSqlPln);
				ps.setObject(1, heatPlanNo);
				// ps.setObject(2, proPlanId + "-" + gxPlanNo);
				// ps.setObject(3, plnZgC.getFeedHeatNo() + "-" + "01");
				ps.executeUpdate();
				ps.close();
				if (listZgC != null) {
					for (PlnZyZgCEntity plnC : listZgC) {
						// 删除炉计划接收表
						String deleteSqlPls = "DELETE MIL_FEED_PLAN  WHERE FEED_ROW_NO = ?";
						ps = conn.prepareStatement(deleteSqlPls);
						ps.setObject(1, plnC.getHeatPlanSqe());
						// ps.setObject(2, plnC.getFeedHeatNo() + "-" + "01");
						ps.executeUpdate();
						ps.close();


						String selectMatNoSql = CoreXmlSqlParsersFactory.getSql("StoveHelper.selectMatNo");
						selectMatNoSql = EntityTool.fillSqlByEntity(selectMatNoSql,plnC);
						ps = conn.prepareStatement(selectMatNoSql);
						rs = ps.executeQuery();
						List<MatGpMEntity> matGpList = EntityTool.getEntitysByRs(rs,MatGpMEntity.class);
						rs.close();
						ps.close();

						for(MatGpMEntity mat : matGpList)
						{

							MatGpMEntity m = new MatGpMEntity();

							if(mat.getIsSetfoot().equals("1"))
							{
								m.setMatNoOld(mat.getMatNoOld());
							}else
							{
								m.setMatNoOld(mat.getMatNo());
							}
								m.setSetfootSeq(mat.getSetfootSeq());
							    String selectMatSql = CoreXmlSqlParsersFactory.getSql("StoveHelper.selecMatPlanStausCancel");//查询小于该套尺顺序号炉计划状态
								selectMatSql = EntityTool.fillSqlByEntity(selectMatSql,m);
								ps = conn.prepareStatement(selectMatSql);
								rs = ps.executeQuery();
								List<MatGpMEntity> matEntity = EntityTool.getEntitysByRs(rs,MatGpMEntity.class);
								rs.close();
								ps.close();
								for(MatGpMEntity str : matEntity)
								{
									if(!str.getPlanstatus().equals("00"))
									{
										messMemo = "此订单下套尺坯之后套尺的炉计划还未撤销下发，请依套尺倒序撤销炉计划下发!";
										return messMemo;
									}
								}
						}


					}
				}
			} else {
				// 判断炼钢判定炉号是否重复下发
				int countZm = 0;
				String queryMjud = CoreXmlSqlParsersFactory
						.getSql("FrmPlanStoveD.QueryPlnZYStatus");
				ps = conn.prepareStatement(queryMjud);
				ps.setObject(1, plnZgC.getProPlanId());
				ps.setObject(2, plnZgC.getGxPlanNo());
				ps.setObject(3, plnZgC.getJudgeStoveNo());
				rs = ps.executeQuery();
				if (rs.next()) {
					if (!rs.getString("PLANSTATUS").equals("00")) {
						countZm = rs.getInt("COUNT");
						messMemo = "轧管订单(" + proPlanId + "/" + gxPlanNo
								+ ")对应上料炉号(" + plnZgC.getJudgeStoveNo()
								+ ")已下发,请先撤销该炉下发!";
						return messMemo;
					}
				}
				rs.close();
				ps.close();
				if (countZm > 0) {
					messMemo = "炼钢上料炉号在同一轧管订单/排产序号下存在多个,请确认!";
					return messMemo;
				}
				int countGz = 0;
				String gradenameM = "";
				// 查询轧管订单对应钢种
				String sqlZgS = "SELECT T.GRADENAME FROM PLN_ZY_ZG_M T WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?";
				ps = conn.prepareStatement(sqlZgS);
				ps.setObject(1, plnZgC.getProPlanId());
				ps.setObject(2, plnZgC.getGxPlanNo());
				rs = ps.executeQuery();
				while (rs.next()) {
					if (gradenameM.equals("")) {
						gradenameM = rs.getString("GRADENAME");
					}
					if (!gradenameM.equals(rs.getString("GRADENAME"))) {
						countGz++;
					}
				}
				rs.close();
				ps.close();
				if (countGz > 0) {
					messMemo = "轧管订单(" + plnZgC.getProPlanId() + "/"
							+ plnZgC.getGxPlanNo() + ")对应上料炉号("
							+ plnZgC.getJudgeStoveNo() + ")钢种不同,请先拆分轧管订单!";
					return messMemo;
				}

				planstatus = "10";
				String feedHeatNo = plnZgC.getFeedHeatNo();
				if (feedHeatNo.equals("")) {
					String feedMax = "";
					PreparedStatement psU = null;
					int m = 0;
					int backM = 0;//回炉坯
					if(plnZgC.getPlineCode().equals("C072"))//天淮508机组生成判定炉号
					{

						backM = queryMatBackFlag(conn,plnZgC);
						if(backM > 0)//装炉材料信息存在回炉坯
						{
							feedMax = queryMaxJudgeNo(conn,plnZgC.getPlineCode(),"D");
						}
						else
						{
							m = queryZyMCount(conn,plnZgC.getJudgeStoveNo(),plnZgC.getPlineCode(),plnZgC.getHeatPlanNo());//判断虚拟炉计划中是否已用
							if(m > 0 || Pattern.compile("^[-\\+]?[\\d]*$").matcher(plnZgC.getJudgeStoveNo()).matches())
							{
								feedMax = queryMaxJudgeNo(conn,plnZgC.getPlineCode(),"C");
							}else
							{
								if(plnZgC.getJudgeStoveNo().length() == 6)//天管自炼坯
								{
									feedMax = queryMaxJudgeNo(conn,plnZgC.getPlineCode(),"B");
								}
								else
								{
									feedMax = plnZgC.getJudgeStoveNo();
								}
							}
						}


					}else//本部轧制机组生成判断炉号
					{
						juList.add(judgeStoveNo);
						String maxFeed = "";
						String sqljend = "2000";//2023年轧管系统用分炉坯:232000~239999
						//2022年分炉炉号
						/*if(plnZgC.getPlineCode().equals("C008")){
							sqljend = "4000";//250机组分炉炉号范围224000－225999
						}else if(plnZgC.getPlineCode().equals("C009")){
							sqljend = "6000";//258机组分炉炉号范围226000－227999
						}else if(plnZgC.getPlineCode().equals("C010")){
							sqljend = "7500";//168机组分炉炉号范围222000－223999,7500借500个炉号
						}else if(plnZgC.getPlineCode().equals("C017")){
							sqljend = "8000";//460机组分炉炉号范围228000－229999
						}else{
							sqljend = "0000";
						}*/
						
						String sqlj = "SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.SORTCODE='5007'";
						ps = conn.prepareStatement(sqlj);
						rs = ps.executeQuery();
						if (rs.next()) {
							maxFeed = rs.getString("BASENAME") + sqljend;
						} else {
							messMemo = "轧管起始判定炉号不能为空！";
							return messMemo;
						}
						rs.close();
						ps.close();
						int feedMaxNum = Integer.parseInt(maxFeed);
						// 查询当前所要用的上料炉号280000-289999区间最大
						String judMatQ = CoreXmlSqlParsersFactory
								.getSql("FrmPlanStoveD.QueryfeedJut");
						ps = conn.prepareStatement(judMatQ);
						ps.setObject(1, maxFeed);
						ps.setObject(2, maxFeed.substring(0, 2));
						//ps.setObject(3, plnZgC.getPlineCode());
						ps.setObject(3, maxFeed.substring(0, 2));
						rs = ps.executeQuery();
						if (rs.next()) {
							feedMaxNum = rs.getInt("FEED_HEAT_NO");
						}
						rs.close();
						ps.close();
						List<String> listFeed1 = new ArrayList<String>();
						for (int j = Integer.parseInt(maxFeed); j <= feedMaxNum; j++) {
							listFeed1.add(String.valueOf(j));
						}
						List<String> listFeed2 = new ArrayList<String>();
						// 查询已用上料炉号数组
						judMatQ = CoreXmlSqlParsersFactory
								.getSql("FrmPlanStoveD.QueryFeedAll");
						ps = conn.prepareStatement(judMatQ);
						ps.setObject(1, maxFeed.substring(0, 2));
						ps.setObject(2, judgeStoveNo);
						ps.setObject(3, maxFeed.substring(0, 2));
						ps.setObject(4, judgeStoveNo);
						rs = ps.executeQuery();
						while (rs.next()) {
							listFeed2.add(rs.getString("FEED_HEAT_NO"));
						}
						rs.close();
						ps.close();

						// 下发时生成上料炉号
						int countSlcod = 0;
						// 1.查询该炉是否存在多个订单
						String sqlJueCount = CoreXmlSqlParsersFactory
								.getSql("FrmPlanStoveD.QueryHeatPlanNo");
						ps = conn.prepareStatement(sqlJueCount);
						ps.setObject(1, judgeStoveNo);
						ps.setObject(2, judgeStoveNo);
						rs = ps.executeQuery();
						while (rs.next()) {
							// 判定是否存在 上料炉号
							String fesNo = rs.getString("FEED_HEAT_NO");
							if (fesNo != null && fesNo.equals(judgeStoveNo)) {
								countSlcod++;
								break;
							}
						}
						rs.close();
						ps.close();



						if (countSlcod == 0) {
							feedMax = judgeStoveNo;
						} else {
							List<String> listMap = FrmPlanStoveD.compareArry(
									listFeed1, listFeed2);
							if (null != listMap && listMap.size() > 0) {
								feedMaxNum = Integer.parseInt(listMap.get(0));
							}
							// 查询当前所要用的上料炉号280000-289999区间最大
							feedMax = String.valueOf(feedMaxNum);
							listFeed2.add(String.valueOf(feedMaxNum));
							feedMaxNum++;
						}
					}

					// 修改轧管炉计划上料炉号
					String update = "UPDATE PLN_ZY_ZG_M T SET T.FEED_HEAT_NO=? WHERE T.HEAT_PLAN_NO=?";
					psU = conn.prepareStatement(update);
					psU.setObject(1, feedMax);
					psU.setObject(2, heatPlanNo);
					psU.executeUpdate();
					psU.close();
					// 修改轧管实际炉计划上料炉号
					update = "UPDATE PLN_ZY_ZG_C T SET T.FEED_HEAT_NO=? WHERE T.HEAT_PLAN_NO=?";
					psU = conn.prepareStatement(update);
					psU.setObject(1, feedMax);
					psU.setObject(2, heatPlanNo);
					psU.executeUpdate();
					psU.close();

					feedHeatNo = feedMax;
				}
				// 查询判定是否已生成接收表信息
				String sqlMil = "SELECT COUNT(*) COUNT FROM MIL_PLAN T WHERE T.JUDGE_STOVE_NO=(SELECT T1.FEED_HEAT_NO||'-01' FROM PLN_ZY_ZG_M T1 WHERE T1.HEAT_PLAN_NO=?)";
				ps = conn.prepareStatement(sqlMil);
				ps.setObject(1, plnZgC.getHeatPlanNo());
				rs = ps.executeQuery();
				if (rs.next()) {
					if (rs.getInt("COUNT") > 0) {
						messMemo = "该轧管判定炉号:" + feedHeatNo + ",已生成装炉信息!";
						return messMemo;
					}
				}
				rs.close();
				ps.close();
				String feedSeq = FrmPlanStoveD.getMaxFeedSeq(conn,
						dFormat.format(dFormat.parse(userTime)),
						plnZgC.getPlineCode());
				String lotSeq = FrmPlanStoveD.getMaxLotSeq(conn, proPlanId
						+ "-" + gxPlanNo, zyBatchId);
				MilPlanEntity milPln = new MilPlanEntity();
				milPln.setPrdcrNo(plnZgC.getPrdcrNo());
				milPln.setIfMonitor(plnZgC.getIfMonitor());
				milPln.setIfProduct(ifProduct);
				milPln.setCraftSeq(plnOrderS.getCraftSeq());
				milPln.setCic(plnZgC.getCic());
				milPln.setIndexSeq(plnOrderS.getIndexSeq());
				milPln.setPic(plnZgC.getPic());
				milPln.setId(plnZgC.getHeatPlanNo());
				milPln.setSeq(proPlanId + "-" + gxPlanNo);
				milPln.setStoveNo(plnZgC.getStoveNo());
				milPln.setJudgeStoveNo(feedHeatNo + "-" + "01");
				milPln.setLotNo(zyBatchId);
				milPln.setContractNo(plnZgC.getOrderNo() + "/"
						+ plnZgC.getOrderSeq());
				milPln.setImpProcess(plnOrderS.getCraftFileNo());
				milPln.setPlineCode(plnZgC.getPlineCode());
				milPln.setProducer(plnZgC.getMonitordemand());
				milPln.setProcessStatus(plnZgC.getProcessDescC());
				milPln.setDbLength(plnZgC.getLenGpSingle());
				milPln.setDbHeight(plnZgC.getWtGpSingle());
				milPln.setRollLength(plnZgC.getRollLength());
				milPln.setSawNum(plnZgC.getOutnumCut());
				milPln.setTargetLength(plnZgC.getAimlength());
				milPln.setFinishUser(plnZgC.getFinalUserDesc());
				milPln.setTargetLiabrary(gowhereName);
				milPln.setVarieties(plnZgC.getProducname());
				milPln.setVarietiesCode(plnZgC.getProduccode());
				String outdiameZg = new BigDecimal(plnZgC.getOutdiameterZg())
						.setScale(2, RoundingMode.HALF_UP).toString();
				String wallthZg = new BigDecimal(plnZgC.getWallthickZg())
						.setScale(2, RoundingMode.HALF_UP).toString();
				milPln.setPipeSize(outdiameZg + "*" + wallthZg);
				// milPln.setPipeSize(plnZgC.getSpecName());
				String sql = "SELECT T.SPEC_CODE  FROM COM_BASE_SPEC t WHERE T.SPEC_NAME=? AND T.VALIDFLAG='1'";
				ps = conn.prepareStatement(sql);
				ps.setObject(1, outdiameZg + "x" + wallthZg);
				rs = ps.executeQuery();
				if (rs.next()) {
					milPln.setPipeSizeCode(rs.getString("SPEC_CODE"));
				}
				rs.close();
				ps.close();
				milPln.setBuckleType(plnZgC.getModelDesc());
				milPln.setBuckleTypeCode(plnZgC.getModelCode());
				milPln.setLengthRange(plnZgC.getLenRollMin() + "-"
						+ plnZgC.getLenRollMax());
				milPln.setRollStandrad(plnZgC.getStdName());
				milPln.setPipeSection(plnZgC.getDiameter());
				milPln.setSteelcode(plnZgC.getSteelcode());
				milPln.setSteelname(plnZgC.getSteelname());
				milPln.setGradecode(plnZgC.getGradecode());
				milPln.setGradename(plnZgC.getGradename());
				String steelStandrad = "";
				if (ifProduct.equals("1")) {
					steelStandrad = plnZgC.getCic() + "+" + plnZgC.getPic()
							+ "+" + plnZgC.getSic() + "+" + plnZgC.getDic();
				} else {
					steelStandrad = plnZgC.getPic() + "+" + plnZgC.getSic()
							+ "+" + plnZgC.getDic();
				}
				if (steelStandrad.replace("+", "").equals("")) {
					steelStandrad = plnZgC.getCraftFileNo();
				}
				milPln.setSteelStandrad(steelStandrad);
				milPln.setTarget(plnZgC.getDecision());
				milPln.setBranch(plnZgC.getPlnInsingleNum());
				milPln.setTon(plnZgC.getPlnInsingleWt());
				milPln.setDbNum(plnZgC.getPlnInsingleNum());
				milPln.setTom(userTime);
				milPln.setCutHeadLengthp(plnZgC.getLenCuthead());
				milPln.setCutTrailLengthp(plnZgC.getLenCutend());
				milPln.setControlThickp(plnZgC.getAimwallthick());
				milPln.setProduceStandrad(plnZgC.getOutputStandard());
				milPln.setFeedSeq(feedSeq);
				milPln.setLotSeq(lotSeq);
				milPln.setFeedHeatNo(judgeStoveNo);
				milPln.setLengthcp(plnZgC.getLengthdisc());
				milPln.setCodeSampleFlag("0");
				milPln.setRollStandradCode(plnZgC.getStdCode());
				milPln.setStdStyle(plnZgC.getStdStyle());
				milPln.setStdStyleDesc(plnZgC.getStdStyleDesc());
				milPln.setCheckNo("");
				milPln.setOrdLnDlyPk(plnZgC.getOrdLnDlyPk() + "-"
						+ plnZgC.getPlnDivideId());
				if (plnZgC.getDecision().contains("A")) {
					milPln.setPrtFlag("1");
				} else {
					milPln.setPrtFlag("0");
				}
				milPln.setProPlanId(proPlanId);
				milPln.setGxPlanNo(gxPlanNo);
				String gpType = "铸坯";
				if (plnZgC.getGptype().equals("2")) {
					gpType = "锻坯";
				}
				milPln.setTubeType(gpType);
				String tubSour = "自炼";
				if (plnZgC.getOutsBilletFl().equals("1")) {
					tubSour = "外购";
				}
				milPln.setTubeSuorce(tubSour);
				milPln.setType(plnZgC.getPlnType());
				milPln.setStatus("00");
				milPln.setNodeStatus("00");
				// 新增炉计划接收表
				String addSqlPln = EntityTool.fillSqlByEntity(
						CoreXmlSqlParsersFactory
								.getSql("FrmPlanStoveD.AddMilPlan"), milPln);
				ps = conn.prepareStatement(addSqlPln);
				ps.executeUpdate();
				ps.close();


				if (listZgC != null) {
					for (PlnZyZgCEntity plnC : listZgC) {// 存在实际炉计划新增上料行

						String selectMatNoSql = CoreXmlSqlParsersFactory.getSql("StoveHelper.selectMatNo");
						selectMatNoSql = EntityTool.fillSqlByEntity(selectMatNoSql,plnC);
						ps = conn.prepareStatement(selectMatNoSql);
						rs = ps.executeQuery();
						List<MatGpMEntity> matGpList = EntityTool.getEntitysByRs(rs,MatGpMEntity.class);
						rs.close();
						ps.close();

						for(MatGpMEntity mat : matGpList)
						{
							if(mat.getIsSetfoot().equals("1"))//是套尺坯
							{
								MatGpMEntity m = new MatGpMEntity();
								m.setMatNo(mat.getMatNo());
								m.setMatNoOld(mat.getMatNoOld());
								m.setSetfootSeq(mat.getSetfootSeq());
								String selectMatSql = CoreXmlSqlParsersFactory.getSql("StoveHelper.selecMatPlanStaus");//查询小于该套尺顺序号炉计划状态
								selectMatSql = EntityTool.fillSqlByEntity(selectMatSql,m);
								ps = conn.prepareStatement(selectMatSql);
								rs = ps.executeQuery();
								List<MatGpMEntity> matEntity = EntityTool.getEntitysByRs(rs,MatGpMEntity.class);
								rs.close();
								ps.close();
								for(MatGpMEntity str : matEntity)
								{
									if(str.getPlanstatus().equals("00"))
									{
										messMemo = "此订单下套尺坯之前套尺的炉计划还未下发，请依套尺顺序下发炉计划!";
										return messMemo;
									}
								}

							}
						}

						// double feedLength = Double.parseDouble(plnC
						// .getLengthM())
						// + Double.parseDouble(plnC.getCutLength());
						MilFeedPlanEntity milFeed = new MilFeedPlanEntity();
						milFeed.setFeedRowNo(plnC.getHeatPlanSqe());
						milFeed.setSeq("");
						milFeed.setLotNo(zyBatchId);
						milFeed.setStoveNo(plnC.getStoveNo());
						milFeed.setJudgeStoveNo(feedHeatNo + "-" + "01");
						milFeed.setPlineCode(plnZgC.getPlineCode());
						milFeed.setDbNum(plnC.getCutNumGp());
						milFeed.setMatHeight(plnC.getWeightM());
						milFeed.setMatTotalHeight(plnC.getPlanIndoubleWt());
						milFeed.setFeedNum(plnC.getPlanIndoubleNum());
						milFeed.setFeedLength(plnC.getLengthMOld());
						milFeed.setUseLength(plnC.getLengthM());
						milFeed.setCutTarget(plnC.getCutTarget());
						milFeed.setCutLength(plnC.getCutLength());
						milFeed.setCutWeight(plnC.getCutWeight());
						milFeed.setRemark("");
						milFeed.setDbLength(plnC.getLenGpSingle());
						milFeed.setNonUseLength(plnC.getCutLength());
						milFeed.setPipeSection(plnC.getDiameter());
						milFeed.setDbHeight(plnC.getWtGpSingle());
						milFeed.setProPlanId(proPlanId);
						milFeed.setGxPlanNo(gxPlanNo);
						milFeed.setFeedNumPlan(plnC.getPlanIndoubleNum());
						milFeed.setCreateName(userName);
						milFeed.setCreateTime(userTime);
						// 新增上料行表
						String addSqlPls = EntityTool
								.fillSqlByEntity(
										CoreXmlSqlParsersFactory
												.getSql("FrmPlanStoveD.AddMilFeedPlan"),
										milFeed);
						ps = conn.prepareStatement(addSqlPls);
						ps.executeUpdate();
						ps.close();
					}
				}
			}
			// 修改轧管虚拟炉计划
			String deleteZgM = "UPDATE PLN_ZY_ZG_M T SET T.ZY_BATCH_ID =?,T.PLANSTATUS=?,T.GOWHERE_CODE=?,T.GOWHERE_NAME=?,"
					+ " T.DOWNMAN=?,T.DOWNTIME=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),T.CRAFT_FILE_NO=?,T.CRAFT_FILE_MAN=?,"
					+ "T.CRAFT_SEQ=?,T.IF_PRODUCT=?,T. MEMO = ?WHERE T.HEAT_PLAN_NO=?";
			ps = conn.prepareStatement(deleteZgM);
			ps.setObject(1, zyBatchId);
			ps.setObject(2, planstatus);
			ps.setObject(3, gowhereCode);
			ps.setObject(4, gowhereName);
			ps.setObject(5, userName);
			ps.setObject(6, userTime);
			ps.setObject(7, plnOrderS.getCraftFileNo());
			ps.setObject(8, plnOrderS.getCraftFileMan());
			ps.setObject(9, plnOrderS.getCraftSeq());
			ps.setObject(10, ifProduct);
			ps.setObject(11, plnOrderS.getMemo());
			ps.setObject(12, heatPlanNo);
			ps.executeUpdate();
			ps.close();
			// 修改轧管实际炉计划
			deleteZgM = "UPDATE PLN_ZY_ZG_C T SET T.ZY_BATCH_ID=? where T.HEAT_PLAN_NO=?";
			ps = conn.prepareStatement(deleteZgM);
			ps.setObject(1, zyBatchId);
			ps.setObject(2, heatPlanNo);
			ps.executeUpdate();
			ps.close();

		}
		return messMemo;
	}

	/***
	 *判断装炉子表的库存信息是否存在回炉坯
	 * @param conn
	 * @param plnZgC
	 * @return
	 */
	private static int queryMatBackFlag(Connection conn, PlnZyZgMEntity plnZgC) {
		int m = 0;
		PreparedStatement psta = null;
		try {
			String sql = CoreXmlSqlParsersFactory.getSql("FrmPlanStoveD.queryMatBackFlag");
			sql = EntityTool.fillSqlByEntity(sql,plnZgC);
			psta = conn.prepareStatement(sql);
			ResultSet rs = psta.executeQuery();
			if(rs.next())
			{
				m = Integer.parseInt(rs.getString("ACOUNT"));
			}
			rs.close();
			psta.close();
		} catch (SQLException e) {

			e.printStackTrace();
		}
		return m;
	}


	/***
	 * 查询上料炉号是否已生成虚拟炉计划
	 * @param conn
	 * @param judgeStoveNo
	 * @param plineCode
	 * @return
	 */
	private static int queryZyMCount(Connection conn, String judgeStoveNo, String plineCode,String heatPlanNo) {
		int m = 0;
		String sql = CoreXmlSqlParsersFactory.getSql("FrmPlanStoveD.queryZyMCount");
		PreparedStatement psta = null;
		try {
			psta = conn.prepareStatement(sql);
			psta.setString(1,judgeStoveNo);
			psta.setString(2,plineCode);
			psta.setString(3,heatPlanNo);
			ResultSet rs = psta.executeQuery();
			if(rs.next())
			{
				m = Integer.parseInt(rs.getString("ACOUNT"));
			}
			rs.close();
			psta.close();
		} catch (SQLException e) {

			e.printStackTrace();
		}
		return m;
	}

	/***
	 * 查询当月最大炉号(B)
	 * @param conn
	 * @return
	 */
	private static String queryMaxJudgeNo(Connection conn,String plineCode,String frist) {
		String judgeNo = "";
		String sql = CoreXmlSqlParsersFactory.getSql("FrmPlanStoveD.queryMaxJudgeNo");
		PreparedStatement psta = null;
		try {
			psta = conn.prepareStatement(sql);
			psta.setString(1,frist);
			psta.setString(2,plineCode);
			psta.setString(3,frist);
			ResultSet rs = psta.executeQuery();
			if(rs.next())
			{
				judgeNo = rs.getString("FEED_HEAT_NO");
			}
			rs.close();
			psta.close();
		} catch (SQLException e) {

			e.printStackTrace();
		}
		return judgeNo;
	}


	/**
	 * 根据订单下发，撤销炉计划热处理
	 * 
	 * @param userName
	 *            操作人
	 */
	public static String updatePlanRcl(String proPlanId, String gxPlanNo,
			String userName, String userTime, String flag, Connection conn,
			String zyBatchId, String plnDivideId, String plineCode)
			throws ParseException, SQLException {
		String messMemo = "";
		PreparedStatement ps = null;
		ResultSet rs = null;
		String sql  = null;
		String planstatus = "";
		String bltype = "";
		// // 查询是否接箍料备料需求
		// String sql =
		// "SELECT T1.BLTYPE FROM PLN_ORDER_RCL_S T ,PLN_PORDER_BL_REQ T1 WHERE T.ORD_LN_DLY_PK=T1.REQ_BL_ID AND T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?";
		// ps = conn.prepareStatement(sql);
		// ps.setObject(1, proPlanId);
		// ps.setObject(2, gxPlanNo);
		// rs = ps.executeQuery();
		// if (rs.next()) {
		// bltype = rs.getString("BLTYPE");
		// }
		// rs.close();
		// ps.close();
		PlnOrderRclSEntity plnOrderS = FrmPlanMaterialDbk.getPlanOrderS(conn,
				proPlanId, gxPlanNo, PlnOrderRclSEntity.class, "F");
		if (plnOrderS == null) {
			messMemo = "未找到订单(" + proPlanId + "/" + gxPlanNo + ")信息!";
			return messMemo;
		}
		String gowhereName = "";
		String gowhereCode = "";
		String ifProduct = "0";
		String designKey = "";
		String delievStateCode = "";
		String delievStateName = "";
		if (flag.equals("0")) {
			// 末工序获取去向
			String gowWhere = corePlanFurnProM.getPlineCodeGroup(conn,
					plineCode, proPlanId, gxPlanNo, "F");
			if (gowWhere != null) {

				// 查询去向
				String sqlGroup = "SELECT T.STORAGE_NO,T.STORAGE_NAME FROM COM_BASE_PLINE_R_GROUP T WHERE T.PLINE_CODE_M=? AND T.PLINE_NAME_C=?";
				ps = conn.prepareStatement(sqlGroup);
				ps.setObject(1, plineCode);
				ps.setObject(2, gowWhere);
				rs = ps.executeQuery();
				if (rs.next()) {
					gowhereName = rs.getString("STORAGE_NAME");
					gowhereCode = rs.getString("STORAGE_NO");
				}
				rs.close();
				ps.close();
			}
			int counnum = getQueryStation(conn, proPlanId, gxPlanNo, "F");
			if (counnum > 0) {
				ifProduct = "1";
			}

		}

		sql = CoreXmlSqlParsersFactory
				.getSql("addPlnFurn.SelectDesignKey");// 查询designkey和mscPline
		ps = conn.prepareStatement(sql);
		ps.setString(1, plnOrderS.getCraftFileNo());
		ps.setString(2, plnOrderS.getCraftSeq());
		rs = ps.executeQuery();
		if (rs.next()) {
			designKey = rs.getString("DESGIN_KEY");
		}
		rs.close();
		ps.close();

		//查询交货状态
		sql = CoreXmlSqlParsersFactory.getSql("addPlnFurn.selectState");
		ps = conn.prepareStatement(sql);
		ps.setString(1,designKey);
		ps.setString(2,plnOrderS.getIndexSeq());
		ps.setString(3,plnOrderS.getDecision());
		rs = ps.executeQuery();
		if(rs.next())
		{
			delievStateCode  = rs.getString("BASECODE");
			delievStateName = rs.getString("BASENAME");
		}
		rs.close();;
		ps.close();

		int countGz = 0;
		String gradenameM = "";
		// 循环虚拟炉计划信息
		String heatPlanNo = "";
		// 查询订单对应炉计划状态
		String sqlDbk = "SELECT  T.GRADENAME,T.PLANSTATUS,T.HEAT_PLAN_NO,T.JUDGE_STOVE_NO,T.FEED_HEAT_NO FROM PLN_ZY_RCL_M T WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?";
		ps = conn.prepareStatement(sqlDbk);
		ps.setObject(1, proPlanId);
		ps.setObject(2, gxPlanNo);
		rs = ps.executeQuery();
		while (rs.next()) {
			String judgeStoveNo = rs.getString("JUDGE_STOVE_NO");
			heatPlanNo = rs.getString("HEAT_PLAN_NO");
			if (flag.equals("1")) {// 撤销下发
				if (rs.getString("PLANSTATUS").equals("20")) {
					messMemo = "判定炉号(" + judgeStoveNo + ")已是生产中,不能撤销下发!";
					return messMemo;
				}
				if (rs.getString("PLANSTATUS").equals("30")) {
					messMemo = "判定炉号(" + judgeStoveNo + ")已是生产完成,不能撤销下发!";
					return messMemo;
				}
				if (rs.getString("PLANSTATUS").equals("40")) {
					messMemo = "判定炉号(" + judgeStoveNo + ")已是关闭,不能撤销下发!";
					return messMemo;
				}
				planstatus = "00";
				// 撤销下工序虚拟炉计划
				String messeGx = PlanFurnProduction.deletePlnFurnJgx(proPlanId,
						gxPlanNo, userName, userTime, heatPlanNo, plnDivideId,
						conn);
				if (!messeGx.equals("")) {
					messMemo = messeGx;
					return messMemo;
				}
			} else {
				if (!rs.getString("PLANSTATUS").equals("00")) {
					continue;
				}
				planstatus = "10";

				if (zyBatchId.equals("")) {
					messMemo = "生产批次不能为空,请确认!";
					return messMemo;
				}

				if (gradenameM.equals("")) {
					gradenameM = rs.getString("GRADENAME");
				}
				if (!gradenameM.equals(rs.getString("GRADENAME"))) {
					countGz++;
				}

				if (countGz > 0) {
					messMemo = "热处理订单(" + plnOrderS.getProPlanId() + "/"
							+ plnOrderS.getGxPlanNo() + ")对应上料炉号("
							+ rs.getString("FEED_HEAT_NO") + ")钢种不同,请先拆分热处理订单!";
					return messMemo;
				}
				if(judgeStoveNo == null || judgeStoveNo.equals(""))//判定炉号为空，证明是天淮内倒的料
				{
					judgeStoveNo = queryMaxJudgeNoWg(conn);
				}

			}

			// 修改虚拟炉计划
			String deleteZgM = "UPDATE PLN_ZY_RCL_M T SET T.ZY_BATCH_ID =?, T.PLANSTATUS=?,T.GOWHERE_CODE=?,T.GOWHERE_NAME=?,"
					+ "T.DOWNMAN=?,T.DOWNTIME=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),T.CRAFT_FILE_NO=?,T.CRAFT_FILE_MAN=?,"
					+ " T.CRAFT_SEQ=?,t.IF_PRODUCT=?,T. JUDGE_STOVE_NO = '"+judgeStoveNo+"',T.FLAG_STOVE_NO = '"+judgeStoveNo+"' WHERE T.HEAT_PLAN_NO=?";
			ps = conn.prepareStatement(deleteZgM);
			ps.setObject(1, zyBatchId);
			ps.setObject(2, planstatus);
			ps.setObject(3, gowhereCode);
			ps.setObject(4, gowhereName);
			ps.setObject(5, userName);
			ps.setObject(6, userTime);
			ps.setObject(7, plnOrderS.getCraftFileNo());
			ps.setObject(8, plnOrderS.getCraftFileMan());
			ps.setObject(9, plnOrderS.getCraftSeq());
			ps.setObject(10, ifProduct);
			ps.setObject(11, heatPlanNo);
			ps.executeUpdate();
			ps.close();
			// 修改实际炉计划
			deleteZgM = "UPDATE PLN_ZY_RCL_C T SET T.ZY_BATCH_ID=?,T. JUDGE_STOVE_NO = '"+judgeStoveNo+"' WHERE T.HEAT_PLAN_NO=?";
			ps = conn.prepareStatement(deleteZgM);
			ps.setObject(1, zyBatchId);
			ps.setObject(2, heatPlanNo);
			ps.executeUpdate();
			ps.close();

			// 新增下工序虚拟炉计划
			String messeGx = PlanFurnProduction.addPlnFurnJgx(proPlanId,
					gxPlanNo, userName, userTime, heatPlanNo, plnDivideId,
					conn,delievStateCode,delievStateName);
			if (!messeGx.equals("")) {
				messMemo = messeGx;
				return messMemo;
			}
		}
		rs.close();
		ps.close();
		return messMemo;
	}

	/***
	 * 天淮内倒至本部，转换本部6位外购炉号
	 * @param con
	 * @param
	 * @return
	 */
	public  static  String queryMaxJudgeNoWg(Connection con) throws SQLException {
		String judegeNo = "";
		String sql  = CoreXmlSqlParsersFactory.getSql("StoveHelper.selectMaxjudgeNo");
		PreparedStatement ps = con.prepareStatement(sql);
		ResultSet rs = ps.executeQuery();
		if(rs.next())
		{
			judegeNo = rs.getString("JUDGE_STOVE_NO");
		}
		rs.close();
		ps.close();
		return judegeNo;

	}

	/**
	 * 根据订单下发，撤销加工线炉计划
	 * 
	 * @param userName
	 *            操作人
	 */
	public static String updatePlanJgx(String proPlanId, String gxPlanNo,
			String userName, String userTime, String flag, Connection conn,
			String zyBatchId, String plnDivideId, String plineCode)
			throws ParseException, SQLException {
		String messMemo = "";
		PreparedStatement ps = null;
		ResultSet rs = null;
		String planstatus = "";
		// 循环虚拟炉计划信息
		String heatPlanNo = "";
		PlnOrderJgxSEntity plnOrderS = FrmPlanMaterialDbk.getPlanOrderS(conn,
				proPlanId, gxPlanNo, PlnOrderJgxSEntity.class, "G");
		if (plnOrderS == null) {
			messMemo = "未找到订单(" + proPlanId + "/" + gxPlanNo + ")信息!";
			return messMemo;
		}
		String gowhereName = "";
		String gowhereCode = "";
		String ifProduct = "0";
		if (flag.equals("0")) {
			String gowWhere = corePlanFurnProM.getPlineCodeGroup(conn,
					plineCode, proPlanId, gxPlanNo, "G");
			if (gowWhere != null) {
				// 查询去向
				String sqlGroup = "SELECT T.STORAGE_NO,T.STORAGE_NAME FROM COM_BASE_PLINE_R_GROUP T WHERE T.PLINE_CODE_M=? AND T.PLINE_NAME_C=?";
				ps = conn.prepareStatement(sqlGroup);
				ps.setObject(1, plineCode);
				ps.setObject(2, gowWhere);
				rs = ps.executeQuery();
				if (rs.next()) {
					gowhereName = rs.getString("STORAGE_NAME");
					gowhereCode = rs.getString("STORAGE_NO");
				}
				rs.close();
				ps.close();
			}
			int counnum = getQueryStation(conn, proPlanId, gxPlanNo, "G");
			if (counnum > 0) {
				ifProduct = "1";
			}
		}
		// 查询订单对应炉计划状态
		String sqlDbk = "SELECT T.PLANSTATUS,T.HEAT_PLAN_NO,T.JUDGE_STOVE_NO,T.OUTWL_DESC FROM PLN_ZY_JGX_M T WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?";
		ps = conn.prepareStatement(sqlDbk);
		ps.setObject(1, proPlanId);
		ps.setObject(2, gxPlanNo);
		rs = ps.executeQuery();
		while (rs.next()) {
			String judgeStoveNo = rs.getString("JUDGE_STOVE_NO");
			heatPlanNo = rs.getString("HEAT_PLAN_NO");
			if (flag.equals("1")) {// 撤销下发
				if (rs.getString("PLANSTATUS").equals("20")) {
					messMemo = "判定炉号(" + judgeStoveNo + ")已是生产中,不能撤销下发!";
					return messMemo;
				}
				if (rs.getString("PLANSTATUS").equals("30")) {
					messMemo = "判定炉号(" + judgeStoveNo + ")已是生产完成,不能撤销下发!";
					return messMemo;
				}
				if (rs.getString("PLANSTATUS").equals("40")) {
					messMemo = "判定炉号(" + judgeStoveNo + ")已是关闭,不能撤销下发!";
					return messMemo;
				}
				planstatus = "00";
				// 撤销下工序虚拟炉计划
				String messeGx = PlanFurnProduction.deletePlnFurnJg(proPlanId,
						gxPlanNo, userName, userTime, heatPlanNo, plnDivideId,
						conn);
				if (!messeGx.equals("")) {
					messMemo = messeGx;
					return messMemo;
				}
			} else {
				if (!rs.getString("PLANSTATUS").equals("00")) {
					continue;
				}
				planstatus = "10";
				if (zyBatchId.equals("")) {
					messMemo = "生产批次不能为空,请确认!";
					return messMemo;
				}
				if(rs.getString("OUTWL_DESC")!=null)
				{

				}else
				{
					messMemo = "判定炉号(" + judgeStoveNo + ")产出物料码为空,不能进行炉计划下发!";
					return messMemo;
				}

				if(judgeStoveNo == null || judgeStoveNo.equals(""))//判定炉号为空，证明是天淮内倒的料
				{
					judgeStoveNo = queryMaxJudgeNoWg(conn);
				}

			}
			// 修改虚拟炉计划
			String deleteZgM = "UPDATE PLN_ZY_JGX_M T SET T.ZY_BATCH_ID =?, T.PLANSTATUS=?,T.GOWHERE_CODE=?,T.GOWHERE_NAME=?,"
					+ "T.DOWNMAN=?,T.DOWNTIME=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),T.CRAFT_FILE_NO=?,T.CRAFT_FILE_MAN=?,"
					+ "T.CRAFT_SEQ=?,t.IF_PRODUCT=?,T.JUDGE_STOVE_NO = '"+judgeStoveNo+"' ,T.FLAG_STOVE_NO = '"+judgeStoveNo+"' WHERE T.HEAT_PLAN_NO=?";
			ps = conn.prepareStatement(deleteZgM);
			ps.setObject(1, zyBatchId);
			ps.setObject(2, planstatus);
			ps.setObject(3, gowhereCode);
			ps.setObject(4, gowhereName);
			ps.setObject(5, userName);
			ps.setObject(6, userTime);
			ps.setObject(7, plnOrderS.getCraftFileNo());
			ps.setObject(8, plnOrderS.getCraftFileMan());
			ps.setObject(9, plnOrderS.getCraftSeq());
			ps.setObject(10, ifProduct);
			ps.setObject(11, heatPlanNo);
			ps.executeUpdate();
			ps.close();
			// 修改实际炉计划
			deleteZgM = "UPDATE PLN_ZY_JGX_C T SET T.ZY_BATCH_ID=?,T.JUDGE_STOVE_NO = '"+judgeStoveNo+"',T.FLAG_STOVE_NO = '"+judgeStoveNo+"' WHERE T.HEAT_PLAN_NO=?";
			ps = conn.prepareStatement(deleteZgM);
			ps.setObject(1, zyBatchId);
			ps.setObject(2, heatPlanNo);
			ps.executeUpdate();
			ps.close();


			// 新增下工序虚拟炉计划
			String messeGx = PlanFurnProduction.addPlnFurnJg(proPlanId,
					gxPlanNo, userName, userTime, heatPlanNo, plnDivideId,
					conn);
			if (!messeGx.equals("")) {
				messMemo = messeGx;
				return messMemo;
			}
		}
		rs.close();
		ps.close();
		return messMemo;
	}

	/**
	 * 根据订单下发，撤销炉计划接箍
	 * 
	 * @param userName
	 *            操作人
	 */
	public static String updatePlanJgM(String proPlanId, String gxPlanNo,
			String userName, String userTime, String flag, Connection conn,
			String zyBatchId, String plnDivideId) throws ParseException,
			SQLException {
		String messMemo = "";
		PreparedStatement ps = null;
		ResultSet rs = null;
		String planstatus = "";
		// 循环虚拟炉计划信息
		String heatPlanNo = "";
		// 查询订单对应炉计划状态
		String sqlDbk = "SELECT T.PLANSTATUS,T.HEAT_PLAN_NO,T.JUDGE_STOVE_NO FROM PLN_ZY_JG_M T WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?";
		ps = conn.prepareStatement(sqlDbk);
		ps.setObject(1, proPlanId);
		ps.setObject(2, gxPlanNo);
		rs = ps.executeQuery();
		while (rs.next()) {
			String judgeStoveNo = rs.getString("JUDGE_STOVE_NO");
			heatPlanNo = rs.getString("HEAT_PLAN_NO");
			if (flag.equals("1")) {// 撤销下发
				if (rs.getString("PLANSTATUS").equals("20")) {
					messMemo = "判定炉号(" + judgeStoveNo + ")已是生产中,不能撤销下发!";
					return messMemo;
				}
				if (rs.getString("PLANSTATUS").equals("30")) {
					messMemo = "判定炉号(" + judgeStoveNo + ")已是生产完成,不能撤销下发!";
					return messMemo;
				}
				if (rs.getString("PLANSTATUS").equals("40")) {
					messMemo = "判定炉号(" + judgeStoveNo + ")已是关闭,不能撤销下发!";
					return messMemo;
				}
				planstatus = "00";
			} else {
				if (!rs.getString("PLANSTATUS").equals("00")) {
					continue;
				}
				planstatus = "10";
				// if(zyBatchId.equals("")){
				// messMemo="生产批次不能为空,请确认!";
				// return messMemo;
				// }

				if(judgeStoveNo == null || judgeStoveNo.equals(""))//判定炉号为空，证明是天淮内倒的料
				{
					judgeStoveNo = queryMaxJudgeNoWg(conn);
				}
			}
			// 修改虚拟炉计划
			String deleteZgM = "UPDATE PLN_ZY_JG_M T SET T.PLANSTATUS=?,T.DOWNMAN=?,T.DOWNTIME=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),T.JUDGE_STOVE_NO = '"+judgeStoveNo+"' ,T.FLAG_STOVE_NO = '"+judgeStoveNo+"'WHERE T.HEAT_PLAN_NO=?";
			ps = conn.prepareStatement(deleteZgM);
			ps.setObject(1, planstatus);
			ps.setObject(2, userName);
			ps.setObject(3, userTime);
			ps.setObject(4, heatPlanNo);
			ps.executeUpdate();
			ps.close();
			// 修改实际炉计划
			 deleteZgM =
			 "UPDATE PLN_ZY_JG_C T SET JUDGE_STOVE_NO = '"+judgeStoveNo+"' WHERE T.HEAT_PLAN_NO=?";
			 ps = conn.prepareStatement(deleteZgM);
			 ps.setObject(1, heatPlanNo);
			 ps.executeUpdate();
			 ps.close();
		}
		rs.close();
		ps.close();
		return messMemo;
	}

	/**
	 * 修改炉计划产线
	 * 
	 * @param
	 *
	 * @throws Exception
	 */
	public static void updatePlnZyMPline(Connection conn, String proPlanId,
			String gxPlanNo, String processCode, String plineCodeM,
			String plineNameM, String wholeBack) throws Exception {
		PreparedStatement ps = null;
		ResultSet rs = null;
		int planstatus = 0;
		String sql = "";
		String updateM = "";
		String storageNo = "";
		String storageName = "";
		String oldPlineSeam = "";//原产线区域
		String newPlineSeam = "";//新产线区域
		if (processCode.equals("D")) {
			// 查询炉计划最大状态
			sql += "SELECT NVL(MAX(T.PLANSTATUS),0) PLANSTATUS FROM PLN_ZY_ZG_M T WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?";
			ps = conn.prepareStatement(sql);
			ps.setObject(1, proPlanId);
			ps.setObject(2, gxPlanNo);
			rs = ps.executeQuery();
			if (rs.next()) {
				planstatus = rs.getInt("PLANSTATUS");
			}
			rs.close();
			ps.close();
			if (planstatus > 10) {
				throw new Exception("订单(" + proPlanId + "/" + gxPlanNo
						+ ")向下炉计划有不是计划或下发状态,不能调整产线,请拆分订单或离线委托!");
			}

			if (planstatus == 10) {
				String gowWhere = ComPlanFurnace.getPlineCodeGroup(conn,
						plineCodeM, proPlanId, gxPlanNo);
				if (gowWhere != null) {
					// 查询去向
					String sqlGroup = "SELECT T.STORAGE_NO,T.STORAGE_NAME FROM COM_BASE_PLINE_R_GROUP T WHERE T.PLINE_CODE_M=? AND T.PLINE_NAME_C=?";
					ps = conn.prepareStatement(sqlGroup);
					ps.setObject(1, plineCodeM);
					ps.setObject(2, gowWhere);
					rs = ps.executeQuery();
					if (rs.next()) {
						storageName = rs.getString("STORAGE_NAME");
						storageNo = rs.getString("STORAGE_NO");
					}
					rs.close();
					ps.close();
				}
			}
			// 修改虚拟炉计划产线
			updateM = "UPDATE PLN_ZY_ZG_M T SET T.PLINE_CODE=?,T.PLINE_NAME=?,T.GOWHERE_CODE=?,T.GOWHERE_NAME=? WHERE T.PRO_PLAN_ID=? AND"
					+ "  T.GX_PLAN_NO=? AND T.PLANSTATUS IN ('00','10')";
			ps = conn.prepareStatement(updateM);
			ps.setObject(1, plineCodeM);
			ps.setObject(2, plineNameM);
			ps.setObject(3, storageNo);
			ps.setObject(4, storageName);
			ps.setObject(5, proPlanId);
			ps.setObject(6, gxPlanNo);
			ps.executeUpdate();
			ps.close();

			// 修改实际炉计划产线
			updateM = "UPDATE PLN_ZY_ZG_C T SET T.PLINE_CODE=?,T.PLINE_NAME=? WHERE T.PRO_PLAN_ID=? AND"
					+ "  T.GX_PLAN_NO=?";
			ps = conn.prepareStatement(updateM);
			ps.setObject(1, plineCodeM);
			ps.setObject(2, plineNameM);
			ps.setObject(3, proPlanId);
			ps.setObject(4, gxPlanNo);
			ps.executeUpdate();
			ps.close();

		} else if (processCode.equals("E")) {
			// 查询炉计划最大状态
			sql += "SELECT NVL(MAX(T.PLANSTATUS),0) PLANSTATUS FROM PLN_ZY_DBK_M T WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?";
			ps = conn.prepareStatement(sql);
			ps.setObject(1, proPlanId);
			ps.setObject(2, gxPlanNo);
			rs = ps.executeQuery();
			if (rs.next()) {
				planstatus = rs.getInt("PLANSTATUS");
			}
			rs.close();
			ps.close();
			if (planstatus > 10) {
				throw new Exception("订单(" + proPlanId + "/" + gxPlanNo
						+ ")向下炉计划有不是计划或下发状态,不能调整产线,请拆分订单或离线委托!");
			}
			if (planstatus == 10) {
				String gowWhere = corePlanFurnProM.getPlineCodeGroup(conn,
						plineCodeM, proPlanId, gxPlanNo, "E");
				if (gowWhere != null) {
					// 查询去向
					String sqlGroup = "SELECT T.STORAGE_NO,T.STORAGE_NAME FROM COM_BASE_PLINE_R_GROUP T WHERE T.PLINE_CODE_M=? AND T.PLINE_NAME_C=?";
					ps = conn.prepareStatement(sqlGroup);
					ps.setObject(1, plineCodeM);
					ps.setObject(2, gowWhere);
					rs = ps.executeQuery();
					if (rs.next()) {
						storageName = rs.getString("STORAGE_NAME");
						storageNo = rs.getString("STORAGE_NO");
					}
					rs.close();
					ps.close();
				}
			}
			// 修改虚拟炉计划产线
			updateM = "UPDATE PLN_ZY_DBK_M T SET T.PLINE_CODE=?,T.PLINE_NAME=?,T.GOWHERE_CODE=?,T.GOWHERE_NAME=? WHERE T.PRO_PLAN_ID=? AND"
					+ "  T.GX_PLAN_NO=? AND T.PLANSTATUS IN ('00','10')";
			ps = conn.prepareStatement(updateM);
			ps.setObject(1, plineCodeM);
			ps.setObject(2, plineNameM);
			ps.setObject(3, storageNo);
			ps.setObject(4, storageName);
			ps.setObject(5, proPlanId);
			ps.setObject(6, gxPlanNo);
			ps.executeUpdate();
			ps.close();

			// 修改实际炉计划产线
			updateM = "UPDATE PLN_ZY_DBK_C T SET T.PLINE_CODE=?,T.PLINE_NAME=? WHERE T.PRO_PLAN_ID=? AND"
					+ "  T.GX_PLAN_NO=?";
			ps = conn.prepareStatement(updateM);
			ps.setObject(1, plineCodeM);
			ps.setObject(2, plineNameM);
			ps.setObject(3, proPlanId);
			ps.setObject(4, gxPlanNo);
			ps.executeUpdate();
			ps.close();
		} else if (processCode.equals("F")) {
			// 查询炉计划最大状态
			sql += "SELECT NVL(MAX(T.PLANSTATUS),0) PLANSTATUS FROM PLN_ZY_RCL_M T WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?";
			ps = conn.prepareStatement(sql);
			ps.setObject(1, proPlanId);
			ps.setObject(2, gxPlanNo);
			rs = ps.executeQuery();
			if (rs.next()) {
				planstatus = rs.getInt("PLANSTATUS");
			}
			rs.close();
			ps.close();


			//查询原产线所属地
			sql = CoreXmlSqlParsersFactory.getSql("StoveHelper.selectPlineAearF");
			ps = conn.prepareStatement(sql);
			ps.setString(1,proPlanId);
			ps.setString(2,gxPlanNo);
			rs = ps.executeQuery();
			if(rs.next())
			{
				oldPlineSeam = rs.getString("SUPPLY_UNIT_CODE");
			}
			rs.close();
			ps.close();

			//查询新产线所属地
			sql = CoreXmlSqlParsersFactory.getSql("StoveHelper.selectPlineAearFNew");
			ps = conn.prepareStatement(sql);
			ps.setString(1,plineCodeM);
			rs = ps.executeQuery();
			if(rs.next())
			{
				newPlineSeam = rs.getString("SUPPLY_UNIT_CODE");
			}
			rs.close();
			ps.close();

			//天淮产线往本部调
			if(oldPlineSeam.equals("120504") && newPlineSeam.equals("120501"))
			{
				if(planstatus > 00)
				{
					throw new Exception("天淮产线往本部调整时,炉计划必须是计划状态!");
				}
			}
			else
			{
				if (planstatus > 10) {
					throw new Exception("订单(" + proPlanId + "/" + gxPlanNo
							+ ")向下炉计划有不是计划或下发状态,不能调整产线,请拆分订单或离线委托!");
				}
			}




			if (planstatus == 10) {
				String gowWhere = corePlanFurnProM.getPlineCodeGroup(conn,
						plineCodeM, proPlanId, gxPlanNo, "F");
				if (gowWhere != null) {
					// 查询去向
					String sqlGroup = "SELECT T.STORAGE_NO,T.STORAGE_NAME FROM COM_BASE_PLINE_R_GROUP T WHERE T.PLINE_CODE_M=? AND T.PLINE_NAME_C=?";
					ps = conn.prepareStatement(sqlGroup);
					ps.setObject(1, plineCodeM);
					ps.setObject(2, gowWhere);
					rs = ps.executeQuery();
					if (rs.next()) {
						storageName = rs.getString("STORAGE_NAME");
						storageNo = rs.getString("STORAGE_NO");
					}
					rs.close();
					ps.close();
				}
			}

			if(oldPlineSeam.equals("120504") && newPlineSeam.equals("120501"))
			{
				// 修改虚拟炉计划产线
				updateM = "UPDATE PLN_ZY_RCL_M T SET T.PLINE_CODE=?,T.PLINE_NAME=?,T.GOWHERE_CODE=?,T.GOWHERE_NAME=?,T.JUDGE_STOVE_NO = '',T.FLAG_STOVE_NO = ''WHERE T.PRO_PLAN_ID=? AND"
						+ "  T.GX_PLAN_NO=? AND T.PLANSTATUS IN ('00','10')";
				ps = conn.prepareStatement(updateM);
				ps.setObject(1, plineCodeM);
				ps.setObject(2, plineNameM);
				ps.setObject(3, storageNo);
				ps.setObject(4, storageName);
				ps.setObject(5, proPlanId);
				ps.setObject(6, gxPlanNo);
				ps.executeUpdate();
				ps.close();

				// 修改实际炉计划产线
				updateM = "UPDATE PLN_ZY_RCL_C T SET T.PLINE_CODE=?,T.PLINE_NAME=? ,T.JUDGE_STOVE_NO = '',T.FLAG_STOVE_NO = '' WHERE T.PRO_PLAN_ID=? AND"
						+ "  T.GX_PLAN_NO=?";
				ps = conn.prepareStatement(updateM);
				ps.setObject(1, plineCodeM);
				ps.setObject(2, plineNameM);
				ps.setObject(3, proPlanId);
				ps.setObject(4, gxPlanNo);
				ps.executeUpdate();
				ps.close();
			}else
			{
				// 修改虚拟炉计划产线
				updateM = "UPDATE PLN_ZY_RCL_M T SET T.PLINE_CODE=?,T.PLINE_NAME=?,T.GOWHERE_CODE=?,T.GOWHERE_NAME=? WHERE T.PRO_PLAN_ID=? AND"
						+ "  T.GX_PLAN_NO=? AND T.PLANSTATUS IN ('00','10')";
				ps = conn.prepareStatement(updateM);
				ps.setObject(1, plineCodeM);
				ps.setObject(2, plineNameM);
				ps.setObject(3, storageNo);
				ps.setObject(4, storageName);
				ps.setObject(5, proPlanId);
				ps.setObject(6, gxPlanNo);
				ps.executeUpdate();
				ps.close();

				// 修改实际炉计划产线
				updateM = "UPDATE PLN_ZY_RCL_C T SET T.PLINE_CODE=?,T.PLINE_NAME=? WHERE T.PRO_PLAN_ID=? AND"
						+ "  T.GX_PLAN_NO=?";
				ps = conn.prepareStatement(updateM);
				ps.setObject(1, plineCodeM);
				ps.setObject(2, plineNameM);
				ps.setObject(3, proPlanId);
				ps.setObject(4, gxPlanNo);
				ps.executeUpdate();
				ps.close();
			}

		} else if (processCode.equals("G")) {
			// 查询炉计划最大状态
			sql += "SELECT NVL(MAX(T.PLANSTATUS),0) PLANSTATUS FROM PLN_ZY_JGX_M T WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?";
			ps = conn.prepareStatement(sql);
			ps.setObject(1, proPlanId);
			ps.setObject(2, gxPlanNo);
			rs = ps.executeQuery();
			if (rs.next()) {
				planstatus = rs.getInt("PLANSTATUS");
			}
			rs.close();
			ps.close();
			//查询原产线所属地
			sql = CoreXmlSqlParsersFactory.getSql("StoveHelper.selectPlineAearF");
			ps = conn.prepareStatement(sql);
			ps.setString(1,proPlanId);
			ps.setString(2,gxPlanNo);
			rs = ps.executeQuery();
			if(rs.next())
			{
				oldPlineSeam = rs.getString("SUPPLY_UNIT_CODE");
			}
			rs.close();
			ps.close();

			//查询新产线所属地
			sql = CoreXmlSqlParsersFactory.getSql("StoveHelper.selectPlineAearFNew");
			ps = conn.prepareStatement(sql);
			ps.setString(1,plineCodeM);
			rs = ps.executeQuery();
			if(rs.next())
			{
				newPlineSeam = rs.getString("SUPPLY_UNIT_CODE");
			}
			rs.close();
			ps.close();

			//天淮产线往本部调
			if(oldPlineSeam.equals("120504") && newPlineSeam.equals("120501"))
			{
				if(planstatus > 00)
				{
					throw new Exception("天淮产线往本部调整时,炉计划必须时计划状态!");
				}
			}
			else
			{
				if (planstatus > 10) {
					throw new Exception("订单(" + proPlanId + "/" + gxPlanNo
							+ ")向下炉计划有不是计划或下发状态,不能调整产线,请拆分订单或离线委托!");
				}
			}
			if (planstatus == 10) {
				String gowWhere = corePlanFurnProM.getPlineCodeGroup(conn,
						plineCodeM, proPlanId, gxPlanNo, "G");
				if (gowWhere != null) {
					// 查询去向
					String sqlGroup = "SELECT T.STORAGE_NO,T.STORAGE_NAME FROM COM_BASE_PLINE_R_GROUP T WHERE T.PLINE_CODE_M=? AND T.PLINE_NAME_C=?";
					ps = conn.prepareStatement(sqlGroup);
					ps.setObject(1, plineCodeM);
					ps.setObject(2, gowWhere);
					rs = ps.executeQuery();
					if (rs.next()) {
						storageName = rs.getString("STORAGE_NAME");
						storageNo = rs.getString("STORAGE_NO");
					}
					rs.close();
					ps.close();
				}
			}
			if(oldPlineSeam.equals("120504") && newPlineSeam.equals("120501"))
			{
				// 修改虚拟炉计划产线
				updateM = "UPDATE PLN_ZY_JGX_M T SET T.PLINE_CODE=?,T.PLINE_NAME=?,T.GOWHERE_CODE=?,T.GOWHERE_NAME=?, T.JUDGE_STOVE_NO = '',T.FLAG_STOVE_NO = '' WHERE T.PRO_PLAN_ID=? AND"
						+ "  T.GX_PLAN_NO=? AND T.PLANSTATUS IN ('00','10')";
				ps = conn.prepareStatement(updateM);
				ps.setObject(1, plineCodeM);
				ps.setObject(2, plineNameM);
				ps.setObject(3, storageNo);
				ps.setObject(4, storageName);
				ps.setObject(5, proPlanId);
				ps.setObject(6, gxPlanNo);
				ps.executeUpdate();
				ps.close();

				// 修改实际炉计划产线
				updateM = "UPDATE PLN_ZY_JGX_C T SET T.PLINE_CODE=?,T.PLINE_NAME=?,T.JUDGE_STOVE_NO = '',T.FLAG_STOVE_NO = '' WHERE T.PRO_PLAN_ID=? AND"
						+ "  T.GX_PLAN_NO=?";
				ps = conn.prepareStatement(updateM);
				ps.setObject(1, plineCodeM);
				ps.setObject(2, plineNameM);
				ps.setObject(3, proPlanId);
				ps.setObject(4, gxPlanNo);
				ps.executeUpdate();
				ps.close();
			}
			else
			{
				// 修改虚拟炉计划产线
				updateM = "UPDATE PLN_ZY_JGX_M T SET T.PLINE_CODE=?,T.PLINE_NAME=?,T.GOWHERE_CODE=?,T.GOWHERE_NAME=? WHERE T.PRO_PLAN_ID=? AND"
						+ "  T.GX_PLAN_NO=? AND T.PLANSTATUS IN ('00','10')";
				ps = conn.prepareStatement(updateM);
				ps.setObject(1, plineCodeM);
				ps.setObject(2, plineNameM);
				ps.setObject(3, storageNo);
				ps.setObject(4, storageName);
				ps.setObject(5, proPlanId);
				ps.setObject(6, gxPlanNo);
				ps.executeUpdate();
				ps.close();

				// 修改实际炉计划产线
				updateM = "UPDATE PLN_ZY_JGX_C T SET T.PLINE_CODE=?,T.PLINE_NAME=? WHERE T.PRO_PLAN_ID=? AND"
						+ "  T.GX_PLAN_NO=?";
				ps = conn.prepareStatement(updateM);
				ps.setObject(1, plineCodeM);
				ps.setObject(2, plineNameM);
				ps.setObject(3, proPlanId);
				ps.setObject(4, gxPlanNo);
				ps.executeUpdate();
				ps.close();
			}

		} else if (processCode.equals("H")) {

			// 查询炉计划最大状态
			sql += "SELECT NVL(MAX(T.PLANSTATUS),0) PLANSTATUS FROM PLN_ZY_JG_M T WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?";
			ps = conn.prepareStatement(sql);
			ps.setObject(1, proPlanId);
			ps.setObject(2, gxPlanNo);
			rs = ps.executeQuery();
			if (rs.next()) {
				planstatus = rs.getInt("PLANSTATUS");
			}
			rs.close();
			ps.close();
			if (planstatus > 10) {
				throw new Exception("订单(" + proPlanId + "/" + gxPlanNo
						+ ")向下炉计划有不是计划或下发状态,不能调整产线,请拆分订单或离线委托!");
			}
			// 修改虚拟炉计划产线
			updateM = "UPDATE PLN_ZY_JG_M T SET T.PLINE_CODE=?,T.PLINE_NAME=? WHERE T.PRO_PLAN_ID=? AND"
					+ "  T.GX_PLAN_NO=? AND T.PLANSTATUS IN ('00','10')";
			ps = conn.prepareStatement(updateM);
			ps.setObject(1, plineCodeM);
			ps.setObject(2, plineNameM);
			ps.setObject(3, proPlanId);
			ps.setObject(4, gxPlanNo);
			ps.executeUpdate();
			ps.close();

			// 修改实际炉计划产线
			updateM = "UPDATE PLN_ZY_JG_C T SET T.PLINE_CODE=?,T.PLINE_NAME=? WHERE T.PRO_PLAN_ID=? AND"
					+ "  T.GX_PLAN_NO=?";
			ps = conn.prepareStatement(updateM);
			ps.setObject(1, plineCodeM);
			ps.setObject(2, plineNameM);
			ps.setObject(3, proPlanId);
			ps.setObject(4, gxPlanNo);
			ps.executeUpdate();
			ps.close();

		}
	}

	/**
	 * 重新获取工艺--单炉重新获取工艺已弃用
	 */
	public CoreReturnObject doAgainProcess(ArrayList<ArrayList<String>> jslist,
			String proPlanId, String gxPlanNo, String proessCode)
			throws ParseException {
		CoreReturnObject cro = new CoreReturnObject();
		Connection jhyCon = null;
		Connection conn = null;
		try {
			conn = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			jhyCon = this.getDao("JhyDao").getConnection();
			conn.setAutoCommit(false);
			jhyCon.setAutoCommit(false);
			PreparedStatement ps = null;
			ResultSet rs = null;

			String ordLnPk = "";
			String orderNoSeq = "";
			String plnOrderS = "";
			String pic = "";
			String sic = "";
			String dic = "";
			String wic = "";
			String ifProduct = "0";
			String msc = "";
			String indexSeq = "";
			String bom = "";
			
//			String sqlPlnS="SELECT T.ORD_LN_PK, T.ORDER_NO || '/' || T.ORDER_SEQ ORDER_NO_SEQ  FROM PLN_SALEORD T WHERE T.ORD_LN_DLY_PK = ?";
//			ps = conn.prepareStatement(sqlPlnS);
//			ps.setObject(1, zgSEntity.getOrdLnDlyPk());
//			rs = ps.executeQuery();
//			if (rs.next()) {
//				ordLnPk=rs.getString("ORD_LN_PK");
//			}
//			rs.close();
//			ps.close();
			// 获取最新工艺 CIC
			String[] craftInfo = PlnHelper.getArray(conn,
					"CorePlnSaleOrder.queryOrdCraftOrdDesign",
					" AND T.VALIDFLAG = '1'", new String[] { ordLnPk },
					new String[] { "CRAFT_SEQ", "DESGIN_KEY", "CRAFT_NAME",
							"CRAFT_NO", "CRAFT_NO_V" });
			if (craftInfo == null || craftInfo.length == 0) {
				cro.setV_errMsg("合同行：" + orderNoSeq + "未找到有效的工艺评审！");
				return cro;
			}
			String craftFileNo = craftInfo[3];
			String craftFileMan = craftInfo[2];
			String desginKey = craftInfo[1];
			String craftSeq = craftInfo[0];
			if (proessCode.equals("D")) {
				plnOrderS = "SELECT T.ORD_LN_PK,T.ORDER_NO||'/'||T.ORDER_SEQ ORDER_NO_SEQ,T1.MSC,T1.INDEX_SEQ,T1.BOM FROM PLN_SALEORD T,PLN_ORDER_ZG_S T1 WHERE T.ORD_LN_DLY_PK=T1.ORD_LN_DLY_PK AND T1.PRO_PLAN_ID=? AND T1.GX_PLAN_NO=?";
				String orders = CoreXmlSqlParsersFactory
						.getSql("StoveHelper.queryZgCf");
				ps = conn.prepareStatement(orders);
				ps.setObject(1, craftSeq);
				ps.setObject(2, desginKey);
				ps.setObject(3, proPlanId);
				ps.setObject(4, gxPlanNo);
				rs = ps.executeQuery();
				if (rs.next()) {
					if (rs.getString("PIC") != null
							&& !rs.getString("PIC").equals("")) {
						pic = rs.getString("PIC").split(",")[0];
					}
					if (rs.getString("SIC") != null
							&& !rs.getString("SIC").equals("")) {
						sic = rs.getString("SIC").split(",")[0];
					}
					if (rs.getString("DIC") != null
							&& !rs.getString("DIC").equals("")) {
						dic = rs.getString("DIC").split(",")[0];
					}

				}
				rs.close();
				ps.close();

				int counnum = StoveHelper.getQueryStation(conn, proPlanId,
						gxPlanNo, "D");
				if (counnum > 0) {
					ifProduct = "1";
				}
			} else if (proessCode.equals("E")) {
				String orders = CoreXmlSqlParsersFactory
						.getSql("StoveHelper.queryDbkCf");
				ps = conn.prepareStatement(orders);
				ps.setObject(1, craftSeq);
				ps.setObject(2, desginKey);
				ps.setObject(3, proPlanId);
				ps.setObject(4, gxPlanNo);
				rs = ps.executeQuery();
				if (rs.next()) {
					if (rs.getString("PIC") != null
							&& !rs.getString("PIC").equals("")) {
						pic = rs.getString("PIC").split(",")[0];
					}
					if (rs.getString("SIC") != null
							&& !rs.getString("SIC").equals("")) {
						sic = rs.getString("SIC").split(",")[0];
					}
					if (rs.getString("DIC") != null
							&& !rs.getString("DIC").equals("")) {
						dic = rs.getString("DIC").split(",")[0];
					}
				}
				rs.close();
				ps.close();
				plnOrderS = "SELECT T.ORD_LN_PK,T.ORDER_NO||'/'||T.ORDER_SEQ ORDER_NO_SEQ,T1.MSC,T1.INDEX_SEQ,T1.BOM FROM PLN_SALEORD T,PLN_ORDER_DBK_S T1 WHERE T.ORD_LN_DLY_PK=T1.ORD_LN_DLY_PK AND T1.PRO_PLAN_ID=? AND T1.GX_PLAN_NO=?";
				int counnum = StoveHelper.getQueryStation(conn, proPlanId,
						gxPlanNo, "E");
				if (counnum > 0) {
					ifProduct = "1";
				}
			} else if (proessCode.equals("F")) {
				String orders = CoreXmlSqlParsersFactory
						.getSql("StoveHelper.queryRclCf");
				ps = conn.prepareStatement(orders);
				ps.setObject(1, craftSeq);
				ps.setObject(2, desginKey);
				ps.setObject(3, proPlanId);
				ps.setObject(4, gxPlanNo);
				rs = ps.executeQuery();
				if (rs.next()) {
					if (rs.getString("PIC") != null
							&& !rs.getString("PIC").equals("")) {
						pic = rs.getString("PIC").split(",")[0];
					}
					if (rs.getString("SIC") != null
							&& !rs.getString("SIC").equals("")) {
						sic = rs.getString("SIC").split(",")[0];
					}
					if (rs.getString("DIC") != null
							&& !rs.getString("DIC").equals("")) {
						dic = rs.getString("DIC").split(",")[0];
					}
				}
				rs.close();
				ps.close();
				plnOrderS = "SELECT T.ORD_LN_PK,T.ORDER_NO||'/'||T.ORDER_SEQ ORDER_NO_SEQ,T1.MSC,T1.INDEX_SEQ,T1.BOM FROM PLN_SALEORD T,PLN_ORDER_RCL_S T1 WHERE T.ORD_LN_DLY_PK=T1.ORD_LN_DLY_PK AND T1.PRO_PLAN_ID=? AND T1.GX_PLAN_NO=?";
				int counnum = StoveHelper.getQueryStation(conn, proPlanId,
						gxPlanNo, "F");
				if (counnum > 0) {
					ifProduct = "1";
				}
			} else if (proessCode.equals("G")) {
				String orders = CoreXmlSqlParsersFactory
						.getSql("StoveHelper.queryJgxCf");
				ps = conn.prepareStatement(orders);
				ps.setObject(1, craftSeq);
				ps.setObject(2, desginKey);
				ps.setObject(3, proPlanId);
				ps.setObject(4, gxPlanNo);
				rs = ps.executeQuery();
				if (rs.next()) {
					if (rs.getString("PIC") != null
							&& !rs.getString("PIC").equals("")) {
						pic = rs.getString("PIC").split(",")[0];
					}
					if (rs.getString("SIC") != null
							&& !rs.getString("SIC").equals("")) {
						sic = rs.getString("SIC").split(",")[0];
					}
					if (rs.getString("DIC") != null
							&& !rs.getString("DIC").equals("")) {
						dic = rs.getString("DIC").split(",")[0];
					}
					if (rs.getString("WIC") != null
							&& !rs.getString("WIC").equals("")) {
						wic = rs.getString("WIC").split(",")[0];
					}
				}
				rs.close();
				ps.close();
				plnOrderS = "SELECT T.ORD_LN_PK,T.ORDER_NO||'/'||T.ORDER_SEQ ORDER_NO_SEQ,T1.MSC,T1.INDEX_SEQ,T1.BOM FROM PLN_SALEORD T,PLN_ORDER_JGX_S T1 WHERE T.ORD_LN_DLY_PK=T1.ORD_LN_DLY_PK AND T1.PRO_PLAN_ID=? AND T1.GX_PLAN_NO=?";
				int counnum = StoveHelper.getQueryStation(conn, proPlanId,
						gxPlanNo, "G");
				if (counnum > 0) {
					ifProduct = "1";
				}
			}
			ps = conn.prepareStatement(plnOrderS);
			ps.setObject(1, proPlanId);
			ps.setObject(2, gxPlanNo);
			rs = ps.executeQuery();
			if (rs.next()) {
				ordLnPk = rs.getString("ORD_LN_PK");
				orderNoSeq = rs.getString("ORDER_NO_SEQ");
				msc = rs.getString("MSC");
				indexSeq = rs.getString("INDEX_SEQ");
				bom = rs.getString("BOM");
			}
			rs.close();
			ps.close();

			int countBom = 0;

			List<SlmOrdDesignBomEntity> bomList = PlnHelper.getEntityDatas(
					conn, new String[] { desginKey, msc, indexSeq },
					"CoreOrdDesginBom.getOrdLineMscBom",
					SlmOrdDesignBomEntity.class);
			if (bomList != null && bomList.size() > 0) {
				for (SlmOrdDesignBomEntity bomEntity : bomList) {
					if (bomEntity.getBom().equals(bom)) {
						countBom++;
					}
				}
			}
			// if(countBom==0){
			// cro.setV_errMsg("新工艺不包含订单使用的Bom,不能重新获取工艺！");
			// return cro;
			// }
			// 循环虚拟炉计划信息
			for (int i = 0; i < jslist.size(); i++) {
				ArrayList<String> list = (ArrayList<String>) jslist.get(i);
				String heatPlanNo = list.get(0);
				// 修改虚拟炉计划
				String updateM = "";
				if (proessCode.equals("D")) {
					updateM = "UPDATE PLN_ZY_ZG_M T SET T.CRAFT_FILE_NO=?,T.CRAFT_FILE_MAN=?,T.CRAFT_SEQ=?,T.PIC=?,T.SIC=?,T.DIC=?,T.IF_PRODUCT='"
							+ ifProduct + "' WHERE T.HEAT_PLAN_NO=?";
				} else if (proessCode.equals("E")) {
					updateM = "UPDATE PLN_ZY_DBK_M T SET T.CRAFT_FILE_NO=?,T.CRAFT_FILE_MAN=?,T.CRAFT_SEQ=?,T.PIC=?,T.SIC=?,T.DIC=?,T.IF_PRODUCT='"
							+ ifProduct + "' WHERE T.HEAT_PLAN_NO=?";
				} else if (proessCode.equals("F")) {
					updateM = "UPDATE PLN_ZY_RCL_M T SET T.CRAFT_FILE_NO=?,T.CRAFT_FILE_MAN=?,T.CRAFT_SEQ=?,T.PIC=?,T.SIC=?,T.DIC=?,T.IF_PRODUCT='"
							+ ifProduct + "' WHERE T.HEAT_PLAN_NO=?";
				} else if (proessCode.equals("G")) {
					updateM = "UPDATE PLN_ZY_JGX_M T SET T.CRAFT_FILE_NO=?,T.CRAFT_FILE_MAN=?,T.CRAFT_SEQ=?,T.PIC=?,T.SIC=?,T.DIC=?,T.IF_PRODUCT='"
							+ ifProduct
							+ "',T.WIC='"
							+ wic
							+ "' WHERE T.HEAT_PLAN_NO=?";
				}
				ps = conn.prepareStatement(updateM);
				ps.setObject(1, craftFileNo);
				ps.setObject(2, craftFileMan);
				ps.setObject(3, craftSeq);
				ps.setObject(4, pic);
				ps.setObject(5, sic);
				ps.setObject(6, dic);
				ps.setObject(7, heatPlanNo);
				ps.executeUpdate();
				ps.close();

				// 判定是否交库
				if (proessCode.equals("D")) {

					String sqlzGm = "SELECT T.HEAT_PLAN_NO, T.ORD_LN_DLY_PK, DECODE(TRIM(T.IF_PRODUCT),0,'','1',T.CIC||'+')  || T.PIC || '+' || T.SIC || '+' || T.DIC STEEL_STANDRAD,T.FEED_HEAT_NO FROM PLN_ZY_ZG_M T WHERE T.HEAT_PLAN_NO=? ";
					PreparedStatement ps1 = conn.prepareStatement(sqlzGm);
					ps1.setObject(1, heatPlanNo);
					ResultSet rs1 = ps1.executeQuery();
					if (rs1.next()) {
						String sreelStandrad = rs1.getString("STEEL_STANDRAD");
						String feedHeatNo = rs1.getString("FEED_HEAT_NO");
						String ordLnDlyPk = rs1.getString("ORD_LN_DLY_PK");
						String impProcess = "";
						String craftSeqOld = "";
						// 查詢原爐計劃工艺号
						String sql = "SELECT  T.IMP_PROCESS,T.CRAFT_SEQ FROM MIL_PLAN T WHERE T.ID=? ";
						ps = conn.prepareStatement(sql);
						ps.setObject(1, heatPlanNo);
						rs = ps.executeQuery();
						if (rs.next()) {
							impProcess = rs.getString("IMP_PROCESS");
							craftSeqOld = rs.getString("CRAFT_SEQ");
						}
						rs.close();
						ps.close();
						// 查询是否综合判断
						String sqlQcm = "SELECT T.VALIDFLAG FROM QCM_ZG_JUGDE_APPLY T WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CODE=? AND T.IS_FLAG='0' ";
						ps = conn.prepareStatement(sqlQcm);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						rs = ps.executeQuery();
						while (rs.next()) {
							if (rs.getString("VALIDFLAG").equals("20")) {
								cro.setV_errMsg("判定炉号:" + feedHeatNo
										+ ",已判定不能获取工艺！");
								return cro;
							}
						}
						rs.close();
						ps.close();
						// 轧管计划表
						String updateMil = "UPDATE MIL_PLAN T SET T.CRAFT_SEQ=?,T.IMP_PROCESS=?,T.PIC=?,T.STEEL_STANDRAD='"
								+ sreelStandrad
								+ "',T.IF_PRODUCT='"
								+ ifProduct + "'  WHERE T.ID=?";
						ps = conn.prepareStatement(updateMil);
						ps.setObject(1, craftSeq);
						ps.setObject(2, craftFileNo);
						ps.setObject(3, pic);
						ps.setObject(4, heatPlanNo);
						ps.executeUpdate();
						ps.close();
						// 修改检化验计划表
						String updateMQcm = "UPDATE QCM_ZC_CHECKCONSIGN T SET T.JUDGE_RESULT_CODE = NULL, T.CRAF_NO=?,T.CRAFT_SEQ=?,T.PIC=?,T.STEEL_STANDRAD='"
								+ sreelStandrad
								+ "' WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CODE='D' AND T.ORD_LN_DLY_PK = ?";
						ps = conn.prepareStatement(updateMQcm);
						ps.setObject(1, craftFileNo);
						ps.setObject(2, craftSeq);
						ps.setObject(3, pic);
						ps.setObject(4, feedHeatNo);
						ps.setObject(5, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						//
						String orders = CoreXmlSqlParsersFactory
								.getSql("StoveHelper.updateQcmZc");
						ps = conn.prepareStatement(orders);
						ps.setObject(1, impProcess);
						ps.setObject(2, craftSeqOld);
						ps.setObject(3, craftFileNo);
						ps.setObject(4, craftSeq);
						ps.setObject(5, pic);
						ps.setObject(6, sreelStandrad);
						ps.setObject(7, craftFileNo);
						ps.setObject(8, craftSeq);
						ps.setObject(9, pic);
						ps.setObject(10, sreelStandrad);
						ps.executeUpdate();
						ps.close();

						// 更新判定表
						String updateQcm = "UPDATE QCM_ZG_JUGDE_APPLY T SET T.CRAF_NO=?,T.CRAFT_SEQ=?,T.PIC=?,T.SIC=?,T.DIC=?,T.STEEL_STANDRAD ='"
								+ sreelStandrad
								+ "' "
								+ " WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CODE=? AND T.IS_FLAG='0' ";
						ps = conn.prepareStatement(updateQcm);
						ps.setObject(1, craftFileNo);
						ps.setObject(2, craftSeq);
						ps.setObject(3, pic);
						ps.setObject(4, sic);
						ps.setObject(5, dic);
						ps.setObject(6, feedHeatNo);
						ps.setObject(7, proessCode);
						ps.executeUpdate();
						ps.close();

						// 更新判庫存
						String updateMat = "UPDATE MAT_BC_M T SET T.CRAF_NO=?,T.CRAFT_SEQ=?,T.JUDGE_STD_DES='"
								+ sreelStandrad
								+ "' WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CDOE=?";
						ps = conn.prepareStatement(updateMat);
						ps.setObject(1, craftFileNo);
						ps.setObject(2, craftSeq);
						ps.setObject(3, feedHeatNo);
						ps.setObject(4, proessCode);
						ps.executeUpdate();
						ps.close();

						// 更新成分实绩表
						String updatejhy = "UPDATE QCM_JHY_ELEMENTS T  SET T.LG_JUDGE_FLAG ='00' WHERE T.JUDGE_STOVE_NO=? AND T.PLINE_CODE IN (SELECT T1.PLINE_CODE FROM COM_BASE_PLINE T1 WHERE T1.PROCESS_CODE=?)  AND T.VALIDFLAG='1' AND EXISTS(SELECT 1 FROM QCM_ZC_CHECKCONSIGN A WHERE A.CHECK_NO = T.SAMPLE_ID AND A.BATCH_NO = T.BATCH_NO AND A.ORD_LN_DLY_PK = ?)";
						ps = conn.prepareStatement(updatejhy);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						// 更新理化判定表
						String updatePh = "UPDATE QCM_JHY_PHYRESULT T  SET T.JUDGE_FLAG ='00' WHERE T.JUDGE_STOVE_NO=? AND T.PLINE_CODE IN (SELECT T1.PLINE_CODE FROM COM_BASE_PLINE T1 WHERE T1.PROCESS_CODE=?)  AND T.VALIDFLAG='1' AND EXISTS(SELECT 1 FROM QCM_ZC_CHECKCONSIGN A WHERE A.CHECK_NO = T.SAMPLE_ID AND A.BATCH_NO = T.BATCH_NO AND A.ORD_LN_DLY_PK = ?)";
						ps = conn.prepareStatement(updatePh);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						// 更新委托二层表
						String setConsignDetail = "UPDATE QCM_ZC_CHECKCONSIGN_DETAIL T SET T.NK_RESULT = NULL, T.JF_RESULT = NULL WHERE EXISTS (SELECT 1 FROM QCM_ZC_CHECKCONSIGN A WHERE A.CHECK_NO = T.CHECK_NO AND A.BATCH_NO = T.BATCH_NO AND A.JUDGE_STOVE_NO = ? AND A.PROCESS_CODE = ? AND A.ORD_LN_DLY_PK = ?)";
						ps = conn.prepareStatement(setConsignDetail);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						// 更新炉批结果表
						String setBatchResult = "UPDATE QCM_BC_BATCH_RESULT T SET T.JUDGE_RESULT_CODE = NULL WHERE T.JUDGE_STOVE_NO = ? AND T.PROCESS_CODE = ? AND T.ORD_LN_DLY_PK = ?";
						ps = conn.prepareStatement(setBatchResult);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();
					}
					rs1.close();
					ps1.close();

				} else if (proessCode.equals("E")) {

					String sqlzGm = "SELECT T.HEAT_PLAN_NO, T.ORD_LN_DLY_PK, DECODE(TRIM(T.IF_PRODUCT),0,'','1',T.CIC||'+')  || T.PIC || '+' || T.SIC || '+' || T.DIC STEEL_STANDRAD,T.JUDGE_STOVE_NO FROM PLN_ZY_DBK_M T WHERE T.HEAT_PLAN_NO=? ";
					PreparedStatement ps1 = conn.prepareStatement(sqlzGm);
					ps1.setObject(1, heatPlanNo);
					ResultSet rs1 = ps1.executeQuery();
					if (rs1.next()) {
						String sreelStandrad = rs1.getString("STEEL_STANDRAD");
						String feedHeatNo = rs1.getString("JUDGE_STOVE_NO");
						String ordLnDlyPk = rs1.getString("ORD_LN_DLY_PK");
						// 查询是否综合判断
						String sqlQcm = "SELECT T.VALIDFLAG FROM QCM_ZG_JUGDE_APPLY T WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CODE=? AND T.IS_FLAG='0' ";
						ps = conn.prepareStatement(sqlQcm);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						rs = ps.executeQuery();
						while (rs.next()) {
							if (rs.getString("VALIDFLAG").equals("20")) {
								cro.setV_errMsg("判定炉号:" + feedHeatNo
										+ ",已判定不能获取工艺！");
								return cro;
							}
						}
						rs.close();
						ps.close();
						// 更新判定表
						String updateQcm = "UPDATE QCM_ZG_JUGDE_APPLY T SET T.CRAF_NO=?,T.CRAFT_SEQ=?,T.PIC=?,T.SIC=?,T.DIC=?,T.STEEL_STANDRAD ='"
								+ sreelStandrad
								+ "' "
								+ " WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CODE=? AND T.IS_FLAG='0' ";
						ps = conn.prepareStatement(updateQcm);
						ps.setObject(1, craftFileNo);
						ps.setObject(2, craftSeq);
						ps.setObject(3, pic);
						ps.setObject(4, sic);
						ps.setObject(5, dic);
						ps.setObject(6, feedHeatNo);
						ps.setObject(7, proessCode);
						ps.executeUpdate();
						ps.close();
						// 修改检化验计划表
						String updateMQcm = "UPDATE QCM_ZC_CHECKCONSIGN T SET T.JUDGE_RESULT_CODE = NULL, T.CRAF_NO=?,T.CRAFT_SEQ=?,T.PIC=?,T.STEEL_STANDRAD='"
								+ sreelStandrad
								+ "' WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CODE='E' AND T.ORD_LN_DLY_PK = ?";
						ps = conn.prepareStatement(updateMQcm);
						ps.setObject(1, craftFileNo);
						ps.setObject(2, craftSeq);
						ps.setObject(3, pic);
						ps.setObject(4, feedHeatNo);
						ps.setObject(5, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();
						// 更新判庫存
						String updateMat = "UPDATE MAT_BC_M T SET T.CRAF_NO=?,T.CRAFT_SEQ=?,T.JUDGE_STD_DES='"
								+ sreelStandrad
								+ "' WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CDOE=?";
						ps = conn.prepareStatement(updateMat);
						ps.setObject(1, craftFileNo);
						ps.setObject(2, craftSeq);
						ps.setObject(3, feedHeatNo);
						ps.setObject(4, proessCode);
						ps.executeUpdate();
						ps.close();
						// 更新成分实绩表
						String updatejhy = "UPDATE QCM_JHY_ELEMENTS T  SET T.LG_JUDGE_FLAG ='00' WHERE T.JUDGE_STOVE_NO=? AND T.PLINE_CODE IN (SELECT T1.PLINE_CODE FROM COM_BASE_PLINE T1 WHERE T1.PROCESS_CODE=?)  AND T.VALIDFLAG='1' AND EXISTS(SELECT 1 FROM QCM_ZC_CHECKCONSIGN A WHERE A.CHECK_NO = T.SAMPLE_ID AND A.BATCH_NO = T.BATCH_NO AND A.ORD_LN_DLY_PK = ?)";
						ps = conn.prepareStatement(updatejhy);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						// 更新理化判定表
						String updatePh = "UPDATE QCM_JHY_PHYRESULT T  SET T.JUDGE_FLAG ='00' WHERE T.JUDGE_STOVE_NO=? AND T.PLINE_CODE IN (SELECT T1.PLINE_CODE FROM COM_BASE_PLINE T1 WHERE T1.PROCESS_CODE=?)  AND T.VALIDFLAG='1' AND EXISTS(SELECT 1 FROM QCM_ZC_CHECKCONSIGN A WHERE A.CHECK_NO = T.SAMPLE_ID AND A.BATCH_NO = T.BATCH_NO AND A.ORD_LN_DLY_PK = ?)";
						ps = conn.prepareStatement(updatePh);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						// 更新委托二层表
						String setConsignDetail = "UPDATE QCM_ZC_CHECKCONSIGN_DETAIL T SET T.NK_RESULT = NULL, T.JF_RESULT = NULL WHERE EXISTS (SELECT 1 FROM QCM_ZC_CHECKCONSIGN A WHERE A.CHECK_NO = T.CHECK_NO AND A.BATCH_NO = T.BATCH_NO AND A.JUDGE_STOVE_NO = ? AND A.PROCESS_CODE = ? AND A.ORD_LN_DLY_PK = ?)";
						ps = conn.prepareStatement(setConsignDetail);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						// 更新炉批结果表
						String setBatchResult = "UPDATE QCM_BC_BATCH_RESULT T SET T.JUDGE_RESULT_CODE = NULL WHERE T.JUDGE_STOVE_NO = ? AND T.PROCESS_CODE = ? AND T.ORD_LN_DLY_PK = ?";
						ps = conn.prepareStatement(setBatchResult);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();
					}
					rs1.close();
					ps1.close();

				} else if (proessCode.equals("F")) {
					// 调整顺序修改生产批
					updatePlnRclGroup(conn, proPlanId, gxPlanNo, pic);
					String sqlzGm = "SELECT T.HEAT_PLAN_NO, T.ORD_LN_DLY_PK, T.LOT_NO_GROUP, DECODE(TRIM(T.IF_PRODUCT),0,'','1',T.CIC||'+')  || T.PIC || '+' || T.SIC || '+' || T.DIC STEEL_STANDRAD,T.JUDGE_STOVE_NO FROM PLN_ZY_RCL_M T WHERE T.HEAT_PLAN_NO=? ";
					PreparedStatement ps1 = conn.prepareStatement(sqlzGm);
					ps1.setObject(1, heatPlanNo);
					ResultSet rs1 = ps1.executeQuery();
					if (rs1.next()) {
						String lotNoGroup = "";
						if (rs1.getString("LOT_NO_GROUP") != null
								&& !rs1.getString("LOT_NO_GROUP").equals("")) {
							lotNoGroup = rs1.getString("LOT_NO_GROUP");
						}
						String sreelStandrad = rs1.getString("STEEL_STANDRAD");
						String feedHeatNo = rs1.getString("JUDGE_STOVE_NO");
						String ordLnDlyPk = rs1.getString("ORD_LN_DLY_PK");
						// 查询是否综合判断
						String sqlQcm = "SELECT T.VALIDFLAG FROM QCM_ZG_JUGDE_APPLY T WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CODE=? AND T.IS_FLAG='0' ";
						ps = conn.prepareStatement(sqlQcm);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						rs = ps.executeQuery();
						while (rs.next()) {
							if (rs.getString("VALIDFLAG").equals("20")) {
								cro.setV_errMsg("判定炉号:" + feedHeatNo
										+ ",已判定不能获取工艺！");
								return cro;
							}
						}
						rs.close();
						ps.close();
						// 更新判定表
						String updateQcm = "UPDATE QCM_ZG_JUGDE_APPLY T SET T.CRAF_NO=?,T.CRAFT_SEQ=?,T.PIC=?,T.SIC=?,T.DIC=?,T.STEEL_STANDRAD ='"
								+ sreelStandrad
								+ "',T.LOT_NO_GROUP='"
								+ lotNoGroup
								+ "' "
								+ " WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CODE=? AND T.IS_FLAG='0' ";
						ps = conn.prepareStatement(updateQcm);
						ps.setObject(1, craftFileNo);
						ps.setObject(2, craftSeq);
						ps.setObject(3, pic);
						ps.setObject(4, sic);
						ps.setObject(5, dic);
						ps.setObject(6, feedHeatNo);
						ps.setObject(7, proessCode);
						ps.executeUpdate();
						ps.close();
						// 修改检化验计划表
						String updateMQcm = "UPDATE QCM_ZC_CHECKCONSIGN T SET T.JUDGE_RESULT_CODE = NULL, T.CRAF_NO=?,T.CRAFT_SEQ=?,T.PIC=?,T.STEEL_STANDRAD='"
								+ sreelStandrad
								+ "',T.LOT_NO_GROUP='"
								+ lotNoGroup
								+ "' WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CODE='F' AND T.ORD_LN_DLY_PK = ?";
						ps = conn.prepareStatement(updateMQcm);
						ps.setObject(1, craftFileNo);
						ps.setObject(2, craftSeq);
						ps.setObject(3, pic);
						ps.setObject(4, feedHeatNo);
						ps.setObject(5, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();
						// 修改检验委托表
						String updatePipe = "UPDATE PIPE_CHECKCONSIGN_BASEINFO T SET T.PIC=?,T.CRAFT_FILE_NO=?,T.LOT_NO_GROUP='"
								+ lotNoGroup
								+ "' WHERE T.HEAT_NO=? AND T.PROCESS_CODE='F'";
						ps = jhyCon.prepareStatement(updatePipe);
						ps.setObject(1, pic);
						ps.setObject(2, craftFileNo);
						ps.setObject(3, feedHeatNo);
						ps.executeUpdate();
						ps.close();
						// 更新判庫存
						String updateMat = "UPDATE MAT_BC_M T SET T.CRAF_NO=?,T.CRAFT_SEQ=?,T.JUDGE_STD_DES='"
								+ sreelStandrad
								+ "' WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CDOE=?";
						ps = conn.prepareStatement(updateMat);
						ps.setObject(1, craftFileNo);
						ps.setObject(2, craftSeq);
						ps.setObject(3, feedHeatNo);
						ps.setObject(4, proessCode);
						ps.executeUpdate();
						ps.close();

						// 更新成分实绩表
						String updatejhy = "UPDATE QCM_JHY_ELEMENTS T  SET T.LG_JUDGE_FLAG ='00' WHERE T.JUDGE_STOVE_NO=? AND T.PLINE_CODE IN (SELECT T1.PLINE_CODE FROM COM_BASE_PLINE T1 WHERE T1.PROCESS_CODE=?)  AND T.VALIDFLAG='1' AND EXISTS(SELECT 1 FROM QCM_ZC_CHECKCONSIGN A WHERE A.CHECK_NO = T.SAMPLE_ID AND A.BATCH_NO = T.BATCH_NO AND A.ORD_LN_DLY_PK = ?)";
						ps = conn.prepareStatement(updatejhy);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						// 更新理化判定表
						String updatePh = "UPDATE QCM_JHY_PHYRESULT T  SET T.JUDGE_FLAG ='00' WHERE T.JUDGE_STOVE_NO=? AND T.PLINE_CODE IN (SELECT T1.PLINE_CODE FROM COM_BASE_PLINE T1 WHERE T1.PROCESS_CODE=?)  AND T.VALIDFLAG='1' AND EXISTS(SELECT 1 FROM QCM_ZC_CHECKCONSIGN A WHERE A.CHECK_NO = T.SAMPLE_ID AND A.BATCH_NO = T.BATCH_NO AND A.ORD_LN_DLY_PK = ?)";
						ps = conn.prepareStatement(updatePh);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						// 更新委托二层表
						String setConsignDetail = "UPDATE QCM_ZC_CHECKCONSIGN_DETAIL T SET T.NK_RESULT = NULL, T.JF_RESULT = NULL WHERE EXISTS (SELECT 1 FROM QCM_ZC_CHECKCONSIGN A WHERE A.CHECK_NO = T.CHECK_NO AND A.BATCH_NO = T.BATCH_NO AND A.JUDGE_STOVE_NO = ? AND A.PROCESS_CODE = ? AND A.ORD_LN_DLY_PK = ?)";
						ps = conn.prepareStatement(setConsignDetail);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						// 更新炉批结果表
						String setBatchResult = "UPDATE QCM_BC_BATCH_RESULT T SET T.JUDGE_RESULT_CODE = NULL WHERE T.JUDGE_STOVE_NO = ? AND T.PROCESS_CODE = ? AND T.ORD_LN_DLY_PK = ?";
						ps = conn.prepareStatement(setBatchResult);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();
					}
					rs1.close();
					ps1.close();

				} else if (proessCode.equals("G")) {
					// 调整顺序修改生产批
					updatePlnJgxGroup(conn, proPlanId, gxPlanNo, pic);
					String sqlzGm = "SELECT T.HEAT_PLAN_NO, T.ORD_LN_DLY_PK,T.LOT_NO_GROUP, DECODE(TRIM(T.IF_PRODUCT),0,'','1',T.CIC||'+')  || T.PIC || '+' || T.SIC || '+' || T.DIC STEEL_STANDRAD,T.JUDGE_STOVE_NO FROM PLN_ZY_JGX_M T WHERE T.HEAT_PLAN_NO=? ";
					PreparedStatement ps1 = conn.prepareStatement(sqlzGm);
					ps1.setObject(1, heatPlanNo);
					ResultSet rs1 = ps1.executeQuery();
					while (rs1.next()) {
						String lotNoGroup = "";
						if (rs1.getString("LOT_NO_GROUP") != null
								&& !rs1.getString("LOT_NO_GROUP").equals("")) {
							lotNoGroup = rs1.getString("LOT_NO_GROUP");
						}
						String sreelStandrad = rs1.getString("STEEL_STANDRAD");
						String feedHeatNo = rs1.getString("JUDGE_STOVE_NO");
						String ordLnDlyPk = rs1.getString("ORD_LN_DLY_PK");
						// 查询是否综合判断
						String sqlQcm = "SELECT T.VALIDFLAG FROM QCM_ZG_JUGDE_APPLY T WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CODE=? AND T.IS_FLAG='0' ";
						ps = conn.prepareStatement(sqlQcm);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						rs = ps.executeQuery();
						while (rs.next()) {
							if (rs.getString("VALIDFLAG").equals("20")) {
								cro.setV_errMsg("判定炉号:" + feedHeatNo
										+ ",已判定不能获取工艺！");
								return cro;
							}
						}
						rs.close();
						ps.close();
						// 更新判定表
						String updateQcm = "UPDATE QCM_ZG_JUGDE_APPLY T SET T.CRAF_NO=?,T.CRAFT_SEQ=?,T.PIC=?,T.SIC=?,T.DIC=?,T.STEEL_STANDRAD ='"
								+ sreelStandrad
								+ "',T.LOT_NO_GROUP='"
								+ lotNoGroup
								+ "' "
								+ ",T.WIC='"
								+ wic
								+ "' WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CODE=? AND T.IS_FLAG='0' ";
						ps = conn.prepareStatement(updateQcm);
						ps.setObject(1, craftFileNo);
						ps.setObject(2, craftSeq);
						ps.setObject(3, pic);
						ps.setObject(4, sic);
						ps.setObject(5, dic);
						ps.setObject(6, feedHeatNo);
						ps.setObject(7, proessCode);
						ps.executeUpdate();
						ps.close();
						// 修改检化验计划表
						String updateMQcm = "UPDATE QCM_ZC_CHECKCONSIGN T SET T.JUDGE_RESULT_CODE = NULL, T.CRAF_NO=?,T.CRAFT_SEQ=?,T.PIC=?,T.STEEL_STANDRAD='"
								+ sreelStandrad
								+ "',T.LOT_NO_GROUP='"
								+ lotNoGroup
								+ "' WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CODE='G' AND T.ORD_LN_DLY_PK = ?";
						ps = conn.prepareStatement(updateMQcm);
						ps.setObject(1, craftFileNo);
						ps.setObject(2, craftSeq);
						ps.setObject(3, pic);
						ps.setObject(4, feedHeatNo);
						ps.setObject(5, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();
						// 修改检验委托表
						String updatePipe = "UPDATE PIPE_CHECKCONSIGN_BASEINFO T SET T.PIC=?,T.CRAFT_FILE_NO=?,T.LOT_NO_GROUP='"
								+ lotNoGroup
								+ "' WHERE T.HEAT_NO=? AND T.PROCESS_CODE='G'";
						ps = jhyCon.prepareStatement(updatePipe);
						ps.setObject(1, pic);
						ps.setObject(2, craftFileNo);
						ps.setObject(3, feedHeatNo);
						ps.executeUpdate();
						ps.close();
						// 更新判庫存
						String updateMat = "UPDATE MAT_BC_M T SET T.CRAF_NO=?,T.CRAFT_SEQ=?,T.JUDGE_STD_DES='"
								+ sreelStandrad
								+ "' WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CDOE=?";
						ps = conn.prepareStatement(updateMat);
						ps.setObject(1, craftFileNo);
						ps.setObject(2, craftSeq);
						ps.setObject(3, feedHeatNo);
						ps.setObject(4, proessCode);
						ps.executeUpdate();
						ps.close();

						// 更新成分实绩表
						String updatejhy = "UPDATE QCM_JHY_ELEMENTS T  SET T.LG_JUDGE_FLAG ='00' WHERE T.JUDGE_STOVE_NO=? AND T.PLINE_CODE IN (SELECT T1.PLINE_CODE FROM COM_BASE_PLINE T1 WHERE T1.PROCESS_CODE=?)  AND T.VALIDFLAG='1' AND EXISTS(SELECT 1 FROM QCM_ZC_CHECKCONSIGN A WHERE A.CHECK_NO = T.SAMPLE_ID AND A.BATCH_NO = T.BATCH_NO AND A.ORD_LN_DLY_PK = ?)";
						ps = conn.prepareStatement(updatejhy);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						// 更新理化判定表
						String updatePh = "UPDATE QCM_JHY_PHYRESULT T  SET T.JUDGE_FLAG ='00' WHERE T.JUDGE_STOVE_NO=? AND T.PLINE_CODE IN (SELECT T1.PLINE_CODE FROM COM_BASE_PLINE T1 WHERE T1.PROCESS_CODE=?)  AND T.VALIDFLAG='1' AND EXISTS(SELECT 1 FROM QCM_ZC_CHECKCONSIGN A WHERE A.CHECK_NO = T.SAMPLE_ID AND A.BATCH_NO = T.BATCH_NO AND A.ORD_LN_DLY_PK = ?)";
						ps = conn.prepareStatement(updatePh);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						// 更新委托二层表
						String setConsignDetail = "UPDATE QCM_ZC_CHECKCONSIGN_DETAIL T SET T.NK_RESULT = NULL, T.JF_RESULT = NULL WHERE EXISTS (SELECT 1 FROM QCM_ZC_CHECKCONSIGN A WHERE A.CHECK_NO = T.CHECK_NO AND A.BATCH_NO = T.BATCH_NO AND A.JUDGE_STOVE_NO = ? AND A.PROCESS_CODE = ? AND A.ORD_LN_DLY_PK = ?)";
						ps = conn.prepareStatement(setConsignDetail);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						// 更新炉批结果表
						String setBatchResult = "UPDATE QCM_BC_BATCH_RESULT T SET T.JUDGE_RESULT_CODE = NULL WHERE T.JUDGE_STOVE_NO = ? AND T.PROCESS_CODE = ? AND T.ORD_LN_DLY_PK = ?";
						ps = conn.prepareStatement(setBatchResult);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();
					}
					rs1.close();
					ps1.close();

				}
			}
			cro.setV_errMsg("获取成功!");
			conn.commit();
			jhyCon.commit();
		} catch (SQLException sqle) {
			try {
				if (conn != null) {
					conn.rollback();
					jhyCon.rollback();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
			cro.setV_errCode(-1);
			cro.setV_errMsg(sqle.getMessage());
		} finally {
			try {
				if (conn != null && !conn.isClosed()) {
					conn.close();
					jhyCon.close();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return cro;
	}

	/**
	 * 订单层重新获取工艺
	 */
	public CoreReturnObject DoModifyProcess(ArrayList<String> jsonList,
			String proessCode) throws ParseException {
		CoreReturnObject cro = new CoreReturnObject();
		Connection jhyCon = null;
		Connection conn = null;
		try {
			conn = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			conn.setAutoCommit(false);
			jhyCon = this.getDao("JhyDao").getConnection();
			jhyCon.setAutoCommit(false);
			PreparedStatement ps = null;
			ResultSet rs = null;
			List<PlnOrderZgSEntity> list = PlnHelper.jsonsToEntityList(
					PlnOrderZgSEntity.class, jsonList);
			int countNum = 0;
			for (PlnOrderZgSEntity zgSEntity : list) {
				String ordLnPk = "";
				String orderNoSeq = "";
				String plnOrderS = "";
				String pic = "";
				String sic = "";
				String dic = "";
				String wic = "";
				String picGroup = "";
				String sicGroup = "";
				String dicGroup = "";
				String wicGroup = "";
				String ifProduct = "0";
				String msc = "";
				String indexSeq = "";
				String bom = "";
				
				String sqlPlnS="SELECT T.ORD_LN_PK, T.ORDER_NO || '/' || T.ORDER_SEQ ORDER_NO_SEQ  FROM PLN_SALEORD T WHERE T.ORD_LN_DLY_PK = ?";
				ps = conn.prepareStatement(sqlPlnS);
				ps.setObject(1, zgSEntity.getOrdLnDlyPk());
				rs = ps.executeQuery();
				if (rs.next()) {
					ordLnPk=rs.getString("ORD_LN_PK");
				}
				rs.close();
				ps.close();
				// 获取最新工艺 CIC
				String[] craftInfo = PlnHelper.getArray(conn,
						"CorePlnSaleOrder.queryOrdCraftOrdDesign",
						" AND T.VALIDFLAG = '1'", new String[] { ordLnPk },
						new String[] { "CRAFT_SEQ", "DESGIN_KEY", "CRAFT_NAME",
								"CRAFT_NO", "CRAFT_NO_V" });
				if (craftInfo == null || craftInfo.length == 0) {
					cro.setV_errMsg("合同行：" + orderNoSeq + "未找到有效的工艺评审！");
					return cro;
				}
				String craftFileNo = craftInfo[3];
				String craftFileMan = craftInfo[2];
				String craftSeq = craftInfo[0];
				String desginKey = craftInfo[1];

				if (proessCode.equals("D")) {
					plnOrderS = "SELECT T.ORD_LN_PK,T.ORDER_NO||'/'||T.ORDER_SEQ ORDER_NO_SEQ,T1.MSC,T1.INDEX_SEQ,T1.BOM  FROM PLN_SALEORD T,PLN_ORDER_ZG_S T1 WHERE T.ORD_LN_DLY_PK=T1.ORD_LN_DLY_PK AND T1.PRO_PLAN_ID=? AND T1.GX_PLAN_NO=?";
					String orders = CoreXmlSqlParsersFactory
							.getSql("StoveHelper.queryZgCf");
					ps = conn.prepareStatement(orders);
					ps.setObject(1, craftSeq);
					ps.setObject(2, desginKey);
					ps.setObject(3, zgSEntity.getProPlanId());
					ps.setObject(4, zgSEntity.getGxPlanNo());
					rs = ps.executeQuery();
					if (rs.next()) {
						if (rs.getString("PIC") != null
								&& !rs.getString("PIC").equals("")) {
							pic = rs.getString("PIC").split(",")[0];
						}
						if (rs.getString("SIC") != null
								&& !rs.getString("SIC").equals("")) {
							sic = rs.getString("SIC").split(",")[0];
						}
						if (rs.getString("DIC") != null
								&& !rs.getString("DIC").equals("")) {
							dic = rs.getString("DIC").split(",")[0];
						}
						picGroup = rs.getString("PIC");
						sicGroup = rs.getString("SIC");
						dicGroup = rs.getString("DIC");

					}
					rs.close();
					ps.close();
					int counnum = StoveHelper.getQueryStation(conn,
							zgSEntity.getProPlanId(), zgSEntity.getGxPlanNo(),
							"D");
					if (counnum > 0) {
						ifProduct = "1";
					}
				} else if (proessCode.equals("E")) {
					String orders = CoreXmlSqlParsersFactory
							.getSql("StoveHelper.queryDbkCf");
					ps = conn.prepareStatement(orders);
					ps.setObject(1, craftSeq);
					ps.setObject(2, desginKey);
					ps.setObject(3, zgSEntity.getProPlanId());
					ps.setObject(4, zgSEntity.getGxPlanNo());
					rs = ps.executeQuery();
					if (rs.next()) {
						if (rs.getString("PIC") != null
								&& !rs.getString("PIC").equals("")) {
							pic = rs.getString("PIC").split(",")[0];
						}
						if (rs.getString("SIC") != null
								&& !rs.getString("SIC").equals("")) {
							sic = rs.getString("SIC").split(",")[0];
						}
						if (rs.getString("DIC") != null
								&& !rs.getString("DIC").equals("")) {
							dic = rs.getString("DIC").split(",")[0];
						}
						picGroup = rs.getString("PIC");
						sicGroup = rs.getString("SIC");
						dicGroup = rs.getString("DIC");
					}
					rs.close();
					ps.close();
					plnOrderS = "SELECT T.ORD_LN_PK,T.ORDER_NO||'/'||T.ORDER_SEQ ORDER_NO_SEQ,T1.MSC,T1.INDEX_SEQ,T1.BOM  FROM PLN_SALEORD T,PLN_ORDER_DBK_S T1 WHERE T.ORD_LN_DLY_PK=T1.ORD_LN_DLY_PK AND T1.PRO_PLAN_ID=? AND T1.GX_PLAN_NO=?";
					int counnum = StoveHelper.getQueryStation(conn,
							zgSEntity.getProPlanId(), zgSEntity.getGxPlanNo(),
							"E");
					if (counnum > 0) {
						ifProduct = "1";
					}
				} else if (proessCode.equals("F")) {
					String orders = CoreXmlSqlParsersFactory
							.getSql("StoveHelper.queryRclCf");
					ps = conn.prepareStatement(orders);
					ps.setObject(1, craftSeq);
					ps.setObject(2, desginKey);
					ps.setObject(3, zgSEntity.getProPlanId());
					ps.setObject(4, zgSEntity.getGxPlanNo());
					rs = ps.executeQuery();
					if (rs.next()) {
						if (rs.getString("PIC") != null
								&& !rs.getString("PIC").equals("")) {
							pic = rs.getString("PIC").split(",")[0];
						}
						if (rs.getString("SIC") != null
								&& !rs.getString("SIC").equals("")) {
							sic = rs.getString("SIC").split(",")[0];
						}
						if (rs.getString("DIC") != null
								&& !rs.getString("DIC").equals("")) {
							dic = rs.getString("DIC").split(",")[0];
						}
						picGroup = rs.getString("PIC");
						sicGroup = rs.getString("SIC");
						dicGroup = rs.getString("DIC");
					}
					rs.close();
					ps.close();
					plnOrderS = "SELECT T.ORD_LN_PK,T.ORDER_NO||'/'||T.ORDER_SEQ ORDER_NO_SEQ,T1.MSC,T1.INDEX_SEQ,T1.BOM  FROM PLN_SALEORD T,PLN_ORDER_RCL_S T1 WHERE T.ORD_LN_DLY_PK=T1.ORD_LN_DLY_PK AND T1.PRO_PLAN_ID=? AND T1.GX_PLAN_NO=?";
					int counnum = StoveHelper.getQueryStation(conn,
							zgSEntity.getProPlanId(), zgSEntity.getGxPlanNo(),
							"F");
					if (counnum > 0) {
						ifProduct = "1";
					}
				} else if (proessCode.equals("G")) {
					String orders = CoreXmlSqlParsersFactory
							.getSql("StoveHelper.queryJgxCf");
					ps = conn.prepareStatement(orders);
					ps.setObject(1, craftSeq);
					ps.setObject(2, desginKey);
					ps.setObject(3, zgSEntity.getProPlanId());
					ps.setObject(4, zgSEntity.getGxPlanNo());
					rs = ps.executeQuery();
					if (rs.next()) {
						if (rs.getString("PIC") != null
								&& !rs.getString("PIC").equals("")) {
							pic = rs.getString("PIC").split(",")[0];
						}
						if (rs.getString("SIC") != null
								&& !rs.getString("SIC").equals("")) {
							sic = rs.getString("SIC").split(",")[0];
						}
						if (rs.getString("DIC") != null
								&& !rs.getString("DIC").equals("")) {
							dic = rs.getString("DIC").split(",")[0];
						}
						if (rs.getString("WIC") != null
								&& !rs.getString("WIC").equals("")) {
							wic = rs.getString("WIC").split(",")[0];
						}
						picGroup = rs.getString("PIC");
						sicGroup = rs.getString("SIC");
						dicGroup = rs.getString("DIC");
						wicGroup = rs.getString("wic");
					}
					rs.close();
					ps.close();
					plnOrderS = "SELECT T.ORD_LN_PK,T.ORDER_NO||'/'||T.ORDER_SEQ ORDER_NO_SEQ,T1.MSC,T1.INDEX_SEQ,T1.BOM  FROM PLN_SALEORD T,PLN_ORDER_JGX_S T1 WHERE T.ORD_LN_DLY_PK=T1.ORD_LN_DLY_PK AND T1.PRO_PLAN_ID=? AND T1.GX_PLAN_NO=?";
					int counnum = StoveHelper.getQueryStation(conn,
							zgSEntity.getProPlanId(), zgSEntity.getGxPlanNo(),
							"G");
					if (counnum > 0) {
						ifProduct = "1";
					}
				}
				ps = conn.prepareStatement(plnOrderS);
				ps.setObject(1, zgSEntity.getProPlanId());
				ps.setObject(2, zgSEntity.getGxPlanNo());
				rs = ps.executeQuery();
				if (rs.next()) {
					ordLnPk = rs.getString("ORD_LN_PK");
					orderNoSeq = rs.getString("ORDER_NO_SEQ");
					msc = rs.getString("MSC");
					indexSeq = rs.getString("INDEX_SEQ");
					bom = rs.getString("BOM");
				}
				rs.close();
				ps.close();

				int countBom = 0;

				List<SlmOrdDesignBomEntity> bomList = PlnHelper.getEntityDatas(
						conn, new String[] { desginKey, msc, indexSeq },
						"CoreOrdDesginBom.getOrdLineMscBom",
						SlmOrdDesignBomEntity.class);
				if (bomList != null && bomList.size() > 0) {
					for (SlmOrdDesignBomEntity bomEntity : bomList) {
						if (bomEntity.getBom().equals(bom)) {
							countBom++;
						}
					}
				}
				// if(countBom==0){
				// cro.setV_errMsg("新工艺不包含订单使用的Bom,不能重新获取工艺！");
				// return cro;
				// }
				// 修改虚拟炉计划
				String updateM = "";
				// 修改订单层
				String updateS = "";
				// 查询是否交库
				String queryMatBc = "";
				if (proessCode.equals("D")) {
					queryMatBc = "SELECT T.FEED_HEAT_NO JUDGE_STOVE_NO FROM PLN_ZY_ZG_M T,(SELECT B.JUDGE_STOVE_NO FROM MAT_BC_M B  WHERE B.PROCESS_CDOE='D' GROUP BY B.JUDGE_STOVE_NO) T1 "
							+ "  WHERE T.FEED_HEAT_NO=T1.JUDGE_STOVE_NO AND T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?";
					updateM = "UPDATE PLN_ZY_ZG_M T SET T.CRAFT_FILE_NO=?,T.CRAFT_FILE_MAN=?,T.CRAFT_SEQ=?,T.PIC=?,T.SIC=?,T.DIC=?,T.IF_PRODUCT='"
							+ ifProduct
							+ "' WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=? ";
					updateS = "UPDATE PLN_ORDER_ZG_S T SET T.CRAFT_FILE_NO=?,T.CRAFT_SEQ=?,T.CRAFT_FILE_MAN=?,T.PIC=?,T.SIC=?,T.DIC=? WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?  ";
				} else if (proessCode.equals("E")) {
					queryMatBc = "SELECT T.JUDGE_STOVE_NO FROM PLN_ZY_DBK_M T,(SELECT B.JUDGE_STOVE_NO FROM MAT_BC_M B  WHERE B.PROCESS_CDOE='E' GROUP BY B.JUDGE_STOVE_NO) T1 "
							+ "  WHERE T.JUDGE_STOVE_NO=T1.JUDGE_STOVE_NO AND T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?";
					updateM = "UPDATE PLN_ZY_DBK_M T SET T.CRAFT_FILE_NO=?,T.CRAFT_FILE_MAN=?,T.CRAFT_SEQ=?,T.PIC=?,T.SIC=?,T.DIC=?,T.IF_PRODUCT='"
							+ ifProduct
							+ "'  WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?  AND T.IF_MATCH_ODD<>'2'";
					updateS = "UPDATE PLN_ORDER_DBK_S T SET T.CRAFT_FILE_NO=?,T.CRAFT_SEQ=?,T.CRAFT_FILE_MAN=?,T.PIC=?,T.SIC=?,T.DIC=? WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?";

				} else if (proessCode.equals("F")) {
					queryMatBc = "SELECT T.JUDGE_STOVE_NO FROM PLN_ZY_RCL_M T,(SELECT B.JUDGE_STOVE_NO FROM MAT_BC_M B  WHERE B.PROCESS_CDOE='F' GROUP BY B.JUDGE_STOVE_NO) T1 "
							+ "  WHERE T.JUDGE_STOVE_NO=T1.JUDGE_STOVE_NO AND T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?";

					updateM = "UPDATE PLN_ZY_RCL_M T SET T.CRAFT_FILE_NO=?,T.CRAFT_FILE_MAN=?,T.CRAFT_SEQ=?,T.PIC=?,T.SIC=?,T.DIC=?,T.IF_PRODUCT='"
							+ ifProduct
							+ "' WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?  AND T.IF_MATCH_ODD<>'2'";
					updateS = "UPDATE PLN_ORDER_RCL_S T SET T.CRAFT_FILE_NO=?,T.CRAFT_SEQ=?,T.CRAFT_FILE_MAN=?,T.PIC=?,T.SIC=?,T.DIC=? WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?";

				} else if (proessCode.equals("G")) {
					queryMatBc = "SELECT T.JUDGE_STOVE_NO FROM PLN_ZY_JGX_M T,(SELECT B.JUDGE_STOVE_NO FROM MAT_BC_M B  WHERE B.PROCESS_CDOE='G' GROUP BY B.JUDGE_STOVE_NO) T1 "
							+ "  WHERE T.JUDGE_STOVE_NO=T1.JUDGE_STOVE_NO AND T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?";

					updateM = "UPDATE PLN_ZY_JGX_M T SET T.CRAFT_FILE_NO=?,T.CRAFT_FILE_MAN=?,T.CRAFT_SEQ=?,T.PIC=?,T.SIC=?,T.DIC=?,T.IF_PRODUCT='"
							+ ifProduct
							+ "',T.WIC='"
							+ wic
							+ "'  WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?  AND T.IF_MATCH_ODD<>'2'";
					updateS = "UPDATE PLN_ORDER_JGX_S T SET T.CRAFT_FILE_NO=?,T.CRAFT_SEQ=?,T.CRAFT_FILE_MAN=?,T.PIC=?,T.SIC=?,T.DIC=?,T.WIC='"
							+ wicGroup
							+ "' WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?";

				}
				String judNo = "";
				// // 查询是否交库
				// ps = conn.prepareStatement(queryMatBc);
				// ps.setObject(1, zgSEntity.getProPlanId());
				// ps.setObject(2, zgSEntity.getGxPlanNo());
				// rs = ps.executeQuery();
				// while (rs.next()) {
				// if (rs.getString("JUDGE_STOVE_NO") != null
				// && !rs.getString("JUDGE_STOVE_NO").equals("")) {
				// // cro.setV_errMsg("在订单(" + zgSEntity.getProPlanId() +
				// // "/"
				// // + zgSEntity.getGxPlanNo() + ")向下炉计划有判定炉号为("
				// // + rs.getString("JUDGE_STOVE_NO")
				// // + ")已交库,不能获取工艺,请撤销交库!");
				// // return cro;
				// judNo += rs.getString("JUDGE_STOVE_NO") + "','";
				// }
				// }
				// rs.close();
				// ps.close();
				// String oldjudNo = "";
				// if (!judNo.equals("")) {
				// oldjudNo = judNo.substring(0, judNo.length() - 3);
				// }

				// 修改订单层
				ps = conn.prepareStatement(updateS);
				ps.setObject(1, craftFileNo);
				ps.setObject(2, craftSeq);
				ps.setObject(3, craftFileMan);
				ps.setObject(4, picGroup);
				ps.setObject(5, sicGroup);
				ps.setObject(6, dicGroup);
				ps.setObject(7, zgSEntity.getProPlanId());
				ps.setObject(8, zgSEntity.getGxPlanNo());
				ps.executeUpdate();
				ps.close();

				// if (!oldjudNo.equals("")) {
				// if (proessCode.equals("D")) {
				// updateM += "AND T.FEED_HEAT_NO NOT IN ('" + oldjudNo
				// + "')";
				// } else {
				// updateM += "AND T.JUDGE_STOVE_NO NOT IN ('" + oldjudNo
				// + "')";
				// }
				// }
				// 修改虚拟炉计划
				ps = conn.prepareStatement(updateM);
				ps.setObject(1, craftFileNo);
				ps.setObject(2, craftFileMan);
				ps.setObject(3, craftSeq);
				ps.setObject(4, pic);
				ps.setObject(5, sic);
				ps.setObject(6, dic);
				ps.setObject(7, zgSEntity.getProPlanId());
				ps.setObject(8, zgSEntity.getGxPlanNo());
				ps.executeUpdate();
				ps.close();

				if (proessCode.equals("D")) {
					String sqlzGm = "SELECT T.HEAT_PLAN_NO, T.ORD_LN_DLY_PK, DECODE(TRIM(T.IF_PRODUCT), 0, '', '1', T.CIC )||'+' ||  T.PIC || '+' || T.SIC || '+' || T.DIC STEEL_STANDRAD,T.FEED_HEAT_NO FROM PLN_ZY_ZG_M T WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=? ";
					// if (!oldjudNo.equals("")) {
					// sqlzGm += "AND T.FEED_HEAT_NO NOT IN ('" + oldjudNo
					// + "')";
					// }
					PreparedStatement ps1 = conn.prepareStatement(sqlzGm);
					ps1.setObject(1, zgSEntity.getProPlanId());
					ps1.setObject(2, zgSEntity.getGxPlanNo());
					ResultSet rs1 = ps1.executeQuery();
					while (rs1.next()) {
						String heatPlanNo = rs1.getString("HEAT_PLAN_NO");
						String sreelStandrad = rs1.getString("STEEL_STANDRAD");
						String feedHeatNo = rs1.getString("FEED_HEAT_NO");
						String ordLnDlyPk = rs1.getString("ORD_LN_DLY_PK");
						String impProcess = "";
						String craftSeqOld = "";
						// 查詢原爐計劃工艺号
						String sql = "SELECT  T.IMP_PROCESS,T.CRAFT_SEQ FROM MIL_PLAN T WHERE T.ID=? ";
						ps = conn.prepareStatement(sql);
						ps.setObject(1, heatPlanNo);
						rs = ps.executeQuery();
						if (rs.next()) {
							impProcess = rs.getString("IMP_PROCESS");
							craftSeqOld = rs.getString("CRAFT_SEQ");
						}
						rs.close();
						ps.close();

						// String sreelStandrad = "";
						// String feedHeatNo = "";
						// sql =
						// "SELECT T1.CIC||'+'||T1.PIC||'+'||T1.SIC||'+'||T1.DIC STEEL_STANDRAD,T1.FEED_HEAT_NO FROM PLN_ZY_ZG_M T1 WHERE T1.HEAT_PLAN_NO=?";
						// ps = conn.prepareStatement(sql);
						// ps.setObject(1, heatPlanNo);
						// rs = ps.executeQuery();
						// if (rs.next()) {
						// sreelStandrad = rs.getString("STEEL_STANDRAD");
						// feedHeatNo = rs.getString("FEED_HEAT_NO");
						// }
						// rs.close();
						// ps.close();

						// 轧管计划表
						String updateMil = "UPDATE MIL_PLAN T SET T.CRAFT_SEQ=?,T.IMP_PROCESS=?,T.PIC=?,T.STEEL_STANDRAD='"
								+ sreelStandrad
								+ "',T.IF_PRODUCT='"
								+ ifProduct + "'  WHERE T.ID=?";
						ps = conn.prepareStatement(updateMil);
						ps.setObject(1, craftSeq);
						ps.setObject(2, craftFileNo);
						ps.setObject(3, pic);
						ps.setObject(4, heatPlanNo);
						ps.executeUpdate();
						ps.close();

						// 查询是否综合判断
						String sqlQcm = "SELECT T.VALIDFLAG,T.JUDGE_RESULT_CODE FROM QCM_ZG_JUGDE_APPLY T WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CODE=? AND T.IS_FLAG='0' ";
						PreparedStatement ps2 = conn.prepareStatement(sqlQcm);
						ps2.setObject(1, feedHeatNo);
						ps2.setObject(2, proessCode);
						ResultSet rs2 = ps2.executeQuery();
						if (rs2.next()) {
							if (rs2.getString("VALIDFLAG").equals("20")) {
								// cro.setV_errMsg("判定炉号:"+feedHeatNo+",已判定不能获取工艺！");
								// return cro;
								if (rs2.getString("JUDGE_RESULT_CODE")==null)
								{
									continue;
								}
								if (!rs2.getString("JUDGE_RESULT_CODE").equals(
										"40740709")) {
									continue;
								}

							}
							countNum++;
						}
						rs2.close();
						ps2.close();
						// 修改检化验计划表
						String updateMQcm = "UPDATE QCM_ZC_CHECKCONSIGN T SET T.JUDGE_RESULT_CODE = NULL, T.CRAF_NO=?,T.CRAFT_SEQ=?,T.PIC=?,T.STEEL_STANDRAD='"
								+ sreelStandrad
								+ "' WHERE T.PRO_ORDER_ID=? AND T.GX_PLAN_NO=? AND T.JUDGE_STOVE_NO=? and T.PROCESS_CODE='D' AND T.ORD_LN_DLY_PK = ?";
						ps = conn.prepareStatement(updateMQcm);
						ps.setObject(1, craftFileNo);
						ps.setObject(2, craftSeq);
						ps.setObject(3, pic);
						ps.setObject(4, zgSEntity.getProPlanId());
						ps.setObject(5, zgSEntity.getGxPlanNo());
						ps.setObject(6, feedHeatNo);
						ps.setObject(7, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						//
						String orders = CoreXmlSqlParsersFactory
								.getSql("StoveHelper.updateQcmZc");
						ps = conn.prepareStatement(orders);
						ps.setObject(1, impProcess);
						ps.setObject(2, craftSeqOld);
						ps.setObject(3, craftFileNo);
						ps.setObject(4, craftSeq);
						ps.setObject(5, pic);
						ps.setObject(6, sreelStandrad);
						ps.setObject(7, craftFileNo);
						ps.setObject(8, craftSeq);
						ps.setObject(9, pic);
						ps.setObject(10, sreelStandrad);
						ps.executeUpdate();
						ps.close();

						// 更新判定表
						String updateQcm = "UPDATE QCM_ZG_JUGDE_APPLY T SET T.CRAF_NO=?,T.CRAFT_SEQ=?,T.PIC=?,T.SIC=?,T.DIC=?,T.STEEL_STANDRAD ='"
								+ sreelStandrad
								+ "' "
								+ " WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CODE=? AND T.IS_FLAG='0' ";
						ps = conn.prepareStatement(updateQcm);
						ps.setObject(1, craftFileNo);
						ps.setObject(2, craftSeq);
						ps.setObject(3, pic);
						ps.setObject(4, sic);
						ps.setObject(5, dic);
						ps.setObject(6, feedHeatNo);
						ps.setObject(7, proessCode);
						ps.executeUpdate();
						ps.close();

						// 更新判庫存
						String updateMat = "UPDATE MAT_BC_M T SET T.CRAF_NO=?,T.CRAFT_SEQ=?,T.JUDGE_STD_DES='"
								+ sreelStandrad
								+ "' WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CDOE=?";
						ps = conn.prepareStatement(updateMat);
						ps.setObject(1, craftFileNo);
						ps.setObject(2, craftSeq);
						ps.setObject(3, feedHeatNo);
						ps.setObject(4, proessCode);
						ps.executeUpdate();
						ps.close();

						// 更新成分实绩表
						String updatejhy = "UPDATE QCM_JHY_ELEMENTS T  SET T.LG_JUDGE_FLAG ='00' WHERE T.JUDGE_STOVE_NO=? AND T.PLINE_CODE IN (SELECT T1.PLINE_CODE FROM COM_BASE_PLINE T1 WHERE T1.PROCESS_CODE=?)  AND T.VALIDFLAG='1' AND EXISTS(SELECT 1 FROM QCM_ZC_CHECKCONSIGN A WHERE A.CHECK_NO = T.SAMPLE_ID AND A.BATCH_NO = T.BATCH_NO AND A.ORD_LN_DLY_PK = ?)";
						ps = conn.prepareStatement(updatejhy);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						// 更新理化判定表
						String updatePh = "UPDATE QCM_JHY_PHYRESULT T  SET T.JUDGE_FLAG ='00' WHERE T.JUDGE_STOVE_NO=? AND T.PLINE_CODE IN (SELECT T1.PLINE_CODE FROM COM_BASE_PLINE T1 WHERE T1.PROCESS_CODE=?)  AND T.VALIDFLAG='1' AND EXISTS(SELECT 1 FROM QCM_ZC_CHECKCONSIGN A WHERE A.CHECK_NO = T.SAMPLE_ID AND A.BATCH_NO = T.BATCH_NO AND A.ORD_LN_DLY_PK = ?)";
						ps = conn.prepareStatement(updatePh);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						// 更新委托二层表
						String setConsignDetail = "UPDATE QCM_ZC_CHECKCONSIGN_DETAIL T SET T.NK_RESULT = NULL, T.JF_RESULT = NULL WHERE EXISTS (SELECT 1 FROM QCM_ZC_CHECKCONSIGN A WHERE A.CHECK_NO = T.CHECK_NO AND A.BATCH_NO = T.BATCH_NO AND A.JUDGE_STOVE_NO = ? AND A.PROCESS_CODE = ? AND A.ORD_LN_DLY_PK = ?)";
						ps = conn.prepareStatement(setConsignDetail);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						// 更新炉批结果表
						String setBatchResult = "UPDATE QCM_BC_BATCH_RESULT T SET T.JUDGE_RESULT_CODE = NULL WHERE T.JUDGE_STOVE_NO = ? AND T.PROCESS_CODE = ? AND T.ORD_LN_DLY_PK = ?";
						ps = conn.prepareStatement(setBatchResult);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

					}
					rs1.close();
					ps1.close();

				} else if (proessCode.equals("E")) {

					String sqlzGm = "SELECT T.HEAT_PLAN_NO, T.ORD_LN_DLY_PK, DECODE(TRIM(T.IF_PRODUCT), 0, '', '1', T.CIC )||'+' || T.PIC || '+' || T.SIC || '+' || T.DIC STEEL_STANDRAD,T.JUDGE_STOVE_NO FROM PLN_ZY_DBK_M T WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=? ";
					PreparedStatement ps1 = conn.prepareStatement(sqlzGm);
					ps1.setObject(1, zgSEntity.getProPlanId());
					ps1.setObject(2, zgSEntity.getGxPlanNo());
					ResultSet rs1 = ps1.executeQuery();
					while (rs1.next()) {
						String sreelStandrad = rs1.getString("STEEL_STANDRAD");
						String feedHeatNo = rs1.getString("JUDGE_STOVE_NO");
						String ordLnDlyPk = rs1.getString("ORD_LN_DLY_PK");

						// 查询是否综合判断
						String sqlQcm = "SELECT T.VALIDFLAG,T.JUDGE_RESULT_CODE FROM QCM_ZG_JUGDE_APPLY T WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CODE=? AND T.IS_FLAG='0' ";
						PreparedStatement ps2 = conn.prepareStatement(sqlQcm);
						ps2.setObject(1, feedHeatNo);
						ps2.setObject(2, proessCode);
						ResultSet rs2 = ps2.executeQuery();
						if (rs2.next()) {
							if (rs2.getString("VALIDFLAG").equals("20")) {
								// cro.setV_errMsg("判定炉号:" + feedHeatNo
								// + ",已判定不能获取工艺！");
								// return cro;
								if (!rs2.getString("JUDGE_RESULT_CODE").equals(
										"40740709")) {
									continue;
								}
							}
							countNum++;
						}
						rs2.close();
						ps2.close();
						// 更新判定表
						String updateQcm = "UPDATE QCM_ZG_JUGDE_APPLY T SET T.CRAF_NO=?,T.CRAFT_SEQ=?,T.PIC=?,T.SIC=?,T.DIC=?,T.STEEL_STANDRAD ='"
								+ sreelStandrad
								+ "' "
								+ " WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CODE=? AND T.IS_FLAG='0' ";
						ps = conn.prepareStatement(updateQcm);
						ps.setObject(1, craftFileNo);
						ps.setObject(2, craftSeq);
						ps.setObject(3, pic);
						ps.setObject(4, sic);
						ps.setObject(5, dic);
						ps.setObject(6, feedHeatNo);
						ps.setObject(7, proessCode);
						ps.executeUpdate();
						ps.close();
						// 修改检化验计划表
						String updateMQcm = "UPDATE QCM_ZC_CHECKCONSIGN T SET T.JUDGE_RESULT_CODE = NULL, T.CRAF_NO=?,T.CRAFT_SEQ=?,T.PIC=?,T.STEEL_STANDRAD='"
								+ sreelStandrad
								+ "' WHERE T.PRO_ORDER_ID=? AND T.GX_PLAN_NO=? AND T.JUDGE_STOVE_NO=? and PROCESS_CODE='E' AND T.ORD_LN_DLY_PK = ?";
						ps = conn.prepareStatement(updateMQcm);
						ps.setObject(1, craftFileNo);
						ps.setObject(2, craftSeq);
						ps.setObject(3, pic);
						ps.setObject(4, zgSEntity.getProPlanId());
						ps.setObject(5, zgSEntity.getGxPlanNo());
						ps.setObject(6, feedHeatNo);
						ps.setObject(7, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();
						// 更新判庫存
						String updateMat = "UPDATE MAT_BC_M T SET T.CRAF_NO=?,T.CRAFT_SEQ=?,T.JUDGE_STD_DES='"
								+ sreelStandrad
								+ "' WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CDOE=?";
						ps = conn.prepareStatement(updateMat);
						ps.setObject(1, craftFileNo);
						ps.setObject(2, craftSeq);
						ps.setObject(3, feedHeatNo);
						ps.setObject(4, proessCode);
						ps.executeUpdate();
						ps.close();

						// 更新成分实绩表
						String updatejhy = "UPDATE QCM_JHY_ELEMENTS T  SET T.LG_JUDGE_FLAG ='00' WHERE T.JUDGE_STOVE_NO=? AND T.PLINE_CODE IN (SELECT T1.PLINE_CODE FROM COM_BASE_PLINE T1 WHERE T1.PROCESS_CODE=?)  AND T.VALIDFLAG='1' AND EXISTS(SELECT 1 FROM QCM_ZC_CHECKCONSIGN A WHERE A.CHECK_NO = T.SAMPLE_ID AND A.BATCH_NO = T.BATCH_NO AND A.ORD_LN_DLY_PK = ?)";
						ps = conn.prepareStatement(updatejhy);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						// 更新理化判定表
						String updatePh = "UPDATE QCM_JHY_PHYRESULT T  SET T.JUDGE_FLAG ='00' WHERE T.JUDGE_STOVE_NO=? AND T.PLINE_CODE IN (SELECT T1.PLINE_CODE FROM COM_BASE_PLINE T1 WHERE T1.PROCESS_CODE=?)  AND T.VALIDFLAG='1' AND EXISTS(SELECT 1 FROM QCM_ZC_CHECKCONSIGN A WHERE A.CHECK_NO = T.SAMPLE_ID AND A.BATCH_NO = T.BATCH_NO AND A.ORD_LN_DLY_PK = ?)";
						ps = conn.prepareStatement(updatePh);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						// 更新委托二层表
						String setConsignDetail = "UPDATE QCM_ZC_CHECKCONSIGN_DETAIL T SET T.NK_RESULT = NULL, T.JF_RESULT = NULL WHERE EXISTS (SELECT 1 FROM QCM_ZC_CHECKCONSIGN A WHERE A.CHECK_NO = T.CHECK_NO AND A.BATCH_NO = T.BATCH_NO AND A.JUDGE_STOVE_NO = ? AND A.PROCESS_CODE = ? AND A.ORD_LN_DLY_PK = ?)";
						ps = conn.prepareStatement(setConsignDetail);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						// 更新炉批结果表
						String setBatchResult = "UPDATE QCM_BC_BATCH_RESULT T SET T.JUDGE_RESULT_CODE = NULL WHERE T.JUDGE_STOVE_NO = ? AND T.PROCESS_CODE = ? AND T.ORD_LN_DLY_PK = ?";
						ps = conn.prepareStatement(setBatchResult);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

					}
					rs1.close();
					ps1.close();

				} else if (proessCode.equals("F")) {
					// 调整顺序修改生产批
					updatePlnRclGroup(conn, zgSEntity.getProPlanId(),
							zgSEntity.getGxPlanNo(), pic);
					String sqlzGm = "SELECT T.HEAT_PLAN_NO, T.ORD_LN_DLY_PK, DECODE(TRIM(T.IF_PRODUCT), 0, '', '1', T.CIC )||'+' || T.PIC || '+' || T.SIC || '+' || T.DIC STEEL_STANDRAD,T.JUDGE_STOVE_NO,T.LOT_NO_GROUP FROM PLN_ZY_RCL_M T WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=? ";
					PreparedStatement ps1 = conn.prepareStatement(sqlzGm);
					ps1.setObject(1, zgSEntity.getProPlanId());
					ps1.setObject(2, zgSEntity.getGxPlanNo());
					ResultSet rs1 = ps1.executeQuery();
					while (rs1.next()) {
						String sreelStandrad = rs1.getString("STEEL_STANDRAD");
						String feedHeatNo = rs1.getString("JUDGE_STOVE_NO");
						String lotNoGroup = "";
						if (rs1.getString("LOT_NO_GROUP") != null
								&& !rs1.getString("LOT_NO_GROUP").equals("")) {
							lotNoGroup = rs1.getString("LOT_NO_GROUP");
						}
						String ordLnDlyPk = rs1.getString("ORD_LN_DLY_PK");

						// 查询是否综合判断
						String sqlQcm = "SELECT T.VALIDFLAG,T.JUDGE_RESULT_CODE FROM QCM_ZG_JUGDE_APPLY T WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CODE=? AND T.IS_FLAG='0' ";
						PreparedStatement ps2 = conn.prepareStatement(sqlQcm);
						ps2.setObject(1, feedHeatNo);
						ps2.setObject(2, proessCode);
						ResultSet rs2 = ps2.executeQuery();
						if (rs2.next()) {
							if (rs2.getString("VALIDFLAG").equals("20")) {
								// cro.setV_errMsg("判定炉号:" + feedHeatNo
								// + ",已判定不能获取工艺！");
								// return cro;
								if (!rs2.getString("JUDGE_RESULT_CODE").equals(
										"40740709")) {
									continue;
								}
							}
							countNum++;
						}
						rs2.close();
						ps2.close();
						// 更新判定表
						String updateQcm = "UPDATE QCM_ZG_JUGDE_APPLY T SET T.CRAF_NO=?,T.CRAFT_SEQ=?,T.PIC=?,T.SIC=?,T.DIC=?,T.STEEL_STANDRAD ='"
								+ sreelStandrad
								+ "',T.LOT_NO_GROUP='"
								+ lotNoGroup
								+ "' "
								+ " WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CODE=? AND T.IS_FLAG='0'  ";
						ps = conn.prepareStatement(updateQcm);
						ps.setObject(1, craftFileNo);
						ps.setObject(2, craftSeq);
						ps.setObject(3, pic);
						ps.setObject(4, sic);
						ps.setObject(5, dic);
						ps.setObject(6, feedHeatNo);
						ps.setObject(7, proessCode);
						ps.executeUpdate();
						ps.close();
						// 修改检化验计划表
						String updateMQcm = "UPDATE QCM_ZC_CHECKCONSIGN T SET T.JUDGE_RESULT_CODE = NULL, T.CRAF_NO=?,T.CRAFT_SEQ=?,T.PIC=?,T.STEEL_STANDRAD='"
								+ sreelStandrad
								+ "',T.LOT_NO_GROUP='"
								+ lotNoGroup
								+ "' WHERE T.PRO_ORDER_ID=? AND T.GX_PLAN_NO=? AND T.JUDGE_STOVE_NO=? and T.PROCESS_CODE='F' AND T.ORD_LN_DLY_PK = ?";
						ps = conn.prepareStatement(updateMQcm);
						ps.setObject(1, craftFileNo);
						ps.setObject(2, craftSeq);
						ps.setObject(3, pic);
						ps.setObject(4, zgSEntity.getProPlanId());
						ps.setObject(5, zgSEntity.getGxPlanNo());
						ps.setObject(6, feedHeatNo);
						ps.setObject(7, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						// 修改检验委托表
						String updatePipe = "UPDATE PIPE_CHECKCONSIGN_BASEINFO T SET T.PIC=?,T.CRAFT_FILE_NO=?,T.LOT_NO_GROUP='"
								+ lotNoGroup
								+ "' WHERE T.HEAT_NO=? AND T.PROCESS_CODE='F'";
						ps = jhyCon.prepareStatement(updatePipe);
						ps.setObject(1, pic);
						ps.setObject(2, craftFileNo);
						ps.setObject(3, feedHeatNo);
						ps.executeUpdate();
						ps.close();

						// 更新判庫存
						String updateMat = "UPDATE MAT_BC_M T SET T.CRAF_NO=?,T.CRAFT_SEQ=?,T.JUDGE_STD_DES='"
								+ sreelStandrad
								+ "' WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CDOE=?";
						ps = conn.prepareStatement(updateMat);
						ps.setObject(1, craftFileNo);
						ps.setObject(2, craftSeq);
						ps.setObject(3, feedHeatNo);
						ps.setObject(4, proessCode);
						ps.executeUpdate();
						ps.close();

						// 更新成分实绩表
						String updatejhy = "UPDATE QCM_JHY_ELEMENTS T  SET T.LG_JUDGE_FLAG ='00' WHERE T.JUDGE_STOVE_NO=? AND T.PLINE_CODE IN (SELECT T1.PLINE_CODE FROM COM_BASE_PLINE T1 WHERE T1.PROCESS_CODE=?)  AND T.VALIDFLAG='1' AND EXISTS(SELECT 1 FROM QCM_ZC_CHECKCONSIGN A WHERE A.CHECK_NO = T.SAMPLE_ID AND A.BATCH_NO = T.BATCH_NO AND A.ORD_LN_DLY_PK = ?)";
						ps = conn.prepareStatement(updatejhy);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						// 更新理化判定表
						String updatePh = "UPDATE QCM_JHY_PHYRESULT T  SET T.JUDGE_FLAG ='00' WHERE T.JUDGE_STOVE_NO=? AND T.PLINE_CODE IN (SELECT T1.PLINE_CODE FROM COM_BASE_PLINE T1 WHERE T1.PROCESS_CODE=?)  AND T.VALIDFLAG='1' AND EXISTS(SELECT 1 FROM QCM_ZC_CHECKCONSIGN A WHERE A.CHECK_NO = T.SAMPLE_ID AND A.BATCH_NO = T.BATCH_NO AND A.ORD_LN_DLY_PK = ?)";
						ps = conn.prepareStatement(updatePh);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						// 更新委托二层表
						String setConsignDetail = "UPDATE QCM_ZC_CHECKCONSIGN_DETAIL T SET T.NK_RESULT = NULL, T.JF_RESULT = NULL WHERE EXISTS (SELECT 1 FROM QCM_ZC_CHECKCONSIGN A WHERE A.CHECK_NO = T.CHECK_NO AND A.BATCH_NO = T.BATCH_NO AND A.JUDGE_STOVE_NO = ? AND A.PROCESS_CODE = ? AND A.ORD_LN_DLY_PK = ?)";
						ps = conn.prepareStatement(setConsignDetail);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						// 更新炉批结果表
						String setBatchResult = "UPDATE QCM_BC_BATCH_RESULT T SET T.JUDGE_RESULT_CODE = NULL WHERE T.JUDGE_STOVE_NO = ? AND T.PROCESS_CODE = ? AND T.ORD_LN_DLY_PK = ?";
						ps = conn.prepareStatement(setBatchResult);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

					}
					rs1.close();
					ps1.close();

					// // 新增生产批号
					// StoveHelper.updatePlnRclGroup(conn,
					// zgSEntity.getProPlanId(), zgSEntity.getGxPlanNo(),
					// pic);
				} else if (proessCode.equals("G")) {
					// 调整顺序修改生产批
					updatePlnJgxGroup(conn, zgSEntity.getProPlanId(),
							zgSEntity.getGxPlanNo(), pic);
					String sqlzGm = "SELECT T.HEAT_PLAN_NO, T.ORD_LN_DLY_PK,T.LOT_NO_GROUP, DECODE(TRIM(T.IF_PRODUCT), 0, '', '1', T.CIC )||'+' || T.PIC || '+' || T.SIC || '+' || T.DIC STEEL_STANDRAD,T.JUDGE_STOVE_NO FROM PLN_ZY_JGX_M T WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=? ";
					PreparedStatement ps1 = conn.prepareStatement(sqlzGm);
					ps1.setObject(1, zgSEntity.getProPlanId());
					ps1.setObject(2, zgSEntity.getGxPlanNo());
					ResultSet rs1 = ps1.executeQuery();
					while (rs1.next()) {
						String sreelStandrad = rs1.getString("STEEL_STANDRAD");
						String feedHeatNo = rs1.getString("JUDGE_STOVE_NO");
						String ordLnDlyPk = rs1.getString("ORD_LN_DLY_PK");
						String lotNoGroup = "";
						if (rs1.getString("LOT_NO_GROUP") != null
								&& !rs1.getString("LOT_NO_GROUP").equals("")) {
							lotNoGroup = rs1.getString("LOT_NO_GROUP");
						}
						// 查询是否综合判断
						String sqlQcm = "SELECT T.VALIDFLAG,T.JUDGE_RESULT_CODE FROM QCM_ZG_JUGDE_APPLY T WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CODE=? AND T.IS_FLAG='0' ";
						PreparedStatement ps2 = conn.prepareStatement(sqlQcm);
						ps2.setObject(1, feedHeatNo);
						ps2.setObject(2, proessCode);
						ResultSet rs2 = ps2.executeQuery();
						if (rs2.next()) {
							if (rs2.getString("VALIDFLAG").equals("20")) {
								// cro.setV_errMsg("判定炉号:" + feedHeatNo
								// + ",已判定不能获取工艺！");
								// return cro;
								if (!rs2.getString("JUDGE_RESULT_CODE").equals(
										"40740709")) {
									continue;
								}
							}
							countNum++;
						}
						rs2.close();
						ps2.close();
						// 更新判定表
						String updateQcm = "UPDATE QCM_ZG_JUGDE_APPLY T SET T.CRAF_NO=?,T.CRAFT_SEQ=?,T.PIC=?,T.SIC=?,T.DIC=?,T.STEEL_STANDRAD ='"
								+ sreelStandrad
								+ "',T.LOT_NO_GROUP='"
								+ lotNoGroup
								+ "' "
								+ ",T.WIC='"
								+ wic
								+ "' WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CODE=? AND T.IS_FLAG='0' ";
						ps = conn.prepareStatement(updateQcm);
						ps.setObject(1, craftFileNo);
						ps.setObject(2, craftSeq);
						ps.setObject(3, pic);
						ps.setObject(4, sic);
						ps.setObject(5, dic);
						ps.setObject(6, feedHeatNo);
						ps.setObject(7, proessCode);
						ps.executeUpdate();
						ps.close();
						// 修改检化验计划表
						String updateMQcm = "UPDATE QCM_ZC_CHECKCONSIGN T SET T.JUDGE_RESULT_CODE = NULL, T.CRAF_NO=?,T.CRAFT_SEQ=?,T.PIC=?,T.STEEL_STANDRAD='"
								+ sreelStandrad
								+ "',T.LOT_NO_GROUP='"
								+ lotNoGroup
								+ "' WHERE T.PRO_ORDER_ID=? AND T.GX_PLAN_NO=? AND T.JUDGE_STOVE_NO=? and PROCESS_CODE='G' AND T.ORD_LN_DLY_PK = ?";
						ps = conn.prepareStatement(updateMQcm);
						ps.setObject(1, craftFileNo);
						ps.setObject(2, craftSeq);
						ps.setObject(3, pic);
						ps.setObject(4, zgSEntity.getProPlanId());
						ps.setObject(5, zgSEntity.getGxPlanNo());
						ps.setObject(6, feedHeatNo);
						ps.setObject(7, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();
						// 修改检验委托表
						String updatePipe = "UPDATE PIPE_CHECKCONSIGN_BASEINFO T SET T.PIC=?,T.CRAFT_FILE_NO=?,T.LOT_NO_GROUP='"
								+ lotNoGroup
								+ "' WHERE T.HEAT_NO=? AND T.PROCESS_CODE='G'";
						ps = jhyCon.prepareStatement(updatePipe);
						ps.setObject(1, pic);
						ps.setObject(2, craftFileNo);
						ps.setObject(3, feedHeatNo);
						ps.executeUpdate();
						ps.close();

						// 更新判庫存
						String updateMat = "UPDATE MAT_BC_M T SET T.CRAF_NO=?,T.CRAFT_SEQ=?,T.JUDGE_STD_DES='"
								+ sreelStandrad
								+ "' WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CDOE=?";
						ps = conn.prepareStatement(updateMat);
						ps.setObject(1, craftFileNo);
						ps.setObject(2, craftSeq);
						ps.setObject(3, feedHeatNo);
						ps.setObject(4, proessCode);
						ps.executeUpdate();
						ps.close();

						// 更新成分实绩表
						String updatejhy = "UPDATE QCM_JHY_ELEMENTS T  SET T.LG_JUDGE_FLAG ='00' WHERE T.JUDGE_STOVE_NO=? AND T.PLINE_CODE IN (SELECT T1.PLINE_CODE FROM COM_BASE_PLINE T1 WHERE T1.PROCESS_CODE=?)  AND T.VALIDFLAG='1' AND EXISTS(SELECT 1 FROM QCM_ZC_CHECKCONSIGN A WHERE A.CHECK_NO = T.SAMPLE_ID AND A.BATCH_NO = T.BATCH_NO AND A.ORD_LN_DLY_PK = ?)";
						ps = conn.prepareStatement(updatejhy);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						// 更新理化判定表
						String updatePh = "UPDATE QCM_JHY_PHYRESULT T  SET T.JUDGE_FLAG ='00' WHERE T.JUDGE_STOVE_NO=? AND T.PLINE_CODE IN (SELECT T1.PLINE_CODE FROM COM_BASE_PLINE T1 WHERE T1.PROCESS_CODE=?)  AND T.VALIDFLAG='1' AND EXISTS(SELECT 1 FROM QCM_ZC_CHECKCONSIGN A WHERE A.CHECK_NO = T.SAMPLE_ID AND A.BATCH_NO = T.BATCH_NO AND A.ORD_LN_DLY_PK = ?)";
						ps = conn.prepareStatement(updatePh);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						// 更新委托二层表
						String setConsignDetail = "UPDATE QCM_ZC_CHECKCONSIGN_DETAIL T SET T.NK_RESULT = NULL, T.JF_RESULT = NULL WHERE EXISTS (SELECT 1 FROM QCM_ZC_CHECKCONSIGN A WHERE A.CHECK_NO = T.CHECK_NO AND A.BATCH_NO = T.BATCH_NO AND A.JUDGE_STOVE_NO = ? AND A.PROCESS_CODE = ? AND A.ORD_LN_DLY_PK = ?)";
						ps = conn.prepareStatement(setConsignDetail);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

						// 更新炉批结果表
						String setBatchResult = "UPDATE QCM_BC_BATCH_RESULT T SET T.JUDGE_RESULT_CODE = NULL WHERE T.JUDGE_STOVE_NO = ? AND T.PROCESS_CODE = ? AND T.ORD_LN_DLY_PK = ?";
						ps = conn.prepareStatement(setBatchResult);
						ps.setObject(1, feedHeatNo);
						ps.setObject(2, proessCode);
						ps.setObject(3, ordLnDlyPk);
						ps.executeUpdate();
						ps.close();

					}
					rs1.close();
					ps1.close();

				}

			}
			cro.setV_errMsg("获取成功!");
			// if(countNum!=0){
			conn.commit();
			jhyCon.commit();
			// }

		} catch (SQLException sqle) {
			try {
				if (conn != null) {
					conn.rollback();
					jhyCon.rollback();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
			cro.setV_errCode(-1);
			cro.setV_errMsg(sqle.getMessage());
		} finally {
			try {
				if (conn != null && !conn.isClosed()) {
					conn.close();
					jhyCon.close();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return cro;
	}
	/**
	 * 热处理炉内顺序调整
	 *
	 * @param
	 * @param
	 * @param
	 * @return
	 */
	public CoreReturnObject sortLotNoSeq(ArrayList<String> jsonstrList,
										 String jsonStrM) {
		CoreReturnObject core = new CoreReturnObject();
		Connection con = null;
		Connection jhyCon = null;
		try {
			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			con.setAutoCommit(false);

			jhyCon = this.getDao("JhyDao").getConnection();
			jhyCon.setAutoCommit(false);
			// 移动行
			List<PlnZyRclMEntity> entityList = new ArrayList<PlnZyRclMEntity>();
			for (String jsonStr : jsonstrList) {
				PlnZyRclMEntity proEntity = BaseHelper.jsonToEntity(
						PlnZyRclMEntity.class, jsonStr);
				entityList.add(proEntity);
			}
			// 定位行
			PlnZyRclMEntity entityM = BaseHelper.jsonToEntity(
					PlnZyRclMEntity.class, jsonStrM);
			if (entityM == null) {
				return core;
			}
			// String plineCode = entityM.getPlineCode();// 用于生产批次号
			/**
			 * 1.判断数据
			 */
			// 1.1定位行数据状态
			// if (!entityM.getPlanstatus().equals("0")
			// || entityM.getLotNoSqe() != entityM.getOrglgxProSeq()) {
			// return core;
			// }
			// 已下发的数据在排产界面不能调整顺序
			// if (processCode.equals("E")) {
			// if (entityM.getIfStoveIssued().equals("1")
			// && customInfo.equals("1")) {
			// return core;
			// }
			// }
			int gxProSeqM = Integer.parseInt(entityM.getLotNoSqe()); // 移至行序号
			int[] intArray = new int[entityList.size()];
			// 1.2移动行数据
			for (int i = 0; i < entityList.size(); i++) {
				PlnZyRclMEntity entity = entityList.get(i);
				if (entity == null) {
					return core;
				}
				// if (!entity.getExeStatus().equals("0")
				// || entity.getGxProSeq() != entity.getOrglgxProSeq()) {
				// return core;
				// }
				intArray[i] = Integer.parseInt(entity.getLotNoSqe());
			}
			// // 1.3必须是在调整行的序号中间
			// if (gxProSeqM >= intArray[0]
			// && gxProSeqM <= intArray[entityList.size() - 1]) {
			// return core;
			// }
			// Arrays.sort(intArray);
			// 调整行操作
			/**
			 * 2. 前移(需要操作步骤:1.)
			 */
			if (gxProSeqM <= intArray[0]) {
				for (int i = 0; i < entityList.size(); i++) {
					// 2.1序号自动调整
					PlnZyRclMEntity entity = entityList.get(i);
					seqIncreaseLot(con, entity.getProPlanId(),
							entity.getGxPlanNo(), gxProSeqM,
							Integer.parseInt(entity.getLotNoSqe()), 1, "F");
					entity.setLotNoSqe(String.valueOf(gxProSeqM));
					// 2.2修改移动数据
					String sql = "UPDATE PLN_ZY_RCL_M T SET T.LOT_NO_SQE = ?"
							+ " WHERE T.HEAT_PLAN_NO=?";
					PreparedStatement ps = con.prepareStatement(sql);
					ps.setObject(1, gxProSeqM);
					ps.setObject(2, entity.getHeatPlanNo());
					ps.executeUpdate();
					ps.close();
					gxProSeqM = gxProSeqM + 1;
				}
			} else {
				/**
				 * 3.后移
				 */
				// 如果不是小于最小序号,那么肯定是大于最大序号,前面加以限制
				int differNum = 0;
				for (int i = 0; i < entityList.size(); i++) {
					PlnZyRclMEntity entity = entityList.get(i);
					// 3.1序号自动调整
					seqIncreaseLot(con, entity.getProPlanId(),
							entity.getGxPlanNo(),
							Integer.parseInt(entity.getLotNoSqe()) - differNum,
							gxProSeqM + 1, -1, "F");
					entity.setLotNoSqe(String.valueOf(gxProSeqM));
					// 3.2 修改数据
					String sql = "UPDATE PLN_ZY_RCL_M T SET T.LOT_NO_SQE = ?"
							+ " WHERE T.HEAT_PLAN_NO=?";
					PreparedStatement ps = con.prepareStatement(sql);
					ps.setObject(1, gxProSeqM);
					ps.setObject(2, entity.getHeatPlanNo());
					ps.executeUpdate();
					ps.close();
					differNum++;
				}
			}
			// 调整顺序修改生产批
			updatePlnRclGroup(con, entityM.getProPlanId(),
					entityM.getGxPlanNo(), entityM.getPic());
			// 修改送判表，检验计划表
			String sqlzGm = "SELECT T.HEAT_PLAN_NO,T.LOT_NO_GROUP, T.JUDGE_STOVE_NO FROM PLN_ZY_RCL_M T WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=? ";
			PreparedStatement ps1 = con.prepareStatement(sqlzGm);
			ps1.setObject(1, entityM.getProPlanId());
			ps1.setObject(2, entityM.getGxPlanNo());
			ResultSet rs1 = ps1.executeQuery();
			while (rs1.next()) {
				String lotNoGroup = rs1.getString("LOT_NO_GROUP");
				String feedHeatNo = rs1.getString("JUDGE_STOVE_NO");

				// // 查询是否综合判断
				// String sqlQcm =
				// "SELECT T.VALIDFLAG,T.JUDGE_RESULT_CODE FROM QCM_ZG_JUGDE_APPLY T WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CODE=? AND T.IS_FLAG='0' ";
				// PreparedStatement ps = con.prepareStatement(sqlQcm);
				// ps.setObject(1, feedHeatNo);
				// ps.setObject(2, "F");
				// ResultSet rs = ps.executeQuery();
				// while (rs.next()) {
				// if (rs.getString("VALIDFLAG").equals("20")) {
				// if (!rs.getString("JUDGE_RESULT_CODE").equals(
				// "40740709")) {
				// core.setV_errMsg("判定炉号:" + feedHeatNo
				// + ",已判定不能获取工艺！");
				// return core;
				// }
				// }
				// }
				// rs.close();
				// ps.close();
				// 更新判定表
				String updateQcm = "UPDATE QCM_ZG_JUGDE_APPLY T SET T.LOT_NO_GROUP='"
						+ lotNoGroup
						+ "' "
						+ " WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CODE='F' AND T.IS_FLAG='0'";
				PreparedStatement ps = con.prepareStatement(updateQcm);
				ps.setObject(1, feedHeatNo);
				ps.executeUpdate();
				ps.close();
				// 修改检化验计划表
				String updateMQcm = "UPDATE QCM_ZC_CHECKCONSIGN T SET T.LOT_NO_GROUP='"
						+ lotNoGroup
						+ "' WHERE T.PRO_ORDER_ID=? AND T.GX_PLAN_NO=? AND T.JUDGE_STOVE_NO=? and PROCESS_CODE='F'";
				ps = con.prepareStatement(updateMQcm);
				ps.setObject(1, entityM.getProPlanId());
				ps.setObject(2, entityM.getGxPlanNo());
				ps.setObject(3, feedHeatNo);
				ps.executeUpdate();
				ps.close();
				// 修改检验委托表
				String updatePipe = "UPDATE PIPE_CHECKCONSIGN_BASEINFO T SET T.LOT_NO_GROUP='"
						+ lotNoGroup
						+ "' WHERE T.HEAT_NO=? AND T.PROCESS_CODE='F'";
				ps = jhyCon.prepareStatement(updatePipe);
				ps.setObject(1, feedHeatNo);
				ps.executeUpdate();
				ps.close();

			}
			rs1.close();
			ps1.close();

			core.setV_errMsg("移动成功!");
			con.commit();
			jhyCon.commit();
		} catch (Exception e) {
			e.printStackTrace();
			try {
				if (con != null) {
					con.rollback();
					jhyCon.rollback();
				}
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		} finally {
			try {
				if (con != null && !con.isClosed())
					con.close();
				jhyCon.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return core;
	}

	/**
	 * 热处理炉内顺序调整
	 * 
	 * @param
	 * @param
	 * @param
	 * @return
	 */
	public CoreReturnObject sortLotNoSeqNew(ArrayList<String> jsonstrList,
			String jsonStrM) {
		CoreReturnObject core = new CoreReturnObject();
		Connection con = null;
		Connection jhyCon = null;
		try {
			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			con.setAutoCommit(false);

			jhyCon = this.getDao("JhyDao").getConnection();
			jhyCon.setAutoCommit(false);
			// 移动行
			List<PlnZyRclMEntity> entityList = new ArrayList<PlnZyRclMEntity>();
			for (String jsonStr : jsonstrList) {
				PlnZyRclMEntity proEntity = BaseHelper.jsonToEntity(
						PlnZyRclMEntity.class, jsonStr);
				entityList.add(proEntity);
			}
			// 定位行
			PlnZyRclMEntity entityM = BaseHelper.jsonToEntity(
					PlnZyRclMEntity.class, jsonStrM);
			if (entityM == null) {
				return core;
			}
			// String plineCode = entityM.getPlineCode();// 用于生产批次号
			/**
			 * 1.判断数据
			 */
			// 1.1定位行数据状态
			// if (!entityM.getPlanstatus().equals("0")
			// || entityM.getLotNoSqe() != entityM.getOrglgxProSeq()) {
			// return core;
			// }
			// 已下发的数据在排产界面不能调整顺序
			// if (processCode.equals("E")) {
			// if (entityM.getIfStoveIssued().equals("1")
			// && customInfo.equals("1")) {
			// return core;
			// }
			// }
			int gxProSeqM = Integer.parseInt(entityM.getLotNoSqe()); // 移至行序号
			int[] intArray = new int[entityList.size()];
			// 1.2移动行数据
			for (int i = 0; i < entityList.size(); i++) {
				PlnZyRclMEntity entity = entityList.get(i);
				if (entity == null) {
					return core;
				}
				// if (!entity.getExeStatus().equals("0")
				// || entity.getGxProSeq() != entity.getOrglgxProSeq()) {
				// return core;
				// }
				intArray[i] = Integer.parseInt(entity.getLotNoSqe());
			}
			// // 1.3必须是在调整行的序号中间
			// if (gxProSeqM >= intArray[0]
			// && gxProSeqM <= intArray[entityList.size() - 1]) {
			// return core;
			// }
			// Arrays.sort(intArray);
			// 调整行操作
			/**
			 * 2. 前移(需要操作步骤:1.)
			 */
			if (gxProSeqM <= intArray[0]) {
				for (int i = 0; i < entityList.size(); i++) {
					// 2.1序号自动调整
					PlnZyRclMEntity entity = entityList.get(i);
					seqIncreaseLot(con, entity.getProPlanId(),
							entity.getGxPlanNo(), gxProSeqM,
							Integer.parseInt(entity.getLotNoSqe()), 1, "F");
					entity.setLotNoSqe(String.valueOf(gxProSeqM));
					// 2.2修改移动数据
					String sql = "UPDATE PLN_ZY_RCL_M T SET T.LOT_NO_SQE = ?"
							+ " WHERE T.HEAT_PLAN_NO=?";
					PreparedStatement ps = con.prepareStatement(sql);
					ps.setObject(1, gxProSeqM);
					ps.setObject(2, entity.getHeatPlanNo());
					ps.executeUpdate();
					ps.close();
					gxProSeqM = gxProSeqM + 1;
				}
			} else {
				/**
				 * 3.后移
				 */
				// 如果不是小于最小序号,那么肯定是大于最大序号,前面加以限制
				int differNum = 0;
				for (int i = 0; i < entityList.size(); i++) {
					PlnZyRclMEntity entity = entityList.get(i);
					// 3.1序号自动调整
					seqIncreaseLot(con, entity.getProPlanId(),
							entity.getGxPlanNo(),
							Integer.parseInt(entity.getLotNoSqe()) - differNum,
							gxProSeqM + 1, -1, "F");
					entity.setLotNoSqe(String.valueOf(gxProSeqM));
					// 3.2 修改数据
					String sql = "UPDATE PLN_ZY_RCL_M T SET T.LOT_NO_SQE = ?"
							+ " WHERE T.HEAT_PLAN_NO=?";
					PreparedStatement ps = con.prepareStatement(sql);
					ps.setObject(1, gxProSeqM);
					ps.setObject(2, entity.getHeatPlanNo());
					ps.executeUpdate();
					ps.close();
					differNum++;
				}
			}

			core.setV_errMsg("移动成功!");
			con.commit();
			jhyCon.commit();
		} catch (Exception e) {
			e.printStackTrace();
			try {
				if (con != null) {
					con.rollback();
					jhyCon.rollback();
				}
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		} finally {
			try {
				if (con != null && !con.isClosed())
					con.close();
				jhyCon.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return core;
	}

	/**
	 * 加工线炉内顺序调整
	 * 
	 * @param
	 * @param
	 * @param
	 * @return
	 */
	public CoreReturnObject sortLotNoSeqJgx(ArrayList<String> jsonstrList,
			String jsonStrM) {
		CoreReturnObject core = new CoreReturnObject();
		Connection con = null;
		Connection jhyCon = null;
		try {
			con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			con.setAutoCommit(false);

			jhyCon = this.getDao("JhyDao").getConnection();
			jhyCon.setAutoCommit(false);
			// 移动行
			List<PlnZyJgxMEntity> entityList = new ArrayList<PlnZyJgxMEntity>();
			for (String jsonStr : jsonstrList) {
				PlnZyJgxMEntity proEntity = BaseHelper.jsonToEntity(
						PlnZyJgxMEntity.class, jsonStr);
				entityList.add(proEntity);
			}
			// 定位行
			PlnZyJgxMEntity entityM = BaseHelper.jsonToEntity(
					PlnZyJgxMEntity.class, jsonStrM);
			if (entityM == null) {
				return core;
			}
			// String plineCode = entityM.getPlineCode();// 用于生产批次号
			/**
			 * 1.判断数据
			 */
			// 1.1定位行数据状态
			// if (!entityM.getPlanstatus().equals("0")
			// || entityM.getLotNoSqe() != entityM.getOrglgxProSeq()) {
			// return core;
			// }
			// 已下发的数据在排产界面不能调整顺序
			// if (processCode.equals("E")) {
			// if (entityM.getIfStoveIssued().equals("1")
			// && customInfo.equals("1")) {
			// return core;
			// }
			// }
			int gxProSeqM = Integer.parseInt(entityM.getLotNoSqe()); // 移至行序号
			int[] intArray = new int[entityList.size()];
			// 1.2移动行数据
			for (int i = 0; i < entityList.size(); i++) {
				PlnZyJgxMEntity entity = entityList.get(i);
				if (entity == null) {
					return core;
				}
				// if (!entity.getExeStatus().equals("0")
				// || entity.getGxProSeq() != entity.getOrglgxProSeq()) {
				// return core;
				// }
				intArray[i] = Integer.parseInt(entity.getLotNoSqe());
			}
			// // 1.3必须是在调整行的序号中间
			// if (gxProSeqM >= intArray[0]
			// && gxProSeqM <= intArray[entityList.size() - 1]) {
			// return core;
			// }
			// Arrays.sort(intArray);
			// 调整行操作
			/**
			 * 2. 前移(需要操作步骤:1.)
			 */
			if (gxProSeqM <= intArray[0]) {
				for (int i = 0; i < entityList.size(); i++) {
					// 2.1序号自动调整
					PlnZyJgxMEntity entity = entityList.get(i);
					seqIncreaseLot(con, entity.getProPlanId(),
							entity.getGxPlanNo(), gxProSeqM,
							Integer.parseInt(entity.getLotNoSqe()), 1, "G");
					entity.setLotNoSqe(String.valueOf(gxProSeqM));
					// 2.2修改移动数据
					String sql = "UPDATE PLN_ZY_JGX_M T SET T.LOT_NO_SQE = ?"
							+ " WHERE T.HEAT_PLAN_NO=?";
					PreparedStatement ps = con.prepareStatement(sql);
					ps.setObject(1, gxProSeqM);
					ps.setObject(2, entity.getHeatPlanNo());
					ps.executeUpdate();
					ps.close();
					gxProSeqM = gxProSeqM + 1;
				}
			} else {
				/**
				 * 3.后移
				 */
				// 如果不是小于最小序号,那么肯定是大于最大序号,前面加以限制
				int differNum = 0;
				for (int i = 0; i < entityList.size(); i++) {
					PlnZyJgxMEntity entity = entityList.get(i);
					// 3.1序号自动调整
					seqIncreaseLot(con, entity.getProPlanId(),
							entity.getGxPlanNo(),
							Integer.parseInt(entity.getLotNoSqe()) - differNum,
							gxProSeqM + 1, -1, "G");
					entity.setLotNoSqe(String.valueOf(gxProSeqM));
					// 3.2 修改数据
					String sql = "UPDATE PLN_ZY_JGX_M T SET T.LOT_NO_SQE = ?"
							+ " WHERE T.HEAT_PLAN_NO=?";
					PreparedStatement ps = con.prepareStatement(sql);
					ps.setObject(1, gxProSeqM);
					ps.setObject(2, entity.getHeatPlanNo());
					ps.executeUpdate();
					ps.close();
					differNum++;
				}
			}
			// 调整顺序修改生产批
			updatePlnJgxGroup(con, entityM.getProPlanId(),
					entityM.getGxPlanNo(), entityM.getPic());
			// 修改送判表，检验计划表
			String sqlzGm = "SELECT T.HEAT_PLAN_NO,T.LOT_NO_GROUP, T.JUDGE_STOVE_NO FROM PLN_ZY_JGX_M T WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=? ";
			PreparedStatement ps1 = con.prepareStatement(sqlzGm);
			ps1.setObject(1, entityM.getProPlanId());
			ps1.setObject(2, entityM.getGxPlanNo());
			ResultSet rs1 = ps1.executeQuery();
			while (rs1.next()) {
				String lotNoGroup = rs1.getString("LOT_NO_GROUP");
				String feedHeatNo = rs1.getString("JUDGE_STOVE_NO");

				// 查询是否综合判断
				// String sqlQcm =
				// "SELECT T.VALIDFLAG FROM QCM_ZG_JUGDE_APPLY T WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CODE=? AND T.IS_FLAG='0' ";
				// PreparedStatement ps = con.prepareStatement(sqlQcm);
				// ps.setObject(1, feedHeatNo);
				// ps.setObject(2, "G");
				// ResultSet rs = ps.executeQuery();
				// while (rs.next()) {
				// if (rs.getString("VALIDFLAG").equals("20")) {
				// core.setV_errMsg("判定炉号:" + feedHeatNo + ",已判定不能获取工艺！");
				// return core;
				// }
				// }
				// rs.close();
				// ps.close();
				// 更新判定表
				String updateQcm = "UPDATE QCM_ZG_JUGDE_APPLY T SET T.LOT_NO_GROUP='"
						+ lotNoGroup
						+ "' "
						+ " WHERE T.JUDGE_STOVE_NO=? AND T.PROCESS_CODE='G' AND T.IS_FLAG='0'";
				PreparedStatement ps = con.prepareStatement(updateQcm);
				ps.setObject(1, feedHeatNo);
				ps.executeUpdate();
				ps.close();
				// 修改检化验计划表
				String updateMQcm = "UPDATE QCM_ZC_CHECKCONSIGN T SET T.LOT_NO_GROUP='"
						+ lotNoGroup
						+ "' WHERE T.PRO_ORDER_ID=? AND T.GX_PLAN_NO=? AND T.JUDGE_STOVE_NO=? and PROCESS_CODE='G'";
				ps = con.prepareStatement(updateMQcm);
				ps.setObject(1, entityM.getProPlanId());
				ps.setObject(2, entityM.getGxPlanNo());
				ps.setObject(3, feedHeatNo);
				ps.executeUpdate();
				ps.close();
				// 修改检验委托表
				String updatePipe = "UPDATE PIPE_CHECKCONSIGN_BASEINFO T SET T.LOT_NO_GROUP='"
						+ lotNoGroup
						+ "' WHERE T.HEAT_NO=? AND T.PROCESS_CODE='G'";
				ps = jhyCon.prepareStatement(updatePipe);
				ps.setObject(1, feedHeatNo);
				ps.executeUpdate();
				ps.close();

			}
			rs1.close();
			ps1.close();

			core.setV_errMsg("移动成功!");
			con.commit();
			jhyCon.commit();
		} catch (Exception e) {
			e.printStackTrace();
			try {
				if (con != null) {
					con.rollback();
					jhyCon.rollback();
				}
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		} finally {
			try {
				if (con != null && !con.isClosed())
					con.close();
				jhyCon.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return core;
	}

	/**
	 * 序号自增减
	 * 
	 * @param con
	 * @param
	 * @param gxProSeqB
	 * @param gxProSeqE
	 *            (如果没有上限，请设为负数)
	 * @param num
	 * @param processCode
	 * @throws SQLException
	 */
	public void seqIncreaseLot(Connection con, String proPlanId,
			String gxPlanNo, int gxProSeqB, int gxProSeqE, int num,
			String processCode) throws SQLException {
		String sql = "";
		if (processCode.equals("F")) {
			sql = "UPDATE PLN_ZY_RCL_M T SET  T.LOT_NO_SQE = TO_NUMBER(T.LOT_NO_SQE) + TO_NUMBER(?)";
		} else if (processCode.equals("G")) {
			sql = "UPDATE PLN_ZY_JGX_M T SET  T.LOT_NO_SQE = TO_NUMBER(T.LOT_NO_SQE) + TO_NUMBER(?)";
		}
		sql += "  WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=? AND TO_NUMBER(T.LOT_NO_SQE) >= TO_NUMBER(?)";
		if (gxProSeqE > 0) {
			sql += "  AND TO_NUMBER(T.LOT_NO_SQE) < TO_NUMBER(?) ";
		}
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, num);
		ps.setObject(2, proPlanId);
		ps.setObject(3, gxPlanNo);
		ps.setObject(4, gxProSeqB);
		if (gxProSeqE > 0) {
			ps.setObject(5, gxProSeqE);
		}
		ps.executeUpdate();
		ps.close();
	}

	/***
	 * 修改热处理生产批
	 * 
	 * @param con
	 * @param proPlanId
	 * @param gxPlanNo
	 * @throws SQLException
	 */
	public static void updatePlnRclGroup(Connection con, String proPlanId,
			String gxPlanNo, String picPlan) throws SQLException {
		PreparedStatement ps = null;
		ResultSet rs = null;
		String desginKey = "";
		String mscPline = "";
		// 查询DesginKey与制程索引号
		String sqlOrderRcl = CoreXmlSqlParsersFactory
				.getSql("StoveHelper.queryDesginKey");
		ps = con.prepareStatement(sqlOrderRcl);
		ps.setObject(1, proPlanId);
		ps.setObject(2, gxPlanNo);
		rs = ps.executeQuery();
		if (rs.next()) {
			desginKey = rs.getString("DESGIN_KEY");
			mscPline = rs.getString("INDEX_SEQ");
		}
		rs.close();
		ps.close();

		int topStove = 0;// 前几炉
		int loopValue = 0;// 循环值
		// 查询是否生产批,前几炉及循环值
		String sqlPic = CoreXmlSqlParsersFactory
				.getSql("StoveHelper.querySqlPic");
		ps = con.prepareStatement(sqlPic);
		ps.setObject(1, desginKey);
		ps.setObject(2, mscPline);
		ps.setObject(3, "F");
		ps.setObject(4, picPlan);
		rs = ps.executeQuery();
		if (rs.next()) {
			topStove = rs.getInt("TOP_STOVE");
			loopValue = rs.getInt("LOOP_VALUE");
		}
		rs.close();
		ps.close();

		if (topStove != 0 || loopValue != 0) {
			int count = 0;
			// 查询有多少炉计划
			String sqlPlnM = "SELECT COUNT(*) COUNT FROM PLN_ZY_RCL_M T WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=? ";
			ps = con.prepareStatement(sqlPlnM);
			ps.setObject(1, proPlanId);
			ps.setObject(2, gxPlanNo);
			rs = ps.executeQuery();
			if (rs.next()) {
				count = rs.getInt("COUNT");
			}
			rs.close();
			ps.close();
			if (topStove != 0) {
				// 修改生产批前topStove 生产坯==A
				String sql = "UPDATE PLN_ZY_RCL_M T SET T.LOT_NO_GROUP='A'"
						+ " WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=? AND T.IF_MATCH_ODD<>'2' AND TO_NUMBER(T.LOT_NO_SQE) <=? ";
				ps = con.prepareStatement(sql);
				ps.setObject(1, proPlanId);
				ps.setObject(2, gxPlanNo);
				ps.setObject(3, topStove);
				ps.executeUpdate();
				ps.close();
			}
			if (loopValue == 0) {
				// 修改生产批 排除前几炉修改==1
				String sql = "UPDATE PLN_ZY_RCL_M T SET T.LOT_NO_GROUP=''"
						+ " WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=? AND T.IF_MATCH_ODD<>'2' AND TO_NUMBER(T.LOT_NO_SQE) >?  ";
				ps = con.prepareStatement(sql);
				ps.setObject(1, proPlanId);
				ps.setObject(2, gxPlanNo);
				ps.setObject(3, topStove);
				ps.executeUpdate();
				ps.close();
			} else {
				int intCount = 0;
				int intCount1 = 0;
				int group = 1;
				int topStove1 = topStove;
				if (count - topStove < loopValue) {
					String sql = "UPDATE PLN_ZY_RCL_M T SET T.LOT_NO_GROUP='1'"
							+ " WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=? AND T.IF_MATCH_ODD<>'2' AND TO_NUMBER(T.LOT_NO_SQE) >?  ";
					ps = con.prepareStatement(sql);
					ps.setObject(1, proPlanId);
					ps.setObject(2, gxPlanNo);
					ps.setObject(3, topStove);
					ps.executeUpdate();
					ps.close();
				} else {
					for (int i = 0; i < count - topStove; i++) {
						// 修改生产批 排除前几炉修改==1
						String sql = "UPDATE PLN_ZY_RCL_M T SET T.LOT_NO_GROUP='"
								+ group
								+ "'"
								+ " WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=? AND T.IF_MATCH_ODD<>'2' AND TO_NUMBER(T.LOT_NO_SQE) >? AND TO_NUMBER(T.LOT_NO_SQE) <=?  ";
						ps = con.prepareStatement(sql);
						ps.setObject(1, proPlanId);
						ps.setObject(2, gxPlanNo);
						ps.setObject(3, topStove + intCount1);
						ps.setObject(4, topStove1 + loopValue);
						ps.executeUpdate();
						ps.close();
						intCount++;
						intCount1++;
						if (loopValue == intCount) {
							topStove1 += loopValue;
							group++;
							intCount = 0;
						}

					}
				}

			}
		} else {
			String sql = "UPDATE PLN_ZY_RCL_M T SET T.LOT_NO_GROUP='1'"
					+ " WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=? AND T.IF_MATCH_ODD<>'2' AND TO_NUMBER(T.LOT_NO_SQE) >? ";
			ps = con.prepareStatement(sql);
			ps.setObject(1, proPlanId);
			ps.setObject(2, gxPlanNo);
			ps.setObject(3, topStove);
			ps.executeUpdate();
			ps.close();
		}
		// 修改组炉炉计划炉归组
		String sql = CoreXmlSqlParsersFactory
				.getSql("StoveHelper.queryZuluPlnRcl");
		ps = con.prepareStatement(sql);
		ps.setObject(1, proPlanId);
		ps.setObject(2, gxPlanNo);
		ps.executeUpdate();
		ps.close();
	}

	/***
	 * 修改加工线生产批
	 * 
	 * @param con
	 * @param proPlanId
	 * @param gxPlanNo
	 * @throws SQLException
	 */
	public static void updatePlnJgxGroup(Connection con, String proPlanId,
			String gxPlanNo, String picPlan) throws SQLException {
		PreparedStatement ps = null;
		ResultSet rs = null;
		String desginKey = "";
		String mscPline = "";
		// 查询DesginKey与制程索引号
		String sqlOrderRcl = CoreXmlSqlParsersFactory
				.getSql("StoveHelper.queryDesginKeyJgx");
		ps = con.prepareStatement(sqlOrderRcl);
		ps.setObject(1, proPlanId);
		ps.setObject(2, gxPlanNo);
		rs = ps.executeQuery();
		if (rs.next()) {
			desginKey = rs.getString("DESGIN_KEY");
			mscPline = rs.getString("INDEX_SEQ");
		}
		rs.close();
		ps.close();

		int topStove = 0;// 前几炉
		int loopValue = 0;// 循环值
		// 查询是否生产批,前几炉及循环值
		String sqlPic = CoreXmlSqlParsersFactory
				.getSql("StoveHelper.querySqlPic");
		ps = con.prepareStatement(sqlPic);
		ps.setObject(1, desginKey);
		ps.setObject(2, mscPline);
		ps.setObject(3, "G");
		ps.setObject(4, picPlan);
		rs = ps.executeQuery();
		if (rs.next()) {
			topStove = rs.getInt("TOP_STOVE");
			loopValue = rs.getInt("LOOP_VALUE");
		}
		rs.close();
		ps.close();

		if (topStove != 0 || loopValue != 0) {
			int count = 0;
			// 查询有多少炉计划
			String sqlPlnM = "SELECT COUNT(*) COUNT FROM PLN_ZY_JGX_M T WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=? ";
			ps = con.prepareStatement(sqlPlnM);
			ps.setObject(1, proPlanId);
			ps.setObject(2, gxPlanNo);
			rs = ps.executeQuery();
			if (rs.next()) {
				count = rs.getInt("COUNT");
			}
			rs.close();
			ps.close();
			if (topStove != 0) {
				// 修改生产批前topStove 生产坯==A
				String sql = "UPDATE PLN_ZY_JGX_M T SET T.LOT_NO_GROUP='A'"
						+ " WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=? AND T.IF_MATCH_ODD<>'2' AND TO_NUMBER(T.LOT_NO_SQE) <=? ";
				ps = con.prepareStatement(sql);
				ps.setObject(1, proPlanId);
				ps.setObject(2, gxPlanNo);
				ps.setObject(3, topStove);
				ps.executeUpdate();
				ps.close();
			}
			if (loopValue == 0) {
				// 修改生产批 排除前几炉修改==1
				String sql = "UPDATE PLN_ZY_JGX_M T SET T.LOT_NO_GROUP=''"
						+ " WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=? AND T.IF_MATCH_ODD<>'2' AND TO_NUMBER(T.LOT_NO_SQE) >? ";
				ps = con.prepareStatement(sql);
				ps.setObject(1, proPlanId);
				ps.setObject(2, gxPlanNo);
				ps.setObject(3, topStove);
				ps.executeUpdate();
				ps.close();
			} else {
				int intCount = 0;
				int intCount1 = 0;
				int group = 1;
				int topStove1 = topStove;
				if (count - topStove < loopValue) {
					String sql = "UPDATE PLN_ZY_JGX_M T SET T.LOT_NO_GROUP='1'"
							+ " WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=? AND T.IF_MATCH_ODD<>'2' AND TO_NUMBER(T.LOT_NO_SQE) >? ";
					ps = con.prepareStatement(sql);
					ps.setObject(1, proPlanId);
					ps.setObject(2, gxPlanNo);
					ps.setObject(3, topStove);
					ps.executeUpdate();
					ps.close();
				} else {
					for (int i = 0; i < count - topStove; i++) {
						// 修改生产批 排除前几炉修改==1
						String sql = "UPDATE PLN_ZY_JGX_M T SET T.LOT_NO_GROUP='"
								+ group
								+ "'"
								+ " WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=? AND T.IF_MATCH_ODD<>'2' AND TO_NUMBER(T.LOT_NO_SQE) >? AND TO_NUMBER(T.LOT_NO_SQE) <=? ";
						ps = con.prepareStatement(sql);
						ps.setObject(1, proPlanId);
						ps.setObject(2, gxPlanNo);
						ps.setObject(3, topStove + intCount1);
						ps.setObject(4, topStove1 + loopValue);
						ps.executeUpdate();
						ps.close();
						intCount++;
						intCount1++;
						if (loopValue == intCount) {
							topStove1 += loopValue;
							group++;
							intCount = 0;
						}

					}
				}

			}
		} else {
			String sql = "UPDATE PLN_ZY_JGX_M T SET T.LOT_NO_GROUP='1'"
					+ " WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=? AND T.IF_MATCH_ODD<>'2' AND TO_NUMBER(T.LOT_NO_SQE) >? ";
			ps = con.prepareStatement(sql);
			ps.setObject(1, proPlanId);
			ps.setObject(2, gxPlanNo);
			ps.setObject(3, topStove);
			ps.executeUpdate();
			ps.close();
		}
		// 修改组炉炉计划炉归组
		String sql = CoreXmlSqlParsersFactory
				.getSql("StoveHelper.queryZuluPlnJgx");
		ps = con.prepareStatement(sql);
		ps.setObject(1, proPlanId);
		ps.setObject(2, gxPlanNo);
		ps.executeUpdate();
		ps.close();
	}

	/**
	 * 订单终止
	 * 
	 * @param
	 *
	 */
	@SuppressWarnings("unused")
	public CoreReturnObject doTermination(ArrayList<String> jsonList,
			String proessCode) {
		CoreReturnObject core = new CoreReturnObject();
		Connection conn = null;
		PreparedStatement ps = null;
		ResultSet rs = null;
		try {
			conn = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			conn.setAutoCommit(false);

			List<PlnOrderZgSEntity> list = PlnHelper.jsonsToEntityList(
					PlnOrderZgSEntity.class, jsonList);
			int countNum = 0;
			for (PlnOrderZgSEntity zgSEntity : list) {
				// if (list == null) {
				// core.setV_errMsg("未找到订单(" + proPlanId + "/" + gxPlanNo +
				// ")信息!");
				// return core;
				// }
				String proPlanId = zgSEntity.getProPlanId();
				String gxPlanNo = zgSEntity.getGxPlanNo();
				String exeStatus = zgSEntity.getExeStatus();
				String numS = zgSEntity.getNumS();
				String weigthS = zgSEntity.getWeigthS();
				String weigthSMin = zgSEntity.getWeigthSMin();
				String gpreqId = zgSEntity.getGpreqId();

				if (!exeStatus.equals("计划")) {
					core.setV_errMsg("订单不是计划状态,不能终止订单！");
					return core;
				}
				if (!gpreqId.equals("")) {
					String exeStatusCast = "0";
					// 查询铸造订单是否关闭
					String sqlCast = "SELECT MIN(T.EXE_STATUS) EXE_STATUS FROM PLN_ORDER_CAST_S T WHERE T.PRO_PLAN_ID=?";
					ps = conn.prepareStatement(sqlCast);
					ps.setObject(1, gpreqId);
					rs = ps.executeQuery();
					if (rs.next()) {
						exeStatusCast = rs.getString("EXE_STATUS");
					}
					rs.close();
					ps.close();

					if (exeStatusCast.equals("0") || exeStatusCast.equals("1")) {
						core.setV_errMsg("轧管订单:" + proPlanId + "/" + gxPlanNo
								+ "已生成管坯需求,并且铸造订单未生产完成,不能终止订单！");
						return core;
					}
				}
				// 查询炉计划是否计划状态
				String sqlDbk = "SELECT T.PLANSTATUS,T.HEAT_PLAN_NO,T.JUDGE_STOVE_NO FROM PLN_ZY_ZG_M T WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?";
				ps = conn.prepareStatement(sqlDbk);
				ps.setObject(1, proPlanId);
				ps.setObject(2, gxPlanNo);
				rs = ps.executeQuery();
				while (rs.next()) {
					String planstatus = rs.getString("PLANSTATUS");
					// String judgeStoveNo = rs.getString("JUDGE_STOVE_NO");
					// String heatPlanNo = rs.getString("HEAT_PLAN_NO");
					if (!planstatus.equals("00")) {
						core.setV_errMsg("轧管订单:" + proPlanId + "/" + gxPlanNo
								+ "下存在不是计划状态的炉计划,不能终止订单！");
						return core;
					}
				}
				rs.close();
				ps.close();
				if (!zgSEntity.getOrderSource().equals("销售合同")) {
//					core.setV_errMsg("轧管订单:" + proPlanId + "/" + gxPlanNo
//							+ "合同来源不是销售合同,不能终止订单！");
//					return core;
				}
				// // 关闭轧管订单
				// String updateZg =
				// "UPDATE PLN_ORDER_ZG_S T SET T.EXE_STATUS='3',T.GX_PRO_SEQ='-1' WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?";
				// ps = conn.prepareStatement(updateZg);
				// ps.setObject(1, proPlanId);
				// ps.setObject(2, gxPlanNo);
				// ps.executeUpdate();
				//
				// // 删除炉计划主
				// String deleteM =
				// "DELETE PLN_ZY_ZG_M T WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?";
				// ps = conn.prepareStatement(deleteM);
				// ps.setObject(1, proPlanId);
				// ps.setObject(2, gxPlanNo);
				// ps.executeUpdate();
				// // 删除炉计划从
				// String deleteC =
				// "DELETE PLN_ZY_ZG_C T WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?";
				// ps = conn.prepareStatement(deleteC);
				// ps.setObject(1, proPlanId);
				// ps.setObject(2, gxPlanNo);
				// ps.executeUpdate();
				//
				// // 修改库坯料库存
				// String sqlUpdateZgS =
				// "UPDATE MAT_GP_M T SET T.HANGING_FLAG='0',T.MAT_STATUS='"
				// + 80150102
				// + "',"
				// + " T.CUT_YU_LONG='0',T.UPDATE_NAME='',"
				// + " T.UPDATE_TIME=TO_DATE('','YYYY-MM-DD HH24:MI:SS'),"
				// +
				// " T.LK_FLAG='0',T.PRO_PLAN_ID_ZG = '',T.GX_PLAN_NO_ZG  = '', T.ORDER_NO= '',T.ORDER_SEQ= '',"
				// +
				// " T.ORDER_SEQ_NO = '',T.ORD_PK= '',T.ORD_LN_PK= '', T.ORD_LN_DLY_PK  = '',T.HEAT_PLAN_NO_NEXT='' WHERE T.PRO_PLAN_ID_ZG=? AND T.GX_PLAN_NO_ZG=?";
				// // T.PRO_PLAN_ID_ZG=?,T.GX_PLAN_NO_ZG=?,
				// ps = conn.prepareStatement(sqlUpdateZgS);
				// ps.setObject(1, proPlanId);
				// ps.setObject(2, gxPlanNo);
				// ps.executeUpdate();
				// ps.close();

				String orderLnPk = "";
				if(zgSEntity.getOrdLnDlyPk().contains("ZZBY"))
				{
					orderLnPk = zgSEntity.getReqBlId();
				}else
				{
					orderLnPk = zgSEntity.getOrdLnDlyPk().substring(0,
							zgSEntity.getOrdLnDlyPk().length() - 3);
				}


				// 2.1查询接收表信息
				PlnSaleordEntity ordEntity = PlnHelper.getEntityData(conn,
						new String[] { zgSEntity.getOrdLnDlyPk() },
						"CorePlnSaleOrder.getPlnSaleordByPk",
						PlnSaleordEntity.class);
				// if (ordEntity == null) {
				// messageErr.add("没有接收合同信息!");
				// continue;
				// }

				// 查询排产工序表信息
				PlnSaleordProcEntity procEntity = getOrderProc(conn,
						zgSEntity.getOrdLnDlyPk(), zgSEntity.getPlnDivideId(),
						PlnSaleordProcEntity.class);
				if (procEntity == null) {
					core.setV_errMsg("未找到排产信息！");
					return core;
				}
				String desginKey = "";// 工艺设计主键

				// 2.3查找工艺
				String[] craftInfo = PlnHelper.getArray(conn,
						"CorePlnSaleOrder.queryOrdCraftOrdDesign",
						" AND T.VALIDFLAG = '1'", new String[] { orderLnPk },
						new String[] { "CRAFT_SEQ", "DESGIN_KEY", "CRAFT_NAME",
								"CRAFT_NO", "CRAFT_NO_V" });
				if (craftInfo == null || craftInfo.length == 0) {
					core.setV_errMsg("合同行：" + zgSEntity.getOrderNo() + "/"
							+ zgSEntity.getOrderSeq() + "未找到有效的工艺评审！");
					continue;
				}
				procEntity.setCraftSeq(craftInfo[0]);
				desginKey = craftInfo[1];
				procEntity.setCraftFileMan(craftInfo[2]);
				procEntity.setCraftFileNo(craftInfo[3]);
				procEntity.setCraftNoV(craftInfo[4]);

				// 2.7查询工艺评审制程
				List<CraftOrdDesignMscPlEntityO> mscPlList = PlnHelper
						.getEntityDatas(conn, new String[] { desginKey,
								desginKey }, "CorePlnSaleOrder.queryDesginPl",
								CraftOrdDesignMscPlEntityO.class);
				if (mscPlList == null || mscPlList.size() == 0) {
					core.setV_errMsg("合同行：" + zgSEntity.getOrderNo() + "/"
							+ zgSEntity.getOrderSeq() + "未找到制程，请查看工艺评审。");
					return core;
				}
				boolean flag = false;
				String[] message = new String[1];
				for (CraftOrdDesignMscPlEntityO mscPlEntity : mscPlList) {
					procEntity.setIndexSeq(mscPlEntity.getMscPline());
					procEntity.setProcessSeq(mscPlEntity.getWholeBacklog());
					procEntity.setGradecodeAll(mscPlEntity.getGradename());
					// 查询二级工序
					List<CraftOrdDesignMscPlPrcEntity> mscPrcList = PlnHelper
							.getEntityDatas(conn, new String[] { desginKey,
									procEntity.getIndexSeq() },
									"CorePlnSaleOrder.queryMscplPrc",
									CraftOrdDesignMscPlPrcEntity.class);
					if (mscPrcList == null) {
						continue;
					}
					// 根据制程查询全程途经工序
					procEntity.setGroupJgx("/");
					procEntity.setGroupRcl("/");
					procEntity.setBjType("/");
					String wholeBacklog = procEntity.getProcessSeq();
					String endgxCode = wholeBacklog.substring(wholeBacklog
							.length() - 1);
					String gprocessC = ""; // 加工二级工序
					String fprocessC = ""; // 热处理二级工序
					for (CraftOrdDesignMscPlPrcEntity prcEntity : mscPrcList) {
						if (prcEntity.getProcessCode().trim().equals("H")) {
							procEntity.setGroupJgx("200401");
						} else if (prcEntity.getProcessCode().trim()
								.equals("G")) {
							gprocessC = prcEntity.getProcessCodeC();
						} else if (prcEntity.getProcessCode().trim()
								.equals("F")) {
							fprocessC = prcEntity.getProcessCodeC();
							procEntity.setProcDescCRcl(prcEntity
									.getProcessDescC());
						} else if (prcEntity.getProcessCode().trim()
								.equals("E")) {
							procEntity.setBjType(prcEntity.getProcessDescC());
						}
					}
					// 轧管去向
					String abc = CoreOrdBase.getAbc(
							mscPlEntity.getWholeBacklog(),
							mscPlEntity.getWholeBacklogDesc());
					procEntity.setAbc(abc);
					procEntity.setPrdcrpro(CoreOrdLinePrdcrLst.getOrdPrdcrpro(
							conn, ordEntity.getPrdcrNo(),
							procEntity.getIndexSeq()));
					// 物料信息
					List<SlmOrdDesignBomEntity> bomList = PlnHelper
							.getEntityDatas(
									conn,
									new String[] { desginKey,
											ordEntity.getMsc(),
											procEntity.getIndexSeq() },
									"CoreOrdDesginBom.getOrdLineMscBom",
									SlmOrdDesignBomEntity.class);
					// if (outsBilletFl.equals("1")) {
					if (bomList == null || bomList.size() == 0) {
						core.setV_errMsg("合同：" + ordEntity.getOrderNo() + "/"
								+ ordEntity.getOrderSeq() + "/"
								+ ordEntity.getDeliveryNo() + "未找到物料信息。");
						return core;
					}

					for (SlmOrdDesignBomEntity bomEntity : bomList) {
						String dinMaterial = "";
						procEntity.setBom(bomEntity.getBom());
						procEntity.setMaterialNo(bomEntity.getMaterialNo());
						procEntity.setMaterialDesc(bomEntity.getMaterialDesc());
						procEntity.setGroupRollAll(bomEntity.getdPline());
						procEntity.setGradecode(bomEntity.getGradecode());
						procEntity.setEInMaterialDesc(bomEntity
								.getEInMaterialDesc());
						procEntity.setEInMaterialNo(bomEntity
								.getEInMaterialNo());
						procEntity.setDimaterYlg(bomEntity.getDimater());
						procEntity.setHeightYlg(bomEntity.getHeight());
						procEntity.setGroupJgx(CoreDefGourp.getJgxDefGroup(
								conn, desginKey, procEntity.getIndexSeq(),
								bomEntity.getBom()));
						procEntity.setGroupRcl(CoreDefGourp.getRclDefGroup(
								conn, desginKey, procEntity.getIndexSeq(),
								bomEntity.getBom()));
						// /轧管投入物料(炼钢末工序产出物料)
						dinMaterial = bomEntity.getDInMaterialNo();
						procEntity.setStuffProperty(CoreOrdBase
								.stuffProperty(dinMaterial));

						ordEntity.setOrderQty(weigthS);
						double orderQty = Double.parseDouble(weigthS);
						double confirmWt = Double.parseDouble(weigthS);
						String sqlQuery = CoreXmlSqlParsersFactory
								.getSql("StoveHelper.queryIsConfrimProc");
						ps = conn.prepareStatement(sqlQuery);
						ps.setObject(1, zgSEntity.getOrdLnDlyPk());
						rs = ps.executeQuery();
						if (rs.next()) {
							PreparedStatement pst = null;
							int planNum = 0;
							double planTotLen = 0;
							double aimlen = rs.getDouble("AIM_LEN_END");
							double weigthMi = rs.getDouble("WEIGHT_PER_M");

							// double delvryRangeMax = 0;// 交货量差上限
							// double delvryRangeMin = 0;// 交货量差下限
							// if (rs.getString("DELVRY_RANGE_TPE").trim()
							// .equals("绝对值")) {
							// delvryRangeMax = (rs
							// .getDouble("DELVRY_RANGE_MAX") / orderQty) * 100;
							// delvryRangeMin = (rs
							// .getDouble("DELVRY_RANGE_MIN") / orderQty) * 100;
							// } else {
							// delvryRangeMax = rs
							// .getDouble("DELVRY_RANGE_MAX");
							// delvryRangeMin = rs
							// .getDouble("DELVRY_RANGE_MIN");
							// }

							double rate = Double.parseDouble(procEntity
									.getCoefficient());
							double rateMin = Double.parseDouble(procEntity
									.getCoefficientMin());// 最小排产系数
							double putRate = Double.parseDouble(procEntity
									.getFeedRate());// 排产原则
							// rate = 1 + ((delvryRangeMax + delvryRangeMin)
							// * putRate - delvryRangeMin) / 100;
							// rateMin = 1 - delvryRangeMin / 100;
							if (weigthMi != 0) {
								planTotLen = confirmWt / weigthMi;
							}
							// if (confirmWt % (aimlen * weigthMi) < 0.00000001)
							// {
							// planNum = (int) (confirmWt / (aimlen *
							// weigthMi));
							// } else {
							// planNum = (int) (confirmWt / (aimlen * weigthMi +
							// 1));
							// }
							// // 排产量
							// double reqPcWt = (confirmWt - planNum
							// * rs.getDouble("WEIGHT_JG") / 1000)
							// * (rate);
							double orderQtyD = Double.parseDouble(procEntity
									.getOrderQtyD())
									/ Double.parseDouble(procEntity
											.getPlanWtD())
									* Double.parseDouble(weigthS);
							procEntity.setOrderQtyD(String.valueOf(orderQtyD));
							procEntity.setPlanNumD(numS);
							procEntity.setPlanWtD(weigthS);
							procEntity.setPlanTotLenD(String
									.valueOf(planTotLen));
							procEntity.setPlanPMain(weigthS);
							procEntity.setPlanPMainMin(weigthSMin);
						}
						rs.close();
						ps.close();
					}
				}
				if (procEntity.getProcessSeq().contains("F")) {
					// 判断是否经过热处理工序
					procEntity.setFIsOk("0");
				} else {
					procEntity.setFIsOk("2");
				}

				if (procEntity.getProcessSeq().contains("G")) {
					// 判断是否经过管加工工序
					procEntity.setGIsOk("0");
				} else {
					procEntity.setGIsOk("2");
				}

				if (procEntity.getProcessSeq().contains("D")) {
					// 判断是否经过轧管工序
					procEntity.setDIsOk("0");
				} else {
					procEntity.setDIsOk("2");
				}
				if (procEntity.getProcessSeq().contains("E")) {
					// 判断是否经过镦拔扩工序
					procEntity.setEIsOk("0");
				} else {
					procEntity.setEIsOk("2");
				}
				// 新增排产表
				String sqlAddProc = CoreXmlSqlParsersFactory
						.getSql("StoveHelper.AddPlnProc");
				String sqlAdd = EntityTool.fillSqlByEntity(sqlAddProc,
						procEntity);
				ps = conn.prepareStatement(sqlAdd);
				ps.executeUpdate();
				ps.close();

			}

			core.setV_errMsg("终止成功!");
			conn.commit();
		} catch (Exception e) {
			e.printStackTrace();
			try {
				if (conn != null) {
					conn.rollback();
				}
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		} finally {
			try {
				if (conn != null && !conn.isClosed())
					conn.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return core;
	}

	/**
	 * 查询排产工序表信息
	 * 
	 * @param con
	 */
	public static <T> T getOrderProc(Connection con, String ordLnDlyPk,
			String plnDivideId, Class<T> cls) throws SQLException {
		String sql = CoreXmlSqlParsersFactory
				.getSql("StoveHelper.queryOrderProc");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, ordLnDlyPk);
		ps.setObject(2, plnDivideId);
		ResultSet rs = ps.executeQuery();
		T t = EntityTool.getEntityByRs(rs, cls);
		rs.close();
		ps.close();
		return t;
	}

	/***
	 * 加工线订单重新排序
	 * @return
	 */
	public CoreReturnObject sortOrderJgx(String plineCode)
	{
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		try {
			ArrayList<String> sqllist = new ArrayList<String>();
			String updateSql = CoreXmlSqlParsersFactory.getSql("StoveHelper.sortOrderJgx");
			PlnOrderJgxSEntity plnOrderEntity = new PlnOrderJgxSEntity();
			plnOrderEntity.setPlineCode(plineCode);
			updateSql = EntityTool.fillSqlByEntity(updateSql,plnOrderEntity);
			sqllist.add(updateSql);
			cro = this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(sqllist);
			if(cro.getV_errMsg().equals(""))
			{
				cro.setV_errMsg("重新排序成功!");
			}
		} 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;
	}
	/***
	 * 热处理订单重新排序
	 * @return
	 */
	public CoreReturnObject sortOrderRcl(String plineCode)
	{
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		try {
			ArrayList<String> sqllist = new ArrayList<String>();
			String updateSql = CoreXmlSqlParsersFactory.getSql("StoveHelper.sortOrderRcl");
			PlnOrderRclSEntity plnOrderEntity = new PlnOrderRclSEntity();
			plnOrderEntity.setPlineCode(plineCode);
			updateSql = EntityTool.fillSqlByEntity(updateSql,plnOrderEntity);
			sqllist.add(updateSql);
			cro = this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(sqllist);
			if(cro.getV_errMsg().equals(""))
			{
				cro.setV_errMsg("重新排序成功!");
			}
		} 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;
	}
	
	/***
	 * 轧线订单重新排序
	 * @return
	 */
	public CoreReturnObject sortOrderZg(String plineCode)
	{
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		try {
			ArrayList<String> sqllist = new ArrayList<String>();
			String updateSql = CoreXmlSqlParsersFactory.getSql("StoveHelper.sortOrderZg");
			PlnOrderJgxSEntity plnOrderEntity = new PlnOrderJgxSEntity();
			plnOrderEntity.setPlineCode(plineCode);
			updateSql = EntityTool.fillSqlByEntity(updateSql,plnOrderEntity);
			sqllist.add(updateSql);
			cro = this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(sqllist);
			if(cro.getV_errMsg().equals(""))
			{
				cro.setV_errMsg("重新排序成功!");
			}
		} 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;
	}
	
	/***
	 * 镦拔扩订单重新排序
	 * @return
	 */
	public CoreReturnObject sortOrderDbk(String plineCode)
	{
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		try {
			ArrayList<String> sqllist = new ArrayList<String>();
			String updateSql = CoreXmlSqlParsersFactory.getSql("StoveHelper.sortOrderDbk");
			PlnOrderJgxSEntity plnOrderEntity = new PlnOrderJgxSEntity();
			plnOrderEntity.setPlineCode(plineCode);
			updateSql = EntityTool.fillSqlByEntity(updateSql,plnOrderEntity);
			sqllist.add(updateSql);
			cro = this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(sqllist);
			if(cro.getV_errMsg().equals(""))
			{
				cro.setV_errMsg("重新排序成功!");
			}
		} 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;
	}
}
