package com.steering.mes.signature;

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.Calendar;
import java.util.Date;
import java.util.List;

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

import com.steering.comm.converter.CoreConverter;
import com.steering.comm.db.DBCommon;
import com.steering.common.EntityTool;
import com.steering.common.LoggableStatement;
import com.steering.common.StringTool;
import com.steering.mes.zgmil.entity.MatZcMEntity;
import com.steering.mes.zgmil.entity.MilPlanEntity3;
import com.steering.mes.zgmil.entity.PortMilBatchSampleResultEntity;
import com.steering.mes.zgmil.entity.QcmAddAskEntity;
import com.steering.mes.zgmil.entity.YdmZcInlistEntity;
import com.steering.mes.zgmil.entity.YdmZcOutlistEntity;

public class FrmInOnlineStore extends DBCommon {

	public CoreReturnObject querySinglePlan(ArrayList<String> list,
			String startTim, String endTim, String nodeStaus,
			String[] plineCodes) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.querySinglePlan");
		if (nodeStaus.equals("0")) {
			sql += " AND T.NODE_STATUS <> '99'";
		} else {
			sql += " AND T.NODE_STATUS = '99'";
		}
		if (!startTim.equals("")) {
			sql += " AND T.START_TIME >=TO_DATE('" + startTim
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.START_TIME <=TO_DATE('"
					+ endTim + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}
		if (!list.get(0).equals("")) {
			sql += " AND T.JUDGE_STOVE_NO LIKE '%" + list.get(0) + "%' ";
		}
		if (!list.get(1).equals("")) {
			sql += " AND T.LOT_NO LIKE '%" + list.get(1) + "%' ";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plineCodes);
		sql += " ORDER BY T.START_TIME,T.ID";
		sql += " ) T3 WHERE (T3.PLAN_COUNT > 0 OR T3.STATUS = '00')";
		return this.getData(sql);
	}
	
	public CoreReturnObject doQueryDeliveryNo(String ordLnPk) {
		 String sql = "select T.ORD_LN_DLY_PK BASECODE,T.DELIVERY_NO BASENAME from SLM_ORDER_LINE_DELIVERY t where t.ord_ln_pk = '"+ordLnPk+"'\r\n" ;
		return this.getData(sql);
	}

	public CoreReturnObject doSaveOrdLnDlyPk(ArrayList<String > parmList) 
	{
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		PreparedStatement psta = null;
		try {
			connection.setAutoCommit(false);
			String updateMatSql  = "";
			
			for (String str : parmList) {
			MatZcMEntity matBcEntity = EntityTool
				.getEntityByJSONStr(str, MatZcMEntity.class);
			updateMatSql = CoreXmlSqlParsersFactory
			.getSql("FrmInOnlineStore.doSaveOrdLnDlyPk");
			String strLengType = matBcEntity.getLengthType().equals("正尺") ? "0" : matBcEntity.getLengthType().equals("长尺") ? "1": matBcEntity.getLengthType().equals("短尺") ? "2":  matBcEntity.getLengthType();
			matBcEntity.setLengthType(strLengType);
			updateMatSql = EntityTool.fillSqlByEntity(updateMatSql, matBcEntity);
			psta = connection.prepareStatement(updateMatSql);
			psta.addBatch();
			psta.executeBatch();
			}
			cro.setResult(1);
			cro.setV_errMsg("保存成功!");
			connection.commit();
		}
		catch (Exception e) {
			System.out.println(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return cro;
		
	}
	
	/**
	 * 查询投入产出
	 * 
	 * @param list
	 * @param startTim
	 * @param endTim
	 * @return
	 * 
	 */
	public CoreReturnObject doQuerySingleJugStove(ArrayList<String> list,
			String startTim, String endTim, String nodeStaus) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.doQuerySingleJugStove2");
		// if (!startTim.equals("")) {
		// String str = " AND T.START_TIME >=TO_DATE('" + startTim
		// + "', 'YYYY-MM-DD HH24:MI:SS')AND T.START_TIME <=TO_DATE('"
		// + endTim + "', 'YYYY-MM-DD HH24:MI:SS') ";
		// sql = sql.replace("#condtions#", str);
		// } else {
		// sql = sql.replace("#condtions#", "");
		// }
		sql = sql.replace("#condtions#", "");
		// String str1 = " AND T.NODE_STATUS <> '99'";
		// String str2 = " AND T.NODE_STATUS = '99'";
		// if(nodeStaus.equals("0"))
		// {
		// sql = sql.replace("#condtions1#", str1);
		// }else
		// {
		// sql = sql.replace("#condtions1#", str2);
		// }
		sql = sql.replace("#condtions1#", "");
		sql = sql.replace("#JUDGE_STOVE_NO#", list.get(1)).replace("#LOT_NO#",
				list.get(2)).replace("#PLINE_CODE#", list.get(0));
		return this.getData(sql);
	}

	/***
	 * 查询表检的炉批信息
	 * 
	 * @param jugeStove
	 * @param plineCode
	 * @return
	 */
	public CoreReturnObject doQueryQaStove(String jugeStove, String plineCode) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryQaStove",
				new Object[] { jugeStove, plineCode });
	}

	/***
	 * 查询详细表检信息
	 * 
	 * @param p
	 * @param p2
	 * @param plineCode
	 * @return
	 */
	public CoreReturnObject doQuerySurface(ArrayList<String> parm, String goType) {
		if (goType.equals("A")) {
			return this.getDataBySqlID("FrmInOnlineStore.doQuerySurface", parm
					.toArray());
		} else {
			return this.getDataBySqlID("FrmInOnlineStore.doQuerySurface1", parm
					.toArray());
		}
	}

	/***
	 * 查询工序合同的去向
	 * 
	 * @param orderNo
	 * @return
	 */
	public CoreReturnObject doQueryGoType(String orderNo) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryGoType",
				new Object[] { orderNo });
	}

	/**
	 * 查询投料量调整记录
	 * 
	 * @param JugdeApplyCode
	 * @param JugdeApplySequeno
	 * @param JudgeStoveNo
	 * @param BatchNo
	 * @param BatchGroudNo
	 * @return
	 */
	public CoreReturnObject QueryZgApplyInputRecord(String JugdeApplyCode,
			String JugdeApplySequeno, String JudgeStoveNo, String BatchNo,
			String BatchGroudNo) {
		return this.getDataBySqlID("FrmInOnlineStore.QueryZgApplyInputRecord",
				new Object[] { JugdeApplyCode, JugdeApplySequeno, JudgeStoveNo,
						BatchNo, BatchGroudNo });
	}

	/***
	 * 查询材料实绩信息
	 * 
	 * @param list
	 * @param startTim
	 * @param endTim
	 * @return
	 */
	public CoreReturnObject doQueryMat(ArrayList<String> list, String startTim,
			String endTim, String departMentId, String plineCode, String value,
			String[] plineCodes) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.doQueryMat");
		String sql1 = "";
		if (!startTim.equals("")) {
			sql1 += " AND T1.INSTOCK_TIME >=TO_DATE('"
					+ startTim
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T1.INSTOCK_TIME <=TO_DATE('"
					+ endTim + "', 'YYYY-MM-DD HH24:MI:SS')";
		}
		if (value.equals("0")) {
			sql1 += " AND T1.JUGDE_APPLY_CODE IS NULL";
		} else if (value.equals("1")) {
			sql1 += " AND T1.JUGDE_APPLY_CODE IS NOT NULL";
		}
		if (!list.get(0).equals("")) {
			sql1 += " AND T1.JUDGE_STOVE_NO LIKE '%" + list.get(0) + "%' ";
		}
		sql1 += CoreConverter.toSqlConditionString("T1.PLINE_CODE", plineCodes);
		// sql1 += " AND T1.BELONG_CODE = '" + departMentId + "'";
		sql = sql.replace("#someThing#", sql1);
		return this.getData(sql);
	}

	/**
	 * 查询送判数据
	 * 
	 * @param list
	 * @param startTim
	 * @param endTim
	 * @param departMentId
	 * @param plineCode
	 * @param value
	 * @return
	 */
	public CoreReturnObject QueryZgJugdeApply(String jugeNo, String startTim,
			String endTim, String departMentId, String plineCode, String value) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.QueryZgJugdeApply");
		if (!startTim.equals("")) {
			sql += " AND T.APPLY_TIME >=TO_DATE('" + startTim
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.APPLY_TIME <=TO_DATE('"
					+ endTim + "', 'YYYY-MM-DD HH24:MI:SS')";
		}
		if (!"".equals(jugeNo)) {
			sql += " AND T.JUDGE_STOVE_NO = '" + jugeNo + "'";
		}
		if (!"".equals(plineCode)) {
			sql += " AND T.PLINE_CODE = '" + plineCode + "'";
		}
		// sql += " AND T.BELONG_CODE = '" + departMentId + "'";
		return this.getData(sql);
	}

	public CoreReturnObject QueryZgJugdeApply(String jugeNo, String startTim,
			String endTim, String plineCode) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.QueryZgJugdeApply");
		if (!startTim.equals("")) {
			sql += " AND T.APPLY_TIME >=TO_DATE('" + startTim
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.APPLY_TIME <=TO_DATE('"
					+ endTim + "', 'YYYY-MM-DD HH24:MI:SS')";
		}
		if (!"".equals(jugeNo)) {
			sql += " AND T.JUDGE_STOVE_NO = '" + jugeNo + "'";
		}
		if (!"".equals(plineCode)) {
			sql += " AND T.PLINE_CODE IN ( '" + plineCode + "') ";
		}
		// sql += " AND T.BELONG_CODE = '" + departMentId + "'";
		return this.getData(sql);
	}

	/***
	 * 查询材料实绩信息
	 * 
	 * @param list
	 * @param startTim
	 * @param endTim
	 * @return
	 */
	public CoreReturnObject doQueryMatWG(ArrayList<String> list,
			String startTim, String endTim, String value) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.doQueryMatWG");
		if (!startTim.equals("")) {
			sql += " AND T1.INSTOCK_TIME >=TO_DATE('"
					+ startTim
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T1.INSTOCK_TIME <=TO_DATE('"
					+ endTim + "', 'YYYY-MM-DD HH24:MI:SS')";
		}
		if (value.equals("0")) {
			sql += " AND T1.JUGDE_APPLY_CODE IS NULL";
		} else if (value.equals("1")) {
			sql += " AND T1.JUGDE_APPLY_CODE IS NOT NULL";
		}
		sql += " AND T1.BELONG_CODE IN( '002001001','002023005')";
		sql += " GROUP BY T1.JUDGE_STOVE_NO,T1.PRODUCCODE,T1.PRODUCNAME,T1.STEELCODE,T1.STEELNAME,T1.SPEC_CODE,T1.SPEC_NAME,T1.MODEL_CODE,T1.GRADECODE,T1.GRADENAME,T1.STD_STYLE,T1.STD_STYLE_DESC,T1.PIPMEMO,T1.MAT_STATUS,";
		sql += " T1.MODEL_DESC,T1.STD_CODE,T1.STD_NAME,T1.ORDER_NO,T1.ORDER_SEQ,T1.ORDER_SEQ_NO,T1.ACT_DIMATER,T1.ACT_HEIGHT,T1.BELONG_CODE,T1.BELONG_NAME,T1.PLINE_CODE,T1.PLINE_NAME,T1.MATERIAL_NO,T1.MATERIAL_NAME,";
		// T2.STORAGE_NO,T2.STORAGE_NAME,T2.LOCATION_NO,T1.OUTSTOCK_DOC,
		sql += " T1.ACT_LEN_MIN,T1.ACT_LEN_MAX,T1.MEMO,T1.PRODUCT_FLAG,T1.JUDGE_STD_DES,T1.JUDGE_STD_NAME,T1.CHEM_RESULT_CODE,T1.TARGET,T1.PACK_FLAG";
		return this.getData(sql, list.toArray());
	}

	/***
	 * 查询炉次计划号详细炉批组
	 * 
	 * @param heatPlanNo
	 * @return
	 */
	public CoreReturnObject doQueryMatData(String heatPlanNo, String value) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.doQueryMatPlanNo");
		System.out.println(sql);
		return this.getData(sql, new Object[] { heatPlanNo });
	}

	/***
	 * 查询炉次计划号详细炉批组
	 * 
	 * @param heatPlanNo
	 * @return
	 */
	public CoreReturnObject doQueryMatDataWG(String heatPlanNo, String value) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.doQueryMatPlanNoWG");

		return this.getData(sql, new Object[] { heatPlanNo });
	}

	/***
	 * 查询炉次计划号转移详细炉批组信息
	 * 
	 * @param heatPlanNo
	 * @return
	 */
	public CoreReturnObject doQueryMatDataOut(String heatPlanNo, String value) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.doQueryMatDataOut");

		if (value.equals("0")) {
			sql += " AND T1.JUGDE_APPLY_CODE IS NULL";
		} else if (value.equals("1")) {
			sql += " AND T1.JUGDE_APPLY_CODE IS NOT NULL";
		}
		sql += " GROUP BY T1.JUDGE_STOVE_NO, T1.BATCH_NO, T1.BATCH_GROUD_NO,T1.PRODUCCODE,T1.PRODUCNAME,T1.STEELCODE,T1.STEELNAME,T1.SPEC_CODE,T1.SPEC_NAME,T1.MODEL_CODE,T1.GRADECODE,T1.GRADENAME,T1.STD_STYLE,T1.STD_STYLE_DESC,T1.PIPMEMO,T1.OLD_ORDER_NO,T1.MAT_STATUS,T2.LOCATION_NO,T1.OUTSTOCK_DOC,T1.JUGDE_APPLY_CODE,T1.Heat_Plan_No,T1.QCM_STAUS,";
		sql += " T1.MODEL_DESC,T1.STD_CODE,T1.STD_NAME,T1.ORDER_NO,T1.ORDER_SEQ,T1.ORDER_SEQ_NO,T1.ACT_DIMATER,T1.ACT_HEIGHT,T1.LEN_NO,T1.LEN_DESC,T1.LEN_UNIT,T1.BELONG_CODE,T1.BELONG_NAME,T1.PLINE_CODE,T1.PLINE_NAME,T1.BAL_YEAR_MONTH,T1.MATERIAL_NO,T1.MATERIAL_NAME,";
		sql += " T1.ACT_LEN_MIN,T1.ACT_LEN_MAX,T1.CREATE_NAME,T2.STORAGE_NO,T2.STORAGE_NAME,T1.MEMO,T1.PRODUCT_FLAG,T1.JUDGE_STD_CODE,T1.JUDGE_STD_NAME ORDER BY T1.BAL_YEAR_MONTH DESC,T1.OUTSTOCK_DOC";

		return this.getData(sql, new Object[] { heatPlanNo });
	}

	/***
	 * 查询库存实绩
	 * 
	 * @return
	 */
	public CoreReturnObject doQueryMatButess(ArrayList<String> list,
			String startTim, String endTim, String departMentId,
			String[] plineCodes) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.doQueryMatButess");
		if (!list.get(0).equals("")) {
			sql += " AND T1.JUDGE_STOVE_NO LIKE '%" + list.get(0) + "%' ";
		}
		sql += CoreConverter.toSqlConditionString("T1.PLINE_CODE", plineCodes);
		if (!startTim.equals("")) {
			sql += " AND T1.INSTOCK_TIME >=TO_DATE('"
					+ startTim
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T1.INSTOCK_TIME <=TO_DATE('"
					+ endTim + "', 'YYYY-MM-DD HH24:MI:SS')";
		}
		// sql += " AND T1.BELONG_CODE = '" + departMentId + "'";
		sql += " GROUP BY T1.JUDGE_STOVE_NO, T1.BATCH_NO, T1.BATCH_GROUD_NO,T1.PRODUCCODE,T1.PRODUCNAME,T1.STEELCODE,T1.STEELNAME,T1.SPEC_CODE,T1.SPEC_NAME,T1.MODEL_CODE,T1.GRADECODE,T1.GRADENAME,T1.STD_STYLE,T1.STD_STYLE_DESC,T1.PIPMEMO,T1.MAT_STATUS,";
		sql += " T1.MODEL_DESC,T1.STD_CODE,T1.STD_NAME,T1.ORDER_NO,T1.ORDER_SEQ,T1.ORDER_SEQ_NO,T1.ACT_DIMATER,T1.ACT_HEIGHT,T1.BELONG_CODE,T1.BELONG_NAME,T1.PLINE_CODE,T1.PLINE_NAME,T1.BAL_YEAR_MONTH,T1.MATERIAL_NO,T1.MATERIAL_NAME,";
		sql += " T1.ACT_LEN_MIN,T1.ACT_LEN_MAX,T1.CREATE_NAME,T2.STORAGE_NO,S.STORAGE_NAME,T1.MEMO,T1.PRODUCT_FLAG,T1.JUDGE_STD_DES,T1.JUDGE_STD_NAME ORDER BY T1.BAL_YEAR_MONTH DESC";

		return this.getData(sql);
	}

	/***
	 * 查询入库实绩
	 * 
	 * @return
	 */
	public CoreReturnObject doQueryInList(ArrayList<String> list,
			String startTim, String endTim, String departMentId,
			String[] plineCodes) {
		String sql1 = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.doQueryInList");
		String sql = "";
		if (!startTim.equals("")) {
			sql += " AND TRUNC(t.IN_TIME_F)>=TO_DATE('" + startTim
					+ "','YYYY-MM-DD') AND TRUNC(t.IN_TIME_F)<= TO_DATE('"
					+ endTim + "','YYYY-MM-DD')";
		}
		// sql += " AND T.BELONG_CODE = '" + departMentId + "'";
		if (!list.get(0).equals("")) {
			sql += " AND t.JUDGE_STOVE_NO = '" + list.get(0) + "'";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plineCodes);
		sql1 = sql1.replace("#SOMETHING#", sql);
		return this.getData(sql1);
	}

	/***
	 * 查询支数、长度
	 * 
	 * @param list
	 * @param staus
	 * @return
	 */
	public CoreReturnObject doQueryNum(ArrayList<String> list, String staus) {
		String sql = "";
		if (staus.equals("样管")) {
			sql = CoreXmlSqlParsersFactory.getSql("doQueryNum.sample");
		} else {
			sql = CoreXmlSqlParsersFactory.getSql("doQueryNum.Qualified");
		}

		return this.getData(sql, list.toArray());
	}

	/***
	 * 查询取样所分批号
	 * 
	 * @param jugeNo
	 * @param lotNo
	 * @param id
	 * @return
	 */
	public CoreReturnObject doQueryBacthNo(String jugeNo, String lotNo,
			String id) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryBacthNo",
				new Object[] { jugeNo, lotNo, id });
	}

	/***
	 * 查询探伤所有结果
	 * 
	 * @return
	 */
	public CoreReturnObject doQueryFlawStaus() {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryFlawStaus");
	}

	/***
	 * 查询表检所有结果
	 * 
	 * @return
	 */
	public CoreReturnObject doQueryTestingStaus() {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryTestingStaus");
	}

	/***
	 * 查询产出炉信息
	 * 
	 * @param jugeNo
	 * @param lotNo
	 * @param id
	 * @return
	 */
	public CoreReturnObject doQueryBacthNoInformation(String jugeNo,
			String lotNo, String id, String flag, String sampleFlag) {
		if (flag.equals("样管")) {
			if (sampleFlag.equals("1")) {
				return this.getDataBySqlID(
						"FrmInOnlineStore.doQueryBacthNoInformation",
						new Object[] { id, jugeNo, jugeNo, jugeNo, lotNo, id,
								"1" });
			} else {
				return this.getDataBySqlID(
						"FrmInOnlineStore.doQueryBacthNoInformation3",
						new Object[] { id, jugeNo, jugeNo, jugeNo, lotNo, id,
								"1" });
			}

		} else if (flag.equals("合格")) {
			return this
					.getDataBySqlID(
							"FrmInOnlineStore.doQueryBacthNoInformation1",
							new Object[] { id, jugeNo, jugeNo, jugeNo, lotNo,
									id, "0" });
		} else if (flag.equals("判废")) {
			return this.getDataBySqlID(
					"FrmInOnlineStore.doQueryBacthNoInformation2",
					new Object[] { id, jugeNo, jugeNo, lotNo, id });
		} else {
			return this.getDataBySqlID(
					"FrmInOnlineStore.doQueryBacthNoInformation", new Object[] {
							id, jugeNo, jugeNo, lotNo, id, "2" });
		}
	}

	/**
	 * 短尺交库
	 * 
	 * @param maTtity
	 * @param list
	 * @param parm
	 * @param strInBound
	 * @param strInMemo
	 * @param storeNo
	 * @param storeName
	 * @param surplusFlag
	 * @param sampleFlag
	 * @param pckFlag
	 * @param matRetunFlag
	 * @param testType
	 * @param testGrade
	 * @param shortList
	 * @return
	 * @throws Exception
	 */
	public CoreReturnObject doPipeIn(String maTtity, ArrayList<String> list,
			ArrayList<ArrayList<String>> parm, String strInBound,
			String strInMemo, String storeNo, String storeName,
			String surplusFlag, String sampleFlag, String pckFlag,
			String matRetunFlag, String testType, String testGrade,
			ArrayList<ArrayList<String>> shortList) throws Exception {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
//		TZH 24.4.24 注销物流接口
//		Connection connection2 = this.getDao("TmsDao").getConnection();
		Date now = new Date();
		SimpleDateFormat dateFormat = new SimpleDateFormat(
				"yyyy-MM-dd HH:mm:ss");
		String systime = dateFormat.format(now);
		String yearMoth = "";// 改25号结转df.format(now);
		String groupNo = "";
		String inListDoc = "";
		String inListSeq = "";
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		String surPlusOrderNo = "";// 余材合同号
		int instoreNum = 0;// 总支数
		double instoreWgt = 0;// 总重量
		String orderNo[] = null;
		String lenMin = "0";// 轧管转移长度下限
		String lenMax = "0";// 轧管转移长度上限
		String LenType = "";// 定尺类型
		int n = 0;
		String orderPk = "";// 合同PK
		String orderLnPk = "";// 合同行PK
		String orderLnDivNo = "";// 交货行号
		String isDealer = "0";// 是否双经销(0 自用 1双经销)
		String materiaNo = "";// 物料码
		String materiaName = "";// 物料描述
		String INWL_ID = "";// 投入物料编码
		String INWL_DESC = "";// 投入物料描述
		String CRAFT_SEQ = ""; // 工艺序号
		String nextProcessCode = ""; // 下工序代码
		String nextProcessName = ""; // 下工序代码名称
		String nextProPlanID = ""; // 下工序订单编号
		String nextGxPlanNo = ""; // 下工序工序排产序号
		String judgeStdDes = ""; // 判定标准集合
		String cic = ""; // cic
		String lengthMin = ""; // 成品最小长度
		String lengthMax = ""; // 成品最大长度
		String actWeigth = ""; // 单支重量
		int sawNum = 1; // 分切数
		int sawNumW = 1; // 外委分切数

		try {
			connection.setAutoCommit(false); // 取消自动提交事务
//			TZH 24.4.24 注销物流接口
//			connection2.setAutoCommit(false); // 取消自动提交事务
			String insertButressSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.doPipeButress");// 位置表
			PreparedStatement insertButressPsta = connection
					.prepareStatement(insertButressSql);
			String insertInListSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.doPipeInList");// 入库表
			PreparedStatement insertListPsta = connection
					.prepareStatement(insertInListSql);
			String insertInListBSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.doPipeInListB");// 插入所属权的入库记录表（已屏蔽）
			PreparedStatement insertInListBPsta = connection
					.prepareStatement(insertInListBSql);
			String insertMatSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.doPipeMat");// 材料表
			PreparedStatement insertMatPsta = connection
					.prepareStatement(insertMatSql);
			String updateStausSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.updateStaus");
			PreparedStatement updateStausPsta = connection
					.prepareStatement(updateStausSql);// 修改状态进程表
			String updatePlanStausSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.updatePlanStaus");// 修改计划状态
			PreparedStatement updatePlanPsta = connection
					.prepareStatement(updatePlanStausSql);
			String insertMilInstoreSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.insertMilInstore");// 插入交库实绩表
			PreparedStatement insertMilInstorePsta = connection
					.prepareStatement(insertMilInstoreSql);

			String updateMilInstoreSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.updateMilInstore2");// 修改交库实绩表
			PreparedStatement updateMilInstorePsta = connection
					.prepareStatement(updateMilInstoreSql);

			String updateNextProPlanIDSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.updateNextProPlanID");// 修改材料表下工序订单编号
			PreparedStatement updateNextProPlanIDPsta = connection
					.prepareStatement(updateNextProPlanIDSql);

			MilPlanEntity3 milPlan = EntityTool.getEntityByJSONStr(maTtity,
					MilPlanEntity3.class);

			yearMoth = StringTool.GetBalYear(now,StringTool.GetSupplyUnit(milPlan.getPlineCode()));// 改25号结转
			String locode = milPlan.getJudgeStoveNo();
			orderNo = milPlan.getContractNo().split("[/]");// 拆分合同号
			inListDoc = querySendSqlDoc(connection, strInBound, strInMemo,
					milPlan.getPlineCode(), systime);// 入库单号
			inListSeq = querySendSql(connection, inListDoc, milPlan
					.getPlineCode()); // 入库流水号
			n = Integer.parseInt(inListSeq.substring(inListSeq.length() - 4,
					inListSeq.length()));
			if (surplusFlag.equals("1")) {
				surPlusOrderNo = querySurplusOrderNo(connection, milPlan
						.getPlineCode());
			}
			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.selectLenM");// 查询轧管转移长度
			psta = connection.prepareStatement(sql);
			psta.setString(1, milPlan.getOrdLnDlyPk());
			rs = psta.executeQuery();
			if (rs.next()) {
				if (Double.parseDouble(rs.getString("LENGTHMIN")) > 0) {
					lenMin = rs.getString("LENGTHMIN");
					lenMax = rs.getString("LENGTHMAX");
				} else {
					lenMin = rs.getString("ROLL_MIN");
					lenMax = rs.getString("ROLL_MAX");
				}
			}
			rs.close();
			psta.close();
			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.selectOrderLnDiv");// 查询合同PK值
			psta = connection.prepareStatement(sql);
			if (milPlan.getOrdLnDlyPk().contains("-")) {
				psta.setString(1, milPlan.getOrdLnDlyPk().substring(0,
						milPlan.getOrdLnDlyPk().lastIndexOf("-")));
			} else {
				psta.setString(1, milPlan.getOrdLnDlyPk());
			}

			rs = psta.executeQuery();
			if (rs.next()) {
				orderPk = rs.getString("ORD_PK");
				orderLnPk = rs.getString("ORD_LN_PK");
				orderLnDivNo = rs.getString("DELIVERY_NO");
			}
			rs.close();
			psta.close();

			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.selectIsDealer");// 查询是否双经销
			psta = connection.prepareStatement(sql);
			psta.setString(1, orderPk);
			rs = psta.executeQuery();
			if (rs.next()) {
				isDealer = rs.getString("ORDER_TYP");
			}
			rs.close();
			psta.close();

			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.selectActWeigth");// 查询单支重量
			psta = connection.prepareStatement(sql);
			psta.setString(1, milPlan.getJudgeNo());
			psta.setString(2, milPlan.getProPlanId());
			psta.setString(3, milPlan.getGxPlanNo());
			rs = psta.executeQuery();
			if (rs.next()) {
				actWeigth = rs.getString("ACT_THEORY_WEIGHT");
			}
			rs.close();
			psta.close();

			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.selectnextProcessCode");// 查询下工序代码、物料码
			psta = connection.prepareStatement(sql);
			psta.setString(1, milPlan.getJudgeStoveNo());
			psta.setString(2, milPlan.getProPlanId());
			psta.setString(3, milPlan.getGxPlanNo());
			rs = psta.executeQuery();
			if (rs.next()) {
				nextProcessCode = rs.getString("next_process_code");
				nextProcessName = rs.getString("process_desc");
				judgeStdDes = rs.getString("judgeStdDes");
				cic = rs.getString("CIC");
				materiaNo = rs.getString("OUTWL_ID");
				materiaName = rs.getString("OUTWL_DESC");
				INWL_ID = rs.getString("INWL_ID");
				INWL_DESC = rs.getString("INWL_DESC");
				CRAFT_SEQ = rs.getString("CRAFT_SEQ");
			}
			rs.close();
			psta.close();

			if ((materiaName + INWL_DESC).equals("")) {
				sql = CoreXmlSqlParsersFactory
						.getSql("FrmInOnlineStore.selectZPMateriaNo");// 查询组炉物料码
				psta = connection.prepareStatement(sql);
				psta.setString(1, milPlan.getProPlanId());
				psta.setString(2, milPlan.getGxPlanNo());
				rs = psta.executeQuery();
				if (rs.next()) {
					judgeStdDes = rs.getString("judgeStdDes");
					cic = rs.getString("CIC");
					materiaNo = rs.getString("OUTWL_ID");
					materiaName = rs.getString("OUTWL_DESC");
					INWL_ID = rs.getString("INWL_ID");
					INWL_DESC = rs.getString("INWL_DESC");
					CRAFT_SEQ = rs.getString("CRAFT_SEQ");
				}
				rs.close();
				psta.close();
			}

			if ((materiaName + INWL_DESC).equals("")) {
				sql = CoreXmlSqlParsersFactory
						.getSql("FrmInOnlineStore.selectZPMateriaNo2");// 查询组炉物料码2
				psta = connection.prepareStatement(sql);
				psta.setString(1, milPlan.getProPlanId());
				psta.setString(2, milPlan.getGxPlanNo());
				psta.setString(3, milPlan.getProPlanId());
				psta.setString(4, milPlan.getGxPlanNo());
				rs = psta.executeQuery();
				if (rs.next()) {
					materiaNo = rs.getString("OUTWL_ID");
					materiaName = rs.getString("OUTWL_DESC");
					INWL_ID = rs.getString("INWL_ID");
					INWL_DESC = rs.getString("INWL_DESC");
					judgeStdDes = rs.getString("judgeStdDes");
					cic = rs.getString("CIC");
					CRAFT_SEQ = rs.getString("CRAFT_SEQ");
				}
				rs.close();
				psta.close();
			}

			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.selectLengthMin");// 查询成品长度上下限
			psta = connection.prepareStatement(sql);
			if (milPlan.getOrdLnDlyPk().contains("-")) {
				psta.setString(1, milPlan.getOrdLnDlyPk().substring(0,
						milPlan.getOrdLnDlyPk().indexOf("-")));
			} else {
				psta.setString(1, milPlan.getOrdLnDlyPk());
			}
			rs = psta.executeQuery();
			if (rs.next()) {
				lengthMin = rs.getString("LENGTHMIN");
				lengthMax = rs.getString("LENGTHMAX");
			}
			rs.close();
			psta.close();

			for (int m = 0; m < shortList.size(); m++) {
				ArrayList<String> parmShort = (ArrayList<String>) shortList
						.get(m);
				for (int i = 0; i < parm.size(); i++) {
					ArrayList<String> parm1 = (ArrayList<String>) parm.get(i);
					ArrayList<String> matNoList = new ArrayList<String>();
					if (milPlan.getLotNo().equals("试轧料")) {
						groupNo = "001";
					} else {
						groupNo = creatGroup(connection, maTtity, parm1);
					}
					String matNo = queryMatNoM(connection, locode, parm.get(i)
							.get(3)); // 材料号
					int g = Integer.parseInt(matNo.substring(
							matNo.length() - 4, matNo.length()));

					List<double[]> list1 = MeanValueCalculation
							.MeanCalculation(Double.parseDouble(parm1.get(2)),
									Integer.parseInt(parmShort.get(0)));
					if (sampleFlag.equals("1")) {
						sql = CoreXmlSqlParsersFactory
								.getSql("FrmInOnlineStore.selectPortBatchMatNo");
					} else {
						sql = CoreXmlSqlParsersFactory
								.getSql("FrmInOnlineStore.selectPortBatchMatNo1");
					}
					// 判断定尺类型
					if (Double.parseDouble(parm1.get(0)) < Double
							.parseDouble(lenMin)) {
						LenType = "1";
					} else if (Double.parseDouble(parm1.get(0)) > Double
							.parseDouble(lenMax)) {
						LenType = "2";
					} else {
						LenType = "0";
					}
					// 材料表分切数
					if (lengthMax != null && lengthMax != "") {
						if (Double.parseDouble(parm1.get(0)) > Double
								.parseDouble(lengthMax)) {
							sawNum = (int) Math.floor(Double.parseDouble(parm1
									.get(0))
									/ Double.parseDouble(lengthMin));
						}
					}

					psta = connection.prepareStatement(sql);
					psta.setString(1, milPlan.getJudgeNo());
					psta.setString(2, parm1.get(3));
					psta.setString(3, parm1.get(0));
					psta.setString(4, parm1.get(0));
					if (milPlan.getAstatus().equals("样管")) {
						psta.setString(5, "1");
					} else {
						psta.setString(5, "0");
					}
					if (milPlan.getAstatus().equals("样管")
							|| milPlan.getAstatus().equals("合格")) {
						psta.setString(6, "0");
					} else if (milPlan.getAstatus().equals("判废")) {
						psta.setString(6, "2");
					}
					psta.setInt(7, Integer.parseInt(parmShort.get(0)));
					rs = psta.executeQuery();
					while (rs.next()) {
						matNoList.add(rs.getString("MAT_NO"));
					}
					rs.close();
					psta.close();
					if (matNoList.size() <= 0) {
						cro.setV_errMsg("程序错误,请联系管理员!");
						return cro;
					}
					if (Integer.parseInt(parmShort.get(0)) > matNoList.size()) {
						cro.setV_errMsg("交库实际支数大于能交库支数,请刷新页面!");
						return cro;
					}

					// 查询可交库支数（按批,不超批上限）
					sql = CoreXmlSqlParsersFactory
							.getSql("FrmInOnlineStore.selectSawNumW"); // 查询外委分切数
					psta = connection.prepareStatement(sql);
					psta.setString(1, milPlan.getJudgeStoveNo());
					psta.setString(2, milPlan.getPlineCode());
					rs = psta.executeQuery();
					while (rs.next()) {
						sawNumW = Integer.parseInt(rs
								.getString("SUBCONTRACT_COMPLETE_CUT"));
					}
					rs.close();
					psta.close();
					sql = CoreXmlSqlParsersFactory
							.getSql("FrmInOnlineStore.selectActcount");
					psta = connection.prepareStatement(sql);
					psta.setString(1, milPlan.getJudgeStoveNo());
					// sawNumW > 1，则外委分切了，否则没有
					if (sawNumW > 1) {
						psta.setString(2, milPlan.getJudgeNo());
					} else {
						psta.setString(2, milPlan.getJudgeStoveNo() + "-01");
					}
					psta.setString(3, parm1.get(3));
					if (milPlan.getAstatus().equals("样管")) {
						psta.setString(4, "1");
					} else {
						psta.setString(4, "0");
					}
					psta.setString(5, milPlan.getPlineCode());
					rs = psta.executeQuery();
					int act_count = 0;
					while (rs.next()) {
						act_count = Integer.parseInt(rs.getString("ACT_COUNT"));
					}
					rs.close();
					psta.close();
					if (act_count < Integer.parseInt(parmShort.get(0))) {
						cro.setV_errMsg("交库支数大于可交库支数," + parm1.get(3)
								+ "批可交库支数为" + act_count + "支！");
						return cro;
					}

					int s = 0;
					for (int j = 0; j < list1.size(); j++) {
						double[] conW = list1.get(j);
						if ((int) conW[0] >= 0) {
							for (int z = 0; z < (int) conW[0]; z++) {
								insertButressPsta.setString(1, milPlan
										.getJudgeStoveNo());
								insertButressPsta.setString(2, parm1.get(3));
								insertButressPsta.setString(3, groupNo);
								insertButressPsta.setString(4, list.get(0));
								insertButressPsta.setString(5, list.get(1));
								insertButressPsta.setString(6, list.get(2));
								insertButressPsta.setString(7, list.get(3));
								insertButressPsta.setString(8, list.get(4));
								insertButressPsta.setString(9, (locode + parm1
										.get(3))
										+ StringTool.formatDecimal(g, "0000"));
								insertButressPsta.setString(10, systime);
								insertButressPsta.setString(11, list.get(5));
								insertButressPsta.setString(12, list.get(6));
								insertButressPsta.setString(13, list.get(7));
								insertButressPsta.setString(14, list.get(8));
								insertButressPsta.setString(15, milPlan
										.getPlineCode());
								insertButressPsta.addBatch();

								insertListPsta.setString(1, list.get(5));
								insertListPsta.setString(2, list.get(6));
								insertListPsta.setString(3, inListDoc
										+ StringTool.formatDecimal(n, "0000"));
								insertListPsta.setString(4, inListDoc);
								insertListPsta.setString(5, "800701");
								insertListPsta.setString(6, "产出入库");
								insertListPsta.setString(7, (locode + parm1
										.get(3))
										+ StringTool.formatDecimal(g, "0000"));
								insertListPsta.setString(8, milPlan.getLotNo());
								insertListPsta.setString(9, milPlan
										.getStoveNo()); // 熔炼炉号
								insertListPsta.setString(10, milPlan
										.getJudgeStoveNo());
								insertListPsta.setString(11, parm1.get(3));
								insertListPsta.setString(12, groupNo);
								if (milPlan.getGoType().equals("成品")) {
									insertListPsta.setString(13, milPlan
											.getProduccode());
									insertListPsta.setString(14, milPlan
											.getProducname());
									insertListPsta.setString(15, milPlan
											.getRollStandradCode());// 标准
									insertListPsta.setString(16, milPlan
											.getRollStandrad());
									insertListPsta.setString(17, milPlan
											.getSteelcode());
									insertListPsta.setString(18, milPlan
											.getSteelname());
									insertListPsta.setString(19, milPlan
											.getStdStyle());
									insertListPsta.setString(20, milPlan
											.getStdStyleDesc());
									insertListPsta.setString(21, milPlan
											.getSpecCode());
									insertListPsta.setString(22, milPlan
											.getSpecName().replace("*", "x"));
									insertListPsta.setString(23, milPlan
											.getModelCode());
									insertListPsta.setString(24, milPlan
											.getModelDesc());
								} else {
									insertListPsta.setString(13, milPlan
											.getVarietiesCode());
									insertListPsta.setString(14, milPlan
											.getVarieties());
									insertListPsta.setString(15, milPlan
											.getRollStandradCode());// 标准
									insertListPsta.setString(16, milPlan
											.getRollStandrad());
									insertListPsta.setString(17, milPlan
											.getSteelcode());
									insertListPsta.setString(18, milPlan
											.getSteelname());
									insertListPsta.setString(19, milPlan
											.getStdStyle());
									insertListPsta.setString(20, milPlan
											.getStdStyleDesc());
									insertListPsta.setString(21, milPlan
											.getPipeSizeCode());
									insertListPsta.setString(22, milPlan
											.getPipeSize().replace("*", "x"));
									insertListPsta.setString(23, milPlan
											.getBuckleTypeCode());
									insertListPsta.setString(24, milPlan
											.getBuckleType());
								}
								insertListPsta.setString(25, milPlan
										.getDimater());
								insertListPsta.setString(26, milPlan
										.getHeight());
								insertListPsta.setString(27, milPlan
										.getLengthmin());
								insertListPsta.setString(28, milPlan
										.getLengthmax());
								insertListPsta.setString(29, "1");

								// 短尺重量
								String dcWeigth = String
										.valueOf(Float
												.valueOf(parmShort.get(1))
												* Float
												.valueOf(actWeigth)
												/ Float.valueOf(parm1.get(0)));
								insertListPsta.setString(30, dcWeigth);
								insertListPsta.setString(31, dcWeigth);

								insertListPsta.setString(32, list.get(7));
								insertListPsta.setString(33, list.get(8));
								insertListPsta.setString(34, list.get(0));
								insertListPsta.setString(35, "");
								insertListPsta.setString(36, "1");
								insertListPsta.setString(37, list.get(4));
								insertListPsta.setString(38, systime);
								if (milPlan.getLotNo().equals("试轧料")) {
									insertListPsta.setString(39, "");
									insertListPsta.setString(40, "");
								} else {
									insertListPsta.setString(39, orderNo[0]
											.toString());
									insertListPsta.setString(40, orderNo[1]
											.toString());
								}

								insertListPsta.setString(41, orderLnDivNo);
								insertListPsta.setString(42, orderPk);
								insertListPsta.setString(43, orderLnPk);
								insertListPsta.setString(44, milPlan
										.getOrdLnDlyPk());
								if (milPlan.getGoType().equals("成品")) {
									insertListPsta.setString(45, "801402");
									insertListPsta.setString(46, "80150201");
								} else {
									insertListPsta.setString(45, "801401");
									insertListPsta.setString(46, "80150101");
								}
								insertListPsta.setString(47, systime);

								// 短尺长度
								insertListPsta.setString(48, parmShort.get(1));

								insertListPsta.setString(49, list.get(7));
								insertListPsta.setString(50, list.get(8));
								insertListPsta.setString(51, milPlan
										.getRollStandrad());
								insertListPsta.setString(52, milPlan
										.getPlineCode());
								insertListPsta.setString(53, milPlan
										.getPlineName());
								insertListPsta.setString(54, milPlan
										.getGradecode());
								insertListPsta.setString(55, milPlan
										.getGradename());
								insertListPsta.setString(56, yearMoth);
								insertListPsta.setString(57, systime);
								parmShort.get(1);

								insertListPsta.setString(58, "短尺:"
										+ parmShort.get(1) + parmShort.get(2)); // 备注

								insertListPsta.setString(59, "801302");
								insertListPsta.setString(60, "机组");
								insertListPsta.setString(61, milPlan
										.getPlineCode());
								insertListPsta.setString(62, milPlan
										.getPlineName());
								if (milPlan.getTarget().equals("A")) {
									insertListPsta.setString(63, milPlan
											.getMaterialNo());
									insertListPsta.setString(64, milPlan
											.getMaterialDesc());
								} else {
									insertListPsta.setString(63, materiaNo);
									insertListPsta.setString(64, materiaName);
								}

								insertListPsta.setString(65, milPlan
										.getContractNo());

								if (milPlan.getAstatus().equals("合格")
										|| milPlan.getAstatus().equals("样管")) {
									insertListPsta.setString(66, "00");
								} else {
									insertListPsta.setString(66, "22");
								}
								insertListPsta.setString(67, milPlan
										.getJudgeNo());
								insertListPsta.setString(68, list.get(9));
								insertListPsta.setString(69, list.get(10));
								// insertListPsta.setString(70, mome);
								insertListPsta.addBatch();

								insertInListBPsta.setString(1, list.get(5));
								insertInListBPsta.setString(2, list.get(6));
								insertInListBPsta.setString(3, inListDoc
										+ StringTool.formatDecimal(n, "0000"));
								insertInListBPsta.setString(4, inListDoc);
								insertInListBPsta.setString(5, "800701");
								insertInListBPsta.setString(6, "产出入库");
								insertInListBPsta.setString(7, (locode + parm1
										.get(3))
										+ StringTool.formatDecimal(g, "0000"));
								insertInListBPsta.setString(8, "");
								insertInListBPsta.setString(9, "");
								insertInListBPsta.setString(10, milPlan
										.getJudgeStoveNo());
								insertInListBPsta.setString(11, parm1.get(3));
								insertInListBPsta.setString(12, groupNo);
								if (milPlan.getGoType().equals("成品")) {
									insertInListBPsta.setString(13, milPlan
											.getProduccode());
									insertInListBPsta.setString(14, milPlan
											.getProducname());
									insertInListBPsta.setString(15, milPlan
											.getRollStandradCode());// 标准
									insertInListBPsta.setString(16, milPlan
											.getRollStandrad());
									insertInListBPsta.setString(17, milPlan
											.getSteelcode());
									insertInListBPsta.setString(18, milPlan
											.getSteelname());
									insertInListBPsta.setString(19, milPlan
											.getStdStyle());
									insertInListBPsta.setString(20, milPlan
											.getStdStyleDesc());
									insertInListBPsta.setString(21, milPlan
											.getSpecCode());
									insertInListBPsta.setString(22, milPlan
											.getSpecName().replace("*", "x"));
									insertInListBPsta.setString(23, milPlan
											.getModelCode());
									insertInListBPsta.setString(24, milPlan
											.getModelDesc());
								} else {
									insertInListBPsta.setString(13, milPlan
											.getVarietiesCode());
									insertInListBPsta.setString(14, milPlan
											.getVarieties());
									insertInListBPsta.setString(15, milPlan
											.getRollStandradCode());// 标准
									insertInListBPsta.setString(16, milPlan
											.getRollStandrad());
									insertInListBPsta.setString(17, milPlan
											.getSteelcode());
									insertInListBPsta.setString(18, milPlan
											.getSteelname());
									insertInListBPsta.setString(19, milPlan
											.getStdStyle());
									insertInListBPsta.setString(20, milPlan
											.getStdStyleDesc());
									insertInListBPsta.setString(21, milPlan
											.getPipeSizeCode());
									insertInListBPsta.setString(22, milPlan
											.getPipeSize().replace("*", "x"));
									insertInListBPsta.setString(23, milPlan
											.getBuckleTypeCode());
									insertInListBPsta.setString(24, milPlan
											.getBuckleType());
								}
								insertInListBPsta.setString(25, milPlan
										.getDimater());
								insertInListBPsta.setString(26, milPlan
										.getHeight());
								insertInListBPsta.setString(27, milPlan
										.getLengthmin());
								insertInListBPsta.setString(28, milPlan
										.getLengthmax());
								insertInListBPsta.setString(29, "1");
								insertInListBPsta.setString(30, String
										.valueOf(conW[1]));
								insertInListBPsta.setString(31, String
										.valueOf(conW[1]));
								insertInListBPsta.setString(32, list.get(7));
								insertInListBPsta.setString(33, list.get(8));
								insertInListBPsta.setString(34, list.get(0));
								insertInListBPsta.setString(35, "");
								insertInListBPsta.setString(36, "1");
								insertInListBPsta.setString(37, list.get(4));
								insertInListBPsta.setString(38, systime);
								if (milPlan.getLotNo().equals("试轧料")) {
									insertInListBPsta.setString(39, "");
									insertInListBPsta.setString(40, "");
								} else {
									insertInListBPsta.setString(39, orderNo[0]
											.toString());
									insertInListBPsta.setString(40, orderNo[1]
											.toString());
								}

								insertInListBPsta.setString(41, orderLnDivNo);
								insertInListBPsta.setString(42, orderPk);
								insertInListBPsta.setString(43, orderLnPk);
								insertInListBPsta.setString(44, milPlan
										.getOrdLnDlyPk());
								if (milPlan.getGoType().equals("成品")) {
									insertInListBPsta.setString(45, "801402");
									insertInListBPsta.setString(46, "80150201");
								} else {
									insertInListBPsta.setString(45, "801401");
									insertInListBPsta.setString(46, "80150101");
								}
								insertInListBPsta.setString(47, systime);
								insertInListBPsta.setString(48, parm1.get(0));// 长度
								insertInListBPsta.setString(49, list.get(7));
								insertInListBPsta.setString(50, list.get(8));
								insertInListBPsta.setString(51, milPlan
										.getRollStandrad());
								insertInListBPsta.setString(52, milPlan
										.getPlineCode());
								insertInListBPsta.setString(53, milPlan
										.getPlineName());
								insertInListBPsta.setString(54, milPlan
										.getGradecode());
								insertInListBPsta.setString(55, milPlan
										.getGradename());
								insertInListBPsta.setString(56, yearMoth);
								insertInListBPsta.setString(57, systime);
								insertInListBPsta.setString(58, "");
								insertInListBPsta.setString(59, "801302");
								insertInListBPsta.setString(60, "机组");
								insertInListBPsta.setString(61, milPlan
										.getPlineCode());
								insertInListBPsta.setString(62, milPlan
										.getPlineName());
								insertInListBPsta.setString(63, milPlan
										.getMaterialNo());
								insertInListBPsta.setString(64, milPlan
										.getMaterialDesc());
								insertInListBPsta.setString(65, milPlan
										.getContractNo());

								if (milPlan.getAstatus().equals("合格")
										|| milPlan.getAstatus().equals("样管")) {
									insertInListBPsta.setString(66, "00");
								} else {
									insertInListBPsta.setString(66, "22");
								}
								insertInListBPsta.addBatch();

								insertMatPsta.setString(1, milPlan
										.getJudgeStoveNo());
								insertMatPsta.setString(2, parm1.get(3));
								insertMatPsta.setString(3, groupNo);
								if (milPlan.getGoType().equals("成品")) {
									insertMatPsta.setString(4, milPlan
											.getProduccode());
									insertMatPsta.setString(5, milPlan
											.getProducname());
									insertMatPsta.setString(6, milPlan
											.getSteelcode());
									insertMatPsta.setString(7, milPlan
											.getSteelname());
									insertMatPsta.setString(8, milPlan
											.getSpecCode());
									insertMatPsta.setString(9, milPlan
											.getSpecName().replace("*", "x"));
									insertMatPsta.setString(10, milPlan
											.getModelCode());
									insertMatPsta.setString(11, milPlan
											.getModelDesc());
									insertMatPsta.setString(12, milPlan
											.getRollStandradCode());// 标准
									insertMatPsta.setString(13, milPlan
											.getRollStandrad());
									insertMatPsta.setString(14, list.get(7));
									insertMatPsta.setString(15, list.get(8));
									insertMatPsta.setString(16, milPlan
											.getStdStyle());
									insertMatPsta.setString(17, milPlan
											.getStdStyleDesc());
								} else {
									insertMatPsta.setString(4, milPlan
											.getVarietiesCode());
									insertMatPsta.setString(5, milPlan
											.getVarieties());
									insertMatPsta.setString(6, milPlan
											.getSteelcode());
									insertMatPsta.setString(7, milPlan
											.getSteelname());
									insertMatPsta.setString(8, milPlan
											.getPipeSizeCode());
									insertMatPsta.setString(9, milPlan
											.getPipeSize().replace("*", "x"));
									insertMatPsta.setString(10, milPlan
											.getBuckleTypeCode());
									insertMatPsta.setString(11, milPlan
											.getBuckleType());
									insertMatPsta.setString(12, milPlan
											.getRollStandradCode());// 标准
									insertMatPsta.setString(13, milPlan
											.getRollStandrad());
									insertMatPsta.setString(14, list.get(7));
									insertMatPsta.setString(15, list.get(8));
									insertMatPsta.setString(16, milPlan
											.getStdStyle());
									insertMatPsta.setString(17, milPlan
											.getStdStyleDesc());
								}
								if (surplusFlag.equals("0")) {
									if (LenType.equals("0")) {
										if (milPlan.getLotNo().equals("试轧料")) {
											insertMatPsta.setString(18, "");
											insertMatPsta.setString(19, "");
										} else {
											insertMatPsta.setString(18,
													orderNo[0].toString());
											insertMatPsta.setString(19,
													orderNo[1].toString());
										}

										insertMatPsta.setString(20,
												orderLnDivNo);
										insertMatPsta.setString(21, orderPk);
										insertMatPsta.setString(22, orderLnPk);
										insertMatPsta.setString(23, milPlan
												.getOrdLnDlyPk());
									} else {
										insertMatPsta.setString(18, "");
										insertMatPsta.setString(19, "");
										insertMatPsta.setString(20, "");
										insertMatPsta.setString(21, orderPk);
										insertMatPsta.setString(22, orderLnPk);
										insertMatPsta.setString(23, milPlan
												.getOrdLnDlyPk());
									}
								} else {
									insertMatPsta.setString(18, "");
									insertMatPsta.setString(19, "");
									insertMatPsta.setString(20, "");
									insertMatPsta.setString(21, orderPk);
									insertMatPsta.setString(22, orderLnPk);
									insertMatPsta.setString(23, milPlan
											.getOrdLnDlyPk());
								}
								insertMatPsta.setString(24, milPlan
										.getDimater());
								insertMatPsta
										.setString(25, milPlan.getHeight());

								insertMatPsta.setString(26, milPlan
										.getLengthmin());
								insertMatPsta.setString(27, milPlan
										.getLengthmax());
								insertMatPsta.setString(28, list.get(4));
								insertMatPsta.setString(29, "1");

								// 短尺重量
								insertMatPsta.setString(30, dcWeigth);

								insertMatPsta.setString(31, systime);
								insertMatPsta.setString(32, systime);
								insertMatPsta.setString(33, (locode + parm1
										.get(3))
										+ StringTool.formatDecimal(g, "0000"));
								insertMatPsta.setString(34, "0");
								insertMatPsta.setString(35, "1");
								if (milPlan.getGoType().equals("成品")) {
									insertMatPsta.setString(36, "801402");
									insertMatPsta.setString(37, "80150201");
								} else {
									insertMatPsta.setString(36, "801401");
									insertMatPsta.setString(37, "80150101");
								}

								// 短尺长度
								insertMatPsta.setString(38, parmShort.get(1));

								insertMatPsta.setString(39, milPlan
										.getRollStandrad());
								insertMatPsta.setString(40, yearMoth);
								insertMatPsta.setString(41, milPlan
										.getPlineCode());
								insertMatPsta.setString(42, milPlan
										.getPlineName());
								insertMatPsta.setString(43, milPlan
										.getGradecode());
								insertMatPsta.setString(44, milPlan
										.getGradename());

								// 短尺备注
								insertMatPsta.setString(45, "短尺:"
										+ parmShort.get(1) + parmShort.get(2));

								insertMatPsta.setString(46, "");
								// insertMatPsta.setString(50, "");
								insertMatPsta.setString(47, "801302");
								insertMatPsta.setString(48, "机组");
								insertMatPsta.setString(49, milPlan
										.getPlineCode());
								insertMatPsta.setString(50, milPlan
										.getPlineName());
								/*
								 * if (milPlan.getTarget().equals("A")) {
								 * insertMatPsta.setString(51, milPlan
								 * .getMaterialNo());
								 * insertMatPsta.setString(52, milPlan
								 * .getMaterialDesc()); } else {
								 */
								insertMatPsta.setString(51, materiaNo); // 物料码
								insertMatPsta.setString(52, materiaName); // 物料描叙
								// }

								if (surplusFlag.equals("1")) {
									insertMatPsta.setString(53, surPlusOrderNo);
								} else {
									insertMatPsta.setString(53, milPlan
											.getContractNo());
								}
								if (milPlan.getAstatus().equals("合格")) {
									insertMatPsta.setString(54, "40740401");
									insertMatPsta.setString(55, "40740601");
								} else {
									insertMatPsta.setString(54, parm1.get(4));
									insertMatPsta.setString(55, parm1.get(5));
								}
								if (milPlan.getAstatus().equals("合格")) {
									insertMatPsta.setString(56, "00");
								} else if (milPlan.getAstatus().equals("待处理")) {
									insertMatPsta.setString(56, "11");
								} else if (milPlan.getAstatus().equals("判废")) {
									insertMatPsta.setString(56, "22");
								} else {
									insertMatPsta.setString(56, "00");
								}
								if (milPlan.getAstatus().equals("样管")) {
									insertMatPsta.setString(57, "1");
								} else {
									insertMatPsta.setString(57, "0");
								}
								insertMatPsta.setString(58, milPlan.getId());
								insertMatPsta.setString(59, milPlan
										.getJudgeNo());
								insertMatPsta.setString(60, milPlan
										.getProPlanId());// 轧管排产订单号
								insertMatPsta.setString(61, "");// 轧管材料号matNoList

								insertMatPsta.setString(62, storeNo); // 交库选去向
								insertMatPsta.setString(63, storeName);
								// insertMatPsta.setString(62, GOWHERE_CODE); //
								// 取计划物流支向
								// insertMatPsta.setString(63, GOWHERE_NAME);
								insertMatPsta
										.setString(64, milPlan.getTarget());
								insertMatPsta.setString(65, milPlan
										.getProcessStatus());
								insertMatPsta.setString(66, milPlan.getLotNo());
								insertMatPsta.setString(67, LenType);
								insertMatPsta.setString(68, milPlan
										.getJudgeStoveNo());
								insertMatPsta.setString(69, milPlan
										.getImpProcess());
								insertMatPsta.setString(70, pckFlag);
								insertMatPsta.setString(71, matRetunFlag);

								insertMatPsta.setString(72, "40740101");
								insertMatPsta.setString(73, "40740201");
								insertMatPsta.setString(74, testType);
								insertMatPsta.setString(75, testGrade);

								insertMatPsta.setString(76, milPlan
										.getGxPlanNo());
								insertMatPsta.setString(77, milPlan
										.getStoveNo());
								// insertMatPsta.setString(78, nextProcessCode);
								// //后面写入
								// insertMatPsta.setString(79, nextProcessName);
								// insertMatPsta.setString(80, nextProPlanID);
								// insertMatPsta.setString(81, nextGxPlanNo);
								insertMatPsta.setString(78, judgeStdDes); // CIC+PIC等标准
								insertMatPsta.setInt(79, sawNum); // 分切数
								insertMatPsta.setString(80, actWeigth); // 理论重量
								insertMatPsta.setString(81, INWL_ID); // 投料物料码
								insertMatPsta.setString(82, INWL_DESC); // 投料物料描叙
								insertMatPsta.setString(83, CRAFT_SEQ); // 工艺序号
								insertMatPsta.setString(84, cic); // cic
								insertMatPsta.setString(85, milPlan.getId());
								insertMatPsta.setString(86, isDealer);// 是否双经销

								insertMatPsta.setString(87, dcWeigth);
								// 短尺备注
								insertMatPsta.setString(88, "短尺:"
										+ parmShort.get(1) + parmShort.get(2));

								insertMatPsta.addBatch();

								updateStausPsta.setString(1, groupNo);
								// updateStausPsta.setString(2, yearMoth);
								updateStausPsta.setString(2, matNoList.get(s));
								updateStausPsta.setString(3, milPlan
										.getJudgeNo());
								updateStausPsta.addBatch();

								n++;
								g++;
								s++;
							}
						}
						insertButressPsta.executeBatch();
						insertListPsta.executeBatch();
						// insertInListBPsta.executeBatch();
						insertMatPsta.executeBatch();
						updateStausPsta.executeBatch();// 修改进程表
					}
					instoreNum = Integer.parseInt(parmShort.get(0));
					instoreWgt = Double.parseDouble(parm1.get(2));
					milPlan.setBranch(String.valueOf(instoreNum));
					milPlan.setTon(String.valueOf(instoreWgt));
					milPlan.setTargetLength(parm1.get(0));

					// insertMilInstoreSql =
					// EntityTool.fillSqlByEntity(insertMilInstoreSql, milPlan);
					// insertMilInstorePsta =
					// connection.prepareStatement(insertMilInstoreSql);
					// insertMilInstorePsta.addBatch();
					insertMilInstorePsta.setString(1, milPlan.getJudgeNo());
					insertMilInstorePsta.setString(2, milPlan.getId());
					insertMilInstorePsta.setString(3, milPlan.getProPlanId());
					insertMilInstorePsta.setString(4, milPlan.getGxPlanNo());
					insertMilInstorePsta.setString(5, milPlan.getBranch());
					insertMilInstorePsta.setString(6, milPlan.getTon());
					insertMilInstorePsta.setString(7, milPlan.getId());
					insertMilInstorePsta.setString(8, milPlan.getJudgeNo());
					insertMilInstorePsta.setString(9, milPlan.getLotNo());
					insertMilInstorePsta.setString(10, milPlan.getPlineCode());
					insertMilInstorePsta.setString(11, milPlan.getGradename());
					insertMilInstorePsta.setString(12, milPlan
							.getTargetLength());
					insertMilInstorePsta.setString(13, milPlan.getBranch());
					insertMilInstorePsta.setString(14, milPlan.getTon());
					insertMilInstorePsta.addBatch();

					if (milPlan.getJudgeNo().endsWith("-01")) {
						updateMilInstorePsta.setString(1, milPlan.getJudgeNo());
						updateMilInstorePsta.setString(2, milPlan.getId());
						updateMilInstorePsta.addBatch();
					}

					updatePlanPsta.setString(1, milPlan.getId());
					updatePlanPsta.addBatch();
				}
			}
			/*
			 * insertButressPsta.executeBatch(); insertListPsta.executeBatch();
			 * // insertInListBPsta.executeBatch();
			 * insertMatPsta.executeBatch(); updateStausPsta.executeBatch();//
			 * 修改进程表
			 */insertMilInstorePsta.executeBatch();
			if (milPlan.getJudgeNo().endsWith("-01")) {
				updateMilInstorePsta.executeBatch();
			}
			updatePlanPsta.executeBatch();

			if (nextProcessCode == null) {
				nextProcessCode = "";
			}

			if (!nextProcessCode.equals(null) && !nextProcessCode.equals("")) {
				if (nextProcessCode.equals("E")) {
					sql = CoreXmlSqlParsersFactory
							.getSql("FrmInOnlineStore.selectPlnZyDBK");// 查询镦拔扩炉计划
				} else if (nextProcessCode.equals("F")) {
					sql = CoreXmlSqlParsersFactory
							.getSql("FrmInOnlineStore.selectPlnZyRCL");// 查询热处理炉计划
				} else if (nextProcessCode.equals("G")) {
					sql = CoreXmlSqlParsersFactory
							.getSql("FrmInOnlineStore.selectPlnZyJGX");// 查询加工炉计划
				}

				psta = connection.prepareStatement(sql);
				psta.setString(1, milPlan.getJudgeStoveNo());
				psta.setString(2, milPlan.getProPlanId());
				psta.setString(3, milPlan.getGxPlanNo());
				rs = psta.executeQuery();
				while (rs.next()) {
					nextProPlanID = rs.getString("PRO_PLAN_ID");
					nextGxPlanNo = rs.getString("GX_PLAN_NO");
					int PLN_OUTSINGLE_NUM = Integer.parseInt(rs
							.getString("PLN_OUTSINGLE_NUM"));

					updateNextProPlanIDPsta.setString(1, milPlan
							.getJudgeStoveNo());
					updateNextProPlanIDPsta
							.setString(2, milPlan.getPlineCode());
					updateNextProPlanIDPsta
							.setString(3, milPlan.getProPlanId());
					updateNextProPlanIDPsta.setString(4, milPlan.getGxPlanNo());
					updateNextProPlanIDPsta.setInt(5, PLN_OUTSINGLE_NUM);
					updateNextProPlanIDPsta.setString(6, nextProPlanID);
					updateNextProPlanIDPsta.setString(7, nextGxPlanNo);
					updateNextProPlanIDPsta.setString(8, nextProcessCode);
					updateNextProPlanIDPsta.setString(9, nextProcessName);
					updateNextProPlanIDPsta.setString(10, rs
							.getString("HEAT_PLAN_NO"));
					updateNextProPlanIDPsta.addBatch();
				}
				rs.close();
				psta.close();
			}
			updateNextProPlanIDPsta.executeBatch();

			// 运输需求
//			TZH 24.4.24 注销物流接口
//			updateTmsDemandM(connection, connection2, cro, milPlan
//					.getJudgeStoveNo(), milPlan.getId(), "XX");
			if (cro.getV_errMsg().equals("")) {
				cro.setV_errMsg("交库成功!");
			}
			connection.commit();
//			TZH 24.4.24 注销物流接口
//			connection2.commit();
		} catch (SQLException e) {
			System.out.println(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
//					TZH 24.4.24 注销物流接口
//					connection2.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
//			TZH 24.4.24 注销物流接口
//			if (connection2 != null) {
//				try {
//					connection.rollback(); // 回滚事务
//					connection2.rollback(); // 回滚事务
//				} catch (Exception e2) {
//				}
//			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
//				TZH 24.4.24 注销物流接口
//				if (connection2 != null && !connection2.isClosed()) {
//					connection2.close();
//				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}

	/***
	 * 钢管交库
	 * 
	 * @param maTtity
	 * @param list
	 * @param parm
	 * @param strInBound
	 *            入库类型
	 * @param strInMemo
	 *            备注
	 * @param storeNo
	 *            去向
	 * @param storeName
	 *            去向
	 * @param surplusFlag
	 *            是否余材
	 * @param sampleFlag
	 *            是否减取样长度
	 * @param pckFlag
	 *            打捆标志
	 * @param matRetunFlag
	 *            交货材料要求标志
	 * @param testType
	 *            双探类别
	 * @param testGrade
	 *            等级
	 * @return
	 * @throws Exception
	 */
	public CoreReturnObject doPipeIn(String maTtity, ArrayList<String> list,
			ArrayList<ArrayList<String>> parm, String strInBound,
			String strInMemo, String storeNo, String storeName,
			String surplusFlag, String sampleFlag, String pckFlag,
			String matRetunFlag, String testType, String testGrade,
			String mome, String mome2) throws Exception {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
//		TZH 24.4.24 注销物流接口
//		Connection connection2 = this.getDao("TmsDao").getConnection();
		Date now = new Date();
		SimpleDateFormat dateFormat = new SimpleDateFormat(
				"yyyy-MM-dd HH:mm:ss");
		SimpleDateFormat df = new SimpleDateFormat("yyyyMM");
		String systime = dateFormat.format(now);
		String yearMoth = "";// 改25号结转df.format(now);
		String groupNo = "";
		String inListDoc = "";
		String inListSeq = "";
		String sql = "";
		PreparedStatement psta = null;
		// PreparedStatement insertMilInstorePsta = null;
		ResultSet rs = null;
		String inStoreCount = "";// 已入库支数
		String surPlusOrderNo = "";// 余材合同号
		int instoreNum = 0;// 总支数
		double instoreWgt = 0;// 总重量
		String orderNo[] = null;
		String lenMin = "0";// 轧管转移长度下限
		String lenMax = "0";// 轧管转移长度上限
		String LenType = "";// 定尺类型
		int n = 0;
		String orderPk = "";// 合同PK
		String orderLnPk = "";// 合同行PK
		String orderLnDivNo = "";// 交货行号
		String isDealer = "0";// 是否双经销(0 自用 1双经销)
		String materiaNo = "";// 物料码
		String materiaName = "";// 物料描述
		String INWL_ID = "";// 投入物料编码
		String INWL_DESC = "";// 投入物料描述
		String CRAFT_SEQ = ""; // 工艺序号
		String GOWHERE_CODE = "";// 物流去向代码
		String GOWHERE_NAME = ""; // 物流去向名称
		String nextProcessCode = ""; // 下工序代码
		String nextProcessName = ""; // 下工序代码名称
		String nextProPlanID = ""; // 下工序订单编号
		String nextGxPlanNo = ""; // 下工序工序排产序号
		String judgeStdDes = ""; // 判定标准集合
		String cic = ""; // cic
		String lengthMin = ""; // 成品最小长度
		String lengthMax = ""; // 成品最大长度
		int sawNum = 1; // 分切数
		int sawNumW = 1; // 外委分切数
		String actCount = "";// 下线支数
		String actWeight = "";// 下线重量

		try {
			connection.setAutoCommit(false); // 取消自动提交事务
//			TZH 24.4.24 注销物流接口
//			connection2.setAutoCommit(false); // 取消自动提交事务
			String insertButressSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.doPipeButress");// 位置表
			PreparedStatement insertButressPsta = connection
					.prepareStatement(insertButressSql);
			String insertInListSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.doPipeInList");// 入库表
			PreparedStatement insertListPsta = connection
					.prepareStatement(insertInListSql);
			String insertInListBSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.doPipeInListB");// 插入所属权的入库记录表（已屏蔽）
			PreparedStatement insertInListBPsta = connection
					.prepareStatement(insertInListBSql);
			String insertMatSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.doPipeMat");// 材料表
			PreparedStatement insertMatPsta = connection
					.prepareStatement(insertMatSql);
			String updateStausSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.updateStaus");
			PreparedStatement updateStausPsta = connection
					.prepareStatement(updateStausSql);// 修改状态进程表
			String updatePlanStausSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.updatePlanStaus");// 修改计划状态
			PreparedStatement updatePlanPsta = connection
					.prepareStatement(updatePlanStausSql);
			String insertMilInstoreSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.insertMilInstore");// 插入交库实绩表
			PreparedStatement insertMilInstorePsta = connection
					.prepareStatement(insertMilInstoreSql);

			String updateMilInstoreSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.updateMilInstore2");// 修改交库实绩表
			PreparedStatement updateMilInstorePsta = connection
					.prepareStatement(updateMilInstoreSql);

			String updateNextProPlanIDSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.updateNextProPlanID");// 修改材料表下工序订单编号
			PreparedStatement updateNextProPlanIDPsta = connection
					.prepareStatement(updateNextProPlanIDSql);

			/*
			 * String insertZgMatNoSql = CoreXmlSqlParsersFactory
			 * .getSql("FrmInOnlineStore.insertZgMatNo2");// 交库时插入轧管材料号
			 * PreparedStatement insertZgMatNoPsta = connection
			 * .prepareStatement(insertZgMatNoSql);
			 */

			MilPlanEntity3 milPlan = EntityTool.getEntityByJSONStr(maTtity,
					MilPlanEntity3.class);
			
			yearMoth = StringTool.GetBalYear(now,StringTool.GetSupplyUnit(milPlan.getPlineCode()));// 改25号结转
			String locode = milPlan.getJudgeStoveNo();
			String lotNo = milPlan.getLotNo();
			orderNo = milPlan.getContractNo().split("[/]");// 拆分合同号
			inListDoc = querySendSqlDoc(connection, strInBound, strInMemo,
					milPlan.getPlineCode(), systime);// 入库单号
			inListSeq = querySendSql(connection, inListDoc, milPlan
					.getPlineCode()); // 入库流水号
			n = Integer.parseInt(inListSeq.substring(inListSeq.length() - 4,
					inListSeq.length()));
			if (surplusFlag.equals("1")) {
				surPlusOrderNo = querySurplusOrderNo(connection, milPlan
						.getPlineCode());
			}
			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.selectLenM");// 查询轧管转移长度
			psta = connection.prepareStatement(sql);
			psta.setString(1, milPlan.getOrdLnDlyPk());
			rs = psta.executeQuery();
			if (rs.next()) {
				if (Double.parseDouble(rs.getString("LENGTHMIN")) > 0) {
					lenMin = rs.getString("LENGTHMIN");
					lenMax = rs.getString("LENGTHMAX");
				} else {
					lenMin = rs.getString("ROLL_MIN");
					lenMax = rs.getString("ROLL_MAX");
				}
			}
			rs.close();
			psta.close();
			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.selectOrderLnDiv");// 查询合同PK值
			psta = connection.prepareStatement(sql);
			if (milPlan.getOrdLnDlyPk().contains("-")) {
				psta.setString(1, milPlan.getOrdLnDlyPk().substring(0,
						milPlan.getOrdLnDlyPk().lastIndexOf("-")));
			} else {
				psta.setString(1, milPlan.getOrdLnDlyPk());
			}

			rs = psta.executeQuery();
			if (rs.next()) {
				orderPk = rs.getString("ORD_PK");
				orderLnPk = rs.getString("ORD_LN_PK");
				orderLnDivNo = rs.getString("DELIVERY_NO");
			}
			rs.close();
			psta.close();

			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.selectIsDealer");// 查询是否双经销
			psta = connection.prepareStatement(sql);
			psta.setString(1, orderPk);
			rs = psta.executeQuery();
			if (rs.next()) {
				isDealer = rs.getString("ORDER_TYP");
			}
			rs.close();
			psta.close();

			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.selectnextProcessCode");// 查询下工序代码、物料码
			psta = connection.prepareStatement(sql);
			psta.setString(1, milPlan.getJudgeStoveNo());
			psta.setString(2, milPlan.getProPlanId());
			psta.setString(3, milPlan.getGxPlanNo());
			rs = psta.executeQuery();
			if (rs.next()) {
				nextProcessCode = rs.getString("next_process_code");
				nextProcessName = rs.getString("process_desc");
				// nextProPlanID = rs.getString("PRO_PLAN_ID");
				// nextGxPlanNo = rs.getString("GX_PLAN_NO");
				judgeStdDes = rs.getString("judgeStdDes");
				cic = rs.getString("CIC");
				materiaNo = rs.getString("OUTWL_ID");
				materiaName = rs.getString("OUTWL_DESC");
				INWL_ID = rs.getString("INWL_ID");
				INWL_DESC = rs.getString("INWL_DESC");
				CRAFT_SEQ = rs.getString("CRAFT_SEQ");
				GOWHERE_CODE = rs.getString("GOWHERE_CODE");
				GOWHERE_NAME = rs.getString("GOWHERE_NAME");
			}
			rs.close();
			psta.close();

			if ((materiaName + INWL_DESC).equals("")) {
				sql = CoreXmlSqlParsersFactory
						.getSql("FrmInOnlineStore.selectZPMateriaNo");// 查询组炉物料码
				psta = connection.prepareStatement(sql);

				psta.setString(1, milPlan.getProPlanId());
				psta.setString(2, milPlan.getGxPlanNo());
				rs = psta.executeQuery();
				if (rs.next()) {
					judgeStdDes = rs.getString("judgeStdDes");
					cic = rs.getString("CIC");
					materiaNo = rs.getString("OUTWL_ID");
					materiaName = rs.getString("OUTWL_DESC");
					INWL_ID = rs.getString("INWL_ID");
					INWL_DESC = rs.getString("INWL_DESC");
					CRAFT_SEQ = rs.getString("CRAFT_SEQ");
					GOWHERE_CODE = rs.getString("GOWHERE_CODE");
					GOWHERE_NAME = rs.getString("GOWHERE_NAME");
				}
				rs.close();
				psta.close();
			}

			if ((materiaName + INWL_DESC).equals("")) {
				sql = CoreXmlSqlParsersFactory
						.getSql("FrmInOnlineStore.selectZPMateriaNo2");// 查询组炉物料码2
				psta = connection.prepareStatement(sql);

				psta.setString(1, milPlan.getProPlanId());
				psta.setString(2, milPlan.getGxPlanNo());
				psta.setString(3, milPlan.getProPlanId());
				psta.setString(4, milPlan.getGxPlanNo());
				rs = psta.executeQuery();
				if (rs.next()) {
					materiaNo = rs.getString("OUTWL_ID");
					materiaName = rs.getString("OUTWL_DESC");
					INWL_ID = rs.getString("INWL_ID");
					INWL_DESC = rs.getString("INWL_DESC");
					judgeStdDes = rs.getString("judgeStdDes");
					cic = rs.getString("CIC");
					CRAFT_SEQ = rs.getString("CRAFT_SEQ");
				}
				rs.close();
				psta.close();
			}

			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.selectLengthMin");// 查询成品长度上下限
			psta = connection.prepareStatement(sql);
			if (milPlan.getOrdLnDlyPk().contains("-")) {
				psta.setString(1, milPlan.getOrdLnDlyPk().substring(0,
						milPlan.getOrdLnDlyPk().indexOf("-")));
			} else {
				psta.setString(1, milPlan.getOrdLnDlyPk());
			}
			rs = psta.executeQuery();
			if (rs.next()) {
				lengthMin = rs.getString("LENGTHMIN");
				lengthMax = rs.getString("LENGTHMAX");
			}
			rs.close();
			psta.close();

			for (int i = 0; i < parm.size(); i++) {
				ArrayList<String> parm1 = (ArrayList<String>) parm.get(i);
				ArrayList<String> matNoList = new ArrayList<String>();
				// groupNo = queryGroupNo(connection,locode,parm1.get(3));//组号
				if (milPlan.getLotNo().equals("试轧料")) {
					groupNo = "001";
				} else {
					groupNo = creatGroup(connection, maTtity, parm1);
				}

				String matNo = queryMatNoM(connection, locode, parm.get(i).get(
						3)); // 材料号
				int g = Integer.parseInt(matNo.substring(matNo.length() - 4,
						matNo.length()));

				List<double[]> list1 = MeanValueCalculation.MeanCalculation(
						Double.parseDouble(parm1.get(2)), Integer
								.parseInt(parm1.get(1)));
				if (sampleFlag.equals("1")) {
					sql = CoreXmlSqlParsersFactory
							.getSql("FrmInOnlineStore.selectPortBatchMatNo");
				} else {
					sql = CoreXmlSqlParsersFactory
							.getSql("FrmInOnlineStore.selectPortBatchMatNo1");
				}
				// 判断定尺类型
				if (Double.parseDouble(parm1.get(0)) < Double
						.parseDouble(lenMin)) {
					LenType = "1";
				} else if (Double.parseDouble(parm1.get(0)) > Double
						.parseDouble(lenMax)) {
					LenType = "2";
				} else {
					LenType = "0";
				}

				// 材料表分切数
				if (lengthMax != null && lengthMax != "") {
					if (Double.parseDouble(parm1.get(0)) > Double
							.parseDouble(lengthMax)) {
						sawNum = (int) Math.floor(Double.parseDouble(parm1
								.get(0))
								/ Double.parseDouble(lengthMin));
					}
				}

				psta = connection.prepareStatement(sql);
				psta.setString(1, milPlan.getJudgeNo());
				psta.setString(2, parm1.get(3));
				psta.setString(3, parm1.get(0));
				psta.setString(4, parm1.get(0));
				if (milPlan.getAstatus().equals("样管")) {
					psta.setString(5, "1");
				} else {
					psta.setString(5, "0");
				}
				if (milPlan.getAstatus().equals("样管")
						|| milPlan.getAstatus().equals("合格")) {
					psta.setString(6, "0");
				} else if (milPlan.getAstatus().equals("判废")) {
					psta.setString(6, "2");
				}
				psta.setInt(7, Integer.parseInt(parm1.get(1)));
				rs = psta.executeQuery();
				while (rs.next()) {
					matNoList.add(rs.getString("MAT_NO"));
				}
				rs.close();
				psta.close();
				if (matNoList.size() <= 0) {
					cro.setV_errMsg("程序错误,请联系管理员!");
					return cro;
				}
				if (Integer.parseInt(parm1.get(1)) > matNoList.size()) {
					cro.setV_errMsg("交库实际支数大于能交库支数,请刷新页面!");
					return cro;
				}

				// 查询可交库支数（按批,不超批上限）
				sql = CoreXmlSqlParsersFactory
						.getSql("FrmInOnlineStore.selectSawNumW"); // 查询外委分切数
				psta = connection.prepareStatement(sql);
				psta.setString(1, milPlan.getJudgeStoveNo());
				psta.setString(2, milPlan.getPlineCode());
				rs = psta.executeQuery();
				while (rs.next()) {
					sawNumW = Integer.parseInt(rs
							.getString("SUBCONTRACT_COMPLETE_CUT"));
				}
				rs.close();
				psta.close();
				sql = CoreXmlSqlParsersFactory
						.getSql("FrmInOnlineStore.selectActcount");
				psta = connection.prepareStatement(sql);
				psta.setString(1, milPlan.getJudgeStoveNo());
				// sawNumW > 1，则外委分切了，否则没有
				if (sawNumW > 1) {
					psta.setString(2, milPlan.getJudgeNo());
				} else {
					//psta.setString(2, milPlan.getJudgeStoveNo() + "-01");
					//每次分批卡控分批组号对应的可交库数量，并非01
					psta.setString(2, milPlan.getJudgeNo());
				}
				psta.setString(3, parm1.get(3));
				if (milPlan.getAstatus().equals("样管")) {
					psta.setString(4, "1");
				} else {
					psta.setString(4, "0");
				}
				psta.setString(5, milPlan.getPlineCode());
				rs = psta.executeQuery();
				int act_count = 0;
				while (rs.next()) {
					act_count = Integer.parseInt(rs.getString("ACT_COUNT"));
				}
				rs.close();
				psta.close();
				if (act_count < Integer.parseInt(parm1.get(1))) {
					cro.setV_errMsg("交库支数大于可交库支数," + parm1.get(3) + "批可交库支数为"
							+ act_count + "支！");
					return cro;
				}

				int s = 0;
				for (int j = 0; j < list1.size(); j++) {
					double[] conW = list1.get(j);
					if ((int) conW[0] >= 0) {
						for (int z = 0; z < (int) conW[0]; z++) {
							insertButressPsta.setString(1, milPlan
									.getJudgeStoveNo());
							insertButressPsta.setString(2, parm1.get(3));
							insertButressPsta.setString(3, groupNo);
							insertButressPsta.setString(4, list.get(0));
							insertButressPsta.setString(5, list.get(1));
							insertButressPsta.setString(6, list.get(2));
							insertButressPsta.setString(7, list.get(3));
							insertButressPsta.setString(8, list.get(4));
							insertButressPsta.setString(9, (locode + parm1
									.get(3))
									+ StringTool.formatDecimal(g, "0000"));
							insertButressPsta.setString(10, systime);
							insertButressPsta.setString(11, list.get(5));
							insertButressPsta.setString(12, list.get(6));
							insertButressPsta.setString(13, list.get(7));
							insertButressPsta.setString(14, list.get(8));
							insertButressPsta.setString(15, milPlan
									.getPlineCode());
							insertButressPsta.addBatch();

							insertListPsta.setString(1, list.get(5));
							insertListPsta.setString(2, list.get(6));
							insertListPsta.setString(3, inListDoc
									+ StringTool.formatDecimal(n, "0000"));
							insertListPsta.setString(4, inListDoc);
							insertListPsta.setString(5, "800701");
							insertListPsta.setString(6, "产出入库");
							insertListPsta.setString(7, (locode + parm1.get(3))
									+ StringTool.formatDecimal(g, "0000"));
							insertListPsta.setString(8, milPlan.getLotNo());
							insertListPsta.setString(9, milPlan.getStoveNo()); // 熔炼炉号
							insertListPsta.setString(10, milPlan
									.getJudgeStoveNo());
							insertListPsta.setString(11, parm1.get(3));
							insertListPsta.setString(12, groupNo);
							if (milPlan.getGoType().equals("成品")) {
								insertListPsta.setString(13, milPlan
										.getProduccode());
								insertListPsta.setString(14, milPlan
										.getProducname());
								insertListPsta.setString(15, milPlan
										.getRollStandradCode());// 标准
								insertListPsta.setString(16, milPlan
										.getRollStandrad());
								insertListPsta.setString(17, milPlan
										.getSteelcode());
								insertListPsta.setString(18, milPlan
										.getSteelname());
								insertListPsta.setString(19, milPlan
										.getStdStyle());
								insertListPsta.setString(20, milPlan
										.getStdStyleDesc());
								insertListPsta.setString(21, milPlan
										.getSpecCode());
								insertListPsta.setString(22, milPlan
										.getSpecName().replace("*", "x"));
								insertListPsta.setString(23, milPlan
										.getModelCode());
								insertListPsta.setString(24, milPlan
										.getModelDesc());
							} else {
								insertListPsta.setString(13, milPlan
										.getVarietiesCode());
								insertListPsta.setString(14, milPlan
										.getVarieties());
								insertListPsta.setString(15, milPlan
										.getRollStandradCode());// 标准
								insertListPsta.setString(16, milPlan
										.getRollStandrad());
								insertListPsta.setString(17, milPlan
										.getSteelcode());
								insertListPsta.setString(18, milPlan
										.getSteelname());
								insertListPsta.setString(19, milPlan
										.getStdStyle());
								insertListPsta.setString(20, milPlan
										.getStdStyleDesc());
								insertListPsta.setString(21, milPlan
										.getPipeSizeCode());
								insertListPsta.setString(22, milPlan
										.getPipeSize().replace("*", "x"));
								insertListPsta.setString(23, milPlan
										.getBuckleTypeCode());
								insertListPsta.setString(24, milPlan
										.getBuckleType());
							}
							insertListPsta.setString(25, milPlan.getDimater());
							insertListPsta.setString(26, milPlan.getHeight());
							insertListPsta
									.setString(27, milPlan.getLengthmin());
							insertListPsta
									.setString(28, milPlan.getLengthmax());
							insertListPsta.setString(29, "1");
							if (mome.equals("")) {
								insertListPsta.setString(30, String
										.valueOf(conW[1]));
								insertListPsta.setString(31, String
										.valueOf(conW[1]));
							} else {
								// 短尺重量
								String dcWeigth = String
										.valueOf(Float.valueOf(mome) * conW[1]
												/ Float.valueOf(parm1.get(0)));
								insertListPsta.setString(30, dcWeigth);
								insertListPsta.setString(31, dcWeigth);
							}
							insertListPsta.setString(32, list.get(7));
							insertListPsta.setString(33, list.get(8));
							insertListPsta.setString(34, list.get(0));
							insertListPsta.setString(35, "");
							insertListPsta.setString(36, "1");
							insertListPsta.setString(37, list.get(4));
							insertListPsta.setString(38, systime);
							if (milPlan.getLotNo().equals("试轧料")) {
								insertListPsta.setString(39, "");
								insertListPsta.setString(40, "");
							} else {
								insertListPsta.setString(39, orderNo[0]
										.toString());
								insertListPsta.setString(40, orderNo[1]
										.toString());
							}

							insertListPsta.setString(41, orderLnDivNo);
							insertListPsta.setString(42, orderPk);
							insertListPsta.setString(43, orderLnPk);
							insertListPsta.setString(44, milPlan
									.getOrdLnDlyPk());
							if (milPlan.getGoType().equals("成品")) {
								insertListPsta.setString(45, "801402");
								insertListPsta.setString(46, "80150201");
							} else {
								insertListPsta.setString(45, "801401");
								insertListPsta.setString(46, "80150101");
							}
							insertListPsta.setString(47, systime);
							if (mome.equals("")) {
								insertListPsta.setString(48, parm1.get(0));// 长度
							} else {
								// 短尺长度
								insertListPsta.setString(48, mome);
							}
							insertListPsta.setString(49, list.get(7));
							insertListPsta.setString(50, list.get(8));
							insertListPsta.setString(51, milPlan
									.getRollStandrad());
							insertListPsta
									.setString(52, milPlan.getPlineCode());
							insertListPsta
									.setString(53, milPlan.getPlineName());
							insertListPsta
									.setString(54, milPlan.getGradecode());
							insertListPsta
									.setString(55, milPlan.getGradename());
							insertListPsta.setString(56, yearMoth);
							insertListPsta.setString(57, systime);
							if (mome.equals("")) {
								insertListPsta.setString(58, mome + mome2); // 备注
							} else {
								insertListPsta.setString(58, "短尺:" + mome
										+ mome2); // 备注
							}
							insertListPsta.setString(59, "801302");
							insertListPsta.setString(60, "机组");
							insertListPsta
									.setString(61, milPlan.getPlineCode());
							insertListPsta
									.setString(62, milPlan.getPlineName());
							if (milPlan.getTarget().equals("A")) {
								insertListPsta.setString(63, milPlan
										.getMaterialNo());
								insertListPsta.setString(64, milPlan
										.getMaterialDesc());
							} else {
								insertListPsta.setString(63, materiaNo);
								insertListPsta.setString(64, materiaName);
							}

							insertListPsta.setString(65, milPlan
									.getContractNo());

							if (milPlan.getAstatus().equals("合格")
									|| milPlan.getAstatus().equals("样管")) {
								insertListPsta.setString(66, "00");
							} else {
								insertListPsta.setString(66, "22");
							}
							insertListPsta.setString(67, milPlan.getJudgeNo());
							insertListPsta.setString(68, list.get(9));
							insertListPsta.setString(69, list.get(10));
							// insertListPsta.setString(70, mome);
							insertListPsta.addBatch();

							insertInListBPsta.setString(1, list.get(5));
							insertInListBPsta.setString(2, list.get(6));
							insertInListBPsta.setString(3, inListDoc
									+ StringTool.formatDecimal(n, "0000"));
							insertInListBPsta.setString(4, inListDoc);
							insertInListBPsta.setString(5, "800701");
							insertInListBPsta.setString(6, "产出入库");
							insertInListBPsta.setString(7, (locode + parm1
									.get(3))
									+ StringTool.formatDecimal(g, "0000"));
							insertInListBPsta.setString(8, "");
							insertInListBPsta.setString(9, "");
							insertInListBPsta.setString(10, milPlan
									.getJudgeStoveNo());
							insertInListBPsta.setString(11, parm1.get(3));
							insertInListBPsta.setString(12, groupNo);
							if (milPlan.getGoType().equals("成品")) {
								insertInListBPsta.setString(13, milPlan
										.getProduccode());
								insertInListBPsta.setString(14, milPlan
										.getProducname());
								insertInListBPsta.setString(15, milPlan
										.getRollStandradCode());// 标准
								insertInListBPsta.setString(16, milPlan
										.getRollStandrad());
								insertInListBPsta.setString(17, milPlan
										.getSteelcode());
								insertInListBPsta.setString(18, milPlan
										.getSteelname());
								insertInListBPsta.setString(19, milPlan
										.getStdStyle());
								insertInListBPsta.setString(20, milPlan
										.getStdStyleDesc());
								insertInListBPsta.setString(21, milPlan
										.getSpecCode());
								insertInListBPsta.setString(22, milPlan
										.getSpecName().replace("*", "x"));
								insertInListBPsta.setString(23, milPlan
										.getModelCode());
								insertInListBPsta.setString(24, milPlan
										.getModelDesc());
							} else {
								insertInListBPsta.setString(13, milPlan
										.getVarietiesCode());
								insertInListBPsta.setString(14, milPlan
										.getVarieties());
								insertInListBPsta.setString(15, milPlan
										.getRollStandradCode());// 标准
								insertInListBPsta.setString(16, milPlan
										.getRollStandrad());
								insertInListBPsta.setString(17, milPlan
										.getSteelcode());
								insertInListBPsta.setString(18, milPlan
										.getSteelname());
								insertInListBPsta.setString(19, milPlan
										.getStdStyle());
								insertInListBPsta.setString(20, milPlan
										.getStdStyleDesc());
								insertInListBPsta.setString(21, milPlan
										.getPipeSizeCode());
								insertInListBPsta.setString(22, milPlan
										.getPipeSize().replace("*", "x"));
								insertInListBPsta.setString(23, milPlan
										.getBuckleTypeCode());
								insertInListBPsta.setString(24, milPlan
										.getBuckleType());
							}
							insertInListBPsta.setString(25, milPlan
									.getDimater());
							insertInListBPsta
									.setString(26, milPlan.getHeight());
							insertInListBPsta.setString(27, milPlan
									.getLengthmin());
							insertInListBPsta.setString(28, milPlan
									.getLengthmax());
							insertInListBPsta.setString(29, "1");
							insertInListBPsta.setString(30, String
									.valueOf(conW[1]));
							insertInListBPsta.setString(31, String
									.valueOf(conW[1]));
							insertInListBPsta.setString(32, list.get(7));
							insertInListBPsta.setString(33, list.get(8));
							insertInListBPsta.setString(34, list.get(0));
							insertInListBPsta.setString(35, "");
							insertInListBPsta.setString(36, "1");
							insertInListBPsta.setString(37, list.get(4));
							insertInListBPsta.setString(38, systime);
							if (milPlan.getLotNo().equals("试轧料")) {
								insertInListBPsta.setString(39, "");
								insertInListBPsta.setString(40, "");
							} else {
								insertInListBPsta.setString(39, orderNo[0]
										.toString());
								insertInListBPsta.setString(40, orderNo[1]
										.toString());
							}

							insertInListBPsta.setString(41, orderLnDivNo);
							insertInListBPsta.setString(42, orderPk);
							insertInListBPsta.setString(43, orderLnPk);
							insertInListBPsta.setString(44, milPlan
									.getOrdLnDlyPk());
							if (milPlan.getGoType().equals("成品")) {
								insertInListBPsta.setString(45, "801402");
								insertInListBPsta.setString(46, "80150201");
							} else {
								insertInListBPsta.setString(45, "801401");
								insertInListBPsta.setString(46, "80150101");
							}
							insertInListBPsta.setString(47, systime);
							insertInListBPsta.setString(48, parm1.get(0));// 长度
							insertInListBPsta.setString(49, list.get(7));
							insertInListBPsta.setString(50, list.get(8));
							insertInListBPsta.setString(51, milPlan
									.getRollStandrad());
							insertInListBPsta.setString(52, milPlan
									.getPlineCode());
							insertInListBPsta.setString(53, milPlan
									.getPlineName());
							insertInListBPsta.setString(54, milPlan
									.getGradecode());
							insertInListBPsta.setString(55, milPlan
									.getGradename());
							insertInListBPsta.setString(56, yearMoth);
							insertInListBPsta.setString(57, systime);
							insertInListBPsta.setString(58, "");
							insertInListBPsta.setString(59, "801302");
							insertInListBPsta.setString(60, "机组");
							insertInListBPsta.setString(61, milPlan
									.getPlineCode());
							insertInListBPsta.setString(62, milPlan
									.getPlineName());
							insertInListBPsta.setString(63, milPlan
									.getMaterialNo());
							insertInListBPsta.setString(64, milPlan
									.getMaterialDesc());
							insertInListBPsta.setString(65, milPlan
									.getContractNo());

							if (milPlan.getAstatus().equals("合格")
									|| milPlan.getAstatus().equals("样管")) {
								insertInListBPsta.setString(66, "00");
							} else {
								insertInListBPsta.setString(66, "22");
							}
							insertInListBPsta.addBatch();

							insertMatPsta.setString(1, milPlan
									.getJudgeStoveNo());
							insertMatPsta.setString(2, parm1.get(3));
							insertMatPsta.setString(3, groupNo);
							if (milPlan.getGoType().equals("成品")) {
								insertMatPsta.setString(4, milPlan
										.getProduccode());
								insertMatPsta.setString(5, milPlan
										.getProducname());
								insertMatPsta.setString(6, milPlan
										.getSteelcode());
								insertMatPsta.setString(7, milPlan
										.getSteelname());
								insertMatPsta.setString(8, milPlan
										.getSpecCode());
								insertMatPsta.setString(9, milPlan
										.getSpecName().replace("*", "x"));
								insertMatPsta.setString(10, milPlan
										.getModelCode());
								insertMatPsta.setString(11, milPlan
										.getModelDesc());
								insertMatPsta.setString(12, milPlan
										.getRollStandradCode());// 标准
								insertMatPsta.setString(13, milPlan
										.getRollStandrad());
								insertMatPsta.setString(14, list.get(7));
								insertMatPsta.setString(15, list.get(8));
								insertMatPsta.setString(16, milPlan
										.getStdStyle());
								insertMatPsta.setString(17, milPlan
										.getStdStyleDesc());
							} else {
								insertMatPsta.setString(4, milPlan
										.getVarietiesCode());
								insertMatPsta.setString(5, milPlan
										.getVarieties());
								insertMatPsta.setString(6, milPlan
										.getSteelcode());
								insertMatPsta.setString(7, milPlan
										.getSteelname());
								insertMatPsta.setString(8, milPlan
										.getPipeSizeCode());
								insertMatPsta.setString(9, milPlan
										.getPipeSize().replace("*", "x"));
								insertMatPsta.setString(10, milPlan
										.getBuckleTypeCode());
								insertMatPsta.setString(11, milPlan
										.getBuckleType());
								insertMatPsta.setString(12, milPlan
										.getRollStandradCode());// 标准
								insertMatPsta.setString(13, milPlan
										.getRollStandrad());
								insertMatPsta.setString(14, list.get(7));
								insertMatPsta.setString(15, list.get(8));
								insertMatPsta.setString(16, milPlan
										.getStdStyle());
								insertMatPsta.setString(17, milPlan
										.getStdStyleDesc());
							}
							if (surplusFlag.equals("0")) {
								if (LenType.equals("0")) {
									if (milPlan.getLotNo().equals("试轧料")) {
										insertMatPsta.setString(18, "");
										insertMatPsta.setString(19, "");
									} else {
										insertMatPsta.setString(18, orderNo[0]
												.toString());
										insertMatPsta.setString(19, orderNo[1]
												.toString());
									}

									insertMatPsta.setString(20, orderLnDivNo);
									insertMatPsta.setString(21, orderPk);
									insertMatPsta.setString(22, orderLnPk);
									insertMatPsta.setString(23, milPlan
											.getOrdLnDlyPk());
								} else {
									insertMatPsta.setString(18, "");
									insertMatPsta.setString(19, "");
									insertMatPsta.setString(20, "");
									insertMatPsta.setString(21, orderPk);
									insertMatPsta.setString(22, orderLnPk);
									insertMatPsta.setString(23, milPlan
											.getOrdLnDlyPk());
								}
							} else {
								insertMatPsta.setString(18, "");
								insertMatPsta.setString(19, "");
								insertMatPsta.setString(20, "");
								insertMatPsta.setString(21, orderPk);
								insertMatPsta.setString(22, orderLnPk);
								insertMatPsta.setString(23, milPlan
										.getOrdLnDlyPk());
							}
							insertMatPsta.setString(24, milPlan.getDimater());
							insertMatPsta.setString(25, milPlan.getHeight());

							insertMatPsta.setString(26, milPlan.getLengthmin());
							insertMatPsta.setString(27, milPlan.getLengthmax());
							insertMatPsta.setString(28, list.get(4));
							insertMatPsta.setString(29, "1");
							if (mome.equals("")) {
								insertMatPsta.setString(30, String
										.valueOf(conW[1]));
							} else {
								// 短尺重量
								String dcWeigth = String
										.valueOf(Float.valueOf(mome) * conW[1]
												/ Float.valueOf(parm1.get(0)));
								insertMatPsta.setString(30, dcWeigth);
							}
							insertMatPsta.setString(31, systime);
							insertMatPsta.setString(32, systime);
							insertMatPsta.setString(33, (locode + parm1.get(3))
									+ StringTool.formatDecimal(g, "0000"));
							insertMatPsta.setString(34, "0");
							insertMatPsta.setString(35, "1");
							if (milPlan.getGoType().equals("成品")) {
								insertMatPsta.setString(36, "801402");
								insertMatPsta.setString(37, "80150201");
							} else {
								insertMatPsta.setString(36, "801401");
								insertMatPsta.setString(37, "80150101");
							}

							if (mome.equals("")) {
								insertMatPsta.setString(38, parm1.get(0));
							} else {
								// 短尺长度
								insertMatPsta.setString(38, mome);
							}
							insertMatPsta.setString(39, milPlan
									.getRollStandrad());
							insertMatPsta.setString(40, yearMoth);
							insertMatPsta.setString(41, milPlan.getPlineCode());
							insertMatPsta.setString(42, milPlan.getPlineName());
							insertMatPsta.setString(43, milPlan.getGradecode());
							insertMatPsta.setString(44, milPlan.getGradename());
							if (mome.equals("")) {
								insertMatPsta.setString(45, mome + mome2);
							} else {
								// 短尺备注
								insertMatPsta.setString(45, "短尺:" + mome
										+ mome2);
							}
							insertMatPsta.setString(46, "");
							// insertMatPsta.setString(50, "");
							insertMatPsta.setString(47, "801302");
							insertMatPsta.setString(48, "机组");
							insertMatPsta.setString(49, milPlan.getPlineCode());
							insertMatPsta.setString(50, milPlan.getPlineName());
							/*
							 * if (milPlan.getTarget().equals("A")) {
							 * insertMatPsta.setString(51, milPlan
							 * .getMaterialNo()); insertMatPsta.setString(52,
							 * milPlan .getMaterialDesc()); } else {
							 */
							insertMatPsta.setString(51, materiaNo); // 物料码
							insertMatPsta.setString(52, materiaName); // 物料描叙
							// }

							if (surplusFlag.equals("1")) {
								insertMatPsta.setString(53, surPlusOrderNo);
							} else {
								insertMatPsta.setString(53, milPlan
										.getContractNo());
							}
							if (milPlan.getAstatus().equals("合格")) {
								insertMatPsta.setString(54, "40740401");
								insertMatPsta.setString(55, "40740601");
							} else {
								insertMatPsta.setString(54, parm1.get(4));
								insertMatPsta.setString(55, parm1.get(5));
							}
							if (milPlan.getAstatus().equals("合格")) {
								insertMatPsta.setString(56, "00");
							} else if (milPlan.getAstatus().equals("待处理")) {
								insertMatPsta.setString(56, "11");
							} else if (milPlan.getAstatus().equals("判废")) {
								insertMatPsta.setString(56, "22");
							} else {
								insertMatPsta.setString(56, "00");
							}
							if (milPlan.getAstatus().equals("样管")) {
								insertMatPsta.setString(57, "1");
							} else {
								insertMatPsta.setString(57, "0");
							}
							insertMatPsta.setString(58, milPlan.getId());
							insertMatPsta.setString(59, milPlan.getJudgeNo());
							insertMatPsta.setString(60, milPlan.getProPlanId());// 轧管排产订单号
							insertMatPsta.setString(61, "");// 轧管材料号matNoList

							insertMatPsta.setString(62, storeNo); // 交库选去向
							insertMatPsta.setString(63, storeName);
							// insertMatPsta.setString(62, GOWHERE_CODE); //
							// 取计划物流支向
							// insertMatPsta.setString(63, GOWHERE_NAME);
							insertMatPsta.setString(64, milPlan.getTarget());
							insertMatPsta.setString(65, milPlan
									.getProcessStatus());
							insertMatPsta.setString(66, milPlan.getLotNo());
							insertMatPsta.setString(67, LenType);
							insertMatPsta.setString(68, milPlan
									.getJudgeStoveNo());
							insertMatPsta
									.setString(69, milPlan.getImpProcess());
							insertMatPsta.setString(70, pckFlag);
							insertMatPsta.setString(71, matRetunFlag);

							insertMatPsta.setString(72, "40740101");
							insertMatPsta.setString(73, "40740201");
							insertMatPsta.setString(74, testType);
							insertMatPsta.setString(75, testGrade);

							insertMatPsta.setString(76, milPlan.getGxPlanNo());
							insertMatPsta.setString(77, milPlan.getStoveNo());
							// insertMatPsta.setString(78, nextProcessCode);
							// //后面写入
							// insertMatPsta.setString(79, nextProcessName);
							// insertMatPsta.setString(80, nextProPlanID);
							// insertMatPsta.setString(81, nextGxPlanNo);
							insertMatPsta.setString(78, judgeStdDes); // CIC+PIC等标准
							insertMatPsta.setInt(79, sawNum); // 分切数
							insertMatPsta
									.setString(80, String.valueOf(conW[1])); // 理论重量
							insertMatPsta.setString(81, INWL_ID); // 投料物料码
							insertMatPsta.setString(82, INWL_DESC); // 投料物料描叙
							insertMatPsta.setString(83, CRAFT_SEQ); // 工艺序号
							insertMatPsta.setString(84, cic); // cic
							insertMatPsta.setString(85, milPlan.getId());
							insertMatPsta.setString(86, isDealer);// 是否双经销
							if (mome.equals("")) {
								insertMatPsta.setString(87, "");
							} else {
								// 短尺过磅重量
								String dcWeigth = String
										.valueOf(Float.valueOf(mome) * conW[1]
												/ Float.valueOf(parm1.get(0)));
								insertMatPsta.setString(87, dcWeigth);
							}
							if (mome.equals("")) {
								insertMatPsta.setString(88, mome + mome2);
							} else {
								// 短尺备注
								insertMatPsta.setString(88, "短尺:" + mome
										+ mome2);
							}

							insertMatPsta.addBatch();

							updateStausPsta.setString(1, groupNo);
							// updateStausPsta.setString(2, yearMoth);
							updateStausPsta.setString(2, matNoList.get(s));
							updateStausPsta.setString(3, milPlan.getJudgeNo());
							updateStausPsta.addBatch();

							n++;
							g++;
							s++;
						}
					}
				}
				instoreNum = Integer.parseInt(parm1.get(1));
				instoreWgt = Double.parseDouble(parm1.get(2));
				milPlan.setBranch(String.valueOf(instoreNum));
				milPlan.setTon(String.valueOf(instoreWgt));
				milPlan.setTargetLength(parm1.get(0));

				// insertMilInstoreSql =
				// EntityTool.fillSqlByEntity(insertMilInstoreSql, milPlan);
				// insertMilInstorePsta =
				// connection.prepareStatement(insertMilInstoreSql);
				// insertMilInstorePsta.addBatch();
				insertMilInstorePsta.setString(1, milPlan.getJudgeNo());
				insertMilInstorePsta.setString(2, milPlan.getId());
				insertMilInstorePsta.setString(3, milPlan.getProPlanId());
				insertMilInstorePsta.setString(4, milPlan.getGxPlanNo());
				insertMilInstorePsta.setString(5, milPlan.getBranch());
				insertMilInstorePsta.setString(6, milPlan.getTon());
				insertMilInstorePsta.setString(7, milPlan.getId());
				insertMilInstorePsta.setString(8, milPlan.getJudgeNo());
				insertMilInstorePsta.setString(9, milPlan.getLotNo());
				insertMilInstorePsta.setString(10, milPlan.getPlineCode());
				insertMilInstorePsta.setString(11, milPlan.getGradename());
				insertMilInstorePsta.setString(12, milPlan.getTargetLength());
				insertMilInstorePsta.setString(13, milPlan.getBranch());
				insertMilInstorePsta.setString(14, milPlan.getTon());
				/*System.out.println("1 = " + milPlan.getJudgeNo());
				System.out.println("2 = " + milPlan.getId());
				System.out.println("3 = " + milPlan.getProPlanId());
				System.out.println("4 = " + milPlan.getGxPlanNo());
				System.out.println("5 = " + milPlan.getBranch());
				System.out.println("6 = " + milPlan.getTon());
				System.out.println("7 = " + milPlan.getId());
				System.out.println("8 = " + milPlan.getJudgeNo());
				System.out.println("9 = " + milPlan.getLotNo());
				System.out.println("10 = " + milPlan.getPlineCode());
				System.out.println("11 = " + milPlan.getGradename());
				System.out.println("12 = " + milPlan.getTargetLength());
				System.out.println("13 = " + milPlan.getBranch());
				System.out.println("14 = " + milPlan.getTon());*/
				insertMilInstorePsta.addBatch();

				if (milPlan.getJudgeNo().endsWith("-01")) {
					updateMilInstorePsta.setString(1, milPlan.getJudgeNo());
					updateMilInstorePsta.setString(2, milPlan.getId());
					updateMilInstorePsta.addBatch();
				}

				updatePlanPsta.setString(1, milPlan.getId());
				updatePlanPsta.addBatch();
			}
			insertButressPsta.executeBatch();
			insertListPsta.executeBatch();
			// insertInListBPsta.executeBatch();
			insertMatPsta.executeBatch();
			updateStausPsta.executeBatch();// 修改进程表
			insertMilInstorePsta.executeBatch();
			if (milPlan.getJudgeNo().endsWith("-01")) {
				updateMilInstorePsta.executeBatch();
			}
			updatePlanPsta.executeBatch();

			if (nextProcessCode == null) {
				nextProcessCode = "";
			}

			if (!nextProcessCode.equals(null) && !nextProcessCode.equals("")) {
				if (nextProcessCode.equals("E")) {
					sql = CoreXmlSqlParsersFactory
							.getSql("FrmInOnlineStore.selectPlnZyDBK");// 查询镦拔扩炉计划
				} else if (nextProcessCode.equals("F")) {
					sql = CoreXmlSqlParsersFactory
							.getSql("FrmInOnlineStore.selectPlnZyRCL");// 查询热处理炉计划
				} else if (nextProcessCode.equals("G")) {
					sql = CoreXmlSqlParsersFactory
							.getSql("FrmInOnlineStore.selectPlnZyJGX");// 查询加工炉计划
				}

				psta = connection.prepareStatement(sql);
				psta.setString(1, milPlan.getJudgeStoveNo());
				psta.setString(2, milPlan.getProPlanId());
				psta.setString(3, milPlan.getGxPlanNo());
				rs = psta.executeQuery();
				while (rs.next()) {
					nextProPlanID = rs.getString("PRO_PLAN_ID");
					nextGxPlanNo = rs.getString("GX_PLAN_NO");
					int PLN_OUTSINGLE_NUM = Integer.parseInt(rs
							.getString("PLN_OUTSINGLE_NUM"));

					updateNextProPlanIDPsta.setString(1, milPlan
							.getJudgeStoveNo());
					updateNextProPlanIDPsta
							.setString(2, milPlan.getPlineCode());
					updateNextProPlanIDPsta
							.setString(3, milPlan.getProPlanId());
					updateNextProPlanIDPsta.setString(4, milPlan.getGxPlanNo());
					updateNextProPlanIDPsta.setInt(5, PLN_OUTSINGLE_NUM);
					updateNextProPlanIDPsta.setString(6, nextProPlanID);
					updateNextProPlanIDPsta.setString(7, nextGxPlanNo);
					updateNextProPlanIDPsta.setString(8, nextProcessCode);
					updateNextProPlanIDPsta.setString(9, nextProcessName);
					updateNextProPlanIDPsta.setString(10, rs
							.getString("HEAT_PLAN_NO"));
					updateNextProPlanIDPsta.addBatch();
				}
				rs.close();
				psta.close();
			}
			updateNextProPlanIDPsta.executeBatch();

			// 插入轧管材料号
			/*
			 * insertZgMatNoPsta.setString(1, milPlan.getJudgeNo());
			 * insertZgMatNoPsta.setString(2, milPlan.getProPlanId());
			 * insertZgMatNoPsta.setString(3, milPlan.getGxPlanNo());
			 * insertZgMatNoPsta.addBatch(); insertZgMatNoPsta.executeBatch();
			 */

			// 运输需求
//			TZH 24.4.24 注销物流接口
//			updateTmsDemandM(connection, connection2, cro, milPlan
//					.getJudgeStoveNo(), milPlan.getId(), "XX");
			if (cro.getV_errMsg().equals("")) {
				cro.setV_errMsg("交库成功!");
			}
			connection.commit();
//			TZH 24.4.24 注销物流接口
//			connection2.commit();
		} catch (SQLException e) {
			System.out.println(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
//					TZH 24.4.24 注销物流接口
//					connection2.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
//			TZH 24.4.24 注销物流接口
//			if (connection2 != null) {
//				try {
//					connection.rollback(); // 回滚事务
//					connection2.rollback(); // 回滚事务
//				} catch (Exception e2) {
//				}
//			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
//				TZH 24.4.24 注销物流接口
//				if (connection2 != null && !connection2.isClosed()) {
//					connection2.close();
//				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}

	/***
	 * 回报过磅重量
	 * 
	 * @return
	 */
	public CoreReturnObject insertProssWt(ArrayList<String> list,
			String departMentId) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		int acount = 0;
		int k = 0;
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String updateProssWtSql = CoreXmlSqlParsersFactory
					.getSql("insertProssWt.updatePossWt");
			PreparedStatement updateProssPsta = connection
					.prepareStatement(updateProssWtSql);
			ArrayList<String> matNoList = new ArrayList<String>();
			sql = CoreXmlSqlParsersFactory.getSql("insertProssWt.selectCount");
			psta = connection.prepareStatement(sql);
			psta.setString(1, list.get(0));
			psta.setString(2, list.get(3));
			psta.setString(3, list.get(2));
			rs = psta.executeQuery();
			if (rs.next()) {
				acount = Integer.parseInt(rs.getString("ACOUNT"));
			}
			rs.close();
			psta.close();

			sql = CoreXmlSqlParsersFactory.getSql("insertProssWt.selectMatNo");
			psta = connection.prepareStatement(sql);
			psta.setString(1, list.get(0));
			psta.setString(2, list.get(3));
			psta.setString(3, list.get(2));
			rs = psta.executeQuery();
			while (rs.next()) {
				matNoList.add(rs.getString("MAT_NO"));
			}
			rs.close();
			psta.close();
			List<double[]> list1 = MeanValueCalculation.MeanCalculationPro(
					Double.parseDouble(list.get(1)), acount);
			for (int j = 0; j < list1.size(); j++) {
				double[] conW = list1.get(j);
				if ((int) conW[0] >= 0) {
					for (int z = 0; z < (int) conW[0]; z++) {
						updateProssPsta.setString(1, String.valueOf(conW[1]));
						updateProssPsta.setString(2, String.valueOf(conW[1]));
						updateProssPsta.setString(3, list.get(4));
						updateProssPsta.setString(4, matNoList.get(k));
						updateProssPsta.setString(5, list.get(0));
						updateProssPsta.setString(6, list.get(3));
						updateProssPsta.setString(7, list.get(2));
						updateProssPsta.addBatch();
						k++;
					}
				}
			}
			updateProssPsta.executeBatch();
			cro.setV_errMsg("回报成功!");
			connection.commit();
		} catch (SQLException e) {
			System.out.println(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}
	
	/**
	 * 报检
	 * @param matZcTity
	 * @param flag 0-报检   1-必检   3-免检
	 * @return
	 */
	public CoreReturnObject inspection(ArrayList<String> list,String process,String flag,String userName) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		int acount = 0;
		int k = 0;
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			for (int m = 0; m < list.size(); m++) {
				MatZcMEntity matZcTityS = EntityTool.getEntityByJSONStr(
						list.get(m), MatZcMEntity.class);
				
				String InspectionNO = ""; //报检编号
				sql = CoreXmlSqlParsersFactory.getSql("FrmInOnlineStore.GetInspectionNO");
				PreparedStatement pst = connection.prepareStatement(sql);
				pst.setObject(1, matZcTityS.getPlineCode());
				pst.setObject(2, matZcTityS.getPlineCode());
				rs = pst.executeQuery();
				if (rs.next()) {
					InspectionNO = rs.getString("INSPECTION_NO");
				}
				rs.close();
				pst.close();
				
				String updateProssWtSql = CoreXmlSqlParsersFactory
						.getSql("FrmInOnlineStore.inspection");
				updateProssWtSql = EntityTool.fillSqlByEntity(updateProssWtSql, matZcTityS);
				PreparedStatement updateProssPsta = connection
						.prepareStatement(updateProssWtSql);
				updateProssPsta.setString(1, InspectionNO);
				updateProssPsta.setString(2, process);
				updateProssPsta.setString(3, flag); 
				updateProssPsta.setString(4, userName); 
				updateProssPsta.addBatch();
				updateProssPsta.executeBatch();
			}

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

	/***
	 * 生成组号
	 * 
	 * @param con
	 * @param matTity
	 * @param parm
	 * @return
	 */
	public String creatGroup(Connection con, String matTity,
			ArrayList<String> parm) throws Exception {
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		String strGroup = "";
		String actLenMin = "";
		String actLenMax = "";
		String[] actLenM = new String[2];
		Date now = new Date();
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS");
		String systime = dateFormat.format(now);
		MilPlanEntity3 milPlan = EntityTool.getEntityByJSONStr(matTity,
				MilPlanEntity3.class);
		sql = CoreXmlSqlParsersFactory.getSql("creatGroup.selectMilInStore");
		psta = con.prepareStatement(sql);
		psta.setString(1, milPlan.getJudgeStoveNo());
		psta.setString(2, parm.get(3));
		psta.setString(3, parm.get(0));
		psta.setString(4, parm.get(0));
		psta.setString(5, "D");
		rs = psta.executeQuery();
		if (rs.next()) {
			strGroup = rs.getString("BATCH_GROUD_NO");
		}
		rs.close();
		psta.close();

		if (strGroup.equals("")) {
			strGroup = queryGroupNo(con, milPlan.getJudgeStoveNo(), parm.get(3));// 组号
			if (Double.parseDouble(milPlan.getLengthmin()) > Double
					.parseDouble(parm.get(0))) {
				actLenM = lessThanActMin(parm.get(0),
						new DecimalFormat("0.000")
								.format(Double.parseDouble(milPlan
										.getLengthmin().toString())));// 长度小于下限
				actLenMin = actLenM[0];
				actLenMax = actLenM[1];
			} else if (Double.parseDouble(parm.get(0)) > Double
					.parseDouble(milPlan.getLengthmax())) {
				actLenM = moreThanActMax(parm.get(0),
						new DecimalFormat("0.000")
								.format(Double.parseDouble(milPlan
										.getLengthmax().toString())));// 长度大于上限
				actLenMin = actLenM[0];
				actLenMax = actLenM[1];
			} else {
				actLenMin = milPlan.getLengthmin();
				actLenMax = milPlan.getLengthmax();
			}
			sql = CoreXmlSqlParsersFactory
					.getSql("creatGroup.InsertMilInStore");// 插入记录
			psta = con.prepareStatement(sql);
			psta.setString(1, systime + strGroup);
			psta.setString(2, milPlan.getJudgeStoveNo());
			psta.setString(3, parm.get(3));
			// if (milPlan.getAstatus().equals("样管")) {
			// psta.setString(4, "1");
			// } else {
			// psta.setString(4, "0");
			// }
			psta.setString(4, parm.get(4));
			psta.setString(5, parm.get(5));
			psta.setString(6, actLenMin);
			psta.setString(7, actLenMax);
			psta.setString(8, strGroup);
			psta.setString(9, "D");
			psta.addBatch();
			psta.executeBatch();
			con.commit();
		}
		return strGroup;
	}

	/***
	 * 小于长度下限时
	 * 
	 * @param length
	 * @param actLenMin
	 * @return
	 */
	public String[] lessThanActMin(String length, String actLenMin) {
		String[] arr = new String[2];
		String[] lengmin = new String[2];// 下限返回的整数位 和小数位
		String[] lengmax = new String[2];// 上限
		double lengthmin = Double.parseDouble(actLenMin);
		double lengthmax = Double.parseDouble(actLenMin);

		for (int i = 0; i < 5; i++) {
			lengthmax = lengthmin;
			lengthmin = lengthmin - 1;
			lengmin = getNumber(String.valueOf(lengthmin));
			// lengmax = getNumber(String.valueOf(lengthmax));
			if (Double.parseDouble(lengmin[1]) > 0
					&& 800 > Double.parseDouble(lengmin[1])
					&& !lengmin[1].equals("5")) {
				lengthmin = Double.parseDouble(lengmin[0].toString() + ".5");
			} else if (Double.parseDouble(lengmin[1]) > 800) {
				lengthmin = Double.parseDouble(String.valueOf(Integer
						.parseInt(lengmin[0]) + 1)
						+ ".0");
			}

			// if(!lengmax[1].equals("0")&&!lengmax[1].equals("5"))
			// {
			// if(Integer.parseInt(lengmax[1])>= 1 &&
			// 8>Integer.parseInt(lengmax[1]))
			// {
			// lengthmax = Double.parseDouble(lengmax[0].toString()+".5");
			// }else if(Integer.parseInt(lengmax[1]) > 8)
			// {
			// lengthmax =
			// Double.parseDouble(String.valueOf(Integer.parseInt(lengmax[0])+1)+".0");
			// }
			// }
			if (Double.parseDouble(length) >= lengthmin
					&& lengthmax > Double.parseDouble(length)) {
				arr[0] = String.valueOf(lengthmin);
				arr[1] = String.valueOf(lengthmax - 0.001);
				break;
			}
			// lengthmin = lengthmin-1;
			// lengthmax = lengthmax-1;
		}
		return arr;
	}

	/***
	 * () 大于长度上限时
	 * 
	 * @param length
	 * @param actLenMin
	 * @return
	 */
	public String[] moreThanActMax(String length, String actLenMax) {
		String[] arr = new String[2];
		String[] lengmax = new String[2];// 上限返回的整数位 和小数位
		String[] lengmin = new String[2];// 下限
		double lengthmin = Double.parseDouble(actLenMax);
		double lengthmax = Double.parseDouble(actLenMax);

		for (int i = 0; i < 5; i++) {
			lengthmin = lengthmax;
			lengthmax = lengthmax + 1;

			lengmax = getNumber(String.valueOf(lengthmax));
			// lengmax = getNumber(String.valueOf(lengthmax));
			if (Integer.parseInt(lengmax[1]) > 0
					&& 500 > Integer.parseInt(lengmax[1])
					&& !lengmax[1].equals("5")) {
				lengthmax = Double.parseDouble(lengmax[0].toString() + ".0");
			} else if (Integer.parseInt(lengmax[1]) > 500
					&& Integer.parseInt(lengmax[1]) < 800) {
				lengthmax = Double.parseDouble(lengmax[0].toString() + ".5");
			} else if (Integer.parseInt(lengmax[1]) > 800) {
				lengthmax = Double.parseDouble(String.valueOf(Integer
						.parseInt(lengmax[0]))
						+ ".5");
			}

			// if(!lengmax[1].equals("0")&&!lengmax[1].equals("5"))
			// {
			// if(Integer.parseInt(lengmax[1])>= 1 &&
			// 8>Integer.parseInt(lengmax[1]))
			// {
			// lengthmax = Double.parseDouble(lengmax[0].toString()+".5");
			// }else if(Integer.parseInt(lengmax[1]) > 8)
			// {
			// lengthmax =
			// Double.parseDouble(String.valueOf(Integer.parseInt(lengmax[0])+1)+".0");
			// }
			// }
			if (Double.parseDouble(length) > lengthmin
					&& lengthmax >= Double.parseDouble(length)) {
				arr[0] = String.valueOf(lengthmin + 0.001);
				arr[1] = String.valueOf(lengthmax);
				break;
			}

		}
		return arr;
	}

	public String[] getNumber(String len) {
		String[] decimal = new String[2];
		int num = len.indexOf(".");
		decimal[0] = len.substring(0, num);
		decimal[1] = len.substring(num + 1);
		return decimal;
	}

	/***
	 * 撤销交库
	 * 
	 * @param parm
	 * @return
	 */
	public CoreReturnObject cancelPipeIn(ArrayList<String> parm) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
//		TZH 24.4.24 注销物流接口
//		Connection connection2 = this.getDao("TmsDao").getConnection();
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		int acount = 0;
		String isOk = ""; // 0-未变仓库位置；1-已导运
		String nodeStaus = "";
		String HeatPlanNo = "";
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
//			TZH 24.4.24 注销物流接口
//			connection2.setAutoCommit(false); // 取消自动提交事务
			String deleteSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.cancelPipeIn1");
			PreparedStatement deletePsta = connection
					.prepareStatement(deleteSql);
			String updateMilInstoreSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.updateMilInstroe1");
			PreparedStatement updateMilInstorePsta = connection
					.prepareStatement(updateMilInstoreSql);

			YdmZcInlistEntity inListEntity2 = EntityTool.getEntityByJSONStr(
					parm.get(0), YdmZcInlistEntity.class);
			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.doQueryHeatPlanNo");// 查询炉计划ID
			psta = connection.prepareStatement(sql);
			psta.setString(1, inListEntity2.getJudgeStoveNo());
			psta.setString(2, inListEntity2.getBatchNo());
			psta.setString(3, inListEntity2.getBatchGroudNo());
			psta.setString(4, inListEntity2.getZgStoveSqe());
			rs = psta.executeQuery();
			if (rs.next()) {
				HeatPlanNo = rs.getString("HEAT_PLAN_NO");
			}
			rs.close();
			psta.close();
			for (String str : parm) {
				YdmZcInlistEntity inListEntity = EntityTool.getEntityByJSONStr(
						str, YdmZcInlistEntity.class);
				sql = CoreXmlSqlParsersFactory
						.getSql("cancelPipeIn.doQueryStaus");//
				psta = connection.prepareStatement(sql);
				psta.setString(1, inListEntity.getJudgeStoveNo());
				psta.setString(2, inListEntity.getBatchNo());
				psta.setString(3, inListEntity.getBatchGroudNo());
				psta.setString(4, inListEntity.getZgStoveSqe());
				rs = psta.executeQuery();
				if (rs.next()) {
					acount = Integer.parseInt(rs.getString("ACOUNT"));
				}
				rs.close();
				psta.close();
				if (acount < Integer.parseInt(inListEntity.getActCount())) {
					cro.setV_errMsg("炉号" + inListEntity.getJudgeStoveNo()
							+ "已有送质量判定,不能撤销!");
					return cro;
				}

				sql = CoreXmlSqlParsersFactory
						.getSql("cancelPipeIn.doQueryCount");// 查询库存中可撤销的支数
				psta = connection.prepareStatement(sql);
				psta.setString(1, inListEntity.getJudgeStoveNo());
				psta.setString(2, inListEntity.getBatchNo());
				psta.setString(3, inListEntity.getBatchGroudNo());
				psta.setString(4, inListEntity.getInstockDoc());
				rs = psta.executeQuery();
				if (rs.next()) {
					acount = Integer.parseInt(rs.getString("ACOUNT"));
				}
				rs.close();
				psta.close();
				if (Integer.parseInt(inListEntity.getActCount()) > acount) {
					cro.setV_errMsg("炉号" + inListEntity.getJudgeStoveNo()
							+ "库存已不够,不能撤销!");
					return cro;
				}

				sql = CoreXmlSqlParsersFactory
						.getSql("cancelPipeIn.doQueryNodeStaus");// 查询该炉是否结炉
				psta = connection.prepareStatement(sql);
				psta.setString(1, inListEntity.getJudgeStoveNo());
				rs = psta.executeQuery();
				if (rs.next()) {
					nodeStaus = rs.getString("NODE_FUR_FLAG");
				}
				rs.close();
				psta.close();
				if (nodeStaus.equals("1")) {
					cro.setV_errMsg("炉号" + inListEntity.getJudgeStoveNo()
							+ "已结炉,不能撤销!");
					return cro;
				}

				/*
				 * sql = CoreXmlSqlParsersFactory
				 * .getSql("cancelPipeIn.doQueryOutStock");// 查询该炉未发运的支数 psta =
				 * connection.prepareStatement(sql); psta.setString(1,
				 * inListEntity.getZgStoveSqe()); psta.setString(2,
				 * inListEntity.getBatchNo()); psta.setString(3,
				 * inListEntity.getBatchGroudNo()); psta.setString(4,
				 * inListEntity.getActLen()); psta.setString(5,
				 * inListEntity.getQcmStaus()); psta.setString(6,
				 * inListEntity.getInstockDoc()); psta.setString(7,
				 * inListEntity.getSampleFlag()); rs = psta.executeQuery(); if
				 * (rs.next()) { acount =
				 * Integer.parseInt(rs.getString("ACT_COUNT")); } rs.close();
				 * psta.close(); if (acount <
				 * Integer.parseInt(inListEntity.getActCount())) {
				 * cro.setV_errMsg("炉号：" + inListEntity.getJudgeStoveNo() +
				 * "；批号：" + inListEntity.getBatchNo() + " 可撤销的未发运支数不足,不能撤销!");
				 * return cro; }
				 */

				deletePsta.setString(1, inListEntity.getZgStoveSqe());
				deletePsta.setString(2, inListEntity.getBatchNo());
				deletePsta.setString(3, inListEntity.getBatchGroudNo());
				deletePsta.setString(4, inListEntity.getPlineCode());
				deletePsta.setString(5, inListEntity.getJudgeStoveNo());
				deletePsta.setString(6, inListEntity.getActLen());
				deletePsta.setString(7, inListEntity.getQcmStaus());
				deletePsta.setString(8, inListEntity.getSampleFlag());
				deletePsta.setInt(9, Integer.parseInt(inListEntity
						.getActCount()));
				deletePsta.setString(10, inListEntity.getInstockDoc());
				deletePsta.addBatch();

				// updateMilInstoreSql =
				// EntityTool.fillSqlByEntity(updateMilInstoreSql,
				// inListEntity);
				// updateMilInstorePsta =
				// connection.prepareStatement(updateMilInstoreSql);
				// updateMilInstorePsta.executeUpdate();
				// updateMilInstorePsta.close();
				updateMilInstorePsta.setString(1, inListEntity
						.getJudgeStoveNo());
				updateMilInstorePsta.setString(2, inListEntity.getBatchNo());
				updateMilInstorePsta.setString(3, inListEntity
						.getBatchGroudNo());
				updateMilInstorePsta.setString(4, inListEntity.getActLen());
				updateMilInstorePsta.setInt(5, Integer.parseInt(inListEntity
						.getActCount()));
				updateMilInstorePsta.setString(6, inListEntity.getZgStoveSqe());
				updateMilInstorePsta.addBatch();
			}
			updateMilInstorePsta.executeBatch();
			deletePsta.executeBatch();
			// 运输需求
//			TZH 24.4.24 注销物流接口
//			updateTmsDemandM(connection, connection2, cro, inListEntity2
//					.getJudgeStoveNo(), HeatPlanNo, "XX");
			if (cro.getV_errMsg().equals("")) {
				cro.setV_errMsg("撤销成功!");
			}
			connection.commit();
//			TZH 24.4.24 注销物流接口
//			connection2.commit();
		} catch (SQLException e) {
			System.out.println(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
//					TZH 24.4.24 注销物流接口
//					connection2.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
//			TZH 24.4.24 注销物流接口
//			if (connection2 != null) {
//				try {
//					connection.rollback(); // 回滚事务
//					connection2.rollback(); // 回滚事务
//				} catch (Exception e2) {
//				}
//			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
//				TZH 24.4.24 注销物流接口
//				if (connection2 != null && !connection2.isClosed()) {
//					connection2.close();
//				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}

	/***
	 * 申请判定
	 * 
	 * @param parm
	 * @return
	 */
	public CoreReturnObject doDecision(ArrayList<String> parm, String jugeNo,
			String productFlag, String userName, String memo, String plineCode,
			String custom) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		String jugdeApplyNo = "";// 判定单号
		int prossWtCount = 0;
		String prnFlag = "";// 是否需过磅
		String testingStandar = null;// 探伤标准
		String notchInfo = null;// 样管刻槽信息
		String notchLength = null;// 槽长
		String notchWidth = null;// 槽宽
		String notchDepth = null;// 槽深
		String testGrade = null;// 探伤等级
		String testType = null;// 探伤类型
		String defectResult = "";// 探伤结果
		String testGrade1 = "";// 超声探伤
		String testType1 = "";// 超声类型
		String testGradeW = null;// 委托探伤等级
		String testTypeW = null;// 委托探伤类别
		String exitTemp = "";// 终轧温度
		String target = "";// 判定字头
		String belogJugeCode = "";// 判定后所属权代码
		String belogJugeName = "";// 判定后所属权名称
		ArrayList<String> sampleNewsList = new ArrayList<String>();// 样管信息集合

		String materiaNo = "";// 物料码
		String materiaName = "";// 物料描述
		String INWL_ID = "";// 投入物料编码
		String INWL_DESC = "";// 投入物料描述
		String CRAFT_SEQ = ""; // 工艺序号
		String DELIVERY_STATE_CODE = "";// 交货状态代码
		String DELIVERY_STATE_NAME = "";// 交货状态名称
		String LOAD_JUDGE_STOVE_NO = "";// 轧管上料炉号
		String CHECK_NO = "";// 检验编号
		String ZP_M_LH = "";// 组批主炉号
		String ZP_COLL = "";// 组批炉号集合
		String TEST_PRESSURE = "";// 水压压力PSI
		String TEST_PRESSURE_Y = "";// 水压压力MPa
		String HOLDTIME_TIME = "";// 保压时间S

		ArrayList<String> loFace = new ArrayList<String>();
		ArrayList<String> liFace = new ArrayList<String>();
		ArrayList<String> toFace = new ArrayList<String>();
		ArrayList<String> tiFace = new ArrayList<String>();
		String sampleNews = "";// 样管信息
		int count = 0;
		int acount = 0;
		int judgeCount = 0;// 判定次数
		String judgeAppNo = "";// 已申请判定单号
		int judgeAppSeq = 1;// 申请判定序号
		int cutNum = 1;// 委外分切数
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			/*
			 * String updateSql = CoreXmlSqlParsersFactory
			 * .getSql("FrmInOnlineStore.doDecision");// 2 PreparedStatement
			 * updatePsta = connection .prepareStatement(updateSql);
			 */
			String insertJugeApplySql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.insertJugeApply");// 插入判定表 1
			//PreparedStatement insertJugeApplyPsta = connection.prepareStatement(insertJugeApplySql);
			PreparedStatement insertJugeApplyPsta = new LoggableStatement(connection, insertJugeApplySql);

			// 3
			String updateProcess = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.insertMilProcess");// 更新进程表mil_processes数据
			PreparedStatement updateMilProcess = connection
					.prepareStatement(updateProcess);

			// 4
			String updateJudgeStoveNoSeqStr = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.updateJudgeStoveNoSeq");// 更新判定表JUDGE_STOVE_NO_SEQ
			PreparedStatement updateJudgeStoveNoSeq = connection
					.prepareStatement(updateJudgeStoveNoSeqStr);

			// 5
			String updateJudgeStoveNoSeqStr2 = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.updateJudgeStoveNoSeq2");// 更新判定表投料量
			PreparedStatement updateJudgeStoveNoSeq2 = connection
					.prepareStatement(updateJudgeStoveNoSeqStr2);
			
			String updateJudgeStoveNoSeqStr3 = CoreXmlSqlParsersFactory
			.getSql("FrmInOnlineStore.updateJudgeStoveNoSeq3");// 天淮更新判定表投料量
	PreparedStatement updateJudgeStoveNoSeq3 = connection
			.prepareStatement(updateJudgeStoveNoSeqStr3);

			MatZcMEntity matZcTityS = EntityTool.getEntityByJSONStr(
					parm.get(0), MatZcMEntity.class);
			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.doQueryMilPlanPrt");
			psta = connection.prepareStatement(sql);
			psta.setString(1, jugeNo + "-01");
			rs = psta.executeQuery();
			if (rs.next()) {
				prnFlag = rs.getString("PRT_FLAG");
			}
			rs.close();
			psta.close();

			if(!custom.equals("WG") && !plineCode.equals("C072") && !plineCode.equals("C098") && !plineCode.equals("C099") && "A".equals(matZcTityS.getTarget())){
				Integer porderstatus = 0;
				sql = CoreXmlSqlParsersFactory
						.getSql("FrmInOnlineStore.selectLengthMin");
				psta = connection.prepareStatement(sql);
				if(matZcTityS.getOrdLnDlyPk().contains("-")){
					psta.setString(1, matZcTityS.getOrdLnDlyPk().substring(0,matZcTityS.getOrdLnDlyPk().indexOf("-")));
				}else{
					psta.setString(1, matZcTityS.getOrdLnDlyPk());
				}

				rs = psta.executeQuery();
				if (rs.next()) {
					porderstatus = rs.getInt("PORDERSTATUS");
				}
				rs.close();
				psta.close();
				if (porderstatus >= 5) {
					cro.setV_errMsg("此炉合同已缴库完成，无法申请判定，请通过本厂生技科联系销售计划管理科!");
					return cro;
				}
			}
			

			/***
			 * 查询交库点是否结炉
			 */
			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.doQueryMilInstoreResultNode");
			psta = connection.prepareStatement(sql);
			psta.setString(1, jugeNo);
			rs = psta.executeQuery();
			if (rs.next()) {
				count = Integer.parseInt(rs.getString("ACOUNT"));
			}
			rs.close();
			psta.close();
			if (count > 0) {
				cro.setV_errMsg("此炉在下线点未结炉，不允许送判!");
				return cro;
			}
			if (prnFlag.equals("1")) {
				sql = CoreXmlSqlParsersFactory
						.getSql("FrmInOnlineStore.SelectPorssWt");
				psta = connection.prepareStatement(sql);
				psta.setString(1, jugeNo);
				rs = psta.executeQuery();
				if (rs.next()) {
					prossWtCount = Integer.parseInt(rs.getString("ACOUNT"));
				}
				rs.close();
				psta.close();
				if (prossWtCount > 0) {
					cro.setV_errMsg("此炉需回报过磅重量才能进行申请判定!");
					return cro;
				}
			}

			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.selectDeliveryState");// 查询交货状态
			psta = connection.prepareStatement(sql);
			psta.setString(1, matZcTityS.getJudgeStoveNo());
			psta.setString(2, matZcTityS.getProOrderId());
			psta.setString(3, matZcTityS.getGxPlanNo());
			rs = psta.executeQuery();
			if (rs.next()) {
				materiaNo = rs.getString("OUTWL_ID");
				materiaName = rs.getString("OUTWL_DESC");
				INWL_ID = rs.getString("INWL_ID");
				INWL_DESC = rs.getString("INWL_DESC");
				CRAFT_SEQ = rs.getString("CRAFT_SEQ");
				DELIVERY_STATE_CODE = rs.getString("DELIVERY_STATE_CODE");// 交货状态代码
				DELIVERY_STATE_NAME = rs.getString("DELIVERY_STATE_NAME");// 交货状态名称
				LOAD_JUDGE_STOVE_NO = rs.getString("JUDGE_STOVE_NO");// 轧管上料炉号
			}
			rs.close();
			psta.close();

			if ((materiaName + INWL_DESC).equals("")) {
				sql = CoreXmlSqlParsersFactory
						.getSql("FrmInOnlineStore.selectZPDeliveryState");// 查询组交货状态
				psta = connection.prepareStatement(sql);
				psta.setString(1, matZcTityS.getProOrderId());
				psta.setString(2, matZcTityS.getGxPlanNo());
				rs = psta.executeQuery();
				if (rs.next()) {
					materiaNo = rs.getString("OUTWL_ID");
					materiaName = rs.getString("OUTWL_DESC");
					INWL_ID = rs.getString("INWL_ID");
					INWL_DESC = rs.getString("INWL_DESC");
					CRAFT_SEQ = rs.getString("CRAFT_SEQ");
					DELIVERY_STATE_CODE = rs.getString("DELIVERY_STATE_CODE");// 交货状态代码
					DELIVERY_STATE_NAME = rs.getString("DELIVERY_STATE_NAME");// 交货状态名称
				}
				rs.close();
				psta.close();
			}

			if (("").equals(LOAD_JUDGE_STOVE_NO) || LOAD_JUDGE_STOVE_NO == null) {
				sql = CoreXmlSqlParsersFactory
						.getSql("FrmInOnlineStore.selectZPJudgeStoveNo");// 查询组炉轧管上料炉号
				psta = connection.prepareStatement(sql);
				psta.setString(1, matZcTityS.getJudgeStoveNo());
				psta.setString(2, matZcTityS.getProOrderId());
				psta.setString(3, matZcTityS.getGxPlanNo());
				rs = psta.executeQuery();
				if (rs.next()) {
					LOAD_JUDGE_STOVE_NO = rs.getString("FEED_HEAT_NO");// 轧管上料炉号
				}
				rs.close();
				psta.close();
			}

			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.selectCheckNo");// 查询检验编号
			psta = connection.prepareStatement(sql);
			psta.setString(1, matZcTityS.getJudgeStoveNo());
			psta.setString(2, matZcTityS.getProOrderId());
			psta.setString(3, matZcTityS.getGxPlanNo());
			rs = psta.executeQuery();
			if (rs.next()) {
				CHECK_NO = rs.getString("CHECK_NO"); // 检验编号
			}
			rs.close();
			psta.close();

			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.selectCutNo");// 查询外委分切数
			psta = connection.prepareStatement(sql);
			psta.setString(1, matZcTityS.getJudgeStoveNo());
			rs = psta.executeQuery();
			if (rs.next()) {
				cutNum = Integer.parseInt(rs.getString("CUT_NO")); // 外委分切数
			}
			rs.close();
			psta.close();

			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.selectZPJudgeStoveNo2");// 组批主炉号
			psta = connection.prepareStatement(sql);
			psta.setString(1, matZcTityS.getJudgeStoveNo());
			psta.setString(2, matZcTityS.getJudgeStoveNo());
			psta.setString(3, matZcTityS.getJudgeStoveNo());
			rs = psta.executeQuery();
			if (rs.next()) {
				ZP_M_LH = rs.getString("ZP_M_LH"); // 
				ZP_COLL = rs.getString("MEMO");
			}
			rs.close();
			psta.close();

			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.selectTestPressure");// 查询外委水压信息
			psta = connection.prepareStatement(sql);
			psta.setString(1, matZcTityS.getJudgeStoveNo());
			rs = psta.executeQuery();
			if (rs.next()) {
				TEST_PRESSURE = rs.getString("TEST_PRESSURE"); // 
				HOLDTIME_TIME = rs.getString("HOLDTIME_TIME");
				TEST_PRESSURE_Y = rs.getString("TEST_PRESSURE_Y");
			}
			rs.close();
			psta.close();

			sql = CoreXmlSqlParsersFactory.getSql("doDecision.jugdeApplyNo");// 生成判定单号
			psta = connection.prepareStatement(sql);
			psta.setString(1, matZcTityS.getPlineCode());
			psta.setString(2, matZcTityS.getProductFlag());
//			psta.setString(3, matZcTityS.getPlineCode());
//			psta.setString(4, matZcTityS.getProductFlag());
			rs = psta.executeQuery();
			if (rs.next()) {
				jugdeApplyNo = rs.getString("JUGDE_APPLY_CODE");
			}
			rs.close();
			psta.close();

			sql = CoreXmlSqlParsersFactory.getSql("doDecision.SelectJudegNo");// 查询该炉是否已申请判定过了
			psta = connection.prepareStatement(sql);
			psta.setString(1, matZcTityS.getJudgeStoveNo());
			rs = psta.executeQuery();
			if (rs.next()) {
				judgeAppNo = rs.getString("JUGDE_APPLY_CODE");
			}
			rs.close();
			psta.close();
			if (judgeAppNo.equals("")) {
				jugdeApplyNo = jugdeApplyNo + "1";
			} else {
				jugdeApplyNo = judgeAppNo
						+ String.valueOf(Integer.parseInt(judgeAppNo
								.substring(judgeAppNo.length() - 1)) + 1);
			}

			if (custom.equals("WG")) {
				if (plineCode.equals("C072") || plineCode.equals("C098") || plineCode.equals("C099") ) {
					belogJugeCode = "002023005";
					belogJugeName = "产品制造部";
				} else {
					belogJugeCode = "002001001";
					belogJugeName = "生产计划部";
				}

				// 查询天淮炉号
				String thJudgeNo = "";
				sql = CoreXmlSqlParsersFactory.getSql("FrmInOnlineStore.getThJudgeNo");
				psta = connection.prepareStatement(sql);
				psta.setString(1, jugeNo);
				rs = psta.executeQuery();
				if (rs.next()) {
					thJudgeNo = rs.getString("JUDGE_STOVE_NO");
				}
				rs.close();
				psta.close();

				//查询天淮炉号探伤信息
				if(!StringUtils.isEmpty(thJudgeNo)){
					sql = CoreXmlSqlParsersFactory
							.getSql("FrmInOnlineStore.SelectETResult");// 关于涡流探伤等级
					psta = connection.prepareStatement(sql);
					psta.setString(1, thJudgeNo);
					psta.setString(2, thJudgeNo);
					rs = psta.executeQuery();
					if (rs.next()) {
						testGrade = rs.getString("TEST_GRADE");
						testingStandar = rs.getString("TESTING_STANDAR");
						notchInfo = rs.getString("NOTCH_INFO");
						notchLength = rs.getString("NOTCH_LENGTH");
						notchWidth = rs.getString("NOTCH_WIDTH");
						notchDepth = rs.getString("NOTCH_DEPTH");
					}
					if (notchInfo == null) {
						notchInfo = "";
					}
					if (notchLength == null) {
						notchLength = "";
					}
					if (notchWidth == null) {
						notchWidth = "";
					}
					if (notchDepth == null) {
						notchDepth = "";
					}
					rs.close();
					psta.close();

					if(StringUtils.isEmpty(testGrade)){
						sql = CoreXmlSqlParsersFactory
								.getSql("FrmInOnlineStore.SelectMTResult");// 关于漏磁探伤等级
						psta = connection.prepareStatement(sql);
						psta.setString(1, thJudgeNo);
						psta.setString(2, thJudgeNo);
						rs = psta.executeQuery();
						if (rs.next()) {
							testGrade = rs.getString("TEST_GRADE");
							testingStandar = rs.getString("TESTING_STANDAR");
							notchInfo = rs.getString("NOTCH_INFO");
							notchLength = rs.getString("NOTCH_LENGTH");
							notchWidth = rs.getString("NOTCH_WIDTH");
							notchDepth = rs.getString("NOTCH_DEPTH");
						}
						if (notchInfo == null) {
							notchInfo = "";
						}
						if (notchLength == null) {
							notchLength = "";
						}
						if (notchWidth == null) {
							notchWidth = "";
						}
						if (notchDepth == null) {
							notchDepth = "";
						}
						rs.close();
						psta.close();
					}
				}

			}
			if (custom.equals("ZG")) {
				sql = CoreXmlSqlParsersFactory
						.getSql("doDecision.SelectOfflineNum");// 查询是否有离线支
				psta = connection.prepareStatement(sql);
				psta.setString(1, jugeNo);
				rs = psta.executeQuery();
				if (rs.next()) {
					acount = Integer.parseInt(rs.getString("ACOUNT"));
				}
				rs.close();
				psta.close();
				// 外委分切的不验证平衡
				if (cutNum == 1) {
					if (acount > 0) {
						sql = CoreXmlSqlParsersFactory
								.getSql("doDecision.SelectOfflineNum1");// 查询是否有离线待处理支
						psta = connection.prepareStatement(sql);
						psta.setString(1, jugeNo);
						rs = psta.executeQuery();
						if (rs.next()) {
							acount = Integer.parseInt(rs.getString("ACOUNT"));
						}
						rs.close();
						psta.close();

						if (acount != 0)// 存在离线待处理支
						{
							if (matZcTityS.getTarget().equals("C")
									&& !matZcTityS.getPlineCode()
											.equals("C072")) {
								cro.setV_errMsg("C字头存在待处理品,不允许申请判定!");
								return cro;
							}
							sql = CoreXmlSqlParsersFactory
									.getSql("doDecision.SelectBalance3");// 离线待处理支!=0
							psta = connection.prepareStatement(sql);
							psta.setString(1, jugeNo);
							psta.setString(2, jugeNo);
							psta.setString(3, jugeNo);
							psta.setString(4, jugeNo);
							rs = psta.executeQuery();
							if (rs.next()) {
								acount = Integer.parseInt(rs
										.getString("ACOUNT"));
							}
							rs.close();
							psta.close();
							if (acount > 0) {
								cro.setV_errMsg("返线不齐，不允许申请判定!");
								return cro;
							}
						} else// 不存在离线待处理支
						{
							sql = CoreXmlSqlParsersFactory
									.getSql("doDecision.SelectBalance2");// 离线待处理支=0
							psta = connection.prepareStatement(sql);
							psta.setString(1, jugeNo);
							psta.setString(2, jugeNo);
							psta.setString(3, jugeNo);
							psta.setString(4, jugeNo);
							psta.setString(5, jugeNo);
							psta.setString(6, jugeNo);
							psta.setString(7, jugeNo);
							rs = psta.executeQuery();
							if (rs.next()) {
								acount = Integer.parseInt(rs
										.getString("ACOUNT"));
							}
							rs.close();
							psta.close();
							if (acount != 0) {
								cro.setV_errMsg("返线不齐，不允许申请判定!");
								return cro;
							}
						}
					} else // 离线支数为0时
					{
						sql = CoreXmlSqlParsersFactory
								.getSql("doDecision.SelectBalance1");// 查询生产支-废品支-交库支=0
						psta = connection.prepareStatement(sql);
						psta.setString(1, jugeNo);
						psta.setString(2, jugeNo);
						psta.setString(3, jugeNo);
						psta.setString(4, jugeNo);
						rs = psta.executeQuery();
						if (rs.next()) {
							acount = Integer.parseInt(rs.getString("ACOUNT"));
						}
						rs.close();
						psta.close();
						if (acount != 0) {
							cro.setV_errMsg("清线不齐,不允许申请判定!");
							return cro;
						}
					}
				}

				if (plineCode.equals("C010")) {
					sql = CoreXmlSqlParsersFactory
							.getSql("FrmInOnlineStore.SelectETResult");// 关于探伤等级
					// 结果的处理(涡流)
				} else if (plineCode.equals("C008") || plineCode.equals("C009")
						|| plineCode.equals("C017") || plineCode.equals("C072")) {
					sql = CoreXmlSqlParsersFactory
							.getSql("FrmInOnlineStore.SelectMTResult");// 关于探伤等级
					// 结果的处理(漏磁)
				}
				psta = connection.prepareStatement(sql);
				psta.setString(1, jugeNo);
				psta.setString(2, jugeNo);
				rs = psta.executeQuery();
				if (rs.next()) {
					testGrade = rs.getString("TEST_GRADE");
					testingStandar = rs.getString("TESTING_STANDAR");
					notchInfo = rs.getString("NOTCH_INFO");
					notchLength = rs.getString("NOTCH_LENGTH");
					notchWidth = rs.getString("NOTCH_WIDTH");
					notchDepth = rs.getString("NOTCH_DEPTH");
				}
				if (notchInfo == null) {
					notchInfo = "";
				}
				if (notchLength == null) {
					notchLength = "";
				}
				if (notchWidth == null) {
					notchWidth = "";
				}
				if (notchDepth == null) {
					notchDepth = "";
				}
				rs.close();
				psta.close();

				sql = CoreXmlSqlParsersFactory
						.getSql("FrmInOnlineStore.SelectEntrBillResult");// 查询委托中的探伤等级、类别
				psta = connection.prepareStatement(sql);
				psta.setString(1, jugeNo);
				rs = psta.executeQuery();
				if (rs.next()) {
					testGradeW = rs.getString("TESTING_GRADE");
					testTypeW = rs.getString("TESTING_TYPE");
				}
				rs.close();
				psta.close();

				if (testGrade == null && testGradeW == null) {
					cro.setV_errMsg("探伤等级为空,不允许送判!");
					return cro;
				} else {
					if (testGradeW != null) {
						testGrade = testGradeW;
						testType = testTypeW;
						defectResult = "40740401";
					} else {
						if (testGrade.equals("/")) {
							testGrade = "";
							testType = "";
							defectResult = "";
						} else {
							if (plineCode.equals("C010")) {
								testType = "ET";
								defectResult = "40740401";
							} else if (plineCode.equals("C008")
									|| plineCode.equals("C009")
									|| plineCode.equals("C017")
									|| plineCode.equals("C072")
									|| (plineCode.equals("C065") && (matZcTityS.getBatchNo().equals("91001") || matZcTityS.getBatchNo().equals("72001")))) {
								testType = "EMI";
								defectResult = "40740401";
							}
						}
					}
				}
				// 轧管外委探伤回报探伤种类和等级
				sql = CoreXmlSqlParsersFactory
						.getSql("FrmInOnlineStore.SelectUTResult");
				psta = connection.prepareStatement(sql);
				psta.setString(1, jugeNo);
				rs = psta.executeQuery();
				if (rs.next()) {
					testGrade1 = rs.getString(1);
				}
				rs.close();
				psta.close();
				if (testGrade1 == null) {
					sql = CoreXmlSqlParsersFactory
							.getSql("FrmInOnlineStore.SelectHttEntrustResult"); // 获取外委探伤等级和种类
					psta = connection.prepareStatement(sql);
					psta.setString(1, jugeNo);
					psta.setString(2, plineCode);
					rs = psta.executeQuery();
					if (rs.next()) {
						testGrade1 = rs.getString("TESTING_GRADE");
						testType1 = rs.getString("TESTING_TYPE");
					}
					rs.close();
					psta.close();

				} else {
					if (!testGrade1.equals("")) {
						testType1 = "UT";
					}
				}
				sql = CoreXmlSqlParsersFactory
						.getSql("doDecision.SelectExitTemp");// 查询终轧温度
				psta = connection.prepareStatement(sql);
				psta.setString(1, matZcTityS.getJudgeStoveNo());
				psta.setString(2, matZcTityS.getJudgeStoveNo());
				rs = psta.executeQuery();
				if (rs.next()) {
					exitTemp = rs.getString("EXIT_TEMP");
				}
				rs.close();
				psta.close();

				if (exitTemp == null || exitTemp.equals("")) {
					cro.setV_errMsg("定径工序终轧温度为空,不允许送判!");
					return cro;
				}

				sql = CoreXmlSqlParsersFactory
						.getSql("doDecision.SelectSampleNews");// 查询样管信息
				psta = connection.prepareStatement(sql);
				psta.setString(1, matZcTityS.getJudgeStoveNo());
				psta.setString(2, matZcTityS.getJudgeStoveNo());
				psta.setString(3, matZcTityS.getJudgeStoveNo());
				psta.setString(4, matZcTityS.getJudgeStoveNo());
				rs = psta.executeQuery();
				if (rs.next()) {
					sampleNewsList.add(rs.getString("SAMPLE_NEWS"));
				}
				rs.close();
				psta.close();
				for (int i = 0; i < sampleNewsList.size(); i++) {
					if (sampleNewsList.get(i) != null
							&& !sampleNewsList.get(i).equals("")) {
						sampleNews = sampleNewsList.get(i);
						break;
					}
				}

				sql = CoreXmlSqlParsersFactory
						.getSql("doDecision.SelectLoFace");// 查询是否存在方向(漏磁)
				psta = connection.prepareStatement(sql);
				psta.setString(1, matZcTityS.getJudgeStoveNo());
				psta.setString(2, matZcTityS.getJudgeStoveNo());
				rs = psta.executeQuery();
				if (rs.next()) {
					loFace.add(rs.getString("LO_SURFACE"));
					liFace.add(rs.getString("LI_SURFACE"));
					toFace.add(rs.getString("TO_SURFACE"));
					tiFace.add(rs.getString("TI_SURFACE"));
				}
				rs.close();
				psta.close();

				for (int j = 0; j < loFace.size(); j++) {
					if (loFace.get(j) != null && !loFace.get(j).equals("/")) {
						if (!sampleNews.equals("")) {
							sampleNews = sampleNews + "/" + "纵向外表面";
						} else {
							sampleNews = "纵向外表面";
						}

						break;
					}
				}
				for (int j = 0; j < liFace.size(); j++) {
					if (liFace.get(j) != null && !liFace.get(j).equals("/")) {
						sampleNews = sampleNews + "/" + "纵向内表面";
						break;
					}
				}
				for (int j = 0; j < toFace.size(); j++) {
					if (toFace.get(j) != null && !toFace.get(j).equals("/")) {
						sampleNews = sampleNews + "/" + "横向外表面";
						break;
					}
				}
				for (int j = 0; j < tiFace.size(); j++) {
					if (tiFace.get(j) != null && !tiFace.get(j).equals("/")) {
						sampleNews = sampleNews + "/" + "横向内表面";
						break;
					}
				}

				String nextG = "";// 下一道工序
				String nextPlineDepartCode = "";// 下一工序指定产线管理部门
				String departCode = "";// 申请判定产线对应管理部门

				if (plineCode.equals("C008") || plineCode.equals("C009")) {
					departCode = "002001016";
				} else if (plineCode.equals("C010")) {
					departCode = "002001017";
				} else if (plineCode.equals("C017")) {
					departCode = "002001018";
				} else if (plineCode.equals("C072")) {
					departCode = "002023018";
				}

				// 申请判定时B\C字头的判定后所属权全写制造部
				if (matZcTityS.getTarget().equals("B")
						|| matZcTityS.getTarget().equals("C")) {
					if (plineCode.equals("C072") || plineCode.equals("C098") || plineCode.equals("C099")) {
						belogJugeCode = "002023005";
						belogJugeName = "产品制造部";
					} else {
						belogJugeCode = "002001001";
						belogJugeName = "生产计划部";
					}
				} else {
					if (productFlag.equals("801402"))// 成品类
					{
						sql = CoreXmlSqlParsersFactory
								.getSql("doDecision.SelectOrderSlaOrg");// 查询合同所属部门
						psta = connection.prepareStatement(sql);
						psta.setString(1, matZcTityS.getJudgeStoveNo());
						rs = psta.executeQuery();
						if (rs.next()) {
							belogJugeCode = rs.getString("SALE_ORG");
							belogJugeName = rs.getString("SALE_ORG_DESC");
						}
						rs.close();
						psta.close();
						if (belogJugeCode.equals("")) {
							if (plineCode.equals("C072")) {
								// 天淮无合同送判默认国内贸易部
								belogJugeCode = "100101";
								belogJugeName = "国内贸易部";
							} else {
								belogJugeCode = "002001001";
								belogJugeName = "生产计划部";
							}
						}

					} else// 半成品
					{
						sql = CoreXmlSqlParsersFactory
								.getSql("doDecision.SelectPlanNextG");// 查询下一道工序
						psta = connection.prepareStatement(sql);
						psta.setString(1, matZcTityS.getProOrderId());
						psta.setString(2, matZcTityS.getGxPlanNo());
						rs = psta.executeQuery();
						if (rs.next()) {
							nextG = rs.getString("NEXT_GX");
						}
						rs.close();
						psta.close();
						if (nextG == null) {
							if (plineCode.equals("C008")) {
								belogJugeCode = "002001016003";
								belogJugeName = "250机组";
							} else if (plineCode.equals("C009")) {
								belogJugeCode = "002001016002";
								belogJugeName = "258机组";
							} else if (plineCode.equals("C010")) {
								belogJugeCode = "002001017003";
								belogJugeName = "168机组";
							} else if (plineCode.equals("C017")) {
								belogJugeCode = "002001018003";
								belogJugeName = "460机组";
							} else if (plineCode.equals("C072")) {
								belogJugeCode = "002023018001";
								belogJugeName = "天淮508机组";
							}
						} else {
							if (nextG.equals("")) {
								if (plineCode.equals("C008")) {
									belogJugeCode = "002001016003";
									belogJugeName = "250机组";
								} else if (plineCode.equals("C009")) {
									belogJugeCode = "002001016002";
									belogJugeName = "258机组";
								} else if (plineCode.equals("C010")) {
									belogJugeCode = "002001017003";
									belogJugeName = "168机组";
								} else if (plineCode.equals("C017")) {
									belogJugeCode = "002001018003";
									belogJugeName = "460机组";
								} else if (plineCode.equals("C072")) {
									belogJugeCode = "002023018001";
									belogJugeName = "天淮508机组";
								}
							} else {
								if (!nextG.equals("E") && !nextG.equals("F")
										&& !nextG.equals("G")) {
									if (plineCode.equals("C072") || plineCode.equals("C098") || plineCode.equals("C099")) {
										belogJugeCode = "002023005";
										belogJugeName = "产品制造部";
									} else {
										belogJugeCode = "002001001";
										belogJugeName = "生产计划部";
									}
								}
								sql = CoreXmlSqlParsersFactory
										.getSql("doDecision.SelectDBKDepartCode");// 查询镦拔扩指定产线管理部门
								if (nextG.equals("E"))// 镦拔扩
								{
									sql = sql
											.replace("#PLAN#", "PLN_ORDER_DBK");
								} else if (nextG.equals("F"))// 热处理
								{
									sql = sql
											.replace("#PLAN#", "PLN_ORDER_RCL");
								} else if (nextG.equals("G"))// 管加工
								{
									sql = sql
											.replace("#PLAN#", "PLN_ORDER_JGX");
								}
								psta = connection.prepareStatement(sql);
								if (matZcTityS.getOrdLnDlyPk().contains("-")) {
									psta.setString(1, matZcTityS
											.getOrdLnDlyPk().substring(
													0,
													matZcTityS.getOrdLnDlyPk()
															.indexOf("-")));
								} else {
									psta.setString(1, matZcTityS
											.getOrdLnDlyPk());
								}
								rs = psta.executeQuery();
								if (rs.next()) {
									nextPlineDepartCode = rs
											.getString("DEPARTMENT_CODE_P");
								}
								rs.close();
								psta.close();
								if (nextPlineDepartCode.equals(departCode)) {
									if (plineCode.equals("C008")) {
										belogJugeCode = "002001016003";
										belogJugeName = "250机组";
									} else if (plineCode.equals("C009")) {
										belogJugeCode = "002001016002";
										belogJugeName = "258机组";
									} else if (plineCode.equals("C010")) {
										belogJugeCode = "002001017003";
										belogJugeName = "168机组";
									} else if (plineCode.equals("C017")) {
										belogJugeCode = "002001018003";
										belogJugeName = "460机组";
									} else if (plineCode.equals("C072")) {
										belogJugeCode = "002023018001";
										belogJugeName = "天淮508机组";
									}
								} else {
									if (plineCode.equals("C072") || plineCode.equals("C098") || plineCode.equals("C099")) {
										belogJugeCode = "002023005";
										belogJugeName = "产品制造部";
									} else {
										belogJugeCode = "002001001";
										belogJugeName = "生产计划部";
									}
								}
							}
						}

					}// 半成品
				} // 申请判定时B\C字头的判定后所属权全写制造部

			}

			String insertJugdeApplyLog = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.insertJugdeApplyLog");// 送判记录
			PreparedStatement insertJugdeApplyLogPsta = connection
					.prepareStatement(insertJugdeApplyLog);

			for (String str : parm) {
				int inputCount = 0;// 投料支
				double inputWeight = 0.000;// 投料吨
				String outputCount = "";// 判定支+废品支
				String outputWeight = "";// 判定吨+废品吨
				int sawCutNum = 0;// 分切数
				String maxBathGroupNo = "";// 最大批号
				String maxGroupNo = "";// 最大组号
				int scapCount = 0;// 所有废品支
				String zpJugeNo = "";// 组炉原炉号
				ArrayList<String> mMatNoList = new ArrayList<String>();
				ArrayList<String> mJudgeNoList = new ArrayList<String>();
				MatZcMEntity matZcTity = EntityTool.getEntityByJSONStr(str,
						MatZcMEntity.class);

				if (custom.equals("ZG")) {
					sql = CoreXmlSqlParsersFactory
							.getSql("doDecision.SelectPlanSaw");// 查询分切数
					psta = connection.prepareStatement(sql);
					psta.setString(1, matZcTity.getJudgeStoveNo());
					rs = psta.executeQuery();
					if (rs.next()) {
						sawCutNum = Integer.parseInt(rs.getString("SAW_NUM"));
					}
					rs.close();
					psta.close();

					sql = CoreXmlSqlParsersFactory
							.getSql("doDecision.SelectOldJugeNo");// 查询原炉号
					psta = connection.prepareStatement(sql);
					psta.setString(1, matZcTity.getJudgeStoveNo());
					psta.setString(2, matZcTity.getJudgeStoveNo());
					psta.setString(3, matZcTity.getJudgeStoveNo());
					rs = psta.executeQuery();
					if (rs.next()) {
						zpJugeNo = rs.getString("JUDGE_STOVE_NO");
					}
					rs.close();
					psta.close();

					sql = CoreXmlSqlParsersFactory
							.getSql("doDecision.SelectMaxGroupNo");// 查询最大批号
					sql = EntityTool.fillSqlByEntity(sql, matZcTity);
					psta = connection.prepareStatement(sql);
					rs = psta.executeQuery();
					if (rs.next()) {
						maxBathGroupNo = rs.getString("BATCH_NO");
						maxGroupNo = rs.getString("GROUP_NO");
					}
					rs.close();
					psta.close();

					sql = CoreXmlSqlParsersFactory
							.getSql("doDecision.SelectScrapCount");// 查询所有废品支
					sql = EntityTool.fillSqlByEntity(sql, matZcTity);
					psta = connection.prepareStatement(sql);
					rs = psta.executeQuery();
					if (rs.next()) {
						scapCount = Integer.parseInt(rs.getString("ACT_COUNT"));
					}
					rs.close();
					psta.close();

					if (matZcTity.getBatchNo().equals(maxBathGroupNo)
							&& matZcTity.getBatchGroudNo().equals(maxGroupNo))// 判断是否为最大批号、组号
					{
						sql = CoreXmlSqlParsersFactory
								.getSql("doDecision.SelectINPUTCOUNTWGT");// 查询投料支吨
						psta = connection.prepareStatement(sql);
						if (!zpJugeNo.equals("")) {
							psta.setString(1, zpJugeNo);
						} else {
							psta.setString(1, matZcTity.getJudgeStoveNo());
						}
						psta.setString(2, String.valueOf(Math.ceil(Double
								.parseDouble(String.valueOf(Integer
										.parseInt(matZcTity.getActCount())
										+ scapCount))
								/ sawCutNum)));
						rs = psta.executeQuery();
						while (rs.next()) {
							mMatNoList.add(rs.getString("M_MAT_NO"));
							// mJudgeNoList.add(rs.getString("JUDGE_STOVE_NO"));
							// inputCount = inputCount +
							// Integer.parseInt(rs.getString("INPUT_COUNT"));
							// inputWeight = inputWeight +
							// Double.parseDouble(rs.getString("INPUT_WEIGHT"));
						}
						rs.close();
						psta.close();

						// sql =
						// CoreXmlSqlParsersFactory.getSql("doDecision.SelectOUTCOUNTWGT1");//
						// 查询判定支+废品支
						// sql = EntityTool.fillSqlByEntity(sql, matZcTity);
						// psta = connection.prepareStatement(sql);
						// rs = psta.executeQuery();
						// if (rs.next()) {
						// outputCount = rs.getString("OUTPUT_COUNT");
						// outputWeight = rs.getString("OUTPUT_WEIGHT");
						// }
						// rs.close();
						// psta.close();
						//						
						// sql =
						// CoreXmlSqlParsersFactory.getSql("doDecision.SelectOutCount");//
						// 查询判定吨+废品
						// sql = EntityTool.fillSqlByEntity(sql, matZcTity);
						// psta = connection.prepareStatement(sql);
						// psta.setString(1,
						// String.valueOf(Math.ceil(Integer.parseInt(outputCount)/sawCutNum)));
						// rs = psta.executeQuery();
						// if (rs.next()) {
						// outputWeight = rs.getString("OUTPUT_WEIGHT");
						// }
						// rs.close();
						// psta.close();

					} else {
						sql = CoreXmlSqlParsersFactory
								.getSql("doDecision.SelectINPUTCOUNTWGT");// 查询投料支吨
						psta = connection.prepareStatement(sql);
						psta.setString(1, matZcTity.getJudgeStoveNo());
						psta.setString(2, String.valueOf(Math.ceil(Double
								.parseDouble(matZcTity.getActCount())
								/ sawCutNum)));
						rs = psta.executeQuery();
						while (rs.next()) {
							mMatNoList.add(rs.getString("M_MAT_NO"));
							// mJudgeNoList.add(rs.getString("JUDGE_STOVE_NO"));
							// inputCount = inputCount +
							// Integer.parseInt(rs.getString("INPUT_COUNT"));
							// inputWeight = inputWeight +
							// Double.parseDouble(rs.getString("INPUT_WEIGHT"));
						}
						rs.close();
						psta.close();

						// sql =
						// CoreXmlSqlParsersFactory.getSql("doDecision.SelectOUTCOUNTWGT");//
						// 查询判定支+废品
						// sql = EntityTool.fillSqlByEntity(sql, matZcTity);
						// psta = connection.prepareStatement(sql);
						// rs = psta.executeQuery();
						// if (rs.next()) {
						// outputCount = rs.getString("OUTPUT_COUNT");
						// //outputWeight = rs.getString("OUTPUT_WEIGHT");
						// }
						// rs.close();
						// psta.close();
						//						
						// sql =
						// CoreXmlSqlParsersFactory.getSql("doDecision.SelectOutCount");//
						// 查询判定吨+废品
						// sql = EntityTool.fillSqlByEntity(sql, matZcTity);
						// psta = connection.prepareStatement(sql);
						// psta.setString(1,
						// String.valueOf(Math.ceil(Integer.parseInt(outputCount)/sawCutNum)));
						// rs = psta.executeQuery();
						// if (rs.next()) {
						// outputWeight = rs.getString("OUTPUT_WEIGHT");
						// }
						// rs.close();
						// psta.close();

					}

					inputCount = mMatNoList.size();
					for (int j = 0; j < mMatNoList.size(); j++) {
						sql = CoreXmlSqlParsersFactory
								.getSql("doDecision.SelectPortWgt");// 查询判定支+废品支

						psta = connection.prepareStatement(sql);
						psta.setString(1, mMatNoList.get(j));
						if (!zpJugeNo.equals("")) {
							psta.setString(2, zpJugeNo);
						} else {
							psta.setString(2, matZcTity.getJudgeStoveNo());
						}
						rs = psta.executeQuery();
						if (rs.next()) {
							inputWeight = inputWeight
									+ Double.parseDouble(rs
											.getString("INPUT_WEIGHT"));
						}
						rs.close();
						psta.close();
					}

					for (int i = 0; i < mMatNoList.size(); i++) {
						String updatePortSql = CoreXmlSqlParsersFactory
								.getSql("FrmInOnlineStore.updtaePortFlag");// 修改进程表标识、申请判定单号
						PreparedStatement updatePortPsta = connection
								.prepareStatement(updatePortSql);
						updatePortPsta.setString(1, jugdeApplyNo);
						// if(!zpJugeNo.equals(""))
						// {
						// updatePortPsta.setString(2, zpJugeNo);
						// }else
						// {
						updatePortPsta
								.setString(2, matZcTity.getJudgeStoveNo());
						// }
						// updatePortPsta.setString(2,
						// matZcTity.getJudgeStoveNo());
						updatePortPsta.setString(3, mMatNoList.get(i));
						updatePortPsta.executeUpdate();

						updatePortPsta.close();
					}
				}

				insertJugeApplyPsta.setString(1, matZcTity.getJudgeStoveNo());
				insertJugeApplyPsta.setString(2, matZcTity.getBatchNo());
				insertJugeApplyPsta.setString(3, matZcTity.getBatchGroudNo());
				insertJugeApplyPsta.setString(4, matZcTity.getPlineCode());
				
				//缴库量上限>累计送判吨（按计划入）,缴库量上限<累计送判吨（按计划入）+送判吨，送判支>预计可送判支
				if(matZcTity.getTarget().equals(("A")) && matZcTity.getInMold().equals("801703")){
					if(Integer.parseInt(matZcTity.getKspz())> 0 &&  Integer.parseInt(matZcTity.getActCount())> Integer.parseInt(matZcTity.getKspz())){
						insertJugeApplyPsta.setString(5,matZcTity.getKspz());
					}else{
						insertJugeApplyPsta.setString(5,matZcTity.getActCount());
					}
					//成品，非计划，有拆分支，按拆分支送判
				}else if(matZcTity.getTarget().equals(("A")) && matZcTity.getInMold().equals("801701") && !matZcTity.getCfz().equals("") && matZcTity.getCfz()!= null){
					if( Double.parseDouble(matZcTity.getCfz()) > 0){
						insertJugeApplyPsta.setString(5,matZcTity.getCfz());
					}
				}else{
					insertJugeApplyPsta.setString(5,matZcTity.getActCount());
				}

				insertJugeApplyPsta.setString(6, jugdeApplyNo);
				insertJugeApplyPsta.setString(7, defectResult); // 探伤结果代码
				insertJugeApplyPsta.setString(8, userName);
				insertJugeApplyPsta.setString(9, memo);// 管捆信息
				insertJugeApplyPsta.setString(10, testGrade);
				insertJugeApplyPsta.setString(11, testType);
				insertJugeApplyPsta.setString(12, testGrade1);
				insertJugeApplyPsta.setString(13, testType1);
				insertJugeApplyPsta.setString(14, exitTemp);// 终轧温度
				insertJugeApplyPsta.setString(15, sampleNews);// 样管信息
				insertJugeApplyPsta.setString(16, belogJugeCode);// 判定后所属权代码
				insertJugeApplyPsta.setString(17, belogJugeName);
				insertJugeApplyPsta.setString(18, String.valueOf(inputCount));
				insertJugeApplyPsta.setString(19, String.valueOf(inputWeight));
				insertJugeApplyPsta.setString(20, String.valueOf(inputCount));
				insertJugeApplyPsta.setString(21, String.valueOf(inputWeight));

				insertJugeApplyPsta.setString(22, DELIVERY_STATE_CODE); // 交货状态代码
				insertJugeApplyPsta.setString(23, DELIVERY_STATE_NAME); // 交货状态
				if (custom.equals("ZG")) {
					insertJugeApplyPsta.setString(24, LOAD_JUDGE_STOVE_NO); // 轧管上料炉号
				} else {
					insertJugeApplyPsta.setString(24, matZcTity
							.getJudgeStoveNo()); // 轧管上料炉号
				}
				insertJugeApplyPsta.setString(25, CHECK_NO); // 检验编号
				insertJugeApplyPsta.setString(26, ZP_M_LH); // 组批主炉号
				insertJugeApplyPsta.setString(27, ZP_COLL); // 组批炉号集合
				insertJugeApplyPsta.setString(28, matZcTity
						.getMchVisualResult()); // 加工表面质量结果
				insertJugeApplyPsta.setString(29, matZcTity
						.getMchDimensionsResult()); // 加工几何尺寸结果
				insertJugeApplyPsta.setString(30, testingStandar); // 探伤标准
				insertJugeApplyPsta.setString(31, notchInfo); // 样管刻槽信息
				insertJugeApplyPsta.setString(32, notchLength); // 槽长
				insertJugeApplyPsta.setString(33, notchWidth); // 槽宽
				insertJugeApplyPsta.setString(34, notchDepth); // 槽深
				insertJugeApplyPsta.setString(35, TEST_PRESSURE); // 水压压力PSI
				insertJugeApplyPsta.setString(36, HOLDTIME_TIME); // 保压时间S
				insertJugeApplyPsta.setString(37, TEST_PRESSURE_Y); // 水压压力MPa
				insertJugeApplyPsta.setString(38, matZcTity.getInMold()); // 入库区分

				insertJugeApplyPsta.setString(39, testGrade);
				insertJugeApplyPsta.setString(40, testType);
				insertJugeApplyPsta.setString(41, testGrade1);
				insertJugeApplyPsta.setString(42, testType1);

				insertJugeApplyPsta.setString(43, jugdeApplyNo);
				insertJugeApplyPsta.setString(44, userName);
	            //System.out.println("Executing SQL:　"+ ((LoggableStatement) insertJugeApplyPsta).getQueryString());
				insertJugeApplyPsta.addBatch();
				insertJugeApplyPsta.executeBatch();

				/*
				 * updatePsta.setString(1, matZcTity.getJudgeStoveNo());
				 * updatePsta.setString(2, matZcTity.getBatchNo());
				 * updatePsta.setString(3, matZcTity.getBatchGroudNo()); //
				 * updatePsta.setString(4, matZcTity.getStorageNo()); //
				 * updatePsta.setString(5, matZcTity.getLocationNo());
				 * updatePsta.setString(4, matZcTity.getProductFlag());
				 * updatePsta.setString(5, matZcTity.getMatStatus());
				 * updatePsta.setString(6, jugdeApplyNo); updatePsta.addBatch();
				 */

				// 更新进程表mil_processes数据
				updateMilProcess.setString(1, jugeNo);
				updateMilProcess.setString(2, matZcTity.getLotNo());
				updateMilProcess.setString(3, plineCode);
				updateMilProcess.setString(4, matZcTity.getProOrderId());
				updateMilProcess.setString(5, matZcTity.getGxPlanNo());
				updateMilProcess.addBatch();

				updateJudgeStoveNoSeq.setString(1, jugeNo);
				updateJudgeStoveNoSeq.addBatch();

				updateJudgeStoveNoSeq2.setString(1, jugeNo);
				updateJudgeStoveNoSeq2.setString(2, jugdeApplyNo);
				updateJudgeStoveNoSeq2.addBatch();
				
				updateJudgeStoveNoSeq3.setString(1, jugeNo);
				updateJudgeStoveNoSeq3.setString(2, plineCode);
				updateJudgeStoveNoSeq3.addBatch();
				if (plineCode.equals("C072")) {
					updateJudgeStoveNoSeq3.executeBatch();
				}

				// 申请记录
				insertJugdeApplyLogPsta.setString(1, jugdeApplyNo);
				insertJugdeApplyLogPsta.setString(2, matZcTity.getJudgeStoveNo());
				insertJugdeApplyLogPsta.setString(3, matZcTity.getBatchNo());
				insertJugdeApplyLogPsta.setString(4, matZcTity.getBatchGroudNo());
				insertJugdeApplyLogPsta.setString(5, matZcTity.getProcessCdoe());
				insertJugdeApplyLogPsta.setString(6, matZcTity.getPlineCode());
				//缴库量上限>累计送判吨（按计划入）,缴库量上限<累计送判吨（按计划入）+送判吨，送判支>预计可送判支
				if(matZcTity.getTarget().equals(("A")) && matZcTity.getInMold().equals("801703")){
					if(Double.parseDouble(matZcTity.getPaydownWtMax())> Double.parseDouble(matZcTity.getActWeight2()) && Double.parseDouble(matZcTity.getPaydownWtMax())< Double.parseDouble(matZcTity.getActWeight2()) + Double.parseDouble(matZcTity.getActWeight()) && Integer.parseInt(matZcTity.getActCount())> Integer.parseInt(matZcTity.getKspz())){
						insertJugdeApplyLogPsta.setString(7,matZcTity.getKspz());
					}else{
						insertJugdeApplyLogPsta.setString(7,matZcTity.getActCount());
					}
					//成品，非计划，有拆分支，按拆分支送判
				}else if(matZcTity.getTarget().equals(("A")) && matZcTity.getInMold().equals("801701") && !matZcTity.getCfz().equals("") && matZcTity.getCfz()!= null){
					if( Double.parseDouble(matZcTity.getCfz()) > 0){
						insertJugdeApplyLogPsta.setString(7,matZcTity.getCfz());
					}
				}else{
					insertJugdeApplyLogPsta.setString(7,matZcTity.getActCount());
				}
				insertJugdeApplyLogPsta.setString(8, matZcTity.getActWeight());
				insertJugdeApplyLogPsta.setString(9, userName);
				insertJugdeApplyLogPsta.setString(10, "1");
				insertJugdeApplyLogPsta.addBatch();

				judgeAppSeq++;

			} // for (String str : parm)
			//insertJugeApplyPsta.executeBatch();
			// updatePsta.executeBatch();
			updateMilProcess.executeBatch();
			updateJudgeStoveNoSeq.executeBatch();
			updateJudgeStoveNoSeq2.executeBatch();
			insertJugdeApplyLogPsta.executeBatch();
			/*if (plineCode.equals("C072")) {
				updateJudgeStoveNoSeq3.executeBatch();
			}*/
			// connection.commit();
			/*
			 * String aNum = ""; sql = CoreXmlSqlParsersFactory
			 * .getSql("FrmInOnlineStore.SelectAcount");// 查询送判支与进程表标记的支数差值 psta
			 * = connection.prepareStatement(sql); psta.setString(1,
			 * jugdeApplyNo); psta.setString(2, jugdeApplyNo); rs =
			 * psta.executeQuery(); while (rs.next()) { aNum =
			 * rs.getString("ACOUNT"); } rs.close(); psta.close();
			 * if(Integer.parseInt(aNum)> 0){
			 * cro.setV_errMsg("送判重量大于投料量，请重新送判!"); return cro; }
			 */

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

	/***
	 * 撤销申请判定
	 * 
	 * @param parm
	 * @return
	 */
	public CoreReturnObject cancelDoDecision(ArrayList<String> parm) {
		return cancelDoDecision(parm,"");
	}
	public CoreReturnObject cancelDoDecision(ArrayList<String> parm,String userName) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String sql = "";
			PreparedStatement psta = null;
			ResultSet rs = null;
			String acount = "";
			String updateMatZcSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.cancelDoDecision");// 正常撤判
			PreparedStatement updateMatZcPsta = connection
					.prepareStatement(updateMatZcSql);
			String updateMatZcExceptionSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.cancelDoDecisionException");// 异常撤判
			PreparedStatement updateMatZcExceptionPsta = connection
					.prepareStatement(updateMatZcExceptionSql);

			String updatePortSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.cancelPortFlag");// 撤销时修改进程表
			PreparedStatement updatePortPsta = connection
					.prepareStatement(updatePortSql);

			String updateProcess = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.insertMilProcess");// 更新进程表mil_processes数据
			PreparedStatement updateMilProcess = connection
					.prepareStatement(updateProcess);

			String insertJugdeApplyLog = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.insertJugdeApplyLog");// 撤判记录
			PreparedStatement insertJugdeApplyLogPsta = connection
					.prepareStatement(insertJugdeApplyLog);

			for (String str : parm) {
				MatZcMEntity matZcTity = EntityTool.getEntityByJSONStr(str,
						MatZcMEntity.class);
				if (matZcTity.getJugdeApplyCode().equals("")) {
					cro.setV_errMsg("炉号'" + matZcTity.getJudgeStoveNo()
							+ "'未进行申请判定,不能进行撤销!");
					return cro;
				}
				sql = CoreXmlSqlParsersFactory
						.getSql("cancelDoDecision.doQuery");// 查询是否已判定
				psta = connection.prepareStatement(sql);
				psta.setString(1, matZcTity.getJugdeApplyCode());
				psta.setString(2, matZcTity.getJudgeStoveNo());
				psta.setString(3, matZcTity.getBatchNo());
				psta.setString(4, matZcTity.getBatchGroudNo());
				rs = psta.executeQuery();
				if (rs.next()) {
					acount = rs.getString("ACOUNT");
				}
				rs.close();
				psta.close();
				if (Integer.parseInt(acount) > 0) {
					cro.setV_errMsg("炉号'" + matZcTity.getJudgeStoveNo()
							+ "'已有进行质量判定的材料,无法撤销申请!");
					return cro;
				}

				sql = CoreXmlSqlParsersFactory
						.getSql("cancelDoDecision.ReciveZB");// 查询质保系统是否已接收
				psta = connection.prepareStatement(sql);
				psta.setString(1, matZcTity.getJugdeApplyCode());
				psta.setString(2, matZcTity.getJudgeStoveNo());
				psta.setString(3, matZcTity.getBatchNo());
				psta.setString(4, matZcTity.getBatchGroudNo());
				rs = psta.executeQuery();
				if (rs.next()) {
					acount = rs.getString("ACOUNT");
				}
				rs.close();
				psta.close();
				if (Integer.parseInt(acount) > 0) {
					cro.setV_errMsg("炉号'" + matZcTity.getJudgeStoveNo()
							+ "'质保系统已接收,无法撤销申请!");
					return cro;
				}

				sql = CoreXmlSqlParsersFactory
						.getSql("cancelDoDecision.SelectPassApply");// 查询是否已紧急放行
				psta = connection.prepareStatement(sql);
				psta.setString(1, matZcTity.getJugdeApplyCode());
				psta.setString(2, matZcTity.getJudgeStoveNo());
				rs = psta.executeQuery();
				if (rs.next()) {
					acount = rs.getString("ACOUNT");
				}
				rs.close();
				psta.close();
				if (Integer.parseInt(acount) > 0) {
					cro.setV_errMsg("炉号'" + matZcTity.getJudgeStoveNo()
							+ "'已紧急放行,无法撤销申请!");
					return cro;
				}
				if (matZcTity.getBackJugdeMemo().equals("")) {
					updateMatZcPsta.setString(1, matZcTity.getJugdeApplyCode());
					updateMatZcPsta.setString(2, matZcTity.getJudgeStoveNo());
					updateMatZcPsta.setString(3, matZcTity.getBatchNo());
					updateMatZcPsta.setString(4, matZcTity.getBatchGroudNo());
					updateMatZcPsta.addBatch();
				} else {
					updateMatZcExceptionPsta.setString(1, matZcTity
							.getJugdeApplyCode());
					updateMatZcExceptionPsta.setString(2, matZcTity
							.getJudgeStoveNo());
					updateMatZcExceptionPsta.setString(3, matZcTity
							.getBatchNo());
					updateMatZcExceptionPsta.setString(4, matZcTity
							.getBatchGroudNo());
					updateMatZcExceptionPsta.addBatch();
				}
				updatePortPsta.setString(1, matZcTity.getJugdeApplyCode());
				updatePortPsta.addBatch();

				// 更新进程表mil_processes数据
				updateMilProcess.setString(1, matZcTity.getJudgeStoveNo());
				updateMilProcess.setString(2, matZcTity.getLotNo());
				updateMilProcess.setString(3, matZcTity.getPlineCode());
				updateMilProcess.setString(4, matZcTity.getProOrderId());
				updateMilProcess.setString(5, matZcTity.getGxPlanNo());
				updateMilProcess.addBatch();

				// 撤判记录
				insertJugdeApplyLogPsta.setString(1, matZcTity.getJugdeApplyCode());
				insertJugdeApplyLogPsta.setString(2, matZcTity.getJudgeStoveNo());
				insertJugdeApplyLogPsta.setString(3, matZcTity.getBatchNo());
				insertJugdeApplyLogPsta.setString(4, matZcTity.getBatchGroudNo());
				insertJugdeApplyLogPsta.setString(5, matZcTity.getProcessCdoe());
				insertJugdeApplyLogPsta.setString(6, matZcTity.getPlineCode());
				insertJugdeApplyLogPsta.setString(7, matZcTity.getActCount());
				insertJugdeApplyLogPsta.setString(8, matZcTity.getActWeight());
				insertJugdeApplyLogPsta.setString(9, userName);
				insertJugdeApplyLogPsta.setString(10, "2");
				insertJugdeApplyLogPsta.addBatch();

			}

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

	/***
	 * 结炉验证
	 * 
	 * @param jugeNo
	 * @param plineCode
	 * @return
	 */
	public CoreReturnObject doBeside(String jugeNo, String lotNo,
			String plineCode, String userid, String proPlanId, String gxPlanNo)
			throws Exception {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
//		TZH 24.4.24 注销物流接口
//		Connection connection2 = this.getDao("TmsDao").getConnection();
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		String nodeStaus = "";
		String backPlan = "";
		Date now = new Date();
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMM");
		String systime = dateFormat.format(now);
		String acount = "";
		String HeatPlanNo = "";
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
//			TZH 24.4.24 注销物流接口
//			connection2.setAutoCommit(false); // 取消自动提交事务
			int matCount = 0;// 库存支数
			int milCount = 0;// 轧管支数
			String updatePlanSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.doBeside");
			PreparedStatement updatePlanPsta = connection
					.prepareStatement(updatePlanSql);
			String updateMilInstoreStausSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.updateMilInstoreStaus");// 修改交库实绩表结炉标识
			PreparedStatement updateMilInstoreStausPsta = connection
					.prepareStatement(updateMilInstoreStausSql);
			String insertZgMatNoSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.insertZgMatNo");// 插入轧管材料号
			PreparedStatement insertZgMatNoPsta = connection
					.prepareStatement(insertZgMatNoSql);

			String updateGroupNoSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.updateGroupNo");// 结炉写进程表组号，结转年月
			PreparedStatement updateGroupNoPsta = connection
					.prepareStatement(updateGroupNoSql);

			String updateStausSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.updatePortStaus");// 结炉时处理交库点离线数据状态
			PreparedStatement updateStausPsta = connection
					.prepareStatement(updateStausSql);

			String updateProcess = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.insertMilProcess");// 更新进程表mil_processes数据
			PreparedStatement updateMilProcess = connection
					.prepareStatement(updateProcess);

			/*
			 * String updatePlnZyZgM = CoreXmlSqlParsersFactory
			 * .getSql("FrmInOnlineStore.updatePlnZyZgM");// 更新计划表计划状态(等待更新使用)
			 * PreparedStatement updatePlnZyZgMPS = connection
			 * .prepareStatement(updatePlnZyZgM);
			 */

			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.selectNodeStaus");
			psta = connection.prepareStatement(sql);
			psta.setString(1, jugeNo);
			psta.setString(2, lotNo);
			psta.setString(3, plineCode);
			rs = psta.executeQuery();
			if (rs.next()) {
				nodeStaus = rs.getString("NODE_STATUS");
				HeatPlanNo = rs.getString("ID");
			}
			rs.close();
			psta.close();
			if (Integer.parseInt(nodeStaus) >= 96) {

			} else {
				cro.setV_errMsg("人工质检未结炉,交库不允许结炉!");
				return cro;
			}

			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.selectMilPlanBackPlan");
			psta = connection.prepareStatement(sql);
			psta.setString(1, jugeNo);
			rs = psta.executeQuery();
			if (rs.next()) {
				backPlan = rs.getString("BACK_PLAN_FLAG");
			}
			rs.close();
			psta.close();
			// if(!backPlan.equals("10"))
			// {
			matCount = doQueryMatZcCount(connection, jugeNo, plineCode);
			milCount = doQueryMilCount(connection, jugeNo, plineCode);
			if (matCount != milCount) {
				cro.setV_errMsg("产出支数与交库支数不一致,不允许进行结炉!");
				return cro;
			}
			// }
			if (!backPlan.equals("10")) {
				sql = CoreXmlSqlParsersFactory
						.getSql("FrmInOnlineStore.selectSurfaceToInStore");
				psta = connection.prepareStatement(sql);
				psta.setString(1, jugeNo);
				rs = psta.executeQuery();
				if (rs.next()) {
					acount = rs.getString("ACOUNT");
				}
				rs.close();
				if (!acount.equals("0")) {
					cro.setV_errMsg("表检支数与交库点支数不一致,不允许结炉!");
					return cro;
				}
			}

			updatePlanPsta.setString(1, jugeNo);
			updatePlanPsta.setString(2, lotNo);
			updatePlanPsta.setString(3, plineCode);
			updatePlanPsta.setString(4, proPlanId);
			updatePlanPsta.setString(5, gxPlanNo);
			updatePlanPsta.addBatch();

			updateMilInstoreStausPsta.setString(1, userid);
			updateMilInstoreStausPsta.setString(2, jugeNo);
			updateMilInstoreStausPsta.setString(3, lotNo);
			updateMilInstoreStausPsta.setString(4, plineCode);
			updateMilInstoreStausPsta.setString(5, proPlanId);
			updateMilInstoreStausPsta.setString(6, gxPlanNo);
			updateMilInstoreStausPsta.addBatch();

			insertZgMatNoPsta.setString(1, jugeNo);
			insertZgMatNoPsta.setString(2, proPlanId);
			insertZgMatNoPsta.setString(3, gxPlanNo);
			insertZgMatNoPsta.addBatch();

			updateGroupNoPsta.setString(1, jugeNo);
			updateGroupNoPsta.setString(2, proPlanId);
			updateGroupNoPsta.setString(3, gxPlanNo);
			// updateGroupNoPsta.setString(2, systime);
			// updateGroupNoPsta.setString(3, jugeNo);
			updateGroupNoPsta.addBatch();

			updateStausPsta.setString(1, jugeNo);
			updateStausPsta.setString(2, proPlanId);
			updateStausPsta.setString(3, gxPlanNo);
			updateStausPsta.setString(4, jugeNo);
			updateStausPsta.setString(5, proPlanId);
			updateStausPsta.setString(6, gxPlanNo);
			updateStausPsta.setString(7, jugeNo);
			updateStausPsta.setString(8, proPlanId);
			updateStausPsta.setString(9, gxPlanNo);
			updateStausPsta.addBatch();

			// 更新进程表mil_processes数据
			updateMilProcess.setString(1, jugeNo);
			updateMilProcess.setString(2, lotNo);
			updateMilProcess.setString(3, plineCode);
			updateMilProcess.setString(4, proPlanId);
			updateMilProcess.setString(5, gxPlanNo);
			updateMilProcess.addBatch();

			// 更新计划表计划状态
			/*
			 * updatePlnZyZgMPS.setString(1, jugeNo);
			 * updatePlnZyZgMPS.setString(2, plineCode);
			 * updatePlnZyZgMPS.setString(3, proPlanId);
			 * updatePlnZyZgMPS.setString(4, gxPlanNo);
			 * updatePlnZyZgMPS.addBatch();
			 */

			updatePlanPsta.executeBatch();
			updateMilInstoreStausPsta.executeBatch();
			updateStausPsta.executeBatch();
			insertZgMatNoPsta.executeBatch();
			updateGroupNoPsta.executeBatch();
			updateMilProcess.executeBatch();
			// updatePlnZyZgMPS.executeBatch();
			// 运输需求
//			TZH 24.4.24 注销物流接口
//			updateTmsDemandM(connection, connection2, cro, jugeNo, HeatPlanNo,
//					"JL");
			if (cro.getV_errMsg().equals("")) {
				cro.setV_errMsg("结炉成功!");
			}
			connection.commit();
//			TZH 24.4.24 注销物流接口
//			connection2.commit();
		} catch (SQLException e) {
			System.out.println(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
//					TZH 24.4.24 注销物流接口
//					connection2.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
//			TZH 24.4.24 注销物流接口
//			if (connection2 != null) {
//				try {
//					connection.rollback(); // 回滚事务
//					connection2.rollback(); // 回滚事务
//				} catch (Exception e2) {
//				}
//			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
//				TZH 24.4.24 注销物流接口
//				if (connection2 != null && !connection2.isClosed()) {
//					connection2.close();
//				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}

	/***
	 * 结炉回退
	 * 
	 * @param jugeNo
	 * @param planId
	 * @return
	 */
	public CoreReturnObject cancelDoBeside(String jugeNo, String lotNo,
			String plineCode, String proPlanId, String gxPlanNo) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
//		TZH 24.4.24 注销物流接口
//		Connection connection2 = this.getDao("TmsDao").getConnection();
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		String HeatPlanNo = "";
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
//			TZH 24.4.24 注销物流接口
//			connection2.setAutoCommit(false); // 取消自动提交事务
			String cancelDoBesidesql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.cancelDoBeside"); // 结炉回退
			PreparedStatement cancelDoBeside = connection
					.prepareStatement(cancelDoBesidesql);

			String updateProcess = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.insertMilProcess");// 更新进程表mil_processes数据
			PreparedStatement updateMilProcess = connection
					.prepareStatement(updateProcess);

			/*
			 * String updatePlnZyZgM = CoreXmlSqlParsersFactory
			 * .getSql("FrmInOnlineStore.updatePlnZyZgM");// 更新计划表计划状态(等待更新使用)
			 * PreparedStatement updatePlnZyZgMPS = connection
			 * .prepareStatement(updatePlnZyZgM);
			 */
			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.selectNodeStaus");
			psta = connection.prepareStatement(sql);
			psta.setString(1, jugeNo);
			psta.setString(2, lotNo);
			psta.setString(3, plineCode);
			rs = psta.executeQuery();
			if (rs.next()) {
				HeatPlanNo = rs.getString("ID");
			}
			rs.close();
			psta.close();
			cancelDoBeside.setString(1, jugeNo);
			cancelDoBeside.setString(2, proPlanId);
			cancelDoBeside.setString(3, gxPlanNo);
			cancelDoBeside.addBatch();

			// 更新进程表mil_processes数据
			updateMilProcess.setString(1, jugeNo);
			updateMilProcess.setString(2, lotNo);
			updateMilProcess.setString(3, plineCode);
			updateMilProcess.setString(4, proPlanId);
			updateMilProcess.setString(5, gxPlanNo);
			updateMilProcess.addBatch();

			// 更新计划表计划状态
			/*
			 * updatePlnZyZgMPS.setString(1, jugeNo);
			 * updatePlnZyZgMPS.setString(2, plineCode);
			 * updatePlnZyZgMPS.setString(3, proPlanId);
			 * updatePlnZyZgMPS.setString(4, gxPlanNo);
			 * updatePlnZyZgMPS.addBatch();
			 */

			cancelDoBeside.executeBatch();
			updateMilProcess.executeBatch();
			// updatePlnZyZgMPS.executeBatch();
			// 运输需求
//			TZH 24.4.24 注销物流接口
//			updateTmsDemandM(connection, connection2, cro, jugeNo, HeatPlanNo,
//					"XX");
			if (cro.getV_errMsg().equals("")) {
				cro.setV_errMsg("结炉回退成功!");
			}
			connection.commit();
//			TZH 24.4.24 注销物流接口
//			connection2.commit();
		} catch (SQLException e) {
			System.out.println(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
//					TZH 24.4.24 注销物流接口
//					connection2.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
//			TZH 24.4.24 注销物流接口
//			if (connection2 != null) {
//				try {
//					connection.rollback(); // 回滚事务
//					connection2.rollback(); // 回滚事务
//				} catch (Exception e2) {
//				}
//			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
//				TZH 24.4.24 注销物流接口
//				if (connection2 != null && !connection2.isClosed()) {
//					connection2.close();
//				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}

	/***
	 * 查询已入库支数
	 * 
	 * @param conn
	 * @param jugeNo
	 * @param plineCode
	 * @return
	 * @throws Exception
	 */
	public int doQueryMatZcCount(Connection conn, String jugeNo,
			String plineCode) throws Exception {
		int count = 0;
		PreparedStatement psta = null;
		String sqlLovsqe = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.queryMatZcCount");
		psta = conn.prepareStatement(sqlLovsqe);
		psta.setString(1, jugeNo);
		psta.setString(2, plineCode);
		ResultSet rs = psta.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("ACOUNT"));
		}
		rs.close();
		psta.close();
		return count;
	}

	/***
	 * 查询轧管产出支数
	 * 
	 * @param conn
	 * @param jugeNo
	 * @param plineCode
	 * @return
	 * @throws Exception
	 */
	public int doQueryMilCount(Connection conn, String jugeNo, String plineCode)
			throws Exception {
		int count = 0;
		PreparedStatement psta = null;
		String sqlLovsqe = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.doQueryMilCount");
		psta = conn.prepareStatement(sqlLovsqe);
		psta.setString(1, jugeNo);
		psta.setString(2, plineCode);
		// psta.setString(3, jugeNo);
		// psta.setString(4, plineCode);
		// psta.setString(5, jugeNo);
		// psta.setString(6, plineCode);
		// psta.setString(7, jugeNo);
		// psta.setString(8, plineCode);
		ResultSet rs = psta.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("ACOUNT"));
		}
		rs.close();
		psta.close();
		return count;
	}

	/**
	 * 根据炉号、批号自动组号
	 * 
	 * @param conn
	 *            c
	 * @param strLcode
	 *            传递参数
	 * @return obj
	 * @throws Exception
	 *             异常处理
	 */
	public String queryGroupNo(Connection conn, String strLcode, String strBatch)
			throws Exception {
		int count = 0;
		String groupNo = "";
		PreparedStatement psta = null;
		String sqlLovsqe = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.queryGroupNo");
		psta = conn.prepareStatement(sqlLovsqe);
		psta.setString(1, strLcode);
		psta.setString(2, strBatch);
		ResultSet rs = psta.executeQuery();
		if (rs.next()) {
			// String res = rs.getString(1);
			// if (res == null) {
			// res = "001";
			// } else {
			// count = Integer.parseInt(res.substring(res.length() - 3, res
			// .length()));
			// }
			groupNo = rs.getString("BATCH_GROUD_NO");
		}
		rs.close();
		psta.close();
		// return StringTool.formatDecimal(++count, "000");
		return groupNo;
	}

	/**
	 * 每支材料对应的入库单号
	 * 
	 * @param conn
	 *            c
	 * @param strlist
	 *            传递参数
	 * @return obj
	 * @throws Exception
	 *             异常处理
	 */
	public String querySendSqlDoc(Connection conn, String strlist, String memo,
			String plineCode, String systime) throws Exception {
		int seq = 0;
		String inListDoc = "";
		PreparedStatement psta = null;
		Date dt = new Date();
		SimpleDateFormat matter1 = new SimpleDateFormat("yyyy-MM-dd");
		SimpleDateFormat matter2 = new SimpleDateFormat("yyMMdd");
		String sqlLovsqe = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.getInListDoc");
		psta = conn.prepareStatement(sqlLovsqe);
		psta.setString(1, memo);
		psta.setString(2, plineCode);
		psta.setString(3, systime);
		psta.setString(4, systime);
		// psta.setString(5, strlist);
		psta.setString(5, plineCode);
		ResultSet rs = psta.executeQuery();
		if (rs.next()) {
			// String res = rs.getString(1);
			// if (res == null) {
			// res = memo + plineCode + matter2.format(dt) + "00001";
			// } else {
			// //seq = Integer.parseInt(res.substring(8, 13));
			// seq = Integer.parseInt(res.substring(12, 17));
			// }
			inListDoc = rs.getString("INSTOCK_DOC");
		}
		rs.close();
		psta.close();
		// return memo + plineCode + matter2.format(dt)
		// + StringTool.formatDecimal(++seq, "00000");
		return inListDoc;
	}

	/**
	 * 每支材料对应的入库流水号
	 * 
	 * @param conn
	 *            c
	 * @param strlist
	 *            传递参数
	 * @return obj
	 * @throws Exception
	 *             异常处理
	 */
	public String querySendSql(Connection conn, String strlist, String plineCode)
			throws Exception {
		int seq = 0;
		String inListDocSeq = "";
		PreparedStatement psta = null;
		Date dt = new Date();
		SimpleDateFormat matter1 = new SimpleDateFormat("yyyy-MM-dd");
		String sqlLovsqe = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.getInListDoc1");
		psta = conn.prepareStatement(sqlLovsqe);
		psta.setString(1, strlist);
		psta.setString(2, strlist);
		ResultSet rs = psta.executeQuery();
		if (rs.next()) {
			// String res = rs.getString(1);
			// if (res == null) {
			// res = strlist + "0001";
			// } else {
			// //seq = Integer.parseInt(res.substring(13, 17));
			// seq = Integer.parseInt(res.substring(17, 21));
			// }
			inListDocSeq = rs.getString("INSTOCK_SQE");
		}
		rs.close();
		psta.close();
		// return strlist + StringTool.formatDecimal(++seq, "0000");
		return inListDocSeq;
	}

	/**
	 * 余材合同号生成
	 * 
	 * @param conn
	 *            c
	 * @param strlist
	 *            传递参数
	 * @return obj
	 * @throws Exception
	 *             异常处理
	 */
	public String querySurplusOrderNo(Connection conn, String plineCode)
			throws Exception {
		int seq = 0;
		String proOrderNo = "";
		PreparedStatement psta = null;
		Date dt = new Date();
		SimpleDateFormat matter1 = new SimpleDateFormat("yyyy-MM-dd");
		String sqlLovsqe = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.querySurplusOrderNo");
		psta = conn.prepareStatement(sqlLovsqe);
		psta.setString(1, plineCode);
		psta.setString(2, plineCode);
		ResultSet rs = psta.executeQuery();
		if (rs.next()) {
			proOrderNo = rs.getString("PRO_ORDER_NO");
		}
		rs.close();
		psta.close();
		return proOrderNo;
	}

	/**
	 * 根据炉号、批号自动生成材料号
	 * 
	 * @param conn
	 *            c
	 * @param strLcode
	 *            传递参数
	 * @return obj
	 * @throws Exception
	 *             异常处理
	 */
	public String queryMatNoM(Connection conn, String strLcode, String strBatch)
			throws Exception {
		int count = 0;
		String matNo = "";
		PreparedStatement psta = null;
		String sqlLovsqe = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.queryMatNoM");
		psta = conn.prepareStatement(sqlLovsqe);
		psta.setString(1, strLcode);
		psta.setString(2, strBatch);
		psta.setString(3, strLcode);
		psta.setString(4, strBatch);
		psta.setString(5, strLcode);
		psta.setString(6, strBatch);
		psta.setString(7, strLcode);
		psta.setString(8, strBatch);
		ResultSet rs = psta.executeQuery();
		if (rs.next()) {
			// String res = rs.getString(1);
			// if (res == null) {
			// res = strLcode + strBatch + "0001";
			// } else {
			// count = Integer.parseInt(res.substring(res.length() - 4, res
			// .length()));
			// }
			matNo = rs.getString("MAT_NO");
		}
		rs.close();
		psta.close();
		// return (strLcode + strBatch)
		// + StringTool.formatDecimal(++count, "0000");
		return matNo;
	}

	/***
	 * 根据产线找在线库信息
	 * 
	 * @param plineCode
	 * @return
	 */
	public CoreReturnObject doQueryStoreNo(String plineCode) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryStoreNo",
				new Object[] { plineCode });
	}

	/**
	 * 根据产线,炉号找仓库信息
	 * 
	 * @param plineCode
	 * @param jugeStove
	 * @return
	 */
	public CoreReturnObject doQueryStoreNo(String plineCode, String jugeStove) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryStoreNo2",
				new Object[] { plineCode, jugeStove });
	}

	/**
	 * 根据产线查找科室
	 * 
	 * @param plineCode
	 * @return
	 */
	public CoreReturnObject doQueryDept(String plineCode) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryDept",
				new Object[] { plineCode });
	}

	/***
	 * 查询轧管管号队列进程
	 * 
	 * @return
	 */
	public CoreReturnObject doQueryProcess(ArrayList<String> list) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryProcess", list
				.toArray());
	}

	/***
	 * 查询轧管队列进程炉信息
	 * 
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryJugeNoProcess(ArrayList<String> list) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryJugeNoProcess",
				list.toArray());
	}

	/***
	 * 查询是否有未送判的数据
	 * 
	 * @param jugeNo
	 * @return
	 */
	public CoreReturnObject doQueryApplyCodeNull(String jugeNo,
			String departMent, String plineCode) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryApplyCodeNull",
				new Object[] { jugeNo, departMent, plineCode });
	}

	/***
	 * 查询该炉是已全部入库
	 * 
	 * @param jugeNo
	 * @return
	 */
	public CoreReturnObject doQueryJugeNoApply(String jugeNo) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryJugeNoApply",
				new Object[] { jugeNo });
	}

	/***
	 * 获取所有实物库
	 * 
	 * @return
	 */
	public CoreReturnObject getStoreNo(String deptid) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.getStoreNo");
		return this.getData(sql, new Object[] { deptid });
	}

	/***
	 * \ 交库时剔除
	 * 
	 * @param matNo
	 * @param jugeNo
	 * @return
	 */
	public CoreReturnObject updateStatus(String portEntity, String userName,
			String colGroup, String colOrder) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		String nodeStaus = "";
		int acount = 0;
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String updateStaus = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.updateStatus");

			PortMilBatchSampleResultEntity portTity = EntityTool
					.getEntityByJSONStr(portEntity,
							PortMilBatchSampleResultEntity.class);
			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.SelectNodeStatus");
			psta = connection.prepareStatement(sql);
			psta.setString(1, portTity.getJudgeStoveNo());
			rs = psta.executeQuery();
			if (rs.next()) {
				nodeStaus = rs.getString("NODE_STATUS");
			}
			rs.close();
			psta.close();
			if (!nodeStaus.equals("96")) {
				cro.setV_errMsg("人工质检未结炉或者交库已结炉不允许进行钢管剔除!");
				return cro;
			}

			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.SelectMilInstore");
			psta = connection.prepareStatement(sql);
			psta.setString(1, portTity.getJudgeStoveNo());
			rs = psta.executeQuery();
			if (rs.next()) {
				acount = Integer.parseInt(rs.getString("ACOUNT"));
			}
			rs.close();
			psta.close();
			if (acount > 0) {

			} else {
				cro.setV_errMsg("请先开始交库下线或者离线之后再进行剔除!");
				return cro;
			}

			updateStaus = EntityTool.fillSqlByEntity(updateStaus, portTity);
			updateStaus = updateStaus.replace("#COL_USER#", userName).replace(
					"#COL_GROUP#", colGroup).replace("#COL_SHIFT#", colOrder);
			PreparedStatement updateStausPsta = connection
					.prepareStatement(updateStaus);
			updateStausPsta.addBatch();
			updateStausPsta.executeBatch();
			cro.setV_errMsg("剔除成功!");
			connection.commit();

		} catch (SQLException e) {
			System.out.println(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}

	/***
	 * \ 交库时修改长度
	 * 
	 * @param matNo
	 * @param jugeNo
	 * @return
	 */
	public CoreReturnObject updateLen(ArrayList<String> parm, String userName,
			String colGroup, String colOrder) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		String nodeStaus = "";
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			for (String str : parm) {
				String updateStaus = CoreXmlSqlParsersFactory
						.getSql("FrmInOnlineStore.updateLen");
				PortMilBatchSampleResultEntity portTity = EntityTool
						.getEntityByJSONStr(str,
								PortMilBatchSampleResultEntity.class);
				updateStaus = EntityTool.fillSqlByEntity(updateStaus, portTity);
				PreparedStatement updateStausPsta = connection
						.prepareStatement(updateStaus);
				updateStausPsta.executeUpdate();
			}
			cro.setV_errMsg("修改成功!");
			connection.commit();

		} catch (SQLException e) {
			System.out.println(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}

	/***
	 * 剔除回退
	 * 
	 * @param portEntity
	 * @return
	 */
	public CoreReturnObject updateStatusBack(String portEntity) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		String nodeStaus = "";
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String updateStaus = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.updateStatusBack");

			PortMilBatchSampleResultEntity portTity = EntityTool
					.getEntityByJSONStr(portEntity,
							PortMilBatchSampleResultEntity.class);
			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.SelectNodeStatus");
			psta = connection.prepareStatement(sql);
			psta.setString(1, portTity.getJudgeStoveNo());
			rs = psta.executeQuery();
			if (rs.next()) {
				nodeStaus = rs.getString("NODE_STATUS");
			}
			rs.close();
			psta.close();
			if (nodeStaus.equals("99")) {
				cro.setV_errMsg("交库已结炉,不允许进行剔除回退!");
				return cro;
			}
			updateStaus = EntityTool.fillSqlByEntity(updateStaus, portTity);
			PreparedStatement updateStausPsta = connection
					.prepareStatement(updateStaus);
			updateStausPsta.addBatch();
			updateStausPsta.executeBatch();
			cro.setV_errMsg("回退成功!");
			connection.commit();

		} catch (SQLException e) {
			System.out.println(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}

	/***
	 * 查询是否存在样管
	 * 
	 * @return
	 */
	public CoreReturnObject doQuerySampleNum(String jugeNo, String plineCode,
			String proPlanId, String gxPlanNo) {
		return this.getDataBySqlID("FrmInOnlineStore.doQuerySampleNum",
				new Object[] { jugeNo, plineCode, proPlanId, gxPlanNo });
	}

	/***
	 * 查询该炉是否已结炉
	 * 
	 * @param jugeNo
	 * @return
	 */
	public CoreReturnObject doQueryNode(String jugeNo, String plineCode) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryNode",
				new Object[] { jugeNo, plineCode });
	}

	/***
	 * 查询是否有已申请判定数据
	 * 
	 * @param jugeNo
	 * @return
	 */
	public CoreReturnObject doQueryFApply(String jugeNo) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryFApply",
				new Object[] { jugeNo, jugeNo });
	}

	/**
	 * 查询是否有复取样废品
	 * 
	 * @param jugeNo
	 * @return
	 */
	public CoreReturnObject doQueryFQY(String jugeNo) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryFQY",
				new Object[] { jugeNo });
	}

	/***
	 * 调整重量
	 * 
	 * @param jugeNo
	 * @param wgt
	 * @return
	 */
	public CoreReturnObject adjustWgt(String jugeNo, String wgt) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String updateWgtSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.adjustWgt");// 调整理论重量
			PreparedStatement updateWgtPsta = connection
					.prepareStatement(updateWgtSql);

			updateWgtPsta.setString(1, wgt);
			updateWgtPsta.setString(2, jugeNo);
			updateWgtPsta.addBatch();

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

	/***
	 * 查询待处理库存信息
	 * 
	 * @return
	 */
	public CoreReturnObject queryXMat(String jugeNo, String plineCode,
			String departMentId) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.queryXMat");
		sql += " AND T1.BELONG_CODE = '" + departMentId + "'";
		sql += " GROUP BY T1.JUDGE_STOVE_NO, T1.BATCH_NO, T1.BATCH_GROUD_NO,T1.LOT_NO,T1.PRODUCCODE,T1.PRODUCNAME,T1.STEELCODE,T1.STEELNAME,T1.SPEC_CODE,T1.SPEC_NAME,T1.MODEL_CODE,T1.GRADECODE,T1.GRADENAME,T1.STD_STYLE,T1.STD_STYLE_DESC,T1.PIPMEMO,T1.MAT_STATUS,";
		sql += " T1.MODEL_DESC,T1.STD_CODE,T1.STD_NAME,T1.ORDER_NO,T1.ORDER_SEQ,T1.ORDER_SEQ_NO,T1.ACT_DIMATER,T1.ACT_HEIGHT,T1.BELONG_CODE,T1.BELONG_NAME,T1.PLINE_CODE,T1.PLINE_NAME,T1.BAL_YEAR_MONTH,T1.MATERIAL_NO,T1.MATERIAL_NAME,T1.FLAG_STOVE_NO_ZG,";
		sql += " T1.ACT_LEN_MIN,T1.ACT_LEN_MAX,T1.CREATE_NAME,T2.STORAGE_NO,S.STORAGE_NAME,T1.MEMO,T1.PRODUCT_FLAG,T1.JUDGE_STD_DES,T1.JUDGE_STD_NAME ORDER BY T1.BAL_YEAR_MONTH DESC";
		return this.getData(sql, new Object[] { jugeNo, plineCode });
	}

	/***
	 * 修改标识炉号
	 * 
	 * @param parm
	 * @return
	 */
	public CoreReturnObject updateFlagStove(ArrayList<String> parm) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String updateFlagStoveNoSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.updateFlagStove");
			PreparedStatement updateFlagStoveNoPsta = connection
					.prepareStatement(updateFlagStoveNoSql);
			for (String str : parm) {
				MatZcMEntity matZcTity = EntityTool.getEntityByJSONStr(str,
						MatZcMEntity.class);
				updateFlagStoveNoPsta
						.setString(1, matZcTity.getFlagStoveNoZg());
				updateFlagStoveNoPsta.setString(2, matZcTity.getJudgeStoveNo());
				updateFlagStoveNoPsta.setString(3, matZcTity.getBatchNo());
				updateFlagStoveNoPsta.setString(4, matZcTity.getBatchGroudNo());
				updateFlagStoveNoPsta.addBatch();
			}
			updateFlagStoveNoPsta.executeBatch();
			cro.setV_errMsg("修改成功!");
			connection.commit();
		} catch (SQLException e) {
			System.out.println(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}

	/***
	 * 查询待处理出库记录
	 * 
	 * @param jugeNo
	 * @param outDoc
	 * @param plineCode
	 * @param departMentId
	 * @return
	 */
	public CoreReturnObject queryXOut(String jugeNo, String outDoc,
			String plineCode, String departMentId) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.queryXOut");
		sql += " AND T.BELONG_CODE = '" + departMentId + "'";

		sql += " group by T.BAL_YEAR_MONTH,T.JUDGE_STOVE_NO,T.BATCH_NO,T.BATCH_GROUD_NO,T.MATERIAL_NO,T.MATERIAL_NAME,T.PRODUCCODE,T.PRODUCNAME,";
		sql += "T.STD_CODE,T.STD_NAME,T.GRADECODE,T.GRADENAME,T.STEELCODE,T.STEELNAME,T.STD_STYLE,T.STD_STYLE_DESC,T.SPEC_CODE,T.SPEC_NAME,T.MODEL_CODE,T.MODEL_DESC,T.PLINE_CODE,";
		sql += "T.PLINE_NAME, T.ACT_DIMATER,T.ACT_HEIGHT,T.ACT_LEN,T.ACT_LEN_MIN,T.ACT_LEN_MAX,T.BELONG_CODE,T.BELONG_NAME,T.STORAGE_NO,T.PRO_ORDER_NO,";

		sql += " T.ORD_PK,T.ORD_LN_PK,T.ORD_LN_DLY_PK,";
		sql += "T.ORDER_NO,T.ORDER_SEQ,T.DELIVERY_NO,T.JUDGE_STD_NAME,T.JUDGE_STD_CODE,T.PONDER_NO,T.OUTSTOCK_PLAN_NO,T.OUTSTOCK_DOC,T.OUTSTOCK_TYPE_CODE,T.OUTSTOCK_TYPE_NAME,T.VEHICLE_NO,s.storage_name";
		return this.getData(sql, new Object[] { jugeNo, outDoc, plineCode });
	}

	/***
	 * 撤销待处理出库记录
	 * 
	 * @param parm
	 * @return
	 */
	public CoreReturnObject cancelOutList(ArrayList<String> parm) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String deleteOutListSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.cancelOutList");
			PreparedStatement deleteOutListPsta = connection
					.prepareStatement(deleteOutListSql);
			for (String str : parm) {
				YdmZcOutlistEntity outListTity = EntityTool.getEntityByJSONStr(
						str, YdmZcOutlistEntity.class);
				deleteOutListPsta.setString(1, outListTity.getOutstockDoc());
				deleteOutListPsta.setInt(2, Integer.parseInt(outListTity
						.getActCount()));
				deleteOutListPsta.addBatch();
			}
			deleteOutListPsta.executeBatch();
			cro.setV_errMsg("撤销成功!");
			connection.commit();
		} catch (SQLException e) {
			System.out.println(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}

	/***
	 * 修改成分结果
	 * 
	 * @param jugeNo
	 * @return
	 */
	public CoreReturnObject updateChemResult(String jugeNo) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String updateChemResultSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.updateChemResult");
			PreparedStatement updateChemResultPsta = connection
					.prepareStatement(updateChemResultSql);
			updateChemResultPsta.setString(1, "40740101");
			updateChemResultPsta.setString(2, jugeNo);
			updateChemResultPsta.addBatch();

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

	/***
	 * 修改理化结果
	 * 
	 * @param jugeNo
	 * @return
	 */
	public CoreReturnObject updatePhyResult(String jugeNo, String bathNo) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String updatePhyResultSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.updatePhyResult");
			PreparedStatement updatePhyResultPsta = connection
					.prepareStatement(updatePhyResultSql);
			updatePhyResultPsta.setString(1, "40740201");
			updatePhyResultPsta.setString(2, jugeNo);
			updatePhyResultPsta.setString(3, bathNo);
			updatePhyResultPsta.addBatch();

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

	/***
	 * 查询该炉批组信息是否完整
	 * 
	 * @return
	 */
	public CoreReturnObject doQueryResult(String jugeNo, String bathNo,
			String groupNo, String target) {
		if (target.equals("C")) {
			return this.getDataBySqlID("FrmInOnlineStore.doQueryResult1",
					new Object[] { jugeNo, bathNo, groupNo });
		} else {
			return this.getDataBySqlID("FrmInOnlineStore.doQueryResult",
					new Object[] { jugeNo, bathNo, groupNo });
		}
	}

	/***
	 * 查询探伤实绩
	 * 
	 * @param jugeNo
	 * @param plineCode
	 * @return
	 */
	public CoreReturnObject doQueryTestingResult(String jugeNo, String plineCode) {
		if (plineCode.equals("C008") || plineCode.equals("C009")
				|| plineCode.equals("C017") || plineCode.equals("C072")) {
			return this.getDataBySqlID("doQueryTestingResult.EMI",
					new Object[] { jugeNo, jugeNo });
		} else if (plineCode.equals("C010")) {
			return this.getDataBySqlID("doQueryTestingResult.ET", new Object[] {
					jugeNo, jugeNo });
		} else {
			return null;
		}

	}

	/***
	 * 修改探伤等级和探伤种类
	 * 
	 * @param jugeNo
	 * @return
	 */
	public CoreReturnObject updateTestingResult(String jugeNo,
			String testingGrade, String testingType) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String updatePhyResultSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.updateMatTestResult");
			PreparedStatement updatePhyResultPsta = connection
					.prepareStatement(updatePhyResultSql);
			updatePhyResultPsta.setString(1, testingGrade);
			updatePhyResultPsta.setString(2, testingType);
			updatePhyResultPsta.setString(3, jugeNo);
			updatePhyResultPsta.addBatch();

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

	/***
	 * 查询炉计划去向
	 * 
	 * @param jugeNo
	 * @return
	 */
	public CoreReturnObject doQueryMilPlan(String jugeNo, String proPlanId,
			String gxPlanNo) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryMilPlan",
				new Object[] { jugeNo, proPlanId, gxPlanNo });
	}

	/**
	 * 交库前验证：查进程表是否取样，材料表是否有样管交库
	 * 
	 * @param jugeNo
	 * @param proPlanId
	 * @param gxPlanNo
	 * @return
	 */
	public CoreReturnObject doQueryPortMilState(String jugeNo,
			String proPlanId, String gxPlanNo) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryPortMilState",
				new Object[] { jugeNo, proPlanId, gxPlanNo, jugeNo, proPlanId,
						gxPlanNo });
	}

	/***
	 * 查询附加要求码
	 * 
	 * @return
	 */
	public CoreReturnObject doQueryOrderAsk(String orderNo) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryOrderAsk",
				new Object[] { orderNo });
	}

	/***
	 * 修改过磅标识
	 * 
	 * @return
	 */
	public CoreReturnObject doUpdatePrn(String jugeNo, String chkPrnFlag) {
		return this.setDataBySqlID("FrmInOnlineStore.doUpdatePrn",
				new Object[] { chkPrnFlag, jugeNo.replaceFirst("-.*", "") });
	}

	/***
	 * 查询计划是否过磅
	 * 
	 * @param jugeNo
	 * @return
	 */
	public CoreReturnObject doQueryMilPlanPrt(String jugeNo) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryMilPlanPrt",
				new Object[] { jugeNo });
	}

	/***
	 * 获取对应支数重量
	 * 
	 * @return
	 */
	public CoreReturnObject doQueryWgt(String jugeNo, Integer num,
			String stausFlag, String isSampleFlag) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryWgt", new Object[] {
				jugeNo, stausFlag, isSampleFlag, num });
	}

	/***
	 * 查询对应的目标外径、控制壁厚
	 * 
	 * @param jugeNo
	 * @return
	 */
	public CoreReturnObject doQueryThickDs(String jugeNo) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryThickDs",
				new Object[] { jugeNo });
	}

	/***
	 * 查询是否存在待处理品
	 * 
	 * @return
	 */
	public CoreReturnObject doQueryOfflineCount(String jugeNo) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryOfflineCount",
				new Object[] { jugeNo });
	}

	/**
	 * 查询工序合同号
	 * 
	 * @param jugeNo
	 * @return
	 */
	public CoreReturnObject doQueryZgContratNo(String jugeNo) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryZgContratNo",
				new Object[] { jugeNo });
	}
	
	/**
	 * 查询成品可送判支
	 * @param jugeNo
	 * @param plineCode
	 * @return
	 */
	public CoreReturnObject doQueryBjCount(String jugeNo,String plineCode ) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryBjCount",
				new Object[] { jugeNo,plineCode,jugeNo,plineCode });
	}

	/**
	 * 查询是否过磅
	 * 
	 * @param jugeNo
	 * @return
	 */
	public CoreReturnObject doQueryZgPrtFlag(String jugeNo) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryZgPrtFlag",
				new Object[] { jugeNo });
	}

	/**
	 * 查询过磅重量
	 * 
	 * @param jugeNo
	 * @return
	 */
	public CoreReturnObject doQueryZgPonderGrossWT(String jugeNo) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryZgPonderGrossWT",
				new Object[] { jugeNo });
	}

	/***
	 * C字头同炉 同生产合同号不允许申请判定
	 * 
	 * @param jugeNo
	 * @param proOrderNo
	 * @return
	 */
	public CoreReturnObject doQueryZgJugdeCount(String jugeNo, String proOrderNo) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryZgJugdeCount",
				new Object[] { jugeNo, proOrderNo });
	}

	/***
	 * 查询超声探伤等级
	 * 
	 * @return
	 */
	public CoreReturnObject getTestGrade() {
		return this.getDataBySqlID("FrmInOnlineStore.getTestGrade");
	}

	/**
	 * 调整库去向
	 * 
	 * @param judgeStoveNo
	 * @param lotNo
	 * @param pline
	 * @param storeNo
	 * @param storeName
	 * @return
	 */
	public CoreReturnObject updateQuXiang(String judgeStoveNo, String lotNo,
			String pline, String storeNo, String storeName) {

		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();

		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String updateWgtSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.updateQuXiang");// 调整库去向
			PreparedStatement updateWgtPsta = connection
					.prepareStatement(updateWgtSql);

			updateWgtPsta.setString(1, storeNo);
			updateWgtPsta.setString(2, storeName);
			updateWgtPsta.setString(3, judgeStoveNo);
			updateWgtPsta.setString(4, lotNo);
			updateWgtPsta.setString(5, pline);
			updateWgtPsta.addBatch();

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

	/**
	 * 调整投料量
	 * 
	 * @param list
	 * @return
	 */
	public CoreReturnObject updateInputWt(ArrayList<String> list) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String sql = "";
		PreparedStatement psta = null;
		int count = 0;
		ResultSet rs = null;
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String updateWgtSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.updateInputWt");// 调整投料量
			PreparedStatement updateWgtPsta = connection
					.prepareStatement(updateWgtSql);

			String JugdeApplyCode = list.get(0);
			String JugdeApplySequeno = list.get(1);
			String JudgeStoveNo = list.get(2);
			String BatchNo = list.get(3);
			String BatchGroudNo = list.get(4);
			int InputCount = Integer.parseInt(list.get(5));
			float InputWeight = Float.parseFloat(list.get(6));
			String userName = list.get(7);

			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.doQueryIsCarryVoer");// 查询是否结转
			psta = connection.prepareStatement(sql);
			psta.setString(1, JugdeApplyCode);
			psta.setString(2, JugdeApplySequeno);
			psta.setString(3, JudgeStoveNo);
			psta.setString(4, BatchNo);
			psta.setString(5, BatchGroudNo);
			rs = psta.executeQuery();
			if (rs.next()) {
				count = Integer.parseInt(rs.getString("ACOUNT"));
			}
			rs.close();
			psta.close();
			if (count > 0) {
				cro.setV_errMsg("此炉批已结转，不允许调整重量!");
				return cro;
			}

			updateWgtPsta.setString(1, JugdeApplyCode);
			updateWgtPsta.setString(2, JugdeApplySequeno);
			updateWgtPsta.setString(3, JudgeStoveNo);
			updateWgtPsta.setString(4, BatchNo);
			updateWgtPsta.setString(5, BatchGroudNo);
			updateWgtPsta.setInt(6, InputCount);
			updateWgtPsta.setFloat(7, InputWeight);
			updateWgtPsta.setString(8, userName);
			updateWgtPsta.addBatch();

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

	/***
	 * 查询委外超声探伤等级
	 * 
	 * @param jugeNo
	 * @return
	 */
	public CoreReturnObject doQueryEntrustT(String jugeNo, String proPlanId,
			String gxPlanNo) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryEntrustT",
				new Object[] { jugeNo, proPlanId, gxPlanNo });
	}

	/***
	 * 查询样管是否都已交库
	 * 
	 * @param jugeNo
	 * @return
	 */
	// public CoreReturnObject doQueryPortSlample(String jugeNo)
	// {
	// return this.getDataBySqlID("FrmInOnlineStore.doQueryPortSlample", new
	// Object[]{jugeNo});
	// }
	/***
	 * 修改去向
	 */
	public CoreReturnObject updateTarget(ArrayList<String> parm) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String sql = "";
		PreparedStatement psta = null;
		String nodeFlag = "0";
		int count = 0;
		ResultSet rs = null;

		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String updateTargetSql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.updateTarget");// 修改去向
			PreparedStatement updateTargetPsta = connection
					.prepareStatement(updateTargetSql);
			for (String str : parm) {
				MatZcMEntity matZcTity = EntityTool.getEntityByJSONStr(str,
						MatZcMEntity.class);
				sql = CoreXmlSqlParsersFactory
						.getSql("FrmInOnlineStore.doQueryMilInstoreResultNode");
				psta = connection.prepareStatement(sql);
				psta.setString(1, matZcTity.getJudgeStoveNo());
				rs = psta.executeQuery();
				if (rs.next()) {
					count = Integer.parseInt(rs.getString("ACOUNT"));
				}
				rs.close();
				psta.close();
				if (count > 0) {
					cro.setV_errMsg("此炉在下线点有未结炉不允许修改去向!");
					return cro;
				}

				sql = CoreXmlSqlParsersFactory
						.getSql("FrmInOnlineStore.SelectQcmAppleJuge");
				psta = connection.prepareStatement(sql);
				psta.setString(1, matZcTity.getJudgeStoveNo());
				rs = psta.executeQuery();
				if (rs.next()) {
					count = Integer.parseInt(rs.getString("ACOUNT"));
				}
				rs.close();
				psta.close();
				if (count > 0) {
					cro.setV_errMsg("此炉已有申请判的信息不允许修改去向!");
					return cro;
				}

				updateTargetPsta.setString(1, matZcTity.getTarget());
				if (matZcTity.getTarget().equals("A")) {
					updateTargetPsta.setString(2, "801402");
					updateTargetPsta.setString(3, "80150201");
				} else {
					updateTargetPsta.setString(2, "801401");
					updateTargetPsta.setString(3, "80150101");
				}
				updateTargetPsta.setString(4, matZcTity.getJudgeStoveNo());
				updateTargetPsta.addBatch();
			}
			updateTargetPsta.executeBatch();
			cro.setV_errMsg("修改成功!");
			connection.commit();
		} catch (SQLException e) {
			System.out.println(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}

	/***
	 * 当前年月下一个月
	 * 
	 * @param date
	 * @return
	 */
	private static Date getLastDate(Date date) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		cal.add(Calendar.MONTH, 1);
		return cal.getTime();
	}

	/***
	 * 查询改炉合格支数
	 * 
	 * @return
	 */
	public CoreReturnObject doQueryPortCount(String jugeNo, String lotNo,
			String id) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryPortCount",
				new Object[] { jugeNo, lotNo, id });
	}

	/***
	 * 查询已交库支数
	 * 
	 * @return
	 */
	public CoreReturnObject doQueryPipeCount(String jugeNo, String lotNo,
			String id) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryPipeCount",
				new Object[] { jugeNo, lotNo, jugeNo, lotNo });
	}

	/***
	 * 查询交库点已离线支数
	 * 
	 * @return
	 */
	public CoreReturnObject doQueryPipeLXCount(String jugeNo, String lotNo,
			String id) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryPipeLXCount",
				new Object[] { id, jugeNo });
	}

	/***
	 * 查询管捆信息
	 * 
	 * @param jugeNo
	 * @return
	 */
	public CoreReturnObject doQueryJugeMemo(String jugeNo) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryJugeMemo",
				new Object[] { jugeNo });
	}

	/**
	 * 查询外委数据进程表库号
	 * 
	 * @param jugeNo
	 * @param plineCode
	 * @return
	 */
	public CoreReturnObject doQueryPortStoreNo(String jugeNo, String plineCode) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryPortStoreNo",
				new Object[] { jugeNo, plineCode });
	}

	/**
	 * 验证数据平衡
	 * 
	 * @param jugeNo
	 * @param proOrderId
	 * @param gxPlanNo
	 * @return
	 */
	public CoreReturnObject doQueryMilProcess(String jugeNo, String proOrderId,
			String gxPlanNo) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryMilProcess",
				new Object[] { jugeNo, proOrderId, gxPlanNo });
	}

	/**
	 * 更新进程表mil_processes数据
	 * 
	 * @param enMilPlan
	 * @return
	 */
	public CoreReturnObject updateProcess(
			com.steering.mes.zgmil.entity.MilPlan enMilPlan) {
		ArrayList<String> sqllist = new ArrayList<String>();
		// 更新进程表mil_processes数据
		String updateProcess = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.insertMilProcess2");
		updateProcess = EntityTool.fillSqlByEntity(updateProcess, enMilPlan);
		sqllist.add(updateProcess);
		return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(
				sqllist);
	}

	/**
	 * 验证是不是组炉炉号
	 * 
	 * @param jugeNo
	 * @param plineCode
	 * @return
	 */
	public CoreReturnObject doQueryZpJudgeStoveNo(String jugeNo,
			String plineCode) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryZpJudgeStoveNo",
				new Object[] { jugeNo, plineCode });
	}

	/**
	 * 查询组炉炉的送判信息
	 * 
	 * @param jugeNo
	 * @param plineCode
	 * @return
	 */
	public CoreReturnObject doQueryZpMLh(String jugeNo, String plineCode) {
		return this.getDataBySqlID("FrmInOnlineStore.doQueryZpMLh",
				new Object[] { jugeNo, plineCode });
	}

	/**
	 * 查询合同附加要求信息 （QCM_ADD_ASK）
	 * 
	 * @param JugdeApplyCode
	 * @param JudgeStoveNo
	 * @return
	 */
	public CoreReturnObject QueryQcmAddAsk(String JugdeApplyCode,
			String JudgeStoveNo) {
		return this.getDataBySqlID("FrmInOnlineStore.QueryQcmAddAsk",
				new Object[] { JugdeApplyCode, JudgeStoveNo });
	}

	/**
	 * 查询合同附加要求信息 （CRAFT_ORD_DESIGN_ADD_ASK）
	 * 
	 * @param ProOrderNo
	 * @return
	 */
	public CoreReturnObject QueryQcmAddAsk(String ProOrderNo) {
		return this.getDataBySqlID("FrmInOnlineStore.QueryQcmAddAsk2",
				new Object[] { ProOrderNo });
	}

	/**
	 * 新增合同附加要求信息 （QCM_ADD_ASK）
	 * 
	 * @param arrayList
	 * @return
	 */
	public CoreReturnObject insertQcmAddAsk(ArrayList<String> arrayList) {
		ArrayList<String> sqllist = new ArrayList<String>();
		String sql = "";
		for (int i = 0; i < arrayList.size(); i++) {
			sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.insertQcmAddAsk");
			QcmAddAskEntity qcmAddAskEntity = EntityTool.getEntityByJSONStr(
					arrayList.get(i), QcmAddAskEntity.class);
			sql = EntityTool.fillSqlByEntity(sql, qcmAddAskEntity);
			sqllist.add(sql);
		}
		return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(
				sqllist);
	}

	/**
	 * 运输需求
	 * 
	 * @param connection
	 * @param connection2
	 * @param core
	 * @param JudgeStoveNo
	 * @param HeatPlanNo
	 * @param flag
	 * @return
	 * @throws SQLException
	 */
	public CoreReturnObject updateTmsDemandM(Connection connection,
			Connection connection2, CoreReturnObject core, String JudgeStoveNo,
			String HeatPlanNo, String flag) throws SQLException {
		PreparedStatement psta = null;
		ResultSet rs = null;
		String sql = "";
		String actCount = "";// 下线支数
		float actWeight = 0;// 下线重量
		String actCountScrap = "";// 废品支数
		float actWeightScrap = 0;// 废品重量
		String prtFlag = "0";// 过磅标识(0否/1是)

		sql = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.selectTmsDemandM");// 查询下线的支、吨
		psta = connection.prepareStatement(sql);
		psta.setString(1, JudgeStoveNo);
		psta.setString(2, HeatPlanNo);
		psta.setString(3, JudgeStoveNo);
		psta.setString(4, HeatPlanNo);
		rs = psta.executeQuery();
		if (rs.next()) {
			actCount = rs.getString("ACT_COUNT");
			actWeight = Float.parseFloat(rs.getString("ACT_WEIGHT"));
		}
		rs.close();
		psta.close();
		sql = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.selectTmsScrap");// 查询废品支、吨
		psta = connection.prepareStatement(sql);
		psta.setString(1, HeatPlanNo);
		rs = psta.executeQuery();
		if (rs.next()) {
			actCountScrap = rs.getString("actCountScrap");
			actWeightScrap = Float.parseFloat(rs.getString("actWeightScrap"));
		}
		rs.close();
		psta.close();

		sql = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.selectTmsPrtFlag");// 查询过磅标识
		psta = connection.prepareStatement(sql);
		psta.setString(1, HeatPlanNo);
		psta.setString(2, JudgeStoveNo);
		rs = psta.executeQuery();
		if (rs.next()) {
			prtFlag = rs.getString("PRT_FLAG");
		}
		rs.close();
		psta.close();

		String updateOff = CoreXmlSqlParsersFactory
				.getSql("FrmInOnlineStore.UpdateTmsDemandM");// 更新运输需求
		PreparedStatement pstaupdateOff = connection2
				.prepareStatement(updateOff);
		pstaupdateOff.setString(1, actCount);
		pstaupdateOff.setFloat(2, actWeight);
		pstaupdateOff.setString(3, JudgeStoveNo);
		pstaupdateOff.setString(4, HeatPlanNo);
		pstaupdateOff.setString(5, flag);
		pstaupdateOff.setString(6, actCountScrap);
		pstaupdateOff.setFloat(7, actWeightScrap);
		pstaupdateOff.setString(8, prtFlag);
		pstaupdateOff.addBatch();
		pstaupdateOff.executeBatch();
		return core;
	}
	
	
	/**
	 * 离线管理查询
	 * @param judgeStoveNo
	 * @param date
	 * @param endDate
	 * @param Factory
	 * @return
	 */
	public CoreReturnObject QueryOfflineProcess(String jugeNo, String startTim,
			String endTim, String plineCode, String isAudit,String reason,String orderno,String lxStartTime, String lxEndTime) {
		String sql = "";
		sql = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.QueryOfflineProcess");
		if (!startTim.equals("")) {
			sql += " AND T.OFFLINE_TIME BETWEEN TO_DATE('" + startTim
					+ "' ,'YYYY-MM-DD HH24:MI:SS') AND TO_DATE('" + endTim
					+ "' ,'YYYY-MM-DD HH24:MI:SS') ";
		} 
		if (!jugeNo.equals("")) {
			sql += "  AND T.JUDGE_STOVE_NO = '" + jugeNo + "' ";
		}
		
		if (!plineCode.equals("")) {
			sql += " AND T.PLINE_CODE  IN ('"
					+ plineCode + "') ";
		}
		if(!"".equals(isAudit)){
			sql += " AND T.IS_AUDIT = '"+isAudit+"' ";
				}
		if(!"".equals(reason)){
			sql += " AND T.REASON1 LIKE '%"+reason+"%' ";
		}
		if(!"".equals(orderno)){
			sql += " AND T.ORDER_NO LIKE '%"+orderno+"%'";
		}
		if (!lxStartTime.equals("")) {
			sql += " AND T.RE_TIME BETWEEN TO_DATE('" + lxStartTime
					+ "' ,'YYYY-MM-DD HH24:MI:SS') AND TO_DATE('" + lxEndTime
					+ "' ,'YYYY-MM-DD HH24:MI:SS') ";
		} 
		
		return this.getData(sql);
	}
	
	/**
	 * 获取测量点重量
	 * @param parm
	 * @return
	 */
	public CoreReturnObject updateProssWt(ArrayList<String> parm,String user) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String sql = "";
			PreparedStatement psta = null;
			ResultSet rs = null;
			String acount = "";
			String updateProcess = CoreXmlSqlParsersFactory
					.getSql("FrmInOnlineStore.updateProssWt");// 获取测量点重量
			PreparedStatement updateMilProcess = connection
					.prepareStatement(updateProcess);

			for (String str : parm) {
				MatZcMEntity matZcTity = EntityTool.getEntityByJSONStr(str,
						MatZcMEntity.class);
				if (!matZcTity.getJugdeApplyCode().equals("")) {
					cro.setV_errMsg("炉号'" + matZcTity.getJudgeStoveNo()
							+ "'已申请判定,不能获取测量点重量!");
					return cro;
				}

				sql = CoreXmlSqlParsersFactory
						.getSql("FrmInOnlineStore.selectOutlist");// 查询是否有在倒运的记录
				psta = connection.prepareStatement(sql);
				psta.setString(1, matZcTity.getJudgeStoveNo());
				psta.setString(2, matZcTity.getPlineCode());
				psta.setString(3, matZcTity.getProOrderId());
				psta.setString(4, matZcTity.getGxPlanNo());
				rs = psta.executeQuery();
				if (rs.next()) {
					acount = rs.getString("ACOUNT");
				}
				rs.close();
				psta.close();
				if (Integer.parseInt(acount) > 0) {
					cro.setV_errMsg("炉号'" + matZcTity.getJudgeStoveNo()
							+ "'有倒运在途记录，请先处理!");
					return cro;
				}
				
				updateMilProcess.setString(1, matZcTity.getJudgeStoveNo());
				updateMilProcess.setString(2, matZcTity.getPlineCode());
				updateMilProcess.setString(3, matZcTity.getProOrderId());
				updateMilProcess.setString(4, matZcTity.getGxPlanNo());
				updateMilProcess.setString(5, user);
				updateMilProcess.addBatch();

			}
			updateMilProcess.executeBatch();
			cro.setV_errMsg("获取测量点重量成功!");
			connection.commit();
		} catch (SQLException e) {
			System.out.println(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}

}
