Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
syyl
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
注册表
注册表
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
svn
syyl
Commits
54b7058e
提交
54b7058e
authored
4月 09, 2020
作者:
yucaiwei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
上级
01cf8854
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
31 行增加
和
0 行删除
+31
-0
FileController.java
...rc/main/java/com/zrqx/file/controller/FileController.java
+31
-0
没有找到文件。
com.zrqx.file/src/main/java/com/zrqx/file/controller/FileController.java
浏览文件 @
54b7058e
...
...
@@ -20,6 +20,8 @@ import java.util.Date;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipInputStream
;
import
java.util.zip.ZipOutputStream
;
...
...
@@ -51,6 +53,7 @@ import com.zrqx.core.model.file.FileInfo;
import
com.zrqx.core.util.datatype.ArrayUtils
;
import
com.zrqx.core.util.datatype.UUIDUtil
;
import
com.zrqx.core.util.download.DownloadUtil
;
import
com.zrqx.core.util.file.Txt2Pdf
;
import
com.zrqx.core.util.page.PageInfo
;
import
com.zrqx.core.util.page.PageParam
;
import
com.zrqx.core.util.response.CallBack
;
...
...
@@ -94,6 +97,15 @@ public class FileController {
if
(!
service
.
insert
(
entity
)){
throw
new
BaseException
(
"上传失败!"
);
}
// 文件解析
String
suffix
=
entity
.
getSuffixName
();
if
(
suffix
.
equalsIgnoreCase
(
".txt"
)
||
suffix
.
equalsIgnoreCase
(
".pdf"
)){
String
filePath
=
rootPath
+
entity
.
getPath
()
+
"/"
+
entity
.
getFileName
()
+
entity
.
getSuffixName
();
String
pdfPath
=
rootPath
+
entity
.
getPath
()
+
"/"
+
entity
.
getFileName
()
+
".pdf"
;
entity
.
setPdfPath
(
"/"
+
entity
.
getPath
()
+
"/"
+
entity
.
getFileName
()
+
".pdf"
);
// 文件2pdf
this
.
file2Pdf
(
filePath
,
pdfPath
);
}
return
entity
;
}
// 处理文件上传
...
...
@@ -742,4 +754,23 @@ public class FileController {
}
return
response
;
}
private
void
file2Pdf
(
String
filePath
,
String
pdfPath
){
ExecutorService
executor
=
Executors
.
newCachedThreadPool
();
executor
.
submit
(()
->
{
Boolean
isTrue
=
false
;
String
suffix
=
filePath
.
substring
(
filePath
.
lastIndexOf
(
"."
),
filePath
.
length
());
if
(
suffix
.
equalsIgnoreCase
(
".txt"
)){
logger
.
info
(
"开始转换txt:"
+
filePath
+
"-----"
+
pdfPath
);
File
file
=
new
File
(
filePath
);
logger
.
info
(
"文件大小:"
+
file
.
length
());
isTrue
=
Txt2Pdf
.
txtToPdf
(
filePath
,
pdfPath
);
logger
.
info
(
"isTrue:"
+
isTrue
);
}
if
(
isTrue
){
logger
.
info
(
filePath
.
subSequence
(
filePath
.
lastIndexOf
(
"/"
)
+
1
,
filePath
.
length
())+
"成功转换成pdf"
);
}
});
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论