陈清红
2025-04-14 880f3c0257eeb8c37761d484258fdd102a369a19
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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;
  *]
}