admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
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
Quintiq file version 2.0
#parent: #root
StaticMethod CreateOldOfflinePlanData (
  MacroPlan macroPlan
) as OfflinePlanTable
{
  TextBody:
  [*
    nopt := maxselect( macroPlan, NewOfflinePlanTable, tempNOPT, true, tempNOPT.SaveDateTime() );
    
    macroPlan.OfflinePlanTable( relflush );
    
    opt  := macroPlan.OfflinePlanTable( relnew, SaveDateTime := nopt.SaveDateTime() );
    
    // 创建列
    firstColumn  := opt.OfflinePlanColumn( relnew, ColumnDate := macroPlan.StartOfPlanning().Date() - 2 );
    secondColumn := opt.OfflinePlanColumn( relnew, ColumnDate := macroPlan.StartOfPlanning().Date() - 1 );
    traverse ( nopt, NewOfflinePlanColumn, nopc ) {
      opt.OfflinePlanColumn( relnew, ColumnDate := nopc.StartDate() );
    }
    
    pls := selectuniquevalues( nopt, NewOfflinePlanRow, tempNOPR, true, tempNOPR.ProductionLine() );
    
    traverse ( pls, Elements, pl ) {
      // 创建明细行
      detailNOPRs := selectsortedset( nopt, NewOfflinePlanRow, tempNOPR, tempNOPR.ProductionLine() = pl and tempNOPR.Type() = "1", tempNOPR.ProductionLine(), tempNOPR.ProductID() );
      traverse ( detailNOPRs, Elements, nopr ) {
        quantityOPR := opt.OfflinePlanRow( relnew, ProductionLine := nopr.ProductionLine(), ProductID := nopr.ProductID(), Type := "1" );
        orderOPR    := opt.OfflinePlanRow( relnew, ProductionLine := nopr.ProductionLine(), ProductID := nopr.ProductID(), Type := "2" );
        
        // 第一列
        quantityOPR.OfflinePlanCell( relnew, OfflinePlanColumn := firstColumn,  Value := nopr.Name() );
        orderOPR.OfflinePlanCell(    relnew, OfflinePlanColumn := firstColumn,  Value := "" );
        
        // 第二列
        quantityOPR.OfflinePlanCell( relnew, OfflinePlanColumn := secondColumn, Value := "Quantity" );
        orderOPR.OfflinePlanCell(    relnew, OfflinePlanColumn := secondColumn,  Value := "Order" );
        
        // 时间列
        traverse ( nopr, NewOfflinePlanCell, nopcell ) {
          opc := select( opt, OfflinePlanColumn, tempOPC, tempOPC.ColumnDate() = nopcell.StartDate() );
          quantityOPR.OfflinePlanCell( relnew, OfflinePlanColumn := opc, Value := [String]nopcell.Quantity() );
          orderOPR.OfflinePlanCell(    relnew, OfflinePlanColumn := opc, Value := nopcell.Order() );
        }
      }
      
      // 创建合计行
      totalNOPR            := select( nopt, NewOfflinePlanRow, tempNOPR, tempNOPR.ProductionLine() = pl and tempNOPR.Type() = "2" );
      
      totalOPR             := opt.OfflinePlanRow( relnew, ProductionLine := totalNOPR.ProductionLine(), ProductID := "Z", Type := "3" );
      shiftPatternNameOPR  := opt.OfflinePlanRow( relnew, ProductionLine := totalNOPR.ProductionLine(), ProductID := "Z", Type := "4" );
      shiftPatternStartOPR := opt.OfflinePlanRow( relnew, ProductionLine := totalNOPR.ProductionLine(), ProductID := "Z", Type := "5" );
      shiftPatternEndOPR   := opt.OfflinePlanRow( relnew, ProductionLine := totalNOPR.ProductionLine(), ProductID := "Z", Type := "6" );
      
      // 第一列
      totalOPR.OfflinePlanCell( relnew, OfflinePlanColumn := firstColumn, Value := "合计" );
      shiftPatternNameOPR.OfflinePlanCell( relnew, OfflinePlanColumn := firstColumn, Value := "" );
      shiftPatternStartOPR.OfflinePlanCell( relnew, OfflinePlanColumn := firstColumn, Value := "" );
      shiftPatternEndOPR.OfflinePlanCell( relnew, OfflinePlanColumn := firstColumn, Value := "" );
      
       // 第二列
      totalOPR.OfflinePlanCell( relnew, OfflinePlanColumn := secondColumn, Value := "总量" );
      shiftPatternNameOPR.OfflinePlanCell( relnew, OfflinePlanColumn := secondColumn, Value := "班次" );
      shiftPatternStartOPR.OfflinePlanCell( relnew, OfflinePlanColumn := secondColumn, Value := "班次开始时间" );
      shiftPatternEndOPR.OfflinePlanCell( relnew, OfflinePlanColumn := secondColumn, Value := "班次结束时间" );
      
      // 时间列
      traverse ( totalNOPR, NewOfflinePlanCell, nopcell ) {
        opc := select( opt, OfflinePlanColumn, tempOPC, tempOPC.ColumnDate() = nopcell.StartDate() );
        totalOPR.OfflinePlanCell(             relnew, OfflinePlanColumn := opc, Value := [String]nopcell.TotalQuantity() );
        shiftPatternNameOPR.OfflinePlanCell(  relnew, OfflinePlanColumn := opc, Value := nopcell.ShiftPatternName() );
        shiftPatternStartOPR.OfflinePlanCell( relnew, OfflinePlanColumn := opc, Value := nopcell.ShiftPatternStart() );
        shiftPatternEndOPR.OfflinePlanCell(   relnew, OfflinePlanColumn := opc, Value := nopcell.ShiftPatternEnd() );
      }
    }
    
    return opt;
  *]
}