admin
2025-01-15 3b5a99bec48b3356d8f4d036b14c55d376809b86
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
Quintiq file version 2.0
#parent: #root
StaticMethod GenerateData (
  InterfaceDataset owner,
  MacroPlan macroplan,
  String werk,
  String version,
  Date startdate,
  Date enddate,
  String executor,
  String feedback,
  Boolean isPush
) as InterfaceLoginfo
{
  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.StartDate() >= startdate and column.StartDate() <= enddate ){//column.TimeUnit() = Translations::MP_GlobalParameters_Day() and 
        traverse( column, Cell, cell, ( werk = 'All' or cell.Row().Unit().FindString( werk, 0 ) > -1 ) ){
          quantityrow      := cell.Row();
          rowwerk          := ifexpr( quantityrow.ProductionLine().FindString( "CC", 0 ) > -1, AOnlineAndMOfflinePlanPIR::GetWerk( FinancialProductionReport::GetDefaultCCUnit() ), AOnlineAndMOfflinePlanPIR::GetWerk( FinancialProductionReport::GetDefaultDLUnit() ) );
          if( not exists( productids, Elements, e, e = quantityrow.ProductID() ) ){
            productids.Add( quantityrow.ProductID() );
          }
          product          := selectobject( macroplan, Product_MP, product, product.ID() = quantityrow.Name() );
          planqty          := [Number]cell.Quantity();
          if( not isnull( product ) and exists( product.GetAllParent(), Elements, proparent, proparent.ID() = 'PL' ) ){
            planqty        := planqty *  4;
          }
          pir.PIRData( relnew, Product := quantityrow.ProductID(), PlanningDate := column.StartDate(), PlanningQty := planqty, Werk := rowwerk );
        }
      }
    }
    
    traverse( owner, OfflinePlanArchiveVersion, table, not table.IsShow() ){
      traverse( table, Column, column, column.StartDate() >= startdate and column.StartDate() <= enddate ){//column.TimeUnit() = Translations::MP_GlobalParameters_Day() and 
        traverse( column, Cell, cell, ( werk = 'All' or cell.Row().Unit().FindString( werk, 0 ) > -1 )
                  and ( cell.Row().ProductionLine() <> 'DL_MOMO' or cell.Row().ProductionLine() <> 'CC_MOMO' ) ){
          row              := cell.Row();
          rowwerk          := ifexpr( row.ProductionLine().FindString( "CC", 0 ) > -1, AOnlineAndMOfflinePlanPIR::GetWerk( FinancialProductionReport::GetDefaultCCUnit() ), AOnlineAndMOfflinePlanPIR::GetWerk( FinancialProductionReport::GetDefaultDLUnit() ) );
          if( not exists( productids, Elements, e, e = row.ProductID() ) ){
            productids.Add( row.ProductID() );
          }
          pirdata          := select( 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, Werk := rowwerk );
          }
          product          := selectobject( macroplan, Product_MP, product, product.ID() = row.Name() );
          planqty          := [Number]cell.Quantity();
          if( not isnull( product ) and exists( product.GetAllParent(), Elements, proparent, proparent.ID() = 'PL' ) ){
            planqty        := planqty *  4;
          }
          pirdata.PlanningQty( pirdata.PlanningQty() + planqty );
        }
      }
    }
    traverse( productids, Elements, e ){
      for( date        := startdate.StartOfYear(); date <= enddate; date := ( date + Duration::Days( 1 ) ).Date() ){
        if( not exists( pir, PIRData, pirdata, pirdata.Product() = e and pirdata.PlanningDate() = date ) ){
          if( werk = 'All' ){
            pir.PIRData( relnew, Product := e, PlanningDate := date, PlanningQty := 0, Werk := '8200' );
            pir.PIRData( relnew, Product := e, PlanningDate := date, PlanningQty := 0, Werk := '8201' );
          }else{
            pir.PIRData( relnew, Product := e, PlanningDate := date, PlanningQty := 0, Werk := pir.Werk() );
          }
        }
      }
    }
    loginfo.TotalRow( pir.PIRData( relsize ) );
    
    if ( isPush ) {
      feedback             := AOnlineAndMOfflinePlanPIR::Publish( owner, loginfo );
    }
    
    return loginfo;
  *]
}