Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YeeAmosFireAutoSysRoot
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
station
YeeAmosFireAutoSysRoot
Commits
c43a0f75
Commit
c43a0f75
authored
Feb 27, 2020
by
单奇雲
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增pdf 导航查看及 文本预案下载接口
parent
8ea74792
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
185 additions
and
4 deletions
+185
-4
pom.xml
YeeAmosFireAutoSysService/pom.xml
+7
-1
FileController.java
.../yeejoin/amos/fas/business/controller/FileController.java
+14
-2
PlanVisual3dController.java
.../amos/fas/business/controller/PlanVisual3dController.java
+69
-0
FileUtil.java
...rc/main/java/com/yeejoin/amos/fas/core/util/FileUtil.java
+1
-0
MyNode.java
.../src/main/java/com/yeejoin/amos/fas/core/util/MyNode.java
+14
-0
PdfUtil.java
...src/main/java/com/yeejoin/amos/fas/core/util/PdfUtil.java
+78
-0
pom.xml
pom.xml
+2
-1
No files found.
YeeAmosFireAutoSysService/pom.xml
View file @
c43a0f75
...
@@ -94,7 +94,12 @@
...
@@ -94,7 +94,12 @@
<artifactId>
easypoi-annotation
</artifactId>
<artifactId>
easypoi-annotation
</artifactId>
<version>
3.0.3
</version>
<version>
3.0.3
</version>
</dependency>
</dependency>
<dependency>
<groupId>
com.itextpdf
</groupId>
<artifactId>
itextpdf
</artifactId>
<version>
5.5.13
</version>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
\ No newline at end of file
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/controller/FileController.java
View file @
c43a0f75
...
@@ -14,12 +14,15 @@ import org.slf4j.Logger;
...
@@ -14,12 +14,15 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.util.ResourceUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
import
java.io.*
;
import
java.net.URL
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -129,7 +132,7 @@ public class FileController extends BaseController {
...
@@ -129,7 +132,7 @@ public class FileController extends BaseController {
ResponseUtils
.
renderText
(
response
,
"File not exists!"
);
ResponseUtils
.
renderText
(
response
,
"File not exists!"
);
}
}
}
}
/**
/**
* 删除文件
* 删除文件
*
*
...
@@ -234,8 +237,17 @@ public class FileController extends BaseController {
...
@@ -234,8 +237,17 @@ public class FileController extends BaseController {
processData
.
put
(
"html"
,
"/"
+
filePath
.
substring
(
0
,
filePath
.
lastIndexOf
(
"."
))
+
".html"
);
processData
.
put
(
"html"
,
"/"
+
filePath
.
substring
(
0
,
filePath
.
lastIndexOf
(
"."
))
+
".html"
);
return
new
CommonResponse
(
SUCCESS
,
processData
,
"查询成功"
);
return
new
CommonResponse
(
SUCCESS
,
processData
,
"查询成功"
);
}
else
{
}
if
(
fileName
.
endsWith
(
".pdf"
))
{
Map
<
String
,
Object
>
processData
=
new
HashMap
<
String
,
Object
>();
MyNode
node
=
PdfUtil
.
getPdfNavs
(
fileName
);
processData
.
put
(
"nodes"
,
node
.
getChildren
());
String
filePath
=
obj
.
getString
(
"file"
);
processData
.
put
(
"html"
,
"/"
+
filePath
.
substring
(
0
,
filePath
.
lastIndexOf
(
"."
))
+
".pdf"
);
return
new
CommonResponse
(
SUCCESS
,
processData
,
"查询成功"
);
}
else
{
return
new
CommonResponse
(
SUCCESS
,
"文件类型不为doc/docx"
,
"查询成功"
);
return
new
CommonResponse
(
SUCCESS
,
"文件类型不为doc/docx"
,
"查询成功"
);
}
}
}
}
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/controller/PlanVisual3dController.java
View file @
c43a0f75
package
com
.
yeejoin
.
amos
.
fas
.
business
.
controller
;
package
com
.
yeejoin
.
amos
.
fas
.
business
.
controller
;
import
com.yeejoin.amos.fas.business.service.intfc.IPlanVisual3dService
;
import
com.yeejoin.amos.fas.business.service.intfc.IPlanVisual3dService
;
import
com.yeejoin.amos.fas.dao.entity.TextPlan
;
import
com.yeejoin.amos.op.core.common.response.CommonResponse
;
import
com.yeejoin.amos.op.core.common.response.CommonResponse
;
import
com.yeejoin.amos.op.core.util.CommonResponseUtil
;
import
com.yeejoin.amos.op.core.util.CommonResponseUtil
;
import
com.yeejoin.amos.security.authorization.Authorization
;
import
com.yeejoin.amos.security.authorization.Authorization
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
io.swagger.annotations.ApiParam
;
import
java.io.BufferedInputStream
;
import
java.io.BufferedOutputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RestController
...
@@ -21,9 +36,18 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -21,9 +36,18 @@ import org.springframework.web.bind.annotation.RestController;
public
class
PlanVisual3dController
extends
BaseController
{
public
class
PlanVisual3dController
extends
BaseController
{
private
final
Logger
log
=
LoggerFactory
.
getLogger
(
PlanVisual3dController
.
class
);
private
final
Logger
log
=
LoggerFactory
.
getLogger
(
PlanVisual3dController
.
class
);
// 上传路径
@Value
(
"${file.uploadUrl}"
)
private
String
fileUploadDir
;
@Autowired
@Autowired
private
IPlanVisual3dService
planVisual3dService
;
private
IPlanVisual3dService
planVisual3dService
;
@Autowired
HttpServletResponse
response
;
@Autowired
HttpServletRequest
request
;
@ApiOperation
(
value
=
"预案应用树"
,
notes
=
"预案应用树"
)
@ApiOperation
(
value
=
"预案应用树"
,
notes
=
"预案应用树"
)
@GetMapping
(
value
=
"/plan/tree"
)
@GetMapping
(
value
=
"/plan/tree"
)
...
@@ -36,6 +60,51 @@ public class PlanVisual3dController extends BaseController {
...
@@ -36,6 +60,51 @@ public class PlanVisual3dController extends BaseController {
public
CommonResponse
getTextPlanById
(
@PathVariable
(
value
=
"id"
)
Long
id
)
{
public
CommonResponse
getTextPlanById
(
@PathVariable
(
value
=
"id"
)
Long
id
)
{
return
CommonResponseUtil
.
success
(
planVisual3dService
.
getTextPlanInfoById
(
id
));
return
CommonResponseUtil
.
success
(
planVisual3dService
.
getTextPlanInfoById
(
id
));
}
}
@Authorization
(
ingore
=
true
)
@RequestMapping
(
value
=
"/plan/text/downloadFile/{id}"
,
method
=
RequestMethod
.
GET
)
public
HttpServletResponse
download
(
@PathVariable
(
"id"
)
Long
id
)
{
TextPlan
testPlan
=
planVisual3dService
.
getTextPlanInfoById
(
id
);
if
(
testPlan
!=
null
)
{
String
path
=
testPlan
.
getFilePath
();
if
(
path
!=
null
&&
!
""
.
equals
(
path
))
{
try
{
// path是指欲下载的文件的路径。
File
file
=
new
File
(
fileUploadDir
+
path
);
if
(
file
.
exists
())
{
// 取得文件名。
String
filename
=
file
.
getName
();
// 取得文件的后缀名。
String
ext
=
filename
.
substring
(
filename
.
lastIndexOf
(
"."
)
+
1
).
toUpperCase
();
// 以流的形式下载文件。
InputStream
fis
=
new
BufferedInputStream
(
new
FileInputStream
(
fileUploadDir
+
path
));
byte
[]
buffer
=
new
byte
[
fis
.
available
()];
fis
.
read
(
buffer
);
fis
.
close
();
// 清空response
// response.reset();
// 设置response的Header
response
.
addHeader
(
"Content-Disposition"
,
"attachment;filename="
+
new
String
(
filename
.
getBytes
()));
response
.
addHeader
(
"Content-Length"
,
""
+
file
.
length
());
response
.
setContentType
(
"application/x-download"
);
OutputStream
toClient
=
new
BufferedOutputStream
(
response
.
getOutputStream
());
response
.
setContentType
(
"application/octet-stream"
);
toClient
.
write
(
buffer
);
toClient
.
flush
();
toClient
.
close
();
}
else
{
response
.
setStatus
(
404
);
}
}
catch
(
IOException
ex
)
{
ex
.
printStackTrace
();
}
}
}
else
{
response
.
setStatus
(
404
);
}
return
response
;
}
/**
/**
* 资源设备信息查询
* 资源设备信息查询
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/core/util/FileUtil.java
View file @
c43a0f75
...
@@ -149,4 +149,5 @@ public class FileUtil {
...
@@ -149,4 +149,5 @@ public class FileUtil {
}
}
return
CommonResponseUtil
.
failure
(
"上传失败"
);
return
CommonResponseUtil
.
failure
(
"上传失败"
);
}
}
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/core/util/MyNode.java
View file @
c43a0f75
...
@@ -12,6 +12,8 @@ public class MyNode {
...
@@ -12,6 +12,8 @@ public class MyNode {
private
String
text
;
private
String
text
;
private
List
<
MyNode
>
children
=
new
ArrayList
<>();
private
List
<
MyNode
>
children
=
new
ArrayList
<>();
private
MyNode
parent
;
private
MyNode
parent
;
private
String
pageInfo
;
public
String
getId
()
{
public
String
getId
()
{
return
id
;
return
id
;
}
}
...
@@ -65,4 +67,16 @@ public class MyNode {
...
@@ -65,4 +67,16 @@ public class MyNode {
super
();
super
();
// TODO Auto-generated constructor stub
// TODO Auto-generated constructor stub
}
}
@Override
public
String
toString
()
{
return
"MyNode [id="
+
id
+
", text="
+
text
+
", children="
+
children
+
"]"
;
}
public
String
getPageInfo
()
{
return
pageInfo
;
}
public
void
setPageInfo
(
String
pageInfo
)
{
this
.
pageInfo
=
pageInfo
;
}
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/core/util/PdfUtil.java
0 → 100644
View file @
c43a0f75
package
com
.
yeejoin
.
amos
.
fas
.
core
.
util
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.List
;
import
com.itextpdf.text.pdf.PdfReader
;
import
com.itextpdf.text.pdf.SimpleBookmark
;
public
class
PdfUtil
{
private
static
Integer
index
=
1
;
public
static
MyNode
getPdfNavs
(
String
pdfUrl
)
{
MyNode
root
=
new
MyNode
();
try
{
PdfReader
reader
=
new
PdfReader
(
pdfUrl
);
List
<
HashMap
<
String
,
Object
>>
list
=
SimpleBookmark
.
getBookmark
(
reader
);
if
(
list
!=
null
&&
list
.
size
()>
0
)
{
index
=
1
;
root
.
setId
(
String
.
valueOf
(
index
));
for
(
Iterator
<
HashMap
<
String
,
Object
>>
i
=
list
.
iterator
();
i
.
hasNext
();)
{
showBookmark
(
i
.
next
(),
root
);
}
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
root
;
}
// 获取标题
public
static
void
showBookmark
(
HashMap
<
String
,
Object
>
bookmark
,
MyNode
parentNode
)
{
List
<
MyNode
>
children
=
parentNode
.
getChildren
();
MyNode
n
=
new
MyNode
();
n
.
setId
(
String
.
valueOf
(
index
++));
n
.
setPageInfo
(
"page="
+
getPageNumbers
(
bookmark
));
n
.
setText
((
String
)
bookmark
.
get
(
"Title"
));
children
.
add
(
n
);
// System.out.println (bookmark.get ( "Title" )) ;
// System.out.println(getPageNumbers( bookmark));
@SuppressWarnings
(
"unchecked"
)
ArrayList
<
HashMap
<
String
,
Object
>>
kids
=
(
ArrayList
<
HashMap
<
String
,
Object
>>)
bookmark
.
get
(
"Kids"
);
if
(
kids
==
null
)
return
;
for
(
Iterator
<
HashMap
<
String
,
Object
>>
i
=
kids
.
iterator
();
i
.
hasNext
();)
{
showBookmark
(
i
.
next
(),
n
);
}
}
// 获取页码
public
static
Integer
getPageNumbers
(
HashMap
<
String
,
Object
>
bookmark
)
{
if
(
bookmark
==
null
)
return
null
;
if
(
"GoTo"
.
equals
(
bookmark
.
get
(
"Action"
)))
{
String
page
=
(
String
)
bookmark
.
get
(
"Page"
);
if
(
page
!=
null
)
{
page
=
page
.
trim
();
int
idx
=
page
.
indexOf
(
' '
);
int
pageNum
;
if
(
idx
<
0
)
{
pageNum
=
Integer
.
parseInt
(
page
);
}
else
{
pageNum
=
Integer
.
parseInt
(
page
.
substring
(
0
,
idx
));
}
return
pageNum
;
}
}
return
null
;
}
}
\ No newline at end of file
pom.xml
View file @
c43a0f75
...
@@ -246,7 +246,7 @@
...
@@ -246,7 +246,7 @@
<name>
maven-public
</name>
<name>
maven-public
</name>
<url>
http://172.16.1.6:8081/nexus/content/repositories/maven-public/
</url>
<url>
http://172.16.1.6:8081/nexus/content/repositories/maven-public/
</url>
</repository>
</repository>
</repositories>
</repositories>
<pluginRepositories>
<pluginRepositories>
...
@@ -258,6 +258,7 @@
...
@@ -258,6 +258,7 @@
</pluginRepositories>
</pluginRepositories>
<build>
<build>
<plugins>
<plugins>
<plugin>
<plugin>
...
...
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