package com.steering.pss.judge.DAL;

import com.steering.comm.db.DBCommon;
import com.steering.comm.tools.SqlBuilder;
import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;

/**
 * 数据库表PORT_MIL_BATCH_SAMPLE_RESULT所对应的Java类（生成工具：代码生成工具4.0   访问地址：http://172.16.2.128/tool/）
 * @author tgcx-test   date 2016-11-14
 */
public class PortMilBatchSampleResultDAL extends DBCommon{

 /**Query
     * 通用查询
     */
    public CoreReturnObject Query(String timeBegin, String timeEnd, String judgeState,
    		String judgeStoveNo, String proPlanId, Integer judgeType){
    	String strJudgeType = judgeType.toString();
        SqlBuilder b = new SqlBuilder("PortMilBatchSampleResultDAL.Query");
        b.AppendLn("AND T.CRATE_TIME >= TO_DATE({0}, 'YYYY-MM-DD HH24:MI:SS')", !timeBegin.equals(""));
        b.AppendLn("AND T.CRATE_TIME <= TO_DATE({1}, 'YYYY-MM-DD HH24:MI:SS')", !timeEnd.equals(""));
        b.AppendLn("AND T.CHEM_RESULT_CODE IS NULL", strJudgeType.endsWith("1") && judgeState.equals("0"));
        b.AppendLn("AND T.CHEM_RESULT_CODE IS NOT NULL", strJudgeType.endsWith("1") && judgeState.equals("1"));
        b.AppendLn("AND T.PHY_RESULT_CODE IS NULL", strJudgeType.endsWith("2") && judgeState.equals("0"));
        b.AppendLn("AND T.PHY_RESULT_CODE IS NOT NULL", strJudgeType.endsWith("2") && judgeState.equals("1"));
        b.AppendLn("AND T.JUDGE_STOVE_NO = {2}", !judgeStoveNo.equals(""));
        b.AppendLn("AND A.PRO_PLAN_ID = {3}", !proPlanId.equals(""));
        b.AppendLn("GROUP BY T.JUDGE_STOVE_NO");
        b.Fill(new String[]{timeBegin, timeEnd, judgeStoveNo, proPlanId});
        return this.getData(b.toString());
    }

    /**
     * 通过主键查询
     */
    public CoreReturnObject QueryByPk(String planId, String lotNo, String judgeStoveNo, String seq){
        String sqlQuery = CoreXmlSqlParsersFactory.getSql("PortMilBatchSampleResultDAL.QueryByPk");
        return this.getData(sqlQuery);
    }
}
