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
d3cf0584
Commit
d3cf0584
authored
Dec 22, 2025
by
huyuchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
huych-电子档案批量导入第二次提交
parent
7f7fec60
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
43 deletions
+12
-43
ElectronicArchiveImportServiceImpl.java
...atch/service/impl/ElectronicArchiveImportServiceImpl.java
+8
-22
TElectronicArchiveDetailServiceImpl.java
...tch/service/impl/TElectronicArchiveDetailServiceImpl.java
+4
-21
No files found.
yifu-batch/yifu-batch-biz/src/main/java/com/yifu/cloud/plus/v1/batch/service/impl/ElectronicArchiveImportServiceImpl.java
View file @
d3cf0584
...
...
@@ -3,6 +3,7 @@ package com.yifu.cloud.plus.v1.batch.service.impl;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.ZipUtil
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.read.listener.ReadListener
;
...
...
@@ -42,6 +43,7 @@ import org.springframework.web.multipart.MultipartFile;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicInteger
;
...
...
@@ -325,7 +327,6 @@ public class ElectronicArchiveImportServiceImpl implements ElectronicArchiveImpo
}
}
log
.
info
(
"任务关联关系创建成功,任务ID:{},关联数量:{}"
,
taskId
,
uniqueMap
.
size
());
}
catch
(
Exception
e
)
{
log
.
error
(
"创建任务关联关系失败,任务ID:{}"
,
taskId
,
e
);
}
...
...
@@ -379,8 +380,8 @@ public class ElectronicArchiveImportServiceImpl implements ElectronicArchiveImpo
// 将ZIP文件保存到临时目录
String
tempDirPath
=
System
.
getProperty
(
"java.io.tmpdir"
)
+
File
.
separator
+
"zip_upload_"
+
taskId
;
File
tempDir
=
new
File
(
tempDirPath
);
if
(!
tempDir
.
exists
())
{
t
empDir
.
mkdirs
(
);
if
(!
tempDir
.
exists
()
&&
!
tempDir
.
mkdirs
()
)
{
t
hrow
new
IOException
(
"Failed to create directory: "
+
tempDirPath
);
}
tempZipFile
=
new
File
(
tempDir
,
file
.
getOriginalFilename
());
...
...
@@ -421,7 +422,6 @@ public class ElectronicArchiveImportServiceImpl implements ElectronicArchiveImpo
@Override
@Async
public
R
<?>
asyncProcessUpload
(
String
taskId
)
{
log
.
info
(
"开始异步处理任务:{}"
,
taskId
);
List
<
ArchiveFeedbackVO
>
feedbackList
=
new
ArrayList
<>();
File
tempDir
=
null
;
...
...
@@ -448,14 +448,12 @@ public class ElectronicArchiveImportServiceImpl implements ElectronicArchiveImpo
// 从附件记录中获取ZIP文件路径
if
(
StrUtil
.
isBlank
(
zipAtta
.
getAttaSrc
()))
{
log
.
error
(
"ZIP文件路径为空,任务ID:{}"
,
taskId
);
updateTaskStatus
(
task
,
ArchiveConstants
.
TASK_STATUS_NOT_UPLOADED
);
return
R
.
failed
(
"ZIP文件路径为空"
);
}
zipSourceFile
=
new
File
(
zipAtta
.
getAttaSrc
());
if
(!
zipSourceFile
.
exists
())
{
log
.
error
(
"ZIP文件不存在:{},任务ID:{}"
,
zipAtta
.
getAttaSrc
(),
taskId
);
updateTaskStatus
(
task
,
ArchiveConstants
.
TASK_STATUS_NOT_UPLOADED
);
return
R
.
failed
(
"ZIP文件不存在"
);
}
...
...
@@ -465,7 +463,6 @@ public class ElectronicArchiveImportServiceImpl implements ElectronicArchiveImpo
.
eq
(
TTaskArchiveRelation:
:
getTaskId
,
taskId
));
if
(
CollUtil
.
isEmpty
(
relations
))
{
log
.
error
(
"任务没有关联的明细数据,任务ID:{}"
,
taskId
);
updateTaskStatus
(
task
,
ArchiveConstants
.
TASK_STATUS_NOT_UPLOADED
);
return
R
.
failed
(
"任务没有关联的明细数据"
);
}
...
...
@@ -485,16 +482,13 @@ public class ElectronicArchiveImportServiceImpl implements ElectronicArchiveImpo
String
tempDirPath
=
System
.
getProperty
(
"java.io.tmpdir"
)
+
File
.
separator
+
"archive_"
+
taskId
+
"_"
+
System
.
currentTimeMillis
();
tempDir
=
new
File
(
tempDirPath
);
if
(!
tempDir
.
mkdirs
())
{
log
.
error
(
"创建临时目录失败:{}"
,
tempDirPath
);
updateTaskStatus
(
task
,
ArchiveConstants
.
TASK_STATUS_NOT_UPLOADED
);
return
R
.
failed
(
"创建临时目录失败"
);
}
// 解压ZIP文件
try
{
log
.
info
(
"开始解压ZIP文件:{},任务ID:{}"
,
zipSourceFile
.
getAbsolutePath
(),
taskId
);
cn
.
hutool
.
core
.
util
.
ZipUtil
.
unzip
(
zipSourceFile
,
tempDir
);
log
.
info
(
"ZIP文件解压成功,任务ID:{}"
,
taskId
);
ZipUtil
.
unzip
(
zipSourceFile
,
tempDir
);
}
catch
(
Exception
e
)
{
log
.
error
(
"解压ZIP文件失败,任务ID:{}"
,
taskId
,
e
);
updateTaskStatus
(
task
,
ArchiveConstants
.
TASK_STATUS_NOT_UPLOADED
);
...
...
@@ -504,7 +498,6 @@ public class ElectronicArchiveImportServiceImpl implements ElectronicArchiveImpo
// 获取ZIP包的根目录(第一级目录)
File
[]
zipRootDirs
=
tempDir
.
listFiles
(
File:
:
isDirectory
);
if
(
zipRootDirs
==
null
||
zipRootDirs
.
length
==
0
)
{
log
.
error
(
"ZIP文件中没有找到目录,任务ID:{}"
,
taskId
);
updateTaskStatus
(
task
,
ArchiveConstants
.
TASK_STATUS_NOT_UPLOADED
);
return
R
.
failed
(
"ZIP文件格式不正确"
);
}
...
...
@@ -514,7 +507,6 @@ public class ElectronicArchiveImportServiceImpl implements ElectronicArchiveImpo
// 处理第二级目录(身份证+姓名目录)
File
[]
personDirs
=
zipRootDir
.
listFiles
(
File:
:
isDirectory
);
if
(
personDirs
==
null
||
personDirs
.
length
==
0
)
{
log
.
error
(
"ZIP文件中没有找到人员目录,任务ID:{}"
,
taskId
);
updateTaskStatus
(
task
,
ArchiveConstants
.
TASK_STATUS_NOT_UPLOADED
);
return
R
.
failed
(
"ZIP文件格式不正确"
);
}
...
...
@@ -545,9 +537,7 @@ public class ElectronicArchiveImportServiceImpl implements ElectronicArchiveImpo
if
(
tempDir
!=
null
&&
tempDir
.
exists
())
{
try
{
FileUtil
.
del
(
tempDir
);
log
.
info
(
"清理临时解压目录成功:{}"
,
tempDir
.
getAbsolutePath
());
}
catch
(
Exception
e
)
{
log
.
error
(
"清理临时解压目录失败:{}"
,
tempDir
.
getAbsolutePath
(),
e
);
}
}
...
...
@@ -555,9 +545,7 @@ public class ElectronicArchiveImportServiceImpl implements ElectronicArchiveImpo
if
(
zipSourceFile
!=
null
&&
zipSourceFile
.
exists
())
{
try
{
FileUtil
.
del
(
zipSourceFile
.
getParentFile
());
log
.
info
(
"清理ZIP源文件成功:{}"
,
zipSourceFile
.
getAbsolutePath
());
}
catch
(
Exception
e
)
{
log
.
error
(
"清理ZIP源文件失败:{}"
,
zipSourceFile
.
getAbsolutePath
(),
e
);
}
}
atomicInteger
.
decrementAndGet
();
...
...
@@ -616,7 +604,6 @@ public class ElectronicArchiveImportServiceImpl implements ElectronicArchiveImpo
private
void
processPersonDirectory
(
File
personDir
,
Map
<
String
,
TElectronicArchiveDetail
>
detailMap
,
List
<
ArchiveFeedbackVO
>
feedbackList
,
String
taskId
)
{
String
dirName
=
personDir
.
getName
();
log
.
info
(
"处理人员目录:{}"
,
dirName
);
// 解析身份证和姓名
Map
<
String
,
String
>
idNameMap
=
parseIdCardAndName
(
dirName
);
...
...
@@ -889,7 +876,6 @@ public class ElectronicArchiveImportServiceImpl implements ElectronicArchiveImpo
*/
private
void
generateFeedbackExcel
(
String
taskId
,
List
<
ArchiveFeedbackVO
>
feedbackList
)
{
if
(
CollUtil
.
isEmpty
(
feedbackList
))
{
log
.
info
(
"没有反馈数据,跳过生成反馈表"
);
return
;
}
...
...
@@ -914,7 +900,7 @@ public class ElectronicArchiveImportServiceImpl implements ElectronicArchiveImpo
taskId
);
if
(
uploadResult
!=
null
&&
R
.
isSuccess
(
uploadResult
))
{
if
(
R
.
isSuccess
(
uploadResult
))
{
log
.
info
(
"反馈表生成成功,任务ID:{}"
,
taskId
);
}
else
{
log
.
error
(
"反馈表上传失败,任务ID:{}"
,
taskId
);
...
...
@@ -1129,7 +1115,7 @@ public class ElectronicArchiveImportServiceImpl implements ElectronicArchiveImpo
detail
.
getId
()
);
if
(
uploadResult
!=
null
&&
R
.
isSuccess
(
uploadResult
))
{
if
(
R
.
isSuccess
(
uploadResult
))
{
successCount
++;
}
else
{
failCount
++;
...
...
yifu-batch/yifu-batch-biz/src/main/java/com/yifu/cloud/plus/v1/batch/service/impl/TElectronicArchiveDetailServiceImpl.java
View file @
d3cf0584
...
...
@@ -13,7 +13,6 @@ import com.yifu.cloud.plus.v1.batch.entity.TAttaInfo;
import
com.yifu.cloud.plus.v1.batch.entity.TElectronicArchiveDetail
;
import
com.yifu.cloud.plus.v1.batch.entity.TElectronicArchiveTask
;
import
com.yifu.cloud.plus.v1.batch.entity.TTaskArchiveRelation
;
import
com.yifu.cloud.plus.v1.batch.mapper.SysConfigLimitMapper
;
import
com.yifu.cloud.plus.v1.batch.mapper.TElectronicArchiveDetailMapper
;
import
com.yifu.cloud.plus.v1.batch.service.TAttaInfoService
;
import
com.yifu.cloud.plus.v1.batch.service.TElectronicArchiveDetailService
;
...
...
@@ -42,7 +41,6 @@ import java.net.URLEncoder;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipOutputStream
;
...
...
@@ -96,7 +94,6 @@ public class TElectronicArchiveDetailServiceImpl extends ServiceImpl<TElectronic
.
eq
(
TTaskArchiveRelation:
:
getArchiveDetailId
,
id
));
if
(
CollUtil
.
isEmpty
(
relations
))
{
log
.
info
(
"电子档案明细没有关联的任务,明细ID:{}"
,
id
);
return
R
.
ok
(
detail
);
}
...
...
@@ -298,8 +295,7 @@ public class TElectronicArchiveDetailServiceImpl extends ServiceImpl<TElectronic
.
eq
(
TElectronicArchiveDetail:
:
getEmpName
,
request
.
getEmpName
())
.
eq
(
TElectronicArchiveDetail:
:
getEmpIdcard
,
request
.
getEmpIdcard
())
.
eq
(
TElectronicArchiveDetail:
:
getDeptNo
,
request
.
getDeptNo
())
.
eq
(
ArchiveConstants
.
DETAIL_STATUS_ENABLED
.
equals
(
ArchiveConstants
.
DETAIL_STATUS_ENABLED
),
TElectronicArchiveDetail:
:
getStatus
,
ArchiveConstants
.
DETAIL_STATUS_ENABLED
);
.
eq
(
TElectronicArchiveDetail:
:
getStatus
,
ArchiveConstants
.
DETAIL_STATUS_ENABLED
);
// 如果项目名称不为空,添加项目名称条件
if
(
StrUtil
.
isNotBlank
(
request
.
getDeptName
()))
{
...
...
@@ -320,9 +316,6 @@ public class TElectronicArchiveDetailServiceImpl extends ServiceImpl<TElectronic
if
(
downloadAllTypes
)
{
// 资料类型为空,下载该人员该项目下所有资料类型
log
.
info
(
"资料类型为空,将下载该人员该项目下所有资料类型,姓名:{},身份证:{},项目编码:{}"
,
request
.
getEmpName
(),
request
.
getEmpIdcard
(),
request
.
getDeptNo
());
// 查询该明细下所有可用附件
List
<
TAttaInfo
>
allAttaList
=
attaInfoService
.
list
(
Wrappers
.<
TAttaInfo
>
lambdaQuery
()
.
eq
(
TAttaInfo:
:
getDomainId
,
detail
.
getId
())
...
...
@@ -475,8 +468,6 @@ public class TElectronicArchiveDetailServiceImpl extends ServiceImpl<TElectronic
zipOut
.
closeEntry
();
excelOut
.
close
();
log
.
info
(
"反馈Excel添加成功,共{}条记录"
,
feedbackList
.
size
());
}
catch
(
Exception
e
)
{
log
.
error
(
"生成反馈Excel失败"
,
e
);
}
...
...
@@ -570,9 +561,6 @@ public class TElectronicArchiveDetailServiceImpl extends ServiceImpl<TElectronic
*/
@Override
public
R
<
String
>
deleteArchiveAttachments
(
ArchiveAttachmentDeleteRequestVO
request
)
{
log
.
info
(
"开始删除电子档案附件,明细ID:{},任务ID:{},资料类型:{},附件数量:{}"
,
request
.
getDetailId
(),
request
.
getTaskId
(),
request
.
getMaterialType
(),
request
.
getAttachmentIds
().
size
());
try
{
// 1. 校验明细是否存在
...
...
@@ -641,7 +629,6 @@ public class TElectronicArchiveDetailServiceImpl extends ServiceImpl<TElectronic
try
{
ossUtil
.
deleteObject
(
"yf-hr-efile-source"
,
atta
.
getAttaSrc
());
successCount
++;
log
.
info
(
"删除附件成功,附件ID:{},文件名:{}"
,
atta
.
getId
(),
atta
.
getAttaName
());
}
catch
(
Exception
e
)
{
log
.
error
(
"删除OSS文件失败,附件ID:{},路径:{}"
,
atta
.
getId
(),
atta
.
getAttaSrc
(),
e
);
// OSS删除失败不影响整体流程,已经逻辑删除了
...
...
@@ -677,7 +664,6 @@ public class TElectronicArchiveDetailServiceImpl extends ServiceImpl<TElectronic
resultMsg
+=
"。失败的附件:"
+
failReasons
.
toString
();
}
log
.
info
(
"删除电子档案附件完成,明细ID:{},结果:{}"
,
request
.
getDetailId
(),
resultMsg
);
return
R
.
ok
(
null
,
resultMsg
);
}
catch
(
Exception
e
)
{
...
...
@@ -725,7 +711,6 @@ public class TElectronicArchiveDetailServiceImpl extends ServiceImpl<TElectronic
}
baseMapper
.
updateById
(
detail
);
log
.
info
(
"更新档案明细资料类型成功,明细ID:{},新的资料类型:{}"
,
detail
.
getId
(),
detail
.
getMaterialType
());
}
catch
(
Exception
e
)
{
log
.
error
(
"更新档案明细资料类型失败,明细ID:{}"
,
detail
.
getId
(),
e
);
...
...
@@ -751,7 +736,6 @@ public class TElectronicArchiveDetailServiceImpl extends ServiceImpl<TElectronic
*/
@Override
public
void
selectedExportArchives
(
List
<
ArchiveSelectedExportRequestVO
>
requestList
,
HttpServletResponse
response
)
{
log
.
info
(
"开始勾选导出电子档案,请求数量:{}"
,
requestList
.
size
());
// 反馈列表
List
<
ArchiveDownloadFeedbackVO
>
feedbackList
=
new
ArrayList
<>();
...
...
@@ -811,7 +795,6 @@ public class TElectronicArchiveDetailServiceImpl extends ServiceImpl<TElectronic
addFeedbackExcel
(
zipOut
,
feedbackList
);
zipOut
.
finish
();
log
.
info
(
"电子档案勾选导出完成"
);
}
}
catch
(
Exception
e
)
{
...
...
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