Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
device-back
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
device-back
Commits
65c25e4b
提交
65c25e4b
authored
6月 10, 2021
作者:
133
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[模版提交]
上级
9354a744
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
77 行增加
和
41 行删除
+77
-41
JavaToPdfHtmlFreeMarker.java
...om/tykj/dev/device/file/util/JavaToPdfHtmlFreeMarker.java
+70
-32
bill.html
dev-union/src/main/resources/bill.html
+2
-2
bill2.html
dev-union/src/main/resources/bill2.html
+5
-7
没有找到文件。
dev-file/src/main/java/com/tykj/dev/device/file/util/JavaToPdfHtmlFreeMarker.java
浏览文件 @
65c25e4b
...
@@ -314,41 +314,22 @@ public class JavaToPdfHtmlFreeMarker {
...
@@ -314,41 +314,22 @@ public class JavaToPdfHtmlFreeMarker {
String
[]
strings
=
new
String
[
100000
];
String
[]
strings
=
new
String
[
100000
];
int
index
=
0
;
int
index
=
0
;
try
{
try
{
// 获取模板,并设置编码方式
Template
template
=
freemarkerCfg
.
getTemplate
(
"bill2.html"
);
Template
template
=
freemarkerCfg
.
getTemplate
(
"bill2.html"
);
template
.
setEncoding
(
"UTF-8"
);
template
.
setEncoding
(
"UTF-8"
);
List
<
DocumentDevice
>
list
=
confirm
.
getConfirmDevices
().
stream
().
sorted
(
Comparator
.
comparing
(
DocumentDevice:
:
getModel
)).
collect
(
Collectors
.
toList
());
boolean
falg
=
true
;
Integer
page
=
0
;
int
pageNum
=
page
+
1
;
int
pageSize
=
34
;
Integer
totalNum
=
list
.
size
();
//默认从零分页,这里要考虑这种情况,下面要计算。
Integer
totalPage
=
0
;
while
(
falg
){
if
(
totalNum
>
0
)
{
totalPage
=
totalNum
%
pageSize
==
0
?
totalNum
/
pageSize
:
totalNum
/
pageSize
+
1
;
}
if
(
pageNum
>=
totalPage
)
{
pageNum
=
totalPage
;
falg
=
false
;
}
int
startPoint
=
(
pageNum
-
1
)
*
pageSize
;
int
endPoint
=
startPoint
+
pageSize
;
if
(
totalNum
<=
endPoint
)
{
endPoint
=
totalNum
;
}
String
htmlname
=
htmlPath
+
UUID
.
randomUUID
().
toString
()+
".html"
;
List
<
DocumentDevice
>
list
=
confirm
.
getConfirmDevices
();
// 合并数据模型与模板
List
<
List
<
DocumentDevice
>>
listList
=
toConfirmList
(
list
);
FileWriter
fileWriter
=
new
FileWriter
(
new
File
(
htmlname
));
int
count
=
listList
.
size
();
template
.
process
(
toConfirmMap
(
confirm
,
list
.
subList
(
startPoint
,
endPoint
),
pageNum
,
totalPage
),
fileWriter
);
Integer
page
=
1
;
out
.
flush
();
for
(
List
<
DocumentDevice
>
list1:
listList
)
{
strings
[
index
]=
htmlname
;
String
htmlname
=
htmlPath
+
UUID
.
randomUUID
().
toString
()+
".html"
;
index
++;
// 合并数据模型与模板
pageNum
++;
FileWriter
fileWriter
=
new
FileWriter
(
new
File
(
htmlname
));
template
.
process
(
toConfirmMap
(
confirm
,
list1
,
page
,
count
),
fileWriter
);
out
.
flush
();
strings
[
index
]=
htmlname
;
index
++;
page
++;
}
}
return
strings
;
return
strings
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -594,6 +575,63 @@ public class JavaToPdfHtmlFreeMarker {
...
@@ -594,6 +575,63 @@ public class JavaToPdfHtmlFreeMarker {
// return new FileRet();
// return new FileRet();
// }
// }
private
static
List
<
List
<
DocumentDevice
>>
toConfirmList
(
List
<
DocumentDevice
>
deviceList
){
List
<
List
<
DocumentDevice
>>
lists
=
new
ArrayList
<>();
List
<
DocumentDevice
>
documentDevices
=
new
ArrayList
<>();
int
i
=
0
;
for
(
DocumentDevice
documentDevice
:
deviceList
)
{
int
max
=
toMax
(
documentDevice
);
if
(
i
+
max
==
34
)
{
documentDevices
.
add
(
documentDevice
);
lists
.
add
(
documentDevices
);
documentDevices
=
new
ArrayList
<>();
i
=
0
;
}
else
if
(
i
+
max
>
34
)
{
lists
.
add
(
documentDevices
);
documentDevices
=
new
ArrayList
<>();
documentDevices
.
add
(
documentDevice
);
i
=
max
;
}
else
{
documentDevices
.
add
(
documentDevice
);
i
=
i
+
max
;
}
}
if
(
documentDevices
.
size
()!=
0
){
lists
.
add
(
documentDevices
);
}
return
lists
;
}
private
static
int
String_length
(
String
value
)
{
int
valueLength
=
0
;
String
chinese
=
"[\u4e00-\u9fa5]"
;
for
(
int
i
=
0
;
i
<
value
.
length
();
i
++)
{
String
temp
=
value
.
substring
(
i
,
i
+
1
);
if
(
temp
.
matches
(
chinese
))
{
valueLength
+=
2
;
}
else
{
valueLength
+=
1
;
}
}
return
valueLength
;
}
private
static
Integer
toMax
(
DocumentDevice
documentDevice
){
int
partsCount
=
String_length
(
documentDevice
.
getParts
());
int
deviceSerialNumberCount
=
String_length
(
documentDevice
.
getDeviceSerialNumber
());
int
modelCount
=
String_length
(
documentDevice
.
getModel
());
int
parts
=
(
partsCount
%
20
>
0
)
?
partsCount
/
20
+
1
:
partsCount
/
20
;
int
deviceSerialNumber
=(
deviceSerialNumberCount
%
22
>
0
)
?
deviceSerialNumberCount
/
22
+
1
:
deviceSerialNumberCount
/
22
;
int
model
=(
modelCount
%
20
>
0
)
?
modelCount
/
20
+
1
:
modelCount
/
20
;
int
max
=
parts
;
//求最大
if
(
max
<
deviceSerialNumber
){
max
=
deviceSerialNumber
;
}
if
(
max
<
model
)
{
max
=
model
;
}
return
max
;
}
/**
/**
...
...
dev-union/src/main/resources/bill.html
浏览文件 @
65c25e4b
...
@@ -372,8 +372,8 @@ border:1px solid #bebebe;
...
@@ -372,8 +372,8 @@ border:1px solid #bebebe;
height
:
24px
;
height
:
24px
;
line-height
:
24px
;
line-height
:
24px
;
font-size
:
15px
;
font-size
:
15px
;
word-break
:
break-al
l
;
word-break
:
norma
l
;
word-wrap
:
break-word
;
word-wrap
:
normal
;
border
:
1px
solid
#bebebe
;
border
:
1px
solid
#bebebe
;
width
:
100%
;
width
:
100%
;
}
}
...
...
dev-union/src/main/resources/bill2.html
浏览文件 @
65c25e4b
...
@@ -184,13 +184,12 @@
...
@@ -184,13 +184,12 @@
<div
style=
"height: 900px;"
>
<div
style=
"height: 900px;"
>
<table
class=
"altrowstable"
id=
"alternatecolor"
>
<table
class=
"altrowstable"
id=
"alternatecolor"
>
<tr>
<tr>
<th
width=
"
7
0px"
>
序号
</th>
<th
width=
"
3
0px"
>
序号
</th>
<th
style=
"width: 150px;"
>
型号
</th>
<th
style=
"width: 150px;"
>
型号
</th>
<th>
部件
</th>
<th
style=
"width: 150px"
>
部件
</th>
<th
width=
"100px"
>
密级
</th>
<th
width=
"80px"
>
应用领域
</th>
<th
width=
"100px"
>
应用领域
</th>
<th
width=
"150"
>
装备序列号
</th>
<th>
装备序列号
</th>
<th
width=
"80px"
>
检查结果
</th>
<th>
检查结果
</th>
</tr>
</tr>
<
#
list
documentDevices
as
dev
>
<
#
list
documentDevices
as
dev
>
<tr>
<tr>
...
@@ -199,7 +198,6 @@
...
@@ -199,7 +198,6 @@
</td>
</td>
<td>
${dev.model!}
</td>
<td>
${dev.model!}
</td>
<td>
${dev.parts!}
</td>
<td>
${dev.parts!}
</td>
<td>
${dev.securityClassification!}
</td>
<td>
${dev.applicationField!}
</td>
<td>
${dev.applicationField!}
</td>
<td>
${dev.deviceSerialNumber!}
</td>
<td>
${dev.deviceSerialNumber!}
</td>
<td>
${dev.proofreading!}
</td>
<td>
${dev.proofreading!}
</td>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论