| 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; | 
|   *] | 
| } |