Quintiq file version 2.0
|
#parent: #root
|
StaticMethod CallInterfaceForSAPGet (
|
InterfaceDataset owner,
|
InterfaceLoginfo loginfo
|
) as String
|
{
|
Description: '调用数据中台接口'
|
TextBody:
|
[*
|
// 甄兰鸽 Jul-22-2024 (created)
|
address := Translations::InterfaceDataset_SAP_Address();
|
httpinterface := HTTPInterface::Create( address,8080);
|
httpinterface.PostMethod( true ); ;
|
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() );
|
}
|
// info( "请求体:", loginfo.RequestBody() );
|
httpinterface.Call( loginfo.RequestBody() );
|
result := httpinterface.Result();
|
loginfo.Response( result );
|
loginfo.Success( true );
|
}onerror{
|
loginfo.ReturnMsg( e.GeneralInformation() );
|
}
|
|
//后续公共处理
|
loginfo.FinishTime( DateTime::ActualTime() );
|
data := JSON::Null().Build();
|
sapresponse := construct( InterfaceSAPResponseLoginfos );
|
feedback := '';
|
info( "返回响应:", loginfo.Response() );
|
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 );
|
sapresponse.Add( InterfaceSAPResponseLoginfo::GenerateData( loginfo, item ) );
|
}
|
Transaction::Transaction().Propagate( attribute( InterfaceSAPResponseLoginfo, IsSuccess ) );
|
// sucproduct := selectuniquevalues( sapresponse, Elements, e, e.IsSuccess(), e.Msg_v1() );
|
failmssages := selectuniquevalues( sapresponse, Elements, e, not e.IsSuccess(), ifexpr( e.Msg().FindString( e.Msg_v1(), 0 ) > -1, e.Msg().ReplaceAll( e.Msg_v1(), '*' ), e.Msg_v2() ) );
|
// if( sucproduct.Size() > 0 ){
|
// feedback := feedback.Concat( '产品' ).Concat( sucproduct.Concatenate( "、" ) ).Concat( '推送成功' ).Concat( ';' );
|
// }
|
traverse( failmssages, Elements, failmsg ){
|
failproduct := selectuniquevalues( sapresponse, Elements, e, not e.IsSuccess() and ( failmsg = e.Msg_v2() or failmsg = e.Msg().ReplaceAll( e.Msg_v1(), '*' ) ), e.Msg_v1() );
|
if( failmsg.FindString( '*', 0 ) > -1 ){
|
feedback := feedback.Concat( failmsg.ReplaceAll( '*', failproduct.Concatenate( '、' ) ) ).Concat( ';' );
|
}else{
|
feedback := feedback.Concat( '产品' ).Concat( failproduct.Concatenate( '、' ) ).Concat( '因为' ).Concat( failmsg ).Concat( '推送失败' ).Concat( ';' );
|
}
|
}
|
feedback := feedback.Replace( feedback.Length() - 1, 1, '。' );
|
}
|
|
return feedback;
|
*]
|
}
|