| Quintiq file version 2.0 | 
| #parent: #root | 
| StaticMethod Import ( | 
|   MacroPlan macroplan, | 
|   BinaryValue binaryvalue | 
| ) | 
| { | 
|   TextBody: | 
|   [* | 
|     // 甄兰鸽 Aug-22-2024 (created) | 
|      | 
|     macroplan.ValidateBroker( typeof( MP_ImportChangeLossSettingsBroker ).ShortName(), macroplan.MP_ImportChangeLossSettingsBroker().Source(), binaryvalue ); | 
|     progress( 'Importing lanes', DateTime::ActualTime() ); | 
|     macroplan.MP_ImportChangeLossSettingsBroker().ExecuteFromXLS( binaryvalue.AsBinaryData(), true ); | 
|      | 
|     try{ | 
|       ChangeLossSettingExcel::CheckImport( macroplan ); | 
|     }onerror{ | 
|       //校验失败后删除 | 
|       macroplan.ChangeLossSettingExcel( relflush ); | 
|       error( e.GeneralInformation() ); | 
|     } | 
|     clsset              := construct( ChangeLossSettings ); | 
|     //遍历处理导入的数据 | 
|     traverse( macroplan, ChangeLossSettingExcel, excel ){ | 
|       cls               := selectobject(  macroplan, ChangeLossSetting, cls, cls.ProductFirst().ID() = excel.Product1() | 
|                                           and cls.ProductSecond().ID() = excel.Product2() | 
|                                           and cls.Unit().ID() = excel.Unit() | 
|                                           and cls.StartDate() = excel.StartDate() | 
|                                           and cls.EndDate() = excel.EndDate() ); | 
|       info( excel.ChangeLossNumber() ); | 
|       if( isnull( cls ) ){ | 
|         product1        := selectobject( macroplan, Product_MP, product, product.ID() = excel.Product1() ); | 
|         product2        := selectobject( macroplan, Product_MP, product, product.ID() = excel.Product2() ); | 
|         unit            := selectobject( macroplan, Unit, unit, unit.ID() = excel.Unit() ); | 
|         feedback        := ''; | 
|         if( ChangeLossSetting::ValidateInput( feedback, macroplan, null( ChangeLossSetting ), unit, product1, product2, excel.StartDate(), excel.EndDate(), excel.ChangeLossNumber() ) ){ | 
|           cls             := macroplan.ChangeLossSetting( relnew, ChangeLossNumber := [Real]excel.ChangeLossNumber(), StartDate := excel.StartDate(), EndDate := excel.EndDate()  ); | 
|            | 
|           cls.ProductFirst( relset, product1 ); | 
|           cls.ProductSecond( relset, product2 ); | 
|           cls.Unit( relset, unit ); | 
|           clsset.Add( cls ); | 
|         }else{ | 
|           traverse( clsset, Elements, e ){ | 
|             e.Delete(); | 
|           } | 
|           error( feedback ); | 
|         } | 
|       }else { | 
|         cls.StartDate( excel.StartDate() ); | 
|         cls.EndDate( excel.EndDate() ); | 
|         cls.ChangeLossNumber( [Real]excel.ChangeLossNumber() ); | 
|       } | 
|       info( '-------------------', cls.ChangeLossNumber() ); | 
|       excel.Delete(); | 
|     } | 
|   *] | 
| } |