Commit a81d2957 by gechengyang

增加pacs010转mt204 seqA Field20和Field19相关代码

parent 686bf764
...@@ -4,8 +4,8 @@ import com.brilliance.swift.constants.Mx2MtConstants; ...@@ -4,8 +4,8 @@ import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.mx2mt.AbstractMx2MtCreator; import com.brilliance.swift.mx2mt.AbstractMx2MtCreator;
import com.brilliance.swift.mx2mt.Mx2MtContextIdentifier; import com.brilliance.swift.mx2mt.Mx2MtContextIdentifier;
import com.brilliance.swift.mx2mt.Mx2MtTagsGenerate; import com.brilliance.swift.mx2mt.Mx2MtTagsGenerate;
import com.brilliance.swift.mx2mt.mt103.impl.*; import com.brilliance.swift.mx2mt.mt204.impl.SeqAField19Generate;
import com.brilliance.swift.mx2mt.mt204.impl.Field20Generate; import com.brilliance.swift.mx2mt.mt204.impl.SeqAField20Generate;
import com.brilliance.swift.util.XmlUtil; import com.brilliance.swift.util.XmlUtil;
import org.dom4j.Document; import org.dom4j.Document;
...@@ -29,8 +29,8 @@ public class Mx2Mt204Creator extends AbstractMx2MtCreator { ...@@ -29,8 +29,8 @@ public class Mx2Mt204Creator extends AbstractMx2MtCreator {
@Override @Override
public List<Mx2MtTagsGenerate> getGenerateTagList() { public List<Mx2MtTagsGenerate> getGenerateTagList() {
List<Mx2MtTagsGenerate> fieldsGenerateList = new ArrayList<>(); List<Mx2MtTagsGenerate> fieldsGenerateList = new ArrayList<>();
fieldsGenerateList.add(new Field20Generate()); fieldsGenerateList.add(new SeqAField20Generate());
fieldsGenerateList.add(new SeqAField19Generate());
return fieldsGenerateList; return fieldsGenerateList;
} }
......
package com.brilliance.swift.mx2mt.mt204.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.NumberUtil;
import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.math.BigDecimal;
import java.util.List;
public class SeqAField19Generate extends AbstractMx2MtTagsGenerate {
private static final String NAME = "19";
@Override
public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String intrBkSttlmAmt = "";
String settleAmount = getXmlNodeValue(bodyHdrParentElementName, document, "CdtInstr.DrctDbtTxInf.IntrBkSttlmAmt");
String settleCcy = getXmlNodeValue(bodyHdrParentElementName, document, "CdtInstr.DrctDbtTxInf.IntrBkSttlmAmt@Ccy");
if (StringUtil.isNotEmpty(settleAmount) && StringUtil.isNotEmpty(settleCcy)) {
intrBkSttlmAmt = NumberUtil.formatAmt(new BigDecimal(settleAmount), settleCcy);
}
if (StringUtil.isNotEmpty(intrBkSttlmAmt)) {
tags.add(new Tag(NAME, intrBkSttlmAmt));
}
}
}
package com.brilliance.swift.mx2mt.mt204.impl; package com.brilliance.swift.mx2mt.mt204.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException; import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate; import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.StringUtil; import com.brilliance.swift.util.StringUtil;
import com.prowidesoftware.swift.model.SwiftMessage; import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.SwiftTagListBlock;
import com.prowidesoftware.swift.model.Tag; import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import java.util.List; import java.util.List;
public class Field20Generate extends AbstractMx2MtTagsGenerate { public class SeqAField20Generate extends AbstractMx2MtTagsGenerate {
private static final String NAME = "20"; private static final String NAME = "20";
@Override @Override
public void tagGenerate() throws SwiftException { public void tagGenerate() throws SwiftException {
SwiftMessage swiftMessage = context.get(SwiftMessage.class); SwiftMessage swiftMessage = context.get(SwiftMessage.class);
// AbstractMT abstractMT = context.get(AbstractMT.class);
//SwiftTagListBlock blockA=new SwiftTagListBlock();
//swiftMessage.getBlock4().append(blockA);
List<Tag> tags = swiftMessage.getBlock4().getTags(); List<Tag> tags = swiftMessage.getBlock4().getTags();
String messageId = getXmlNodeValue(bodyHdrParentElementName, document, "CdtInstr.CdtId"); String orgMessageId = getXmlNodeValue(bodyHdrParentElementName, document, "CdtInstr.CdtId");
String messageId=orgMessageId;
if (StringUtil.isNotEmpty(messageId)) { if (StringUtil.isNotEmpty(messageId)) {
if(messageId.matches("(/.*)|(.*/)|(.*//.*)")){
messageId= Mx2MtConstants.MX_TO_MT_DEFAULT_VALUE;
buildSTErrorInfo(42,"Block4/:20",orgMessageId);
}
if (messageId.length() > 16) { if (messageId.length() > 16) {
buildSTErrorInfo(13, "Block4/:20:", messageId); buildSTErrorInfo(13, "Block4/:20:", messageId);
messageId = messageId.substring(0, 15) + "+"; messageId = messageId.substring(0, 15) + "+";
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
<NbOfTxs>1</NbOfTxs> <NbOfTxs>1</NbOfTxs>
</GrpHdr> </GrpHdr>
<CdtInstr> <CdtInstr>
<CdtId>2023020815114929</CdtId> <CdtId>2023020815114921</CdtId>
<InstgAgt> <InstgAgt>
<FinInstnId> <FinInstnId>
<BICFI>HSBCHKHHUSI</BICFI> <BICFI>HSBCHKHHUSI</BICFI>
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
<Prtry>SI Direct Debit or Credit</Prtry> <Prtry>SI Direct Debit or Credit</Prtry>
</CtgyPurp> </CtgyPurp>
</PmtTpInf> </PmtTpInf>
<IntrBkSttlmAmt Ccy="USD">1000</IntrBkSttlmAmt> <IntrBkSttlmAmt Ccy="USD">1000.78</IntrBkSttlmAmt>
<IntrBkSttlmDt>2023-02-08</IntrBkSttlmDt> <IntrBkSttlmDt>2023-02-08</IntrBkSttlmDt>
<Dbtr> <Dbtr>
<FinInstnId> <FinInstnId>
......
...@@ -195,15 +195,15 @@ public class Mx2MtTest { ...@@ -195,15 +195,15 @@ public class Mx2MtTest {
@Test @Test
//Invalid message type //Invalid message type
public void test204() { public void test204() {
//test("/swiftXml/pacs.010.xml",null); test("/swiftXml/pacs.010.xml",null);
MT204 mt204=new MT204(); /* MT204 mt204=new MT204();
MT204.SequenceA sequenceA=MT204.SequenceA.newInstance(new Tag("20","SA123"),new Tag("19","123"),new Tag("30","240820")); MT204.SequenceA sequenceA=MT204.SequenceA.newInstance(new Tag("20","SA123"),new Tag("19","123"),new Tag("30","240820"));
mt204.append(sequenceA); mt204.append(sequenceA);
MT204.SequenceB sequenceB=MT204.SequenceB.newInstance(new Tag("20","SB123"),new Tag("53A","PSBCCNBJXXX")); MT204.SequenceB sequenceB=MT204.SequenceB.newInstance(new Tag("20","SB123"),new Tag("53A","PSBCCNBJXXX"));
mt204.append(sequenceB); mt204.append(sequenceB);
System.out.println(mt204.message()); System.out.println(mt204.message());*/
} }
......
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