xiaoding721
2024-05-27 191fc5cc2e5eeaff377b749dfa7e497fe503506b
_Main/BL/Type_Archive/StaticMethod_HandlePP.qbl
@@ -7,37 +7,41 @@
  String ppFileName,
  BinaryValue ppBinaryValue,
  Boolean isPPArchive,
  String filePath
)
  String filePath,
  Boolean isOverwriteFile
) as stream[JSON]
{
  TextBody:
  [*
    // 请求参数
    pathPP    := filePath + ppFileName;
    isArchive := ifexpr( isPPArchive, "true", "false" );
    minorKey  := [String]macroPlan.MDSID().MinorKey();
    json      := JSON::Object()
                 .Add( "path", pathPP )
                 .Add( "isArchive", isArchive )
                 .Add( "minorKey", minorKey ).Build().AsString();
    pathPP     := filePath + ppFileName;
    isArchive  := ifexpr( isPPArchive, "true", "false" );
    isOverride := ifexpr( isOverwriteFile, "true", "false" );
    minorKey   := [String]macroPlan.MDSID().MinorKey();
    json       := JSON::Object()
                  .Add( "path", pathPP )
                  .Add( "isArchive", isArchive )
                  .Add( "isOverride", isOverride )
                  .Add( "minorKey", minorKey ).Build().AsString();
    
    // 写入临时文件
    Archive::WriteTempFile( pathPP, ppBinaryValue );
    
    info( json );
    // 调用接口
    //url := "/PR/Import";
    //i := HTTPInterface::Create( archive.JavaInterfaceAddress(), archive.JavaInterfacePort() );
    //i.URL( url );
    //i.PostMethod( true );
    //
    //try {
    //  i.Call( json );
    //
    //  htmlresult := i.Result();
    //} onerror {
    //
    //}
    url := "/PPBudget/Import";
    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 );
    return emit( respJSON );
  *]
}