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
110a897e
Commit
110a897e
authored
Jan 04, 2024
by
gechengyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交JsonMxConvertTest测试类
parent
88a48653
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
123 additions
and
2 deletions
+123
-2
SwiftTransfer.java
...ore/src/main/java/com/brilliance/swift/SwiftTransfer.java
+23
-2
DateUtil.java
...ore/src/main/java/com/brilliance/swift/util/DateUtil.java
+13
-0
xsys01100101.xml
swiftCore/src/main/resources/swiftXml/xsys01100101.xml
+1
-0
xsys01200101.xml
swiftCore/src/main/resources/swiftXml/xsys01200101.xml
+1
-0
JsonMxConvertTest.java
...tCore/src/test/java/com/brilliance/JsonMxConvertTest.java
+83
-0
Mx2MapTest.java
swiftCore/src/test/java/com/brilliance/Mx2MapTest.java
+2
-0
No files found.
swiftCore/src/main/java/com/brilliance/swift/SwiftTransfer.java
View file @
110a897e
...
@@ -10,9 +10,8 @@ import com.brilliance.swift.mx2mt.Mx2MtCreatorManager;
...
@@ -10,9 +10,8 @@ import com.brilliance.swift.mx2mt.Mx2MtCreatorManager;
import
com.brilliance.swift.util.*
;
import
com.brilliance.swift.util.*
;
import
com.brilliance.swift.vo.SwiftTranslationReport
;
import
com.brilliance.swift.vo.SwiftTranslationReport
;
import
com.prowidesoftware.swift.model.MxId
;
import
com.prowidesoftware.swift.model.MxId
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
com.prowidesoftware.swift.model.mx.AbstractMX
;
import
com.prowidesoftware.swift.model.mx.AbstractMX
;
import
com.prowidesoftware.swift.model.mx.AppHdr
;
import
com.prowidesoftware.swift.model.mx.BusinessAppHdrV02
;
import
com.prowidesoftware.swift.model.mx.NamespaceReader
;
import
com.prowidesoftware.swift.model.mx.NamespaceReader
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.FileUtils
;
import
org.dom4j.Document
;
import
org.dom4j.Document
;
...
@@ -428,4 +427,26 @@ public class SwiftTransfer {
...
@@ -428,4 +427,26 @@ public class SwiftTransfer {
return
fetchFinFromMixMessage
(
mixFilePath
);
return
fetchFinFromMixMessage
(
mixFilePath
);
}
}
}
}
public
static
String
json2Mx
(
String
isoJson
){
AbstractMX
abstractMX
=
AbstractMX
.
fromJson
(
isoJson
);
if
(
abstractMX
!=
null
)
return
abstractMX
.
message
();
return
null
;
}
public
static
String
mx2Json
(
String
isoXml
){
AbstractMX
abstractMX
=
AbstractMX
.
parse
(
isoXml
);
if
(
abstractMX
!=
null
)
return
abstractMX
.
toJson
();
return
null
;
}
public
static
AbstractMT
getMt
(
String
mtStr
)
throws
IOException
{
AbstractMT
abstractMT
=
AbstractMT
.
parse
(
mtStr
);
//MT103 mt103= (MT103) abstractMT;
return
abstractMT
;
}
}
}
swiftCore/src/main/java/com/brilliance/swift/util/DateUtil.java
View file @
110a897e
...
@@ -21,6 +21,8 @@ public class DateUtil {
...
@@ -21,6 +21,8 @@ public class DateUtil {
public
static
String
defaultFormate
=
"yyyy-MM-dd HH:mm:ss,SSS"
;
// 默认的日期格式
public
static
String
defaultFormate
=
"yyyy-MM-dd HH:mm:ss,SSS"
;
// 默认的日期格式
public
static
String
defaultISOFormate
=
"yyyy-MM-dd HH:mm:ss"
;
/***
/***
* @param paramDate
* @param paramDate
* 日期
* 日期
...
@@ -199,6 +201,17 @@ public class DateUtil {
...
@@ -199,6 +201,17 @@ public class DateUtil {
return
xgc
;
return
xgc
;
}
}
public
static
String
date2XMLGregorianCalendarStr
(
String
date
)
throws
ParseException
,
DatatypeConfigurationException
{
return
date2XMLGregorianCalendarStr
(
date
,
defaultISOFormate
);
}
public
static
String
date2XMLGregorianCalendarStr
(
String
date
,
String
format
)
throws
ParseException
,
DatatypeConfigurationException
{
if
(
StringUtil
.
isEmpty
(
format
))
format
=
defaultISOFormate
;
String
xmlGregorianCalendarStr
=
DateUtil
.
parseXMLGregorianCalendar
(
DateUtil
.
parseDate
(
date
,
format
)).
toXMLFormat
();
return
xmlGregorianCalendarStr
;
}
public
static
XMLGregorianCalendar
parseXMLGregorianCalendarOfUTC
(
Date
date
)
throws
ParseException
,
DatatypeConfigurationException
{
public
static
XMLGregorianCalendar
parseXMLGregorianCalendarOfUTC
(
Date
date
)
throws
ParseException
,
DatatypeConfigurationException
{
GregorianCalendar
gc
=
new
GregorianCalendar
();
GregorianCalendar
gc
=
new
GregorianCalendar
();
// 获取当前默认时区
// 获取当前默认时区
...
...
swiftCore/src/main/resources/swiftXml/xsys01100101.xml
View file @
110a897e
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
>
>
<Doc:xsys.011.001.01>
<Doc:xsys.011.001.01>
<Doc:DlvryNtfctn>
<Doc:DlvryNtfctn>
<Sw:OrigSnFRef>
REF00001
</Sw:OrigSnFRef>
<Sw:SnFRef>
swi00001-2010-05-04T15:31:37.22284.11144096Z
</Sw:SnFRef>
<Sw:SnFRef>
swi00001-2010-05-04T15:31:37.22284.11144096Z
</Sw:SnFRef>
<Sw:SnFRefType>
InterAct
</Sw:SnFRefType>
<Sw:SnFRefType>
InterAct
</Sw:SnFRefType>
<Sw:AcceptStatus>
Accepted
</Sw:AcceptStatus>
<Sw:AcceptStatus>
Accepted
</Sw:AcceptStatus>
...
...
swiftCore/src/main/resources/swiftXml/xsys01200101.xml
View file @
110a897e
...
@@ -37,6 +37,7 @@
...
@@ -37,6 +37,7 @@
>
>
<Doc:xsys.012.001.01>
<Doc:xsys.012.001.01>
<Doc:DlvryNtfctn>
<Doc:DlvryNtfctn>
<Sw:OrigSnFRef>
REF00001
</Sw:OrigSnFRef>
<Sw:SnFRef>
swi00001-2010-05-04T15:32:59.21582.11198379Z
</Sw:SnFRef>
<Sw:SnFRef>
swi00001-2010-05-04T15:32:59.21582.11198379Z
</Sw:SnFRef>
<Sw:SnFRefType>
InterAct
</Sw:SnFRefType>
<Sw:SnFRefType>
InterAct
</Sw:SnFRefType>
<Sw:AcceptStatus>
Failed
</Sw:AcceptStatus>
<Sw:AcceptStatus>
Failed
</Sw:AcceptStatus>
...
...
swiftCore/src/test/java/com/brilliance/JsonMxConvertTest.java
0 → 100644
View file @
110a897e
package
com
.
brilliance
;
import
com.brilliance.swift.SwiftTransfer
;
import
com.brilliance.swift.util.DateUtil
;
import
com.prowidesoftware.swift.model.mt.AbstractMT
;
import
com.prowidesoftware.swift.model.mt1xx.MT103
;
import
com.prowidesoftware.swift.model.mt1xx.MT103_STP
;
import
org.apache.commons.io.FileUtils
;
import
org.junit.Test
;
import
javax.xml.datatype.DatatypeConfigurationException
;
import
java.io.File
;
import
java.io.IOException
;
import
java.text.DateFormat
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.TimeZone
;
public
class
JsonMxConvertTest
{
@Test
public
void
json2MxTest
()
throws
IOException
{
File
file
=
FileUtils
.
toFile
(
Mx2MtTest
.
class
.
getResource
(
"/mxjson/JSONpacs00800108.json"
));
String
isoXml
=
SwiftTransfer
.
json2Mx
(
FileUtils
.
readFileToString
(
file
,
"UTF-8"
));
System
.
out
.
println
(
isoXml
);
}
@Test
public
void
mx2JsonTest
()
throws
IOException
{
File
file
=
FileUtils
.
toFile
(
Mx2MtTest
.
class
.
getResource
(
"/mxjson/Pacs00800108.xml"
));
String
isoJson
=
SwiftTransfer
.
mx2Json
(
FileUtils
.
readFileToString
(
file
,
"UTF-8"
));
System
.
out
.
println
(
isoJson
);
}
@Test
public
void
dateFormatTest
()
throws
DatatypeConfigurationException
,
ParseException
{
String
date
=
"2023-12-10 20:10:11"
;
String
isoDateTime
=
DateUtil
.
date2XMLGregorianCalendarStr
(
date
);
System
.
out
.
println
(
isoDateTime
);
}
@Test
public
void
testDate
(){
TimeZone
timezone
=
TimeZone
.
getTimeZone
(
"UTC"
);
//"Z" indicates UTC, which means no timezone offset
//2024-01-03T07:06:36.496+08:00
//标准的ISO 8601日期格式 yyyy-MM-ddThh:mm:ss.sss+/-hh:mm
// 发报时,采用东八区时间,样例如2024-01-03T07:06:36.496+08:00
DateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss.SSS"
);
dateFormat
.
setTimeZone
(
timezone
);
String
ISODate
=
dateFormat
.
format
(
new
Date
());
System
.
out
.
println
(
ISODate
+
"+08:00"
);
}
@Test
public
void
testMt
()
throws
IOException
{
File
file
=
FileUtils
.
toFile
(
Mx2MtTest
.
class
.
getResource
(
"/swiftTxt/MT103.txt"
));
String
mtStr
=
FileUtils
.
readFileToString
(
file
,
"UTF-8"
);
AbstractMT
abstractMT
=
AbstractMT
.
parse
(
mtStr
);
if
(
abstractMT
!=
null
)
{
String
mtType
=
abstractMT
.
getMessageType
();
if
(
"103"
.
equals
(
mtType
))
{
if
(
abstractMT
.
getSwiftMessage
().
getBlock3
().
isSTP
())
{
MT103_STP
mt103Stp
=
(
MT103_STP
)
abstractMT
;
System
.
out
.
println
(
"this is mt103_stp"
);
System
.
out
.
println
(
mt103Stp
.
message
());
}
else
{
MT103
mt103
=
(
MT103
)
abstractMT
;
System
.
out
.
println
(
"this is mt103"
);
System
.
out
.
println
(
mt103
.
message
());
}
}
}
}
}
swiftCore/src/test/java/com/brilliance/Mx2MapTest.java
View file @
110a897e
...
@@ -15,6 +15,7 @@ import java.util.Map;
...
@@ -15,6 +15,7 @@ import java.util.Map;
*/
*/
public
class
Mx2MapTest
{
public
class
Mx2MapTest
{
/**
/**
* 如果origSnFRef=xsys01100101.dlvryNtfctn.origSnFRef不为空则origSnFRef,否则snFRef=xsys01100101.dlvryNtfctn.snFRef
* ack报文
* ack报文
*
*
* @throws IOException
* @throws IOException
...
@@ -28,6 +29,7 @@ public class Mx2MapTest {
...
@@ -28,6 +29,7 @@ public class Mx2MapTest {
}
}
/**
/**
*如果origSnFRef=xsys01100101.dlvryNtfctn.origSnFRef不为空则origSnFRef,否则snFRef=xsys01100101.dlvryNtfctn.snFRef
* nck报文
* nck报文
*
*
* @throws IOException
* @throws IOException
...
...
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