package com.steering.pss.sale.order;

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

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

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

/**
 * 排产信息(报表)
 * @author Administrator
 */
public class CoreSchedulingInfomation extends DBCommon {
    /**
     * 查询排产信息
     * @param orderNo 合同头号
     * @param begintime 开始时间
     * @param endtime 结束时间
     * @param dataPurviews 数据权限
     * @return CoreReturnObject
     */
    public CoreReturnObject getSchedulingInfo(String orderNo, String begintime,
            String endtime, String[] dataPurviews) {
        String sql = CoreXmlSqlParsersFactory
                .getSql("CoreSchedulingInfomation.getSchedulingInfo");
        List<String> params = new ArrayList<String>();
        params.add(orderNo);
        if (!begintime.equals("") && !endtime.equals("")) {
            sql += " AND T1.CREATE_TIME BETWEEN TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')  AND TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')";
            params.add(begintime);
            params.add(endtime);
        }
        String dataStr = CoreConverter.toSqlConditionString(" T2.CREATE_DEPT",
                dataPurviews);
        //sql = sql.replace("#CONDITION#", dataStr);
        sql += " ORDER BY T1.ORDER_NO, T1.ORDER_SEQ, T1.DELIVERY_NO,T1.CREATE_TIME";
        //System.out.println(sql);
        return this.getData(sql, params.toArray());
    }

    /**
     * 查询某一行的数据
     * @param ordLnPk
     * @return
     */
    public CoreReturnObject getSchedulingInfoByLnPk(String ordLnPk) {
        String sql = CoreXmlSqlParsersFactory
                .getSql("CoreSchedulingInfomation.getSchedulingInfoByOrdLnPk");
        return this.getData(sql, new Object[] { ordLnPk, ordLnPk, ordLnPk,
                ordLnPk, ordLnPk, ordLnPk });
    }
}
