| 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 ); | 
|       startDate := Date::MinDate(); | 
|       timeUnit := ""; | 
|       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() = "开始时间" ){ | 
|            startDate := cnv2.Convert( cell.Value() ); | 
|          } | 
|          if( cell.GeneralExcelImportAndExportDataColumn().Name() = "时间单位" ){ | 
|            timeUnit := cell.Value(); | 
|          } | 
|          if( cell.GeneralExcelImportAndExportDataColumn().Name() = "基本工资" ){ | 
|            baseSalary := [Real]cell.Value(); | 
|          } | 
|       } | 
|       if( not isnull( unit )){ | 
|         unit.EmployeeCost( relnew,EmployeeType := employeeType,EmployeeNumber := employeeNumber,StartDate := startDate,TimeUnit := timeUnit,BaseSalary := baseSalary ); | 
|       } | 
|     } | 
|   *] | 
| } |