xiaoding721
2024-12-24 d0ce0f549cd0d63cac13c6dc14411c79d7dae113
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 SplitUsingCurve (
  SalesSegment_MP salesSegment,
  Product_MP product,
  StockingPoint_MP stockingPoint,
  Date startDate,
  Date endDate,
  Real quantity,
  String origin,
  String curve,
  const Archive archive,
  ArchiveExecutionStatus archiveExecutionStatus
)
{
  TextBody:
  [*
    // Akari Sep-11-2024 (created)
    filePath := archive.FileArchivePath() + "\" + "temp" + "\";
    OS::CreateDirectory( filePath );
    
    macroPlan := salesSegment.MacroPlan();
    ac := select( archive, ArchiveFile.astype( ArchiveCurve ), tempAC, true );
    
    pathCurve     := filePath + ac.FilePath();
    Archive::WriteTempFile( pathCurve, ac.SourceFileBinaryValue() );
    
    // 请求参数
    json          := JSON::Object()
                     .Add( "salesSegment", salesSegment.Name() )
                     .Add( "productID", product.ID() )
                     .Add( "stockingPointID", stockingPoint.ID() )
                     .Add( "startDate", startDate.Format( "Y-M2-D2") )
                     .Add( "endDate", endDate.Format( "Y-M2-D2") )
                     .Add( "quantity", quantity )
                     .Add( "origin", origin )
                     .Add( "curve", curve )
                     .Add( "pathCurve", pathCurve ).Build().AsString();
    
    // 调用接口
    url := "/IDSPPACurve/ImportCurveIncremental";
    
    i := HTTPInterface::Create( archive.JavaInterfaceAddress(), archive.JavaInterfacePort() );
    i.URL( url );
    i.PostMethod( true );
    i.MediaType( "application/json" );
    i.TimeOut( Duration::Minutes( 5 ) );
    
    i.Call( json );
      
    htmlresult := i.Result();
    
    respJSON   := JSON::Parse( htmlresult );
    
    code    := respJSON.Get( "code" ).GetNumber();
    message := respJSON.Get( "message" ).GetString();
    
    if( code = 200 ){
        // 获取需求
      archiveExecutionStatus.AES_TemporaryDemandData().Execute();
      
      // 生成Forecast
      Archive::GenerateForecast( archiveExecutionStatus, macroPlan ,false );
      
      // 清空临时数据库
      archiveExecutionStatus.AES_TemporaryDemandData().Source().FlatQuery( "truncate table A_Forecasts" );
    }else{
      error( message ); 
    }
  *]
}