| Quintiq file version 2.0 | 
| #parent: #root | 
| StaticMethod Dispatch ( | 
|   InterfaceDataset interfaceDataset, | 
|   const MacroPlan macroPlan, | 
|   String executor | 
| ) | 
| { | 
|   TextBody: | 
|   [* | 
|     // Akari Aug-21-2024 (created) | 
|     now := DateTime::Now(); | 
|      | 
|     interfaceLoginfo := maxselect( interfaceDataset,InterfaceLoginfo,loginfo,loginfo.Name() = Translations::InterfaceDataset_ShiftPlanPPPSPush_Name() ,loginfo.InterfaceDateTime() ); | 
|     if( not isnull( interfaceLoginfo )){ | 
|       if( not interfaceLoginfo.IsShow() ){ | 
|         interfaceLoginfo.Delete(); | 
|       }else{ | 
|         interfaceLoginfo.Last( false ); | 
|       } | 
|     } | 
|      | 
|     interfaceLoginfo := interfaceDataset.InterfaceLoginfo( relnew, | 
|                                                            ExecuteUser := executor, | 
|                                                            Name := Translations::InterfaceDataset_ShiftPlanPPPSPush_Name(), | 
|                                                            InterfaceDateTime := now, | 
|                                                            Last := true, | 
|                                                            Message := '班次计划(PPA+IDS)数据推送' ); | 
|      | 
|     dispatchShiftPlans := selectset( interfaceLoginfo,DispatchShiftPlan,dispatchShiftPlan,true ); | 
|     dispatchShiftPlanIndexTree := NamedValueTree::Create(); | 
|     for( i := 0 ; i < dispatchShiftPlans.Size() ; i++){ | 
|       dispatchShiftPlan := dispatchShiftPlans.Element( i ); | 
|       dispatchShiftPlanHandle := dispatchShiftPlanIndexTree.GetHandle( dispatchShiftPlan.FactoryName() + dispatchShiftPlan.ProductLine() + dispatchShiftPlan.ShiftDate().AsQUILL() ); | 
|       dispatchShiftPlanIndexTree.Root().AddChild( dispatchShiftPlanHandle,i ); | 
|     } | 
|      | 
|     now := DateTime::Now(); | 
|     macroPlanName := macroPlan.MDSMacroPlan().Description(); | 
|     traverse( macroPlan,Unit.UnitPeriod.astype( UnitPeriodTime ).ShiftPlan,shiftPlan ,shiftPlan.UnitPeriodTime().Period_MP().StartDate() >= macroPlan.StartOfPlanning().Date()){ | 
|        factory := LocalTool::GetFactoryByUnit( shiftPlan.UnitPeriodTime().Unit() ); | 
|         | 
|        productLine :=  shiftPlan.UnitPeriodTime().Unit().ID(); | 
|        shiftDate := shiftPlan.UnitPeriodTime().Period_MP().StartDate(); | 
|        factoryName := factory.ID(); | 
|         | 
|        dispatchShiftPlanHandle := dispatchShiftPlanIndexTree.GetHandle( factoryName + productLine + shiftDate.AsQUILL() ); | 
|        dispatchShiftPlanIndex := guard( dispatchShiftPlanIndexTree.Root().Child( dispatchShiftPlanHandle ),null( NamedValue )); | 
|        if( not isnull( dispatchShiftPlanIndex )){ | 
|          dispatchShiftPlan := dispatchShiftPlans.Element( dispatchShiftPlanIndex.GetValueAsNumber() ); | 
|          dispatchShiftPlan.Tips( shiftPlan.Remark() ); | 
|          dispatchShiftPlan.VersionName( macroPlanName ); | 
|          dispatchShiftPlan.InterfaceTime( now ); | 
|        }else{ | 
|          if( shiftPlan.Outcome() <> "" ){ | 
|            interfaceLoginfo.DispatchShiftPlan( relnew,ID := OS:: GenerateGUIDAsString(), | 
|                                                ProductLine := productLine, | 
|                                                FactoryName := factory.ID(), | 
|                                                ShiftQty := shiftPlan.Outcome(), | 
|                                    | 
|                                                ShiftDate := shiftDate, | 
|                                                Tips := shiftPlan.Remark(), | 
|                                                VersionName := macroPlanName, | 
|                                                InterfaceTime := now ); | 
|          } | 
|        } | 
|     } | 
|     DispatchShiftPlan::Publish( interfaceLoginfo ); | 
|   *] | 
| } |