Commit fc76d9fb by chengzhuoshen

mt103rejt,mt202rejt转pacs002

parent 4d0c20e9
......@@ -7,6 +7,7 @@ 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.MxMtReasonCodeInfo;
import com.brilliance.swift.vo.SwiftTranslationErrorInfo;
import com.brilliance.swift.vo.SwiftTranslationReport;
import com.brilliance.swift.vo.VoSettlementMethodHelper;
......@@ -1893,6 +1894,121 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
cxlRsnInfMaps.put("addtlInf",addtlInfJSONArray);
addtlInfJSONArray.addAll(list);
}
protected void mt_to_mxReject72(String mt72, Map<String, Object> maps) {
if (StringUtil.isEmpty(mt72)) {
return;
}
JSONArray stsRsnInfJsonArray = null;
if (maps.containsKey("stsRsnInf")) {
stsRsnInfJsonArray = (JSONArray)maps.get("stsRsnInf");
} else {
stsRsnInfJsonArray = new JSONArray();
}
Map<String, Object> stsRsnInfMap = new HashMap<>();
String mxReasonCodeOrProprietary = "";
String additionalInformation = "";
int maxLength = 0;
String mtReasonCode = "";
String[] mt72s = mt72.split(Mx2MtConstants.NEW_LINE);
String line2 = "";
if (mt72s.length >= 2) {
line2 = mt72s[1];
}
String regex = "/XT99/(.*)/(.*)";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(line2);
if (m.find()) {
mxReasonCodeOrProprietary = m.group(1);
additionalInformation = m.group(2);
maxLength = 35 - 6 - mxReasonCodeOrProprietary.length() - 1;
} else {
regex = "/([0-9A-Z]{2}[0-9]{2})/(.*)";
p = Pattern.compile(regex);
m = p.matcher(line2);
if (m.find()) {
mtReasonCode = m.group(1);
additionalInformation = m.group(2);
maxLength = 29;
}
}
String line6 = "";
String refreshMt72 = refreshValue(mt72, "//", 35).replace(Mx2MtConstants.NEW_LINE + "//", "");
String[] refreshMt72s = refreshMt72.split(Mx2MtConstants.NEW_LINE);
for (int i=0; i<refreshMt72s.length; i++) {
if (refreshMt72s[i].startsWith("/TEXT/")) {
line6 = refreshMt72s[i].substring(6);
break;
}
}
if (line6.length() > 0) {
if (additionalInformation.length() > 0) {
if (additionalInformation.length() < maxLength) {
additionalInformation += " " + line6;
} else {
additionalInformation += line6;
}
} else {
additionalInformation = line6;
}
}
if (additionalInformation.length() > 0) {
if (additionalInformation.length() > 210) {
buildSTErrorInfo(ERROR.T0000T, "TxInfAndSts/StsRsnInf/AddtlInf", additionalInformation);
additionalInformation = additionalInformation.substring(0, 209) + "+";
}
List<String> list = new ArrayList<>();
if (additionalInformation.length() > 105) {
String addInf1 = additionalInformation.substring(0, 105);
String addInf2 = additionalInformation.substring(105);
list.add(addInf1);
list.add(addInf2);
} else {
list.add(additionalInformation);
}
stsRsnInfMap.put("addtlInf", list);
}
Map<String, Object> rsnMaps = new HashMap<>();
if (mxReasonCodeOrProprietary.length() > 0) {
StatusReasonCode code = SwiftTransferUtil.getStatusReasonCodeByCode(mxReasonCodeOrProprietary);
if (code != null) {
rsnMaps.put("cd", mxReasonCodeOrProprietary);
} else {
rsnMaps.put("prtry", mxReasonCodeOrProprietary);
}
} else if (mtReasonCode.length() > 0) {
List<MxMtReasonCodeInfo> mxMtReasonCodeInfos = SwiftTransferUtil.getMxMtReasonCodes();
String mxReasonCode = "";
boolean isMxErrorCodePresent = false;
if (mxMtReasonCodeInfos != null && mxMtReasonCodeInfos.size() > 0) {
for (int i=0; i<mxMtReasonCodeInfos.size(); i++) {
MxMtReasonCodeInfo mxMtReasonCodeInfo = mxMtReasonCodeInfos.get(i);
if (mtReasonCode.equals(mxMtReasonCodeInfo.getMtCode())) {
isMxErrorCodePresent = mxMtReasonCodeInfo.isMxErrorCodePresent();
mxReasonCode = mxMtReasonCodeInfo.getIsoCode();
break;
}
}
}
if (isMxErrorCodePresent) {
rsnMaps.put("cd", mxReasonCode);
} else {
rsnMaps.put("prtry", mtReasonCode);
}
} else {
rsnMaps.put("cd", StatusReasonCode.NARR.value());
}
if (rsnMaps.size() > 0) {
stsRsnInfMap.put("rsn", rsnMaps);
}
if (stsRsnInfMap.size() > 0) {
stsRsnInfJsonArray.add(stsRsnInfMap);
}
if (stsRsnInfJsonArray.size() > 0) {
maps.put("stsRsnInf", stsRsnInfJsonArray);
}
}
/**
* MT 转 MX 转换函数结束
*/
......
......@@ -4,6 +4,7 @@ import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.camt029001.Mt2MxCamt029001Creator;
import com.brilliance.swift.mt2mx.camt054001.Mt2MxCamt054001Creator;
import com.brilliance.swift.mt2mx.camt056001.Mt2MxCamt056001Creator;
import com.brilliance.swift.mt2mx.pacs002001.Mt2MxPacs002001Creator;
import com.brilliance.swift.mt2mx.pacs008001.Mt2MxPacs008001Creator;
import com.brilliance.swift.mt2mx.pacs009001.Mt2MxPacs009001Creator;
import com.brilliance.swift.util.StringUtil;
......@@ -48,13 +49,13 @@ public class Mt2MxCreatorManager {
}
public AbstractMt2MxCreator getMt2MxCreator() throws SwiftException {
String messageType = abstractMT.getMessageType();
String messageType = processMessageType(abstractMT.getMessageType());
if ("103".equals(messageType)) {
return new Mt2MxPacs008001Creator();
} else if ("202".equals(messageType) || "205".equals(messageType)) {
return new Mt2MxPacs009001Creator();
} else if ("103REJT".equals(messageType) || "202REJT".equals(messageType) || "205REJT".equals(messageType)) {
return new Mt2MxPacs009001Creator();
return new Mt2MxPacs002001Creator();
} else if ("103RETN".equals(messageType) || "202RETN".equals(messageType) || "205RETN".equals(messageType)) {
return new Mt2MxPacs009001Creator();
} else if("196".equals(messageType) || "296".equals(messageType)) {
......
......@@ -23,6 +23,7 @@ public class Mt2MxPacs002001Creator extends AbstractMt2MxCreator {
jsonMaps.put("identifier", "pacs.002.001.10");
Map<String, Object> appHdrMaps = (Map<String, Object>)jsonMaps.get("appHdr");
appHdrMaps.put("msgDefIdr", "pacs.002.001.10");
appHdrMaps.put("bizSvc", "swift.cbprplus.02");
AbstractMT abstractMT = context.get(AbstractMT.class);
//初始化转换和不需要BLOCK4的转换
......@@ -58,7 +59,7 @@ public class Mt2MxPacs002001Creator extends AbstractMt2MxCreator {
Map<String, Object> orgnlGrpInfMaps = new HashMap<>();
String messageType = "MT" + abstractMT.getMessageType();
if (abstractMT.getSwiftMessage().isCOV()) {
messageType += "COVE";
messageType += " COVE";
}
orgnlGrpInfMaps.put("orgnlMsgNmId", messageType);
txInfAndStsMaps.put("orgnlGrpInf", orgnlGrpInfMaps);
......
......@@ -15,6 +15,7 @@ public class Pacs002001Parse20Field extends AbstractMt2MxPacs002001ParseField {
Tag tag20 = abstractMT.getSwiftMessage().getBlock4().getTagByName(NAME);
if (tag20 != null) {
grpHdrMaps.put("msgId", tag20.getValue());
appHdrMaps.put("bizMsgIdr", tag20.getValue());
}
}
}
package com.brilliance.swift.mt2mx.pacs002001.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.mt2mx.pacs002001.AbstractMt2MxPacs002001ParseField;
import com.brilliance.swift.vo.common.PaymentTransactionStatusCode;
import com.prowidesoftware.swift.model.SwiftTagListBlock;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.util.HashMap;
import java.util.Map;
public class Pacs002001Parse72Field extends AbstractMt2MxPacs002001ParseField {
@Override
public void parseField() {
Tag tag72 = null;
AbstractMT abstractMT = context.get(AbstractMT.class);
boolean isCov = abstractMT.getSwiftMessage().isCOV();
if (isCov) {
SwiftTagListBlock swiftTagListBlock = abstractMT.getSequence("A");
if (swiftTagListBlock != null) {
tag72 = swiftTagListBlock.getTagByName("72");
}
} else {
tag72 = abstractMT.getSwiftMessage().getBlock4().getTagByName("72");
}
if (tag72 != null) {
txInfAndStsMaps.put("txSts", PaymentTransactionStatusCode.RJCT.value());
String mt72 = tag72.getValue();
String[] mt72s = mt72.split(Mx2MtConstants.NEW_LINE);
String mRef = "";
String tRef = "";
for (String value : mt72s) {
if (value.startsWith("/MREF/")) {
mRef = value.substring(6);
}
if (value.startsWith("/TREF/")) {
tRef = value.substring(6);
}
}
Map<String, Object> orgnlGrpInfMaps = null;
if (txInfAndStsMaps.containsKey("orgnlGrpInf")) {
orgnlGrpInfMaps = (Map<String, Object>)txInfAndStsMaps.get("orgnlGrpInf");
} else {
orgnlGrpInfMaps = new HashMap<>();
txInfAndStsMaps.put("orgnlGrpInf", orgnlGrpInfMaps);
}
if (mRef.length() > 0) {
orgnlGrpInfMaps.put("orgnlMsgId", mRef);
txInfAndStsMaps.put("orgnlInstrId", mRef);
} else {
orgnlGrpInfMaps.put("orgnlMsgId", Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE);
txInfAndStsMaps.put("orgnlInstrId", Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE);
}
if ("103".equals(abstractMT.getMessageType())) {
if (tRef.length() > 0) {
txInfAndStsMaps.put("orgnlEndToEndId", tRef);
} else {
txInfAndStsMaps.put("orgnlEndToEndId", Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE);
}
}
mt_to_mxReject72(mt72, txInfAndStsMaps);
}
}
}
......@@ -695,6 +695,21 @@ public class SwiftTransferUtil {
}
/**
* 根据mxcode取StatusReasonCode
*/
public static StatusReasonCode getStatusReasonCodeByCode(String mxCode) {
StatusReasonCode code = null;
StatusReasonCode[] values = StatusReasonCode.values();
for (StatusReasonCode tmpCode : values) {
if (tmpCode.value().equals(mxCode)) {
code = tmpCode;
break;
}
}
return code;
}
/**
* 根据ErrorCodesRETNREJT.xlsx文件返回
* List<MxMtReasonCodeInfo>
*/
......
package com.brilliance.swift.vo.common;
public enum StatusReasonCode {
AB01("AbortedClearingTimeout"),
AB02("AbortedClearingFatalError"),
AB03("AbortedSettlementTimeout"),
AB04("AbortedSettlementFatalError"),
AB05("TimeoutCreditorAgent"),
AB06("TimeoutInstructedAgent"),
AB07("OfflineAgent"),
AB08("OfflineCreditorAgent"),
AB09("ErrorCreditorAgent"),
AB10("ErrorInstructedAgent"),
AB11("TimeoutDebtorAgent"),
AC01("IncorrectAccountNumber"),
AC02("InvalidDebtorAccountNumber"),
AC03("InvalidCreditorAccountNumber"),
AC04("ClosedAccountNumber"),
AC05("ClosedDebtorAccountNumber"),
AC06("BlockedAccount"),
AC07("ClosedCreditorAccountNumber"),
AC08("InvalidBranchCode"),
AC09("InvalidAccountCurrency"),
AC10("InvalidDebtorAccountCurrency"),
AC11("InvalidCreditorAccountCurrency"),
AC12("InvalidAccountType"),
AC13("InvalidDebtorAccountType"),
AC14("InvalidCreditorAccountType"),
AC15("AccountDetailsChanged"),
AC16("CardNumberInvalid"),
AG01("TransactionForbidden"),
AG02("InvalidBankOperationCode"),
AG03("TransactionNotSupported"),
AG04("InvalidAgentCountry"),
AG05("InvalidDebtorAgentCountry"),
AG06("InvalidCreditorAgentCountry"),
AG07("UnsuccesfulDirectDebit"),
AG08("InvalidAccessRights"),
AG09("PaymentNotReceived"),
AG10("AgentSuspended"),
AG11("CreditorAgentSuspended"),
AG12("NotAllowedBookTransfer"),
AG13("ForbiddenReturnPayment"),
AGNT("IncorrectAgent"),
AM01("ZeroAmount"),
AM02("NotAllowedAmount"),
AM03("NotAllowedCurrency"),
AM04("InsufficientFunds"),
AM05("Duplication"),
AM06("TooLowAmount"),
AM07("BlockedAmount"),
AM09("WrongAmount"),
AM10("InvalidControlSum"),
AM11("InvalidTransactionCurrency"),
AM12("InvalidAmount"),
AM13("AmountExceedsClearingSystemLimit"),
AM14("AmountExceedsAgreedLimit"),
AM15("AmountBelowClearingSystemMinimum"),
AM16("InvalidGroupControlSum"),
AM17("InvalidPaymentInfoControlSum"),
AM18("InvalidNumberOfTransactions"),
AM19("InvalidGroupNumberOfTransactions"),
AM20("InvalidPaymentInfoNumberOfTransactions"),
AM21("LimitExceeded"),
AM22("ZeroAmountNotApplied"),
AM23("AmountExceedsSettlementLimit"),
BE01("InconsistenWithEndCustomer"),
BE04("MissingCreditorAddress"),
BE05("UnrecognisedInitiatingParty"),
BE06("UnknownEndCustomer"),
BE07("MissingDebtorAddress"),
BE08("MissingDebtorName"),
BE09("InvalidCountry"),
BE10("InvalidDebtorCountry"),
BE11("InvalidCreditorCountry"),
BE12("InvalidCountryOfResidence"),
BE13("InvalidDebtorCountryOfResidence"),
BE14("InvalidCreditorCountryOfResidence"),
BE15("InvalidIdentificationCode"),
BE16("InvalidDebtorIdentificationCode"),
BE17("InvalidCreditorIdentificationCode"),
BE18("InvalidContactDetails"),
BE19("InvalidChargeBearerCode"),
BE20("InvalidNameLength"),
BE21("MissingName"),
BE22("MissingCreditorName"),
BE23("AccountProxyInvalid"),
CERI("CheckERI"),
CH03("RequestedExecutionDateOrRequestedCollectionDateTooFarInFuture"),
CH04("RequestedExecutionDateOrRequestedCollectionDateTooFarInPast"),
CH07("ElementIsNotToBeUsedAtB-andC-Level"),
CH09("MandateChangesNotAllowed"),
CH10("InformationOnMandateChangesMissing"),
CH11("CreditorIdentifierIncorrect"),
CH12("CreditorIdentifierNotUnambiguouslyAtTransaction-Level"),
CH13("OriginalDebtorAccountIsNotToBeUsed"),
CH14("OriginalDebtorAgentIsNotToBeUsed"),
CH15("ElementContentIncludesMoreThan140Characters"),
CH16("ElementContentFormallyIncorrect"),
CH17("ElementNotAdmitted"),
CH19("ValuesWillBeSetToNextTARGETday"),
CH20("DecimalPointsNotCompatibleWithCurrency"),
CH21("RequiredCompulsoryElementMissing"),
CH22("COREandB2BwithinOnemessage"),
CHQC("ChequeSettledOnCreditorAccount"),
CNOR("CreditorBankIsNotRegistered"),
CURR("IncorrectCurrency"),
CUST("RequestedByCustomer"),
DNOR("DebtorBankIsNotRegistered"),
DS01("ElectronicSignaturesCorrect"),
DS02("OrderCancelled"),
DS03("OrderNotCancelled"),
DS04("OrderRejected"),
DS05("OrderForwardedForPostprocessing"),
DS06("TransferOrder"),
DS07("ProcessingOK"),
DS08("DecompressionError"),
DS09("DecryptionError"),
DS0A("DataSignRequested"),
DS0B("UnknownDataSignFormat"),
DS0C("SignerCertificateRevoked"),
DS0D("SignerCertificateNotValid"),
DS0E("IncorrectSignerCertificate"),
DS0F("SignerCertificationAuthoritySignerNotValid"),
DS0G("NotAllowedPayment"),
DS0H("NotAllowedAccount"),
DS0K("NotAllowedNumberOfTransaction"),
DS10("Signer1CertificateRevoked"),
DS11("Signer1CertificateNotValid"),
DS12("IncorrectSigner1Certificate"),
DS13("SignerCertificationAuthoritySigner1NotValid"),
DS14("UserDoesNotExist"),
DS15("IdenticalSignatureFound"),
DS16("PublicKeyVersionIncorrect"),
DS17("DifferentOrderDataInSignatures"),
DS18("RepeatOrder"),
DS19("ElectronicSignatureRightsInsufficient"),
DS20("Signer2CertificateRevoked"),
DS21("Signer2CertificateNotValid"),
DS22("IncorrectSigner2Certificate"),
DS23("SignerCertificationAuthoritySigner2NotValid"),
DS24("WaitingTimeExpired"),
DS25("OrderFileDeleted"),
DS26("UserSignedMultipleTimes"),
DS27("UserNotYetActivated"),
DT01("InvalidDate"),
DT02("InvalidCreationDate"),
DT03("InvalidNonProcessingDate"),
DT04("FutureDateNotSupported"),
DT05("InvalidCutOffDate"),
DT06("ExecutionDateChanged"),
DU01("DuplicateMessageID"),
DU02("DuplicatePaymentInformationID"),
DU03("DuplicateTransaction"),
DU04("DuplicateEndToEndID"),
DU05("DuplicateInstructionID"),
DUPL("DuplicatePayment"),
ED01("CorrespondentBankNotPossible"),
ED03("BalanceInfoRequest"),
ED05("SettlementFailed"),
ED06("SettlementSystemNotAvailable"),
ERIN("ERIOptionNotSupported"),
FF01("InvalidFileFormat"),
FF02("SyntaxError"),
FF03("InvalidPaymentTypeInformation"),
FF04("InvalidServiceLevelCode"),
FF05("InvalidLocalInstrumentCode"),
FF06("InvalidCategoryPurposeCode"),
FF07("InvalidPurpose"),
FF08("InvalidEndToEndId"),
FF09("InvalidChequeNumber"),
FF10("BankSystemProcessingError"),
FF11("ClearingRequestAborted"),
G000("PaymentTransferredAndTracked"),
G001("PaymentTransferredAndNotTracked"),
G002("CreditDebitNotConfirmed"),
G003("CreditPendingDocuments"),
G004("CreditPendingFunds"),
G005("DeliveredWithServiceLevel"),
G006("DeliveredWIthoutServiceLevel"),
ID01("CorrespondingOriginalFileStillNotSent"),
MD01("NoMandate"),
MD02("MissingMandatoryInformationInMandate"),
MD05("CollectionNotDue"),
MD06("RefundRequestByEndCustomer"),
MD07("EndCustomerDeceased"),
MS02("NotSpecifiedReasonCustomerGenerated"),
MS03("NotSpecifiedReasonAgentGenerated"),
NARR("Narrative"),
NERI("NoERI"),
RC01("BankIdentifierIncorrect"),
RC02("InvalidBankIdentifier"),
RC03("InvalidDebtorBankIdentifier"),
RC04("InvalidCreditorBankIdentifier"),
RC05("InvalidBICIdentifier"),
RC06("InvalidDebtorBICIdentifier"),
RC07("InvalidCreditorBICIdentifier"),
RC08("InvalidClearingSystemMemberIdentifier"),
RC09("InvalidDebtorClearingSystemMemberIdentifier"),
RC10("InvalidCreditorClearingSystemMemberIdentifier"),
RC11("InvalidIntermediaryAgent"),
RC12("MissingCreditorSchemeId"),
RCON("RMessageConflict"),
RECI("ReceiverCustomerInformation"),
RF01("NotUniqueTransactionReference"),
RR01("MissingDebtorAccountOrIdentification"),
RR02("MissingDebtorNameOrAddress"),
RR03("MissingCreditorNameOrAddress"),
RR04("RegulatoryReason"),
RR05("RegulatoryInformationInvalid"),
RR06("TaxInformationInvalid"),
RR07("RemittanceInformationInvalid"),
RR08("RemittanceInformationTruncated"),
RR09("InvalidStructuredCreditorReference"),
RR10("InvalidCharacterSet"),
RR11("InvalidDebtorAgentServiceID"),
RR12("InvalidPartyID"),
S000("ValidRequestForCancellationAcknowledged"),
S001("UETRFlaggedForCancellation"),
S002("NetworkStopOfUETR"),
S003("RequestForCancellationForwarded"),
S004("RequestForCancellationDeliveryAcknowledgement"),
SL01("SpecificServiceOfferedByDebtorAgent"),
SL02("SpecificServiceOfferedByCreditorAgent"),
SL03("ServiceofClearingSystem"),
SL11("CreditorNotOnWhitelistOfDebtor"),
SL12("CreditorOnBlacklistOfDebtor"),
SL13("MaximumNumberOfDirectDebitTransactionsExceeded"),
SL14("MaximumDirectDebitTransactionAmountExceeded"),
TA01("TransmissonAborted"),
TD01("NoDataAvailable"),
TD02("FileNonReadable"),
TD03("IncorrectFileStructure"),
TK01("TokenInvalid"),
TK02("SenderTokenNotFound"),
TK03("ReceiverTokenNotFound"),
TK09("TokenMissing"),
TKCM("TokenCounterpartyMismatch"),
TKSG("TokenSingleUse"),
TKSP("TokenSuspended"),
TKVE("TokenValueLimitExceeded"),
TKXP("TokenExpired"),
TM01("InvalidCutOffTime"),
TS01("TransmissionSuccessful"),
TS04("TransferToSignByHand"),
CN01("AuthorisationCancelled"),
FOCR("FollowingCancellationRequest"),
FR01("Fraud"),
NOCM("NotCompliantGeneric"),
NOAS("NoAnswerFromCustomer"),
RUTA("ReturnUponUnableToApply"),
UPAY("UnduePayment"),
ALAC("AlreadyAcceptedRTP"),
AEXR("AlreadyExpiredRTP"),
ARFR("AlreadyRefusedRTP"),
ARJR("AlreadyRejectedRTP"),
ATNS("AttachementsNotSupported"),
EDTR("ExpiryDateTimeReached"),
EDTL("ExpiryDateTooLong"),
FRAD("FraudulentOrigin"),
IEDT("IncorrectExpiryDateTime"),
IRNR("InitialRTPNeverReceived"),
NOAR("NonAgreedRTP"),
NOPG("NoPaymentGuarantee"),
NRCH("PayerOrPayerRTPSPNotReachable"),
RTNS("RTPNotSupportedForDebtor"),
REPR("RTPReceivedCanBeProcessed"),
SPII("RTPServiceProviderIdentifierIncorrect"),
PINS("TypeOfPaymentInstrumentNotSupported"),
UCRD("UnknownCreditor"),
FF12("OriginalTransactionNotEligibleForRequestedReturn"),
FF13("RequestForCancellationNotFound");
StatusReasonCode(String s) {}
public String value() {
return name();
}
}
package com.brilliance.mt2mx.pacs009001;
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 {
private static void test202() throws IOException {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftTxt\\Mt202.txt");
//File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftTxt\\Mt103.txt");
File file = new File("d:/test/MT202.txt");
String mtStr = FileUtils.readFileToString(file);
String mxXml = SwiftTransfer.mt2Mx(mtStr, "D:/test/mt2mx/pacs00900108.xml", null);
System.out.println(mxXml);
SwiftTranslationReport str = SwiftTransfer.mt2MxPlus(mtStr, "D:/test/mt2mx/pacs00900108.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());
}
}
private static void test202Cov() throws IOException {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftTxt\\Mt202_COV.txt");
//File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftTxt\\Mt103.txt");
File file = new File("d:/test/MT202Cov.txt");
String mtStr = FileUtils.readFileToString(file);
String mxXml = SwiftTransfer.mt2Mx(mtStr, "D:/test/mt2mx/pacs00900108.xml", null);
System.out.println(mxXml);
SwiftTranslationReport str = SwiftTransfer.mt2MxPlus(mtStr, "D:/test/mt2mx/pacs00900108.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());
}
}
......
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