lazhen
2024-11-05 aa42b48fd2d23e75b64a0aec05d5be4b9ebf0465
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
Quintiq file version 2.0
#parent: #root
StaticMethod CallInterfaceForSAPGet (
  InterfaceDataset owner,
  InterfaceLoginfo loginfo
) as owning InterfaceSAPResponseLoginfos
{
  Description: '调用数据中台接口'
  TextBody:
  [*
    // 甄兰鸽 Jul-22-2024 (created)
    address           := Translations::InterfaceDataset_SAP_Address(); 
    httpinterface     := HTTPInterface::Create( address,8080);
    httpinterface.PostMethod( false ); 
    httpinterface.MediaType( Translations::InterfaceDataset_ContentType() );
    try{
      if( loginfo.Name() = Translations::InterfaceDataset_AOnlineAndMOfflinePlanPIR_Name() ){//装配上线计划PIR
        httpinterface.URL( Translations::InterfaceDataset_AOnlineAndMOfflinePlanPIR_URL() );
      } 
      if( loginfo.Name() = Translations::InterfaceDataset_AOnlineAndMOfflinePlanMS64_Name() ){//装配上线计划MS64
        httpinterface.URL( Translations::InterfaceDataset_AOnlineAndMOfflinePlanMS64_URL() );
      } 
      httpinterface.Call();
      result         := httpinterface.Result();
      loginfo.Response( result );
      loginfo.Success( true );
    }onerror{
      loginfo.ReturnMsg( e.GeneralInformation() );
    }
    
    //后续公共处理
    loginfo.FinishTime( DateTime::ActualTime() );
    data             := JSON::Null().Build();
    saploginfos      := construct( InterfaceSAPResponseLoginfos );
    if( loginfo.Success() ){
      resultJson     := JSON::Parse( loginfo.Response() );
      code           := resultJson.Get( "code" ).GetNumber();
      msg            := resultJson.Get( "message" ).GetString();
      data           := resultJson.Get( "data" );
      
      loginfo.ReturnMsg( msg );
      if( code = 200 ){
    //    total        := resultJson.Get( "dataSize" ).GetNumber();
        loginfo.ReturnSuccess( true );
    //    loginfo.TotalRow( total );
        loginfo.UpdateLast();
      }
      for( i := 0; i < data.Size(); i++ ){
        item := data.Get( i );
        saploginfos.Add( InterfaceSAPResponseLoginfo::GenerateData( loginfo, item ) );
      }
    }
    
    return &saploginfos;
  *]
}