Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
device-back
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
device-back
Commits
d6f71b75
提交
d6f71b75
authored
6月 21, 2021
作者:
133
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[模版 字体] 上传了字体以及模版
上级
a1f15bad
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
361 行增加
和
4 行删除
+361
-4
FileController.java
...a/com/tykj/dev/device/file/Controller/FileController.java
+12
-0
DocumentDevice.java
.../java/com/tykj/dev/device/file/entity/DocumentDevice.java
+3
-0
PdfServiceImpl.java
...com/tykj/dev/device/file/service/Impl/PdfServiceImpl.java
+1
-1
JavaToPdfHtmlFreeMarker.java
...om/tykj/dev/device/file/util/JavaToPdfHtmlFreeMarker.java
+99
-1
bill.html
dev-union/src/main/resources/bill.html
+1
-1
bill2.html
dev-union/src/main/resources/bill2.html
+1
-1
bill5.html
dev-union/src/main/resources/bill5.html
+244
-0
simhei.ttf
dev-union/src/main/resources/simhei.ttf
+0
-0
simhei2.ttf
dev-union/src/main/resources/simhei2.ttf
+0
-0
没有找到文件。
dev-file/src/main/java/com/tykj/dev/device/file/Controller/FileController.java
浏览文件 @
d6f71b75
...
@@ -114,6 +114,18 @@ public class FileController {
...
@@ -114,6 +114,18 @@ public class FileController {
return
ResponseEntity
.
ok
(
JavaToPdfHtmlFreeMarker
.
createPdf
(
content
,
url
,
preview
,
"confirm/"
));
return
ResponseEntity
.
ok
(
JavaToPdfHtmlFreeMarker
.
createPdf
(
content
,
url
,
preview
,
"confirm/"
));
}
}
/**
* 生成单据 核查确认单据
* @return
*/
@ApiOperation
(
value
=
"生成单据 核查确认单据"
)
@PostMapping
(
"/printVerification"
)
public
ResponseEntity
printVerification
(
@RequestBody
Confirm
confirm
)
{
String
[]
content
=
JavaToPdfHtmlFreeMarker
.
freeMarkerRenderVerification
(
confirm
,
url
+
"htmlModel/"
);
log
.
info
(
"[file] 调用了生成核查确认单据对接口 confirm"
);
return
ResponseEntity
.
ok
(
JavaToPdfHtmlFreeMarker
.
createPdf
(
content
,
url
,
preview
,
"confirm/"
));
}
/**
/**
* 生成单据 销毁单据
* 生成单据 销毁单据
* @return
* @return
...
...
dev-file/src/main/java/com/tykj/dev/device/file/entity/DocumentDevice.java
浏览文件 @
d6f71b75
...
@@ -52,6 +52,9 @@ public class DocumentDevice {
...
@@ -52,6 +52,9 @@ public class DocumentDevice {
@ApiModelProperty
(
value
=
"校对"
)
@ApiModelProperty
(
value
=
"校对"
)
private
String
proofreading
;
private
String
proofreading
;
@ApiModelProperty
(
value
=
"状态"
)
private
String
status
;
private
Integer
oneCount
;
private
Integer
oneCount
;
public
Integer
getLen
(){
public
Integer
getLen
(){
...
...
dev-file/src/main/java/com/tykj/dev/device/file/service/Impl/PdfServiceImpl.java
浏览文件 @
d6f71b75
...
@@ -37,7 +37,7 @@ public class PdfServiceImpl implements PdfService {
...
@@ -37,7 +37,7 @@ public class PdfServiceImpl implements PdfService {
}
}
private
DocumentDevice
toDocDev
(
ScriptSaveVo
scriptSaveVo
){
private
DocumentDevice
toDocDev
(
ScriptSaveVo
scriptSaveVo
){
return
new
DocumentDevice
(
null
,
scriptSaveVo
.
getModel
(),
null
,
scriptSaveVo
.
getType
(),
scriptSaveVo
.
getSecretLevel
(),
scriptSaveVo
.
getInvisibleRange
(),
scriptSaveVo
.
getNum
(),
scriptSaveVo
.
getSeqNumber
(),
null
,
scriptSaveVo
.
getRemark
(),
null
,
null
);
return
new
DocumentDevice
(
null
,
scriptSaveVo
.
getModel
(),
null
,
scriptSaveVo
.
getType
(),
scriptSaveVo
.
getSecretLevel
(),
scriptSaveVo
.
getInvisibleRange
(),
scriptSaveVo
.
getNum
(),
scriptSaveVo
.
getSeqNumber
(),
null
,
scriptSaveVo
.
getRemark
(),
null
,
null
,
null
);
}
}
}
}
dev-file/src/main/java/com/tykj/dev/device/file/util/JavaToPdfHtmlFreeMarker.java
浏览文件 @
d6f71b75
...
@@ -115,7 +115,8 @@ public class JavaToPdfHtmlFreeMarker {
...
@@ -115,7 +115,8 @@ public class JavaToPdfHtmlFreeMarker {
renderer
.
setDocument
(
htmlFile
);
renderer
.
setDocument
(
htmlFile
);
// 解决中文不显示问题
// 解决中文不显示问题
ITextFontResolver
fontResolver
=
renderer
.
getFontResolver
();
ITextFontResolver
fontResolver
=
renderer
.
getFontResolver
();
fontResolver
.
addFont
(
path
+
"fond/"
+
"simhei.ttf"
,
BaseFont
.
IDENTITY_H
,
BaseFont
.
NOT_EMBEDDED
);
fontResolver
.
addFont
(
"simhei.ttf"
,
BaseFont
.
IDENTITY_H
,
BaseFont
.
NOT_EMBEDDED
);
fontResolver
.
addFont
(
"simhei2.ttf"
,
BaseFont
.
IDENTITY_H
,
BaseFont
.
NOT_EMBEDDED
);
renderer
.
layout
();
renderer
.
layout
();
renderer
.
createPDF
(
os
);
renderer
.
createPDF
(
os
);
PdfReader
pdfReader
=
new
PdfReader
(
os
.
toByteArray
());
PdfReader
pdfReader
=
new
PdfReader
(
os
.
toByteArray
());
...
@@ -511,6 +512,45 @@ public class JavaToPdfHtmlFreeMarker {
...
@@ -511,6 +512,45 @@ public class JavaToPdfHtmlFreeMarker {
return
null
;
return
null
;
}
}
/**
* freemarker渲染html 核查确认单据
*/
public
static
String
[]
freeMarkerRenderVerification
(
Confirm
confirm
,
String
htmlPath
)
{
Writer
out
=
new
StringWriter
();
String
[]
strings
=
new
String
[
100000
];
int
index
=
0
;
try
{
Template
template
=
freemarkerCfg
.
getTemplate
(
"bill5.html"
);
template
.
setEncoding
(
"UTF-8"
);
List
<
DocumentDevice
>
list
=
confirm
.
getConfirmDevices
();
List
<
List
<
DocumentDevice
>>
listList
=
toVerificationList
(
list
);
int
count
=
listList
.
size
();
Integer
page
=
1
;
for
(
List
<
DocumentDevice
>
list1:
listList
)
{
String
htmlname
=
htmlPath
+
UUID
.
randomUUID
().
toString
()+
".html"
;
// 合并数据模型与模板
FileWriter
fileWriter
=
new
FileWriter
(
new
File
(
htmlname
));
template
.
process
(
toConfirmMap
(
confirm
,
list1
,
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
;
}
// /**
// /**
// * 确认单据页面调用接口
// * 确认单据页面调用接口
// */
// */
...
@@ -742,6 +782,64 @@ public class JavaToPdfHtmlFreeMarker {
...
@@ -742,6 +782,64 @@ public class JavaToPdfHtmlFreeMarker {
// return new FileRet();
// return new FileRet();
// }
// }
/**
* 核查清单
* @param deviceList
* @return
*/
private
static
List
<
List
<
DocumentDevice
>>
toVerificationList
(
List
<
DocumentDevice
>
deviceList
){
List
<
List
<
DocumentDevice
>>
lists
=
new
ArrayList
<>();
List
<
DocumentDevice
>
documentDevices
=
new
ArrayList
<>();
int
i
=
0
;
for
(
DocumentDevice
documentDevice
:
deviceList
)
{
int
max
=
toVerificationMax
(
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
Integer
toVerificationMax
(
DocumentDevice
documentDevice
){
int
partsCount
=
String_length
(
documentDevice
.
getParts
());
int
deviceSerialNumberCount
=
String_length
(
documentDevice
.
getDeviceSerialNumber
());
int
modelCount
=
String_length
(
documentDevice
.
getModel
());
int
parts
=
(
partsCount
%
17
>
0
)
?
partsCount
/
17
+
1
:
partsCount
/
17
;
int
deviceSerialNumber
=(
deviceSerialNumberCount
%
22
>
0
)
?
deviceSerialNumberCount
/
22
+
1
:
deviceSerialNumberCount
/
22
;
int
model
=(
modelCount
%
17
>
0
)
?
modelCount
/
17
+
1
:
modelCount
/
17
;
int
max
=
parts
;
//求最大
if
(
max
<
deviceSerialNumber
){
max
=
deviceSerialNumber
;
}
if
(
max
<
model
)
{
max
=
model
;
}
return
max
;
}
/**
* 自查确认单据
* @param deviceList
* @return
*/
private
static
List
<
List
<
DocumentDevice
>>
toConfirmList
(
List
<
DocumentDevice
>
deviceList
){
private
static
List
<
List
<
DocumentDevice
>>
toConfirmList
(
List
<
DocumentDevice
>
deviceList
){
List
<
List
<
DocumentDevice
>>
lists
=
new
ArrayList
<>();
List
<
List
<
DocumentDevice
>>
lists
=
new
ArrayList
<>();
List
<
DocumentDevice
>
documentDevices
=
new
ArrayList
<>();
List
<
DocumentDevice
>
documentDevices
=
new
ArrayList
<>();
...
...
dev-union/src/main/resources/bill.html
浏览文件 @
d6f71b75
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
<style>
<style>
body
,
span
,
p
,
tr
,
td
{
body
,
span
,
p
,
tr
,
td
{
font-size
:
15px
;
font-size
:
15px
;
font-family
:
SimHei
;
font-family
:
FangSong_GB2312
;
margin
:
0
;
margin
:
0
;
padding
:
0
;
padding
:
0
;
}
}
...
...
dev-union/src/main/resources/bill2.html
浏览文件 @
d6f71b75
...
@@ -186,7 +186,7 @@
...
@@ -186,7 +186,7 @@
<tr>
<tr>
<th
width=
"30px"
>
序号
</th>
<th
width=
"30px"
>
序号
</th>
<th
style=
"width: 150px;"
>
型号
</th>
<th
style=
"width: 150px;"
>
型号
</th>
<th
style=
"width: 150px"
>
部件
</th>
<th
style=
"width: 150px"
>
名称
</th>
<th
width=
"80px"
>
应用领域
</th>
<th
width=
"80px"
>
应用领域
</th>
<th
width=
"150"
>
装备序列号
</th>
<th
width=
"150"
>
装备序列号
</th>
<th
width=
"80px"
>
检查结果
</th>
<th
width=
"80px"
>
检查结果
</th>
...
...
dev-union/src/main/resources/bill5.html
0 → 100755
浏览文件 @
d6f71b75
<!DOCTYPE html>
<html
lang=
"en"
>
<!--核查确认-->
<head>
<meta
charset=
"UTF-8"
/>
<title>
Document
</title>
<style>
body
,
span
,
p
,
tr
,
td
{
font-size
:
15px
;
font-family
:
SimHei
;
margin
:
0
;
padding
:
0
;
}
.bottomTxt
{
text-align
:
center
;
font-size
:
15px
;
color
:
#000
;
height
:
15px
;
line-height
:
10px
;
}
/*
@page
{
size
:
297mm
210mm
;}
<!
--
设置
PDF
页面大小,此配置只对生成
PDF
文件有效,不会对页面显示生效
--
>*/
@page
{
size
:
210mm
297mm
;
/*margin: 0.25in;*/
/*-fs-flow-bottom: "footer";*/
/*-fs-flow-left: "left";*/
/*-fs-flow-right: "right";*/
/*border: thin solid black;*/
/*padding: 1em;*/
}
.returnTablePrint
{
width
:
100%
;
height
:
100%
;
overflow
:
hidden
;
color
:
#000
;
cursor
:
default
;
}
.returnTablePrint
.content
{
width
:
100%
;
height
:
100%
;
/* background: url("../../../assets/img/detailsBg.png") no-repeat; */
/*background-size: 100% 100%;*/
/*padding: 30px;*/
/*box-sizing: border-box;*/
}
.returnTablePrint
.content
>
div
{
width
:
100%
;
height
:
100%
;
background
:
#fff
;
/* padding: 30px; */
box-sizing
:
border-box
;
}
.returnTablePrint
.content
>
p
{
width
:
100%
;
text-align
:
center
;
font-size
:
22px
;
font-weight
:
bold
;
color
:
#4a475d
;
}
.returnTablePrint
.listWrapper
{
/* width: 92%; */
margin
:
0
auto
;
/* padding: 0px 20px 20px 20px; */
height
:
calc
(
100%
-
70px
);
/*padding: 10px 30px;*/
box-sizing
:
border-box
;
}
.returnTablePrint
.list
{
/* width: 92%; */
margin
:
0
auto
;
/* padding: 0px 20px 20px 20px; */
/* height: calc(100% - 75px); */
height
:
calc
(
100%
-
12px
)
}
.returnTablePrint
.title
{
width
:
100%
;
font-size
:
20px
;
text-align
:
center
;
position
:
relative
;
margin
:
0
;
padding
:
0
;
box-sizing
:
border-box
;
margin-top
:
9px
;
}
.returnTablePrint
.title
span
:nth-child
(
2
)
{
font-size
:
28px
;
color
:
#000000
;
}
.returnTablePrint
.title
span
:nth-child
(
2
)
span
{
font-size
:
20px
;
color
:
#000
;
}
.returnTablePrint
.main-title
span
{
font-size
:
22px
;
color
:
#333
;
font-weight
:
bold
;
}
.returnTablePrint
.main-title
{
font-size
:
17px
;
color
:
#000000
;
text-align
:
center
;
}
table
.altrowstable
{
width
:
100%
;
font-size
:
15px
;
color
:
#000
;
border-width
:
0px
;
border-color
:
#a9c6c9
;
border-collapse
:
collapse
;
text-align
:
center
;
table-layout
:
fixed
;
word-break
:
break-all
;
}
table
.altrowstable
th
{
background-color
:
#dedede
;
border
:
1px
solid
#bebebe
;
height
:
24px
;
line-height
:
24px
;
font-size
:
15px
;
}
table
.altrowstable
td
{
word-break
:
break-all
;
/*border: 1px solid #bebebe;*/
word-wrap
:
break-word
;
height
:
24px
;
line-height
:
24px
;
font-size
:
15px
;
width
:
100%
;
}
.oddrowcolor
{
background-color
:
#fff
;
}
.evenrowcolor
{
background-color
:
#fafafa
;
}
.person
{
color
:
#000
;
text-align
:
right
;
font-size
:
15px
;
}
.person
>
span
{
display
:
inline-block
;
margin-right
:
30pt
;
}
tr
:nth-child
(
odd
)
{
background
:
#fafafa
;
}
</style>
</head>
<body>
<div
class=
"returnTablePrint"
>
<div
class=
"content"
>
<div>
<div
class=
"listWrapper"
>
<div
class=
"list"
>
<p
class=
"title"
style=
"margin-bottom:20px"
>
<div
class=
"main-title"
>
<span>
${title!}
</span>
</div>
</p>
<div
style=
"height: 900px;"
>
<table
class=
"altrowstable"
id=
"alternatecolor"
>
<tr>
<th
width=
"30px"
>
序号
</th>
<th
style=
"width: 130px;"
>
型号
</th>
<th
style=
"width: 130px"
>
名称
</th>
<th
width=
"60px"
>
应用领域
</th>
<th
width=
"150"
>
装备序列号
</th>
<th
width=
"100px"
>
状态
</th>
<th
width=
"80px"
>
检查结果
</th>
</tr>
<
#
list
documentDevices
as
dev
>
<tr>
<td>
${dev.code!}
</td>
<td>
${dev.model!}
</td>
<td>
${dev.parts!}
</td>
<td>
${dev.applicationField!}
</td>
<td>
${dev.deviceSerialNumber!}
</td>
<td>
${dev.status!}
</td>
<td>
${dev.proofreading!}
</td>
</tr>
</
#
list>
</table>
</div>
</div>
<p
class=
"person"
style=
"margin-top: 20px;font-size: 10px;"
>
<span
style=
"width: 200px;text-align: left"
>
经办人:
</span>
<span
style=
"width: 200px;text-align: left"
>
审核人:
</span>
</p>
</div>
</div>
</div>
<p
class=
"bottomTxt"
style=
"margin-top: 20px;"
>
第${page}页/共${count}页
</p>
</div>
<!--<script type="text/javascript">-->
<!--function altRows(id){-->
<!--if(document.getElementsByTagName){-->
<!--var table = document.getElementById(id);-->
<!--var rows = table.getElementsByTagName("tr");-->
<!--for(i = 0; i < rows.length; i++){-->
<!--if(i % 2 == 0){-->
<!--rows[i].className = "evenrowcolor";-->
<!--}else{-->
<!--rows[i].className = "oddrowcolor";-->
<!--}-->
<!--}-->
<!--}-->
<!--}-->
<!--window.onload=function(){-->
<!--altRows('alternatecolor');-->
<!--}-->
<!--</script>-->
</body>
</html>
\ No newline at end of file
dev-union/src/main/resources/simhei.ttf
0 → 100644
浏览文件 @
d6f71b75
File added
dev-union/src/main/resources/simhei2.ttf
0 → 100644
浏览文件 @
d6f71b75
File added
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论