@ -22,10 +22,10 @@ namespace BWP.B3ButcherManageToSale.TypeIOCs
{
{
public List < ButcherForecast_Detail > Invoke ( IDmoContext context , ButcherForecast dmo )
public List < ButcherForecast_Detail > Invoke ( IDmoContext context , ButcherForecast dmo )
{
{
var ord er Info = GetSaleOrd er Info ( context . Session , dmo ) ;
var saleOutSt oreInfo = GetSaleOutSto reInfo ( context . Session , dmo ) ;
var avgWeightList = GetAllProductAvgWeightSet ( context . Session ) ;
var avgWeightList = GetAllProductAvgWeightSet ( context . Session ) ;
var result = new List < ButcherForecast_Detail > ( ) ;
var result = new List < ButcherForecast_Detail > ( ) ;
foreach ( var item in ord er Info )
foreach ( var item in saleOutSt oreInfo)
{
{
var first = avgWeightList . FirstOrDefault ( x = > x . Item2 = = item . Item1 ) ;
var first = avgWeightList . FirstOrDefault ( x = > x . Item2 = = item . Item1 ) ;
var detail = new ButcherForecast_Detail ( ) ;
var detail = new ButcherForecast_Detail ( ) ;
@ -33,7 +33,7 @@ namespace BWP.B3ButcherManageToSale.TypeIOCs
detail . NeedNumber = item . Item2 ;
detail . NeedNumber = item . Item2 ;
if ( first ! = null )
if ( first ! = null )
{
{
detail . ProductAvgWeightSet_ID = first . Item2 ;
detail . ProductAvgWeightSet_ID = first . Item1 ;
detail . AvgWeight = first . Item3 ;
detail . AvgWeight = first . Item3 ;
if ( detail . AvgWeight ! = 0 )
if ( detail . AvgWeight ! = 0 )
{
{
@ -49,15 +49,16 @@ namespace BWP.B3ButcherManageToSale.TypeIOCs
return result ;
return result ;
}
}
List < Tuple < long , Money < decimal > > > GetSaleOrd er Info ( IDmoSession session , ButcherForecast dmo )
List < Tuple < long , Money < decimal > > > GetSaleOutSto reInfo ( IDmoSession session , ButcherForecast dmo )
{
{
var main = new JoinAlias ( "_main" , typeof ( Ord er ) ) ;
var detail = new JoinAlias ( typeof ( Ord er _Detail ) ) ;
var main = new JoinAlias ( "_main" , typeof ( Sale OutSto re) ) ;
var detail = new JoinAlias ( typeof ( Sale OutSto re_Detail) ) ;
var query = new DQueryDom ( main ) ;
var query = new DQueryDom ( main ) ;
query . From . AddJoin ( JoinType . Inner , new DQDmoSource ( detail ) , DQCondition . EQ ( main , "ID" , detail , "Ord er _ID" ) ) ;
query . From . AddJoin ( JoinType . Inner , new DQDmoSource ( detail ) , DQCondition . EQ ( main , "ID" , detail , "Sale OutSto re_ID" ) ) ;
query . Columns . Add ( DQSelectColumn . Field ( "SaleGoods_ID" , detail ) ) ;
query . Columns . Add ( DQSelectColumn . Field ( "SaleGoods_ID" , detail ) ) ;
query . Columns . Add ( DQSelectColumn . Sum ( detail , "Number" ) ) ;
query . Columns . Add ( DQSelectColumn . Sum ( detail , "Number" ) ) ;
query . Where . Conditions . Add ( DQCondition . And ( DQCondition . EQ ( "AccountingUnit_ID" , dmo . AccountingUnit_ID ) , DQCondition . EQ ( DQExpression . Snippet ( "cast(_main.LoadTime as date)" ) , DQExpression . Value ( dmo . SendDate ) ) , DQCondition . GreaterThanOrEqual ( "BillState" , 单 据 状 态 . 已 审 核 ) , DQCondition . IsNotNull ( DQExpression . Field ( detail , "Number" ) ) ) ) ;
query . Where . Conditions . Add ( DQCondition . And ( DQCondition . EQ ( "AccountingUnit_ID" , dmo . AccountingUnit_ID ) , DQCondition . EQ ( DQExpression . Snippet ( "cast(_main.LoadTime as date)" ) , DQExpression . Value ( dmo . SendDate ) ) , DQCondition . EQ ( "BillState" , 单 据 状 态 . 未 审 核 ) , DQCondition . IsNotNull ( DQExpression . Field ( detail , "Number" ) ) ) ) ;
query . Where . Conditions . Add ( DQCondition . EQ ( "Store_ID" , dmo . Store_ID ) ) ;
query . GroupBy . Expressions . Add ( DQExpression . Field ( detail , "SaleGoods_ID" ) ) ;
query . GroupBy . Expressions . Add ( DQExpression . Field ( detail , "SaleGoods_ID" ) ) ;
return query . EExecuteList < long , Money < decimal > > ( session ) ;
return query . EExecuteList < long , Money < decimal > > ( session ) ;
}
}