lazhen
2024-11-05 aa42b48fd2d23e75b64a0aec05d5be4b9ebf0465
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
Quintiq file version 2.0
#parent: #root
StaticMethod RefreshData (
  InterfaceDataset interface,
  const MacroPlan macroPlan,
  const Archive archive
)
{
  TextBody:
  [*
    //根据当前版本的下线计划
    allunit                := OfflinePlanArchiveVersion::GetDefaultAllUnit();
    name                   := OfflinePlanArchiveVersion::GetDefaultName();
    interface.OfflinePlanArchiveSearch( relnew, Product := allunit, ProductionLine := allunit, TimeUnit := Translations::MP_GlobalParameters_Day(), Unit := allunit, StartDate := Date::MinDate(), EndDate := Date::MaxDate() );
    table                  := selectobject( interface, OfflinePlanArchiveVersion, version, not version.IsShow() );
    if( isnull( table ) ){
      table                := interface.OfflinePlanArchiveVersion( relnew, ID := name, Name := name );
    }
    //showtable              := selectobject( interface, OfflinePlanArchiveVersion, version, version.IsShow() );
    //if( isnull( table ) ){
    //  showtable               := interface.OfflinePlanArchiveVersion( relnew, ID := name, Name := name, IsShow := true );
    //}
    nopcolumns             := selectuniquevalues(  macroPlan, NewOfflinePlanTable.NewOfflinePlanColumn, nopcolumn, not exists( table, Column, column, column.TimeUnit() = Translations::MP_GlobalParameters_Day() and column.StartDate() = nopcolumn.StartDate() ), nopcolumn.StartDate() );
    table.GenerateColumn( nopcolumns );
    noptable               := maxobject( macroPlan, NewOfflinePlanTable, noptable, noptable.SaveDateTime() );
    actproductiondatas     := selectset( archive,ActualDailyProductionData,data,true );
    actproductiontree      := NamedValueTree::Create();
    for( i := 0; i< actproductiondatas.Size(); i++ ){
      actproduction        := actproductiondatas.Element( i );
      actproductionKey     := actproduction.ProductNo() + actproduction.ProductionDate().AsQUILL();
      actproductionhandle  := actproductiontree.GetHandle( actproductionKey );
      actproductiontree.Root().AddChild( actproductionhandle,i ); 
    }
    traverse( noptable, NewOfflinePlanRow, noprow ){
      row                  := table.GetRow( noprow );
      traverse( noprow, NewOfflinePlanCell, nopcell ){
        column             := selectobject( table, Column, column, column.TimeUnit() = Translations::MP_GlobalParameters_Day() and column.StartDate() = nopcell.NewOfflinePlanColumn().StartDate() );
        cell               := selectobject( row, Cell, cell, cell.Column() = column );
        actproductionKey   := noprow.ProductID() + column.StartDate().AsQUILL();
        actproductionhandle:= actproductiontree.GetHandle( actproductionKey );
        actproductionindex := guard( actproductiontree.Root().Child( actproductionhandle ),null( NamedValue ));
        
        actproductionqty       := 0.0;
        if( not isnull( actproductionindex )){
          actproduction        := actproductiondatas.Element( actproductionindex.GetValueAsNumber() );
          actproductionqty     := actproduction.ActualOut();
        }
        cell.ActualProductionQty( actproductionqty );
        cell.InventoryWeight( nopcell.InventoryWeight() );
    //      cell.ProductionSerialNumber( nopcell.ProductionSerialNumber() );
        cell.Quantity( nopcell.Quantity() );
    //      cell.Shift( nopcell.Shift() );
    //      cell.Value( nopcell.Value() );
      }
    }
    //showtable.Generate( search, products );
  *]
}