package com.steering.pss.judge.DAL;

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

import com.steering.comm.db.DBCommon;
import com.steering.comm.tools.SqlBuilder;

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

 /**
     * 通用查询
     */
    public CoreReturnObject Query(String bofStartTime, String bofEndTime, String judgeState,
    		String stoveNo, String judgeStoveNo, String proPlanId, String queryType){
    	SqlBuilder b;
    	if(queryType.equals("Cic")){
    		b = new SqlBuilder("PlnSteelforOrdDAL.QueryCic");
    	}else if(queryType.equals("Pic")){
    		b = new SqlBuilder("PlnSteelforOrdDAL.QueryPic");
    	}else{
    		b = new SqlBuilder("PlnSteelforOrdDAL.QueryColligate");
    	}
        b.AppendLn("AND T.DOWNTIME >= TO_DATE({0}, 'YYYY-MM-DD HH24:MI:SS')", !bofStartTime.equals(""));
        b.AppendLn("AND T.DOWNTIME <= TO_DATE({1}, 'YYYY-MM-DD HH24:MI:SS')", !bofEndTime.equals(""));
        b.AppendLn("AND T.CHEM_JUDGE_ID IS NULL", judgeState.equals("0"));
        b.AppendLn("AND T.CHEM_JUDGE_ID IS NOT NULL", judgeState.equals("1"));
        b.AppendLn("AND T.STOVE_NO LIKE '%' || {2} || '%'", !stoveNo.equals(""));
        b.AppendLn("AND T.JUDGE_STOVE_NO LIKE '%' || {3} || '%'", !judgeStoveNo.equals(""));
        b.AppendLn("AND T.PRO_PLAN_ID LIKE '%' || {4} || '%'", !proPlanId.equals(""));
        //b.AppendLn("AND ROWNUM <= 1");
        b.AppendLn("GROUP BY T.STOVE_NO, T.JUDGE_STOVE_NO");
        b.Fill(new String[]{ bofStartTime, bofEndTime, stoveNo, judgeStoveNo, proPlanId });
        
        return this.getData(b.toString());
    }

    /**
     * 通过主键查询
     */
    public CoreReturnObject QueryByPk(String furnaceno, String sequenceno){
        String sqlQuery = CoreXmlSqlParsersFactory.getSql("PlnSteelforOrdDAL.QueryByPk");
        return this.getData(sqlQuery);
    }
}
