package com.steering.pss.plnsaleord.planStove;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
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.GpOptimize.model.PlnOrderZgSEntity;
import com.steering.pss.plnsaleord.base.PlnHelper;
import com.steering.pss.plnsaleord.planStove.entity.MatBcTrackEntity;
import com.steering.pss.plnsaleord.processOrder.tmsDemand.writeDemand;
import com.steering.pss.plnsaleord.stove.entity.MatBcMEntityPln;
import com.steering.pss.plnsaleord.stove.entity.PlnOrderDbkSEntity;
import com.steering.pss.plnsaleord.stove.entity.PlnZyDbkMEntity;
import com.steering.pss.plnsaleord.stove.entity.PlnZyDbkCEntity;
import com.steering.pss.plnsaleord.stove.entity.PlnZyJgxCEntity;
import com.steering.pss.plnsaleord.stove.entity.PlnZyJgxMEntity;
import com.steering.pss.plnsaleord.stove.entity.PlnZyRclCEntity;
import com.steering.pss.plnsaleord.stove.entity.PlnZyRclMEntity;
import com.steering.pss.plnsaleord.stove.PlanFurnProduction;
import com.steering.pss.plnsaleord.stove.corePlanFurnProM;
import com.steering.pss.plnsaleord.steelMarkingPlan.FrmSteelMakingPlanChange;
import com.sun.xml.bind.v2.runtime.unmarshaller.XsiNilLoader;

/**
 * 镦拔扩炉计划
 * 
 * @author
 */
public class FrmPlanStoveE extends DBCommon {

	/**
	 * doBreakUp 查询虚拟炉计划
	 * 
	 * @return
	 */
	public CoreReturnObject queryPlanStoveYzE(String timeBegin, String timeEnd,
			String plineCode, String orderNo, String proPlanId, String heatId,
			String[] statusArr, String judgeNo, String feedNo) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmPlanStoveE.queryPlanStoveME");
		List<String> param = new ArrayList<String>();
		if (!timeBegin.equals("") && !timeEnd.equals("")) {
			sql += " AND TO_DATE(T.PRO_DAY, 'YYYY-MM-DD') BETWEEN TO_DATE(?,'YYYY-MM-DD') AND TO_DATE(?,'YYYY-MM-DD')";
			param.add(timeBegin);
			param.add(timeEnd);
		}
		if (!plineCode.equals("")) {
			sql += " AND T.PLINE_CODE=? ";
			param.add(plineCode);
		}
		if (!orderNo.equals("")) {
			sql += " AND T.ORDER_NO||'/'||T.ORDER_SEQ LIKE '%'||?||'%'";
			param.add(orderNo);
		}
		if (!proPlanId.equals("")) {
			sql += " AND T.PRO_PLAN_ID=?";
			param.add(proPlanId);
		}
		if (!heatId.equals("")) {
			sql += " AND T.HEAT_PLAN_NO LIKE '%'||?||'%'";
			param.add(heatId);
		}
		if (!judgeNo.equals("")) {
			sql += " AND T.JUDGE_STOVE_NO=?";
			param.add(judgeNo);
		}
		if (!feedNo.equals("")) {
			sql += " AND T.FEED_HEAT_NO=?";
			param.add(feedNo);
		}
		sql += CoreConverter.toSqlConditionString("T.PLANSTATUS", statusArr);
		sql += " ORDER BY S.GX_PRO_SEQ,T.PLINE_NAME  ASC";
		return this.getData(sql, param.toArray());
	}

	/**
	 * 查询镦拔扩实际炉计划
	 * 
	 * @return
	 */
	public CoreReturnObject queryPlnZyDbkReadyById(String timeBegin,
			String timeEnd, String plineCode, String orderNo, String proPlanId,
			String heatId, String[] statusArr, String judgeNo, String feedNo) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmPlanStoveE.queryPlanStoveReadyE");
		List<String> param = new ArrayList<String>();
		if (!timeBegin.equals("") && !timeEnd.equals("")) {
			sql += " AND TO_DATE(T.PRO_DAY, 'YYYY-MM-DD') BETWEEN TO_DATE(?,'YYYY-MM-DD') AND TO_DATE(?,'YYYY-MM-DD')";
			param.add(timeBegin);
			param.add(timeEnd);
		}
		if (!plineCode.equals("")) {
			sql += " AND T.PLINE_CODE=? ";
			param.add(plineCode);
		}
		if (!orderNo.equals("")) {
			sql += " AND T.ORDER_NO||'/'||T.ORDER_SEQ LIKE '%'||?||'%'";
			param.add(orderNo);
		}
		if (!proPlanId.equals("")) {
			sql += " AND T.PRO_PLAN_ID=?";
			param.add(proPlanId);
		}
		if (!heatId.equals("")) {
			sql += " AND T.HEAT_PLAN_NO LIKE '%'||?||'%'";
			param.add(heatId);
		}
		if (!judgeNo.equals("")) {
			sql += " AND T.JUDGE_STOVE_NO=?";
			param.add(judgeNo);
		}
		if (!feedNo.equals("")) {
			sql += " AND T.FEED_HEAT_NO=?";
			param.add(feedNo);
		}
		sql += CoreConverter.toSqlConditionString("T.PLANSTATUS", statusArr);
		sql += " ORDER BY T.GX_PRO_SEQ,T.HEAT_PLAN_NO ASC";
		return this.getData(sql, param.toArray());
	}

	/**
	 * 根据炉计划号查询实际炉计划
	 * 
	 * @param heatPlanNo
	 * @return
	 */
	public CoreReturnObject queryPlanStoveRow(String heatPlanNo) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmPlanStoveE.queryPlanStoveReadyE");
		sql += "  AND T.HEAT_PLAN_NO ='" + heatPlanNo + "' ";
		sql += " ORDER BY T.GX_PRO_SEQ,T.HEAT_PLAN_NO ASC";
		return this.getData(sql);
	}

	/**
	 * 根据订单号，排产序号查询炉计划
	 * 
	 * @param
	 * @return
	 */
	public CoreReturnObject queryPlanStovePlanId(String proPlanId,
			String gxPlanNo) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmPlanStoveE.queryPlanStoveReadyE");
		sql += "  AND T.PRO_PLAN_ID ='" + proPlanId + "' AND T.GX_PLAN_NO='"
				+ gxPlanNo + "' ";
		sql += " ORDER BY T.GX_PRO_SEQ,T.HEAT_PLAN_NO ASC";
		return this.getData(sql);
	}

	/**
	 * 查询虚拟炉计划
	 */
	public static <T> T getQureyZyM(Connection con, String heatPlanNo,
			String processCode, Class<T> cls) throws SQLException {
		String sql = "";
		if (processCode.equals("D")) {
			sql = "SELECT T.* FROM PLN_ZY_ZG_M T WHERE 1=1";
		} else if (processCode.equals("E")) {
			sql = CoreXmlSqlParsersFactory
					.getSql("FrmPlanStoveE.queryPlanStoveME");
		} else if (processCode.equals("F")) {
			sql = CoreXmlSqlParsersFactory
					.getSql("FrmPlanStoveF.queryPlanStoveME");
		} else if (processCode.equals("G")) {
			sql = CoreXmlSqlParsersFactory
					.getSql("FrmPlanStoveG.queryPlanStoveME");
		} else if (processCode.equals("H")) {
			sql = CoreXmlSqlParsersFactory
					.getSql("FrmPlanStoveH.queryPlanStoveMH");
		}
		sql += "  AND T.HEAT_PLAN_NO ='" + heatPlanNo + "' ";
		PreparedStatement ps = con.prepareStatement(sql);
		ResultSet rs = ps.executeQuery();
		T t = EntityTool.getEntityByRs(rs, cls);
		rs.close();
		ps.close();
		return t;
	}

	/**
	 * 查询实际炉计划
	 */
	public static <T> T getQureyZyC(Connection con, String heatPlanNo,
			String heatPlanSeqNo, Class<T> cls, String processCode)
			throws SQLException {
		String sql = "";
		if (processCode.equals("E")) {
			sql = "SELECT T.* FROM PLN_ZY_DBK_C T WHERE 1=1";
		} else if (processCode.equals("F")) {
			sql = "SELECT T.* FROM PLN_ZY_RCL_C T WHERE 1=1";
		} else if (processCode.equals("G")) {
			sql = "SELECT T.* FROM PLN_ZY_JGX_C T WHERE 1=1";
		} else if (processCode.equals("H")) {
			sql = "SELECT T.* FROM PLN_ZY_JG_C T WHERE 1=1";
		}
		sql += "  AND T.HEAT_PLAN_NO ='" + heatPlanNo + "' ";
		sql += "  AND T.HEAT_PLAN_SQE ='" + heatPlanSeqNo + "' ";
		PreparedStatement ps = con.prepareStatement(sql);
		ResultSet rs = ps.executeQuery();
		T t = EntityTool.getEntityByRs(rs, cls);
		rs.close();
		ps.close();
		return t;
	}

	/**
	 * 根据订单查询炉计划
	 * 
	 * @param <T>
	 * @throws SQLException
	 */
	public static <T> ArrayList<T> getPlnZyM(Connection con, String proPlanId,
			String gxPlanNo, String processCode, Class<T> cls)
			throws SQLException {
		String sql = "";
		if (processCode.equals("E")) {
			sql = "SELECT T.* FROM PLN_ZY_DBK_M T WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?";
		} else if (processCode.equals("F")) {
			sql = "SELECT T.* FROM PLN_ZY_RCL_M T WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?";
		} else if (processCode.equals("G")) {
			sql = "SELECT T.* FROM PLN_ZY_JGX_M T WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?";
		}
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, proPlanId);
		ps.setObject(2, gxPlanNo);
		ResultSet rs = ps.executeQuery();
		ArrayList<T> t = EntityTool.getEntitysByRs(rs, cls);
		rs.close();
		ps.close();
		return t;
	}

	/**
	 * 选择炉计划下发，撤销下发
	 */
	public CoreReturnObject doFurnacePlan(ArrayList<ArrayList<String>> jslist,
			String userName, String flag, String proPlanId, String gxPlanNo,ArrayList<String> possList)
			throws ParseException {
		CoreReturnObject cro = new CoreReturnObject();
		Connection conn = null;
		//Connection tmsCon = null;
		try {
			conn = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			//tmsCon = this.getDao("TmsDao").getConnection();注释生产物流  2024/4/24 肖沅累
			conn.setAutoCommit(false);
			//tmsCon.setAutoCommit(false);
			PreparedStatement ps = null;
			ResultSet rs = null;
			String msg = "";
			// 获取数据库当前时间
			String dateTime = FrmSteelMakingPlanChange.getSystemTime(conn);

			// 查询镦拔扩信息
			PlnOrderDbkSEntity plnOrderS = FrmPlanMaterialDbk.getPlanOrderS(
					conn, proPlanId, gxPlanNo, PlnOrderDbkSEntity.class, "E");
			if (plnOrderS == null) {
				cro.setV_errMsg("未找到订单(" + proPlanId + "/" + gxPlanNo + ")信息!");
				return cro;
			}
			// 循环虚拟炉计划信息
			String heatPlanNo1 = "";
			for (int i = 0; i < jslist.size(); i++) {
				ArrayList<String> list = (ArrayList<String>) jslist.get(i);
				String heatPlanNo = list.get(0);
				if (heatPlanNo1.equals(heatPlanNo)) {
					continue;
				}
				if (heatPlanNo1.equals("") || !heatPlanNo1.equals(heatPlanNo)) {
					heatPlanNo1 = heatPlanNo;
				}
				// 查询炉计划信息
				PlnZyDbkMEntity listM = getQureyZyM(conn, heatPlanNo, "E",
						PlnZyDbkMEntity.class);
				if (listM == null) {
					cro.setV_errMsg("炉计划已发生变化,请重新查询!");
					return cro;
				}
				String feedHeatNo = listM.getFeedHeatNo();
				String judgeStoveNo = listM.getJudgeStoveNo();
				// String proPlanId = listM.getProPlanId();
				// String gxPlanNo = listM.getGxPlanNo();
				// String plnDivideId = listM.getPlnDivideId();
				String plineCode = listM.getPlineCode();
				String gowhereName = "";
				String gowhereCode = "";
				String ifProduct = "0";
				if (flag.equals("0") && !listM.getPlanstatus().equals("计划")) {
					cro.setV_errMsg("选择的炉计划状态不是计划状态,不能下发!");
					return cro;
				}
				if (flag.equals("1") && !listM.getPlanstatus().equals("下发")) {
					cro.setV_errMsg("选择的炉计划不是下发状态,不能撤销下发!");
					return cro;
				}
				String zyBatchId = "";
				String planstatus = "";
				if (flag.equals("1")) {// 撤销下发
					planstatus = "00";
					zyBatchId = "";
				} else {
					if (plnOrderS.getIfStoveIssued().equals("0")) {
						cro.setV_errMsg("订单(" + proPlanId + "/" + gxPlanNo
								+ "),未下发,请先下发订单锁定生产批次!");
						return cro;
					}
					planstatus = "10";
					zyBatchId = plnOrderS.getZyBatchId();
					if (zyBatchId.equals("")) {
						cro.setV_errMsg("生产批次不能为空,请确认!");
						return cro;
					}
					// 末工序获取去向
					String gowWhere = corePlanFurnProM.getPlineCodeGroup(conn,
							plineCode, 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, 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 countGz = 0;
					String gradenameM = "";
					// 查询镦拔扩订单对应钢种
					String sqlZgS = "SELECT T.GRADENAME FROM PLN_ZY_DBK_M T WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=?";
					ps = conn.prepareStatement(sqlZgS);
					ps.setObject(1, plnOrderS.getProPlanId());
					ps.setObject(2, plnOrderS.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) {
						cro.setV_errMsg("镦拔扩订单(" + plnOrderS.getProPlanId()
								+ "/" + plnOrderS.getGxPlanNo() + ")对应上料炉号("
								+ listM.getFeedHeatNo() + ")钢种不同,请先拆分镦拔扩订单!");
						return cro;
					}
					int counnum = StoveHelper.getQueryStation(conn, proPlanId,
							gxPlanNo, "E");
					if (counnum > 0) {
						ifProduct = "1";
					}
					if (judgeStoveNo.equals("")) {
						cro.setV_errMsg("镦拔扩订单(" + listM.getProPlanId() + "/"
								+ listM.getGxPlanNo() + ")判定炉号为空,不能下发!");
						return cro;
					}
					// 判断判定炉号是否重复下发
					String queryMjud = CoreXmlSqlParsersFactory
							.getSql("FrmPlanStoveE.QueryPlnZYStatus");
					ps = conn.prepareStatement(queryMjud);
					ps.setObject(1, judgeStoveNo);
					ps.setObject(2, proPlanId);
					ps.setObject(3, gxPlanNo);
					rs = ps.executeQuery();
					if (rs.next()) {
						if (!rs.getString("PLANSTATUS").equals("00")) {
							cro.setV_errMsg("判定炉号(" + judgeStoveNo + ")在镦拔扩订单("
									+ proPlanId + "/" + gxPlanNo
									+ ")下已下发,不能重复下发,请修改判定炉号!");
							return cro;
						}
					}
					rs.close();
					ps.close();
				}
				// 修改虚拟炉计划
				String deleteZgM = "UPDATE PLN_ZY_DBK_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=?  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, dateTime);
				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_DBK_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();

				if (flag.equals("1")) {
					// 撤销下工序虚拟炉计划
					String messeGx = PlanFurnProduction.deletePlnFurnRcl(
							listM.getProPlanId(), listM.getGxPlanNo(),
							userName, dateTime, heatPlanNo,
							listM.getPlnDivideId(), conn);
					if (!messeGx.equals("")) {
						cro.setV_errMsg(messeGx);
						return cro;
					}
				} else {
					// 新增下工序虚拟炉计划
					String messeGx = PlanFurnProduction.addPlnFurnRcl(
							listM.getProPlanId(), listM.getGxPlanNo(),
							userName, dateTime, heatPlanNo,
							listM.getPlnDivideId(), conn);
					if (!messeGx.equals("")) {
						cro.setV_errMsg(messeGx);
						return cro;
					}
				}
			}

			/*if (flag.equals("1")) {
				msg = writeDemand.cancelWriteDemandPlnSinger(jslist, "E", userName, tmsCon, conn);
			} else {
				msg = writeDemand.writeDemandPlnSinger(jslist, "E", userName, tmsCon, conn,possList);
			}*/
			if (!msg.equals("")) {
				cro.setV_errMsg("生成/删除运输需求出错!");
			}

			if (flag.equals("1")) {
				cro.setV_errMsg("撤销成功!");
			} else {
				cro.setV_errMsg("下发成功!");
			}
			conn.commit();
			//tmsCon.commit();
		}catch (SQLException sqle) {
			try {
				if (conn != null /*|| tmsCon !=null*/) {
					conn.rollback();
					//tmsCon.rollback();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
			cro.setV_errCode(-1);
			cro.setV_errMsg(sqle.getMessage());
		} finally {
			try {
				if (conn != null && !conn.isClosed()) {
					conn.close();
				}
				/*if (tmsCon != null && !tmsCon.isClosed()) {
					tmsCon.close();
				}*/
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return cro;
	}

	/**
	 * 比较2个数组，获取相对于数组1相同的元素、相对于数组2相同的元素，2个数组相同的元素
	 * 
	 * @param t1
	 * @param t2
	 * @return
	 */
	public static List<String> compareArry(List<String> t1, List<String> t2) {
		/**
		 * 集合A (新的数据有，旧的数据没有，即为要添加的数据)
		 */
		List<String> listA = new ArrayList<String>();
		for (String str1 : t1) {// 遍历新的数组元素
			if (!t2.contains(str1)) {// 旧的数组中不包含新的元素（即为要添加的元素）
				if (!listA.contains(str1)) {
					listA.add(String.valueOf(str1));
				}
			}
		}
		Collections.sort(listA);
		return listA;
	}

	/**
	 * 删除炉计划
	 */
	public CoreReturnObject doDeleteLu(ArrayList<ArrayList<String>> jslist,
			String userName) throws ParseException {
		CoreReturnObject cro = new CoreReturnObject();
		Connection conn = null;
		try {
			conn = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			conn.setAutoCommit(false);
			PreparedStatement ps = null;
			ResultSet rs = null;
			// 获取数据库当前时间
			String dateTime = FrmSteelMakingPlanChange.getSystemTime(conn);
			Date now = new Date();
			SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
			DecimalFormat df = new DecimalFormat("0000000000");
			int seq = 1;
			// 循环炉计划信息
			for (int i = 0; i < jslist.size(); i++) {
				ArrayList<String> list = (ArrayList<String>) jslist.get(i);
				String heatPlanNo = list.get(0);
				String heatPlanSeqNo = list.get(1);
				// 查询炉计信息

				PlnZyDbkMEntity listM = getQureyZyM(conn, heatPlanNo, "E",
						PlnZyDbkMEntity.class);
				if (listM == null) {
					cro.setV_errMsg("炉计划已发生变化,请重新查询!");
					return cro;
				}
				if (!listM.getPlanstatus().equals("计划")) {
					cro.setV_errMsg("选择的镦拔扩炉计划状态不是计划状态,不能删除!");
					return cro;
				}

				if (!heatPlanSeqNo.equals("")) {// 删除实际炉计划
					PlnZyDbkCEntity listC = getQureyZyC(conn, heatPlanNo,
							heatPlanSeqNo, PlnZyDbkCEntity.class, "E");
					if (listC == null) {
						cro.setV_errMsg("炉计划已发生变化,请重新查询!");
						return cro;
					}

					int plnNumGp = Integer.parseInt(listC.getPlanIndoubleNum());
					List<MatBcMEntityPln> matGpMlist = FrmRollTubeLibraryDbk
							.getQureyMatGpM(conn, listC, plnNumGp, heatPlanNo);
					if (matGpMlist == null) {
						cro.setV_errMsg("管坯物料已发生改变,请刷新!");
						return cro;
					}
					String proPlanIdNo = listC.getProPlanId() + "/"
							+ listC.getGxPlanNo();
					MatBcTrackEntity matTrack = FrmPlanMaterialDbk
							.getQureyMatTrack(conn, listC.getFeedHeatNo(),
									listC.getBatchNo(),
									listC.getBatchGroudNo(), plnNumGp, "1",
									proPlanIdNo, MatBcTrackEntity.class,
									"delete", "", "");
					int matCount = 0;
					for (MatBcMEntityPln matGpM : matGpMlist) {
						if (!matGpM.getMatStatus().equals("80150103")) {
							cro.setV_errMsg("判定炉号为:" + matGpM.getJudgeStoveNo()
									+ ",不是材料已编计划状态,不能删除炉计划!");
							return cro;
						}

						String matStatus = "80150102";
						if (matGpM.getJudgeResultCode() == null
								|| matGpM.getJudgeResultCode().equals("")) {
							matStatus = "80150101";
						}
						matCount += Integer.parseInt(matGpM.getActCount());
						// 修改坯子库存信息
						String sqlUpdateMat = CoreXmlSqlParsersFactory
								.getSql("FrmPlanMaterialDbk.UpdateMatGp");
						ps = conn.prepareStatement(sqlUpdateMat);
						ps.setObject(1, matStatus);
						ps.setObject(2, "");
						ps.setObject(3, "");
						ps.setObject(4, "0");
						ps.setObject(5, "0");
						ps.setObject(6, "");
						ps.setObject(7, "");
						ps.setObject(8, matGpM.getMatNo());
						ps.executeUpdate();
						ps.close();
					}
					String resumeSeq = dateFormat.format(now) + df.format(seq);
					// 生成利库日志
					matTrack.setResumeSeq(resumeSeq);
					matTrack.setEventId("900101");
					matTrack.setEventDesc("脱单");
					matTrack.setFormName("com.steering.pss.plnsaleord.planStove.FrmRollTubeLibraryDbk");
					matTrack.setCallFuncCoding("doDeleteLu");
					matTrack.setKeyvalue1("List<MatBcMEntityPln> matGpMlist");
					matTrack.setKeyvalue1Desc("物料主表关键字实体类集合");
					matTrack.setKeyvalue2("String userName");
					matTrack.setKeyvalue2Desc2("操作人");
					matTrack.setKeyvalue3("doDeleteLu");
					matTrack.setKeyvalue3Desc3("删除炉计划");
					matTrack.setProcessCdoe("E");
					matTrack.setMemo("");
					matTrack.setCreateName(userName);
					matTrack.setCreateTime(dateTime);
					seq++;
					String sqlAddTrack = EntityTool
							.fillSqlByEntity(
									CoreXmlSqlParsersFactory
											.getSql("FrmPlanMaterialDbk.addMatBcTrack"),
									matTrack);
					ps = conn.prepareStatement(sqlAddTrack);
					ps.executeUpdate();
					ps.close();

					if (matCount != plnNumGp) {
						cro.setV_errMsg("库存支数与实际炉计划支数不符,请确认!");
						return cro;
					}

					// 删除实际炉计划
					String deleteZgC = "DELETE PLN_ZY_DBK_C WHERE HEAT_PLAN_NO = ? AND HEAT_PLAN_SQE=?";
					ps = conn.prepareStatement(deleteZgC);
					ps.setObject(1, heatPlanNo);
					ps.setObject(2, heatPlanSeqNo);
					ps.executeUpdate();
					ps.close();

					// 查询实际炉计划是否全部删除
					int count = 0;
					String sql = "SELECT COUNT(*) COUNT FROM PLN_ZY_DBK_C T WHERE T.HEAT_PLAN_NO=?";
					ps = conn.prepareStatement(sql);
					ps.setObject(1, heatPlanNo);
					rs = ps.executeQuery();
					if (rs.next()) {
						count = rs.getInt("COUNT");
					}
					if (count == 0) {
						// 删除虚拟炉计划
						String deleteZgM = "DELETE PLN_ZY_DBK_M WHERE HEAT_PLAN_NO = ?";
						ps = conn.prepareStatement(deleteZgM);
						ps.setObject(1, heatPlanNo);
						ps.executeUpdate();
						ps.close();
					}
				} else {
					// 删除虚拟炉计划
					String deleteZgM = "DELETE PLN_ZY_DBK_M WHERE HEAT_PLAN_NO = ?";
					ps = conn.prepareStatement(deleteZgM);
					ps.setObject(1, heatPlanNo);
					ps.executeUpdate();
					ps.close();

					// 修改库存订单号
					String updateMat = "UPDATE MAT_BC_M T SET T.PRO_PLAN_ID_NEXT='', T.GX_PLAN_NO_NEXT='',T.NEXT_PROCESS_CDOE='',T.NEXT_PROCESS_DESC='',T.HEAT_PLAN_NO_NEXT=''"
							+ " WHERE T.JUDGE_STOVE_NO=? AND T.HEAT_PLAN_NO_NEXT=?  AND T.HANGING_FLAG='0'";
					ps = conn.prepareStatement(updateMat);
					ps.setObject(1, listM.getFeedHeatNo());
					ps.setObject(2, heatPlanNo);
					ps.executeUpdate();
					ps.close();
					// // 删除实际炉计划
					// String deleteZgC =
					// "DELETE PLN_ZY_DBK_C WHERE HEAT_PLAN_NO = ?";
					// ps = conn.prepareStatement(deleteZgC);
					// ps.setObject(1, heatPlanNo);
					// ps.executeUpdate();
					// ps.close();
				}

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

	/**
	 * 修改炉计划
	 */
	public CoreReturnObject doUpdate(ArrayList<ArrayList<String>> jslist,
			String userName, String processCode) throws ParseException {
		CoreReturnObject cro = new CoreReturnObject();
		Connection conn = null;
		try {
			conn = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			conn.setAutoCommit(false);
			PreparedStatement ps = null;
			// 循环炉计划信息
			for (int i = 0; i < jslist.size(); i++) {
				ArrayList<String> list = (ArrayList<String>) jslist.get(i);
				String heatPlanNo = list.get(0);
				// String heatPlanSeqNo = list.get(1);
				String feedStoveNo = list.get(2);
				String memo = list.get(3);
				String zyBatchId = list.get(4);
				if (processCode.equals("E")) {
					String outnumCut = list.get(5);
					// 查询炉计信息
					PlnZyDbkMEntity listM = getQureyZyM(conn, heatPlanNo, "E",
							PlnZyDbkMEntity.class);
					if (listM == null) {
						cro.setV_errMsg("炉计划已发生变化,请重新查询!");
						return cro;
					}
					if (!listM.getPlanstatus().equals("计划")) {
						cro.setV_errMsg("选择的镦拔扩炉计划状态不是计划状态,不能修改!");
						return cro;
					}

					// 修改虚拟炉计划
					String deleteZgM = "UPDATE PLN_ZY_DBK_M  SET JUDGE_STOVE_NO=? ,MEMO =?,UPDATE_NAME=?,UPDATE_TIME=SYSDATE,FLAG_STOVE_NO=?,outnum_cut=?,PLN_OUTSINGLE_NUM=PLN_INSINGLE_NUM*?  WHERE HEAT_PLAN_NO = ?";
					ps = conn.prepareStatement(deleteZgM);
					ps.setObject(1, feedStoveNo);
					ps.setObject(2, memo);
					ps.setObject(3, userName);
					ps.setObject(4, feedStoveNo);
					ps.setObject(5, outnumCut);
					ps.setObject(6, outnumCut);
					ps.setObject(7, heatPlanNo);
					ps.executeUpdate();
					ps.close();
					// 修改实际炉计划
					String deleteZgC = "UPDATE PLN_ZY_DBK_C SET JUDGE_STOVE_NO=? ,FLAG_STOVE_NO=?,outnum_cut=? WHERE HEAT_PLAN_NO = ? ";
					ps = conn.prepareStatement(deleteZgC);
					ps.setObject(1, feedStoveNo);
					ps.setObject(2, feedStoveNo);
					ps.setObject(3, outnumCut);
					ps.setObject(4, heatPlanNo);
					ps.executeUpdate();
					ps.close();
				} else if (processCode.equals("F")) {
					// 查询炉计信息
					PlnZyRclMEntity listM = getQureyZyM(conn, heatPlanNo, "F",
							PlnZyRclMEntity.class);
					if (listM == null) {
						cro.setV_errMsg("炉计划已发生变化,请重新查询!");
						return cro;
					}
					if (!listM.getPlanstatus().equals("计划")) {
						cro.setV_errMsg("选择的热处理炉计划状态不是计划状态,不能修改!");
						return cro;
					}
					// 修改虚拟炉计划
					String deleteZgM = "UPDATE PLN_ZY_RCL_M  SET JUDGE_STOVE_NO=? ,MEMO =?,UPDATE_NAME=?,UPDATE_TIME=SYSDATE,FLAG_STOVE_NO=?  WHERE HEAT_PLAN_NO = ?";
					ps = conn.prepareStatement(deleteZgM);
					ps.setObject(1, feedStoveNo);
					ps.setObject(2, memo);
					ps.setObject(3, userName);
					ps.setObject(4, feedStoveNo);
					ps.setObject(5, heatPlanNo);
					ps.executeUpdate();
					ps.close();
					// 修改实际炉计划
					String deleteZgC = "UPDATE PLN_ZY_RCL_C SET JUDGE_STOVE_NO=? ,FLAG_STOVE_NO=?  WHERE HEAT_PLAN_NO = ? ";
					ps = conn.prepareStatement(deleteZgC);
					ps.setObject(1, feedStoveNo);
					ps.setObject(2, feedStoveNo);
					ps.setObject(3, heatPlanNo);
					ps.executeUpdate();
					ps.close();
				} else if (processCode.equals("G")) {
					String outnumCut = list.get(5);
					// 查询炉计信息
					PlnZyJgxMEntity listM = getQureyZyM(conn, heatPlanNo, "G",
							PlnZyJgxMEntity.class);
					if (listM == null) {
						cro.setV_errMsg("炉计划已发生变化,请重新查询!");
						return cro;
					}
					if (!listM.getPlanstatus().equals("计划")&&!listM.getIfMatchOdd().equals("6")) {
						cro.setV_errMsg("选择的加工线炉计划状态不是计划状态,不能修改!");
						return cro;
					}
					// 修改虚拟炉计划
					String deleteZgM = "UPDATE PLN_ZY_JGX_M  SET JUDGE_STOVE_NO=? ,MEMO =?,UPDATE_NAME=?,UPDATE_TIME=SYSDATE,FLAG_STOVE_NO=?,OUTNUM_CUT=?,PLN_OUTSINGLE_NUM=PLN_INSINGLE_NUM*?  WHERE HEAT_PLAN_NO = ?";
					ps = conn.prepareStatement(deleteZgM);
					ps.setObject(1, feedStoveNo);
					ps.setObject(2, memo);
					ps.setObject(3, userName);
					ps.setObject(4, feedStoveNo);
					ps.setObject(5, outnumCut);
					ps.setObject(6, outnumCut);
					ps.setObject(7, heatPlanNo);
					ps.executeUpdate();
					ps.close();
					// 修改实际炉计划
					String deleteZgC = "UPDATE PLN_ZY_JGX_C SET JUDGE_STOVE_NO=?,FLAG_STOVE_NO=?,OUTNUM_CUT=?  WHERE HEAT_PLAN_NO = ? ";
					ps = conn.prepareStatement(deleteZgC);
					ps.setObject(1, feedStoveNo);
					ps.setObject(2, feedStoveNo);
					ps.setObject(3, outnumCut);
					ps.setObject(4, heatPlanNo);
					ps.executeUpdate();
					ps.close();
				}
			}
			cro.setV_errMsg("修改成功!");
			conn.commit();
		} catch (SQLException sqle) {
			try {
				if (conn != null) {
					conn.rollback();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
			cro.setV_errMsg(sqle.getMessage());
		} finally {
			try {
				if (conn != null && !conn.isClosed()) {
					conn.close();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return cro;
	}

	/**
	 * 删除剩余炉计划
	 * 
	 * @param jslist
	 * @param userName
	 *            操作人
	 * @throws ParseException
	 */
	public CoreReturnObject doDeleteStatr(ArrayList<ArrayList<String>> jslist,
			String userName, String processCode) throws ParseException {
		CoreReturnObject cro = new CoreReturnObject();
		Connection conn = null;
		try {
			conn = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			conn.setAutoCommit(false);
			PreparedStatement ps = null;
			ResultSet rs = null;
			// 循环虚拟炉计划信息
			for (int i = 0; i < jslist.size(); i++) {
				ArrayList<String> list = (ArrayList<String>) jslist.get(i);
				String heatPlanNo = list.get(0);
				String heatPlanSqe = list.get(1);
				int countNum = 0;// 可删除剩余支
				int actNum = 0;// 库存剩余支
				int realNum = 0;// 实际上料支
				String feedHeatNo = "";
				String proPlanId = "";
				String gxPlanNo = "";
				String batchNo = "";
				String batchGroudNo = "";
				String jugdeApplyCode = "";
				double realWt = 0;
				if (processCode.equals("E")) {
					// 查询炉计划可删除支
					String querySql = CoreXmlSqlParsersFactory
							.getSql("FrmPlanStoveE.QueryRemaDbk");
					ps = conn.prepareStatement(querySql);
					ps.setObject(1, heatPlanNo);
					ps.setObject(2, heatPlanSqe);
					rs = ps.executeQuery();
					if (rs.next()) {
						actNum = rs.getInt("ACT_COUNT");
						realWt = rs.getDouble("REAL_INDOUBLE_WT");
						countNum = rs.getInt("COUNTNUM");
						feedHeatNo = rs.getString("FEED_HEAT_NO");
						proPlanId = rs.getString("PRO_PLAN_ID");
						gxPlanNo = rs.getString("GX_PLAN_NO");
						batchNo = rs.getString("BATCH_NO");
						batchGroudNo = rs.getString("BATCH_GROUD_NO");
						jugdeApplyCode = rs.getString("JUGDE_APPLY_CODE");
						realNum = rs.getInt("REAL_INDOUBLE_NUM");
						if (rs.getInt("PLANSTATUS") < 20) {
							cro.setV_errMsg("上料炉号(" + feedHeatNo
									+ ")未上料,不能进行次操作!");
							return cro;
						}
					} else {
						cro.setV_errMsg("炉计划信息已发生改变,请重新查询数据!");
						return cro;
					}
					rs.close();
					ps.close();
					if (countNum <= 0 || actNum == 0) {
						cro.setV_errMsg("上料炉号(" + feedHeatNo + ")已全部上料!");
						return cro;
					}

					if (realNum == 0) {
						// 刪除原实际炉计划
						String updateOldC = " DELETE PLN_ZY_DBK_C T WHERE T.HEAT_PLAN_NO=? AND T.HEAT_PLAN_SQE=?";
						ps = conn.prepareStatement(updateOldC);
						ps.setObject(1, heatPlanNo);
						ps.setObject(2, heatPlanSqe);
						ps.executeUpdate();
						ps.close();
					} else {
						// 修改原实际炉计划
						String updateOldC = " UPDATE PLN_ZY_DBK_C T SET T.PLAN_INDOUBLE_NUM=TO_NUMBER(T.PLAN_INDOUBLE_NUM)-TO_NUMBER(?),t.PLAN_INDOUBLE_WT=TO_NUMBER(T.PLAN_INDOUBLE_WT)-TO_NUMBER(?)  WHERE T.HEAT_PLAN_NO=? AND T.HEAT_PLAN_SQE=?";
						ps = conn.prepareStatement(updateOldC);
						ps.setObject(1, realNum);
						ps.setObject(2, realWt);
						ps.setObject(3, heatPlanNo);
						ps.setObject(4, heatPlanSqe);
						ps.executeUpdate();
						ps.close();
					}
					// 修改原虚拟炉计划支吨
					String updateOldM = CoreXmlSqlParsersFactory
							.getSql("FrmPlanMaterialDbk.updatePlnZgM");
					ps = conn.prepareStatement(updateOldM);
					ps.setObject(1, heatPlanNo);
					ps.setObject(2, heatPlanNo);
					ps.executeUpdate();
					ps.close();
				} else if (processCode.equals("F")) {
					// 查询炉计划可删除支
					String querySql = CoreXmlSqlParsersFactory
							.getSql("FrmPlanStoveE.QueryRemaRcl");
					ps = conn.prepareStatement(querySql);
					ps.setObject(1, heatPlanNo);
					ps.setObject(2, heatPlanSqe);
					rs = ps.executeQuery();
					if (rs.next()) {
						actNum = rs.getInt("ACT_COUNT");
						realWt = rs.getDouble("REAL_INDOUBLE_WT");
						countNum = rs.getInt("COUNTNUM");
						feedHeatNo = rs.getString("JUDGE_STOVE_NO");
						proPlanId = rs.getString("PRO_PLAN_ID");
						gxPlanNo = rs.getString("GX_PLAN_NO");
						batchNo = rs.getString("BATCH_NO");
						batchGroudNo = rs.getString("BATCH_GROUD_NO");
						jugdeApplyCode = rs.getString("JUGDE_APPLY_CODE");
						realNum = rs.getInt("REAL_INDOUBLE_NUM");
						if (rs.getInt("PLANSTATUS") < 20) {
							cro.setV_errMsg("判定炉号(" + feedHeatNo
									+ ")未上料,不能进行次操作!");
							return cro;
						}
					} else {
						cro.setV_errMsg("炉计划信息已发生改变,请重新查询数据!");
						return cro;
					}
					rs.close();
					ps.close();
					if (countNum <= 0 || actNum == 0) {
						cro.setV_errMsg("判定炉号(" + feedHeatNo + ")已全部上料!");
						return cro;
					}
					if (realNum == 0) {
						// 刪除原实际炉计划
						String updateOldC = " DELETE PLN_ZY_RCL_C T WHERE T.HEAT_PLAN_NO=? AND T.HEAT_PLAN_SQE=?";
						ps = conn.prepareStatement(updateOldC);
						ps.setObject(1, heatPlanNo);
						ps.setObject(2, heatPlanSqe);
						ps.executeUpdate();
						ps.close();
					} else {
						// 修改原实际炉计划
						String updateOldC = " UPDATE PLN_ZY_RCL_C T SET T.PLAN_INDOUBLE_NUM=TO_NUMBER(T.PLAN_INDOUBLE_NUM)-TO_NUMBER(?),t.PLAN_INDOUBLE_WT=TO_NUMBER(T.PLAN_INDOUBLE_WT)-TO_NUMBER(?)  WHERE T.HEAT_PLAN_NO=? AND T.HEAT_PLAN_SQE=?";
						ps = conn.prepareStatement(updateOldC);
						ps.setObject(1, realNum);
						ps.setObject(2, realWt);
						ps.setObject(3, heatPlanNo);
						ps.setObject(4, heatPlanSqe);
						ps.executeUpdate();
						ps.close();
					}
					// 修改原虚拟炉计划支吨
					String updateOldM = CoreXmlSqlParsersFactory
							.getSql("FrmPlanMaterialRcl.updatePlnZgM");
					ps = conn.prepareStatement(updateOldM);
					ps.setObject(1, heatPlanNo);
					ps.setObject(2, heatPlanNo);
					ps.executeUpdate();
					ps.close();

				} else if (processCode.equals("G")) {
					// 查询炉计划可删除支
					String querySql = CoreXmlSqlParsersFactory
							.getSql("FrmPlanStoveE.QueryRemaJgx");
					ps = conn.prepareStatement(querySql);
					ps.setObject(1, heatPlanNo);
					ps.setObject(2, heatPlanSqe);
					rs = ps.executeQuery();
					if (rs.next()) {
						actNum = rs.getInt("ACT_COUNT");
						realWt = rs.getDouble("REAL_INDOUBLE_WT");
						countNum = rs.getInt("COUNTNUM");
						feedHeatNo = rs.getString("JUDGE_STOVE_NO");
						proPlanId = rs.getString("PRO_PLAN_ID");
						gxPlanNo = rs.getString("GX_PLAN_NO");
						batchNo = rs.getString("BATCH_NO");
						batchGroudNo = rs.getString("BATCH_GROUD_NO");
						jugdeApplyCode = rs.getString("JUGDE_APPLY_CODE");
						realNum = rs.getInt("REAL_INDOUBLE_NUM");
						if (rs.getInt("PLANSTATUS") < 20) {
							cro.setV_errMsg("判定炉号(" + feedHeatNo
									+ ")未上料,不能进行次操作!");
							return cro;
						}
					} else {
						cro.setV_errMsg("炉计划信息已发生改变,请重新查询数据!");
						return cro;
					}
					rs.close();
					ps.close();
					if (countNum <= 0 || actNum == 0) {
						cro.setV_errMsg("判定炉号(" + feedHeatNo + ")已全部上料!");
						return cro;
					}
					if (realNum == 0) {
						// 刪除原实际炉计划
						String updateOldC = " DELETE PLN_ZY_JGX_C T WHERE T.HEAT_PLAN_NO=? AND T.HEAT_PLAN_SQE=?";
						ps = conn.prepareStatement(updateOldC);
						ps.setObject(1, heatPlanNo);
						ps.setObject(2, heatPlanSqe);
						ps.executeUpdate();
						ps.close();
					} else {
						// 修改原实际炉计划
						String updateOldC = "  UPDATE PLN_ZY_RCL_C T SET T.PLAN_INDOUBLE_NUM=TO_NUMBER(T.PLAN_INDOUBLE_NUM)-TO_NUMBER(?),t.PLAN_INDOUBLE_WT=TO_NUMBER(T.PLAN_INDOUBLE_WT)-TO_NUMBER(?)  WHERE T.HEAT_PLAN_NO=? AND T.HEAT_PLAN_SQE=?";
						ps = conn.prepareStatement(updateOldC);
						ps.setObject(1, realNum);
						ps.setObject(2, realWt);
						ps.setObject(3, heatPlanNo);
						ps.setObject(4, heatPlanSqe);
						ps.executeUpdate();
						ps.close();
					}
					// 修改原虚拟炉计划支吨
					String updateOldM = CoreXmlSqlParsersFactory
							.getSql("FrmPlanMaterialJgx.updatePlnZgM");
					ps = conn.prepareStatement(updateOldM);
					ps.setObject(1, heatPlanNo);
					ps.setObject(2, heatPlanNo);
					ps.executeUpdate();
					ps.close();

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

					// 查询炉计划可删除支
					String querySql = CoreXmlSqlParsersFactory
							.getSql("FrmPlanStoveE.QueryRemaJg");
					ps = conn.prepareStatement(querySql);
					ps.setObject(1, heatPlanNo);
					ps.setObject(2, heatPlanSqe);
					rs = ps.executeQuery();
					if (rs.next()) {
						actNum = rs.getInt("ACT_COUNT");
						realWt = rs.getDouble("REAL_INDOUBLE_WT");
						countNum = rs.getInt("COUNTNUM");
						feedHeatNo = rs.getString("JUDGE_STOVE_NO");
						proPlanId = rs.getString("PRO_PLAN_ID");
						gxPlanNo = rs.getString("GX_PLAN_NO");
						batchNo = rs.getString("BATCH_NO");
						batchGroudNo = rs.getString("BATCH_GROUD_NO");
						jugdeApplyCode = rs.getString("JUGDE_APPLY_CODE");
						realNum = rs.getInt("REAL_INDOUBLE_NUM");
						if (rs.getInt("PLANSTATUS") < 20) {
							cro.setV_errMsg("判定炉号(" + feedHeatNo
									+ ")未上料,不能进行次操作!");
							return cro;
						}
					} else {
						cro.setV_errMsg("炉计划信息已发生改变,请重新查询数据!");
						return cro;
					}
					rs.close();
					ps.close();
					if (countNum <= 0 || actNum == 0) {
						cro.setV_errMsg("判定炉号(" + feedHeatNo + ")已全部上料!");
						return cro;
					}
					if (realNum == 0) {
						// 刪除原实际炉计划
						String updateOldC = " DELETE PLN_ZY_JG_C T WHERE T.HEAT_PLAN_NO=? AND T.HEAT_PLAN_SQE=?";
						ps = conn.prepareStatement(updateOldC);
						ps.setObject(1, heatPlanNo);
						ps.setObject(2, heatPlanSqe);
						ps.executeUpdate();
						ps.close();
					} else {
						// 修改原实际炉计划
						String updateOldC = " UPDATE PLN_ZY_JG_C T  SET T.USE_BL_NUM=TO_NUMBER(?),t.USE_BL_WT=TO_NUMBER(?)  WHERE T.HEAT_PLAN_NO=? AND T.HEAT_PLAN_SQE=?";
						ps = conn.prepareStatement(updateOldC);
						ps.setObject(1, realNum);
						ps.setObject(2, realWt);
						ps.setObject(3, heatPlanNo);
						ps.setObject(4, heatPlanSqe);
						ps.executeUpdate();
						ps.close();
					}
					// 修改原虚拟炉计划支吨
					String updateOldM = CoreXmlSqlParsersFactory
							.getSql("FrmPlanMaterialJg.updatePlnZgM");
					ps = conn.prepareStatement(updateOldM);
					ps.setObject(1, heatPlanNo);
					ps.setObject(2, heatPlanNo);
					ps.executeUpdate();
					ps.close();

				}
				// 修改库存释放余材
				String updateSql = CoreXmlSqlParsersFactory
						.getSql("FrmPlanStoveE.UpdateMatBcYc");
				ps = conn.prepareStatement(updateSql);
				ps.setObject(1, feedHeatNo);
				ps.setObject(2, jugdeApplyCode);
				ps.setObject(3, proPlanId);
				ps.setObject(4, gxPlanNo);
				ps.setObject(5, batchNo);
				ps.setObject(6, batchGroudNo);
				ps.setObject(7, processCode);
				ps.executeUpdate();
				ps.close();
			}
			cro.setV_errMsg("删除成功!");

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

	/**
	 * 修改订单轧批号
	 * 
	 * @param
	 * @return
	 */
	public CoreReturnObject updateBatch(ArrayList<String> jsonList) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection conn = null;
		try {
			conn = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			conn.setAutoCommit(false);
			List<PlnOrderZgSEntity> list = PlnHelper.jsonsToEntityList(
					PlnOrderZgSEntity.class, jsonList);
			PreparedStatement ps = null;
			ResultSet rs = null;
			for (PlnOrderZgSEntity zgSEntity : list) {
				String sql = CoreXmlSqlParsersFactory
						.getSql("FrmPlanStoveE.queryZgMSStatus");
				ps = conn.prepareStatement(sql);
				ps.setObject(1, zgSEntity.getProPlanId());
				ps.setObject(2, zgSEntity.getGxPlanNo());
				rs = ps.executeQuery();
				if (rs.next()) {
					if (!rs.getString("EXE_STATUS").equals("0")) {
						cro.setV_errMsg("合同号：" + zgSEntity.getOrderNo()
								+ ",不是计划状态,不允许修改。");
						return cro;
					}
					// if (rs.getString("EXE_STATUS").equals("0")
					// && rs.getString("IS_PLAN_OK") != null
					// && rs.getString("IS_PLAN_OK").equals("1")) {
					// cro.setV_errMsg("合同号：" + zgSEntity.getOrderNo()
					// + ",已确认,不允许修改。");
					// return cro;
					// }
					if (rs.getString("IF_STOVE_ISSUED") != null
							&& rs.getString("IF_STOVE_ISSUED").equals("1")) {
						cro.setV_errMsg("合同号：" + zgSEntity.getOrderNo()
								+ ",已炉计划下发,不允许修改。");
						return cro;
					}
				} else {
					cro.setV_errMsg("找不到合同：" + zgSEntity.getOrderNo() + "。");
					return cro;
				}
				rs.close();
				ps.close();

				// 查询是否有重复轧批号
				int count = 0;
				sql = CoreXmlSqlParsersFactory
						.getSql("FrmPlanStoveE.SelectatchId");
				ps = conn.prepareStatement(sql);
				ps.setObject(1, zgSEntity.getZyBatchId());
				ps.setObject(2, zgSEntity.getPlineCode());
				rs = ps.executeQuery();
				if (rs.next()) {
					count = rs.getInt("COUNT");
				}
				rs.close();
				ps.close();
				if (count > 0) {
					cro.setV_errMsg("合同号：" + zgSEntity.getOrderNo()
							+ ",存在相同作业批次号,不允许修改。");
					return cro;
				}
				// 修改轧批号
				String sqlupdate = EntityTool.fillSqlByEntity(
						CoreXmlSqlParsersFactory
								.getSql("FrmPlanStoveE.UpdateBatchId"),
						zgSEntity);
				ps = conn.prepareStatement(sqlupdate);
				ps.executeUpdate();
				ps.close();
			}
			cro.setV_errMsg("修改成功!");
			conn.commit();
		} catch (SQLException sqle) {
			try {
				conn.rollback();
			} catch (SQLException e) {
				e.printStackTrace();
			}
			cro.setV_errCode(-1);
			cro.setV_errMsg(sqle.getMessage());
		} finally {
			try {
				if (conn != null && !conn.isClosed()) {
					conn.close();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return cro;
	}

	/**
	 * 炉计划拆分
	 */
	public CoreReturnObject doBreakUp(ArrayList<ArrayList<String>> jslist,
			String userName, String processCode) throws ParseException {
		CoreReturnObject cro = new CoreReturnObject();
		Connection conn = null;
		try {
			conn = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			conn.setAutoCommit(false);
			PreparedStatement ps = null;
			// 循环炉计划信息
			String heatPlanNoAdd = "";
			String heatPlanSeqNoAdd = "";
			for (int i = 0; i < jslist.size(); i++) {
				ArrayList<String> list = (ArrayList<String>) jslist.get(i);
				String heatPlanNo = list.get(0);
				String heatPlanSeqNo = list.get(1);

				int reaNum = 0;// 上料支
				int plnNum = 0;// 装炉支
				if (processCode.equals("E")) {
					// 查询炉计信息
					PlnZyDbkMEntity listM = getQureyZySipM(conn, heatPlanNo,
							"E", PlnZyDbkMEntity.class);
					if (listM == null) {
						cro.setV_errMsg("炉计划已发生变化,请重新查询!");
						return cro;
					}
					if (listM.getPlanstatus().equals("00")
							|| listM.getPlanstatus().equals("10")) {
						cro.setV_errMsg("选择的炉计划是计划/下发状态,不能拆分!");
						return cro;
					}
					PlnZyDbkCEntity listC = getQureyZyC(conn, heatPlanNo,
							heatPlanSeqNo, PlnZyDbkCEntity.class, "E");
					if (listC == null) {
						cro.setV_errMsg("选中的炉计划无装炉信息,不能拆分!");
						return cro;
					}
					if (listC.getRealIndoubleNum() != null
							&& !listC.getRealIndoubleNum().equals("")) {
						reaNum = Integer.parseInt(listC.getRealIndoubleNum());
					}
					if (listC.getPlanIndoubleNum() != null
							&& !listC.getPlanIndoubleNum().equals("")) {
						plnNum = Integer.parseInt(listC.getPlanIndoubleNum());
					}
					if (reaNum == 0) {
						cro.setV_errMsg("选中的炉计划无上料支,不能拆分!");
						return cro;
					}
					if (plnNum - reaNum <= 0) {
						cro.setV_errMsg("选中的炉计划已全部上料,不能拆分!");
						return cro;
					}
					int addPlnNum = plnNum - reaNum;// 拆分支
					// 查询库存拆分吨
					double addPlnWt = queryMatWt(conn, listC.getFeedHeatNo(),
							listC.getBatchNo(), listC.getBatchGroudNo(),
							listC.getJugdeApplyCode(), listC.getHeatPlanNo(),
							"E", addPlnNum);
					if (addPlnWt == 0) {
						cro.setV_errMsg("无库存信息,请确认!");
						return cro;
					}
					// 修改原实际炉计划支吨
					String updateOldC = " UPDATE PLN_ZY_DBK_C T SET T.PLAN_INDOUBLE_NUM=TO_NUMBER(T.PLAN_INDOUBLE_NUM)-TO_NUMBER(?), "
							+ " T.PLAN_INDOUBLE_WT=TO_NUMBER(T.PLAN_INDOUBLE_WT)-TO_NUMBER(?) "
							+ " WHERE T.HEAT_PLAN_NO=? AND T.HEAT_PLAN_SQE=?";
					ps = conn.prepareStatement(updateOldC);
					ps.setObject(1, addPlnNum);
					ps.setObject(2, addPlnWt);
					ps.setObject(3, heatPlanNo);
					ps.setObject(4, heatPlanSeqNo);
					ps.executeUpdate();
					ps.close();
					// 修改原虚拟炉计划支吨
					String updateOldM = CoreXmlSqlParsersFactory
							.getSql("FrmPlanMaterialDbk.updatePlnZgM");
					ps = conn.prepareStatement(updateOldM);
					ps.setObject(1, heatPlanNo);
					ps.setObject(2, heatPlanNo);
					ps.executeUpdate();
					ps.close();
					if (listM.getHeatPlanNoOld().equals("")) {
						listM.setHeatPlanNoOld(heatPlanNo);
					}
					// 查询炉计划ID
					heatPlanNoAdd = corePlanFurnProM.getMaxHeatPlanNo(conn,
							listM.getProPlanId(), listM.getProPlanId(), "E");
					heatPlanSeqNoAdd = corePlanFurnProM.getHeatPlanSeq(conn,
							heatPlanNoAdd, "E");

					listC.setPlanIndoubleNum(String.valueOf(addPlnNum));
					listC.setPlanIndoubleWt(String.valueOf(addPlnWt));
					listC.setRealIndoubleNum("");
					listC.setRealIndoubleWt("");
					listC.setRealOutdoubleNum("");
					listC.setRealOutdoubleWt("");
					// 新增新实际炉计划
					String addC = EntityTool.fillSqlByEntity(
							CoreXmlSqlParsersFactory
									.getSql("FrmPlanStoveE.addPlnCDbk"), listC);
					ps = conn.prepareStatement(addC);
					ps.setObject(1, heatPlanNoAdd);
					ps.setObject(2, heatPlanSeqNoAdd);
					ps.executeUpdate();
					ps.close();

					// listM.setPlnInsingleNum(String.valueOf(addPlnNum));
					// 新增新虚拟炉计划
					String addM = EntityTool.fillSqlByEntity(
							CoreXmlSqlParsersFactory
									.getSql("FrmPlanStoveE.addPlnMDbk"), listM);
					ps = conn.prepareStatement(addM);
					ps.setObject(1, heatPlanNoAdd);
					ps.setObject(2, userName);
					ps.executeUpdate();
					ps.close();

					// 修改原虚拟炉计划支吨
					String updateAdM = CoreXmlSqlParsersFactory
							.getSql("FrmPlanMaterialDbk.updatePlnZgM");
					ps = conn.prepareStatement(updateAdM);
					ps.setObject(1, heatPlanNoAdd);
					ps.setObject(2, heatPlanNoAdd);
					ps.executeUpdate();
					ps.close();
					// 修改库存下工序炉计划ID
					String updateMat = CoreXmlSqlParsersFactory
							.getSql("FrmPlanStoveE.UpdateMatBc");
					ps = conn.prepareStatement(updateMat);
					ps.setObject(1, listC.getFeedHeatNo());
					ps.setObject(2, listC.getBatchNo());
					ps.setObject(3, listC.getBatchGroudNo());
					ps.setObject(4, listC.getJugdeApplyCode());
					ps.setObject(5, listC.getHeatPlanNo());
					ps.setObject(6, processCode);
					ps.setObject(7, addPlnNum);
					ps.setObject(8, heatPlanNoAdd);
					ps.executeUpdate();
					ps.close();

				} else if (processCode.equals("F")) {
					// 查询炉计信息
					PlnZyRclMEntity listM = getQureyZySipM(conn, heatPlanNo,
							"F", PlnZyRclMEntity.class);
					if (listM == null) {
						cro.setV_errMsg("炉计划已发生变化,请重新查询!");
						return cro;
					}
					if (listM.getPlanstatus().equals("00")
							|| listM.getPlanstatus().equals("10")) {
						cro.setV_errMsg("选择的炉计划是计划/下发状态,不能拆分!");
						return cro;
					}
					PlnZyRclCEntity listC = getQureyZyC(conn, heatPlanNo,
							heatPlanSeqNo, PlnZyRclCEntity.class, "F");
					if (listC == null) {
						cro.setV_errMsg("选中的炉计划无装炉信息,不能拆分!");
						return cro;
					}
					if (listC.getRealIndoubleNum() != null
							&& !listC.getRealIndoubleNum().equals("")) {
						reaNum = Integer.parseInt(listC.getRealIndoubleNum());
					}
					if (listC.getPlanIndoubleNum() != null
							&& !listC.getPlanIndoubleNum().equals("")) {
						plnNum = Integer.parseInt(listC.getPlanIndoubleNum());
					}
					if (reaNum == 0) {
						cro.setV_errMsg("选中的炉计划无上料支,不能拆分!");
						return cro;
					}
					if (plnNum - reaNum <= 0) {
						cro.setV_errMsg("选中的炉计划已全部上料,不能拆分!");
						return cro;
					}
					int addPlnNum = plnNum - reaNum;// 拆分支
					// 查询库存拆分吨
					double addPlnWt = queryMatWt(conn, listC.getFeedHeatNo(),
							listC.getBatchNo(), listC.getBatchGroudNo(),
							listC.getJugdeApplyCode(), listC.getHeatPlanNo(),
							"F", addPlnNum);
					if (addPlnWt == 0) {
						cro.setV_errMsg("无库存信息,请确认!");
						return cro;
					}
					// 修改原实际炉计划支吨
					String updateOldC = " UPDATE PLN_ZY_RCL_C T SET T.PLAN_INDOUBLE_NUM=TO_NUMBER(T.PLAN_INDOUBLE_NUM)-TO_NUMBER(?), "
							+ " T.PLAN_INDOUBLE_WT=TO_NUMBER(T.PLAN_INDOUBLE_WT)-TO_NUMBER(?) "
							+ " WHERE T.HEAT_PLAN_NO=? AND T.HEAT_PLAN_SQE=?";
					ps = conn.prepareStatement(updateOldC);
					ps.setObject(1, addPlnNum);
					ps.setObject(2, addPlnWt);
					ps.setObject(3, heatPlanNo);
					ps.setObject(4, heatPlanSeqNo);
					ps.executeUpdate();
					ps.close();
					// 修改原虚拟炉计划支吨
					String updateOldM = CoreXmlSqlParsersFactory
							.getSql("FrmPlanMaterialRcl.updatePlnZgM");
					ps = conn.prepareStatement(updateOldM);
					ps.setObject(1, heatPlanNo);
					ps.setObject(2, heatPlanNo);
					ps.executeUpdate();
					ps.close();
					if (listM.getHeatPlanNoOld().equals("")) {
						listM.setHeatPlanNoOld(heatPlanNo);
					}
					// 查询炉计划ID
					heatPlanNoAdd = corePlanFurnProM.getMaxHeatPlanNo(conn,
							listM.getProPlanId(), listM.getProPlanId(), "F");
					heatPlanSeqNoAdd = corePlanFurnProM.getHeatPlanSeq(conn,
							heatPlanNoAdd, "F");

					listC.setPlanIndoubleNum(String.valueOf(addPlnNum));
					listC.setPlanIndoubleWt(String.valueOf(addPlnWt));
					listC.setRealIndoubleNum("");
					listC.setRealIndoubleWt("");
					listC.setRealOutdoubleNum("");
					listC.setRealOutdoubleWt("");
					// 新增新实际炉计划
					String addC = EntityTool.fillSqlByEntity(
							CoreXmlSqlParsersFactory
									.getSql("FrmPlanStoveF.addPlnCRcl"), listC);
					ps = conn.prepareStatement(addC);
					ps.setObject(1, heatPlanNoAdd);
					ps.setObject(2, heatPlanSeqNoAdd);
					ps.executeUpdate();
					ps.close();

					// listM.setPlnInsingleNum(String.valueOf(addPlnNum));
					// 新增新虚拟炉计划
					int lotNoSqe = corePlanFurnProM.getMaxLotNoSqe(conn,
							listM.getProPlanId(), listM.getGxPlanNo(), "F");
					listM.setLotNoSqe(String.valueOf(lotNoSqe));
					String addM = EntityTool.fillSqlByEntity(
							CoreXmlSqlParsersFactory
									.getSql("FrmPlanStoveF.addPlnMRcl"), listM);
					ps = conn.prepareStatement(addM);
					ps.setObject(1, heatPlanNoAdd);
					ps.setObject(2, userName);
					ps.executeUpdate();
					ps.close();
					// 新增生产批号
					StoveHelper.updatePlnRclGroup(conn, listM.getProPlanId(),
							listM.getGxPlanNo(), listM.getPic());
					// 修改原虚拟炉计划支吨
					String updateAdM = CoreXmlSqlParsersFactory
							.getSql("FrmPlanMaterialRcl.updatePlnZgM");
					ps = conn.prepareStatement(updateAdM);
					ps.setObject(1, heatPlanNoAdd);
					ps.setObject(2, heatPlanNoAdd);
					ps.executeUpdate();
					ps.close();
					// 修改库存下工序炉计划ID
					String updateMat = CoreXmlSqlParsersFactory
							.getSql("FrmPlanStoveE.UpdateMatBc");
					ps = conn.prepareStatement(updateMat);
					ps.setObject(1, listC.getFeedHeatNo());
					ps.setObject(2, listC.getBatchNo());
					ps.setObject(3, listC.getBatchGroudNo());
					ps.setObject(4, listC.getJugdeApplyCode());
					ps.setObject(5, listC.getHeatPlanNo());
					ps.setObject(6, processCode);
					ps.setObject(7, addPlnNum);
					ps.setObject(8, heatPlanNoAdd);
					ps.executeUpdate();
					ps.close();
				} else if (processCode.equals("G")) {
					// 查询炉计信息
					PlnZyJgxMEntity listM = getQureyZySipM(conn, heatPlanNo,
							"G", PlnZyJgxMEntity.class);
					if (listM == null) {
						cro.setV_errMsg("炉计划已发生变化,请重新查询!");
						return cro;
					}
					if (listM.getPlanstatus().equals("00")
							|| listM.getPlanstatus().equals("10")) {
						cro.setV_errMsg("选择的炉计划是计划/下发状态,不能拆分!");
						return cro;
					}
					PlnZyJgxCEntity listC = getQureyZyC(conn, heatPlanNo,
							heatPlanSeqNo, PlnZyJgxCEntity.class, "G");
					if (listC == null) {
						cro.setV_errMsg("选中的炉计划无装炉信息,不能拆分!");
						return cro;
					}
					if (listC.getRealIndoubleNum() != null
							&& !listC.getRealIndoubleNum().equals("")) {
						reaNum = Integer.parseInt(listC.getRealIndoubleNum());
					}
					if (listC.getPlanIndoubleNum() != null
							&& !listC.getPlanIndoubleNum().equals("")) {
						plnNum = Integer.parseInt(listC.getPlanIndoubleNum());
					}
					// if (reaNum == 0) {
					// cro.setV_errMsg("选中的炉计划无上料支,不能拆分!");
					// return cro;
					// }
					if (plnNum - reaNum <= 0) {
						cro.setV_errMsg("选中的炉计划已全部上料,不能拆分!");
						return cro;
					}
					int addPlnNum = plnNum - reaNum;// 拆分支
					// 查询库存拆分吨
					double addPlnWt = queryMatWt(conn, listC.getFeedHeatNo(),
							listC.getBatchNo(), listC.getBatchGroudNo(),
							listC.getJugdeApplyCode(), listC.getHeatPlanNo(),
							"G", addPlnNum);
					if (addPlnWt == 0) {
						cro.setV_errMsg("无库存信息,请确认!");
						return cro;
					}

					if (listM.getHeatPlanNoOld().equals("")) {
						listM.setHeatPlanNoOld(heatPlanNo);
					}
					// 查询炉计划ID
					heatPlanNoAdd = corePlanFurnProM.getMaxHeatPlanNo(conn,
							listM.getProPlanId(), listM.getProPlanId(), "G");
					heatPlanSeqNoAdd = corePlanFurnProM.getHeatPlanSeq(conn,
							heatPlanNoAdd, "G");

					listC.setPlanIndoubleNum(String.valueOf(addPlnNum));
					listC.setPlanIndoubleWt(String.valueOf(addPlnWt));
					listC.setRealIndoubleNum("");
					listC.setRealIndoubleWt("");
					listC.setRealOutdoubleNum("");
					listC.setRealOutdoubleWt("");
					// 新增新实际炉计划
					String addC = EntityTool.fillSqlByEntity(
							CoreXmlSqlParsersFactory
									.getSql("FrmPlanStoveG.addPlnCJgx"), listC);
					ps = conn.prepareStatement(addC);
					ps.setObject(1, heatPlanNoAdd);
					ps.setObject(2, heatPlanSeqNoAdd);
					ps.executeUpdate();
					ps.close();

					// listM.setPlnInsingleNum(String.valueOf(addPlnNum));
					// 新增新虚拟炉计划

					// 订单内炉顺序号
					int lotNo = corePlanFurnProM.getMaxLotNoSqe(conn,
							listM.getProPlanId(), listM.getGxPlanNo(), "G");
					listM.setLotNoSqe(String.valueOf(lotNo));
					String addM = EntityTool.fillSqlByEntity(
							CoreXmlSqlParsersFactory
									.getSql("FrmPlanStoveG.addPlnMJgx"), listM);
					ps = conn.prepareStatement(addM);
					ps.setObject(1, heatPlanNoAdd);
					ps.setObject(2, userName);
					ps.executeUpdate();
					ps.close();
					// 新增生产批号
					StoveHelper.updatePlnJgxGroup(conn, listM.getProPlanId(),
							listM.getGxPlanNo(), listM.getPic());

					if (plnNum == addPlnNum) {
						String deleteC = "DELETE PLN_ZY_JGX_C WHERE HEAT_PLAN_NO = ? AND HEAT_PLAN_SQE=?";
						ps = conn.prepareStatement(deleteC);
						ps.setObject(1, heatPlanNo);
						ps.setObject(2, heatPlanSeqNo);
						ps.executeUpdate();
						ps.close();
					} else {
						// 修改原实际炉计划支吨
						String updateOldC = " UPDATE PLN_ZY_JGX_C T SET T.PLAN_INDOUBLE_NUM=TO_NUMBER(T.PLAN_INDOUBLE_NUM)-TO_NUMBER(?), "
								+ " T.PLAN_INDOUBLE_WT=TO_NUMBER(T.PLAN_INDOUBLE_WT)-TO_NUMBER(?) "
								+ " WHERE T.HEAT_PLAN_NO=? AND T.HEAT_PLAN_SQE=?";
						ps = conn.prepareStatement(updateOldC);
						ps.setObject(1, addPlnNum);
						ps.setObject(2, addPlnWt);
						ps.setObject(3, heatPlanNo);
						ps.setObject(4, heatPlanSeqNo);
						ps.executeUpdate();
						ps.close();
					}
					// 修改原虚拟炉计划支吨
					String updateOldM = CoreXmlSqlParsersFactory
							.getSql("FrmPlanMaterialJgx.updatePlnZgM");
					ps = conn.prepareStatement(updateOldM);
					ps.setObject(1, heatPlanNo);
					ps.setObject(2, heatPlanNo);
					ps.executeUpdate();
					ps.close();
					// 修改原虚拟炉计划支吨
					String updateAdM = CoreXmlSqlParsersFactory
							.getSql("FrmPlanMaterialJgx.updatePlnZgM");
					ps = conn.prepareStatement(updateAdM);
					ps.setObject(1, heatPlanNoAdd);
					ps.setObject(2, heatPlanNoAdd);
					ps.executeUpdate();
					ps.close();
					// 修改库存下工序炉计划ID
					String updateMat = CoreXmlSqlParsersFactory
							.getSql("FrmPlanStoveE.UpdateMatBc");
					ps = conn.prepareStatement(updateMat);
					ps.setObject(1, listC.getFeedHeatNo());
					ps.setObject(2, listC.getBatchNo());
					ps.setObject(3, listC.getBatchGroudNo());
					ps.setObject(4, listC.getJugdeApplyCode());
					ps.setObject(5, listC.getHeatPlanNo());
					ps.setObject(6, processCode);
					ps.setObject(7, addPlnNum);
					ps.setObject(8, heatPlanNoAdd);
					ps.executeUpdate();
					ps.close();
				}
			}
			cro.setV_errMsg("拆分成功!");
			conn.commit();
		} catch (SQLException sqle) {
			try {
				if (conn != null) {
					conn.rollback();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
			cro.setV_errMsg(sqle.getMessage());
		} finally {
			try {
				if (conn != null && !conn.isClosed()) {
					conn.close();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return cro;
	}

	/**
	 * 按批拆分
	 */
	public CoreReturnObject dowholeBreak(ArrayList<ArrayList<String>> jslist,
			String userName, String processCode) throws ParseException {
		CoreReturnObject cro = new CoreReturnObject();
		Connection conn = null;
		try {
			conn = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			conn.setAutoCommit(false);
			PreparedStatement ps = null;
			// 循环炉计划信息
			String heatPlanNoAdd = "";
			String heatPlanSeqNoAdd = "";
			for (int i = 0; i < jslist.size(); i++) {
				ArrayList<String> list = (ArrayList<String>) jslist.get(i);
				String heatPlanNo = list.get(0);
				String heatPlanSeqNo = list.get(1);

				int reaNum = 0;// 上料支
				int plnNum = 0;// 装炉支
				if (processCode.equals("E")) {
					// 查询炉计信息
					PlnZyDbkMEntity listM = getQureyZySipM(conn, heatPlanNo,
							"E", PlnZyDbkMEntity.class);
					if (listM == null) {
						cro.setV_errMsg("炉计划已发生变化,请重新查询!");
						return cro;
					}
					if (listM.getPlanstatus().equals("00")
							|| listM.getPlanstatus().equals("10")) {
						cro.setV_errMsg("选择的炉计划是计划/下发状态,不能拆分!");
						return cro;
					}
					PlnZyDbkCEntity listC = getQureyZyC(conn, heatPlanNo,
							heatPlanSeqNo, PlnZyDbkCEntity.class, "E");
					if (listC == null) {
						cro.setV_errMsg("选中的炉计划无装炉信息,不能拆分!");
						return cro;
					}
					if (listC.getRealIndoubleNum() != null
							&& !listC.getRealIndoubleNum().equals("")) {
						reaNum = Integer.parseInt(listC.getRealIndoubleNum());
					}
					if (listC.getPlanIndoubleNum() != null
							&& !listC.getPlanIndoubleNum().equals("")) {
						plnNum = Integer.parseInt(listC.getPlanIndoubleNum());
					}
					if (reaNum > 0) {
						cro.setV_errMsg("选中的炉计划有上料支,不能拆分!");
						return cro;
					}
					// if (plnNum - reaNum <= 0) {
					// cro.setV_errMsg("选中的炉计划已全部上料,不能拆分!");
					// return cro;
					// }
					int addPlnNum = plnNum - reaNum;// 拆分支
					// 查询库存拆分吨
					double addPlnWt = queryMatWt(conn, listC.getFeedHeatNo(),
							listC.getBatchNo(), listC.getBatchGroudNo(),
							listC.getJugdeApplyCode(), listC.getHeatPlanNo(),
							"E", addPlnNum);
					if (addPlnWt == 0) {
						cro.setV_errMsg("无库存信息,请确认!");
						return cro;
					}
					if (listM.getHeatPlanNoOld().equals("")) {
						listM.setHeatPlanNoOld(heatPlanNo);
					}
					// if()
					// 查询炉计划ID
					heatPlanNoAdd = corePlanFurnProM.getMaxHeatPlanNo(conn,
							listM.getProPlanId(), listM.getProPlanId(), "E");
					heatPlanSeqNoAdd = corePlanFurnProM.getHeatPlanSeq(conn,
							heatPlanNoAdd, "E");
					// 新增新虚拟炉计划
					String addM = EntityTool.fillSqlByEntity(
							CoreXmlSqlParsersFactory
									.getSql("FrmPlanStoveE.addPlnMDbk"), listM);
					ps = conn.prepareStatement(addM);
					ps.setObject(1, heatPlanNoAdd);
					ps.setObject(2, userName);
					ps.executeUpdate();
					ps.close();

					listC.setPlanIndoubleNum(String.valueOf(addPlnNum));
					listC.setPlanIndoubleWt(String.valueOf(addPlnWt));
					listC.setRealIndoubleNum("");
					listC.setRealIndoubleWt("");
					listC.setRealOutdoubleNum("");
					listC.setRealOutdoubleWt("");
					// 新增新实际炉计划
					String addC = EntityTool.fillSqlByEntity(
							CoreXmlSqlParsersFactory
									.getSql("FrmPlanStoveE.addPlnCDbk"), listC);
					ps = conn.prepareStatement(addC);
					ps.setObject(1, heatPlanNoAdd);
					ps.setObject(2, heatPlanSeqNoAdd);
					ps.executeUpdate();
					ps.close();

					// 修改新虚拟炉计划支吨
					String updateAdM = CoreXmlSqlParsersFactory
							.getSql("FrmPlanMaterialDbk.updatePlnZgM");
					ps = conn.prepareStatement(updateAdM);
					ps.setObject(1, heatPlanNoAdd);
					ps.setObject(2, heatPlanNoAdd);
					ps.executeUpdate();
					ps.close();

					// 刪除原实际炉计划
					String updateOldC = " DELETE PLN_ZY_DBK_C T WHERE T.HEAT_PLAN_NO=? AND T.HEAT_PLAN_SQE=?";
					ps = conn.prepareStatement(updateOldC);
					ps.setObject(1, heatPlanNo);
					ps.setObject(2, heatPlanSeqNo);
					ps.executeUpdate();
					ps.close();
					// 修改原虚拟炉计划支吨
					String updateOldM = CoreXmlSqlParsersFactory
							.getSql("FrmPlanMaterialDbk.updatePlnZgM");
					ps = conn.prepareStatement(updateOldM);
					ps.setObject(1, heatPlanNo);
					ps.setObject(2, heatPlanNo);
					ps.executeUpdate();
					ps.close();

					// listM.setPlnInsingleNum(String.valueOf(addPlnNum));

					// 修改库存下工序炉计划ID
					String updateMat = CoreXmlSqlParsersFactory
							.getSql("FrmPlanStoveE.UpdateMatBc");
					ps = conn.prepareStatement(updateMat);
					ps.setObject(1, listC.getFeedHeatNo());
					ps.setObject(2, listC.getBatchNo());
					ps.setObject(3, listC.getBatchGroudNo());
					ps.setObject(4, listC.getJugdeApplyCode());
					ps.setObject(5, listC.getHeatPlanNo());
					ps.setObject(6, processCode);
					ps.setObject(7, addPlnNum);
					ps.setObject(8, heatPlanNoAdd);
					ps.executeUpdate();
					ps.close();

				} else if (processCode.equals("F")) {
					// 查询炉计信息
					PlnZyRclMEntity listM = getQureyZySipM(conn, heatPlanNo,
							"F", PlnZyRclMEntity.class);
					if (listM == null) {
						cro.setV_errMsg("炉计划已发生变化,请重新查询!");
						return cro;
					}
					if (listM.getPlanstatus().equals("00")
							|| listM.getPlanstatus().equals("10")) {
						cro.setV_errMsg("选择的炉计划是计划/下发状态,不能拆分!");
						return cro;
					}
					PlnZyRclCEntity listC = getQureyZyC(conn, heatPlanNo,
							heatPlanSeqNo, PlnZyRclCEntity.class, "F");
					if (listC == null) {
						cro.setV_errMsg("选中的炉计划无装炉信息,不能拆分!");
						return cro;
					}
					if (listC.getRealIndoubleNum() != null
							&& !listC.getRealIndoubleNum().equals("")) {
						reaNum = Integer.parseInt(listC.getRealIndoubleNum());
					}
					if (listC.getPlanIndoubleNum() != null
							&& !listC.getPlanIndoubleNum().equals("")) {
						plnNum = Integer.parseInt(listC.getPlanIndoubleNum());
					}
					if (reaNum == 0) {
						cro.setV_errMsg("选中的炉计划无上料支,不能拆分!");
						return cro;
					}
					if (plnNum - reaNum <= 0) {
						cro.setV_errMsg("选中的炉计划已全部上料,不能拆分!");
						return cro;
					}
					int addPlnNum = plnNum - reaNum;// 拆分支
					// 查询库存拆分吨
					double addPlnWt = queryMatWt(conn, listC.getFeedHeatNo(),
							listC.getBatchNo(), listC.getBatchGroudNo(),
							listC.getJugdeApplyCode(), listC.getHeatPlanNo(),
							"F", addPlnNum);
					if (addPlnWt == 0) {
						cro.setV_errMsg("无库存信息,请确认!");
						return cro;
					}
					// 修改原实际炉计划支吨
					String updateOldC = " UPDATE PLN_ZY_RCL_C T SET T.PLAN_INDOUBLE_NUM=TO_NUMBER(T.PLAN_INDOUBLE_NUM)-TO_NUMBER(?), "
							+ " T.PLAN_INDOUBLE_WT=TO_NUMBER(T.PLAN_INDOUBLE_WT)-TO_NUMBER(?) "
							+ " WHERE T.HEAT_PLAN_NO=? AND T.HEAT_PLAN_SQE=?";
					ps = conn.prepareStatement(updateOldC);
					ps.setObject(1, addPlnNum);
					ps.setObject(2, addPlnWt);
					ps.setObject(3, heatPlanNo);
					ps.setObject(4, heatPlanSeqNo);
					ps.executeUpdate();
					ps.close();
					// 修改原虚拟炉计划支吨
					String updateOldM = CoreXmlSqlParsersFactory
							.getSql("FrmPlanMaterialRcl.updatePlnZgM");
					ps = conn.prepareStatement(updateOldM);
					ps.setObject(1, heatPlanNo);
					ps.setObject(2, heatPlanNo);
					ps.executeUpdate();
					ps.close();
					if (listM.getHeatPlanNoOld().equals("")) {
						listM.setHeatPlanNoOld(heatPlanNo);
					}
					// 查询炉计划ID
					heatPlanNoAdd = corePlanFurnProM.getMaxHeatPlanNo(conn,
							listM.getProPlanId(), listM.getProPlanId(), "F");
					heatPlanSeqNoAdd = corePlanFurnProM.getHeatPlanSeq(conn,
							heatPlanNoAdd, "F");

					listC.setPlanIndoubleNum(String.valueOf(addPlnNum));
					listC.setPlanIndoubleWt(String.valueOf(addPlnWt));
					listC.setRealIndoubleNum("");
					listC.setRealIndoubleWt("");
					listC.setRealOutdoubleNum("");
					listC.setRealOutdoubleWt("");
					// 新增新实际炉计划
					String addC = EntityTool.fillSqlByEntity(
							CoreXmlSqlParsersFactory
									.getSql("FrmPlanStoveF.addPlnCRcl"), listC);
					ps = conn.prepareStatement(addC);
					ps.setObject(1, heatPlanNoAdd);
					ps.setObject(2, heatPlanSeqNoAdd);
					ps.executeUpdate();
					ps.close();

					// listM.setPlnInsingleNum(String.valueOf(addPlnNum));
					// 新增新虚拟炉计划
					String addM = EntityTool.fillSqlByEntity(
							CoreXmlSqlParsersFactory
									.getSql("FrmPlanStoveF.addPlnMRcl"), listM);
					ps = conn.prepareStatement(addM);
					ps.setObject(1, heatPlanNoAdd);
					ps.setObject(2, userName);
					ps.executeUpdate();
					ps.close();

					// 修改原虚拟炉计划支吨
					String updateAdM = CoreXmlSqlParsersFactory
							.getSql("FrmPlanMaterialRcl.updatePlnZgM");
					ps = conn.prepareStatement(updateAdM);
					ps.setObject(1, heatPlanNoAdd);
					ps.setObject(2, heatPlanNoAdd);
					ps.executeUpdate();
					ps.close();
					// 修改库存下工序炉计划ID
					String updateMat = CoreXmlSqlParsersFactory
							.getSql("FrmPlanStoveE.UpdateMatBc");
					ps = conn.prepareStatement(updateMat);
					ps.setObject(1, listC.getFeedHeatNo());
					ps.setObject(2, listC.getBatchNo());
					ps.setObject(3, listC.getBatchGroudNo());
					ps.setObject(4, listC.getJugdeApplyCode());
					ps.setObject(5, listC.getHeatPlanNo());
					ps.setObject(6, processCode);
					ps.setObject(7, addPlnNum);
					ps.setObject(8, heatPlanNoAdd);
					ps.executeUpdate();
					ps.close();
				} else if (processCode.equals("G")) {
					// 查询炉计信息
					PlnZyJgxMEntity listM = getQureyZySipM(conn, heatPlanNo,
							"G", PlnZyJgxMEntity.class);
					if (listM == null) {
						cro.setV_errMsg("炉计划已发生变化,请重新查询!");
						return cro;
					}
					if (listM.getPlanstatus().equals("00")
							|| listM.getPlanstatus().equals("10")) {
						cro.setV_errMsg("选择的炉计划是计划/下发状态,不能拆分!");
						return cro;
					}
					PlnZyJgxCEntity listC = getQureyZyC(conn, heatPlanNo,
							heatPlanSeqNo, PlnZyJgxCEntity.class, "G");
					if (listC == null) {
						cro.setV_errMsg("选中的炉计划无装炉信息,不能拆分!");
						return cro;
					}
					if (listC.getRealIndoubleNum() != null
							&& !listC.getRealIndoubleNum().equals("")) {
						reaNum = Integer.parseInt(listC.getRealIndoubleNum());
					}
					if (listC.getPlanIndoubleNum() != null
							&& !listC.getPlanIndoubleNum().equals("")) {
						plnNum = Integer.parseInt(listC.getPlanIndoubleNum());
					}
					if (reaNum == 0) {
						cro.setV_errMsg("选中的炉计划无上料支,不能拆分!");
						return cro;
					}
					if (plnNum - reaNum <= 0) {
						cro.setV_errMsg("选中的炉计划已全部上料,不能拆分!");
						return cro;
					}
					int addPlnNum = plnNum - reaNum;// 拆分支
					// 查询库存拆分吨
					double addPlnWt = queryMatWt(conn, listC.getFeedHeatNo(),
							listC.getBatchNo(), listC.getBatchGroudNo(),
							listC.getJugdeApplyCode(), listC.getHeatPlanNo(),
							"G", addPlnNum);
					if (addPlnWt == 0) {
						cro.setV_errMsg("无库存信息,请确认!");
						return cro;
					}
					// 修改原实际炉计划支吨
					String updateOldC = " UPDATE PLN_ZY_JGX_C T SET T.PLAN_INDOUBLE_NUM=TO_NUMBER(T.PLAN_INDOUBLE_NUM)-TO_NUMBER(?), "
							+ " T.PLAN_INDOUBLE_WT=TO_NUMBER(T.PLAN_INDOUBLE_WT)-TO_NUMBER(?) "
							+ " WHERE T.HEAT_PLAN_NO=? AND T.HEAT_PLAN_SQE=?";
					ps = conn.prepareStatement(updateOldC);
					ps.setObject(1, addPlnNum);
					ps.setObject(2, addPlnWt);
					ps.setObject(3, heatPlanNo);
					ps.setObject(4, heatPlanSeqNo);
					ps.executeUpdate();
					ps.close();
					// 修改原虚拟炉计划支吨
					String updateOldM = CoreXmlSqlParsersFactory
							.getSql("FrmPlanMaterialJgx.updatePlnZgM");
					ps = conn.prepareStatement(updateOldM);
					ps.setObject(1, heatPlanNo);
					ps.setObject(2, heatPlanNo);
					ps.executeUpdate();
					ps.close();
					if (listM.getHeatPlanNoOld().equals("")) {
						listM.setHeatPlanNoOld(heatPlanNo);
					}
					// 查询炉计划ID
					heatPlanNoAdd = corePlanFurnProM.getMaxHeatPlanNo(conn,
							listM.getProPlanId(), listM.getProPlanId(), "G");
					heatPlanSeqNoAdd = corePlanFurnProM.getHeatPlanSeq(conn,
							heatPlanNoAdd, "G");

					listC.setPlanIndoubleNum(String.valueOf(addPlnNum));
					listC.setPlanIndoubleWt(String.valueOf(addPlnWt));
					listC.setRealIndoubleNum("");
					listC.setRealIndoubleWt("");
					listC.setRealOutdoubleNum("");
					listC.setRealOutdoubleWt("");
					// 新增新实际炉计划
					String addC = EntityTool.fillSqlByEntity(
							CoreXmlSqlParsersFactory
									.getSql("FrmPlanStoveG.addPlnCJgx"), listC);
					ps = conn.prepareStatement(addC);
					ps.setObject(1, heatPlanNoAdd);
					ps.setObject(2, heatPlanSeqNoAdd);
					ps.executeUpdate();
					ps.close();

					// listM.setPlnInsingleNum(String.valueOf(addPlnNum));
					// 新增新虚拟炉计划
					String addM = EntityTool.fillSqlByEntity(
							CoreXmlSqlParsersFactory
									.getSql("FrmPlanStoveG.addPlnMJgx"), listM);
					ps = conn.prepareStatement(addM);
					ps.setObject(1, heatPlanNoAdd);
					ps.setObject(2, userName);
					ps.executeUpdate();
					ps.close();

					// 修改原虚拟炉计划支吨
					String updateAdM = CoreXmlSqlParsersFactory
							.getSql("FrmPlanMaterialJgx.updatePlnZgM");
					ps = conn.prepareStatement(updateAdM);
					ps.setObject(1, heatPlanNoAdd);
					ps.setObject(2, heatPlanNoAdd);
					ps.executeUpdate();
					ps.close();
					// 修改库存下工序炉计划ID
					String updateMat = CoreXmlSqlParsersFactory
							.getSql("FrmPlanStoveE.UpdateMatBc");
					ps = conn.prepareStatement(updateMat);
					ps.setObject(1, listC.getFeedHeatNo());
					ps.setObject(2, listC.getBatchNo());
					ps.setObject(3, listC.getBatchGroudNo());
					ps.setObject(4, listC.getJugdeApplyCode());
					ps.setObject(5, listC.getHeatPlanNo());
					ps.setObject(6, processCode);
					ps.setObject(7, addPlnNum);
					ps.setObject(8, heatPlanNoAdd);
					ps.executeUpdate();
					ps.close();
				}
			}
			cro.setV_errMsg("拆分成功!");
			conn.commit();
		} catch (SQLException sqle) {
			try {
				if (conn != null) {
					conn.rollback();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
			cro.setV_errMsg(sqle.getMessage());
		} finally {
			try {
				if (conn != null && !conn.isClosed()) {
					conn.close();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return cro;
	}

	/**
	 * 查询库存可拆分吨
	 * 
	 * @param con
	 * @throws SQLException
	 */
	public static double queryMatWt(Connection con, String judgeStoveNo,
			String batchNo, String batchGroudNo, String jugdeApplyCode,
			String heatPlanNo, String processCode, int num) throws SQLException {
		double wt = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmPlanStoveE.QueryMatWt");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, judgeStoveNo);
		ps.setObject(2, batchNo);
		ps.setObject(3, batchGroudNo);
		ps.setObject(4, jugdeApplyCode);
		ps.setObject(5, heatPlanNo);
		ps.setObject(6, processCode);
		ps.setObject(7, num);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			wt = rs.getDouble("ACT_WEIGHT");
		}
		rs.close();
		ps.close();
		return wt;
	}

	/**
	 * 查询拆分虚拟炉计划
	 */
	public static <T> T getQureyZySipM(Connection con, String heatPlanNo,
			String processCode, Class<T> cls) throws SQLException {
		String sql = "";
		if (processCode.equals("E")) {
			sql = "SELECT T.* FROM PLN_ZY_DBK_M T WHERE 1=1";
		} else if (processCode.equals("F")) {
			sql = "SELECT T.* FROM PLN_ZY_RCL_M T WHERE 1=1";
		} else if (processCode.equals("G")) {
			sql = "SELECT T.* FROM PLN_ZY_JGX_M T WHERE 1=1";
		} else if (processCode.equals("H")) {
			sql = "SELECT T.* FROM PLN_ZY_JG_M T WHERE 1=1";
		}
		sql += "  AND T.HEAT_PLAN_NO ='" + heatPlanNo + "' ";
		PreparedStatement ps = con.prepareStatement(sql);
		ResultSet rs = ps.executeQuery();
		T t = EntityTool.getEntityByRs(rs, cls);
		rs.close();
		ps.close();
		return t;
	}

	/**
	 * 手动关闭炉计划
	 */
	public CoreReturnObject doLuClose(ArrayList<ArrayList<String>> jslist,
			String userName) throws ParseException {
		CoreReturnObject cro = new CoreReturnObject();
		Connection conn = null;
		try {
			conn = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			conn.setAutoCommit(false);
			PreparedStatement ps = null;
			// 循环炉计划信息
			for (int i = 0; i < jslist.size(); i++) {
				ArrayList<String> list = (ArrayList<String>) jslist.get(i);
				String heatPlanNo = list.get(0);
				// 查询炉计信息
				PlnZyDbkMEntity listM = FrmPlanStoveE.getQureyZyM(conn,
						heatPlanNo, "E", PlnZyDbkMEntity.class);
				if (listM == null) {
					cro.setV_errMsg("炉计划已发生变化,请重新查询!");
					return cro;
				}
				if (listM.getPlanstatus().equals("关闭")) {
					cro.setV_errMsg("选择的镦拔扩炉计划状态是关闭状态,不能重复关闭!");
					return cro;
				}

				// 关闭炉计划
				String deleteZgC = "UPDATE PLN_ZY_DBK_M T SET T.IS_CLOSE='1',T.PLANSTATUS='40' WHERE HEAT_PLAN_NO = ?";
				ps = conn.prepareStatement(deleteZgC);
				ps.setObject(1, heatPlanNo);
				ps.executeUpdate();
				ps.close();
			}
			cro.setV_errMsg("关闭成功!");
			conn.commit();
		} catch (SQLException sqle) {
			try {
				if (conn != null) {
					conn.rollback();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
			cro.setV_errCode(-1);
			cro.setV_errMsg(sqle.getMessage());
		} finally {
			try {
				if (conn != null && !conn.isClosed()) {
					conn.close();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return cro;
	}
	/***
	 * 修改物流去向
	 * @param parmList
	 * @return
	 */
	public CoreReturnObject updateGoWhere(ArrayList<String> parmList)
	{
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		try {
			ArrayList<String> sqllist = new ArrayList<String>();
			for(String str: parmList)
			{
				PlnZyDbkMEntity plnZyZgEntity = EntityTool.getEntityByJSONStr(str,PlnZyDbkMEntity.class);
				String updateGoWhereSql = CoreXmlSqlParsersFactory.getSql("FrmPlanStoveE.updateGoWhere");
				updateGoWhereSql = EntityTool.fillSqlByEntity(updateGoWhereSql,plnZyZgEntity);
				sqllist.add(updateGoWhereSql);
			}
			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;
	}
	/***
	 * 修改上料标识
	 * @param parmList
	 * @return
	 */
	public CoreReturnObject updateLoadFlag(ArrayList<String> parmList) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		try {
			ArrayList<String> sqllist = new ArrayList<String>();
			for (String str : parmList) {
				PlnZyDbkMEntity plnZyZgEntity = EntityTool.getEntityByJSONStr(str, PlnZyDbkMEntity.class);
				if(plnZyZgEntity.getIsLoadFlag().equals("是"))
				{
					plnZyZgEntity.setIsLoadFlag("0");
				}else
				{
					plnZyZgEntity.setIsLoadFlag("1");
				}
				String updateGoWhereSql = CoreXmlSqlParsersFactory.getSql("FrmPlanStoveE.updateLoadFlag");
				updateGoWhereSql = EntityTool.fillSqlByEntity(updateGoWhereSql, plnZyZgEntity);
				sqllist.add(updateGoWhereSql);
			}
			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;
	}
	/***
	 * 标识过磅
	 * @param parmList
	 * @return
	 */
	public CoreReturnObject updateIsWeight(ArrayList<String> parmList) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		try {
			ArrayList<String> sqllist = new ArrayList<String>();
			for (String str : parmList) {
				PlnZyDbkMEntity plnZyZgEntity = EntityTool.getEntityByJSONStr(str, PlnZyDbkMEntity.class);
				if(!plnZyZgEntity.getPlanstatus().equals("计划"))
				{
					cro.setV_errMsg("炉计划不是计划状态的不允许修改过磅标识!");
					return  cro;
				}
				if(plnZyZgEntity.getIsWeightFlag().equals("是"))
				{
					plnZyZgEntity.setIsWeightFlag("0");
				}else
				{
					plnZyZgEntity.setIsWeightFlag("1");
				}
				String updateGoWhereSql = CoreXmlSqlParsersFactory.getSql("FrmPlanStoveE.updateIsWeight");
				updateGoWhereSql = EntityTool.fillSqlByEntity(updateGoWhereSql, plnZyZgEntity);
				sqllist.add(updateGoWhereSql);
			}
			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;
	}
}
