Commit bc69c3b6 by zhanghou

完成对测试报文bic的处理

parent 2ffa4c81
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
...@@ -360,12 +360,20 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator { ...@@ -360,12 +360,20 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
if (StringUtil.isEmpty(senderBic)) { if (StringUtil.isEmpty(senderBic)) {
senderBic = getXmlNodeValue(appHdrParentPath, document, "AppHdr.Fr.FIId.FinInstnId.BICFI"); senderBic = getXmlNodeValue(appHdrParentPath, document, "AppHdr.Fr.FIId.FinInstnId.BICFI");
} }
context.set(Mx2MtContextIdentifier.MX_SENDER_BIC, senderBic);
String receiverBic = (String)context.get(Mx2MtConstants.RECEIVERS_ADDRESS, true); String receiverBic = (String)context.get(Mx2MtConstants.RECEIVERS_ADDRESS, true);
if (StringUtil.isEmpty(receiverBic)) { if (StringUtil.isEmpty(receiverBic)) {
receiverBic = getXmlNodeValue(appHdrParentPath, document, "AppHdr.To.FIId.FinInstnId.BICFI"); receiverBic = getXmlNodeValue(appHdrParentPath, document, "AppHdr.To.FIId.FinInstnId.BICFI");
} }
String service = (String) context.get(Mx2MtContextIdentifier.MX_TO_MT_SERVICE);
if(!StringUtil.isEmpty(service)&&!"swift.finplus".equals(service)){
StringBuilder replaceSenderBic = new StringBuilder(senderBic);
replaceSenderBic.replace(7,8,"0");
StringBuilder replaceReceiverBic = new StringBuilder(senderBic);
replaceReceiverBic.replace(7,8,"0");
senderBic = replaceSenderBic.toString();
receiverBic = replaceReceiverBic.toString();
}
context.set(Mx2MtContextIdentifier.MX_SENDER_BIC, senderBic);
context.set(Mx2MtContextIdentifier.MX_RECEIVER_BIC, receiverBic); context.set(Mx2MtContextIdentifier.MX_RECEIVER_BIC, receiverBic);
String applicationMode = (String)context.get(Mx2MtConstants.APPLICATION_MODE, true); String applicationMode = (String)context.get(Mx2MtConstants.APPLICATION_MODE, true);
if ("O".equalsIgnoreCase(applicationMode)) { if ("O".equalsIgnoreCase(applicationMode)) {
......
...@@ -28,4 +28,6 @@ public class Mx2MtContextIdentifier { ...@@ -28,4 +28,6 @@ public class Mx2MtContextIdentifier {
public static final String MX_TO_MT_LISTENER_CLASS = "mx.to.mt.listener.class"; public static final String MX_TO_MT_LISTENER_CLASS = "mx.to.mt.listener.class";
public static final String MX_TO_MT_SERVICE = "mx.to.mt.service";
} }
package com.brilliance.swift.mx2mt; package com.brilliance.swift.mx2mt;
import com.brilliance.swift.constants.Mx2MtConstants; import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.context.Context;
import com.brilliance.swift.exception.SwiftException; import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.mt103.Mx2Mt103Creator; import com.brilliance.swift.mx2mt.mt103.Mx2Mt103Creator;
import com.brilliance.swift.mx2mt.mt103Retn.Mx2Mt103RetnCreator; import com.brilliance.swift.mx2mt.mt103Retn.Mx2Mt103RetnCreator;
...@@ -41,6 +42,8 @@ public class Mx2MtCreatorManager { ...@@ -41,6 +42,8 @@ public class Mx2MtCreatorManager {
//+ abstractMX.getMxId().getVersion()) //+ abstractMX.getMxId().getVersion())
.trim(); .trim();
Mx2MtContext context = new Mx2MtContext(); Mx2MtContext context = new Mx2MtContext();
String service = getServiceMessage(xml);
context.set(Mx2MtContextIdentifier.MX_TO_MT_SERVICE,service);
Document document = DocumentHelper.parseText(xml); Document document = DocumentHelper.parseText(xml);
context.set(Mx2MtContextIdentifier.MX_TO_MT_LISTENER_CLASS, new Mx2MtListener()); //注册监听器 context.set(Mx2MtContextIdentifier.MX_TO_MT_LISTENER_CLASS, new Mx2MtListener()); //注册监听器
context.set(Mx2MtContextIdentifier.MX_XMl_DOCUMENT, document); context.set(Mx2MtContextIdentifier.MX_XMl_DOCUMENT, document);
...@@ -77,6 +80,14 @@ public class Mx2MtCreatorManager { ...@@ -77,6 +80,14 @@ public class Mx2MtCreatorManager {
throw new SwiftException(e.getMessage()); throw new SwiftException(e.getMessage());
} }
} }
public String getServiceMessage(String xml){
if(xml.contains("Saa:Service")){
int beginIndex = xml.indexOf("<Saa:Service>");
int endIndex = xml.indexOf("</Saa:Service>");
return xml.substring(beginIndex+"<Saa:Service>".length(),endIndex);
}
return null;
}
public AbstractMx2MtCreator getCreator(String messageType) { public AbstractMx2MtCreator getCreator(String messageType) {
if ("pacs008001".equals(messageType)) { if ("pacs008001".equals(messageType)) {
......
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