Commit 8f9dedf7 by chengzhuoshen

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

parent 9abf0089
......@@ -4,7 +4,9 @@ import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.SwiftTransferUtil;
import com.brilliance.swift.util.XmlUtil;
import com.brilliance.swift.vo.SwiftTranslationErrorInfo;
import com.brilliance.swift.vo.SwiftTranslationReport;
import com.brilliance.swift.vo.common.MessagePriority;
import com.prowidesoftware.swift.io.ConversionService;
......@@ -34,6 +36,23 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
this.context = context;
}
/**
* 封装报文转换详细报告
* @param errorCode
* @param location
* @param originalValue
* @return
*/
protected void buildSTErrorInfo(String errorCode, String location, String originalValue) {
SwiftTranslationReport str = context.get(SwiftTranslationReport.class);
SwiftTranslationErrorInfo errorInfo = SwiftTransferUtil.getSwiftTranslationErrorInfoByErrorCode(errorCode);
errorInfo.setLocation(location);
errorInfo.setOriginalValue(originalValue);
str.addErrorInfo(errorInfo);
if ("FAILURE".equalsIgnoreCase(errorInfo.getErrorType())) {
throw new SwiftException(location + Mx2MtConstants.NEW_LINE + "-" + errorInfo.getErrorType() + ":" + errorInfo.getDescription());
}
}
protected String getRandomNumber(int length) {
/*String randomNumber = "";
......
......@@ -4,6 +4,8 @@ import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.util.*;
import com.brilliance.swift.vo.MxMtReasonCodeInfo;
import com.brilliance.swift.vo.SwiftTranslationErrorInfo;
import com.brilliance.swift.vo.SwiftTranslationReport;
import com.brilliance.swift.vo.common.*;
import org.dom4j.Document;
......@@ -54,6 +56,24 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
return XmlUtil.getChildrenCount(document, path, null);
}
/**
* 封装报文转换详细报告
* @param errorCode
* @param location
* @param originalValue
* @return
*/
protected void buildSTErrorInfo(String errorCode, String location, String originalValue) {
SwiftTranslationReport str = context.get(SwiftTranslationReport.class);
SwiftTranslationErrorInfo errorInfo = SwiftTransferUtil.getSwiftTranslationErrorInfoByErrorCode(errorCode);
errorInfo.setLocation(location);
errorInfo.setOriginalValue(originalValue);
str.addErrorInfo(errorInfo);
if ("FAILURE".equalsIgnoreCase(errorInfo.getErrorType())) {
throw new SwiftException(location + Mx2MtConstants.NEW_LINE + "-" + errorInfo.getErrorType() + ":" + errorInfo.getDescription());
}
}
//转换函数方法区开始
/**
* MX InstructionForCreditorAgent转23域
......
......@@ -34,11 +34,7 @@ public class Field20Generate extends AbstractMx2MtTagsGenerate {
}
if (StringUtil.isNotEmpty(messageId)) {
if (messageId.length() > 16) {
SwiftTranslationReport str = context.get(SwiftTranslationReport.class);
SwiftTranslationErrorInfo errorInfo = SwiftTransferUtil.getSwiftTranslationErrorInfoByErrorCode(ERROR.T0000T);
errorInfo.setLocation("MT103/BLOCK4/:20:");
errorInfo.setOriginalValue(messageId);
str.addErrorInfo(errorInfo);
buildSTErrorInfo(ERROR.T0000T, "MT103/BLOCK4/:20:", messageId);
messageId = messageId.substring(0, 15) + "+";
}
tags.add(new Tag(name, messageId));
......
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