haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
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
Quintiq file version 2.0
#parent: #root
Method DoCall () as ERPResponseOfPR
{
  TextBody:
  [*
    // yypsybs Sep-11-2023 (created)
    conv := DateTimeToString::StandardConverter();
    conv.SetCustomConversion();
    conv.CustomFormatString( 'yyyyMMdd' );
    
    requestJSON := JSON::Object();
    requestJSON.Add( "BusinessType", this.BusinessType() );
    requestJSON.Add( "DataID", this.DataID() );
    requestJSON.Add( "DeliveryDate", conv.Convert( this.DeliveryDate().DateTime() ) );
    requestJSON.Add( "MRPCalverNo", this.MRPCalverNo() );
    requestJSON.Add( "OrganCode", this.OrganCode() );
    requestJSON.Add( "ProductID", this.ProductID() );
    requestJSON.Add( "ProductName", this.ProductName() );
    requestJSON.Add( "ProvideCode", this.ProviderCode() );
    requestJSON.Add( "ProviderName", this.ProviderName() );
    requestJSON.Add( "Quantity", this.Quantity() );
    requestJSON.Add( "StockingPointID", this.StockingPointID() );
    requestJSON.Add( "UnitOfMeasure", this.UnitOfMeasure() );
    
    requestString := requestJSON.AsString();
    
    // 构造http请求 todo
    httpInterface := HTTPInterface::Create( "127.0.0.1", 443 );
    httpInterface.URL( "/url" );
    httpInterface.PostMethod( true );
    httpInterface.AddHeader( "content-type", "application/json" );
    
    // 发送请求
    result := null( ERPResponseOfPR );
    try {
      httpInterface.Call( requestString );
      responseString := httpInterface.Result();
      
      responseJSON := JSON::Parse( responseString );
      dataID := responseJSON.Get( "DataID" ).GetString();
      status := responseJSON.Get( "Status" ).GetString();
      errorDescription := responseJSON.Get( "ErrorDescription" ).GetString();
      
      result := this.ERPResponseOfPR( relnew, 
                                      DataID := dataID,
                                      Status := status, 
                                      ErrorDescription := errorDescription );
    } onerror {
      result := this.ERPResponseOfPR( relnew, 
                                      DataID := this.DataID(),
                                      Status := "E", 
                                      ErrorDescription := e.GeneralInformation() );
    }
    
    return result;
  *]
}