package com.steering.mes.mcp.Mch;

import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;
import CoreFS.SC01.CoreConstantData;
import com.steering.comm.converter.CoreConverter;
import com.steering.comm.db.DBCommon;
import com.steering.common.EntityTool;
import com.steering.mes.mcp.common.PlanService;
import com.steering.mes.mcp.entity.MatBcMEntity;
import com.steering.mes.mcp.entity.MchEntity.PlnZyJgxMEntity;
import com.steering.mes.mcp.entity.YdmBcScrapfrimEntity;
import org.hsqldb.lib.StringUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;

/**
 * 加工台帐查询
 * 
 * @author Administrator
 */
public class FrmJgxReport extends DBCommon {


	public CoreReturnObject updateSource(String[] ResultNo,String Source) throws Exception {
		CoreReturnObject core = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		PreparedStatement psta = null;
		SimpleDateFormat matter1 = new SimpleDateFormat("yyMMdd");
		try {
			connection.setAutoCommit(false); // 取消自动提交事务

			if(ResultNo.length<=0){

				throw new Exception("请选择需要修改的实绩！");
			}

			String sql =  CoreXmlSqlParsersFactory.getSql("FrmJgxReport.updateSource");

			sql+= CoreConverter.toSqlConditionString("T.RESULT_NO", ResultNo);

			PreparedStatement patsUpdate = connection.prepareStatement(sql);
			patsUpdate.setObject(1,Source);
			patsUpdate.addBatch();
			patsUpdate.executeBatch();

			core.setV_errMsg("修改成功！");
			core.setResult(1);
			connection.commit();
		}
		catch (Exception e) {
			core.setV_errMsg(e.getMessage());
			core.setV_errCode(-1);
			core.setResult(1);
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
				}
				catch (Exception e2) {
				}
			}
		}
		finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			}
			catch (Exception e2) {
			}
		}
		return core;
	}


	public CoreReturnObject ChangePline(String[] LoadInfo) throws Exception {
		CoreReturnObject core = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		PreparedStatement psta = null;
		SimpleDateFormat matter1 = new SimpleDateFormat("yyMMdd");
		try {
			connection.setAutoCommit(false); // 取消自动提交事务

			if(LoadInfo.length<=0){

				throw new Exception("请选择需要修改的上料信息！");
			}


			String sql1 =  CoreXmlSqlParsersFactory.getSql("FrmJgxReport.ChangePline1");
			PreparedStatement patsChangePline1 = connection.prepareStatement(sql1);

			String sql2 =  CoreXmlSqlParsersFactory.getSql("FrmJgxReport.ChangePline2");
			PreparedStatement patsChangePline2 = connection.prepareStatement(sql2);

			for (int i = 0; i <LoadInfo.length ; i++) {
				String[] Info = LoadInfo[i].split(",");
				if(Info.length< 3){
					throw new Exception("数据异常！");
				}
				String HeatPlanNo = Info[0];
				String BatchNo = Info[1];
				String PlineCode = Info[2];


				PlnZyJgxMEntity pln = PlanService.getSendHttPlanCInfo3(connection,
						HeatPlanNo,BatchNo);


				if(PlineCode.equals(pln.getPlineCode())){
					throw new Exception("炉号"+ pln.getJudgeStoveNo()+"未委内或者已经更换产线！");
				}

				patsChangePline1.setObject(1,pln.getPlineCode());
				patsChangePline1.setObject(2,pln.getPlineName());
				patsChangePline1.setObject(3,HeatPlanNo);
				patsChangePline1.setObject(4,BatchNo);
				patsChangePline1.addBatch();


				patsChangePline2.setObject(1,pln.getPlineCode());
				patsChangePline2.setObject(2,pln.getPlineName());
				patsChangePline2.setObject(3,HeatPlanNo);
				patsChangePline2.setObject(4,BatchNo);
				patsChangePline2.addBatch();
			}

			patsChangePline1.executeBatch();
			patsChangePline2.executeBatch();

			core.setV_errMsg("修改成功！");
			core.setResult(1);
			connection.commit();
		}
		catch (Exception e) {
			core.setV_errMsg(e.getMessage());
			core.setV_errCode(-1);
			core.setResult(1);
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
				}
				catch (Exception e2) {
				}
			}
		}
		finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			}
			catch (Exception e2) {
			}
		}
		return core;
	}


	/**
	 *   入库检验产线调整
	 * @param ResultNo
	 * @param PlineCode
	 * @return
	 * @throws Exception
	 */
	public CoreReturnObject ChangePline(String ResultNo, String PlineCode) throws Exception {
		CoreReturnObject core = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		PreparedStatement psta = null;
		SimpleDateFormat matter1 = new SimpleDateFormat("yyMMdd");
		try {
			connection.setAutoCommit(false); // 取消自动提交事务




			String sql1 =  CoreXmlSqlParsersFactory.getSql("FrmJgxReport.ChangePlineFinalCheck");
			PreparedStatement patsChangePline1 = connection.prepareStatement(sql1);



				patsChangePline1.setObject(1,PlineCode);
				patsChangePline1.setObject(2,PlineCode);
				patsChangePline1.setObject(3,ResultNo);
				patsChangePline1.addBatch();
			patsChangePline1.executeBatch();

			core.setV_errMsg("修改成功！");
			core.setResult(1);
			connection.commit();
		}
		catch (Exception e) {
			core.setV_errMsg(e.getMessage());
			core.setV_errCode(-1);
			core.setResult(1);
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
				}
				catch (Exception e2) {
				}
			}
		}
		finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			}
			catch (Exception e2) {
			}
		}
		return core;
	}

	/**
	 * 查询打捆
	 * 
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryBundingResult(String bc, String bz,
			String[] plinCodes, String start, String end) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryBundingResult");
		if (!start.equals("")) {
			sql += " AND T.PRO_TIME >=TO_DATE('" + start
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+ end + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND T.PRO_SHIFT='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND T.PRO_GROUP ='" + bz + "'";
		}

		sql += " Order by T.PRO_TIME";

		return this.getData(sql);
	}

	/**
	 * 查询打捆
	 * 
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryBundingResult(String bc, String bz,
			String[] plinCodes, String start, String end, String OrderNo,
			String JudgeStove) {
           return doQueryBundingResult( bc,  bz,plinCodes,  start,  end,  OrderNo, JudgeStove,"");
	}

	/**
	 * 查询打捆
	 *
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryBundingResult(String bc, String bz,
												 String[] plinCodes, String start, String end, String OrderNo,
												 String JudgeStove,String BathNo) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryBundingResult");
		if (!start.equals("")) {
			sql += " AND T.PRO_TIME >=TO_DATE('" + start
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+ end + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND T.PRO_SHIFT='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND T.PRO_GROUP ='" + bz + "'";
		}

		if (!OrderNo.equals("")) {
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" + OrderNo + "'";
		}

		if (!JudgeStove.equals("")) {
			sql += " AND T.JUDGE_STOVE_NO ='" + JudgeStove + "'";
		}

		if(!BathNo.equals("")){
			sql += " AND T.BATCH_NO ='" + BathNo + "'";
		}

		sql += " Order by T.PRO_TIME";

		return this.getData(sql);
	}





	/**
	 * 查询倒凌
	 * 
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryAppResult(String bc, String bz,
			String[] plinCodes, String start, String end) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryAppResult");
		if (!start.equals("")) {
			sql += " AND T.PRO_TIME >=TO_DATE('" + start
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+ end + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND T.PRO_SHIFT='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND T.PRO_GROUP ='" + bz + "'";
		}

		sql += " Order by T.PRO_TIME";

		return this.getData(sql);
	}

	/**
	 * 查询倒凌
	 *
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryAppResult(String bc, String bz,
											 String[] plinCodes, String start, String end, String OrderNo,
											 String JudgeStove) {

		return doQueryAppResult( bc,  bz,plinCodes,  start,  end,  OrderNo,
				 JudgeStove,"");
	}

	/**
	 * 查询倒凌
	 * 
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryAppResult(String bc, String bz,
			String[] plinCodes, String start, String end, String OrderNo,
			String JudgeStove,String BathNo) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryAppResult");
		if (!start.equals("")) {
			sql += " AND T.PRO_TIME >=TO_DATE('" + start
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+ end + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND T.PRO_SHIFT='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND T.PRO_GROUP ='" + bz + "'";
		}

		if (!OrderNo.equals("")) {
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" + OrderNo + "'";
		}

		if (!JudgeStove.equals("")) {
			sql += " AND T.JUDGE_STOVE_NO ='" + JudgeStove + "'";
		}

		if(!BathNo.equals("")){
			sql += " AND T.BATCH_NO ='" + BathNo + "'";
		}


		sql += " Order by T.PRO_TIME";

		return this.getData(sql);
	}

	/**
	 * 查询上料台账
	 * 
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryLoadResult(String bc, String bz,
			String[] plinCodes, String start, String end) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryLoadResult");
		if (!start.equals("")) {
			sql += " AND T.LOAD_TIME >=TO_DATE('" + start
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.LOAD_TIME <=TO_DATE('"
					+ end + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND T.LOAD_SHIFT ='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND T.LOAD_GROUP ='" + bz + "'";
		}

		sql += " Order by T.LOAD_TIME";
		return this.getData(sql);
	}

	/**
	 * 查询上料台账
	 * 
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryLoadResult(String bc, String bz,
			String[] plinCodes, String start, String end, String OrderNo,
			String JudgeStove) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryLoadResult");
		if (!start.equals("")) {
			sql += " AND T.LOAD_TIME >=TO_DATE('" + start
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.LOAD_TIME <=TO_DATE('"
					+ end + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND T.LOAD_SHIFT ='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND T.LOAD_GROUP ='" + bz + "'";
		}

		if (!OrderNo.equals("")) {
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" + OrderNo + "'";
		}

		if (!JudgeStove.equals("")) {
			sql += " AND T.JUDGE_STOVE_NO ='" + JudgeStove + "'";
		}

		sql += " Order by T.LOAD_TIME";
		return this.getData(sql);
	}


	/**
	 * 查询分切台账
	 *
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryLoadResult(String bc, String bz,
											 String[] plinCodes, String start, String end, String OrderNo,
											 String JudgeStove,String BathNo) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryLoadResult1");
		if (!start.equals("")) {
			sql += " AND T.LOAD_TIME >=TO_DATE('" + start
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.LOAD_TIME <=TO_DATE('"
					+ end + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}

		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND T.PRO_SHIFT ='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND T.PRO_GROUP ='" + bz + "'";
		}
		if (!OrderNo.equals("")) {
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" + OrderNo + "'";
		}

		if (!JudgeStove.equals("")) {
			sql += " AND T.JUDGE_STOVE_NO ='" + JudgeStove + "'";
		}

		if(!BathNo.equals("")){
			sql += " AND T.BATCH_NO ='" + BathNo + "'";
		}

		sql += " Order by T.LOAD_TIME";
		return this.getData(sql);
	}

	/**
	 * 查询分切台账
	 * 
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryCutResult(String bc, String bz,
			String[] plinCodes, String start, String end) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryCutResult");
		if (!start.equals("")) {
			sql += " AND T.PRO_TIME >=TO_DATE('" + start
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+ end + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND T.PRO_SHIFT ='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND T.PRO_GROUP ='" + bz + "'";
		}

		sql += " Order by T.PRO_TIME";
		return this.getData(sql);
	}

	/**
	 * 查询分切台账
	 * 
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryCutResult(String bc, String bz,
			String[] plinCodes, String start, String end, String OrderNo,
			String JudgeStove) {
           return doQueryCutResult( bc,  bz,plinCodes,  start,  end,  OrderNo,
				 JudgeStove,"");
	}

	/**
	 * 查询分切台账
	 *
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryCutResult(String bc, String bz,
											 String[] plinCodes, String start, String end, String OrderNo,
											 String JudgeStove,String BathNo) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryCutResult");
		if (!start.equals("")) {
			sql += " AND T.PRO_TIME >=TO_DATE('" + start
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+ end + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND T.PRO_SHIFT ='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND T.PRO_GROUP ='" + bz + "'";
		}
		if (!OrderNo.equals("")) {
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" + OrderNo + "'";
		}

		if (!JudgeStove.equals("")) {
			sql += " AND T.JUDGE_STOVE_NO ='" + JudgeStove + "'";
		}

		if(!BathNo.equals("")){
			sql += " AND T.BATCH_NO ='" + BathNo + "'";
		}

		sql += " Order by T.PRO_TIME";
		return this.getData(sql);
	}

	/**
	 * 查询螺纹检验台账
	 * 
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryHreadResult(String bc, String bz,
			String[] plinCodes, String start, String end) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryHreadResult");
		if (!start.equals("")) {
			sql += " AND T.PRO_TIME >=TO_DATE('" + start
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+ end + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND T.PRO_SHIFT ='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND T.PRO_GROUP ='" + bz + "'";
		}

		sql += " Order by T.PRO_TIME";
		return this.getData(sql);
	}

	/**
	 * 查询螺纹检验台账
	 * 
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryHreadResult(String bc, String bz,
			String[] plinCodes, String start, String end, String OrderNo,
			String JudgeStove) {

	   return 	doQueryHreadResult( bc,  bz,plinCodes,  start,  end,  OrderNo,
				 JudgeStove,"");
	}

	/**
	 * 查询螺纹检验台账
	 *
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryHreadResult(String bc, String bz,
											   String[] plinCodes, String start, String end, String OrderNo,
											   String JudgeStove,String BathNo) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryHreadResult");
		if (!start.equals("")) {
			sql += " AND T.PRO_TIME >=TO_DATE('" + start
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+ end + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND T.PRO_SHIFT ='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND T.PRO_GROUP ='" + bz + "'";
		}
		if (!OrderNo.equals("")) {
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" + OrderNo + "'";
		}

		if (!JudgeStove.equals("")) {
			sql += " AND T.JUDGE_STOVE_NO ='" + JudgeStove + "'";
		}

		if(!BathNo.equals("")){
			sql += " AND T.BATCH_NO ='" + BathNo + "'";
		}

		sql += " Order by T.PRO_TIME";
		return this.getData(sql);
	}


	/**
	 * 查询入库检验处置单
	 *
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryTreatment(String bc, String bz,
											   String[] plinCodes, String start, String end, String OrderNo,
											   String JudgeStove,String BathNo,String ResponsibleCode,String Status) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryTreatment");
		if (!start.equals("")) {
			sql += " AND T.PRO_TIME >=TO_DATE('" + start
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+ end + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND T.REPLY_SHIFT ='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND T.REPLY_GROUP ='" + bz + "'";
		}
		if (!OrderNo.equals("")) {
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" + OrderNo + "'";
		}

		if (!JudgeStove.equals("")) {
			sql += " AND T.JUDGE_STOVE_NO ='" + JudgeStove + "'";
		}

		if(!BathNo.equals("")){
			sql += " AND T.BATCH_NO ='" + BathNo + "'";
		}

		if (!ResponsibleCode.equals("")) {

			sql +=  " AND T.RESPONSIBLE_CODE = '" +ResponsibleCode + "'";
		}else{
			sql +=  " AND T.RESPONSIBLE_CODE IS NULL ";
		}

		if (!Status.equals("")) {

			sql +=  " AND T.APPROVAL_STATUS = '" +Status + "'";
		}

		sql += " Order by T.PRO_TIME";
		return this.getData(sql);
	}


	/**
	 * 查询测量点台账
	 * 
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryMeasureResult(String bc, String bz,
			String[] plinCodes, String start, String end) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryMeasureResult");
		if (!start.equals("")) {
			sql += " AND T.PRO_TIME >=TO_DATE('" + start
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+ end + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND T.PRO_SHIFT ='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND T.PRO_GROUP ='" + bz + "'";
		}

		sql += " Order by T.PRO_TIME";
		return this.getData(sql);
	}


	/**
	 * 查询测量点台账
	 *
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryMeasureResult(String bc, String bz,
											   String[] plinCodes, String start, String end, String OrderNo,
											   String JudgeStove,String BathNo) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryMeasureResult");
		if (!start.equals("")) {
			sql += " AND T.PRO_TIME >=TO_DATE('" + start
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+ end + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND T.PRO_SHIFT ='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND T.PRO_GROUP ='" + bz + "'";
		}
		if (!OrderNo.equals("")) {
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" + OrderNo + "'";
		}

		if (!JudgeStove.equals("")) {
			sql += " AND T.JUDGE_STOVE_NO ='" + JudgeStove + "'";
		}

		if(!BathNo.equals("")){
			sql += " AND T.BATCH_NO ='" + BathNo + "'";
		}

		sql += " Order by T.PRO_TIME";
		return this.getData(sql);
	}


	/**
	 * 查询测量点台账
	 * 
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryMeasureResult(String bc, String bz,
			String[] plinCodes, String start, String end,
												 String OrderNo,String JudgeStove) {
		return doQueryMeasureResult(bc,  bz, plinCodes,  start,  end,  OrderNo, JudgeStove,"");
	}

	/**
	 * 查询测量点明细
	 *
	 * @param bc
	 * @param bz
	 * @param plinCodes
	 * @param start
	 * @param end
	 * @param OrderNo
	 * @param JudgeStove
	 * @return
	 */
	public CoreReturnObject doQueryMeasureDetailsResult(String bc, String bz,
														String[] plinCodes, String start, String end, String OrderNo,
														String JudgeStove){
		return  doQueryMeasureDetailsResult( bc,  bz,
				 plinCodes,  start,  end,  OrderNo,JudgeStove,"","0","1");
	}
	//质保部加的加长度范围
	public CoreReturnObject doQueryMeasureDetailsResultzb(String bc, String bz,
														String[] plinCodes, String start, String end, String OrderNo,
														String JudgeStove){
		return  doQueryMeasureDetailsResultzb( bc,  bz,
				plinCodes,  start,  end,  OrderNo,JudgeStove,"","0","1");
	}
	public CoreReturnObject doQueryMeasureDetailsResultzb(String bc, String bz,
														String[] plinCodes, String start, String end, String OrderNo,
														String JudgeStove,String BathNo,String Flag1,String Flag2) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryMeasureDetailsResultzb");
		if (!start.equals("")) {
			sql += " AND R.MSAUER_DATE >=TO_DATE('"
					+ start
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND R.MSAUER_DATE <=TO_DATE('"
					+ end + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}
		sql += CoreConverter.toSqlConditionString("R.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND R.PRO_BC ='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND R.PRO_BZ ='" + bz + "'";
		}

		if (!OrderNo.equals("")) {
			sql += " AND DECODE(M.ORDER_NO,NULL,R.PRO_ORDER_NO, M.ORDER_NO || '/' || M.ORDER_SEQ)  like '" + OrderNo+ "%'";
		}


		if (!JudgeStove.equals("")) {
			sql += " AND R.JUDGE_STOVE_NO ='" + JudgeStove + "'";
		}

		if (!BathNo.equals("")) {
			sql += " AND R.BATCH_NO ='" + BathNo + "'";
		}

		if(Flag1.equals("1")){
			sql += " AND T.MAT_NO IS NOT NULL ";
		}

		if(Flag2.equals("0")){
			sql += " AND R.FLAG = '00' ";
		}

		sql += " Order by R.PLINE_CODE ASC, R.MSAUER_DATE DESC";
		return this.getData(sql);
	}
	/**
	 * 查询测量点明细
	 * 
	 * @param bc
	 * @param bz
	 * @param plinCodes
	 * @param start
	 * @param end
	 * @param OrderNo
	 * @param JudgeStove
	 * @return
	 */
	public CoreReturnObject doQueryMeasureDetailsResult(String bc, String bz,
			String[] plinCodes, String start, String end, String OrderNo,
			String JudgeStove,String BathNo,String Flag1,String Flag2) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryMeasureDetailsResult");
		if (!start.equals("")) {
			sql += " AND R.MSAUER_DATE >=TO_DATE('"
					+ start
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND R.MSAUER_DATE <=TO_DATE('"
					+ end + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}
		sql += CoreConverter.toSqlConditionString("R.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND R.PRO_BC ='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND R.PRO_BZ ='" + bz + "'";
		}

		if (!OrderNo.equals("")) {
			sql += " AND DECODE(M.ORDER_NO,NULL,R.PRO_ORDER_NO, M.ORDER_NO || '/' || M.ORDER_SEQ)  like '" + OrderNo+ "%'";
		}


		if (!JudgeStove.equals("")) {
			sql += " AND R.JUDGE_STOVE_NO ='" + JudgeStove + "'";
		}

		if (!BathNo.equals("")) {
			sql += " AND R.BATCH_NO ='" + BathNo + "'";
		}

		if(Flag1.equals("1")){
			sql += " AND T.MAT_NO IS NOT NULL ";
		}

		if(Flag2.equals("0")){
			sql += " AND R.FLAG = '00' ";
		}

		sql += " Order by R.PLINE_CODE ASC, R.MSAUER_DATE DESC";
		return this.getData(sql);
	}

	/**
	 * 查询车丝台账
	 * 
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryThreaderResult(String bc, String bz,
			String[] plinCodes, String start, String end) {

		 return doQueryThreaderResult( bc,  bz,plinCodes,  start,  end,"","");
	}


	/**
	 * 查询车丝台账
	 *
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryThreaderResult(String bc, String bz,
												 String[] plinCodes, String start, String end, String OrderNo,
												 String JudgeStove,String BathNo) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryThreaderResult");
		if (!start.equals("")) {
			sql += " AND T.PRO_TIME >=TO_DATE('" + start
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+ end + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND T.PRO_SHIFT ='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND T.PRO_GROUP ='" + bz + "'";
		}
		if (!OrderNo.equals("")) {
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" + OrderNo + "'";
		}

		if (!JudgeStove.equals("")) {
			sql += " AND T.JUDGE_STOVE_NO ='" + JudgeStove + "'";
		}

		if(!BathNo.equals("")){
			sql += " AND T.BATCH_NO ='" + BathNo + "'";
		}

		sql += " Order by T.PRO_TIME";
		return this.getData(sql);
	}

	/**
	 * 查询车丝台账
	 * 
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryThreaderResult(String bc, String bz,
			String[] plinCodes, String start, String end, String OrderNo,
			String JudgeStove) {
   return doQueryThreaderResult( bc,  bz,plinCodes,  start,  end,OrderNo,JudgeStove,"");
	}

	/**
	 * 查询水压台账
	 * 
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryWaterResult(String bc, String bz,
			String[] plinCodes, String start, String end) {
		return doQueryWaterResult( bc,  bz, plinCodes,  start,  end,  "",
				"","");
	}

	/**
	 * 查询水压台账
	 * 
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryWaterResult(String bc, String bz,
			String[] plinCodes, String start, String end, String OrderNo,
			String JudgeStove) {
           return doQueryWaterResult( bc,  bz, plinCodes,  start,  end,  OrderNo,
				 JudgeStove,"");
	}

	/**
	 * 查询水压台账
	 *
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryWaterResult(String bc, String bz,
											   String[] plinCodes, String start, String end, String OrderNo,
											   String JudgeStove,String BathNo) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryWaterResult");
		if (!start.equals("")) {
			sql += " AND T.PRO_TIME >=TO_DATE('" + start
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+ end + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND T.PRO_SHIFT ='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND T.PRO_GROUP ='" + bz + "'";
		}

		if (!OrderNo.equals("")) {
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" + OrderNo + "'";
		}

		if (!JudgeStove.equals("")) {
			sql += " AND T.JUDGE_STOVE_NO ='" + JudgeStove + "'";
		}

		if(!BathNo.equals("")){
			sql += " AND T.BATCH_NO ='" + BathNo + "'";
		}

		sql += " Order by T.PRO_TIME";
		return this.getData(sql);
	}

	/**
	 * 查询通径台账
	 * 
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryPathResult(String bc, String bz,
			String[] plinCodes, String start, String end) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryPathResult");
		if (!start.equals("")) {
			sql += " AND T.PRO_TIME >=TO_DATE('" + start
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+ end + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND T.PRO_SHIFT ='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND T.PRO_GROUP ='" + bz + "'";
		}

		sql += " Order by T.PRO_TIME";
		return this.getData(sql);
	}

	/**
	 * 查询通径台账
	 *
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryRemanenceResult(String bc, String bz,
												   String[] plinCodes, String start, String end, String OrderNo,
												   String JudgeStove,String BathNo) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryRemanenceResult");

		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND T.PRO_SHIFT ='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND T.PRO_GROUP ='" + bz + "'";
		}

		if (!OrderNo.equals("")) {
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" + OrderNo + "'";
		}

		if (!JudgeStove.equals("")) {
			sql += " AND T.JUDGE_STOVE_NO ='" + JudgeStove + "'";
		}

		if(!BathNo.equals("")){
			sql += " AND T.BATCH_NO ='" + BathNo + "'";
		}

		sql += " Order by T.PRO_TIME";
		return this.getData(sql);
	}


	/**
	 * 查询通径台账
	 * 
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryPathResult(String bc, String bz,
			String[] plinCodes, String start, String end, String OrderNo,
			String JudgeStove,String BathNo) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryPathResult");
		if (!start.equals("")) {
			sql += " AND T.PRO_TIME >=TO_DATE('" + start
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+ end + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND T.PRO_SHIFT ='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND T.PRO_GROUP ='" + bz + "'";
		}

		if (!OrderNo.equals("")) {
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" + OrderNo + "'";
		}

		if (!JudgeStove.equals("")) {
			sql += " AND T.JUDGE_STOVE_NO ='" + JudgeStove + "'";
		}

		if(!BathNo.equals("")){
			sql += " AND T.BATCH_NO ='" + BathNo + "'";
		}

		sql += " Order by T.PRO_TIME";
		return this.getData(sql);
	}

	/**
	 * 查询拧接台账
	 * 
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryTwistinResult(String bc, String bz,
			String[] plinCodes, String start, String end, String OrderNo,
			String JudgeStove) {
		return  doQueryTwistinResult( bc,  bz,plinCodes,  start,  end,  OrderNo, JudgeStove,"");
	}

	/**
	 * 查询拧接台账
	 *
	 * @return
	 */
	public CoreReturnObject doQueryTwistinResult(String bc, String bz,
                     	String[] plinCodes, String start, String end, String OrderNo,
	String JudgeStove,String BathNo){
		return  doQueryTwistinResult( bc,  bz,plinCodes,  start,  end,  OrderNo, JudgeStove,BathNo,"","");
	}

	/**
	 * 查询拧接台账
	 *
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryTwistinResult(String bc, String bz,
												 String[] plinCodes, String start, String end, String OrderNo,
												 String JudgeStove,String BathNo,String JgStoveNo,String JgBatchNo) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryTwistinResult");
		if (!start.equals("")) {
			sql += " AND T.PRO_TIME >=TO_DATE('" + start
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+ end + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND T.PRO_SHIFT ='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND T.LOAD_GROUP ='" + bz + "'";
		}

		if (!OrderNo.equals("")) {
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" + OrderNo + "'";
		}

		if (!JudgeStove.equals("")) {
			sql += " AND T.JUDGE_STOVE_NO ='" + JudgeStove + "'";
		}


		if(!BathNo.equals("")){
			sql += " AND T.BATCH_NO ='" + BathNo + "'";
		}

		if (!JgStoveNo.equals("")) {
			sql += "  AND EXISTS" +
					" (SELECT * FROM MCH_TWISTINGLY_RESULT_D WHERE RESULT_NO = T.RESULT_NO " +
					"AND   COUPLING_STOVE_NO ='" + JgStoveNo + "')";
		}


		if(!JgBatchNo.equals("")){
			sql += "  AND EXISTS" +
					" (SELECT * FROM MCH_TWISTINGLY_RESULT_D WHERE RESULT_NO = T.RESULT_NO " +
					"AND   LOT_NO ='" + JgBatchNo + "')";
		}

		sql += " Order by T.PRO_TIME";
		return this.getData(sql);
	}

	/**
	 * 查询拧接台账
	 * 
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryTwistinResult(String bc, String bz,
			String[] plinCodes, String start, String end) {
		return  doQueryTwistinResult( bc,  bz,plinCodes,  start,  end,  "", "","");
	}

	/**
	 * 查询磁粉探伤台账
	 * 
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryMtResult(String bc, String bz,
			String[] plinCodes, String start, String end) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryMtResult");
		if (!start.equals("")) {
			sql += " AND T.CREATE_TIME >=TO_DATE('"
					+ start
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.CREATE_TIME <=TO_DATE('"
					+ end + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND T.PRO_SHIFT ='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND T.PRO_GROUP ='" + bz + "'";
		}

		sql += " Order by T.PRO_TIME";
		return this.getData(sql);
	}

	/**
	 * 查询超声探伤台账
	 * 
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryUtResult(String bc, String bz,
			String[] plinCodes, String start, String end) {
		return  doQueryUtResult( bc,  bz,plinCodes,  start,  end,"", "","");
	}

	/**
	 * 查询超声探伤台账
	 *
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryUtResult(String bc, String bz,
											String[] plinCodes, String start, String end,String OrderNo,	String JudgeStove) {
return  doQueryUtResult( bc,  bz,plinCodes,  start,  end,OrderNo, JudgeStove,"");
	}

	/**
	 * 查询超声探伤台账
	 * 
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryUtResult(String bc, String bz,
			String[] plinCodes, String start, String end, String OrderNo,
			String JudgeStove,String BathNo) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryUtResult");
		if (!start.equals("")) {
			sql += " AND T.COL_TIME >=TO_DATE('" + start
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.COL_TIME <=TO_DATE('"
					+ end + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND T.COL_SHIFT ='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND T.COL_GROUP ='" + bz + "'";
		}
		if (!OrderNo.equals("")) {
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" + OrderNo + "'";
		}

		if (!JudgeStove.equals("")) {
			sql += " AND T.JUDGE_STOVE_NO ='" + JudgeStove + "'";
		}

		if(!BathNo.equals("")){
			sql += " AND T.BATCH_NO ='" + BathNo + "'";
		}


		sql += " Order by T.COL_TIME";
		return this.getData(sql);
	}

	/**
	 * 查询入库台账数据
	 * 
	 * @param bc
	 * @param bz
	 * @param plinCodes
	 * @param start
	 * @param end
	 * @return
	 */
	public CoreReturnObject doQueryGoDown(String bc, String bz,
			String[] plinCodes, String start, String end, String OrderNo,
			String JudgeStove) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryGoDown");
		if (!start.equals("")) {
			sql += " AND T.IN_TIME_F>=TO_DATE('" + start
					+ "','YYYY-MM-DD HH24:MI:SS') AND T.IN_TIME_F<= TO_DATE('"
					+ end + "','YYYY-MM-DD HH24:MI:SS')";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND T.IN_BC ='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND T.IN_BZ ='" + bz + "'";
		}
		if (!OrderNo.equals("")) {
			sql += " AND T.ORDER_NO LIKE '%" + OrderNo + "%'";
		}

		if (!JudgeStove.equals("")) {
			sql += " AND T.JUDGE_STOVE_NO ='" + JudgeStove + "'";
		}
		sql += " group by t.JUDGE_STOVE_NO,t.BATCH_NO,t.INSTOCK_DOC,t.PRODUCCODE,t.PRODUCNAME,t.STD_CODE,t.STD_NAME,t.STEELCODE,t.STEELNAME,t.STD_STYLE,t.STD_STYLE_DESC,t.SPEC_CODE,t.SPEC_NAME,t.JUDGE_STD_CODE,t.JUDGE_STD_NAME,t.GRADECODE,t.GRADENAME,t.BAL_YEAR_MONTH,t.PIPMEMO,t.BATCH_GROUD_NO,t.MATERIAL_NO,t.MATERIAL_NAME,t.MAT_STATUS,T.STORAGE_NO,";
		sql += " t.MODEL_DESC,t.ACT_DIMATER,t.ACT_HEIGHT,t.ACT_LEN_MIN,t.ACT_LEN_MAX,t.BELONG_CODE,t.BELONG_NAME,t.MEMO,t.CREATE_NAME,t.ORDER_NO,t.ORDER_SEQ,t.DELIVERY_NO,t.MODEL_CODE,t.PRODUCT_FLAG,t.PLINE_CODE,t.PLINE_NAME,t.GX_PLAN_NO,t.PRO_PLAN_ID,T.IN_BC,T.IN_BZ,T.LOT_NO";
		sql += " order by t.instock_doc desc";
		return this.getData(sql);
	}

	/**
	 * 查询废品台账
	 * 
	 * @param bc
	 * @param bz
	 * @param plinCodes
	 * @param start
	 * @param end
	 * @param OrderNo
	 * @param JudgeStove
	 * @return
	 */
	public CoreReturnObject doQueryWaster(String bc, String bz,
			String[] plinCodes, String start, String end, String OrderNo,
			String JudgeStove) {
		String sql1 = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryWaster");
		String sql = "";
		if (!start.equals("")) {
			sql += " AND T.INSTOCK_TIME>=TO_DATE('"
					+ start
					+ "','YYYY-MM-DD HH24:MI:SS') AND T.INSTOCK_TIME <= TO_DATE('"
					+ end + "','YYYY-MM-DD HH24:MI:SS')";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!OrderNo.equals("")) {
			sql += " AND T.ORDER_NO LIKE '%" + OrderNo + "%'";
		}
		if (!JudgeStove.equals("")) {
			sql += " AND T.JUDGE_STOVE_NO ='" + JudgeStove + "'";
		}
		sql1 = sql1.replace("#something#", sql);
		return this.getData(sql1);
	}

	/**
	 * 查询待审核废品
	 * 
	 * @param plinCodes
	 * @param start
	 * @param end
	 * @param OrderNo
	 * @param JudgeStove
	 * @return
	 */
	public CoreReturnObject doQueryWasterAudit(String[] plinCodes,
			String start, String end, String OrderNo, String JudgeStove) {
		String sql1 = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryWasterAudit");
		String sql = "";
		if (!start.equals("")) {
			sql += " AND T.INSTOCK_TIME>=TO_DATE('"
					+ start
					+ "','YYYY-MM-DD HH24:MI:SS') AND T.INSTOCK_TIME <= TO_DATE('"
					+ end + "','YYYY-MM-DD HH24:MI:SS')";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!OrderNo.equals("")) {
			sql += " AND T.ORDER_NO LIKE '%" + OrderNo + "%'";
		}
		if (!JudgeStove.equals("")) {
			sql += " AND T.JUDGE_STOVE_NO ='" + JudgeStove + "'";
		}
		sql1 = sql1.replace("#something#", sql);
		return this.getData(sql1);
	}

	public CoreReturnObject getHttEntrustInfo() {
		return this.getDataBySqlID("FrmJgxReport.doQueryENTRUST",
				new Object[] { });
	}
	/**
	 * 查询废品审核记录
	 * 
	 * @param plinCodes
	 * @param start
	 * @param end
	 * @return
	 */
	public CoreReturnObject doQueryWasterAuditRecords(String[] plinCodes,
			String start, String end, String OrderNo, String JudgeStove) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryWasterAuditRecords");
		if (!start.equals("")) {
			sql += " AND T.APPROVAL_TIME >=TO_DATE('"
					+ start
					+ "','YYYY-MM-DD HH24:MI:SS') AND T.APPROVAL_TIME <= TO_DATE('"
					+ end + "','YYYY-MM-DD HH24:MI:SS')";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		return this.getData(sql);
	}

	/**
	 * 根据废品审核单号查询废品审核记录
	 * 
	 * @param failApprovalCode
	 * @return
	 */
	public CoreReturnObject doQueryWasterAuditRecordsByID(
			String failApprovalCode) {
		String sql1 = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryWasterAuditRecordsByID");
		String sql = "";
		if (!failApprovalCode.equals("")) {
			sql += " AND T.FAIL_APPROVAL_CODE ='" + failApprovalCode + "'";
		}
		sql1 = sql1.replace("#something#", sql);
		return this.getData(sql1);
	}

	/**
	 * 审核
	 * 
	 * @param parm
	 * @param user
	 * @return
	 */
	public CoreReturnObject Audit(ArrayList<String> parm, String user,
			String process) {
		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 FailAppovalCode = ""; // 废品审核单号
			String PlineCode = "";
			String PlineName = "";
			String updatePortSql1 ="";
			String doAuditSql = CoreXmlSqlParsersFactory
					.getSql("FrmJgxReport.doAudit");// 审核
			PreparedStatement doAuditSqlPsta = connection
					.prepareStatement(doAuditSql);
			String insertAuditRecordsSql = CoreXmlSqlParsersFactory
					.getSql("FrmJgxReport.insertAuditRecordsSql");// 新增废品审核记录
			PreparedStatement insertAuditRecordsSqlPsta = connection
					.prepareStatement(insertAuditRecordsSql);

			String updatePortSql = CoreXmlSqlParsersFactory
					.getSql("FrmJgxReport.updatePortSql");// 修改队列表
			if (process.equals("F")) {
				updatePortSql1 = updatePortSql.replace("#TABLE#",
						"PORT_HTT_BATCH_SAMPLE_RESULT");
			} else if (process.equals("G")) {
				updatePortSql1 = updatePortSql.replace("#TABLE#",
						"PORT_MCH_BATCH_SAMPLE_RESULT");
			}
			PreparedStatement updatePortSqlPsta = connection
					.prepareStatement(updatePortSql1);

			sql = CoreXmlSqlParsersFactory
					.getSql("FrmJgxReport.doQueryFailAppovalCode");// 生成废品审核单号
			psta = connection.prepareStatement(sql);
			rs = psta.executeQuery();
			if (rs.next()) {
				FailAppovalCode = rs.getString("FAIL_APPROVAL_CODE");
			}
			rs.close();
			psta.close();

			for (String str : parm) {
				MatBcMEntity matZcTity = EntityTool.getEntityByJSONStr(str,
						MatBcMEntity.class);
				doAuditSqlPsta.setString(1, FailAppovalCode);
				doAuditSqlPsta.setString(2, matZcTity.getMatNo());
				doAuditSqlPsta.setString(3, matZcTity.getPlineCode());
				doAuditSqlPsta.addBatch();

				updatePortSqlPsta.setString(1, "1");
				updatePortSqlPsta.setString(2, "1");
				updatePortSqlPsta.setString(3, matZcTity.getMatNo());
				updatePortSqlPsta.setString(4, matZcTity.getPlineCode());
				updatePortSqlPsta.addBatch();

				PlineCode = matZcTity.getPlineCode();
				PlineName = matZcTity.getPlineName();
			}
			insertAuditRecordsSqlPsta.setString(1, FailAppovalCode);
			insertAuditRecordsSqlPsta.setString(2, user);
			insertAuditRecordsSqlPsta.setString(3, PlineCode);
			insertAuditRecordsSqlPsta.setString(4, PlineName);
			insertAuditRecordsSqlPsta.addBatch();

			doAuditSqlPsta.executeBatch();
			updatePortSqlPsta.executeBatch();
			insertAuditRecordsSqlPsta.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 parm
	 * @return
	 */
	public CoreReturnObject CancelAudit(ArrayList<String> parm,
			String FailAppovalCode, String process) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String updatePortSql1 ="";
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String doCancelAuditSql = CoreXmlSqlParsersFactory
					.getSql("FrmJgxReport.doCancelAudit");// 取消审核
			PreparedStatement doCancelAuditSqlPsta = connection
					.prepareStatement(doCancelAuditSql);

			String updatePortSql = CoreXmlSqlParsersFactory
					.getSql("FrmJgxReport.updatePortSql");// 修改队列表
			if (process.equals("F")) {
				updatePortSql1 = updatePortSql.replace("#TABLE#",
						"PORT_HTT_BATCH_SAMPLE_RESULT");
			} else if (process.equals("G")) {
				updatePortSql1 = updatePortSql.replace("#TABLE#",
						"PORT_MCH_BATCH_SAMPLE_RESULT");
			}
			PreparedStatement updatePortSqlPsta = connection
					.prepareStatement(updatePortSql1);

			String doUpdateWasteRecordsSql = CoreXmlSqlParsersFactory
					.getSql("FrmJgxReport.doUpdateWasteRecords");// 清理废品审核记录
			PreparedStatement doUpdateWasteRecordsSqlPsta = connection
					.prepareStatement(doUpdateWasteRecordsSql);
			for (String str : parm) {
				MatBcMEntity matZcTity = EntityTool.getEntityByJSONStr(str,
						MatBcMEntity.class);
				doCancelAuditSqlPsta.setString(1, matZcTity.getMatNo());
				doCancelAuditSqlPsta.setString(2, matZcTity.getPlineCode());
				doCancelAuditSqlPsta.addBatch();

				updatePortSqlPsta.setString(1, "0");
				updatePortSqlPsta.setString(2, "0");
				updatePortSqlPsta.setString(3, matZcTity.getMatNo());
				updatePortSqlPsta.setString(4, matZcTity.getPlineCode());
				updatePortSqlPsta.addBatch();
			}

			doUpdateWasteRecordsSqlPsta.setString(1, FailAppovalCode);
			doUpdateWasteRecordsSqlPsta.addBatch();

			doCancelAuditSqlPsta.executeBatch();
			updatePortSqlPsta.executeBatch();
			doUpdateWasteRecordsSqlPsta.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;
	}


	public CoreReturnObject doQueryOffLine(ArrayList<String> list,String[] status,
										   String[] plineCode) {

		String sql = "";
		sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryOffLine");
		if (!list.get(0).equals("")) {
			sql += "  AND T.PRO_TIME BETWEEN TO_DATE('" + list.get(0)
					+ "','YYYY-MM-DD HH24:MI:SS') " + " AND TO_DATE('"
					+ list.get(1) + "','YYYY-MM-DD HH24:MI:SS')";
		}
		if (!list.get(2).equals("")) {
			sql += " AND T.JUDGE_STOVE_NO  LIKE '" + list.get(2)
					+ "' || '%'  OR  EXISTS (SELECT 1 FROM HTT_GROUP_RESULT WHERE JUDGE_STOVE_NO LIKE '"+ list.get(2)+ "%'  AND GROUP_ID =T.GROUP_ID)";

		}
		if (!list.get(3).equals("")) {
			sql += " AND T.ZY_BATCH_ID  LIKE  '" + list.get(3)
					+ "' || '%'";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plineCode);
		if (!list.get(4).equals("")) {
			sql += " AND T.STATION_CODE ='" + list.get(4) + "'";
		}

		if (!list.get(5).equals("-1")) {
			sql += " AND T.GROUP_LOG ='" + list.get(5) + "'";
		}


		if(status[0].equals("1") && status[1].equals("1") && status[2].equals("1") && status[3].equals("1")){

		}else {
			String statusSql = "";

			if (status[0].equals("1")) {
				statusSql = statusSql + (statusSql.equals("")? "":" OR ")  + " ((TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -\n" +
						"       TO_NUMBER(NVL(T.RE_NUM, 0)) - TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +\n" +
						"       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) <>0)";
			}
			if(status[1].equals("1")){
				statusSql  = statusSql + (statusSql.equals("")? "":" OR ")  + " T.RE_NUM > 0 ";
			}

			if(status[2].equals("1")){
				statusSql  = statusSql + (statusSql.equals("")? "":" OR ")  + " T.GROUP_NUM > 0 ";
			}

			if(status[3].equals("1")){
				statusSql  = statusSql + (statusSql.equals("")? "":" OR ")  + " (NVL(T.SUBCONTRACT_NUM,0) > 0 " +
						"AND NVL(SUBCONTRACTCOMPLETE_NUM,0)=0   AND  NVL(HB_FP_NUM,0)=0)";
			}

			if(!statusSql.equals("")){
				sql+= "AND  ("+statusSql +")";
			}

		}

		sql +=" ORDER BY T.JUDGE_STOVE_NO,T.BATCH_NO, T.PRO_TIME";
		return this.getData(sql);
	}





	/**
	 * 查询抽检台账
	 *
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryFinalCheck(String bc, String bz,
											   String[] plinCodes, String start, String end, String OrderNo,
											   String JudgeStove,String BathNo,String Status) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryFinalCheck");
		if (!start.equals("")) {
			sql += " AND T.PRO_TIME >=TO_DATE('" + start
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+ end + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plinCodes);
		if (!bc.equals("")) {
			sql += " AND T.PRO_SHIFT ='" + bc + "'";
		}
		if (!bz.equals("")) {
			sql += " AND T.PRO_GROUP ='" + bz + "'";
		}
		if (!OrderNo.equals("")) {
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" + OrderNo + "'";
		}

		if (!JudgeStove.equals("")) {
			sql += " AND T.JUDGE_STOVE_NO ='" + JudgeStove + "'";
		}

		if(!BathNo.equals("")){
			sql += " AND T.BATCH_NO ='" + BathNo + "'";
		}

		if(Status.equals("0")){
			sql +=" AND  (SELECT MAX(STATION_STATUS)\n" +
					"                  FROM MCH_COM_INFO\n" +
					"                 WHERE STATION_CODE = '701313'\n" +
					"                   AND HEAT_PLAN_NO = T.HEAT_PLAN_NO\n" +
					"                   AND BATCH_NO = T.BATCH_NO) != 2 ";
		}else if(Status.equals("1")){
			sql +=" AND  (SELECT MAX(STATION_STATUS)\n" +
					"                  FROM MCH_COM_INFO\n" +
					"                 WHERE STATION_CODE = '701313'\n" +
					"                   AND HEAT_PLAN_NO = T.HEAT_PLAN_NO\n" +
					"                   AND BATCH_NO = T.BATCH_NO)  = 2 ";
		}

		sql += " Order by T.PRO_TIME";
		return this.getData(sql);
	}



	/**
	 * 查询待上料
	 *
	 * @param list
	 * @return
	 */
	public CoreReturnObject doQueryUnLoadReport(  String[] plinCodes,String OrderNo,
											  String JudgeStove,String BathNo,String Flag1,String Flag2) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryUnLoadReport");

		String Condition = "";

		Condition += CoreConverter.toSqlConditionString("T2.PLINE_CODE ", plinCodes);



		if (!OrderNo.equals("")) {
			Condition += " AND T.ORDER_NO||'/'|| T.ORDER_SEQ ='" + OrderNo + "'";
		}

		if (!JudgeStove.equals("")) {
			Condition += " AND T.JUDGE_STOVE_NO ='" + JudgeStove + "'";
		}

		if(!BathNo.equals("")){
			Condition += " AND T2.BATCH_NO ='" + BathNo + "'";
		}

		if(Flag1.equals("1")){
			Condition += "  AND (SELECT SUM(M.ACT_COUNT)\n" +
					"                  FROM MAT_BC_M M, YDM_BC_BUTTRESS B\n" +
					"                 WHERE M.MAT_NO = B.MAT_NO\n" +
					"                   AND M.HEAT_PLAN_NO_NEXT = T.HEAT_PLAN_NO\n" +
					"                   AND M.PRODUCT_FLAG = '801401'\n" +
					"                   AND M.MAT_STATUS = '80150103'\n" +
					"                   AND (T.IF_MATCH_ODD = '5' OR\n" +
					"                       (NVL(M.BATCH_NO, '/') = NVL(T2.BATCH_NO, '/') AND\n" +
					"                       NVL(M.BATCH_GROUD_NO, '/') =\n" +
					"                       NVL(T2.BATCH_GROUD_NO, '/')))) > 0";
		}

		if(Flag2.equals("1")){
			Condition += "  AND T2.REAL_INDOUBLE_NUM >0 ";

		}


		sql = sql.replace("#CONDITION#",Condition);

		return this.getData(sql);
	}




	/**
	 *   入库检验产线调整
	 * @param ResultNo
	 * @param PlineCode
	 * @return
	 * @throws Exception
	 */
	public CoreReturnObject ChangeRtdPline(String[] IDs, String PlineCode) throws Exception {
		CoreReturnObject core = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		PreparedStatement psta = null;
		SimpleDateFormat matter1 = new SimpleDateFormat("yyMMdd");
		try {
			connection.setAutoCommit(false); // 取消自动提交事务


			if(IDs==null || IDs.length<=0)  {
				throw new Exception("请选择需要修改的测量点数据！");
			}


			String sql1 =CoreXmlSqlParsersFactory.getSql("FrmJgxReport.ChangeRtdPline");
			sql1+=  PlanService.toSqlConditionString("KEY_ID", IDs);

			PreparedStatement patsChangePline1 = connection.prepareStatement(sql1);



			patsChangePline1.setObject(1,PlineCode);
			patsChangePline1.setObject(2,PlineCode);
			patsChangePline1.addBatch();
			patsChangePline1.executeBatch();

			core.setV_errMsg("修改成功！");
			core.setResult(1);
			connection.commit();
		}
		catch (Exception e) {
			core.setV_errMsg(e.getMessage());
			core.setV_errCode(-1);
			core.setResult(1);
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
				}
				catch (Exception e2) {
				}
			}
		}
		finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			}
			catch (Exception e2) {
			}
		}
		return core;
	}





	/**
	 *  打捆台账查询
	 * @param para  查询参数
	 * @return
	 */
	public CoreReturnObject doQueryBundingResult(HashMap<String,Object> para) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryBundingResult");

		if(para.containsKey("start") && para.get("start")!=null && !StringUtil.isEmpty(para.get("start").toString()) ){
			sql += " AND T.PRO_TIME >=TO_DATE('" + para.get("start")
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+  para.get("end") + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}


		if(para.containsKey("plineCodes") && para.get("plineCodes")!=null && para.get("plineCodes")  instanceof  String[] ) {
			sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", ( String[])  para.get("plineCodes"));
		}



		if(para.containsKey("shift") && para.get("shift")!=null && !StringUtil.isEmpty(para.get("shift").toString()) ){
			sql += " AND T.PRO_SHIFT='" + para.get("shift") + "'";
		}



		if(para.containsKey("group") && para.get("group")!=null && !StringUtil.isEmpty(para.get("group").toString()) ){
			sql += " AND T.PRO_GROUP ='" + para.get("group") + "'";
		}


		if(para.containsKey("orderNo") && para.get("orderNo")!=null && !StringUtil.isEmpty(para.get("orderNo").toString()) ){
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" +  para.get("orderNo") + "'";
		}

		if(para.containsKey("judgeStoveNo") && para.get("judgeStoveNo")!=null && !StringUtil.isEmpty(para.get("judgeStoveNo").toString()) ){
			sql += " AND T.JUDGE_STOVE_NO ='" +  para.get("judgeStoveNo")  + "'";
		}


		if(para.containsKey("batchNo") && para.get("batchNo")!=null && !StringUtil.isEmpty(para.get("batchNo").toString()) ){
			sql += " AND T.BATCH_NO ='" +   para.get("batchNo")  + "'";
		}

		sql += " Order by T.PRO_TIME";

		return this.getData(sql);
	}


	/**
	 * 查询倒凌
	 *
	 * @param para  查询参数
	 * @return
	 */
	public CoreReturnObject doQueryAppResult(HashMap<String,Object> para) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryAppResult");

		if(para.containsKey("start") && para.get("start")!=null && !StringUtil.isEmpty(para.get("start").toString()) ){
			sql += " AND T.PRO_TIME >=TO_DATE('" + para.get("start")
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+  para.get("end") + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}


		if(para.containsKey("plineCodes") && para.get("plineCodes")!=null && para.get("plineCodes")  instanceof  String[] ) {
			sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", ( String[])  para.get("plineCodes"));
		}



		if(para.containsKey("shift") && para.get("shift")!=null && !StringUtil.isEmpty(para.get("shift").toString()) ){
			sql += " AND T.PRO_SHIFT='" + para.get("shift") + "'";
		}



		if(para.containsKey("group") && para.get("group")!=null && !StringUtil.isEmpty(para.get("group").toString()) ){
			sql += " AND T.PRO_GROUP ='" + para.get("group") + "'";
		}


		if(para.containsKey("orderNo") && para.get("orderNo")!=null && !StringUtil.isEmpty(para.get("orderNo").toString()) ){
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" +  para.get("orderNo") + "'";
		}

		if(para.containsKey("judgeStoveNo") && para.get("judgeStoveNo")!=null && !StringUtil.isEmpty(para.get("judgeStoveNo").toString()) ){
			sql += " AND T.JUDGE_STOVE_NO ='" +  para.get("judgeStoveNo")  + "'";
		}


		if(para.containsKey("batchNo") && para.get("batchNo")!=null && !StringUtil.isEmpty(para.get("batchNo").toString()) ){
			sql += " AND T.BATCH_NO ='" +   para.get("batchNo")  + "'";
		}

		sql += " Order by T.PRO_TIME";


		return this.getData(sql);
	}




	/**
	 * 查询分切台账
	 *
	 * @param para  查询参数
	 * @return
	 */
	public CoreReturnObject doQueryCutResult(HashMap<String,Object> para) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryCutResult");
		if(para.containsKey("start") && para.get("start")!=null && !StringUtil.isEmpty(para.get("start").toString()) ){
			sql += " AND T.PRO_TIME >=TO_DATE('" + para.get("start")
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+  para.get("end") + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}


		if(para.containsKey("plineCodes") && para.get("plineCodes")!=null && para.get("plineCodes")  instanceof  String[] ) {
			sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", ( String[])  para.get("plineCodes"));
		}



		if(para.containsKey("shift") && para.get("shift")!=null && !StringUtil.isEmpty(para.get("shift").toString()) ){
			sql += " AND T.PRO_SHIFT='" + para.get("shift") + "'";
		}



		if(para.containsKey("group") && para.get("group")!=null && !StringUtil.isEmpty(para.get("group").toString()) ){
			sql += " AND T.PRO_GROUP ='" + para.get("group") + "'";
		}


		if(para.containsKey("orderNo") && para.get("orderNo")!=null && !StringUtil.isEmpty(para.get("orderNo").toString()) ){
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" +  para.get("orderNo") + "'";
		}

		if(para.containsKey("judgeStoveNo") && para.get("judgeStoveNo")!=null && !StringUtil.isEmpty(para.get("judgeStoveNo").toString()) ){
			sql += " AND T.JUDGE_STOVE_NO ='" +  para.get("judgeStoveNo")  + "'";
		}


		if(para.containsKey("batchNo") && para.get("batchNo")!=null && !StringUtil.isEmpty(para.get("batchNo").toString()) ){
			sql += " AND T.BATCH_NO ='" +   para.get("batchNo")  + "'";
		}

		sql += " Order by T.PRO_TIME";
		return this.getData(sql);
	}



	/**
	 * 查询抽检台账
	 *
	 * @param para  查询参数
	 * @return
	 */
	public CoreReturnObject doQueryFinalCheck(HashMap<String,Object> para) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryFinalCheck");



		if(para.containsKey("start") && para.get("start")!=null && !StringUtil.isEmpty(para.get("start").toString()) ){
			sql += " AND T.PRO_TIME >=TO_DATE('" + para.get("start")
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+  para.get("end") + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}


		if(para.containsKey("plineCodes") && para.get("plineCodes")!=null && para.get("plineCodes")  instanceof  String[] ) {
			sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", ( String[])  para.get("plineCodes"));
		}



		if(para.containsKey("shift") && para.get("shift")!=null && !StringUtil.isEmpty(para.get("shift").toString()) ){
			sql += " AND T.PRO_SHIFT='" + para.get("shift") + "'";
		}



		if(para.containsKey("group") && para.get("group")!=null && !StringUtil.isEmpty(para.get("group").toString()) ){
			sql += " AND T.PRO_GROUP ='" + para.get("group") + "'";
		}


		if(para.containsKey("orderNo") && para.get("orderNo")!=null && !StringUtil.isEmpty(para.get("orderNo").toString()) ){
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" +  para.get("orderNo") + "'";
		}

		if(para.containsKey("judgeStoveNo") && para.get("judgeStoveNo")!=null && !StringUtil.isEmpty(para.get("judgeStoveNo").toString()) ){
			sql += " AND T.JUDGE_STOVE_NO ='" +  para.get("judgeStoveNo")  + "'";
		}


		if(para.containsKey("batchNo") && para.get("batchNo")!=null && !StringUtil.isEmpty(para.get("batchNo").toString()) ){
			sql += " AND T.BATCH_NO ='" +   para.get("batchNo")  + "'";
		}


		if(para.containsKey("Status") && para.get("Status")!=null && !StringUtil.isEmpty(para.get("Status").toString()) ){
			if(para.get("Status").toString().equals("0")){
				sql +=" AND  (SELECT MAX(STATION_STATUS)\n" +
						"                  FROM MCH_COM_INFO\n" +
						"                 WHERE STATION_CODE = '701313'\n" +
						"                   AND HEAT_PLAN_NO = T.HEAT_PLAN_NO\n" +
						"                   AND BATCH_NO = T.BATCH_NO) != 2 ";
			}else if(para.get("Status").toString().equals("1")){
				sql +=" AND  (SELECT MAX(STATION_STATUS)\n" +
						"                  FROM MCH_COM_INFO\n" +
						"                 WHERE STATION_CODE = '701313'\n" +
						"                   AND HEAT_PLAN_NO = T.HEAT_PLAN_NO\n" +
						"                   AND BATCH_NO = T.BATCH_NO)  = 2 ";
			}
		}

		sql += " Order by T.PRO_TIME";

		return this.getData(sql);
	}



	/**
	 * 查询螺纹检验台账
	 *
	 * @param para  查询参数
	 * @return
	 */
	public CoreReturnObject doQueryHreadResult(HashMap<String,Object> para) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryHreadResult");
		if(para.containsKey("start") && para.get("start")!=null && !StringUtil.isEmpty(para.get("start").toString()) ){
			sql += " AND T.PRO_TIME >=TO_DATE('" + para.get("start")
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+  para.get("end") + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}


		if(para.containsKey("plineCodes") && para.get("plineCodes")!=null && para.get("plineCodes")  instanceof  String[] ) {
			sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", ( String[])  para.get("plineCodes"));
		}



		if(para.containsKey("shift") && para.get("shift")!=null && !StringUtil.isEmpty(para.get("shift").toString()) ){
			sql += " AND T.PRO_SHIFT='" + para.get("shift") + "'";
		}



		if(para.containsKey("group") && para.get("group")!=null && !StringUtil.isEmpty(para.get("group").toString()) ){
			sql += " AND T.PRO_GROUP ='" + para.get("group") + "'";
		}


		if(para.containsKey("orderNo") && para.get("orderNo")!=null && !StringUtil.isEmpty(para.get("orderNo").toString()) ){
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" +  para.get("orderNo") + "'";
		}

		if(para.containsKey("judgeStoveNo") && para.get("judgeStoveNo")!=null && !StringUtil.isEmpty(para.get("judgeStoveNo").toString()) ){
			sql += " AND T.JUDGE_STOVE_NO ='" +  para.get("judgeStoveNo")  + "'";
		}


		if(para.containsKey("batchNo") && para.get("batchNo")!=null && !StringUtil.isEmpty(para.get("batchNo").toString()) ){
			sql += " AND T.BATCH_NO ='" +   para.get("batchNo")  + "'";
		}

		sql += " Order by T.PRO_TIME";
		return this.getData(sql);
	}



	/**
	 * 查询上料台账
	 *
	 * @param para  查询参数
	 * @return
	 */
	public CoreReturnObject doQueryLoadResult(HashMap<String,Object> para) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryLoadResult1");
		if(para.containsKey("start") && para.get("start")!=null && !StringUtil.isEmpty(para.get("start").toString()) ){
			sql += " AND T.LOAD_TIME >=TO_DATE('" + para.get("start")
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.LOAD_TIME <=TO_DATE('"
					+  para.get("end") + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}


		if(para.containsKey("plineCodes") && para.get("plineCodes")!=null && para.get("plineCodes")  instanceof  String[] ) {
			sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", ( String[])  para.get("plineCodes"));
		}



		if(para.containsKey("shift") && para.get("shift")!=null && !StringUtil.isEmpty(para.get("shift").toString()) ){
			sql += " AND T.LOAD_SHIFT='" + para.get("shift") + "'";
		}



		if(para.containsKey("group") && para.get("group")!=null && !StringUtil.isEmpty(para.get("group").toString()) ){
			sql += " AND T.LOAD_GROUP ='" + para.get("group") + "'";
		}


		if(para.containsKey("orderNo") && para.get("orderNo")!=null && !StringUtil.isEmpty(para.get("orderNo").toString()) ){
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" +  para.get("orderNo") + "'";
		}

		if(para.containsKey("judgeStoveNo") && para.get("judgeStoveNo")!=null && !StringUtil.isEmpty(para.get("judgeStoveNo").toString()) ){
			sql += " AND T.JUDGE_STOVE_NO ='" +  para.get("judgeStoveNo")  + "'";
		}


		if(para.containsKey("batchNo") && para.get("batchNo")!=null && !StringUtil.isEmpty(para.get("batchNo").toString()) ){
			sql += " AND T.BATCH_NO ='" +   para.get("batchNo")  + "'";
		}

		sql += " Order by T.LOAD_TIME";
		return this.getData(sql);
	}


	/**
	 * 查询测量点台账
	 *
	 * @param para  查询参数
	 * @return
	 */
	public CoreReturnObject doQueryMeasureResult(HashMap<String,Object> para) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryMeasureResult");
		if(para.containsKey("start") && para.get("start")!=null && !StringUtil.isEmpty(para.get("start").toString()) ){
			sql += " AND T.PRO_TIME >=TO_DATE('" + para.get("start")
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+  para.get("end") + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}


		if(para.containsKey("plineCodes") && para.get("plineCodes")!=null && para.get("plineCodes")  instanceof  String[] ) {
			sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", ( String[])  para.get("plineCodes"));
		}



		if(para.containsKey("shift") && para.get("shift")!=null && !StringUtil.isEmpty(para.get("shift").toString()) ){
			sql += " AND T.PRO_SHIFT='" + para.get("shift") + "'";
		}



		if(para.containsKey("group") && para.get("group")!=null && !StringUtil.isEmpty(para.get("group").toString()) ){
			sql += " AND T.PRO_GROUP ='" + para.get("group") + "'";
		}


		if(para.containsKey("orderNo") && para.get("orderNo")!=null && !StringUtil.isEmpty(para.get("orderNo").toString()) ){
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" +  para.get("orderNo") + "'";
		}

		if(para.containsKey("judgeStoveNo") && para.get("judgeStoveNo")!=null && !StringUtil.isEmpty(para.get("judgeStoveNo").toString()) ){
			sql += " AND T.JUDGE_STOVE_NO ='" +  para.get("judgeStoveNo")  + "'";
		}


		if(para.containsKey("batchNo") && para.get("batchNo")!=null && !StringUtil.isEmpty(para.get("batchNo").toString()) ){
			sql += " AND T.BATCH_NO ='" +   para.get("batchNo")  + "'";
		}

		sql += " Order by T.PRO_TIME";
		return this.getData(sql);

	}




	/**
	 * 查询通径台账
	 *
	 * @param para  查询参数
	 * @return
	 */
	public CoreReturnObject doQueryPathResult(HashMap<String,Object> para) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryPathResult");

		if(para.containsKey("start") && para.get("start")!=null && !StringUtil.isEmpty(para.get("start").toString()) ){
			sql += " AND T.PRO_TIME >=TO_DATE('" + para.get("start")
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+  para.get("end") + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}


		if(para.containsKey("plineCodes") && para.get("plineCodes")!=null && para.get("plineCodes")  instanceof  String[] ) {
			sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", ( String[])  para.get("plineCodes"));
		}



		if(para.containsKey("shift") && para.get("shift")!=null && !StringUtil.isEmpty(para.get("shift").toString()) ){
			sql += " AND T.PRO_SHIFT='" + para.get("shift") + "'";
		}



		if(para.containsKey("group") && para.get("group")!=null && !StringUtil.isEmpty(para.get("group").toString()) ){
			sql += " AND T.PRO_GROUP ='" + para.get("group") + "'";
		}


		if(para.containsKey("orderNo") && para.get("orderNo")!=null && !StringUtil.isEmpty(para.get("orderNo").toString()) ){
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" +  para.get("orderNo") + "'";
		}

		if(para.containsKey("judgeStoveNo") && para.get("judgeStoveNo")!=null && !StringUtil.isEmpty(para.get("judgeStoveNo").toString()) ){
			sql += " AND T.JUDGE_STOVE_NO ='" +  para.get("judgeStoveNo")  + "'";
		}


		if(para.containsKey("batchNo") && para.get("batchNo")!=null && !StringUtil.isEmpty(para.get("batchNo").toString()) ){
			sql += " AND T.BATCH_NO ='" +   para.get("batchNo")  + "'";
		}

		sql += " Order by T.PRO_TIME";
		return this.getData(sql);
	}


	/**
	 * 查询剩磁台账
	 *
	 * @param para  查询参数
	 * @return
	 */
	public CoreReturnObject doQueryRemanenceResult(HashMap<String,Object> para) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryRemanenceResult");

		if(para.containsKey("start") && para.get("start")!=null && !StringUtil.isEmpty(para.get("start").toString()) ){
			sql += " AND T.PRO_TIME >=TO_DATE('" + para.get("start")
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+  para.get("end") + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}


		if(para.containsKey("plineCodes") && para.get("plineCodes")!=null && para.get("plineCodes")  instanceof  String[] ) {
			sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", ( String[])  para.get("plineCodes"));
		}



		if(para.containsKey("shift") && para.get("shift")!=null && !StringUtil.isEmpty(para.get("shift").toString()) ){
			sql += " AND T.PRO_SHIFT='" + para.get("shift") + "'";
		}



		if(para.containsKey("group") && para.get("group")!=null && !StringUtil.isEmpty(para.get("group").toString()) ){
			sql += " AND T.PRO_GROUP ='" + para.get("group") + "'";
		}


		if(para.containsKey("orderNo") && para.get("orderNo")!=null && !StringUtil.isEmpty(para.get("orderNo").toString()) ){
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" +  para.get("orderNo") + "'";
		}

		if(para.containsKey("judgeStoveNo") && para.get("judgeStoveNo")!=null && !StringUtil.isEmpty(para.get("judgeStoveNo").toString()) ){
			sql += " AND T.JUDGE_STOVE_NO ='" +  para.get("judgeStoveNo")  + "'";
		}


		if(para.containsKey("batchNo") && para.get("batchNo")!=null && !StringUtil.isEmpty(para.get("batchNo").toString()) ){
			sql += " AND T.BATCH_NO ='" +   para.get("batchNo")  + "'";
		}

		sql += " Order by T.PRO_TIME";
		return this.getData(sql);
	}




	/**
	 * 查询车丝台账
	 *
	 * @param para  查询参数
	 * @return
	 */
	public CoreReturnObject doQueryThreaderResult(HashMap<String,Object> para) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryThreaderResult");
		if(para.containsKey("start") && para.get("start")!=null && !StringUtil.isEmpty(para.get("start").toString()) ){
			sql += " AND T.PRO_TIME >=TO_DATE('" + para.get("start")
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+  para.get("end") + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}


		if(para.containsKey("plineCodes") && para.get("plineCodes")!=null && para.get("plineCodes")  instanceof  String[] ) {
			sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", ( String[])  para.get("plineCodes"));
		}



		if(para.containsKey("shift") && para.get("shift")!=null && !StringUtil.isEmpty(para.get("shift").toString()) ){
			sql += " AND T.PRO_SHIFT='" + para.get("shift") + "'";
		}



		if(para.containsKey("group") && para.get("group")!=null && !StringUtil.isEmpty(para.get("group").toString()) ){
			sql += " AND T.PRO_GROUP ='" + para.get("group") + "'";
		}


		if(para.containsKey("orderNo") && para.get("orderNo")!=null && !StringUtil.isEmpty(para.get("orderNo").toString()) ){
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" +  para.get("orderNo") + "'";
		}

		if(para.containsKey("judgeStoveNo") && para.get("judgeStoveNo")!=null && !StringUtil.isEmpty(para.get("judgeStoveNo").toString()) ){
			sql += " AND T.JUDGE_STOVE_NO ='" +  para.get("judgeStoveNo")  + "'";
		}


		if(para.containsKey("batchNo") && para.get("batchNo")!=null && !StringUtil.isEmpty(para.get("batchNo").toString()) ){
			sql += " AND T.BATCH_NO ='" +   para.get("batchNo")  + "'";
		}

		sql += " Order by T.PRO_TIME";
		return this.getData(sql);
	}


	/**
	 * 查询入库检验处置单
	 *
	 * @param para  查询参数
	 * @return
	 */
	public CoreReturnObject doQueryTreatment(HashMap<String,Object> para) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryTreatment");


		if(para.containsKey("start") && para.get("start")!=null && !StringUtil.isEmpty(para.get("start").toString()) ){
			sql += " AND T.PRO_TIME >=TO_DATE('" + para.get("start")
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+  para.get("end") + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}


		if(para.containsKey("plineCodes") && para.get("plineCodes")!=null && para.get("plineCodes")  instanceof  String[] ) {
			sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", ( String[])  para.get("plineCodes"));
		}



		if(para.containsKey("shift") && para.get("shift")!=null && !StringUtil.isEmpty(para.get("shift").toString()) ){
			sql += " AND T.REPLY_SHIFT='" + para.get("shift") + "'";
		}



		if(para.containsKey("group") && para.get("group")!=null && !StringUtil.isEmpty(para.get("group").toString()) ){
			sql += " AND T.REPLY_GROUP ='" + para.get("group") + "'";
		}


		if(para.containsKey("orderNo") && para.get("orderNo")!=null && !StringUtil.isEmpty(para.get("orderNo").toString()) ){
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" +  para.get("orderNo") + "'";
		}

		if(para.containsKey("judgeStoveNo") && para.get("judgeStoveNo")!=null && !StringUtil.isEmpty(para.get("judgeStoveNo").toString()) ){
			sql += " AND T.JUDGE_STOVE_NO ='" +  para.get("judgeStoveNo")  + "'";
		}


		if(para.containsKey("batchNo") && para.get("batchNo")!=null && !StringUtil.isEmpty(para.get("batchNo").toString()) ){
			sql += " AND T.BATCH_NO ='" +   para.get("batchNo")  + "'";
		}

		if(para.containsKey("responsibleCode") && para.get("responsibleCode")!=null && !StringUtil.isEmpty(para.get("responsibleCode").toString()) ){

			sql +=  " AND T.RESPONSIBLE_CODE = '" +para.containsKey("responsibleCode")  + "'";
		}else{
			sql +=  " AND T.RESPONSIBLE_CODE IS NULL ";
		}

		if(para.containsKey("status") && para.get("status")!=null && !StringUtil.isEmpty(para.get("status").toString()) ){

			sql +=  " AND T.APPROVAL_STATUS = '" +para.containsKey("status") + "'";
		}


		sql += " Order by T.PRO_TIME";
		return this.getData(sql);
	}

	/**
	 * 查询拧接台账
	 *
	 * @param para  查询参数
	 * @return
	 */
	public CoreReturnObject doQueryTwistinResult(HashMap<String,Object> para) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryTwistinResult");

		if(para.containsKey("start") && para.get("start")!=null && !StringUtil.isEmpty(para.get("start").toString()) ){
			sql += " AND T.PRO_TIME >=TO_DATE('" + para.get("start")
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+  para.get("end") + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}


		if(para.containsKey("plineCodes") && para.get("plineCodes")!=null && para.get("plineCodes")  instanceof  String[] ) {
			sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", ( String[])  para.get("plineCodes"));
		}



		if(para.containsKey("shift") && para.get("shift")!=null && !StringUtil.isEmpty(para.get("shift").toString()) ){
			sql += " AND T.PRO_SHIFT='" + para.get("shift") + "'";
		}



		if(para.containsKey("group") && para.get("group")!=null && !StringUtil.isEmpty(para.get("group").toString()) ){
			sql += " AND T.PRO_GROUP ='" + para.get("group") + "'";
		}


		if(para.containsKey("orderNo") && para.get("orderNo")!=null && !StringUtil.isEmpty(para.get("orderNo").toString()) ){
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" +  para.get("orderNo") + "'";
		}

		if(para.containsKey("judgeStoveNo") && para.get("judgeStoveNo")!=null && !StringUtil.isEmpty(para.get("judgeStoveNo").toString()) ){
			sql += " AND T.JUDGE_STOVE_NO ='" +  para.get("judgeStoveNo")  + "'";
		}


		if(para.containsKey("batchNo") && para.get("batchNo")!=null && !StringUtil.isEmpty(para.get("batchNo").toString()) ){
			sql += " AND T.BATCH_NO ='" +   para.get("batchNo")  + "'";
		}


		if(para.containsKey("judgeStoveNoJg") && para.get("judgeStoveNoJg")!=null && !StringUtil.isEmpty(para.get("judgeStoveNoJg").toString()) ){
			sql += "  AND EXISTS" +
					" (SELECT * FROM MCH_TWISTINGLY_RESULT_D WHERE RESULT_NO = T.RESULT_NO " +
					"AND   COUPLING_STOVE_NO ='" + para.get("judgeStoveNoJg")   + "')";
		}


		if(para.containsKey("batchNoJg") && para.get("batchNoJg")!=null && !StringUtil.isEmpty(para.get("batchNoJg").toString()) ){
			sql += "  AND EXISTS" +
					" (SELECT * FROM MCH_TWISTINGLY_RESULT_D WHERE RESULT_NO = T.RESULT_NO " +
					"AND   LOT_NO ='" + para.get("batchNoJg")   + "')";
		}

		sql += " Order by T.PRO_TIME";


		return this.getData(sql);

	}
	public CoreReturnObject doConfirmFrimResult(ArrayList<String> parmList)
	{
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		try {

			for(String str: parmList)
			{

				sql = CoreXmlSqlParsersFactory.getSql("FrmJgxReport.doConfirmFrimResult");
				sql+="='"+str+"'";
				psta = connection.prepareStatement(sql);
				rs = psta.executeQuery();

				rs.close();
				psta.close();

			}

			if(cro.getV_errMsg().equals(""))
			{
				cro.setV_errMsg("审核成功！");
			}
		} catch (Exception e) {
			System.out.println(e.getMessage());
			if (connection != null) {
				try {
					cro.setV_errMsg(e.getMessage());
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}
	public CoreReturnObject doSendFrimResult(ArrayList<String> parmList)
	{
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		try {

			for(String str: parmList)
			{

				sql = CoreXmlSqlParsersFactory.getSql("FrmJgxReport.doSendFrimResult");
				sql+="='"+str+"'";
				psta = connection.prepareStatement(sql);
				rs = psta.executeQuery();

				rs.close();
				psta.close();

			}

			if(cro.getV_errMsg().equals(""))
			{
				cro.setV_errMsg("送审成功！");
			}
		} catch (Exception e) {
			System.out.println(e.getMessage());
			if (connection != null) {
				try {
					cro.setV_errMsg(e.getMessage());
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}
	/**
	 * 查询超声探伤台账
	 *
	 * @param para  查询参数
	 * @return
	 */
	public CoreReturnObject doQueryUtResult(HashMap<String,Object> para) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryUtResult");


		if(para.containsKey("start") && para.get("start")!=null && !StringUtil.isEmpty(para.get("start").toString()) ){
			sql += " AND T.COL_TIME >=TO_DATE('" + para.get("start")
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.COL_TIME <=TO_DATE('"
					+  para.get("end") + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}


		if(para.containsKey("plineCodes") && para.get("plineCodes")!=null && para.get("plineCodes")  instanceof  String[] ) {
			sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", ( String[])  para.get("plineCodes"));
		}



		if(para.containsKey("shift") && para.get("shift")!=null && !StringUtil.isEmpty(para.get("shift").toString()) ){
			sql += " AND T.COL_SHIFT='" + para.get("shift") + "'";
		}



		if(para.containsKey("group") && para.get("group")!=null && !StringUtil.isEmpty(para.get("group").toString()) ){
			sql += " AND T.COL_GROUP ='" + para.get("group") + "'";
		}


		if(para.containsKey("orderNo") && para.get("orderNo")!=null && !StringUtil.isEmpty(para.get("orderNo").toString()) ){
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" +  para.get("orderNo") + "'";
		}

		if(para.containsKey("judgeStoveNo") && para.get("judgeStoveNo")!=null && !StringUtil.isEmpty(para.get("judgeStoveNo").toString()) ){
			sql += " AND T.JUDGE_STOVE_NO ='" +  para.get("judgeStoveNo")  + "'";
		}


		if(para.containsKey("batchNo") && para.get("batchNo")!=null && !StringUtil.isEmpty(para.get("batchNo").toString()) ){
			sql += " AND T.BATCH_NO ='" +   para.get("batchNo")  + "'";
		}

		sql += " Order by T.COL_TIME";
		return this.getData(sql);

	}


	/**
	 * 查询水压台账
	 *
	 * @param para  查询参数
	 * @return
	 */
	public CoreReturnObject doQueryWaterResult(HashMap<String,Object> para) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryWaterResult");
		if(para.containsKey("start") && para.get("start")!=null && !StringUtil.isEmpty(para.get("start").toString()) ){
			sql += " AND T.PRO_TIME >=TO_DATE('" + para.get("start")
					+ "', 'YYYY-MM-DD HH24:MI:SS')AND T.PRO_TIME <=TO_DATE('"
					+  para.get("end") + "', 'YYYY-MM-DD HH24:MI:SS') ";
		}


		if(para.containsKey("plineCodes") && para.get("plineCodes")!=null && para.get("plineCodes")  instanceof  String[] ) {
			sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", ( String[])  para.get("plineCodes"));
		}



		if(para.containsKey("shift") && para.get("shift")!=null && !StringUtil.isEmpty(para.get("shift").toString()) ){
			sql += " AND T.PRO_SHIFT='" + para.get("shift") + "'";
		}



		if(para.containsKey("group") && para.get("group")!=null && !StringUtil.isEmpty(para.get("group").toString()) ){
			sql += " AND T.PRO_GROUP ='" + para.get("group") + "'";
		}


		if(para.containsKey("orderNo") && para.get("orderNo")!=null && !StringUtil.isEmpty(para.get("orderNo").toString()) ){
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" +  para.get("orderNo") + "'";
		}

		if(para.containsKey("judgeStoveNo") && para.get("judgeStoveNo")!=null && !StringUtil.isEmpty(para.get("judgeStoveNo").toString()) ){
			sql += " AND T.JUDGE_STOVE_NO ='" +  para.get("judgeStoveNo")  + "'";
		}


		if(para.containsKey("batchNo") && para.get("batchNo")!=null && !StringUtil.isEmpty(para.get("batchNo").toString()) ){
			sql += " AND T.BATCH_NO ='" +   para.get("batchNo")  + "'";
		}

		sql += " Order by T.PRO_TIME";
		return this.getData(sql);
	}


	/**
	 * 查询已审核废品台账
	 *
	 * @param para  查询参数
	 * @return
	 */
	public CoreReturnObject doQueryMchWaste(HashMap<String,Object> para) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmJgxReport.doQueryMchWaste");
		if(para.containsKey("YearMonthStart") && para.get("YearMonthStart")!=null && !StringUtil.isEmpty(para.get("YearMonthStart").toString()) ){
			sql += " AND T.BAL_YEAR_MONTH_FAIL >= '" + para.get("YearMonthStart")
					+ "' AND T.BAL_YEAR_MONTH_FAIL <= '"
					+  para.get("YearMonthEnd") + "' ";
		}


		if(para.containsKey("plineCodes") && para.get("plineCodes")!=null && para.get("plineCodes")  instanceof  String[] ) {
			sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", ( String[])  para.get("plineCodes"));
		}



		if(para.containsKey("orderNo") && para.get("orderNo")!=null && !StringUtil.isEmpty(para.get("orderNo").toString()) ){
			sql += " AND M.ORDER_NO||'/'|| M.ORDER_SEQ ='" +  para.get("orderNo") + "'";
		}

		if(para.containsKey("judgeStoveNo") && para.get("judgeStoveNo")!=null && !StringUtil.isEmpty(para.get("judgeStoveNo").toString()) ){
			sql += " AND T.JUDGE_STOVE_NO ='" +  para.get("judgeStoveNo")  + "'";
		}


		if(para.containsKey("batchNo") && para.get("batchNo")!=null && !StringUtil.isEmpty(para.get("batchNo").toString()) ){
			sql += " AND T.PHY_BATCH_NO ='" +   para.get("batchNo")  + "'";
		}

		sql += " Order by T.BAL_YEAR_MONTH_FAIL, T.PLINE_CODE, T.JUDGE_STOVE_NO, T.PHY_BATCH_NO ";
		return this.getData(sql);
	}




}
