【问题标题】:Change specific values in GSMA TAP3 file更改 GSMA TAP3 文件中的特定值
【发布时间】:2019-06-21 14:20:00
【问题描述】:

我正在尝试更改 GSM TAP3.11 文件中 MO(发起)呼叫的费用值,但它无法处理所需的

在这里我可以直接访问持续时间值,但收费值与附加的情况不同,我正在尝试更改 (1) chargeDetail(2) chargeDetail 上的收费值(下面屏幕截图中 ChargeDetailList 中的第一和第二条记录) .

我的背景只有python,这是第一次使用perl。我使用它是因为经过搜索我相信只有 perl 可以处理 TAP 文件。 (见TAP3::Tap3edit

$struct=$tap3->structure;

my $key;

# Will scan all the calls for MOC's.
foreach $key ( @{$struct->{'transferBatch'}->{'callEventDetails'} } ) {

    foreach ( keys %{$key} ) {

        if ( $_ eq "mobileOriginatedCall" )
        {
            $duration= $key->{$_}->{'basicCallInformation'}->{'totalCallEventDuration'};
            delete $key->{$_}{'basicCallInformation'}{'basicServiceUsedList'}[0]{'chargeInformationList'}[0]{'chargeDetailList'}[0]{'charge'};
            $key->{$_}{'basicCallInformation'}{'basicServiceUsedList'}[0]{'chargeInformationList'}[0]{'chargeDetailList'}[0]{'charge'}=$duration * 0.12 /0.6;
            $new_charge_value = $key->{$_}{'basicCallInformation'}{'basicServiceUsedList'}[0]{'chargeInformationList'}[0]{'chargeDetailList'}[0]{'charge'}=$duration * 0.12 /0.6;


        }
    }
}

$tap3->encode("$tap_file")  or  die $tap3->error; 

【问题讨论】:

  • 欢迎来到本站,欢迎使用 Perl 5! :) 查看tourhow-to-ask page 了解更多关于提出问题的信息,以吸引高质量的答案。您可以edit your question 包含更多信息。例如,您能否添加创建$tap3 的方式,以及运行当前代码时会发生什么?谢谢!
  • 抱歉,perl 还是新手,我在这里尝试更改收费值
  • mashro3ak,Perl 人通常喜欢看到人们学习该语言 :) 。为了回答您的问题,我们需要更多信息。最好的是我们可以运行一个小程序来重现您的问题,以及您的 TAP3 文件的副本。

标签: arrays regex perl struct


【解决方案1】:

Perl 中的 exists() 函数用于检查给定数组或散列中的元素是否存在。如果给定数组中存在所需元素,则此函数返回 1,否则返回 0。

$Tax_Rate = 3;
$Exchange_Rate = 3;
$Rate_Plan_Charge_Rate = 8;
my $key;

# Will scan all the calls for MOC's.
foreach $key ( @{$struct->{'transferBatch'}->{'callEventDetails'} } ) {

    foreach ( keys %{$key} ) {

        if ( $_ eq "mobileOriginatedCall" )
        {
            if (exists $key->{$_}->{'basicCallInformation'}->{'totalCallEventDuration'}){

                $duration = $key->{$_}->{'basicCallInformation'}->{'totalCallEventDuration'};

                if (exists $key->{$_}->{basicServiceUsedList}[0]{chargeInformationList}[0]{chargeDetailList}[0]){

                    $key->{$_}->{basicServiceUsedList}[0]{chargeInformationList}[0]{chargeDetailList}[0]{charge}=($duration * $Rate_Plan_Charge_Rate) / $Exchange_Rate;
                }
                if (exists $key->{$_}->{basicServiceUsedList}[0]{chargeInformationList}[0]{chargeDetailList}[1]){

                    $key->{$_}->{basicServiceUsedList}[0]{chargeInformationList}[0]{chargeDetailList}[1]{charge}=($duration * $Rate_Plan_Charge_Rate) / $Exchange_Rate;
                }
                $New_Charge = $key->{$_}->{basicServiceUsedList}[0]{chargeInformationList}[0]{chargeDetailList}[0]{charge};

                if (exists $key->{$_}->{basicServiceUsedList}[0]{chargeInformationList}[0]{taxInformation}[0]){

                    $key->{$_}->{basicServiceUsedList}[0]{chargeInformationList}[0]{taxInformation}[0]{taxValue}=($New_Charge / $Tax_Rate);
                }
                if (exists $key->{$_}->{basicServiceUsedList}[0]{chargeInformationList}[0]{taxInformation}[1]){

                    $key->{$_}->{basicServiceUsedList}[0]{chargeInformationList}[0]{taxInformation}[0]{taxValue}=($New_Charge / $Tax_Rate);

                }
            }
        }
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多