package com.steering.ydm.bc;

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

import java.util.ArrayList;


public class FrmStorageInfo extends DBCommon {

    public CoreReturnObject doQuery(String[] arr, ArrayList<Object> list) {
        String sql = CoreXmlSqlParsersFactory.getSql("FrmStorageInfo.doQuery");
        StringBuffer strNo = new StringBuffer();
        for (String arg : arr) {
            if (arg != null) {
                strNo.append("'");
                strNo.append(arg);
                strNo.append("',");
            }
        }
        if(arr.length>0){
            strNo.deleteCharAt(strNo.lastIndexOf(","));
            sql = sql.replace("#STORAGE_NO#", "AND T2.STORAGE_NO IN("+strNo+")");
        }else{
            sql = sql.replace("#STORAGE_NO#", "");
        }
        if (!list.get(0).equals("")) {
            sql = sql.replace("#STORAGE_NAME#", " AND S.STORAGE_NAME LIKE '%" + list.get(0) + "%'");
        } else {
            sql = sql.replace("#STORAGE_NAME#", "");
        }
        if (!list.get(1).equals("")) {
            sql = sql.replace("#LOCATION_NAME#", " AND B.LOCATION_NAME LIKE '%" + list.get(1) + "%'");
        } else {
            sql = sql.replace("#LOCATION_NAME#", "");
        }
//        if (!list.get(0).equals("")){
//            sql +=" AND B.STORAGE_NAME LIKE '%"+list.get(0)+"%'";
//        }
//        if (!list.get(1).equals("")){
//            sql +=" AND T.LOCATION_NAME LIKE '%"+list.get(1)+"%'";
//        }
        return this.getData(sql);
    }
}
