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 FrmRptOutSend extends DBCommon{

	public CoreReturnObject doQueryData(String[] arr,String flag,String supplyUnit)
	{
		return doQueryData(arr,flag,supplyUnit,null);
	}
	public CoreReturnObject doQueryData(String[] arr,String flag,String supplyUnit,String[] depts)
	{
		String str = "";
		String sql = CoreXmlSqlParsersFactory.getSql("FrmRptOutSend.doQueryData");
		if(flag.equals("0"))
		{
			 str  = " AND S.SALE_ORG = '100102'";
		}else
		{
			str  = " AND S.SALE_ORG = '100101'";
		}
		String strSupplyUnit="";
		if( supplyUnit.equals("120501"))
		{
			strSupplyUnit = " AND (S.SUPPLY_UNIT = '"+supplyUnit+"' OR S.SUPPLY_UNIT IS NULL)";
			if(depts!=null && depts.length >0){
				strSupplyUnit += CoreConverter.toSqlConditionString("s.MANAGEMENT_NO",depts);
			}
		}else if(supplyUnit.equals("120504")){
			strSupplyUnit = " AND S.SUPPLY_UNIT = '"+supplyUnit+"'";
		}
		sql = sql.replace("#CONDTIONS#",str+strSupplyUnit);
		return this.getData(sql);
	}
}
