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
4d39eea6
Commit
4d39eea6
authored
Sep 13, 2024
by
wangqiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
计划模板下载功能开发
parent
ead13b20
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
129 additions
and
2 deletions
+129
-2
Constants.java
...n/java/com/yonde/dcs/plan/common/constants/Constants.java
+4
-0
ExtFileTemplateManagerController.java
...lan/core/controller/ExtFileTemplateManagerController.java
+46
-0
ExtFileTemplateManagerService.java
.../dcs/plan/core/service/ExtFileTemplateManagerService.java
+10
-0
ExtFileTemplateManagerServiceImpl.java
.../core/service/impl/ExtFileTemplateManagerServiceImpl.java
+67
-0
ExtIEDPlanServiceImpl.java
...nde/dcs/plan/core/service/impl/ExtIEDPlanServiceImpl.java
+2
-2
No files found.
dcs-plan-common/src/main/java/com/yonde/dcs/plan/common/constants/Constants.java
View file @
4d39eea6
...
...
@@ -412,5 +412,9 @@ public class Constants {
*/
public
static
final
String
IED_PLAN_EXCEL_NAME
=
"\\IED计划列表.xlsx"
;
public
static
final
String
IED_PLAN_TEMP_FILE_CODE_NAME
=
"IED计划001模板"
;
/**
* 计划模板
*/
public
static
final
String
PLAN_TEMP_FILE_NAME
=
"\\计划模板.xlsx"
;
}
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/controller/ExtFileTemplateManagerController.java
0 → 100644
View file @
4d39eea6
package
com
.
yonde
.
dcs
.
plan
.
core
.
controller
;
import
com.yonde.dcs.plan.core.service.ExtFileTemplateManagerService
;
import
com.yonde.dex.basedata.entity.api.ApiResult
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.models.auth.In
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.List
;
/**
* @description: ExtIEDPlan-Controller
* @author: dexadmin
* @version: V
* @date: 2024-9-11 15:49:41
**/
@Api
(
tags
=
"ExtIEDPlan管理服务"
)
@RequestMapping
(
"/ExtFileTemplateManager"
)
@ResponseBody
()
@Controller
public
class
ExtFileTemplateManagerController
{
@Autowired
private
ExtFileTemplateManagerService
extFileTemplateManagerService
;
/**
* 采购计划、IED计划、ICM计划模板导出
* @param response
* @param fileType =1采购计划模板导出、=2 IED计划模板导出、=3 ICM计划摸模板导出
* @throws IOException
*/
@ApiOperation
(
value
=
"下载计划模板"
,
notes
=
"下载计划模板"
,
httpMethod
=
"GET"
)
@GetMapping
(
value
=
"/planTemplateDownload"
)
public
ApiResult
planTemplateDownload
(
HttpServletResponse
response
,
@RequestParam
(
"fileType"
)
Integer
fileType
)
throws
IOException
{
return
ApiResult
.
ok
(
extFileTemplateManagerService
.
FileTemplateDownload
(
response
,
fileType
),
"模板下载成功"
);
}
}
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/service/ExtFileTemplateManagerService.java
0 → 100644
View file @
4d39eea6
package
com
.
yonde
.
dcs
.
plan
.
core
.
service
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
public
interface
ExtFileTemplateManagerService
{
public
String
FileTemplateDownload
(
HttpServletResponse
response
,
Integer
fileType
)
throws
IOException
;
}
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/service/impl/ExtFileTemplateManagerServiceImpl.java
0 → 100644
View file @
4d39eea6
package
com
.
yonde
.
dcs
.
plan
.
core
.
service
.
impl
;
import
com.yonde.dcs.plan.common.constants.Constants
;
import
com.yonde.dcs.plan.core.service.ExtFileTemplateManagerService
;
import
com.yonde.dcs.plan.core.util.FileUtils
;
import
com.yonde.dcs.plan.core.util.ResourceHelper
;
import
com.yonde.dex.basedata.entity.api.ApiResult
;
import
com.yonde.dex.basedata.entity.api.CustomMultipartFile
;
import
com.yonde.dex.basedata.exception.DxBusinessException
;
import
com.yonde.dex.dfs.feign.FileManagerFeignService
;
import
com.yonde.dex.systemfile.feign.SystemFileFeignService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
@Slf4j
@Service
public
class
ExtFileTemplateManagerServiceImpl
implements
ExtFileTemplateManagerService
{
@Autowired
private
SystemFileFeignService
systemFileFeignService
;
@Autowired
private
FileManagerFeignService
fileManagerFeignService
;
@Override
public
String
FileTemplateDownload
(
HttpServletResponse
response
,
Integer
fileType
)
throws
IOException
{
InputStream
inputStream
=
null
;
CustomMultipartFile
multipartFile
=
null
;
Long
fileId
=
null
;
try
{
if
(
fileType
==
1
){
//采购计划模板下载
fileId
=
systemFileFeignService
.
getSystemFileId
(
Constants
.
PURCHASE_PLAN_TEMP_FILE_CODE_NAME
);
}
else
if
(
fileType
==
2
){
//IED计划模板下载
fileId
=
systemFileFeignService
.
getSystemFileId
(
Constants
.
IED_PLAN_TEMP_FILE_CODE_NAME
);
}
else
if
(
fileType
==
3
){
//ICM计划模板下载
//todo ICM计划暂时还未创建模板
}
else
{
log
.
info
(
"未知文件类型:{}"
,
fileType
);
}
multipartFile
=
fileManagerFeignService
.
feignDownloadIO
(
fileId
);
}
catch
(
IOException
e
)
{
log
.
info
(
"[计划模板] >>> 文件服务下载为文件:{}--失败!"
,
fileId
);
throw
new
DxBusinessException
(
"500"
,
"文件服务下载文件失败:"
+
fileId
);
}
try
{
inputStream
=
new
ByteArrayInputStream
(
multipartFile
.
getBytes
());
}
catch
(
IOException
e
)
{
log
.
info
(
"[计划模板] >>> 文件服务下载的文件:{}--转换为输入流失败!"
,
fileId
);
throw
new
DxBusinessException
(
"500"
,
"文件服务下载的文件转换为输入流失败:"
+
fileId
);
}
String
dir
=
ResourceHelper
.
CreateTemDir
().
getPath
();
String
filePath
=
dir
+
Constants
.
PLAN_TEMP_FILE_NAME
;
//创建采购计划列表.xlsx 文件
FileUtils
.
inputToFile
(
inputStream
,
filePath
);
//导出数据
FileUtils
.
exportFile
(
response
,
new
FileInputStream
(
filePath
),
"application/vnd.ms-excel;charset=utf-8"
,
"计划模板.xlsx"
);
return
ApiResult
.
SUCCESS
;
}
}
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/service/impl/ExtIEDPlanServiceImpl.java
View file @
4d39eea6
...
...
@@ -92,13 +92,13 @@ public class ExtIEDPlanServiceImpl<V extends ExtIEDPlanVO> implements ExtIEDPlan
fileId
=
systemFileFeignService
.
getSystemFileId
(
Constants
.
IED_PLAN_TEMP_FILE_CODE_NAME
);
multipartFile
=
fileManagerFeignService
.
feignDownloadIO
(
fileId
);
}
catch
(
IOException
e
)
{
log
.
info
(
"[
接口单
] >>> 文件服务下载为文件:{}--失败!"
,
fileId
);
log
.
info
(
"[
IED计划模板
] >>> 文件服务下载为文件:{}--失败!"
,
fileId
);
throw
new
DxBusinessException
(
"500"
,
"文件服务下载文件失败:"
+
fileId
);
}
try
{
inputStream
=
new
ByteArrayInputStream
(
multipartFile
.
getBytes
());
}
catch
(
IOException
e
)
{
log
.
info
(
"[
接口单
] >>> 文件服务下载的文件:{}--转换为输入流失败!"
,
fileId
);
log
.
info
(
"[
IED计划模板
] >>> 文件服务下载的文件:{}--转换为输入流失败!"
,
fileId
);
throw
new
DxBusinessException
(
"500"
,
"文件服务下载的文件转换为输入流失败:"
+
fileId
);
}
String
dir
=
ResourceHelper
.
CreateTemDir
().
getPath
();
...
...
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