admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
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
Quintiq file version 2.0
#parent: #root
StaticMethod Dispatch (
  InterfaceDataset interfaceDataset,
  const Archive archive,
  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();
    traverse( archive,ArchiveShiftPlanRow.ArchiveShiftPlanCell,archiveShiftPlan ){
       factoryName := archiveShiftPlan.ArchiveShiftPlanRow().FactoryName();
       
       productLine :=  archiveShiftPlan.ArchiveShiftPlanRow().UnitID();
       shiftDate := archiveShiftPlan.ArchiveShiftPlanColumn().StartDate();
       
       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( archiveShiftPlan.Remark() );
         dispatchShiftPlan.VersionName( archiveShiftPlan.MacroPlanName() );
         dispatchShiftPlan.InterfaceTime( now );
       }else{
         if( archiveShiftPlan.Outcome() <> "" ){
           dispatchShiftPlan := interfaceLoginfo.DispatchShiftPlan( relnew,ID := OS:: GenerateGUIDAsString(),
                                                                    ProductLine := productLine,
                                                                    FactoryName := factoryName,
                                                                    ShiftQty := archiveShiftPlan.Outcome(),
                                  
                                                                    ShiftDate := shiftDate,
                                                                    Tips := archiveShiftPlan.Remark(),
                                                                    VersionName := archiveShiftPlan.MacroPlanName(),
                                                                    InterfaceTime := now );
           dispatchShiftPlan.CalcFac();
         }
       }
    }
    DispatchShiftPlan::Publish( interfaceLoginfo );
  *]
}