yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
Quintiq file version 2.0
#parent: #root
StaticMethod GetProcessQuantity (
  Period_MP period,
  Lane lane,
  ProductInStockingPoint_MPs pisps,
  ProductInStockingPoint_MP targetpisp,
  Boolean isdependentdemand,
  Boolean isupstream,
  output String tooltip
) declarative remote as Real
{
  Description: 'Return quantities of a lane to pisps in a period or pisp to a lane in a period'
  TextBody:
  [*
    value := 0.0;
    
    // Insert table tag for tooltip
    // Lane name
    tooltip := "<table>";
    tooltip := tooltip + '<tr><td><b>Lane: </b></td><td>' 
               + lane.Name() + '</td></tr>';
    
    // Unit name
    tooltip := tooltip + '<tr><td><b>Unit: </b></td><td>' 
               + lane.Unit().Name() + '</td></tr>';
    
    // Period
    tooltip := tooltip + '<tr><td><b>Period: </b></td><td>' 
               + period.StartDate().Format( 'D-MM-Y' ) + ' until ' + period.EndDate().Format( 'D-MM-Y' ) + '</td></tr>'; 
    
    // A separating line
    tooltip := tooltip + '</table><hr>';
    
    // Lanelegs and products headers
    tooltip := tooltip + '<table><tr><td><b>Lane leg:</b></td><td><b>' 
               + select( pisps, Elements, e, true ).Product_MP().Name() + ' quantity: </b></td></tr>';
    
    if( isdependentdemand )
    {
      if( not isupstream )
      {
        traverse( lane, LaneLeg.Trip.PeriodTaskLaneLeg.DependentDemand, dd,
                  exists( pisps, Elements, e, e = dd.ProductInStockingPointInPeriodPlanningLeaf().ProductInStockingPoint_MP() )
                  and dd.Start() >= period.Start()
                  and dd.End() <= period.End() )
                  {
                    value := value + dd.Quantity();
                    tooltip := tooltip + '<tr><td>' + dd.PeriodTask_MP().Process_MP().Name() + '</td><td>' 
                               + dd.Quantity().AsQUILL() + '</td></tr>';
                  }
      }
      else
      {
        lanelegs := selectset( lane, LaneLeg, ll,
                               ll.AsDestinationStockingPointLeg().StockingPoint_MP() = targetpisp.StockingPoint_MP() );
    
        traverse( lanelegs, Elements.Trip.PeriodTaskLaneLeg.DependentDemand, dd,
                  exists( pisps, Elements, e, e = dd.ProductInStockingPointInPeriodPlanningLeaf().ProductInStockingPoint_MP() )
                  and dd.Start() >= period.Start()
                  and dd.End() <= period.End() )
                  {
                    value := value + dd.Quantity();
                    tooltip := tooltip + '<tr><td>' + dd.PeriodTask_MP().Process_MP().Name() + '</td><td>' 
                               + dd.Quantity().AsQUILL() + '</td></tr>';
                  }
      }
    }
    else
    {
      if( isupstream )
      {
        traverse( lane, LaneLeg.Trip.PeriodTaskLaneLeg.NewSupply, ns, 
                  exists( pisps, Elements, e, e = ns.ProductInStockingPointInPeriodPlanningLeaf().ProductInStockingPoint_MP() )
                  and ns.Start() >= period.Start()
                  and ns.End() <= period.End() )
                  {
                    value := value + ns.Quantity();
                    tooltip := tooltip + '<tr><td>' + ns.PeriodTask_MP().Process_MP().Name() + '</td><td>' 
                               + ns.Quantity().AsQUILL() + '</td></tr>';
                  }
      }
      else
      {
        lanelegs := selectset( lane, LaneLeg, ll,
                               ll.AsOriginStockingPointLeg().StockingPoint_MP() = targetpisp.StockingPoint_MP() );
        
        traverse( lanelegs, Elements.Trip.PeriodTaskLaneLeg.NewSupply, ns,
                  exists( pisps, Elements, e, e = ns.ProductInStockingPointInPeriodPlanningLeaf().ProductInStockingPoint_MP() )
                  and ns.Start() >= period.Start()
                  and ns.End() <= period.End() )
                  {
                    value := value + ns.Quantity();
                    tooltip := tooltip + '<tr><td>' + ns.PeriodTask_MP().Process_MP().Name() + '</td><td>' 
                               + ns.Quantity().AsQUILL() + '</td></tr>';               
                  }
      }
    } 
    
    tooltip := tooltip + '</table>';
    
    return value;
  *]
}