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

	/***
	 * 取出库实单量
	 * @param dateForm
	 * @param dateTo
	 * @return
	 */
	public CoreReturnObject getSOutWgt(String dateForm,String dateTo,String bathYear,String[] arr)
	{ 
		String sql = CoreXmlSqlParsersFactory.getSql("FrmrptSendClosing.getSOutWgt");
		//2025年3月15日 去掉权限配置
		//sql += CoreConverter.toSqlConditionString("BELONG_CODE", arr);
		//sql += " AND BELONG_CODE = '"+beglogCode+"'";
		sql += " GROUP BY Bill_No,JUDGE_STOVE_NO,BATCH_NO,BATCH_GROUD_NO,PRODUCNAME,STD_STYLE_DESC,STEELNAME,SPEC_NAME,MODEL_DESC";
		return this.getData(sql, new Object[]{bathYear,bathYear});
	}
	
	/***
	 * 取出库虚单量
	 * @param dateForm
	 * @param dateTo
	 * @return
	 */
	public CoreReturnObject getXOutWgt(String dateForm,String dateTo,String bathYear, String[] arr)
	{ 
		String sql = CoreXmlSqlParsersFactory.getSql("FrmrptSendClosing.getXOutWgt");
		sql += CoreConverter.toSqlConditionString("S.SALE_ORG", arr);
		//sql += " AND S.SALE_ORG || '&' LIKE ('%' || '"+beglogCode+"' || '%')";
		sql += " GROUP BY T.JUDGE_STOVE_NO,T.BATCH_NO,T.GROUP_NO,T.bill_no,t.PRODUCNAME,T.STD_STYLE_DESC,T.STEELNAME,T.SPEC_NAME,T.MODEL_DESC";
		return this.getData(sql,new Object[]{bathYear});
	}
	
	/***
	 * 已结算实单量
	 * @param dateForm
	 * @param dateTo
	 * @return
	 */
	public CoreReturnObject getSClosingWgt(String dateForm,String dateTo,String bathYear,String[] arr)
	{
		String sql = CoreXmlSqlParsersFactory.getSql("FrmrptSendClosing.getSClosingWgt");
		if(arr.length == 1)
		{
			if(arr[0].toString() == "100102")
			{
				sql += " AND T.FORECORPCODE = '国际贸易部'";
			}else
			{
				sql += " AND T.FORECORPCODE <> '国际贸易部'";
			}
		}
		if(arr.length == 2)
		{
			sql += " AND T.FORECORPCODE <> '国际贸易部'";
		}
//		if(beglogCode.equals("100101"))
//		{
//			sql += " AND T.FORECORPCODE ='销售公司'";
//		}
//		else if(beglogCode.equals("100102"))
//		{
//			sql += " AND T.FORECORPCODE ='国贸公司'";
//		}else if(beglogCode.equals("100103"))
//		{
//			sql += " AND T.FORECORPCODE ='钢贸公司'";
//		}else 
//		{
//			sql += " AND T.FORECORPCODE IN ('销售公司','钢贸公司','国贸公司')";
//		}
		sql += " GROUP BY T.JUDGE_STOVE_NO,T.BATCH_NO,T.BATCH_GROUD_NO,T.BILL_NO,t.PRODUCNAME,T.STD_STYLE_DESC,T.STEELNAME,T.SPEC_NAME,T.MODEL_DESC";
		return this.getData(sql,new Object[]{bathYear,bathYear});
	}
	
	/***
	 * 已结算虚单量
	 * @param dateForm
	 * @param dateTo
	 * @return
	 */
	public CoreReturnObject getXClosingWgt(String dateForm,String dateTo,String bathYear, String[] arr)
	{
		String sql = CoreXmlSqlParsersFactory.getSql("FrmrptSendClosing.getXClosingWgt");
		if(arr.length == 1)
		{
			if(arr[0].toString() == "100102")
			{
				sql += " AND T.FORECORPCODE = '国际贸易部'";
			}else
			{
				sql += " AND T.FORECORPCODE <> '国际贸易部'";
			}
		}
		if(arr.length == 2)
		{
			sql += " AND T.FORECORPCODE <> '国际贸易部'";
		}
//		if(beglogCode.equals("100101"))
//		{
//			sql += " AND T.FORECORPCODE ='销售公司'";
//		}
//		else if(beglogCode.equals("100102"))
//		{
//			sql += " AND T.FORECORPCODE ='国贸公司'";
//		}else if(beglogCode.equals("100103"))
//		{
//			sql += " AND T.FORECORPCODE ='钢贸公司'";
//		}else 
//		{
//			sql += " AND T.FORECORPCODE IN ('销售公司','钢贸公司','国贸公司')";
//		}
		sql += " GROUP BY T.JUDGE_STOVE_NO,T.BATCH_NO,T.BATCH_GROUD_NO,T.BILL_NO,t.PRODUCNAME,T.STD_STYLE_DESC,T.STEELNAME,T.SPEC_NAME,T.MODEL_DESC";
		return this.getData(sql,new Object[]{bathYear,bathYear});
	}
	/***
	 * 实时未结算
	 * @param dateForm
	 * @param dateTo
	 * @return
	 */
	public CoreReturnObject getRealNoClosingWgt(String dateForm,String dateTo,String bathYear,String[] arr)
	{
		String sql = CoreXmlSqlParsersFactory.getSql("FrmrptSendClosing.getRealNoClosingWgt");
		if(arr.length == 1)
		{
			if(arr[0].toString() == "100102")
			{
				sql += " AND T.FORECORPCODE = '国际贸易部'";
			}else
			{
				sql += " AND T.FORECORPCODE <> '国际贸易部'";
			}
		}
		if(arr.length == 2)
		{
			sql += " AND T.FORECORPCODE <> '国际贸易部'";
		}
//		if(beglogCode.equals("100101"))
//		{
//			sql += " AND T.FORECORPCODE ='销售公司'";
//		}
//		else if(beglogCode.equals("100102"))
//		{
//			sql += " AND T.FORECORPCODE ='国贸公司'";
//		}else if(beglogCode.equals("100103"))
//		{
//			sql += " AND T.FORECORPCODE ='钢贸公司'";
//		}else 
//		{
//			sql += " AND T.FORECORPCODE IN ('销售公司','钢贸公司','国贸公司')";
//		}
		sql += " GROUP BY T.JUDGE_STOVE_NO,T.BATCH_NO,T.BATCH_GROUD_NO,T.BILL_NO,t.PRODUCNAME,T.STD_STYLE_DESC,T.STEELNAME,T.SPEC_NAME,T.MODEL_DESC";
		return this.getData(sql,new Object[]{bathYear,bathYear});
	}
	/***
	 * 票据未对齐
	 * @param dateForm
	 * @param dateTo
	 * @param arr
	 * @return
	 */
	public CoreReturnObject getReaggedWgt(String dateForm,String dateTo,String bathYear,String[] arr)
	{
		String sql = CoreXmlSqlParsersFactory.getSql("FrmrptSendClosing.getReaggedWgt");
		sql += CoreConverter.toSqlConditionString("SALE_ORG", arr);
		//sql += " AND SALE_ORG || '&' LIKE ('%' || '"+beglogCode+"' || '%')";
		sql += " GROUP BY Bill_No,JUDGE_STOVE_NO,BATCH_NO,BATCH_GROUD_NO,PRODUCNAME,STD_STYLE_DESC,STEELNAME,SPEC_NAME,MODEL_DESC";
		return this.getData(sql,new Object[]{bathYear,bathYear});
	}
}
