package com.steering.mes.zgmil.report;

import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;

import com.steering.comm.converter.CoreConverter;
import com.steering.comm.db.DBCommon;

public class FrmMilQualityEvaluation extends DBCommon {

	/**
	 *查询外观检测质量原始记录
	 */
	public CoreReturnObject queryMinResult(String date, String endDate,
			String bc, String bz,String JudgeStoveNo, String[] plineCodes) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmMilQualityEvaluation.queryMinResult");
		if (!date.equals("")) {
			sql += " AND T.END_TIME BETWEEN TO_DATE('" + date
					+ "' ,'YYYY-MM-DD HH24:MI:SS') AND TO_DATE('" + endDate
					+ "' ,'YYYY-MM-DD HH24:MI:SS') ";
		}
		if (!bc.equals("")) {
			sql += "  AND T.COL_SHIFT = '" + bc + "' ";
		}
		if (!bz.equals("")) {
			sql += " AND T.COL_GROUP = '" + bz + "' ";
		}
		if (!JudgeStoveNo.equals("")) {
			sql += " AND T.JUDGE_STOVE_NO LIKE '%" + JudgeStoveNo + "%' ";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plineCodes);
		sql += "ORDER BY T.JUDGE_STOVE_NO,T.END_TIME";
		return this.getData(sql);
	}
	
	public CoreReturnObject queryMinResultFeiPing(String date, String endDate,
			String bc, String bz, String[] plineCodes, String JudgeStoveNo) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmMilQualityEvaluation.queryMinResultFeiPing");
		if (!date.equals("")) {
			sql += " AND T.END_TIME BETWEEN TO_DATE('" + date
					+ "' ,'YYYY-MM-DD HH24:MI:SS') AND TO_DATE('" + endDate
					+ "' ,'YYYY-MM-DD HH24:MI:SS') ";
		}
		if (!bc.equals("")) {
			sql += "  AND T.COL_SHIFT = '" + bc + "' ";
		}
		if (!bz.equals("")) {
			sql += " AND T.COL_GROUP = '" + bz + "' ";
		}
		sql += CoreConverter.toSqlConditionString("T.PLINE_CODE", plineCodes);
		if (!JudgeStoveNo.equals("")) {
			sql += " AND T.JUDGE_STOVE_NO LIKE '%" + JudgeStoveNo + "%' ";
		}
		sql += "ORDER BY T.JUDGE_STOVE_NO,T.END_TIME";
		return this.getData(sql);
	}

	/**
	 * 查询外观检测上料管号队列表
	 * 
	 * @return
	 */
	public CoreReturnObject getSurfaceRackSeq(String str_JudgeStove_No,
			String OffLineFlag) {
		return this.getDataBySqlID("FrmMilQualityEvaluation.getSurfaceRackSeq",
				new Object[] { str_JudgeStove_No });
	}

	/***
	 * 查询指定炉号的缺陷项
	 * 
	 * @param jugeNo
	 * @return
	 */
	public CoreReturnObject getDefectData(String jugeNo) {
		return this.getDataBySqlID("FrmMilQualityEvaluation.getDefectData",
				new Object[] { jugeNo });
	}

	/**
	 * 几何尺寸抽检管查询
	 * 
	 * @return
	 */
	public CoreReturnObject sizeCheckQuery(String JudgeStoveNo) {
		return this.getDataBySqlID("FrmMilQualityEvaluation.SizeCheckQuery",
				new Object[] { JudgeStoveNo });
	}
}
