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
59
60
61
62
63
64
65
66
67
68
69
70
71
Quintiq file version 2.0
#parent: #root
StaticMethod Send (
  MacroPlan macroPlan,
  Scenario scenario,
  String businessType,
  String address
)
{
  TextBody:
  [*
    info( "版本号:", scenario.Name(), "    事业部:", businessType );
    
    jsonBuilder := JSON::Object();
    
    jsonBuilder.Add( "releaseDate", DateTime::ActualTime().Format( "Y-M2-D2 H2:m:s" ) );
    jsonBuilder.Add( "businessType", businessType );
    jsonBuilder.Add( "scenarioName", scenario.Name() );
    
    jsonBuilderPanelMaterials := JSON::Array();
    traverse ( macroPlan, PanelMaterial, pm, true ) {
      jsonBuilderPanelMaterial := JSON::Object();
      
      jsonBuilderPanelMaterial.Add( "productID", pm.PanelModel() );
      jsonBuilderPanelMaterial.Add( "productDescription", pm.MaterialDescription() );
      jsonBuilderPanelMaterial.Add( "startDate", pm.StartDate().Format( "Y-M2-D2" ) );
      jsonBuilderPanelMaterial.Add( "quantity", pm.DemandQuantity() );
      
      jsonBuilderPanelMaterials.Add( jsonBuilderPanelMaterial );
    }
    jsonBuilder.Add( "panelMaterials", jsonBuilderPanelMaterials );
    
    json := jsonBuilder.Build();
    
    //url := "/panelMaterial/send";
     
    // for HTTPS requests:
    //i := HTTPInterface::Create( address, 8080 );
    //i.URL( url );
    i := HTTPInterface::Create( address, 8080 );
    i.MediaType( "application/json" );
    i.URL( "/panelMaterial/send" ); 
    i.PostMethod( true ); //it's not a POST method
    //postrequestbody := '{
    //    "releaseDate": "2023-09-15 17:47:29",
    //    "businessType": "车载",
    //    "scenarioName": "1.0 Base",
    //    "panelMaterials": [
    //        {
    //            "productID": "Body side left - E series",
    //            "productDescription": "测试A",
    //            "startDate": "2023-09-13",
    //            "quantity": 100.0
    //        },
    //        {
    //            "productID": "Body side left - E series",
    //            "productDescription": "测试B",
    //            "startDate": "2023-09-22",
    //            "quantity": 200.0
    //        }
    //    ]
    //}';
    postrequestbody := json.AsString();
    
    i.Call( postrequestbody ); // Call's argument is for POST method's content.
    htmlresult := i.Result();
    
    info( "-----------------------发送方--------------------------------" );
    info( htmlresult.AsQUILL() );
  *]
}