Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
leaf-hlcm
Project
Project
Details
Activity
Releases
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
hlcm
leaf-hlcm
Commits
c58b71fd
Commit
c58b71fd
authored
Mar 10, 2021
by
111
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
对账单打印
parent
efbf12be
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
94 additions
and
24 deletions
+94
-24
ConExportServiceImpl.java
...hand/hls/hlcm/cont/service/impl/ConExportServiceImpl.java
+94
-24
No files found.
src/main/java/com/hand/hls/hlcm/cont/service/impl/ConExportServiceImpl.java
View file @
c58b71fd
...
@@ -11,8 +11,13 @@ import com.hand.hls.hlcm.cont.service.ConExportService;
...
@@ -11,8 +11,13 @@ import com.hand.hls.hlcm.cont.service.ConExportService;
import
java.awt.image.BufferedImage
;
import
java.awt.image.BufferedImage
;
import
java.io.*
;
import
java.io.*
;
import
java.math.BigDecimal
;
import
java.net.URL
;
import
java.net.URL
;
import
java.net.URLEncoder
;
import
java.net.URLEncoder
;
import
java.text.DecimalFormat
;
import
java.text.DecimalFormatSymbols
;
import
java.text.NumberFormat
;
import
java.text.ParseException
;
import
java.util.*
;
import
java.util.*
;
import
javax.imageio.ImageIO
;
import
javax.imageio.ImageIO
;
...
@@ -22,14 +27,14 @@ import javax.servlet.http.HttpServletResponse;
...
@@ -22,14 +27,14 @@ import javax.servlet.http.HttpServletResponse;
import
com.hand.hls.hlcm.cont.util.ExcelFormatUtil
;
import
com.hand.hls.hlcm.cont.util.ExcelFormatUtil
;
import
org.apache.poi.hssf.usermodel.HSSFCellStyle
;
import
org.apache.poi.hssf.usermodel.HSSFCellStyle
;
import
org.apache.poi.hssf.usermodel.HSSFDataFormat
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.ss.usermodel.CellStyle
;
import
org.apache.poi.ss.usermodel.*
;
import
org.apache.poi.ss.usermodel.ClientAnchor
;
import
org.apache.poi.ss.usermodel.HorizontalAlignment
;
import
org.apache.poi.ss.usermodel.VerticalAlignment
;
import
org.apache.poi.ss.util.CellRangeAddress
;
import
org.apache.poi.ss.util.CellRangeAddress
;
import
org.apache.poi.xssf.streaming.*
;
import
org.apache.poi.xssf.streaming.*
;
import
org.apache.poi.xssf.usermodel.XSSFClientAnchor
;
import
org.apache.poi.xssf.usermodel.XSSFClientAnchor
;
import
org.apache.poi.xssf.usermodel.XSSFDataFormat
;
import
org.codehaus.jackson.annotate.JsonSubTypes
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -61,7 +66,7 @@ public class ConExportServiceImpl implements ConExportService {
...
@@ -61,7 +66,7 @@ public class ConExportServiceImpl implements ConExportService {
//return null;
//return null;
}
}
private
void
export
(
HashMap
map
,
LinkedList
list
,
HttpServletResponse
response
)
{
private
void
export
(
HashMap
map
,
LinkedList
list
,
HttpServletResponse
response
)
throws
ParseException
{
//logger.info(">>>>>>>>>>>>>>>>>>>>开始进入导出方法>>>>>>>>>>");
//logger.info(">>>>>>>>>>>>>>>>>>>>开始进入导出方法>>>>>>>>>>");
SXSSFWorkbook
wb
=
new
SXSSFWorkbook
(
1000
);
// 保留1000条数据在内存中
SXSSFWorkbook
wb
=
new
SXSSFWorkbook
(
1000
);
// 保留1000条数据在内存中
SXSSFSheet
sheet
=
wb
.
createSheet
();
SXSSFSheet
sheet
=
wb
.
createSheet
();
...
@@ -75,7 +80,6 @@ public class ConExportServiceImpl implements ConExportService {
...
@@ -75,7 +80,6 @@ public class ConExportServiceImpl implements ConExportService {
ClassLoader
classLoader
=
this
.
getClass
().
getClassLoader
();
ClassLoader
classLoader
=
this
.
getClass
().
getClassLoader
();
URL
resource
=
classLoader
.
getResource
(
"/"
);
URL
resource
=
classLoader
.
getResource
(
"/"
);
String
path
=
resource
.
getPath
();
String
path
=
resource
.
getPath
();
System
.
out
.
println
(
path
);
bufferImg
=
ImageIO
.
read
(
new
File
(
path
+
"com/hand/hls/hlcm/cont/img/HonglingNew.jpg"
));
bufferImg
=
ImageIO
.
read
(
new
File
(
path
+
"com/hand/hls/hlcm/cont/img/HonglingNew.jpg"
));
ImageIO
.
write
(
bufferImg
,
"jpg"
,
byteArrayOut
);
ImageIO
.
write
(
bufferImg
,
"jpg"
,
byteArrayOut
);
...
@@ -178,52 +182,103 @@ public class ConExportServiceImpl implements ConExportService {
...
@@ -178,52 +182,103 @@ public class ConExportServiceImpl implements ConExportService {
//logger.info(">>>>>>>>>>>>>>>>>>>>开始遍历数据组装单元格内容>>>>>>>>>>");
//logger.info(">>>>>>>>>>>>>>>>>>>>开始遍历数据组装单元格内容>>>>>>>>>>");
// 每一列字段名
// 每一列字段名
String
[]
strs
=
new
String
[]{
"款项性质"
,
"期次"
,
"约定支付日"
,
"应付金额"
,
"实际收款日"
,
"收款金额"
,
"实收违约金"
,
"未收金额"
};
// String[] strs = new String[]{"款项性质", "期次", "约定支付日", "应付金额", "实际收款日", "收款金额", "实收违约金", "未收金额"};
// modify by lihh 20210308 修改描述为当期逾期金额
String
[]
strs
=
new
String
[]{
"款项性质"
,
"期次"
,
"约定支付日"
,
"应付金额"
,
"实际收款日"
,
"收款金额"
,
"实收违约金"
,
"当期逾期金额"
};
// 字段名所在表格的宽度
// 字段名所在表格的宽度
int
[]
ints
=
new
int
[]{
2500
,
1800
,
3000
,
3000
,
3000
,
3000
,
3000
,
3000
};
int
[]
ints
=
new
int
[]{
2500
,
1800
,
3000
,
3000
,
3000
,
3000
,
3000
,
3000
};
// 设置表头样式
// 设置表头样式
ExcelFormatUtil
.
initColumn
(
sheet
,
contentTable
,
strs
,
ints
,
16
);
ExcelFormatUtil
.
initColumn
(
sheet
,
contentTable
,
strs
,
ints
,
16
);
//logger.info(">>>>>>>>>>>>>>>>>>>>表头样式设置完成>>>>>>>>>>");
//logger.info(">>>>>>>>>>>>>>>>>>>>表头样式设置完成>>>>>>>>>>");
double
amount
=
0
;
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
LinkedHashMap
<
String
,
Object
>
map1
=
(
LinkedHashMap
<
String
,
Object
>)
list
.
get
(
i
);
LinkedHashMap
<
String
,
Object
>
map1
=
(
LinkedHashMap
<
String
,
Object
>)
list
.
get
(
i
);
SXSSFRow
row
=
sheet
.
createRow
(
i
+
17
);
SXSSFRow
row
=
sheet
.
createRow
(
i
+
17
);
int
j
=
1
;
int
j
=
1
;
SXSSFCell
cell
=
row
.
createCell
(
j
++);
SXSSFCell
cell
=
row
.
createCell
(
j
++);
if
(
map1
.
get
(
"CF_ITEM_N"
)
!=
null
)
{
if
(
map1
.
get
(
"CF_ITEM_N"
)
!=
null
)
{
cell
.
setCellValue
((
String
)
map1
.
get
(
"CF_ITEM_N"
));
// 款项性质
// add by lihh 判断记录是否重复
}
else
{
if
(
i
>=
1
&&
map1
.
get
(
"TIMES"
)
!=
null
){
cell
.
setCellValue
(
""
);
// 款项性质
// 获取上一条记录
LinkedHashMap
<
String
,
Object
>
temp
=
(
LinkedHashMap
<
String
,
Object
>)
list
.
get
(
i
-
1
);
if
(!
map1
.
get
(
"TIMES"
).
equals
(
temp
.
get
(
"TIMES"
))
||
!(
map1
.
get
(
"CF_ITEM_N"
).
equals
(
temp
.
get
(
"CF_ITEM_N"
))))
{
cell
.
setCellValue
((
String
)
map1
.
get
(
"CF_ITEM_N"
));
// 款项性质
}
else
{
// 重复记录的金额
amount
+=
new
DecimalFormat
().
parse
(
map1
.
get
(
"DUE_AMOUNT"
).
toString
()).
doubleValue
();
cell
.
setCellValue
(
""
);
// 款项性质
}
}
else
{
cell
.
setCellValue
((
String
)
map1
.
get
(
"CF_ITEM_N"
));
// 款项性质
}
}
}
cell
.
setCellStyle
(
contentTable
);
cell
.
setCellStyle
(
contentTable
);
cell
=
row
.
createCell
(
j
++);
cell
=
row
.
createCell
(
j
++);
if
(
map1
.
get
(
"TIMES"
)
!=
null
)
{
if
(
map1
.
get
(
"TIMES"
)
!=
null
)
{
cell
.
setCellValue
(
ExcelFormatUtil
.
getBigDecimal
(
map1
.
get
(
"TIMES"
)).
toString
());
// 期次
if
(
i
>=
1
){
}
else
{
LinkedHashMap
<
String
,
Object
>
temp
=
(
LinkedHashMap
<
String
,
Object
>)
list
.
get
(
i
-
1
);
cell
.
setCellValue
(
""
);
// 期次
if
(!
map1
.
get
(
"TIMES"
).
equals
(
temp
.
get
(
"TIMES"
))||
!(
map1
.
get
(
"CF_ITEM_N"
).
equals
(
temp
.
get
(
"CF_ITEM_N"
))))
{
cell
.
setCellValue
(
map1
.
get
(
"TIMES"
).
toString
());
// 期次
}
else
{
cell
.
setCellValue
(
""
);
// 期次
}
}
else
{
cell
.
setCellValue
(
map1
.
get
(
"TIMES"
).
toString
());
// 期次
}
}
}
cell
.
setCellStyle
(
contentTable
);
cell
.
setCellStyle
(
contentTable
);
cell
=
row
.
createCell
(
j
++);
cell
=
row
.
createCell
(
j
++);
if
(
map1
.
get
(
"DUE_DATE"
)
!=
null
)
{
if
(
map1
.
get
(
"DUE_DATE"
)
!=
null
)
{
cell
.
setCellValue
((
String
)
map1
.
get
(
"DUE_DATE"
));
// 应付日
if
(
i
>=
1
)
{
}
else
{
LinkedHashMap
<
String
,
Object
>
temp
=
(
LinkedHashMap
<
String
,
Object
>)
list
.
get
(
i
-
1
);
cell
.
setCellValue
(
""
);
// 应付日
if
(!
map1
.
get
(
"TIMES"
).
equals
(
temp
.
get
(
"TIMES"
))||
!(
map1
.
get
(
"CF_ITEM_N"
).
equals
(
temp
.
get
(
"CF_ITEM_N"
))))
{
cell
.
setCellValue
((
String
)
map1
.
get
(
"DUE_DATE"
));
// 应付日
}
else
{
cell
.
setCellValue
(
""
);
// 应付日
}
}
else
{
cell
.
setCellValue
((
String
)
map1
.
get
(
"DUE_DATE"
));
// 应付日
}
}
}
cell
.
setCellStyle
(
contentTable
);
cell
.
setCellStyle
(
contentTable
);
cell
=
row
.
createCell
(
j
++);
cell
=
row
.
createCell
(
j
++);
if
(
map1
.
get
(
"DUE_AMOUNT"
)
!=
null
)
{
if
(
map1
.
get
(
"DUE_AMOUNT"
)
!=
null
)
{
cell
.
setCellValue
((
String
)
map1
.
get
(
"DUE_AMOUNT"
));
// 应付金额
if
(
i
>=
1
)
{
// 取上一条记录
LinkedHashMap
<
String
,
Object
>
temp
=
(
LinkedHashMap
<
String
,
Object
>)
list
.
get
(
i
-
1
);
BigDecimal
x
=
new
BigDecimal
(
100
);
//如果CF_ITEM = 100, 打印计算后的合计金额
if
(
x
.
compareTo
((
BigDecimal
)
map1
.
get
(
"CF_ITEM"
))
==
0
){
DataFormat
df
=
wb
.
createDataFormat
();
// 此处设置数据格式
contentTable
.
setDataFormat
(
df
.
getFormat
(
"#,##0.00"
));
//保留两位小数点
cell
.
setCellStyle
(
contentTable
);
cell
.
setCellValue
(
new
DecimalFormat
().
parse
(
map1
.
get
(
"DUE_AMOUNT"
).
toString
()).
doubleValue
()-
amount
);
//如果期次和性质跟上条记录不一样,则打印
}
else
if
(!
map1
.
get
(
"TIMES"
).
equals
(
temp
.
get
(
"TIMES"
))||
!(
map1
.
get
(
"CF_ITEM_N"
).
equals
(
temp
.
get
(
"CF_ITEM_N"
))))
{
DataFormat
df
=
wb
.
createDataFormat
();
// 此处设置数据格式
contentTable
.
setDataFormat
(
df
.
getFormat
(
"#,##0.00"
));
//保留两位小数点
cell
.
setCellStyle
(
contentTable
);
cell
.
setCellValue
(
new
DecimalFormat
().
parse
(
map1
.
get
(
"DUE_AMOUNT"
).
toString
()).
doubleValue
());
//否则置空
}
else
{
cell
.
setCellValue
(
""
);
}
//如果是首付款,直接打印
}
else
{
DataFormat
df
=
wb
.
createDataFormat
();
// 此处设置数据格式
contentTable
.
setDataFormat
(
df
.
getFormat
(
"#,##0.00"
));
//保留两位小数点
cell
.
setCellStyle
(
contentTable
);
cell
.
setCellValue
(
new
DecimalFormat
().
parse
(
map1
.
get
(
"DUE_AMOUNT"
).
toString
()).
doubleValue
());
}
}
else
{
}
else
{
cell
.
setCellValue
(
""
);
// 应付金额
cell
.
setCellValue
(
""
);
// 应付金额
}
}
cell
.
setCellStyle
(
contentTable
);
cell
.
setCellStyle
(
contentTable
);
cell
=
row
.
createCell
(
j
++);
cell
=
row
.
createCell
(
j
++);
if
(
map1
.
get
(
"TRANSACTION_DATE"
)
!=
null
)
{
if
(
map1
.
get
(
"TRANSACTION_DATE"
)
!=
null
)
{
cell
.
setCellValue
((
String
)
map1
.
get
(
"TRANSACTION_DATE"
));
// 实际收款日
cell
.
setCellValue
((
String
)
map1
.
get
(
"TRANSACTION_DATE"
));
// 实际收款日
...
@@ -234,7 +289,10 @@ public class ConExportServiceImpl implements ConExportService {
...
@@ -234,7 +289,10 @@ public class ConExportServiceImpl implements ConExportService {
cell
=
row
.
createCell
(
j
++);
cell
=
row
.
createCell
(
j
++);
if
(
map1
.
get
(
"RECEIVED_AMOUNT"
)
!=
null
)
{
if
(
map1
.
get
(
"RECEIVED_AMOUNT"
)
!=
null
)
{
cell
.
setCellValue
((
String
)
map1
.
get
(
"RECEIVED_AMOUNT"
));
// 收款金额
DataFormat
df
=
wb
.
createDataFormat
();
// 此处设置数据格式
contentTable
.
setDataFormat
(
df
.
getFormat
(
"#,##0.00"
));
//保留两位小数点
cell
.
setCellStyle
(
contentTable
);
cell
.
setCellValue
(
new
DecimalFormat
().
parse
(
map1
.
get
(
"RECEIVED_AMOUNT"
).
toString
()).
doubleValue
());
// 收款金额
}
else
{
}
else
{
cell
.
setCellValue
(
""
);
// 收款金额
cell
.
setCellValue
(
""
);
// 收款金额
}
}
...
@@ -242,7 +300,10 @@ public class ConExportServiceImpl implements ConExportService {
...
@@ -242,7 +300,10 @@ public class ConExportServiceImpl implements ConExportService {
cell
=
row
.
createCell
(
j
++);
cell
=
row
.
createCell
(
j
++);
if
(
map1
.
get
(
"RECEIVED_AMOUNT_9"
)
!=
null
)
{
if
(
map1
.
get
(
"RECEIVED_AMOUNT_9"
)
!=
null
)
{
cell
.
setCellValue
((
String
)
map1
.
get
(
"RECEIVED_AMOUNT_9"
));
// 实收违约金
DataFormat
df
=
wb
.
createDataFormat
();
// 此处设置数据格式
contentTable
.
setDataFormat
(
df
.
getFormat
(
"#,##0.00"
));
//保留两位小数点
cell
.
setCellStyle
(
contentTable
);
cell
.
setCellValue
(
new
DecimalFormat
().
parse
(
map1
.
get
(
"RECEIVED_AMOUNT_9"
).
toString
()).
doubleValue
());
// 实收违约金
}
else
{
}
else
{
cell
.
setCellValue
(
""
);
// 实收违约金
cell
.
setCellValue
(
""
);
// 实收违约金
}
}
...
@@ -250,7 +311,16 @@ public class ConExportServiceImpl implements ConExportService {
...
@@ -250,7 +311,16 @@ public class ConExportServiceImpl implements ConExportService {
cell
=
row
.
createCell
(
j
++);
cell
=
row
.
createCell
(
j
++);
if
(
map1
.
get
(
"UNRECEIVED_AMOUNT"
)
!=
null
)
{
if
(
map1
.
get
(
"UNRECEIVED_AMOUNT"
)
!=
null
)
{
cell
.
setCellValue
((
String
)
map1
.
get
(
"UNRECEIVED_AMOUNT"
));
// 未收金额
// 合计
BigDecimal
x
=
new
BigDecimal
(
100
);
if
(
x
.
compareTo
((
BigDecimal
)
map1
.
get
(
"CF_ITEM"
))
==
0
){
cell
.
setCellValue
(
""
);
}
else
{
DataFormat
df
=
wb
.
createDataFormat
();
// 此处设置数据格式
contentTable
.
setDataFormat
(
df
.
getFormat
(
"#,##0.00"
));
//保留两位小数点
cell
.
setCellStyle
(
contentTable
);
cell
.
setCellValue
(
new
DecimalFormat
().
parse
(
map1
.
get
(
"UNRECEIVED_AMOUNT"
).
toString
()).
doubleValue
());
// 未收金额
}
}
else
{
}
else
{
cell
.
setCellValue
(
""
);
// 未收金额
cell
.
setCellValue
(
""
);
// 未收金额
}
}
...
...
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