package com.steering.pss.plnsaleord.order;

import java.util.ArrayList;

import com.steering.comm.db.DBCommon;

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

/**
 * 排产合同分解综合查询
 * @author xiaohai
 */
public class CoreQueryOrdProcInf extends DBCommon {
    /**
     * 查询
     * @param list
     * @return
     */
    public CoreReturnObject queryOrdProcInf(ArrayList<Object> list,String startTim,String endTim) {
        CoreReturnObject cro = new CoreReturnObject();
        String sql = CoreXmlSqlParsersFactory
                .getSql("CoreQueryOrdProcInf.queryOrdProcInf");
        if (list.get(0).toString().toLowerCase().equals("true")) {
            sql = sql + " AND T.JGORD_IS_OK != 2";
        }
        if (list.get(1).toString().toLowerCase().equals("true")) {
            sql = sql + " AND (T.LEN_TOEND_MIN > 0 OR T.LEN_TOEND_MAX > 0)";
        }
        if (list.get(2).toString().toLowerCase().equals("true")) {
            sql = sql + " AND E.BJ_TYPE IS NOT NULL" +
            		" AND E.BJ_TYPE != '/'" +
            		" AND E.BJ_TYPE != '镦粗'";
        }
        if (list.get(3).toString().toLowerCase().equals("true")) {
            sql = sql + " AND E.BJ_TYPE = '镦粗'";
        }
        if (list.get(4).toString().toLowerCase().equals("true")) {
            sql = sql + " AND (SELECT B.INSPECTION_VALUE" +
            		" FROM SLM_ORDER_LINE B" +
            		" WHERE B.VALIDFLAG = '1'" +
            		" AND B.ORD_LN_PK = T.ORD_LN_PK) > 0";
        }
        if(!startTim.equals(""))
        {
        	sql += " AND T.CREATE_TIME >= TO_DATE('"+startTim+"','YYYY-MM-DD HH24:MI:SS') AND T.CREATE_TIME <= TO_DATE('"+endTim+"','YYYY-MM-DD HH24:MI:SS')";
        }
        list.remove(0);
        list.remove(0);
        list.remove(0);
        list.remove(0);
        list.remove(0);
        cro = this.getData(sql, list.toArray());
        return cro;
    }
}