Commit e400f07f by chengzhuoshen

完成Mt2Mx,103->pacs008,202->pacs009报文转换详细报告

parent d30ba29b
......@@ -70,6 +70,20 @@ public class SwiftTransfer {
}
public static String mt2Mx(String mtStr, String outPutFilePath, Map<String, Object> extraMap) throws SwiftException {
SwiftTranslationReport str = new Mt2MxCreatorManager().mt2mx(mtStr, outPutFilePath, extraMap);
return str.getMessage();
}
public static SwiftTranslationReport mt2MxPlus(File file, String outPutFilePath, Map<String, Object> extraMap) throws SwiftException {
try{
String mtStr = FileUtils.readFileToString(file);
return mt2MxPlus(mtStr, outPutFilePath, extraMap);
} catch (IOException e) {
throw new SwiftException(e.getMessage());
}
}
public static SwiftTranslationReport mt2MxPlus(String mtStr, String outPutFilePath, Map<String, Object> extraMap) throws SwiftException {
return new Mt2MxCreatorManager().mt2mx(mtStr, outPutFilePath, extraMap);
}
......
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.SwiftTranslationReport;
import com.brilliance.swift.vo.common.MessagePriority;
import com.prowidesoftware.swift.model.SwiftBlock5;
import com.prowidesoftware.swift.model.SwiftBlock5Field;
......@@ -11,6 +12,9 @@ import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mx.AbstractMX;
import javax.xml.datatype.DatatypeConfigurationException;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.ParseException;
import java.util.Date;
import java.util.HashMap;
......@@ -32,6 +36,8 @@ public abstract class AbstractMt2MxCreator implements Mt2MxCreator{
@Override
public void preProcess() {
SwiftTranslationReport str = new SwiftTranslationReport();
context.set(str);
context.set(Mt2MxContextIdentifier.MT_TO_MX_JSON_MAP, jsonMaps);
Map<String, Object> appHdrMaps = new HashMap<>();
jsonMaps.put("appHdr", appHdrMaps);
......@@ -83,9 +89,23 @@ public abstract class AbstractMt2MxCreator implements Mt2MxCreator{
String swiftGsonStr = new JSONObject(jsonMaps).toJSONString();
AbstractMX abstractMX = AbstractMX.fromJson(swiftGsonStr);
String xml = abstractMX.message();
context.set(Mt2MxContextIdentifier.MT_TO_MX_XML, xml);
SwiftTranslationReport str = context.get(SwiftTranslationReport.class);
str.setMessage(xml);
try {
String outputFilePath = (String)context.get(Mt2MxContextIdentifier.MT_TO_MX_OUTPUT_FILE_PATH, true);
if (StringUtil.isNotEmpty(outputFilePath)) {
File file = new File(outputFilePath);
if (!file.exists()) {
file.createNewFile();
}
FileOutputStream stream = new FileOutputStream(file.getAbsoluteFile());
stream.write(xml.getBytes("UTF-8"));
stream.close();
}
} catch (IOException e) {
throw new SwiftException(e.getMessage());
}
}
/**
* 公共方法
*/
......
package com.brilliance.swift.mt2mx;
import com.alibaba.fastjson.JSONArray;
import com.brilliance.swift.constants.ERROR;
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.vo.SwiftTranslationErrorInfo;
import com.brilliance.swift.vo.SwiftTranslationReport;
import com.brilliance.swift.vo.VoSettlementMethodHelper;
import com.brilliance.swift.vo.common.*;
import com.prowidesoftware.swift.model.field.Field23E;
import javax.xml.datatype.DatatypeConfigurationException;
import java.text.ParseException;
import java.util.*;
import java.util.regex.Matcher;
......@@ -34,7 +37,33 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
jsonMaps = (Map<String, Object>)context.get(Mt2MxContextIdentifier.MT_TO_MX_JSON_MAP, true);
}
/**
* 封装报文转换详细报告
* @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);
List<SwiftTranslationErrorInfo> errorInfos = str.getErrorInfos();
boolean existFlag = false;
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());
}
}
}
/**
* MT 转 MX 转换函数开始
*/
......@@ -440,7 +469,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
return flag;
}
protected void mt_to_mxClearingSystemToNameAndAddressLine(String mtPartyIdentifier, String location, Map<String, Object> maps) {
protected void mt_to_mxClearingSystemToNameAndAddressLine(String mtPartyIdentifier, String location, Map<String, Object> maps, String path) {
if (StringUtil.isEmpty(mtPartyIdentifier)) {
return;
}
......@@ -459,7 +488,9 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
}
if (StringUtil.isNotEmpty(nameAddress) && !"RT".equals(nameAddress)) {
nameAddress = "//" + nameAddress;
buildSTErrorInfo(ERROR.T20033, path, null);
} else {
buildSTErrorInfo(ERROR.T20034, path, null);
nameAddress = Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE;
}
maps.put("nm", nameAddress);
......@@ -522,7 +553,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
if (StringUtil.isEmpty(mt72)) {
return;
}
String mt72Value = mt72.replace("\r\n//", "");
String mt72Value = mt72.replace("\r\n//", " ");
String[] lines = mt72Value.split("\r\n");
String nextAgtInfo = "";
for (int i=0; i<lines.length; i++) {
......@@ -537,12 +568,14 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
nextAgtInfo += lines[i];
}
}
String nextAgeFin53 = (String)context.get(Mt2MxContextIdentifier.MT_TO_MX_INSTRUCTION_FOR_NEXT_AGENT_FIN53, true);
VoSettlementMethodHelper setlMtdHelper = context.get(VoSettlementMethodHelper.class);
String nextAgeFin53 = setlMtdHelper.getInstructionForNextAgent();
if (StringUtil.isNotEmpty(nextAgeFin53)) {
nextAgtInfo = nextAgeFin53 + nextAgtInfo;
}
if (StringUtil.isNotEmpty(nextAgtInfo)) {
if (nextAgtInfo.length() > 210) {
buildSTErrorInfo(ERROR.T0000T, "InstrForNxtAgt/InstrInf", nextAgtInfo);
nextAgtInfo = nextAgtInfo.substring(0, 209) + "+";
}
JSONArray instrForNxtAgtJsonArray = null;
......@@ -569,7 +602,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
if (StringUtil.isEmpty(mt72)) {
return;
}
String mt72Value = mt72.replace("\r\n//", "");
String mt72Value = mt72.replace("\r\n//", " ");
String[] lines = mt72Value.split("\r\n");
List<String> insList = new ArrayList<>();
for (int i=0; i<lines.length; i++) {
......@@ -600,6 +633,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
finInstnIdMaps.put("bicfi", insLine);
} else {
if (insLine.length() > 140){
buildSTErrorInfo(ERROR.T0000T, "PrvsInstgAgt" + (i+1) + "/FinInstnId/Nm", insLine);
insLine = insLine.substring(0, 139) + "+";
}
finInstnIdMaps.put("nm", insLine);
......@@ -622,7 +656,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
* @param mtPartyIdentifier
* @param maps
*/
protected void mt_to_mxFinancialInstitutionAccount(String mtPartyIdentifier, Map<String, Object> maps) {
protected void mt_to_mxFinancialInstitutionAccount(String mtPartyIdentifier, Map<String, Object> maps, String path) {
if (StringUtil.isEmpty(mtPartyIdentifier)) {
return;
}
......@@ -652,6 +686,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
schmeNmMaps.put("cd", "CUID");
return;
} else if ((mtPartyIdentifier.startsWith("/C/") || mtPartyIdentifier.startsWith("/D/")) && mtPartyIdentifier.length() > 3) {
buildSTErrorInfo(ERROR.T20086, path, null);
mtPartyIdentifier = mtPartyIdentifier.substring(3);
} else if (mtPartyIdentifier.length() > 1) {
mtPartyIdentifier = mtPartyIdentifier.substring(1);
......@@ -713,7 +748,10 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
endToEndId = m.group(1);
}
}
if (endToEndId.length() > 35) endToEndId = endToEndId.substring(0, 34) + "+";
if (endToEndId.length() > 35) {
buildSTErrorInfo(ERROR.T0000T, "PmtId/EndToEndId", endToEndId);
endToEndId = endToEndId.substring(0, 34) + "+";
}
return endToEndId;
}
......@@ -729,17 +767,19 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
return "";
}
String mxCode = "";
String mt72Value = mt72.replace("\r\n//", "");
String mt72Value = mt72.replace("\r\n//", " ");
String[] lines = mt72Value.split("\r\n");
for (int i=0; i<lines.length; i++) {
if (lines[i].startsWith(mtCode)) {
mxCode = lines[i];
}
}
mxCode = mtCode.substring(mtCode.length());
if (StringUtil.isNotEmpty(mxCode)) {
mxCode = mxCode.substring(mtCode.length());
if (mxCode.length() > maxLength) {
mxCode = mxCode.substring(0, maxLength-1) + "+";
}
}
return mxCode;
}
......@@ -773,6 +813,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
}
} else if ("ACCCode".equals(configIndicator)) {
if (mxText.length() > 140) {
buildSTErrorInfo(ERROR.T0000T, "InstrForCdtrAgt/InstrInf", mxText);
instrForCdtrAgt1.put("instrInf", mxText.substring(0, 139) + "+");
} else {
instrForCdtrAgt1.put("instrInf", mxText);
......@@ -823,7 +864,9 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
}
}
}
if (StringUtil.isNotEmpty(instructionCode)) {
instrForCdtrAgt2.put("cd", instructionCode);
}
if (StringUtil.isNotEmpty(instructionInfo)) {
instrForCdtrAgt2.put("instrInf", instructionInfo);
}
......@@ -885,6 +928,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
}
} else if ("ACCCode".equals(configIndicator)) {
if (mxAccText.length() > 140) {
buildSTErrorInfo(ERROR.T0000T, "InstrForCdtrAgt/InstrInf", mxAccText);
instrForCdtrAgt1.put("instrInf", mxAccText.substring(0, 139) + "+");
} else {
instrForCdtrAgt1.put("instrInf", mxAccText);
......@@ -895,6 +939,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
if (StringUtil.isNotEmpty(mxTelbText) && remainLength >= 7) {
String tmpInstructionInfo = "/TELB/" + mxTelbText;
if (tmpInstructionInfo.length() > remainLength) {
buildSTErrorInfo(ERROR.T0000T, "InstrForCdtrAgt/InstrInf", tmpInstructionInfo);
tmpInstructionInfo = tmpInstructionInfo.substring(0, remainLength-1) + "+";
}
instructionInfo += tmpInstructionInfo;
......@@ -921,12 +966,14 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
}
} else if ("UDLCACC".equals(configIndicator)) {
if (mxAccText.length() > 140) {
buildSTErrorInfo(ERROR.T0000T, "InstrForCdtrAgt/InstrInf", mxAccText);
instrForCdtrAgt1.put("instrInf", mxAccText.substring(0, 139) + "+");
} else {
instrForCdtrAgt1.put("instrInf", mxAccText);
}
mxUdlcText = "/UDLC/" + mxUdlcText;
if (mxUdlcText.length() > 140) {
buildSTErrorInfo(ERROR.T0000T, "InstrForCdtrAgt/InstrInf", mxUdlcText);
instrForCdtrAgt2.put("instrInf", mxUdlcText.substring(0, 139) + "+");
} else {
instrForCdtrAgt2.put("instrInf", mxUdlcText);
......@@ -934,6 +981,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
} else if ("UDLC".equals(configIndicator)) {
mxUdlcText = "/UDLC/" + mxUdlcText;
if (mxUdlcText.length() > 140) {
buildSTErrorInfo(ERROR.T0000T, "InstrForCdtrAgt/InstrInf", mxUdlcText);
mxUdlcText = mxUdlcText.substring(0, 139) + "+";
}
if (StringUtil.isNotEmpty(mxPhobText) || StringUtil.isNotEmpty(mxTelbText)) {
......@@ -943,6 +991,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
if (StringUtil.isNotEmpty(mxTelbText) && remainLength >= 7) {
String tmpInstructionInfo = "/TELB/" + mxTelbText;
if (tmpInstructionInfo.length() > remainLength) {
buildSTErrorInfo(ERROR.T0000T, "InstrForCdtrAgt/InstrInf", tmpInstructionInfo);
tmpInstructionInfo = tmpInstructionInfo.substring(0, remainLength-1) + "+";
}
instructionInfo += tmpInstructionInfo;
......@@ -988,6 +1037,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
if (StringUtil.isNotEmpty(mxTsuText) && remainLength >= 6) {
mxTsuText = "/TSU/" + mxTsuText;
if (mxTsuText.length() > remainLength) {
buildSTErrorInfo(ERROR.T0000T, "RmtInf/Ustrd", mxTsuText);
mxUnstructuredRemittanceInformation += mxTsuText.substring(0, remainLength-1) + "+";
}
}
......@@ -1357,7 +1407,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
* @param maps
*/
protected void mt_to_mxField72NewCodeWords(String mt72, boolean pacs009001Flag, Map<String, Object> maps) {
String mt72Value = mt72.replace("\r\n//", "");
String mt72Value = mt72.replace("\r\n//", " ");
String[] lines = mt72Value.split("\r\n");
List<String> intermediaryAgentLines = new ArrayList<>();
List<String> serviceLevelLines = new ArrayList<>();
......@@ -1402,7 +1452,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
if (i == 2) break; //最多转换2次 IntermediaryAgent2, IntermediaryAgent3
String line = intermediaryAgentLines.get(i);
Map<String, Object> intrmyAgtMaps = new HashMap<>();
mt_to_mxIntermediaryAgent(line, intrmyAgtMaps);
mt_to_mxIntermediaryAgent(line, intrmyAgtMaps, "intrmyAgt"+(i+2));
maps.put("intrmyAgt"+(i+2), intrmyAgtMaps);
}
}
......@@ -1434,6 +1484,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
svcLvlMaps.put("cd", code.value());
} else {
if (line.length() > 35) {
buildSTErrorInfo(ERROR.T0000T, "PmtTpInf/SvcLvl/Prtry", line);
line = line.substring(0, 34) + "+";
}
svcLvlMaps.put("prtry", line);
......@@ -1459,6 +1510,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
lclInstrmMaps.put("cd", code.value());
} else {
if (line.length() > 35) {
buildSTErrorInfo(ERROR.T0000T, "PmtTpInf/LclInstrm/Prtry", line);
line = line.substring(0, 34) + "+";
}
lclInstrmMaps.put("prtry", line);
......@@ -1482,6 +1534,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
ctgyPurpMaps.put("cd", code.value());
} else {
if (line.length() > 35) {
buildSTErrorInfo(ERROR.T0000T, "PmtTpInf/CtgyPurp/Prtry", line);
line = line.substring(0, 34) + "+";
}
ctgyPurpMaps.put("prtry", line);
......@@ -1508,6 +1561,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
purpMaps.put("cd", purpCode);
} else {
if (purpCode.length() > 35) {
buildSTErrorInfo(ERROR.T0000T, "Purp/Prtry", purpCode);
purpCode = purpCode.substring(0, 34) + "+";
}
purpMaps.put("prtry", purpCode);
......@@ -1519,7 +1573,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
* @param mtAgent
* @param maps
*/
protected void mt_to_mxIntermediaryAgent(String mtAgent, Map<String, Object> maps) {
protected void mt_to_mxIntermediaryAgent(String mtAgent, Map<String, Object> maps, String path) {
if (StringUtil.isEmpty(mtAgent)) {
return;
}
......@@ -1549,6 +1603,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
finInstnIdMaps.put("clrSysMmbId", clrSysMmbIdMaps);
}
if (mxMemId.length() > 28) {
buildSTErrorInfo(ERROR.T0000T, path + "/FinInstnId/ClrSysMmbId/MmbId", mxMemId);
mxMemId = mxMemId.substring(0, 27) + "+";
}
clrSysMmbIdMaps.put("mmbId", mxMemId);
......@@ -1603,6 +1658,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
List<String> adrLineList = new ArrayList<>();
adrLineList.add(Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE);
pstlAdrMaps.put("adrLine", adrLineList);
buildSTErrorInfo(ERROR.T20030, path, null);
} else {
if (StringUtil.isNotEmpty(mxCountryCode)) {
pstlAdrMaps.put("ctry", mxCountryCode);
......@@ -1614,7 +1670,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
}
protected String mt_To_mxField76(String mt76, Map<String, Object> maps){
String mt76Value = mt76.replace("\r\n//", "").trim();
String mt76Value = mt76.replace("\r\n//", " ").trim();
String status = "";
String reason = "";
if(mt76Value.length()>5){
......@@ -1672,6 +1728,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
}
List<String> list = new ArrayList<>();
if(additionalInformation.length()>210){
buildSTErrorInfo(ERROR.T0000T, "CxlDtls/TxInfAndSts/CxlStsRsnInf/AddtlInf", additionalInformation);
additionalInformation = additionalInformation.substring(0,209) + "+";
}
if (additionalInformation.length()>105){
......@@ -1710,7 +1767,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
return mxType;
}
protected void mt_To_mxField79(String mt79, Map<String, Object> maps){
String mt79Value = mt79.replace("\r\n//", "").trim();
String mt79Value = mt79.replace("\r\n//", " ").trim();
String code = "";
if(mt79Value.length()>5){
code = mt79Value.substring(1,5);
......@@ -1745,6 +1802,7 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
code = "";
}
if(additionalInformation.length()>210){
buildSTErrorInfo(ERROR.T0000T, "FIToFIPmtCxlReq/Undrlyg/TxInf/CxlRsnInf/AddtlInf", additionalInformation);
additionalInformation = additionalInformation.substring(0,209) + "+";
}
if (additionalInformation.length()>105){
......
......@@ -4,16 +4,12 @@ public class Mt2MxContextIdentifier {
public static final String MT_TO_MX_OUTPUT_FILE_PATH = "mt.to.mx.output.file.path";
public static final String MT_TO_MX_XML = "mt.to.mx.xml";
public static final String MT_TO_MX_JSON_MAP = "mt.to.mx.json.map";
public static final String MT_SEND_BIC = "mt.send.bic";
public static final String MT_RECEIVE_BIC = "mt.receive.bic";
public static final String MT_TO_MX_INSTRUCTION_FOR_NEXT_AGENT_FIN53 = "mt.to.mx.instruction.for.next.agent.fin53";
public static final String MT_TO_MX_NOW = "mt.to.mx.now";
/**
* 外部参数
......
......@@ -5,6 +5,7 @@ import com.brilliance.swift.mt2mx.camt029001.Mt2MxCamt029001Creator;
import com.brilliance.swift.mt2mx.camt056001.Mt2MxCamt056001Creator;
import com.brilliance.swift.mt2mx.pacs008001.Mt2MxPacs008001Creator;
import com.brilliance.swift.mt2mx.pacs009001.Mt2MxPacs009001Creator;
import com.brilliance.swift.vo.SwiftTranslationReport;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.util.List;
......@@ -22,7 +23,7 @@ public class Mt2MxCreatorManager {
}
}
public String mt2mx(String mtStr, String outPutFilePath, Map<String, Object> extraMap) throws SwiftException {
public SwiftTranslationReport mt2mx(String mtStr, String outPutFilePath, Map<String, Object> extraMap) throws SwiftException {
init(mtStr);
AbstractMt2MxCreator creator = getMt2MxCreator();
Mt2MxContext context = new Mt2MxContext();
......@@ -38,7 +39,8 @@ public class Mt2MxCreatorManager {
parseField.parseField();
}
creator.postProcess();
return (String) context.get(Mt2MxContextIdentifier.MT_TO_MX_XML);
SwiftTranslationReport str = context.get(SwiftTranslationReport.class);
return str;
}
public AbstractMt2MxCreator getMt2MxCreator() throws SwiftException {
......
......@@ -19,7 +19,7 @@ public class Camt029001Parse77AField extends AbstractMt2MxCamt029001ParseField {
if (tag77A != null) {
Map<String, Object> txInfAndStsMaps = getTxInfAndStsMaps();
Field77A field77A = (Field77A)tag77A.asField();
String String77A = field77A.getValue().replace("\r\n//", "").replace("\r\n","");
String String77A = field77A.getValue().replace("\r\n//", " ").replace("\r\n","");
int index = String77A.indexOf("/UETR/");
if(index>-1){
String uetr = String77A.substring(index+6);
......
......@@ -18,7 +18,7 @@ public class Pacs00801Parse23EField extends AbstractMt2MxPacs008001ParseField {
private static final String NAME_23E = "23E";
private static final String NAME_70 = "70";
private static final String NAME_72 = "72";
@Override
public void parseField() throws SwiftException {
......@@ -64,7 +64,6 @@ public class Pacs00801Parse23EField extends AbstractMt2MxPacs008001ParseField {
ctgyPurpMaps = (Map<String, Object>)pmtTpInfMaps.get("ctgyPurp");
} else {
ctgyPurpMaps = new HashMap<>();
pmtTpInfMaps.put("ctgyPurp", ctgyPurpMaps);
}
if (intcField23E != null && cortField23E != null) {
ctgyPurpMaps.put("prtry", CategoryPurposeCode.INTC.value() + " " + CategoryPurposeCode.CORT.value());
......@@ -73,12 +72,15 @@ public class Pacs00801Parse23EField extends AbstractMt2MxPacs008001ParseField {
} else if (cortField23E != null) {
ctgyPurpMaps.put("cd", CategoryPurposeCode.CORT.value());
}
if (ctgyPurpMaps.size() > 0) {
pmtTpInfMaps.put("ctgyPurp", ctgyPurpMaps);
}
}
Tag tag70 = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME_70);
String mt70 = "";
if (tag70 != null) {
mt70 = tag70.getValue();
Tag tag72 = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME_72);
String mt72 = "";
if (tag72 != null) {
mt72 = tag72.getValue();
}
mt_to_mxInstructionForCreditorAgent(field23EList, mt70, cdtTrfTxInfMaps);
mt_to_mxInstructionForCreditorAgent(field23EList, mt72, cdtTrfTxInfMaps);
}
}
......@@ -18,7 +18,7 @@ public class Pacs00801Parse36Field extends AbstractMt2MxPacs008001ParseField {
Tag tag = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME);
if (tag != null) {
Field36 field36 = (Field36)tag.asField();
cdtTrfTxInfMaps.put("xchgRate", new BigDecimal(field36.getRateAsNumber().toString()));
cdtTrfTxInfMaps.put("xchgRate", new BigDecimal(field36.getRateAsNumber().toString()).stripTrailingZeros());
}
}
}
......@@ -48,17 +48,17 @@ public class Pacs00801Parse52Field extends AbstractMt2MxPacs008001ParseField {
String bicCode = field52A.getBIC();
mt_to_mxBICFI(bicCode, dbtrAgtMaps);
if (StringUtil.isNotEmpty(field52A.getComponent1())) {
account = "/" + field52A.getComponent1();
account += "/" + field52A.getComponent1();
}
if (StringUtil.isNotEmpty(field52A.getComponent2())) {
account = "/" + field52A.getComponent2();
account += "/" + field52A.getComponent2();
}
} else if (field52D != null) {
if (StringUtil.isNotEmpty(field52D.getComponent1())) {
account = "/" + field52D.getComponent1();
account += "/" + field52D.getComponent1();
}
if (StringUtil.isNotEmpty(field52D.getComponent2())) {
account = "/" + field52D.getComponent2();
account += "/" + field52D.getComponent2();
}
String nameAddress = field52D.getNameAndAddress();
mt_to_mxFinancialInstitutionNameAndUnstructuredAddress(nameAddress, dbtrAgtMaps);
......@@ -84,7 +84,7 @@ public class Pacs00801Parse52Field extends AbstractMt2MxPacs008001ParseField {
}
mt_to_mxClearingIdentifier(account, clrSysMmbIdMaps);
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, dbtrAgtAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, dbtrAgtAcctMaps, "DbtrAgtAcct/Id");
}
}
if (dbtrAgtMaps.size() > 0) {
......
......@@ -95,7 +95,7 @@ public class Pacs00801Parse53Field extends AbstractMt2MxPacs008001ParseField {
}
mt_to_mxClearingIdentifier(account, clrSysMmbIdMaps);
} else {
mt_to_mxFinancialInstitutionAccount(account, instgRmbrsmntAgtAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, instgRmbrsmntAgtAcctMaps, "InstgRmbrsmntAgtAcct/Id");
}
}
}
......
package com.brilliance.swift.mt2mx.pacs008001.impl;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField;
......@@ -67,10 +68,10 @@ public class Pacs00801Parse54Field extends AbstractMt2MxPacs008001ParseField {
String bicCode = field54A.getBIC();
mt_to_mxBICFI(bicCode, instdRmbrsmntAgtMaps);
if (StringUtil.isNotEmpty(field54A.getComponent1())) {
account = "/" + field54A.getComponent1();
account += "/" + field54A.getComponent1();
}
if (StringUtil.isNotEmpty(field54A.getComponent2())) {
account = "/" + field54A.getComponent2();
account += "/" + field54A.getComponent2();
}
if (account.startsWith("//") && !account.startsWith("//CH")) {
Map<String, Object> finInstnIdMaps = null;
......@@ -89,14 +90,14 @@ public class Pacs00801Parse54Field extends AbstractMt2MxPacs008001ParseField {
}
mt_to_mxClearingIdentifier(account, clrSysMmbIdMaps);
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, instdRmbrsmntAgtAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, instdRmbrsmntAgtAcctMaps, "InstdRmbrsmntAgtAcct/Id");
}
} else if (field54B != null) {
if (StringUtil.isNotEmpty(field54B.getComponent1())) {
account = "/" + field54B.getComponent1();
account += "/" + field54B.getComponent1();
}
if (StringUtil.isNotEmpty(field54B.getComponent2())) {
account = "/" + field54B.getComponent2();
account += "/" + field54B.getComponent2();
}
String location = field54B.getLocation();
Map<String, Object> finInstnIdMaps = null;
......@@ -129,10 +130,13 @@ public class Pacs00801Parse54Field extends AbstractMt2MxPacs008001ParseField {
adrLineList.add(StringUtil.isEmpty(location)?Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE:location);
pstlAdrMaps.put("adrLine", adrLineList);
} else {
mt_to_mxClearingSystemToNameAndAddressLine(account, location, finInstnIdMaps);
mt_to_mxClearingSystemToNameAndAddressLine(account, location, finInstnIdMaps, "InstdRmbrsmntAgt/FinInstnId");
}
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, instdRmbrsmntAgtAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, instdRmbrsmntAgtAcctMaps, "InstdRmbrsmntAgtAcct/Id");
if (StringUtil.isEmpty(account)) {
buildSTErrorInfo(ERROR.T20004, "Block4/:54B:", null);
}
//name address 设置NOTPROVIDED
finInstnIdMaps.put("nm", Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE);
Map<String, Object> pstlAdrMaps = null;
......@@ -148,10 +152,10 @@ public class Pacs00801Parse54Field extends AbstractMt2MxPacs008001ParseField {
}
} else if (field54D != null) {
if (StringUtil.isNotEmpty(field54D.getComponent1())) {
account = "/" + field54D.getComponent1();
account += "/" + field54D.getComponent1();
}
if (StringUtil.isNotEmpty(field54D.getComponent2())) {
account = "/" + field54D.getComponent2();
account += "/" + field54D.getComponent2();
}
String nameAddress = field54D.getNameAndAddress();
mt_to_mxFinancialInstitutionNameAndUnstructuredAddress(nameAddress, instdRmbrsmntAgtMaps);
......@@ -172,7 +176,7 @@ public class Pacs00801Parse54Field extends AbstractMt2MxPacs008001ParseField {
}
mt_to_mxClearingIdentifier(account, clrSysMmbIdMaps);
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, instdRmbrsmntAgtAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, instdRmbrsmntAgtAcctMaps, "InstdRmbrsmntAgtAcct/Id");
}
}
if (instdRmbrsmntAgtMaps.size() > 0) {
......
package com.brilliance.swift.mt2mx.pacs008001.impl;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoSettlementMethodHelper;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.*;
import com.prowidesoftware.swift.model.field.Field55A;
import com.prowidesoftware.swift.model.field.Field55B;
import com.prowidesoftware.swift.model.field.Field55D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.util.ArrayList;
......@@ -69,10 +72,10 @@ public class Pacs00801Parse55Field extends AbstractMt2MxPacs008001ParseField {
String bicCode = field55A.getBIC();
mt_to_mxBICFI(bicCode, thrdRmbrsmntAgtMaps);
if (StringUtil.isNotEmpty(field55A.getComponent1())) {
account = "/" + field55A.getComponent1();
account += "/" + field55A.getComponent1();
}
if (StringUtil.isNotEmpty(field55A.getComponent2())) {
account = "/" + field55A.getComponent2();
account += "/" + field55A.getComponent2();
}
if (account.startsWith("//") && !account.startsWith("//CH")) {
Map<String, Object> finInstnIdMaps = null;
......@@ -91,14 +94,14 @@ public class Pacs00801Parse55Field extends AbstractMt2MxPacs008001ParseField {
}
mt_to_mxClearingIdentifier(account, clrSysMmbIdMaps);
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, thrdRmbrsmntAgtAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, thrdRmbrsmntAgtAcctMaps, "ThrdRmbrsmntAgtAcct/Id");
}
} else if (field55B != null) {
if (StringUtil.isNotEmpty(field55B.getComponent1())) {
account = "/" + field55B.getComponent1();
account += "/" + field55B.getComponent1();
}
if (StringUtil.isNotEmpty(field55B.getComponent2())) {
account = "/" + field55B.getComponent2();
account += "/" + field55B.getComponent2();
}
String location = field55B.getLocation();
Map<String, Object> finInstnIdMaps = null;
......@@ -131,10 +134,13 @@ public class Pacs00801Parse55Field extends AbstractMt2MxPacs008001ParseField {
adrLineList.add(StringUtil.isEmpty(location)?Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE:location);
pstlAdrMaps.put("adrLine", adrLineList);
} else {
mt_to_mxClearingSystemToNameAndAddressLine(account, location, finInstnIdMaps);
mt_to_mxClearingSystemToNameAndAddressLine(account, location, finInstnIdMaps, "ThrdRmbrsmntAgt/FinInstnId");
}
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, thrdRmbrsmntAgtAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, thrdRmbrsmntAgtAcctMaps, "ThrdRmbrsmntAgtAcct/Id");
if (StringUtil.isEmpty(account)) {
buildSTErrorInfo(ERROR.T20005, "Block4/:55B:", null);
}
//name address 设置NOTPROVIDED
finInstnIdMaps.put("nm", Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE);
Map<String, Object> pstlAdrMaps = null;
......@@ -150,10 +156,10 @@ public class Pacs00801Parse55Field extends AbstractMt2MxPacs008001ParseField {
}
} else if (field55D != null) {
if (StringUtil.isNotEmpty(field55D.getComponent1())) {
account = "/" + field55D.getComponent1();
account += "/" + field55D.getComponent1();
}
if (StringUtil.isNotEmpty(field55D.getComponent2())) {
account = "/" + field55D.getComponent2();
account += "/" + field55D.getComponent2();
}
String nameAddress = field55D.getNameAndAddress();
mt_to_mxFinancialInstitutionNameAndUnstructuredAddress(nameAddress, thrdRmbrsmntAgtMaps);
......@@ -174,7 +180,7 @@ public class Pacs00801Parse55Field extends AbstractMt2MxPacs008001ParseField {
}
mt_to_mxClearingIdentifier(account, clrSysMmbIdMaps);
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, thrdRmbrsmntAgtAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, thrdRmbrsmntAgtAcctMaps, "ThrdRmbrsmntAgtAcct/Id");
}
}
if (thrdRmbrsmntAgtMaps.size() > 0) {
......
......@@ -59,10 +59,10 @@ public class Pacs00801Parse56Field extends AbstractMt2MxPacs008001ParseField {
String bicCode = field56A.getBIC();
mt_to_mxBICFI(bicCode, intrmyAgt1Maps);
if (StringUtil.isNotEmpty(field56A.getComponent1())) {
account = "/" + field56A.getComponent1();
account += "/" + field56A.getComponent1();
}
if (StringUtil.isNotEmpty(field56A.getComponent2())) {
account = "/" + field56A.getComponent2();
account += "/" + field56A.getComponent2();
}
if (account.startsWith("//RT") || account.startsWith("//FW")) {
clearingChannelRTGSFlag = true;
......@@ -84,7 +84,7 @@ public class Pacs00801Parse56Field extends AbstractMt2MxPacs008001ParseField {
}
mt_to_mxClearingIdentifier(account, clrSysMmbIdMaps);
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, intrmyAgt1AcctMaps);
mt_to_mxFinancialInstitutionAccount(account, intrmyAgt1AcctMaps, "ThrdRmbrsmntAgtAcct/Id");
}
} else if (field56C != null) {
account = field56C.getValue();
......@@ -121,10 +121,10 @@ public class Pacs00801Parse56Field extends AbstractMt2MxPacs008001ParseField {
adrLineList.add(Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE);
pstlAdrMaps.put("adrLine", adrLineList);
} else {
mt_to_mxClearingSystemToNameAndAddressLine(account, null, finInstnIdMaps);
mt_to_mxClearingSystemToNameAndAddressLine(account, null, finInstnIdMaps, "IntrmyAgt1/FinInstnId");
}
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, intrmyAgt1AcctMaps);
mt_to_mxFinancialInstitutionAccount(account, intrmyAgt1AcctMaps, "IntrmyAgt1Acct/Id");
//name address 设置NOTPROVIDED
finInstnIdMaps.put("nm", Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE);
Map<String, Object> pstlAdrMaps = null;
......@@ -140,10 +140,10 @@ public class Pacs00801Parse56Field extends AbstractMt2MxPacs008001ParseField {
}
} else if (field56D != null) {
if (StringUtil.isNotEmpty(field56D.getComponent1())) {
account = "/" + field56D.getComponent1();
account += "/" + field56D.getComponent1();
}
if (StringUtil.isNotEmpty(field56D.getComponent2())) {
account = "/" + field56D.getComponent2();
account += "/" + field56D.getComponent2();
}
if (account.startsWith("//RT")) {
clearingChannelRTGSFlag = true;
......@@ -167,7 +167,7 @@ public class Pacs00801Parse56Field extends AbstractMt2MxPacs008001ParseField {
}
mt_to_mxClearingIdentifier(account, clrSysMmbIdMaps);
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, intrmyAgt1AcctMaps);
mt_to_mxFinancialInstitutionAccount(account, intrmyAgt1AcctMaps, "IntrmyAgt1Acct/Id");
}
}
if (intrmyAgt1Maps.size() > 0) {
......
package com.brilliance.swift.mt2mx.pacs008001.impl;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.Mt2MxContextIdentifier;
import com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.*;
import com.prowidesoftware.swift.model.field.Field57A;
import com.prowidesoftware.swift.model.field.Field57B;
import com.prowidesoftware.swift.model.field.Field57C;
import com.prowidesoftware.swift.model.field.Field57D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.util.ArrayList;
......@@ -65,10 +69,10 @@ public class Pacs00801Parse57Field extends AbstractMt2MxPacs008001ParseField {
String bicCode = field57A.getBIC();
mt_to_mxBICFI(bicCode, cdtrAgtMaps);
if (StringUtil.isNotEmpty(field57A.getComponent1())) {
account = "/" + field57A.getComponent1();
account += "/" + field57A.getComponent1();
}
if (StringUtil.isNotEmpty(field57A.getComponent2())) {
account = "/" + field57A.getComponent2();
account += "/" + field57A.getComponent2();
}
if (account.startsWith("//RT") || account.startsWith("//FW")) {
clearingChannelRTGSFlag = true;
......@@ -90,14 +94,14 @@ public class Pacs00801Parse57Field extends AbstractMt2MxPacs008001ParseField {
}
mt_to_mxClearingIdentifier(account, clrSysMmbIdMaps);
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, cdtrAgtAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, cdtrAgtAcctMaps, "CdtrAgtAcct/Id");
}
} else if (field57B != null) {
if (StringUtil.isNotEmpty(field57B.getComponent1())) {
account = "/" + field57B.getComponent1();
account += "/" + field57B.getComponent1();
}
if (StringUtil.isNotEmpty(field57B.getComponent2())) {
account = "/" + field57B.getComponent2();
account += "/" + field57B.getComponent2();
}
String location = field57B.getLocation();
Map<String, Object> finInstnIdMaps = null;
......@@ -130,10 +134,13 @@ public class Pacs00801Parse57Field extends AbstractMt2MxPacs008001ParseField {
adrLineList.add(StringUtil.isEmpty(location)?Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE:location);
pstlAdrMaps.put("adrLine", adrLineList);
} else {
mt_to_mxClearingSystemToNameAndAddressLine(account, location, finInstnIdMaps);
mt_to_mxClearingSystemToNameAndAddressLine(account, location, finInstnIdMaps, "CdtrAgt/FinInstnId");
}
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, cdtrAgtAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, cdtrAgtAcctMaps, "CdtrAgtAcct/Id");
if (StringUtil.isEmpty(account)) {
buildSTErrorInfo(ERROR.T20007, "Block4/:57B:", null);
}
//name address 设置NOTPROVIDED
finInstnIdMaps.put("nm", Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE);
Map<String, Object> pstlAdrMaps = null;
......@@ -182,10 +189,10 @@ public class Pacs00801Parse57Field extends AbstractMt2MxPacs008001ParseField {
adrLineList.add(Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE);
pstlAdrMaps.put("adrLine", adrLineList);
} else {
mt_to_mxClearingSystemToNameAndAddressLine(account, null, finInstnIdMaps);
mt_to_mxClearingSystemToNameAndAddressLine(account, null, finInstnIdMaps, "CdtrAgt/FinInstnId");
}
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, cdtrAgtAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, cdtrAgtAcctMaps, "CdtrAgtAcct/Id");
//name address 设置NOTPROVIDED
finInstnIdMaps.put("nm", Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE);
Map<String, Object> pstlAdrMaps = null;
......@@ -201,10 +208,10 @@ public class Pacs00801Parse57Field extends AbstractMt2MxPacs008001ParseField {
}
} else if (field57D != null) {
if (StringUtil.isNotEmpty(field57D.getComponent1())) {
account = "/" + field57D.getComponent1();
account += "/" + field57D.getComponent1();
}
if (StringUtil.isNotEmpty(field57D.getComponent2())) {
account = "/" + field57D.getComponent2();
account += "/" + field57D.getComponent2();
}
if (account.startsWith("//RT")) {
clearingChannelRTGSFlag = true;
......@@ -228,7 +235,7 @@ public class Pacs00801Parse57Field extends AbstractMt2MxPacs008001ParseField {
}
mt_to_mxClearingIdentifier(account, clrSysMmbIdMaps);
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, cdtrAgtAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, cdtrAgtAcctMaps, "CdtrAgtAcct/Id");
}
} else {
String receiverBic = (String) context.get(Mt2MxContextIdentifier.MT_RECEIVE_BIC, true);
......
package com.brilliance.swift.mt2mx.pacs008001.impl;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.Field72;
import com.prowidesoftware.swift.model.mt.AbstractMT;
......@@ -19,6 +21,10 @@ public class Pacs00801Parse72Field extends AbstractMt2MxPacs008001ParseField {
Tag tag = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME);
if (tag != null) {
Field72 field72 = (Field72)tag.asField();
if (StringUtil.isNotEmpty(field72.getValue())
&& (field72.getValue().startsWith("/REJT/") || field72.getValue().startsWith("/RETN/"))) {
buildSTErrorInfo(ERROR.T20063, "Block4/:72:", null);
}
mt72ins_to_mxAgent(field72.getValue(), cdtTrfTxInfMaps);
List<String> excludeCodeList = new ArrayList<>();
excludeCodeList.add("/ACC/");
......
......@@ -83,7 +83,7 @@ public class Pacs00801ParseSetlAcctField extends AbstractMt2MxPacs008001ParseFie
sttlmAcctMaps = new HashMap<>();
sttlmInfMaps.put("sttlmAcct", sttlmAcctMaps);
}
mt_to_mxFinancialInstitutionAccount(account, sttlmAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, sttlmAcctMaps, "SttlmAcct/Id");
}
}
}
......@@ -48,17 +48,17 @@ public class Pacs009001Parse52Field extends AbstractMt2MxPacs009001ParseField {
String bicCode = field52A.getBIC();
mt_to_mxBICFI(bicCode, dbtrMaps);
if (StringUtil.isNotEmpty(field52A.getComponent1())) {
account = "/" + field52A.getComponent1();
account += "/" + field52A.getComponent1();
}
if (StringUtil.isNotEmpty(field52A.getComponent2())) {
account = "/" + field52A.getComponent2();
account += "/" + field52A.getComponent2();
}
} else if (field52D != null) {
if (StringUtil.isNotEmpty(field52D.getComponent1())) {
account = "/" + field52D.getComponent1();
account += "/" + field52D.getComponent1();
}
if (StringUtil.isNotEmpty(field52D.getComponent2())) {
account = "/" + field52D.getComponent2();
account += "/" + field52D.getComponent2();
}
String nameAddress = field52D.getNameAndAddress();
mt_to_mxFinancialInstitutionNameAndUnstructuredAddress(nameAddress, dbtrMaps);
......@@ -84,7 +84,7 @@ public class Pacs009001Parse52Field extends AbstractMt2MxPacs009001ParseField {
}
mt_to_mxClearingIdentifier(account, clrSysMmbIdMaps);
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, dbtrAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, dbtrAcctMaps, "DbtrAcct/Id");
}
}
if (dbtrMaps.size() > 0) {
......
......@@ -95,7 +95,7 @@ public class Pacs009001Parse53Field extends AbstractMt2MxPacs009001ParseField {
}
mt_to_mxClearingIdentifier(account, clrSysMmbIdMaps);
} else {
mt_to_mxFinancialInstitutionAccount(account, instgRmbrsmntAgtAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, instgRmbrsmntAgtAcctMaps, "InstgRmbrsmntAgtAcct/Id");
}
}
}
......
package com.brilliance.swift.mt2mx.pacs009001.impl;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.pacs009001.AbstractMt2MxPacs009001ParseField;
......@@ -67,10 +68,10 @@ public class Pacs009001Parse54Field extends AbstractMt2MxPacs009001ParseField {
String bicCode = field54A.getBIC();
mt_to_mxBICFI(bicCode, instdRmbrsmntAgtMaps);
if (StringUtil.isNotEmpty(field54A.getComponent1())) {
account = "/" + field54A.getComponent1();
account += "/" + field54A.getComponent1();
}
if (StringUtil.isNotEmpty(field54A.getComponent2())) {
account = "/" + field54A.getComponent2();
account += "/" + field54A.getComponent2();
}
if (account.startsWith("//") && !account.startsWith("//CH")) {
Map<String, Object> finInstnIdMaps = null;
......@@ -89,14 +90,14 @@ public class Pacs009001Parse54Field extends AbstractMt2MxPacs009001ParseField {
}
mt_to_mxClearingIdentifier(account, clrSysMmbIdMaps);
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, instdRmbrsmntAgtAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, instdRmbrsmntAgtAcctMaps, "InstdRmbrsmntAgtAcct/Id");
}
} else if (field54B != null) {
if (StringUtil.isNotEmpty(field54B.getComponent1())) {
account = "/" + field54B.getComponent1();
account += "/" + field54B.getComponent1();
}
if (StringUtil.isNotEmpty(field54B.getComponent2())) {
account = "/" + field54B.getComponent2();
account += "/" + field54B.getComponent2();
}
String location = field54B.getLocation();
Map<String, Object> finInstnIdMaps = null;
......@@ -129,10 +130,13 @@ public class Pacs009001Parse54Field extends AbstractMt2MxPacs009001ParseField {
adrLineList.add(StringUtil.isEmpty(location)?Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE:location);
pstlAdrMaps.put("adrLine", adrLineList);
} else {
mt_to_mxClearingSystemToNameAndAddressLine(account, location, finInstnIdMaps);
mt_to_mxClearingSystemToNameAndAddressLine(account, location, finInstnIdMaps, "InstdRmbrsmntAgt/FinInstnId");
}
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, instdRmbrsmntAgtAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, instdRmbrsmntAgtAcctMaps, "InstdRmbrsmntAgtAcct/Id");
if (StringUtil.isEmpty(account)) {
buildSTErrorInfo(ERROR.T20004, "Block4/:54B:", null);
}
//name address 设置NOTPROVIDED
finInstnIdMaps.put("nm", Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE);
Map<String, Object> pstlAdrMaps = null;
......@@ -148,10 +152,10 @@ public class Pacs009001Parse54Field extends AbstractMt2MxPacs009001ParseField {
}
} else if (field54D != null) {
if (StringUtil.isNotEmpty(field54D.getComponent1())) {
account = "/" + field54D.getComponent1();
account += "/" + field54D.getComponent1();
}
if (StringUtil.isNotEmpty(field54D.getComponent2())) {
account = "/" + field54D.getComponent2();
account += "/" + field54D.getComponent2();
}
String nameAddress = field54D.getNameAndAddress();
mt_to_mxFinancialInstitutionNameAndUnstructuredAddress(nameAddress, instdRmbrsmntAgtMaps);
......@@ -172,7 +176,7 @@ public class Pacs009001Parse54Field extends AbstractMt2MxPacs009001ParseField {
}
mt_to_mxClearingIdentifier(account, clrSysMmbIdMaps);
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, instdRmbrsmntAgtAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, instdRmbrsmntAgtAcctMaps, "InstdRmbrsmntAgtAcct/Id");
}
}
if (instdRmbrsmntAgtMaps.size() > 0) {
......
......@@ -50,10 +50,10 @@ public class Pacs009001Parse56Field extends AbstractMt2MxPacs009001ParseField {
String bicCode = field56A.getBIC();
mt_to_mxBICFI(bicCode, intrmyAgt1Maps);
if (StringUtil.isNotEmpty(field56A.getComponent1())) {
account = "/" + field56A.getComponent1();
account += "/" + field56A.getComponent1();
}
if (StringUtil.isNotEmpty(field56A.getComponent2())) {
account = "/" + field56A.getComponent2();
account += "/" + field56A.getComponent2();
}
if (account.startsWith("//RT") || account.startsWith("//FW")) {
clearingChannelRTGSFlag = true;
......@@ -75,14 +75,14 @@ public class Pacs009001Parse56Field extends AbstractMt2MxPacs009001ParseField {
}
mt_to_mxClearingIdentifier(account, clrSysMmbIdMaps);
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, intrmyAgt1AcctMaps);
mt_to_mxFinancialInstitutionAccount(account, intrmyAgt1AcctMaps, "IntrmyAgt1Acct/Id");
}
} else if (field56D != null) {
if (StringUtil.isNotEmpty(field56D.getComponent1())) {
account = "/" + field56D.getComponent1();
account += "/" + field56D.getComponent1();
}
if (StringUtil.isNotEmpty(field56D.getComponent2())) {
account = "/" + field56D.getComponent2();
account += "/" + field56D.getComponent2();
}
if (account.startsWith("//RT")) {
clearingChannelRTGSFlag = true;
......@@ -106,7 +106,7 @@ public class Pacs009001Parse56Field extends AbstractMt2MxPacs009001ParseField {
}
mt_to_mxClearingIdentifier(account, clrSysMmbIdMaps);
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, intrmyAgt1AcctMaps);
mt_to_mxFinancialInstitutionAccount(account, intrmyAgt1AcctMaps, "IntrmyAgt1Acct/Id");
}
}
if (intrmyAgt1Maps.size() > 0) {
......
package com.brilliance.swift.mt2mx.pacs009001.impl;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.pacs009001.AbstractMt2MxPacs009001ParseField;
......@@ -61,10 +62,10 @@ public class Pacs009001Parse57Field extends AbstractMt2MxPacs009001ParseField {
String bicCode = field57A.getBIC();
mt_to_mxBICFI(bicCode, cdtrAgtMaps);
if (StringUtil.isNotEmpty(field57A.getComponent1())) {
account = "/" + field57A.getComponent1();
account += "/" + field57A.getComponent1();
}
if (StringUtil.isNotEmpty(field57A.getComponent2())) {
account = "/" + field57A.getComponent2();
account += "/" + field57A.getComponent2();
}
if (account.startsWith("//RT") || account.startsWith("//FW")) {
clearingChannelRTGSFlag = true;
......@@ -86,14 +87,14 @@ public class Pacs009001Parse57Field extends AbstractMt2MxPacs009001ParseField {
}
mt_to_mxClearingIdentifier(account, clrSysMmbIdMaps);
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, cdtrAgtAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, cdtrAgtAcctMaps, "CdtrAgtAcct/Id");
}
} else if (field57B != null) {
if (StringUtil.isNotEmpty(field57B.getComponent1())) {
account = "/" + field57B.getComponent1();
account += "/" + field57B.getComponent1();
}
if (StringUtil.isNotEmpty(field57B.getComponent2())) {
account = "/" + field57B.getComponent2();
account += "/" + field57B.getComponent2();
}
String location = field57B.getLocation();
Map<String, Object> finInstnIdMaps = null;
......@@ -126,10 +127,13 @@ public class Pacs009001Parse57Field extends AbstractMt2MxPacs009001ParseField {
adrLineList.add(StringUtil.isEmpty(location)?Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE:location);
pstlAdrMaps.put("adrLine", adrLineList);
} else {
mt_to_mxClearingSystemToNameAndAddressLine(account, location, finInstnIdMaps);
mt_to_mxClearingSystemToNameAndAddressLine(account, location, finInstnIdMaps, "CdtrAgt/FinInstnId");
}
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, cdtrAgtAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, cdtrAgtAcctMaps, "CdtrAgtAcct/Id");
if (StringUtil.isEmpty(account)) {
buildSTErrorInfo(ERROR.T20007, "Block4/:57B:", null);
}
//name address 设置NOTPROVIDED
finInstnIdMaps.put("nm", Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE);
Map<String, Object> pstlAdrMaps = null;
......@@ -145,10 +149,10 @@ public class Pacs009001Parse57Field extends AbstractMt2MxPacs009001ParseField {
}
} else if (field57D != null) {
if (StringUtil.isNotEmpty(field57D.getComponent1())) {
account = "/" + field57D.getComponent1();
account += "/" + field57D.getComponent1();
}
if (StringUtil.isNotEmpty(field57D.getComponent2())) {
account = "/" + field57D.getComponent2();
account += "/" + field57D.getComponent2();
}
if (account.startsWith("//RT")) {
clearingChannelRTGSFlag = true;
......@@ -172,7 +176,7 @@ public class Pacs009001Parse57Field extends AbstractMt2MxPacs009001ParseField {
}
mt_to_mxClearingIdentifier(account, clrSysMmbIdMaps);
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, cdtrAgtAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, cdtrAgtAcctMaps, "CdtrAgtAcct/Id");
}
}
if (cdtrAgtMaps.size() > 0) {
......
......@@ -48,10 +48,10 @@ public class Pacs009001Parse58Field extends AbstractMt2MxPacs009001ParseField {
String bicCode = field58A.getBIC();
mt_to_mxBICFI(bicCode, cdtrMaps);
if (StringUtil.isNotEmpty(field58A.getComponent1())) {
account = "/" + field58A.getComponent1();
account += "/" + field58A.getComponent1();
}
if (StringUtil.isNotEmpty(field58A.getComponent2())) {
account = "/" + field58A.getComponent2();
account += "/" + field58A.getComponent2();
}
if (account.startsWith("//RT") || account.startsWith("//FW")) {
clearingChannelRTGSFlag = true;
......@@ -73,14 +73,14 @@ public class Pacs009001Parse58Field extends AbstractMt2MxPacs009001ParseField {
}
mt_to_mxClearingIdentifier(account, clrSysMmbIdMaps);
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, cdtrAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, cdtrAcctMaps, "CdtrAcct/Id");
}
} else if (field58D != null) {
if (StringUtil.isNotEmpty(field58D.getComponent1())) {
account = "/" + field58D.getComponent1();
account += "/" + field58D.getComponent1();
}
if (StringUtil.isNotEmpty(field58D.getComponent2())) {
account = "/" + field58D.getComponent2();
account += "/" + field58D.getComponent2();
}
if (account.startsWith("//RT")) {
clearingChannelRTGSFlag = true;
......@@ -104,7 +104,7 @@ public class Pacs009001Parse58Field extends AbstractMt2MxPacs009001ParseField {
}
mt_to_mxClearingIdentifier(account, clrSysMmbIdMaps);
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, cdtrAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, cdtrAcctMaps, "CdtrAcct/Id");
}
}
if (cdtrMaps.size() > 0) {
......
......@@ -65,17 +65,17 @@ public class Pacs009001ParseSeqB52Field extends AbstractMt2MxPacs009001ParseFiel
String bicCode = field52A.getBIC();
mt_to_mxBICFI(bicCode, dbtrAgtMaps);
if (StringUtil.isNotEmpty(field52A.getComponent1())) {
account = "/" + field52A.getComponent1();
account += "/" + field52A.getComponent1();
}
if (StringUtil.isNotEmpty(field52A.getComponent2())) {
account = "/" + field52A.getComponent2();
account += "/" + field52A.getComponent2();
}
} else if (field52D != null) {
if (StringUtil.isNotEmpty(field52D.getComponent1())) {
account = "/" + field52D.getComponent1();
account += "/" + field52D.getComponent1();
}
if (StringUtil.isNotEmpty(field52D.getComponent2())) {
account = "/" + field52D.getComponent2();
account += "/" + field52D.getComponent2();
}
String nameAddress = field52D.getNameAndAddress();
mt_to_mxFinancialInstitutionNameAndUnstructuredAddress(nameAddress, dbtrAgtMaps);
......@@ -101,7 +101,7 @@ public class Pacs009001ParseSeqB52Field extends AbstractMt2MxPacs009001ParseFiel
}
mt_to_mxClearingIdentifier(account, clrSysMmbIdMaps);
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, dbtrAgtAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, dbtrAgtAcctMaps, "DbtrAgtAcct/Id");
}
}
if (dbtrAgtMaps.size() > 0) {
......
......@@ -63,10 +63,10 @@ public class Pacs009001ParseSeqB56Field extends AbstractMt2MxPacs009001ParseFiel
String bicCode = field56A.getBIC();
mt_to_mxBICFI(bicCode, intrmyAgt1Maps);
if (StringUtil.isNotEmpty(field56A.getComponent1())) {
account = "/" + field56A.getComponent1();
account += "/" + field56A.getComponent1();
}
if (StringUtil.isNotEmpty(field56A.getComponent2())) {
account = "/" + field56A.getComponent2();
account += "/" + field56A.getComponent2();
}
if (account.startsWith("//") && !account.startsWith("//CH") && !account.startsWith("//FW") && !account.startsWith("//RT")) {
Map<String, Object> finInstnIdMaps = null;
......@@ -85,7 +85,7 @@ public class Pacs009001ParseSeqB56Field extends AbstractMt2MxPacs009001ParseFiel
}
mt_to_mxClearingIdentifier(account, clrSysMmbIdMaps);
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, intrmyAgt1AcctMaps);
mt_to_mxFinancialInstitutionAccount(account, intrmyAgt1AcctMaps, "IntrmyAgt1Acct/Id");
}
} else if (field56C != null) {
account = field56C.getValue();
......@@ -119,10 +119,10 @@ public class Pacs009001ParseSeqB56Field extends AbstractMt2MxPacs009001ParseFiel
adrLineList.add(Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE);
pstlAdrMaps.put("adrLine", adrLineList);
} else {
mt_to_mxClearingSystemToNameAndAddressLine(account, null, finInstnIdMaps);
mt_to_mxClearingSystemToNameAndAddressLine(account, null, finInstnIdMaps, "IntrmyAgt1/FinInstnId");
}
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, intrmyAgt1AcctMaps);
mt_to_mxFinancialInstitutionAccount(account, intrmyAgt1AcctMaps, "IntrmyAgt1Acct/Id");
//name address 设置NOTPROVIDED
finInstnIdMaps.put("nm", Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE);
Map<String, Object> pstlAdrMaps = null;
......@@ -138,10 +138,10 @@ public class Pacs009001ParseSeqB56Field extends AbstractMt2MxPacs009001ParseFiel
}
} else if (field56D != null) {
if (StringUtil.isNotEmpty(field56D.getComponent1())) {
account = "/" + field56D.getComponent1();
account += "/" + field56D.getComponent1();
}
if (StringUtil.isNotEmpty(field56D.getComponent2())) {
account = "/" + field56D.getComponent2();
account += "/" + field56D.getComponent2();
}
String nameAddress = field56D.getNameAndAddress();
mt_to_mxFinancialInstitutionNameAndUnstructuredAddress(nameAddress, intrmyAgt1Maps);
......@@ -162,7 +162,7 @@ public class Pacs009001ParseSeqB56Field extends AbstractMt2MxPacs009001ParseFiel
}
mt_to_mxClearingIdentifier(account, clrSysMmbIdMaps);
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, intrmyAgt1AcctMaps);
mt_to_mxFinancialInstitutionAccount(account, intrmyAgt1AcctMaps, "IntrmyAgt1Acct/Id");
}
}
if (intrmyAgt1Maps.size() > 0) {
......
package com.brilliance.swift.mt2mx.pacs009001.impl;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.pacs009001.AbstractMt2MxPacs009001ParseField;
......@@ -71,10 +72,10 @@ public class Pacs009001ParseSeqB57Field extends AbstractMt2MxPacs009001ParseFiel
String bicCode = field57A.getBIC();
mt_to_mxBICFI(bicCode, cdtrAgtMaps);
if (StringUtil.isNotEmpty(field57A.getComponent1())) {
account = "/" + field57A.getComponent1();
account += "/" + field57A.getComponent1();
}
if (StringUtil.isNotEmpty(field57A.getComponent2())) {
account = "/" + field57A.getComponent2();
account += "/" + field57A.getComponent2();
}
if (account.startsWith("//") && !account.startsWith("//CH") && !account.startsWith("//FW") && !account.startsWith("//RT")) {
Map<String, Object> finInstnIdMaps = null;
......@@ -93,14 +94,14 @@ public class Pacs009001ParseSeqB57Field extends AbstractMt2MxPacs009001ParseFiel
}
mt_to_mxClearingIdentifier(account, clrSysMmbIdMaps);
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, cdtrAgtAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, cdtrAgtAcctMaps, "CdtrAgtAcct/Id");
}
} else if (field57B != null) {
if (StringUtil.isNotEmpty(field57B.getComponent1())) {
account = "/" + field57B.getComponent1();
account += "/" + field57B.getComponent1();
}
if (StringUtil.isNotEmpty(field57B.getComponent2())) {
account = "/" + field57B.getComponent2();
account += "/" + field57B.getComponent2();
}
String location = field57B.getLocation();
Map<String, Object> finInstnIdMaps = null;
......@@ -133,10 +134,10 @@ public class Pacs009001ParseSeqB57Field extends AbstractMt2MxPacs009001ParseFiel
adrLineList.add(StringUtil.isEmpty(location)?Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE:location);
pstlAdrMaps.put("adrLine", adrLineList);
} else {
mt_to_mxClearingSystemToNameAndAddressLine(account, location, finInstnIdMaps);
mt_to_mxClearingSystemToNameAndAddressLine(account, location, finInstnIdMaps, "CdtrAgt/FinInstnId");
}
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, cdtrAgtAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, cdtrAgtAcctMaps, "CdtrAgtAcct/Id");
//name address 设置NOTPROVIDED
finInstnIdMaps.put("nm", Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE);
Map<String, Object> pstlAdrMaps = null;
......@@ -182,10 +183,13 @@ public class Pacs009001ParseSeqB57Field extends AbstractMt2MxPacs009001ParseFiel
adrLineList.add(Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE);
pstlAdrMaps.put("adrLine", adrLineList);
} else {
mt_to_mxClearingSystemToNameAndAddressLine(account, null, finInstnIdMaps);
mt_to_mxClearingSystemToNameAndAddressLine(account, null, finInstnIdMaps, "CdtrAgt/FinInstnId");
}
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, cdtrAgtAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, cdtrAgtAcctMaps, "CdtrAgtAcct/Id");
if (StringUtil.isEmpty(account)) {
buildSTErrorInfo(ERROR.T20007, "Block4/SeqB/:57B:", null);
}
//name address 设置NOTPROVIDED
finInstnIdMaps.put("nm", Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE);
Map<String, Object> pstlAdrMaps = null;
......@@ -201,10 +205,10 @@ public class Pacs009001ParseSeqB57Field extends AbstractMt2MxPacs009001ParseFiel
}
} else if (field57D != null) {
if (StringUtil.isNotEmpty(field57D.getComponent1())) {
account = "/" + field57D.getComponent1();
account += "/" + field57D.getComponent1();
}
if (StringUtil.isNotEmpty(field57D.getComponent2())) {
account = "/" + field57D.getComponent2();
account += "/" + field57D.getComponent2();
}
String nameAddress = field57D.getNameAndAddress();
mt_to_mxFinancialInstitutionNameAndUnstructuredAddress(nameAddress, cdtrAgtMaps);
......@@ -225,7 +229,7 @@ public class Pacs009001ParseSeqB57Field extends AbstractMt2MxPacs009001ParseFiel
}
mt_to_mxClearingIdentifier(account, clrSysMmbIdMaps);
} else if (!account.startsWith("//") || account.startsWith("//CH")) {
mt_to_mxFinancialInstitutionAccount(account, cdtrAgtAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, cdtrAgtAcctMaps, "CdtrAgtAcct/Id");
}
}
if (cdtrAgtMaps.size() > 0) {
......
......@@ -83,7 +83,7 @@ public class Pacs009001ParseSetlAcctField extends AbstractMt2MxPacs009001ParseFi
sttlmAcctMaps = new HashMap<>();
sttlmInfMaps.put("sttlmAcct", sttlmAcctMaps);
}
mt_to_mxFinancialInstitutionAccount(account, sttlmAcctMaps);
mt_to_mxFinancialInstitutionAccount(account, sttlmAcctMaps, "SttlmAcct/Id");
}
}
}
package com.brilliance.swift.mt2mx.setlmtd;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.Mt2MxContext;
import com.brilliance.swift.util.SwiftTransferUtil;
import com.brilliance.swift.vo.SwiftTranslationErrorInfo;
import com.brilliance.swift.vo.SwiftTranslationReport;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.Field;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.util.List;
public abstract class AbstractSettlementMethodAnalyzer implements SettlementMethodAnalyzer{
......@@ -37,4 +46,49 @@ public abstract class AbstractSettlementMethodAnalyzer implements SettlementMeth
this.field54 = field54;
return this;
}
/**
* 封装报文转换详细报告
* @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);
List<SwiftTranslationErrorInfo> errorInfos = str.getErrorInfos();
boolean existFlag = false;
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());
}
}
}
protected Boolean exist55a() {
AbstractMT abstractMT = context.get(AbstractMT.class);
Tag tag = abstractMT.getSwiftMessage().getBlock4().getTagByName("55A");
if (tag != null) {
return true;
}
tag = abstractMT.getSwiftMessage().getBlock4().getTagByName("55B");
if (tag != null) {
return true;
}
tag = abstractMT.getSwiftMessage().getBlock4().getTagByName("55D");
if (tag != null) {
return true;
}
return false;
}
}
package com.brilliance.swift.mt2mx.setlmtd.impl;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.mt2mx.Mt2MxContextIdentifier;
import com.brilliance.swift.mt2mx.setlmtd.AbstractSettlementMethodAnalyzer;
import com.brilliance.swift.util.StringUtil;
......@@ -34,6 +35,11 @@ public class Field53A54AAnalyzer extends AbstractSettlementMethodAnalyzer {
String receiveBic = (String) context.get(Mt2MxContextIdentifier.MT_RECEIVE_BIC, true);
if (field53BicCode.equals(sendBic) && field54BicCode.equals(receiveBic)) {
seltMtdHelper.setSettlementMethod("INDA");
buildSTErrorInfo(ERROR.T20009, "Block4/:53A:", null);
buildSTErrorInfo(ERROR.T20010, "Block4/:54A:", null);
if (exist55a()) {
buildSTErrorInfo(ERROR.T20008, "Block4/:55a:", null);
}
} else if (StringUtil.isNotEmpty(sendBic)
&& field53BicCode.substring(0, 6).equals(sendBic.substring(0, 6))
&& SwiftTransferUtil.isAccount(account)) {
......@@ -43,10 +49,17 @@ public class Field53A54AAnalyzer extends AbstractSettlementMethodAnalyzer {
seltMtdHelper.setSettlementMethod("INDA");
}
seltMtdHelper.setTranslateSetlAcctFlag(true);
buildSTErrorInfo(ERROR.T20071, "Block4/:53A:", null);
buildSTErrorInfo(ERROR.T20018, "Block4/:54A:", null);
if (exist55a()) {
buildSTErrorInfo(ERROR.T20008, "Block4/:55a:", null);
}
} else {
AbstractMT abstractMT = context.get(AbstractMT.class);
if (abstractMT.getSwiftMessage().isCOV()) {
seltMtdHelper.setSettlementMethod("INDA");
buildSTErrorInfo(ERROR.T20024, "Block4/:53A:", null);
buildSTErrorInfo(ERROR.T20023, "Block4/:54A:", null);
} else {
seltMtdHelper.setSettlementMethod("COVE");
seltMtdHelper.setTranslate53Flag(true);
......
package com.brilliance.swift.mt2mx.setlmtd.impl;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.mt2mx.Mt2MxContextIdentifier;
import com.brilliance.swift.mt2mx.setlmtd.AbstractSettlementMethodAnalyzer;
import com.brilliance.swift.util.StringUtil;
......@@ -31,10 +32,17 @@ public class Field53A54BAnalyzer extends AbstractSettlementMethodAnalyzer {
seltMtdHelper.setSettlementMethod("INDA");
}
seltMtdHelper.setTranslateSetlAcctFlag(true);
buildSTErrorInfo(ERROR.T20071, "Block4/:53A:", null);
buildSTErrorInfo(ERROR.T20023, "Block4/:54B:", null);
if (exist55a()) {
buildSTErrorInfo(ERROR.T20008, "Block4/:55a:", null);
}
} else {
AbstractMT abstractMT = context.get(AbstractMT.class);
if (abstractMT.getSwiftMessage().isCOV()) {
seltMtdHelper.setSettlementMethod("INDA");
buildSTErrorInfo(ERROR.T20024, "Block4/:53A:", null);
buildSTErrorInfo(ERROR.T20023, "Block4/:54B:", null);
} else {
seltMtdHelper.setSettlementMethod("COVE");
seltMtdHelper.setTranslate53Flag(true);
......
package com.brilliance.swift.mt2mx.setlmtd.impl;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.mt2mx.Mt2MxContextIdentifier;
import com.brilliance.swift.mt2mx.setlmtd.AbstractSettlementMethodAnalyzer;
import com.brilliance.swift.util.StringUtil;
......@@ -31,10 +32,17 @@ public class Field53A54DAnalyzer extends AbstractSettlementMethodAnalyzer {
seltMtdHelper.setSettlementMethod("INDA");
}
seltMtdHelper.setTranslateSetlAcctFlag(true);
buildSTErrorInfo(ERROR.T20071, "Block4/:53A:", null);
buildSTErrorInfo(ERROR.T20023, "Block4/:54D:", null);
if (exist55a()) {
buildSTErrorInfo(ERROR.T20008, "Block4/:55a:", null);
}
} else {
AbstractMT abstractMT = context.get(AbstractMT.class);
if (abstractMT.getSwiftMessage().isCOV()) {
seltMtdHelper.setSettlementMethod("INDA");
buildSTErrorInfo(ERROR.T20024, "Block4/:53A:", null);
buildSTErrorInfo(ERROR.T20023, "Block4/:54D:", null);
} else {
seltMtdHelper.setSettlementMethod("COVE");
seltMtdHelper.setTranslate53Flag(true);
......
package com.brilliance.swift.mt2mx.setlmtd.impl;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.mt2mx.setlmtd.AbstractSettlementMethodAnalyzer;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.SwiftTransferUtil;
......@@ -25,8 +26,16 @@ public class Field53B54aAnalyzer extends AbstractSettlementMethodAnalyzer {
seltMtdHelper.setSettlementMethod("INDA");
}
seltMtdHelper.setTranslateSetlAcctFlag(true);
if (StringUtil.isNotEmpty(field53B.getLocation())) {
buildSTErrorInfo(ERROR.T20070, "Block4/:53B:", null);
}
} else {
seltMtdHelper.setSettlementMethod("INDA");
buildSTErrorInfo(ERROR.T20001, "Block4/:53B:", null);
}
buildSTErrorInfo(ERROR.T20002, "Block4/:54a:", null);
if (exist55a()) {
buildSTErrorInfo(ERROR.T20008, "Block4/:55a:", null);
}
return seltMtdHelper;
}
......
package com.brilliance.swift.mt2mx.setlmtd.impl;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.mt2mx.setlmtd.AbstractSettlementMethodAnalyzer;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.SwiftTransferUtil;
......@@ -26,10 +27,17 @@ public class Field53D54aAnalyzer extends AbstractSettlementMethodAnalyzer {
seltMtdHelper.setSettlementMethod("INDA");
}
seltMtdHelper.setTranslateSetlAcctFlag(true);
buildSTErrorInfo(ERROR.T20069, "Block4/:53D:", null);
buildSTErrorInfo(ERROR.T20023, "Block4/:54a:", null);
if (exist55a()) {
buildSTErrorInfo(ERROR.T20008, "Block4/:55a:", null);
}
} else {
AbstractMT abstractMT = context.get(AbstractMT.class);
if (abstractMT.getSwiftMessage().isCOV()) {
seltMtdHelper.setSettlementMethod("INDA");
buildSTErrorInfo(ERROR.T20024, "Block4/:53D:", null);
buildSTErrorInfo(ERROR.T20023, "Block4/:54a:", null);
} else {
seltMtdHelper.setSettlementMethod("COVE");
seltMtdHelper.setTranslate53Flag(true);
......
package com.brilliance.swift.mt2mx.setlmtd.impl;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.mt2mx.Mt2MxContextIdentifier;
import com.brilliance.swift.mt2mx.setlmtd.AbstractSettlementMethodAnalyzer;
import com.brilliance.swift.util.StringUtil;
......@@ -29,6 +30,7 @@ public class FieldOnly53AAnalyzer extends AbstractSettlementMethodAnalyzer {
}
seltMtdHelper.setTranslateSetlAcctFlag(true);
seltMtdHelper.setInstructionForNextAgent("/FIN53/"+bicCode);
buildSTErrorInfo(ERROR.T20021, "Block4/:53A:", null);
} else {
String sendBic = (String) context.get(Mt2MxContextIdentifier.MT_SEND_BIC, true);
String receiveBic = (String) context.get(Mt2MxContextIdentifier.MT_RECEIVE_BIC, true);
......@@ -36,10 +38,15 @@ public class FieldOnly53AAnalyzer extends AbstractSettlementMethodAnalyzer {
|| (StringUtil.isNotEmpty(receiveBic) && bicCode.substring(0, 6).equals(receiveBic.substring(0, 6)))) {
seltMtdHelper.setSettlementMethod("INDA");
seltMtdHelper.setInstructionForNextAgent("/FIN53/"+bicCode);
buildSTErrorInfo(ERROR.T20021, "Block4/:53A:", null);
if (StringUtil.isNotEmpty(account)) {
buildSTErrorInfo(ERROR.T20068, "Block4/:53A:", null);
}
} else {
AbstractMT abstractMT = context.get(AbstractMT.class);
if (abstractMT.getSwiftMessage().isCOV()) {
seltMtdHelper.setSettlementMethod("INDA");
buildSTErrorInfo(ERROR.T20024, "Block4/:53A:", null);
} else {
seltMtdHelper.setSettlementMethod("COVE");
seltMtdHelper.setTranslate53Flag(true);
......
package com.brilliance.swift.mt2mx.setlmtd.impl;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.mt2mx.setlmtd.AbstractSettlementMethodAnalyzer;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.SwiftTransferUtil;
......@@ -25,8 +26,12 @@ public class FieldOnly53BAnalyzer extends AbstractSettlementMethodAnalyzer {
seltMtdHelper.setSettlementMethod("INDA");
}
seltMtdHelper.setTranslateSetlAcctFlag(true);
if (StringUtil.isNotEmpty(field53B.getLocation())) {
buildSTErrorInfo(ERROR.T20070, "Block4/:53B:", null);
}
} else {
seltMtdHelper.setSettlementMethod("INDA");
buildSTErrorInfo(ERROR.T20001, "Block4/:53B:", null);
}
return seltMtdHelper;
}
......
package com.brilliance.swift.mt2mx.setlmtd.impl;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.mt2mx.setlmtd.AbstractSettlementMethodAnalyzer;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.SwiftTransferUtil;
......@@ -25,8 +26,10 @@ public class FieldOnly53DAnalyzer extends AbstractSettlementMethodAnalyzer {
seltMtdHelper.setSettlementMethod("INDA");
}
seltMtdHelper.setTranslateSetlAcctFlag(true);
buildSTErrorInfo(ERROR.T20069, "Block4/:53D:", null);
} else {
seltMtdHelper.setSettlementMethod("INDA");
buildSTErrorInfo(ERROR.T20022, "Block4/:53D:", null);
}
return seltMtdHelper;
}
......
package com.brilliance.swift.mt2mx.setlmtd.impl;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.mt2mx.Mt2MxContextIdentifier;
import com.brilliance.swift.mt2mx.setlmtd.AbstractSettlementMethodAnalyzer;
import com.brilliance.swift.util.StringUtil;
......@@ -18,10 +19,12 @@ public class FieldOnly54AAnalyzer extends AbstractSettlementMethodAnalyzer {
if ((StringUtil.isNotEmpty(sendBic) && bicCode.substring(0, 8).equals(sendBic.substring(0, 8)))
|| (StringUtil.isNotEmpty(receiveBic) && bicCode.substring(0, 8).equals(receiveBic.substring(0, 8)))) {
seltMtdHelper.setSettlementMethod("INDA");
buildSTErrorInfo(ERROR.T20010, "Block4/:54A:", null);
} else {
AbstractMT abstractMT = context.get(AbstractMT.class);
if (abstractMT.getSwiftMessage().isCOV()) {
seltMtdHelper.setSettlementMethod("INDA");
buildSTErrorInfo(ERROR.T20023, "Block4/:54A:", null);
} else {
seltMtdHelper.setSettlementMethod("COVE");
seltMtdHelper.setTranslate54Flag(true);
......
package com.brilliance.swift.mt2mx.setlmtd.impl;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.mt2mx.setlmtd.AbstractSettlementMethodAnalyzer;
import com.brilliance.swift.vo.VoSettlementMethodHelper;
import com.prowidesoftware.swift.model.mt.AbstractMT;
......@@ -11,6 +12,7 @@ public class FieldOnly54BAnalyzer extends AbstractSettlementMethodAnalyzer {
AbstractMT abstractMT = context.get(AbstractMT.class);
if (abstractMT.getSwiftMessage().isCOV()) {
seltMtdHelper.setSettlementMethod("INDA");
buildSTErrorInfo(ERROR.T20023, "Block4/:54B:", null);
} else {
seltMtdHelper.setSettlementMethod("COVE");
seltMtdHelper.setTranslate54Flag(true);
......
package com.brilliance.swift.mt2mx.setlmtd.impl;
import com.brilliance.swift.constants.ERROR;
import com.brilliance.swift.mt2mx.setlmtd.AbstractSettlementMethodAnalyzer;
import com.brilliance.swift.vo.VoSettlementMethodHelper;
import com.prowidesoftware.swift.model.mt.AbstractMT;
......@@ -11,6 +12,7 @@ public class FieldOnly54DAnalyzer extends AbstractSettlementMethodAnalyzer {
AbstractMT abstractMT = context.get(AbstractMT.class);
if (abstractMT.getSwiftMessage().isCOV()) {
seltMtdHelper.setSettlementMethod("INDA");
buildSTErrorInfo(ERROR.T20023, "Block4/:54D:", null);
} else {
seltMtdHelper.setSettlementMethod("COVE");
seltMtdHelper.setTranslate54Flag(true);
......
package com.brilliance.mt2mx.camt029001;
import com.brilliance.swift.mt2mx.Mt2MxCreatorManager;
import com.brilliance.swift.SwiftTransfer;
import org.apache.commons.io.FileUtils;
import java.io.File;
......@@ -11,7 +11,7 @@ public class Test196 {
public static void main(String[] args) throws IOException {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftTxt\\Mt196.txt");
String mtStr = FileUtils.readFileToString(file);
String mxXml = new Mt2MxCreatorManager().mt2mx(mtStr, null, null);
String mxXml = SwiftTransfer.mt2Mx(mtStr, "D:/test/mt2mx/camt02900108.xml", null);
System.out.println(mxXml);
}
}
package com.brilliance.mt2mx.camt029001;
import com.brilliance.swift.mt2mx.Mt2MxCreatorManager;
import com.brilliance.swift.SwiftTransfer;
import org.apache.commons.io.FileUtils;
import java.io.File;
......@@ -11,7 +11,7 @@ public class Test296 {
public static void main(String[] args) throws IOException {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftTxt\\Mt296.txt");
String mtStr = FileUtils.readFileToString(file);
String mxXml = new Mt2MxCreatorManager().mt2mx(mtStr, null, null);
String mxXml = SwiftTransfer.mt2Mx(mtStr, "D:/test/mt2mx/camt02900108.xml", null);
System.out.println(mxXml);
}
}
package com.brilliance.mt2mx.camt056001;
import com.brilliance.swift.mt2mx.Mt2MxCreatorManager;
import com.brilliance.swift.SwiftTransfer;
import org.apache.commons.io.FileUtils;
import java.io.File;
......@@ -11,7 +11,7 @@ public class Test192 {
public static void main(String[] args) throws IOException {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftTxt\\Mt192.txt");
String mtStr = FileUtils.readFileToString(file);
String mxXml = new Mt2MxCreatorManager().mt2mx(mtStr, null, null);
String mxXml = SwiftTransfer.mt2Mx(mtStr, "D:/test/mt2mx/camt05600108.xml", null);
System.out.println(mxXml);
}
}
package com.brilliance.mt2mx.camt056001;
import com.brilliance.swift.mt2mx.Mt2MxCreatorManager;
import com.brilliance.swift.SwiftTransfer;
import org.apache.commons.io.FileUtils;
import java.io.File;
......@@ -11,7 +11,7 @@ public class Test292 {
public static void main(String[] args) throws IOException {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftTxt\\Mt292.txt");
String mtStr = FileUtils.readFileToString(file);
String mxXml = new Mt2MxCreatorManager().mt2mx(mtStr, null, null);
String mxXml = SwiftTransfer.mt2Mx(mtStr, "D:/test/mt2mx/camt05600108.xml", null);
System.out.println(mxXml);
}
}
package com.brilliance.mt2mx.pacs008001;
import com.brilliance.swift.mt2mx.Mt2MxCreatorManager;
import com.brilliance.swift.SwiftTransfer;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.SwiftTranslationErrorInfo;
import com.brilliance.swift.vo.SwiftTranslationReport;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
import java.util.List;
public class Test {
public static void main(String[] args) throws IOException {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftTxt\\Mt103.txt");
//File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftTxt\\Mt103.txt");
File file = new File("d:/test/MT103.txt");
String mtStr = FileUtils.readFileToString(file);
String mxXml = new Mt2MxCreatorManager().mt2mx(mtStr, null, null);
System.out.println(mxXml);
/*AbstractMT abstractMT = AbstractMT.parse(mtStr);
MT103 mt103 = (MT103)abstractMT;
Field53A field53A = mt103.getField53A();
System.out.println(field53A.getComponent(1) + field53A.getComponent2());
System.out.println(field53A.getBIC());*/
SwiftTranslationReport str = SwiftTransfer.mt2MxPlus(mtStr, "D:/test/mt2mx/pacs00800108.xml", null);
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);
String originalValue = errorInfo.getOriginalValue();
if (StringUtil.isNotEmpty(originalValue)) {
System.out.println(originalValue);
}
}
}
System.out.println(str.getMessage());
}
}
}
package com.brilliance.mt2mx.pacs009001;
import com.brilliance.swift.mt2mx.Mt2MxCreatorManager;
import com.brilliance.swift.SwiftTransfer;
import org.apache.commons.io.FileUtils;
import java.io.File;
......@@ -11,14 +11,14 @@ public class Test {
private static void test202() throws IOException {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftTxt\\Mt202.txt");
String mtStr = FileUtils.readFileToString(file);
String mxXml = new Mt2MxCreatorManager().mt2mx(mtStr, null, null);
String mxXml = SwiftTransfer.mt2Mx(mtStr, "D:/test/mt2mx/pacs00900108.xml", null);
System.out.println(mxXml);
}
private static void test202Cov() throws IOException {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftTxt\\Mt202_COV.txt");
String mtStr = FileUtils.readFileToString(file);
String mxXml = new Mt2MxCreatorManager().mt2mx(mtStr, null, null);
String mxXml = SwiftTransfer.mt2Mx(mtStr, "D:/test/mt2mx/pacs00900108.xml", null);
System.out.println(mxXml);
}
......
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