package com.steering.pss.ydm.Report;

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

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

public class FrmOutBoundSum extends DBCommon {

    public CoreReturnObject getGpDataB(String statTime, String endTime,
            String biegTime, String juNo, String ordeNo, String[] arr,String supplyUnit) {
        String sql = CoreXmlSqlParsersFactory
                .getSql("FrmOutBoundSum.getGpDataB");
        sql += CoreConverter.toSqlConditionString("T.BELONG_CODE", arr);
        if (!statTime.equals("")) {
            sql += "  AND T.CREATE_TIME BETWEEN  TO_DATE('" + statTime
                    + "','YYYY-MM-DD HH24:MI:SS') AND TO_DATE('" + endTime
                    + "','YYYY-MM-DD HH24:MI:SS') ";
        }
        if (!biegTime.equals("")) {
            sql += " AND T.BAL_YEAR_MONTH='" + biegTime + "'";
        }
        if (!juNo.equals("")) {
            sql += " AND T.JUDGE_STOVE_NO =  '" + juNo + "'";
        }
        if (!ordeNo.equals("")) {
            sql += " AND T.ORDER_NO||'/'||T.ORDER_SEQ = '" + ordeNo +"'";
        }
        if(supplyUnit.equals("120501"))
        {
            sql += " AND (T.SUPPLY_UNIT_CODE = '"+supplyUnit+"' OR T.SUPPLY_UNIT_CODE IS NULL)";
        }else if(supplyUnit.equals("120504")){
            sql += " AND T.SUPPLY_UNIT_CODE = '"+supplyUnit+"'";
        }
        sql += "  GROUP BY  T.RECEIV_NM,T1.RECEIV_NM,T.JUDGE_STOVE_NO, T.BATCH_NO, T.BATCH_GROUD_NO, T.MATERIAL_NAME, T.PRODUCNAME, "
                + "T.STD_NAME, T.GRADENAME, T.STEELNAME, T.STD_STYLE_DESC, T.SPEC_NAME, T.MODEL_DESC, T.PLINE_NAME, "
                + "T.ACT_LEN_MIN, T.ACT_LEN_MAX, T.BELONG_NAME, T.STORAGE_NO, T.ORD_PK, T.MANAGEMENT_NAME, "
                + "T.CREATE_NAME, T.ORD_LN_DLY_PK, T.DEPARTMENT_DESC, T.ORDER_NO, T.ORDER_SEQ, "
                + "T.DELIVERY_NO, T.PRODUCT_FLAG, T.PONDER_NO, T.BILL_NO,T.BAL_YEAR_MONTH, T.OUTSTOCK_TYPE_CODE,"
                + " T.OUTSTOCK_TYPE_NAME,T.IN_MOLD,T.FINISHPRO_MOLD,T.PRO_ORDER_NO";
        return this.getData(sql);
    }
}
