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
904a5834
Commit
904a5834
authored
Jun 19, 2022
by
chengzhuoshen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MT2MX,mt103转pacs008001
parent
57dda6f4
Hide whitespace changes
Inline
Side-by-side
Showing
57 changed files
with
4777 additions
and
48 deletions
+4777
-48
AbstractMt2MxCreator.java
...java/com/brilliance/swift/mt2mx/AbstractMt2MxCreator.java
+108
-0
AbstractMt2MxParseField.java
...a/com/brilliance/swift/mt2mx/AbstractMt2MxParseField.java
+1427
-0
Mt2MxContext.java
...rc/main/java/com/brilliance/swift/mt2mx/Mt2MxContext.java
+7
-0
Mt2MxContextIdentifier.java
...va/com/brilliance/swift/mt2mx/Mt2MxContextIdentifier.java
+20
-0
Mt2MxCreator.java
...rc/main/java/com/brilliance/swift/mt2mx/Mt2MxCreator.java
+13
-0
Mt2MxCreatorManager.java
.../java/com/brilliance/swift/mt2mx/Mt2MxCreatorManager.java
+49
-0
Mt2MxParseField.java
...main/java/com/brilliance/swift/mt2mx/Mt2MxParseField.java
+6
-0
AbstractMt2MxPacs008001ParseField.java
...t/mt2mx/pacs008001/AbstractMt2MxPacs008001ParseField.java
+26
-0
Mt2MxPacs008001Creator.java
...liance/swift/mt2mx/pacs008001/Mt2MxPacs008001Creator.java
+107
-0
Pacs00801Parse13CField.java
...e/swift/mt2mx/pacs008001/impl/Pacs00801Parse13CField.java
+66
-0
Pacs00801Parse20Field.java
...ce/swift/mt2mx/pacs008001/impl/Pacs00801Parse20Field.java
+32
-0
Pacs00801Parse23BField.java
...e/swift/mt2mx/pacs008001/impl/Pacs00801Parse23BField.java
+11
-0
Pacs00801Parse23EField.java
...e/swift/mt2mx/pacs008001/impl/Pacs00801Parse23EField.java
+84
-0
Pacs00801Parse26TField.java
...e/swift/mt2mx/pacs008001/impl/Pacs00801Parse26TField.java
+31
-0
Pacs00801Parse32AField.java
...e/swift/mt2mx/pacs008001/impl/Pacs00801Parse32AField.java
+38
-0
Pacs00801Parse33BField.java
...e/swift/mt2mx/pacs008001/impl/Pacs00801Parse33BField.java
+28
-0
Pacs00801Parse36Field.java
...ce/swift/mt2mx/pacs008001/impl/Pacs00801Parse36Field.java
+24
-0
Pacs00801Parse50Field.java
...ce/swift/mt2mx/pacs008001/impl/Pacs00801Parse50Field.java
+158
-0
Pacs00801Parse52Field.java
...ce/swift/mt2mx/pacs008001/impl/Pacs00801Parse52Field.java
+97
-0
Pacs00801Parse53Field.java
...ce/swift/mt2mx/pacs008001/impl/Pacs00801Parse53Field.java
+103
-0
Pacs00801Parse54Field.java
...ce/swift/mt2mx/pacs008001/impl/Pacs00801Parse54Field.java
+186
-0
Pacs00801Parse55Field.java
...ce/swift/mt2mx/pacs008001/impl/Pacs00801Parse55Field.java
+188
-0
Pacs00801Parse56Field.java
...ce/swift/mt2mx/pacs008001/impl/Pacs00801Parse56Field.java
+190
-0
Pacs00801Parse57Field.java
...ce/swift/mt2mx/pacs008001/impl/Pacs00801Parse57Field.java
+254
-0
Pacs00801Parse59Field.java
...ce/swift/mt2mx/pacs008001/impl/Pacs00801Parse59Field.java
+143
-0
Pacs00801Parse70Field.java
...ce/swift/mt2mx/pacs008001/impl/Pacs00801Parse70Field.java
+49
-0
Pacs00801Parse71Field.java
...ce/swift/mt2mx/pacs008001/impl/Pacs00801Parse71Field.java
+105
-0
Pacs00801Parse72Field.java
...ce/swift/mt2mx/pacs008001/impl/Pacs00801Parse72Field.java
+24
-0
Pacs00801Parse77BField.java
...e/swift/mt2mx/pacs008001/impl/Pacs00801Parse77BField.java
+89
-0
Pacs00801ParseSetlAcctField.java
...ft/mt2mx/pacs008001/impl/Pacs00801ParseSetlAcctField.java
+89
-0
Pacs00801ParseSetlMtdField.java
...ift/mt2mx/pacs008001/impl/Pacs00801ParseSetlMtdField.java
+29
-0
AbstractSettlementMethodAnalyzer.java
...swift/mt2mx/setlmtd/AbstractSettlementMethodAnalyzer.java
+40
-0
SettlementMethodAnalyzer.java
...lliance/swift/mt2mx/setlmtd/SettlementMethodAnalyzer.java
+11
-0
SettlementMethodAnalyzerFactory.java
.../swift/mt2mx/setlmtd/SettlementMethodAnalyzerFactory.java
+109
-0
Field53A54AAnalyzer.java
...lliance/swift/mt2mx/setlmtd/impl/Field53A54AAnalyzer.java
+47
-0
Field53A54BAnalyzer.java
...lliance/swift/mt2mx/setlmtd/impl/Field53A54BAnalyzer.java
+41
-0
Field53A54DAnalyzer.java
...lliance/swift/mt2mx/setlmtd/impl/Field53A54DAnalyzer.java
+41
-0
Field53B54aAnalyzer.java
...lliance/swift/mt2mx/setlmtd/impl/Field53B54aAnalyzer.java
+33
-0
Field53D54aAnalyzer.java
...lliance/swift/mt2mx/setlmtd/impl/Field53D54aAnalyzer.java
+36
-0
FieldNone5354Analyzer.java
...iance/swift/mt2mx/setlmtd/impl/FieldNone5354Analyzer.java
+13
-0
FieldOnly53AAnalyzer.java
...liance/swift/mt2mx/setlmtd/impl/FieldOnly53AAnalyzer.java
+45
-0
FieldOnly53BAnalyzer.java
...liance/swift/mt2mx/setlmtd/impl/FieldOnly53BAnalyzer.java
+33
-0
FieldOnly53DAnalyzer.java
...liance/swift/mt2mx/setlmtd/impl/FieldOnly53DAnalyzer.java
+33
-0
FieldOnly54AAnalyzer.java
...liance/swift/mt2mx/setlmtd/impl/FieldOnly54AAnalyzer.java
+26
-0
FieldOnly54BAnalyzer.java
...liance/swift/mt2mx/setlmtd/impl/FieldOnly54BAnalyzer.java
+14
-0
FieldOnly54DAnalyzer.java
...liance/swift/mt2mx/setlmtd/impl/FieldOnly54DAnalyzer.java
+14
-0
AbstractMx2MtCreator.java
...java/com/brilliance/swift/mx2mt/AbstractMx2MtCreator.java
+21
-7
SwiftTransferUtil.java
...ain/java/com/brilliance/swift/util/SwiftTransferUtil.java
+74
-4
VoSettlementMethodHelper.java
...ava/com/brilliance/swift/vo/VoSettlementMethodHelper.java
+90
-0
ClearingSystemMemberCode.java
.../brilliance/swift/vo/common/ClearingSystemMemberCode.java
+10
-0
LocalInstrumentCode.java
...a/com/brilliance/swift/vo/common/LocalInstrumentCode.java
+120
-0
MT103.txt
swiftCore/src/main/resources/swiftTxt/MT103.txt
+33
-18
MxPacs00800109.xml
swiftCore/src/main/resources/swiftXml/MxPacs00800109.xml
+0
-16
Test.java
...e/src/test/java/com/brilliance/mt2mx/pacs008001/Test.java
+22
-0
Test.java
...ore/src/test/java/com/brilliance/mx2mtmap/mt103/Test.java
+33
-3
AbstractMX.java
...n/java/com/prowidesoftware/swift/model/mx/AbstractMX.java
+2
-0
AppHdrAdapter.java
...ava/com/prowidesoftware/swift/model/mx/AppHdrAdapter.java
+55
-0
No files found.
swiftCore/src/main/java/com/brilliance/swift/mt2mx/AbstractMt2MxCreator.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
;
import
com.alibaba.fastjson.JSONObject
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.vo.common.MessagePriority
;
import
com.prowidesoftware.swift.model.SwiftBlock5
;
import
com.prowidesoftware.swift.model.SwiftBlock5Field
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
com.prowidesoftware.swift.model.mx.AbstractMX
;
import
java.util.HashMap
;
import
java.util.Map
;
public
abstract
class
AbstractMt2MxCreator
implements
Mt2MxCreator
{
protected
Mt2MxContext
context
;
public
Mt2MxContext
getContext
()
{
return
context
;
}
public
void
setContext
(
Mt2MxContext
context
)
{
this
.
context
=
context
;
}
protected
Map
<
String
,
Object
>
jsonMaps
=
new
HashMap
<>();
@Override
public
void
preProcess
()
{
context
.
set
(
Mt2MxContextIdentifier
.
MT_TO_MX_JSON_MAP
,
jsonMaps
);
Map
<
String
,
Object
>
appHdrMaps
=
new
HashMap
<>();
jsonMaps
.
put
(
"appHdr"
,
appHdrMaps
);
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
String
senderBic
=
abstractMT
.
getSender
();
senderBic
=
senderBic
.
substring
(
0
,
8
)
+
senderBic
.
substring
(
9
,
12
);
context
.
set
(
Mt2MxContextIdentifier
.
MT_SEND_BIC
,
senderBic
);
Map
<
String
,
Object
>
frMaps
=
new
HashMap
<>();
appHdrMaps
.
put
(
"fr"
,
frMaps
);
Map
<
String
,
Object
>
frFiIdMaps
=
new
HashMap
<>();
frMaps
.
put
(
"fiId"
,
frFiIdMaps
);
Map
<
String
,
Object
>
frFiIdFinInstnIdMaps
=
new
HashMap
<>();
frFiIdMaps
.
put
(
"finInstnId"
,
frFiIdFinInstnIdMaps
);
frFiIdFinInstnIdMaps
.
put
(
"bicfi"
,
senderBic
);
String
receiverBic
=
abstractMT
.
getReceiver
();
receiverBic
=
receiverBic
.
substring
(
0
,
8
)
+
receiverBic
.
substring
(
9
,
12
);
context
.
set
(
Mt2MxContextIdentifier
.
MT_RECEIVE_BIC
,
receiverBic
);
Map
<
String
,
Object
>
toMaps
=
new
HashMap
<>();
appHdrMaps
.
put
(
"to"
,
toMaps
);
Map
<
String
,
Object
>
toFiIdMaps
=
new
HashMap
<>();
toMaps
.
put
(
"fiId"
,
toFiIdMaps
);
Map
<
String
,
Object
>
toFiIdFinInstnIdMaps
=
new
HashMap
<>();
toFiIdMaps
.
put
(
"finInstnId"
,
toFiIdFinInstnIdMaps
);
toFiIdFinInstnIdMaps
.
put
(
"bicfi"
,
receiverBic
);
String
createDateStr
=
(
String
)
context
.
get
(
Mt2MxContextIdentifier
.
EXTERNAL_PARAMETERS_CREATION_DATE
,
true
);
if
(
StringUtil
.
isEmpty
(
createDateStr
))
{
createDateStr
=
"9999-12-31T00:00:00+00:00"
;
}
appHdrMaps
.
put
(
"creDt"
,
createDateStr
);
boolean
covFlag
=
abstractMT
.
getSwiftMessage
().
isCOV
();
if
(
covFlag
)
{
appHdrMaps
.
put
(
"bizSvc"
,
"swift.cbprplus.cov.02"
);
}
else
{
appHdrMaps
.
put
(
"bizSvc"
,
"swift.cbprplus.02"
);
}
String
priority
=
abstractMT
.
getMessagePriority
();
if
(
"U"
.
equals
(
priority
))
{
appHdrMaps
.
put
(
"prty"
,
MessagePriority
.
HIGH
.
value
());
}
else
{
// "N".equals(priority)
appHdrMaps
.
put
(
"prty"
,
MessagePriority
.
NORM
.
value
());
}
SwiftBlock5
block5
=
abstractMT
.
getSwiftMessage
().
getBlock5
();
if
(
block5
!=
null
&&
block5
.
containsTag
(
SwiftBlock5Field
.
PDE
.
name
()))
{
appHdrMaps
.
put
(
"pssblDplct"
,
Boolean
.
TRUE
);
}
else
{
appHdrMaps
.
put
(
"pssblDplct"
,
Boolean
.
FALSE
);
}
}
@Override
public
void
postProcess
()
{
String
swiftGsonStr
=
new
JSONObject
(
jsonMaps
).
toJSONString
();
AbstractMX
abstractMX
=
AbstractMX
.
fromJson
(
swiftGsonStr
);
String
xml
=
abstractMX
.
message
();
context
.
set
(
Mt2MxContextIdentifier
.
MT_TO_MX_XML
,
xml
);
}
/**
* 公共方法
*/
/**
* FinInstnId.BICFI = mtBicCode
* @param mtBicCode
* @param maps
*/
protected
void
mt_to_mxBICFI
(
String
mtBicCode
,
Map
<
String
,
Object
>
maps
)
{
if
(
StringUtil
.
isEmpty
(
mtBicCode
))
{
return
;
}
Map
<
String
,
Object
>
finInstnIdMaps
=
null
;
if
(
maps
.
containsKey
(
"finInstnId"
))
{
finInstnIdMaps
=
(
Map
<
String
,
Object
>)
maps
.
get
(
"finInstnId"
);
}
else
{
finInstnIdMaps
=
new
HashMap
<>();
maps
.
put
(
"finInstnId"
,
finInstnIdMaps
);
}
finInstnIdMaps
.
put
(
"bicfi"
,
mtBicCode
);
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/AbstractMt2MxParseField.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
;
import
com.alibaba.fastjson.JSONArray
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
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.common.*
;
import
com.prowidesoftware.swift.model.field.Field23E
;
import
java.text.ParseException
;
import
java.util.*
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
public
abstract
class
AbstractMt2MxParseField
implements
Mt2MxParseField
{
protected
Mt2MxContext
context
;
public
Mt2MxContext
getContext
()
{
return
context
;
}
public
AbstractMt2MxParseField
setContext
(
Mt2MxContext
context
)
{
this
.
context
=
context
;
return
this
;
}
protected
Map
<
String
,
Object
>
jsonMaps
=
null
;
public
void
initJsonMaps
()
{
jsonMaps
=
(
Map
<
String
,
Object
>)
context
.
get
(
Mt2MxContextIdentifier
.
MT_TO_MX_JSON_MAP
,
true
);
}
/**
* MT 转 MX 转换函数开始
*/
/**
* 1.如果 mtAccount 以//CH开始,Id.Othr.SchmeNm.Cd = CUID,Id.Othr.Id=mtAccount.subString(5)
* 2.如果 mtAccount 是IBAN账户,Id.IBAN = mtAccount
* 3.否则 Id.Othr.Id=mtAccount
* @param mtAccount
* @param maps(account对应的map对象)
*/
protected
void
mt_to_mxPartyAccount
(
String
mtAccount
,
Map
<
String
,
Object
>
maps
)
{
if
(
StringUtil
.
isEmpty
(
mtAccount
))
{
return
;
}
Map
<
String
,
Object
>
idMaps
=
null
;
if
(
maps
.
containsKey
(
"id"
))
{
idMaps
=
(
Map
<
String
,
Object
>)
maps
.
get
(
"id"
);
}
else
{
idMaps
=
new
HashMap
<>();
maps
.
put
(
"id"
,
idMaps
);
}
if
(
mtAccount
.
startsWith
(
"//CH"
)
&&
mtAccount
.
length
()
>
4
)
{
Map
<
String
,
Object
>
othrMaps
=
null
;
if
(
idMaps
.
containsKey
(
"othr"
))
{
othrMaps
=
(
Map
<
String
,
Object
>)
idMaps
.
get
(
"othr"
);
}
else
{
othrMaps
=
new
HashMap
<>();
idMaps
.
put
(
"othr"
,
othrMaps
);
}
othrMaps
.
put
(
"id"
,
mtAccount
.
substring
(
4
));
Map
<
String
,
Object
>
schmeNmMaps
=
null
;
if
(
othrMaps
.
containsKey
(
"schmeNm"
))
{
schmeNmMaps
=
(
Map
<
String
,
Object
>)
othrMaps
.
get
(
"schmeNm"
);
}
else
{
schmeNmMaps
=
new
HashMap
<>();
othrMaps
.
put
(
"schmeNm"
,
schmeNmMaps
);
}
schmeNmMaps
.
put
(
"cd"
,
"CUID"
);
}
else
if
(
mtAccount
.
length
()
>
1
)
{
mtAccount
=
mtAccount
.
substring
(
1
);
if
(
SwiftTransferUtil
.
checkIbanAccount
(
mtAccount
)){
idMaps
.
put
(
"iban"
,
mtAccount
);
}
else
{
Map
<
String
,
Object
>
othrMaps
=
null
;
if
(
idMaps
.
containsKey
(
"othr"
))
{
othrMaps
=
(
Map
<
String
,
Object
>)
idMaps
.
get
(
"othr"
);
}
else
{
othrMaps
=
new
HashMap
<>();
idMaps
.
put
(
"othr"
,
othrMaps
);
}
othrMaps
.
put
(
"id"
,
mtAccount
);
}
}
}
/**
* 1.如果 mtAccount 以//CH开始,Id.Othr.SchmeNm.Cd = CUID,Id.Othr.Id=mtAccount.subString(5)
* 2.如果长度大于34,Id.Othr.Id=mtAccount截取33位,最后一位给+
* 3.如果 mtAccount 是IBAN账户,Id.IBAN = mtAccount
* 4.否则 Id.Othr.Id=mtAccount
* @param mtAccount
* @param maps(account对应的map对象)
*/
protected
void
mt_to_mxAccount35
(
String
mtAccount
,
Map
<
String
,
Object
>
maps
)
{
if
(
StringUtil
.
isEmpty
(
mtAccount
))
{
return
;
}
Map
<
String
,
Object
>
idMaps
=
null
;
if
(
maps
.
containsKey
(
"id"
))
{
idMaps
=
(
Map
<
String
,
Object
>)
maps
.
get
(
"id"
);
}
else
{
idMaps
=
new
HashMap
<>();
maps
.
put
(
"id"
,
idMaps
);
}
if
(
mtAccount
.
startsWith
(
"//CH"
)
&&
mtAccount
.
length
()
>
4
)
{
Map
<
String
,
Object
>
othrMaps
=
null
;
if
(
idMaps
.
containsKey
(
"othr"
))
{
othrMaps
=
(
Map
<
String
,
Object
>)
idMaps
.
get
(
"othr"
);
}
else
{
othrMaps
=
new
HashMap
<>();
idMaps
.
put
(
"othr"
,
othrMaps
);
}
othrMaps
.
put
(
"id"
,
mtAccount
.
substring
(
4
));
Map
<
String
,
Object
>
schmeNmMaps
=
null
;
if
(
othrMaps
.
containsKey
(
"schmeNm"
))
{
schmeNmMaps
=
(
Map
<
String
,
Object
>)
othrMaps
.
get
(
"schmeNm"
);
}
else
{
schmeNmMaps
=
new
HashMap
<>();
othrMaps
.
put
(
"schmeNm"
,
schmeNmMaps
);
}
schmeNmMaps
.
put
(
"cd"
,
"CUID"
);
}
else
if
(
mtAccount
.
length
()
>
34
)
{
mtAccount
=
mtAccount
.
substring
(
1
);
Map
<
String
,
Object
>
othrMaps
=
null
;
if
(
idMaps
.
containsKey
(
"othr"
))
{
othrMaps
=
(
Map
<
String
,
Object
>)
idMaps
.
get
(
"othr"
);
}
else
{
othrMaps
=
new
HashMap
<>();
idMaps
.
put
(
"othr"
,
othrMaps
);
}
othrMaps
.
put
(
"id"
,
mtAccount
.
substring
(
0
,
33
)
+
"+"
);
}
else
if
(
mtAccount
.
length
()
>
1
)
{
mtAccount
=
mtAccount
.
substring
(
1
);
if
(
SwiftTransferUtil
.
checkIbanAccount
(
mtAccount
)){
idMaps
.
put
(
"iban"
,
mtAccount
);
}
else
{
Map
<
String
,
Object
>
othrMaps
=
null
;
if
(
idMaps
.
containsKey
(
"othr"
))
{
othrMaps
=
(
Map
<
String
,
Object
>)
idMaps
.
get
(
"othr"
);
}
else
{
othrMaps
=
new
HashMap
<>();
idMaps
.
put
(
"othr"
,
othrMaps
);
}
othrMaps
.
put
(
"id"
,
mtAccount
);
}
}
}
/**
* Id.OrgId.AnyBIC = mtBicCode
* @param mtBicCode
* @param maps
*/
protected
void
mt_to_mxAnyBIC
(
String
mtBicCode
,
Map
<
String
,
Object
>
maps
)
{
if
(
StringUtil
.
isEmpty
(
mtBicCode
))
{
return
;
}
Map
<
String
,
Object
>
idMaps
=
null
;
if
(
maps
.
containsKey
(
"id"
))
{
idMaps
=
(
Map
<
String
,
Object
>)
maps
.
get
(
"id"
);
}
else
{
idMaps
=
new
HashMap
<>();
maps
.
put
(
"id"
,
idMaps
);
}
Map
<
String
,
Object
>
idOrgMaps
=
null
;
if
(
idMaps
.
containsKey
(
"orgId"
))
{
idOrgMaps
=
(
Map
<
String
,
Object
>)
idMaps
.
get
(
"orgId"
);
}
else
{
idOrgMaps
=
new
HashMap
<>();
idMaps
.
put
(
"orgId"
,
idOrgMaps
);
}
idOrgMaps
.
put
(
"anyBIC"
,
mtBicCode
);
}
/**
* FinInstnId.BICFI = mtBicCode
* @param mtBicCode
* @param maps
*/
protected
void
mt_to_mxBICFI
(
String
mtBicCode
,
Map
<
String
,
Object
>
maps
)
{
if
(
StringUtil
.
isEmpty
(
mtBicCode
))
{
return
;
}
Map
<
String
,
Object
>
finInstnIdMaps
=
null
;
if
(
maps
.
containsKey
(
"finInstnId"
))
{
finInstnIdMaps
=
(
Map
<
String
,
Object
>)
maps
.
get
(
"finInstnId"
);
}
else
{
finInstnIdMaps
=
new
HashMap
<>();
maps
.
put
(
"finInstnId"
,
finInstnIdMaps
);
}
finInstnIdMaps
.
put
(
"bicfi"
,
mtBicCode
);
}
/**
* nameAndAddress 通过回车换行切割成数组 nameAndAddress[]
* Nm = nameAndAddress[0]
* PstlAdr.AdrLine = 剩余的 nameAndAddress[]
* @param nameAndAddress
* @param maps
*/
protected
void
mt_to_mxPartyNameAndAddress
(
String
nameAndAddress
,
Map
<
String
,
Object
>
maps
)
{
if
(
StringUtil
.
isEmpty
(
nameAndAddress
))
{
return
;
}
String
[]
nameAndAddresses
=
nameAndAddress
.
split
(
Mx2MtConstants
.
NEW_LINE
);
String
name
=
""
;
List
<
String
>
addressList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
nameAndAddresses
.
length
;
i
++)
{
if
(
i
==
0
)
{
name
=
nameAndAddresses
[
i
];
}
else
{
addressList
.
add
(
nameAndAddresses
[
i
]);
}
}
maps
.
put
(
"nm"
,
name
);
if
(
addressList
.
size
()
>
0
)
{
Map
<
String
,
Object
>
pstlAdrMaps
=
null
;
if
(
maps
.
containsKey
(
"pstlAdr"
))
{
pstlAdrMaps
=
(
Map
<
String
,
Object
>)
maps
.
get
(
"pstlAdr"
);
}
else
{
pstlAdrMaps
=
new
HashMap
<>();
maps
.
put
(
"pstlAdr"
,
pstlAdrMaps
);
}
pstlAdrMaps
.
put
(
"adrLine"
,
addressList
);
}
}
/**
* 1/ 开头的给name
* 2/ 开头的给adrLine
* 3/[A-Z]{2}/LEIC/([A-Z0-9]{18,18}[0-9]{2,2}) 括号里面的内容给LEI
* 否则 给 adrLine
* @param nameAndAddress
* @param maps
*/
protected
void
mt_to_mxPartyNameAndStructuredAddress
(
String
nameAndAddress
,
Map
<
String
,
Object
>
maps
)
{
if
(
StringUtil
.
isEmpty
(
nameAndAddress
))
{
return
;
}
String
[]
nameAndAddresses
=
nameAndAddress
.
split
(
Mx2MtConstants
.
NEW_LINE
);
String
name
=
""
;
String
lei
=
""
;
List
<
String
>
addressList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
nameAndAddresses
.
length
;
i
++)
{
String
tmpNameAndAddress
=
nameAndAddresses
[
i
];
if
(
tmpNameAndAddress
.
startsWith
(
"1/"
))
{
name
+=
tmpNameAndAddress
.
substring
(
2
);
}
if
(
tmpNameAndAddress
.
startsWith
(
"2/"
))
{
addressList
.
add
(
tmpNameAndAddress
);
}
if
(
tmpNameAndAddress
.
startsWith
(
"3/"
))
{
String
regex
=
"3/[A-Z]{2}/LEIC/([A-Z0-9]{18,18}[0-9]{2,2})"
;
Pattern
p
=
Pattern
.
compile
(
regex
);
Matcher
m
=
p
.
matcher
(
tmpNameAndAddress
);
if
(
m
.
find
())
{
/**
* group(0)就是指的整个串,group(1)指的是第一个括号里的东西,group(2)指的第二个括号里的东西
*/
lei
=
m
.
group
(
1
);
}
else
{
addressList
.
add
(
tmpNameAndAddress
);
}
}
}
if
(
name
.
length
()
>
0
)
{
maps
.
put
(
"nm"
,
name
);
}
if
(
lei
.
length
()
>
0
)
{
Map
<
String
,
Object
>
idMaps
=
null
;
if
(
maps
.
containsKey
(
"id"
))
{
idMaps
=
(
Map
<
String
,
Object
>)
maps
.
get
(
"id"
);
}
else
{
idMaps
=
new
HashMap
<>();
maps
.
put
(
"id"
,
idMaps
);
}
Map
<
String
,
Object
>
orgIdMaps
=
null
;
if
(
idMaps
.
containsKey
(
"orgId"
))
{
orgIdMaps
=
(
Map
<
String
,
Object
>)
idMaps
.
get
(
"orgId"
);
}
else
{
orgIdMaps
=
new
HashMap
<>();
idMaps
.
put
(
"orgId"
,
orgIdMaps
);
}
orgIdMaps
.
put
(
"lei"
,
lei
);
}
if
(
addressList
.
size
()
>
0
)
{
Map
<
String
,
Object
>
pstlAdrMaps
=
null
;
if
(
maps
.
containsKey
(
"id"
))
{
pstlAdrMaps
=
(
Map
<
String
,
Object
>)
maps
.
get
(
"pstlAdr"
);
}
else
{
pstlAdrMaps
=
new
HashMap
<>();
maps
.
put
(
"pstlAdr"
,
pstlAdrMaps
);
}
pstlAdrMaps
.
put
(
"adrLine"
,
addressList
);
}
}
/**
* ① //RT//([A-Z]{5})(.*)
* ② //([A-Z]{5})(.*)
* ③ //RT//([A-Z]{2})(.*)
* ④ //([A-Z]{2})(.*)
* 第一个括号内容给mxSystemCode
* 第二个括号内容给mxMemberId
* @param mtPartyIdentifier
* @param maps
*/
protected
void
mt_to_mxClearingIdentifier
(
String
mtPartyIdentifier
,
Map
<
String
,
Object
>
maps
)
{
if
(
StringUtil
.
isEmpty
(
mtPartyIdentifier
))
{
return
;
}
String
mxClearingSystem
=
""
;
String
mxClearingCode
=
""
;
String
regex1
=
"//RT//([A-Z]{5})(.*)"
;
Pattern
p1
=
Pattern
.
compile
(
regex1
);
Matcher
m1
=
p1
.
matcher
(
mtPartyIdentifier
);
if
(
m1
.
find
())
{
mxClearingSystem
=
m1
.
group
(
1
);
mxClearingCode
=
m1
.
group
(
2
);
}
String
regex2
=
"//([A-Z]{5})(.*)"
;
Pattern
p2
=
Pattern
.
compile
(
regex2
);
Matcher
m2
=
p2
.
matcher
(
mtPartyIdentifier
);
if
(
m2
.
find
())
{
mxClearingSystem
=
m2
.
group
(
1
);
mxClearingCode
=
m2
.
group
(
2
);
}
ClearingSystemMemberCode
code
=
SwiftTransferUtil
.
getClsSysMemberByValue
(
mxClearingSystem
);
if
(
mxClearingCode
.
length
()
>
0
&&
code
!=
null
)
{
Map
<
String
,
Object
>
clrSysIdMaps
=
null
;
if
(
maps
.
containsKey
(
"clrSysId"
))
{
clrSysIdMaps
=
(
Map
<
String
,
Object
>)
maps
.
get
(
"clrSysId"
);
}
else
{
clrSysIdMaps
=
new
HashMap
<>();
maps
.
put
(
"clrSysId"
,
clrSysIdMaps
);
}
clrSysIdMaps
.
put
(
"cd"
,
mxClearingSystem
);
maps
.
put
(
"mmbId"
,
mxClearingCode
);
return
;
}
/**
* 第2种情况
*/
String
mtClearingSystem
=
""
;
String
mtClearingCode
=
""
;
String
regex3
=
"//RT//([A-Z]{2})(.*)"
;
Pattern
p3
=
Pattern
.
compile
(
regex3
);
Matcher
m3
=
p3
.
matcher
(
mtPartyIdentifier
);
if
(
m3
.
find
())
{
mtClearingSystem
=
m3
.
group
(
1
);
mtClearingCode
=
m3
.
group
(
2
);
}
String
regex4
=
"//([A-Z]{2})(.*)"
;
Pattern
p4
=
Pattern
.
compile
(
regex4
);
Matcher
m4
=
p4
.
matcher
(
mtPartyIdentifier
);
if
(
m4
.
find
())
{
mtClearingSystem
=
m4
.
group
(
1
);
mtClearingCode
=
m4
.
group
(
2
);
}
code
=
SwiftTransferUtil
.
getClsSysMemberByDesc
(
mtClearingSystem
);
if
(
mtClearingCode
.
length
()
>
0
&&
code
!=
null
)
{
if
(
"SW"
.
equals
(
mtClearingSystem
)){
if
(
mtClearingCode
.
length
()
>
5
)
{
mxClearingSystem
=
ClearingSystemMemberCode
.
CHSIC
.
value
();
}
else
{
mxClearingSystem
=
ClearingSystemMemberCode
.
CHBCC
.
value
();
}
}
else
{
mxClearingSystem
=
code
.
value
();
}
mxClearingCode
=
mtClearingCode
;
Map
<
String
,
Object
>
clrSysIdMaps
=
null
;
if
(
maps
.
containsKey
(
"clrSysId"
))
{
clrSysIdMaps
=
(
Map
<
String
,
Object
>)
maps
.
get
(
"clrSysId"
);
}
else
{
clrSysIdMaps
=
new
HashMap
<>();
maps
.
put
(
"clrSysId"
,
clrSysIdMaps
);
}
clrSysIdMaps
.
put
(
"cd"
,
mxClearingSystem
);
maps
.
put
(
"mmbId"
,
mxClearingCode
);
}
}
/**
* 判断 mt systemcode 在不在 MTClearingSystemCodeList 里面
* 存在返回true
* 不在返回false
* @param mtPartyIdentifier
*/
protected
boolean
isMTClearingSystemCodeInList
(
String
mtPartyIdentifier
)
{
if
(
StringUtil
.
isEmpty
(
mtPartyIdentifier
))
{
return
false
;
}
boolean
flag
=
false
;
String
mxClearingSystem
=
""
;
String
regex1
=
"//RT//([A-Z]{5})(.*)"
;
Pattern
p1
=
Pattern
.
compile
(
regex1
);
Matcher
m1
=
p1
.
matcher
(
mtPartyIdentifier
);
if
(
m1
.
find
())
{
mxClearingSystem
=
m1
.
group
(
1
);
}
String
regex2
=
"//([A-Z]{5})(.*)"
;
Pattern
p2
=
Pattern
.
compile
(
regex2
);
Matcher
m2
=
p2
.
matcher
(
mtPartyIdentifier
);
if
(
m2
.
find
())
{
mxClearingSystem
=
m2
.
group
(
1
);
}
ClearingSystemMemberCode
code
=
SwiftTransferUtil
.
getClsSysMemberByValue
(
mxClearingSystem
);
if
(
code
!=
null
)
{
flag
=
true
;
}
else
{
/**
* 第2种情况
*/
String
mtClearingSystem
=
""
;
String
regex3
=
"//RT//([A-Z]{2})(.*)"
;
Pattern
p3
=
Pattern
.
compile
(
regex3
);
Matcher
m3
=
p3
.
matcher
(
mtPartyIdentifier
);
if
(
m3
.
find
())
{
mtClearingSystem
=
m3
.
group
(
1
);
}
String
regex4
=
"//([A-Z]{2})(.*)"
;
Pattern
p4
=
Pattern
.
compile
(
regex4
);
Matcher
m4
=
p4
.
matcher
(
mtPartyIdentifier
);
if
(
m4
.
find
())
{
mtClearingSystem
=
m4
.
group
(
1
);
}
code
=
SwiftTransferUtil
.
getClsSysMemberByDesc
(
mtClearingSystem
);
if
(
code
!=
null
)
{
flag
=
true
;
}
}
return
flag
;
}
protected
void
mt_to_mxClearingSystemToNameAndAddressLine
(
String
mtPartyIdentifier
,
String
location
,
Map
<
String
,
Object
>
maps
)
{
if
(
StringUtil
.
isEmpty
(
mtPartyIdentifier
))
{
return
;
}
String
nameAddress
=
""
;
String
regex1
=
"//RT//(.*)"
;
Pattern
p1
=
Pattern
.
compile
(
regex1
);
Matcher
m1
=
p1
.
matcher
(
mtPartyIdentifier
);
if
(
m1
.
find
())
{
nameAddress
=
m1
.
group
(
1
);
}
String
regex2
=
"//(.*)"
;
Pattern
p2
=
Pattern
.
compile
(
regex2
);
Matcher
m2
=
p2
.
matcher
(
mtPartyIdentifier
);
if
(
m2
.
find
())
{
nameAddress
=
m2
.
group
(
1
);
}
if
(
StringUtil
.
isNotEmpty
(
nameAddress
)
&&
!
"RT"
.
equals
(
nameAddress
))
{
nameAddress
=
"//"
+
nameAddress
;
}
else
{
nameAddress
=
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
;
}
maps
.
put
(
"nm"
,
nameAddress
);
List
<
String
>
addressList
=
new
ArrayList
<>();
addressList
.
add
(
nameAddress
);
if
(
StringUtil
.
isNotEmpty
(
location
))
{
addressList
.
add
(
location
);
}
Map
<
String
,
Object
>
pstlAdrMaps
=
null
;
if
(
maps
.
containsKey
(
"pstlAdr"
))
{
pstlAdrMaps
=
(
Map
<
String
,
Object
>)
maps
.
get
(
"pstlAdr"
);
}
else
{
pstlAdrMaps
=
new
HashMap
<>();
maps
.
put
(
"pstlAdr"
,
pstlAdrMaps
);
}
pstlAdrMaps
.
put
(
"adrLine"
,
addressList
);
}
protected
void
mt_to_mxFinancialInstitutionNameAndUnstructuredAddress
(
String
nameAddress
,
Map
<
String
,
Object
>
maps
)
{
if
(
StringUtil
.
isEmpty
(
nameAddress
))
{
return
;
}
Map
<
String
,
Object
>
finInstnIdMaps
=
null
;
if
(
maps
.
containsKey
(
"finInstnId"
))
{
finInstnIdMaps
=
(
Map
<
String
,
Object
>)
maps
.
get
(
"finInstnId"
);
}
else
{
finInstnIdMaps
=
new
HashMap
<>();
maps
.
put
(
"finInstnId"
,
finInstnIdMaps
);
}
String
[]
nameAddresses
=
nameAddress
.
split
(
Mx2MtConstants
.
NEW_LINE
);
String
name
=
""
;
List
<
String
>
addressList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
nameAddresses
.
length
;
i
++)
{
if
(
i
==
0
)
{
name
=
nameAddresses
[
i
];
}
else
{
addressList
.
add
(
nameAddresses
[
i
]);
}
}
finInstnIdMaps
.
put
(
"nm"
,
name
);
if
(
addressList
.
size
()
==
0
)
{
addressList
.
add
(
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
);
}
Map
<
String
,
Object
>
pstlAdrMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"pstlAdr"
))
{
pstlAdrMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"pstlAdr"
);
}
else
{
pstlAdrMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"pstlAdr"
,
pstlAdrMaps
);
}
pstlAdrMaps
.
put
(
"adrLine"
,
addressList
);
}
/**
*
* @param mt72
* @param maps
*/
protected
void
mt72_to_mxNextAgent
(
String
mt72
,
Map
<
String
,
Object
>
maps
)
{
if
(
StringUtil
.
isEmpty
(
mt72
))
{
return
;
}
String
mt72Value
=
mt72
.
replace
(
"\r\n//"
,
""
);
String
[]
lines
=
mt72Value
.
split
(
"\r\n"
);
String
nextAgtInfo
=
""
;
List
<
String
>
insList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
lines
.
length
;
i
++)
{
if
(!
lines
[
i
].
startsWith
(
"/ACC/"
)
&&
!
lines
[
i
].
startsWith
(
"/INS/"
)
&&
!
lines
[
i
].
startsWith
(
"/INTA/"
)
&&
!
lines
[
i
].
startsWith
(
"/SVCLVL/"
)
&&
!
lines
[
i
].
startsWith
(
"/LOCINS/"
)
&&
!
lines
[
i
].
startsWith
(
"/CATPURP/"
))
{
nextAgtInfo
+=
lines
[
i
];
}
}
String
nextAgeFin53
=
(
String
)
context
.
get
(
Mt2MxContextIdentifier
.
MT_TO_MX_INSTRUCTION_FOR_NEXT_AGENT_FIN53
,
true
);
if
(
StringUtil
.
isNotEmpty
(
nextAgeFin53
))
{
nextAgtInfo
=
nextAgeFin53
+
nextAgtInfo
;
}
if
(
StringUtil
.
isNotEmpty
(
nextAgtInfo
))
{
if
(
nextAgtInfo
.
length
()
>
210
)
{
nextAgtInfo
=
nextAgtInfo
.
substring
(
0
,
209
)
+
"+"
;
}
JSONArray
instrForNxtAgtJsonArray
=
null
;
if
(
maps
.
containsKey
(
"instrForNxtAgt"
))
{
instrForNxtAgtJsonArray
=
(
JSONArray
)
maps
.
get
(
"instrForNxtAgt"
);
}
else
{
instrForNxtAgtJsonArray
=
new
JSONArray
();
maps
.
put
(
"instrForNxtAgt"
,
instrForNxtAgtJsonArray
);
}
List
<
String
>
nextAgtInfoList
=
StringUtil
.
outStringList
(
nextAgtInfo
,
35
,
""
);
for
(
int
i
=
0
;
i
<
nextAgtInfoList
.
size
();
i
++)
{
Map
<
String
,
Object
>
instrForNxtAgtMaps
=
new
HashMap
<>();
instrForNxtAgtMaps
.
put
(
"instrInf"
,
nextAgtInfoList
.
get
(
i
));
instrForNxtAgtJsonArray
.
add
(
instrForNxtAgtMaps
);
}
}
}
/**
*
* @param mt72
* @param maps
*/
protected
void
mt72ins_to_mxAgent
(
String
mt72
,
Map
<
String
,
Object
>
maps
)
{
if
(
StringUtil
.
isEmpty
(
mt72
))
{
return
;
}
String
mt72Value
=
mt72
.
replace
(
"\r\n//"
,
""
);
String
[]
lines
=
mt72Value
.
split
(
"\r\n"
);
List
<
String
>
insList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
lines
.
length
;
i
++)
{
if
(
lines
[
i
].
startsWith
(
"/INS/"
))
{
insList
.
add
(
lines
[
i
]);
}
}
for
(
int
i
=
0
;
i
<
insList
.
size
();
i
++)
{
String
insLine
=
insList
.
get
(
i
);
insLine
=
insLine
.
substring
(
5
);
if
(
i
==
3
)
break
;
String
key
=
"prvsInstgAgt"
+
(
i
+
1
);
Map
<
String
,
Object
>
prvsInstgAgt1Maps
=
null
;
if
(
maps
.
containsKey
(
key
))
{
prvsInstgAgt1Maps
=
(
Map
<
String
,
Object
>)
maps
.
get
(
key
);
}
else
{
prvsInstgAgt1Maps
=
new
HashMap
<>();
maps
.
put
(
key
,
prvsInstgAgt1Maps
);
}
Map
<
String
,
Object
>
finInstnIdMaps
=
null
;
if
(
prvsInstgAgt1Maps
.
containsKey
(
"finInstnId"
))
{
finInstnIdMaps
=
(
Map
<
String
,
Object
>)
maps
.
get
(
"finInstnId"
);
}
else
{
finInstnIdMaps
=
new
HashMap
<>();
prvsInstgAgt1Maps
.
put
(
"finInstnId"
,
finInstnIdMaps
);
}
if
(
SwiftTransferUtil
.
isBIC
(
insLine
))
{
finInstnIdMaps
.
put
(
"bicfi"
,
insLine
);
}
else
{
if
(
insLine
.
length
()
>
140
){
insLine
=
insLine
.
substring
(
0
,
139
)
+
"+"
;
}
finInstnIdMaps
.
put
(
"nm"
,
insLine
);
Map
<
String
,
Object
>
pstlAdrMaps
=
null
;
List
<
String
>
addressList
=
new
ArrayList
<>();
addressList
.
add
(
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
);
if
(
finInstnIdMaps
.
containsKey
(
"pstlAdr"
))
{
pstlAdrMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"pstlAdr"
);
}
else
{
pstlAdrMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"pstlAdr"
,
pstlAdrMaps
);
}
pstlAdrMaps
.
put
(
"adrLine"
,
addressList
);
}
}
}
/**
*
* @param mtPartyIdentifier
* @param maps
*/
protected
void
mt_to_mxFinancialInstitutionAccount
(
String
mtPartyIdentifier
,
Map
<
String
,
Object
>
maps
)
{
if
(
StringUtil
.
isEmpty
(
mtPartyIdentifier
))
{
return
;
}
Map
<
String
,
Object
>
idMaps
=
null
;
if
(
maps
.
containsKey
(
"id"
))
{
idMaps
=
(
Map
<
String
,
Object
>)
maps
.
get
(
"id"
);
}
else
{
idMaps
=
new
HashMap
<>();
maps
.
put
(
"id"
,
idMaps
);
}
if
(
mtPartyIdentifier
.
startsWith
(
"//CH"
)
&&
mtPartyIdentifier
.
length
()
>
4
)
{
Map
<
String
,
Object
>
othrMaps
=
null
;
if
(
idMaps
.
containsKey
(
"othr"
))
{
othrMaps
=
(
Map
<
String
,
Object
>)
idMaps
.
get
(
"othr"
);
}
else
{
othrMaps
=
new
HashMap
<>();
idMaps
.
put
(
"othr"
,
othrMaps
);
}
othrMaps
.
put
(
"id"
,
mtPartyIdentifier
.
substring
(
4
));
Map
<
String
,
Object
>
schmeNmMaps
=
null
;
if
(
othrMaps
.
containsKey
(
"schmeNm"
))
{
schmeNmMaps
=
(
Map
<
String
,
Object
>)
othrMaps
.
get
(
"schmeNm"
);
}
else
{
schmeNmMaps
=
new
HashMap
<>();
othrMaps
.
put
(
"schmeNm"
,
schmeNmMaps
);
}
schmeNmMaps
.
put
(
"cd"
,
"CUID"
);
return
;
}
else
if
((
mtPartyIdentifier
.
startsWith
(
"/C/"
)
||
mtPartyIdentifier
.
startsWith
(
"/D/"
))
&&
mtPartyIdentifier
.
length
()
>
3
)
{
mtPartyIdentifier
=
mtPartyIdentifier
.
substring
(
3
);
}
else
if
(
mtPartyIdentifier
.
length
()
>
1
)
{
mtPartyIdentifier
=
mtPartyIdentifier
.
substring
(
1
);
}
if
(
SwiftTransferUtil
.
checkIbanAccount
(
mtPartyIdentifier
)){
idMaps
.
put
(
"iban"
,
mtPartyIdentifier
);
}
else
{
Map
<
String
,
Object
>
othrMaps
=
null
;
if
(
idMaps
.
containsKey
(
"othr"
))
{
othrMaps
=
(
Map
<
String
,
Object
>)
idMaps
.
get
(
"othr"
);
}
else
{
othrMaps
=
new
HashMap
<>();
idMaps
.
put
(
"othr"
,
othrMaps
);
}
othrMaps
.
put
(
"id"
,
mtPartyIdentifier
);
}
}
protected
void
mt_to_mxRemittanceInformation
(
String
mt70
,
Map
<
String
,
Object
>
maps
)
{
if
(
StringUtil
.
isEmpty
(
mt70
))
{
return
;
}
String
[]
mt70Lines
=
mt70
.
split
(
Mx2MtConstants
.
NEW_LINE
);
String
ustrd
=
""
;
for
(
int
i
=
0
;
i
<
mt70Lines
.
length
;
i
++)
{
String
mt70Line
=
mt70Lines
[
i
];
if
(
mt70Line
.
length
()
<
35
&&
i
<
(
mt70Lines
.
length
-
1
))
{
ustrd
+=
mt70Line
+
" "
;
}
else
{
ustrd
+=
mt70Line
;
}
}
List
<
String
>
ustrdList
=
new
ArrayList
<>();
ustrdList
.
add
(
ustrd
);
maps
.
put
(
"ustrd"
,
ustrdList
);
}
/**
* 获取 EndToEndId
* @param mt70Value
* @return
*/
protected
String
mt70roc_to_mx35Text
(
String
mt70Value
)
{
if
(
StringUtil
.
isEmpty
(
mt70Value
))
{
return
null
;
}
String
endToEndId
=
""
;
String
tmpMtValue
=
mt70Value
.
replace
(
Mx2MtConstants
.
NEW_LINE
,
""
);
String
regex
=
"/ROC/(.*)///"
;
Pattern
p
=
Pattern
.
compile
(
regex
);
Matcher
m
=
p
.
matcher
(
tmpMtValue
);
if
(
m
.
find
())
{
endToEndId
=
m
.
group
(
1
);
}
else
{
regex
=
"/ROC/(.*)"
;
p
=
Pattern
.
compile
(
regex
);
m
=
p
.
matcher
(
tmpMtValue
);
if
(
m
.
find
())
{
endToEndId
=
m
.
group
(
1
);
}
}
if
(
endToEndId
.
length
()
>
35
)
endToEndId
=
endToEndId
.
substring
(
0
,
34
)
+
"+"
;
return
endToEndId
;
}
/**
* 提取72域中指定mtcode的值
* @param mt72
* @param mtCode
* @param maxLength
* @return
*/
protected
String
mt72_to_mxText
(
String
mt72
,
String
mtCode
,
int
maxLength
)
{
if
(
StringUtil
.
isEmpty
(
mt72
))
{
return
""
;
}
String
mxCode
=
""
;
String
mt72Value
=
mt72
.
replace
(
"\r\n//"
,
""
);
String
[]
lines
=
mt72Value
.
split
(
"\r\n"
);
for
(
int
i
=
0
;
i
<
lines
.
length
;
i
++)
{
if
(
lines
[
i
].
startsWith
(
mtCode
))
{
mxCode
=
lines
[
i
];
}
}
mxCode
=
mtCode
.
substring
(
mtCode
.
length
());
if
(
mxCode
.
length
()
>
maxLength
)
{
mxCode
=
mxCode
.
substring
(
0
,
maxLength
-
1
)
+
"+"
;
}
return
mxCode
;
}
/**
* 23E 72 转换成 Instruction For Creditor Agent
* @param field23EList (HOLD, PHOB, CHQB,TELB)
* @param mt72
* @param maps
*/
protected
void
mt_to_mxInstructionForCreditorAgent
(
List
<
Field23E
>
field23EList
,
String
mt72
,
Map
<
String
,
Object
>
maps
)
{
if
(
field23EList
.
size
()
==
0
&&
StringUtil
.
isEmpty
(
mt72
))
{
return
;
}
Map
<
String
,
Object
>
instrForCdtrAgt1
=
new
HashMap
<>();
Map
<
String
,
Object
>
instrForCdtrAgt2
=
new
HashMap
<>();
String
mxText
=
mt72_to_mxText
(
mt72
,
"/ACC/"
,
205
);
String
configIndicator
=
""
;
if
(
mxText
.
length
()
>
0
&&
field23EList
.
size
()
>
0
)
{
configIndicator
=
"ACCCode"
;
}
else
if
(
mxText
.
length
()
>
0
)
{
configIndicator
=
"ACCOnly"
;
}
else
if
(
field23EList
.
size
()
>
0
)
{
configIndicator
=
"CodeOnly"
;
}
if
(
"ACCOnly"
.
equals
(
configIndicator
))
{
if
(
mxText
.
length
()
>
140
)
{
instrForCdtrAgt1
.
put
(
"instrInf"
,
mxText
.
substring
(
0
,
140
));
instrForCdtrAgt2
.
put
(
"instrInf"
,
mxText
.
substring
(
140
));
}
else
{
instrForCdtrAgt1
.
put
(
"instrInf"
,
mxText
);
}
}
else
if
(
"ACCCode"
.
equals
(
configIndicator
))
{
if
(
mxText
.
length
()
>
140
)
{
instrForCdtrAgt1
.
put
(
"instrInf"
,
mxText
.
substring
(
0
,
139
)
+
"+"
);
}
else
{
instrForCdtrAgt1
.
put
(
"instrInf"
,
mxText
);
}
String
instructionCode
=
""
;
String
instructionInfo
=
""
;
for
(
int
i
=
0
;
i
<
field23EList
.
size
();
i
++)
{
Field23E
field23E
=
field23EList
.
get
(
i
);
String
code
=
field23E
.
getCode
();
String
info
=
field23E
.
getAdditionalInformation
();
if
(
i
==
0
)
{
instructionCode
=
code
;
if
(
StringUtil
.
isNotEmpty
(
info
))
{
instructionInfo
+=
info
;
}
}
else
{
instructionInfo
+=
"/"
+
code
+
"/"
;
if
(
StringUtil
.
isNotEmpty
(
info
))
{
instructionInfo
+=
info
;
}
}
}
instrForCdtrAgt2
.
put
(
"cd"
,
instructionCode
);
if
(
StringUtil
.
isNotEmpty
(
instructionInfo
))
{
instrForCdtrAgt2
.
put
(
"instrInf"
,
instructionInfo
);
}
}
else
if
(
"CodeOnly"
.
equals
(
configIndicator
))
{
String
instructionCode
=
""
;
String
instructionInfo
=
""
;
for
(
int
i
=
0
;
i
<
field23EList
.
size
();
i
++)
{
Field23E
field23E
=
field23EList
.
get
(
i
);
String
code
=
field23E
.
getCode
();
String
info
=
field23E
.
getAdditionalInformation
();
if
(
i
==
0
)
{
instrForCdtrAgt1
.
put
(
"cd"
,
code
);
if
(
StringUtil
.
isNotEmpty
(
info
))
{
instrForCdtrAgt1
.
put
(
"instrInf"
,
info
);
}
}
else
if
(
i
==
1
){
instructionCode
=
code
;
if
(
StringUtil
.
isNotEmpty
(
info
))
{
instructionInfo
+=
info
;
}
}
else
{
instructionInfo
+=
"/"
+
code
+
"/"
;
if
(
StringUtil
.
isNotEmpty
(
info
))
{
instructionInfo
+=
info
;
}
}
}
instrForCdtrAgt2
.
put
(
"cd"
,
instructionCode
);
if
(
StringUtil
.
isNotEmpty
(
instructionInfo
))
{
instrForCdtrAgt2
.
put
(
"instrInf"
,
instructionInfo
);
}
}
JSONArray
instrForCdtrAgtJsonArray
=
null
;
if
(
maps
.
containsKey
(
"instrForCdtrAgt"
))
{
instrForCdtrAgtJsonArray
=
(
JSONArray
)
maps
.
get
(
"instrForCdtrAgt"
);
}
else
{
instrForCdtrAgtJsonArray
=
new
JSONArray
();
maps
.
put
(
"instrForCdtrAgt"
,
instrForCdtrAgtJsonArray
);
}
if
(
instrForCdtrAgt1
.
size
()
>
0
)
{
instrForCdtrAgtJsonArray
.
add
(
instrForCdtrAgt1
);
}
if
(
instrForCdtrAgt2
.
size
()
>
0
)
{
instrForCdtrAgtJsonArray
.
add
(
instrForCdtrAgt2
);
}
}
/**
* 前提条件是 mtPartyIdentifier 不以/开始
* @param mtPartyIdentifier
* @param nameAddress
* @param maps
*/
protected
void
mt_to_mxFATFIdentification
(
String
mtPartyIdentifier
,
String
nameAddress
,
Map
<
String
,
Object
>
maps
)
{
if
(
StringUtil
.
isEmpty
(
mtPartyIdentifier
))
{
return
;
}
String
mtCode8
=
""
;
if
(
StringUtil
.
isNotEmpty
(
nameAddress
))
{
String
[]
nameAndAddresses
=
nameAddress
.
split
(
Mx2MtConstants
.
NEW_LINE
);
for
(
int
i
=
0
;
i
<
nameAndAddresses
.
length
;
i
++)
{
if
(
nameAndAddresses
[
i
].
startsWith
(
"8/"
))
{
mtCode8
=
nameAndAddresses
[
i
].
substring
(
2
);
}
}
}
String
mtFullId
=
mtPartyIdentifier
;
if
(
mtPartyIdentifier
.
length
()
==
35
)
{
mtFullId
+=
mtCode8
;
}
//格式类似 mtSchemeCode + "/" + mtCountryCode + "/" + mtIssuer + "/" + mtIdentifier
String
mtFATFCode
=
mtFullId
.
substring
(
0
,
4
);
String
mtFATFId
=
mtFullId
.
substring
(
5
);
String
mtCountry
=
""
;
String
mtIssuer
=
""
;
String
mtId
=
""
;
Boolean
flagOrgId
=
false
;
String
mxOrgSchemeCode
=
""
;
if
(
"CUST"
.
equals
(
mtFATFCode
)
||
"EMPL"
.
equals
(
mtFATFCode
)
||
"DRLC"
.
equals
(
mtFATFCode
))
{
mtCountry
=
mtFATFId
.
substring
(
0
,
2
);
String
regex
=
"(.*)/(.*)"
;
Pattern
p
=
Pattern
.
compile
(
regex
);
Matcher
m
=
p
.
matcher
(
mtFATFId
.
substring
(
3
));
if
(
m
.
find
())
{
mtIssuer
=
m
.
group
(
1
);
mtId
=
m
.
group
(
2
);
if
(
StringUtil
.
isEmpty
(
mtId
))
{
mtId
=
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
;
}
if
(
mtIssuer
.
length
()
>
4
&&
"CUST"
.
equals
(
mtFATFCode
))
{
OrganisationIdentificationCode
code
=
SwiftTransferUtil
.
getOrganisationIdentificationCodeByCode
(
mtIssuer
.
substring
(
0
,
4
));
if
(
code
!=
null
&&
!
OrganisationIdentificationCode
.
CUST
.
equals
(
code
)
&&
!
OrganisationIdentificationCode
.
TXID
.
equals
(
code
)
&&
!
OrganisationIdentificationCode
.
EMPL
.
equals
(
code
))
{
mxOrgSchemeCode
=
code
.
value
();
mtIssuer
=
mtIssuer
.
substring
(
5
);
flagOrgId
=
true
;
}
}
}
else
{
mtId
=
mtFATFId
.
substring
(
3
);
}
if
(
mtId
.
length
()
>
35
)
mtId
=
mtId
.
substring
(
0
,
34
)
+
"+"
;
}
else
{
//MTFATFCode 不在 {EMPL, CUST, DRLC}
mtCountry
=
mtFATFId
.
substring
(
0
,
2
);
mtId
=
mtFATFId
.
substring
(
3
);
if
(
StringUtil
.
isEmpty
(
mtId
))
{
mtId
=
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
;
}
if
(
mtId
.
length
()
>
35
)
mtId
=
mtId
.
substring
(
0
,
34
)
+
"+"
;
}
String
mxIssuer
=
mtCountry
;
if
(
StringUtil
.
isNotEmpty
(
mtIssuer
))
{
mxIssuer
+=
"/"
+
mtIssuer
;
}
//开始转换
Map
<
String
,
Object
>
orgIdMaps
=
null
;
if
(
maps
.
containsKey
(
"orgId"
))
{
orgIdMaps
=
(
Map
<
String
,
Object
>)
maps
.
get
(
"orgId"
);
}
else
{
orgIdMaps
=
new
HashMap
<>();
//如果orgIdMaps 长度大于0,put到maps
}
Map
<
String
,
Object
>
prvtIdMaps
=
null
;
if
(
maps
.
containsKey
(
"prvtId"
))
{
prvtIdMaps
=
(
Map
<
String
,
Object
>)
maps
.
get
(
"prvtId"
);
}
else
{
prvtIdMaps
=
new
HashMap
<>();
//如果prvtIdMaps 长度大于0,put到maps
}
if
(
PersonIdentificationCode
.
ARNU
.
value
().
equals
(
mtFATFCode
)
||
PersonIdentificationCode
.
CCPT
.
value
().
equals
(
mtFATFCode
)
||
PersonIdentificationCode
.
DRLC
.
value
().
equals
(
mtFATFCode
)
||
PersonIdentificationCode
.
EMPL
.
value
().
equals
(
mtFATFCode
)
||
PersonIdentificationCode
.
NIDN
.
value
().
equals
(
mtFATFCode
)
||
PersonIdentificationCode
.
SOSE
.
value
().
equals
(
mtFATFCode
)
||
PersonIdentificationCode
.
TXID
.
value
().
equals
(
mtFATFCode
)
||
(
PersonIdentificationCode
.
CUST
.
value
().
equals
(
mtFATFCode
)
&&
!
flagOrgId
))
{
JSONArray
othrJsonArray
=
null
;
if
(
prvtIdMaps
.
containsKey
(
"othr"
))
{
othrJsonArray
=
(
JSONArray
)
prvtIdMaps
.
get
(
"othr"
);
}
else
{
othrJsonArray
=
new
JSONArray
();
prvtIdMaps
.
put
(
"othr"
,
othrJsonArray
);
}
Map
<
String
,
Object
>
othrMaps
=
new
HashMap
<>();
othrJsonArray
.
add
(
othrMaps
);
othrMaps
.
put
(
"id"
,
mtId
);
othrMaps
.
put
(
"issr"
,
mxIssuer
);
Map
<
String
,
Object
>
schmeNmMaps
=
null
;
if
(
othrMaps
.
containsKey
(
"schmeNm"
))
{
schmeNmMaps
=
(
Map
<
String
,
Object
>)
othrMaps
.
get
(
"schmeNm"
);
}
else
{
schmeNmMaps
=
new
HashMap
<>();
othrMaps
.
put
(
"schmeNm"
,
schmeNmMaps
);
}
schmeNmMaps
.
put
(
"cd"
,
mtFATFCode
);
}
else
if
(
PersonIdentificationCode
.
CUST
.
value
().
equals
(
mtFATFCode
)
&&
flagOrgId
)
{
JSONArray
othrJsonArray
=
null
;
if
(
orgIdMaps
.
containsKey
(
"othr"
))
{
othrJsonArray
=
(
JSONArray
)
orgIdMaps
.
get
(
"othr"
);
}
else
{
othrJsonArray
=
new
JSONArray
();
orgIdMaps
.
put
(
"othr"
,
othrJsonArray
);
}
Map
<
String
,
Object
>
othrMaps
=
new
HashMap
<>();
othrJsonArray
.
add
(
othrMaps
);
othrMaps
.
put
(
"id"
,
mtId
);
othrMaps
.
put
(
"issr"
,
mxIssuer
);
Map
<
String
,
Object
>
schmeNmMaps
=
null
;
if
(
othrMaps
.
containsKey
(
"schmeNm"
))
{
schmeNmMaps
=
(
Map
<
String
,
Object
>)
othrMaps
.
get
(
"schmeNm"
);
}
else
{
schmeNmMaps
=
new
HashMap
<>();
othrMaps
.
put
(
"schmeNm"
,
schmeNmMaps
);
}
schmeNmMaps
.
put
(
"cd"
,
mxOrgSchemeCode
);
}
if
(
orgIdMaps
.
size
()
>
0
)
{
maps
.
put
(
"orgId"
,
orgIdMaps
);
}
if
(
prvtIdMaps
.
size
()
>
0
)
{
maps
.
put
(
"prvtId"
,
prvtIdMaps
);
}
}
/**
*
* @param mtPartyIdentifier
* @param nameAddress
* @param maps
*/
protected
void
mt_to_mxFATFNameAndAddress
(
String
mtPartyIdentifier
,
String
nameAddress
,
Map
<
String
,
Object
>
maps
)
{
mt_to_mxPartyNameAndStructuredAddress
(
nameAddress
,
maps
);
String
mtCode4
=
""
;
String
mtCode5
=
""
;
String
mtCode6
=
""
;
String
mtCode7
=
""
;
String
mtCode8
=
""
;
if
(
StringUtil
.
isNotEmpty
(
nameAddress
))
{
String
[]
nameAndAddresses
=
nameAddress
.
split
(
Mx2MtConstants
.
NEW_LINE
);
for
(
int
i
=
0
;
i
<
nameAndAddresses
.
length
;
i
++)
{
if
(
nameAndAddresses
[
i
].
startsWith
(
"4/"
))
{
mtCode4
=
nameAndAddresses
[
i
].
substring
(
2
);
}
if
(
nameAndAddresses
[
i
].
startsWith
(
"5/"
))
{
mtCode5
=
nameAndAddresses
[
i
].
substring
(
2
);
}
if
(
nameAndAddresses
[
i
].
startsWith
(
"6/"
))
{
mtCode6
=
nameAndAddresses
[
i
].
substring
(
2
);
}
if
(
nameAndAddresses
[
i
].
startsWith
(
"7/"
))
{
mtCode7
=
nameAndAddresses
[
i
].
substring
(
2
);
}
if
(
nameAndAddresses
[
i
].
startsWith
(
"8/"
))
{
mtCode8
=
nameAndAddresses
[
i
].
substring
(
2
);
}
}
}
if
(
StringUtil
.
isEmpty
(
mtCode4
)
&&
StringUtil
.
isEmpty
(
mtCode5
)
&&
StringUtil
.
isEmpty
(
mtCode6
)
&&
StringUtil
.
isEmpty
(
mtCode7
))
{
return
;
//找不到mtcode4 5 6 7,终止转换
}
Map
<
String
,
Object
>
idMaps
=
null
;
if
(
maps
.
containsKey
(
"id"
))
{
idMaps
=
(
Map
<
String
,
Object
>)
maps
.
get
(
"id"
);
}
else
{
idMaps
=
new
HashMap
<>();
maps
.
put
(
"id"
,
idMaps
);
}
if
(
StringUtil
.
isNotEmpty
(
mtCode6
))
{
boolean
flagOrgId
=
false
;
String
regex
=
"[A-Z]{2}/LEIC/([A-Z0-9]{18,18}[0-9]{2,2})"
;
String
lei
=
""
;
Pattern
p
=
Pattern
.
compile
(
regex
);
Matcher
m
=
p
.
matcher
(
mtCode6
);
if
(
m
.
find
())
{
lei
=
m
.
group
(
1
);
if
(
mtPartyIdentifier
.
startsWith
(
"/"
))
{
flagOrgId
=
true
;
}
else
{
String
regex1
=
"CUST/[A-Z]{2}/([A-Z0-9]{4})"
;
Pattern
p1
=
Pattern
.
compile
(
regex1
);
Matcher
m1
=
p1
.
matcher
(
mtPartyIdentifier
);
if
(
m1
.
find
())
{
String
orgIdCode
=
m1
.
group
(
1
);
OrganisationIdentificationCode
code
=
SwiftTransferUtil
.
getOrganisationIdentificationCodeByCode
(
orgIdCode
);
if
(
code
!=
null
&&
!
OrganisationIdentificationCode
.
CUST
.
equals
(
code
)
&&
!
OrganisationIdentificationCode
.
TXID
.
equals
(
code
)
&&
!
OrganisationIdentificationCode
.
EMPL
.
equals
(
code
))
{
flagOrgId
=
true
;
}
}
}
}
if
(
flagOrgId
)
{
Map
<
String
,
Object
>
orgIdMaps
=
null
;
if
(
idMaps
.
containsKey
(
"orgId"
))
{
orgIdMaps
=
(
Map
<
String
,
Object
>)
idMaps
.
get
(
"orgId"
);
}
else
{
orgIdMaps
=
new
HashMap
<>();
idMaps
.
put
(
"orgId"
,
orgIdMaps
);
}
orgIdMaps
.
put
(
"lei"
,
lei
);
return
;
//组织信息转换了,私人信息将不会转换.
}
}
Map
<
String
,
Object
>
prvtIdMaps
=
null
;
if
(
idMaps
.
containsKey
(
"prvtId"
))
{
prvtIdMaps
=
(
Map
<
String
,
Object
>)
idMaps
.
get
(
"prvtId"
);
}
else
{
prvtIdMaps
=
new
HashMap
<>();
//idMaps.put("prvtId", prvtIdMaps);
}
if
(
StringUtil
.
isNotEmpty
(
mtCode4
)
&&
StringUtil
.
isNotEmpty
(
mtCode5
))
{
try
{
Map
<
String
,
Object
>
dtAndPlcOfBirthMaps
=
null
;
if
(
prvtIdMaps
.
containsKey
(
"dtAndPlcOfBirth"
))
{
dtAndPlcOfBirthMaps
=
(
Map
<
String
,
Object
>)
prvtIdMaps
.
get
(
"dtAndPlcOfBirth"
);
}
else
{
dtAndPlcOfBirthMaps
=
new
HashMap
<>();
prvtIdMaps
.
put
(
"dtAndPlcOfBirth"
,
dtAndPlcOfBirthMaps
);
}
Date
brithDate
=
DateUtil
.
parseDate
(
mtCode4
,
"yyyyMMdd"
);
String
brithDateStr
=
DateUtil
.
format
(
brithDate
,
"yyyy-MM-dd"
);
dtAndPlcOfBirthMaps
.
put
(
"birthDt"
,
brithDateStr
);
String
regex
=
"([A-Z]{2})/(.*)"
;
Pattern
p
=
Pattern
.
compile
(
regex
);
Matcher
m
=
p
.
matcher
(
mtCode5
);
if
(
m
.
find
())
{
dtAndPlcOfBirthMaps
.
put
(
"ctryOfBirth"
,
m
.
group
(
1
));
dtAndPlcOfBirthMaps
.
put
(
"cityOfBirth"
,
m
.
group
(
2
));
}
}
catch
(
ParseException
e
)
{
throw
new
SwiftException
(
"ERROR"
,
e
.
getMessage
());
}
}
if
(
StringUtil
.
isNotEmpty
(
mtPartyIdentifier
)
&&
!
mtPartyIdentifier
.
startsWith
(
"CUST"
))
{
if
(
StringUtil
.
isNotEmpty
(
mtCode6
))
{
String
mtFullId
=
mtCode6
;
if
((
mtPartyIdentifier
.
startsWith
(
"/"
)
||
mtPartyIdentifier
.
length
()
<
35
)
&&
mtCode8
.
length
()
>
0
&&
mtCode6
.
length
()
==
33
)
{
mtFullId
+=
mtCode8
;
}
String
regex
=
"(.*)/(.*)"
;
Pattern
p
=
Pattern
.
compile
(
regex
);
Matcher
m
=
p
.
matcher
(
mtFullId
.
substring
(
3
));
String
mtCountry
=
mtFullId
.
substring
(
0
,
2
);
String
mtIssuer
=
""
;
String
mtNum
=
""
;
if
(
m
.
find
())
{
mtIssuer
=
m
.
group
(
1
);
mtNum
=
m
.
group
(
2
);
if
(
StringUtil
.
isEmpty
(
mtNum
))
{
mtNum
=
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
;
}
}
else
{
mtNum
=
mtFullId
.
substring
(
3
);
}
if
(
mtNum
.
length
()
>
35
)
{
mtNum
=
mtNum
.
substring
(
0
,
34
)
+
"+"
;
}
JSONArray
othrJsonArray
=
null
;
if
(
prvtIdMaps
.
containsKey
(
"othr"
))
{
othrJsonArray
=
(
JSONArray
)
prvtIdMaps
.
get
(
"othr"
);
}
else
{
othrJsonArray
=
new
JSONArray
();
prvtIdMaps
.
put
(
"othr"
,
othrJsonArray
);
}
Map
<
String
,
Object
>
othrMaps
=
new
HashMap
<>();
othrJsonArray
.
add
(
othrMaps
);
othrMaps
.
put
(
"id"
,
mtNum
);
Map
<
String
,
Object
>
schmeNmMaps
=
null
;
if
(
othrMaps
.
containsKey
(
"schmeNm"
))
{
schmeNmMaps
=
(
Map
<
String
,
Object
>)
othrMaps
.
get
(
"schmeNm"
);
}
else
{
schmeNmMaps
=
new
HashMap
<>();
othrMaps
.
put
(
"schmeNm"
,
schmeNmMaps
);
}
schmeNmMaps
.
put
(
"cd"
,
"CUST"
);
if
(
StringUtil
.
isNotEmpty
(
mtIssuer
))
{
mtCountry
+=
"/"
+
mtIssuer
;
}
othrMaps
.
put
(
"issr"
,
mtCountry
);
}
}
if
(
StringUtil
.
isNotEmpty
(
mtPartyIdentifier
)
&&
!
mtPartyIdentifier
.
startsWith
(
"NIDN"
))
{
if
(
StringUtil
.
isNotEmpty
(
mtCode7
))
{
JSONArray
othrJsonArray
=
null
;
if
(
prvtIdMaps
.
containsKey
(
"othr"
))
{
othrJsonArray
=
(
JSONArray
)
prvtIdMaps
.
get
(
"othr"
);
}
else
{
othrJsonArray
=
new
JSONArray
();
prvtIdMaps
.
put
(
"othr"
,
othrJsonArray
);
}
if
(
othrJsonArray
.
size
()
>=
2
)
{
return
;
}
String
mtFullId
=
mtCode7
;
if
((
mtPartyIdentifier
.
startsWith
(
"/"
)
||
mtPartyIdentifier
.
length
()
<
35
)
&&
mtCode8
.
length
()
>
0
&&
mtCode6
.
length
()
!=
33
&&
mtCode7
.
length
()
==
33
)
{
mtFullId
+=
mtCode8
;
}
if
(
mtFullId
.
length
()
>
3
&&
mtFullId
.
indexOf
(
"/"
)
==
2
)
{
String
mtNum
=
mtFullId
.
substring
(
3
);
if
(
mtNum
.
length
()
>
35
)
{
mtNum
=
mtNum
.
substring
(
0
,
34
)
+
"+"
;
}
Map
<
String
,
Object
>
othrMaps
=
new
HashMap
<>();
othrJsonArray
.
add
(
othrMaps
);
othrMaps
.
put
(
"id"
,
mtNum
);
Map
<
String
,
Object
>
schmeNmMaps
=
null
;
if
(
othrMaps
.
containsKey
(
"schmeNm"
))
{
schmeNmMaps
=
(
Map
<
String
,
Object
>)
othrMaps
.
get
(
"schmeNm"
);
}
else
{
schmeNmMaps
=
new
HashMap
<>();
othrMaps
.
put
(
"schmeNm"
,
schmeNmMaps
);
}
schmeNmMaps
.
put
(
"cd"
,
"NIDN"
);
othrMaps
.
put
(
"issr"
,
mtFullId
.
substring
(
0
,
2
));
}
}
}
if
(
prvtIdMaps
.
size
()
>
0
)
{
idMaps
.
put
(
"prvtId"
,
prvtIdMaps
);
}
}
/**
* /INTA/ -> MXIntermediaryAgent2, MXIntermediaryAgent3
* /SVCLVL/ -> Payment Type Information/Service Level
* /LOCINS/ -> Payment Type Information/Local Instrument
* /CATPURP/ -> Payment Type Information/Category Purpose
* @param mt72
* @param maps
*/
protected
void
mt_to_mxField72NewCodeWords
(
String
mt72
,
Map
<
String
,
Object
>
maps
)
{
String
mt72Value
=
mt72
.
replace
(
"\r\n//"
,
""
);
String
[]
lines
=
mt72Value
.
split
(
"\r\n"
);
List
<
String
>
intermediaryAgentLines
=
new
ArrayList
<>();
List
<
String
>
serviceLevelLines
=
new
ArrayList
<>();
List
<
String
>
localInstrumentLines
=
new
ArrayList
<>();
List
<
String
>
categoryPurposeLines
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
lines
.
length
;
i
++)
{
if
(
lines
[
i
].
startsWith
(
"/INTA/"
))
{
String
line
=
lines
[
i
].
substring
(
6
);
if
(
StringUtil
.
isNotEmpty
(
line
))
{
intermediaryAgentLines
.
add
(
line
);
}
}
if
(
lines
[
i
].
startsWith
(
"/SVCLVL/"
))
{
String
line
=
lines
[
i
].
substring
(
8
);
if
(
StringUtil
.
isNotEmpty
(
line
))
{
serviceLevelLines
.
add
(
line
);
}
}
if
(
lines
[
i
].
startsWith
(
"/LOCINS/"
))
{
String
line
=
lines
[
i
].
substring
(
8
);
if
(
StringUtil
.
isNotEmpty
(
line
))
{
localInstrumentLines
.
add
(
line
);
}
}
if
(
lines
[
i
].
startsWith
(
"/CATPURP/"
))
{
String
line
=
lines
[
i
].
substring
(
9
);
if
(
StringUtil
.
isNotEmpty
(
line
))
{
categoryPurposeLines
.
add
(
line
);
}
}
}
//开始转换
if
(
intermediaryAgentLines
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
intermediaryAgentLines
.
size
();
i
++)
{
if
(
i
==
2
)
break
;
//最多转换2次 IntermediaryAgent2, IntermediaryAgent3
String
line
=
intermediaryAgentLines
.
get
(
i
);
Map
<
String
,
Object
>
intrmyAgtMaps
=
new
HashMap
<>();
mt_to_mxIntermediaryAgent
(
line
,
intrmyAgtMaps
);
maps
.
put
(
"intrmyAgt"
+(
i
+
2
),
intrmyAgtMaps
);
}
}
Map
<
String
,
Object
>
pmtTpInfMaps
=
null
;
if
(
maps
.
containsKey
(
"pmtTpInf"
))
{
pmtTpInfMaps
=
(
Map
<
String
,
Object
>)
maps
.
get
(
"pmtTpInf"
);
}
else
{
pmtTpInfMaps
=
new
HashMap
<>();
}
if
(
serviceLevelLines
.
size
()
>
0
)
{
JSONArray
svcLvlJsonArray
=
null
;
if
(
pmtTpInfMaps
.
containsKey
(
"svcLvl"
))
{
svcLvlJsonArray
=
(
JSONArray
)
pmtTpInfMaps
.
get
(
"svcLvl"
);
}
else
{
svcLvlJsonArray
=
new
JSONArray
();
}
for
(
int
i
=
0
;
i
<
serviceLevelLines
.
size
();
i
++)
{
if
(
svcLvlJsonArray
.
size
()
>=
3
)
break
;
//Service Level 最多转换3次
String
line
=
serviceLevelLines
.
get
(
i
);
if
(
ServiceLevelCode
.
SDVA
.
value
().
equals
(
line
))
{
continue
;
}
if
(
line
.
matches
(
"G00[1-9]{1}"
))
{
continue
;
}
Map
<
String
,
Object
>
svcLvlMaps
=
new
HashMap
<>();
ServiceLevelCode
code
=
SwiftTransferUtil
.
getServiceLevelByValue
(
line
);
if
(
code
!=
null
)
{
svcLvlMaps
.
put
(
"cd"
,
code
.
value
());
}
else
{
if
(
line
.
length
()
>
35
)
{
line
=
line
.
substring
(
0
,
34
)
+
"+"
;
}
svcLvlMaps
.
put
(
"prtry"
,
line
);
}
svcLvlJsonArray
.
add
(
svcLvlMaps
);
}
if
(
svcLvlJsonArray
.
size
()
>
0
)
{
pmtTpInfMaps
.
put
(
"svcLvl"
,
svcLvlJsonArray
);
}
}
//NOT IsInList {CRED,CRTS,SPAY, SPRI, SSTD}
if
(
localInstrumentLines
.
size
()
>
0
&&
!
pmtTpInfMaps
.
containsKey
(
"lclInstrm"
))
{
Map
<
String
,
Object
>
lclInstrmMaps
=
new
HashMap
<>();
for
(
int
i
=
0
;
i
<
localInstrumentLines
.
size
();
i
++)
{
if
(
lclInstrmMaps
.
size
()
==
1
)
break
;
//只取第一条
String
line
=
localInstrumentLines
.
get
(
i
);
if
(
"CRED"
.
equals
(
line
)
||
"CRTS"
.
equals
(
line
)
||
"SPAY"
.
equals
(
line
)
||
"SPRI"
.
equals
(
line
)
||
"SSTD"
.
equals
(
line
))
{
continue
;
}
LocalInstrumentCode
code
=
SwiftTransferUtil
.
getLocalInstrumentByValue
(
line
);
if
(
code
!=
null
)
{
lclInstrmMaps
.
put
(
"cd"
,
code
.
value
());
}
else
{
if
(
line
.
length
()
>
35
)
{
line
=
line
.
substring
(
0
,
34
)
+
"+"
;
}
lclInstrmMaps
.
put
(
"prtry"
,
line
);
}
}
if
(
lclInstrmMaps
.
size
()
>
0
)
{
pmtTpInfMaps
.
put
(
"lclInstrm"
,
lclInstrmMaps
);
}
}
if
(
categoryPurposeLines
.
size
()
>
0
&&
!
pmtTpInfMaps
.
containsKey
(
"ctgyPurp"
))
{
Map
<
String
,
Object
>
ctgyPurpMaps
=
new
HashMap
<>();
for
(
int
i
=
0
;
i
<
localInstrumentLines
.
size
();
i
++)
{
if
(
ctgyPurpMaps
.
size
()
==
1
)
break
;
//只取第一条
String
line
=
localInstrumentLines
.
get
(
i
);
if
(
CategoryPurposeCode
.
INTC
.
value
().
equals
(
line
)
||
CategoryPurposeCode
.
CORT
.
value
().
equals
(
line
))
{
continue
;
}
CategoryPurposeCode
code
=
SwiftTransferUtil
.
getCategoryPurposeByValue
(
line
);
if
(
code
!=
null
)
{
ctgyPurpMaps
.
put
(
"cd"
,
code
.
value
());
}
else
{
if
(
line
.
length
()
>
35
)
{
line
=
line
.
substring
(
0
,
34
)
+
"+"
;
}
ctgyPurpMaps
.
put
(
"prtry"
,
line
);
}
}
if
(
ctgyPurpMaps
.
size
()
>
0
)
{
pmtTpInfMaps
.
put
(
"ctgyPurp"
,
ctgyPurpMaps
);
}
}
if
(
pmtTpInfMaps
.
size
()
>
0
)
{
maps
.
put
(
"pmtTpInf"
,
pmtTpInfMaps
);
}
}
/**
*
* @param mtAgent
* @param maps
*/
protected
void
mt_to_mxIntermediaryAgent
(
String
mtAgent
,
Map
<
String
,
Object
>
maps
)
{
if
(
StringUtil
.
isEmpty
(
mtAgent
))
{
return
;
}
if
(
SwiftTransferUtil
.
isBIC
(
mtAgent
))
{
mt_to_mxBICFI
(
mtAgent
,
maps
);
return
;
}
String
regex
=
"([A-Z]{5})(.*)"
;
Pattern
p
=
Pattern
.
compile
(
regex
);
Matcher
m
=
p
.
matcher
(
mtAgent
);
if
(
m
.
find
())
{
String
mxCode
=
m
.
group
(
1
);
String
mxMemId
=
m
.
group
(
2
);
if
(
SwiftTransferUtil
.
getClsSysMemberByValue
(
mxCode
)
!=
null
)
{
Map
<
String
,
Object
>
finInstnIdMaps
=
null
;
if
(
maps
.
containsKey
(
"finInstnId"
))
{
finInstnIdMaps
=
(
Map
<
String
,
Object
>)
maps
.
get
(
"finInstnId"
);
}
else
{
finInstnIdMaps
=
new
HashMap
<>();
maps
.
put
(
"finInstnId"
,
finInstnIdMaps
);
}
Map
<
String
,
Object
>
clrSysMmbIdMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"clrSysMmbId"
))
{
clrSysMmbIdMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"clrSysMmbId"
);
}
else
{
clrSysMmbIdMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"clrSysMmbId"
,
clrSysMmbIdMaps
);
}
if
(
mxMemId
.
length
()
>
28
)
{
mxMemId
=
mxMemId
.
substring
(
0
,
27
)
+
"+"
;
}
clrSysMmbIdMaps
.
put
(
"mmbId"
,
mxMemId
);
Map
<
String
,
Object
>
clrSysIdMaps
=
null
;
if
(
clrSysMmbIdMaps
.
containsKey
(
"clrSysId"
))
{
clrSysIdMaps
=
(
Map
<
String
,
Object
>)
clrSysMmbIdMaps
.
get
(
"clrSysId"
);
}
else
{
clrSysIdMaps
=
new
HashMap
<>();
clrSysMmbIdMaps
.
put
(
"clrSysId"
,
clrSysIdMaps
);
}
clrSysMmbIdMaps
.
put
(
"cd"
,
mxCode
);
return
;
}
}
String
mxName
=
""
;
String
mxCountryCode
=
""
;
String
mxTownName
=
""
;
regex
=
"(.*)\\(([A-Z]{2})\\((.*)"
;
p
=
Pattern
.
compile
(
regex
);
m
=
p
.
matcher
(
mtAgent
);
if
(
m
.
find
())
{
mxName
=
m
.
group
(
1
);
mxCountryCode
=
m
.
group
(
2
);
mxTownName
=
m
.
group
(
3
);
}
else
{
regex
=
"(.*)\\(([A-Z]{2})"
;
p
=
Pattern
.
compile
(
regex
);
m
=
p
.
matcher
(
mtAgent
);
if
(
m
.
find
())
{
mxName
=
m
.
group
(
1
);
mxCountryCode
=
m
.
group
(
2
);
}
else
{
mxName
=
mtAgent
;
}
}
Map
<
String
,
Object
>
finInstnIdMaps
=
null
;
if
(
maps
.
containsKey
(
"finInstnId"
))
{
finInstnIdMaps
=
(
Map
<
String
,
Object
>)
maps
.
get
(
"finInstnId"
);
}
else
{
finInstnIdMaps
=
new
HashMap
<>();
maps
.
put
(
"finInstnId"
,
finInstnIdMaps
);
}
finInstnIdMaps
.
put
(
"nm"
,
mxName
);
Map
<
String
,
Object
>
pstlAdrMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"pstlAdr"
))
{
pstlAdrMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"pstlAdr"
);
}
else
{
pstlAdrMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"pstlAdr"
,
pstlAdrMaps
);
}
if
(
StringUtil
.
isEmpty
(
mxCountryCode
)
&&
StringUtil
.
isEmpty
(
mxTownName
))
{
List
<
String
>
adrLineList
=
new
ArrayList
<>();
adrLineList
.
add
(
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
);
pstlAdrMaps
.
put
(
"adrLine"
,
adrLineList
);
}
else
{
if
(
StringUtil
.
isNotEmpty
(
mxCountryCode
))
{
pstlAdrMaps
.
put
(
"ctry"
,
mxCountryCode
);
}
if
(
StringUtil
.
isNotEmpty
(
mxTownName
))
{
pstlAdrMaps
.
put
(
"twnNm"
,
mxTownName
);
}
}
}
/**
* MT 转 MX 转换函数结束
*/
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/Mt2MxContext.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
;
import
com.brilliance.swift.context.ContextImpl
;
public
class
Mt2MxContext
extends
ContextImpl
{
private
static
final
long
serialVersionUID
=
7846958949591485021L
;
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/Mt2MxContextIdentifier.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
;
public
class
Mt2MxContextIdentifier
{
public
static
final
String
MT_TO_MX_OUTPUT_FILE_PATH
=
"mt.to.mx.output.file.path"
;
public
static
final
String
MT_TO_MX_XML
=
"mt.to.mx.xml"
;
public
static
final
String
MT_TO_MX_JSON_MAP
=
"mt.to.mx.json.map"
;
public
static
final
String
MT_SEND_BIC
=
"mt.send.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
EXTERNAL_PARAMETERS_CREATION_DATE
=
"CreationDate"
;
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/Mt2MxCreator.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
;
import
java.util.List
;
public
interface
Mt2MxCreator
{
void
preProcess
();
List
<
Mt2MxParseField
>
getParseFieldList
();
void
postProcess
();
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/Mt2MxCreatorManager.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.pacs008001.Mt2MxPacs008001Creator
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.util.List
;
import
java.util.Map
;
public
class
Mt2MxCreatorManager
{
public
AbstractMT
abstractMT
=
null
;
public
void
init
(
String
mtStr
)
{
try
{
abstractMT
=
AbstractMT
.
parse
(
mtStr
);
}
catch
(
Exception
e
)
{
throw
new
SwiftException
(
"ERROR"
,
e
.
getMessage
());
}
}
public
String
mt2mx
(
String
mtStr
,
String
outPutFilePath
,
Map
<
String
,
Object
>
extraMap
)
throws
SwiftException
{
init
(
mtStr
);
AbstractMt2MxCreator
creator
=
getMt2MxCreator
();
Mt2MxContext
context
=
new
Mt2MxContext
();
context
.
set
(
AbstractMT
.
class
,
abstractMT
);
context
.
set
(
Mt2MxContextIdentifier
.
MT_TO_MX_OUTPUT_FILE_PATH
,
outPutFilePath
);
context
.
putAll
(
extraMap
);
creator
.
setContext
(
context
);
creator
.
preProcess
();
List
<
Mt2MxParseField
>
parseFields
=
creator
.
getParseFieldList
();
for
(
int
i
=
0
;
i
<
parseFields
.
size
();
i
++)
{
AbstractMt2MxParseField
parseField
=
(
AbstractMt2MxParseField
)
parseFields
.
get
(
i
);
parseField
.
setContext
(
context
).
initJsonMaps
();
parseField
.
parseField
();
}
creator
.
postProcess
();
return
(
String
)
context
.
get
(
Mt2MxContextIdentifier
.
MT_TO_MX_XML
);
}
public
AbstractMt2MxCreator
getMt2MxCreator
()
throws
SwiftException
{
String
messageType
=
abstractMT
.
getMessageType
();
if
(
"103"
.
equals
(
messageType
))
{
return
new
Mt2MxPacs008001Creator
();
}
else
{
throw
new
SwiftException
(
"ERROR"
,
"Invalid message type"
);
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/Mt2MxParseField.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
;
public
interface
Mt2MxParseField
{
void
parseField
();
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/AbstractMt2MxPacs008001ParseField.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs008001
;
import
com.alibaba.fastjson.JSONArray
;
import
com.brilliance.swift.mt2mx.AbstractMt2MxParseField
;
import
java.util.Map
;
public
abstract
class
AbstractMt2MxPacs008001ParseField
extends
AbstractMt2MxParseField
{
protected
Map
<
String
,
Object
>
appHdrMaps
=
null
;
protected
Map
<
String
,
Object
>
grpHdrMaps
=
null
;
protected
Map
<
String
,
Object
>
cdtTrfTxInfMaps
=
null
;
@Override
public
void
initJsonMaps
()
{
super
.
initJsonMaps
();
appHdrMaps
=
(
Map
<
String
,
Object
>)
jsonMaps
.
get
(
"appHdr"
);
Map
<
String
,
Object
>
fIToFICstmrCdtTrfMaps
=
(
Map
<
String
,
Object
>)
jsonMaps
.
get
(
"fiToFICstmrCdtTrf"
);
grpHdrMaps
=
(
Map
<
String
,
Object
>)
fIToFICstmrCdtTrfMaps
.
get
(
"grpHdr"
);
JSONArray
cdtTrfTxInfJsonArray
=
(
JSONArray
)
fIToFICstmrCdtTrfMaps
.
get
(
"cdtTrfTxInf"
);
cdtTrfTxInfMaps
=
(
Map
<
String
,
Object
>)
cdtTrfTxInfJsonArray
.
get
(
0
);
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/Mt2MxPacs008001Creator.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs008001
;
import
com.alibaba.fastjson.JSONArray
;
import
com.brilliance.swift.mt2mx.AbstractMt2MxCreator
;
import
com.brilliance.swift.mt2mx.Mt2MxContextIdentifier
;
import
com.brilliance.swift.mt2mx.Mt2MxParseField
;
import
com.brilliance.swift.mt2mx.pacs008001.impl.*
;
import
com.brilliance.swift.util.StringUtil
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
Mt2MxPacs008001Creator
extends
AbstractMt2MxCreator
{
@Override
public
void
preProcess
()
{
super
.
preProcess
();
jsonMaps
.
put
(
"identifier"
,
"pacs.008.001.08"
);
Map
<
String
,
Object
>
appHdrMaps
=
(
Map
<
String
,
Object
>)
jsonMaps
.
get
(
"appHdr"
);
appHdrMaps
.
put
(
"msgDefIdr"
,
"pacs.008.001.08"
);
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
//初始化转换和不需要BLOCK4的转换
Map
<
String
,
Object
>
fiToFICstmrCdtTrfMaps
=
new
HashMap
<>();
jsonMaps
.
put
(
"fiToFICstmrCdtTrf"
,
fiToFICstmrCdtTrfMaps
);
Map
<
String
,
Object
>
grpHdrMaps
=
new
HashMap
<>();
fiToFICstmrCdtTrfMaps
.
put
(
"grpHdr"
,
grpHdrMaps
);
grpHdrMaps
.
put
(
"creDtTm"
,
"9999-12-31T00:00:00+00:00"
);
grpHdrMaps
.
put
(
"nbOfTxs"
,
"1"
);
Map
<
String
,
Object
>
cdtTrfTxInfMaps
=
new
HashMap
<>();
JSONArray
cdtTrfTxInfJsonArray
=
new
JSONArray
();
cdtTrfTxInfJsonArray
.
add
(
cdtTrfTxInfMaps
);
fiToFICstmrCdtTrfMaps
.
put
(
"cdtTrfTxInf"
,
cdtTrfTxInfJsonArray
);
//设置 Payment Identification
Map
<
String
,
Object
>
pmtIdMaps
=
new
HashMap
<>();
cdtTrfTxInfMaps
.
put
(
"pmtId"
,
pmtIdMaps
);
String
uetr
=
abstractMT
.
getSwiftMessage
().
getUETR
();
if
(
StringUtil
.
isNotEmpty
(
uetr
))
{
pmtIdMaps
.
put
(
"uetr"
,
uetr
);
}
//设置InstructingAgent InstructedAgent 取值从sendbic receivebic
String
sendBic
=
(
String
)
context
.
get
(
Mt2MxContextIdentifier
.
MT_SEND_BIC
,
true
);
if
(
StringUtil
.
isNotEmpty
(
sendBic
))
{
Map
<
String
,
Object
>
instgAgtMaps
=
new
HashMap
<>();
cdtTrfTxInfMaps
.
put
(
"instgAgt"
,
instgAgtMaps
);
mt_to_mxBICFI
(
sendBic
,
instgAgtMaps
);
}
String
receiverBic
=
(
String
)
context
.
get
(
Mt2MxContextIdentifier
.
MT_RECEIVE_BIC
,
true
);
if
(
StringUtil
.
isNotEmpty
(
receiverBic
))
{
Map
<
String
,
Object
>
instdAgtMaps
=
new
HashMap
<>();
cdtTrfTxInfMaps
.
put
(
"instdAgt"
,
instdAgtMaps
);
mt_to_mxBICFI
(
receiverBic
,
instdAgtMaps
);
}
//设置Service Level 取值从block3 {111:00[0-9]}
Tag
tag111
=
abstractMT
.
getSwiftMessage
().
getBlock3
().
getTagByName
(
"111"
);
if
(
tag111
!=
null
)
{
String
svcLvlCode
=
""
;
String
value
=
tag111
.
getValue
();
if
(
value
.
matches
(
"00[0-9]{1}"
))
{
svcLvlCode
=
value
;
}
if
(
StringUtil
.
isNotEmpty
(
svcLvlCode
))
{
Map
<
String
,
Object
>
pmtTpInfMaps
=
new
HashMap
<>();
cdtTrfTxInfMaps
.
put
(
"pmtTpInf"
,
pmtTpInfMaps
);
JSONArray
svcLvlJsonArray
=
new
JSONArray
();
pmtTpInfMaps
.
put
(
"svcLvl"
,
svcLvlJsonArray
);
Map
<
String
,
Object
>
svcLvlMaps
=
new
HashMap
<>();
svcLvlJsonArray
.
add
(
svcLvlMaps
);
svcLvlMaps
.
put
(
"cd"
,
"G"
+
svcLvlCode
);
}
}
}
@Override
public
List
<
Mt2MxParseField
>
getParseFieldList
()
{
List
<
Mt2MxParseField
>
list
=
new
ArrayList
<>();
list
.
add
(
new
Pacs00801Parse20Field
());
list
.
add
(
new
Pacs00801Parse13CField
());
list
.
add
(
new
Pacs00801Parse23BField
());
list
.
add
(
new
Pacs00801Parse23EField
());
list
.
add
(
new
Pacs00801Parse26TField
());
list
.
add
(
new
Pacs00801Parse32AField
());
list
.
add
(
new
Pacs00801Parse33BField
());
list
.
add
(
new
Pacs00801Parse36Field
());
list
.
add
(
new
Pacs00801Parse50Field
());
list
.
add
(
new
Pacs00801Parse52Field
());
list
.
add
(
new
Pacs00801ParseSetlMtdField
());
list
.
add
(
new
Pacs00801ParseSetlAcctField
());
list
.
add
(
new
Pacs00801Parse53Field
());
list
.
add
(
new
Pacs00801Parse54Field
());
list
.
add
(
new
Pacs00801Parse55Field
());
list
.
add
(
new
Pacs00801Parse56Field
());
list
.
add
(
new
Pacs00801Parse57Field
());
list
.
add
(
new
Pacs00801Parse59Field
());
list
.
add
(
new
Pacs00801Parse70Field
());
list
.
add
(
new
Pacs00801Parse71Field
());
list
.
add
(
new
Pacs00801Parse72Field
());
list
.
add
(
new
Pacs00801Parse77BField
());
return
list
;
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/impl/Pacs00801Parse13CField.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs008001
.
impl
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.field.Field13C
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
Pacs00801Parse13CField
extends
AbstractMt2MxPacs008001ParseField
{
private
static
final
String
NAME
=
"13C"
;
@Override
public
void
parseField
()
throws
SwiftException
{
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
Tag
[]
tags
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagsByName
(
NAME
);
if
(
tags
!=
null
&&
tags
.
length
>
0
)
{
Map
<
String
,
Object
>
sttlmTmIndctnMaps
=
null
;
if
(
cdtTrfTxInfMaps
.
containsKey
(
"sttlmTmIndctn"
))
{
sttlmTmIndctnMaps
=
(
Map
<
String
,
Object
>)
cdtTrfTxInfMaps
.
get
(
"sttlmTmIndctn"
);
}
else
{
sttlmTmIndctnMaps
=
new
HashMap
<>();
cdtTrfTxInfMaps
.
put
(
"sttlmTmIndctn"
,
sttlmTmIndctnMaps
);
}
Map
<
String
,
Object
>
sttlmTmReqMaps
=
null
;
if
(
cdtTrfTxInfMaps
.
containsKey
(
"sttlmTmReq"
))
{
sttlmTmReqMaps
=
(
Map
<
String
,
Object
>)
cdtTrfTxInfMaps
.
get
(
"sttlmTmReq"
);
}
else
{
sttlmTmReqMaps
=
new
HashMap
<>();
cdtTrfTxInfMaps
.
put
(
"sttlmTmReq"
,
sttlmTmReqMaps
);
}
for
(
int
i
=
0
;
i
<
tags
.
length
;
i
++)
{
Field13C
field13C
=
(
Field13C
)
tags
[
i
].
asField
();
String
dateTimeStr
=
"0001-01-01T"
+
field13C
.
getTime
().
substring
(
0
,
2
)
+
":"
+
field13C
.
getTime
().
substring
(
2
,
4
)
+
":00"
+
field13C
.
getSign
()
+
field13C
.
getOffset
().
substring
(
0
,
2
)
+
":"
+
field13C
.
getOffset
().
substring
(
2
,
4
);
String
timeStr
=
field13C
.
getTime
().
substring
(
0
,
2
)
+
":"
+
field13C
.
getTime
().
substring
(
2
,
4
)
+
":00"
+
field13C
.
getSign
()
+
field13C
.
getOffset
().
substring
(
0
,
2
)
+
":"
+
field13C
.
getOffset
().
substring
(
2
,
4
);
if
(
"SNDTIME"
.
equals
(
field13C
.
getCode
()))
{
sttlmTmIndctnMaps
.
put
(
"dbtDtTm"
,
dateTimeStr
);
}
else
if
(
"RNCTIME"
.
equals
(
field13C
.
getCode
()))
{
sttlmTmIndctnMaps
.
put
(
"cdtDtTm"
,
dateTimeStr
);
}
else
if
(
"CLSTIME"
.
equals
(
field13C
.
getCode
()))
{
sttlmTmReqMaps
.
put
(
"clsTm"
,
timeStr
);
}
else
if
(
"TILTIME"
.
equals
(
field13C
.
getCode
()))
{
sttlmTmReqMaps
.
put
(
"tillTm"
,
timeStr
);
}
else
if
(
"FROTIME"
.
equals
(
field13C
.
getCode
()))
{
sttlmTmReqMaps
.
put
(
"frTm"
,
timeStr
);
}
else
if
(
"REJTIME"
.
equals
(
field13C
.
getCode
()))
{
sttlmTmReqMaps
.
put
(
"rjctTm"
,
timeStr
);
}
}
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/impl/Pacs00801Parse20Field.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs008001
.
impl
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
Pacs00801Parse20Field
extends
AbstractMt2MxPacs008001ParseField
{
private
static
final
String
NAME
=
"20"
;
@Override
public
void
parseField
()
throws
SwiftException
{
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
Tag
tag20
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME
);
if
(
tag20
!=
null
)
{
appHdrMaps
.
put
(
"bizMsgIdr"
,
tag20
.
getValue
());
grpHdrMaps
.
put
(
"msgId"
,
tag20
.
getValue
());
Map
<
String
,
Object
>
pmtIdMaps
=
null
;
if
(
cdtTrfTxInfMaps
.
containsKey
(
"pmtId"
))
{
pmtIdMaps
=
(
Map
<
String
,
Object
>)
cdtTrfTxInfMaps
.
get
(
"pmtId"
);
}
else
{
pmtIdMaps
=
new
HashMap
<>();
cdtTrfTxInfMaps
.
put
(
"pmtId"
,
pmtIdMaps
);
}
pmtIdMaps
.
put
(
"instrId"
,
tag20
.
getValue
());
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/impl/Pacs00801Parse23BField.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs008001
.
impl
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField
;
public
class
Pacs00801Parse23BField
extends
AbstractMt2MxPacs008001ParseField
{
@Override
public
void
parseField
()
throws
SwiftException
{
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/impl/Pacs00801Parse23EField.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs008001
.
impl
;
import
com.alibaba.fastjson.JSONArray
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField
;
import
com.brilliance.swift.vo.common.CategoryPurposeCode
;
import
com.brilliance.swift.vo.common.ExternalCreditorAgentInstructionCode
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.field.Field23E
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
Pacs00801Parse23EField
extends
AbstractMt2MxPacs008001ParseField
{
private
static
final
String
NAME_23E
=
"23E"
;
private
static
final
String
NAME_70
=
"70"
;
@Override
public
void
parseField
()
throws
SwiftException
{
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
Tag
[]
tags
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagsByName
(
NAME_23E
);
List
<
Field23E
>
field23EList
=
new
ArrayList
<>();
if
(
tags
!=
null
&&
tags
.
length
>
0
)
{
Map
<
String
,
Object
>
pmtTpInfMaps
=
null
;
if
(
cdtTrfTxInfMaps
.
containsKey
(
"pmtTpInf"
))
{
pmtTpInfMaps
=
(
Map
<
String
,
Object
>)
cdtTrfTxInfMaps
.
get
(
"pmtTpInf"
);
}
else
{
pmtTpInfMaps
=
new
HashMap
<>();
cdtTrfTxInfMaps
.
put
(
"pmtTpInf"
,
pmtTpInfMaps
);
}
JSONArray
svcLvlJsonArray
=
null
;
if
(
pmtTpInfMaps
.
containsKey
(
"svcLvl"
))
{
svcLvlJsonArray
=
(
JSONArray
)
pmtTpInfMaps
.
get
(
"svcLvl"
);
}
else
{
svcLvlJsonArray
=
new
JSONArray
();
pmtTpInfMaps
.
put
(
"svcLvl"
,
svcLvlJsonArray
);
}
Field23E
intcField23E
=
null
;
Field23E
cortField23E
=
null
;
for
(
int
i
=
0
;
i
<
tags
.
length
;
i
++)
{
Field23E
field23E
=
(
Field23E
)
tags
[
i
].
asField
();
if
(
ExternalCreditorAgentInstructionCode
.
HOLD
.
value
().
equals
(
field23E
.
getCode
())
||
ExternalCreditorAgentInstructionCode
.
PHOB
.
value
().
equals
(
field23E
.
getCode
())
||
ExternalCreditorAgentInstructionCode
.
CHQB
.
value
().
equals
(
field23E
.
getCode
())
||
ExternalCreditorAgentInstructionCode
.
TELB
.
value
().
equals
(
field23E
.
getCode
()))
{
field23EList
.
add
(
field23E
);
}
else
if
(
"SDVA"
.
equals
(
field23E
.
getCode
()))
{
Map
<
String
,
Object
>
svcLvlMaps
=
new
HashMap
<>();
svcLvlMaps
.
put
(
"cd"
,
field23E
.
getCode
());
svcLvlJsonArray
.
add
(
svcLvlMaps
);
}
else
if
(
CategoryPurposeCode
.
INTC
.
value
().
equals
(
field23E
.
getCode
()))
{
intcField23E
=
field23E
;
}
else
if
(
CategoryPurposeCode
.
CORT
.
value
().
equals
(
field23E
.
getCode
()))
{
cortField23E
=
field23E
;
}
}
Map
<
String
,
Object
>
ctgyPurpMaps
=
null
;
if
(
pmtTpInfMaps
.
containsKey
(
"ctgyPurp"
))
{
ctgyPurpMaps
=
(
Map
<
String
,
Object
>)
pmtTpInfMaps
.
get
(
"ctgyPurp"
);
}
else
{
ctgyPurpMaps
=
new
HashMap
<>();
pmtTpInfMaps
.
put
(
"ctgyPurp"
,
ctgyPurpMaps
);
}
if
(
intcField23E
!=
null
&&
cortField23E
!=
null
)
{
ctgyPurpMaps
.
put
(
"prtry"
,
CategoryPurposeCode
.
INTC
.
value
()
+
" "
+
CategoryPurposeCode
.
CORT
.
value
());
}
else
if
(
intcField23E
!=
null
)
{
ctgyPurpMaps
.
put
(
"cd"
,
CategoryPurposeCode
.
INTC
.
value
());
}
else
if
(
cortField23E
!=
null
)
{
ctgyPurpMaps
.
put
(
"cd"
,
CategoryPurposeCode
.
CORT
.
value
());
}
}
Tag
tag70
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_70
);
String
mt70
=
""
;
if
(
tag70
!=
null
)
{
mt70
=
tag70
.
getValue
();
}
mt_to_mxInstructionForCreditorAgent
(
field23EList
,
mt70
,
cdtTrfTxInfMaps
);
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/impl/Pacs00801Parse26TField.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs008001
.
impl
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
Pacs00801Parse26TField
extends
AbstractMt2MxPacs008001ParseField
{
private
static
final
String
NAME
=
"26T"
;
@Override
public
void
parseField
()
throws
SwiftException
{
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
Tag
tag26T
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME
);
if
(
tag26T
!=
null
)
{
String
value
=
":26T:"
+
tag26T
.
getValue
();
Map
<
String
,
Object
>
purpMaps
=
null
;
if
(
cdtTrfTxInfMaps
.
containsKey
(
"purp"
))
{
purpMaps
=
(
Map
<
String
,
Object
>)
cdtTrfTxInfMaps
.
get
(
"purp"
);
}
else
{
purpMaps
=
new
HashMap
<>();
cdtTrfTxInfMaps
.
put
(
"purp"
,
purpMaps
);
}
purpMaps
.
put
(
"prtry"
,
value
);
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/impl/Pacs00801Parse32AField.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs008001
.
impl
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField
;
import
com.brilliance.swift.util.DateUtil
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.field.Field32A
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.text.ParseException
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
Pacs00801Parse32AField
extends
AbstractMt2MxPacs008001ParseField
{
private
static
final
String
NAME
=
"32A"
;
@Override
public
void
parseField
()
throws
SwiftException
{
try
{
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
Tag
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME
);
if
(
tag
!=
null
)
{
Field32A
field32A
=
(
Field32A
)
tag
.
asField
();
Date
date
=
DateUtil
.
parseDate
(
"20"
+
field32A
.
getDate
(),
"yyyyMMdd"
);
String
dateStr
=
DateUtil
.
format
(
date
,
"yyyy-MM-dd"
);
cdtTrfTxInfMaps
.
put
(
"intrBkSttlmDt"
,
dateStr
);
Map
<
String
,
Object
>
intrBkSttlmAmtMaps
=
new
HashMap
<>();
intrBkSttlmAmtMaps
.
put
(
"value"
,
field32A
.
amount
());
intrBkSttlmAmtMaps
.
put
(
"ccy"
,
field32A
.
getCurrency
());
cdtTrfTxInfMaps
.
put
(
"intrBkSttlmAmt"
,
intrBkSttlmAmtMaps
);
}
}
catch
(
ParseException
e
)
{
throw
new
SwiftException
(
"ERROR"
,
e
.
getMessage
());
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/impl/Pacs00801Parse33BField.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs008001
.
impl
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.field.Field33B
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
Pacs00801Parse33BField
extends
AbstractMt2MxPacs008001ParseField
{
private
static
final
String
NAME
=
"33B"
;
@Override
public
void
parseField
()
throws
SwiftException
{
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
Tag
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME
);
if
(
tag
!=
null
)
{
Field33B
field33B
=
(
Field33B
)
tag
.
asField
();
Map
<
String
,
Object
>
instdAmtMaps
=
new
HashMap
<>();
instdAmtMaps
.
put
(
"value"
,
field33B
.
amount
());
instdAmtMaps
.
put
(
"ccy"
,
field33B
.
getCurrency
());
cdtTrfTxInfMaps
.
put
(
"instdAmt"
,
instdAmtMaps
);
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/impl/Pacs00801Parse36Field.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs008001
.
impl
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.field.Field36
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.math.BigDecimal
;
public
class
Pacs00801Parse36Field
extends
AbstractMt2MxPacs008001ParseField
{
private
static
final
String
NAME
=
"36"
;
@Override
public
void
parseField
()
throws
SwiftException
{
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
Tag
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME
);
if
(
tag
!=
null
)
{
Field36
field36
=
(
Field36
)
tag
.
asField
();
cdtTrfTxInfMaps
.
put
(
"xchgRate"
,
new
BigDecimal
(
field36
.
getRateAsNumber
().
toString
()));
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/impl/Pacs00801Parse50Field.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs008001
.
impl
;
import
com.alibaba.fastjson.JSONArray
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.vo.common.OrganisationIdentificationCode
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.field.Field50A
;
import
com.prowidesoftware.swift.model.field.Field50F
;
import
com.prowidesoftware.swift.model.field.Field50K
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
Pacs00801Parse50Field
extends
AbstractMt2MxPacs008001ParseField
{
private
static
final
String
NAME_A
=
"50A"
;
private
static
final
String
NAME_F
=
"50F"
;
private
static
final
String
NAME_K
=
"50K"
;
@Override
public
void
parseField
()
throws
SwiftException
{
Field50A
field50A
=
null
;
Field50F
field50F
=
null
;
Field50K
field50K
=
null
;
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
Tag
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_A
);
if
(
tag
!=
null
)
{
field50A
=
(
Field50A
)
tag
.
asField
();
}
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_F
);
if
(
tag
!=
null
)
{
field50F
=
(
Field50F
)
tag
.
asField
();
}
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_K
);
if
(
tag
!=
null
)
{
field50K
=
(
Field50K
)
tag
.
asField
();
}
Map
<
String
,
Object
>
dbtrMaps
=
null
;
if
(
cdtTrfTxInfMaps
.
containsKey
(
"dbtr"
))
{
dbtrMaps
=
(
Map
<
String
,
Object
>)
cdtTrfTxInfMaps
.
get
(
"dbtr"
);
}
else
{
dbtrMaps
=
new
HashMap
<>();
}
Map
<
String
,
Object
>
dbtrAcctMaps
=
null
;
if
(
cdtTrfTxInfMaps
.
containsKey
(
"dbtrAcct"
))
{
dbtrAcctMaps
=
(
Map
<
String
,
Object
>)
cdtTrfTxInfMaps
.
get
(
"dbtrAcct"
);
}
else
{
dbtrAcctMaps
=
new
HashMap
<>();
}
String
account
=
""
;
if
(
field50A
!=
null
)
{
String
bicCode
=
field50A
.
getBIC
();
if
(
StringUtil
.
isNotEmpty
(
field50A
.
getComponent1
()))
{
account
+=
"/"
+
field50A
.
getComponent1
();
}
mt_to_mxAnyBIC
(
bicCode
,
dbtrMaps
);
if
(
StringUtil
.
isEmpty
(
account
))
{
buildDefaultValue
(
dbtrMaps
);
}
else
{
mt_to_mxPartyAccount
(
account
,
dbtrAcctMaps
);
}
}
if
(
field50F
!=
null
)
{
String
partyIdentifier
=
field50F
.
getPartyIdentifier
();
String
nameAddress
=
""
;
List
<
String
>
lines
=
field50F
.
getLines
();
for
(
int
i
=
0
;
i
<
lines
.
size
();
i
++)
{
if
(
i
==
0
)
{
continue
;
}
if
(
i
==
lines
.
size
()-
1
)
{
nameAddress
+=
lines
.
get
(
i
);
}
else
{
nameAddress
+=
lines
.
get
(
i
)
+
Mx2MtConstants
.
NEW_LINE
;
}
}
if
(
partyIdentifier
.
startsWith
(
"/"
))
{
mt_to_mxPartyAccount
(
partyIdentifier
.
substring
(
1
),
dbtrAcctMaps
);
}
else
{
Map
<
String
,
Object
>
idMaps
=
null
;
if
(
dbtrMaps
.
containsKey
(
"id"
))
{
idMaps
=
(
Map
<
String
,
Object
>)
dbtrMaps
.
get
(
"id"
);
}
else
{
idMaps
=
new
HashMap
<>();
dbtrMaps
.
put
(
"id"
,
idMaps
);
}
mt_to_mxFATFIdentification
(
partyIdentifier
,
nameAddress
,
idMaps
);
}
mt_to_mxFATFNameAndAddress
(
partyIdentifier
,
nameAddress
,
dbtrMaps
);
}
if
(
field50K
!=
null
)
{
String
nameAddress
=
field50K
.
getNameAndAddress
();
if
(
StringUtil
.
isNotEmpty
(
field50K
.
getComponent1
()))
{
account
+=
"/"
+
field50K
.
getComponent1
();
}
mt_to_mxPartyNameAndAddress
(
nameAddress
,
dbtrMaps
);
if
(
StringUtil
.
isEmpty
(
account
))
{
buildDefaultValue
(
dbtrMaps
);
}
else
{
mt_to_mxPartyAccount
(
account
,
dbtrAcctMaps
);
}
}
if
(
dbtrMaps
.
size
()
>
0
)
{
cdtTrfTxInfMaps
.
put
(
"dbtr"
,
dbtrMaps
);
}
if
(
dbtrAcctMaps
.
size
()
>
0
)
{
cdtTrfTxInfMaps
.
put
(
"dbtrAcct"
,
dbtrAcctMaps
);
}
}
/**
* IF 50A/Account 50K/Account IsAbsent
* THEN Copy "NOTPROVIDED" to Debtor/Id/OrgID/Other/ID
* and "TXID" to SchemeName/Code
* @param dbtrMaps
*/
private
void
buildDefaultValue
(
Map
<
String
,
Object
>
dbtrMaps
)
{
Map
<
String
,
Object
>
idMaps
=
null
;
if
(
dbtrMaps
.
containsKey
(
"id"
))
{
idMaps
=
(
Map
<
String
,
Object
>)
dbtrMaps
.
get
(
"id"
);
}
else
{
idMaps
=
new
HashMap
<>();
dbtrMaps
.
put
(
"id"
,
idMaps
);
}
Map
<
String
,
Object
>
idOrgMaps
=
null
;
if
(
idMaps
.
containsKey
(
"orgId"
))
{
idOrgMaps
=
(
Map
<
String
,
Object
>)
idMaps
.
get
(
"orgId"
);
}
else
{
idOrgMaps
=
new
HashMap
<>();
idMaps
.
put
(
"orgId"
,
idOrgMaps
);
}
JSONArray
othrJsonArray
=
null
;
if
(
idOrgMaps
.
containsKey
(
"othr"
))
{
othrJsonArray
=
(
JSONArray
)
idOrgMaps
.
get
(
"othr"
);
}
else
{
othrJsonArray
=
new
JSONArray
();
idOrgMaps
.
put
(
"othr"
,
othrJsonArray
);
}
Map
<
String
,
Object
>
othrMaps
=
new
HashMap
<>();
othrJsonArray
.
add
(
othrMaps
);
othrMaps
.
put
(
"id"
,
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
);
Map
<
String
,
Object
>
schmeNmMaps
=
null
;
if
(
othrMaps
.
containsKey
(
"schmeNm"
))
{
schmeNmMaps
=
(
Map
<
String
,
Object
>)
othrMaps
.
get
(
"schmeNm"
);
}
else
{
schmeNmMaps
=
new
HashMap
<>();
othrMaps
.
put
(
"schmeNm"
,
schmeNmMaps
);
}
schmeNmMaps
.
put
(
"cd"
,
OrganisationIdentificationCode
.
TXID
.
value
());
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/impl/Pacs00801Parse52Field.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs008001
.
impl
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.Mt2MxContextIdentifier
;
import
com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField
;
import
com.brilliance.swift.util.StringUtil
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.field.Field52A
;
import
com.prowidesoftware.swift.model.field.Field52D
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
Pacs00801Parse52Field
extends
AbstractMt2MxPacs008001ParseField
{
private
static
final
String
NAME_A
=
"52A"
;
private
static
final
String
NAME_D
=
"52D"
;
@Override
public
void
parseField
()
throws
SwiftException
{
Field52A
field52A
=
null
;
Field52D
field52D
=
null
;
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
Tag
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_A
);
if
(
tag
!=
null
)
{
field52A
=
(
Field52A
)
tag
.
asField
();
}
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_D
);
if
(
tag
!=
null
)
{
field52D
=
(
Field52D
)
tag
.
asField
();
}
Map
<
String
,
Object
>
dbtrAgtMaps
=
null
;
if
(
cdtTrfTxInfMaps
.
containsKey
(
"dbtrAgt"
))
{
dbtrAgtMaps
=
(
Map
<
String
,
Object
>)
cdtTrfTxInfMaps
.
get
(
"dbtrAgt"
);
}
else
{
dbtrAgtMaps
=
new
HashMap
<>();
}
Map
<
String
,
Object
>
dbtrAgtAcctMaps
=
null
;
if
(
cdtTrfTxInfMaps
.
containsKey
(
"dbtrAgtAcct"
))
{
dbtrAgtAcctMaps
=
(
Map
<
String
,
Object
>)
cdtTrfTxInfMaps
.
get
(
"dbtrAgtAcct"
);
}
else
{
dbtrAgtAcctMaps
=
new
HashMap
<>();
}
String
account
=
""
;
if
(
field52A
!=
null
)
{
String
bicCode
=
field52A
.
getBIC
();
mt_to_mxBICFI
(
bicCode
,
dbtrAgtMaps
);
if
(
StringUtil
.
isNotEmpty
(
field52A
.
getComponent1
()))
{
account
=
"/"
+
field52A
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field52A
.
getComponent2
()))
{
account
=
"/"
+
field52A
.
getComponent2
();
}
}
else
if
(
field52D
!=
null
)
{
if
(
StringUtil
.
isNotEmpty
(
field52D
.
getComponent1
()))
{
account
=
"/"
+
field52D
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field52D
.
getComponent2
()))
{
account
=
"/"
+
field52D
.
getComponent2
();
}
String
nameAddress
=
field52D
.
getNameAndAddress
();
mt_to_mxFinancialInstitutionNameAndUnstructuredAddress
(
nameAddress
,
dbtrAgtMaps
);
}
else
{
String
sendBic
=
(
String
)
context
.
get
(
Mt2MxContextIdentifier
.
MT_SEND_BIC
,
true
);
mt_to_mxBICFI
(
sendBic
,
dbtrAgtMaps
);
}
if
(
StringUtil
.
isNotEmpty
(
account
))
{
if
(
account
.
startsWith
(
"//"
)
&&
!
account
.
startsWith
(
"//CH"
)
&&
!
account
.
startsWith
(
"//FW"
))
{
Map
<
String
,
Object
>
finInstnIdMaps
=
null
;
if
(
dbtrAgtMaps
.
containsKey
(
"finInstnId"
))
{
finInstnIdMaps
=
(
Map
<
String
,
Object
>)
dbtrAgtMaps
.
get
(
"finInstnId"
);
}
else
{
finInstnIdMaps
=
new
HashMap
<>();
dbtrAgtMaps
.
put
(
"finInstnId"
,
finInstnIdMaps
);
}
Map
<
String
,
Object
>
clrSysMmbIdMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"clrSysMmbId"
))
{
clrSysMmbIdMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"clrSysMmbId"
);
}
else
{
clrSysMmbIdMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"clrSysMmbId"
,
clrSysMmbIdMaps
);
}
mt_to_mxClearingIdentifier
(
account
,
clrSysMmbIdMaps
);
}
else
if
(!
account
.
startsWith
(
"//"
)
||
account
.
startsWith
(
"//CH"
))
{
mt_to_mxFinancialInstitutionAccount
(
account
,
dbtrAgtAcctMaps
);
}
}
if
(
dbtrAgtMaps
.
size
()
>
0
)
{
cdtTrfTxInfMaps
.
put
(
"dbtrAgt"
,
dbtrAgtMaps
);
}
if
(
dbtrAgtAcctMaps
.
size
()
>
0
)
{
cdtTrfTxInfMaps
.
put
(
"dbtrAgtAcct"
,
dbtrAgtAcctMaps
);
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/impl/Pacs00801Parse53Field.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs008001
.
impl
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.vo.VoSettlementMethodHelper
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.field.Field53A
;
import
com.prowidesoftware.swift.model.field.Field53D
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
Pacs00801Parse53Field
extends
AbstractMt2MxPacs008001ParseField
{
private
static
final
String
NAME_A
=
"53A"
;
//private static final String NAME_B = "53B";
private
static
final
String
NAME_D
=
"53D"
;
@Override
public
void
parseField
()
throws
SwiftException
{
VoSettlementMethodHelper
setlMtdHelper
=
context
.
get
(
VoSettlementMethodHelper
.
class
);
if
(
setlMtdHelper
.
isTranslate53Flag
())
{
//53B 只能翻译成 Group Header -> Settlement Information -> Settlement Account/Settlement Method
Field53A
field53A
=
null
;
Field53D
field53D
=
null
;
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
Tag
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_A
);
if
(
tag
!=
null
)
{
field53A
=
(
Field53A
)
tag
.
asField
();
}
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_D
);
if
(
tag
!=
null
)
{
field53D
=
(
Field53D
)
tag
.
asField
();
}
Map
<
String
,
Object
>
sttlmInfMaps
=
null
;
if
(
grpHdrMaps
.
containsKey
(
"sttlmInf"
))
{
sttlmInfMaps
=
(
Map
<
String
,
Object
>)
grpHdrMaps
.
get
(
"sttlmInf"
);
}
else
{
sttlmInfMaps
=
new
HashMap
<>();
grpHdrMaps
.
put
(
"sttlmInf"
,
sttlmInfMaps
);
}
Map
<
String
,
Object
>
instgRmbrsmntAgtMaps
=
null
;
if
(
sttlmInfMaps
.
containsKey
(
"instgRmbrsmntAgt"
))
{
instgRmbrsmntAgtMaps
=
(
Map
<
String
,
Object
>)
sttlmInfMaps
.
get
(
"instgRmbrsmntAgt"
);
}
else
{
instgRmbrsmntAgtMaps
=
new
HashMap
<>();
sttlmInfMaps
.
put
(
"instgRmbrsmntAgt"
,
instgRmbrsmntAgtMaps
);
}
String
account
=
""
;
if
(
field53A
!=
null
)
{
String
bicCode
=
field53A
.
getBIC
();
mt_to_mxBICFI
(
bicCode
,
instgRmbrsmntAgtMaps
);
if
(
StringUtil
.
isNotEmpty
(
field53A
.
getComponent1
()))
{
account
+=
"/"
+
field53A
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field53A
.
getComponent2
()))
{
account
+=
"/"
+
field53A
.
getComponent2
();
}
}
else
if
(
field53D
!=
null
)
{
String
nameAddress
=
field53D
.
getNameAndAddress
();
mt_to_mxFinancialInstitutionNameAndUnstructuredAddress
(
nameAddress
,
instgRmbrsmntAgtMaps
);
if
(
StringUtil
.
isNotEmpty
(
field53D
.
getComponent1
()))
{
account
+=
"/"
+
field53D
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field53D
.
getComponent2
()))
{
account
+=
"/"
+
field53D
.
getComponent2
();
}
}
if
(
StringUtil
.
isNotEmpty
(
account
))
{
Map
<
String
,
Object
>
instgRmbrsmntAgtAcctMaps
=
null
;
if
(
sttlmInfMaps
.
containsKey
(
"instgRmbrsmntAgtAcct"
))
{
instgRmbrsmntAgtAcctMaps
=
(
Map
<
String
,
Object
>)
sttlmInfMaps
.
get
(
"instgRmbrsmntAgtAcct"
);
}
else
{
instgRmbrsmntAgtAcctMaps
=
new
HashMap
<>();
sttlmInfMaps
.
put
(
"instgRmbrsmntAgtAcct"
,
instgRmbrsmntAgtAcctMaps
);
}
if
(
account
.
startsWith
(
"//"
)
&&
!
account
.
startsWith
(
"//CH"
))
{
Map
<
String
,
Object
>
finInstnIdMaps
=
null
;
if
(
instgRmbrsmntAgtMaps
.
containsKey
(
"finInstnId"
))
{
finInstnIdMaps
=
(
Map
<
String
,
Object
>)
instgRmbrsmntAgtMaps
.
get
(
"finInstnId"
);
}
else
{
finInstnIdMaps
=
new
HashMap
<>();
instgRmbrsmntAgtMaps
.
put
(
"finInstnId"
,
finInstnIdMaps
);
}
Map
<
String
,
Object
>
clrSysMmbIdMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"clrSysMmbId"
))
{
clrSysMmbIdMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"clrSysMmbId"
);
}
else
{
clrSysMmbIdMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"clrSysMmbId"
,
clrSysMmbIdMaps
);
}
mt_to_mxClearingIdentifier
(
account
,
clrSysMmbIdMaps
);
}
else
{
mt_to_mxFinancialInstitutionAccount
(
account
,
instgRmbrsmntAgtAcctMaps
);
}
}
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/impl/Pacs00801Parse54Field.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs008001
.
impl
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.vo.VoSettlementMethodHelper
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.field.Field54A
;
import
com.prowidesoftware.swift.model.field.Field54B
;
import
com.prowidesoftware.swift.model.field.Field54D
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
Pacs00801Parse54Field
extends
AbstractMt2MxPacs008001ParseField
{
private
static
final
String
NAME_A
=
"54A"
;
private
static
final
String
NAME_B
=
"54B"
;
private
static
final
String
NAME_D
=
"54D"
;
@Override
public
void
parseField
()
throws
SwiftException
{
VoSettlementMethodHelper
setlMtdHelper
=
context
.
get
(
VoSettlementMethodHelper
.
class
);
if
(
setlMtdHelper
.
isTranslate54Flag
())
{
Field54A
field54A
=
null
;
Field54B
field54B
=
null
;
Field54D
field54D
=
null
;
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
Tag
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_A
);
if
(
tag
!=
null
)
{
field54A
=
(
Field54A
)
tag
.
asField
();
}
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_B
);
if
(
tag
!=
null
)
{
field54B
=
(
Field54B
)
tag
.
asField
();
}
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_D
);
if
(
tag
!=
null
)
{
field54D
=
(
Field54D
)
tag
.
asField
();
}
Map
<
String
,
Object
>
sttlmInfMaps
=
null
;
if
(
grpHdrMaps
.
containsKey
(
"sttlmInf"
))
{
sttlmInfMaps
=
(
Map
<
String
,
Object
>)
grpHdrMaps
.
get
(
"sttlmInf"
);
}
else
{
sttlmInfMaps
=
new
HashMap
<>();
grpHdrMaps
.
put
(
"sttlmInf"
,
sttlmInfMaps
);
}
Map
<
String
,
Object
>
instdRmbrsmntAgtMaps
=
null
;
if
(
sttlmInfMaps
.
containsKey
(
"instdRmbrsmntAgt"
))
{
instdRmbrsmntAgtMaps
=
(
Map
<
String
,
Object
>)
sttlmInfMaps
.
get
(
"instdRmbrsmntAgt"
);
}
else
{
instdRmbrsmntAgtMaps
=
new
HashMap
<>();
}
Map
<
String
,
Object
>
instdRmbrsmntAgtAcctMaps
=
null
;
if
(
sttlmInfMaps
.
containsKey
(
"instdRmbrsmntAgtAcct"
))
{
instdRmbrsmntAgtAcctMaps
=
(
Map
<
String
,
Object
>)
sttlmInfMaps
.
get
(
"instdRmbrsmntAgtAcct"
);
}
else
{
instdRmbrsmntAgtAcctMaps
=
new
HashMap
<>();
}
String
account
=
""
;
if
(
field54A
!=
null
)
{
String
bicCode
=
field54A
.
getBIC
();
mt_to_mxBICFI
(
bicCode
,
instdRmbrsmntAgtMaps
);
if
(
StringUtil
.
isNotEmpty
(
field54A
.
getComponent1
()))
{
account
=
"/"
+
field54A
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field54A
.
getComponent2
()))
{
account
=
"/"
+
field54A
.
getComponent2
();
}
if
(
account
.
startsWith
(
"//"
)
&&
!
account
.
startsWith
(
"//CH"
))
{
Map
<
String
,
Object
>
finInstnIdMaps
=
null
;
if
(
instdRmbrsmntAgtMaps
.
containsKey
(
"finInstnId"
))
{
finInstnIdMaps
=
(
Map
<
String
,
Object
>)
instdRmbrsmntAgtMaps
.
get
(
"finInstnId"
);
}
else
{
finInstnIdMaps
=
new
HashMap
<>();
instdRmbrsmntAgtMaps
.
put
(
"finInstnId"
,
finInstnIdMaps
);
}
Map
<
String
,
Object
>
clrSysMmbIdMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"clrSysMmbId"
))
{
clrSysMmbIdMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"clrSysMmbId"
);
}
else
{
clrSysMmbIdMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"clrSysMmbId"
,
clrSysMmbIdMaps
);
}
mt_to_mxClearingIdentifier
(
account
,
clrSysMmbIdMaps
);
}
else
if
(!
account
.
startsWith
(
"//"
)
||
account
.
startsWith
(
"//CH"
))
{
mt_to_mxFinancialInstitutionAccount
(
account
,
instdRmbrsmntAgtAcctMaps
);
}
}
else
if
(
field54B
!=
null
)
{
if
(
StringUtil
.
isNotEmpty
(
field54B
.
getComponent1
()))
{
account
=
"/"
+
field54B
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field54B
.
getComponent2
()))
{
account
=
"/"
+
field54B
.
getComponent2
();
}
String
location
=
field54B
.
getLocation
();
Map
<
String
,
Object
>
finInstnIdMaps
=
null
;
if
(
instdRmbrsmntAgtMaps
.
containsKey
(
"finInstnId"
))
{
finInstnIdMaps
=
(
Map
<
String
,
Object
>)
instdRmbrsmntAgtMaps
.
get
(
"finInstnId"
);
}
else
{
finInstnIdMaps
=
new
HashMap
<>();
instdRmbrsmntAgtMaps
.
put
(
"finInstnId"
,
finInstnIdMaps
);
}
if
(
account
.
startsWith
(
"//"
)
&&
!
account
.
startsWith
(
"//CH"
))
{
if
(
isMTClearingSystemCodeInList
(
account
))
{
Map
<
String
,
Object
>
clrSysMmbIdMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"clrSysMmbId"
))
{
clrSysMmbIdMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"clrSysMmbId"
);
}
else
{
clrSysMmbIdMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"clrSysMmbId"
,
clrSysMmbIdMaps
);
}
mt_to_mxClearingIdentifier
(
account
,
clrSysMmbIdMaps
);
//name address 设置NOTPROVIDED
finInstnIdMaps
.
put
(
"nm"
,
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
);
Map
<
String
,
Object
>
pstlAdrMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"pstlAdr"
))
{
pstlAdrMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"pstlAdr"
);
}
else
{
pstlAdrMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"pstlAdr"
,
pstlAdrMaps
);
}
List
<
String
>
adrLineList
=
new
ArrayList
<>();
adrLineList
.
add
(
StringUtil
.
isEmpty
(
location
)?
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
:
location
);
pstlAdrMaps
.
put
(
"adrLine"
,
adrLineList
);
}
else
{
mt_to_mxClearingSystemToNameAndAddressLine
(
account
,
location
,
finInstnIdMaps
);
}
}
else
if
(!
account
.
startsWith
(
"//"
)
||
account
.
startsWith
(
"//CH"
))
{
mt_to_mxFinancialInstitutionAccount
(
account
,
instdRmbrsmntAgtAcctMaps
);
//name address 设置NOTPROVIDED
finInstnIdMaps
.
put
(
"nm"
,
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
);
Map
<
String
,
Object
>
pstlAdrMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"pstlAdr"
))
{
pstlAdrMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"pstlAdr"
);
}
else
{
pstlAdrMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"pstlAdr"
,
pstlAdrMaps
);
}
List
<
String
>
adrLineList
=
new
ArrayList
<>();
adrLineList
.
add
(
StringUtil
.
isEmpty
(
location
)?
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
:
location
);
pstlAdrMaps
.
put
(
"adrLine"
,
adrLineList
);
}
}
else
if
(
field54D
!=
null
)
{
if
(
StringUtil
.
isNotEmpty
(
field54D
.
getComponent1
()))
{
account
=
"/"
+
field54D
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field54D
.
getComponent2
()))
{
account
=
"/"
+
field54D
.
getComponent2
();
}
String
nameAddress
=
field54D
.
getNameAndAddress
();
mt_to_mxFinancialInstitutionNameAndUnstructuredAddress
(
nameAddress
,
instdRmbrsmntAgtMaps
);
if
(
account
.
startsWith
(
"//"
)
&&
!
account
.
startsWith
(
"//CH"
))
{
Map
<
String
,
Object
>
finInstnIdMaps
=
null
;
if
(
instdRmbrsmntAgtMaps
.
containsKey
(
"finInstnId"
))
{
finInstnIdMaps
=
(
Map
<
String
,
Object
>)
instdRmbrsmntAgtMaps
.
get
(
"finInstnId"
);
}
else
{
finInstnIdMaps
=
new
HashMap
<>();
instdRmbrsmntAgtMaps
.
put
(
"finInstnId"
,
finInstnIdMaps
);
}
Map
<
String
,
Object
>
clrSysMmbIdMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"clrSysMmbId"
))
{
clrSysMmbIdMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"clrSysMmbId"
);
}
else
{
clrSysMmbIdMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"clrSysMmbId"
,
clrSysMmbIdMaps
);
}
mt_to_mxClearingIdentifier
(
account
,
clrSysMmbIdMaps
);
}
else
if
(!
account
.
startsWith
(
"//"
)
||
account
.
startsWith
(
"//CH"
))
{
mt_to_mxFinancialInstitutionAccount
(
account
,
instdRmbrsmntAgtAcctMaps
);
}
}
if
(
instdRmbrsmntAgtMaps
.
size
()
>
0
)
{
sttlmInfMaps
.
put
(
"instdRmbrsmntAgt"
,
instdRmbrsmntAgtMaps
);
}
if
(
instdRmbrsmntAgtAcctMaps
.
size
()
>
0
)
{
sttlmInfMaps
.
put
(
"instdRmbrsmntAgtAcct"
,
instdRmbrsmntAgtAcctMaps
);
}
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/impl/Pacs00801Parse55Field.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs008001
.
impl
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.vo.VoSettlementMethodHelper
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.field.*
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* 如果55存在,那么53 54必须同时存在
*/
public
class
Pacs00801Parse55Field
extends
AbstractMt2MxPacs008001ParseField
{
private
static
final
String
NAME_A
=
"55A"
;
private
static
final
String
NAME_B
=
"55B"
;
private
static
final
String
NAME_D
=
"55D"
;
@Override
public
void
parseField
()
throws
SwiftException
{
VoSettlementMethodHelper
setlMtdHelper
=
context
.
get
(
VoSettlementMethodHelper
.
class
);
if
(
setlMtdHelper
.
isTranslate55Flag
())
{
Field55A
field55A
=
null
;
Field55B
field55B
=
null
;
Field55D
field55D
=
null
;
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
Tag
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_A
);
if
(
tag
!=
null
)
{
field55A
=
(
Field55A
)
tag
.
asField
();
}
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_B
);
if
(
tag
!=
null
)
{
field55B
=
(
Field55B
)
tag
.
asField
();
}
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_D
);
if
(
tag
!=
null
)
{
field55D
=
(
Field55D
)
tag
.
asField
();
}
Map
<
String
,
Object
>
sttlmInfMaps
=
null
;
if
(
grpHdrMaps
.
containsKey
(
"sttlmInf"
))
{
sttlmInfMaps
=
(
Map
<
String
,
Object
>)
grpHdrMaps
.
get
(
"sttlmInf"
);
}
else
{
sttlmInfMaps
=
new
HashMap
<>();
grpHdrMaps
.
put
(
"sttlmInf"
,
sttlmInfMaps
);
}
Map
<
String
,
Object
>
thrdRmbrsmntAgtMaps
=
null
;
if
(
sttlmInfMaps
.
containsKey
(
"thrdRmbrsmntAgt"
))
{
thrdRmbrsmntAgtMaps
=
(
Map
<
String
,
Object
>)
sttlmInfMaps
.
get
(
"thrdRmbrsmntAgt"
);
}
else
{
thrdRmbrsmntAgtMaps
=
new
HashMap
<>();
}
Map
<
String
,
Object
>
thrdRmbrsmntAgtAcctMaps
=
null
;
if
(
sttlmInfMaps
.
containsKey
(
"thrdRmbrsmntAgtAcct"
))
{
thrdRmbrsmntAgtAcctMaps
=
(
Map
<
String
,
Object
>)
sttlmInfMaps
.
get
(
"thrdRmbrsmntAgtAcct"
);
}
else
{
thrdRmbrsmntAgtAcctMaps
=
new
HashMap
<>();
}
String
account
=
""
;
if
(
field55A
!=
null
)
{
String
bicCode
=
field55A
.
getBIC
();
mt_to_mxBICFI
(
bicCode
,
thrdRmbrsmntAgtMaps
);
if
(
StringUtil
.
isNotEmpty
(
field55A
.
getComponent1
()))
{
account
=
"/"
+
field55A
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field55A
.
getComponent2
()))
{
account
=
"/"
+
field55A
.
getComponent2
();
}
if
(
account
.
startsWith
(
"//"
)
&&
!
account
.
startsWith
(
"//CH"
))
{
Map
<
String
,
Object
>
finInstnIdMaps
=
null
;
if
(
thrdRmbrsmntAgtMaps
.
containsKey
(
"finInstnId"
))
{
finInstnIdMaps
=
(
Map
<
String
,
Object
>)
thrdRmbrsmntAgtMaps
.
get
(
"finInstnId"
);
}
else
{
finInstnIdMaps
=
new
HashMap
<>();
thrdRmbrsmntAgtMaps
.
put
(
"finInstnId"
,
finInstnIdMaps
);
}
Map
<
String
,
Object
>
clrSysMmbIdMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"clrSysMmbId"
))
{
clrSysMmbIdMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"clrSysMmbId"
);
}
else
{
clrSysMmbIdMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"clrSysMmbId"
,
clrSysMmbIdMaps
);
}
mt_to_mxClearingIdentifier
(
account
,
clrSysMmbIdMaps
);
}
else
if
(!
account
.
startsWith
(
"//"
)
||
account
.
startsWith
(
"//CH"
))
{
mt_to_mxFinancialInstitutionAccount
(
account
,
thrdRmbrsmntAgtAcctMaps
);
}
}
else
if
(
field55B
!=
null
)
{
if
(
StringUtil
.
isNotEmpty
(
field55B
.
getComponent1
()))
{
account
=
"/"
+
field55B
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field55B
.
getComponent2
()))
{
account
=
"/"
+
field55B
.
getComponent2
();
}
String
location
=
field55B
.
getLocation
();
Map
<
String
,
Object
>
finInstnIdMaps
=
null
;
if
(
thrdRmbrsmntAgtMaps
.
containsKey
(
"finInstnId"
))
{
finInstnIdMaps
=
(
Map
<
String
,
Object
>)
thrdRmbrsmntAgtMaps
.
get
(
"finInstnId"
);
}
else
{
finInstnIdMaps
=
new
HashMap
<>();
thrdRmbrsmntAgtMaps
.
put
(
"finInstnId"
,
finInstnIdMaps
);
}
if
(
account
.
startsWith
(
"//"
)
&&
!
account
.
startsWith
(
"//CH"
))
{
if
(
isMTClearingSystemCodeInList
(
account
))
{
Map
<
String
,
Object
>
clrSysMmbIdMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"clrSysMmbId"
))
{
clrSysMmbIdMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"clrSysMmbId"
);
}
else
{
clrSysMmbIdMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"clrSysMmbId"
,
clrSysMmbIdMaps
);
}
mt_to_mxClearingIdentifier
(
account
,
clrSysMmbIdMaps
);
//name address 设置NOTPROVIDED
finInstnIdMaps
.
put
(
"nm"
,
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
);
Map
<
String
,
Object
>
pstlAdrMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"pstlAdr"
))
{
pstlAdrMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"pstlAdr"
);
}
else
{
pstlAdrMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"pstlAdr"
,
pstlAdrMaps
);
}
List
<
String
>
adrLineList
=
new
ArrayList
<>();
adrLineList
.
add
(
StringUtil
.
isEmpty
(
location
)?
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
:
location
);
pstlAdrMaps
.
put
(
"adrLine"
,
adrLineList
);
}
else
{
mt_to_mxClearingSystemToNameAndAddressLine
(
account
,
location
,
finInstnIdMaps
);
}
}
else
if
(!
account
.
startsWith
(
"//"
)
||
account
.
startsWith
(
"//CH"
))
{
mt_to_mxFinancialInstitutionAccount
(
account
,
thrdRmbrsmntAgtAcctMaps
);
//name address 设置NOTPROVIDED
finInstnIdMaps
.
put
(
"nm"
,
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
);
Map
<
String
,
Object
>
pstlAdrMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"pstlAdr"
))
{
pstlAdrMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"pstlAdr"
);
}
else
{
pstlAdrMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"pstlAdr"
,
pstlAdrMaps
);
}
List
<
String
>
adrLineList
=
new
ArrayList
<>();
adrLineList
.
add
(
StringUtil
.
isEmpty
(
location
)?
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
:
location
);
pstlAdrMaps
.
put
(
"adrLine"
,
adrLineList
);
}
}
else
if
(
field55D
!=
null
)
{
if
(
StringUtil
.
isNotEmpty
(
field55D
.
getComponent1
()))
{
account
=
"/"
+
field55D
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field55D
.
getComponent2
()))
{
account
=
"/"
+
field55D
.
getComponent2
();
}
String
nameAddress
=
field55D
.
getNameAndAddress
();
mt_to_mxFinancialInstitutionNameAndUnstructuredAddress
(
nameAddress
,
thrdRmbrsmntAgtMaps
);
if
(
account
.
startsWith
(
"//"
)
&&
!
account
.
startsWith
(
"//CH"
))
{
Map
<
String
,
Object
>
finInstnIdMaps
=
null
;
if
(
thrdRmbrsmntAgtMaps
.
containsKey
(
"finInstnId"
))
{
finInstnIdMaps
=
(
Map
<
String
,
Object
>)
thrdRmbrsmntAgtMaps
.
get
(
"finInstnId"
);
}
else
{
finInstnIdMaps
=
new
HashMap
<>();
thrdRmbrsmntAgtMaps
.
put
(
"finInstnId"
,
finInstnIdMaps
);
}
Map
<
String
,
Object
>
clrSysMmbIdMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"clrSysMmbId"
))
{
clrSysMmbIdMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"clrSysMmbId"
);
}
else
{
clrSysMmbIdMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"clrSysMmbId"
,
clrSysMmbIdMaps
);
}
mt_to_mxClearingIdentifier
(
account
,
clrSysMmbIdMaps
);
}
else
if
(!
account
.
startsWith
(
"//"
)
||
account
.
startsWith
(
"//CH"
))
{
mt_to_mxFinancialInstitutionAccount
(
account
,
thrdRmbrsmntAgtAcctMaps
);
}
}
if
(
thrdRmbrsmntAgtMaps
.
size
()
>
0
)
{
sttlmInfMaps
.
put
(
"thrdRmbrsmntAgt"
,
thrdRmbrsmntAgtMaps
);
}
if
(
thrdRmbrsmntAgtAcctMaps
.
size
()
>
0
)
{
sttlmInfMaps
.
put
(
"thrdRmbrsmntAgtAcct"
,
thrdRmbrsmntAgtAcctMaps
);
}
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/impl/Pacs00801Parse56Field.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs008001
.
impl
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField
;
import
com.brilliance.swift.util.StringUtil
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.field.Field56A
;
import
com.prowidesoftware.swift.model.field.Field56C
;
import
com.prowidesoftware.swift.model.field.Field56D
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
Pacs00801Parse56Field
extends
AbstractMt2MxPacs008001ParseField
{
private
static
final
String
NAME_A
=
"56A"
;
private
static
final
String
NAME_C
=
"56C"
;
private
static
final
String
NAME_D
=
"56D"
;
@Override
public
void
parseField
()
throws
SwiftException
{
Field56A
field56A
=
null
;
Field56C
field56C
=
null
;
Field56D
field56D
=
null
;
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
Tag
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_A
);
if
(
tag
!=
null
)
{
field56A
=
(
Field56A
)
tag
.
asField
();
}
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_C
);
if
(
tag
!=
null
)
{
field56C
=
(
Field56C
)
tag
.
asField
();
}
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_D
);
if
(
tag
!=
null
)
{
field56D
=
(
Field56D
)
tag
.
asField
();
}
Map
<
String
,
Object
>
intrmyAgt1Maps
=
null
;
if
(
cdtTrfTxInfMaps
.
containsKey
(
"intrmyAgt1"
))
{
intrmyAgt1Maps
=
(
Map
<
String
,
Object
>)
cdtTrfTxInfMaps
.
get
(
"intrmyAgt1"
);
}
else
{
intrmyAgt1Maps
=
new
HashMap
<>();
}
Map
<
String
,
Object
>
intrmyAgt1AcctMaps
=
null
;
if
(
cdtTrfTxInfMaps
.
containsKey
(
"intrmyAgt1Acct"
))
{
intrmyAgt1AcctMaps
=
(
Map
<
String
,
Object
>)
cdtTrfTxInfMaps
.
get
(
"intrmyAgt1Acct"
);
}
else
{
intrmyAgt1AcctMaps
=
new
HashMap
<>();
}
boolean
clearingChannelRTGSFlag
=
false
;
String
account
=
""
;
if
(
field56A
!=
null
)
{
String
bicCode
=
field56A
.
getBIC
();
mt_to_mxBICFI
(
bicCode
,
intrmyAgt1Maps
);
if
(
StringUtil
.
isNotEmpty
(
field56A
.
getComponent1
()))
{
account
=
"/"
+
field56A
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field56A
.
getComponent2
()))
{
account
=
"/"
+
field56A
.
getComponent2
();
}
if
(
account
.
startsWith
(
"//RT"
)
||
account
.
startsWith
(
"//FW"
))
{
clearingChannelRTGSFlag
=
true
;
}
if
(
account
.
startsWith
(
"//"
)
&&
!
account
.
startsWith
(
"//CH"
)
&&
!
account
.
startsWith
(
"//FW"
)
&&
!
account
.
startsWith
(
"//RT"
))
{
Map
<
String
,
Object
>
finInstnIdMaps
=
null
;
if
(
intrmyAgt1Maps
.
containsKey
(
"finInstnId"
))
{
finInstnIdMaps
=
(
Map
<
String
,
Object
>)
intrmyAgt1Maps
.
get
(
"finInstnId"
);
}
else
{
finInstnIdMaps
=
new
HashMap
<>();
intrmyAgt1Maps
.
put
(
"finInstnId"
,
finInstnIdMaps
);
}
Map
<
String
,
Object
>
clrSysMmbIdMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"clrSysMmbId"
))
{
clrSysMmbIdMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"clrSysMmbId"
);
}
else
{
clrSysMmbIdMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"clrSysMmbId"
,
clrSysMmbIdMaps
);
}
mt_to_mxClearingIdentifier
(
account
,
clrSysMmbIdMaps
);
}
else
if
(!
account
.
startsWith
(
"//"
)
||
account
.
startsWith
(
"//CH"
))
{
mt_to_mxFinancialInstitutionAccount
(
account
,
intrmyAgt1AcctMaps
);
}
}
else
if
(
field56C
!=
null
)
{
account
=
field56C
.
getValue
();
if
(
account
.
startsWith
(
"//RT"
))
{
clearingChannelRTGSFlag
=
true
;
}
Map
<
String
,
Object
>
finInstnIdMaps
=
null
;
if
(
intrmyAgt1Maps
.
containsKey
(
"finInstnId"
))
{
finInstnIdMaps
=
(
Map
<
String
,
Object
>)
intrmyAgt1Maps
.
get
(
"finInstnId"
);
}
else
{
finInstnIdMaps
=
new
HashMap
<>();
intrmyAgt1Maps
.
put
(
"finInstnId"
,
finInstnIdMaps
);
}
if
(
account
.
startsWith
(
"//"
)
&&
!
account
.
startsWith
(
"//CH"
)
&&
!
account
.
startsWith
(
"//FW"
))
{
if
(
isMTClearingSystemCodeInList
(
account
))
{
Map
<
String
,
Object
>
clrSysMmbIdMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"clrSysMmbId"
))
{
clrSysMmbIdMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"clrSysMmbId"
);
}
else
{
clrSysMmbIdMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"clrSysMmbId"
,
clrSysMmbIdMaps
);
}
mt_to_mxClearingIdentifier
(
account
,
clrSysMmbIdMaps
);
//name address 设置NOTPROVIDED
finInstnIdMaps
.
put
(
"nm"
,
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
);
Map
<
String
,
Object
>
pstlAdrMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"pstlAdr"
))
{
pstlAdrMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"pstlAdr"
);
}
else
{
pstlAdrMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"pstlAdr"
,
pstlAdrMaps
);
}
List
<
String
>
adrLineList
=
new
ArrayList
<>();
adrLineList
.
add
(
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
);
pstlAdrMaps
.
put
(
"adrLine"
,
adrLineList
);
}
else
{
mt_to_mxClearingSystemToNameAndAddressLine
(
account
,
null
,
finInstnIdMaps
);
}
}
else
if
(!
account
.
startsWith
(
"//"
)
||
account
.
startsWith
(
"//CH"
))
{
mt_to_mxFinancialInstitutionAccount
(
account
,
intrmyAgt1AcctMaps
);
//name address 设置NOTPROVIDED
finInstnIdMaps
.
put
(
"nm"
,
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
);
Map
<
String
,
Object
>
pstlAdrMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"pstlAdr"
))
{
pstlAdrMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"pstlAdr"
);
}
else
{
pstlAdrMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"pstlAdr"
,
pstlAdrMaps
);
}
List
<
String
>
adrLineList
=
new
ArrayList
<>();
adrLineList
.
add
(
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
);
pstlAdrMaps
.
put
(
"adrLine"
,
adrLineList
);
}
}
else
if
(
field56D
!=
null
)
{
if
(
StringUtil
.
isNotEmpty
(
field56D
.
getComponent1
()))
{
account
=
"/"
+
field56D
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field56D
.
getComponent2
()))
{
account
=
"/"
+
field56D
.
getComponent2
();
}
if
(
account
.
startsWith
(
"//RT"
))
{
clearingChannelRTGSFlag
=
true
;
}
String
nameAddress
=
field56D
.
getNameAndAddress
();
mt_to_mxFinancialInstitutionNameAndUnstructuredAddress
(
nameAddress
,
intrmyAgt1Maps
);
if
(
account
.
startsWith
(
"//"
)
&&
!
account
.
startsWith
(
"//CH"
)
&&
!
account
.
startsWith
(
"//FW"
))
{
Map
<
String
,
Object
>
finInstnIdMaps
=
null
;
if
(
intrmyAgt1Maps
.
containsKey
(
"finInstnId"
))
{
finInstnIdMaps
=
(
Map
<
String
,
Object
>)
intrmyAgt1Maps
.
get
(
"finInstnId"
);
}
else
{
finInstnIdMaps
=
new
HashMap
<>();
intrmyAgt1Maps
.
put
(
"finInstnId"
,
finInstnIdMaps
);
}
Map
<
String
,
Object
>
clrSysMmbIdMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"clrSysMmbId"
))
{
clrSysMmbIdMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"clrSysMmbId"
);
}
else
{
clrSysMmbIdMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"clrSysMmbId"
,
clrSysMmbIdMaps
);
}
mt_to_mxClearingIdentifier
(
account
,
clrSysMmbIdMaps
);
}
else
if
(!
account
.
startsWith
(
"//"
)
||
account
.
startsWith
(
"//CH"
))
{
mt_to_mxFinancialInstitutionAccount
(
account
,
intrmyAgt1AcctMaps
);
}
}
if
(
intrmyAgt1Maps
.
size
()
>
0
)
{
cdtTrfTxInfMaps
.
put
(
"intrmyAgt1"
,
intrmyAgt1Maps
);
}
if
(
intrmyAgt1AcctMaps
.
size
()
>
0
)
{
cdtTrfTxInfMaps
.
put
(
"intrmyAgt1Acct"
,
intrmyAgt1AcctMaps
);
}
if
(
clearingChannelRTGSFlag
)
{
Map
<
String
,
Object
>
pmtTpInfMaps
=
null
;
if
(
cdtTrfTxInfMaps
.
containsKey
(
"pmtTpInf"
))
{
pmtTpInfMaps
=
(
Map
<
String
,
Object
>)
cdtTrfTxInfMaps
.
get
(
"pmtTpInf"
);
}
else
{
pmtTpInfMaps
=
new
HashMap
<>();
cdtTrfTxInfMaps
.
put
(
"pmtTpInf"
,
pmtTpInfMaps
);
}
pmtTpInfMaps
.
put
(
"clrChanl"
,
"RTGS"
);
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/impl/Pacs00801Parse57Field.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs008001
.
impl
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.Mt2MxContextIdentifier
;
import
com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField
;
import
com.brilliance.swift.util.StringUtil
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.field.*
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
Pacs00801Parse57Field
extends
AbstractMt2MxPacs008001ParseField
{
private
static
final
String
NAME_A
=
"57A"
;
private
static
final
String
NAME_B
=
"57B"
;
private
static
final
String
NAME_C
=
"57C"
;
private
static
final
String
NAME_D
=
"57D"
;
@Override
public
void
parseField
()
throws
SwiftException
{
Field57A
field57A
=
null
;
Field57B
field57B
=
null
;
Field57C
field57C
=
null
;
Field57D
field57D
=
null
;
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
Tag
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_A
);
if
(
tag
!=
null
)
{
field57A
=
(
Field57A
)
tag
.
asField
();
}
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_B
);
if
(
tag
!=
null
)
{
field57B
=
(
Field57B
)
tag
.
asField
();
}
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_C
);
if
(
tag
!=
null
)
{
field57C
=
(
Field57C
)
tag
.
asField
();
}
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_D
);
if
(
tag
!=
null
)
{
field57D
=
(
Field57D
)
tag
.
asField
();
}
Map
<
String
,
Object
>
cdtrAgtMaps
=
null
;
if
(
cdtTrfTxInfMaps
.
containsKey
(
"cdtrAgt"
))
{
cdtrAgtMaps
=
(
Map
<
String
,
Object
>)
cdtTrfTxInfMaps
.
get
(
"cdtrAgt"
);
}
else
{
cdtrAgtMaps
=
new
HashMap
<>();
}
Map
<
String
,
Object
>
cdtrAgtAcctMaps
=
null
;
if
(
cdtTrfTxInfMaps
.
containsKey
(
"cdtrAgtAcct"
))
{
cdtrAgtAcctMaps
=
(
Map
<
String
,
Object
>)
cdtTrfTxInfMaps
.
get
(
"cdtrAgtAcct"
);
}
else
{
cdtrAgtAcctMaps
=
new
HashMap
<>();
}
boolean
clearingChannelRTGSFlag
=
false
;
String
account
=
""
;
if
(
field57A
!=
null
)
{
String
bicCode
=
field57A
.
getBIC
();
mt_to_mxBICFI
(
bicCode
,
cdtrAgtMaps
);
if
(
StringUtil
.
isNotEmpty
(
field57A
.
getComponent1
()))
{
account
=
"/"
+
field57A
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field57A
.
getComponent2
()))
{
account
=
"/"
+
field57A
.
getComponent2
();
}
if
(
account
.
startsWith
(
"//RT"
)
||
account
.
startsWith
(
"//FW"
))
{
clearingChannelRTGSFlag
=
true
;
}
if
(
account
.
startsWith
(
"//"
)
&&
!
account
.
startsWith
(
"//CH"
)
&&
!
account
.
startsWith
(
"//FW"
)
&&
!
account
.
startsWith
(
"//RT"
))
{
Map
<
String
,
Object
>
finInstnIdMaps
=
null
;
if
(
cdtrAgtMaps
.
containsKey
(
"finInstnId"
))
{
finInstnIdMaps
=
(
Map
<
String
,
Object
>)
cdtrAgtMaps
.
get
(
"finInstnId"
);
}
else
{
finInstnIdMaps
=
new
HashMap
<>();
cdtrAgtMaps
.
put
(
"finInstnId"
,
finInstnIdMaps
);
}
Map
<
String
,
Object
>
clrSysMmbIdMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"clrSysMmbId"
))
{
clrSysMmbIdMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"clrSysMmbId"
);
}
else
{
clrSysMmbIdMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"clrSysMmbId"
,
clrSysMmbIdMaps
);
}
mt_to_mxClearingIdentifier
(
account
,
clrSysMmbIdMaps
);
}
else
if
(!
account
.
startsWith
(
"//"
)
||
account
.
startsWith
(
"//CH"
))
{
mt_to_mxFinancialInstitutionAccount
(
account
,
cdtrAgtAcctMaps
);
}
}
else
if
(
field57B
!=
null
)
{
if
(
StringUtil
.
isNotEmpty
(
field57B
.
getComponent1
()))
{
account
=
"/"
+
field57B
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field57B
.
getComponent2
()))
{
account
=
"/"
+
field57B
.
getComponent2
();
}
String
location
=
field57B
.
getLocation
();
Map
<
String
,
Object
>
finInstnIdMaps
=
null
;
if
(
cdtrAgtMaps
.
containsKey
(
"finInstnId"
))
{
finInstnIdMaps
=
(
Map
<
String
,
Object
>)
cdtrAgtMaps
.
get
(
"finInstnId"
);
}
else
{
finInstnIdMaps
=
new
HashMap
<>();
cdtrAgtMaps
.
put
(
"finInstnId"
,
finInstnIdMaps
);
}
if
(
account
.
startsWith
(
"//"
)
&&
!
account
.
startsWith
(
"//CH"
)
&&
!
account
.
startsWith
(
"//FW"
))
{
if
(
isMTClearingSystemCodeInList
(
account
))
{
Map
<
String
,
Object
>
clrSysMmbIdMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"clrSysMmbId"
))
{
clrSysMmbIdMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"clrSysMmbId"
);
}
else
{
clrSysMmbIdMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"clrSysMmbId"
,
clrSysMmbIdMaps
);
}
mt_to_mxClearingIdentifier
(
account
,
clrSysMmbIdMaps
);
//name address 设置NOTPROVIDED
finInstnIdMaps
.
put
(
"nm"
,
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
);
Map
<
String
,
Object
>
pstlAdrMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"pstlAdr"
))
{
pstlAdrMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"pstlAdr"
);
}
else
{
pstlAdrMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"pstlAdr"
,
pstlAdrMaps
);
}
List
<
String
>
adrLineList
=
new
ArrayList
<>();
adrLineList
.
add
(
StringUtil
.
isEmpty
(
location
)?
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
:
location
);
pstlAdrMaps
.
put
(
"adrLine"
,
adrLineList
);
}
else
{
mt_to_mxClearingSystemToNameAndAddressLine
(
account
,
location
,
finInstnIdMaps
);
}
}
else
if
(!
account
.
startsWith
(
"//"
)
||
account
.
startsWith
(
"//CH"
))
{
mt_to_mxFinancialInstitutionAccount
(
account
,
cdtrAgtAcctMaps
);
//name address 设置NOTPROVIDED
finInstnIdMaps
.
put
(
"nm"
,
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
);
Map
<
String
,
Object
>
pstlAdrMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"pstlAdr"
))
{
pstlAdrMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"pstlAdr"
);
}
else
{
pstlAdrMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"pstlAdr"
,
pstlAdrMaps
);
}
List
<
String
>
adrLineList
=
new
ArrayList
<>();
adrLineList
.
add
(
StringUtil
.
isEmpty
(
location
)?
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
:
location
);
pstlAdrMaps
.
put
(
"adrLine"
,
adrLineList
);
}
}
else
if
(
field57C
!=
null
)
{
account
=
field57C
.
getValue
();
if
(
account
.
startsWith
(
"//RT"
))
{
clearingChannelRTGSFlag
=
true
;
}
Map
<
String
,
Object
>
finInstnIdMaps
=
null
;
if
(
cdtrAgtMaps
.
containsKey
(
"finInstnId"
))
{
finInstnIdMaps
=
(
Map
<
String
,
Object
>)
cdtrAgtMaps
.
get
(
"finInstnId"
);
}
else
{
finInstnIdMaps
=
new
HashMap
<>();
cdtrAgtMaps
.
put
(
"finInstnId"
,
finInstnIdMaps
);
}
if
(
account
.
startsWith
(
"//"
)
&&
!
account
.
startsWith
(
"//CH"
)
&&
!
account
.
startsWith
(
"//FW"
))
{
if
(
isMTClearingSystemCodeInList
(
account
))
{
Map
<
String
,
Object
>
clrSysMmbIdMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"clrSysMmbId"
))
{
clrSysMmbIdMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"clrSysMmbId"
);
}
else
{
clrSysMmbIdMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"clrSysMmbId"
,
clrSysMmbIdMaps
);
}
mt_to_mxClearingIdentifier
(
account
,
clrSysMmbIdMaps
);
//name address 设置NOTPROVIDED
finInstnIdMaps
.
put
(
"nm"
,
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
);
Map
<
String
,
Object
>
pstlAdrMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"pstlAdr"
))
{
pstlAdrMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"pstlAdr"
);
}
else
{
pstlAdrMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"pstlAdr"
,
pstlAdrMaps
);
}
List
<
String
>
adrLineList
=
new
ArrayList
<>();
adrLineList
.
add
(
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
);
pstlAdrMaps
.
put
(
"adrLine"
,
adrLineList
);
}
else
{
mt_to_mxClearingSystemToNameAndAddressLine
(
account
,
null
,
finInstnIdMaps
);
}
}
else
if
(!
account
.
startsWith
(
"//"
)
||
account
.
startsWith
(
"//CH"
))
{
mt_to_mxFinancialInstitutionAccount
(
account
,
cdtrAgtAcctMaps
);
//name address 设置NOTPROVIDED
finInstnIdMaps
.
put
(
"nm"
,
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
);
Map
<
String
,
Object
>
pstlAdrMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"pstlAdr"
))
{
pstlAdrMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"pstlAdr"
);
}
else
{
pstlAdrMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"pstlAdr"
,
pstlAdrMaps
);
}
List
<
String
>
adrLineList
=
new
ArrayList
<>();
adrLineList
.
add
(
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
);
pstlAdrMaps
.
put
(
"adrLine"
,
adrLineList
);
}
}
else
if
(
field57D
!=
null
)
{
if
(
StringUtil
.
isNotEmpty
(
field57D
.
getComponent1
()))
{
account
=
"/"
+
field57D
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field57D
.
getComponent2
()))
{
account
=
"/"
+
field57D
.
getComponent2
();
}
if
(
account
.
startsWith
(
"//RT"
))
{
clearingChannelRTGSFlag
=
true
;
}
String
nameAddress
=
field57D
.
getNameAndAddress
();
mt_to_mxFinancialInstitutionNameAndUnstructuredAddress
(
nameAddress
,
cdtrAgtMaps
);
if
(
account
.
startsWith
(
"//"
)
&&
!
account
.
startsWith
(
"//CH"
)
&&
!
account
.
startsWith
(
"//FW"
))
{
Map
<
String
,
Object
>
finInstnIdMaps
=
null
;
if
(
cdtrAgtMaps
.
containsKey
(
"finInstnId"
))
{
finInstnIdMaps
=
(
Map
<
String
,
Object
>)
cdtrAgtMaps
.
get
(
"finInstnId"
);
}
else
{
finInstnIdMaps
=
new
HashMap
<>();
cdtrAgtMaps
.
put
(
"finInstnId"
,
finInstnIdMaps
);
}
Map
<
String
,
Object
>
clrSysMmbIdMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"clrSysMmbId"
))
{
clrSysMmbIdMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"clrSysMmbId"
);
}
else
{
clrSysMmbIdMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"clrSysMmbId"
,
clrSysMmbIdMaps
);
}
mt_to_mxClearingIdentifier
(
account
,
clrSysMmbIdMaps
);
}
else
if
(!
account
.
startsWith
(
"//"
)
||
account
.
startsWith
(
"//CH"
))
{
mt_to_mxFinancialInstitutionAccount
(
account
,
cdtrAgtAcctMaps
);
}
}
else
{
String
receiverBic
=
(
String
)
context
.
get
(
Mt2MxContextIdentifier
.
MT_RECEIVE_BIC
,
true
);
mt_to_mxBICFI
(
receiverBic
,
cdtrAgtMaps
);
}
if
(
cdtrAgtMaps
.
size
()
>
0
)
{
cdtTrfTxInfMaps
.
put
(
"cdtrAgt"
,
cdtrAgtMaps
);
}
if
(
cdtrAgtAcctMaps
.
size
()
>
0
)
{
cdtTrfTxInfMaps
.
put
(
"cdtrAgtAcct"
,
cdtrAgtAcctMaps
);
}
if
(
clearingChannelRTGSFlag
)
{
Map
<
String
,
Object
>
pmtTpInfMaps
=
null
;
if
(
cdtTrfTxInfMaps
.
containsKey
(
"pmtTpInf"
))
{
pmtTpInfMaps
=
(
Map
<
String
,
Object
>)
cdtTrfTxInfMaps
.
get
(
"pmtTpInf"
);
}
else
{
pmtTpInfMaps
=
new
HashMap
<>();
cdtTrfTxInfMaps
.
put
(
"pmtTpInf"
,
pmtTpInfMaps
);
}
pmtTpInfMaps
.
put
(
"clrChanl"
,
"RTGS"
);
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/impl/Pacs00801Parse59Field.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs008001
.
impl
;
import
com.alibaba.fastjson.JSONArray
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField
;
import
com.brilliance.swift.util.StringUtil
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.field.Field59
;
import
com.prowidesoftware.swift.model.field.Field59A
;
import
com.prowidesoftware.swift.model.field.Field59F
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
Pacs00801Parse59Field
extends
AbstractMt2MxPacs008001ParseField
{
private
static
final
String
NAME
=
"59"
;
private
static
final
String
NAME_A
=
"59A"
;
private
static
final
String
NAME_F
=
"59F"
;
@Override
public
void
parseField
()
throws
SwiftException
{
Field59
field59
=
null
;
Field59A
field59A
=
null
;
Field59F
field59F
=
null
;
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
Tag
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME
);
if
(
tag
!=
null
)
{
field59
=
(
Field59
)
tag
.
asField
();
}
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_A
);
if
(
tag
!=
null
)
{
field59A
=
(
Field59A
)
tag
.
asField
();
}
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_F
);
if
(
tag
!=
null
)
{
field59F
=
(
Field59F
)
tag
.
asField
();
}
Map
<
String
,
Object
>
cdtrMaps
=
null
;
if
(
cdtTrfTxInfMaps
.
containsKey
(
"cdtr"
))
{
cdtrMaps
=
(
Map
<
String
,
Object
>)
cdtTrfTxInfMaps
.
get
(
"cdtr"
);
}
else
{
cdtrMaps
=
new
HashMap
<>();
}
Map
<
String
,
Object
>
cdtrAcctMaps
=
null
;
if
(
cdtTrfTxInfMaps
.
containsKey
(
"cdtrAcct"
))
{
cdtrAcctMaps
=
(
Map
<
String
,
Object
>)
cdtTrfTxInfMaps
.
get
(
"cdtrAcct"
);
}
else
{
cdtrAcctMaps
=
new
HashMap
<>();
}
String
account
=
""
;
if
(
field59A
!=
null
)
{
String
bicCode
=
field59A
.
getBIC
();
if
(
StringUtil
.
isNotEmpty
(
field59A
.
getComponent1
()))
{
account
+=
"/"
+
field59A
.
getComponent1
();
}
mt_to_mxAnyBIC
(
bicCode
,
cdtrMaps
);
if
(
StringUtil
.
isEmpty
(
account
))
{
buildDefaultValue
(
cdtrMaps
);
}
else
{
mt_to_mxPartyAccount
(
account
,
cdtrAcctMaps
);
}
}
if
(
field59F
!=
null
)
{
if
(
StringUtil
.
isNotEmpty
(
field59F
.
getComponent1
()))
{
account
+=
"/"
+
field59F
.
getComponent1
();
}
if
(
StringUtil
.
isEmpty
(
account
))
{
buildDefaultValue
(
cdtrMaps
);
}
else
{
mt_to_mxPartyAccount
(
account
,
cdtrAcctMaps
);
}
String
nameAddress
=
""
;
List
<
String
>
lines
=
field59F
.
getLines
();
for
(
int
i
=
0
;
i
<
lines
.
size
();
i
++)
{
if
(
i
==
0
&&
StringUtil
.
isNotEmpty
(
account
))
{
continue
;
}
if
(
i
==
lines
.
size
()-
1
)
{
nameAddress
+=
lines
.
get
(
i
);
}
else
{
nameAddress
+=
lines
.
get
(
i
)
+
Mx2MtConstants
.
NEW_LINE
;
}
}
mt_to_mxPartyNameAndStructuredAddress
(
nameAddress
,
cdtrMaps
);
}
if
(
field59
!=
null
)
{
String
nameAddress
=
field59
.
getNameAndAddress
(
Mx2MtConstants
.
NEW_LINE
);
if
(
StringUtil
.
isNotEmpty
(
field59
.
getComponent1
()))
{
account
+=
"/"
+
field59
.
getComponent1
();
}
mt_to_mxPartyNameAndAddress
(
nameAddress
,
cdtrMaps
);
if
(
StringUtil
.
isEmpty
(
account
))
{
buildDefaultValue
(
cdtrMaps
);
}
else
{
mt_to_mxPartyAccount
(
account
,
cdtrAcctMaps
);
}
}
if
(
cdtrMaps
.
size
()
>
0
)
{
cdtTrfTxInfMaps
.
put
(
"cdtr"
,
cdtrMaps
);
}
if
(
cdtrAcctMaps
.
size
()
>
0
)
{
cdtTrfTxInfMaps
.
put
(
"cdtrAcct"
,
cdtrAcctMaps
);
}
}
/**
* IF 59A/Account 59/Account IsAbsent
* THEN Copy "NOTPROVIDED" to Debtor/Id/OrgID/Other/ID
* and "TXID" to SchemeName/Code
* @param dbtrMaps
*/
private
void
buildDefaultValue
(
Map
<
String
,
Object
>
dbtrMaps
)
{
Map
<
String
,
Object
>
idMaps
=
null
;
if
(
dbtrMaps
.
containsKey
(
"id"
))
{
idMaps
=
(
Map
<
String
,
Object
>)
dbtrMaps
.
get
(
"id"
);
}
else
{
idMaps
=
new
HashMap
<>();
dbtrMaps
.
put
(
"id"
,
idMaps
);
}
Map
<
String
,
Object
>
idOrgMaps
=
null
;
if
(
idMaps
.
containsKey
(
"orgId"
))
{
idOrgMaps
=
(
Map
<
String
,
Object
>)
idMaps
.
get
(
"orgId"
);
}
else
{
idOrgMaps
=
new
HashMap
<>();
idMaps
.
put
(
"orgId"
,
idOrgMaps
);
}
JSONArray
othrJsonArray
=
null
;
if
(
idOrgMaps
.
containsKey
(
"othr"
))
{
othrJsonArray
=
(
JSONArray
)
idOrgMaps
.
get
(
"othr"
);
}
else
{
othrJsonArray
=
new
JSONArray
();
idOrgMaps
.
put
(
"othr"
,
othrJsonArray
);
}
Map
<
String
,
Object
>
othrMaps
=
new
HashMap
<>();
othrJsonArray
.
add
(
othrMaps
);
othrMaps
.
put
(
"id"
,
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
);
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/impl/Pacs00801Parse70Field.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs008001
.
impl
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField
;
import
com.brilliance.swift.util.StringUtil
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.field.Field70
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
Pacs00801Parse70Field
extends
AbstractMt2MxPacs008001ParseField
{
private
static
final
String
NAME
=
"70"
;
@Override
public
void
parseField
()
throws
SwiftException
{
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
Tag
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME
);
if
(
tag
!=
null
)
{
Field70
field70
=
(
Field70
)
tag
.
asField
();
String
mt70
=
field70
.
getValue
();
String
endToEndId
=
mt70roc_to_mx35Text
(
mt70
);;
if
(
StringUtil
.
isEmpty
(
endToEndId
))
{
endToEndId
=
Mx2MtConstants
.
MX_END_TO_END_ID_DEFAULT_VALUE
;
}
Map
<
String
,
Object
>
pmtIdMaps
=
null
;
if
(
cdtTrfTxInfMaps
.
containsKey
(
"pmtId"
))
{
pmtIdMaps
=
(
Map
<
String
,
Object
>)
cdtTrfTxInfMaps
.
get
(
"pmtId"
);
}
else
{
pmtIdMaps
=
new
HashMap
<>();
cdtTrfTxInfMaps
.
put
(
"pmtId"
,
pmtIdMaps
);
}
pmtIdMaps
.
put
(
"endToEndId"
,
endToEndId
);
Map
<
String
,
Object
>
rmtInfMaps
=
null
;
if
(
cdtTrfTxInfMaps
.
containsKey
(
"rmtInf"
))
{
rmtInfMaps
=
(
Map
<
String
,
Object
>)
cdtTrfTxInfMaps
.
get
(
"rmtInf"
);
}
else
{
rmtInfMaps
=
new
HashMap
<>();
}
mt_to_mxRemittanceInformation
(
mt70
,
rmtInfMaps
);
if
(
rmtInfMaps
.
size
()
>
0
)
{
cdtTrfTxInfMaps
.
put
(
"rmtInf"
,
rmtInfMaps
);
}
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/impl/Pacs00801Parse71Field.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs008001
.
impl
;
import
com.alibaba.fastjson.JSONArray
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.Mt2MxContextIdentifier
;
import
com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField
;
import
com.brilliance.swift.util.SwiftTransferUtil
;
import
com.brilliance.swift.vo.common.ChargeForEnum
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.field.Field71A
;
import
com.prowidesoftware.swift.model.field.Field71F
;
import
com.prowidesoftware.swift.model.field.Field71G
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
Pacs00801Parse71Field
extends
AbstractMt2MxPacs008001ParseField
{
private
static
final
String
NAME_A
=
"71A"
;
private
static
final
String
NAME_F
=
"71F"
;
private
static
final
String
NAME_G
=
"71G"
;
@Override
public
void
parseField
()
throws
SwiftException
{
Field71A
field71A
=
null
;
Field71G
field71G
=
null
;
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
Tag
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_A
);
if
(
tag
!=
null
)
{
field71A
=
(
Field71A
)
tag
.
asField
();
}
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_G
);
if
(
tag
!=
null
)
{
field71G
=
(
Field71G
)
tag
.
asField
();
}
if
(
field71A
!=
null
)
{
ChargeForEnum
chargeForEnum
=
SwiftTransferUtil
.
getChargeForByDesc
(
field71A
.
getValue
());
if
(
chargeForEnum
!=
null
)
{
cdtTrfTxInfMaps
.
put
(
"chrgBr"
,
chargeForEnum
.
value
());
}
}
if
(
field71G
!=
null
)
{
String
ccy
=
field71G
.
getCurrency
();
BigDecimal
amt
=
field71G
.
amount
();
JSONArray
jsonArray
=
new
JSONArray
();
cdtTrfTxInfMaps
.
put
(
"chrgsInf"
,
jsonArray
);
Map
<
String
,
Object
>
chrgsInfMaps
=
new
HashMap
<>();
jsonArray
.
add
(
chrgsInfMaps
);
Map
<
String
,
Object
>
amtMaps
=
new
HashMap
<>();
amtMaps
.
put
(
"value"
,
amt
);
amtMaps
.
put
(
"ccy"
,
ccy
);
chrgsInfMaps
.
put
(
"amt"
,
amtMaps
);
Map
<
String
,
Object
>
agtMaps
=
new
HashMap
<>();
chrgsInfMaps
.
put
(
"agt"
,
agtMaps
);
String
receiverBic
=
(
String
)
context
.
get
(
Mt2MxContextIdentifier
.
MT_RECEIVE_BIC
,
true
);
mt_to_mxBICFI
(
receiverBic
,
agtMaps
);
}
Tag
[]
tags
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagsByName
(
NAME_F
);
if
(
tag
!=
null
&&
tags
.
length
>
0
)
{
JSONArray
jsonArray
=
new
JSONArray
();
cdtTrfTxInfMaps
.
put
(
"chrgsInf"
,
jsonArray
);
for
(
int
i
=
0
;
i
<
tags
.
length
;
i
++)
{
Field71F
field71F
=
(
Field71F
)
tags
[
i
].
asField
();
String
ccy
=
field71F
.
getCurrency
();
BigDecimal
amt
=
field71F
.
amount
();
Map
<
String
,
Object
>
chrgsInfMaps
=
new
HashMap
<>();
jsonArray
.
add
(
chrgsInfMaps
);
Map
<
String
,
Object
>
amtMaps
=
new
HashMap
<>();
amtMaps
.
put
(
"value"
,
amt
);
amtMaps
.
put
(
"ccy"
,
ccy
);
chrgsInfMaps
.
put
(
"amt"
,
amtMaps
);
Map
<
String
,
Object
>
agtMaps
=
new
HashMap
<>();
chrgsInfMaps
.
put
(
"agt"
,
agtMaps
);
Map
<
String
,
Object
>
finInstnIdMaps
=
null
;
if
(
agtMaps
.
containsKey
(
"finInstnId"
))
{
finInstnIdMaps
=
(
Map
<
String
,
Object
>)
agtMaps
.
get
(
"finInstnId"
);
}
else
{
finInstnIdMaps
=
new
HashMap
<>();
agtMaps
.
put
(
"finInstnId"
,
finInstnIdMaps
);
}
//name address 设置NOTPROVIDED
finInstnIdMaps
.
put
(
"nm"
,
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
);
Map
<
String
,
Object
>
pstlAdrMaps
=
null
;
if
(
finInstnIdMaps
.
containsKey
(
"pstlAdr"
))
{
pstlAdrMaps
=
(
Map
<
String
,
Object
>)
finInstnIdMaps
.
get
(
"pstlAdr"
);
}
else
{
pstlAdrMaps
=
new
HashMap
<>();
finInstnIdMaps
.
put
(
"pstlAdr"
,
pstlAdrMaps
);
}
List
<
String
>
adrLineList
=
new
ArrayList
<>();
adrLineList
.
add
(
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
);
pstlAdrMaps
.
put
(
"adrLine"
,
adrLineList
);
}
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/impl/Pacs00801Parse72Field.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs008001
.
impl
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.field.Field72
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
public
class
Pacs00801Parse72Field
extends
AbstractMt2MxPacs008001ParseField
{
private
static
final
String
NAME
=
"72"
;
@Override
public
void
parseField
()
throws
SwiftException
{
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
Tag
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME
);
if
(
tag
!=
null
)
{
Field72
field72
=
(
Field72
)
tag
.
asField
();
mt72ins_to_mxAgent
(
field72
.
getValue
(),
cdtTrfTxInfMaps
);
mt72_to_mxNextAgent
(
field72
.
getValue
(),
cdtTrfTxInfMaps
);
mt_to_mxField72NewCodeWords
(
field72
.
getValue
(),
cdtTrfTxInfMaps
);
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/impl/Pacs00801Parse77BField.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs008001
.
impl
;
import
com.alibaba.fastjson.JSONArray
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField
;
import
com.brilliance.swift.util.StringUtil
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.field.Field77B
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
public
class
Pacs00801Parse77BField
extends
AbstractMt2MxPacs008001ParseField
{
private
static
final
String
NAME
=
"77B"
;
@Override
public
void
parseField
()
throws
SwiftException
{
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
Tag
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME
);
if
(
tag
!=
null
)
{
String
creditorCountryCode
=
""
;
String
debtorCountryCode
=
""
;
Field77B
field77B
=
(
Field77B
)
tag
.
asField
();
List
<
String
>
lines
=
field77B
.
getLines
();
JSONArray
rgltryRptgJsonArray
=
null
;
if
(
cdtTrfTxInfMaps
.
containsKey
(
"rgltryRptg"
))
{
rgltryRptgJsonArray
=
(
JSONArray
)
cdtTrfTxInfMaps
.
get
(
"rgltryRptg"
);
}
else
{
rgltryRptgJsonArray
=
new
JSONArray
();
cdtTrfTxInfMaps
.
put
(
"rgltryRptg"
,
rgltryRptgJsonArray
);
}
Map
<
String
,
Object
>
rgltryRptgMaps
=
new
HashMap
<>();
rgltryRptgJsonArray
.
add
(
rgltryRptgMaps
);
JSONArray
dtlsJsonArray
=
null
;
if
(
rgltryRptgMaps
.
containsKey
(
"dtls"
))
{
dtlsJsonArray
=
(
JSONArray
)
rgltryRptgMaps
.
get
(
"dtls"
);
}
else
{
dtlsJsonArray
=
new
JSONArray
();
rgltryRptgMaps
.
put
(
"dtls"
,
dtlsJsonArray
);
}
Map
<
String
,
Object
>
dtlsMaps
=
new
HashMap
<>();
dtlsJsonArray
.
add
(
dtlsMaps
);
dtlsMaps
.
put
(
"inf"
,
lines
);
for
(
int
i
=
0
;
i
<
lines
.
size
();
i
++)
{
String
line
=
lines
.
get
(
i
);
String
regex
=
"/BENEFRES/([A-Z]{2})"
;
Pattern
p
=
Pattern
.
compile
(
regex
);
Matcher
m
=
p
.
matcher
(
line
);
if
(
m
.
find
())
{
creditorCountryCode
=
m
.
group
(
1
);
break
;
}
}
if
(
StringUtil
.
isNotEmpty
(
creditorCountryCode
))
{
Map
<
String
,
Object
>
cdtrMaps
=
null
;
if
(
cdtTrfTxInfMaps
.
containsKey
(
"cdtr"
))
{
cdtrMaps
=
(
Map
<
String
,
Object
>)
cdtTrfTxInfMaps
.
get
(
"cdtr"
);
}
else
{
cdtrMaps
=
new
HashMap
<>();
}
cdtrMaps
.
put
(
"ctryOfRes"
,
creditorCountryCode
);
}
for
(
int
i
=
0
;
i
<
lines
.
size
();
i
++)
{
String
line
=
lines
.
get
(
i
);
String
regex
=
"/ORDERRES/([A-Z]{2})"
;
Pattern
p
=
Pattern
.
compile
(
regex
);
Matcher
m
=
p
.
matcher
(
line
);
if
(
m
.
find
())
{
debtorCountryCode
=
m
.
group
(
1
);
break
;
}
}
if
(
StringUtil
.
isNotEmpty
(
debtorCountryCode
))
{
Map
<
String
,
Object
>
dbtrMaps
=
null
;
if
(
cdtTrfTxInfMaps
.
containsKey
(
"dbtr"
))
{
dbtrMaps
=
(
Map
<
String
,
Object
>)
cdtTrfTxInfMaps
.
get
(
"dbtr"
);
}
else
{
dbtrMaps
=
new
HashMap
<>();
}
dbtrMaps
.
put
(
"ctryOfRes"
,
debtorCountryCode
);
}
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/impl/Pacs00801ParseSetlAcctField.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs008001
.
impl
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.vo.VoSettlementMethodHelper
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.field.Field53A
;
import
com.prowidesoftware.swift.model.field.Field53B
;
import
com.prowidesoftware.swift.model.field.Field53D
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* Group Header -> Settlement Information -> Settlement Account
*/
public
class
Pacs00801ParseSetlAcctField
extends
AbstractMt2MxPacs008001ParseField
{
private
static
final
String
NAME_A
=
"53A"
;
private
static
final
String
NAME_B
=
"53B"
;
private
static
final
String
NAME_D
=
"53D"
;
@Override
public
void
parseField
()
throws
SwiftException
{
//值来源于 Pacs00801ParseSetlMtdField
VoSettlementMethodHelper
setlMtdHelper
=
context
.
get
(
VoSettlementMethodHelper
.
class
);
if
(
setlMtdHelper
.
isTranslateSetlAcctFlag
())
{
Field53A
field53A
=
null
;
Field53B
field53B
=
null
;
Field53D
field53D
=
null
;
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
Tag
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_A
);
if
(
tag
!=
null
)
{
field53A
=
(
Field53A
)
tag
.
asField
();
}
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_B
);
if
(
tag
!=
null
)
{
field53B
=
(
Field53B
)
tag
.
asField
();
}
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
NAME_D
);
if
(
tag
!=
null
)
{
field53D
=
(
Field53D
)
tag
.
asField
();
}
String
account
=
""
;
if
(
field53A
!=
null
)
{
if
(
StringUtil
.
isNotEmpty
(
field53A
.
getComponent1
()))
{
account
+=
"/"
+
field53A
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field53A
.
getComponent2
()))
{
account
+=
"/"
+
field53A
.
getComponent2
();
}
}
else
if
(
field53B
!=
null
)
{
if
(
StringUtil
.
isNotEmpty
(
field53B
.
getComponent1
()))
{
account
+=
"/"
+
field53B
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field53B
.
getComponent2
()))
{
account
+=
"/"
+
field53B
.
getComponent2
();
}
}
else
if
(
field53D
!=
null
)
{
if
(
StringUtil
.
isNotEmpty
(
field53D
.
getComponent1
()))
{
account
+=
"/"
+
field53D
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field53D
.
getComponent2
()))
{
account
+=
"/"
+
field53D
.
getComponent2
();
}
}
if
(
StringUtil
.
isEmpty
(
account
))
return
;
Map
<
String
,
Object
>
sttlmInfMaps
=
null
;
if
(
grpHdrMaps
.
containsKey
(
"sttlmInf"
))
{
sttlmInfMaps
=
(
Map
<
String
,
Object
>)
grpHdrMaps
.
get
(
"sttlmInf"
);
}
else
{
sttlmInfMaps
=
new
HashMap
<>();
grpHdrMaps
.
put
(
"sttlmInf"
,
sttlmInfMaps
);
}
Map
<
String
,
Object
>
sttlmAcctMaps
=
null
;
if
(
sttlmInfMaps
.
containsKey
(
"sttlmAcct"
))
{
sttlmAcctMaps
=
(
Map
<
String
,
Object
>)
sttlmInfMaps
.
get
(
"sttlmAcct"
);
}
else
{
sttlmAcctMaps
=
new
HashMap
<>();
sttlmInfMaps
.
put
(
"sttlmAcct"
,
sttlmAcctMaps
);
}
mt_to_mxFinancialInstitutionAccount
(
account
,
sttlmAcctMaps
);
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/impl/Pacs00801ParseSetlMtdField.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
pacs008001
.
impl
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mt2mx.pacs008001.AbstractMt2MxPacs008001ParseField
;
import
com.brilliance.swift.mt2mx.setlmtd.SettlementMethodAnalyzerFactory
;
import
com.brilliance.swift.vo.VoSettlementMethodHelper
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* Group Header -> Settlement Information -> Settlement Method
*/
public
class
Pacs00801ParseSetlMtdField
extends
AbstractMt2MxPacs008001ParseField
{
@Override
public
void
parseField
()
throws
SwiftException
{
VoSettlementMethodHelper
setlMtdHelper
=
SettlementMethodAnalyzerFactory
.
find
(
context
).
analyse
();
String
settlementMethod
=
setlMtdHelper
.
getSettlementMethod
();
Map
<
String
,
Object
>
sttlmInfMaps
=
null
;
if
(
grpHdrMaps
.
containsKey
(
"sttlmInf"
))
{
sttlmInfMaps
=
(
Map
<
String
,
Object
>)
grpHdrMaps
.
get
(
"sttlmInf"
);
}
else
{
sttlmInfMaps
=
new
HashMap
<>();
grpHdrMaps
.
put
(
"sttlmInf"
,
sttlmInfMaps
);
}
sttlmInfMaps
.
put
(
"sttlmMtd"
,
settlementMethod
);
context
.
set
(
setlMtdHelper
);
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/setlmtd/AbstractSettlementMethodAnalyzer.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
setlmtd
;
import
com.brilliance.swift.mt2mx.Mt2MxContext
;
import
com.prowidesoftware.swift.model.field.Field
;
public
abstract
class
AbstractSettlementMethodAnalyzer
implements
SettlementMethodAnalyzer
{
protected
Mt2MxContext
context
;
public
Mt2MxContext
getContext
()
{
return
context
;
}
public
AbstractSettlementMethodAnalyzer
setContext
(
Mt2MxContext
context
)
{
this
.
context
=
context
;
return
this
;
}
protected
Field
field53
;
protected
Field
field54
;
public
Field
getField53
()
{
return
field53
;
}
public
AbstractSettlementMethodAnalyzer
setField53
(
Field
field53
)
{
this
.
field53
=
field53
;
return
this
;
}
public
Field
getField54
()
{
return
field54
;
}
public
AbstractSettlementMethodAnalyzer
setField54
(
Field
field54
)
{
this
.
field54
=
field54
;
return
this
;
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/setlmtd/SettlementMethodAnalyzer.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
setlmtd
;
import
com.brilliance.swift.vo.VoSettlementMethodHelper
;
/**
* 根据53 54 分析出settlement method 以及 53 54 55是否被翻译
*/
public
interface
SettlementMethodAnalyzer
{
VoSettlementMethodHelper
analyse
();
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/setlmtd/SettlementMethodAnalyzerFactory.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
setlmtd
;
import
com.brilliance.swift.mt2mx.Mt2MxContext
;
import
com.brilliance.swift.mt2mx.setlmtd.impl.*
;
import
com.prowidesoftware.swift.model.Tag
;
import
com.prowidesoftware.swift.model.field.*
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
public
class
SettlementMethodAnalyzerFactory
{
public
static
SettlementMethodAnalyzer
find
(
Mt2MxContext
context
)
{
SettlementMethodAnalyzer
analyzer
=
null
;
Field53A
field53A
=
null
;
Field53B
field53B
=
null
;
Field53D
field53D
=
null
;
Field54A
field54A
=
null
;
Field54B
field54B
=
null
;
Field54D
field54D
=
null
;
AbstractMT
abstractMT
=
context
.
get
(
AbstractMT
.
class
);
Tag
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
"53A"
);
if
(
tag
!=
null
)
{
field53A
=
(
Field53A
)
tag
.
asField
();
}
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
"53B"
);
if
(
tag
!=
null
)
{
field53B
=
(
Field53B
)
tag
.
asField
();
}
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
"53D"
);
if
(
tag
!=
null
)
{
field53D
=
(
Field53D
)
tag
.
asField
();
}
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
"54A"
);
if
(
tag
!=
null
)
{
field54A
=
(
Field54A
)
tag
.
asField
();
}
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
"54B"
);
if
(
tag
!=
null
)
{
field54B
=
(
Field54B
)
tag
.
asField
();
}
tag
=
abstractMT
.
getSwiftMessage
().
getBlock4
().
getTagByName
(
"54D"
);
if
(
tag
!=
null
)
{
field54D
=
(
Field54D
)
tag
.
asField
();
}
boolean
noneField53
=
false
;
if
(
field53A
==
null
&&
field53B
==
null
&&
field53D
==
null
)
{
noneField53
=
true
;
}
boolean
noneField54
=
false
;
if
(
field54A
==
null
&&
field54B
==
null
&&
field54D
==
null
)
{
noneField54
=
true
;
}
if
(
noneField53
&&
noneField54
)
{
analyzer
=
new
FieldNone5354Analyzer
().
setContext
(
context
);
}
else
if
(
field53A
!=
null
&&
noneField54
)
{
analyzer
=
new
FieldOnly53AAnalyzer
()
.
setContext
(
context
)
.
setField53
(
field53A
);
}
else
if
(
field53B
!=
null
&&
noneField54
)
{
analyzer
=
new
FieldOnly53BAnalyzer
()
.
setContext
(
context
)
.
setField53
(
field53B
);
}
else
if
(
field53D
!=
null
&&
noneField54
)
{
analyzer
=
new
FieldOnly53DAnalyzer
()
.
setContext
(
context
)
.
setField53
(
field53D
);
}
else
if
(
noneField53
&&
field54A
!=
null
)
{
analyzer
=
new
FieldOnly54AAnalyzer
()
.
setContext
(
context
)
.
setField54
(
field54A
);
}
else
if
(
noneField53
&&
field54B
!=
null
)
{
analyzer
=
new
FieldOnly54BAnalyzer
()
.
setContext
(
context
)
.
setField54
(
field54B
);
}
else
if
(
noneField53
&&
field54D
!=
null
)
{
analyzer
=
new
FieldOnly54DAnalyzer
()
.
setContext
(
context
)
.
setField54
(
field54D
);
}
else
if
(
field53A
!=
null
&&
field54A
!=
null
)
{
analyzer
=
new
Field53A54AAnalyzer
()
.
setContext
(
context
)
.
setField53
(
field53A
)
.
setField54
(
field54A
);
}
else
if
(
field53A
!=
null
&&
field54B
!=
null
)
{
analyzer
=
new
Field53A54BAnalyzer
()
.
setContext
(
context
)
.
setField53
(
field53A
)
.
setField54
(
field54B
);
}
else
if
(
field53A
!=
null
&&
field54D
!=
null
)
{
analyzer
=
new
Field53A54DAnalyzer
()
.
setContext
(
context
)
.
setField53
(
field53A
)
.
setField54
(
field54D
);
}
else
if
(
field53B
!=
null
&&
field54A
!=
null
)
{
analyzer
=
new
Field53B54aAnalyzer
()
.
setContext
(
context
)
.
setField53
(
field53B
)
.
setField54
(
field54A
);
}
else
if
(
field53B
!=
null
&&
!
noneField54
)
{
analyzer
=
new
Field53B54aAnalyzer
()
.
setContext
(
context
)
.
setField53
(
field53B
);
}
else
if
(
field53D
!=
null
&&
!
noneField54
)
{
analyzer
=
new
Field53D54aAnalyzer
()
.
setContext
(
context
)
.
setField53
(
field53D
);
}
return
analyzer
;
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/setlmtd/impl/Field53A54AAnalyzer.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
setlmtd
.
impl
;
import
com.brilliance.swift.mt2mx.Mt2MxContextIdentifier
;
import
com.brilliance.swift.mt2mx.setlmtd.AbstractSettlementMethodAnalyzer
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.util.SwiftTransferUtil
;
import
com.brilliance.swift.vo.VoSettlementMethodHelper
;
import
com.prowidesoftware.swift.model.field.Field53A
;
import
com.prowidesoftware.swift.model.field.Field54A
;
public
class
Field53A54AAnalyzer
extends
AbstractSettlementMethodAnalyzer
{
@Override
public
VoSettlementMethodHelper
analyse
()
{
VoSettlementMethodHelper
seltMtdHelper
=
new
VoSettlementMethodHelper
();
Field53A
field53A
=
(
Field53A
)
field53
;
String
field53BicCode
=
field53A
.
getBIC
();
String
account
=
""
;
if
(
StringUtil
.
isNotEmpty
(
field53A
.
getComponent1
()))
{
account
+=
"/"
+
field53A
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field53A
.
getComponent2
()))
{
account
+=
"/"
+
field53A
.
getComponent2
();
}
Field54A
field54A
=
(
Field54A
)
field54
;
String
field54BicCode
=
field54A
.
getBIC
();
String
sendBic
=
(
String
)
context
.
get
(
Mt2MxContextIdentifier
.
MT_SEND_BIC
,
true
);
String
receiveBic
=
(
String
)
context
.
get
(
Mt2MxContextIdentifier
.
MT_RECEIVE_BIC
,
true
);
if
(
field53BicCode
.
equals
(
sendBic
)
&&
field54BicCode
.
equals
(
receiveBic
))
{
seltMtdHelper
.
setSettlementMethod
(
"INDA"
);
}
else
if
(
StringUtil
.
isNotEmpty
(
sendBic
)
&&
field53BicCode
.
substring
(
0
,
6
).
equals
(
sendBic
.
substring
(
0
,
6
))
&&
SwiftTransferUtil
.
isAccount
(
account
))
{
if
(
account
.
startsWith
(
"/C/"
))
{
seltMtdHelper
.
setSettlementMethod
(
"INGA"
);
}
else
{
seltMtdHelper
.
setSettlementMethod
(
"INDA"
);
}
seltMtdHelper
.
setTranslateSetlAcctFlag
(
true
);
}
else
{
seltMtdHelper
.
setSettlementMethod
(
"COVE"
);
seltMtdHelper
.
setTranslate53Flag
(
true
);
seltMtdHelper
.
setTranslate54Flag
(
true
);
seltMtdHelper
.
setTranslate55Flag
(
true
);
}
return
seltMtdHelper
;
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/setlmtd/impl/Field53A54BAnalyzer.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
setlmtd
.
impl
;
import
com.brilliance.swift.mt2mx.Mt2MxContextIdentifier
;
import
com.brilliance.swift.mt2mx.setlmtd.AbstractSettlementMethodAnalyzer
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.util.SwiftTransferUtil
;
import
com.brilliance.swift.vo.VoSettlementMethodHelper
;
import
com.prowidesoftware.swift.model.field.Field53A
;
public
class
Field53A54BAnalyzer
extends
AbstractSettlementMethodAnalyzer
{
@Override
public
VoSettlementMethodHelper
analyse
()
{
VoSettlementMethodHelper
seltMtdHelper
=
new
VoSettlementMethodHelper
();
Field53A
field53A
=
(
Field53A
)
field53
;
String
field53BicCode
=
field53A
.
getBIC
();
String
account
=
""
;
if
(
StringUtil
.
isNotEmpty
(
field53A
.
getComponent1
()))
{
account
+=
"/"
+
field53A
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field53A
.
getComponent2
()))
{
account
+=
"/"
+
field53A
.
getComponent2
();
}
String
sendBic
=
(
String
)
context
.
get
(
Mt2MxContextIdentifier
.
MT_SEND_BIC
,
true
);
if
(
StringUtil
.
isNotEmpty
(
sendBic
)
&&
field53BicCode
.
substring
(
0
,
6
).
equals
(
sendBic
.
substring
(
0
,
6
))
&&
SwiftTransferUtil
.
isAccount
(
account
))
{
if
(
account
.
startsWith
(
"/C/"
))
{
seltMtdHelper
.
setSettlementMethod
(
"INGA"
);
}
else
{
seltMtdHelper
.
setSettlementMethod
(
"INDA"
);
}
seltMtdHelper
.
setTranslateSetlAcctFlag
(
true
);
}
else
{
seltMtdHelper
.
setSettlementMethod
(
"COVE"
);
seltMtdHelper
.
setTranslate53Flag
(
true
);
seltMtdHelper
.
setTranslate54Flag
(
true
);
seltMtdHelper
.
setTranslate55Flag
(
true
);
}
return
seltMtdHelper
;
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/setlmtd/impl/Field53A54DAnalyzer.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
setlmtd
.
impl
;
import
com.brilliance.swift.mt2mx.Mt2MxContextIdentifier
;
import
com.brilliance.swift.mt2mx.setlmtd.AbstractSettlementMethodAnalyzer
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.util.SwiftTransferUtil
;
import
com.brilliance.swift.vo.VoSettlementMethodHelper
;
import
com.prowidesoftware.swift.model.field.Field53A
;
public
class
Field53A54DAnalyzer
extends
AbstractSettlementMethodAnalyzer
{
@Override
public
VoSettlementMethodHelper
analyse
()
{
VoSettlementMethodHelper
seltMtdHelper
=
new
VoSettlementMethodHelper
();
Field53A
field53A
=
(
Field53A
)
field53
;
String
field53BicCode
=
field53A
.
getBIC
();
String
account
=
""
;
if
(
StringUtil
.
isNotEmpty
(
field53A
.
getComponent1
()))
{
account
+=
"/"
+
field53A
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field53A
.
getComponent2
()))
{
account
+=
"/"
+
field53A
.
getComponent2
();
}
String
sendBic
=
(
String
)
context
.
get
(
Mt2MxContextIdentifier
.
MT_SEND_BIC
,
true
);
if
(
StringUtil
.
isNotEmpty
(
sendBic
)
&&
field53BicCode
.
substring
(
0
,
6
).
equals
(
sendBic
.
substring
(
0
,
6
))
&&
SwiftTransferUtil
.
isAccount
(
account
))
{
if
(
account
.
startsWith
(
"/C/"
))
{
seltMtdHelper
.
setSettlementMethod
(
"INGA"
);
}
else
{
seltMtdHelper
.
setSettlementMethod
(
"INDA"
);
}
seltMtdHelper
.
setTranslateSetlAcctFlag
(
true
);
}
else
{
seltMtdHelper
.
setSettlementMethod
(
"COVE"
);
seltMtdHelper
.
setTranslate53Flag
(
true
);
seltMtdHelper
.
setTranslate54Flag
(
true
);
seltMtdHelper
.
setTranslate55Flag
(
true
);
}
return
seltMtdHelper
;
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/setlmtd/impl/Field53B54aAnalyzer.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
setlmtd
.
impl
;
import
com.brilliance.swift.mt2mx.setlmtd.AbstractSettlementMethodAnalyzer
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.util.SwiftTransferUtil
;
import
com.brilliance.swift.vo.VoSettlementMethodHelper
;
import
com.prowidesoftware.swift.model.field.Field53B
;
public
class
Field53B54aAnalyzer
extends
AbstractSettlementMethodAnalyzer
{
@Override
public
VoSettlementMethodHelper
analyse
()
{
VoSettlementMethodHelper
seltMtdHelper
=
new
VoSettlementMethodHelper
();
Field53B
field53B
=
(
Field53B
)
field53
;
String
account
=
""
;
if
(
StringUtil
.
isNotEmpty
(
field53B
.
getComponent1
()))
{
account
+=
"/"
+
field53B
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field53B
.
getComponent2
()))
{
account
+=
"/"
+
field53B
.
getComponent2
();
}
if
(
SwiftTransferUtil
.
isAccount
(
account
))
{
if
(
account
.
startsWith
(
"/C/"
))
{
seltMtdHelper
.
setSettlementMethod
(
"INGA"
);
}
else
{
seltMtdHelper
.
setSettlementMethod
(
"INDA"
);
}
seltMtdHelper
.
setTranslateSetlAcctFlag
(
true
);
}
else
{
seltMtdHelper
.
setSettlementMethod
(
"INDA"
);
}
return
seltMtdHelper
;
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/setlmtd/impl/Field53D54aAnalyzer.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
setlmtd
.
impl
;
import
com.brilliance.swift.mt2mx.setlmtd.AbstractSettlementMethodAnalyzer
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.util.SwiftTransferUtil
;
import
com.brilliance.swift.vo.VoSettlementMethodHelper
;
import
com.prowidesoftware.swift.model.field.Field53D
;
public
class
Field53D54aAnalyzer
extends
AbstractSettlementMethodAnalyzer
{
@Override
public
VoSettlementMethodHelper
analyse
()
{
VoSettlementMethodHelper
seltMtdHelper
=
new
VoSettlementMethodHelper
();
Field53D
field53D
=
(
Field53D
)
field53
;
String
account
=
""
;
if
(
StringUtil
.
isNotEmpty
(
field53D
.
getComponent1
()))
{
account
+=
"/"
+
field53D
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field53D
.
getComponent2
()))
{
account
+=
"/"
+
field53D
.
getComponent2
();
}
if
(
SwiftTransferUtil
.
isAccount
(
account
))
{
if
(
account
.
startsWith
(
"/C/"
))
{
seltMtdHelper
.
setSettlementMethod
(
"INGA"
);
}
else
{
seltMtdHelper
.
setSettlementMethod
(
"INDA"
);
}
seltMtdHelper
.
setTranslateSetlAcctFlag
(
true
);
}
else
{
seltMtdHelper
.
setSettlementMethod
(
"COVE"
);
seltMtdHelper
.
setTranslate53Flag
(
true
);
seltMtdHelper
.
setTranslate54Flag
(
true
);
seltMtdHelper
.
setTranslate55Flag
(
true
);
}
return
seltMtdHelper
;
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/setlmtd/impl/FieldNone5354Analyzer.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
setlmtd
.
impl
;
import
com.brilliance.swift.mt2mx.setlmtd.AbstractSettlementMethodAnalyzer
;
import
com.brilliance.swift.vo.VoSettlementMethodHelper
;
public
class
FieldNone5354Analyzer
extends
AbstractSettlementMethodAnalyzer
{
@Override
public
VoSettlementMethodHelper
analyse
()
{
VoSettlementMethodHelper
seltMtdHelper
=
new
VoSettlementMethodHelper
();
seltMtdHelper
.
setSettlementMethod
(
"INDA"
);
return
seltMtdHelper
;
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/setlmtd/impl/FieldOnly53AAnalyzer.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
setlmtd
.
impl
;
import
com.brilliance.swift.mt2mx.Mt2MxContextIdentifier
;
import
com.brilliance.swift.mt2mx.setlmtd.AbstractSettlementMethodAnalyzer
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.util.SwiftTransferUtil
;
import
com.brilliance.swift.vo.VoSettlementMethodHelper
;
import
com.prowidesoftware.swift.model.field.Field53A
;
public
class
FieldOnly53AAnalyzer
extends
AbstractSettlementMethodAnalyzer
{
@Override
public
VoSettlementMethodHelper
analyse
()
{
VoSettlementMethodHelper
seltMtdHelper
=
new
VoSettlementMethodHelper
();
Field53A
field53A
=
(
Field53A
)
field53
;
String
account
=
""
;
if
(
StringUtil
.
isNotEmpty
(
field53A
.
getComponent1
()))
{
account
+=
"/"
+
field53A
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field53A
.
getComponent2
()))
{
account
+=
"/"
+
field53A
.
getComponent2
();
}
String
bicCode
=
field53A
.
getBIC
();
if
(
SwiftTransferUtil
.
isAccount
(
account
))
{
if
(
account
.
startsWith
(
"/C/"
))
{
seltMtdHelper
.
setSettlementMethod
(
"INGA"
);
}
else
{
seltMtdHelper
.
setSettlementMethod
(
"INDA"
);
}
seltMtdHelper
.
setTranslateSetlAcctFlag
(
true
);
seltMtdHelper
.
setInstructionForNextAgent
(
"/FIN53/"
+
bicCode
);
}
else
{
String
sendBic
=
(
String
)
context
.
get
(
Mt2MxContextIdentifier
.
MT_SEND_BIC
,
true
);
String
receiveBic
=
(
String
)
context
.
get
(
Mt2MxContextIdentifier
.
MT_RECEIVE_BIC
,
true
);
if
((
StringUtil
.
isNotEmpty
(
sendBic
)
&&
bicCode
.
substring
(
0
,
6
).
equals
(
sendBic
.
substring
(
0
,
6
)))
||
(
StringUtil
.
isNotEmpty
(
receiveBic
)
&&
bicCode
.
substring
(
0
,
6
).
equals
(
receiveBic
.
substring
(
0
,
6
))))
{
seltMtdHelper
.
setSettlementMethod
(
"INDA"
);
seltMtdHelper
.
setInstructionForNextAgent
(
"/FIN53/"
+
bicCode
);
}
else
{
seltMtdHelper
.
setSettlementMethod
(
"COVE"
);
seltMtdHelper
.
setTranslate53Flag
(
true
);
}
}
return
seltMtdHelper
;
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/setlmtd/impl/FieldOnly53BAnalyzer.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
setlmtd
.
impl
;
import
com.brilliance.swift.mt2mx.setlmtd.AbstractSettlementMethodAnalyzer
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.util.SwiftTransferUtil
;
import
com.brilliance.swift.vo.VoSettlementMethodHelper
;
import
com.prowidesoftware.swift.model.field.Field53B
;
public
class
FieldOnly53BAnalyzer
extends
AbstractSettlementMethodAnalyzer
{
@Override
public
VoSettlementMethodHelper
analyse
()
{
VoSettlementMethodHelper
seltMtdHelper
=
new
VoSettlementMethodHelper
();
Field53B
field53B
=
(
Field53B
)
field53
;
String
account
=
""
;
if
(
StringUtil
.
isNotEmpty
(
field53B
.
getComponent1
()))
{
account
+=
"/"
+
field53B
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field53B
.
getComponent2
()))
{
account
+=
"/"
+
field53B
.
getComponent2
();
}
if
(
SwiftTransferUtil
.
isAccount
(
account
))
{
if
(
account
.
startsWith
(
"/C/"
))
{
seltMtdHelper
.
setSettlementMethod
(
"INGA"
);
}
else
{
seltMtdHelper
.
setSettlementMethod
(
"INDA"
);
}
seltMtdHelper
.
setTranslateSetlAcctFlag
(
true
);
}
else
{
seltMtdHelper
.
setSettlementMethod
(
"INDA"
);
}
return
seltMtdHelper
;
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/setlmtd/impl/FieldOnly53DAnalyzer.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
setlmtd
.
impl
;
import
com.brilliance.swift.mt2mx.setlmtd.AbstractSettlementMethodAnalyzer
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.util.SwiftTransferUtil
;
import
com.brilliance.swift.vo.VoSettlementMethodHelper
;
import
com.prowidesoftware.swift.model.field.Field53D
;
public
class
FieldOnly53DAnalyzer
extends
AbstractSettlementMethodAnalyzer
{
@Override
public
VoSettlementMethodHelper
analyse
()
{
VoSettlementMethodHelper
seltMtdHelper
=
new
VoSettlementMethodHelper
();
Field53D
field53D
=
(
Field53D
)
field53
;
String
account
=
""
;
if
(
StringUtil
.
isNotEmpty
(
field53D
.
getComponent1
()))
{
account
+=
"/"
+
field53D
.
getComponent1
();
}
if
(
StringUtil
.
isNotEmpty
(
field53D
.
getComponent2
()))
{
account
+=
"/"
+
field53D
.
getComponent2
();
}
if
(
SwiftTransferUtil
.
isAccount
(
account
))
{
if
(
account
.
startsWith
(
"/C/"
))
{
seltMtdHelper
.
setSettlementMethod
(
"INGA"
);
}
else
{
seltMtdHelper
.
setSettlementMethod
(
"INDA"
);
}
seltMtdHelper
.
setTranslateSetlAcctFlag
(
true
);
}
else
{
seltMtdHelper
.
setSettlementMethod
(
"INDA"
);
}
return
seltMtdHelper
;
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/setlmtd/impl/FieldOnly54AAnalyzer.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
setlmtd
.
impl
;
import
com.brilliance.swift.mt2mx.Mt2MxContextIdentifier
;
import
com.brilliance.swift.mt2mx.setlmtd.AbstractSettlementMethodAnalyzer
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.vo.VoSettlementMethodHelper
;
import
com.prowidesoftware.swift.model.field.Field54A
;
public
class
FieldOnly54AAnalyzer
extends
AbstractSettlementMethodAnalyzer
{
@Override
public
VoSettlementMethodHelper
analyse
()
{
VoSettlementMethodHelper
seltMtdHelper
=
new
VoSettlementMethodHelper
();
Field54A
field54A
=
(
Field54A
)
field54
;
String
bicCode
=
field54A
.
getBIC
();
String
sendBic
=
(
String
)
context
.
get
(
Mt2MxContextIdentifier
.
MT_SEND_BIC
,
true
);
String
receiveBic
=
(
String
)
context
.
get
(
Mt2MxContextIdentifier
.
MT_RECEIVE_BIC
,
true
);
if
((
StringUtil
.
isNotEmpty
(
sendBic
)
&&
bicCode
.
substring
(
0
,
8
).
equals
(
sendBic
.
substring
(
0
,
8
)))
||
(
StringUtil
.
isNotEmpty
(
receiveBic
)
&&
bicCode
.
substring
(
0
,
8
).
equals
(
receiveBic
.
substring
(
0
,
8
))))
{
seltMtdHelper
.
setSettlementMethod
(
"INDA"
);
}
else
{
seltMtdHelper
.
setSettlementMethod
(
"COVE"
);
seltMtdHelper
.
setTranslate54Flag
(
true
);
}
return
seltMtdHelper
;
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/setlmtd/impl/FieldOnly54BAnalyzer.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
setlmtd
.
impl
;
import
com.brilliance.swift.mt2mx.setlmtd.AbstractSettlementMethodAnalyzer
;
import
com.brilliance.swift.vo.VoSettlementMethodHelper
;
public
class
FieldOnly54BAnalyzer
extends
AbstractSettlementMethodAnalyzer
{
@Override
public
VoSettlementMethodHelper
analyse
()
{
VoSettlementMethodHelper
seltMtdHelper
=
new
VoSettlementMethodHelper
();
seltMtdHelper
.
setSettlementMethod
(
"COVE"
);
seltMtdHelper
.
setTranslate54Flag
(
true
);
return
seltMtdHelper
;
}
}
swiftCore/src/main/java/com/brilliance/swift/mt2mx/setlmtd/impl/FieldOnly54DAnalyzer.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
mt2mx
.
setlmtd
.
impl
;
import
com.brilliance.swift.mt2mx.setlmtd.AbstractSettlementMethodAnalyzer
;
import
com.brilliance.swift.vo.VoSettlementMethodHelper
;
public
class
FieldOnly54DAnalyzer
extends
AbstractSettlementMethodAnalyzer
{
@Override
public
VoSettlementMethodHelper
analyse
()
{
VoSettlementMethodHelper
seltMtdHelper
=
new
VoSettlementMethodHelper
();
seltMtdHelper
.
setSettlementMethod
(
"COVE"
);
seltMtdHelper
.
setTranslate54Flag
(
true
);
return
seltMtdHelper
;
}
}
swiftCore/src/main/java/com/brilliance/swift/mx2mt/AbstractMx2MtCreator.java
View file @
904a5834
...
...
@@ -18,6 +18,7 @@ import org.dom4j.Document;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.text.ParseException
;
import
java.util.*
;
public
abstract
class
AbstractMx2MtCreator
implements
Mx2MtCreator
{
...
...
@@ -32,13 +33,18 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
this
.
context
=
context
;
}
//TODO
protected
String
getRandomNumber
(
int
length
)
{
String
randomNumber
=
""
;
/*
String randomNumber = "";
Random random = new Random();
for (int i=0; i<length; i++) {
randomNumber += random.nextInt(9);
}
return randomNumber;*/
String
randomNumber
=
""
;
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
randomNumber
+=
"0"
;
}
return
randomNumber
;
}
...
...
@@ -46,9 +52,11 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
String
processedBicCode
=
""
;
if
(!
StringUtil
.
isEmpty
(
bicCode
))
{
if
(
bicCode
.
length
()
==
8
)
{
processedBicCode
=
bicCode
+
Mx2MtConstants
.
BICSUFFIX
;
//processedBicCode = bicCode + Mx2MtConstants.BICSUFFIX;
processedBicCode
=
bicCode
+
"XXXX"
;
}
else
if
(
bicCode
.
length
()
==
11
)
{
processedBicCode
=
bicCode
.
substring
(
0
,
8
)
+
Mx2MtConstants
.
BICMIDDLE
+
bicCode
.
substring
(
8
);
//processedBicCode = bicCode.substring(0, 8) + Mx2MtConstants.BICMIDDLE + bicCode.substring(8);
processedBicCode
=
bicCode
.
substring
(
0
,
8
)
+
"X"
+
bicCode
.
substring
(
8
);
}
else
{
throw
new
SwiftException
(
"ERROR"
,
"BicCode length is invalid."
);
}
...
...
@@ -129,14 +137,20 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
}
Date
outputDate
=
(
Date
)
context
.
get
(
Mx2MtConstants
.
OUTPUT_DATE
,
true
);
if
(
outputDate
==
null
)
{
outputDate
=
new
Date
();
try
{
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
);
if
(
"O"
.
equalsIgnoreCase
(
applicationMode
))
{
SwiftBlock2Output
block2
=
new
SwiftBlock2Output
();
block2
.
setMessageType
(
getMtType
());
block2
.
setSenderInputTime
(
DateUtil
.
format
(
inputDate
,
"HHmm"
));
block2
.
setMIRDate
(
DateUtil
.
format
(
inputDate
,
"yyMMdd"
));
//block2.setSenderInputTime(DateUtil.format(inputDate, "HHmm"));
//block2.setMIRDate(DateUtil.format(inputDate, "yyMMdd"));
block2
.
setSenderInputTime
(
"0000"
);
block2
.
setMIRDate
(
"991231"
);
block2
.
setMIRLogicalTerminal
(
processBicCode
(
senderBic
));
block2
.
setMIRSessionNumber
(
getRandomNumber
(
4
));
block2
.
setMIRSequenceNumber
(
getRandomNumber
(
6
));
...
...
swiftCore/src/main/java/com/brilliance/swift/util/SwiftTransferUtil.java
View file @
904a5834
...
...
@@ -4,9 +4,7 @@ import cn.hutool.poi.excel.ExcelReader;
import
cn.hutool.poi.excel.ExcelUtil
;
import
com.brilliance.swift.vo.MxMtReasonCodeInfo
;
import
com.brilliance.swift.vo.SwiftTransferErrorInfo
;
import
com.brilliance.swift.vo.common.ClearingSystemMemberCode
;
import
com.brilliance.swift.vo.common.OrganisationIdentificationCode
;
import
com.brilliance.swift.vo.common.PersonIdentificationCode
;
import
com.brilliance.swift.vo.common.*
;
import
javax.xml.datatype.DatatypeConfigurationException
;
import
javax.xml.datatype.DatatypeFactory
;
...
...
@@ -16,8 +14,8 @@ import java.math.BigDecimal;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
public
class
SwiftTransferUtil
{
public
class
SwiftTransferUtil
{
private
static
Properties
properties
=
null
;
public
static
XMLGregorianCalendar
getXMLGregorianCalendarNow
()
{
...
...
@@ -558,6 +556,69 @@ public class SwiftTransferUtil {
return
false
;
}
public
static
CategoryPurposeCode
getCategoryPurposeByValue
(
String
value
)
{
CategoryPurposeCode
code
=
null
;
CategoryPurposeCode
[]
values
=
CategoryPurposeCode
.
values
();
for
(
CategoryPurposeCode
tmpCode
:
values
)
{
if
(
tmpCode
.
value
().
equals
(
value
))
{
code
=
tmpCode
;
break
;
}
}
return
code
;
}
public
static
LocalInstrumentCode
getLocalInstrumentByValue
(
String
value
)
{
LocalInstrumentCode
code
=
null
;
LocalInstrumentCode
[]
values
=
LocalInstrumentCode
.
values
();
for
(
LocalInstrumentCode
tmpCode
:
values
)
{
if
(
value
.
matches
(
"^[0-9]*$"
))
{
value
=
"_"
+
value
;
//如果value是纯数字,则前缀加上下划线
}
if
(
tmpCode
.
value
().
equals
(
value
))
{
code
=
tmpCode
;
break
;
}
}
return
code
;
}
public
static
ServiceLevelCode
getServiceLevelByValue
(
String
value
)
{
ServiceLevelCode
code
=
null
;
ServiceLevelCode
[]
values
=
ServiceLevelCode
.
values
();
for
(
ServiceLevelCode
tmpCode
:
values
)
{
if
(
tmpCode
.
value
().
equals
(
value
))
{
code
=
tmpCode
;
break
;
}
}
return
code
;
}
public
static
ChargeForEnum
getChargeForByDesc
(
String
desc
)
{
ChargeForEnum
code
=
null
;
ChargeForEnum
[]
values
=
ChargeForEnum
.
values
();
for
(
ChargeForEnum
tmpCode
:
values
)
{
if
(
tmpCode
.
desc
().
equals
(
desc
))
{
code
=
tmpCode
;
break
;
}
}
return
code
;
}
public
static
ClearingSystemMemberCode
getClsSysMemberByDesc
(
String
desc
)
{
ClearingSystemMemberCode
code
=
null
;
ClearingSystemMemberCode
[]
values
=
ClearingSystemMemberCode
.
values
();
for
(
ClearingSystemMemberCode
tmpCode
:
values
)
{
if
(
tmpCode
.
desc
().
equals
(
desc
))
{
code
=
tmpCode
;
break
;
}
}
return
code
;
}
/**
* 根据字符串取到清算系统代码
* ClearingSystemMemberCode对象包含了
...
...
@@ -675,4 +736,13 @@ public class SwiftTransferUtil {
}
return
list
;
}
public
static
boolean
isAccount
(
String
account
)
{
boolean
flag
=
false
;
if
(
StringUtil
.
isEmpty
(
account
))
return
flag
;
if
(
account
.
startsWith
(
"//CH"
)
||
!
account
.
startsWith
(
"//"
))
{
flag
=
true
;
}
return
flag
;
}
}
swiftCore/src/main/java/com/brilliance/swift/vo/VoSettlementMethodHelper.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
vo
;
import
java.io.Serializable
;
public
class
VoSettlementMethodHelper
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
4632575473568055560L
;
/**
* 结算方式,对应MX Group Header->Settlement Information->Settlement Method
*/
private
String
settlementMethod
;
/**
* mt -> mx
* false 表示不转换53域
* true 表示转换53域
*/
private
boolean
translate53Flag
=
false
;
/**
* mt -> mx
* false 表示不转换54域
* true 表示转换54域
*/
private
boolean
translate54Flag
=
false
;
/**
* mt -> mx
* false 表示不转换55域
* true 表示转换55域
*/
private
boolean
translate55Flag
=
false
;
/**
* mt -> mx
* false 表示不转换 Group Header -> Settlement Information -> Settlement Account
* true 表示转换 Group Header -> Settlement Information -> Settlement Account
*/
private
boolean
translateSetlAcctFlag
=
false
;
private
String
instructionForNextAgent
;
public
String
getSettlementMethod
()
{
return
settlementMethod
;
}
public
void
setSettlementMethod
(
String
settlementMethod
)
{
this
.
settlementMethod
=
settlementMethod
;
}
public
boolean
isTranslate53Flag
()
{
return
translate53Flag
;
}
public
void
setTranslate53Flag
(
boolean
translate53Flag
)
{
this
.
translate53Flag
=
translate53Flag
;
}
public
boolean
isTranslate54Flag
()
{
return
translate54Flag
;
}
public
void
setTranslate54Flag
(
boolean
translate54Flag
)
{
this
.
translate54Flag
=
translate54Flag
;
}
public
boolean
isTranslate55Flag
()
{
return
translate55Flag
;
}
public
void
setTranslate55Flag
(
boolean
translate55Flag
)
{
this
.
translate55Flag
=
translate55Flag
;
}
public
String
getInstructionForNextAgent
()
{
return
instructionForNextAgent
;
}
public
void
setInstructionForNextAgent
(
String
instructionForNextAgent
)
{
this
.
instructionForNextAgent
=
instructionForNextAgent
;
}
public
boolean
isTranslateSetlAcctFlag
()
{
return
translateSetlAcctFlag
;
}
public
void
setTranslateSetlAcctFlag
(
boolean
translateSetlAcctFlag
)
{
this
.
translateSetlAcctFlag
=
translateSetlAcctFlag
;
}
}
swiftCore/src/main/java/com/brilliance/swift/vo/common/ClearingSystemMemberCode.java
View file @
904a5834
...
...
@@ -28,6 +28,8 @@ public enum ClearingSystemMemberCode {
CACPA
(
"CC"
),
CNAPS
(
"CN"
),
DEBLZ
(
"BL"
),
GRBIC
(
"GR"
),
...
...
@@ -40,6 +42,8 @@ public enum ClearingSystemMemberCode {
ITNCC
(
"IT"
),
JPZGN
(
"JP"
),
NZNCC
(
"NZ"
),
PLKNR
(
"PL"
),
...
...
@@ -52,6 +56,12 @@ public enum ClearingSystemMemberCode {
ESNCC
(
"ES"
),
CHBCC
(
"SW"
),
CHSIC
(
"SW"
),
TWNCC
(
"TW"
),
GBDSC
(
"SC"
),
USPID
(
"CP"
),
...
...
swiftCore/src/main/java/com/brilliance/swift/vo/common/LocalInstrumentCode.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
swift
.
vo
.
common
;
public
enum
LocalInstrumentCode
{
DDMC
(
"DirectDebitConfirmedElectronicMandate"
),
DDMP
(
"DirectDebitPaperMandateWithPaperAuthorization"
),
DDMU
(
"DirectDebitUnconfirmedElectronicMandate"
),
BPA
(
"BatchPaymentsAruba"
),
IPA
(
"InstantPaymentsAruba"
),
TRF
(
"CreditTransfers"
),
_82
(
"NonPreauthorisedDirectDebitAT"
),
_83
(
"PreauthorisedDirectDebitAT"
),
CPP
(
"CashPerPost"
),
RTR
(
"ReturnedCreditTransfers"
),
GST
(
"TruncatedCreditTransfers"
),
DDT
(
"DirectDebits"
),
RDD
(
"ReturnedDirectDebits"
),
CHN
(
"TruncatedChecks"
),
STR
(
"RevokedCreditTransfers"
),
SDD
(
"RevokedDirectDebits"
),
SRT
(
"RevokedReturnedCreditTransfers"
),
SRD
(
"RevokedReturnedDirectDebits"
),
SCN
(
"RevokedTruncatedChecks"
),
SGT
(
"RevokedTruncatedCreditTransfers"
),
CARD
(
"CardClearing"
),
_05
(
"NonPreauthorisedDirectDebitDE"
),
_04
(
"PreauthorisedDirectDebitDE"
),
ISE
(
"ImageBasedChequeCollection"
),
BSE
(
"PaperlessChequeCollection"
),
_58
(
"BusinessToBusinessDirectDebit"
),
_19
(
"BusinessToCustomerDirectDebit"
),
ASTI
(
"AncillarySystemTransferInitiation"
),
BACP
(
"BackupPayment"
),
MANP
(
"MandatedPayment"
),
SBTI
(
"SettlementBankTransferInitiation"
),
_85
(
"PreauthorisedDirectDebitAccéléréAcceleratedClearing2DayOrdinaireNormalClearing4Day"
),
_08
(
"PreauthorisedDirectDebitOrdinaireNormalClearing4Day"
),
_89
(
"PreauthorisedDirectDebitVérifiéVerifiedClearing"
),
_60
(
"RecoveredBillofExchangeorPromissoryNote"
),
RIBA
(
"NonPreauthorisedDirectDebitRIBA"
),
RIDO
(
"PreauthorisedRevocableDirectDebit"
),
RIDV
(
"PreauthorisedRevocableUrgentDirectDebit"
),
IDEAL
(
"PaymentsViaInternetOwnedByCurrence"
),
INSTNT01
(
"InstantCreditTransferNotTimeCritical"
),
INSTTC01
(
"InstantCreditTransferTimeCritical"
),
INSTIDEAL
(
"PaymentsViaInternetOwnedByCurrenceUsingInstantCreditTransfer"
),
INSTNT01IDEAL
(
"PaymentsViaInternetOwnedByCurrenceUsingInstantCreditTransferNotTimeCritical"
),
INSTTC01IDEAL
(
"PaymentsViaInternetOwnedByCurrenceUsingInstantCreditTransferTimeCritical"
),
NLDO
(
"DutchDomesticBulkPayment"
),
NLUP
(
"DutchUrgentPayment"
),
SDN
(
"PaymentsViaStandaardDigitaleNota"
),
ACCEPT
(
"PaymentViaAcceptgiroOwnedByCurrence"
),
ICMC
(
"IncidentManagementCorrection"
),
NLGOV
(
"DirectDebitInitiatedByTheGovernmentWithSpecialConditions"
),
_0090
(
"MassPaymentBeneficiary"
),
_0091
(
"MassPaymentOurs"
),
_0092
(
"MassPaymentShared"
),
_0002
(
"StandingOrder"
),
_0221
(
"OneOffAuthorisation"
),
_0224
(
"OneOffAuthorisationCharities"
),
_0226
(
"OneOffAuthorisationConstructionIndustry"
),
_0225
(
"OneOffAuthorisationTuitionFees"
),
_0222
(
"StandingAuthorisationCompanies"
),
_0227
(
"StandingAuthorisationCompaniesWithoutDebtorRevocationRight"
),
_0220
(
"StandingAuthorisationGeneral"
),
_0223
(
"StandingAuthorisationLotteries"
),
_0001
(
"ConvertedBankPayment"
),
_0000
(
"BusinessPayment"
),
IN
(
"CrossBorderCustomerCreditTransfer"
),
ONCL
(
"Overnight"
),
PERI
(
"PaymentWithERI"
),
SDCL
(
"SameDayClearedPayments"
),
DDNR
(
"CoreNoRefund"
),
DDFA
(
"DirectDebitFixedAmount"
),
CORE
(
"SEPADirectDebitCore"
),
B2BAMIPM
(
"SEPAB2BDirectDebitAMI"
),
B2B
(
"SEPABusinessToBusinessDirectDebit"
),
CR1AMIPM
(
"SEPACoreD1DirectDebitAMI"
),
CORAMIPM
(
"SEPACoreDirectDebitAMI"
),
COR1
(
"SEPADirectDebit1DaySettlement"
),
FADAMIPM
(
"SEPAFADirectDebitAMI"
),
CLSCCPERX
(
"CLSClearedFXForEurex"
),
CLSCCPLCH
(
"CLSClearedFXForLCH"
),
INST
(
"InstantCreditTransfer"
),
ADD
(
"AuthenticatedDirectDebit"
),
UDD
(
"UnauthenticatedDirectDebit"
),
CCI
(
"CashConcentrationIntragroup"
),
BTR
(
"BankTransfer"
),
CKS
(
"CheckSameDaySettlementWire"
),
CTR
(
"CustomerTransfer"
),
CTP
(
"CustomerTransferPlus"
),
DEP
(
"DepositToSendersAccount"
),
FFR
(
"FedFundsReturned"
),
FFS
(
"FedFundsSold"
),
SVC
(
"NonValueServiceMessage"
),
DRW
(
"DrawdownResponseValueToHonorADrawdownRequest"
),
DRB
(
"BankToBankDrawdownRequestOrResponseNonvalue"
),
DRC
(
"CustomerOrCorporateDrawdownRequestOrResponseNonvalue"
),
IAT
(
"InternationalACH"
),
CCD
(
"CashConcentrationOrDisbursementCorporateCounterparty"
),
CTX
(
"CorporateTradeExchange"
),
PPD
(
"PrearrangedPaymentOrDepositConsumerCounterparty"
),
CIE
(
"CustomerInitiatedEntry"
),
RCK
(
"RepresentedCheckEntry"
),
ARC
(
"AccountsReceivableCheck"
),
WEB
(
"InternetInitiatedEntry"
),
POP
(
"PointOfPurchase"
),
POS
(
"PointOfSale"
),
TEL
(
"TelephoneInitiatedEntry"
),
ITP
(
"InstantCreditTransferPreferred"
);
//CTP("CreditTransferPreferred");
LocalInstrumentCode
(
String
s
)
{}
public
String
value
()
{
return
name
();
}
}
swiftCore/src/main/resources/swiftTxt/MT103.txt
View file @
904a5834
{1:F01FOOBARC0AXXX4402221388}{2:O1031010200908BANKANC0AXXX50363658012204281624U}{3:{1
08:220428162427085
1}{121:8a562c67-ca16-48ba-b074-65581be6f001}}{4:
{1:F01FOOBARC0AXXX4402221388}{2:O1031010200908BANKANC0AXXX50363658012204281624U}{3:{1
11:00
1}{121:8a562c67-ca16-48ba-b074-65581be6f001}}{4:
:20:TBEXO12345
:13C:/SNDTIME/2124+0
8
00
:13C:/SNDTIME/2124+0
7
00
:13C:/RNCTIME/2330+0800
:13C:/CLSTIME/2221+0800
:13C:/CLSTIME/2221+0600
:13C:/TILTIME/2321+0800
:13C:/FROTIME/2021+0900
:13C:/REJTIME/2121+0800
:23B:CRED
:23E:HOLD/81939316763
:23E:SDVA
:23E:CASH
:23E:TELB/789556
:23E:INTC
:23E:TELB
:23E:PHOB
:23E:CHQB
:26T:GCY
:32A:220313USD23453,13
:33B:EUR1345,12
:36:17,4357135422
:50A:/01111001759234567890
GCYXXXXXX12
:52A:FOOBARC0
:53A:FOOBARC1
:54A:FOOBARC3
:55A:FOOBARC4
:36:17,435713542
:50F:ARNU/BE/12598766233
1/Name
6/BE/FvW/ABC1234567
7/BE/1256ABC12345678976543213854847
8/54689
:52A://AUqwert123456
FOOBARC0
:53B:/C/we1234
bobjack
:56A:FOOBARC6
:57A:BANKANC7
:59:/00013500510020179998
TEST CORP
Nellis ABC, NV
:70:gechengyang
:57C:/Q1234433
:59F://CH3234232
1/Vanmusten Ilya
2/Brugmannlaan 415
3/BE/Brussels
:70:/ROC/CUST123456789///INV/123 dated
03/04/2006
:71A:OUR
:71G:USD12,43
:72:/INS/FOOBARC7
/ACC/789556
/REC/chengzhuoshendsdsdsdsddsd
/INTA/BANKERUN
/LOCINS/DDMC
/CATPURP/DVPM
/SVCLVL/PRPT
:77B:/ORDERRES/BE//MEILAAN 1, 9000 GENT
//JIANGXIAQU
//WENHUADADAO
...
...
swiftCore/src/main/resources/swiftXml/MxPacs00800109.xml
View file @
904a5834
...
...
@@ -44,13 +44,6 @@ Change Log
</SttlmInf>
</GrpHdr>
<CdtTrfTxInf>
<SttlmTmIndctn>
<DbtDtTm>
2022-03-13T20:24:42.112+07:00
</DbtDtTm>
<CdtDtTm>
2022-03-13T22:30:42.112+07:00
</CdtDtTm>
</SttlmTmIndctn>
<SttlmTmReq>
<CLSTm>
21:21:42.112+07:00
</CLSTm>
</SttlmTmReq>
<PmtId>
<InstrId>
pacs8bizmsgidr01
</InstrId>
<EndToEndId>
pacs008EndToEndId-001
</EndToEndId>
...
...
@@ -93,17 +86,8 @@ Change Log
<StrtNm>
Rue Saint Exupery
</StrtNm>
<TwnNm>
17/13 4460 GRACE-HOLLOGNE
</TwnNm>
<Ctry>
BG
</Ctry>
<AdrLine>
HuBei
</AdrLine>
<AdrLine>
WuHan
</AdrLine>
</PstlAdr>
</Cdtr>
<CdtrAcct>
<Id>
<Othr>
<Id>
123456
</Id>
</Othr>
</Id>
</CdtrAcct>
<RmtInf>
<Ustrd>
SWEEP 454-9663
</Ustrd>
</RmtInf>
...
...
swiftCore/src/test/java/com/brilliance/mt2mx/pacs008001/Test.java
0 → 100644
View file @
904a5834
package
com
.
brilliance
.
mt2mx
.
pacs008001
;
import
com.brilliance.swift.mt2mx.Mt2MxCreatorManager
;
import
org.apache.commons.io.FileUtils
;
import
java.io.File
;
import
java.io.IOException
;
public
class
Test
{
public
static
void
main
(
String
[]
args
)
throws
IOException
{
File
file
=
new
File
(
System
.
getProperty
(
"user.dir"
)+
"\\swiftCore\\src\\main\\resources\\swiftTxt\\Mt103.txt"
);
String
mtStr
=
FileUtils
.
readFileToString
(
file
);
String
mxXml
=
new
Mt2MxCreatorManager
().
mt2mx
(
mtStr
,
null
,
null
);
System
.
out
.
println
(
mxXml
);
/*AbstractMT abstractMT = AbstractMT.parse(mtStr);
MT103 mt103 = (MT103)abstractMT;
Field53A field53A = mt103.getField53A();
System.out.println(field53A.getComponent(1) + field53A.getComponent2());
System.out.println(field53A.getBIC());*/
}
}
swiftCore/src/test/java/com/brilliance/mx2mtmap/mt103/Test.java
View file @
904a5834
package
com
.
brilliance
.
mx2mtmap
.
mt103
;
import
com.brilliance.swift.SwiftTransfer
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.prowidesoftware.swift.model.mx.AbstractMX
;
import
org.apache.commons.io.FileUtils
;
import
java.io.File
;
...
...
@@ -22,8 +24,36 @@ public class Test {
//String gsonStr = SwiftTransfer.mx2Gson(xmlStr);
//System.out.println(gson);
Map
<
String
,
String
>
maps
=
SwiftTransfer
.
mx2Map
(
xmlStr
);
maps
.
forEach
((
k
,
v
)
->
System
.
out
.
println
(
k
+
"="
+
v
));
//Map<String, String> maps = SwiftTransfer.mx2Map(xmlStr);
//maps.forEach((k, v) -> System.out.println(k + "=" + v));
//String json = SwiftTransfer.mx2Gson(xmlStr);
//System.out.println(json);
AbstractMX
abstractMX
=
AbstractMX
.
parse
(
xmlStr
);
String
gsonStr
=
abstractMX
.
toJson
();
System
.
out
.
println
(
gsonStr
);
AbstractMX
abstractMX1
=
AbstractMX
.
fromJson
(
gsonStr
);
System
.
out
.
println
(
abstractMX1
.
message
());
Map
<
String
,
Object
>
mxGsonMaps
=
JSON
.
parseObject
(
gsonStr
);
//String swiftGsonStr = new JSONObject(mxGsonMaps).toJSONString();
//AbstractMX abstractMX1 = AbstractMX.fromJson(swiftGsonStr);
// System.out.println(abstractMX1.toString());
Map
<
String
,
Object
>
maps
=
(
Map
<
String
,
Object
>)
mxGsonMaps
.
get
(
"fiToFICstmrCdtTrf"
);
JSONArray
jsonArrays
=
(
JSONArray
)
maps
.
get
(
"cdtTrfTxInf"
);
int
size
=
jsonArrays
.
size
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
Map
<
String
,
Object
>
tmpMaps
=
(
Map
<
String
,
Object
>)
jsonArrays
.
get
(
i
);
Map
<
String
,
Object
>
maps1
=
(
Map
<
String
,
Object
>)
tmpMaps
.
get
(
"cdtr"
);
maps1
=
(
Map
<
String
,
Object
>)
maps1
.
get
(
"pstlAdr"
);
JSONArray
objs
=
(
JSONArray
)
maps1
.
get
(
"adrLine"
);
int
objSize
=
objs
.
size
();
for
(
int
j
=
0
;
j
<
objSize
;
j
++)
{
System
.
out
.
println
(
objs
.
get
(
j
).
getClass
());
}
}
//System.out.println(mxGsonMaps);
}
}
swiftMx/src/main/java/com/prowidesoftware/swift/model/mx/AbstractMX.java
View file @
904a5834
...
...
@@ -188,6 +188,7 @@ public abstract class AbstractMX extends AbstractMessage implements JsonSerializ
final
Gson
gson
=
new
GsonBuilder
()
.
registerTypeAdapter
(
AbstractMX
.
class
,
new
AbstractMXAdapter
())
.
registerTypeAdapter
(
XMLGregorianCalendar
.
class
,
new
XMLGregorianCalendarAdapter
())
.
registerTypeAdapter
(
AppHdr
.
class
,
new
AppHdrAdapter
())
.
create
();
return
gson
.
fromJson
(
json
,
classOfT
);
}
...
...
@@ -203,6 +204,7 @@ public abstract class AbstractMX extends AbstractMessage implements JsonSerializ
final
Gson
gson
=
new
GsonBuilder
()
.
registerTypeAdapter
(
AbstractMX
.
class
,
new
AbstractMXAdapter
())
.
registerTypeAdapter
(
XMLGregorianCalendar
.
class
,
new
XMLGregorianCalendarAdapter
())
.
registerTypeAdapter
(
AppHdr
.
class
,
new
AppHdrAdapter
())
.
create
();
return
gson
.
fromJson
(
json
,
AbstractMX
.
class
);
}
...
...
swiftMx/src/main/java/com/prowidesoftware/swift/model/mx/AppHdrAdapter.java
0 → 100644
View file @
904a5834
/*
* Copyright 2006-2021 Prowide
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
prowidesoftware
.
swift
.
model
.
mx
;
import
com.google.gson.*
;
import
java.lang.reflect.Type
;
/**
* {@link AbstractMX} JSON serialization and deserialization implementation based on Gson.
* <p>
* The implementation relieas on the default object serialization that will fill the JSON structure
* with all content from the subclasses model (MX model in Integrator). On top of the default subclass
* data, this serializer will add the namespace and identifier (needed to clearly identify the message
* type in the generic deserialization)
*
* @since 7.10.3
*/
class
AppHdrAdapter
implements
JsonSerializer
<
AppHdr
>,
JsonDeserializer
<
AppHdr
>
{
private
static
final
String
IDENTIFIER
=
"identifier"
;
@Override
public
JsonElement
serialize
(
final
AppHdr
appHdr
,
Type
type
,
final
JsonSerializationContext
context
)
{
JsonObject
object
=
context
.
serialize
(
appHdr
).
getAsJsonObject
();
return
object
;
}
@Override
public
AppHdr
deserialize
(
JsonElement
json
,
Type
typeOfT
,
JsonDeserializationContext
context
)
throws
JsonParseException
{
Class
<?>
klass
=
null
;
try
{
String
className
=
"com.prowidesoftware.swift.model.mx.BusinessAppHdrV02"
;
klass
=
Class
.
forName
(
className
);
}
catch
(
ClassNotFoundException
e
)
{
throw
new
JsonParseException
(
"Cannot find AppHdr implementation for "
+
e
.
getMessage
());
}
return
context
.
deserialize
(
json
,
klass
);
}
}
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