package com.steering.mes.mcp.Report;

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

/**
 *DBK查询
 * @author siy 2015/05/28
 * @version v1.0
 */
public class FrmDBKPerformance extends DBCommon {

    /**
     * 查询DBK实绩查询
     * @param list
     * @return
     */
    public CoreReturnObject doQuery(ArrayList<String> list, String plineCode,String stationCode) {

        String sql = CoreXmlSqlParsersFactory
                .getSql("FrmDBKPerformance.doQuery");
        if (!list.get(0).equals("")) {
            sql += " AND T1.LOAD_TIME BETWEEN TO_DATE('" + list.get(0)
                    + "' ,'YYYY-MM-DD HH24:MI:SS') AND TO_DATE('" + list.get(1)
                    + "' ,'YYYY-MM-DD HH24:MI:SS') ";
        }
        if (!list.get(2).equals("")) {
            sql += " AND M.JUDGE_STOVE_NO LIKE'%'||'" + list.get(2) + "'||'%'";
        }
        if (!list.get(3).equals("")) {
            sql += " AND M.ZY_BATCH_ID LIKE'%'||'" + list.get(3) + "'||'%'";
        }
        if (!list.get(4).equals("")) {
            sql += " AND M.ORDER_NO || '/' || M.ORDER_SEQ || '/' || M.DELIVERY_NO LIKE'%'||'" + list.get(4) + "'||'%'";
        }
        if (!plineCode.equals("")) {
            sql += " AND M.PLINE_CODE='" + plineCode + "'";
        }
        if (!stationCode.equals("")) {
            sql += " AND T.STATION_CODE='" + stationCode + "'";
        }
        sql += " GROUP BY M.PLINE_CODE,C.PLAN_INDOUBLE_NUM,C.PLAN_INDOUBLE_WT,M.HEAT_PLAN_NO,M.PLINE_NAME, M.ZY_BATCH_ID, M.PRO_PLAN_ID,  M.GX_PLAN_NO, "
                + "M.CRAFT_FILE_NO, M.CRAFT_FILE_MAN, M.CRAFT_SEQ, M.FEED_HEAT_NO,M.JUDGE_STOVE_NO,  C.BATCH_NO, "
                + "C.BATCH_GROUD_NO, M.GRADENAME, M1.STEELNAME,  M.ORDER_NO, M.ORDER_SEQ,"
                + " M.DELIVERY_NO, M.OUTWL_DESC,  M1.SPEC_NAME, M1.STD_NAME,"
                + " M1.PRODUCNAME, M1.MODEL_DESC";
        return this.getData(sql);
    }

    /**
     * 查询DBK进程数据统计
     * @param list
     * @return
     */
    public CoreReturnObject doQueryPort(ArrayList<String> list, String plineCode,String stationCode) {

        String sql = CoreXmlSqlParsersFactory
                .getSql("FrmDBKPerformance.doQueryPort");
        if (!list.get(0).equals("")) {
            sql += " AND T.PRO_TIME BETWEEN TO_DATE('" + list.get(0)
                    + "' ,'YYYY-MM-DD HH24:MI:SS') AND TO_DATE('" + list.get(1)
                    + "' ,'YYYY-MM-DD HH24:MI:SS') ";
        }
        if (!list.get(2).equals("")) {
            sql += " AND M.JUDGE_STOVE_NO LIKE'%'||'" + list.get(2) + "'||'%'";
        }
        if (!list.get(3).equals("")) {
            sql += " AND M.ZY_BATCH_ID LIKE'%'||'" + list.get(3) + "'||'%'";
        }
        if (!list.get(4).equals("")) {
            sql += " AND M.ORDER_NO || '/' || M.ORDER_SEQ || '/' || M.DELIVERY_NO LIKE'%'||'" + list.get(4) + "'||'%'";
        }
        if (!plineCode.equals("")) {
            sql += " AND M.PLINE_CODE='" + plineCode + "'";
        }
        sql += " GROUP BY M.IF_MATCH_ODD,C.REAL_INDOUBLE_WT,C.REAL_INDOUBLE_NUM,M.PLINE_CODE,C.PLAN_INDOUBLE_NUM,C.PLAN_INDOUBLE_WT,M.HEAT_PLAN_NO,M.PLINE_NAME, M.ZY_BATCH_ID, M.PRO_PLAN_ID,  M.GX_PLAN_NO, "
                + "M.CRAFT_FILE_NO, M.CRAFT_FILE_MAN, M.CRAFT_SEQ, M.JUDGE_STOVE_NO, M.FEED_HEAT_NO, C.BATCH_NO, "
                + "C.BATCH_GROUD_NO, M.GRADENAME, M1.STEELNAME,  M.ORDER_NO, M.ORDER_SEQ,"
                + " M.DELIVERY_NO, M.OUTWL_DESC,  M1.SPEC_NAME, M1.STD_NAME,"
                + " M1.PRODUCNAME, M1.MODEL_DESC";
        return this.getData(sql);
    }
}
