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
Quintiq file version 2.0
#parent: #root
StaticMethod Import (
  MacroPlan owner,
  const GeneralExcelImportAndExportDataTable table
)
{
  TextBody:
  [*
    // rislai Jul-3-2024 (created)
    units := construct( Units );
    unitIndexTree := NamedValueTree::Create();
    
    employeeTypes := construct( EmployeeTypes );
    employeeTypeIndexTree := NamedValueTree::Create();
    
    costs := selectset( owner,Unit.EmployeeCost,cost,true );
    traverse( costs,Elements,element ){
      element.Delete(); 
    }
    
    cnv2 := StringToDate::StandardConverter();
    cnv2.SetCustomConversion();
    cnv2.CustomFormatString( 'yyyy-MM-dd' );//2024-07-03
    
    traverse( table,GeneralExcelImportAndExportDataRow,row ){
      employeeType := null( EmployeeType );
      employeeNumber := 0;
      unit := null( Unit );
      baseSalary := 0.0;
      traverse( row,GeneralExcelImportAndExportDataCell,cell ){
         if( cell.GeneralExcelImportAndExportDataColumn().Name() = "人员类别" ){
           employeeTypeHandle := employeeTypeIndexTree.GetHandle( cell.Value() );
           index := guard( employeeTypeIndexTree.Root().Child( employeeTypeHandle ),null( NamedValue ));
           if( not isnull( index )){
              employeeType := employeeTypes.Element( index.GetValueAsNumber() ); 
           }else{
              employeeType := select( owner,EmployeeType,type,type.Name() = cell.Value() );
              if( not isnull( employeeType )){
                employeeTypes.Add( employeeType );
                employeeTypeIndexTree.Root().AddChild( employeeTypeHandle,employeeTypes.Size() - 1 ); 
              }
           }
         }
         if( cell.GeneralExcelImportAndExportDataColumn().Name() = "人数" ){
           employeeNumber := [Number]cell.Value();
         }
         if( cell.GeneralExcelImportAndExportDataColumn().Name() = "产线" ){
           unitHandle := unitIndexTree.GetHandle( cell.Value() );
           index := guard( unitIndexTree.Root().Child( unitHandle ),null( NamedValue ));
           if( not isnull( index )){
              unit := units.Element( index.GetValueAsNumber() ); 
           }else{
              unit := select( owner,Unit,temp_unit,temp_unit.ID() = cell.Value() );
              if( not isnull( unit )){
                units.Add( unit );
                unitIndexTree.Root().AddChild( unitHandle,units.Size() - 1 ); 
              }
           }
         }
         if( cell.GeneralExcelImportAndExportDataColumn().Name() = "基本工资" ){
           baseSalary := [Real]cell.Value();
         }
      }
      if( not isnull( unit )){
        unit.EmployeeCost( relnew,EmployeeType := employeeType,EmployeeNumber := employeeNumber,BaseSalary := baseSalary );
      }
    }
  *]
}