package com.steering.pss.sale.order;

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

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

public class CoreSaleAccountQuery extends DBCommon {

    /**
     * 初始化客户信息
     * @return
     */
    public CoreReturnObject initCustomerData() {
        return this.getDataBySqlID("CoreSaleAccountQuery.InitCustomerData");
    }

    /**
     * 查询数据
     * @param yearMon
     * @param saleOrg
     * @return
     */
    public CoreReturnObject query(String yearMon, String saleOrg, String[] arr) {

        String sql = "";
        if (saleOrg.equals("销售公司")) {
            sql = CoreXmlSqlParsersFactory
                    .getSql("CoreSaleAccountQuery.QueryXS");
            sql += CoreConverter.toSqlConditionString(" DEPARTID", arr);
        }
        else {
            sql = CoreXmlSqlParsersFactory
                    .getSql("CoreSaleAccountQuery.QueryGM");
            sql += CoreConverter.toSqlConditionString(" DEPARTID", arr);
        }

        sql = sql.replaceAll("#TIME#", yearMon);
        sql = sql.replaceAll("#SALEORG#", saleOrg);

        return this.getData(sql);

    }

}
