Commit 0c5fd4ad by chengzhuoshen

1.修改抛异常代码

2.移除掉900 910 940 950转换的log代码
parent 35524c5f
......@@ -35,9 +35,7 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
protected AbstractMx2MtCreator withExtraMap(Map<String, Object> extraMap) {
if (extraMap != null && extraMap.size() > 0) {
logger.info("External Map...");
extraMap.forEach((key, value) -> {
logger.info(key + "-" + value);
map.put(key, value);
});
}
......@@ -52,19 +50,6 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
this.map = map;
}
protected void generateCommonField(GroupHeader42 grpHdr) {
if (grpHdr != null) {
String createDateStr = DateUtil.format(grpHdr.getCreDtTm(), "YYMMdd");
String createTimeStr = DateUtil.format(grpHdr.getCreDtTm(), "HHmm");
map.put("createDate", createDateStr);
map.put("createTime", createTimeStr);
String outDateStr = DateUtil.formatNow( "YYMMdd");
String outTimeStr = DateUtil.formatNow("HHmm");
map.put("outDate", outDateStr);
map.put("outTime", outTimeStr);
}
}
//TODO
protected String getRandomNumber(int length) {
String randomNumber = "";
......@@ -153,7 +138,7 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
} else if (Mx2MtConstants.MT_IO_TYPE_OUTPUT.equals(mtIOType)) {
String createDateStr = "";
String createTimeStr = "";
String outDateStr = DateUtil.formatNow( "YYMMdd");
String outDateStr = DateUtil.formatNow( "yyMMdd");
String outTimeStr = DateUtil.formatNow("HHmm");
String bicCode = "";
String sessionNumber = getRandomNumber(4);
......@@ -161,10 +146,10 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
if (appHdr != null) {
bicCode = processBicCode(appHdr.from());
if (appHdr.creationDate() != null) {
createDateStr = DateUtil.format(appHdr.creationDate(), "YYMMdd");
createDateStr = DateUtil.format(appHdr.creationDate(), "yyMMdd");
createTimeStr = DateUtil.format(appHdr.creationDate(), "HHmm");
} else {
createDateStr = DateUtil.formatNow("YYMMdd");
createDateStr = DateUtil.formatNow("yyMMdd");
createTimeStr = DateUtil.formatNow("HHmm");
}
}
......
......@@ -16,26 +16,6 @@ public abstract class AbstractMx2MtFieldsGenerate implements Mx2MtFieldsGenerate
map = targetMap;
}
/**
* length == 8 append AXXX
* length == 11 substring(0,8)+A+substring(8)
* @param bicCode
* @return
*/
protected String processBicCode(String bicCode) {
String processedBicCode = "";
if (!StringUtil.isEmpty(bicCode)) {
if (bicCode.length() == 8) {
processedBicCode = bicCode + Mx2MtConstants.BICSUFFIX;
} else if (bicCode.length() == 11) {
processedBicCode = bicCode.substring(0, 8) + Mx2MtConstants.BICMIDDLE + bicCode.substring(8);
} else {
throw new SwiftException("ERROR", "BicCode length is invalid.");
}
}
return processedBicCode;
}
protected String getMtFormatAccount(CashAccount16 dbtrAcct) {
String account = "";
String iban = "";
......
......@@ -51,11 +51,8 @@ public class Mx2MtCreateManager {
}
public String mx2mt(File file, String outPutFilePath, Map<String, Object> extraMap) throws Exception {
logger.info("invoke mx2mt(file) start...");
String xmlStr = FileUtils.readFileToString(file);
init(xmlStr);
logger.info("Xml Message Type = " + msgType);
logger.info("Xml Message Obj = " + mxObj);
return convert(outPutFilePath, extraMap);
}
......@@ -68,10 +65,7 @@ public class Mx2MtCreateManager {
}
public String mx2mt(String xmlStr, String outPutFilePath, Map<String, Object> extraMap) throws Exception {
logger.info("invoke mx2mt(string) start...");
init(xmlStr);
logger.info("Xml Message Type = " + msgType);
logger.info("Xml Message Obj = " + mxObj);
return convert(outPutFilePath, extraMap);
}
......
......@@ -49,7 +49,7 @@ public class Field32AGenerate extends AbstractMx2MtFieldsGenerate {
String yymMdd = "";
if (cdtTrfTxInf.get(0).getIntrBkSttlmDt() != null){
XMLGregorianCalendar dt = cdtTrfTxInf.get(0).getIntrBkSttlmDt();
yymMdd = DateUtil.format(dt, "YYMMdd");
yymMdd = DateUtil.format(dt, "yyMMdd");
}
String ccy = cdtTrfTxInf.get(0).getIntrBkSttlmAmt().getCcy();
......
......@@ -50,10 +50,10 @@ public class Field13CGenerate extends AbstractMx2MtFieldsGenerate {
field13cList.add("/CLSTIME/"+hmm+"+0800");
}
if (field13cList.size() > 0) {
map.put("field13CList", field13cList);
map.put("field13cList", field13cList);
}
} catch(Exception e) {
throw new SwiftException("ERROR", "Convert MT202 Field13C error");
throw new SwiftException("ERROR", e.getMessage());
}
}
......
......@@ -26,7 +26,7 @@ public class Field20Generate extends AbstractMx2MtFieldsGenerate {
GroupHeader35 grpHdr = finInstnCdtTrf.getGrpHdr();
map.put("field20", grpHdr.getMsgId());
} catch(Exception e) {
throw new SwiftException("ERROR", "Convert MT202 Field20 error");
throw new SwiftException("ERROR", e.getMessage());
}
}
......
......@@ -31,7 +31,7 @@ public class Field21Generate extends AbstractMx2MtFieldsGenerate {
}
map.put("field21", field21);
} catch(Exception e) {
throw new SwiftException("ERROR", "Convert MT202 Field21 error");
throw new SwiftException("ERROR", e.getMessage());
}
}
......
......@@ -56,7 +56,7 @@ public class Field32AGenerate extends AbstractMx2MtFieldsGenerate {
}
}
} catch(Exception e) {
throw new SwiftException("ERROR", "Convert MT202 Field32A error");
throw new SwiftException("ERROR", e.getMessage());
}
}
......
......@@ -81,7 +81,7 @@ public class Field52AGenerate extends AbstractMx2MtFieldsGenerate {
map.put("field52Option", field52Option);
map.put("field52A", field52A);
} catch(Exception e) {
throw new SwiftException("ERROR", "Convert MT202 Field52A error");
throw new SwiftException("ERROR", e.getMessage());
}
}
......
......@@ -106,7 +106,7 @@ public class Field53AGenerate extends AbstractMx2MtFieldsGenerate {
map.put("field53Option", field53Option);
map.put("field53A", field53A);
} catch(Exception e) {
throw new SwiftException("ERROR", "Convert MT202 Field53A error");
throw new SwiftException("ERROR", e.getMessage());
}
}
......
......@@ -85,7 +85,7 @@ public class Field54AGenerate extends AbstractMx2MtFieldsGenerate {
map.put("field54Option", field54Option);
map.put("field54A", field54A);
} catch(Exception e) {
throw new SwiftException("ERROR", "Convert MT202 Field54A error");
throw new SwiftException("ERROR", e.getMessage());
}
}
......
......@@ -84,7 +84,7 @@ public class Field56AGenerate extends AbstractMx2MtFieldsGenerate {
map.put("field56Option", field56Option);
map.put("field56A", field56A);
} catch(Exception e) {
throw new SwiftException("ERROR", "Convert MT202 Field56A error");
throw new SwiftException("ERROR", e.getMessage());
}
}
......
......@@ -84,7 +84,7 @@ public class Field57AGenerate extends AbstractMx2MtFieldsGenerate {
map.put("field57Option", field57Option);
map.put("field57A", field57A);
} catch(Exception e) {
throw new SwiftException("ERROR", "Convert MT202 Field57A error");
throw new SwiftException("ERROR", e.getMessage());
}
}
......
......@@ -84,7 +84,7 @@ public class Field58AGenerate extends AbstractMx2MtFieldsGenerate {
map.put("field58Option", field58Option);
map.put("field58A", field58A);
} catch(Exception e) {
throw new SwiftException("ERROR", "Convert MT202 Field58A error");
throw new SwiftException("ERROR", e.getMessage());
}
}
......
......@@ -115,7 +115,7 @@ public class Field72Generate extends AbstractMx2MtFieldsGenerate {
map.put("field72", field72);
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT202 filed72 error");
throw new SwiftException("ERROR", e.getMessage());
}
}
......
......@@ -87,7 +87,7 @@ public class Field50AGenerate extends AbstractMx2MtFieldsGenerate {
map.put("field50BOption", field50BOption);
map.put("field50B", field50B);
} catch(Exception e) {
throw new SwiftException("ERROR", "Convert MT202COV Field50A error");
throw new SwiftException("ERROR", e.getMessage());
}
}
......
......@@ -43,7 +43,7 @@ public class FieldB33BGenerate extends AbstractMx2MtFieldsGenerate {
}
map.put("field33B", filed33B);
} catch(Exception e) {
throw new SwiftException("ERROR", "Convert MT202COV Field33B error");
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......
......@@ -84,7 +84,7 @@ public class FieldB52AGenerate extends AbstractMx2MtFieldsGenerate {
map.put("field52BOption", field52BOption);
map.put("field52B", field52B);
} catch(Exception e) {
throw new SwiftException("ERROR", "Convert MT202COV Field52 error");
throw new SwiftException("ERROR", e.getMessage());
}
}
......
......@@ -97,7 +97,7 @@ public class FieldB56Generate extends AbstractMx2MtFieldsGenerate {
map.put("field56BOption", field56BOption);
map.put("field56B", field56B);
} catch(Exception e) {
throw new SwiftException("ERROR", "Convert MT202COV Field56 error");
throw new SwiftException("ERROR", e.getMessage());
}
}
......
......@@ -95,7 +95,7 @@ public class FieldB57Generate extends AbstractMx2MtFieldsGenerate {
map.put("field57BOption", field57BOption);
map.put("field57B", field57B);
} catch(Exception e) {
throw new SwiftException("ERROR", "Convert MT202COV Field57 error");
throw new SwiftException("ERROR", e.getMessage());
}
}
......
......@@ -84,7 +84,7 @@ public class FieldB59Generate extends AbstractMx2MtFieldsGenerate {
map.put("field59BOption", field59BOption);
map.put("field59B", field59B);
} catch(Exception e) {
throw new SwiftException("ERROR", "Convert MT202COV Field59 error");
throw new SwiftException("ERROR", e.getMessage());
}
}
......
......@@ -43,7 +43,7 @@ public class FieldB70Generate extends AbstractMx2MtFieldsGenerate {
}
map.put("field70B", field70B);
} catch(Exception e) {
throw new SwiftException("ERROR", "Convert MT202COV Field70 error");
throw new SwiftException("ERROR", e.getMessage());
}
}
......
......@@ -16,6 +16,8 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
public class Mx2Mt900910Creator extends AbstractMx2MtCreator {
......@@ -75,6 +77,7 @@ public class Mx2Mt900910Creator extends AbstractMx2MtCreator {
} else if (CreditDebitCode.CRDT.equals(ntry.getCdtDbtInd())) {
mtType = Mx2MtConstants.MT_TYPE_910;
}
map.put(Mx2MtConstants.MT_TYPE, mtType);
}
}
return mtType;
......
......@@ -18,7 +18,6 @@ public class Field20Generate extends AbstractMx2MtFieldsGenerate {
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field20Generate start.");
try {
MxCamt05400102 mxCamt05400102 = (MxCamt05400102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05400102 == null || mxCamt05400102.getBkToCstmrDbtCdtNtfctn() == null) {
......@@ -31,8 +30,7 @@ public class Field20Generate extends AbstractMx2MtFieldsGenerate {
map.put("field20", field20);
}
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 Field20 error");
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -19,7 +19,6 @@ public class Field21Generate extends AbstractMx2MtFieldsGenerate {
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field21Generate start.");
try {
MxCamt05400102 mxCamt05400102 = (MxCamt05400102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05400102 == null || mxCamt05400102.getBkToCstmrDbtCdtNtfctn() == null) {
......@@ -47,8 +46,7 @@ public class Field21Generate extends AbstractMx2MtFieldsGenerate {
}
}
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 Field21 error");
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -21,7 +21,6 @@ public class Field25aGenerate extends AbstractMx2MtFieldsGenerate {
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field25aGenerate start.");
try {
MxCamt05400102 mxCamt05400102 = (MxCamt05400102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05400102 == null || mxCamt05400102.getBkToCstmrDbtCdtNtfctn() == null) {
......@@ -47,8 +46,7 @@ public class Field25aGenerate extends AbstractMx2MtFieldsGenerate {
}
}
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 Field25a error");
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -22,7 +22,6 @@ public class Field32AGenerate extends AbstractMx2MtFieldsGenerate {
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field32AGenerate start.");
try {
MxCamt05400102 mxCamt05400102 = (MxCamt05400102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05400102 == null || mxCamt05400102.getBkToCstmrDbtCdtNtfctn() == null) {
......@@ -37,7 +36,7 @@ public class Field32AGenerate extends AbstractMx2MtFieldsGenerate {
ReportEntry2 ntry = ntryList.get(0);
String dateStr = "";
if (ntry.getValDt() != null) {
dateStr = DateUtil.format(ntry.getValDt().getDt(), "YYMMdd");
dateStr = DateUtil.format(ntry.getValDt().getDt(), "yyMMdd");
}
String ccy = "";
String amtStr = "";
......@@ -47,17 +46,10 @@ public class Field32AGenerate extends AbstractMx2MtFieldsGenerate {
amtStr = NumberUtil.formatAmt(amt.getValue(), ccy);
}
map.put("field32A", dateStr+ccy+amtStr);
//judge 900 or 910
if (CreditDebitCode.DBIT.equals(ntry.getCdtDbtInd())) {
map.put(Mx2MtConstants.MT_TYPE, Mx2MtConstants.MT_TYPE_900);
} else if (CreditDebitCode.CRDT.equals(ntry.getCdtDbtInd())) {
map.put(Mx2MtConstants.MT_TYPE, Mx2MtConstants.MT_TYPE_910);
}
}
}
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 Field32A error");
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -27,15 +27,13 @@ public class Field50aGenerate extends AbstractMx2MtFieldsGenerate {
@Override
public void fieldsGenerate() throws SwiftException {
String mtType = (String)map.get("mtType");
String mtType = (String)map.get(Mx2MtConstants.MT_TYPE);
if (!Mx2MtConstants.MT_TYPE_910.equals(mtType)) {
return;
}
logger.info("Field50aGenerate start.");
try {
TransactionParty2 rltdPties = getTransactionParty2();
if (rltdPties == null) {
logger.info("<Ntfctn><Ntry><NtryDtls><TxDtls><RltdPties> Object is null.");
return;
}
String field50aOption = "";
......@@ -89,8 +87,7 @@ public class Field50aGenerate extends AbstractMx2MtFieldsGenerate {
map.put("field50a", field50a);
}
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 Field50a error");
throw new SwiftException("ERROR", e.getMessage());
}
}
......@@ -121,8 +118,7 @@ public class Field50aGenerate extends AbstractMx2MtFieldsGenerate {
}
return rltdPties;
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 Field50a error");
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -17,11 +17,9 @@ public class Field52aGenerate extends AbstractMx2MtFieldsGenerate {
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field52aGenerate start.");
try {
BranchAndFinancialInstitutionIdentification4 crDrTrAgt = getCrDrTrAgt();
if (crDrTrAgt == null) {
logger.info("<Ntfctn><Ntry><NtryDtls><TxDtls><RltdAgts><DbtrAgt>or<CdtrAgt> Object is null.");
return;
}
String field52aOption = "";
......@@ -73,8 +71,7 @@ public class Field52aGenerate extends AbstractMx2MtFieldsGenerate {
map.put("field52a", field52a);
}
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 Field52a error");
throw new SwiftException("ERROR", e.getMessage());
}
}
......
......@@ -17,15 +17,13 @@ public class Field56aGenerate extends AbstractMx2MtFieldsGenerate {
@Override
public void fieldsGenerate() throws SwiftException {
String mtType = (String)map.get("mtType");
String mtType = (String)map.get(Mx2MtConstants.MT_TYPE);
if (!Mx2MtConstants.MT_TYPE_910.equals(mtType)) {
return;
}
logger.info("Field56aGenerate start.");
try {
BranchAndFinancialInstitutionIdentification4 intrmyAgt1 = getIntrmyAgt1();
if (intrmyAgt1 == null) {
logger.info("<Ntfctn><Ntry><NtryDtls><TxDtls><RltdAgts><IntrmyAgt1> Object is null.");
return;
}
String field56aOption = "";
......@@ -77,8 +75,7 @@ public class Field56aGenerate extends AbstractMx2MtFieldsGenerate {
map.put("field56a", field56a);
}
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 Field56a error");
throw new SwiftException("ERROR", e.getMessage());
}
}
......@@ -112,8 +109,7 @@ public class Field56aGenerate extends AbstractMx2MtFieldsGenerate {
}
return intrmyAgt1;
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 Field56a error");
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -17,21 +17,19 @@ public class Field72Generate extends AbstractMx2MtFieldsGenerate {
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field72Generate start.");
try {
String field72 = "";
EntryTransaction2 txDtls = getEntryTransaction2();
if (txDtls != null) {
String addtLtxnInf = txDtls.getAddtlTxInf();
if (StringUtil.isNotEmpty(addtLtxnInf)) {
logger.info(addtLtxnInf);
field72 = StringUtil.getStringByEnter(addtLtxnInf, 35, 6);
}
}
map.put("field72", field72);
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 Field56a error");
throw new SwiftException("ERROR", e.getMessage());
}
}
......@@ -62,7 +60,7 @@ public class Field72Generate extends AbstractMx2MtFieldsGenerate {
return txDtls;
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 Field72 error");
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -58,17 +58,7 @@ public class Mx2Mt950Creator extends AbstractMx2MtCreator {
@Override
public String generateMtMsg() {
MxCamt05300102 mxCamt05300102 = (MxCamt05300102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05300102 != null
&& mxCamt05300102.getBkToCstmrStmt() != null
&& mxCamt05300102.getBkToCstmrStmt().getGrpHdr() != null) {
generateCommonField(mxCamt05300102.getBkToCstmrStmt().getGrpHdr());
}
map.forEach((key, value) -> {
if (!Mx2MtConstants.MX_OBJECT.equals(key)) {
logger.info(key + "-" + value);
}
});
postProcess();
String outPutFilePath = (String) map.get(Mx2MtConstants.OUT_PUT_FILE_PATH);
return TemplateUtil.makeFileByTemplate("swift_mt_940_950.vm", map, outPutFilePath, "utf-8");
......@@ -127,4 +117,17 @@ public class Mx2Mt950Creator extends AbstractMx2MtCreator {
return Mx2MtConstants.MT_TYPE_950;
}
}
/**
* set field 21 = ""
* set filed 65 = ""
* set filed 86 = ""
*/
private void postProcess() {
if (Mx2MtConstants.MT_TYPE_950.equals(getMtType())) {
map.put("field21", "");
map.put("field65", "");
map.put("field86", "");
}
}
}
......@@ -18,7 +18,6 @@ public class Field20Generate extends AbstractMx2MtFieldsGenerate{
@Override
public void fieldsGenerate() throws SwiftException{
logger.info("Field20Generate start.");
try {
MxCamt05300102 mxCamt05300102 = (MxCamt05300102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05300102 == null || mxCamt05300102.getBkToCstmrStmt() == null) {
......@@ -29,7 +28,7 @@ public class Field20Generate extends AbstractMx2MtFieldsGenerate{
map.put("field20", grpHdr.getMsgId());
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT940/MT950 Field20 error");
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -24,7 +24,6 @@ public class Field25aGenerate extends AbstractMx2MtFieldsGenerate{
@Override
public void fieldsGenerate() throws SwiftException{
logger.info("Field25aGenerate start.");
try {
MxCamt05300102 mxCamt05300102 = (MxCamt05300102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05300102 == null || mxCamt05300102.getBkToCstmrStmt() == null) {
......@@ -49,7 +48,7 @@ public class Field25aGenerate extends AbstractMx2MtFieldsGenerate{
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT940/MT950 Field25a error");
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -24,7 +24,6 @@ public class Field28CGenerate extends AbstractMx2MtFieldsGenerate{
@Override
public void fieldsGenerate() throws SwiftException{
logger.info("Field28CGenerate start.");
try {
MxCamt05300102 mxCamt05300102 = (MxCamt05300102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05300102 == null || mxCamt05300102.getBkToCstmrStmt() == null) {
......@@ -57,7 +56,7 @@ public class Field28CGenerate extends AbstractMx2MtFieldsGenerate{
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT940/MT950 field28C error");
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -26,7 +26,6 @@ public class Field60Generate extends AbstractMx2MtFieldsGenerate{
@Override
public void fieldsGenerate() throws SwiftException{
logger.info("Field60Generate start.");
try {
MxCamt05300102 mxCamt05300102 = (MxCamt05300102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05300102 == null || mxCamt05300102.getBkToCstmrStmt() == null) {
......@@ -62,7 +61,7 @@ public class Field60Generate extends AbstractMx2MtFieldsGenerate{
}
String dateStr = "";
if (bal.getDt() != null) {
dateStr = DateUtil.format(bal.getDt().getDt(), "YYMMdd");
dateStr = DateUtil.format(bal.getDt().getDt(), "yyMMdd");
}
String ccy = "";
String amtStr = "";
......@@ -78,7 +77,7 @@ public class Field60Generate extends AbstractMx2MtFieldsGenerate{
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT940/MT950 Field60Generate error");
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -33,7 +33,6 @@ public class Field61ListGenerate extends AbstractMx2MtFieldsGenerate{
@Override
public void fieldsGenerate() throws SwiftException{
logger.info("Field61ListGenerate start.");
try {
MxCamt05300102 mxCamt05300102 = (MxCamt05300102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05300102 == null || mxCamt05300102.getBkToCstmrStmt() == null) {
......@@ -48,8 +47,8 @@ public class Field61ListGenerate extends AbstractMx2MtFieldsGenerate{
List<String> filed61List = new ArrayList<>();
for (int i=0; i<ntryList.size(); i++) {
ReportEntry2 ntry = ntryList.get(i);
String valueDateStr = DateUtil.format(ntry.getValDt().getDt(), "YYMMdd");
String entryDateStr = DateUtil.format(ntry.getBookgDt().getDt(), "YYMMdd");
String valueDateStr = DateUtil.format(ntry.getValDt().getDt(), "yyMMdd");
String entryDateStr = DateUtil.format(ntry.getBookgDt().getDt(), "yyMMdd");
String drCrMark = "";
if (CreditDebitCode.CRDT.equals(ntry.getCdtDbtInd())) {
if (Boolean.TRUE.equals(ntry.isRvslInd())) {
......@@ -118,14 +117,13 @@ public class Field61ListGenerate extends AbstractMx2MtFieldsGenerate{
filed61List.add(sb.toString());
}
if (filed61List.size() > 0) {
filed61List.forEach(field61 -> logger.info(":61:"+field61));
map.put("field61List", filed61List);
}
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT940/MT950 Field61List error");
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -26,7 +26,6 @@ public class Field62Generate extends AbstractMx2MtFieldsGenerate{
@Override
public void fieldsGenerate() throws SwiftException{
logger.info("Field62Generate start.");
try {
MxCamt05300102 mxCamt05300102 = (MxCamt05300102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05300102 == null || mxCamt05300102.getBkToCstmrStmt() == null) {
......@@ -62,7 +61,7 @@ public class Field62Generate extends AbstractMx2MtFieldsGenerate{
}
String dateStr = "";
if (bal.getDt() != null) {
dateStr = DateUtil.format(bal.getDt().getDt(), "YYMMdd");
dateStr = DateUtil.format(bal.getDt().getDt(), "yyMMdd");
}
String ccy = "";
String amtStr = "";
......@@ -79,7 +78,7 @@ public class Field62Generate extends AbstractMx2MtFieldsGenerate{
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT940/MT950 Field62 error");
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -27,7 +27,6 @@ public class Field64Generate extends AbstractMx2MtFieldsGenerate{
@Override
public void fieldsGenerate() throws SwiftException{
logger.info("Field64Generate start.");
try {
MxCamt05300102 mxCamt05300102 = (MxCamt05300102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05300102 == null || mxCamt05300102.getBkToCstmrStmt() == null) {
......@@ -61,7 +60,7 @@ public class Field64Generate extends AbstractMx2MtFieldsGenerate{
}
String dateStr = "";
if (bal.getDt() != null) {
dateStr = DateUtil.format(bal.getDt().getDt(), "YYMMdd");
dateStr = DateUtil.format(bal.getDt().getDt(), "yyMMdd");
}
String ccy = "";
String amtStr = "";
......@@ -79,7 +78,7 @@ public class Field64Generate extends AbstractMx2MtFieldsGenerate{
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT940/MT950 filed64 error");
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -27,7 +27,6 @@ public class Field65Generate extends AbstractMx2MtFieldsGenerate {
@Override
public void fieldsGenerate() throws SwiftException{
logger.info("Field65Generate start.");
try {
MxCamt05300102 mxCamt05300102 = (MxCamt05300102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05300102 == null || mxCamt05300102.getBkToCstmrStmt() == null) {
......@@ -61,7 +60,7 @@ public class Field65Generate extends AbstractMx2MtFieldsGenerate {
}
String dateStr = "";
if (bal.getDt() != null) {
dateStr = DateUtil.format(bal.getDt().getDt(), "YYMMdd");
dateStr = DateUtil.format(bal.getDt().getDt(), "yyMMdd");
}
String ccy = "";
String amtStr = "";
......@@ -77,7 +76,7 @@ public class Field65Generate extends AbstractMx2MtFieldsGenerate {
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT940 filed65 error");
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -23,7 +23,6 @@ public class Field86Generate extends AbstractMx2MtFieldsGenerate {
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field86Generate start");
try {
MxCamt05300102 mxCamt05300102 = (MxCamt05300102) map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05300102 == null || mxCamt05300102.getBkToCstmrStmt() == null) {
......@@ -39,7 +38,7 @@ public class Field86Generate extends AbstractMx2MtFieldsGenerate {
}
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT940 filed86 error");
throw new SwiftException("ERROR", e.getMessage());
}
}
......
package com.prowidesoftware.brilliance.mx2mt.mt940950.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05300102;
import com.prowidesoftware.swift.model.mx.dic.AccountStatement2;
import com.prowidesoftware.swift.model.mx.dic.BankToCustomerStatementV02;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
public class ReceiverBicFieldGenerate extends AbstractMx2MtFieldsGenerate{
private static final Logger logger = LoggerFactory.getLogger(ReceiverBicFieldGenerate.class);
/**
* <Stmt><Acct><Svcr><FinInstnId><BICFI>
* @throws SwiftException
*/
@Override
public void fieldsGenerate() throws SwiftException{
logger.info("ReceiverBicFieldGenerate start.");
try {
MxCamt05300102 mxCamt05300102 = (MxCamt05300102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05300102 == null || mxCamt05300102.getBkToCstmrStmt() == null) {
return;
}
BankToCustomerStatementV02 bkToCstmrStmt = mxCamt05300102.getBkToCstmrStmt();
List<AccountStatement2> stmtList = bkToCstmrStmt.getStmt();
if (stmtList != null && stmtList.size() > 0) {
AccountStatement2 accountStatement2 = stmtList.get(0);
if (accountStatement2 != null
&& accountStatement2.getAcct() != null
&& accountStatement2.getAcct().getSvcr() != null
&& accountStatement2.getAcct().getSvcr().getFinInstnId() != null) {
String receiverBic = accountStatement2.getAcct().getSvcr().getFinInstnId().getBIC();
String mtReceiverBic = processBicCode(receiverBic);
if (!StringUtil.isEmpty(mtReceiverBic)) {
map.put("receiverBic", mtReceiverBic);
}
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT950 ReceiverBic error.");
}
}
}
package com.prowidesoftware.brilliance.mx2mt.mt940950.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05300102;
import com.prowidesoftware.swift.model.mx.dic.AccountStatement2;
import com.prowidesoftware.swift.model.mx.dic.BankToCustomerStatementV02;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
public class SenderBicFieldGenerate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(SenderBicFieldGenerate.class);
/**
* <Stmt><Acct><Ownr><Id><OrgId><AnyBIC> BICOrBEI
* @throws SwiftException
*/
@Override
public void fieldsGenerate() throws SwiftException{
logger.info("SenderBicFieldGenerate start.");
try {
MxCamt05300102 mxCamt05300102 = (MxCamt05300102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05300102 == null || mxCamt05300102.getBkToCstmrStmt() == null) {
return;
}
BankToCustomerStatementV02 bkToCstmrStmt = mxCamt05300102.getBkToCstmrStmt();
List<AccountStatement2> stmtList = bkToCstmrStmt.getStmt();
if (stmtList != null && stmtList.size() > 0) {
AccountStatement2 accountStatement2 = stmtList.get(0);
if (accountStatement2 != null
&& accountStatement2.getAcct() != null
&& accountStatement2.getAcct().getOwnr() != null
&& accountStatement2.getAcct().getOwnr().getId() != null
&& accountStatement2.getAcct().getOwnr().getId().getOrgId() != null) {
String senderBic = accountStatement2.getAcct().getOwnr().getId().getOrgId().getBICOrBEI();
String mtSenderBic = processBicCode(senderBic);
if (!StringUtil.isEmpty(mtSenderBic)) {
map.put("senderBic", mtSenderBic);
}
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT950 SenderBic error");
}
}
}
......@@ -54,7 +54,7 @@ public class TemplateUtil {
FileUtils.write(new File(outPut),lastStr.replaceAll("\\\\\\\\", "\\$"), encode, false);
}
} catch (Exception e) {
throw new SwiftException(ERROR.ERROR_0002,ERROR.ERROR_0002_DESC);
throw new SwiftException("ERROR", e.getMessage());
}
} else {
}
......
......@@ -138,11 +138,11 @@
<IntrBkSttlmAmt Ccy="USD">120274.34</IntrBkSttlmAmt>
<IntrBkSttlmDt>2022-04-02+08:00</IntrBkSttlmDt>
<SttlmTmIndctn>
<DbtDtTm>2022-04-02T13:35:04.807+08:00</DbtDtTm>
<CdtDtTm>2022-04-02T13:35:04.807+08:00</CdtDtTm>
<DbtDtTm>2022-04-02T13:35:04.807+01:00</DbtDtTm>
<CdtDtTm>2022-04-02T13:35:04.807+01:00</CdtDtTm>
</SttlmTmIndctn>
<SttlmTmReq>
<CLSTm>13:35:04.807+08:00</CLSTm>
<CLSTm>13:35:04.807+01:00</CLSTm>
</SttlmTmReq>
<IntrmyAgt1>
<FinInstnId>
......
......@@ -9,7 +9,7 @@ public class TestMx2MtFor103 {
Mx2MtCreateManager mx2MtCreateManager = new Mx2MtCreateManager();
String mt103 = mx2MtCreateManager.mx2mt(
new File(System.getProperty("user.dir")+"\\src\\main\\resources\\swiftXml\\MxPacs00800102.xml"),
"f:/test/MT900.txt");
"d:/test/MT103.txt");
System.out.println(mt103);
}
}
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