Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
device-back
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
device-back
Commits
c3bfdfb0
提交
c3bfdfb0
authored
8月 10, 2021
作者:
133
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[工作交接] 代码提交
上级
7e057efb
全部展开
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
143 行增加
和
3 行删除
+143
-3
FileController.java
...a/com/tykj/dev/device/file/Controller/FileController.java
+1
-1
WorkHandoverDevice.java
...a/com/tykj/dev/device/file/entity/WorkHandoverDevice.java
+2
-0
JavaToPdfHtmlFreeMarker.java
...om/tykj/dev/device/file/util/JavaToPdfHtmlFreeMarker.java
+140
-2
bill13.html
dev-union/src/main/resources/bill13.html
+0
-0
没有找到文件。
dev-file/src/main/java/com/tykj/dev/device/file/Controller/FileController.java
浏览文件 @
c3bfdfb0
...
@@ -81,7 +81,7 @@ public class FileController {
...
@@ -81,7 +81,7 @@ public class FileController {
@ApiOperation
(
value
=
"生成工作交接的单据"
)
@ApiOperation
(
value
=
"生成工作交接的单据"
)
@PostMapping
(
"/wordHandover"
)
@PostMapping
(
"/wordHandover"
)
public
ResponseEntity
wordHandover
(
@RequestBody
WorkHandoverDoc
workHandoverDoc
)
{
public
ResponseEntity
wordHandover
(
@RequestBody
WorkHandoverDoc
workHandoverDoc
)
{
String
[]
content
=
JavaToPdfHtmlFreeMarker
.
freeMarkerRenderWorkHandover
(
workHandoverDoc
,
url
+
"htmlModel/"
);
String
[]
content
=
JavaToPdfHtmlFreeMarker
.
freeMarkerRenderWorkHandover
2
(
workHandoverDoc
,
url
+
"htmlModel/"
);
log
.
info
(
"[file] 生成工作交接的单据"
);
log
.
info
(
"[file] 生成工作交接的单据"
);
return
ResponseEntity
.
ok
(
JavaToPdfHtmlFreeMarker
.
createPdf
(
content
,
url
,
preview
,
"workHandover/"
));
return
ResponseEntity
.
ok
(
JavaToPdfHtmlFreeMarker
.
createPdf
(
content
,
url
,
preview
,
"workHandover/"
));
}
}
...
...
dev-file/src/main/java/com/tykj/dev/device/file/entity/WorkHandoverDevice.java
浏览文件 @
c3bfdfb0
...
@@ -59,6 +59,8 @@ public class WorkHandoverDevice {
...
@@ -59,6 +59,8 @@ public class WorkHandoverDevice {
@ApiModelProperty
(
value
=
"序列号区间"
)
@ApiModelProperty
(
value
=
"序列号区间"
)
public
String
seqs
;
public
String
seqs
;
public
int
oneCount
;
public
Integer
getLen
(){
public
Integer
getLen
(){
return
seqs
.
length
();
return
seqs
.
length
();
}
}
...
...
dev-file/src/main/java/com/tykj/dev/device/file/util/JavaToPdfHtmlFreeMarker.java
浏览文件 @
c3bfdfb0
...
@@ -823,7 +823,6 @@ public class JavaToPdfHtmlFreeMarker {
...
@@ -823,7 +823,6 @@ public class JavaToPdfHtmlFreeMarker {
}
}
List
<
String
>
endList
=
strings
.
subList
((
count
-
1
)
*
6
*
30
,
strings
.
size
());
List
<
String
>
endList
=
strings
.
subList
((
count
-
1
)
*
6
*
30
,
strings
.
size
());
Integer
max4
=
toMaxList
(
endList
);
Integer
max4
=
toMaxList
(
endList
);
int
count1
=
(
max4
%
30
>
0
)
?
max4
/
30
+
1
:
max4
/
30
;
if
(
max4
==
30
)
{
if
(
max4
==
30
)
{
Check
check1
=
new
Check
();
Check
check1
=
new
Check
();
check1
.
setSeqStirng
(
toALLSeqStirng
(
endList
));
check1
.
setSeqStirng
(
toALLSeqStirng
(
endList
));
...
@@ -1411,7 +1410,7 @@ public class JavaToPdfHtmlFreeMarker {
...
@@ -1411,7 +1410,7 @@ public class JavaToPdfHtmlFreeMarker {
}
}
/**
/**
* 计算每一页打印的内容
* 计算每一页打印的内容
(遗弃)
* 判断是否超过一页展示的最多的内容
* 判断是否超过一页展示的最多的内容
* 如大于
* 如大于
* 直接生成一个页面的数据 放入到集合中 List<List<DocumentDevice>>
* 直接生成一个页面的数据 放入到集合中 List<List<DocumentDevice>>
...
@@ -2001,4 +2000,143 @@ public class JavaToPdfHtmlFreeMarker {
...
@@ -2001,4 +2000,143 @@ public class JavaToPdfHtmlFreeMarker {
return
allStirng
.
toString
();
return
allStirng
.
toString
();
}
}
/**
* 工作交接计算每一页数据
* @param deviceList
* @return
* @throws UnsupportedEncodingException
*/
public
static
List
<
List
<
WorkHandoverDevice
>>
toWorkHandoverDeviceList
(
List
<
WorkHandoverDevice
>
deviceList
)
throws
UnsupportedEncodingException
{
List
<
List
<
WorkHandoverDevice
>>
lists
=
new
ArrayList
<>();
List
<
WorkHandoverDevice
>
revenues
=
new
ArrayList
<>();
deviceList
=
deviceList
.
stream
().
sorted
(
Comparator
.
comparing
(
WorkHandoverDevice:
:
getModel
).
thenComparing
(
WorkHandoverDevice:
:
getName
)).
collect
(
Collectors
.
toList
());
Integer
code
=
0
;
int
i
=
0
;
for
(
int
j
=
0
;
j
<
deviceList
.
size
();
j
++){
WorkHandoverDevice
workHandoverDevice
=
deviceList
.
get
(
j
);
int
max
=
toWorkHandoverMax
(
workHandoverDevice
);
if
(
i
+
max
==
19
){
workHandoverDevice
.
setModel
(
String
.
join
(
""
,
toListString
(
workHandoverDevice
.
getModel
(),
16
)));
workHandoverDevice
.
setName
(
String
.
join
(
""
,
toListString
(
workHandoverDevice
.
getName
(),
16
)));
workHandoverDevice
.
setSeqs
(
String
.
join
(
""
,
toListString
(
workHandoverDevice
.
getSeqs
(),
32
)));
workHandoverDevice
.
setOneCount
(
max
);
code
++;
workHandoverDevice
.
setCode
(
code
);
revenues
.
add
(
workHandoverDevice
);
lists
.
add
(
revenues
);
revenues
=
new
ArrayList
<>();
i
=
0
;
}
else
if
(
i
+
max
>
19
){
//当前页面少了多少行
int
differ
=
19
-
i
;
List
<
String
>
modelList
=
toListString
(
workHandoverDevice
.
getModel
(),
16
);
List
<
String
>
nameList
=
toListString
(
workHandoverDevice
.
getName
(),
16
);
List
<
String
>
seqList
=
toListString
(
workHandoverDevice
.
getSeqs
(),
32
);
WorkHandoverDevice
workHandoverDevice1
=
new
WorkHandoverDevice
();
if
(
modelList
.
size
()>
differ
){
workHandoverDevice
.
setModel
(
String
.
join
(
""
,
modelList
.
subList
(
0
,
differ
)));
workHandoverDevice1
.
setModel
(
String
.
join
(
""
,
modelList
.
subList
(
differ
,
modelList
.
size
())));
}
else
{
workHandoverDevice
.
setModel
(
String
.
join
(
""
,
modelList
));
}
if
(
nameList
.
size
()>
differ
){
workHandoverDevice
.
setName
(
String
.
join
(
""
,
nameList
.
subList
(
0
,
differ
)));
workHandoverDevice1
.
setName
(
String
.
join
(
""
,
nameList
.
subList
(
differ
,
nameList
.
size
())));
}
else
{
workHandoverDevice
.
setName
(
String
.
join
(
""
,
nameList
));
}
if
(
seqList
.
size
()>
differ
){
workHandoverDevice
.
setSeqs
(
String
.
join
(
""
,
seqList
.
subList
(
0
,
differ
)));
workHandoverDevice1
.
setSeqs
(
String
.
join
(
""
,
seqList
.
subList
(
differ
,
seqList
.
size
())));
}
else
{
workHandoverDevice
.
setSeqs
(
String
.
join
(
""
,
seqList
));
}
code
++;
workHandoverDevice
.
setCode
(
code
);
workHandoverDevice
.
setOneCount
(
differ
);
revenues
.
add
(
workHandoverDevice
);
lists
.
add
(
revenues
);
revenues
=
new
ArrayList
<>();
workHandoverDevice1
.
setOneCount
(
max
-
differ
);
code
++;
workHandoverDevice1
.
setCode
(
code
);
revenues
.
add
(
workHandoverDevice1
);
i
=
max
-
differ
;
}
else
{
code
++;
workHandoverDevice
.
setModel
(
String
.
join
(
""
,
toListString
(
workHandoverDevice
.
getModel
(),
16
)));
workHandoverDevice
.
setName
(
String
.
join
(
""
,
toListString
(
workHandoverDevice
.
getName
(),
16
)));
workHandoverDevice
.
setSeqs
(
String
.
join
(
""
,
toListString
(
workHandoverDevice
.
getSeqs
(),
32
)));
workHandoverDevice
.
setCode
(
code
);
workHandoverDevice
.
setOneCount
(
max
);
revenues
.
add
(
workHandoverDevice
);
i
=
i
+
max
;
}
}
if
(
revenues
.
size
()!=
0
){
lists
.
add
(
revenues
);
}
return
lists
;
}
private
static
Integer
toWorkHandoverMax
(
WorkHandoverDevice
workHandoverDevice
){
int
nameCount
=
String_length
(
workHandoverDevice
.
getName
());
int
modelCount
=
String_length
(
workHandoverDevice
.
getModel
());
int
seqCount
=
String_length
(
workHandoverDevice
.
getSeqs
());
int
name
=
(
nameCount
%
16
>
0
)
?
nameCount
/
16
+
1
:
nameCount
/
16
;
int
model
=(
modelCount
%
16
>
0
)
?
modelCount
/
16
+
1
:
modelCount
/
16
;
int
seq
=(
seqCount
%
32
>
0
)
?
seqCount
/
32
+
1
:
seqCount
/
32
;
int
max
=
name
;
//求最大
if
(
max
<
model
){
max
=
model
;
}
if
(
max
<
seq
){
max
=
seq
;
}
return
max
;
}
/**
* freemarker渲染html workHandoverDoc
*/
public
static
String
[]
freeMarkerRenderWorkHandover2
(
WorkHandoverDoc
workHandoverDoc
,
String
htmlPath
)
{
Writer
out
=
new
StringWriter
();
String
[]
strings
=
new
String
[
100000
];
int
index
=
0
;
try
{
// 获取模板,并设置编码方式
Template
template
=
freemarkerCfg
.
getTemplate
(
"bill13.html"
);
template
.
setEncoding
(
"UTF-8"
);
List
<
WorkHandoverDevice
>
list
=
workHandoverDoc
.
getWorkHandoverDeviceList
();
List
<
List
<
WorkHandoverDevice
>>
listList
=
toWorkHandoverDeviceList
(
list
);
Integer
count
=
listList
.
size
();
for
(
int
i
=
1
;
i
<=
3
;
i
++){
Integer
page
=
1
;
for
(
List
<
WorkHandoverDevice
>
list1:
listList
)
{
String
htmlname
=
htmlPath
+
UUID
.
randomUUID
().
toString
()+
".html"
;
// 合并数据模型与模板
FileWriter
fileWriter
=
new
FileWriter
(
new
File
(
htmlname
));
template
.
process
(
toMapWork
(
workHandoverDoc
,
list1
,
MAP1
.
get
(
i
),
page
,
count
),
fileWriter
);
out
.
flush
();
strings
[
index
]=
htmlname
;
index
++;
page
++;
}
}
return
strings
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
out
.
close
();
}
catch
(
IOException
ex
)
{
ex
.
printStackTrace
();
}
}
return
null
;
}
}
}
dev-union/src/main/resources/bill13.html
0 → 100755
浏览文件 @
c3bfdfb0
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论