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
6d855680
Commit
6d855680
authored
Jul 05, 2022
by
chengzhuoshen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mx转900,910,940,950的转换详细报告
parent
8e808049
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
434 additions
and
93 deletions
+434
-93
Mx2MtCreatorManager.java
.../java/com/brilliance/swift/mx2mt/Mx2MtCreatorManager.java
+1
-1
Field71AGenerate.java
...m/brilliance/swift/mx2mt/mt103/impl/Field71AGenerate.java
+3
-0
Field71AGenerate.java
...illiance/swift/mx2mt/mt103Retn/impl/Field71AGenerate.java
+3
-0
Mx2Mt900910Creator.java
...m/brilliance/swift/mx2mt/mt900910/Mx2Mt900910Creator.java
+23
-0
Field20Generate.java
...brilliance/swift/mx2mt/mt900910/impl/Field20Generate.java
+8
-6
Field21Generate.java
...brilliance/swift/mx2mt/mt900910/impl/Field21Generate.java
+13
-7
Field32AGenerate.java
...rilliance/swift/mx2mt/mt900910/impl/Field32AGenerate.java
+4
-0
Field50aGenerate.java
...rilliance/swift/mx2mt/mt900910/impl/Field50aGenerate.java
+19
-0
Field52aFor900Generate.java
...nce/swift/mx2mt/mt900910/impl/Field52aFor900Generate.java
+13
-0
Field52aFor910Generate.java
...nce/swift/mx2mt/mt900910/impl/Field52aFor910Generate.java
+28
-0
Field56aGenerate.java
...rilliance/swift/mx2mt/mt900910/impl/Field56aGenerate.java
+2
-0
Field72Generate.java
...brilliance/swift/mx2mt/mt900910/impl/Field72Generate.java
+3
-0
Field20Generate.java
...om/brilliance/swift/mx2mt/mt920/impl/Field20Generate.java
+1
-0
Mx2Mt940950Creator.java
...m/brilliance/swift/mx2mt/mt940950/Mx2Mt940950Creator.java
+42
-0
Field20Generate.java
...brilliance/swift/mx2mt/mt940950/impl/Field20Generate.java
+7
-5
Field60Generate.java
...brilliance/swift/mx2mt/mt940950/impl/Field60Generate.java
+52
-30
Field61Generate.java
...brilliance/swift/mx2mt/mt940950/impl/Field61Generate.java
+13
-0
Field62Generate.java
...brilliance/swift/mx2mt/mt940950/impl/Field62Generate.java
+50
-32
Field64Generate.java
...brilliance/swift/mx2mt/mt940950/impl/Field64Generate.java
+9
-1
Field65Generate.java
...brilliance/swift/mx2mt/mt940950/impl/Field65Generate.java
+4
-0
Field86Generate.java
...brilliance/swift/mx2mt/mt940950/impl/Field86Generate.java
+3
-0
Mx2MtN99Creator.java
...ava/com/brilliance/swift/mx2mt/mtn99/Mx2MtN99Creator.java
+10
-0
Field20Generate.java
...om/brilliance/swift/mx2mt/mtn99/impl/Field20Generate.java
+7
-5
Field79Generate.java
...om/brilliance/swift/mx2mt/mtn99/impl/Field79Generate.java
+3
-0
NumberUtil.java
...e/src/main/java/com/brilliance/swift/util/NumberUtil.java
+10
-0
EntryStatusCode.java
.../java/com/brilliance/swift/vo/common/EntryStatusCode.java
+16
-0
PaymentTransactionStatusCode.java
...lliance/swift/vo/common/PaymentTransactionStatusCode.java
+39
-0
TestMx2MtFor950.java
...test/java/com/brilliance/mx2mt/mt950/TestMx2MtFor950.java
+23
-2
Test.java
swiftCore/src/test/java/com/brilliance/mx2mt/mtn99/Test.java
+25
-4
No files found.
swiftCore/src/main/java/com/brilliance/swift/mx2mt/Mx2MtCreatorManager.java
View file @
6d855680
...
...
@@ -55,7 +55,7 @@ public class Mx2MtCreatorManager {
}
}
context
.
putAll
(
extraMap
);
context
.
set
(
Mx2MtConstants
.
APPLICATION_MODE
,
applicationMode
);
context
.
set
(
Mx2MtConstants
.
APPLICATION_MODE
,
StringUtil
.
isEmpty
(
applicationMode
)?
"O"
:
applicationMode
);
AbstractMx2MtCreator
creator
=
getCreator
(
handlingMessageType
(
document
,
messageType
));
creator
.
setContext
(
context
);
creator
.
preProcess
();
...
...
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt103/impl/Field71AGenerate.java
View file @
6d855680
...
...
@@ -62,6 +62,9 @@ public class Field71AGenerate extends AbstractMx2MtTagsGenerate {
}
}
}
if
(
NumberUtil
.
judgeAmtStrExceedLength
(
sumAmt
.
toString
(),
14
))
{
buildSTErrorInfo
(
ERROR
.
T20039
,
"Block4/:"
+
name_G
+
":"
,
sumAmt
.
toString
());
}
//mapping转换文档 Translation Post Conditions -> POSTC006
String
intrBkSttlmAmtCcy
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"CdtTrfTxInf.IntrBkSttlmAmt@Ccy"
);
if
(
ccy
.
equals
(
intrBkSttlmAmtCcy
))
{
...
...
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt103Retn/impl/Field71AGenerate.java
View file @
6d855680
...
...
@@ -62,6 +62,9 @@ public class Field71AGenerate extends AbstractMx2MtTagsGenerate {
}
}
}
if
(
NumberUtil
.
judgeAmtStrExceedLength
(
sumAmt
.
toString
(),
14
))
{
buildSTErrorInfo
(
ERROR
.
T20039
,
"Block4/:"
+
name_G
+
":"
,
sumAmt
.
toString
());
}
//mapping转换文档 Translation Post Conditions -> POSTC003
String
intrBkSttlmAmtCcy
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"CdtTrfTxInf.IntrBkSttlmAmt@Ccy"
);
if
(
ccy
.
equals
(
intrBkSttlmAmtCcy
))
{
...
...
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt900910/Mx2Mt900910Creator.java
View file @
6d855680
package
com
.
brilliance
.
swift
.
mx2mt
.
mt900910
;
import
com.brilliance.swift.constants.ERROR
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtCreator
;
import
com.brilliance.swift.mx2mt.Mx2MtContextIdentifier
;
import
com.brilliance.swift.mx2mt.Mx2MtTagsGenerate
;
import
com.brilliance.swift.mx2mt.mt900910.impl.*
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.util.XmlUtil
;
import
com.brilliance.swift.vo.common.EntryStatusCode
;
import
com.prowidesoftware.swift.model.mx.dic.CreditDebitCode
;
import
org.dom4j.Document
;
...
...
@@ -23,6 +26,26 @@ public class Mx2Mt900910Creator extends AbstractMx2MtCreator {
context
.
set
(
Mx2MtContextIdentifier
.
APPHDR_PARENT_ELEMENT_NAME
,
parentElementMaps
.
get
(
"AppHdr"
));
context
.
set
(
Mx2MtContextIdentifier
.
GRPHDR_PARENT_ELEMENT_NAME
,
parentElementMaps
.
get
(
"GrpHdr"
));
context
.
set
(
Mx2MtContextIdentifier
.
BODY_PARENT_ELEMENT_NAME
,
parentElementMaps
.
get
(
"Ntfctn"
));
String
bodyParentPath
=
parentElementMaps
.
get
(
"Ntfctn"
);
//Translation Preconditions/PREC001
int
ntfctnCount
=
getXmlNodeCounts
(
bodyParentPath
,
document
,
"Ntfctn"
);
int
entryCount
=
getXmlNodeCounts
(
bodyParentPath
,
document
,
"Ntfctn.Ntry"
);
int
entryDetailsCount
=
getXmlNodeCounts
(
bodyParentPath
,
document
,
"Ntfctn.Ntry.NtryDtls"
);
int
txnDetailsCount
=
getXmlNodeCounts
(
bodyParentPath
,
document
,
"Ntfctn.Ntry.NtryDtls.TxDtls"
);
if
(
ntfctnCount
>
1
||
entryCount
>
1
||
entryDetailsCount
>
1
||
txnDetailsCount
>
1
)
{
buildSTErrorInfo
(
ERROR
.
T20053
,
"TranslationPrecondition"
,
null
);
}
//Translation Preconditions/PREC002
String
status
=
getXmlNodeValue
(
bodyParentPath
,
document
,
"Ntfctn.Ntry.Sts.Cd"
);
if
(!
EntryStatusCode
.
BOOK
.
value
().
equals
(
status
))
{
buildSTErrorInfo
(
ERROR
.
T20038
,
"TranslationPrecondition"
,
null
);
}
//Translation Preconditions/PREC005
String
valueDateStr
=
getXmlNodeValue
(
bodyParentPath
,
document
,
"Ntfctn.Ntry.ValDt.Dt"
);
String
setlDateStr
=
getXmlNodeValue
(
bodyParentPath
,
document
,
"Ntfctn.Ntry.NtryDtls.TxDtls.RltdDts.IntrBkSttlmDt"
);
if
(
StringUtil
.
isEmpty
(
valueDateStr
)
&&
StringUtil
.
isEmpty
(
setlDateStr
))
{
buildSTErrorInfo
(
ERROR
.
T20078
,
"TranslationPrecondition"
,
null
);
}
}
@Override
...
...
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt900910/impl/Field20Generate.java
View file @
6d855680
package
com
.
brilliance
.
swift
.
mx2mt
.
mt900910
.
impl
;
import
com.brilliance.swift.constants.ERROR
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
...
...
@@ -22,14 +23,15 @@ public class Field20Generate extends AbstractMx2MtTagsGenerate {
List
<
Tag
>
tags
=
swiftMessage
.
getBlock4
().
getTags
();
String
messageId
=
getXmlNodeValue
(
grpHdrParentElementName
,
document
,
"GrpHdr.MsgId"
);
if
(
StringUtil
.
isNotEmpty
(
messageId
))
{
String
value
=
""
;
if
(
messageId
.
length
()
>
16
)
{
value
=
messageId
.
substring
(
0
,
15
)
+
"+"
;
if
(
messageId
.
startsWith
(
"/"
)
||
messageId
.
endsWith
(
"/"
)
||
messageId
.
contains
(
"//"
))
{
buildSTErrorInfo
(
ERROR
.
T20051
,
"Block4/:20:"
,
messageId
);
messageId
=
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
;
}
if
(
value
.
startsWith
(
"/"
)
||
value
.
endsWith
(
"/"
)
||
value
.
contains
(
"//"
))
{
value
=
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
;
if
(
messageId
.
length
()
>
16
)
{
buildSTErrorInfo
(
ERROR
.
T0000T
,
"Block4/:20:"
,
messageId
);
messageId
=
messageId
.
substring
(
0
,
15
)
+
"+"
;
}
tags
.
add
(
new
Tag
(
name
,
value
));
tags
.
add
(
new
Tag
(
name
,
messageId
));
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt900910/impl/Field21Generate.java
View file @
6d855680
package
com
.
brilliance
.
swift
.
mx2mt
.
mt900910
.
impl
;
import
com.brilliance.swift.constants.ERROR
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
import
com.brilliance.swift.util.StringUtil
;
...
...
@@ -22,16 +24,20 @@ public class Field21Generate extends AbstractMx2MtTagsGenerate {
String
endToEndId
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Ntfctn.Ntry.NtryDtls.TxDtls.Refs.EndToEndId"
);
String
instructionId
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Ntfctn.Ntry.NtryDtls.TxDtls.Refs.InstrId"
);
String
value
=
""
;
if
(
StringUtil
.
isNotEmpty
(
instruction
Id
))
{
value
=
instructionId
;
if
(
instructionId
.
length
()
>
16
)
{
value
=
instruction
Id
.
substring
(
0
,
15
)
+
"+"
;
if
(
StringUtil
.
isNotEmpty
(
endToEnd
Id
))
{
if
(
endToEndId
.
length
()
>
16
)
{
buildSTErrorInfo
(
ERROR
.
T0000T
,
"Block4/:21:"
,
endToEndId
);
endToEndId
=
endToEnd
Id
.
substring
(
0
,
15
)
+
"+"
;
}
}
else
if
(
StringUtil
.
isNotEmpty
(
endToEndId
))
{
value
=
endToEndId
;
if
(
endToEndId
.
length
()
>
16
)
{
value
=
endToEndId
.
substring
(
0
,
15
)
+
"+"
;
}
else
if
(
StringUtil
.
isNotEmpty
(
instructionId
))
{
if
(
instructionId
.
length
()
>
16
)
{
buildSTErrorInfo
(
ERROR
.
T0000T
,
"Block4/:21:"
,
instructionId
);
instructionId
=
instructionId
.
substring
(
0
,
15
)
+
"+"
;
}
value
=
instructionId
;
}
else
{
value
=
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
;
}
if
(
StringUtil
.
isNotEmpty
(
value
))
{
tags
.
add
(
new
Tag
(
name
,
value
));
...
...
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt900910/impl/Field32AGenerate.java
View file @
6d855680
package
com
.
brilliance
.
swift
.
mx2mt
.
mt900910
.
impl
;
import
com.brilliance.swift.constants.ERROR
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
import
com.brilliance.swift.util.DateUtil
;
...
...
@@ -41,6 +42,9 @@ public class Field32AGenerate extends AbstractMx2MtTagsGenerate {
String
amt
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Ntfctn.Ntry.Amt"
);
String
ccy
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Ntfctn.Ntry.Amt@Ccy"
);
if
(
StringUtil
.
isNotEmpty
(
amt
)
&&
StringUtil
.
isNotEmpty
(
ccy
))
{
if
(
NumberUtil
.
judgeAmtStrExceedLength
(
amt
,
14
))
{
buildSTErrorInfo
(
ERROR
.
T20066
,
"Block4/:32A:"
,
amt
);
}
intrBkSttlmAmt
=
NumberUtil
.
formatAmt
(
new
BigDecimal
(
amt
),
ccy
);
intrBkSttlmccy
=
ccy
;
}
...
...
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt900910/impl/Field50aGenerate.java
View file @
6d855680
package
com
.
brilliance
.
swift
.
mx2mt
.
mt900910
.
impl
;
import
com.brilliance.swift.constants.ERROR
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
import
com.brilliance.swift.mx2mt.Mx2MtContextIdentifier
;
import
com.brilliance.swift.util.StringUtil
;
import
com.prowidesoftware.swift.model.SwiftMessage
;
import
com.prowidesoftware.swift.model.Tag
;
...
...
@@ -30,6 +32,7 @@ public class Field50aGenerate extends AbstractMx2MtTagsGenerate {
@Override
public
void
tagGenerate
()
throws
SwiftException
{
context
.
set
(
Mx2MtContextIdentifier
.
MX_TO_MT_ERROR_LOCATION
,
"Block4/50a"
);
SwiftMessage
swiftMessage
=
context
.
get
(
SwiftMessage
.
class
);
List
<
Tag
>
tags
=
swiftMessage
.
getBlock4
().
getTags
();
String
cdtDbtInd
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Ntfctn.Ntry.CdtDbtInd"
);
...
...
@@ -95,6 +98,14 @@ public class Field50aGenerate extends AbstractMx2MtTagsGenerate {
value
=
mtNameAddress
;
}
tags
.
add
(
new
Tag
(
name_K
,
value
));
}
else
{
buildSTErrorInfo
(
ERROR
.
T20043
,
"Block4/50a"
,
null
);
if
(
StringUtil
.
isNotEmpty
(
account
))
{
value
=
account
+
Mx2MtConstants
.
NEW_LINE
+
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
;
}
else
{
value
=
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
;
}
tags
.
add
(
new
Tag
(
name_K
,
value
));
}
if
(
StringUtil
.
isEmpty
(
value
))
{
bicCode
=
mx_to_mtBICFI
(
bodyHdrParentElementName
+
".Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.Dbtr.Agt"
);
...
...
@@ -116,6 +127,14 @@ public class Field50aGenerate extends AbstractMx2MtTagsGenerate {
mtNameAddress
=
mx_to_mtFinancialInstitutionNameAndStructuredAddress
(
bodyHdrParentElementName
+
".Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.Dbtr.Agt.FinInstnId"
,
false
);
}
else
if
(
StringUtil
.
isNotEmpty
(
name
))
{
mtNameAddress
=
mx_to_mtFinancialInstitutionNameAndUnstructuredAddress
(
bodyHdrParentElementName
+
".Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.Dbtr.Agt.FinInstnId"
);
}
else
{
mtNameAddress
=
mx_to_mtClearingIdentifier
(
bodyHdrParentElementName
+
".Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.Dbtr.Agt"
);
if
(
StringUtil
.
isNotEmpty
(
mtNameAddress
))
{
if
(
StringUtil
.
isEmpty
(
account
))
{
account
=
"/"
+
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
;
}
buildSTErrorInfo
(
ERROR
.
T20097
,
"Block4/50a"
,
null
);
}
}
if
(
StringUtil
.
isEmpty
(
mtNameAddress
))
return
;
//如果name和地址不存在,返回。
if
(
StringUtil
.
isNotEmpty
(
account
))
{
...
...
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt900910/impl/Field52aFor900Generate.java
View file @
6d855680
package
com
.
brilliance
.
swift
.
mx2mt
.
mt900910
.
impl
;
import
com.brilliance.swift.constants.ERROR
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
import
com.brilliance.swift.mx2mt.Mx2MtContextIdentifier
;
import
com.brilliance.swift.util.StringUtil
;
import
com.prowidesoftware.swift.model.SwiftMessage
;
import
com.prowidesoftware.swift.model.Tag
;
...
...
@@ -19,6 +21,7 @@ public class Field52aFor900Generate extends AbstractMx2MtTagsGenerate {
@Override
public
void
tagGenerate
()
throws
SwiftException
{
context
.
set
(
Mx2MtContextIdentifier
.
MX_TO_MT_ERROR_LOCATION
,
"Block4/52a"
);
SwiftMessage
swiftMessage
=
context
.
get
(
SwiftMessage
.
class
);
List
<
Tag
>
tags
=
swiftMessage
.
getBlock4
().
getTags
();
String
cdtDbtInd
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Ntfctn.Ntry.CdtDbtInd"
);
...
...
@@ -53,6 +56,10 @@ public class Field52aFor900Generate extends AbstractMx2MtTagsGenerate {
value
=
mtClearSystemId
+
Mx2MtConstants
.
NEW_LINE
+
mtNameAddress
;
}
else
{
value
=
mtNameAddress
;
if
(
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
.
equals
(
value
))
{
buildSTErrorInfo
(
ERROR
.
T20064
,
"Block4/52a"
,
null
);
return
;
}
}
tags
.
add
(
new
Tag
(
name_D
,
value
));
}
...
...
@@ -66,6 +73,7 @@ public class Field52aFor900Generate extends AbstractMx2MtTagsGenerate {
}
else
{
value
=
bicCode
;
}
buildSTErrorInfo
(
ERROR
.
T20202
,
"Block4/52a"
,
null
);
tags
.
add
(
new
Tag
(
name_A
,
value
));
}
else
{
String
name
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Ntfctn.Ntry.NtryDtls.TxDtls.RltdPties.Dbtr.Agt.FinInstnId.Nm"
);
...
...
@@ -84,7 +92,12 @@ public class Field52aFor900Generate extends AbstractMx2MtTagsGenerate {
value
=
account
+
Mx2MtConstants
.
NEW_LINE
+
mtNameAddress
;
}
else
{
value
=
mtNameAddress
;
if
(
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
.
equals
(
value
))
{
buildSTErrorInfo
(
ERROR
.
T20064
,
"Block4/52a"
,
null
);
return
;
}
}
buildSTErrorInfo
(
ERROR
.
T20202
,
"Block4/52a"
,
null
);
tags
.
add
(
new
Tag
(
name_D
,
value
));
}
}
...
...
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt900910/impl/Field52aFor910Generate.java
View file @
6d855680
package
com
.
brilliance
.
swift
.
mx2mt
.
mt900910
.
impl
;
import
com.brilliance.swift.constants.ERROR
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
import
com.brilliance.swift.mx2mt.Mx2MtContextIdentifier
;
import
com.brilliance.swift.util.StringUtil
;
import
com.prowidesoftware.swift.model.SwiftMessage
;
import
com.prowidesoftware.swift.model.Tag
;
...
...
@@ -20,6 +22,7 @@ public class Field52aFor910Generate extends AbstractMx2MtTagsGenerate {
@Override
public
void
tagGenerate
()
throws
SwiftException
{
context
.
set
(
Mx2MtContextIdentifier
.
MX_TO_MT_ERROR_LOCATION
,
"Block4/52a"
);
SwiftMessage
swiftMessage
=
context
.
get
(
SwiftMessage
.
class
);
List
<
Tag
>
tags
=
swiftMessage
.
getBlock4
().
getTags
();
String
cdtDbtInd
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Ntfctn.Ntry.CdtDbtInd"
);
...
...
@@ -54,8 +57,33 @@ public class Field52aFor910Generate extends AbstractMx2MtTagsGenerate {
value
=
mtClearSystemId
+
Mx2MtConstants
.
NEW_LINE
+
mtNameAddress
;
}
else
{
value
=
mtNameAddress
;
if
(
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
.
equals
(
value
)
&&
exist50a
(
tags
))
{
buildSTErrorInfo
(
ERROR
.
T20064
,
"Block4/52a"
,
null
);
return
;
}
}
tags
.
add
(
new
Tag
(
name_D
,
value
));
}
}
/**
* 判断是否存在50a
* @param tags
* @return
*/
private
boolean
exist50a
(
List
<
Tag
>
tags
)
{
boolean
flag
=
false
;
if
(
tags
!=
null
&&
tags
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
tags
.
size
();
i
++)
{
Tag
tag
=
tags
.
get
(
i
);
if
(
"50A"
.
equals
(
tag
.
getName
())
||
"50F"
.
equals
(
tag
.
getName
())
||
"50K"
.
equals
(
tag
.
getName
()))
{
flag
=
true
;
break
;
}
}
}
return
flag
;
}
}
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt900910/impl/Field56aGenerate.java
View file @
6d855680
...
...
@@ -3,6 +3,7 @@ package com.brilliance.swift.mx2mt.mt900910.impl;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
import
com.brilliance.swift.mx2mt.Mx2MtContextIdentifier
;
import
com.brilliance.swift.util.StringUtil
;
import
com.prowidesoftware.swift.model.SwiftMessage
;
import
com.prowidesoftware.swift.model.Tag
;
...
...
@@ -19,6 +20,7 @@ public class Field56aGenerate extends AbstractMx2MtTagsGenerate {
@Override
public
void
tagGenerate
()
throws
SwiftException
{
context
.
set
(
Mx2MtContextIdentifier
.
MX_TO_MT_ERROR_LOCATION
,
"Block4/56a"
);
SwiftMessage
swiftMessage
=
context
.
get
(
SwiftMessage
.
class
);
List
<
Tag
>
tags
=
swiftMessage
.
getBlock4
().
getTags
();
String
cdtDbtInd
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Ntfctn.Ntry.CdtDbtInd"
);
...
...
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt900910/impl/Field72Generate.java
View file @
6d855680
package
com
.
brilliance
.
swift
.
mx2mt
.
mt900910
.
impl
;
import
com.brilliance.swift.constants.ERROR
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
import
com.brilliance.swift.util.StringUtil
;
...
...
@@ -19,9 +20,11 @@ public class Field72Generate extends AbstractMx2MtTagsGenerate {
String
additionalTxnInf
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Ntfctn.Ntry.NtryDtls.TxDtls.AddtlTxInf"
);
if
(
StringUtil
.
isNotEmpty
(
additionalTxnInf
))
{
if
(
additionalTxnInf
.
length
()
>
210
)
{
buildSTErrorInfo
(
ERROR
.
T0000T
,
"Block4/:72:"
,
additionalTxnInf
);
additionalTxnInf
=
additionalTxnInf
.
substring
(
0
,
209
)
+
"+"
;
}
String
value
=
StringUtil
.
getStringByEnter
(
additionalTxnInf
,
35
,
6
);
value
=
mx_to_mtStartingLineCharacter
(
value
,
"Block4/:72:"
);
tags
.
add
(
new
Tag
(
name
,
value
));
}
}
...
...
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt920/impl/Field20Generate.java
View file @
6d855680
...
...
@@ -28,6 +28,7 @@ public class Field20Generate extends AbstractMx2MtTagsGenerate {
messageId
=
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
;
}
if
(
messageId
.
length
()
>
16
)
{
buildSTErrorInfo
(
ERROR
.
T0000T
,
"Block4/:20:"
,
messageId
);
messageId
=
messageId
.
substring
(
0
,
15
)
+
"+"
;
}
tags
.
add
(
new
Tag
(
NAME
,
messageId
));
...
...
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt940950/Mx2Mt940950Creator.java
View file @
6d855680
package
com
.
brilliance
.
swift
.
mx2mt
.
mt940950
;
import
com.brilliance.swift.constants.ERROR
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtCreator
;
import
com.brilliance.swift.mx2mt.Mx2MtContextIdentifier
;
import
com.brilliance.swift.mx2mt.Mx2MtTagsGenerate
;
import
com.brilliance.swift.mx2mt.mt940950.impl.*
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.util.XmlUtil
;
import
com.brilliance.swift.vo.common.BalanceTypeCode
;
import
org.dom4j.Document
;
import
java.util.ArrayList
;
...
...
@@ -23,6 +26,45 @@ public class Mx2Mt940950Creator extends AbstractMx2MtCreator {
context
.
set
(
Mx2MtContextIdentifier
.
APPHDR_PARENT_ELEMENT_NAME
,
parentElementMaps
.
get
(
"AppHdr"
));
context
.
set
(
Mx2MtContextIdentifier
.
GRPHDR_PARENT_ELEMENT_NAME
,
parentElementMaps
.
get
(
"GrpHdr"
));
context
.
set
(
Mx2MtContextIdentifier
.
BODY_PARENT_ELEMENT_NAME
,
parentElementMaps
.
get
(
"Stmt"
));
String
bodyParentPath
=
parentElementMaps
.
get
(
"Stmt"
);
//Translation Preconditions/PREC001
String
lglSeqNbStr
=
getXmlNodeValue
(
bodyParentPath
,
document
,
"Stmt.LglSeqNb"
);
String
elctrncSeqNbStr
=
getXmlNodeValue
(
bodyParentPath
,
document
,
"Stmt.ElctrncSeqNb"
);
if
(
StringUtil
.
isEmpty
(
lglSeqNbStr
)
||
lglSeqNbStr
.
length
()
>
5
)
{
if
(
StringUtil
.
isEmpty
(
elctrncSeqNbStr
)
||
elctrncSeqNbStr
.
length
()
>
5
)
{
buildSTErrorInfo
(
ERROR
.
T20103
,
"TranslationPrecondition"
,
null
);
}
}
//Translation Preconditions/PREC007
int
entryCount
=
getXmlNodeCounts
(
bodyParentPath
,
document
,
"Stmt.Ntry"
);
if
(
entryCount
>
190
)
{
buildSTErrorInfo
(
ERROR
.
T20110
,
"TranslationPrecondition"
,
null
);
}
//Translation Preconditions/PREC009
int
balanceTypeCount
=
getXmlNodeCounts
(
bodyParentPath
,
document
,
"Stmt.Bal"
);
int
index
=
-
1
;
if
(
balanceTypeCount
>
0
)
{
for
(
int
i
=
0
;
i
<
balanceTypeCount
;
i
++)
{
String
balanceType
=
getXmlNodeValue
(
bodyParentPath
,
document
,
"Stmt.Bal("
+
i
+
").Tp.CdOrPrtry.Cd"
);
if
(
BalanceTypeCode
.
OPBD
.
value
().
equals
(
balanceType
))
{
index
=
i
;
}
}
if
(
index
>
-
1
)
{
String
opbdCcy
=
getXmlNodeValue
(
bodyParentPath
,
document
,
"Stmt.Bal("
+
index
+
").Amt@Ccy"
);
for
(
int
i
=
0
;
i
<
balanceTypeCount
;
i
++)
{
String
balanceType
=
getXmlNodeValue
(
bodyParentPath
,
document
,
"Stmt.Bal("
+
i
+
").Tp.CdOrPrtry.Cd"
);
if
(
BalanceTypeCode
.
CLBD
.
value
().
equals
(
balanceType
)
||
BalanceTypeCode
.
CLAV
.
value
().
equals
(
balanceType
)
||
BalanceTypeCode
.
FWAV
.
value
().
equals
(
balanceType
))
{
String
balanceCcy
=
getXmlNodeValue
(
bodyParentPath
,
document
,
"Stmt.Bal("
+
i
+
").Amt@Ccy"
);
if
(
StringUtil
.
isNotEmpty
(
opbdCcy
)
&&
StringUtil
.
isNotEmpty
(
balanceCcy
)
&&
!
opbdCcy
.
substring
(
0
,
2
).
equals
(
balanceCcy
.
substring
(
0
,
2
)))
{
buildSTErrorInfo
(
ERROR
.
T20111
,
"TranslationPrecondition"
,
null
);
}
}
}
}
}
}
@Override
...
...
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt940950/impl/Field20Generate.java
View file @
6d855680
package
com
.
brilliance
.
swift
.
mx2mt
.
mt940950
.
impl
;
import
com.brilliance.swift.constants.ERROR
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
...
...
@@ -21,14 +22,15 @@ public class Field20Generate extends AbstractMx2MtTagsGenerate {
List
<
Tag
>
tags
=
swiftMessage
.
getBlock4
().
getTags
();
String
identification
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Id"
);
if
(
StringUtil
.
isNotEmpty
(
identification
))
{
if
(
identification
.
startsWith
(
"/"
)
||
identification
.
endsWith
(
"/"
)
||
identification
.
contains
(
"//"
))
{
buildSTErrorInfo
(
ERROR
.
T20101
,
"Block4/:20:"
,
identification
);
identification
=
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
;
}
if
(
identification
.
length
()
>
16
)
{
buildSTErrorInfo
(
ERROR
.
T0000T
,
"Block4/:20:"
,
identification
);
identification
=
identification
.
substring
(
0
,
15
)
+
"+"
;
}
String
value
=
identification
;
if
(
value
.
startsWith
(
"/"
)
||
value
.
endsWith
(
"/"
)
||
value
.
contains
(
"//"
))
{
value
=
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
;
}
tags
.
add
(
new
Tag
(
name
,
value
));
tags
.
add
(
new
Tag
(
name
,
identification
));
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt940950/impl/Field60Generate.java
View file @
6d855680
package
com
.
brilliance
.
swift
.
mx2mt
.
mt940950
.
impl
;
import
com.brilliance.swift.constants.ERROR
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
import
com.brilliance.swift.util.DateUtil
;
import
com.brilliance.swift.util.NumberUtil
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.vo.common.BalanceSubTypeCode
;
import
com.brilliance.swift.vo.common.BalanceTypeCode
;
import
com.brilliance.swift.vo.common.CdtDbtCode
;
import
com.prowidesoftware.swift.model.SwiftMessage
;
...
...
@@ -35,48 +37,68 @@ public class Field60Generate extends AbstractMx2MtTagsGenerate {
List
<
Tag
>
tags
=
swiftMessage
.
getBlock4
().
getTags
();
int
balanceTypeCount
=
getXmlNodeCounts
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal"
);
int
index
=
-
1
;
int
counter
=
0
;
if
(
balanceTypeCount
>
0
)
{
for
(
int
i
=
0
;
i
<
balanceTypeCount
;
i
++)
{
String
balanceType
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
i
+
").Tp.CdOrPrtry.Cd"
);
if
(
BalanceTypeCode
.
OPBD
.
value
().
equals
(
balanceType
))
{
index
=
i
;
break
;
counter
++
;
}
}
}
if
(
index
>
-
1
)
{
try
{
String
crdr
=
""
;
String
cdtDbtInd
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
index
+
").CdtDbtInd"
);
if
(
CdtDbtCode
.
CRDT
.
value
().
equals
(
cdtDbtInd
))
{
crdr
=
"C"
;
}
else
{
//if (CdtDbtCode.DBIT.value().equals(cdtDbtInd)) {
crdr
=
"D"
;
}
String
balanceDate
=
""
;
String
dateStr
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
index
+
").Dt.Dt"
);
if
(
StringUtil
.
isNotEmpty
(
dateStr
))
{
XMLGregorianCalendar
date
=
DatatypeFactory
.
newInstance
().
newXMLGregorianCalendar
(
dateStr
);
balanceDate
=
DateUtil
.
format
(
date
,
"yyMMdd"
);
if
(
counter
!=
1
)
{
//没有OPBD 或者 OPBD不止一条数据
buildSTErrorInfo
(
ERROR
.
T20104
,
"Block4/60a"
,
null
);
}
String
pageNumber
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.StmtPgntn.PgNb"
);
if
(
StringUtil
.
isNotEmpty
(
pageNumber
))
{
int
pgNb
=
Integer
.
parseInt
(
pageNumber
);
if
(
pgNb
==
1
)
{
String
subTypeCode
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
index
+
").Tp.SubTp.Cd"
);
if
(
BalanceSubTypeCode
.
INTM
.
value
().
equals
(
subTypeCode
))
{
buildSTErrorInfo
(
ERROR
.
T20105
,
"Block4/60a"
,
null
);
}
String
balanceAmt
=
""
;
String
balanceCcy
=
""
;
String
amt
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
index
+
").Amt"
);
String
ccy
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
index
+
").Amt@Ccy"
);
if
(
StringUtil
.
isNotEmpty
(
amt
)
&&
StringUtil
.
isNotEmpty
(
ccy
))
{
balanceAmt
=
NumberUtil
.
formatAmt
(
new
BigDecimal
(
amt
),
ccy
);
balanceCcy
=
ccy
;
}
else
if
(
pgNb
>
1
)
{
String
subTypeCode
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
index
+
").Tp.SubTp.Cd"
);
if
(!
BalanceSubTypeCode
.
INTM
.
value
().
equals
(
subTypeCode
))
{
buildSTErrorInfo
(
ERROR
.
T20106
,
"Block4/60a"
,
null
);
}
String
value
=
crdr
+
balanceDate
+
balanceCcy
+
balanceAmt
;
String
pageNumber
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.StmtPgntn.PgNb"
);
if
(
StringUtil
.
isNotEmpty
(
pageNumber
)
&&
Integer
.
parseInt
(
pageNumber
)
==
1
)
{
tags
.
add
(
new
Tag
(
name_F
,
value
));
}
else
{
tags
.
add
(
new
Tag
(
name_M
,
value
));
}
}
try
{
String
crdr
=
""
;
String
cdtDbtInd
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
index
+
").CdtDbtInd"
);
if
(
CdtDbtCode
.
CRDT
.
value
().
equals
(
cdtDbtInd
))
{
crdr
=
"C"
;
}
else
{
//if (CdtDbtCode.DBIT.value().equals(cdtDbtInd)) {
crdr
=
"D"
;
}
String
balanceDate
=
""
;
String
dateStr
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
index
+
").Dt.Dt"
);
if
(
StringUtil
.
isNotEmpty
(
dateStr
))
{
XMLGregorianCalendar
date
=
DatatypeFactory
.
newInstance
().
newXMLGregorianCalendar
(
dateStr
);
balanceDate
=
DateUtil
.
format
(
date
,
"yyMMdd"
);
}
String
balanceAmt
=
""
;
String
balanceCcy
=
""
;
String
amt
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
index
+
").Amt"
);
String
ccy
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
index
+
").Amt@Ccy"
);
if
(
StringUtil
.
isNotEmpty
(
amt
)
&&
StringUtil
.
isNotEmpty
(
ccy
))
{
if
(
NumberUtil
.
judgeAmtStrExceedLength
(
amt
,
14
))
{
buildSTErrorInfo
(
ERROR
.
T20112
,
"Block4/60a"
,
amt
);
}
}
catch
(
DatatypeConfigurationException
e
)
{
throw
new
SwiftException
(
"ERROR"
,
e
.
getMessage
());
balanceAmt
=
NumberUtil
.
formatAmt
(
new
BigDecimal
(
amt
),
ccy
);
balanceCcy
=
ccy
;
}
String
value
=
crdr
+
balanceDate
+
balanceCcy
+
balanceAmt
;
//String pageNumber = getXmlNodeValue(bodyHdrParentElementName, document, "Stmt.StmtPgntn.PgNb");
if
(
StringUtil
.
isNotEmpty
(
pageNumber
)
&&
Integer
.
parseInt
(
pageNumber
)
==
1
)
{
tags
.
add
(
new
Tag
(
name_F
,
value
));
}
else
{
tags
.
add
(
new
Tag
(
name_M
,
value
));
}
}
catch
(
DatatypeConfigurationException
e
)
{
throw
new
SwiftException
(
"ERROR"
,
e
.
getMessage
());
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt940950/impl/Field61Generate.java
View file @
6d855680
package
com
.
brilliance
.
swift
.
mx2mt
.
mt940950
.
impl
;
import
com.brilliance.swift.constants.ERROR
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
...
...
@@ -40,6 +41,7 @@ public class Field61Generate extends AbstractMx2MtTagsGenerate {
try
{
SwiftMessage
swiftMessage
=
context
.
get
(
SwiftMessage
.
class
);
List
<
Tag
>
tags
=
swiftMessage
.
getBlock4
().
getTags
();
String
acctCcy
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Acct.Ccy"
);
int
entryCount
=
getXmlNodeCounts
(
bodyHdrParentElementName
,
document
,
"Stmt.Ntry"
);
if
(
entryCount
>
0
)
{
for
(
int
i
=
0
;
i
<
entryCount
;
i
++)
{
...
...
@@ -72,6 +74,13 @@ public class Field61Generate extends AbstractMx2MtTagsGenerate {
String
amt
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Ntry("
+
i
+
").Amt"
);
String
ccy
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Ntry("
+
i
+
").Amt@Ccy"
);
if
(
StringUtil
.
isNotEmpty
(
amt
)
&&
StringUtil
.
isNotEmpty
(
ccy
))
{
//Translation Preconditions/PREC008
if
(
StringUtil
.
isNotEmpty
(
acctCcy
)
&&
!
acctCcy
.
equals
(
ccy
))
{
buildSTErrorInfo
(
ERROR
.
T20116
,
"Block4/61/"
+(
i
+
1
),
null
);
}
if
(
NumberUtil
.
judgeAmtStrExceedLength
(
amt
,
14
))
{
buildSTErrorInfo
(
ERROR
.
T20113
,
"Block4/61/"
+(
i
+
1
),
amt
);
}
value
+=
NumberUtil
.
formatAmt
(
new
BigDecimal
(
amt
),
ccy
);
}
value
+=
"NTRF"
;
...
...
@@ -94,18 +103,22 @@ public class Field61Generate extends AbstractMx2MtTagsGenerate {
String
additionalInformation
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Ntry("
+
i
+
").NtryDtls.TxDtls.AddtlTxInf"
);
if
(
StringUtil
.
isNotEmpty
(
additionalInformation
))
{
if
(
additionalInformation
.
length
()
>
34
)
{
buildSTErrorInfo
(
ERROR
.
T0000T
,
"Block4/61"
,
additionalInformation
);
additionalInformation
=
additionalInformation
.
substring
(
0
,
33
)
+
"+"
;
}
value
+=
Mx2MtConstants
.
NEW_LINE
+
additionalInformation
;
}
value
=
mx_to_mtStartingLineCharacter
(
value
,
"Block4/61"
);
tags
.
add
(
new
Tag
(
name_61
,
value
));
String
additionalEntryInformation
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Ntry("
+
i
+
").AddtlNtryInf"
);
if
(
StringUtil
.
isNotEmpty
(
additionalEntryInformation
))
{
if
(
additionalEntryInformation
.
length
()
>
390
)
{
buildSTErrorInfo
(
ERROR
.
T0000T
,
"Block4/61"
,
additionalEntryInformation
);
additionalEntryInformation
=
additionalEntryInformation
.
substring
(
0
,
389
)
+
"+"
;
}
String
value86
=
StringUtil
.
getStringByEnter
(
additionalEntryInformation
,
65
,
6
);
value86
=
mx_to_mtStartingLineCharacter
(
value86
,
"Block4/61/86"
);
tags
.
add
(
new
Tag
(
name_86
,
value86
));
context
.
set
(
Mx2MtContextIdentifier
.
MT_TYPE_940_FLAG
,
Mx2MtConstants
.
YES
);
}
...
...
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt940950/impl/Field62Generate.java
View file @
6d855680
package
com
.
brilliance
.
swift
.
mx2mt
.
mt940950
.
impl
;
import
com.brilliance.swift.constants.ERROR
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
import
com.brilliance.swift.util.DateUtil
;
import
com.brilliance.swift.util.NumberUtil
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.vo.common.BalanceSubTypeCode
;
import
com.brilliance.swift.vo.common.BalanceTypeCode
;
import
com.brilliance.swift.vo.common.CdtDbtCode
;
import
com.prowidesoftware.swift.model.SwiftMessage
;
...
...
@@ -35,48 +37,64 @@ public class Field62Generate extends AbstractMx2MtTagsGenerate {
List
<
Tag
>
tags
=
swiftMessage
.
getBlock4
().
getTags
();
int
balanceTypeCount
=
getXmlNodeCounts
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal"
);
int
index
=
-
1
;
int
counter
=
0
;
if
(
balanceTypeCount
>
0
)
{
for
(
int
i
=
0
;
i
<
balanceTypeCount
;
i
++)
{
String
balanceType
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
i
+
").Tp.CdOrPrtry.Cd"
);
if
(
BalanceTypeCode
.
CLBD
.
value
().
equals
(
balanceType
))
{
index
=
i
;
break
;
counter
++
;
}
}
}
if
(
index
>
-
1
)
{
try
{
String
crdr
=
""
;
String
cdtDbtInd
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
index
+
").CdtDbtInd"
);
if
(
CdtDbtCode
.
CRDT
.
value
().
equals
(
cdtDbtInd
))
{
crdr
=
"C"
;
}
else
{
//if (CdtDbtCode.DBIT.value().equals(cdtDbtInd)) {
crdr
=
"D"
;
}
String
balanceDate
=
""
;
String
dateStr
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
index
+
").Dt.Dt"
);
if
(
StringUtil
.
isNotEmpty
(
dateStr
))
{
XMLGregorianCalendar
date
=
DatatypeFactory
.
newInstance
().
newXMLGregorianCalendar
(
dateStr
);
balanceDate
=
DateUtil
.
format
(
date
,
"yyMMdd"
);
}
String
balanceAmt
=
""
;
String
balanceCcy
=
""
;
String
amt
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
index
+
").Amt"
);
String
ccy
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
index
+
").Amt@Ccy"
);
if
(
StringUtil
.
isNotEmpty
(
amt
)
&&
StringUtil
.
isNotEmpty
(
ccy
))
{
balanceAmt
=
NumberUtil
.
formatAmt
(
new
BigDecimal
(
amt
),
ccy
);
balanceCcy
=
ccy
;
}
String
value
=
crdr
+
balanceDate
+
balanceCcy
+
balanceAmt
;
String
lastPageIndicator
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.StmtPgntn.LastPgInd"
);
if
(
StringUtil
.
isNotEmpty
(
lastPageIndicator
)
&&
Boolean
.
TRUE
.
equals
(
Boolean
.
valueOf
(
lastPageIndicator
)))
{
tags
.
add
(
new
Tag
(
name_F
,
value
));
}
else
{
tags
.
add
(
new
Tag
(
name_M
,
value
));
if
(
counter
!=
1
)
{
//没有CLBD 或者 CLBD不止一条数据
buildSTErrorInfo
(
ERROR
.
T20107
,
"Block4/62a"
,
null
);
}
String
lastPageIndicator
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.StmtPgntn.LastPgInd"
);
if
(
StringUtil
.
isNotEmpty
(
lastPageIndicator
)
&&
Boolean
.
TRUE
.
equals
(
Boolean
.
valueOf
(
lastPageIndicator
)))
{
String
subTypeCode
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
index
+
").Tp.SubTp.Cd"
);
if
(
BalanceSubTypeCode
.
INTM
.
value
().
equals
(
subTypeCode
))
{
buildSTErrorInfo
(
ERROR
.
T20125
,
"Block4/62a"
,
null
);
}
}
else
{
String
subTypeCode
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
index
+
").Tp.SubTp.Cd"
);
if
(!
BalanceSubTypeCode
.
INTM
.
value
().
equals
(
subTypeCode
))
{
buildSTErrorInfo
(
ERROR
.
T20108
,
"Block4/62a"
,
null
);
}
}
try
{
String
crdr
=
""
;
String
cdtDbtInd
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
index
+
").CdtDbtInd"
);
if
(
CdtDbtCode
.
CRDT
.
value
().
equals
(
cdtDbtInd
))
{
crdr
=
"C"
;
}
else
{
//if (CdtDbtCode.DBIT.value().equals(cdtDbtInd)) {
crdr
=
"D"
;
}
String
balanceDate
=
""
;
String
dateStr
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
index
+
").Dt.Dt"
);
if
(
StringUtil
.
isNotEmpty
(
dateStr
))
{
XMLGregorianCalendar
date
=
DatatypeFactory
.
newInstance
().
newXMLGregorianCalendar
(
dateStr
);
balanceDate
=
DateUtil
.
format
(
date
,
"yyMMdd"
);
}
String
balanceAmt
=
""
;
String
balanceCcy
=
""
;
String
amt
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
index
+
").Amt"
);
String
ccy
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
index
+
").Amt@Ccy"
);
if
(
StringUtil
.
isNotEmpty
(
amt
)
&&
StringUtil
.
isNotEmpty
(
ccy
))
{
if
(
NumberUtil
.
judgeAmtStrExceedLength
(
amt
,
14
))
{
buildSTErrorInfo
(
ERROR
.
T20112
,
"Block4/60a"
,
amt
);
}
}
catch
(
DatatypeConfigurationException
e
)
{
throw
new
SwiftException
(
"ERROR"
,
e
.
getMessage
());
balanceAmt
=
NumberUtil
.
formatAmt
(
new
BigDecimal
(
amt
),
ccy
);
balanceCcy
=
ccy
;
}
String
value
=
crdr
+
balanceDate
+
balanceCcy
+
balanceAmt
;
if
(
StringUtil
.
isNotEmpty
(
lastPageIndicator
)
&&
Boolean
.
TRUE
.
equals
(
Boolean
.
valueOf
(
lastPageIndicator
)))
{
tags
.
add
(
new
Tag
(
name_F
,
value
));
}
else
{
tags
.
add
(
new
Tag
(
name_M
,
value
));
}
}
catch
(
DatatypeConfigurationException
e
)
{
throw
new
SwiftException
(
"ERROR"
,
e
.
getMessage
());
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt940950/impl/Field64Generate.java
View file @
6d855680
package
com
.
brilliance
.
swift
.
mx2mt
.
mt940950
.
impl
;
import
com.brilliance.swift.constants.ERROR
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
import
com.brilliance.swift.util.DateUtil
;
...
...
@@ -34,15 +35,19 @@ public class Field64Generate extends AbstractMx2MtTagsGenerate {
List
<
Tag
>
tags
=
swiftMessage
.
getBlock4
().
getTags
();
int
balanceTypeCount
=
getXmlNodeCounts
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal"
);
int
index
=
-
1
;
int
counter
=
0
;
if
(
balanceTypeCount
>
0
)
{
for
(
int
i
=
0
;
i
<
balanceTypeCount
;
i
++)
{
String
balanceType
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
i
+
").Tp.CdOrPrtry.Cd"
);
if
(
BalanceTypeCode
.
CLAV
.
value
().
equals
(
balanceType
))
{
index
=
i
;
break
;
counter
++
;
}
}
}
if
(
counter
>
1
)
{
//CLAV不止一条数据
buildSTErrorInfo
(
ERROR
.
T20109
,
"Block4/64"
,
null
);
}
if
(
index
>
-
1
)
{
try
{
String
crdr
=
""
;
...
...
@@ -63,6 +68,9 @@ public class Field64Generate extends AbstractMx2MtTagsGenerate {
String
amt
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
index
+
").Amt"
);
String
ccy
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
index
+
").Amt@Ccy"
);
if
(
StringUtil
.
isNotEmpty
(
amt
)
&&
StringUtil
.
isNotEmpty
(
ccy
))
{
if
(
NumberUtil
.
judgeAmtStrExceedLength
(
amt
,
14
))
{
buildSTErrorInfo
(
ERROR
.
T20112
,
"Block4/60a"
,
amt
);
}
balanceAmt
=
NumberUtil
.
formatAmt
(
new
BigDecimal
(
amt
),
ccy
);
balanceCcy
=
ccy
;
}
...
...
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt940950/impl/Field65Generate.java
View file @
6d855680
package
com
.
brilliance
.
swift
.
mx2mt
.
mt940950
.
impl
;
import
com.brilliance.swift.constants.ERROR
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
...
...
@@ -53,6 +54,9 @@ public class Field65Generate extends AbstractMx2MtTagsGenerate {
String
amt
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
i
+
").Amt"
);
String
ccy
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.Bal("
+
i
+
").Amt@Ccy"
);
if
(
StringUtil
.
isNotEmpty
(
amt
)
&&
StringUtil
.
isNotEmpty
(
ccy
))
{
if
(
NumberUtil
.
judgeAmtStrExceedLength
(
amt
,
14
))
{
buildSTErrorInfo
(
ERROR
.
T20112
,
"Block4/60a"
,
amt
);
}
balanceAmt
=
NumberUtil
.
formatAmt
(
new
BigDecimal
(
amt
),
ccy
);
balanceCcy
=
ccy
;
}
...
...
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mt940950/impl/Field86Generate.java
View file @
6d855680
package
com
.
brilliance
.
swift
.
mx2mt
.
mt940950
.
impl
;
import
com.brilliance.swift.constants.ERROR
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
...
...
@@ -25,9 +26,11 @@ public class Field86Generate extends AbstractMx2MtTagsGenerate {
String
addtlStmtInf
=
getXmlNodeValue
(
bodyHdrParentElementName
,
document
,
"Stmt.AddtlStmtInf"
);
if
(
StringUtil
.
isNotEmpty
(
addtlStmtInf
))
{
if
(
addtlStmtInf
.
length
()
>
390
)
{
buildSTErrorInfo
(
ERROR
.
T0000T
,
"Block4/86"
,
addtlStmtInf
);
addtlStmtInf
=
addtlStmtInf
.
substring
(
0
,
389
)
+
"+"
;
}
String
value
=
StringUtil
.
getStringByEnter
(
addtlStmtInf
,
65
,
6
);
value
=
mx_to_mtStartingLineCharacter
(
value
,
"Block4/86"
);
tags
.
add
(
new
Tag
(
name
,
value
));
context
.
set
(
Mx2MtContextIdentifier
.
MT_TYPE_940_FLAG
,
Mx2MtConstants
.
YES
);
}
...
...
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mtn99/Mx2MtN99Creator.java
View file @
6d855680
package
com
.
brilliance
.
swift
.
mx2mt
.
mtn99
;
import
com.brilliance.swift.constants.ERROR
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtCreator
;
...
...
@@ -10,6 +11,7 @@ import com.brilliance.swift.mx2mt.mtn99.impl.Field21Generate;
import
com.brilliance.swift.mx2mt.mtn99.impl.Field79Generate
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.util.XmlUtil
;
import
com.brilliance.swift.vo.common.PaymentTransactionStatusCode
;
import
com.prowidesoftware.swift.model.SwiftBlock3
;
import
com.prowidesoftware.swift.model.SwiftMessage
;
import
com.prowidesoftware.swift.model.field.Field121
;
...
...
@@ -29,6 +31,12 @@ public class Mx2MtN99Creator extends AbstractMx2MtCreator {
context
.
set
(
Mx2MtContextIdentifier
.
APPHDR_PARENT_ELEMENT_NAME
,
parentElementMaps
.
get
(
"AppHdr"
));
context
.
set
(
Mx2MtContextIdentifier
.
GRPHDR_PARENT_ELEMENT_NAME
,
parentElementMaps
.
get
(
"GrpHdr"
));
context
.
set
(
Mx2MtContextIdentifier
.
BODY_PARENT_ELEMENT_NAME
,
parentElementMaps
.
get
(
"TxInfAndSts"
));
//Translation Preconditions/PREC002
String
bodyParentPath
=
parentElementMaps
.
get
(
"TxInfAndSts"
);
String
txnStatus
=
getXmlNodeValue
(
bodyParentPath
,
document
,
"TxInfAndSts.TxSts"
);
if
(!
PaymentTransactionStatusCode
.
RJCT
.
value
().
equals
(
txnStatus
))
{
buildSTErrorInfo
(
ERROR
.
T20056
,
"TxInfAndSts.TxSts"
,
null
);
}
}
@Override
...
...
@@ -70,6 +78,8 @@ public class Mx2MtN99Creator extends AbstractMx2MtCreator {
mtType
=
Mx2MtConstants
.
MT_TYPE_199
;
}
else
if
(
orgMsgNameIdentification
.
matches
(
"MT20[0-9]{1}"
))
{
mtType
=
Mx2MtConstants
.
MT_TYPE_299
;
}
else
{
buildSTErrorInfo
(
ERROR
.
T20092
,
"Block2/MtType"
,
null
);
}
}
return
mtType
;
...
...
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mtn99/impl/Field20Generate.java
View file @
6d855680
package
com
.
brilliance
.
swift
.
mx2mt
.
mtn99
.
impl
;
import
com.brilliance.swift.constants.ERROR
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
...
...
@@ -19,14 +20,15 @@ public class Field20Generate extends AbstractMx2MtTagsGenerate {
List
<
Tag
>
tags
=
swiftMessage
.
getBlock4
().
getTags
();
String
messageId
=
getXmlNodeValue
(
grpHdrParentElementName
,
document
,
"GrpHdr.MsgId"
);
if
(
StringUtil
.
isNotEmpty
(
messageId
))
{
if
(
messageId
.
startsWith
(
"/"
)
||
messageId
.
endsWith
(
"/"
)
||
messageId
.
contains
(
"//"
))
{
buildSTErrorInfo
(
ERROR
.
T20051
,
"Block4/:20:"
,
messageId
);
messageId
=
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
;
}
if
(
messageId
.
length
()
>
16
)
{
buildSTErrorInfo
(
ERROR
.
T0000T
,
"Block4/:20:"
,
messageId
);
messageId
=
messageId
.
substring
(
0
,
15
)
+
"+"
;
}
String
value
=
messageId
;
if
(
value
.
startsWith
(
"/"
)
||
value
.
endsWith
(
"/"
)
||
value
.
contains
(
"//"
))
{
value
=
Mx2MtConstants
.
MX_TO_MT_DEFAULT_VALUE
;
}
tags
.
add
(
new
Tag
(
name
,
value
));
tags
.
add
(
new
Tag
(
name
,
messageId
));
}
}
}
swiftCore/src/main/java/com/brilliance/swift/mx2mt/mtn99/impl/Field79Generate.java
View file @
6d855680
...
...
@@ -3,6 +3,7 @@ package com.brilliance.swift.mx2mt.mtn99.impl;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.exception.SwiftException
;
import
com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate
;
import
com.brilliance.swift.mx2mt.Mx2MtContextIdentifier
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.util.SwiftTransferUtil
;
import
com.brilliance.swift.vo.MxMtReasonCodeInfo
;
...
...
@@ -18,6 +19,7 @@ public class Field79Generate extends AbstractMx2MtTagsGenerate {
@Override
public
void
tagGenerate
()
throws
SwiftException
{
context
.
set
(
Mx2MtContextIdentifier
.
MX_TO_MT_ERROR_LOCATION
,
"Block4/:79:"
);
SwiftMessage
swiftMessage
=
context
.
get
(
SwiftMessage
.
class
);
List
<
Tag
>
tags
=
swiftMessage
.
getBlock4
().
getTags
();
List
<
String
>
mt79List
=
new
ArrayList
<>();
...
...
@@ -95,6 +97,7 @@ public class Field79Generate extends AbstractMx2MtTagsGenerate {
value
+=
Mx2MtConstants
.
NEW_LINE
+
list
.
get
(
i
);
}
}
value
=
mx_to_mtStartingLineCharacter
(
value
,
"Block4/:79:"
);
tags
.
add
(
new
Tag
(
name
,
value
));
}
...
...
swiftCore/src/main/java/com/brilliance/swift/util/NumberUtil.java
View file @
6d855680
...
...
@@ -128,4 +128,14 @@ public class NumberUtil {
}
}
public
static
boolean
judgeAmtStrExceedLength
(
String
amtStr
,
int
maxLength
)
{
boolean
flag
=
false
;
if
(
StringUtil
.
isNotEmpty
(
amtStr
))
{
amtStr
=
amtStr
.
replace
(
"."
,
""
);
if
(
amtStr
.
length
()
>
maxLength
)
{
flag
=
true
;
}
}
return
flag
;
}
}
swiftCore/src/main/java/com/brilliance/swift/vo/common/EntryStatusCode.java
0 → 100644
View file @
6d855680
package
com
.
brilliance
.
swift
.
vo
.
common
;
public
enum
EntryStatusCode
{
BOOK
(
"Booked"
),
FUTR
(
"Future"
),
INFO
(
"Information"
),
PDNG
(
"Pending"
);
EntryStatusCode
(
String
s
)
{}
public
String
value
()
{
return
name
();
}
}
swiftCore/src/main/java/com/brilliance/swift/vo/common/PaymentTransactionStatusCode.java
0 → 100644
View file @
6d855680
package
com
.
brilliance
.
swift
.
vo
.
common
;
public
enum
PaymentTransactionStatusCode
{
ACCC
(
"AcceptedSettlementCompletedCreditorAccount"
),
ACCP
(
"AcceptedCustomerProfile"
),
ACFC
(
"AcceptedFundsChecked"
),
ACIS
(
"AcceptedandChequeIssued"
),
ACSC
(
"AcceptedSettlementCompletedDebitorAccount"
),
ACSP
(
"AcceptedSettlementInProcess"
),
ACTC
(
"AcceptedTechnicalValidation"
),
ACWC
(
"AcceptedWithChange"
),
ACWP
(
"AcceptedWithoutPosting"
),
BLCK
(
"Blocked"
),
CANC
(
"Cancelled"
),
CPUC
(
"CashPickedUpByCreditor"
),
PATC
(
"PartiallyAcceptedTechnicalCorrect"
),
PDNG
(
"Pending"
),
PRES
(
"Presented"
),
RCVD
(
"Received"
),
RJCT
(
"Rejected"
),
ADEA
(
"ServicerDeadlineMissed"
),
DISA
(
"NaturalDisaster"
),
ESCA
(
"Escalation"
),
IAAD
(
"StatusReasonInvestigation"
),
LPRO
(
"LongerProcessing"
),
MINF
(
"MissingInformation"
),
NEWI
(
"NewIssues"
),
NEXT
(
"NextProcess"
),
NSTP
(
"NotStraightThroughProcessing"
),
PRSY
(
"SystemOnHold"
);
PaymentTransactionStatusCode
(
String
s
)
{}
public
String
value
()
{
return
name
();
}
}
swiftCore/src/test/java/com/brilliance/mx2mt/mt950/TestMx2MtFor950.java
View file @
6d855680
package
com
.
brilliance
.
mx2mt
.
mt950
;
import
com.brilliance.swift.SwiftTransfer
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.vo.SwiftTranslationErrorInfo
;
import
com.brilliance.swift.vo.SwiftTranslationReport
;
import
org.apache.commons.io.FileUtils
;
import
java.io.File
;
import
java.util.List
;
public
class
TestMx2MtFor950
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
File
file
=
new
File
(
System
.
getProperty
(
"user.dir"
)+
"\\swiftCore\\src\\main\\resources\\swiftXml\\MxCamt05300108_950.xml"
);
String
xmlStr
=
FileUtils
.
readFileToString
(
file
);
String
mt910
=
SwiftTransfer
.
mx2Mt
(
xmlStr
,
null
,
null
);
System
.
out
.
println
(
mt910
);
SwiftTranslationReport
str
=
SwiftTransfer
.
mx2MtPlus
(
xmlStr
,
null
,
null
);
if
(
str
!=
null
)
{
List
<
SwiftTranslationErrorInfo
>
errorInfos
=
str
.
getErrorInfos
();
if
(
errorInfos
!=
null
&&
errorInfos
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
errorInfos
.
size
();
i
++)
{
SwiftTranslationErrorInfo
errorInfo
=
errorInfos
.
get
(
i
);
String
location
=
errorInfo
.
getLocation
();
String
errorType
=
errorInfo
.
getErrorType
();
String
description
=
errorInfo
.
getDescription
();
System
.
out
.
println
(
location
+
Mx2MtConstants
.
NEW_LINE
+
"-"
+
errorType
+
":"
+
description
);
String
originalValue
=
errorInfo
.
getOriginalValue
();
if
(
StringUtil
.
isNotEmpty
(
originalValue
))
{
System
.
out
.
println
(
originalValue
);
}
}
}
System
.
out
.
println
(
str
.
getMessage
());
}
}
}
swiftCore/src/test/java/com/brilliance/mx2mt/mtn99/Test.java
View file @
6d855680
package
com
.
brilliance
.
mx2mt
.
mtn99
;
import
com.brilliance.swift.SwiftTransfer
;
import
com.brilliance.swift.constants.Mx2MtConstants
;
import
com.brilliance.swift.util.StringUtil
;
import
com.brilliance.swift.vo.SwiftTranslationErrorInfo
;
import
com.brilliance.swift.vo.SwiftTranslationReport
;
import
org.apache.commons.io.FileUtils
;
import
java.io.File
;
import
java.util.List
;
public
class
Test
{
public
static
void
test199
()
throws
Exception
{
File
file
=
new
File
(
System
.
getProperty
(
"user.dir"
)+
"\\swiftCore\\src\\main\\resources\\swiftXml\\MxPacs00200110_Pacs008.xml"
);
String
xmlStr
=
FileUtils
.
readFileToString
(
file
);
String
mt103Retn
=
SwiftTransfer
.
mx2Mt
(
xmlStr
,
null
,
null
);
System
.
out
.
println
(
mt103Retn
);
SwiftTranslationReport
str
=
SwiftTransfer
.
mx2MtPlus
(
xmlStr
,
null
,
null
);
if
(
str
!=
null
)
{
List
<
SwiftTranslationErrorInfo
>
errorInfos
=
str
.
getErrorInfos
();
if
(
errorInfos
!=
null
&&
errorInfos
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
errorInfos
.
size
();
i
++)
{
SwiftTranslationErrorInfo
errorInfo
=
errorInfos
.
get
(
i
);
String
location
=
errorInfo
.
getLocation
();
String
errorType
=
errorInfo
.
getErrorType
();
String
description
=
errorInfo
.
getDescription
();
System
.
out
.
println
(
location
+
Mx2MtConstants
.
NEW_LINE
+
"-"
+
errorType
+
":"
+
description
);
String
originalValue
=
errorInfo
.
getOriginalValue
();
if
(
StringUtil
.
isNotEmpty
(
originalValue
))
{
System
.
out
.
println
(
originalValue
);
}
}
}
System
.
out
.
println
(
str
.
getMessage
());
}
}
public
static
void
test299
()
throws
Exception
{
...
...
@@ -22,7 +43,7 @@ public class Test {
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
//
test199();
test299
();
test199
();
//
test299();
}
}
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