简体   繁体   English

数据电源中的状态监控

[英]Conditions monitoring in datapower

I have following request 我有以下要求

URI: /IP/{Version}/Account/Payment
HTTP Method: POST

Custom Headers: 

 X-account-number
 X- account-type
 X-user-initials,
 X-dda-number
 X-dda-account-type
 X-number-of-days-gap
 X-send-ch-letter-flag 
 X-payment-date
 X-payment-option

Now what I have to do is I have to get the Payment date from the request and then I have to check the following conditions 现在我要做的是我必须从请求中获取付款日期,然后我必须检查以下条件

if the payment date is not null and is a future date and is within 180 days from today. 如果付款日期不为空,并且是未来日期,并且是从今天起的180天内。 If so then first do a lookup to make sure there is no future payment scheduled for this date 如果是这样,那么请先进行查找以确保在该日期没有安排将来的付款

If no payments for the date scheduled then insert the payment to table 如果在预定日期没有付款,则将付款插入表格

Finally do the first select query again and retrieve the value 最后再次执行第一个选择查询并检索值

I am trying to do it using XSLT and datapower 我正在尝试使用XSLT和datapower做到这一点

but I am not getting the logic correct. 但我的逻辑不正确。

Here is what I have tried 这是我尝试过的

    <xsl:stylesheet 
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:dp="http://www.datapower.com/extensions"
 xmlns:dpconfig="http://www.datapower.com/param/config"
 xmlns:date="http://exslt.org/dates-and-times"
 extension-element-prefixes="dp date"
 exclude-result-prefixes="dp dpconfig"
 version="1.0" >


<xsl:template match="/">

<AccountNumber><xsl:value-of select="dp:http-request-header('X-account-number')"/></AccountNumber>
<PaymentDate><xsl:value-of select="dp:http-request-header('X-payment-date')"/></PaymentDate>
<PaymentOption><xsl:value-of select="dp:http-request-header('X-payment-option')"/></PaymentOption>
<Amount><xsl:value-of select="dp:http-request-header('X-amount')"/></Amount>
<AccountType><xsl:value-of select="dp:http-request-header('X-dda-account-type')"/></AccountType>

<xsl:variable name="timestamp" select="date:date-time()"/> 

<xsl:variable name="dateDifference" select="date:difference($timestamp,$PaymentDate)"/>

<xsl:if "$dateDifference" < '180' AND "$PaymentDate" != NULL>

<xsl:variable name="LookUp" Select PAYMENT_STATUS_CODE FROM TABLE WHERE WHERE ACCT_NBR ='$ACCOUNTNUMBER' AND AND PMT_DATE = '$PaymentDate'/>
<xsl:variable name ="RunQuery1">
<dp:sql-execute
    source="'XXXXX'"
    statement="$Lookup">
</dp:sql-execute>
<xsl:variable name="test" copy-of select ="$RunQuery1"/>
<xsl:if test = NULL>

<xsl:variable name="InsertQuery" Insert into TABLE(CREATED_DATE,ACCT_NBR,PMT_AMT_OPTION_CODE,AMOUNT,PMT_DATE,ACCOUNT_TYPE_CODE,PAYMENT_STATUS_CODE)
 VALUES('$timestamp','$ACCOUNTNUMBER','$PaymentOption','$Amount','$PaymentDate','$AccountType','P'/>
<xsl:variable name="RunQuery2">
<dp:sql-execute
    source="'XXXXX'"
    statement="$InsertQuery">
</dp:sql-execute>
</xsl:variable>
</xsl:if>
<xsl:variable name="RetrieveQuery" SELECT PAYMENT_STATUS_CODE from TABLE/>
<xsl:variable name="RunQuery3">
<dp:sql-execute
    source="'XXXXX'"
    statement="$RetrieveQuery">
</dp:sql-execute>
</xsl:variable>
<xsl:copy-of select="$RunQuery3"/>

</xsl:if>
</xsl:template>
</xsl:stylesheet>

What I am doing incorrect? 我做错了什么?

Well, not sure about the entire script, but since the if statement is not correct, here is something that should be a starting point: 好吧,不确定整个脚本,但是由于if语句不正确,因此以下内容应作为起点:

<xsl:if test="fn:days-from-duration($dateDifference) &lt; 180 and $PaymentDate != null">

the conversion function used is this . 使用的转换函数是this

The SQL variables are not correct. SQL变量不正确。 Please check the syntax on both how to define the queries and how to test the result of the SQL operation. 请检查有关如何定义查询以及如何测试SQL操作结果的语法。 There are many good examples on the Datapower info center . Datapower信息中心上有很多很好的例子。

"$dateDifference" < '180'

Two Three things jump out: 两个三件事情跳出来:

  1. You cannot use < as a comparison operator; 您不能将<用作比较运算符; you need to use &lt; 您需要使用&lt; instead. 代替。

  2. The result of date:difference() is not a number. date:difference()的结果不是数字。

  3. The syntax of the <xsl:if> statement is entirely wrong. <xsl:if>语句的语法完全错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM