xiaoding721
2024-11-21 e18d66cac7fbf43b0d341ee8976d6550a9a4f1af
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 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 );
  *]
}