Commit c8727197 by gechengyang

mx2mtMap函数逻辑判断,增加iso ACK/NAK报文 的报文处理

parent 97a641b7
...@@ -121,12 +121,16 @@ public class SwiftTransfer { ...@@ -121,12 +121,16 @@ public class SwiftTransfer {
* 用于邮储版本 * 用于邮储版本
* @param xmlStr * @param xmlStr
* @param extraMap * @param extraMap
* @return
* @throws SwiftException * @throws SwiftException
*/ */
public static Map<String, String> mx2MtMap(String xmlStr, Map<String, Object> extraMap) throws SwiftException { public static Map<String, String> mx2MtMap(String xmlStr, Map<String, Object> extraMap) throws SwiftException {
try { try {
xmlStr = XmlUtil.handlingXml(xmlStr); xmlStr = XmlUtil.handlingXml(xmlStr);
//增加ISO ACK/NAK处理逻辑
Map<String,String> ackNakMap=SwiftTransferUtil.anasyIsoACKNAK(xmlStr);
if(ackNakMap!=null){
return ackNakMap;
}
SwiftTranslationReport str = mx2MtPlus(xmlStr, null, extraMap); SwiftTranslationReport str = mx2MtPlus(xmlStr, null, extraMap);
Map<String, String> maps = MxMessageReader.getSwfMsgInfoViaMsg(str); Map<String, String> maps = MxMessageReader.getSwfMsgInfoViaMsg(str);
AbstractMX abstractMx = AbstractMX.parse(xmlStr); AbstractMX abstractMx = AbstractMX.parse(xmlStr);
......
...@@ -34,12 +34,13 @@ public class Mx2MtCreatorManager { ...@@ -34,12 +34,13 @@ public class Mx2MtCreatorManager {
public SwiftTranslationReport mx2Mt(String xml, String fileOutputPath, Map<String, Object> extraMap) throws SwiftException { public SwiftTranslationReport mx2Mt(String xml, String fileOutputPath, Map<String, Object> extraMap) throws SwiftException {
try { try {
String messageType=null;
xml = XmlUtil.handlingXml(xml); xml = XmlUtil.handlingXml(xml);
MxId mxId = XmlUtil.getMxMessageType(xml); MxId mxId = XmlUtil.getMxMessageType(xml);
if (mxId == null) { if (mxId == null) {
throw new SwiftException("找不到MX报文类型"); throw new SwiftException("找不到MX报文类型");
} }
String messageType = (mxId.getBusinessProcess().name() messageType = (mxId.getBusinessProcess().name()
+ mxId.getFunctionality() + mxId.getFunctionality()
+ mxId.getVariant()) + mxId.getVariant())
//+ abstractMX.getMxId().getVersion()) //+ abstractMX.getMxId().getVersion())
......
...@@ -6,7 +6,11 @@ import com.brilliance.swift.constants.ERROR; ...@@ -6,7 +6,11 @@ import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.exception.SwiftException; import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.vo.MxMtReasonCodeInfo; import com.brilliance.swift.vo.MxMtReasonCodeInfo;
import com.brilliance.swift.vo.SwiftTranslationErrorInfo; import com.brilliance.swift.vo.SwiftTranslationErrorInfo;
import com.brilliance.swift.vo.SwiftTranslationReport;
import com.brilliance.swift.vo.common.*; import com.brilliance.swift.vo.common.*;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeConfigurationException;
...@@ -917,4 +921,37 @@ public class SwiftTransferUtil { ...@@ -917,4 +921,37 @@ public class SwiftTransferUtil {
} }
return flag; return flag;
} }
public static Map<String,String> anasyIsoACKNAK(String xmlStr){
if(StringUtil.isNotEmpty(xmlStr) && (xmlStr.contains("<PseudoAckNack>")&& xmlStr.contains("</PseudoAckNack>"))){
SwiftTranslationReport swiftTranslationReport=new SwiftTranslationReport();
String mtType="";
Document document = null;
try {
document = DocumentHelper.parseText(xmlStr);
} catch (DocumentException e) {
throw new SwiftException("parse iso xml error:" + e.getMessage());
}
String mtAckNakStr=XmlUtil.getXmlNodeValue(document,"DataPDU.Header.TransmissionReport.Interventions.Intervention.Contents.AckNack.PseudoAckNack");
String senderReference=XmlUtil.getXmlNodeValue(document,"DataPDU.Header.TransmissionReport.Message.SenderReference");
String messageIdentifier=XmlUtil.getXmlNodeValue(document,"DataPDU.Header.TransmissionReport.Message.MessageIdentifier");
Map<String, String> maps =new HashMap<>();
String result="";
maps.put("mtAckNakStr",mtAckNakStr);
maps.put("senderReference",senderReference);
maps.put("messageIdentifier",messageIdentifier);
if(StringUtil.isNotEmpty(mtAckNakStr)){
if(mtAckNakStr.contains("{311:ACK")){
result="ACK";
}else if(mtAckNakStr.contains("{311:NAK")){
result="NAK";
}
}
maps.put("result",result);
// System.out.println("maps="+maps);
return maps;
}
return null;
}
} }
<?xml version="1.0" encoding="UTF-8" ?>
<Saa:DataPDU xmlns:Saa="urn:swift:saa:xsd:saa.2.0"
xmlns:Sw="urn:swift:snl:ns.Sw"
xmlns:SwInt="urn:swift:snl:ns.SwInt"
xmlns:SwGbl="urn:swift:snl:ns.SwGbl"
xmlns:SwSec="urn:swift:snl:ns.SwSec">
<Saa:Revision>2.0.15</Saa:Revision>
<Saa:Header>
<Saa:TransmissionReport>
<Saa:SenderReference>2024072400023204</Saa:SenderReference>
<Saa:ReconciliationInfo>swi03002-2024-07-25T06:22:23.19563.358889Z</Saa:ReconciliationInfo>
<Saa:NetworkDeliveryStatus>NetworkAcked</Saa:NetworkDeliveryStatus>
<Saa:OriginalInstanceAddressee>
<Saa:X1>NYCBCNSHXXX</Saa:X1>
<Saa:X2>xxx</Saa:X2>
</Saa:OriginalInstanceAddressee>
<Saa:ReportingApplication>SWIFTNetInterface</Saa:ReportingApplication>
<Saa:NetworkInfo>
<Saa:Priority>Normal</Saa:Priority>
<Saa:IsPossibleDuplicate>true</Saa:IsPossibleDuplicate>
<Saa:Service>swift.finplus!pc</Saa:Service>
<Saa:Network>SWIFTNet</Saa:Network>
<Saa:SessionNr>000002</Saa:SessionNr>
<Saa:SeqNr>000000027</Saa:SeqNr>
<Saa:SWIFTNetNetworkInfo>
<Saa:RequestType>pacs.008.001.08</Saa:RequestType>
<Saa:SWIFTRef>swi03002-2024-07-25T06:22:23.19563.358889Z</Saa:SWIFTRef>
<Saa:SNLRef>SNL35282-2024-07-25T06:23:18.6584.000445Z</Saa:SNLRef>
<Saa:Reference>769c43c1-17d0-4012-93f1-b4462d765d08</Saa:Reference>
<Saa:SnFInputTime>0301:2024-07-25T06:22:23</Saa:SnFInputTime>
<Saa:ResponsePayloadAttributes>
<Saa:PayloadAttribute>
<Saa:Name>type</Saa:Name>
<Saa:Value>swift.emptyresponse</Saa:Value>
</Saa:PayloadAttribute>
</Saa:ResponsePayloadAttributes>
</Saa:SWIFTNetNetworkInfo>
</Saa:NetworkInfo>
<Saa:Interventions>
<Saa:Intervention>
<Saa:IntvCategory>TransmissionReport</Saa:IntvCategory>
<Saa:CreationTime>20240725142317</Saa:CreationTime>
<Saa:OperatorOrigin>SYSTEM</Saa:OperatorOrigin>
<Saa:Contents>
<AckNack>
<PseudoAckNack>{1:F21NYCBCNSHAXXX000002000000027}{4:{177:2407251423}{451:0}{311:ACK}{108:2024072400023204}}</PseudoAckNack>
</AckNack>
</Saa:Contents>
</Saa:Intervention>
</Saa:Interventions>
<Saa:IsRelatedInstanceOriginal>true</Saa:IsRelatedInstanceOriginal>
<Saa:MessageCreator>ApplicationInterface</Saa:MessageCreator>
<Saa:IsMessageModified>false</Saa:IsMessageModified>
<Saa:MessageFields>MinimumInfo</Saa:MessageFields>
<Saa:Message>
<Saa:SenderReference>2024072400023204</Saa:SenderReference>
<Saa:MessageIdentifier>pacs.008.001.08</Saa:MessageIdentifier>
<Saa:Format>MX</Saa:Format>
<Saa:SubFormat>Input</Saa:SubFormat>
<Saa:Sender>
<Saa:DN>ou=xxx,o=nycbcnsh,o=swift</Saa:DN>
<Saa:FullName>
<Saa:X1>NYCBCNSHXXX</Saa:X1>
<Saa:X2>xxx</Saa:X2>
</Saa:FullName>
</Saa:Sender>
<Saa:Receiver>
<Saa:DN>ou=xxx,o=nycbcnsh,o=swift</Saa:DN>
<Saa:FullName>
<Saa:X1>NYCBCNSHXXX</Saa:X1>
<Saa:X2>xxx</Saa:X2>
</Saa:FullName>
</Saa:Receiver>
</Saa:Message>
</Saa:TransmissionReport>
</Saa:Header>
</Saa:DataPDU>
\ No newline at end of file
...@@ -298,7 +298,8 @@ public class Mx2MtTest { ...@@ -298,7 +298,8 @@ public class Mx2MtTest {
@Test @Test
public void testMx2MtMap() throws IOException { public void testMx2MtMap() throws IOException {
File file = FileUtils.toFile(Mx2MtTest.class.getResource("/swiftXml/MxPacs00900108_COV.xml")); //File file = FileUtils.toFile(Mx2MtTest.class.getResource("/swiftXml/MxPacs00900108_COV.xml"));
File file = FileUtils.toFile(Mx2MtTest.class.getResource("/swiftXml/iso_ack.xml"));
String xmlStr = FileUtils.readFileToString(file); String xmlStr = FileUtils.readFileToString(file);
Map<String, String> maps = SwiftTransfer.mx2MtMap(xmlStr, null); Map<String, String> maps = SwiftTransfer.mx2MtMap(xmlStr, null);
for (String key : maps.keySet()) { for (String key : maps.keySet()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment