Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
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
fangxinjiang
yifu-mvp
Commits
5eb768a7
Commit
5eb768a7
authored
Jan 09, 2026
by
fangxinjiang
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/MVP1.7.18' into MVP1.7.18
parents
52e0aaa9
30b1912b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
8 deletions
+81
-8
TElectronicArchiveDetailServiceImpl.java
...tch/service/impl/TElectronicArchiveDetailServiceImpl.java
+81
-8
No files found.
yifu-batch/yifu-batch-biz/src/main/java/com/yifu/cloud/plus/v1/batch/service/impl/TElectronicArchiveDetailServiceImpl.java
View file @
5eb768a7
...
...
@@ -240,7 +240,20 @@ public class TElectronicArchiveDetailServiceImpl extends ServiceImpl<TElectronic
}
}
// 2. 设置响应头
// 2. 校验文件总大小是否超过500MB
long
totalSize
=
calculateTotalFileSize
(
downloadMap
);
long
maxSize
=
500
*
1024
*
1024L
;
// 500MB
if
(
totalSize
>
maxSize
)
{
log
.
warn
(
"批量下载文件总大小超过限制,总大小:{}MB,限制:500MB"
,
totalSize
/
1024
/
1024
);
response
.
setContentType
(
"application/json;charset=UTF-8"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
String
errorMsg
=
String
.
format
(
"{\"code\":1,\"msg\":\"下载文件总大小超过限制,当前总大小:%.2fMB,最大允许:500MB\"}"
,
totalSize
/
1024.0
/
1024.0
);
response
.
getWriter
().
write
(
errorMsg
);
return
;
}
// 3. 设置响应头
String
fileName
=
"电子档案批量下载_"
+
LocalDateTime
.
now
().
format
(
DateTimeFormatter
.
ofPattern
(
"yyyyMMddHHmmss"
))
+
".zip"
;
response
.
setContentType
(
"application/zip"
);
...
...
@@ -248,10 +261,10 @@ public class TElectronicArchiveDetailServiceImpl extends ServiceImpl<TElectronic
response
.
setHeader
(
CommonConstants
.
CONTENT_DISPOSITION
,
"attachment; filename="
+
URLEncoder
.
encode
(
fileName
,
"UTF-8"
));
//
3
. 创建ZIP输出流
//
4
. 创建ZIP输出流
try
(
ZipOutputStream
zipOut
=
new
ZipOutputStream
(
response
.
getOutputStream
()))
{
//
4
. 下载并打包档案文件
//
5
. 下载并打包档案文件
for
(
Map
.
Entry
<
String
,
ArchiveDownloadInfo
>
entry
:
downloadMap
.
entrySet
())
{
String
folderName
=
entry
.
getKey
();
ArchiveDownloadInfo
downloadInfo
=
entry
.
getValue
();
...
...
@@ -260,11 +273,13 @@ public class TElectronicArchiveDetailServiceImpl extends ServiceImpl<TElectronic
downloadArchiveFiles
(
zipOut
,
folderName
,
downloadInfo
);
// 更新反馈状态为成功
// 使用materialTypeAttaMap的所有key来匹配,确保所有资料类型的反馈都被更新
Set
<
String
>
materialTypes
=
downloadInfo
.
getMaterialTypeAttaMap
().
keySet
();
for
(
ArchiveDownloadFeedbackVO
feedback
:
feedbackList
)
{
if
(
feedback
.
getEmpName
().
equals
(
downloadInfo
.
getDetail
().
getEmpName
())
&&
feedback
.
getEmpIdcard
().
equals
(
downloadInfo
.
getDetail
().
getEmpIdcard
())
&&
feedback
.
getDeptNo
().
equals
(
downloadInfo
.
getDetail
().
getDeptNo
())
&&
feedback
.
getMaterialType
().
equals
(
downloadInfo
.
getMaterialType
(
)))
{
(
materialTypes
.
contains
(
feedback
.
getMaterialType
())
||
"全部资料类型"
.
equals
(
feedback
.
getMaterialType
()
)))
{
feedback
.
setDownloadStatus
(
"成功"
);
feedback
.
setFailReason
(
""
);
}
...
...
@@ -272,11 +287,12 @@ public class TElectronicArchiveDetailServiceImpl extends ServiceImpl<TElectronic
}
catch
(
Exception
e
)
{
log
.
error
(
"下载档案文件失败,文件夹:{}"
,
folderName
,
e
);
// 更新反馈状态为失败
Set
<
String
>
materialTypes
=
downloadInfo
.
getMaterialTypeAttaMap
().
keySet
();
for
(
ArchiveDownloadFeedbackVO
feedback
:
feedbackList
)
{
if
(
feedback
.
getEmpName
().
equals
(
downloadInfo
.
getDetail
().
getEmpName
())
&&
feedback
.
getEmpIdcard
().
equals
(
downloadInfo
.
getDetail
().
getEmpIdcard
())
&&
feedback
.
getDeptNo
().
equals
(
downloadInfo
.
getDetail
().
getDeptNo
())
&&
feedback
.
getMaterialType
().
equals
(
downloadInfo
.
getMaterialType
(
)))
{
(
materialTypes
.
contains
(
feedback
.
getMaterialType
())
||
"全部资料类型"
.
equals
(
feedback
.
getMaterialType
()
)))
{
feedback
.
setDownloadStatus
(
"失败"
);
feedback
.
setFailReason
(
"下载文件失败:"
+
e
.
getMessage
());
}
...
...
@@ -284,7 +300,7 @@ public class TElectronicArchiveDetailServiceImpl extends ServiceImpl<TElectronic
}
}
//
5
. 生成并添加反馈Excel表
//
6
. 生成并添加反馈Excel表
addFeedbackExcel
(
zipOut
,
feedbackList
);
zipOut
.
finish
();
...
...
@@ -447,7 +463,7 @@ public class TElectronicArchiveDetailServiceImpl extends ServiceImpl<TElectronic
if
(!
downloadInfo
.
getMaterialTypeAttaMap
().
containsKey
(
request
.
getMaterialType
()))
{
downloadInfo
.
getMaterialTypeAttaMap
().
put
(
request
.
getMaterialType
(),
attaList
);
}
downloadInfo
.
setMaterialType
(
request
.
getMaterialType
());
// 不再使用单个materialType字段,而是使用materialTypeAttaMap的所有key
// 添加成功的反馈(状态暂时为"处理中",实际下载完成后更新)
feedbackList
.
add
(
createSuccessFeedbackVO
(
request
,
detail
));
...
...
@@ -802,7 +818,20 @@ public class TElectronicArchiveDetailServiceImpl extends ServiceImpl<TElectronic
response
.
getWriter
().
write
(
"{\"code\":1,\"msg\":\"没有可导出的档案\"}"
);
return
;
}
// 2. 校验文件总大小是否超过500MB
long
totalSize
=
calculateTotalFileSize
(
downloadMap
);
long
maxSize
=
500
*
1024
*
1024L
;
// 500MB
if
(
totalSize
>
maxSize
)
{
log
.
warn
(
"批量下载文件总大小超过限制,总大小:{}MB,限制:500MB"
,
totalSize
/
1024
/
1024
);
response
.
setContentType
(
"application/json;charset=UTF-8"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
String
errorMsg
=
String
.
format
(
"{\"code\":1,\"msg\":\"下载文件总大小超过限制,当前总大小:%.2fMB,最大允许:500MB\"}"
,
totalSize
/
1024.0
/
1024.0
);
response
.
getWriter
().
write
(
errorMsg
);
return
;
}
// 3. 设置响应头
String
fileName
=
"电子档案勾选导出_"
+
LocalDateTime
.
now
().
format
(
DateTimeFormatter
.
ofPattern
(
"yyyyMMddHHmmss"
))
+
".zip"
;
...
...
@@ -1130,6 +1159,19 @@ public class TElectronicArchiveDetailServiceImpl extends ServiceImpl<TElectronic
response
.
getWriter
().
write
(
"{\"code\":1,\"msg\":\"没有可导出的档案附件\"}"
);
return
;
}
// 2. 校验文件总大小是否超过500MB
long
totalSize
=
calculateTotalFileSize
(
downloadMap
);
long
maxSize
=
500
*
1024
*
1024L
;
// 500MB
if
(
totalSize
>
maxSize
)
{
log
.
warn
(
"批量下载文件总大小超过限制,总大小:{}MB,限制:500MB"
,
totalSize
/
1024
/
1024
);
response
.
setContentType
(
"application/json;charset=UTF-8"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
String
errorMsg
=
String
.
format
(
"{\"code\":1,\"msg\":\"下载文件总大小超过限制,当前总大小:%.2fMB,最大允许:500MB\"}"
,
totalSize
/
1024.0
/
1024.0
);
response
.
getWriter
().
write
(
errorMsg
);
return
;
}
// 5. 设置响应头
String
fileName
=
"电子档案条件导出_"
+
...
...
@@ -1388,4 +1430,35 @@ public class TElectronicArchiveDetailServiceImpl extends ServiceImpl<TElectronic
return
R
.
failed
(
"删除失败:"
+
e
.
getMessage
());
}
}
/**
* 计算下载文件总大小
*
* @param downloadMap 下载信息Map
* @return 文件总大小(字节)
*/
private
long
calculateTotalFileSize
(
Map
<
String
,
ArchiveDownloadInfo
>
downloadMap
)
{
long
totalSize
=
0L
;
for
(
Map
.
Entry
<
String
,
ArchiveDownloadInfo
>
entry
:
downloadMap
.
entrySet
())
{
ArchiveDownloadInfo
downloadInfo
=
entry
.
getValue
();
Map
<
String
,
List
<
TAttaInfo
>>
materialTypeAttaMap
=
downloadInfo
.
getMaterialTypeAttaMap
();
if
(
materialTypeAttaMap
!=
null
)
{
for
(
Map
.
Entry
<
String
,
List
<
TAttaInfo
>>
attaEntry
:
materialTypeAttaMap
.
entrySet
())
{
List
<
TAttaInfo
>
attaList
=
attaEntry
.
getValue
();
if
(
CollUtil
.
isNotEmpty
(
attaList
))
{
for
(
TAttaInfo
atta
:
attaList
)
{
if
(
atta
.
getAttaSize
()
!=
null
)
{
totalSize
+=
atta
.
getAttaSize
();
}
}
}
}
}
}
log
.
info
(
"批量下载文件总大小:{}字节({}MB)"
,
totalSize
,
totalSize
/
1024.0
/
1024.0
);
return
totalSize
;
}
}
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