Commit d30ba29b by chengzhuoshen

修改MXMT相互转换createdate的逻辑,取当前系统时间,之前的逻辑是取默认值

parent 4d10ee51
package com.brilliance.swift.mt2mx; package com.brilliance.swift.mt2mx;
import com.alibaba.fastjson.JSONObject; 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.util.StringUtil;
import com.brilliance.swift.vo.common.MessagePriority; import com.brilliance.swift.vo.common.MessagePriority;
import com.prowidesoftware.swift.model.SwiftBlock5; import com.prowidesoftware.swift.model.SwiftBlock5;
...@@ -8,6 +10,9 @@ import com.prowidesoftware.swift.model.SwiftBlock5Field; ...@@ -8,6 +10,9 @@ import com.prowidesoftware.swift.model.SwiftBlock5Field;
import com.prowidesoftware.swift.model.mt.AbstractMT; import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mx.AbstractMX; import com.prowidesoftware.swift.model.mx.AbstractMX;
import javax.xml.datatype.DatatypeConfigurationException;
import java.text.ParseException;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -51,10 +56,7 @@ public abstract class AbstractMt2MxCreator implements Mt2MxCreator{ ...@@ -51,10 +56,7 @@ public abstract class AbstractMt2MxCreator implements Mt2MxCreator{
Map<String, Object> toFiIdFinInstnIdMaps = new HashMap<>(); Map<String, Object> toFiIdFinInstnIdMaps = new HashMap<>();
toFiIdMaps.put("finInstnId", toFiIdFinInstnIdMaps); toFiIdMaps.put("finInstnId", toFiIdFinInstnIdMaps);
toFiIdFinInstnIdMaps.put("bicfi", receiverBic); toFiIdFinInstnIdMaps.put("bicfi", receiverBic);
String createDateStr = (String) context.get(Mt2MxContextIdentifier.EXTERNAL_PARAMETERS_CREATION_DATE, true); String createDateStr = getCreateDateStr();
if (StringUtil.isEmpty(createDateStr)) {
createDateStr = "9999-12-31T00:00:00+00:00";
}
appHdrMaps.put("creDt", createDateStr); appHdrMaps.put("creDt", createDateStr);
boolean covFlag = abstractMT.getSwiftMessage().isCOV(); boolean covFlag = abstractMT.getSwiftMessage().isCOV();
if (covFlag) { if (covFlag) {
...@@ -105,4 +107,23 @@ public abstract class AbstractMt2MxCreator implements Mt2MxCreator{ ...@@ -105,4 +107,23 @@ public abstract class AbstractMt2MxCreator implements Mt2MxCreator{
} }
finInstnIdMaps.put("bicfi", mtBicCode); finInstnIdMaps.put("bicfi", mtBicCode);
} }
protected String getCreateDateStr() {
String createDateStr = (String) context.get(Mt2MxContextIdentifier.EXTERNAL_PARAMETERS_CREATION_DATE, true);
if (StringUtil.isEmpty(createDateStr)) {
try {
Date now = (Date)context.get(Mt2MxContextIdentifier.MT_TO_MX_NOW, true);
if (now == null) {
now = new Date();
context.set(Mt2MxContextIdentifier.MT_TO_MX_NOW, now);
}
createDateStr = DateUtil.parseXMLGregorianCalendar(now).toXMLFormat();
} catch (DatatypeConfigurationException e) {
throw new SwiftException(e.getMessage());
} catch (ParseException e) {
throw new SwiftException(e.getMessage());
}
}
return createDateStr;
}
} }
...@@ -9,6 +9,7 @@ import com.brilliance.swift.util.SwiftTransferUtil; ...@@ -9,6 +9,7 @@ import com.brilliance.swift.util.SwiftTransferUtil;
import com.brilliance.swift.vo.common.*; import com.brilliance.swift.vo.common.*;
import com.prowidesoftware.swift.model.field.Field23E; import com.prowidesoftware.swift.model.field.Field23E;
import javax.xml.datatype.DatatypeConfigurationException;
import java.text.ParseException; import java.text.ParseException;
import java.util.*; import java.util.*;
import java.util.regex.Matcher; import java.util.regex.Matcher;
...@@ -32,6 +33,8 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField { ...@@ -32,6 +33,8 @@ public abstract class AbstractMt2MxParseField implements Mt2MxParseField {
public void initJsonMaps() { public void initJsonMaps() {
jsonMaps = (Map<String, Object>)context.get(Mt2MxContextIdentifier.MT_TO_MX_JSON_MAP, true); jsonMaps = (Map<String, Object>)context.get(Mt2MxContextIdentifier.MT_TO_MX_JSON_MAP, true);
} }
/** /**
* MT 转 MX 转换函数开始 * MT 转 MX 转换函数开始
*/ */
......
...@@ -13,6 +13,8 @@ public class Mt2MxContextIdentifier { ...@@ -13,6 +13,8 @@ public class Mt2MxContextIdentifier {
public static final String MT_RECEIVE_BIC = "mt.receive.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_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";
/** /**
* 外部参数 * 外部参数
*/ */
......
...@@ -29,7 +29,7 @@ public class Mt2MxCamt029001Creator extends AbstractMt2MxCreator { ...@@ -29,7 +29,7 @@ public class Mt2MxCamt029001Creator extends AbstractMt2MxCreator {
jsonMaps.put("rsltnOfInvstgtn", rsltnOfInvstgtnMaps); jsonMaps.put("rsltnOfInvstgtn", rsltnOfInvstgtnMaps);
Map<String, Object> assgnmtMaps = new HashMap<>(); Map<String, Object> assgnmtMaps = new HashMap<>();
rsltnOfInvstgtnMaps.put("assgnmt", assgnmtMaps); rsltnOfInvstgtnMaps.put("assgnmt", assgnmtMaps);
assgnmtMaps.put("creDtTm", "9999-12-31T00:00:00+00:00"); assgnmtMaps.put("creDtTm", getCreateDateStr());
Map<String, Object> cxlDtlsMaps = new HashMap<>(); Map<String, Object> cxlDtlsMaps = new HashMap<>();
JSONArray cxlDtlsJsonArray = new JSONArray(); JSONArray cxlDtlsJsonArray = new JSONArray();
......
...@@ -29,7 +29,7 @@ public class Mt2MxCamt056001Creator extends AbstractMt2MxCreator { ...@@ -29,7 +29,7 @@ public class Mt2MxCamt056001Creator extends AbstractMt2MxCreator {
jsonMaps.put("fiToFIPmtCxlReq", fiToFIPmtCxlReqMaps); jsonMaps.put("fiToFIPmtCxlReq", fiToFIPmtCxlReqMaps);
Map<String, Object> assgnmtMaps = new HashMap<>(); Map<String, Object> assgnmtMaps = new HashMap<>();
fiToFIPmtCxlReqMaps.put("assgnmt", assgnmtMaps); fiToFIPmtCxlReqMaps.put("assgnmt", assgnmtMaps);
assgnmtMaps.put("creDtTm", "9999-12-31T00:00:00+00:00"); assgnmtMaps.put("creDtTm", getCreateDateStr());
Map<String, Object> undrlygMaps = new HashMap<>(); Map<String, Object> undrlygMaps = new HashMap<>();
JSONArray undrlygJsonArray = new JSONArray(); JSONArray undrlygJsonArray = new JSONArray();
......
...@@ -29,7 +29,7 @@ public class Mt2MxPacs008001Creator extends AbstractMt2MxCreator { ...@@ -29,7 +29,7 @@ public class Mt2MxPacs008001Creator extends AbstractMt2MxCreator {
jsonMaps.put("fiToFICstmrCdtTrf", fiToFICstmrCdtTrfMaps); jsonMaps.put("fiToFICstmrCdtTrf", fiToFICstmrCdtTrfMaps);
Map<String, Object> grpHdrMaps = new HashMap<>(); Map<String, Object> grpHdrMaps = new HashMap<>();
fiToFICstmrCdtTrfMaps.put("grpHdr", grpHdrMaps); fiToFICstmrCdtTrfMaps.put("grpHdr", grpHdrMaps);
grpHdrMaps.put("creDtTm", "9999-12-31T00:00:00+00:00"); grpHdrMaps.put("creDtTm", getCreateDateStr());
grpHdrMaps.put("nbOfTxs", "1"); grpHdrMaps.put("nbOfTxs", "1");
Map<String, Object> cdtTrfTxInfMaps = new HashMap<>(); Map<String, Object> cdtTrfTxInfMaps = new HashMap<>();
......
...@@ -29,7 +29,7 @@ public class Mt2MxPacs009001Creator extends AbstractMt2MxCreator { ...@@ -29,7 +29,7 @@ public class Mt2MxPacs009001Creator extends AbstractMt2MxCreator {
jsonMaps.put("fiCdtTrf", fiCdtTrfMaps); jsonMaps.put("fiCdtTrf", fiCdtTrfMaps);
Map<String, Object> grpHdrMaps = new HashMap<>(); Map<String, Object> grpHdrMaps = new HashMap<>();
fiCdtTrfMaps.put("grpHdr", grpHdrMaps); fiCdtTrfMaps.put("grpHdr", grpHdrMaps);
grpHdrMaps.put("creDtTm", "9999-12-31T00:00:00+00:00"); grpHdrMaps.put("creDtTm", getCreateDateStr());
grpHdrMaps.put("nbOfTxs", "1"); grpHdrMaps.put("nbOfTxs", "1");
Map<String, Object> cdtTrfTxInfMaps = new HashMap<>(); Map<String, Object> cdtTrfTxInfMaps = new HashMap<>();
......
...@@ -22,8 +22,10 @@ import org.dom4j.Document; ...@@ -22,8 +22,10 @@ import org.dom4j.Document;
import java.io.File; import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException; import java.util.ArrayList;
import java.util.*; import java.util.Calendar;
import java.util.Date;
import java.util.List;
public abstract class AbstractMx2MtCreator implements Mx2MtCreator { public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
...@@ -195,20 +197,14 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator { ...@@ -195,20 +197,14 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
} }
Date outputDate = (Date)context.get(Mx2MtConstants.OUTPUT_DATE, true); Date outputDate = (Date)context.get(Mx2MtConstants.OUTPUT_DATE, true);
if (outputDate == null) { if (outputDate == null) {
try { outputDate = new Date();
outputDate = DateUtil.parseDate("9999-12-31", "yyyy-MM-dd");
} catch (ParseException e) {
throw new SwiftException("ERROR", e.getMessage());
}
} }
String applicationMode = (String)context.get(Mx2MtConstants.APPLICATION_MODE, true); String applicationMode = (String)context.get(Mx2MtConstants.APPLICATION_MODE, true);
if ("O".equalsIgnoreCase(applicationMode)) { if ("O".equalsIgnoreCase(applicationMode)) {
SwiftBlock2Output block2 = new SwiftBlock2Output(); SwiftBlock2Output block2 = new SwiftBlock2Output();
block2.setMessageType(getMtType()); block2.setMessageType(getMtType());
//block2.setSenderInputTime(DateUtil.format(inputDate, "HHmm")); block2.setSenderInputTime(DateUtil.format(inputDate, "HHmm"));
//block2.setMIRDate(DateUtil.format(inputDate, "yyMMdd")); block2.setMIRDate(DateUtil.format(inputDate, "yyMMdd"));
block2.setSenderInputTime("0000");
block2.setMIRDate("991231");
block2.setMIRLogicalTerminal(processBicCode(senderBic)); block2.setMIRLogicalTerminal(processBicCode(senderBic));
block2.setMIRSessionNumber(getRandomNumber(4)); block2.setMIRSessionNumber(getRandomNumber(4));
block2.setMIRSequenceNumber(getRandomNumber(6)); block2.setMIRSequenceNumber(getRandomNumber(6));
......
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