Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
swiftMtMx
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
isc-v3.1-tmp
swiftMtMx
Commits
84b37ad9
Commit
84b37ad9
authored
May 05, 2023
by
s_guodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复NullPointException
parent
2a7541da
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
34 deletions
+48
-34
AbstractMx2MtTagsGenerate.java
...com/brilliance/swift/mx2mt/AbstractMx2MtTagsGenerate.java
+48
-34
No files found.
swiftCore/src/main/java/com/brilliance/swift/mx2mt/AbstractMx2MtTagsGenerate.java
View file @
84b37ad9
...
...
@@ -7,7 +7,6 @@ import com.brilliance.swift.vo.MxMtReasonCodeInfo;
import
com.brilliance.swift.vo.SwiftTranslationErrorInfo
;
import
com.brilliance.swift.vo.SwiftTranslationReport
;
import
com.brilliance.swift.vo.common.*
;
import
com.prowidesoftware.swift.model.SwiftMessage
;
import
com.prowidesoftware.swift.model.Tag
;
import
org.dom4j.Document
;
...
...
@@ -48,12 +47,12 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
}
String
value
=
XmlUtil
.
getXmlNodeValue
(
document
,
path
);
if
(
StringUtil
.
isNotEmpty
(
value
))
{
Mx2MtListener
mx2MtListener
=
(
Mx2MtListener
)
context
.
get
(
Mx2MtContextIdentifier
.
MX_TO_MT_LISTENER_CLASS
,
true
);
Mx2MtListener
mx2MtListener
=
(
Mx2MtListener
)
context
.
get
(
Mx2MtContextIdentifier
.
MX_TO_MT_LISTENER_CLASS
,
true
);
if
(
mx2MtListener
!=
null
)
{
mx2MtListener
.
process
(
path
);
//如果存在监听器且得到的值不为空,则执行监听操作
}
}
return
value
;
return
value
==
null
?
""
:
value
;
}
protected
int
getXmlNodeCounts
(
String
parentPath
,
Document
document
,
String
path
)
{
...
...
@@ -65,6 +64,7 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
/**
* 封装报文转换详细报告
*
* @param id
* @param location
* @param originalValue
...
...
@@ -75,13 +75,13 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
SwiftTranslationErrorInfo
errorInfo
=
SwiftTransferUtil
.
getSwiftTranslationErrorInfoById
(
id
);
if
(
errorInfo
==
null
)
return
;
if
(
StringUtil
.
isEmpty
(
location
))
{
location
=
(
String
)
context
.
get
(
Mx2MtContextIdentifier
.
MX_TO_MT_ERROR_LOCATION
,
true
);
location
=
(
String
)
context
.
get
(
Mx2MtContextIdentifier
.
MX_TO_MT_ERROR_LOCATION
,
true
);
}
errorInfo
.
setLocation
(
location
);
errorInfo
.
setOriginalValue
(
originalValue
);
List
<
SwiftTranslationErrorInfo
>
errorInfos
=
str
.
getErrorInfos
();
boolean
existFlag
=
false
;
for
(
int
i
=
0
;
i
<
errorInfos
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
errorInfos
.
size
();
i
++)
{
if
(
SwiftTransferUtil
.
compareStErrorInfo
(
errorInfo
,
errorInfos
.
get
(
i
)))
{
existFlag
=
true
;
break
;
...
...
@@ -91,8 +91,10 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
str
.
addErrorInfo
(
errorInfo
);
}
}
/**
* 如何第二行以 : 或者 - 开始,替换成 .
*
* @param value
* @param location
* @return
...
...
@@ -105,7 +107,7 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
if
(
values
.
length
==
1
)
return
value
;
String
newValue
=
values
[
0
];
boolean
flag
=
false
;
for
(
int
i
=
1
;
i
<
values
.
length
;
i
++)
{
for
(
int
i
=
1
;
i
<
values
.
length
;
i
++)
{
if
(
values
[
i
].
startsWith
(
":"
)
||
values
[
i
].
startsWith
(
"-"
))
{
flag
=
true
;
newValue
+=
Mx2MtConstants
.
NEW_LINE
+
"."
+
values
[
i
].
substring
(
1
);
...
...
@@ -120,9 +122,11 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
}
//转换函数方法区开始
/**
* MX InstructionForCreditorAgent转23域
* 前提就是code在{HOLD,CHQB,PHOB,TELB}里面
*
* @return
*/
protected
List
<
String
>
mx_to_mt23E
(
String
code
,
String
instructionInformation
)
{
...
...
@@ -137,10 +141,10 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
if
(
StringUtil
.
isEmpty
(
instructionInformation
))
{
list
.
add
(
code
);
}
else
{
String
[]
instrInfos
=
instructionInformation
.
split
(
"(?=/"
+
chqbCode
+
"/|/"
+
holdCode
+
"/|/"
+
phobCode
+
"/|/"
+
telbCode
+
"/)"
);
String
[]
instrInfos
=
instructionInformation
.
split
(
"(?=/"
+
chqbCode
+
"/|/"
+
holdCode
+
"/|/"
+
phobCode
+
"/|/"
+
telbCode
+
"/)"
);
for
(
String
ins
:
instrInfos
)
{
if
(
ins
.
startsWith
(
"/"
+
chqbCode
+
"/"
)
||
ins
.
startsWith
(
"/"
+
holdCode
+
"/"
)
||
ins
.
startsWith
(
"/"
+
phobCode
+
"/"
)
||
ins
.
startsWith
(
"/"
+
telbCode
+
"/"
))
{
if
(
ins
.
startsWith
(
"/"
+
chqbCode
+
"/"
)
||
ins
.
startsWith
(
"/"
+
holdCode
+
"/"
)
||
ins
.
startsWith
(
"/"
+
phobCode
+
"/"
)
||
ins
.
startsWith
(
"/"
+
telbCode
+
"/"
))
{
String
tmpCode
=
ins
.
substring
(
1
,
5
);
String
tmpInstrInf
=
ins
.
substring
(
6
);
if
(
StringUtil
.
isNotEmpty
(
tmpInstrInf
))
{
...
...
@@ -168,6 +172,7 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
/**
* MX InstructionForCreditorAgent转23域
* 前提就是code不存在,只有instructionInformation
*
* @return
*/
protected
List
<
String
>
mx_to_mt23E_BIS
(
String
instructionInformation
)
{
...
...
@@ -176,10 +181,10 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
String
holdCode
=
ExternalCreditorAgentInstructionCode
.
HOLD
.
value
();
String
phobCode
=
ExternalCreditorAgentInstructionCode
.
PHOB
.
value
();
String
telbCode
=
ExternalCreditorAgentInstructionCode
.
TELB
.
value
();
String
[]
instrInfos
=
instructionInformation
.
split
(
"(?=/"
+
chqbCode
+
"/|/"
+
holdCode
+
"/|/"
+
phobCode
+
"/|/"
+
telbCode
+
"/)"
);
String
[]
instrInfos
=
instructionInformation
.
split
(
"(?=/"
+
chqbCode
+
"/|/"
+
holdCode
+
"/|/"
+
phobCode
+
"/|/"
+
telbCode
+
"/)"
);
for
(
String
ins
:
instrInfos
)
{
if
(
ins
.
startsWith
(
"/"
+
chqbCode
+
"/"
)
||
ins
.
startsWith
(
"/"
+
holdCode
+
"/"
)
||
ins
.
startsWith
(
"/"
+
phobCode
+
"/"
)
||
ins
.
startsWith
(
"/"
+
telbCode
+
"/"
))
{
if
(
ins
.
startsWith
(
"/"
+
chqbCode
+
"/"
)
||
ins
.
startsWith
(
"/"
+
holdCode
+
"/"
)
||
ins
.
startsWith
(
"/"
+
phobCode
+
"/"
)
||
ins
.
startsWith
(
"/"
+
telbCode
+
"/"
))
{
String
tmpCode
=
ins
.
substring
(
1
,
5
);
String
tmpInstrInf
=
ins
.
substring
(
6
);
if
(
StringUtil
.
isNotEmpty
(
tmpInstrInf
))
{
...
...
@@ -195,8 +200,10 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
}
return
list
;
}
/**
* 返回代理行下面的bicCode
*
* @param agtPath
* @return
*/
...
...
@@ -204,8 +211,10 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
String
bicCode
=
getXmlNodeValue
(
null
,
document
,
agtPath
+
".FinInstnId.BICFI"
);
return
bicCode
;
}
/**
* 返回账号行下面的bicCode
*
* @param partyPath
* @return
*/
...
...
@@ -213,8 +222,8 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
String
bicCode
=
getXmlNodeValue
(
null
,
document
,
partyPath
+
".Id.OrgId.AnyBIC"
);
return
bicCode
;
}
/**
*
* @param settlementMethod
* @param accountPath
* @return
...
...
@@ -226,12 +235,14 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
}
return
mtAccount
;
}
/**
* 如果CashAccount38.Id.iban有值,account = "/" + CashAccount38.Id.iban
* 否则 如果CashAccount38.Id.Othr.Id有值,
* 如果CashAccount38.Id.Othr.SchmeNm.Cd = CUID 并且 CashAccount38.Id.Othr.Id长度等于6
* account = "//CH" + CashAccount38.Id.Othr.Id
* 否则 account = "/" + CashAccount38.Id.Othr.Id
* 否则 如果CashAccount38.Id.Othr.Id有值,
* 如果CashAccount38.Id.Othr.SchmeNm.Cd = CUID 并且 CashAccount38.Id.Othr.Id长度等于6
* account = "//CH" + CashAccount38.Id.Othr.Id
* 否则 account = "/" + CashAccount38.Id.Othr.Id
*
* @param accountPath
* @return
*/
...
...
@@ -239,7 +250,7 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
String
mtAccount
=
""
;
String
ibanAcct
=
getXmlNodeValue
(
null
,
document
,
accountPath
+
".Id.IBAN"
);
if
(
StringUtil
.
isNotEmpty
(
ibanAcct
))
{
mtAccount
=
"/"
+
ibanAcct
;
mtAccount
=
"/"
+
ibanAcct
;
}
else
{
String
account
=
getXmlNodeValue
(
null
,
document
,
accountPath
+
".Id.Othr.Id"
);
if
(
StringUtil
.
isNotEmpty
(
account
))
{
...
...
@@ -261,8 +272,9 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
* MTClearingSystem = //+MTClearingSystemCode + ClearingSystemMemberIdentification2.MmbId
* (MTClearingSytemCode和MXClearingSystemCode Mapping规则参考word文档Annex章节)
* 2.如果BIC存在,MTClearingSystem包含FW,最终取值为//FW
*
如果BIC存在,MTClearingSystem包含CP或者RU或者SW,最终取值为空
* 如果BIC存在,MTClearingSystem包含CP或者RU或者SW,最终取值为空
* 3.如果BIC不存在,最终取值就是MTClearingSystem
*
* @return
*/
protected
String
mx_to_mtClearingIdentifier
(
String
agtPath
)
{
...
...
@@ -296,16 +308,17 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
/**
* MX_To_MTClearingIdentifierAndChannel(BranchAndFinancialInstitutionIdentification6 agt)
* 前提是CdtTrfTxInf.PmtTpInf.ClrChanl = RTGS
*
*
<p>
* 1.如果agt.FinInstnId.ClrSysMmbId.ClrSysId.Cd能mapping到MT的clearingSystemCode,则取MTClearingSystemCode,否则MTClearingSystemCode直接取agt.FinInstnId.ClrSysMmbId.ClrSysId.Cd
* MTClearingSystem = //+MTClearingSystemCode + agt.FinInstnId.ClrSysMmbId.MmbId
* (MTClearingSytemCode和MXClearingSystemCode Mapping规则参考word文档Annex章节)
* 2如果agt.FinInstnId.BICFI存在,
* 如果BIC的5-6位等于US,MTAccount=//FW,如果agt.FinInstnId.ClrSysMmbId.ClrSysId.Cd存在,报T20075警告
* 否则MTAccount=//RT,如果agt.FinInstnId.ClrSysMmbId.ClrSysId.Cd存在,报T20077警告
* 如果agt.FinInstnId.BICFI不存在,
* MTClearingSystem第3-4包含FW,MTAccount=MTClearingSystem
* 否则如果MTClearingSystem长度小于32,MTAccount=//RT+MTClearingSystem,否则MTAccount=MTClearingSystem
* 如果BIC的5-6位等于US,MTAccount=//FW,如果agt.FinInstnId.ClrSysMmbId.ClrSysId.Cd存在,报T20075警告
* 否则MTAccount=//RT,如果agt.FinInstnId.ClrSysMmbId.ClrSysId.Cd存在,报T20077警告
* 如果agt.FinInstnId.BICFI不存在,
* MTClearingSystem第3-4包含FW,MTAccount=MTClearingSystem
* 否则如果MTClearingSystem长度小于32,MTAccount=//RT+MTClearingSystem,否则MTAccount=MTClearingSystem
*
* @param agtPath
* @return
*/
...
...
@@ -355,14 +368,15 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
* 无结构性地址的取值规则:MX_To_MTFinancialInstitutionNameAndUnstructuredAddress(AgentObj)
* addressCount =AgentObj.FinInstnId.PostalAddress.AddressLine
* 1.先组装Name
*
Name = AgentObj.FinInstnId.Nm
*
如果Name.length<1,Name = "NOTPROVIDED"
*
如果addrescount >= 3,并且Name长度大于35,Name只截取到34位,最后一位用+表示
*
否则 如果Name长度大于70,Name只截取到69位,最后一位用+表示(表示name Address中name最多占2行)
* Name = AgentObj.FinInstnId.Nm
* 如果Name.length<1,Name = "NOTPROVIDED"
* 如果addrescount >= 3,并且Name长度大于35,Name只截取到34位,最后一位用+表示
* 否则 如果Name长度大于70,Name只截取到69位,最后一位用+表示(表示name Address中name最多占2行)
* 2.再组装address
*
address = AgentObj.FinInstnId.PostalAddress.AddressLine(i),如果长度超过35位就截取到35位
* address = AgentObj.FinInstnId.PostalAddress.AddressLine(i),如果长度超过35位就截取到35位
* 3.最后name address 组成 4 *35 格式
* @param nameAddressPrefixPath 名字和地址的前缀路径
*
* @param nameAddressPrefixPath 名字和地址的前缀路径
* @return
*/
protected
String
mx_to_mtFinancialInstitutionNameAndUnstructuredAddress
(
String
nameAddressPrefixPath
)
{
...
...
@@ -388,11 +402,11 @@ public abstract class AbstractMx2MtTagsGenerate implements Mx2MtTagsGenerate {
}
int
addressRemainLine
=
3
;
//address剩余的行数
if
(
mxName
.
length
()
>
35
)
addressRemainLine
=
2
;
String
mtNameAddress
=
StringUtil
.
getStringByEnter
(
mxName
,
35
,
4
-
addressRemainLine
);
String
mtNameAddress
=
StringUtil
.
getStringByEnter
(
mxName
,
35
,
4
-
addressRemainLine
);
if
(
addressLineCount
>
0
)
{
for
(
int
i
=
0
;
i
<
addressLineCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
addressLineCount
;
i
++)
{
if
(
i
==
addressRemainLine
)
break
;
String
mxAddress
=
getXmlNodeValue
(
null
,
document
,
nameAddressPrefixPath
+
".PstlAdr.AdrLine("
+
i
+
")"
);
String
mxAddress
=
getXmlNodeValue
(
null
,
document
,
nameAddressPrefixPath
+
".PstlAdr.AdrLine("
+
i
+
")"
);
if
(
mxAddress
.
length
()
>
35
)
{
buildSTErrorInfo
(
12
,
null
,
mxAddress
);
mxAddress
=
mxAddress
.
substring
(
0
,
34
)
+
"+"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment