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
ad4e11fc
Commit
ad4e11fc
authored
Apr 18, 2022
by
zhanghou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
基本完成了940和950报文转化代码的编写
parent
0e6abdbd
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
188 additions
and
220 deletions
+188
-220
Field28CGenerate.java
...ware/brilliance/mx2mt/mt940950/impl/Field28CGenerate.java
+0
-7
Field60Generate.java
...tware/brilliance/mx2mt/mt940950/impl/Field60Generate.java
+4
-4
Field61ListGenerate.java
...e/brilliance/mx2mt/mt940950/impl/Field61ListGenerate.java
+59
-50
Field62Generate.java
...tware/brilliance/mx2mt/mt940950/impl/Field62Generate.java
+42
-50
Field64Generate.java
...tware/brilliance/mx2mt/mt940950/impl/Field64Generate.java
+38
-47
Field65Generate.java
...tware/brilliance/mx2mt/mt940950/impl/Field65Generate.java
+38
-45
Field86Generate.java
...tware/brilliance/mx2mt/mt940950/impl/Field86Generate.java
+7
-17
No files found.
src/main/java/com/prowidesoftware/brilliance/mx2mt/mt940950/impl/Field28CGenerate.java
View file @
ad4e11fc
...
...
@@ -4,17 +4,10 @@ import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import
com.prowidesoftware.brilliance.exception.SwiftException
;
import
com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate
;
import
com.prowidesoftware.brilliance.util.StringUtil
;
import
com.prowidesoftware.swift.model.mx.MxCamt05300102
;
import
com.prowidesoftware.swift.model.mx.dic.AccountStatement2
;
import
com.prowidesoftware.swift.model.mx.dic.BankToCustomerStatementV02
;
import
com.prowidesoftware.swift.model.mx.dic.GroupHeader42
;
import
org.dom4j.Document
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.math.BigDecimal
;
import
java.util.List
;
/**
* <GrpHdr><MsgPgntn><PgNb>
* <Stmt><ElctrncSeqNb>
...
...
src/main/java/com/prowidesoftware/brilliance/mx2mt/mt940950/impl/Field60Generate.java
View file @
ad4e11fc
...
...
@@ -37,18 +37,18 @@ public class Field60Generate extends AbstractMx2MtFieldsGenerate{
String
amt
=
""
;
Document
document
=
(
Document
)
map
.
get
(
Mx2MtConstants
.
MX_XML_DOCUMENT
);
String
cd
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Bal.Tp.CdOrPrtry.Cd"
);
if
(
BalanceType12Code
.
PRCD
.
equals
(
BalanceType12Code
.
valueOf
(
cd
)
))
{
if
(
BalanceType12Code
.
PRCD
.
value
().
equals
(
cd
))
{
filed60Option
=
"F"
;
}
else
if
(
BalanceType12Code
.
ITBD
.
equals
(
BalanceType12Code
.
valueOf
(
cd
)
))
{
}
else
if
(
BalanceType12Code
.
ITBD
.
value
().
equals
(
cd
))
{
filed60Option
=
"M"
;
}
else
{
throw
new
SwiftException
(
"ERROR"
,
"cannot find filed60Option."
);
}
map
.
put
(
"field60Option"
,
filed60Option
);
String
cdtDbtInd
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Bal.CdtDbtInd"
);
if
(
CreditDebitCode
.
CRDT
.
equals
(
CreditDebitCode
.
valueOf
(
cdtDbtInd
)
))
{
if
(
CreditDebitCode
.
CRDT
.
value
().
equals
(
cdtDbtInd
))
{
crdr
=
Mx2MtConstants
.
DRCRMARK_C
;
}
else
if
(
CreditDebitCode
.
DBIT
.
equals
(
CreditDebitCode
.
valueOf
(
cdtDbtInd
)
))
{
}
else
if
(
CreditDebitCode
.
DBIT
.
value
().
equals
(
cdtDbtInd
))
{
crdr
=
Mx2MtConstants
.
DRCRMARK_D
;
}
else
{
throw
new
SwiftException
(
"ERROR"
,
"cannot find filed60 D/C Mark."
);
...
...
src/main/java/com/prowidesoftware/brilliance/mx2mt/mt940950/impl/Field61ListGenerate.java
View file @
ad4e11fc
...
...
@@ -43,58 +43,67 @@ public class Field61ListGenerate extends AbstractMx2MtFieldsGenerate{
String
ccy
=
""
;
List
<
String
>
filed61List
=
new
ArrayList
<>();
Document
document
=
(
Document
)
map
.
get
(
Mx2MtConstants
.
MX_XML_DOCUMENT
);
String
dt
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Ntry.ValDt.Dt"
);
String
dt2
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Ntry.BookgDt.Dt"
);
if
(
StringUtil
.
isNotEmpty
(
dt
)){
XMLGregorianCalendar
valueDateDt
=
DatatypeFactory
.
newInstance
().
newXMLGregorianCalendar
(
dt
);
valueDateStr
=
DateUtil
.
format
(
valueDateDt
,
"yyMMdd"
);
}
if
(
StringUtil
.
isNotEmpty
(
dt2
)){
XMLGregorianCalendar
entryDateDt
=
DatatypeFactory
.
newInstance
().
newXMLGregorianCalendar
(
dt
);
entryDateStr
=
DateUtil
.
format
(
entryDateDt
,
"yyMMdd"
);
}
String
cdtDbtInd
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Ntry.CdtDbtInd"
);
String
rvslInd
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Ntry.RvslInd"
);
if
(
CreditDebitCode
.
CRDT
.
equals
(
CreditDebitCode
.
valueOf
(
cdtDbtInd
)))
{
if
(
Boolean
.
TRUE
.
equals
(
Boolean
.
getBoolean
(
rvslInd
)))
{
drCrMark
=
Mx2MtConstants
.
DRCRMARK_RD
;
}
else
{
drCrMark
=
Mx2MtConstants
.
DRCRMARK_C
;
}
}
else
if
(
CreditDebitCode
.
DBIT
.
equals
(
CreditDebitCode
.
valueOf
(
cdtDbtInd
)))
{
if
(
Boolean
.
TRUE
.
equals
(
Boolean
.
getBoolean
(
rvslInd
)))
{
drCrMark
=
Mx2MtConstants
.
DRCRMARK_RC
;
}
else
{
drCrMark
=
Mx2MtConstants
.
DRCRMARK_D
;
int
ntryCounts
=
getXmlNodeCounts
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Ntry"
);
if
(
ntryCounts
>
0
){
for
(
int
i
=
0
;
i
<
ntryCounts
;
i
++)
{
String
dt
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Ntry("
+
i
+
").ValDt.Dt"
);
String
dt2
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Ntry("
+
i
+
").BookgDt.Dt"
);
if
(
StringUtil
.
isNotEmpty
(
dt
)){
XMLGregorianCalendar
valueDateDt
=
DatatypeFactory
.
newInstance
().
newXMLGregorianCalendar
(
dt
);
valueDateStr
=
DateUtil
.
format
(
valueDateDt
,
"yyMMdd"
);
}
if
(
StringUtil
.
isNotEmpty
(
dt2
)){
XMLGregorianCalendar
entryDateDt
=
DatatypeFactory
.
newInstance
().
newXMLGregorianCalendar
(
dt
);
entryDateStr
=
DateUtil
.
format
(
entryDateDt
,
"yyMMdd"
);
}
String
cdtDbtInd
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Ntry("
+
i
+
").CdtDbtInd"
);
String
rvslInd
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Ntry("
+
i
+
").RvslInd"
);
if
(
CreditDebitCode
.
CRDT
.
value
().
equals
(
cdtDbtInd
))
{
if
(
Boolean
.
TRUE
.
equals
(
Boolean
.
getBoolean
(
rvslInd
)))
{
drCrMark
=
Mx2MtConstants
.
DRCRMARK_RD
;
}
else
{
drCrMark
=
Mx2MtConstants
.
DRCRMARK_C
;
}
}
else
if
(
CreditDebitCode
.
DBIT
.
value
().
equals
(
cdtDbtInd
))
{
if
(
Boolean
.
TRUE
.
equals
(
Boolean
.
getBoolean
(
rvslInd
)))
{
drCrMark
=
Mx2MtConstants
.
DRCRMARK_RC
;
}
else
{
drCrMark
=
Mx2MtConstants
.
DRCRMARK_D
;
}
}
else
{
throw
new
SwiftException
(
"ERROR"
,
"cannot find filed61 D/C Mark."
);
}
String
amtStr
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Ntry("
+
i
+
").Amt"
);
String
ccyStr
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Ntry("
+
i
+
").Amt@Ccy"
);
if
(
StringUtil
.
isNotEmpty
(
amtStr
)
&&
StringUtil
.
isNotEmpty
(
ccyStr
))
{
amt
=
NumberUtil
.
formatAmt
(
new
BigDecimal
(
amtStr
),
ccyStr
);
ccy
=
ccyStr
;
}
String
cd
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Ntry("
+
i
+
").BkTxCd.Prtry.Cd"
);
String
endToEndId
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Ntry("
+
i
+
").NtryDtls.TxDtls.Refs.EndToEndId"
);
String
addtlTxInf
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Ntry("
+
i
+
").NtryDtls.TxDtls.AddtlTxInf"
);
String
acctSvcrRef
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Ntry("
+
i
+
").AcctSvcrRef"
);
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
valueDateStr
)
.
append
(
entryDateStr
)
.
append
(
drCrMark
)
.
append
(
ccy
)
.
append
(
amt
)
.
append
(
cd
)
.
append
(
endToEndId
);
if
(
StringUtil
.
isNotEmpty
(
acctSvcrRef
))
{
sb
.
append
(
"//"
+
acctSvcrRef
);
}
if
(
StringUtil
.
isNotEmpty
(
addtlTxInf
))
{
sb
.
append
(
Mx2MtConstants
.
NEW_LINE
+
addtlTxInf
);
}
String
addtlNtryInf
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Ntry("
+
i
+
").AddtlNtryInf"
);
if
(
StringUtil
.
isNotEmpty
(
addtlNtryInf
)){
sb
.
append
(
Mx2MtConstants
.
NEW_LINE
).
append
(
":86:"
).
append
(
StringUtil
.
getStringByEnter
(
addtlNtryInf
,
35
,
6
));
}
filed61List
.
add
(
sb
.
toString
());
}
}
else
{
throw
new
SwiftException
(
"ERROR"
,
"cannot find filed61 D/C Mark."
);
}
String
amtStr
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Ntry.Amt"
);
String
ccyStr
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Ntry.Amt@Ccy"
);
if
(
StringUtil
.
isNotEmpty
(
amtStr
)
&&
StringUtil
.
isNotEmpty
(
ccyStr
))
{
amt
=
NumberUtil
.
formatAmt
(
new
BigDecimal
(
amtStr
),
ccyStr
);
ccy
=
ccyStr
;
}
String
cd
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Ntry.BkTxCd.Prtry.Cd"
);
String
endToEndId
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Ntry.NtryDtls.TxDtls.Refs.EndToEndId"
);
String
addtlTxInf
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Ntry.NtryDtls.TxDtls.AddtlTxInf"
);
String
acctSvcrRef
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Ntry.AcctSvcrRef"
);
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
valueDateStr
)
.
append
(
entryDateStr
)
.
append
(
drCrMark
)
.
append
(
ccy
)
.
append
(
amt
)
.
append
(
cd
)
.
append
(
endToEndId
);
if
(
StringUtil
.
isNotEmpty
(
acctSvcrRef
))
{
sb
.
append
(
"//"
+
acctSvcrRef
);
}
if
(
StringUtil
.
isNotEmpty
(
addtlTxInf
))
{
sb
.
append
(
Mx2MtConstants
.
NEW_LINE
+
addtlTxInf
);
}
filed61List
.
add
(
sb
.
toString
());
if
(
filed61List
.
size
()
>
0
)
{
map
.
put
(
"field61List"
,
filed61List
);
}
...
...
src/main/java/com/prowidesoftware/brilliance/mx2mt/mt940950/impl/Field62Generate.java
View file @
ad4e11fc
...
...
@@ -5,13 +5,16 @@ import com.prowidesoftware.brilliance.exception.SwiftException;
import
com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate
;
import
com.prowidesoftware.brilliance.util.DateUtil
;
import
com.prowidesoftware.brilliance.util.NumberUtil
;
import
com.prowidesoftware.swift.model.mx.MxCamt05300102
;
import
com.prowidesoftware.swift.model.mx.dic.*
;
import
com.prowidesoftware.brilliance.util.StringUtil
;
import
com.prowidesoftware.swift.model.mx.dic.BalanceType12Code
;
import
com.prowidesoftware.swift.model.mx.dic.CreditDebitCode
;
import
org.dom4j.Document
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.xml.datatype.DatatypeFactory
;
import
javax.xml.datatype.XMLGregorianCalendar
;
import
java.math.BigDecimal
;
import
java.util.List
;
/**
* <Stmt><Bal>[i]<Tp><CdOrPrtry><Cd>
...
...
@@ -27,54 +30,43 @@ public class Field62Generate extends AbstractMx2MtFieldsGenerate{
@Override
public
void
fieldsGenerate
()
throws
SwiftException
{
try
{
MxCamt05300102
mxCamt05300102
=
(
MxCamt05300102
)
map
.
get
(
Mx2MtConstants
.
MX_OBJECT
);
if
(
mxCamt05300102
==
null
||
mxCamt05300102
.
getBkToCstmrStmt
()
==
null
)
{
return
;
}
BankToCustomerStatementV02
bkToCstmrStmt
=
mxCamt05300102
.
getBkToCstmrStmt
();
List
<
AccountStatement2
>
stmtList
=
bkToCstmrStmt
.
getStmt
();
if
(
stmtList
!=
null
&&
stmtList
.
size
()
>
0
)
{
AccountStatement2
stmt
=
stmtList
.
get
(
0
);
List
<
CashBalance3
>
balList
=
stmt
.
getBal
();
if
(
balList
!=
null
&&
balList
.
size
()
>=
2
)
{
CashBalance3
bal
=
balList
.
get
(
1
);
String
filed62Option
=
""
;
if
(
bal
!=
null
&&
bal
.
getTp
()
!=
null
&&
bal
.
getTp
().
getCdOrPrtry
()
!=
null
)
{
if
(
BalanceType12Code
.
CLBD
.
equals
(
bal
.
getTp
().
getCdOrPrtry
().
getCd
()))
{
filed62Option
=
"F"
;
}
else
if
(
BalanceType12Code
.
ITBD
.
equals
(
bal
.
getTp
().
getCdOrPrtry
().
getCd
()))
{
filed62Option
=
"M"
;
}
else
{
throw
new
SwiftException
(
"ERROR"
,
"cannot find filed62Option."
);
}
map
.
put
(
"field62Option"
,
filed62Option
);
}
if
(
bal
!=
null
)
{
String
crdr
=
""
;
if
(
CreditDebitCode
.
CRDT
.
equals
(
bal
.
getCdtDbtInd
()))
{
crdr
=
Mx2MtConstants
.
DRCRMARK_C
;
}
else
if
(
CreditDebitCode
.
DBIT
.
equals
(
bal
.
getCdtDbtInd
()))
{
crdr
=
Mx2MtConstants
.
DRCRMARK_D
;
}
else
{
throw
new
SwiftException
(
"ERROR"
,
"cannot find filed60 D/C Mark."
);
}
String
dateStr
=
""
;
if
(
bal
.
getDt
()
!=
null
)
{
dateStr
=
DateUtil
.
format
(
bal
.
getDt
().
getDt
(),
"yyMMdd"
);
}
String
ccy
=
""
;
String
amtStr
=
""
;
ActiveOrHistoricCurrencyAndAmount
ccyAndAmt
=
bal
.
getAmt
();
if
(
ccyAndAmt
!=
null
)
{
ccy
=
ccyAndAmt
.
getCcy
();
BigDecimal
amt
=
ccyAndAmt
.
getValue
();
amtStr
=
NumberUtil
.
formatAmt
(
amt
,
ccy
);
}
map
.
put
(
"field62"
,
crdr
+
dateStr
+
ccy
+
amtStr
);
}
Document
document
=
(
Document
)
map
.
get
(
Mx2MtConstants
.
MX_XML_DOCUMENT
);
int
balCounts
=
getXmlNodeCounts
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Bal"
);
if
(
balCounts
>=
1
){
String
filed62Option
=
""
;
String
cd
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Bal(1).Tp.CdOrPrtry.Cd"
);
if
(
BalanceType12Code
.
CLBD
.
equals
(
BalanceType12Code
.
valueOf
(
cd
)))
{
filed62Option
=
"F"
;
}
else
if
(
BalanceType12Code
.
ITBD
.
equals
(
BalanceType12Code
.
valueOf
(
cd
)))
{
filed62Option
=
"M"
;
}
else
{
throw
new
SwiftException
(
"ERROR"
,
"cannot find filed62Option."
);
}
map
.
put
(
"field62Option"
,
filed62Option
);
String
cdtDbtInd
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Bal(1).CdtDbtInd"
);
String
crdr
=
""
;
if
(
CreditDebitCode
.
CRDT
.
value
().
equals
(
cdtDbtInd
))
{
crdr
=
Mx2MtConstants
.
DRCRMARK_C
;
}
else
if
(
CreditDebitCode
.
DBIT
.
value
().
equals
(
cdtDbtInd
))
{
crdr
=
Mx2MtConstants
.
DRCRMARK_D
;
}
else
{
throw
new
SwiftException
(
"ERROR"
,
"cannot find filed60 D/C Mark."
);
}
String
dt
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Bal(1).Dt.Dt"
);
String
dateStr
=
""
;
if
(
StringUtil
.
isNotEmpty
(
dt
))
{
XMLGregorianCalendar
dateDt
=
DatatypeFactory
.
newInstance
().
newXMLGregorianCalendar
(
dt
);
dateStr
=
DateUtil
.
format
(
dateDt
,
"yyMMdd"
);
}
String
amtStr
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Bal(1).Amt"
);
String
ccyStr
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Bal(1).Amt@Ccy"
);
String
amt
=
""
;
String
ccy
=
""
;
if
(
StringUtil
.
isNotEmpty
(
amtStr
)
&&
StringUtil
.
isNotEmpty
(
ccyStr
))
{
amt
=
NumberUtil
.
formatAmt
(
new
BigDecimal
(
amtStr
),
ccyStr
);
ccy
=
ccyStr
;
}
map
.
put
(
"field62"
,
crdr
+
dateStr
+
ccy
+
amt
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
());
...
...
src/main/java/com/prowidesoftware/brilliance/mx2mt/mt940950/impl/Field64Generate.java
View file @
ad4e11fc
...
...
@@ -5,13 +5,16 @@ import com.prowidesoftware.brilliance.exception.SwiftException;
import
com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate
;
import
com.prowidesoftware.brilliance.util.DateUtil
;
import
com.prowidesoftware.brilliance.util.NumberUtil
;
import
com.prowidesoftware.swift.model.mx.MxCamt05300102
;
import
com.prowidesoftware.swift.model.mx.dic.*
;
import
com.prowidesoftware.brilliance.util.StringUtil
;
import
com.prowidesoftware.swift.model.mx.dic.BalanceType12Code
;
import
com.prowidesoftware.swift.model.mx.dic.CreditDebitCode
;
import
org.dom4j.Document
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.xml.datatype.DatatypeFactory
;
import
javax.xml.datatype.XMLGregorianCalendar
;
import
java.math.BigDecimal
;
import
java.util.List
;
/**
* <Stmt><Bal>[i]<Tp><CdOrPrtry><Cd>
...
...
@@ -28,53 +31,41 @@ public class Field64Generate extends AbstractMx2MtFieldsGenerate{
@Override
public
void
fieldsGenerate
()
throws
SwiftException
{
try
{
MxCamt05300102
mxCamt05300102
=
(
MxCamt05300102
)
map
.
get
(
Mx2MtConstants
.
MX_OBJECT
);
if
(
mxCamt05300102
==
null
||
mxCamt05300102
.
getBkToCstmrStmt
()
==
null
)
{
return
;
}
BankToCustomerStatementV02
bkToCstmrStmt
=
mxCamt05300102
.
getBkToCstmrStmt
();
List
<
AccountStatement2
>
stmtList
=
bkToCstmrStmt
.
getStmt
();
if
(
stmtList
!=
null
&&
stmtList
.
size
()
>
0
)
{
AccountStatement2
stmt
=
stmtList
.
get
(
0
);
List
<
CashBalance3
>
balList
=
stmt
.
getBal
();
CashBalance3
bal
=
null
;
if
(
balList
!=
null
&&
balList
.
size
()
>
0
)
{
for
(
CashBalance3
tmpBal
:
balList
)
{
if
(
tmpBal
!=
null
&&
tmpBal
.
getTp
()
!=
null
&&
tmpBal
.
getTp
().
getCdOrPrtry
()
!=
null
&&
BalanceType12Code
.
CLAV
.
equals
(
tmpBal
.
getTp
().
getCdOrPrtry
().
getCd
()))
{
bal
=
tmpBal
;
break
;
map
.
put
(
"field64"
,
""
);
Document
document
=
(
Document
)
map
.
get
(
Mx2MtConstants
.
MX_XML_DOCUMENT
);
int
balCounts
=
getXmlNodeCounts
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Bal"
);
if
(
balCounts
>
0
){
for
(
int
i
=
0
;
i
<
balCounts
;
i
++)
{
String
cd
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Bal("
+
i
+
").Tp.CdOrPrtry.Cd"
);
if
(
BalanceType12Code
.
CLAV
.
value
().
equals
(
cd
)){
String
cdtDbtInd
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Bal("
+
i
+
").CdtDbtInd"
);
String
crdr
=
""
;
if
(
CreditDebitCode
.
CRDT
.
value
().
equals
(
cdtDbtInd
))
{
crdr
=
Mx2MtConstants
.
DRCRMARK_C
;
}
else
if
(
CreditDebitCode
.
DBIT
.
value
().
equals
(
cdtDbtInd
))
{
crdr
=
Mx2MtConstants
.
DRCRMARK_D
;
}
else
{
throw
new
SwiftException
(
"ERROR"
,
"cannot find filed60 D/C Mark."
);
}
String
dt
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Bal("
+
i
+
").Dt.Dt"
);
String
dateStr
=
""
;
if
(
StringUtil
.
isNotEmpty
(
dt
))
{
XMLGregorianCalendar
dateDt
=
DatatypeFactory
.
newInstance
().
newXMLGregorianCalendar
(
dt
);
dateStr
=
DateUtil
.
format
(
dateDt
,
"yyMMdd"
);
}
String
amtStr
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Bal("
+
i
+
").Amt"
);
String
ccyStr
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Bal("
+
i
+
").Amt@Ccy"
);
String
amt
=
""
;
String
ccy
=
""
;
if
(
StringUtil
.
isNotEmpty
(
amtStr
)
&&
StringUtil
.
isNotEmpty
(
ccyStr
))
{
amt
=
NumberUtil
.
formatAmt
(
new
BigDecimal
(
amtStr
),
ccyStr
);
ccy
=
ccyStr
;
}
map
.
put
(
"field64"
,
crdr
+
dateStr
+
ccy
+
amt
);
}
}
if
(
bal
!=
null
)
{
//exist 64
String
crdr
=
""
;
if
(
CreditDebitCode
.
CRDT
.
equals
(
bal
.
getCdtDbtInd
()))
{
crdr
=
Mx2MtConstants
.
DRCRMARK_C
;
}
else
if
(
CreditDebitCode
.
DBIT
.
equals
(
bal
.
getCdtDbtInd
()))
{
crdr
=
Mx2MtConstants
.
DRCRMARK_D
;
}
else
{
throw
new
SwiftException
(
"ERROR"
,
"cannot find filed64 D/C Mark."
);
}
String
dateStr
=
""
;
if
(
bal
.
getDt
()
!=
null
)
{
dateStr
=
DateUtil
.
format
(
bal
.
getDt
().
getDt
(),
"yyMMdd"
);
}
String
ccy
=
""
;
String
amtStr
=
""
;
ActiveOrHistoricCurrencyAndAmount
ccyAndAmt
=
bal
.
getAmt
();
if
(
ccyAndAmt
!=
null
)
{
ccy
=
ccyAndAmt
.
getCcy
();
BigDecimal
amt
=
ccyAndAmt
.
getValue
();
amtStr
=
NumberUtil
.
formatAmt
(
amt
,
ccy
);
}
String
filed64
=
crdr
+
dateStr
+
ccy
+
amtStr
;
map
.
put
(
"field64"
,
filed64
);
}
else
{
map
.
put
(
"field64"
,
""
);
}
}
else
{
map
.
put
(
"field64"
,
" "
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
());
...
...
src/main/java/com/prowidesoftware/brilliance/mx2mt/mt940950/impl/Field65Generate.java
View file @
ad4e11fc
...
...
@@ -5,13 +5,16 @@ import com.prowidesoftware.brilliance.exception.SwiftException;
import
com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate
;
import
com.prowidesoftware.brilliance.util.DateUtil
;
import
com.prowidesoftware.brilliance.util.NumberUtil
;
import
com.prowidesoftware.swift.model.mx.MxCamt05300102
;
import
com.prowidesoftware.swift.model.mx.dic.*
;
import
com.prowidesoftware.brilliance.util.StringUtil
;
import
com.prowidesoftware.swift.model.mx.dic.BalanceType12Code
;
import
com.prowidesoftware.swift.model.mx.dic.CreditDebitCode
;
import
org.dom4j.Document
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.xml.datatype.DatatypeFactory
;
import
javax.xml.datatype.XMLGregorianCalendar
;
import
java.math.BigDecimal
;
import
java.util.List
;
/**
* <Stmt><Bal>[i]<Tp><CdOrPrtry><Cd>
...
...
@@ -28,51 +31,41 @@ public class Field65Generate extends AbstractMx2MtFieldsGenerate {
@Override
public
void
fieldsGenerate
()
throws
SwiftException
{
try
{
MxCamt05300102
mxCamt05300102
=
(
MxCamt05300102
)
map
.
get
(
Mx2MtConstants
.
MX_OBJECT
);
if
(
mxCamt05300102
==
null
||
mxCamt05300102
.
getBkToCstmrStmt
()
==
null
)
{
return
;
}
BankToCustomerStatementV02
bkToCstmrStmt
=
mxCamt05300102
.
getBkToCstmrStmt
();
List
<
AccountStatement2
>
stmtList
=
bkToCstmrStmt
.
getStmt
();
if
(
stmtList
!=
null
&&
stmtList
.
size
()
>
0
)
{
AccountStatement2
stmt
=
stmtList
.
get
(
0
);
List
<
CashBalance3
>
balList
=
stmt
.
getBal
();
CashBalance3
bal
=
null
;
if
(
balList
!=
null
&&
balList
.
size
()
>
0
)
{
for
(
CashBalance3
tmpBal
:
balList
)
{
if
(
tmpBal
!=
null
&&
tmpBal
.
getTp
()
!=
null
&&
tmpBal
.
getTp
().
getCdOrPrtry
()
!=
null
&&
BalanceType12Code
.
FWAV
.
equals
(
tmpBal
.
getTp
().
getCdOrPrtry
().
getCd
()))
{
bal
=
tmpBal
;
break
;
map
.
put
(
"field65"
,
""
);
Document
document
=
(
Document
)
map
.
get
(
Mx2MtConstants
.
MX_XML_DOCUMENT
);
int
balCounts
=
getXmlNodeCounts
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Bal"
);
if
(
balCounts
>
0
){
for
(
int
i
=
0
;
i
<
balCounts
;
i
++)
{
String
cd
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Bal("
+
i
+
").Tp.CdOrPrtry.Cd"
);
if
(
BalanceType12Code
.
FWAV
.
equals
(
BalanceType12Code
.
valueOf
(
cd
))){
String
cdtDbtInd
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Bal("
+
i
+
").CdtDbtInd"
);
String
crdr
=
""
;
if
(
CreditDebitCode
.
CRDT
.
value
().
equals
(
cdtDbtInd
))
{
crdr
=
Mx2MtConstants
.
DRCRMARK_C
;
}
else
if
(
CreditDebitCode
.
DBIT
.
value
().
equals
(
cdtDbtInd
))
{
crdr
=
Mx2MtConstants
.
DRCRMARK_D
;
}
else
{
throw
new
SwiftException
(
"ERROR"
,
"cannot find filed60 D/C Mark."
);
}
String
dt
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Bal("
+
i
+
").Dt.Dt"
);
String
dateStr
=
""
;
if
(
StringUtil
.
isNotEmpty
(
dt
))
{
XMLGregorianCalendar
dateDt
=
DatatypeFactory
.
newInstance
().
newXMLGregorianCalendar
(
dt
);
dateStr
=
DateUtil
.
format
(
dateDt
,
"yyMMdd"
);
}
String
amtStr
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Bal("
+
i
+
").Amt"
);
String
ccyStr
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.Bal("
+
i
+
").Amt@Ccy"
);
String
amt
=
""
;
String
ccy
=
""
;
if
(
StringUtil
.
isNotEmpty
(
amtStr
)
&&
StringUtil
.
isNotEmpty
(
ccyStr
))
{
amt
=
NumberUtil
.
formatAmt
(
new
BigDecimal
(
amtStr
),
ccyStr
);
ccy
=
ccyStr
;
}
map
.
put
(
"field65"
,
crdr
+
dateStr
+
ccy
+
amt
);
}
}
if
(
bal
!=
null
)
{
//exist 65
String
crdr
=
""
;
if
(
CreditDebitCode
.
CRDT
.
equals
(
bal
.
getCdtDbtInd
()))
{
crdr
=
Mx2MtConstants
.
DRCRMARK_C
;
}
else
if
(
CreditDebitCode
.
DBIT
.
equals
(
bal
.
getCdtDbtInd
()))
{
crdr
=
Mx2MtConstants
.
DRCRMARK_D
;
}
else
{
throw
new
SwiftException
(
"ERROR"
,
"cannot find filed65 D/C Mark."
);
}
String
dateStr
=
""
;
if
(
bal
.
getDt
()
!=
null
)
{
dateStr
=
DateUtil
.
format
(
bal
.
getDt
().
getDt
(),
"yyMMdd"
);
}
String
ccy
=
""
;
String
amtStr
=
""
;
ActiveOrHistoricCurrencyAndAmount
ccyAndAmt
=
bal
.
getAmt
();
if
(
ccyAndAmt
!=
null
)
{
ccy
=
ccyAndAmt
.
getCcy
();
BigDecimal
amt
=
ccyAndAmt
.
getValue
();
amtStr
=
NumberUtil
.
formatAmt
(
amt
,
ccy
);
}
String
filed65
=
crdr
+
dateStr
+
ccy
+
amtStr
;
map
.
put
(
"field65"
,
filed65
);
}
}
else
{
map
.
put
(
"field65"
,
""
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
());
...
...
src/main/java/com/prowidesoftware/brilliance/mx2mt/mt940950/impl/Field86Generate.java
View file @
ad4e11fc
...
...
@@ -4,15 +4,10 @@ import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import
com.prowidesoftware.brilliance.exception.SwiftException
;
import
com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate
;
import
com.prowidesoftware.brilliance.util.StringUtil
;
import
com.prowidesoftware.swift.model.mx.MxCamt05300102
;
import
com.prowidesoftware.swift.model.mx.dic.AccountStatement2
;
import
com.prowidesoftware.swift.model.mx.dic.BankToCustomerStatementV02
;
import
org.apache.commons.lang.StringUtils
;
import
org.dom4j.Document
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.List
;
/**
*<Stmt><AddtlStmtInf>
*
...
...
@@ -24,17 +19,12 @@ public class Field86Generate extends AbstractMx2MtFieldsGenerate {
@Override
public
void
fieldsGenerate
()
throws
SwiftException
{
try
{
MxCamt05300102
mxCamt05300102
=
(
MxCamt05300102
)
map
.
get
(
Mx2MtConstants
.
MX_OBJECT
);
if
(
mxCamt05300102
==
null
||
mxCamt05300102
.
getBkToCstmrStmt
()
==
null
)
{
return
;
}
BankToCustomerStatementV02
bkToCstmrStmt
=
mxCamt05300102
.
getBkToCstmrStmt
();
List
<
AccountStatement2
>
stmtList
=
bkToCstmrStmt
.
getStmt
();
if
(
stmtList
!=
null
&&
stmtList
.
size
()
>
0
)
{
AccountStatement2
stmt
=
stmtList
.
get
(
0
);
if
(
StringUtils
.
isNotEmpty
(
stmt
.
getAddtlStmtInf
()))
{
map
.
put
(
"field86"
,
StringUtil
.
getStringByEnter
(
stmt
.
getAddtlStmtInf
(),
35
,
6
));
}
String
addtlStmtInf
=
""
;
Document
document
=
(
Document
)
map
.
get
(
Mx2MtConstants
.
MX_XML_DOCUMENT
);
String
stmtInf
=
getXmlNodeValue
(
Mx2MtConstants
.
MAINBODY_PARENT_ELEMENT_NAME
,
document
,
"Stmt.AddtlStmtInf"
);
if
(
StringUtil
.
isNotEmpty
(
stmtInf
))
{
addtlStmtInf
=
stmtInf
;
map
.
put
(
"field86"
,
addtlStmtInf
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
());
...
...
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