Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dcs-plan
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
INET-TWO
server
dcs-plan
Commits
e3d3d599
Commit
e3d3d599
authored
Sep 30, 2024
by
wangqiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
导出模板代码修改
parent
f80188a7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
3 deletions
+9
-3
ExtFileTemplateManagerServiceImpl.java
.../core/service/impl/ExtFileTemplateManagerServiceImpl.java
+7
-2
FileUtils.java
...src/main/java/com/yonde/dcs/plan/core/util/FileUtils.java
+2
-1
No files found.
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/service/impl/ExtFileTemplateManagerServiceImpl.java
View file @
e3d3d599
...
...
@@ -34,16 +34,21 @@ public class ExtFileTemplateManagerServiceImpl implements ExtFileTemplateManager
InputStream
inputStream
=
null
;
CustomMultipartFile
multipartFile
=
null
;
Long
fileId
=
null
;
String
fileName
;
try
{
if
(
fileType
==
1
){
//采购计划模板下载
fileId
=
systemFileFeignService
.
getSystemFileId
(
Constants
.
PURCHASE_PLAN_TEMP_FILE_CODE_NAME
);
fileName
=
"采购计划模板(内部)..xlsx"
;
}
else
if
(
fileType
==
2
){
//IED计划模板下载
fileId
=
systemFileFeignService
.
getSystemFileId
(
Constants
.
IED_PLAN_TEMP_FILE_CODE_NAME
);
fileName
=
"IED计划模板(内部)..xlsx"
;
}
else
if
(
fileType
==
3
){
//ICM计划模板下载
fileId
=
systemFileFeignService
.
getSystemFileId
(
Constants
.
ICM_PLAN_TEMP_FILE_CODE_NAME
);
}
else
if
(
fileType
==
4
){
fileName
=
"ICM计划模板(内部)..xlsx"
;
}
else
if
(
fileType
==
4
){
//进度计划
fileId
=
systemFileFeignService
.
getSystemFileId
(
Constants
.
PROGRESS_TEMP_FILE_CODE_NAME
);
fileName
=
"进度计划模板(内部)..xlsx"
;
}
else
{
log
.
info
(
"未知文件类型:{}"
,
fileType
);
throw
new
DxBusinessException
(
"500"
,
"未知文件类型:"
+
fileType
);
...
...
@@ -64,7 +69,7 @@ public class ExtFileTemplateManagerServiceImpl implements ExtFileTemplateManager
//创建采购计划列表.xlsx 文件
FileUtils
.
inputToFile
(
inputStream
,
filePath
);
//导出数据
FileUtils
.
exportFile
(
response
,
new
FileInputStream
(
filePath
),
"application/vnd.ms-excel;charset=utf-8"
,
"计划模板.xlsx"
);
FileUtils
.
exportFile
(
response
,
new
FileInputStream
(
filePath
),
"application/vnd.ms-excel;charset=utf-8"
,
fileName
);
//删除临时目录
FileUtil
.
del
(
dir
);
return
ApiResult
.
SUCCESS
;
...
...
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/util/FileUtils.java
View file @
e3d3d599
...
...
@@ -6,6 +6,7 @@ import lombok.extern.slf4j.Slf4j;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
import
java.net.URLEncoder
;
/**
* @author xfchai
...
...
@@ -38,7 +39,7 @@ public class FileUtils {
BufferedOutputStream
bouts
=
new
BufferedOutputStream
(
outs
);
response
.
setContentType
(
exportType
);
response
.
setHeader
(
"Access-Control-Expose-Headers"
,
"Content-Disposition"
);
response
.
setHeader
(
"Content-disposition"
,
"attachment;filename="
+
name
);
response
.
setHeader
(
"Content-disposition"
,
"attachment;filename="
+
URLEncoder
.
encode
(
name
,
"UTF-8"
)
);
//修正 Excel在“xxx.xlsx”中发现不可读取的内容。是否恢复此工作薄的内容?如果信任此工作簿的来源,请点击"是"
OutputStream
out
=
response
.
getOutputStream
();
byte
[]
b
=
new
byte
[
2048
];
...
...
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