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
Quintiq file version 2.0
#parent: #root
StaticMethod Import (
  MacroPlan macroPlan,
  GeneralExcelImportAndExportDataTable table
)
{
  TextBody:
  [*
    // 清空原始数据
    units := selectset( macroPlan,Unit,unit,true );
    unitIndexTree := NamedValueTree::Create();
    for( i := 0; i< units.Size(); i++ ){
      unit := units.Element( i );
      unit.SingleShiftConfig( relflush );
      
      unitHandle := unitIndexTree.GetHandle( unit.ID() );
      unitIndexTree.Root().AddChild( unitHandle,i );
    }
    
    // 校验文件名
    //if ( table.GeneralExcelImportAndExportDataSource().Name() <> "发动机匹配-六位码.xlsx" ) {
    //  error( Translations::A_VWED_GeneralExcelImportAndExportDataSource_UploadError2() );
    //}
    
    // 生成数据
    rows := selectsortedset( table,GeneralExcelImportAndExportDataRow,row,row.RowNr());
    
    traverse( rows,Elements,row ){
      
      unitIDCell := select( row, GeneralExcelImportAndExportDataCell, tempGEIAEDC, tempGEIAEDC.GeneralExcelImportAndExportDataColumn().ColumnIndex() = 1 );
      shiftNameCell := select( row, GeneralExcelImportAndExportDataCell, tempGEIAEDC, tempGEIAEDC.GeneralExcelImportAndExportDataColumn().ColumnIndex() = 2 );
      firstSingleShiftQuantityCell := select( row, GeneralExcelImportAndExportDataCell, tempGEIAEDC, tempGEIAEDC.GeneralExcelImportAndExportDataColumn().ColumnIndex() = 3 );
      secondSingleShiftQuantityCell := select( row, GeneralExcelImportAndExportDataCell, tempGEIAEDC, tempGEIAEDC.GeneralExcelImportAndExportDataColumn().ColumnIndex() = 4 );
      thirdSingleShiftQuantityCell := select( row, GeneralExcelImportAndExportDataCell, tempGEIAEDC, tempGEIAEDC.GeneralExcelImportAndExportDataColumn().ColumnIndex() = 5 );
      maintenanceDeduction := select( row, GeneralExcelImportAndExportDataCell, tempGEIAEDC, tempGEIAEDC.GeneralExcelImportAndExportDataColumn().ColumnIndex() = 6 );
      
      unitID := guard( unitIDCell.Value(), "" );
      if( unitID = "" ){
        error( "Unit ID 为必填项。" );
      }
      unitHandle := unitIndexTree.GetHandle( unitID );
      unitIndex := guard( unitIndexTree.Root().Child( unitHandle ),null( NamedValue ));
      if( not isnull( unitIndex )){
        unit := units.Element( unitIndex.GetValueAsNumber() );
        unit.SingleShiftConfig( relnew,
                                ID := IDHolder::GetGUID(),
                                ShiftName := guard( shiftNameCell.Value(), "" ),
                                FirstSingleShiftQuantity := guard( [Real]firstSingleShiftQuantityCell.Value(), 0.0 ),
                                SecondSingleShiftQuantity := guard( [Real]secondSingleShiftQuantityCell.Value(), 0.0 ),
                                ThirdSingleShiftQuantity := guard( [Real]thirdSingleShiftQuantityCell.Value(), 0.0 ),
                                MaintenanceDeduction := guard( [Real]maintenanceDeduction.Value(), 0.0 ) );
      }else{
        error( "无法在【" + macroPlan.MDSMacroPlan().Description() + "】内找到产线【" + unitID + "】。");
      }
    }
    
    //// 校验数据
    //feedback            := "";
    //sanitycheckfeedback := "";
    //flag                := true;
    //
    //traverse ( macroPlan, SixDigitCode, sdc, flag ) {
    //  SixDigitCode::ValidateInput( feedback, sanitycheckfeedback, macroPlan, sdc.Code(), sdc.Curve(), sdc.VehicleModel(), sdc.ProducingArea(), sdc.Engine(), sdc.Power(), sdc.EnginePartNumber(), 
    //                               sdc.EngineFourDigitCode(), sdc.Remarks(), sdc );
    //  flag := feedback = "";
    //}
    //
    //if ( not flag ) {
    //  error( feedback );
    //}
  *]
}