Commit 16fa7d77 by zhanghou

修改了mt210,mt192292,mt196296,mt942的异常警告的定义和对判断是转成mt941还是mt942逻辑的修改

parent f3d17e8a
...@@ -24,4 +24,6 @@ public class Mx2MtContextIdentifier { ...@@ -24,4 +24,6 @@ public class Mx2MtContextIdentifier {
public static final String MX_TO_MT_ERROR_LOCATION = "mx.to.mt.error.location"; public static final String MX_TO_MT_ERROR_LOCATION = "mx.to.mt.error.location";
public static final String MX_TO_MT_TYPE = "mx.to.mt.type";
} }
...@@ -83,7 +83,7 @@ public class Mx2Mtn92Creator extends AbstractMx2MtCreator { ...@@ -83,7 +83,7 @@ public class Mx2Mtn92Creator extends AbstractMx2MtCreator {
} else if (orgMsgNameIdentification.matches("MT20[0-9]{1}")) { } else if (orgMsgNameIdentification.matches("MT20[0-9]{1}")) {
mtType = Mx2MtConstants.MT_TYPE_292; mtType = Mx2MtConstants.MT_TYPE_292;
}else { }else {
buildSTErrorInfo(ERROR.T20092,"",bodyParentPath+"Undrlyg.TxInf.OrgnlGrpInf.OrgnlMsgNmId"); buildSTErrorInfo(ERROR.T20092,null,null);
} }
} }
return mtType; return mtType;
......
...@@ -40,7 +40,7 @@ public class Field11SGenerate extends AbstractMx2MtTagsGenerate { ...@@ -40,7 +40,7 @@ public class Field11SGenerate extends AbstractMx2MtTagsGenerate {
orgnlMsgNmId = mtType.substring(2); orgnlMsgNmId = mtType.substring(2);
}else { }else {
orgnlMsgNmId = "202"; orgnlMsgNmId = "202";
buildSTErrorInfo(ERROR.T20083,"",""); buildSTErrorInfo(ERROR.T20083,null,null);
} }
} }
} }
...@@ -48,7 +48,7 @@ public class Field11SGenerate extends AbstractMx2MtTagsGenerate { ...@@ -48,7 +48,7 @@ public class Field11SGenerate extends AbstractMx2MtTagsGenerate {
if(dateStr.length()>0){ if(dateStr.length()>0){
date = mXToMTDate(dateStr); date = mXToMTDate(dateStr);
}else { }else {
date = mXToMTDate("993112"); date = "993112";
} }
} }
......
...@@ -83,7 +83,7 @@ public class Mx2Mtn96Creator extends AbstractMx2MtCreator { ...@@ -83,7 +83,7 @@ public class Mx2Mtn96Creator extends AbstractMx2MtCreator {
} else if (orgMsgNameIdentification.matches("MT20[0-9]{1}")) { } else if (orgMsgNameIdentification.matches("MT20[0-9]{1}")) {
mtType = Mx2MtConstants.MT_TYPE_296; mtType = Mx2MtConstants.MT_TYPE_296;
}else { }else {
buildSTErrorInfo(ERROR.T20092,"",bodyParentPath+"CxlDtls.TxInfAndSts.OrgnlGrpInf.OrgnlMsgNmId"); buildSTErrorInfo(ERROR.T20092,null,null);
} }
} }
return mtType; return mtType;
......
...@@ -51,7 +51,7 @@ public class Field11RGenerate extends AbstractMx2MtTagsGenerate { ...@@ -51,7 +51,7 @@ public class Field11RGenerate extends AbstractMx2MtTagsGenerate {
if(dateStr.length()>0){ if(dateStr.length()>0){
date = mXToMTDate(dateStr); date = mXToMTDate(dateStr);
}else { }else {
date = mXToMTDate("993112"); date = "993112";
boolean2 = true; boolean2 = true;
} }
} }
...@@ -60,7 +60,7 @@ public class Field11RGenerate extends AbstractMx2MtTagsGenerate { ...@@ -60,7 +60,7 @@ public class Field11RGenerate extends AbstractMx2MtTagsGenerate {
}else { }else {
tags.add(new Tag(name, orgnlMsgNmId+Mx2MtConstants.NEW_LINE+date)); tags.add(new Tag(name, orgnlMsgNmId+Mx2MtConstants.NEW_LINE+date));
if(boolean1){ if(boolean1){
buildSTErrorInfo(ERROR.T20083,"",""); buildSTErrorInfo(ERROR.T20083,null,null);
} }
} }
......
package com.brilliance.swift.mx2mt.mt210.impl; package com.brilliance.swift.mx2mt.mt210.impl;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.constants.Mx2MtConstants; import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException; import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate; import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
...@@ -24,11 +25,12 @@ public class Field20Generate extends AbstractMx2MtTagsGenerate { ...@@ -24,11 +25,12 @@ public class Field20Generate extends AbstractMx2MtTagsGenerate {
if (StringUtil.isNotEmpty(messageId)) { if (StringUtil.isNotEmpty(messageId)) {
if (messageId.length() > 16) { if (messageId.length() > 16) {
messageId = messageId.substring(0, 15) + "+"; messageId = messageId.substring(0, 15) + "+";
buildSTErrorInfo(ERROR.T0000T, "BLOCK4/:20:", messageId);
} }
String value = messageId; String value = messageId;
if (value.startsWith("/") || value.endsWith("/") || value.contains("//")) { if (value.startsWith("/") || value.endsWith("/") || value.contains("//")) {
value = Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE; value = Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE;
//TODO,填入location:mt210/block3/:20:,errorcode:T20051 buildSTErrorInfo(ERROR.T20051, "BLOCK4/:20:", messageId);
} }
tags.add(new Tag(name, value)); tags.add(new Tag(name, value));
} }
......
package com.brilliance.swift.mx2mt.mt210.impl; package com.brilliance.swift.mx2mt.mt210.impl;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.constants.Mx2MtConstants; import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException; import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate; import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
...@@ -29,12 +30,13 @@ public class Field21Generate extends AbstractMx2MtTagsGenerate { ...@@ -29,12 +30,13 @@ public class Field21Generate extends AbstractMx2MtTagsGenerate {
} }
if (StringUtil.isNotEmpty(filed21)) { if (StringUtil.isNotEmpty(filed21)) {
if (filed21.length() > 16) { if (filed21.length() > 16) {
buildSTErrorInfo(ERROR.T0000T, "BLOCK4/:21:", endToEndId);
filed21 = filed21.substring(0, 15) + "+"; filed21 = filed21.substring(0, 15) + "+";
} }
String value = filed21; String value = filed21;
if (value.startsWith("/") || value.endsWith("/") || value.contains("//")) { if (value.startsWith("/") || value.endsWith("/") || value.contains("//")) {
value = Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE; value = Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE;
//TODO,填入location:mt210/block3/:21:,errorcode:T20055 buildSTErrorInfo(ERROR.T20055, "BLOCK4/:21:", endToEndId);
} }
tags.add(new Tag(name, value)); tags.add(new Tag(name, value));
} }
......
package com.brilliance.swift.mx2mt.mt210.impl; package com.brilliance.swift.mx2mt.mt210.impl;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.exception.SwiftException; import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate; import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.StringUtil; import com.brilliance.swift.util.StringUtil;
...@@ -31,7 +32,7 @@ public class Field30Generate extends AbstractMx2MtTagsGenerate { ...@@ -31,7 +32,7 @@ public class Field30Generate extends AbstractMx2MtTagsGenerate {
mtDate = mXToMTDate(mxDate); mtDate = mXToMTDate(mxDate);
}else { }else {
mtDate = mXToMTDate("991231"); mtDate = mXToMTDate("991231");
//TODO,填入location:mt210/block3/:30:,errorcode:T00062 buildSTErrorInfo(ERROR.T20062, "BLOCK4/:20:","");
} }
tags.add(new Tag(name, mtDate)); tags.add(new Tag(name, mtDate));
} }
......
package com.brilliance.swift.mx2mt.mt210.impl; package com.brilliance.swift.mx2mt.mt210.impl;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.constants.Mx2MtConstants; import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException; import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate; import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
...@@ -24,6 +25,7 @@ public class Field50aGenerate extends AbstractMx2MtTagsGenerate { ...@@ -24,6 +25,7 @@ public class Field50aGenerate extends AbstractMx2MtTagsGenerate {
@Override @Override
public void tagGenerate() throws SwiftException { public void tagGenerate() throws SwiftException {
context.set(Mx2MtContextIdentifier.MX_TO_MT_ERROR_LOCATION, "Block4/50a");
SwiftMessage swiftMessage = context.get(SwiftMessage.class); SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags(); List<Tag> tags = swiftMessage.getBlock4().getTags();
int counts1 = getXmlNodeCounts(bodyHdrParentElementName, document, "Ntfctn.Dbtr.Pty"); int counts1 = getXmlNodeCounts(bodyHdrParentElementName, document, "Ntfctn.Dbtr.Pty");
...@@ -96,7 +98,7 @@ public class Field50aGenerate extends AbstractMx2MtTagsGenerate { ...@@ -96,7 +98,7 @@ public class Field50aGenerate extends AbstractMx2MtTagsGenerate {
tags.add(new Tag(name_F, account + Mx2MtConstants.NEW_LINE + mtNameAddress)); tags.add(new Tag(name_F, account + Mx2MtConstants.NEW_LINE + mtNameAddress));
} }
}else { }else {
//TODO,填入location:mt210/block3/:50a:,errorcode:T20102 buildSTErrorInfo(ERROR.T20102, "BLOCK4/:50a:","");
} }
if(counts3>0||counts4>0) { if(counts3>0||counts4>0) {
if (StringUtil.isNotEmpty(bicCode)) { if (StringUtil.isNotEmpty(bicCode)) {
...@@ -109,10 +111,10 @@ public class Field50aGenerate extends AbstractMx2MtTagsGenerate { ...@@ -109,10 +111,10 @@ public class Field50aGenerate extends AbstractMx2MtTagsGenerate {
tags.add(new Tag(name_, nameAddress)); tags.add(new Tag(name_, nameAddress));
} else if (StringUtil.isNotEmpty(clearSystemId)) { } else if (StringUtil.isNotEmpty(clearSystemId)) {
tags.add(new Tag(name_, clearSystemId)); tags.add(new Tag(name_, clearSystemId));
//TODO,填入location:mt210/block3/:50a:,errorcode:T20097 buildSTErrorInfo(ERROR.T20097, "BLOCK4/:50a:","");
} }
}else { }else {
//TODO,填入location:mt210/block3/:50a:,errorcode:T20102 buildSTErrorInfo(ERROR.T20102, "BLOCK4/:50a:","");
} }
} }
} }
...@@ -21,6 +21,7 @@ public class Field52aGenerate extends AbstractMx2MtTagsGenerate { ...@@ -21,6 +21,7 @@ public class Field52aGenerate extends AbstractMx2MtTagsGenerate {
@Override @Override
public void tagGenerate() throws SwiftException { public void tagGenerate() throws SwiftException {
context.set(Mx2MtContextIdentifier.MX_TO_MT_ERROR_LOCATION, "Block4/52a");
String s = (String)context.get(Mx2MtContextIdentifier.MT_TYPE_210_50_FLAG); String s = (String)context.get(Mx2MtContextIdentifier.MT_TYPE_210_50_FLAG);
if(Mx2MtConstants.YES.equals(s)){ if(Mx2MtConstants.YES.equals(s)){
return; return;
......
...@@ -48,14 +48,18 @@ public class Mx2Mt941942Creator extends AbstractMx2MtCreator { ...@@ -48,14 +48,18 @@ public class Mx2Mt941942Creator extends AbstractMx2MtCreator {
@Override @Override
protected String getMtType() { protected String getMtType() {
/*Document document = (Document)context.get(Mx2MtContextIdentifier.MX_XMl_DOCUMENT); Document document = (Document)context.get(Mx2MtContextIdentifier.MX_XMl_DOCUMENT);
String bodyParentPath = (String)context.get(Mx2MtContextIdentifier.BODY_PARENT_ELEMENT_NAME, true); String bodyParentPath = (String)context.get(Mx2MtContextIdentifier.BODY_PARENT_ELEMENT_NAME, true);
int balanceTypeCount = getXmlNodeCounts(bodyParentPath, document, "Rpt.Bal"); int entryCount = getXmlNodeCounts(bodyParentPath, document, "Rpt.Ntry");
if(balanceTypeCount>0){ String sumc = getXmlNodeValue(bodyParentPath, document, "Rpt.TxsSummry.TtlCdtNtries.Sum");
return Mx2MtConstants.MT_TYPE_941; String sumd = getXmlNodeValue(bodyParentPath, document, "Rpt.TxsSummry.TtlDbtNtries.Sum");
}else { if(entryCount!=0||StringUtil.isNotEmpty(sumc)||StringUtil.isNotEmpty(sumd)){
context.set(Mx2MtContextIdentifier.MX_TO_MT_TYPE,Mx2MtConstants.MT_TYPE_942);
return Mx2MtConstants.MT_TYPE_942; return Mx2MtConstants.MT_TYPE_942;
}*/ }else {
return Mx2MtConstants.MT_TYPE_942; context.set(Mx2MtContextIdentifier.MX_TO_MT_TYPE,Mx2MtConstants.MT_TYPE_941);
return Mx2MtConstants.MT_TYPE_941;
}
} }
} }
...@@ -20,18 +20,16 @@ public class Field28CGenerate extends AbstractMx2MtTagsGenerate { ...@@ -20,18 +20,16 @@ public class Field28CGenerate extends AbstractMx2MtTagsGenerate {
public void tagGenerate() throws SwiftException { public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class); SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags(); List<Tag> tags = swiftMessage.getBlock4().getTags();
String leSeNum = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.LglSeqNb"); String num = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.LglSeqNb");
String mt = ""; if(StringUtil.isEmpty(num)||num.length()>5){
if(StringUtil.isEmpty(leSeNum)||leSeNum.length()>5){ num = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.ElctrncSeqNb");
mt = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.ElctrncSeqNb"); if(StringUtil.isEmpty(num)||num.length()>5){
if(StringUtil.isEmpty(mt)||mt.length()>5){
buildSTErrorInfo(ERROR.T20103, "BLOCK4/:28:", bodyHdrParentElementName+"Rpt.ElctrncSeqNb"); buildSTErrorInfo(ERROR.T20103, "BLOCK4/:28:", bodyHdrParentElementName+"Rpt.ElctrncSeqNb");
return; return;
} }
}else {
String pageNum = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.RptPgntn.PgNb");
mt = leSeNum + "/" + pageNum;
} }
String pageNum = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.RptPgntn.PgNb");
String mt = num + "/" + pageNum;
tags.add(new Tag(name,mt)); tags.add(new Tag(name,mt));
} }
} }
package com.brilliance.swift.mx2mt.mt941942.impl; package com.brilliance.swift.mx2mt.mt941942.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException; import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate; import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.mx2mt.Mx2MtContextIdentifier;
import com.brilliance.swift.util.DateUtil; import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.util.NumberUtil; import com.brilliance.swift.util.NumberUtil;
import com.brilliance.swift.util.StringUtil; import com.brilliance.swift.util.StringUtil;
...@@ -25,7 +27,11 @@ public class Field60FGenerate extends AbstractMx2MtTagsGenerate { ...@@ -25,7 +27,11 @@ public class Field60FGenerate extends AbstractMx2MtTagsGenerate {
@Override @Override
public void tagGenerate() throws SwiftException { public void tagGenerate() throws SwiftException {
/*SwiftMessage swiftMessage = context.get(SwiftMessage.class); String mtType = (String) context.get(Mx2MtContextIdentifier.MX_TO_MT_TYPE);
if(Mx2MtConstants.MT_TYPE_942.equals(mtType)){
return;
}
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags(); List<Tag> tags = swiftMessage.getBlock4().getTags();
int balanceTypeCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Rpt.Bal"); int balanceTypeCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Rpt.Bal");
int index = -1; int index = -1;
...@@ -66,6 +72,6 @@ public class Field60FGenerate extends AbstractMx2MtTagsGenerate { ...@@ -66,6 +72,6 @@ public class Field60FGenerate extends AbstractMx2MtTagsGenerate {
} catch (DatatypeConfigurationException e) { } catch (DatatypeConfigurationException e) {
throw new SwiftException("ERROR", e.getMessage()); throw new SwiftException("ERROR", e.getMessage());
} }
}*/ }
} }
} }
...@@ -30,21 +30,15 @@ public class Field61Generate extends AbstractMx2MtTagsGenerate { ...@@ -30,21 +30,15 @@ public class Field61Generate extends AbstractMx2MtTagsGenerate {
@Override @Override
public void tagGenerate() throws SwiftException { public void tagGenerate() throws SwiftException {
try { try {
String mtType = (String) context.get(Mx2MtContextIdentifier.MX_TO_MT_TYPE);
if(Mx2MtConstants.MT_TYPE_941.equals(mtType)){
return;
}
SwiftMessage swiftMessage = context.get(SwiftMessage.class); SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags(); List<Tag> tags = swiftMessage.getBlock4().getTags();
/*int balanceTypeCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Rpt.Bal");
if(balanceTypeCount>0){
return;
}*/
int entryCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Rpt.Ntry"); int entryCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Rpt.Ntry");
if(entryCount>189){ if(entryCount>189){
buildSTErrorInfo(ERROR.T20110, "BLOCK4/:61:",bodyHdrParentElementName+"Rpt.Ntry"); buildSTErrorInfo(ERROR.T20110, "BLOCK4/:61:",entryCount+"");
return;
}
String sumc = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.TxsSummry.TtlCdtNtries.Sum");
String sumd = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.TxsSummry.TtlDbtNtries.Sum");
if(entryCount<0|| StringUtil.isEmpty(sumc)&&StringUtil.isEmpty(sumd)){
buildSTErrorInfo(ERROR.T20114, "BLOCK4/:61:","");
return; return;
} }
String ccy2 = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Acct.Ccy"); String ccy2 = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Acct.Ccy");
...@@ -87,28 +81,25 @@ public class Field61Generate extends AbstractMx2MtTagsGenerate { ...@@ -87,28 +81,25 @@ public class Field61Generate extends AbstractMx2MtTagsGenerate {
} }
String amt = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Ntry(" + i + ").Amt"); String amt = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Ntry(" + i + ").Amt");
String ccy = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Ntry(" + i + ").Amt@Ccy"); String ccy = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Ntry(" + i + ").Amt@Ccy");
if(amt.length()>14){
buildSTErrorInfo(ERROR.T20113, "BLOCK4/:61:", amt);
return;
}
if (StringUtil.isNotEmpty(amt) && StringUtil.isNotEmpty(ccy)) { if (StringUtil.isNotEmpty(amt) && StringUtil.isNotEmpty(ccy)) {
String amount = NumberUtil.formatAmt(new BigDecimal(amt), ccy); String amount = NumberUtil.formatAmt(new BigDecimal(amt), ccy);
if(amount.length()>15){
buildSTErrorInfo(ERROR.T20113, "BLOCK4/:61:", amt);
return;
}
value += amount; value += amount;
} }
if(StringUtil.isNotEmpty(ccy)&&StringUtil.isNotEmpty(ccy2)){ if(StringUtil.isNotEmpty(ccy)&&StringUtil.isNotEmpty(ccy2)){
if(ccy.equals(ccy2)){ if(!ccy.equals(ccy2)){
buildSTErrorInfo(ERROR.T20116, "BLOCK4/:61:", ccy); buildSTErrorInfo(ERROR.T20116, "BLOCK4/:61:", ccy);
return; return;
} }
} }
if(amt.length()>14){
buildSTErrorInfo(ERROR.T20113, "BLOCK4/:61:", bodyHdrParentElementName+"Rpt.Ntry(" + i + ").Amt");
return;
}
value += "NTRF"; value += "NTRF";
String endToEndId = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Ntry(" + i + ").NtryDtls.TxDtls.Refs.EndToEndId"); String endToEndId = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Ntry(" + i + ").NtryDtls.TxDtls.Refs.EndToEndId");
if (StringUtil.isNotEmpty(endToEndId)) { if (StringUtil.isNotEmpty(endToEndId)) {
if (endToEndId.length() > 16) { if (endToEndId.length() > 16) {
buildSTErrorInfo(ERROR.T0000T, "BLOCK4/:61:", endToEndId);
endToEndId = endToEndId.substring(0, 15) + "+"; endToEndId = endToEndId.substring(0, 15) + "+";
} }
value += endToEndId; value += endToEndId;
...@@ -118,6 +109,7 @@ public class Field61Generate extends AbstractMx2MtTagsGenerate { ...@@ -118,6 +109,7 @@ public class Field61Generate extends AbstractMx2MtTagsGenerate {
String accountServicerReference = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Ntry("+i+").AcctSvcrRef"); String accountServicerReference = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Ntry("+i+").AcctSvcrRef");
if (StringUtil.isNotEmpty(accountServicerReference)) { if (StringUtil.isNotEmpty(accountServicerReference)) {
if (accountServicerReference.length() > 16) { if (accountServicerReference.length() > 16) {
buildSTErrorInfo(ERROR.T0000T, "BLOCK4/:61:", accountServicerReference);
accountServicerReference = accountServicerReference.substring(0, 15) + "+"; accountServicerReference = accountServicerReference.substring(0, 15) + "+";
} }
value += "//" + accountServicerReference; value += "//" + accountServicerReference;
...@@ -125,6 +117,7 @@ public class Field61Generate extends AbstractMx2MtTagsGenerate { ...@@ -125,6 +117,7 @@ public class Field61Generate extends AbstractMx2MtTagsGenerate {
String additionalInformation = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Ntry("+i+").NtryDtls.TxDtls.AddtlTxInf"); String additionalInformation = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Ntry("+i+").NtryDtls.TxDtls.AddtlTxInf");
if (StringUtil.isNotEmpty(additionalInformation)) { if (StringUtil.isNotEmpty(additionalInformation)) {
if (additionalInformation.length() > 34) { if (additionalInformation.length() > 34) {
buildSTErrorInfo(ERROR.T0000T, "BLOCK4/:61:", additionalInformation);
additionalInformation = additionalInformation.substring(0, 33) + "+"; additionalInformation = additionalInformation.substring(0, 33) + "+";
} }
value += Mx2MtConstants.NEW_LINE + additionalInformation; value += Mx2MtConstants.NEW_LINE + additionalInformation;
...@@ -133,6 +126,7 @@ public class Field61Generate extends AbstractMx2MtTagsGenerate { ...@@ -133,6 +126,7 @@ public class Field61Generate extends AbstractMx2MtTagsGenerate {
String additionalEntryInformation = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Ntry("+i+").AddtlNtryInf"); String additionalEntryInformation = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Ntry("+i+").AddtlNtryInf");
if (StringUtil.isNotEmpty(additionalEntryInformation)) { if (StringUtil.isNotEmpty(additionalEntryInformation)) {
if (additionalEntryInformation.length() > 390) { if (additionalEntryInformation.length() > 390) {
buildSTErrorInfo(ERROR.T0000T, "BLOCK4/:61:", additionalEntryInformation);
additionalEntryInformation = additionalEntryInformation.substring(0, 389) + "+"; additionalEntryInformation = additionalEntryInformation.substring(0, 389) + "+";
} }
String value86 = StringUtil.getStringByEnter(additionalEntryInformation, 65, 6); String value86 = StringUtil.getStringByEnter(additionalEntryInformation, 65, 6);
......
package com.brilliance.swift.mx2mt.mt941942.impl; package com.brilliance.swift.mx2mt.mt941942.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException; import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate; import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.mx2mt.Mx2MtContextIdentifier;
import com.brilliance.swift.util.DateUtil; import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.util.NumberUtil; import com.brilliance.swift.util.NumberUtil;
import com.brilliance.swift.util.StringUtil; import com.brilliance.swift.util.StringUtil;
...@@ -25,7 +27,11 @@ public class Field62FGenerate extends AbstractMx2MtTagsGenerate { ...@@ -25,7 +27,11 @@ public class Field62FGenerate extends AbstractMx2MtTagsGenerate {
@Override @Override
public void tagGenerate() throws SwiftException { public void tagGenerate() throws SwiftException {
/*SwiftMessage swiftMessage = context.get(SwiftMessage.class); String mtType = (String) context.get(Mx2MtContextIdentifier.MX_TO_MT_TYPE);
if(Mx2MtConstants.MT_TYPE_942.equals(mtType)){
return;
}
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags(); List<Tag> tags = swiftMessage.getBlock4().getTags();
int balanceTypeCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Rpt.Bal"); int balanceTypeCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Rpt.Bal");
int index = -1; int index = -1;
...@@ -66,6 +72,6 @@ public class Field62FGenerate extends AbstractMx2MtTagsGenerate { ...@@ -66,6 +72,6 @@ public class Field62FGenerate extends AbstractMx2MtTagsGenerate {
} catch (DatatypeConfigurationException e) { } catch (DatatypeConfigurationException e) {
throw new SwiftException("ERROR", e.getMessage()); throw new SwiftException("ERROR", e.getMessage());
} }
}*/ }
} }
} }
package com.brilliance.swift.mx2mt.mt941942.impl; package com.brilliance.swift.mx2mt.mt941942.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException; import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate; import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.mx2mt.Mx2MtContextIdentifier;
import com.brilliance.swift.util.DateUtil; import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.util.NumberUtil; import com.brilliance.swift.util.NumberUtil;
import com.brilliance.swift.util.StringUtil; import com.brilliance.swift.util.StringUtil;
...@@ -25,7 +27,11 @@ public class Field64Generate extends AbstractMx2MtTagsGenerate { ...@@ -25,7 +27,11 @@ public class Field64Generate extends AbstractMx2MtTagsGenerate {
@Override @Override
public void tagGenerate() throws SwiftException { public void tagGenerate() throws SwiftException {
/*SwiftMessage swiftMessage = context.get(SwiftMessage.class); String mtType = (String) context.get(Mx2MtContextIdentifier.MX_TO_MT_TYPE);
if(Mx2MtConstants.MT_TYPE_942.equals(mtType)){
return;
}
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags(); List<Tag> tags = swiftMessage.getBlock4().getTags();
int balanceTypeCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Rpt.Bal"); int balanceTypeCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Rpt.Bal");
int index = -1; int index = -1;
...@@ -66,6 +72,6 @@ public class Field64Generate extends AbstractMx2MtTagsGenerate { ...@@ -66,6 +72,6 @@ public class Field64Generate extends AbstractMx2MtTagsGenerate {
} catch (DatatypeConfigurationException e) { } catch (DatatypeConfigurationException e) {
throw new SwiftException("ERROR", e.getMessage()); throw new SwiftException("ERROR", e.getMessage());
} }
}*/ }
} }
} }
...@@ -27,7 +27,11 @@ public class Field65Generate extends AbstractMx2MtTagsGenerate { ...@@ -27,7 +27,11 @@ public class Field65Generate extends AbstractMx2MtTagsGenerate {
@Override @Override
public void tagGenerate() throws SwiftException { public void tagGenerate() throws SwiftException {
/* SwiftMessage swiftMessage = context.get(SwiftMessage.class); String mtType = (String) context.get(Mx2MtContextIdentifier.MX_TO_MT_TYPE);
if(Mx2MtConstants.MT_TYPE_942.equals(mtType)){
return;
}
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags(); List<Tag> tags = swiftMessage.getBlock4().getTags();
int balanceTypeCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Rpt.Bal"); int balanceTypeCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Rpt.Bal");
if (balanceTypeCount > 0) { if (balanceTypeCount > 0) {
...@@ -64,6 +68,6 @@ public class Field65Generate extends AbstractMx2MtTagsGenerate { ...@@ -64,6 +68,6 @@ public class Field65Generate extends AbstractMx2MtTagsGenerate {
} }
} }
} }
}*/ }
} }
} }
...@@ -24,12 +24,6 @@ public class Field90CGenerate extends AbstractMx2MtTagsGenerate { ...@@ -24,12 +24,6 @@ public class Field90CGenerate extends AbstractMx2MtTagsGenerate {
List<Tag> tags = swiftMessage.getBlock4().getTags(); List<Tag> tags = swiftMessage.getBlock4().getTags();
String sumc = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.TxsSummry.TtlCdtNtries.Sum"); String sumc = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.TxsSummry.TtlCdtNtries.Sum");
String nbOfNtries = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.TxsSummry.TtlCdtNtries.NbOfNtries"); String nbOfNtries = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.TxsSummry.TtlCdtNtries.NbOfNtries");
int entryCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Rpt.Ntry");
String sumd = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.TxsSummry.TtlDbtNtries.Sum");
if(entryCount<0|| StringUtil.isEmpty(sumc)&&StringUtil.isEmpty(sumd)){
buildSTErrorInfo(ERROR.T20114, "BLOCK4/:90C:",bodyHdrParentElementName+"Rpt.TxsSummry.TtlCdtNtries.Sum");
return;
}
if(StringUtil.isNotEmpty(sumc)&&StringUtil.isNotEmpty(nbOfNtries)) { if(StringUtil.isNotEmpty(sumc)&&StringUtil.isNotEmpty(nbOfNtries)) {
String currency = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Acct.Ccy"); String currency = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Acct.Ccy");
String amt = NumberUtil.formatAmt(new BigDecimal(sumc), currency); String amt = NumberUtil.formatAmt(new BigDecimal(sumc), currency);
......
...@@ -22,14 +22,8 @@ public class Field90DGenerate extends AbstractMx2MtTagsGenerate { ...@@ -22,14 +22,8 @@ public class Field90DGenerate extends AbstractMx2MtTagsGenerate {
public void tagGenerate() throws SwiftException { public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class); SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags(); List<Tag> tags = swiftMessage.getBlock4().getTags();
String sumc = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.TxsSummry.TtlCdtNtries.Sum");
String sumd = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.TxsSummry.TtlDbtNtries.Sum"); String sumd = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.TxsSummry.TtlDbtNtries.Sum");
String nbOfNtries = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.TxsSummry.TtlDbtNtries.NbOfNtries"); String nbOfNtries = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.TxsSummry.TtlDbtNtries.NbOfNtries");
int entryCount = getXmlNodeCounts(bodyHdrParentElementName, document, "Rpt.Ntry");
if(entryCount<0|| StringUtil.isEmpty(sumc)&&StringUtil.isEmpty(sumd)){
buildSTErrorInfo(ERROR.T20114, "BLOCK4/:90D:",bodyHdrParentElementName+"Rpt.TxsSummry.TtlDbtNtries.Sum");
return;
}
if(StringUtil.isNotEmpty(sumd)&&StringUtil.isNotEmpty(nbOfNtries)) { if(StringUtil.isNotEmpty(sumd)&&StringUtil.isNotEmpty(nbOfNtries)) {
String currency = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Acct.Ccy"); String currency = getXmlNodeValue(bodyHdrParentElementName, document, "Rpt.Acct.Ccy");
String amt = NumberUtil.formatAmt(new BigDecimal(sumd), currency); String amt = NumberUtil.formatAmt(new BigDecimal(sumd), currency);
......
...@@ -78,9 +78,9 @@ Change Log ...@@ -78,9 +78,9 @@ Change Log
</Sts> </Sts>
<CxlDtls> <CxlDtls>
<TxInfAndSts> <TxInfAndSts>
<CxlStsId>CNCL-ID001</CxlStsId> <CxlStsId>CNCL-ID001</CxlStsId>
<RslvdCase> <RslvdCase>
<Id>CSE-001</Id> <Id>CSE-001</Id>
<Cretr> <Cretr>
<Agt> <Agt>
<FinInstnId> <FinInstnId>
...@@ -90,8 +90,8 @@ Change Log ...@@ -90,8 +90,8 @@ Change Log
</Cretr> </Cretr>
</RslvdCase> </RslvdCase>
<OrgnlGrpInf> <OrgnlGrpInf>
<OrgnlMsgId>pacs8bizmsgidr01</OrgnlMsgId> <OrgnlMsgId>pacs8bizmsgidr01</OrgnlMsgId>
<OrgnlMsgNmId>pacs.008.001.08</OrgnlMsgNmId> <OrgnlMsgNmId>pacs.008.001.08</OrgnlMsgNmId>
<OrgnlCreDtTm>2021-02-17T08:30:00+01:00</OrgnlCreDtTm> <OrgnlCreDtTm>2021-02-17T08:30:00+01:00</OrgnlCreDtTm>
</OrgnlGrpInf> </OrgnlGrpInf>
<OrgnlInstrId>pacs8bizmsgidr01</OrgnlInstrId> <OrgnlInstrId>pacs8bizmsgidr01</OrgnlInstrId>
......
...@@ -66,7 +66,7 @@ Change Log ...@@ -66,7 +66,7 @@ Change Log
</Cretr> </Cretr>
</Case> </Case>
<OrgnlGrpInf> <OrgnlGrpInf>
<OrgnlMsgId>pacs8bizmsgidr01</OrgnlMsgId> <OrgnlMsgId>pacs8bizmsgidr01</OrgnlMsgId>
<OrgnlMsgNmId>pacs.008.001.08</OrgnlMsgNmId> <OrgnlMsgNmId>pacs.008.001.08</OrgnlMsgNmId>
<OrgnlCreDtTm>2021-02-17T08:30:00+01:00</OrgnlCreDtTm> <OrgnlCreDtTm>2021-02-17T08:30:00+01:00</OrgnlCreDtTm>
</OrgnlGrpInf> </OrgnlGrpInf>
......
...@@ -38,7 +38,7 @@ Change Log ...@@ -38,7 +38,7 @@ Change Log
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.057.001.06"> <Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.057.001.06">
<NtfctnToRcv> <NtfctnToRcv>
<GrpHdr> <GrpHdr>
<MsgId>camt57bizmsgidr1</MsgId> <MsgId>camt57bizmsgidr1</MsgId>
<CreDtTm>2020-11-30T09:00:00+01:00</CreDtTm> <CreDtTm>2020-11-30T09:00:00+01:00</CreDtTm>
</GrpHdr> </GrpHdr>
<Ntfctn> <Ntfctn>
...@@ -62,21 +62,21 @@ Change Log ...@@ -62,21 +62,21 @@ Change Log
<BICFI>KREDBEBB</BICFI> <BICFI>KREDBEBB</BICFI>
</FinInstnId> </FinInstnId>
</AcctSvcr> </AcctSvcr>
<Dbtr> <Dbtr>
<Pty> <Pty>
<Nm>ABC Ltd</Nm> <Nm>ABC Ltd</Nm>
<PstlAdr> <PstlAdr>
<StrtNm>10 Broad Street</StrtNm> <StrtNm>10 Broad Street</StrtNm>
<TwnNm>London</TwnNm> <TwnNm>London</TwnNm>
<Ctry>GB</Ctry> <Ctry>GB</Ctry>
</PstlAdr> </PstlAdr>
</Pty> </Pty>
</Dbtr> </Dbtr>
<DbtrAgt> <DbtrAgt>
<FinInstnId> <FinInstnId>
<BICFI>BARCGB22</BICFI> <BICFI>BARCGB22</BICFI>
</FinInstnId> </FinInstnId>
</DbtrAgt> </DbtrAgt>
<IntrmyAgt> <IntrmyAgt>
<FinInstnId> <FinInstnId>
<BICFI>CBPXBE99</BICFI> <BICFI>CBPXBE99</BICFI>
......
package com.brilliance.mx2mt.mt196; package com.brilliance.mx2mt.mt196;
import com.brilliance.swift.SwiftTransfer; import com.brilliance.swift.SwiftTransfer;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.vo.SwiftTranslationErrorInfo;
import com.brilliance.swift.vo.SwiftTranslationReport;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import java.io.File; import java.io.File;
import java.util.List;
public class TestMx2MtFor196 { public class TestMx2MtFor196 {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftXml\\Mxcamt02900108_196.xml"); File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftXml\\MxCamt02900108_196.xml");
String xmlStr = FileUtils.readFileToString(file); String xmlStr = FileUtils.readFileToString(file);
String mt196 = SwiftTransfer.mx2Mt(xmlStr, null, null); SwiftTranslationReport str = SwiftTransfer.mx2MtPlus(xmlStr, null, null);
System.out.println(mt196); if (str != null) {
List<SwiftTranslationErrorInfo> errorInfos = str.getErrorInfos();
if (errorInfos != null && errorInfos.size() > 0) {
for (int i=0; i<errorInfos.size(); i++) {
SwiftTranslationErrorInfo errorInfo = errorInfos.get(i);
String location = errorInfo.getLocation();
String errorType = errorInfo.getErrorType();
String description = errorInfo.getDescription();
System.out.println(location + Mx2MtConstants.NEW_LINE + "-" + errorType + ":" + description);
}
}
System.out.println(str.getMessage());
}
} }
} }
package com.brilliance.mx2mt.mt210; package com.brilliance.mx2mt.mt210;
import com.brilliance.swift.SwiftTransfer; import com.brilliance.swift.SwiftTransfer;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.vo.SwiftTranslationErrorInfo;
import com.brilliance.swift.vo.SwiftTranslationReport;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import java.io.File; import java.io.File;
import java.util.List;
public class TestMx2MtFor210 { public class TestMx2MtFor210 {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftXml\\MxCamt05700106.xml"); File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftXml\\MxCamt05700106.xml");
String xmlStr = FileUtils.readFileToString(file); String xmlStr = FileUtils.readFileToString(file);
String mt210 = SwiftTransfer.mx2Mt(xmlStr, null, null); SwiftTranslationReport str = SwiftTransfer.mx2MtPlus(xmlStr, null, null);
System.out.println(mt210); if (str != null) {
List<SwiftTranslationErrorInfo> errorInfos = str.getErrorInfos();
if (errorInfos != null && errorInfos.size() > 0) {
for (int i=0; i<errorInfos.size(); i++) {
SwiftTranslationErrorInfo errorInfo = errorInfos.get(i);
String location = errorInfo.getLocation();
String errorType = errorInfo.getErrorType();
String description = errorInfo.getDescription();
System.out.println(location + Mx2MtConstants.NEW_LINE + "-" + errorType + ":" + description);
}
}
System.out.println(str.getMessage());
}
} }
} }
package com.brilliance.mx2mt.mt942; package com.brilliance.mx2mt.mt942;
import com.brilliance.swift.SwiftTransfer; import com.brilliance.swift.SwiftTransfer;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.vo.SwiftTranslationErrorInfo;
import com.brilliance.swift.vo.SwiftTranslationReport;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import java.io.File; import java.io.File;
import java.util.List;
public class TestMx2MtFor942 { public class TestMx2MtFor942 {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftXml\\MXcamt05200108_942.xml"); File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftXml\\MXcamt05200108_942.xml");
String xmlStr = FileUtils.readFileToString(file); String xmlStr = FileUtils.readFileToString(file);
String mt942 = SwiftTransfer.mx2Mt(xmlStr, null, null); SwiftTranslationReport str = SwiftTransfer.mx2MtPlus(xmlStr, null, null);
System.out.println(mt942); if (str != null) {
List<SwiftTranslationErrorInfo> errorInfos = str.getErrorInfos();
if (errorInfos != null && errorInfos.size() > 0) {
for (int i=0; i<errorInfos.size(); i++) {
SwiftTranslationErrorInfo errorInfo = errorInfos.get(i);
String location = errorInfo.getLocation();
String errorType = errorInfo.getErrorType();
String description = errorInfo.getDescription();
System.out.println(location + Mx2MtConstants.NEW_LINE + "-" + errorType + ":" + description);
}
}
System.out.println(str.getMessage());
}
} }
} }
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