Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
slm-fileview
Project
Project
Details
Activity
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
梁杰芳
slm-fileview
Commits
37c37868
Commit
37c37868
authored
Dec 25, 2020
by
chenkailing
Committed by
kl
Dec 25, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Office组件启动异步化,提速应用启动速度到5秒内
parent
01218e4a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
16 deletions
+25
-16
OfficeProcessManager.java
...src/main/java/cn/keking/service/OfficeProcessManager.java
+14
-5
OfficeToPdfService.java
...b/src/main/java/cn/keking/service/OfficeToPdfService.java
+6
-6
OfficeFilePreviewImpl.java
...in/java/cn/keking/service/impl/OfficeFilePreviewImpl.java
+5
-5
No files found.
jodconverter-web/src/main/java/cn/keking/
utils/ConverterUtils
.java
→
jodconverter-web/src/main/java/cn/keking/
service/OfficeProcessManager
.java
View file @
37c37868
package
cn
.
keking
.
utils
;
package
cn
.
keking
.
service
;
import
com.sun.star.document.UpdateDocMode
;
import
com.sun.star.document.UpdateDocMode
;
import
cn.keking.extend.ControlDocumentFormatRegistry
;
import
cn.keking.extend.ControlDocumentFormatRegistry
;
...
@@ -9,6 +9,8 @@ import org.artofsolving.jodconverter.office.OfficeManager;
...
@@ -9,6 +9,8 @@ import org.artofsolving.jodconverter.office.OfficeManager;
import
org.artofsolving.jodconverter.office.OfficeUtils
;
import
org.artofsolving.jodconverter.office.OfficeUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.core.Ordered
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.PostConstruct
;
...
@@ -29,16 +31,23 @@ import java.util.Properties;
...
@@ -29,16 +31,23 @@ import java.util.Properties;
* @date 2017/11/13
* @date 2017/11/13
*/
*/
@Component
@Component
public
class
ConverterUtils
{
@Order
(
Ordered
.
HIGHEST_PRECEDENCE
)
public
class
OfficeProcessManager
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ConverterUtils
.
class
);
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
OfficeProcessManager
.
class
);
private
OfficeManager
officeManager
;
private
OfficeManager
officeManager
;
@PostConstruct
@PostConstruct
public
void
initOfficeManager
()
{
public
void
initOfficeManager
()
{
File
officeHome
;
new
Thread
(
this
::
startOfficeManager
).
start
();
officeHome
=
OfficeUtils
.
getDefaultOfficeHome
();
}
/**
* 启动Office组件进程
*/
private
void
startOfficeManager
(){
File
officeHome
=
OfficeUtils
.
getDefaultOfficeHome
();
if
(
officeHome
==
null
)
{
if
(
officeHome
==
null
)
{
throw
new
RuntimeException
(
"找不到office组件,请确认'office.home'配置是否有误"
);
throw
new
RuntimeException
(
"找不到office组件,请确认'office.home'配置是否有误"
);
}
}
...
...
jodconverter-web/src/main/java/cn/keking/
utils/OfficeToPdf
.java
→
jodconverter-web/src/main/java/cn/keking/
service/OfficeToPdfService
.java
View file @
37c37868
package
cn
.
keking
.
utils
;
package
cn
.
keking
.
service
;
import
org.artofsolving.jodconverter.OfficeDocumentConverter
;
import
org.artofsolving.jodconverter.OfficeDocumentConverter
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -9,11 +9,11 @@ import java.io.File;
...
@@ -9,11 +9,11 @@ import java.io.File;
* @author yudian-it
* @author yudian-it
*/
*/
@Component
@Component
public
class
OfficeToPdf
{
public
class
OfficeToPdf
Service
{
private
final
ConverterUtils
converterUtils
;
private
final
OfficeProcessManager
officeProcessManager
;
public
OfficeToPdf
(
ConverterUtils
converterUtils
)
{
public
OfficeToPdf
Service
(
OfficeProcessManager
officeProcessManager
)
{
this
.
converterUtils
=
converterUtils
;
this
.
officeProcessManager
=
officeProcessManager
;
}
}
public
void
openOfficeToPDF
(
String
inputFilePath
,
String
outputFilePath
)
{
public
void
openOfficeToPDF
(
String
inputFilePath
,
String
outputFilePath
)
{
...
@@ -33,7 +33,7 @@ public class OfficeToPdf {
...
@@ -33,7 +33,7 @@ public class OfficeToPdf {
public
void
office2pdf
(
String
inputFilePath
,
String
outputFilePath
)
{
public
void
office2pdf
(
String
inputFilePath
,
String
outputFilePath
)
{
OfficeDocumentConverter
converter
=
converterUtils
.
getDocumentConverter
();
OfficeDocumentConverter
converter
=
officeProcessManager
.
getDocumentConverter
();
if
(
null
!=
inputFilePath
)
{
if
(
null
!=
inputFilePath
)
{
File
inputFile
=
new
File
(
inputFilePath
);
File
inputFile
=
new
File
(
inputFilePath
);
// 判断目标文件路径是否为空
// 判断目标文件路径是否为空
...
...
jodconverter-web/src/main/java/cn/keking/service/impl/OfficeFilePreviewImpl.java
View file @
37c37868
...
@@ -6,7 +6,7 @@ import cn.keking.model.ReturnResponse;
...
@@ -6,7 +6,7 @@ import cn.keking.model.ReturnResponse;
import
cn.keking.service.FilePreview
;
import
cn.keking.service.FilePreview
;
import
cn.keking.utils.DownloadUtils
;
import
cn.keking.utils.DownloadUtils
;
import
cn.keking.utils.FileUtils
;
import
cn.keking.utils.FileUtils
;
import
cn.keking.
utils.OfficeToPdf
;
import
cn.keking.
service.OfficeToPdfService
;
import
cn.keking.utils.PdfUtils
;
import
cn.keking.utils.PdfUtils
;
import
cn.keking.web.filter.BaseUrlFilter
;
import
cn.keking.web.filter.BaseUrlFilter
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -25,13 +25,13 @@ public class OfficeFilePreviewImpl implements FilePreview {
...
@@ -25,13 +25,13 @@ public class OfficeFilePreviewImpl implements FilePreview {
private
final
FileUtils
fileUtils
;
private
final
FileUtils
fileUtils
;
private
final
PdfUtils
pdfUtils
;
private
final
PdfUtils
pdfUtils
;
private
final
DownloadUtils
downloadUtils
;
private
final
DownloadUtils
downloadUtils
;
private
final
OfficeToPdf
officeToPdf
;
private
final
OfficeToPdf
Service
officeToPdfService
;
public
OfficeFilePreviewImpl
(
FileUtils
fileUtils
,
PdfUtils
pdfUtils
,
DownloadUtils
downloadUtils
,
OfficeToPdf
officeToPdf
)
{
public
OfficeFilePreviewImpl
(
FileUtils
fileUtils
,
PdfUtils
pdfUtils
,
DownloadUtils
downloadUtils
,
OfficeToPdf
Service
officeToPdfService
)
{
this
.
fileUtils
=
fileUtils
;
this
.
fileUtils
=
fileUtils
;
this
.
pdfUtils
=
pdfUtils
;
this
.
pdfUtils
=
pdfUtils
;
this
.
downloadUtils
=
downloadUtils
;
this
.
downloadUtils
=
downloadUtils
;
this
.
officeToPdf
=
officeToPdf
;
this
.
officeToPdf
Service
=
officeToPdfService
;
}
}
public
static
final
String
OFFICE_PREVIEW_TYPE_IMAGE
=
"image"
;
public
static
final
String
OFFICE_PREVIEW_TYPE_IMAGE
=
"image"
;
...
@@ -59,7 +59,7 @@ public class OfficeFilePreviewImpl implements FilePreview {
...
@@ -59,7 +59,7 @@ public class OfficeFilePreviewImpl implements FilePreview {
}
}
filePath
=
response
.
getContent
();
filePath
=
response
.
getContent
();
if
(
StringUtils
.
hasText
(
outFilePath
))
{
if
(
StringUtils
.
hasText
(
outFilePath
))
{
officeToPdf
.
openOfficeToPDF
(
filePath
,
outFilePath
);
officeToPdf
Service
.
openOfficeToPDF
(
filePath
,
outFilePath
);
if
(
isHtml
)
{
if
(
isHtml
)
{
// 对转换后的文件进行操作(改变编码方式)
// 对转换后的文件进行操作(改变编码方式)
fileUtils
.
doActionConvertedFile
(
outFilePath
);
fileUtils
.
doActionConvertedFile
(
outFilePath
);
...
...
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