lazhen
2025-01-09 8afe90b633046db39042aada36b88193062f8cff
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
Quintiq file version 2.0
#parent: #root
StaticMethod PushPlanInventoryData (
  const MacroPlan macroPlan,
  InterfaceDataset interfaceDataset,
  String executor,
  Boolean isinventoryplandl,
  Boolean isinventoryplancc
)
{
  Description: '发送计划库存数据接口'
  TextBody:
  [*
    table         := selectobject( interfaceDataset, InventoryPlanArchiveVersion, version, not version.IsShow() );
    
    totalRow      := 0;
    interfaceTime := DateTime::ActualTime().Format( "Y-M2-D2 H2:m:s" );
    
    jsonarray     := JSON::Array();
    
    traverse ( table, Row, r, ifexpr( isinventoryplandl, r.Unit().Regex( "DL" ), false ) or ifexpr( isinventoryplancc, r.Unit().Regex( "CC" ), false ) ){
      traverse ( table, Column, c ) {//, c.TimeUnit() = Translations::MP_GlobalParameters_Day()
        cell := select( r, Cell, tempC, tempC.Column() = c );
        
        if ( not isnull( cell ) ) {
          idsjson := JSON::Object().Add( "product", r.Name() )       
                                   .Add( "inventoryDate", c.StartDate().Format( 'Y-M2-D2' ) )
                                   .Add( "planningInventory", cell.PlanQuantity() )
                                   .Add( "versionName", macroPlan.ScenarioName() )
                                   .Add( "factoryName", ifexpr( r.Unit().Regex( "CC" ), "长春工厂", "大连工厂" ) )
                                   .Add( "fac", ifexpr( r.Unit().Regex( "CC" ), "CC", "DL" ) )
                                   .Add( "interfaceTime", interfaceTime ).Build();
          jsonarray.Add( idsjson );
          totalRow++;
        }
      }
    }
    
    requestbody := jsonarray.Build().AsString();
    
    //info(  requestbody );
    
    loginfo := interfaceDataset.InterfaceLoginfo( relnew, 
                                                  ExecuteUser       := executor, 
                                                  Name              := Translations::InterfaceDataset_InventoryPlanPPPSPush_Name(), 
                                                  InterfaceDateTime := DateTime::ActualTime(), 
                                                  Message           := "计划库存数据", 
                                                  RequestBody       := requestbody,
                                                  TotalRow          := totalRow );
    
    InterfaceLoginfo::CallInterfaceForDataCenter_PlanInventory( interfaceDataset, loginfo );
  *]
}