package com.steering.pss.ydm.Report;

import java.util.ArrayList;
import java.util.List;

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

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

public class FrmOrderStock extends DBCommon {
    public CoreReturnObject getOrderStockInfo(String orderNo, String beginTime,
            String endTime, String[] dataPurviews) {
        String sql = CoreXmlSqlParsersFactory
                .getSql("FrmOrderStock.getOrderStockInfo");
        List<String> params = new ArrayList<String>();
        params.add(orderNo);
        if (!beginTime.equals("") && !endTime.equals("")) {
//            params.add(beginTime);
//            params.add(endTime);
            sql += "  AND T1.CREATE_TIME BETWEEN TO_DATE('" + beginTime
                    + "', 'YYYY-MM-DD HH24:MI:SS')  " + " AND TO_DATE('"
                    + endTime + "', 'YYYY-MM-DD HH24:MI:SS')";
        }
        sql += CoreConverter.toSqlConditionString("T1.BELONG_CODE",
                dataPurviews);
        sql += "  GROUP BY T1.ORDER_NO,T1.ORDER_SEQ,T1.JUDGE_STOVE_NO,T1.BATCH_NO,T1.BATCH_GROUD_NO,T1.SPEC_NAME,T1.PRODUCNAME,T1.GRADENAME,T1.SPEC_NAME,T1.MODEL_DESC,T1.STD_NAME";
        sql += " ORDER BY T1.ORDER_NO,T1.ORDER_SEQ,T1.JUDGE_STOVE_NO,T1.BATCH_NO,T1.BATCH_GROUD_NO";
        return this.getData(sql, params.toArray());
    }
}
