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.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.planStove.entity.MatBcTrackEntity;
import com.steering.pss.plnsaleord.processOrder.tmsDemand.writeDemand;
import com.steering.pss.plnsaleord.stove.PlanFurnProduction;
import com.steering.pss.plnsaleord.stove.corePlanFurnProM;
import com.steering.pss.plnsaleord.stove.entity.MatBcMEntityPln;
import com.steering.pss.plnsaleord.stove.entity.PlnOrderJgxSEntity;
import com.steering.pss.plnsaleord.stove.entity.PlnZyJgxMEntity;
import com.steering.pss.plnsaleord.stove.entity.PlnZyJgxCEntity;
import com.steering.pss.plnsaleord.stove.entity.PlnZyZgMEntity;
import com.steering.pss.plnsaleord.steelMarkingPlan.FrmSteelMakingPlanChange;
import com.steering.pss.sale.order.qualityDesign.QualityDesignTool;

/**
 * 加工线炉计划
 * 
 * @author
 */
public class FrmPlanStoveG extends DBCommon {

	/**
	 * 查询虚拟炉计划
	 * 
	 * @return
	 */
	public CoreReturnObject queryPlanStoveYzF(String timeBegin, String timeEnd,
			String plineCode, String orderNo, String proPlanId, String heatId,
			String[] statusArr, String judgeNo, String feedNo) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmPlanStoveG.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("FrmPlanStoveG.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("FrmPlanStoveG.queryPlanStoveReadyE");
		sql += "  AND T.HEAT_PLAN_NO ='" + heatPlanNo + "' ";
		sql += " ORDER BY T.lot_no_sqe ASC";
		return this.getData(sql);
	}

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

	/**
	 * 查询炉计划从表
	 * 
	 * @param con
	 * @param heatPlanNo
	 * @return
	 * @throws SQLException
	 */
	public static List<PlnZyJgxCEntity> getPlanJgxC(Connection con,
			String heatPlanNo) throws SQLException {
		String sql = "SELECT T.* FROM PLN_ZY_JGX_C T WHERE 1=1";
		sql += " AND T.HEAT_PLAN_NO='" + heatPlanNo + "'";
		PreparedStatement ps = con.prepareStatement(sql);
		ResultSet rs = ps.executeQuery();
		List<PlnZyJgxCEntity> list = EntityTool.getEntitysByRs(rs,
				PlnZyJgxCEntity.class);
		ps.close();
		rs.close();
		if (list == null || list.size() == 0) {
			return null;
		} else {
			for (PlnZyJgxCEntity listL : list) {
				QualityDesignTool.nullConverNullString(listL);
			}
			return list;
		}
	}

	/**
	 * 查询炉计划备份从表
	 * 
	 * @param con
	 * @param heatPlanNo
	 * @return
	 * @throws SQLException
	 */
	public static List<PlnZyJgxCEntity> getPlanJgxCBf(Connection con,
			String heatPlanNoNew, String heatPlanNo) throws SQLException {
		String sql = "SELECT T.* FROM PLN_ZY_JGX_C_OLD T WHERE 1=1";
		sql += " AND T.HEAT_PLAN_NO_NEW='" + heatPlanNoNew + "'";
		sql += " AND T.HEAT_PLAN_NO='" + heatPlanNo + "'";
		PreparedStatement ps = con.prepareStatement(sql);
		ResultSet rs = ps.executeQuery();
		List<PlnZyJgxCEntity> list = EntityTool.getEntitysByRs(rs,
				PlnZyJgxCEntity.class);
		ps.close();
		rs.close();
		if (list == null || list.size() == 0) {
			return null;
		} else {
			for (PlnZyJgxCEntity listL : list) {
				QualityDesignTool.nullConverNullString(listL);
			}
			return list;
		}
	}

	/**
	 * 查询炉计划备份主表
	 * 
	 * @param con
	 * @param heatPlanNo
	 * @return
	 * @throws SQLException
	 */
	public static List<PlnZyJgxMEntity> getPlanJgxMBf(Connection con,
			String heatPlanNo) throws SQLException {
		String sql = "SELECT T.* FROM PLN_ZY_JGX_M_OLD T WHERE 1=1";
		sql += " AND T.HEAT_PLAN_NO_NEW='" + heatPlanNo + "'";
		PreparedStatement ps = con.prepareStatement(sql);
		ResultSet rs = ps.executeQuery();
		List<PlnZyJgxMEntity> list = EntityTool.getEntitysByRs(rs,
				PlnZyJgxMEntity.class);
		ps.close();
		rs.close();
		if (list == null || list.size() == 0) {
			return null;
		} else {
			for (PlnZyJgxMEntity listL : list) {
				QualityDesignTool.nullConverNullString(listL);
			}
			return list;
		}
	}

	/**
	 * 选择炉计划下发，撤销下发
	 */
	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 = "";
			// ResultSet rs = null;
			// 获取数据库当前时间
			String dateTime = FrmSteelMakingPlanChange.getSystemTime(conn);
			PlnOrderJgxSEntity plnOrderS = FrmPlanMaterialDbk.getPlanOrderS(
					conn, proPlanId, gxPlanNo, PlnOrderJgxSEntity.class, "G");
			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;
				}
				// 查询炉计划信息
				PlnZyJgxMEntity listM = FrmPlanStoveE.getQureyZyM(conn,
						heatPlanNo, "G", PlnZyJgxMEntity.class);
				if (listM == null) {
					cro.setV_errMsg("炉计划已发生变化,请重新查询!");
					return cro;
				}
				if(listM.getOutwlDesc().equals(""))
				{
					cro.setV_errMsg("炉计划产出物料为空,不允许下发!");
					return cro;
				}
				// String proPlanId = listM.getProPlanId();
				// String gxPlanNo = listM.getGxPlanNo();
				// String plnDivideId = listM.getPlnDivideId();
				String plineCode = listM.getPlineCode();
				String judgeStoveNo = listM.getJudgeStoveNo();
				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, "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 = StoveHelper.getQueryStation(conn, proPlanId,
							gxPlanNo, "G");
					if (counnum > 0) {
						ifProduct = "1";
					}
					// // 判断判定炉号是否重复下发
					// String queryMjud =
					// "SELECT T.PLANSTATUS FROM PLN_ZY_JGX_M T  WHERE 1 = 1  AND T.JUDGE_STOVE_NO = ?  AND T.PRO_PLAN_ID = ? AND T.GX_PLAN_NO = ?  ORDER BY T.PLANSTATUS DESC";
					// 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_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=? 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_JGX_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.deletePlnFurnJg(
							listM.getProPlanId(), listM.getGxPlanNo(),
							userName, dateTime, heatPlanNo,
							listM.getPlnDivideId(), conn);
					if (!messeGx.equals("")) {
						cro.setV_errMsg(messeGx);
						return cro;
					}
				} else {
					// 新增下工序虚拟炉计划
					String messeGx = PlanFurnProduction.addPlnFurnJg(
							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, "G", userName, tmsCon, conn);
			} else {
				msg = writeDemand.writeDemandPlnSinger(jslist, "G", 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;
	}

	/**
	 * 选择炉计划删除
	 */
	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);
				// 查询炉计信息

				PlnZyJgxMEntity listM = FrmPlanStoveE.getQureyZyM(conn,
						heatPlanNo, "G", PlnZyJgxMEntity.class);
				if (listM == null) {
					cro.setV_errMsg("炉计划已发生变化,请重新查询!");
					return cro;
				}
				if (!listM.getPlanstatus().equals("计划")) {
					cro.setV_errMsg("选择的加工线炉计划状态不是计划状态,不能删除!");
					return cro;
				}
				int lotNo = Integer.parseInt(listM.getLotNoSqe());
				String proPlanId = listM.getProPlanId();
				String gxPlanNo = listM.getGxPlanNo();
				if (!heatPlanSeqNo.equals("")) {// 删除实际炉计划
					PlnZyJgxCEntity listC = FrmPlanStoveE.getQureyZyC(conn,
							heatPlanNo, heatPlanSeqNo, PlnZyJgxCEntity.class,
							"G");
					if (listC == null) {
						cro.setV_errMsg("炉计划已发生变化,请重新查询!");
						return cro;
					}

					int plnNumGp = Integer.parseInt(listC.getPlanIndoubleNum());
					List<MatBcMEntityPln> matGpMlist = FrmRollTubeLibraryJgx
							.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.FrmRollTubeLibraryJgx");
					matTrack.setCallFuncCoding("doDeleteLu");
					matTrack.setKeyvalue1("List<MatBcMEntityPln> matGpMlist");
					matTrack.setKeyvalue1Desc("物料主表关键字实体类集合");
					matTrack.setKeyvalue2("String userName");
					matTrack.setKeyvalue2Desc2("操作人");
					matTrack.setKeyvalue3("doDeleteLu");
					matTrack.setKeyvalue3Desc3("删除炉计划");
					matTrack.setProcessCdoe("G");
					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_JGX_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_JGX_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_JGX_M WHERE HEAT_PLAN_NO = ?";
						ps = conn.prepareStatement(deleteZgM);
						ps.setObject(1, heatPlanNo);
						ps.executeUpdate();
						ps.close();

						String updatesql = "UPDATE PLN_ZY_JGX_M T SET T.LOT_NO_SQE = TO_NUMBER(T.LOT_NO_SQE) + TO_NUMBER(-1)"
								+ " WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=? AND TO_NUMBER(T.LOT_NO_SQE) >= TO_NUMBER(?)";
						ps = conn.prepareStatement(updatesql);
						ps.setObject(1, proPlanId);
						ps.setObject(2, gxPlanNo);
						ps.setObject(3, lotNo);
						ps.executeUpdate();
						ps.close();

						// 新增生产批号
//						StoveHelper.updatePlnJgxGroup(conn, proPlanId,
//								gxPlanNo, listM.getPic());
					}
				} else {
					// 删除虚拟炉计划
					String deleteZgM = "DELETE PLN_ZY_JGX_M WHERE HEAT_PLAN_NO = ?";
					ps = conn.prepareStatement(deleteZgM);
					ps.setObject(1, heatPlanNo);
					ps.executeUpdate();
					ps.close();

					String sql = "UPDATE PLN_ZY_JGX_M T SET T.LOT_NO_SQE = TO_NUMBER(T.LOT_NO_SQE) + TO_NUMBER(-1)"
							+ " WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=? AND TO_NUMBER(T.LOT_NO_SQE) >= TO_NUMBER(?)";
					ps = conn.prepareStatement(sql);
					ps.setObject(1, proPlanId);
					ps.setObject(2, gxPlanNo);
					ps.setObject(3, lotNo);
					ps.executeUpdate();
					ps.close();
					// 新增生产批号
//					StoveHelper.updatePlnJgxGroup(conn, proPlanId, gxPlanNo,
//							listM.getPic());
					// 修改库存订单号
					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_JGX_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 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);
				// 查询炉计信息
				PlnZyJgxMEntity listM = FrmPlanStoveE.getQureyZyM(conn,
						heatPlanNo, "G", PlnZyJgxMEntity.class);
				if (listM == null) {
					cro.setV_errMsg("炉计划已发生变化,请重新查询!");
					return cro;
				}
				if (listM.getPlanstatus().equals("关闭")) {
					cro.setV_errMsg("选择的加工线炉计划状态是关闭状态,不能重复关闭!");
					return cro;
				}

				// 关闭炉计划
				String deleteZgC = "UPDATE PLN_ZY_JGX_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;
	}

	/**
	 * 合并炉计划
	 */
	public CoreReturnObject doMergeLu(ArrayList<ArrayList<String>> jslist,
			String createName, String heatPlanNoOld, String heatPlanNoSeqOld,
			String judgeStoveNo, String batchNo, String num)
			throws ParseException {
		CoreReturnObject cro = new CoreReturnObject();
		Connection conn = null;
		try {
			conn = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			conn.setAutoCommit(false);
			PreparedStatement ps = null;
			// 获取数据库当前时间
			String createTime = FrmSteelMakingPlanChange.getSystemTime(conn);
			PlnZyJgxMEntity listMOld = FrmPlanStoveE.getQureyZyM(conn,
					heatPlanNoOld, "G", PlnZyJgxMEntity.class);
			PlnZyJgxCEntity listCOld = FrmPlanStoveE
					.getQureyZyC(conn, heatPlanNoOld, heatPlanNoSeqOld,
							PlnZyJgxCEntity.class, "G");

			double weight = 0;
			// 循环炉计划信息
			for (int i = 0; i < jslist.size(); i++) {
				ArrayList<String> list = (ArrayList<String>) jslist.get(i);
				String heatPlanNo = list.get(0);

				// 查询炉计信息
				PlnZyJgxMEntity listM = FrmPlanStoveE.getQureyZyM(conn,
						heatPlanNo, "G", PlnZyJgxMEntity.class);
				if (listM == null) {
					cro.setV_errMsg("炉计划已发生变化,请重新查询!");
					return cro;
				}
				if (!listM.getPlanstatus().equals("计划")) {
					cro.setV_errMsg("选择的加工线炉计划不是计划状态,不能合并!");
					return cro;
				}
				int lotNo = Integer.parseInt(listM.getLotNoSqe());
				// 查询炉计信息
				List<PlnZyJgxCEntity> listC = getPlanJgxC(conn, heatPlanNo);
				if (listC == null) {
					cro.setV_errMsg("选择的加工线炉计划没有实际炉计划,不能合并!");
					return cro;
				}
				for (PlnZyJgxCEntity plnC : listC) {
					weight += Double.parseDouble(plnC.getPlanIndoubleWt());

					// 修改库存炉计划ID
					String updateMat = "UPDATE MAT_BC_M T SET T.HEAT_PLAN_NO_NEXT=? WHERE T.JUDGE_STOVE_NO=? AND T.BATCH_NO=? AND T.BATCH_GROUD_NO=? AND T.HEAT_PLAN_NO_NEXT=? AND T.MAT_STATUS='80150103' AND T.HANGING_FLAG='1'";
					ps = conn.prepareStatement(updateMat);
					ps.setObject(1, heatPlanNoOld);
					ps.setObject(2, plnC.getJudgeStoveNo());
					ps.setObject(3, plnC.getBatchNo());
					ps.setObject(4, plnC.getBatchGroudNo());
					ps.setObject(5, heatPlanNo);
					ps.executeUpdate();
					ps.close();
				}
				// 新增炉计划主表备份表
				String sqlMbf = CoreXmlSqlParsersFactory
						.getSql("FrmPlanStoveG.addPlnMOldBf");
				ps = conn.prepareStatement(sqlMbf);
				ps.setObject(1, heatPlanNoOld);
				ps.setObject(2, heatPlanNo);
				ps.executeUpdate();
				ps.close();
				// 新增炉计划从表备份表
				String sqlCbf = CoreXmlSqlParsersFactory
						.getSql("FrmPlanStoveG.addPlnCOldBf");
				ps = conn.prepareStatement(sqlCbf);
				ps.setObject(1, heatPlanNoOld);
				ps.setObject(2, heatPlanNo);
				ps.executeUpdate();
				ps.close();
				// 删除原主炉计划
				String deleteM = "DELETE PLN_ZY_JGX_M WHERE HEAT_PLAN_NO = ?";
				ps = conn.prepareStatement(deleteM);
				ps.setObject(1, heatPlanNo);
				ps.executeUpdate();
				ps.close();
				// 删除原从炉计划
				String deleteC = "DELETE PLN_ZY_JGX_C WHERE HEAT_PLAN_NO = ?";
				ps = conn.prepareStatement(deleteC);
				ps.setObject(1, heatPlanNo);
				ps.executeUpdate();
				ps.close();
				// 修改顺序号
				String updatesql = "UPDATE PLN_ZY_JGX_M T SET T.LOT_NO_SQE = TO_NUMBER(T.LOT_NO_SQE) + TO_NUMBER(-1)"
						+ " WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=? AND TO_NUMBER(T.LOT_NO_SQE) >= TO_NUMBER(?)";
				ps = conn.prepareStatement(updatesql);
				ps.setObject(1, listM.getProPlanId());
				ps.setObject(2, listM.getGxPlanNo());
				ps.setObject(3, lotNo);
				ps.executeUpdate();
				ps.close();

				// 新增生产批号
				StoveHelper.updatePlnJgxGroup(conn, listM.getProPlanId(),
						listM.getGxPlanNo(), listM.getPic());
			}

			// 获取炉计划顺序号
			int gxProSeq = corePlanFurnProM.getMaxGxPlnSeq(conn,
					listMOld.getPlineCode(), "G");
			// 订单内炉顺序号
			int lotNom = corePlanFurnProM.getMaxLotNoSqe(conn,
					listMOld.getProPlanId(), listMOld.getGxPlanNo(), "G");
			listMOld.setJudgeStoveNo(judgeStoveNo);
			listMOld.setDecision("A");
			listMOld.setPlanstatus("00");
			listMOld.setNextProcessCode("");
			listMOld.setIsendgx("1");
			listMOld.setIfMatchOdd("5");
			listMOld.setIfDoHeatPlan("1");
			listMOld.setZyBatchId("");
			// 单倍支吨
			listMOld.setPlnInsingleNum(num);
			listMOld.setPlnInsingleWt(String.valueOf(weight));
			listMOld.setPlnOutsingleNum(String.valueOf(Integer.parseInt(num)
					* Integer.parseInt(listMOld.getOutnumCut())));
			double burnoutRate = 0;
			// 查询产线烧损
			String sqlRate = "SELECT NVL(T.BURNOUT_RATE,0)/100 BURNOUT_RATE FROM COM_BASE_PLINE T WHERE T.PLINE_CODE='"
					+ listMOld.getPlineCode() + "'";
			ps = conn.prepareStatement(sqlRate);
			ResultSet rs = ps.executeQuery();
			if (rs.next()) {
				burnoutRate = rs.getDouble("BURNOUT_RATE");
			}
			rs.close();
			ps.close();
			double yjWt = weight - weight * burnoutRate;
			listMOld.setPlnOutsingleW(String.valueOf(yjWt));
			listMOld.setProDay(createTime.substring(0, 10).replace("-", ""));
			listMOld.setBalYearMonth(createTime.substring(0, 7)
					.replace("-", ""));
			listMOld.setCreateName(createName);
			listMOld.setCreateTime(createTime);
			listMOld.setLotNoSqe(String.valueOf(lotNom));
			listMOld.setHeatPlanNo(heatPlanNoOld);
			listMOld.setGxProSeq(String.valueOf(gxProSeq));
			// 新增炉计划主
			String addPlnGxZg = EntityTool
					.fillSqlByEntity(CoreXmlSqlParsersFactory
							.getSql("PlanFurnProduction.addPlnZyJgx"), listMOld);
			ps = conn.prepareStatement(addPlnGxZg);
			ps.executeUpdate();
			ps.close();
			// 新增生产批号
			StoveHelper.updatePlnJgxGroup(conn, listMOld.getProPlanId(),
					listMOld.getGxPlanNo(), listMOld.getPic());

			listCOld.setHeatPlanNo(heatPlanNoOld);
			listCOld.setJudgeStoveNo(judgeStoveNo);
			listCOld.setBatchNo(batchNo);
			listCOld.setBatchGroudNo("001");
			listCOld.setPlanIndoubleNum(num);
			listCOld.setPlanIndoubleWt(String.valueOf(weight));
			listCOld.setHeatPlanSqe(heatPlanNoSeqOld);
			// 新增炉计划从
			String addPlnGxZgC = EntityTool.fillSqlByEntity(
					CoreXmlSqlParsersFactory
							.getSql("PlanFurnProduction.addPlnZyJgxC"),
					listCOld);
			ps = conn.prepareStatement(addPlnGxZgC);
			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 doCancelMerge(ArrayList<ArrayList<String>> jslist,
			String createName) throws ParseException {
		CoreReturnObject cro = new CoreReturnObject();
		Connection conn = null;
		try {
			conn = this.getDao(CoreConstantData.sysbeanstr).getConnection();
			conn.setAutoCommit(false);
			PreparedStatement ps = null;
			// 获取数据库当前时间
//			String createTime = FrmSteelMakingPlanChange.getSystemTime(conn);
			// 循环炉计划信息
			for (int i = 0; i < jslist.size(); i++) {
				ArrayList<String> list = (ArrayList<String>) jslist.get(i);
				String heatPlanNo = list.get(0);
				// 查询炉计信息
				PlnZyJgxMEntity listM = FrmPlanStoveE.getQureyZyM(conn,
						heatPlanNo, "G", PlnZyJgxMEntity.class);
				if (listM == null) {
					cro.setV_errMsg("炉计划已发生变化,请重新查询!");
					return cro;
				}
				if (!listM.getPlanstatus().equals("计划")) {
					cro.setV_errMsg("选择的加工线炉计划不是计划状态,不能撤销合并!");
					return cro;
				}
				if (!listM.getIfMatchOdd().equals("合并计划")) {
					cro.setV_errMsg("选择的加工线炉计划不是合并计划,不能撤销合并!");
					return cro;
				}
				int lotNo = Integer.parseInt(listM.getLotNoSqe());

				// 删除原主炉计划
				String deleteM = "DELETE PLN_ZY_JGX_M WHERE HEAT_PLAN_NO = ?";
				ps = conn.prepareStatement(deleteM);
				ps.setObject(1, heatPlanNo);
				ps.executeUpdate();
				ps.close();
				// 删除原从炉计划
				String deleteC = "DELETE PLN_ZY_JGX_C WHERE HEAT_PLAN_NO = ?";
				ps = conn.prepareStatement(deleteC);
				ps.setObject(1, heatPlanNo);
				ps.executeUpdate();
				ps.close();
				// 修改顺序号
				String updatesql = "UPDATE PLN_ZY_JGX_M T SET T.LOT_NO_SQE = TO_NUMBER(T.LOT_NO_SQE) + TO_NUMBER(-1)"
						+ " WHERE T.PRO_PLAN_ID=? AND T.GX_PLAN_NO=? AND TO_NUMBER(T.LOT_NO_SQE) >= TO_NUMBER(?)";
				ps = conn.prepareStatement(updatesql);
				ps.setObject(1, listM.getProPlanId());
				ps.setObject(2, listM.getGxPlanNo());
				ps.setObject(3, lotNo);
				ps.executeUpdate();
				ps.close();

				// 查询备份表炉计划主表
				List<PlnZyJgxMEntity> listBfM = getPlanJgxMBf(conn, heatPlanNo);
				if (listBfM == null) {
					cro.setV_errMsg("未找到炉计划主信息,请重新查询!");
					return cro;
				}
				for (PlnZyJgxMEntity plnM : listBfM) {
					// 查询备份表炉计划从表
					List<PlnZyJgxCEntity> listBfC = getPlanJgxCBf(conn,
							heatPlanNo, plnM.getHeatPlanNo());
					if (listBfC == null) {
						cro.setV_errMsg("未找到炉计划从信息,请重新查询!");
						return cro;
					}
					for (PlnZyJgxCEntity plnC : listBfC) {
						// 修改库存炉计划ID
						String updateMat = "UPDATE MAT_BC_M T SET T.HEAT_PLAN_NO_NEXT=? WHERE T.JUDGE_STOVE_NO=? AND T.BATCH_NO=? AND T.BATCH_GROUD_NO=? AND T.HEAT_PLAN_NO_NEXT=? AND T.MAT_STATUS='80150103' AND T.HANGING_FLAG='1'";
						ps = conn.prepareStatement(updateMat);
						ps.setObject(1, plnC.getHeatPlanNo());
						ps.setObject(2, plnC.getJudgeStoveNo());
						ps.setObject(3, plnC.getBatchNo());
						ps.setObject(4, plnC.getBatchGroudNo());
						ps.setObject(5, heatPlanNo);
						ps.executeUpdate();
						ps.close();
					}
					// 订单内炉顺序号
					int lotNom = corePlanFurnProM.getMaxLotNoSqe(conn,
							plnM.getProPlanId(), plnM.getGxPlanNo(),
							"G");
					// 新增炉计划主表备份表
					String sqlMbf = CoreXmlSqlParsersFactory
							.getSql("FrmPlanStoveG.addPlnM");
					ps = conn.prepareStatement(sqlMbf);
					ps.setObject(1, lotNom);
					ps.setObject(2, heatPlanNo);
					ps.setObject(3, plnM.getHeatPlanNo());
					ps.executeUpdate();
					ps.close();

					// 新增生产批号
					StoveHelper.updatePlnJgxGroup(conn, listM.getProPlanId(),
							listM.getGxPlanNo(), listM.getPic());
					// 新增炉计划从表
					String sqlCbf = CoreXmlSqlParsersFactory
							.getSql("FrmPlanStoveG.addPlnC");
					ps = conn.prepareStatement(sqlCbf);
					ps.setObject(1, heatPlanNo);
					ps.setObject(2, plnM.getHeatPlanNo());
					ps.executeUpdate();
					ps.close();
				}
				// 删除炉计划主表备份表
				String sqlMbf = "DELETE PLN_ZY_JGX_M_OLD WHERE HEAT_PLAN_NO_NEW = ?";
				ps = conn.prepareStatement(sqlMbf);
				ps.setObject(1, heatPlanNo);
				ps.executeUpdate();
				ps.close();
				// 删除炉计划从表备份表
				String sqlCbf = "DELETE PLN_ZY_JGX_C_OLD WHERE HEAT_PLAN_NO_NEW = ?";
				ps = conn.prepareStatement(sqlCbf);
				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) {
				PlnZyJgxMEntity plnZyZgEntity = EntityTool.getEntityByJSONStr(str, PlnZyJgxMEntity.class);
				String updateGoWhereSql = CoreXmlSqlParsersFactory.getSql("FrmPlanStoveG.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) {
				PlnZyJgxMEntity plnZyZgEntity = EntityTool.getEntityByJSONStr(str, PlnZyJgxMEntity.class);
				if(plnZyZgEntity.getIsLoadFlag().equals("是"))
				{
					plnZyZgEntity.setIsLoadFlag("0");
				}else
				{
					plnZyZgEntity.setIsLoadFlag("1");
				}
				String updateGoWhereSql = CoreXmlSqlParsersFactory.getSql("FrmPlanStoveG.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) {
				PlnZyJgxMEntity plnZyZgEntity = EntityTool.getEntityByJSONStr(str, PlnZyJgxMEntity.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("FrmPlanStoveG.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;
	}
}
