lihongji
2024-11-11 a67dc2f0b8dd2803982cfa9c6ea42b77c191d22c
_Main/BL/Type_DispatchShiftPlan/StaticMethod_Dispatch.qbl
@@ -1,18 +1,33 @@
Quintiq file version 2.0
#parent: #root
StaticMethod Dispatch (
  InterfaceDataset interfaceDataset,
  const MacroPlan macroPlan,
  Archive owner,
  String versionFlag
  String executor
)
{
  TextBody:
  [*
    // Akari Aug-21-2024 (created)
    // owner.DispatchShiftPlan( relflush );
    // owner.RB_DispatchShiftPlanBroker().Source().FlatQuery( "truncate table A_DispatchShiftPlan" );
    now := DateTime::Now();
    
    dispatchShiftPlans := selectset( owner,DispatchShiftPlan,dispatchShiftPlan,true );
    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 );
@@ -41,21 +56,20 @@
         dispatchShiftPlan := dispatchShiftPlans.Element( dispatchShiftPlanIndex.GetValueAsNumber() );
         dispatchShiftPlan.Tips( shiftPlan.Remark() );
         dispatchShiftPlan.VersionName( macroPlanName );
         dispatchShiftPlan.VersionFlag( versionFlag );
         dispatchShiftPlan.InterfaceTime( now );
       }else{
         owner.DispatchShiftPlan( relnew,ID := OS:: GenerateGUIDAsString(),
                                  ProductLine := productLine,
                                  FactoryName := factory.ID(),
         interfaceLoginfo.DispatchShiftPlan( relnew,ID := OS:: GenerateGUIDAsString(),
                                             ProductLine := productLine,
                                             FactoryName := factory.ID(),
                                             ShiftQty := shiftPlan.Outcome(),
                                  
                                  ShiftDate := shiftDate,
                                  Tips := shiftPlan.Remark(),
                                  VersionName := macroPlanName,
                                  VersionFlag := versionFlag,
                                  InterfaceTime := now );
                                             ShiftDate := shiftDate,
                                             Tips := shiftPlan.Remark(),
                                             VersionName := macroPlanName,
                                             InterfaceTime := now );
       }
    }
    DispatchShiftPlan::Publish( interfaceLoginfo );
    // owner.RB_DispatchShiftPlanBroker().AsyncExecute();
  *]
}