package com.steering.pss.ydm.Report;

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

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

public class FrmInList extends DBCommon{

	/**
	 * 查询
	 * @param monthYear
	 * @param arr
	 * @return
	 */
	public CoreReturnObject doQuery(String monthYear,String[] arr,String startTim,String endTim,String supplyUnit,String orderNo,String judgeNo)
	{
		String sql  = CoreXmlSqlParsersFactory.getSql("FrmInList.doQuery");
		if(!startTim.equals(""))
		{
		   sql += " AND T.INSTOCK_TIME >= to_date('"+startTim+"','YYYY-MM-DD HH24:MI:SS') AND T.INSTOCK_TIME <= to_date('"+endTim+"','YYYY-MM-DD HH24:MI:SS')";
		}
		if(!orderNo.equals(""))
		{
			sql += " AND T.ORDER_NO||'/'||T.ORDER_SEQ LIKE '%"+orderNo+"%'";
		}
		if(!judgeNo.equals(""))
		{
			sql += " AND T.JUDGE_STOVE_NO = '"+judgeNo+"'";
		}
		if(!monthYear.equals(""))
		{
			sql += " AND T.BAL_YEAR_MONTH = '"+monthYear+"'";
		}
		if(supplyUnit.equals("120501"))
		{
			sql += " AND (T.SUPPLY_UNIT_CODE = '"+supplyUnit+"' OR T.SUPPLY_UNIT_CODE IS NULL)";
		}else if(supplyUnit.equals("120504")){
			sql += " AND T.SUPPLY_UNIT_CODE = '"+supplyUnit+"'";
		}

		sql += CoreConverter.toSqlConditionString("T.BELONG_CODE", arr);
		sql += " GROUP BY T.HAND_FLAG,T.INSTOCK_TYPE_CODE,T.ORD_PK,T.JUDGE_STOVE_NO,T.BATCH_NO,T.BATCH_GROUD_NO,T.MATERIAL_NAME,T.PRODUCNAME,T.STD_NAME,T.GRADENAME,";
		sql += " T.STEELNAME,T.STD_STYLE_DESC,T.SPEC_NAME,T.MODEL_DESC,T.PLINE_NAME,T.ACT_LEN_MIN,T.ACT_LEN_MAX,T.BELONG_NAME,T.STORAGE_NO,T.ORDER_NO,T.ORDER_SEQ,";
		sql += " T.DELIVERY_NO,T.BAL_YEAR_MONTH,T.ACT_DIMATER,T.ACT_HEIGHT,T.INSTOCK_TYPE_NAME,S.RECEIV_NM,T.IN_MOLD,T.FINISHPRO_MOLD";
		return this.getData(sql);
	}
}
