Kevin Kok Khah Whey
2023-11-07 5ae534ab606e6f2ba5ea60914224d665b0447d5a
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
Quintiq file version 2.0
#parent: #root
StaticMethod CreasteFromMapping (
  const GlobalOTDTable globalOTDTable,
  MacroPlan macroPlan
)
{
  TextBody:
  [*
    // Administrator Oct-31-2023 (created)
    updates := construct( Lanes );
    traverse( globalOTDTable, Global_MappingLane, gl, true )
    {
      id := gl.ID();
      unitid := gl.UnitID();
      name := gl.Name();
      userleadtime := gl.UserLeadTime();
      processingtime := Duration::Zero();
      
      unitofmeasurename := "PCS";
      currencyid := "CNY";
      startdate := Date::Date( 1900, 1, 1 );
      enddate := Date::Date( 9999, 12, 31 );
      capacitytype := "Transport quantity";
      if( userleadtime.Length() = 0 )
      {
        processingtime := Duration::Zero(); 
        }
      else
      {
        processingtime := Duration::Hours( [Number]userleadtime );
        };
      
      unit := Unit::FindById( macroPlan, unitid );
      if( isnull( unit)){
        unit :=macroPlan.Unit( relnew, 
                               ID := unitid, 
                               Name := unitid, 
                               UnitOfMeasureName := unitofmeasurename, 
                               CurrencyID := currencyid, 
                               StartDate := startdate, 
                               EndDate := enddate, 
                               CapacityType := capacitytype );
      }
      
      a := Lane::CreateLane( macroPlan, unit, id, name, processingtime);
      updates.Add( a );
      }
    origindataset := selectset( macroPlan, Unit.Lane, l, true );
    obsoletes := origindataset.Difference( updates );
    // delete obsoleted
    difflength := obsoletes.Size();
    for( j:=0; j<difflength; j++ )
    {
      obsolete := obsoletes.Element( j );
      obsolete.Delete();
      }
  *]
}