lazhen
2024-11-01 b068efe67a223c53e2d608b553d327ca61bfd1e9
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
Quintiq file version 2.0
#parent: #root
StaticMethod GenerateData (
  InterfaceDataset owner,
  String werk,
  String version,
  Date startdate,
  Date enddate,
  String executor
)
{
  TextBody:
  [*
    // 甄兰鸽 Aug-23-2024 (created)
    loginfo                := maxobject(  owner, InterfaceLoginfo, loginfo, loginfo.Name() = Translations::InterfaceDataset_AOnlineAndMOfflinePlanPIR_Name(), loginfo.InterfaceDateTime() );
    if( not isnull( loginfo ) ){
      if( not loginfo.IsShow() ){
        loginfo.Delete();
      }else{
        loginfo.Last( false );
      }
    //  owner.AOnlineAndMOfflinePlanPIR( relflush );
    }
    owner.AOnlineAndMOfflinePlanPIR( relflush );
    nowdate                := DateTime::ActualTime();
    productids             := construct( Strings );
    loginfo                := owner.InterfaceLoginfo( relnew, ExecuteUser := executor
                                                      , Name := Translations::InterfaceDataset_AOnlineAndMOfflinePlanPIR_Name()
                                                      , InterfaceDateTime := nowdate
                                                      , Message := '装配上线计划 + 机加下线计划 - PIR'
    //                                                  , IsShow := false
                                                      , Last := true
                                                      , ReturnSuccess := true
                                                      , ReturnMsg := 'Success'
                                                      , Success := true
                                                      );
    pir                    := owner.AOnlineAndMOfflinePlanPIR( relnew, ZPPPSCode := OS::GenerateGUIDAsString(), Werk := AOnlineAndMOfflinePlanPIR::GetWerk( werk ), Version := version, StartDate := startdate, EndDate := enddate );
    loginfo.AOnlineAndMOfflinePlanPIR( relinsert, pir );
    traverse( owner, AssemblyOnlinePlanVersion, verison, not verison.IsShow() ){
      traverse( verison, Column, column, column.TimeUnit() = Translations::MP_GlobalParameters_Day() and column.StartDate() >= startdate and column.StartDate() <= enddate ){
        traverse( column, Cell, cell, ( werk = 'All' or cell.Row().ProductionLine().FindString( werk, 0 ) > -1 )
                  and cell.Row().Type() = '1' ){
          quantityrow        := cell.Row();
          if( not exists( productids, Elements, e, e = quantityrow.ProductID() ) ){
            productids.Add( quantityrow.ProductID() );
          }
      
          pir.PIRData( relnew, Product           := quantityrow.ProductID()
                       , PlanningDate            := column.StartDate()
                       , PlanningQty             := [Number]cell.Value());
        }
      }
    }
    
    traverse( owner, OfflinePlanArchiveVersion, table ){
      traverse( table, Column, column, column.StartDate() >= startdate and column.StartDate() <= enddate ){
        traverse( column, Cell, cell, ( werk = 'All' or cell.Row().ProductionLine().FindString( werk, 0 ) > -1 )
                  and ( cell.Row().ProductionLine() <> 'DL_MOMO' or cell.Row().ProductionLine() <> 'CC_MOMO' )
                  and cell.Row().Type() = '1' ){
          row              := cell.Row();
          if( not exists( productids, Elements, e, e = row.ProductID() ) ){
            productids.Add( row.ProductID() );
          }
          pirdata          := selectobject(  pir, PIRData, pirdata, pirdata.Product() = row.ProductID() and pirdata.PlanningDate() = column.StartDate() );
          if( isnull( pirdata ) ){
            pirdata          := pir.PIRData( relnew, Product           := row.ProductID()
                                             , PlanningDate            := column.StartDate()
                                             , PlanningQty             := 0 );
          }
          pirdata.PlanningQty( pirdata.PlanningQty() + [Number]cell.Value() );
        }
      }
    }
    traverse( productids, Elements, e ){
      for( date := startdate.StartOfWeek(); date <= enddate; date := ( date + Duration::Days( 1 ) ).Date() ){
        if( not exists( pir, PIRData, pirdata, pirdata.Product() = e and pirdata.PlanningDate() = date ) ){
          pir.PIRData( relnew, Product         := e
                     , PlanningDate            := date
                     , PlanningQty             := 0 );
        }
      }
    }
    loginfo.TotalRow( pir.PIRData( relsize ) );
    InterfaceLoginfo::CallInterfaceForSAPGet( owner, loginfo );
  *]
}