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
Quintiq file version 2.0
#parent: #root
StaticMethod Upload (
  MacroPlan macroPlan,
  OfflinePlanTable opt,
  GeneralExcelImportAndExportDataTable table
)
{
  TextBody:
  [*
    indexUnitID    := "";
    indexProductID := "";
    
    traverse ( table, GeneralExcelImportAndExportDataRow, row ) {
      firstColumn  := select( table, GeneralExcelImportAndExportDataColumn, tempC, tempC.ColumnIndex() = 0 );
      secondColumn := select( table, GeneralExcelImportAndExportDataColumn, tempC, tempC.ColumnIndex() = 1 );
      
      firstCell    := select( row, GeneralExcelImportAndExportDataCell, tempC, tempC.GeneralExcelImportAndExportDataColumn() = firstColumn );
      u            := select( macroPlan, Unit, tempU, tempU.ID() = firstCell.Value() );
      product      := select( macroPlan, Product_MP, tempPMP, tempPMP.ID() = firstCell.Value() );
      
      secondCell    := select( row, GeneralExcelImportAndExportDataCell, tempC, tempC.GeneralExcelImportAndExportDataColumn() = secondColumn );
      
      if ( not isnull( u ) and secondCell.Value() = "" ) {
        indexUnitID := u.ID();
        opr         := select( opt, OfflinePlanRow, tempOPR, tempOPR.ProductionLine() = indexUnitID and tempOPR.ProductID() = "" and tempOPR.Type() = "0" );
        opr.OfflinePlanCell( relflush );
        
        OfflinePlanImportData::UpdateCell( table, row, opt, opr );
      } else if ( not isnull( product ) and secondCell.Value() = "Quantity" ) {
        indexProductID := product.ID();
        opr            := select( opt, OfflinePlanRow, tempOPR, tempOPR.ProductionLine() = indexUnitID and tempOPR.ProductID() = indexProductID and tempOPR.Type() = "1" );
        opr.OfflinePlanCell( relflush );
        
        OfflinePlanImportData::UpdateCell( table, row, opt, opr );
      } else if ( isnull( product ) and secondCell.Value() = "Order" ) {
        opr := select( opt, OfflinePlanRow, tempOPR, tempOPR.ProductionLine() = indexUnitID and tempOPR.ProductID() = indexProductID and tempOPR.Type() = "2" );
        opr.OfflinePlanCell( relflush );
        
        OfflinePlanImportData::UpdateCell( table, row, opt, opr );
      } else if ( firstCell.Value() = "合计" and secondCell.Value() = "总量" ) {
        opr := select( opt, OfflinePlanRow, tempOPR, tempOPR.ProductionLine() = indexUnitID and tempOPR.ProductID() = "Z" and tempOPR.Type() = "3" );
        opr.OfflinePlanCell( relflush );
        
        OfflinePlanImportData::UpdateCell( table, row, opt, opr );
      } else if ( firstCell.Value() = "" and secondCell.Value() = "班次" ) {
        opr := select( opt, OfflinePlanRow, tempOPR, tempOPR.ProductionLine() = indexUnitID and tempOPR.ProductID() = "Z" and tempOPR.Type() = "4" );
        opr.OfflinePlanCell( relflush );
        
        OfflinePlanImportData::UpdateCell( table, row, opt, opr );
      } else if ( firstCell.Value() = "" and secondCell.Value() = "班次开始时间" ) {
        opr := select( opt, OfflinePlanRow, tempOPR, tempOPR.ProductionLine() = indexUnitID and tempOPR.ProductID() = "Z" and tempOPR.Type() = "5" );
        opr.OfflinePlanCell( relflush );
        
        OfflinePlanImportData::UpdateCell( table, row, opt, opr );
      } else if ( firstCell.Value() = "" and secondCell.Value() = "班次结束时间" ) {
        opr := select( opt, OfflinePlanRow, tempOPR, tempOPR.ProductionLine() = indexUnitID and tempOPR.ProductID() = "Z" and tempOPR.Type() = "6" );
        opr.OfflinePlanCell( relflush );
        
        OfflinePlanImportData::UpdateCell( table, row, opt, opr );
      } else {
        error( "导入失败,数据异常" );
      }
    }
  *]
}