From b1a0a49947bc7c9806f4d3b6277375ef543dbccf Mon Sep 17 00:00:00 2001 From: lazhen <17772815105@139.com> Date: 星期四, 14 十一月 2024 18:19:14 +0800 Subject: [PATCH] 物流报表部分费用支持跨月 --- _Main/BL/Type_CCEngineLogisticsCostColumn0/Method_CalcEngineCost.qbl | 111 ++++++++++++ _Main/BL/Type_CCEngineLogisticsCostReport0/Method_GenerateColumn.qbl | 2 _Main/BL/Type_CCEngineLogisticsCostReport0/Method_Generate.qbl | 8 _Main/BL/Type_CCEngineLogisticsCostReport/Method_Generate.qbl | 8 _Main/BL/Type_CCEngineLogisticsCostColumn/Attribute_EndDate.qbl | 7 _Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl | 45 ++--- _Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_Initialize.qbl | 221 ++++++++++++++++++++++++ _Main/BL/Type_CCEngineLogisticsCostColumn/Method_CalcEngineCost.qbl | 35 +++ _Main/BL/Type_CCEngineLogisticsCostColumn0/Method_CalcTransCost.qbl | 35 +++ _Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_InitializeNew.qbl | 2 _Main/BL/Type_CCEngineLogisticsCostColumn0/Attribute_EndDate.qbl | 7 _Main/BL/Type_CCEngineLogisticsCostReport/Method_GenerateColumn.qbl | 2 12 files changed, 453 insertions(+), 30 deletions(-) diff --git a/_Main/BL/Type_CCEngineLogisticsCostColumn/Attribute_EndDate.qbl b/_Main/BL/Type_CCEngineLogisticsCostColumn/Attribute_EndDate.qbl new file mode 100644 index 0000000..c84a23b --- /dev/null +++ b/_Main/BL/Type_CCEngineLogisticsCostColumn/Attribute_EndDate.qbl @@ -0,0 +1,7 @@ +Quintiq file version 2.0 +#parent: #root +Attribute EndDate +{ + #keys: '3[415136.0.1304620060][415136.0.1304620059][415136.0.1304620061]' + ValueType: Date +} diff --git a/_Main/BL/Type_CCEngineLogisticsCostColumn/Method_CalcEngineCost.qbl b/_Main/BL/Type_CCEngineLogisticsCostColumn/Method_CalcEngineCost.qbl new file mode 100644 index 0000000..b630a19 --- /dev/null +++ b/_Main/BL/Type_CCEngineLogisticsCostColumn/Method_CalcEngineCost.qbl @@ -0,0 +1,35 @@ +Quintiq file version 2.0 +#parent: #root +Method CalcEngineCost ( + ProductInStockingPointInPeriods pispips, + LogisticsCostEngines enginecosts +) as Real +{ + TextBody: + [* + // 鐢勫叞楦� Nov-14-2024 (created) + cost := 0.0; + enginecost := selectobject( enginecosts, Elements, engine, engine.StartDate() <= this.StartDate() and engine.EndDate() >= this.EndDate() ); + if( isnull( enginecost ) ){ + fenginecost := selectobject( enginecosts, Elements, engine, engine.EndDate() > this.StartDate() and engine.EndDate() <= this.EndDate() and engine.StartDate() < this.StartDate() ); + if( not isnull( fenginecost ) ){ + pinvqty := sum( pispips, Elements, pispip, pispip.Start().Date() >= fenginecost.StartDate() and pispip.Start().Date() <= fenginecost.EndDate(), pispip.PlannedInventoryLevelEnd() ); + cost := cost + ceil( pinvqty / fenginecost.PackagingCapacity() ) * fenginecost.StoragePrice();//鍥涜垗浜斿叆 + } + menginecost := selectobject( enginecosts, Elements, engine, engine.StartDate() > this.StartDate() and engine.EndDate() < this.EndDate() ); + if( not isnull( menginecost ) ){ + pinvqty := sum( pispips, Elements, pispip, pispip.Start().Date() >= menginecost.StartDate() and pispip.Start().Date() <= menginecost.EndDate(), pispip.PlannedInventoryLevelEnd() ); + cost := cost + ceil( pinvqty / menginecost.PackagingCapacity() ) * menginecost.StoragePrice();//鍥涜垗浜斿叆 + } + benginecost := selectobject( enginecosts, Elements, engine, engine.StartDate() > this.StartDate() and engine.StartDate() <= this.EndDate() and engine.EndDate() > this.EndDate() ); + if( not isnull( benginecost ) ){ + pinvqty := sum( pispips, Elements, pispip, pispip.Start().Date() >= benginecost.StartDate() and pispip.Start().Date() <= benginecost.EndDate(), pispip.PlannedInventoryLevelEnd() ); + cost := cost + ceil( pinvqty / benginecost.PackagingCapacity() ) * benginecost.StoragePrice();//鍥涜垗浜斿叆 + } + }else{ + pinvqty := sum( pispips, Elements, pispip, pispip.PlannedInventoryLevelEnd() ); + cost := cost + ceil( pinvqty / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//鍥涜垗浜斿叆 + } + return cost; + *] +} diff --git a/_Main/BL/Type_CCEngineLogisticsCostColumn0/Attribute_EndDate.qbl b/_Main/BL/Type_CCEngineLogisticsCostColumn0/Attribute_EndDate.qbl new file mode 100644 index 0000000..f805f4a --- /dev/null +++ b/_Main/BL/Type_CCEngineLogisticsCostColumn0/Attribute_EndDate.qbl @@ -0,0 +1,7 @@ +Quintiq file version 2.0 +#parent: #root +Attribute EndDate +{ + #keys: '3[415136.0.1304630050][415136.0.1304630049][415136.0.1304630051]' + ValueType: Date +} diff --git a/_Main/BL/Type_CCEngineLogisticsCostColumn0/Method_CalcEngineCost.qbl b/_Main/BL/Type_CCEngineLogisticsCostColumn0/Method_CalcEngineCost.qbl new file mode 100644 index 0000000..c7d248a --- /dev/null +++ b/_Main/BL/Type_CCEngineLogisticsCostColumn0/Method_CalcEngineCost.qbl @@ -0,0 +1,111 @@ +Quintiq file version 2.0 +#parent: #root +Method CalcEngineCost ( + ProductInStockingPointInPeriods pispips, + LogisticsCostEngines enginecosts, + LogisticsCostTransports transcosts, + String factory, + output Real entercost, + output Real othercost, + output Real outcost, + output Real storecost, + output Real transcost +) +{ + TextBody: + [* + // 鐢勫叞楦� Nov-14-2024 (created) + enginecost := selectobject( enginecosts, Elements, engine, engine.StartDate() <= this.StartDate() and engine.EndDate() >= this.EndDate() and engine.Factory() = factory ); + if( isnull( enginecost ) ){ + fenginecost := selectobject( enginecosts, Elements, engine, engine.EndDate() > this.StartDate() and engine.EndDate() <= this.EndDate() and engine.StartDate() < this.StartDate() and engine.Factory() = factory ); + if( not isnull( fenginecost ) ){ + fpispips := selectset( pispips, Elements, pispip, pispip.Start().Date() >= fenginecost.StartDate() and pispip.Start().Date() <= fenginecost.EndDate() ); + if( entercost.IsMaxInfinity() ){ + newsqty := sum( fpispips, Elements, e, e.NewSupplyQuantity() ); + entercost := entercost + ceil( newsqty / fenginecost.PackagingCapacity() ) * fenginecost.WarehousingPrice(); + } + if( othercost.IsMaxInfinity() ){ + newsqty := sum( fpispips, Elements, e, e.NewSupplyQuantity() ); + othercost := othercost + ceil( newsqty / fenginecost.PackagingCapacity() ) * fenginecost.OtherPrice(); + } + if( outcost.IsMaxInfinity() ){ + newsqty := sum( fpispips, Elements, e, e.NewSupplyQuantity() ); + outcost := outcost + ceil( newsqty / fenginecost.PackagingCapacity() ) * fenginecost.OutboundPrice(); + } + if( storecost.IsMaxInfinity() ){ + pinvqty := sum( fpispips, Elements, e, e.PlannedInventoryLevelEnd() ); + storecost := storecost + ceil( pinvqty / fenginecost.PackagingCapacity() ) * fenginecost.StoragePrice();//鍥涜垗浜斿叆 + } + if( transcost.IsMaxInfinity() ){ + this.CalcTransCost( fpispips, transcosts, fenginecost, transcost ); + } + } + menginecost := selectobject( enginecosts, Elements, engine, engine.StartDate() > this.StartDate() and engine.EndDate() < this.EndDate() and engine.Factory() = factory ); + if( not isnull( menginecost ) ){ + mpispips := selectset( pispips, Elements, pispip, pispip.Start().Date() >= menginecost.StartDate() and pispip.Start().Date() <= menginecost.EndDate() ); + if( entercost.IsMaxInfinity() ){ + newsqty := sum( mpispips, Elements, e, e.NewSupplyQuantity() ); + entercost := entercost + ceil( newsqty / menginecost.PackagingCapacity() ) * menginecost.WarehousingPrice(); + } + if( othercost.IsMaxInfinity() ){ + newsqty := sum( mpispips, Elements, e, e.NewSupplyQuantity() ); + othercost := othercost + ceil( newsqty / menginecost.PackagingCapacity() ) * menginecost.OtherPrice(); + } + if( outcost.IsMaxInfinity() ){ + newsqty := sum( mpispips, Elements, e, e.NewSupplyQuantity() ); + outcost := outcost + ceil( newsqty / menginecost.PackagingCapacity() ) * menginecost.OutboundPrice(); + } + if( storecost.IsMaxInfinity() ){ + pinvqty := sum( mpispips, Elements, e, e.PlannedInventoryLevelEnd() ); + storecost := storecost + ceil( pinvqty / menginecost.PackagingCapacity() ) * menginecost.StoragePrice();//鍥涜垗浜斿叆 + } + if( transcost.IsMaxInfinity() ){ + this.CalcTransCost( mpispips, transcosts, menginecost, transcost ); + } + } + benginecost := selectobject( enginecosts, Elements, engine, engine.StartDate() > this.StartDate() and engine.StartDate() <= this.EndDate() and engine.EndDate() > this.EndDate() and engine.Factory() = factory ); + if( not isnull( benginecost ) ){ + bpispips := selectset( pispips, Elements, pispip, pispip.Start().Date() >= benginecost.StartDate() and pispip.Start().Date() <= benginecost.EndDate() ) + if( entercost.IsMaxInfinity() ){ + newsqty := sum( bpispips, Elements, e, e.NewSupplyQuantity() ); + entercost := entercost + ceil( newsqty / benginecost.PackagingCapacity() ) * benginecost.WarehousingPrice(); + } + if( othercost.IsMaxInfinity() ){ + newsqty := sum( bpispips, Elements, e, e.NewSupplyQuantity() ); + othercost := othercost + ceil( newsqty / benginecost.PackagingCapacity() ) * benginecost.OtherPrice(); + } + if( outcost.IsMaxInfinity() ){ + newsqty := sum( bpispips, Elements, e, e.NewSupplyQuantity() ); + outcost := outcost + ceil( newsqty / benginecost.PackagingCapacity() ) * benginecost.OutboundPrice(); + } + if( storecost.IsMaxInfinity() ){ + pinvqty := sum( bpispips, Elements, e, e.PlannedInventoryLevelEnd() ); + storecost := storecost + ceil( pinvqty / benginecost.PackagingCapacity() ) * benginecost.StoragePrice();//鍥涜垗浜斿叆 + } + if( transcost.IsMaxInfinity() ){ + this.CalcTransCost( bpispips, transcosts, benginecost, transcost ); + } + } + }else{ + if( entercost.IsMaxInfinity() ){ + newsqty := sum( pispips, Elements, pispip, pispip.NewSupplyQuantity() ); + entercost := entercost + ceil( newsqty / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice(); + } + if( othercost.IsMaxInfinity() ){ + newsqty := sum( pispips, Elements, pispip, pispip.NewSupplyQuantity() ); + othercost := othercost + ceil( newsqty / enginecost.PackagingCapacity() ) * enginecost.OtherPrice(); + } + if( outcost.IsMaxInfinity() ){ + newsqty := sum( pispips, Elements, pispip, pispip.NewSupplyQuantity() ); + outcost := outcost + ceil( newsqty / enginecost.PackagingCapacity() ) * enginecost.OutboundPrice(); + } + if( storecost.IsMaxInfinity() ){ + pinvqty := sum( pispips, Elements, pispip, pispip.PlannedInventoryLevelEnd() ); + storecost := storecost + ceil( pinvqty / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//鍥涜垗浜斿叆 + } + if( transcost.IsMaxInfinity() ){ + this.CalcTransCost( pispips, transcosts, enginecost, transcost ); + } + } + *] +} diff --git a/_Main/BL/Type_CCEngineLogisticsCostColumn0/Method_CalcTransCost.qbl b/_Main/BL/Type_CCEngineLogisticsCostColumn0/Method_CalcTransCost.qbl new file mode 100644 index 0000000..9e13b8d --- /dev/null +++ b/_Main/BL/Type_CCEngineLogisticsCostColumn0/Method_CalcTransCost.qbl @@ -0,0 +1,35 @@ +Quintiq file version 2.0 +#parent: #root +Method CalcTransCost ( + ProductInStockingPointInPeriods pispips, + LogisticsCostTransports transcosts, + LogisticsCostEngine enginecost, + output Real transcost +) +{ + TextBody: + [* + // 鐢勫叞楦� Nov-14-2024 (created) + tran := selectobject( transcosts, Elements, trans, trans.StartDate() <= this.StartDate() and trans.EndDate() >= this.StartDate() ); + if( isnull( tran ) ){ + ftranscost := selectobject( transcosts, Elements, trans, trans.EndDate() > this.StartDate() and this.EndDate() <= this.EndDate() and trans.StartDate() < this.StartDate() ); + if( not isnull( ftranscost ) ){ + newsqty := sum( pispips, Elements, pispip, pispip.Start().Date() >= ftranscost.StartDate() and pispip.Start().Date() <= ftranscost.EndDate(), pispip.NewSupplyQuantity() ); + transcost := transcost + ceil( ceil( newsqty / enginecost.PackagingCapacity() ) / ftranscost.LoadingCapacity() ) * ftranscost.TransportPrice(); + } + mtranscost := selectobject( transcosts, Elements, trans, trans.StartDate() > this.StartDate() and trans.EndDate() < this.EndDate() ); + if( not isnull( mtranscost ) ){ + newsqty := sum( pispips, Elements, pispip, pispip.Start().Date() >= mtranscost.StartDate() and pispip.Start().Date() <= mtranscost.EndDate(), pispip.NewSupplyQuantity() ); + transcost := transcost + ceil( ceil( newsqty / enginecost.PackagingCapacity() ) / mtranscost.LoadingCapacity() ) * mtranscost.TransportPrice(); + } + btranscost := selectobject( transcosts, Elements, trans, trans.StartDate() > this.StartDate() and trans.StartDate() <= this.EndDate() and trans.EndDate() > this.EndDate() ); + if( not isnull( btranscost ) ){ + newsqty := sum( pispips, Elements, pispip, pispip.Start().Date() >= btranscost.StartDate() and pispip.Start().Date() <= btranscost.EndDate(), pispip.NewSupplyQuantity() ); + transcost := transcost + ceil( ceil( newsqty / enginecost.PackagingCapacity() ) / btranscost.LoadingCapacity() ) * btranscost.TransportPrice(); + } + }else{ + newsqty := sum( pispips, Elements, pispip, pispip.NewSupplyQuantity() ); + transcost := transcost + ceil( ceil( newsqty / enginecost.PackagingCapacity() ) / tran.LoadingCapacity() ) * tran.TransportPrice(); + } + *] +} diff --git a/_Main/BL/Type_CCEngineLogisticsCostReport/Method_Generate.qbl b/_Main/BL/Type_CCEngineLogisticsCostReport/Method_Generate.qbl index d7c5a6a..12bebf3 100644 --- a/_Main/BL/Type_CCEngineLogisticsCostReport/Method_Generate.qbl +++ b/_Main/BL/Type_CCEngineLogisticsCostReport/Method_Generate.qbl @@ -38,6 +38,8 @@ //鏄剧ず鏈堝崟鍏冩牸 showcell := showrow.Cell( relnew, RentInCost := cell.RentInCost(), RentOutOfCost := cell.RentOutOfCost(), WerkToRentTransCost := cell.WerkToRentTransCost(), RentStorCost := cell.RentStorCost(), CoefficientValue := cell.CoefficientValue(), AllCost := cell.EstimateTotalCost() * [Real]cell.CoefficientValue() ); column.Cell( relinsert, showcell ); + showcell.EstimateTotalCost( showcell.CalcEstimateTotalCost() ); + showcell.AllCost( showcell.EstimateTotalCost() * [Real]showcell.CoefficientValue() ); //鏄剧ず骞村崟鍏冩牸 yearcell.RentInCost( cell.RentInCost() + yearcell.RentInCost() ); yearcell.RentOutOfCost( cell.RentOutOfCost() + yearcell.RentOutOfCost() ); @@ -74,5 +76,11 @@ cell.IsRentStorCostUpdate( exists( cell.Column(), Cell, acell, acell.IsRentStorCostUpdate() ) ); cell.IsWerkToRentTransCostUpdate( exists( cell.Column(), Cell, acell, acell.IsWerkToRentTransCostUpdate() ) ); } + rows := selectsortedset( this, Row, row, row.Name() ); + i := 0; + traverse( rows, Elements, e ){ + e.RowNr( i ); + i := i + 1; + } *] } diff --git a/_Main/BL/Type_CCEngineLogisticsCostReport/Method_GenerateColumn.qbl b/_Main/BL/Type_CCEngineLogisticsCostReport/Method_GenerateColumn.qbl index 880436e..562bcfe 100644 --- a/_Main/BL/Type_CCEngineLogisticsCostReport/Method_GenerateColumn.qbl +++ b/_Main/BL/Type_CCEngineLogisticsCostReport/Method_GenerateColumn.qbl @@ -14,7 +14,7 @@ for( start := startofyear; start < startofnextyear; start := start.StartOfNextMonth() ){ periodtime := start.Date(); periodname := periodtime.Format( "M2/D2/Y" ); - this.Column( relnew, Name := periodname, StartDate := periodtime ); + this.Column( relnew, Name := periodname, StartDate := periodtime, EndDate := ( start.StartOfNextMonth() - Duration::Days( 1 ) ).Date() ); } *] } diff --git a/_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl b/_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl index 6c8de34..493fd05 100644 --- a/_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl +++ b/_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl @@ -7,7 +7,7 @@ TextBody: [* // 鐢勫叞楦� Aug-12-2024 (created) - owner.CCEngineLogisticsCostReport( relflush ); + //owner.CCEngineLogisticsCostReport( relflush ); produtparent := CCEngineLogisticsCostReport::GetDefaultProductParent(); name := CCEngineLogisticsCostReport::GetDefaultName(); allunit := CCEngineLogisticsCostReport::GetDefaultAllUnit(); @@ -20,9 +20,17 @@ //startofyear := startofplanning.StartOfYear(); startofnextyear := startofplanning.StartOfNextYear(); - table := owner.CCEngineLogisticsCostReport( relnew, ID := name, Name := name ); - owner.CCEngineLogisticsCostReport( relnew, ID := name + 'Show', Name := name, IsShow := true ); - owner.CCEngineLogisticsCostSearch( relnew, Generation := allunit, MqbMlb := allunit, Power := allunit ); + table := selectobject(owner, CCEngineLogisticsCostReport, report, report.ID() = name ); + if( isnull( table ) ){ + owner.CCEngineLogisticsCostReport( relnew, ID := name, Name := name ); + } + showname := name + 'Show'; + if( exists( owner, CCEngineLogisticsCostReport, report, report.ID() = showname and report.IsShow() ) ){ + owner.CCEngineLogisticsCostReport( relnew, ID := showname, Name := name, IsShow := true ); + } + if( isnull( owner.CCEngineLogisticsCostSearch() ) ){ + owner.CCEngineLogisticsCostSearch( relnew, Generation := allunit, MqbMlb := allunit, Power := allunit ); + } products := construct( Product_MPs ); @@ -130,33 +138,16 @@ if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){ row := table.GetRow( pisp.ProductID() ); products.Add( product ); - //褰損roduct planning鐨勬棩鏈熷尯闂村湪闇�瑕佺殑鏃ユ湡鍖洪棿鍐� - // traverse( table, Column, column ){ - // pispips := selectset( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.PlannedInventoryLevelEnd() <> 0 - // and pispip.Start().Date() < column.StartDate().StartOfNextMonth() and pispip.Start().Date() >= column.StartDate() ); + traverse( table, Column, column ){ - traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.PlannedInventoryLevelEnd() <> 0 ){ - enginecost := selectobject( enginecosts, Elements, engine, engine.StartDate() <= pispip.Start().Date() and engine.EndDate() >= pispip.Start().Date() ); - if( not isnull( enginecost ) ){ - periodtime := pispip.Start().StartOfMonth().Date(); - periodname := periodtime.Format( "M2/D2/Y" ); - quantity := ceil( pispip.PlannedInventoryLevelEnd() / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//鍥涜垗浜斿叆 - - column := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime ); - - row.SetRentStorageCost( column, quantity ); - } + pispips := selectset( pisp, ProductInStockingPointInPeriod, pispip, pispip.Start().Date() >= column.StartDate() + and pispip.Start().Date() < column.StartDate().StartOfNextMonth() + and pispip.PlannedInventoryLevelEnd() <> 0 ); + cost := column.CalcEngineCost( pispips, enginecosts ); + row.SetRentStorageCost( column, cost ); } } } } - //rows := selectsortedset( table, Row, row, row.Name() ); - //i := 0; - //traverse( rows, Elements, e ){ - // e.RowNr( i ); - // i := i + 1; - //} - // - //showtable.Generate( search, products ); *] } diff --git a/_Main/BL/Type_CCEngineLogisticsCostReport0/Method_Generate.qbl b/_Main/BL/Type_CCEngineLogisticsCostReport0/Method_Generate.qbl index b7889a3..c3797aa 100644 --- a/_Main/BL/Type_CCEngineLogisticsCostReport0/Method_Generate.qbl +++ b/_Main/BL/Type_CCEngineLogisticsCostReport0/Method_Generate.qbl @@ -48,6 +48,8 @@ , CoefficientValue := cell.CoefficientValue() , AllCost := cell.EstimateTotalCost() * [Real]cell.CoefficientValue() ); column.Cell( relinsert, showcell ); + showcell.EstimateTotalCost( showcell.CalcEstimateTotalCost() ); + showcell.AllCost( showcell.EstimateTotalCost() * [Real]showcell.CoefficientValue() ); //鏄剧ず骞村崟鍏冩牸 yearcell.CCRentInCost( cell.CCRentInCost() + yearcell.CCRentInCost() ); yearcell.CCRentOutOfCost( cell.CCRentOutOfCost() + yearcell.CCRentOutOfCost() ); @@ -105,6 +107,12 @@ cell.IsEstimateTotalCostUpdate( exists( cell.Column(), Cell, acell, acell.IsEstimateTotalCostUpdate() ) ); cell.IsWerkToDLRentTransCostUpdate( exists( cell.Column(), Cell, acell, acell.IsWerkToDLRentTransCostUpdate() ) ); } + rows := selectsortedset( this, Row, row, row.Name() ); + i := 0; + traverse( rows, Elements, e ){ + e.RowNr( i ); + i := i + 1; + } info( '-------------------------g------------end---------------------------------' ); *] } diff --git a/_Main/BL/Type_CCEngineLogisticsCostReport0/Method_GenerateColumn.qbl b/_Main/BL/Type_CCEngineLogisticsCostReport0/Method_GenerateColumn.qbl index b1ab93a..d7ef470 100644 --- a/_Main/BL/Type_CCEngineLogisticsCostReport0/Method_GenerateColumn.qbl +++ b/_Main/BL/Type_CCEngineLogisticsCostReport0/Method_GenerateColumn.qbl @@ -14,7 +14,7 @@ for( start := startofyear; start < startofnextyear; start := start.StartOfNextMonth() ){ periodtime := start.Date(); periodname := periodtime.Format( "M2/D2/Y" ); - this.Column( relnew, Name := periodname, StartDate := periodtime ); + this.Column( relnew, Name := periodname, StartDate := periodtime, EndDate := ( start.StartOfNextMonth() - Duration::Days( 1 ) ).Date() ); } *] } diff --git a/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_Initialize.qbl b/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_Initialize.qbl new file mode 100644 index 0000000..c8d0617 --- /dev/null +++ b/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_Initialize.qbl @@ -0,0 +1,221 @@ +Quintiq file version 2.0 +#parent: #root +StaticMethod Initialize ( + MacroPlan owner +) +{ + TextBody: + [* + // 鐢勫叞楦� Aug-12-2024 (created) + owner.DLEngineLogisticsCostReport( relflush ); + produtparent := DLEngineLogisticsCostReport::GetDefaultProductParent(); + name := DLEngineLogisticsCostReport::GetDefaultName(); + allunit := DLEngineLogisticsCostReport::GetDefaultAllUnit(); + ccfactory := DLEngineLogisticsCostReport::GetCCFactory(); + dlfactory := DLEngineLogisticsCostReport::GetDLFactory(); + + startofplanning := owner.StartOfPlanning().Date(); + startofnextyear := startofplanning.StartOfNextYear(); + + table := owner.DLEngineLogisticsCostReport( relnew, ID := name, Name := name ); + owner.DLEngineLogisticsCostReport( relnew, ID := name + 'Show', Name := name, IsShow := true ); + owner.DLEngineLogisticsCostSearch( relnew, Generation := allunit, MqbMlb := allunit, Power := allunit ); + + products := construct( Product_MPs ); + + table.GenerateColumn( owner ); + //澶栫搴撲粨鍌ㄨ垂鐢細浠撳偍鏁伴噺/鍖呰瀹归噺*浠撳偍鍗曚环锛屽湪Actual inventories閲屽彇鍒伴暱鏄ュ绉熷簱/澶ц繛澶栫搴撹鍙戝姩鏈虹殑浠撳偍閲忥紝鏍规嵁鍙戝姩鏈哄彿鎵惧埌瀵瑰簲鐨凣eneration 鍜屾í绾靛埗锛屽湪鍙戝姩鏈烘垚鏈弬鏁拌〃閲屾壘鍒板搴旂殑浠撳偍鍗曚环鍜屽寘瑁呭閲忥紝鐢ㄥ叕寮忚绠楋紝鏈堝害杩涜姹囨�� + //闀挎槬澶栫搴撳叆搴�/鍑哄簱璐圭敤锛屽ぇ杩炲彂鍔ㄦ満鐨勯暱鏄ュ绉熷簱鐨凬ew supply + traverse( owner, StockingPoint_MP, stockingpoint, stockingpoint.ID().EndsWith( '澶栫搴�' ) ){ + isdltoccrent := stockingpoint.ID().StartsWith( '澶ц繛鍙戝姩鏈虹殑闀挎槬' ); + isdlrent := not isdltoccrent and stockingpoint.ID().StartsWith( '澶ц繛' ) or stockingpoint.ID().StartsWith( 'DL' ); + if( isdlrent or isdltoccrent){ + traverse( stockingpoint, ProductInStockingPoint_MP, pisp, pisp.Product_MP().IsLeaf() + and exists( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and ( pispip.NewSupplyQuantity() <> 0 or pispip.PlannedInventoryLevelEnd() <> 0 ) ) ){ + //鑾峰彇琛� + product := pisp.Product_MP(); + productparents := product.GetAllParent(); + if( exists( productparents, Elements, e, e.ID() = produtparent ) ){//鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満 + row := table.GetRow( pisp.ProductID() ); + enginecosts := selectset( owner, LogisticsCostEngine, engine, engine.PackagingCapacity() <> 0 and engine.Generation().ToLower() = product.Generation().ToLower() and engine.MLB_MQB() = product.MQBMLB() ); + transcosts := selectset( owner, LogisticsCostTransport, trans, trans.LoadingCapacity() <> 0 and exists( productparents, Elements, e, ifexpr( trans.Product().FindString( '鍙戝姩鏈�', 0 ) >= 0, e.ID() = produtparent, e.ID() = trans.Product() ) ) ); + if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){ + traverse( table, Column, column ){ + pispips := selectset( pisp, ProductInStockingPointInPeriod, pispip, pispip.Start().Date() >= column.StartDate() + and pispip.Start().Date() < column.StartDate().StartOfNextMonth() + and ( pispip.NewSupplyQuantity() <> 0 or pispip.PlannedInventoryLevelEnd() <> 0 ) ); + cell := selectobject( row, Cell, cell, cell.Column() = column ); + entercost := 0.0; + othercost := 0.0; + outcost := 0.0; + storecost := 0.0; + transcost := 0.0; + if( isdltoccrent){ + othercost := Real::MaxReal(); + transset := selectset( transcosts, Elements, trans, trans.Origin() = '闀挎槬澶栫搴�' and trans.Destination() = '瀹㈡埛搴�' ); + column.CalcEngineCost( pispips, enginecosts, transset, ccfactory, entercost, othercost, outcost, storecost, transcost ); + cell.CCRentQty( cell.CCRentQty() + sum( pispips, Elements, pispip, pispip.NewSupplyQuantity() ) ); + cell.CCRentInCost( cell.CCRentInCost() + entercost ); + cell.CCRentOutOfCost( cell.CCRentOutOfCost() + outcost ); + cell.CCRentStorCost( cell.CCRentStorCost() + storecost );//闀挎槬澶栫搴撲粨鍌ㄨ垂鐢� + cell.CCShorTransCost( cell.CCShorTransCost() + transcost );//闀挎槬鐭�旇繍杈撹垂鐢� + } else { + outcost := Real::MaxReal(); + transset := selectset( transcosts, Elements, trans, trans.Origin() = '澶ц繛鍘傚唴搴�' and trans.Destination() = '澶ц繛澶栫搴�' ); + column.CalcEngineCost( pispips, enginecosts, transset, dlfactory, entercost, othercost, outcost, storecost, transcost ); + cell.DLRentStorCost( cell.DLRentStorCost() + storecost );//澶ц繛澶栫搴撲粨鍌ㄨ垂鐢� + cell.DLRentOtherCost( cell.DLRentOtherCost() + othercost );//澶ц繛澶栫搴撳叾浠栬垂鐢� + cell.DLRentInCost( cell.DLRentInCost() + entercost );//澶ц繛澶栫搴撳叆搴撹垂鐢� + cell.WerkToDLRentTransCost( cell.WerkToDLRentTransCost() + transcost );//鍘傚唴鍒板ぇ杩炲绉熷簱杩愯緭璐圭敤 + } + } + products.Add( pisp.Product_MP() ); + } + } + } + } + } + + //闀挎槬闀块�旇繍杈撹垂鐢細璋冩嫧鏁伴噺/鍖呰瀹归噺/瑁呰浇瀹归噺*杩愯緭鍗曚环锛岃皟鎷ㄨ鍒掗噷鎵惧埌璇ヤ骇鍝佷粠DL鍒癈C鐨勮皟鎷ㄦ暟閲忥紝鍗宠捣濮嬪湴澶ц繛瑁呴厤绾胯竟搴擄紝鐩殑鍦颁负闀挎槬澶栫搴撳搴旂殑杩愯緭鏁伴噺锛屽湪鍙戝姩鏈烘垚鏈弬鏁拌〃鎵惧埌瀵瑰簲鐨勫寘瑁呭閲忥紝鍦ㄨ繍杈撴垚鏈弬鏁拌〃閲屾壘鍒板彂鍔ㄦ満瀵瑰簲杩愯緭鍗曚环鍜岃杞藉閲忥紝鐢ㄥ叕寮忚绠楀緱鍑虹粨鏋滐紝鏈堝害杩涜姹囨�� + traverse( owner, Unit.Lane.LaneLeg, laneleg ){ + //璧峰搴撳瓨鐐规槸鍚︽槸澶ц繛(澶ц繛鍘傚唴搴擄級 + isdl := laneleg.OriginStockingPointID().EndsWith( '鍘傚唴搴�' ) and ( laneleg.OriginStockingPointID().StartsWith( '澶ц繛' ) or laneleg.OriginStockingPointID().StartsWith( 'DL' ) ); + //鐩殑鍦板簱瀛樼偣鏄惁鏄暱鏄ワ紙闀挎槬澶栫搴擄級 + iscc := laneleg.DestinationStockingPointID() = '澶ц繛鍙戝姩鏈虹殑闀挎槬澶栫搴�'; + if( isdl and iscc ){ + traverse( table, Column, column){//, column.StartDate().Month() = 1 + alltrips := selectset( laneleg, Trip, trip, trip.Arrival().Date() < column.StartDate().StartOfNextMonth() and trip.Arrival().Date() >= column.StartDate() ); + enginecosts := selectset( owner, LogisticsCostEngine, engine, engine.PackagingCapacity() <> 0 and engine.StartDate() <= column.StartDate() and engine.EndDate() >= column.StartDate() ); + transcosts := selectset( owner, LogisticsCostTransport, trans, trans.LoadingCapacity() <> 0 and trans.StartDate() <= column.StartDate() and trans.EndDate() >= column.StartDate() ); + if( not isnull( enginecosts ) and enginecosts.Size() > 0 and not isnull( transcosts ) and transcosts.Size() > 0 ){ + producttrips := selectuniquevalues( alltrips, Elements.ProductInTrip, pit, pit.Quantity() <> 0 and exists( pit.Product_MP().GetAllParent(), Elements, e, e.ID() = produtparent ), pit.ProductID() ); + traverse( producttrips, Elements, producttrip ){//, producttrip = '6912' + + row := table.GetRow( producttrip ); + product := selectobject( owner, Product_MP, product, product.ID() = producttrip ); + products.Add( product ); + quantity := sum( alltrips, Elements.ProductInTrip, pit, pit.Product_MP() = product, pit.Quantity() ); + enginecost := selectobject( enginecosts, Elements, engine, engine.Generation().ToLower() = product.Generation().ToLower() + and engine.MLB_MQB() = product.MQBMLB() + and engine.Factory() = ccfactory ); + //鍦ㄨ繍杈撴垚鏈弬鏁拌〃閲屾壘鍒板彂鍔ㄦ満瀵瑰簲杩愯緭鍗曚环鍜岃杞藉閲� + transcost := selectobject( transcosts, Elements, trans, trans.Origin() = laneleg.OriginStockingPointID() + and trans.Destination() = laneleg.DestinationStockingPointID() + and exists( product.GetAllParent(), Elements, e, ifexpr( trans.Product().FindString( '鍙戝姩鏈�', 0 ) >= 0, e.ID() = produtparent, e.ID() = trans.Product() ) ) ); + + if( not isnull( enginecost ) and not isnull( transcost ) ){ + cost := ceil( ceil( quantity / enginecost.PackagingCapacity() ) / transcost.LoadingCapacity() ) * transcost.TransportPrice();//鍥涜垗浜斿叆 + cell := selectobject( row, Cell, cell, cell.Column() = column ); + cell.CCLongTransCost( cell.CCLongTransCost() + cost ) + } + } + } + } + //traverse( owner, TransferPlanRow, tprow ){ + // product := selectobject( owner, Product_MP, product, product.ID() = tprow.ProductID() ); + // productparents := product.GetAllParent(); + // if( exists( productparents, Elements, e, e.ID() = produtparent ) ){//鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満 + // //璧峰搴撳瓨鐐规槸鍚︽槸澶ц繛(澶ц繛鍘傚唴搴擄級 + // isdl := tprow.SourceStockpoingPointID().EndsWith( '鍘傚唴搴�' ) and ( tprow.TargetStockpoingPointID().StartsWith( '澶ц繛' ) or tprow.TargetStockpoingPointID().StartsWith( 'DL' ) ); + // //鐩殑鍦板簱瀛樼偣鏄惁鏄暱鏄ワ紙闀挎槬澶栫搴擄級 + // iscc := tprow.TargetStockpoingPointID().EndsWith( '澶栫搴�' ) and ( tprow.TargetStockpoingPointID().StartsWith( '闀挎槬' ) or tprow.TargetStockpoingPointID().StartsWith( 'CC' ) ); + // if( isdl and iscc ){ + // //鏌ヨ瀵瑰簲鐨勫彂鍔ㄦ満鎴愭湰 + // enginecosts := selectset( owner, LogisticsCostEngine, engine, engine.PackagingCapacity() <> 0 and engine.Generation().ToLower() = product.Generation().ToLower() + // and engine.MLB_MQB() = product.MQBMLB() + // and engine.Factory() = ccfactory ); + // //鍦ㄨ繍杈撴垚鏈弬鏁拌〃閲屾壘鍒板彂鍔ㄦ満瀵瑰簲杩愯緭鍗曚环鍜岃杞藉閲� + // transcosts := selectset( owner, LogisticsCostTransport, trans, trans.LoadingCapacity() <> 0 and trans.Origin() = tprow.SourceStockpoingPointID() + // and trans.Destination() = tprow.TargetStockpoingPointID() + // and exists( productparents, Elements, e, ifexpr( trans.Product().FindString( '鍙戝姩鏈�', 0 ) >= 0, e.ID() = produtparent, e.ID() = trans.Product() ) ) ); + // if( not isnull( enginecosts ) and enginecosts.Size() > 0 and not isnull( transcosts ) and transcosts.Size() > 0 ){ + // row := table.GetRow( product.ID() ); + // products.Add( product ); + // traverse( tprow,TransferPlanCell, tpcell, tpcell.TransferPlanColumn().ColumnDate() <> Date::MinDate() and [Number]tpcell.Value() > 0){ + // tpcolumndate := tpcell.TransferPlanColumn().ColumnDate(); + // enginecost := selectobject( enginecosts, Elements, engine, engine.StartDate() <= tpcolumndate and engine.EndDate() >= tpcolumndate ); + // transcost := selectobject( transcosts, Elements, trans, trans.StartDate() <= tpcolumndate and trans.EndDate() >= tpcolumndate ); + // if( not isnull( enginecost ) and not isnull( transcost ) ){ + // periodtime := tpcolumndate.StartOfMonth(); + // periodname := periodtime.Format( "M2/D2/Y" ); + // column := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime ); + // + // cost := ceil( ceil( [Number]tpcell.Value() / enginecost.PackagingCapacity() ) / transcost.LoadingCapacity() ) * transcost.TransportPrice(); + // cell := selectobject( row, Cell, cell, cell.Column() = column ); + // cell.CCLongTransCost( cell.CCLongTransCost() + cost ); + // } + // } + // } + // } + } + } + //闀挎槬鐭�旇繍杈撹垂鐢細瀹㈡埛闇�姹傛暟閲�/鍖呰瀹归噺/瑁呰浇瀹归噺*杩愯緭鍗曚环锛屽鎴烽渶姹傛暟閲忓彇鑷猣orecast閲宻ales segment涓洪暱鏄ョ殑鏁伴噺姹囨�伙紝鍐嶇敤鍏紡璁$畻锛屾湀搴﹁繘琛屾眹鎬伙紙鍙栧鎴烽渶姹傛暟閲忔崲绠楁垚杞︽锛� + allforecast := selectset( owner, SalesDemand.astype( Forecast ), forecast, forecast.Quantity() > 0 and not isnull( forecast.SalesSegment_MP() ) and forecast.StartDate() < startofnextyear and //forecast.ProductID() = '6912' and forecast.StartDate().Month() = 1 and + // ( forecast.SalesSegment_MP().Name().StartsWith( 'Changchun' ) or exists( forecast.SalesSegment_MP().GetAllParent(), Elements, psalessegment, psalessegment.Name().StartsWith( 'Changchun' ) ) or + ( forecast.SalesSegment_MP().Name().StartsWith( 'Foshan' ) or forecast.SalesSegment_MP().Name().StartsWith( 'Tianjin' ) + or exists( forecast.SalesSegment_MP().GetAllParent(), Elements, psalessegment, psalessegment.Name().StartsWith( 'Foshan' ) or psalessegment.Name().StartsWith( 'Tianjin' ) ) ) + and exists( forecast.Product_MP().GetAllParent(), Elements, e, e.ID() = produtparent ) ); + //ccforecasts := selectset( allforecast, Elements, forecast, forecast.SalesSegment_MP().Name().StartsWith( 'Changchun' ) or exists( forecast.SalesSegment_MP().GetAllParent(), Elements, psalessegment, psalessegment.Name().StartsWith( 'Changchun' ) ) ); + //ccproducts := selectuniquevalues( ccforecasts, Elements, forecast, forecast.ProductID() ); + dlforecasts := selectset( allforecast, Elements, forecast, forecast.SalesSegment_MP().Name().StartsWith( 'Foshan' ) or forecast.SalesSegment_MP().Name().StartsWith( 'Tianjin' ) + or exists( forecast.SalesSegment_MP().GetAllParent(), Elements, psalessegment, psalessegment.Name().StartsWith( 'Foshan' ) or psalessegment.Name().StartsWith( 'Tianjin' ) ) ); + dlproducts := selectuniquevalues( dlforecasts, Elements, forecast, forecast.ProductID() );; + //traverse( ccproducts, Elements, ccproduct){ + // product := selectobject( owner, Product_MP, product, product.ID() = ccproduct ); + //// info( '************', product.ID(), exists( ccforecasts, Elements, forecast, forecast.Quantity() > 0 )); + // //鏌ヨ瀵瑰簲鐨勫彂鍔ㄦ満鎴愭湰 + // enginecosts := selectset( owner, LogisticsCostEngine, engine, engine.PackagingCapacity() <> 0 and engine.Generation().ToLower() = product.Generation().ToLower() + // and engine.MLB_MQB() = product.MQBMLB()and engine.Factory() = ccfactory ); + // //鍦ㄨ繍杈撴垚鏈弬鏁拌〃閲屾壘鍒板彂鍔ㄦ満瀵瑰簲杩愯緭鍗曚环鍜岃杞藉閲� + // transcosts := selectset( owner, LogisticsCostTransport, trans, trans.LoadingCapacity() <> 0 and trans.Origin() = '闀挎槬澶栫搴�' + // and trans.Destination() = '瀹㈡埛搴�' + // and exists( product.GetAllParent(), Elements, e, ifexpr( trans.Product().FindString( '鍙戝姩鏈�', 0 ) >= 0, e.ID() = produtparent, e.ID() = trans.Product() ) ) ); + // if( not isnull( enginecosts ) and enginecosts.Size() > 0 and not isnull( transcosts ) and transcosts.Size() > 0 ){ + // row := table.GetRow( ccproduct ) + // products.Add( product ); + // traverse( table, Column, column ){ + // allpsdips := selectset( ccforecasts, Elements.PlanningSalesDemandInPeriod, psdip, psdip.ProductID() = ccproduct and psdip.Quantity() > 0 and psdip.StartDate() < column.StartDate().StartOfNextMonth() and psdip.StartDate() >= column.StartDate() ); + // enginecost := selectobject( enginecosts, Elements, engine, engine.StartDate() <= column.StartDate() and engine.EndDate() >= column.StartDate() ); + // transcost := selectobject( transcosts, Elements, trans, trans.StartDate() <= column.StartDate() and trans.EndDate() >= column.StartDate() ); + // if( not isnull( enginecost ) and not isnull( transcost ) ){ + // quantity := sum( allpsdips, Elements, psdip, psdip.Quantity() ); + // cost := ceil( ceil( quantity / enginecost.PackagingCapacity() ) / transcost.LoadingCapacity() ) * transcost.TransportPrice(); + // cell := selectobject( row, Cell, cell, cell.Column() = column ); + // cell.CCShorTransCost( cell.CCShorTransCost() + cost ); + // } + // } + // } + //} + traverse( dlproducts, Elements, ccproduct){ + + row := table.GetRow( ccproduct ) + product := selectobject( owner, Product_MP, product, product.ID() = ccproduct ); + //鏌ヨ瀵瑰簲鐨勫彂鍔ㄦ満鎴愭湰 + enginecosts := selectset( owner, LogisticsCostEngine, engine, engine.PackagingCapacity() <> 0 and engine.Generation().ToLower() = product.Generation().ToLower() + and engine.MLB_MQB() = product.MQBMLB()and engine.Factory() = dlfactory ); + if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){ + traverse( table, Column, column ){ + allpsdips := selectset( dlforecasts, Elements.PlanningSalesDemandInPeriod, psdip, psdip.ProductID() = ccproduct and psdip.Quantity() > 0 and psdip.StartDate() < column.StartDate().StartOfNextMonth() and psdip.StartDate() >= column.StartDate() ); + enginecost := selectobject( enginecosts, Elements, engine, engine.StartDate() <= column.StartDate() and engine.EndDate() >= column.StartDate() ); + if( not isnull( enginecost ) ){ + products.Add( product ); + quantity := sum( allpsdips, Elements, psdip, psdip.Quantity() );// + psdip.FulfilledQuantity() + + cost := ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.OutboundPrice(); + row.SetDLRentOutCost( column, cost ); + } + } + } + } + + //rows := selectsortedset( table, Row, row, row.Name() ); + //i := 0; + //traverse( rows, Elements, e ){ + // e.RowNr( i ); + // i := i + 1; + //} + info( '-------------------------------------end----------------------------------' ); + // + //showtable.Generate( search, products ); + *] +} diff --git a/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_InitializeNew.qbl b/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_InitializeNew.qbl index 7d6e205..6bc14fb 100644 --- a/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_InitializeNew.qbl +++ b/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_InitializeNew.qbl @@ -211,7 +211,7 @@ enginecost := selectobject( enginecosts, Elements, engine, engine.StartDate() <= column.StartDate() and engine.EndDate() >= column.StartDate() ); if( not isnull( enginecost ) ){ products.Add( product ); - quantity := sum( allpsdips, Elements, psdip, psdip.Quantity() ); + quantity := sum( allpsdips, Elements, psdip, psdip.Quantity() );// + psdip.FulfilledQuantity() cost := ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.OutboundPrice(); row.SetDLRentOutCost( column, cost ); -- Gitblit v1.9.3