package com.steering.mes.mcp.common;

import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;
import com.steering.comm.converter.CoreConverter;
import com.steering.comm.db.DBCommon;

/**
 * @Author xiay
 * @Date 2020/12/28 17:40
 * @Version 1.0
 */
public class FrmHttInitialRpt extends DBCommon {

    public CoreReturnObject doQuery(String BalYearMonth, String[] plineCode , String ProStation, String Type, String JudgeStove) {

        String sql = CoreXmlSqlParsersFactory.getSql("FrmHttInitialRpt.query");

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

            sql+=" AND T.PLINE_CODE IN (SELECT PLINE_CODE FROM COM_BASE_PLINE WHERE FACTORY_CODE = '"+ProStation+"')";
        }

        if(Type.equals("0")){
            sql+=" AND  T.PRODUCCODE  IN ('S000094','S000082','S000040')";
        } else  if(Type.equals("1")){
            sql+=" AND  T.PRODUCCODE  NOT IN ('S000094','S000082','S000040')";
        }

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

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

        if(plineCode.length>0){
            sql+= CoreConverter.toSqlConditionString("T.PLINE_CODE", plineCode);
        }

        return this.getData(sql);
    }
}
