Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
K
kwell-mes
Project
Project
Details
Activity
Releases
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
gavelinfo
kwell-mes
Commits
d2837c7a
Commit
d2837c7a
authored
Mar 10, 2022
by
zhoumaotao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文件流传入
parent
29097f3b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
19 deletions
+84
-19
KmesBoardController.java
.../java/com/gavel/kwell/controller/KmesBoardController.java
+12
-13
KmesBoardService.java
...c/main/java/com/gavel/kwell/service/KmesBoardService.java
+8
-2
KmesBoardServiceImpl.java
...va/com/gavel/kwell/service/impl/KmesBoardServiceImpl.java
+64
-4
No files found.
gavel/src/main/java/com/gavel/kwell/controller/KmesBoardController.java
View file @
d2837c7a
...
...
@@ -2,13 +2,11 @@ package com.gavel.kwell.controller;
import
com.alibaba.fastjson.JSONObject
;
import
com.gavel.common.base.controller.BaseController
;
import
com.gavel.common.utils.ThreadContext
;
import
com.gavel.kwell.service.KmesBoardService
;
import
com.gavel.kwell.vo.GpfkHgVO
;
import
com.gavel.kwell.vo.PcslVO
;
import
com.gavel.kwell.vo.SdclVO
;
import
com.gavel.kwell.vo.UWoVO
;
import
com.gavel.wo.persistent.Pcjhmx
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestBody
;
...
...
@@ -16,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.FileInputStream
;
import
java.util.List
;
@Controller
...
...
@@ -127,25 +127,24 @@ public class KmesBoardController extends BaseController {
/**
*
视频
路径api
*
pdf
路径api
*/
@RequestMapping
(
value
=
"getPdf"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Object
getPdf
(
@RequestBody
JSONObject
param
)
{
returnData
().
add
(
"pdf"
,
kmesBoardService
.
getPdf
());
return
ThreadContext
.
getReturnData
();
@RequestMapping
(
value
=
"getPdf"
)
public
void
getPdf
(
HttpServletResponse
response
)
{
FileInputStream
fileInputStream
=
kmesBoardService
.
getPdf
();
kmesBoardService
.
doAttachmentPreview
(
response
,
fileInputStream
);
}
/**
* 视频路径api
*/
@RequestMapping
(
value
=
"getVideo"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Object
getVideo
(
@RequestBody
JSONObject
param
)
{
returnData
().
add
(
"video"
,
kmesBoardService
.
getVideo
());
return
ThreadContext
.
getReturnData
();
@RequestMapping
(
value
=
"getVideo"
)
public
void
getVideo
(
HttpServletResponse
response
)
{
FileInputStream
fileInputStream
=
kmesBoardService
.
getVideo
();
kmesBoardService
.
doAttachmentPreview
(
response
,
fileInputStream
);
}
}
gavel/src/main/java/com/gavel/kwell/service/KmesBoardService.java
View file @
d2837c7a
...
...
@@ -7,6 +7,8 @@ import com.gavel.kwell.vo.SdclVO;
import
com.gavel.kwell.vo.UWoVO
;
import
com.gavel.wo.persistent.Pcjhmx
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.FileInputStream
;
import
java.util.List
;
...
...
@@ -26,7 +28,11 @@ public interface KmesBoardService extends BaseEditService {
public
List
<
GpfkHgVO
>
queryGpfkHgl
();
public
String
getPdf
();
public
FileInputStream
getPdf
();
public
String
getVideo
();
public
FileInputStream
getVideo
();
public
FileInputStream
downloadFile
(
String
path
);
public
void
doAttachmentPreview
(
HttpServletResponse
response
,
FileInputStream
fileInputStream
);
}
gavel/src/main/java/com/gavel/kwell/service/impl/KmesBoardServiceImpl.java
View file @
d2837c7a
...
...
@@ -4,6 +4,7 @@ import com.gavel.common.base.service.impl.BaseEditServiceImpl;
import
com.gavel.common.business.service.CommonService
;
import
com.gavel.common.utils.DateUtils
;
import
com.gavel.common.utils.NumberUtils
;
import
com.gavel.common.utils.StringUtils
;
import
com.gavel.kwell.dao.GpfkcxDao
;
import
com.gavel.kwell.dao.KmesBoardDao
;
import
com.gavel.kwell.persistent.Gpfk
;
...
...
@@ -15,10 +16,14 @@ import com.gavel.kwell.vo.PcslVO;
import
com.gavel.kwell.vo.SdclVO
;
import
com.gavel.kwell.vo.UWoVO
;
import
com.gavel.wo.persistent.Pcjhmx
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
...
...
@@ -29,6 +34,9 @@ import java.util.List;
@Transactional
public
class
KmesBoardServiceImpl
extends
BaseEditServiceImpl
implements
KmesBoardService
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
KmesBoardServiceImpl
.
class
);
@Autowired
private
KmesBoardDao
kmesBoardDao
;
...
...
@@ -135,12 +143,64 @@ public class KmesBoardServiceImpl extends BaseEditServiceImpl implements KmesBoa
}
@Override
public
String
getPdf
()
{
return
commonService
.
getStringOptionValue
(
KwellParamEnum
.
DASHBORAD_PDF
.
getId
());
public
FileInputStream
getPdf
()
{
String
path
=
commonService
.
getStringOptionValue
(
KwellParamEnum
.
DASHBORAD_PDF
.
getId
());
if
(
StringUtils
.
isEmpty
(
path
))
{
logger
.
error
(
"文件路径参数为空,请检查!"
);
return
null
;
}
return
downloadFile
(
path
);
}
@Override
public
FileInputStream
getVideo
()
{
String
path
=
commonService
.
getStringOptionValue
(
KwellParamEnum
.
DASHBORAD_VIDEO
.
getId
());
if
(
StringUtils
.
isEmpty
(
path
))
{
logger
.
error
(
"文件路径参数为空,请检查!"
);
return
null
;
}
return
downloadFile
(
path
);
}
@Override
public
void
doAttachmentPreview
(
HttpServletResponse
response
,
FileInputStream
fileInputStream
)
{
try
{
BufferedInputStream
bis
=
new
BufferedInputStream
(
fileInputStream
);
try
{
BufferedOutputStream
bos
=
new
BufferedOutputStream
(
response
.
getOutputStream
());
try
{
byte
[]
buff
=
new
byte
[
2048
];
int
bytesRead
;
while
(-
1
!=
(
bytesRead
=
bis
.
read
(
buff
,
0
,
buff
.
length
)))
{
bos
.
write
(
buff
,
0
,
bytesRead
);
}
}
finally
{
bos
.
close
();
}
}
finally
{
bis
.
close
();
}
}
catch
(
Exception
var23
)
{
this
.
logger
.
error
(
""
,
var23
);
}
}
@Override
public
String
getVideo
()
{
return
commonService
.
getStringOptionValue
(
KwellParamEnum
.
DASHBORAD_VIDEO
.
getId
());
public
FileInputStream
downloadFile
(
String
path
)
{
File
dataFile
=
new
File
(
path
);
if
(
dataFile
.
exists
())
{
//获取输入流
FileInputStream
inStream
=
null
;
try
{
inStream
=
new
FileInputStream
(
dataFile
);
}
catch
(
FileNotFoundException
e
)
{
logger
.
error
(
e
.
getMessage
());
}
return
inStream
;
}
return
null
;
}
}
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