Commit 2d8c7b15 by chengzhuoshen

增加pacs008001转mt103的报文转换详细报告

parent 16fa7d77
package com.brilliance.swift.mx2mt; package com.brilliance.swift.mx2mt;
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.util.DateUtil; import com.brilliance.swift.util.DateUtil;
...@@ -36,6 +37,7 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator { ...@@ -36,6 +37,7 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
this.context = context; this.context = context;
} }
/** /**
* 封装报文转换详细报告 * 封装报文转换详细报告
* @param errorCode * @param errorCode
...@@ -46,14 +48,50 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator { ...@@ -46,14 +48,50 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
protected void buildSTErrorInfo(String errorCode, String location, String originalValue) { protected void buildSTErrorInfo(String errorCode, String location, String originalValue) {
SwiftTranslationReport str = context.get(SwiftTranslationReport.class); SwiftTranslationReport str = context.get(SwiftTranslationReport.class);
SwiftTranslationErrorInfo errorInfo = SwiftTransferUtil.getSwiftTranslationErrorInfoByErrorCode(errorCode); SwiftTranslationErrorInfo errorInfo = SwiftTransferUtil.getSwiftTranslationErrorInfoByErrorCode(errorCode);
if (StringUtil.isEmpty(location)) {
location = (String) context.get(Mx2MtContextIdentifier.MX_TO_MT_ERROR_LOCATION,true);
}
errorInfo.setLocation(location); errorInfo.setLocation(location);
errorInfo.setOriginalValue(originalValue); errorInfo.setOriginalValue(originalValue);
str.addErrorInfo(errorInfo); List<SwiftTranslationErrorInfo> errorInfos = str.getErrorInfos();
if ("FAILURE".equalsIgnoreCase(errorInfo.getErrorType())) { boolean existFlag = false;
throw new SwiftException(location + "-" + errorInfo.getErrorType() + ":" + errorInfo.getDescription()); for (int i=0; i<errorInfos.size(); i++) {
if (SwiftTransferUtil.compareStErrorInfo(errorInfo, errorInfos.get(i))) {
existFlag = true;
break;
}
}
if (!existFlag) {
str.addErrorInfo(errorInfo);
if ("FAILURE".equalsIgnoreCase(errorInfo.getErrorType())) {
throw new SwiftException(location + Mx2MtConstants.NEW_LINE + "-" + errorInfo.getErrorType() + ":" + errorInfo.getDescription());
}
} }
} }
/**
* 出现中文字符替换成.
* @param tag
* @return
*/
protected void mx_to_mtCharSet(Tag tag) {
if (tag == null || StringUtil.isEmpty(tag.getValue())) {
return;
}
String value = tag.getValue();
//表示出现了中文字符
if (value.getBytes().length != value.length()) {
buildSTErrorInfo(ERROR.T0000R, "Block4/"+tag.getName(), value);
char[] chars = value.toCharArray();
for (char c : chars) {
if (c > 127 || c < 0) {
value = value.replace(c,'.');
}
}
}
tag.setValue(value);
}
protected String getRandomNumber(int length) { protected String getRandomNumber(int length) {
/*String randomNumber = ""; /*String randomNumber = "";
Random random = new Random(); Random random = new Random();
...@@ -259,6 +297,12 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator { ...@@ -259,6 +297,12 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
@Override @Override
public void postProcess() throws SwiftException { public void postProcess() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class); SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
if (tags.size() > 0) {
for (Tag tag : tags) {
mx_to_mtCharSet(tag);
}
}
IConversionService srv = new ConversionService(); IConversionService srv = new ConversionService();
String mtStr = srv.getFIN(swiftMessage); String mtStr = srv.getFIN(swiftMessage);
SwiftTranslationReport str = context.get(SwiftTranslationReport.class); SwiftTranslationReport str = context.get(SwiftTranslationReport.class);
......
...@@ -87,6 +87,33 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate { ...@@ -87,6 +87,33 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
} }
} }
} }
/**
* 如何第二行以 : 或者 - 开始,替换成 .
* @param value
* @param location
* @return
*/
protected String mx_to_mtStartingLineCharacter(String value, String location) {
if (StringUtil.isEmpty(value)) {
return value;
}
String[] values = value.split(Mx2MtConstants.NEW_LINE);
if (values.length == 1) return value;
String newValue = values[0];
boolean flag = false;
for (int i=1; i<values.length; i++) {
if (values[i].startsWith(":") || values[i].startsWith("-")) {
flag = true;
newValue += Mx2MtConstants.NEW_LINE + "." + values[i].substring(1);
} else {
newValue += Mx2MtConstants.NEW_LINE + values[i];
}
}
if (flag) {
buildSTErrorInfo(ERROR.T0000R, location, value);
}
return newValue;
}
//转换函数方法区开始 //转换函数方法区开始
/** /**
...@@ -205,6 +232,8 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate { ...@@ -205,6 +232,8 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
} else { } else {
list.add(code + "/" + remainTxt); list.add(code + "/" + remainTxt);
} }
} else {
list.add(code + "/" + instructionInformation);
} }
} }
return list; return list;
...@@ -358,7 +387,7 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate { ...@@ -358,7 +387,7 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
String bicCode = mx_to_mtBICFI(agtPath); String bicCode = mx_to_mtBICFI(agtPath);
if (StringUtil.isNotEmpty(bicCode)) { if (StringUtil.isNotEmpty(bicCode)) {
if (mtClearingSystem.indexOf("FW") > -1) { if (mtClearingSystem.indexOf("FW") > -1) {
mtClearingSystem = "//FW"; mtClearingSystem = "";
buildSTErrorInfo(ERROR.T20075, null, null); buildSTErrorInfo(ERROR.T20075, null, null);
} else if (mtClearingSystem.indexOf("CP") > -1 } else if (mtClearingSystem.indexOf("CP") > -1
|| mtClearingSystem.indexOf("RU") > -1 || mtClearingSystem.indexOf("RU") > -1
...@@ -407,8 +436,14 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate { ...@@ -407,8 +436,14 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
if (StringUtil.isNotEmpty(bicCode)) { if (StringUtil.isNotEmpty(bicCode)) {
if ("US".equals(bicCode.substring(4, 6))) { if ("US".equals(bicCode.substring(4, 6))) {
mtAccount = "//FW"; mtAccount = "//FW";
if (StringUtil.isNotEmpty(mxClearingSystemCode)) {
buildSTErrorInfo(ERROR.T20075, null, null);
}
} else { } else {
mtAccount = "//RT"; mtAccount = "//RT";
if (StringUtil.isNotEmpty(mxClearingSystemCode)) {
buildSTErrorInfo(ERROR.T20077, null, null);
}
} }
} else { } else {
if (mtClearingSystem.indexOf("FW") > -1) { if (mtClearingSystem.indexOf("FW") > -1) {
......
package com.brilliance.swift.mx2mt.mt103.impl; package com.brilliance.swift.mx2mt.mt103.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;
import com.brilliance.swift.vo.common.CategoryPurposeCode; import com.brilliance.swift.vo.common.CategoryPurposeCode;
import com.brilliance.swift.vo.common.ExternalCreditorAgentInstructionCode;
import com.brilliance.swift.vo.common.ServiceLevelCode; import com.brilliance.swift.vo.common.ServiceLevelCode;
import com.prowidesoftware.swift.model.SwiftMessage; import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag; import com.prowidesoftware.swift.model.Tag;
import java.util.ArrayList; import java.util.*;
import java.util.List;
/** /**
* *
...@@ -22,13 +23,17 @@ public class Field23EGenerate extends AbstractMx2MtTagsGenerate { ...@@ -22,13 +23,17 @@ public class Field23EGenerate 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();
List<String> code23EList = new ArrayList<>();
boolean sdvcFlag = false;
boolean intcCortFlag = false;
//CdtTrfTxInf.PmtTpInf.SvcLvl //CdtTrfTxInf.PmtTpInf.SvcLvl
int svcLvlCount = getXmlNodeCounts(bodyHdrParentElementName, document, "CdtTrfTxInf.PmtTpInf.SvcLvl"); int svcLvlCount = getXmlNodeCounts(bodyHdrParentElementName, document, "CdtTrfTxInf.PmtTpInf.SvcLvl");
if (svcLvlCount > 0) { if (svcLvlCount > 0) {
for (int i=0; i<svcLvlCount; i++) { for (int i=0; i<svcLvlCount; i++) {
String code = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.PmtTpInf.SvcLvl("+i+").Cd"); String code = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.PmtTpInf.SvcLvl("+i+").Cd");
if (ServiceLevelCode.SDVA.value().equals(code)) { if (ServiceLevelCode.SDVA.value().equals(code)) {
tags.add(new Tag(name, code)); code23EList.add(code);
sdvcFlag = true;
break; break;
} }
} }
...@@ -37,38 +42,137 @@ public class Field23EGenerate extends AbstractMx2MtTagsGenerate { ...@@ -37,38 +42,137 @@ public class Field23EGenerate extends AbstractMx2MtTagsGenerate {
String ctgyPurpCode = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.PmtTpInf.CtgyPurp.Cd"); String ctgyPurpCode = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.PmtTpInf.CtgyPurp.Cd");
String ctgyPurpProprietary = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.PmtTpInf.CtgyPurp.Prtry"); String ctgyPurpProprietary = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.PmtTpInf.CtgyPurp.Prtry");
if (CategoryPurposeCode.INTC.value().equals(ctgyPurpCode) || CategoryPurposeCode.CORT.value().equals(ctgyPurpCode)) { if (CategoryPurposeCode.INTC.value().equals(ctgyPurpCode) || CategoryPurposeCode.CORT.value().equals(ctgyPurpCode)) {
tags.add(new Tag(name, ctgyPurpCode)); code23EList.add(ctgyPurpCode);
intcCortFlag = true;
} else { } else {
String proprietary = CategoryPurposeCode.INTC.value() + " " + CategoryPurposeCode.CORT.value(); String proprietary = CategoryPurposeCode.INTC.value() + " " + CategoryPurposeCode.CORT.value();
if (proprietary.equalsIgnoreCase(ctgyPurpProprietary)) { if (proprietary.equalsIgnoreCase(ctgyPurpProprietary)) {
tags.add(new Tag(name, CategoryPurposeCode.INTC.value())); code23EList.add(CategoryPurposeCode.INTC.value());
tags.add(new Tag(name, CategoryPurposeCode.CORT.value())); code23EList.add(CategoryPurposeCode.CORT.value());
intcCortFlag = true;
} }
} }
//CdtTrfTxInf.InstrForCdtrAgt //CdtTrfTxInf.InstrForCdtrAgt
int instrForCdtrAgtCount = getXmlNodeCounts(bodyHdrParentElementName, document, "CdtTrfTxInf.InstrForCdtrAgt"); int instrForCdtrAgtCount = getXmlNodeCounts(bodyHdrParentElementName, document, "CdtTrfTxInf.InstrForCdtrAgt");
if (instrForCdtrAgtCount > 0) { if (instrForCdtrAgtCount > 0) {
List<String> list = new ArrayList<>();
String totalInstrInf = ""; String totalInstrInf = "";
for (int i=0; i<instrForCdtrAgtCount; i++) { for (int i=0; i<instrForCdtrAgtCount; i++) {
if (i == 2) break;//只取2个CdtrAgt if (i == 2) break;//只取2个CdtrAgt
String code = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.InstrForCdtrAgt("+i+").Cd"); String code = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.InstrForCdtrAgt("+i+").Cd");
String instrInf = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.InstrForCdtrAgt("+i+").InstrInf"); String instrInf = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.InstrForCdtrAgt("+i+").InstrInf");
if (StringUtil.isNotEmpty(code)) { if (StringUtil.isNotEmpty(code)) {
list.addAll(mx_to_mt23E(code, instrInf)); code23EList.addAll(mx_to_mt23E(code, instrInf));
} else { } else {
totalInstrInf += instrInf; totalInstrInf += instrInf;
} }
} }
if (totalInstrInf.length() > 0) { if (totalInstrInf.length() > 0) {
list.addAll(mx_to_mt23E_BIS(totalInstrInf)); code23EList.addAll(mx_to_mt23E_BIS(totalInstrInf));
} }
if (list.size() > 0) { }
for (String value : list) { //mapping转换文档 Translation Post Conditions -> POSTC0010
tags.add(new Tag(name, value)); code23EList = removeRepeatCode(code23EList);
String errorLocation = "Block4/:23E:";
List<String> list = new ArrayList<>();
//mapping转换文档 Translation Post Conditions -> POSTC001
//mapping转换文档 Translation Post Conditions -> POSTC002
if (sdvcFlag || intcCortFlag) {
boolean errorFlag = false;
for (int i=0; i<code23EList.size(); i++) {
if (code23EList.get(i).startsWith(ExternalCreditorAgentInstructionCode.HOLD.value()) || code23EList.get(i).startsWith(ExternalCreditorAgentInstructionCode.CHQB.value())) {
errorFlag = true;
} else {
list.add(code23EList.get(i));
}
}
if (errorFlag) {
if (sdvcFlag) {
buildSTErrorInfo(ERROR.T20040, errorLocation, null);
}
if (intcCortFlag) {
buildSTErrorInfo(ERROR.T20041, errorLocation, null);
}
}
} else {
for (String code : code23EList) {
list.add(code);
}
}
//mapping转换文档 Translation Post Conditions -> POSTC005
list = removeConflictCode(list, ExternalCreditorAgentInstructionCode.HOLD.value(), ExternalCreditorAgentInstructionCode.CHQB.value(), ERROR.T15005, errorLocation);
list = removeConflictCode(list, ExternalCreditorAgentInstructionCode.PHOB.value(), ExternalCreditorAgentInstructionCode.TELB.value(), ERROR.T15004, errorLocation);
if (list.size() > 0) {
for (String value : list) {
tags.add(new Tag(name, value));
}
}
}
/**
* 移除冲突的code
* code1 和 code2 冲突
* @param list
* @param code1
* @param code2
* @param errorCode
* @param location
* @return
*/
private List<String> removeConflictCode(List<String> list, String code1, String code2, String errorCode, String location) {
List<String> newList = new ArrayList<>();
boolean existCode1Flag = false;
for (String code : list) {
if (code.startsWith(code1)) {
existCode1Flag = true;
break;
}
}
if (existCode1Flag) {
boolean errorFlag = false;
for (String code : list) {
if (code.startsWith(code2)) {
errorFlag = true;
} else {
newList.add(code);
} }
} }
if (errorFlag) {
buildSTErrorInfo(errorCode, location, null);
}
return newList;
} else {
return list;
} }
}
/**
* 移除重复的code
* "SDVA", "INTC", "CORT", "HOLD", "CHQB", "PHOB", "TELB"
* @param code23EList
* @return
*/
private List<String> removeRepeatCode(List<String> code23EList) {
Map<String, String> maps = new LinkedHashMap<>();
for (String code : code23EList) {
if (code.length() == 4) {
maps.put(code, code);
} else {
if (!maps.containsKey(code.substring(0,5))) {
maps.put(code.substring(0,5), code);
}
}
}
String[] repeatCodes = new String[]{"SDVA", "INTC", "CORT", "HOLD", "CHQB", "PHOB", "TELB"};
for (String repeatCode : repeatCodes) {
if (maps.containsKey(repeatCode) && maps.containsKey(repeatCode+"/")) {
maps.remove(repeatCode);
}
}
List<String> list = new ArrayList<>();
Set<String> keySets = maps.keySet();
for (String key : keySets) {
list.add(maps.get(key));
}
return list;
} }
} }
...@@ -75,6 +75,7 @@ public class Field50AGenerate extends AbstractMx2MtTagsGenerate { ...@@ -75,6 +75,7 @@ public class Field50AGenerate extends AbstractMx2MtTagsGenerate {
} else { } else {
value = mtNameAddress; value = mtNameAddress;
} }
value = mx_to_mtStartingLineCharacter(value, "Block4/:50K:");
tags.add(new Tag(name_K, value)); tags.add(new Tag(name_K, value));
} }
} else if (StringUtil.isNotEmpty(name)) { } else if (StringUtil.isNotEmpty(name)) {
...@@ -84,6 +85,7 @@ public class Field50AGenerate extends AbstractMx2MtTagsGenerate { ...@@ -84,6 +85,7 @@ public class Field50AGenerate extends AbstractMx2MtTagsGenerate {
} else { } else {
value = mtNameAddress; value = mtNameAddress;
} }
value = mx_to_mtStartingLineCharacter(value, "Block4/:50K:");
tags.add(new Tag(name_K, value)); tags.add(new Tag(name_K, value));
} }
} }
......
...@@ -64,6 +64,7 @@ public class Field52AGenerate extends AbstractMx2MtTagsGenerate { ...@@ -64,6 +64,7 @@ public class Field52AGenerate extends AbstractMx2MtTagsGenerate {
} else { } else {
value = mtNameAddress; value = mtNameAddress;
} }
value = mx_to_mtStartingLineCharacter(value, "Block4/:52D:");
tags.add(new Tag(name_D, value)); tags.add(new Tag(name_D, value));
} }
} }
......
...@@ -87,6 +87,7 @@ public class Field53AGenerate extends AbstractMx2MtTagsGenerate { ...@@ -87,6 +87,7 @@ public class Field53AGenerate extends AbstractMx2MtTagsGenerate {
} else { } else {
value = mtNameAddress; value = mtNameAddress;
} }
value = mx_to_mtStartingLineCharacter(value, "Block4/:53D:");
tags.add(new Tag(name_D, value)); tags.add(new Tag(name_D, value));
} }
} }
......
...@@ -3,6 +3,7 @@ package com.brilliance.swift.mx2mt.mt103.impl; ...@@ -3,6 +3,7 @@ package com.brilliance.swift.mx2mt.mt103.impl;
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;
import com.brilliance.swift.mx2mt.Mx2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil; import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage; import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag; import com.prowidesoftware.swift.model.Tag;
...@@ -21,6 +22,7 @@ public class Field54AGenerate extends AbstractMx2MtTagsGenerate { ...@@ -21,6 +22,7 @@ public class Field54AGenerate extends AbstractMx2MtTagsGenerate {
@Override @Override
public void tagGenerate() throws SwiftException { public void tagGenerate() throws SwiftException {
context.set(Mx2MtContextIdentifier.MX_TO_MT_ERROR_LOCATION, "Block4/54a");
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 value = ""; String value = "";
...@@ -63,6 +65,7 @@ public class Field54AGenerate extends AbstractMx2MtTagsGenerate { ...@@ -63,6 +65,7 @@ public class Field54AGenerate extends AbstractMx2MtTagsGenerate {
} else { } else {
value = mtNameAddress; value = mtNameAddress;
} }
value = mx_to_mtStartingLineCharacter(value, "Block4/:54D:");
tags.add(new Tag(name_D, value)); tags.add(new Tag(name_D, value));
} }
} }
......
...@@ -3,6 +3,7 @@ package com.brilliance.swift.mx2mt.mt103.impl; ...@@ -3,6 +3,7 @@ package com.brilliance.swift.mx2mt.mt103.impl;
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;
import com.brilliance.swift.mx2mt.Mx2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil; import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage; import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag; import com.prowidesoftware.swift.model.Tag;
...@@ -21,6 +22,7 @@ public class Field55AGenerate extends AbstractMx2MtTagsGenerate { ...@@ -21,6 +22,7 @@ public class Field55AGenerate extends AbstractMx2MtTagsGenerate {
@Override @Override
public void tagGenerate() throws SwiftException { public void tagGenerate() throws SwiftException {
context.set(Mx2MtContextIdentifier.MX_TO_MT_ERROR_LOCATION, "Block4/55a");
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 value = ""; String value = "";
...@@ -63,6 +65,7 @@ public class Field55AGenerate extends AbstractMx2MtTagsGenerate { ...@@ -63,6 +65,7 @@ public class Field55AGenerate extends AbstractMx2MtTagsGenerate {
} else { } else {
value = mtNameAddress; value = mtNameAddress;
} }
value = mx_to_mtStartingLineCharacter(value, "Block4/:55D:");
tags.add(new Tag(name_D, value)); tags.add(new Tag(name_D, value));
} }
} }
......
...@@ -3,6 +3,7 @@ package com.brilliance.swift.mx2mt.mt103.impl; ...@@ -3,6 +3,7 @@ package com.brilliance.swift.mx2mt.mt103.impl;
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;
import com.brilliance.swift.mx2mt.Mx2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil; import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage; import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag; import com.prowidesoftware.swift.model.Tag;
...@@ -21,6 +22,7 @@ public class Field56AGenerate extends AbstractMx2MtTagsGenerate { ...@@ -21,6 +22,7 @@ public class Field56AGenerate extends AbstractMx2MtTagsGenerate {
@Override @Override
public void tagGenerate() throws SwiftException { public void tagGenerate() throws SwiftException {
context.set(Mx2MtContextIdentifier.MX_TO_MT_ERROR_LOCATION, "Block4/56a");
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 bicCode = mx_to_mtBICFI(bodyHdrParentElementName + ".CdtTrfTxInf.IntrmyAgt1"); String bicCode = mx_to_mtBICFI(bodyHdrParentElementName + ".CdtTrfTxInf.IntrmyAgt1");
...@@ -68,6 +70,7 @@ public class Field56AGenerate extends AbstractMx2MtTagsGenerate { ...@@ -68,6 +70,7 @@ public class Field56AGenerate extends AbstractMx2MtTagsGenerate {
} else { } else {
value = mtNameAddress; value = mtNameAddress;
} }
value = mx_to_mtStartingLineCharacter(value, "Block4/:56D:");
tags.add(new Tag(name_D, value)); tags.add(new Tag(name_D, value));
} }
} }
......
package com.brilliance.swift.mx2mt.mt103.impl; package com.brilliance.swift.mx2mt.mt103.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;
import com.brilliance.swift.mx2mt.Mx2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil; import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage; import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag; import com.prowidesoftware.swift.model.Tag;
...@@ -21,8 +23,10 @@ public class Field57AGenerate extends AbstractMx2MtTagsGenerate { ...@@ -21,8 +23,10 @@ public class Field57AGenerate extends AbstractMx2MtTagsGenerate {
@Override @Override
public void tagGenerate() throws SwiftException { public void tagGenerate() throws SwiftException {
context.set(Mx2MtContextIdentifier.MX_TO_MT_ERROR_LOCATION, "Block4/57a");
SwiftMessage swiftMessage = context.get(SwiftMessage.class); SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags(); List<Tag> tags = swiftMessage.getBlock4().getTags();
boolean flag = exist56aStartWithFWRT(tags);
String bicCode = mx_to_mtBICFI(bodyHdrParentElementName + ".CdtTrfTxInf.CdtrAgt"); String bicCode = mx_to_mtBICFI(bodyHdrParentElementName + ".CdtTrfTxInf.CdtrAgt");
String account = mx_to_mtAccount(bodyHdrParentElementName + ".CdtTrfTxInf.CdtrAgtAcct"); String account = mx_to_mtAccount(bodyHdrParentElementName + ".CdtTrfTxInf.CdtrAgtAcct");
String mtClearSystemId = mx_to_mtClearingIdentifier(bodyHdrParentElementName + ".CdtTrfTxInf.CdtrAgt"); String mtClearSystemId = mx_to_mtClearingIdentifier(bodyHdrParentElementName + ".CdtTrfTxInf.CdtrAgt");
...@@ -37,6 +41,15 @@ public class Field57AGenerate extends AbstractMx2MtTagsGenerate { ...@@ -37,6 +41,15 @@ public class Field57AGenerate extends AbstractMx2MtTagsGenerate {
} else { } else {
mtAccount = mtClearSystemId; mtAccount = mtClearSystemId;
} }
//mapping转换文档 Translation Post Conditions -> POSTC007
if (flag && StringUtil.isNotEmpty(mtAccount) && (mtAccount.startsWith("//FW") || mtAccount.startsWith("//RT"))) {
if (StringUtil.isEmpty(mtClearSystemId) || mtClearSystemId.startsWith("//FW")) {
mtAccount = "";
buildSTErrorInfo(ERROR.T20224, "Block4/:"+name_A+":", null);
} else {
mtAccount = mtClearSystemId;
}
}
if (StringUtil.isNotEmpty(mtAccount)) { if (StringUtil.isNotEmpty(mtAccount)) {
value = mtAccount + Mx2MtConstants.NEW_LINE + bicCode; value = mtAccount + Mx2MtConstants.NEW_LINE + bicCode;
} else { } else {
...@@ -63,12 +76,44 @@ public class Field57AGenerate extends AbstractMx2MtTagsGenerate { ...@@ -63,12 +76,44 @@ public class Field57AGenerate extends AbstractMx2MtTagsGenerate {
} else { } else {
mtAccount = account; mtAccount = account;
} }
//mapping转换文档 Translation Post Conditions -> POSTC007
if (flag && StringUtil.isNotEmpty(mtAccount) && (mtAccount.startsWith("//FW") || mtAccount.startsWith("//RT"))) {
if (StringUtil.isEmpty(mtClearSystemId) || mtClearSystemId.startsWith("//FW")) {
mtAccount = "";
buildSTErrorInfo(ERROR.T20224, "Block4/:"+name_D+":", null);
} else {
mtAccount = mtClearSystemId;
}
}
if (StringUtil.isNotEmpty(mtAccount)) { if (StringUtil.isNotEmpty(mtAccount)) {
value = mtAccount + Mx2MtConstants.NEW_LINE + mtNameAddress; value = mtAccount + Mx2MtConstants.NEW_LINE + mtNameAddress;
} else { } else {
value = mtNameAddress; value = mtNameAddress;
} }
value = mx_to_mtStartingLineCharacter(value, "Block4/:57D:");
tags.add(new Tag(name_D, value)); tags.add(new Tag(name_D, value));
} }
} }
/**
* 56a 是否以 //FW or //RT 开始
* @param tags
* @return
*/
private boolean exist56aStartWithFWRT(List<Tag> tags) {
boolean flag = false;
if (tags != null && tags.size() > 0) {
for (int i=0; i<tags.size(); i++) {
Tag tag = tags.get(i);
if ("56A".equals(tag.getName()) || "56D".equals(tag.getName())) {
String value = tag.getValue();
if (value.startsWith("//FW") || value.startsWith("//RT")) {
flag = true;
break;
}
}
}
}
return flag;
}
} }
...@@ -3,6 +3,7 @@ package com.brilliance.swift.mx2mt.mt103.impl; ...@@ -3,6 +3,7 @@ package com.brilliance.swift.mx2mt.mt103.impl;
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;
import com.brilliance.swift.mx2mt.Mx2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil; import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage; import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag; import com.prowidesoftware.swift.model.Tag;
...@@ -28,6 +29,7 @@ public class Field59Generate extends AbstractMx2MtTagsGenerate { ...@@ -28,6 +29,7 @@ public class Field59Generate extends AbstractMx2MtTagsGenerate {
@Override @Override
public void tagGenerate() throws SwiftException { public void tagGenerate() throws SwiftException {
context.set(Mx2MtContextIdentifier.MX_TO_MT_ERROR_LOCATION, "Block4/59a");
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 partyPath = bodyHdrParentElementName + ".CdtTrfTxInf.Cdtr"; String partyPath = bodyHdrParentElementName + ".CdtTrfTxInf.Cdtr";
...@@ -70,6 +72,7 @@ public class Field59Generate extends AbstractMx2MtTagsGenerate { ...@@ -70,6 +72,7 @@ public class Field59Generate extends AbstractMx2MtTagsGenerate {
} else { } else {
value = nameAddress; value = nameAddress;
} }
value = mx_to_mtStartingLineCharacter(value, "Block4/:59:");
tags.add(new Tag(name, value)); tags.add(new Tag(name, value));
} }
} else if (StringUtil.isNotEmpty(partyName)){ } else if (StringUtil.isNotEmpty(partyName)){
...@@ -79,6 +82,7 @@ public class Field59Generate extends AbstractMx2MtTagsGenerate { ...@@ -79,6 +82,7 @@ public class Field59Generate extends AbstractMx2MtTagsGenerate {
} else { } else {
value = nameAddress; value = nameAddress;
} }
value = mx_to_mtStartingLineCharacter(value, "Block4/:59:");
tags.add(new Tag(name, value)); tags.add(new Tag(name, value));
} }
} }
......
package com.brilliance.swift.mx2mt.mt103.impl; package com.brilliance.swift.mx2mt.mt103.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;
...@@ -40,22 +41,46 @@ public class Field70Generate extends AbstractMx2MtTagsGenerate { ...@@ -40,22 +41,46 @@ public class Field70Generate extends AbstractMx2MtTagsGenerate {
String mt70FullString = ""; String mt70FullString = "";
String mtUltimateCreditor = mx_to_mtUltimateParty(bodyHdrParentElementName + ".CdtTrfTxInf.UltmtCdtr"); String mtUltimateCreditor = mx_to_mtUltimateParty(bodyHdrParentElementName + ".CdtTrfTxInf.UltmtCdtr");
if (StringUtil.isNotEmpty(mtUltimateCreditor)) { if (StringUtil.isNotEmpty(mtUltimateCreditor)) {
String str = "/ULTB/" + mtUltimateCreditor;
if (str.length() > 140) str = str.substring(0, 139) + "+";
if (StringUtil.isEmpty(mt70FullString)) { if (StringUtil.isEmpty(mt70FullString)) {
mt70FullString += str; int remainLength = 140 - mt70FullString.length() - 6;
if (remainLength > 0) {
if (mtUltimateCreditor.length() > remainLength) {
buildSTErrorInfo(ERROR.T0000T, "Block4/:70:/ULTB/", mtUltimateCreditor);
mtUltimateCreditor = mtUltimateCreditor.substring(0, remainLength-1) + "+";
}
mt70FullString += "/ULTB/" + mtUltimateCreditor;
}
} else { } else {
mt70FullString += "//" + str; int remainLength = 140 - mt70FullString.length() - 8;
if (remainLength > 0) {
if (mtUltimateCreditor.length() > remainLength) {
buildSTErrorInfo(ERROR.T0000T, "Block4/:70:///ULTB/", mtUltimateCreditor);
mtUltimateCreditor = mtUltimateCreditor.substring(0, remainLength-1) + "+";
}
mt70FullString += "///ULTB/" + mtUltimateCreditor;
}
} }
} }
String mtUltimateDebtor = mx_to_mtUltimateParty(bodyHdrParentElementName + ".CdtTrfTxInf.UltmtDbtr"); String mtUltimateDebtor = mx_to_mtUltimateParty(bodyHdrParentElementName + ".CdtTrfTxInf.UltmtDbtr");
if (StringUtil.isNotEmpty(mtUltimateDebtor)) { if (StringUtil.isNotEmpty(mtUltimateDebtor)) {
String str = "/ULTD/" + mtUltimateDebtor;
if (str.length() > 140) str = str.substring(0, 139) + "+";
if (StringUtil.isEmpty(mt70FullString)) { if (StringUtil.isEmpty(mt70FullString)) {
mt70FullString += str; int remainLength = 140 - mt70FullString.length() - 6;
if (remainLength > 0) {
if (mtUltimateDebtor.length() > remainLength) {
buildSTErrorInfo(ERROR.T0000T, "Block4/:70:/ULTD/", mtUltimateDebtor);
mtUltimateDebtor = mtUltimateDebtor.substring(0, remainLength-1) + "+";
}
mt70FullString += "/ULTD/" + mtUltimateDebtor;
}
} else { } else {
mt70FullString += "//" + str; int remainLength = 140 - mt70FullString.length() - 8;
if (remainLength > 0) {
if (mtUltimateDebtor.length() > remainLength) {
buildSTErrorInfo(ERROR.T0000T, "Block4/:70:///ULTD/", mtUltimateDebtor);
mtUltimateDebtor = mtUltimateDebtor.substring(0, remainLength-1) + "+";
}
mt70FullString += "///ULTD/" + mtUltimateDebtor;
}
} }
} }
String mxPurposeCode = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.Purp.Cd"); String mxPurposeCode = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.Purp.Cd");
...@@ -73,33 +98,86 @@ public class Field70Generate extends AbstractMx2MtTagsGenerate { ...@@ -73,33 +98,86 @@ public class Field70Generate extends AbstractMx2MtTagsGenerate {
} }
if (StringUtil.isNotEmpty(mtPurposeCode)) { if (StringUtil.isNotEmpty(mtPurposeCode)) {
if (StringUtil.isEmpty(mt70FullString)) { if (StringUtil.isEmpty(mt70FullString)) {
mt70FullString += "/PURP/" + mtPurposeCode; int remainLength = 140 - mt70FullString.length() - 6;
if (remainLength > 0) {
if (mtPurposeCode.length() > remainLength) {
buildSTErrorInfo(ERROR.T0000T, "Block4/:70:/PURP/", mtPurposeCode);
mtPurposeCode = mtPurposeCode.substring(0, remainLength-1) + "+";
}
mt70FullString += "/PURP/" + mtPurposeCode;
}
} else { } else {
mt70FullString += "///PURP/" + mtPurposeCode; int remainLength = 140 - mt70FullString.length() - 8;
if (remainLength > 0) {
if (mtPurposeCode.length() > remainLength) {
buildSTErrorInfo(ERROR.T0000T, "Block4/:70:///PURP/", mtPurposeCode);
mtPurposeCode = mtPurposeCode.substring(0, remainLength-1) + "+";
}
mt70FullString += "///PURP/" + mtPurposeCode;
}
} }
} }
String endToEndIdentification = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.PmtId.EndToEndId"); String endToEndIdentification = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.PmtId.EndToEndId");
if (StringUtil.isNotEmpty(endToEndIdentification)) { if (StringUtil.isNotEmpty(endToEndIdentification)) {
if (StringUtil.isEmpty(mt70FullString)) { if (StringUtil.isEmpty(mt70FullString)) {
mt70FullString += "/ROC/" + endToEndIdentification; int remainLength = 140 - mt70FullString.length() - 5;
if (remainLength > 0) {
if (endToEndIdentification.length() > remainLength) {
buildSTErrorInfo(ERROR.T0000T, "Block4/:70:/ROC/", endToEndIdentification);
endToEndIdentification = endToEndIdentification.substring(0, remainLength-1) + "+";
}
mt70FullString += "/ROC/" + endToEndIdentification;
}
} else { } else {
mt70FullString += "///ROC/" + endToEndIdentification; int remainLength = 140 - mt70FullString.length() - 7;
if (remainLength > 0) {
if (endToEndIdentification.length() > remainLength) {
buildSTErrorInfo(ERROR.T0000T, "Block4/:70:///ROC/", endToEndIdentification);
endToEndIdentification = endToEndIdentification.substring(0, remainLength-1) + "+";
}
mt70FullString += "///ROC/" + endToEndIdentification;
}
} }
} }
String relatedRemittanceInformation = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.RltdRmtInf.RmtId"); String relatedRemittanceInformation = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.RltdRmtInf.RmtId");
if (StringUtil.isNotEmpty(relatedRemittanceInformation)) { if (StringUtil.isNotEmpty(relatedRemittanceInformation)) {
if (StringUtil.isEmpty(mt70FullString)) { if (StringUtil.isEmpty(mt70FullString)) {
mt70FullString += "/RELID/" + relatedRemittanceInformation; int remainLength = 140 - mt70FullString.length() - 7;
if (remainLength > 0) {
if (relatedRemittanceInformation.length() > remainLength) {
buildSTErrorInfo(ERROR.T0000T, "Block4/:70:/RELID/", relatedRemittanceInformation);
relatedRemittanceInformation = relatedRemittanceInformation.substring(0, remainLength-1) + "+";
}
mt70FullString += "/RELID/" + relatedRemittanceInformation;
}
} else { } else {
mt70FullString += "///RELID/" + relatedRemittanceInformation; int remainLength = 140 - mt70FullString.length() - 9;
if (remainLength > 0) {
if (relatedRemittanceInformation.length() > remainLength) {
buildSTErrorInfo(ERROR.T0000T, "Block4/:70:///RELID/", relatedRemittanceInformation);
relatedRemittanceInformation = relatedRemittanceInformation.substring(0, remainLength-1) + "+";
}
mt70FullString += "///RELID/" + relatedRemittanceInformation;
}
} }
} }
String remittanceInfoUnstructured = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.RmtInf.Ustrd"); String remittanceInfoUnstructured = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.RmtInf.Ustrd");
if (StringUtil.isNotEmpty(remittanceInfoUnstructured)) { if (StringUtil.isNotEmpty(remittanceInfoUnstructured)) {
if (StringUtil.isEmpty(mt70FullString)) { if (StringUtil.isEmpty(mt70FullString)) {
mt70FullString += "/URI/" + remittanceInfoUnstructured; if (remittanceInfoUnstructured.length() > 140) {
buildSTErrorInfo(ERROR.T0000T, "Block4/:70:", remittanceInfoUnstructured);
remittanceInfoUnstructured = remittanceInfoUnstructured.substring(0, 139) + "+";
}
mt70FullString += remittanceInfoUnstructured;
} else { } else {
mt70FullString += "///URI/" + remittanceInfoUnstructured; int remainLength = 140 - mt70FullString.length() - 7;
if (remainLength > 0) {
if (remittanceInfoUnstructured.length() > remainLength) {
buildSTErrorInfo(ERROR.T0000T, "Block4/:70:///URI/", remittanceInfoUnstructured);
remittanceInfoUnstructured = remittanceInfoUnstructured.substring(0, remainLength-1) + "+";
}
mt70FullString += "///URI/" + remittanceInfoUnstructured;
}
} }
} }
int remittanceInfoStructuredCount = getXmlNodeCounts(bodyHdrParentElementName, document, "CdtTrfTxInf.RmtInf.Strd"); int remittanceInfoStructuredCount = getXmlNodeCounts(bodyHdrParentElementName, document, "CdtTrfTxInf.RmtInf.Strd");
...@@ -112,6 +190,7 @@ public class Field70Generate extends AbstractMx2MtTagsGenerate { ...@@ -112,6 +190,7 @@ public class Field70Generate extends AbstractMx2MtTagsGenerate {
} }
if (StringUtil.isNotEmpty(mt70FullString)) { if (StringUtil.isNotEmpty(mt70FullString)) {
String value = StringUtil.getStringByEnter(mt70FullString, 35, 4); String value = StringUtil.getStringByEnter(mt70FullString, 35, 4);
value = mx_to_mtStartingLineCharacter(value, "Block4/:70:");
tags.add(new Tag(name, value)); tags.add(new Tag(name, value));
} }
} }
......
package com.brilliance.swift.mx2mt.mt103.impl; package com.brilliance.swift.mx2mt.mt103.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.NumberUtil; import com.brilliance.swift.util.NumberUtil;
...@@ -56,10 +57,18 @@ public class Field71AGenerate extends AbstractMx2MtTagsGenerate { ...@@ -56,10 +57,18 @@ public class Field71AGenerate extends AbstractMx2MtTagsGenerate {
if (ccy.equals(getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.ChrgsInf("+i+").Amt@Ccy"))) { if (ccy.equals(getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.ChrgsInf("+i+").Amt@Ccy"))) {
BigDecimal tmpAmt = new BigDecimal(getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.ChrgsInf("+i+").Amt")); BigDecimal tmpAmt = new BigDecimal(getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.ChrgsInf("+i+").Amt"));
sumAmt = sumAmt.add(tmpAmt); sumAmt = sumAmt.add(tmpAmt);
} else {
buildSTErrorInfo(ERROR.T20045, "block4/:"+name_G+":", null);
} }
} }
} }
tags.add(new Tag(name_G, ccy + NumberUtil.formatAmt(sumAmt, ccy))); //mapping转换文档 Translation Post Conditions -> POSTC006
String intrBkSttlmAmtCcy = getXmlNodeValue(bodyHdrParentElementName, document, "CdtTrfTxInf.IntrBkSttlmAmt@Ccy");
if (ccy.equals(intrBkSttlmAmtCcy)) {
tags.add(new Tag(name_G, ccy + NumberUtil.formatAmt(sumAmt, ccy)));
} else {
buildSTErrorInfo(ERROR.T20042, "Block4/:"+name_G+":", null);
}
} }
} }
} }
......
...@@ -3,6 +3,7 @@ package com.brilliance.swift.mx2mt.mt103.impl; ...@@ -3,6 +3,7 @@ package com.brilliance.swift.mx2mt.mt103.impl;
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;
import com.brilliance.swift.mx2mt.Mx2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil; import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.common.CategoryPurposeCode; import com.brilliance.swift.vo.common.CategoryPurposeCode;
import com.brilliance.swift.vo.common.ServiceLevelCode; import com.brilliance.swift.vo.common.ServiceLevelCode;
...@@ -41,6 +42,7 @@ public class Field72Generate extends AbstractMx2MtTagsGenerate { ...@@ -41,6 +42,7 @@ public class Field72Generate extends AbstractMx2MtTagsGenerate {
@Override @Override
public void tagGenerate() throws SwiftException { public void tagGenerate() throws SwiftException {
context.set(Mx2MtContextIdentifier.MX_TO_MT_ERROR_LOCATION, "Block4/:72:");
SwiftMessage swiftMessage = context.get(SwiftMessage.class); SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags(); List<Tag> tags = swiftMessage.getBlock4().getTags();
List<String> mt72List = new ArrayList<>(); List<String> mt72List = new ArrayList<>();
...@@ -126,6 +128,7 @@ public class Field72Generate extends AbstractMx2MtTagsGenerate { ...@@ -126,6 +128,7 @@ public class Field72Generate extends AbstractMx2MtTagsGenerate {
value += Mx2MtConstants.NEW_LINE + list.get(i); value += Mx2MtConstants.NEW_LINE + list.get(i);
} }
} }
value = mx_to_mtStartingLineCharacter(value, "Block4/:72:");
tags.add(new Tag(name, value)); tags.add(new Tag(name, value));
} }
} }
......
package com.brilliance.swift.mx2mt.mt103.impl; package com.brilliance.swift.mx2mt.mt103.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.mx2mt.Mx2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil; import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage; import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag; import com.prowidesoftware.swift.model.Tag;
...@@ -32,6 +34,7 @@ public class Field77BGenerate extends AbstractMx2MtTagsGenerate { ...@@ -32,6 +34,7 @@ public class Field77BGenerate extends AbstractMx2MtTagsGenerate {
@Override @Override
public void tagGenerate() throws SwiftException { public void tagGenerate() throws SwiftException {
context.set(Mx2MtContextIdentifier.MX_TO_MT_ERROR_LOCATION, "Block4/:77B:");
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 mtRegulatoryReporting = ""; String mtRegulatoryReporting = "";
...@@ -77,9 +80,13 @@ public class Field77BGenerate extends AbstractMx2MtTagsGenerate { ...@@ -77,9 +80,13 @@ public class Field77BGenerate extends AbstractMx2MtTagsGenerate {
} }
} }
} }
if (mtRegulatoryReporting.length() > 105) mtRegulatoryReporting = mtRegulatoryReporting.substring(0, 104) + "+"; if (mtRegulatoryReporting.length() > 105) {
buildSTErrorInfo(ERROR.T0000T, "Block4/:77B:", mtRegulatoryReporting);
mtRegulatoryReporting = mtRegulatoryReporting.substring(0, 104) + "+";
}
if (StringUtil.isNotEmpty(mtRegulatoryReporting)) { if (StringUtil.isNotEmpty(mtRegulatoryReporting)) {
String value = StringUtil.getStringByEnter(mtRegulatoryReporting, 35, 3); String value = StringUtil.getStringByEnter(mtRegulatoryReporting, 35, 3);
value = mx_to_mtStartingLineCharacter(value, "Block4/:77B:");
tags.add(new Tag(name, value)); tags.add(new Tag(name, value));
} }
} }
......
...@@ -2,6 +2,7 @@ package com.brilliance.mx2mt.mt103; ...@@ -2,6 +2,7 @@ package com.brilliance.mx2mt.mt103;
import com.brilliance.swift.SwiftTransfer; import com.brilliance.swift.SwiftTransfer;
import com.brilliance.swift.constants.Mx2MtConstants; import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.SwiftTranslationErrorInfo; import com.brilliance.swift.vo.SwiftTranslationErrorInfo;
import com.brilliance.swift.vo.SwiftTranslationReport; import com.brilliance.swift.vo.SwiftTranslationReport;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
...@@ -23,6 +24,10 @@ public class TestMx2MtFor103 { ...@@ -23,6 +24,10 @@ public class TestMx2MtFor103 {
String errorType = errorInfo.getErrorType(); String errorType = errorInfo.getErrorType();
String description = errorInfo.getDescription(); String description = errorInfo.getDescription();
System.out.println(location + Mx2MtConstants.NEW_LINE + "-" + errorType + ":" + description); System.out.println(location + Mx2MtConstants.NEW_LINE + "-" + errorType + ":" + description);
String originalValue = errorInfo.getOriginalValue();
if (StringUtil.isNotEmpty(originalValue)) {
System.out.println(originalValue);
}
} }
} }
System.out.println(str.getMessage()); 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