Commit f3d17e8a by chengzhuoshen

封装报文转换详细报告方法

parent 961ca0f0
......@@ -50,7 +50,7 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
errorInfo.setOriginalValue(originalValue);
str.addErrorInfo(errorInfo);
if ("FAILURE".equalsIgnoreCase(errorInfo.getErrorType())) {
throw new SwiftException(location + Mx2MtConstants.NEW_LINE + "-" + errorInfo.getErrorType() + ":" + errorInfo.getDescription());
throw new SwiftException(location + "-" + errorInfo.getErrorType() + ":" + errorInfo.getDescription());
}
}
......
......@@ -22,4 +22,6 @@ public class Mx2MtContextIdentifier {
public static final String MT_TYPE_210_50_FLAG = "mt.type.210.50.flag";
public static final String MX_TO_MT_ERROR_LOCATION = "mx.to.mt.error.location";
}
package com.brilliance.swift.mx2mt.mt103;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtCreator;
......@@ -29,6 +30,11 @@ public class Mx2Mt103Creator extends AbstractMx2MtCreator {
context.set(Mx2MtContextIdentifier.APPHDR_PARENT_ELEMENT_NAME, parentElementMaps.get("AppHdr"));
context.set(Mx2MtContextIdentifier.GRPHDR_PARENT_ELEMENT_NAME, parentElementMaps.get("GrpHdr"));
context.set(Mx2MtContextIdentifier.BODY_PARENT_ELEMENT_NAME, parentElementMaps.get("CdtTrfTxInf"));
String bodyParentPath = parentElementMaps.get("CdtTrfTxInf");
int counts = getXmlNodeCounts(bodyParentPath, document, "CdtTrfTxInf");
if (counts > 1) {
buildSTErrorInfo(ERROR.T20053, bodyParentPath+".CdtTrfTxInf", null);
}
}
@Override
......
......@@ -4,9 +4,6 @@ import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.SwiftTransferUtil;
import com.brilliance.swift.vo.SwiftTranslationErrorInfo;
import com.brilliance.swift.vo.SwiftTranslationReport;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
......@@ -34,7 +31,7 @@ public class Field20Generate extends AbstractMx2MtTagsGenerate {
}
if (StringUtil.isNotEmpty(messageId)) {
if (messageId.length() > 16) {
buildSTErrorInfo(ERROR.T0000T, "MT103/BLOCK4/:20:", messageId);
buildSTErrorInfo(ERROR.T0000T, "Block4/:20:", messageId);
messageId = messageId.substring(0, 15) + "+";
}
tags.add(new Tag(name, messageId));
......
package com.brilliance.swift.mx2mt.mt103.impl;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.DateUtil;
......@@ -33,6 +34,10 @@ public class Field32AGenerate extends AbstractMx2MtTagsGenerate {
}
String amt = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.IntrBkSttlmAmt");
String ccy = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.IntrBkSttlmAmt@Ccy");
if ("XAU".equalsIgnoreCase(ccy) || "XAG".equalsIgnoreCase(ccy)
|| "XPD".equalsIgnoreCase(ccy) || "XPT".equalsIgnoreCase(ccy)) {
buildSTErrorInfo(ERROR.T20054, bodyHdrParentElementName+".CdtTrfTxInf.IntrBkSttlmAmt", null);
}
if (StringUtil.isNotEmpty(amt) && StringUtil.isNotEmpty(ccy)) {
intrBkSttlmAmt = NumberUtil.formatAmt(new BigDecimal(amt), ccy);
intrBkSttlmccy = ccy;
......
package com.brilliance.swift.mx2mt.mt103.impl;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.mx2mt.Mx2MtContextIdentifier;
......@@ -32,6 +33,7 @@ public class Field33BGenerate extends AbstractMx2MtTagsGenerate {
amt = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.IntrBkSttlmAmt");
ccy = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.IntrBkSttlmAmt@Ccy");
if (StringUtil.isNotEmpty(amt) && StringUtil.isNotEmpty(ccy)) {
buildSTErrorInfo(ERROR.T20025, "Block4/:"+name+":", null);
tags.add(new Tag(name, ccy+NumberUtil.formatAmt(new BigDecimal(amt), ccy)));
}
}
......
......@@ -3,6 +3,7 @@ package com.brilliance.swift.mx2mt.mt103.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.mx2mt.Mx2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
......@@ -22,6 +23,7 @@ public class Field50AGenerate extends AbstractMx2MtTagsGenerate {
@Override
public void tagGenerate() throws SwiftException {
context.set(Mx2MtContextIdentifier.MX_TO_MT_ERROR_LOCATION, "Block4/50a");
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String partyPath = bodyHdrParentElementName + ".CdtTrfTxInf.Dbtr";
......
......@@ -3,6 +3,7 @@ package com.brilliance.swift.mx2mt.mt103.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.mx2mt.Mx2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
......@@ -20,6 +21,7 @@ public class Field52AGenerate extends AbstractMx2MtTagsGenerate {
@Override
public void tagGenerate() throws SwiftException {
context.set(Mx2MtContextIdentifier.MX_TO_MT_ERROR_LOCATION, "Block4/52a");
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String bicCode = mx_to_mtBICFI(bodyHdrParentElementName + ".CdtTrfTxInf.DbtrAgt");
......
......@@ -3,6 +3,7 @@ package com.brilliance.swift.mx2mt.mt103.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.mx2mt.Mx2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.common.SettlementMethodCode;
import com.prowidesoftware.swift.model.SwiftMessage;
......@@ -24,6 +25,7 @@ public class Field53AGenerate extends AbstractMx2MtTagsGenerate {
@Override
public void tagGenerate() throws SwiftException {
context.set(Mx2MtContextIdentifier.MX_TO_MT_ERROR_LOCATION, "Block4/53a");
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String settlementMethod = getXmlNodeValue(grpHdrParentElementName, document, "GrpHdr.SttlmInf.SttlmMtd");
......
......@@ -2,6 +2,7 @@ package com.brilliance.swift.util;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.vo.MxMtReasonCodeInfo;
import com.brilliance.swift.vo.SwiftTranslationErrorInfo;
......@@ -761,21 +762,24 @@ public class SwiftTransferUtil {
}
}
}
SwiftTranslationErrorInfo errorInfo = null;
SwiftTranslationErrorInfo tmpErrorInfo = null;
if (stErrorInfos != null && stErrorInfos.size() > 0) {
for (int i=0; i<stErrorInfos.size(); i++) {
SwiftTranslationErrorInfo tmpErrorInfo = stErrorInfos.get(i);
if (key.equalsIgnoreCase(tmpErrorInfo.getErrorCode())) {
errorInfo = tmpErrorInfo;
if (key.equalsIgnoreCase(stErrorInfos.get(i).getErrorCode())) {
tmpErrorInfo = stErrorInfos.get(i);
break;
}
}
}
if (errorInfo == null) { //在errorcode list里面找不到,生成默认值
errorInfo = new SwiftTranslationErrorInfo();
SwiftTranslationErrorInfo errorInfo = new SwiftTranslationErrorInfo();
if (tmpErrorInfo == null) { //在errorcode list里面找不到,生成默认值
errorInfo.setErrorCode(key);
errorInfo.setDescription(key);
errorInfo.setErrorType("WARNING");
} else {
errorInfo.setErrorCode(tmpErrorInfo.getErrorCode());
errorInfo.setDescription(tmpErrorInfo.getDescription());
errorInfo.setErrorType(tmpErrorInfo.getErrorType());
}
return errorInfo;
}
......@@ -809,4 +813,21 @@ public class SwiftTransferUtil {
throw new SwiftException("Validate " + xsdName + ".xsd Error;" + e.getMessage());
}
}
public static boolean compareStErrorInfo(SwiftTranslationErrorInfo target, SwiftTranslationErrorInfo source) {
boolean flag = false;
if (target != null && source != null) {
if (target.getErrorCode().equals(source.getErrorCode())
&& target.getLocation().equals(source.getLocation())) {
if (ERROR.T0000T.equals(target.getErrorCode()) || ERROR.T0000R.equals(target.getErrorCode())) {
if (target.getOriginalValue().equals(source.getOriginalValue())) {
flag = true;
}
} else {
flag = true;
}
}
}
return flag;
}
}
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