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
c316053e
Commit
c316053e
authored
Apr 22, 2022
by
chengzhuoshen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加VoCustomerCreditTransfer gson相关代码,支持gson转xml
parent
71aea669
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
220 additions
and
9 deletions
+220
-9
Mt2MxPacs00801Creator.java
...lliance/swift/mt2mx/pacs008001/Mt2MxPacs00801Creator.java
+1
-0
Pacs00801Parse23EField.java
...e/swift/mt2mx/pacs008001/impl/Pacs00801Parse23EField.java
+1
-2
SwiftDto2MxCreatorManager.java
...va/com/brilliance/swift/mx/SwiftDto2MxCreatorManager.java
+14
-0
DateAdapter.java
...re/src/main/java/com/brilliance/swift/vo/DateAdapter.java
+28
-0
SwiftDto.java
...tCore/src/main/java/com/brilliance/swift/vo/SwiftDto.java
+20
-0
SwiftDtoAdapter.java
...rc/main/java/com/brilliance/swift/vo/SwiftDtoAdapter.java
+36
-0
VoCustomerCreditTransfer.java
...ava/com/brilliance/swift/vo/VoCustomerCreditTransfer.java
+0
-5
customercredittransfer.txt
...e/src/main/resources/swiftJson/customercredittransfer.txt
+106
-0
TestPacs008001.java
.../java/com/brilliance/mt2mx/pacs008001/TestPacs008001.java
+0
-2
TestPacs008001_GSON.java
...ava/com/brilliance/mx/pacs008001/TestPacs008001_GSON.java
+14
-0
No files found.
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/Mt2MxPacs00801Creator.java
View file @
c316053e
...
...
@@ -27,6 +27,7 @@ public class Mt2MxPacs00801Creator extends AbstractMt2MxCreator {
customerCreditTransfer
.
setCreateDate
(
swiftDto
.
getCreateDate
());
customerCreditTransfer
.
setMessagePriority
(
swiftDto
.
getMessagePriority
());
customerCreditTransfer
.
setUetr
(
swiftDto
.
getUetr
());
customerCreditTransfer
.
setMessageType
(
"pacs.008.001"
);
context
.
set
(
customerCreditTransfer
);
}
catch
(
Exception
e
)
{
throw
new
SwiftException
(
"ERROR"
,
e
.
getMessage
());
...
...
swiftCore/src/main/java/com/brilliance/swift/mt2mx/pacs008001/impl/Pacs00801Parse23EField.java
View file @
c316053e
...
...
@@ -8,7 +8,6 @@ import com.prowidesoftware.swift.model.field.Field23E;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
com.prowidesoftware.swift.model.mt1xx.MT103
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
Pacs00801Parse23EField
extends
AbstractMt2MxParseFields
{
...
...
@@ -23,7 +22,7 @@ public class Pacs00801Parse23EField extends AbstractMt2MxParseFields {
Field23E
field23E
=
field23EList
.
get
(
i
);
InstructionCode
instructionCode
=
new
InstructionCode
();
instructionCode
.
setCode
(
field23E
.
getCode
());
instructionCode
.
set
Code
(
field23E
.
getAdditionalInformation
());
instructionCode
.
set
AdditionalInformation
(
field23E
.
getAdditionalInformation
());
customerCreditTransfer
.
addInstructionCode
(
instructionCode
);
}
}
...
...
swiftCore/src/main/java/com/brilliance/swift/mx/SwiftDto2MxCreatorManager.java
View file @
c316053e
...
...
@@ -3,9 +3,23 @@ package com.brilliance.swift.mx;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx.pacs00801.SwiftDto2MxPacs008001Creator
;
import
com.brilliance.swift.vo.SwiftDto
;
import
org.apache.commons.io.FileUtils
;
import
java.io.File
;
public
class
SwiftDto2MxCreatorManager
{
public
String
swiftDto2Mx
(
File
file
,
String
fileOutputPath
)
throws
Exception
{
String
gsonStr
=
FileUtils
.
readFileToString
(
file
);
SwiftDto
swiftDto
=
SwiftDto
.
fromJson
(
gsonStr
);
return
swiftDto2Mx
(
swiftDto
,
fileOutputPath
);
}
public
String
swiftDto2Mx
(
String
gsonStr
,
String
fileOutputPath
)
{
SwiftDto
swiftDto
=
SwiftDto
.
fromJson
(
gsonStr
);
return
swiftDto2Mx
(
swiftDto
,
fileOutputPath
);
}
public
String
swiftDto2Mx
(
SwiftDto
swiftDto
,
String
fileOutputPath
)
throws
SwiftException
{
try
{
SwiftDto2MxContext
context
=
new
SwiftDto2MxContext
();
...
...
swiftCore/src/main/java/com/brilliance/swift/vo/DateAdapter.java
0 → 100644
View file @
c316053e
package
com
.
brilliance
.
swift
.
vo
;
import
com.brilliance.swift.util.DateUtil
;
import
com.google.gson.*
;
import
java.lang.reflect.Type
;
import
java.text.ParseException
;
import
java.util.Date
;
public
class
DateAdapter
implements
JsonSerializer
<
Date
>,
JsonDeserializer
<
Date
>
{
private
static
final
String
DATE_FORMAT
=
"yyyy-MM-dd HH:mm:ss,SSS"
;
@Override
public
Date
deserialize
(
JsonElement
json
,
Type
typeOfT
,
JsonDeserializationContext
context
)
throws
JsonParseException
{
try
{
return
DateUtil
.
parseDate
(
json
.
getAsString
(),
DATE_FORMAT
);
}
catch
(
ParseException
e
)
{
throw
new
JsonParseException
(
e
.
getMessage
());
}
}
@Override
public
JsonElement
serialize
(
Date
src
,
Type
typeOfSrc
,
JsonSerializationContext
context
)
{
String
dateStr
=
DateUtil
.
format
(
src
,
DATE_FORMAT
);
return
new
JsonPrimitive
(
dateStr
);
}
}
swiftCore/src/main/java/com/brilliance/swift/vo/SwiftDto.java
View file @
c316053e
package
com
.
brilliance
.
swift
.
vo
;
import
com.brilliance.swift.vo.common.MessagePriority
;
import
com.google.gson.Gson
;
import
com.google.gson.GsonBuilder
;
import
java.util.Date
;
...
...
@@ -75,4 +77,22 @@ public class SwiftDto {
public
void
setUetr
(
String
uetr
)
{
this
.
uetr
=
uetr
;
}
public
String
toJson
()
{
final
Gson
gson
=
new
GsonBuilder
()
.
registerTypeAdapter
(
SwiftDto
.
class
,
new
SwiftDtoAdapter
())
.
registerTypeAdapter
(
Date
.
class
,
new
DateAdapter
())
.
setPrettyPrinting
()
.
create
();
return
gson
.
toJson
(
this
,
this
.
getClass
());
}
public
static
SwiftDto
fromJson
(
String
json
)
{
final
Gson
gson
=
new
GsonBuilder
()
.
registerTypeAdapter
(
SwiftDto
.
class
,
new
SwiftDtoAdapter
())
.
registerTypeAdapter
(
Date
.
class
,
new
DateAdapter
())
.
create
();
return
gson
.
fromJson
(
json
,
SwiftDto
.
class
);
}
}
swiftCore/src/main/java/com/brilliance/swift/vo/SwiftDtoAdapter.java
0 → 100644
View file @
c316053e
package
com
.
brilliance
.
swift
.
vo
;
import
com.google.gson.*
;
import
java.lang.reflect.Type
;
public
class
SwiftDtoAdapter
implements
JsonSerializer
<
SwiftDto
>,
JsonDeserializer
<
SwiftDto
>
{
private
static
final
String
MESSAGETYPE
=
"messageType"
;
@Override
public
SwiftDto
deserialize
(
JsonElement
json
,
Type
typeOfT
,
JsonDeserializationContext
context
)
throws
JsonParseException
{
JsonObject
jsonObject
=
json
.
getAsJsonObject
();
JsonPrimitive
prim
=
(
JsonPrimitive
)
jsonObject
.
get
(
MESSAGETYPE
);
if
(
prim
==
null
)
{
throw
new
JsonParseException
(
"Missing "
+
MESSAGETYPE
+
" in JSON structure"
);
}
Class
<?>
klass
=
null
;
try
{
String
className
=
""
;
if
(
"pacs.008.001"
.
equals
(
prim
.
getAsString
()))
{
className
=
"com.brilliance.swift.vo.VoCustomerCreditTransfer"
;
}
klass
=
Class
.
forName
(
className
);
}
catch
(
ClassNotFoundException
e
)
{
throw
new
JsonParseException
(
"Cannot find MX implementation for "
+
e
.
getMessage
());
}
return
context
.
deserialize
(
json
,
klass
);
}
@Override
public
JsonElement
serialize
(
SwiftDto
src
,
Type
typeOfSrc
,
JsonSerializationContext
context
)
{
JsonObject
object
=
context
.
serialize
(
src
).
getAsJsonObject
();
return
object
;
}
}
swiftCore/src/main/java/com/brilliance/swift/vo/VoCustomerCreditTransfer.java
View file @
c316053e
...
...
@@ -191,9 +191,4 @@ public class VoCustomerCreditTransfer extends SwiftDto {
getRegulatoryReportingList
().
add
(
regulatoryReporting
);
return
this
;
}
@Override
public
String
getMessageType
()
{
return
"pacs.008.001"
;
}
}
swiftCore/src/main/resources/swiftJson/customercredittransfer.txt
0 → 100644
View file @
c316053e
{
"debitDate": "2022-04-21 22:24:00,000",
"creditDate": "2022-04-22 00:30:00,000",
"clsDate": "2022-04-21 23:21:00,000",
"bussinessCode": "SDVA",
"instructionCodes": [
{
"code": "SDVA"
},
{
"code": "BNKK"
},
{
"code": "GHJK",
"additionalInformation": "789556"
}
],
"txnTypeCode": "GCY",
"settledDate": "2022-03-13 00:00:00,000",
"settledCcyFormatAmount": {
"ccy": "USD",
"amt": 23453.13
},
"InstructedCcyFormatAmount": {
"ccy": "EUR",
"amt": 1345.12
},
"exchangeRate": 17.4357135422,
"partyDtos": [
{
"partyType": "OC",
"partyBic": "GCYXXXXXX12",
"partyAcct": "01111001759234567890",
"addressList": []
},
{
"partyType": "OI",
"partyBic": "FOOBARC0",
"addressList": []
},
{
"partyType": "SC",
"partyBic": "FOOBARC1",
"addressList": []
},
{
"partyType": "RC",
"partyBic": "FOOBARC3",
"addressList": []
},
{
"partyType": "RI",
"partyBic": "FOOBARC4",
"addressList": []
},
{
"partyType": "II",
"partyBic": "FOOBARC6",
"addressList": []
},
{
"partyType": "AI",
"partyBic": "BANKANC7",
"addressList": []
},
{
"partyType": "BC",
"partyName": "TEST CORP",
"partyIBANAcct": "00013500510020179998",
"addressList": [
"Nellis ABC, NV"
]
}
],
"remittanceInfos": [
"gechengyang"
],
"chargeFor": "DEBT",
"chargeCcyFormatAmount": {
"ccy": "USD",
"amt": 12.43
},
"senderToReceiverInformations": [
{
"type": "PIA",
"InstructionInformation": "FOOBARC7"
},
{
"type": "IFCA",
"InstructionInformation": "789556"
}
],
"regulatoryReportings": [
"/ORDERRES/BE//MEILAAN 1, 9000 GENT",
"//JIANGXIAQU",
"//WENHUADADAO"
],
"messageType": "pacs.008.001",
"senderBic": "BANKANC0",
"receiverBic": "FOOBARC0",
"createDate": "2022-04-21 17:41:30,705",
"messagePriority": "NORM",
"messageId": "TBEXO12345",
"uetr": "8a562c67-ca16-48ba-b074-65581be6f001"
}
\ No newline at end of file
swiftCore/src/test/java/com/brilliance/mt2mx/pacs008001/TestPacs008001.java
View file @
c316053e
package
com
.
brilliance
.
mt2mx
.
pacs008001
;
import
com.brilliance.swift.mt2mx.Mt2MxCreateManager
;
import
org.apache.commons.io.FileUtils
;
import
java.io.File
;
...
...
@@ -9,7 +8,6 @@ public class TestPacs008001 {
public
static
void
main
(
String
[]
args
)
throws
Exception
{
File
file
=
new
File
(
System
.
getProperty
(
"user.dir"
)+
"\\swiftCore\\src\\main\\resources\\swiftTxt\\MT103.txt"
);
String
mtStr
=
FileUtils
.
readFileToString
(
file
);
String
xmlStr
=
new
Mt2MxCreateManager
().
mt2mx
(
file
,
"d:/test/pacs008.xml"
,
null
);
System
.
out
.
println
(
xmlStr
);
}
...
...
swiftCore/src/test/java/com/brilliance/mx/pacs008001/TestPacs008001_GSON.java
0 → 100644
View file @
c316053e
package
com
.
brilliance
.
mx
.
pacs008001
;
import
com.brilliance.swift.mx.SwiftDto2MxCreatorManager
;
import
java.io.File
;
public
class
TestPacs008001_GSON
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
File
file
=
new
File
(
System
.
getProperty
(
"user.dir"
)+
"\\swiftCore\\src\\main\\resources\\swiftJson\\customercredittransfer.txt"
);
String
xmlStr
=
new
SwiftDto2MxCreatorManager
().
swiftDto2Mx
(
file
,
"d:/test/pacs008_json.xml"
);
System
.
out
.
println
(
xmlStr
);
}
}
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