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
4338a7a0
Commit
4338a7a0
authored
Dec 31, 2025
by
huyuchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
huych-电子档案批量导入第三次提交
parent
36892b58
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
602 additions
and
86 deletions
+602
-86
TAttaInfo.java
...n/java/com/yifu/cloud/plus/v1/batch/entity/TAttaInfo.java
+2
-2
TElectronicArchiveDetail.java
.../cloud/plus/v1/batch/entity/TElectronicArchiveDetail.java
+0
-1
TElectronicArchiveTask.java
...fu/cloud/plus/v1/batch/entity/TElectronicArchiveTask.java
+5
-0
SingleArchiveUploadVO.java
...om/yifu/cloud/plus/v1/batch/vo/SingleArchiveUploadVO.java
+65
-0
FileUploadController.java
.../cloud/plus/v1/batch/controller/FileUploadController.java
+139
-4
TElectronicArchiveDetailController.java
.../batch/controller/TElectronicArchiveDetailController.java
+22
-0
TElectronicArchiveTaskController.java
...v1/batch/controller/TElectronicArchiveTaskController.java
+15
-14
ElectronicArchiveImportService.java
...plus/v1/batch/service/ElectronicArchiveImportService.java
+16
-1
TElectronicArchiveDetailService.java
...lus/v1/batch/service/TElectronicArchiveDetailService.java
+7
-0
ElectronicArchiveImportServiceImpl.java
...atch/service/impl/ElectronicArchiveImportServiceImpl.java
+190
-33
FileUploadServiceImpl.java
...oud/plus/v1/batch/service/impl/FileUploadServiceImpl.java
+28
-19
TElectronicArchiveDetailServiceImpl.java
...tch/service/impl/TElectronicArchiveDetailServiceImpl.java
+99
-4
TElectronicArchiveDetailMapper.xml
.../main/resources/mapper/TElectronicArchiveDetailMapper.xml
+9
-8
TElectronicArchiveTaskMapper.xml
...rc/main/resources/mapper/TElectronicArchiveTaskMapper.xml
+5
-0
No files found.
yifu-batch/yifu-batch-api/src/main/java/com/yifu/cloud/plus/v1/batch/entity/TAttaInfo.java
View file @
4338a7a0
...
@@ -55,11 +55,11 @@ public class TAttaInfo extends BaseEntity {
...
@@ -55,11 +55,11 @@ public class TAttaInfo extends BaseEntity {
@Schema
(
description
=
"资源类型"
)
@Schema
(
description
=
"资源类型"
)
private
String
attaType
;
private
String
attaType
;
/**
/**
* 关系类型 1 任务表附件 2 zip附件 3反馈表附件
* 关系类型 1 任务表附件 2 zip附件 3反馈表附件
4人员文件
*/
*/
@NotBlank
(
message
=
"关系类型不能为空"
)
@NotBlank
(
message
=
"关系类型不能为空"
)
@Length
(
max
=
20
,
message
=
"关系类型不能超过20个字符"
)
@Length
(
max
=
20
,
message
=
"关系类型不能超过20个字符"
)
@Schema
(
description
=
"关系类型 1 任务表附件 2 zip附件 3反馈表附件"
)
@Schema
(
description
=
"关系类型 1 任务表附件 2 zip附件 3反馈表附件
4人员文件
"
)
private
String
relationType
;
private
String
relationType
;
/**
/**
* 实体id和关系类型共同确定附件所属
* 实体id和关系类型共同确定附件所属
...
...
yifu-batch/yifu-batch-api/src/main/java/com/yifu/cloud/plus/v1/batch/entity/TElectronicArchiveDetail.java
View file @
4338a7a0
...
@@ -132,7 +132,6 @@ public class TElectronicArchiveDetail extends BaseEntity {
...
@@ -132,7 +132,6 @@ public class TElectronicArchiveDetail extends BaseEntity {
@Schema
(
description
=
"是否删除 0否/1是"
)
@Schema
(
description
=
"是否删除 0否/1是"
)
private
String
deleteFlag
;
private
String
deleteFlag
;
/**
/**
* 附件Id
* 附件Id
*/
*/
...
...
yifu-batch/yifu-batch-api/src/main/java/com/yifu/cloud/plus/v1/batch/entity/TElectronicArchiveTask.java
View file @
4338a7a0
...
@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.batch.entity;
...
@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.batch.entity;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute
;
...
@@ -62,4 +63,8 @@ public class TElectronicArchiveTask extends BaseEntity {
...
@@ -62,4 +63,8 @@ public class TElectronicArchiveTask extends BaseEntity {
@Schema
(
description
=
"是否删除 0否/1是"
)
@Schema
(
description
=
"是否删除 0否/1是"
)
private
String
deleteFlag
;
private
String
deleteFlag
;
@Schema
(
description
=
"反馈表附件名称"
)
@TableField
(
exist
=
false
)
private
String
backAttaName
;
}
}
yifu-batch/yifu-batch-api/src/main/java/com/yifu/cloud/plus/v1/batch/vo/SingleArchiveUploadVO.java
0 → 100644
View file @
4338a7a0
package
com
.
yifu
.
cloud
.
plus
.
v1
.
batch
.
vo
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotEmpty
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* 单个新增人员档案附件请求VO
*
* @author huych
* @date 2025-12-31
*/
@Data
@Schema
(
description
=
"单个新增人员档案附件请求VO"
)
public
class
SingleArchiveUploadVO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 身份证号
*/
@NotBlank
(
message
=
"身份证号不能为空"
)
@Schema
(
description
=
"身份证号"
)
private
String
empIdcard
;
/**
* 姓名
*/
@NotBlank
(
message
=
"姓名不能为空"
)
@Schema
(
description
=
"姓名"
)
private
String
empName
;
/**
* 项目编码
*/
@NotBlank
(
message
=
"项目编码不能为空"
)
@Schema
(
description
=
"项目编码"
)
private
String
deptNo
;
/**
* 项目名称
*/
@NotBlank
(
message
=
"项目名称不能为空"
)
@Schema
(
description
=
"项目名称"
)
private
String
deptName
;
/**
* 资料类型(存量、新签、续签、离职)
*/
@NotBlank
(
message
=
"资料类型不能为空"
)
@Schema
(
description
=
"资料类型(存量、新签、续签、离职)"
)
private
String
materialType
;
/**
* 附件ID列表
*/
@NotEmpty
(
message
=
"附件ID列表不能为空"
)
@Schema
(
description
=
"附件ID列表"
)
private
List
<
String
>
attaIdList
;
}
yifu-batch/yifu-batch-biz/src/main/java/com/yifu/cloud/plus/v1/batch/controller/FileUploadController.java
View file @
4338a7a0
...
@@ -8,7 +8,6 @@ import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
...
@@ -8,7 +8,6 @@ import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.Common
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.Common
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.OSSUtil
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.OSSUtil
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -84,7 +83,6 @@ public class FileUploadController {
...
@@ -84,7 +83,6 @@ public class FileUploadController {
* @return
* @return
**/
**/
@Operation
(
description
=
"附件删除"
)
@Operation
(
description
=
"附件删除"
)
@SysLog
(
"附件删除"
)
@PostMapping
(
"/ossFileDelete/deleteByIds"
)
@PostMapping
(
"/ossFileDelete/deleteByIds"
)
public
R
<
Boolean
>
ossFileDelete
(
@RequestBody
List
<
String
>
Ids
)
{
public
R
<
Boolean
>
ossFileDelete
(
@RequestBody
List
<
String
>
Ids
)
{
if
(
Common
.
isNotNull
(
Ids
))
{
if
(
Common
.
isNotNull
(
Ids
))
{
...
@@ -95,7 +93,7 @@ public class FileUploadController {
...
@@ -95,7 +93,7 @@ public class FileUploadController {
return
R
.
failed
(
"无对应附件信息"
);
return
R
.
failed
(
"无对应附件信息"
);
}
}
if
(
tAttaInfoService
.
removeById
(
id
))
{
if
(
tAttaInfoService
.
removeById
(
id
))
{
ossUtil
.
deleteObject
(
null
,
attaInfo
.
getAttaSrc
());
ossUtil
.
deleteObject
(
"yf-hr-efile-source"
,
attaInfo
.
getAttaSrc
());
return
R
.
ok
(
null
,
"删除成功!"
);
return
R
.
ok
(
null
,
"删除成功!"
);
}
}
}
}
...
@@ -125,10 +123,147 @@ public class FileUploadController {
...
@@ -125,10 +123,147 @@ public class FileUploadController {
return
new
R
<>(
attas
);
return
new
R
<>(
attas
);
}
}
for
(
TAttaInfo
atta:
attas
){
for
(
TAttaInfo
atta:
attas
){
URL
url
=
ossUtil
.
getObjectUrl
(
null
,
atta
.
getAttaSrc
());
URL
url
=
ossUtil
.
getObjectUrl
(
"yf-hr-efile-source"
,
atta
.
getAttaSrc
());
atta
.
setAttaUrl
(
url
.
toString
().
replace
(
"http"
,
"https"
));
atta
.
setAttaUrl
(
url
.
toString
().
replace
(
"http"
,
"https"
));
}
}
return
new
R
<>(
attas
);
return
new
R
<>(
attas
);
}
}
/**
* 获取附件下载地址
*
* @param id
* @return
* @Author fxj
* @Date 2019-08-16
* @param id domainId
**/
@Operation
(
description
=
"附件预览下载地址 根据ID和附件类型"
)
@PostMapping
(
"/overrideOssFileUrl"
)
public
R
<
List
<
TAttaInfo
>>
ossFileUrl
(
@RequestParam
String
id
,
@RequestParam
String
type
)
{
List
<
TAttaInfo
>
attas
=
tAttaInfoService
.
list
(
Wrappers
.<
TAttaInfo
>
query
().
lambda
()
.
eq
(
TAttaInfo:
:
getDomainId
,
id
)
.
eq
(
TAttaInfo:
:
getRelationType
,
type
));
if
(
Common
.
isEmpty
(
attas
))
{
return
new
R
<>(
attas
);
}
for
(
TAttaInfo
atta:
attas
){
URL
url
=
ossUtil
.
getObjectUrl
(
"yf-hr-efile-source"
,
atta
.
getAttaSrc
());
atta
.
setAttaUrl
(
url
.
toString
().
replace
(
"http"
,
"https"
));
}
return
new
R
<>(
attas
);
}
/**
* 电子档案单个新增-附件上传接口
* 前端先调用此接口上传文件到阿里云OSS,如果文件名重复则自动添加后缀
*
* @param file 文件
* @param filePath 文件路径
* @param type 关系类型 4 人员文件
* @return R<TAttaInfo> 返回附件信息,包含附件ID
* @Author huych
* @Date 2025-12-31
*/
@Operation
(
description
=
"电子档案单个新增-附件上传接口,上传文件到OSS并返回附件ID"
)
@PostMapping
(
value
=
"/uploadArchiveFile"
)
public
R
<
TAttaInfo
>
uploadArchiveFile
(
@RequestBody
MultipartFile
file
,
String
filePath
,
String
type
)
throws
IOException
{
if
(
file
==
null
||
file
.
isEmpty
())
{
return
R
.
failed
(
"文件不能为空"
);
}
String
fileName
=
file
.
getOriginalFilename
();
if
(
fileName
==
null
||
Common
.
isEmpty
(
fileName
))
{
return
R
.
failed
(
"文件名不能为空"
);
}
if
(
fileName
.
length
()
>
100
)
{
return
R
.
failed
(
"文件名不能超过100个字符"
);
}
// 默认关系类型为4(人员文件)
if
(
Common
.
isEmpty
(
type
))
{
type
=
CommonConstants
.
FOUR_STRING
;
}
// 构建OSS文件路径,如果文件名重复则添加后缀
String
key
=
buildUniqueFilePath
(
filePath
,
fileName
);
// 校验文件类型
if
(!
Common
.
checkFile
(
key
))
{
return
R
.
failed
(
"非法上传类型:"
+
fileName
);
}
try
{
// 上传文件到OSS
boolean
uploadSuccess
=
ossUtil
.
uploadFileByStream
(
file
.
getInputStream
(),
key
,
"yf-hr-efile-source"
);
if
(!
uploadSuccess
)
{
return
R
.
failed
(
"文件上传失败"
);
}
// 创建附件信息记录,domainId暂时为空,后续调用uploadSingleArchive接口时更新
TAttaInfo
attaInfo
=
new
TAttaInfo
();
attaInfo
.
setAttaName
(
fileName
);
attaInfo
.
setAttaSrc
(
key
);
attaInfo
.
setAttaSize
(
file
.
getSize
());
// 提取文件扩展名
int
lastDotIndex
=
key
.
lastIndexOf
(
'.'
);
if
(
lastDotIndex
>=
0
)
{
attaInfo
.
setAttaType
(
key
.
substring
(
lastDotIndex
));
}
attaInfo
.
setRelationType
(
type
);
attaInfo
.
setDomainId
(
CommonConstants
.
ZERO_STRING
);
// 临时设置为"0",后续更新
attaInfo
.
setStatus
(
CommonConstants
.
ZERO_STRING
);
// 0可用
// 保存附件信息到数据库
tAttaInfoService
.
save
(
attaInfo
);
// 获取附件URL
URL
url
=
ossUtil
.
getObjectUrl
(
"yf-hr-efile-source"
,
attaInfo
.
getAttaSrc
());
attaInfo
.
setAttaUrl
(
url
.
toString
().
replace
(
"http"
,
"https"
));
return
R
.
ok
(
attaInfo
,
"文件上传成功"
);
}
catch
(
Exception
e
)
{
log
.
error
(
"附件上传异常:"
,
e
);
// 上传失败,删除OSS文件
try
{
ossUtil
.
deleteObject
(
"yf-hr-efile-source"
,
key
);
}
catch
(
Exception
ex
)
{
log
.
error
(
"删除OSS文件失败:"
,
ex
);
}
return
R
.
failed
(
"上传异常:"
+
e
.
getMessage
());
}
}
/**
* 构建唯一的文件路径,如果文件名重复则添加后缀
*
* @param filePath 文件路径
* @param fileName 文件名
* @return 唯一的文件路径
*/
private
String
buildUniqueFilePath
(
String
filePath
,
String
fileName
)
{
// 检查文件是否存在
if
(!
fileUploadService
.
checkFileExists
(
filePath
+
"/"
+
fileName
))
{
return
filePath
+
"/"
+
fileName
;
}
// 文件存在,添加后缀
int
lastDotIndex
=
fileName
.
lastIndexOf
(
'.'
);
String
nameWithoutExt
;
String
extension
;
if
(
lastDotIndex
>
0
)
{
nameWithoutExt
=
fileName
.
substring
(
0
,
lastDotIndex
);
extension
=
fileName
.
substring
(
lastDotIndex
);
}
else
{
nameWithoutExt
=
fileName
;
extension
=
""
;
}
return
filePath
+
"/"
+
nameWithoutExt
+
"_"
+
System
.
currentTimeMillis
()
+
extension
;
}
}
}
yifu-batch/yifu-batch-biz/src/main/java/com/yifu/cloud/plus/v1/batch/controller/TElectronicArchiveDetailController.java
View file @
4338a7a0
...
@@ -170,4 +170,26 @@ public class TElectronicArchiveDetailController {
...
@@ -170,4 +170,26 @@ public class TElectronicArchiveDetailController {
tElectronicArchiveDetailService
.
exportArchivesByCondition
(
searchVo
,
response
);
tElectronicArchiveDetailService
.
exportArchivesByCondition
(
searchVo
,
response
);
}
}
/**
* 删除电子档案明细表
* <p>
* 功能说明:
* 1. 单条删除电子档案明细表记录
* 2. 同步删除该明细下所有关联的附件信息
* 3. 将明细状态更新为不可用(逻辑删除)
* 4. 将附件删除
* 5. 同时删除OSS上的附件文件
* </p>
*
* @param id 明细ID
* @return 删除结果
* @author huych
* @date 2025-12-30
*/
@Operation
(
summary
=
"删除电子档案明细表"
,
description
=
"删除电子档案明细表,同步删除所有关联的附件信息"
)
@DeleteMapping
(
"/{id}"
)
public
R
<
String
>
deleteDetail
(
@PathVariable
(
"id"
)
String
id
)
{
return
tElectronicArchiveDetailService
.
deleteArchiveDetail
(
id
);
}
}
}
yifu-batch/yifu-batch-biz/src/main/java/com/yifu/cloud/plus/v1/batch/controller/TElectronicArchiveTaskController.java
View file @
4338a7a0
...
@@ -2,16 +2,17 @@ package com.yifu.cloud.plus.v1.batch.controller;
...
@@ -2,16 +2,17 @@ package com.yifu.cloud.plus.v1.batch.controller;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
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.TElectronicArchiveTask
;
import
com.yifu.cloud.plus.v1.batch.service.ElectronicArchiveImportService
;
import
com.yifu.cloud.plus.v1.batch.service.ElectronicArchiveImportService
;
import
com.yifu.cloud.plus.v1.batch.service.TElectronicArchiveTaskService
;
import
com.yifu.cloud.plus.v1.batch.service.TElectronicArchiveTaskService
;
import
com.yifu.cloud.plus.v1.batch.vo.SingleArchiveUploadVO
;
import
com.yifu.cloud.plus.v1.batch.vo.TElectronicArchiveTaskSearchVo
;
import
com.yifu.cloud.plus.v1.batch.vo.TElectronicArchiveTaskSearchVo
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Parameter
;
import
io.swagger.v3.oas.annotations.Parameter
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
...
@@ -156,22 +157,22 @@ public class TElectronicArchiveTaskController {
...
@@ -156,22 +157,22 @@ public class TElectronicArchiveTaskController {
/**
/**
* 单个新增人员附件
* 单个新增人员附件
* 前端先调用 /fileUpload/uploadArchiveFile 接口上传文件获取附件ID列表
* 然后调用此接口传入人员信息和附件ID列表,更新附件的domainId
*
*
* @param detail 人员信息
* @param vo 人员信息,包含身份证号、姓名、项目编码、项目名称、资料类型、附件ID列表
* @param files 附件文件列表
* @return R
* @return R
*/
*/
@Operation
(
summary
=
"单个新增人员附件"
,
description
=
"单个新增人员档案附件,
包含身份证号、姓名、项目编码、项目名称、资料类型和多个附件
"
)
@Operation
(
summary
=
"单个新增人员附件"
,
description
=
"单个新增人员档案附件,
前端先上传文件获取附件ID,再调用此接口更新domainId
"
)
@PostMapping
(
"/uploadSingleArchive"
)
@PostMapping
(
"/uploadSingleArchive"
)
public
R
<?>
uploadSingleArchive
(
@RequestBody
TElectronicArchiveDetail
detail
,
public
R
<?>
uploadSingleArchive
(
@Validated
@RequestBody
SingleArchiveUploadVO
vo
)
{
@RequestParam
(
"files"
)
MultipartFile
[]
files
)
{
return
importService
.
uploadSinglePersonArchiveByAttaIds
(
vo
.
getEmpIdcard
(),
// 参数校验
vo
.
getEmpName
(),
if
(
files
==
null
||
files
.
length
==
0
)
{
vo
.
getDeptNo
(),
return
R
.
failed
(
"附件不能为空"
);
vo
.
getDeptName
(),
}
vo
.
getMaterialType
(),
vo
.
getAttaIdList
()
return
importService
.
uploadSinglePersonArchive
(
detail
.
getEmpIdcard
(),
detail
.
getEmpName
()
);
,
detail
.
getDeptNo
(),
detail
.
getDeptName
(),
detail
.
getMaterialType
(),
files
);
}
}
}
}
yifu-batch/yifu-batch-biz/src/main/java/com/yifu/cloud/plus/v1/batch/service/ElectronicArchiveImportService.java
View file @
4338a7a0
...
@@ -47,7 +47,7 @@ public interface ElectronicArchiveImportService {
...
@@ -47,7 +47,7 @@ public interface ElectronicArchiveImportService {
String
generateTaskCode
();
String
generateTaskCode
();
/**
/**
* 单个新增人员附件
* 单个新增人员附件
(旧方法,保留用于兼容)
*
*
* @param empIdcard 身份证号
* @param empIdcard 身份证号
* @param empName 姓名
* @param empName 姓名
...
@@ -59,5 +59,20 @@ public interface ElectronicArchiveImportService {
...
@@ -59,5 +59,20 @@ public interface ElectronicArchiveImportService {
*/
*/
R
<?>
uploadSinglePersonArchive
(
String
empIdcard
,
String
empName
,
String
deptNo
,
R
<?>
uploadSinglePersonArchive
(
String
empIdcard
,
String
empName
,
String
deptNo
,
String
deptName
,
String
materialType
,
MultipartFile
[]
files
);
String
deptName
,
String
materialType
,
MultipartFile
[]
files
);
/**
* 单个新增人员附件(通过附件ID列表)
* 前端先调用文件上传接口获取附件ID列表,再调用此方法更新附件的domainId
*
* @param empIdcard 身份证号
* @param empName 姓名
* @param deptNo 项目编码
* @param deptName 项目名称
* @param materialType 资料类型
* @param attaIdList 附件ID列表
* @return 上传结果
*/
R
<?>
uploadSinglePersonArchiveByAttaIds
(
String
empIdcard
,
String
empName
,
String
deptNo
,
String
deptName
,
String
materialType
,
java
.
util
.
List
<
String
>
attaIdList
);
}
}
yifu-batch/yifu-batch-biz/src/main/java/com/yifu/cloud/plus/v1/batch/service/TElectronicArchiveDetailService.java
View file @
4338a7a0
...
@@ -62,4 +62,11 @@ public interface TElectronicArchiveDetailService extends IService<TElectronicArc
...
@@ -62,4 +62,11 @@ public interface TElectronicArchiveDetailService extends IService<TElectronicArc
*/
*/
void
exportArchivesByCondition
(
TElectronicArchiveDetailSearchVo
searchVo
,
HttpServletResponse
response
);
void
exportArchivesByCondition
(
TElectronicArchiveDetailSearchVo
searchVo
,
HttpServletResponse
response
);
/**
* 删除电子档案明细表
* @param id 明细ID
* @return 删除结果
*/
R
<
String
>
deleteArchiveDetail
(
String
id
);
}
}
yifu-batch/yifu-batch-biz/src/main/java/com/yifu/cloud/plus/v1/batch/service/impl/ElectronicArchiveImportServiceImpl.java
View file @
4338a7a0
This diff is collapsed.
Click to expand it.
yifu-batch/yifu-batch-biz/src/main/java/com/yifu/cloud/plus/v1/batch/service/impl/FileUploadServiceImpl.java
View file @
4338a7a0
...
@@ -6,12 +6,12 @@ import com.yifu.cloud.plus.v1.batch.service.FileUploadService;
...
@@ -6,12 +6,12 @@ import com.yifu.cloud.plus.v1.batch.service.FileUploadService;
import
com.yifu.cloud.plus.v1.batch.service.TAttaInfoService
;
import
com.yifu.cloud.plus.v1.batch.service.TAttaInfoService
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.ResultConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.ResultConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.Common
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.Common
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.OSSUtil
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.OSSUtil
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.core.vo.FileVo
;
import
com.yifu.cloud.plus.v1.yifu.common.core.vo.FileVo
;
import
com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser
;
import
com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser
;
import
com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.GrantedAuthority
;
...
@@ -58,18 +58,34 @@ public class FileUploadServiceImpl implements FileUploadService {
...
@@ -58,18 +58,34 @@ public class FileUploadServiceImpl implements FileUploadService {
//jpg,jpeg,png,bmp
//jpg,jpeg,png,bmp
String
key
=
""
;
String
key
=
""
;
if
(
Common
.
isNotNull
(
filePath
))
{
if
(
Common
.
isNotNull
(
filePath
))
{
key
=
filePath
+
"/"
+
System
.
currentTimeMillis
()
+
fileName
;
key
=
filePath
+
"/"
+
fileName
;
}
else
{
}
else
{
key
=
System
.
currentTimeMillis
()
+
fileName
;
key
=
System
.
currentTimeMillis
()
+
fileName
;
}
}
if
(!
Common
.
checkFile
(
key
))
{
if
(!
Common
.
checkFile
(
key
))
{
return
R
.
failed
(
"非法上传类型:"
+
fileName
);
return
R
.
failed
(
"非法上传类型:"
+
fileName
);
}
}
boolean
flag
=
ossUtil
.
uploadFileByStream
(
file
.
getInputStream
(),
key
,
null
);
//判断是否存在此文件,存在的话,加后缀
if
(
ossUtil
.
doesObjectExist
(
"yf-hr-efile-source"
,
key
,
CommonConstants
.
ZERO_INT
))
{
// 文件存在,添加后缀
int
lastDotIndex
=
fileName
.
lastIndexOf
(
'.'
);
String
nameWithoutExt
;
String
extension
;
if
(
lastDotIndex
>
0
)
{
nameWithoutExt
=
fileName
.
substring
(
0
,
lastDotIndex
);
extension
=
fileName
.
substring
(
lastDotIndex
);
}
else
{
nameWithoutExt
=
fileName
;
extension
=
""
;
}
key
=
filePath
+
"/"
+
nameWithoutExt
+
"_"
+
System
.
currentTimeMillis
()
+
extension
;
}
boolean
flag
=
ossUtil
.
uploadFileByStream
(
file
.
getInputStream
(),
key
,
"yf-hr-efile-source"
);
TAttaInfo
attaInfo
;
TAttaInfo
attaInfo
;
URL
url
;
URL
url
;
if
(
flag
)
{
if
(
flag
)
{
log
.
info
(
"文件:"
+
fileName
+
"上传到存储空间"
+
ossUtil
.
getBucketName
()
+
"成功!"
);
attaInfo
=
initUnitAttaForInsert
(
fileName
,
key
,
file
.
getSize
());
attaInfo
=
initUnitAttaForInsert
(
fileName
,
key
,
file
.
getSize
());
attaInfo
.
setRelationType
(
type
);
attaInfo
.
setRelationType
(
type
);
try
{
try
{
...
@@ -78,22 +94,16 @@ public class FileUploadServiceImpl implements FileUploadService {
...
@@ -78,22 +94,16 @@ public class FileUploadServiceImpl implements FileUploadService {
Set
<
String
>
dbAuthsSet
=
new
HashSet
<>();
Set
<
String
>
dbAuthsSet
=
new
HashSet
<>();
Collection
<?
extends
GrantedAuthority
>
authorities
=
AuthorityUtils
Collection
<?
extends
GrantedAuthority
>
authorities
=
AuthorityUtils
.
createAuthorityList
(
dbAuthsSet
.
toArray
(
new
String
[
0
]));
.
createAuthorityList
(
dbAuthsSet
.
toArray
(
new
String
[
0
]));
YifuUser
user
=
new
YifuUser
(
"8"
,
1L
,
""
,
"电子档案上传"
,
YifuUser
user
=
SecurityUtils
.
getUser
();
"电子档案上传"
,
"0"
,
SecurityConstants
.
BCRYPT
+
"123456"
,
"12345678911"
,
true
,
true
,
true
,
true
,
"1"
,
authorities
,
"1"
,
null
,
null
,
null
,
null
);
attaInfo
.
setCreateBy
(
user
.
getId
());
attaInfo
.
setCreateBy
(
user
.
getId
());
attaInfo
.
setCreateName
(
user
.
getNickname
());
attaInfo
.
setCreateName
(
user
.
getNickname
());
attaInfo
=
tAttaInfoService
.
add
(
attaInfo
);
attaInfo
=
tAttaInfoService
.
add
(
attaInfo
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"OSS文件上传异常:"
+
e
.
getMessage
());
log
.
error
(
"OSS文件上传异常:"
+
e
.
getMessage
());
ossUtil
.
deleteObject
(
null
,
key
);
ossUtil
.
deleteObject
(
"yf-hr-efile-source"
,
key
);
return
R
.
failed
(
"上传异常:"
+
e
.
getMessage
());
return
R
.
failed
(
"上传异常:"
+
e
.
getMessage
());
}
}
url
=
ossUtil
.
getObjectUrl
(
null
,
attaInfo
.
getAttaSrc
());
url
=
ossUtil
.
getObjectUrl
(
"yf-hr-efile-source"
,
attaInfo
.
getAttaSrc
());
attaInfo
.
setAttaUrl
(
String
.
valueOf
(
url
));
attaInfo
.
setAttaUrl
(
String
.
valueOf
(
url
));
return
R
.
ok
(
attaInfo
);
return
R
.
ok
(
attaInfo
);
}
else
{
}
else
{
...
@@ -124,12 +134,11 @@ public class FileUploadServiceImpl implements FileUploadService {
...
@@ -124,12 +134,11 @@ public class FileUploadServiceImpl implements FileUploadService {
if
(!
Common
.
checkFile
(
key
))
{
if
(!
Common
.
checkFile
(
key
))
{
return
R
.
failed
(
"非法上传类型!"
);
return
R
.
failed
(
"非法上传类型!"
);
}
}
boolean
flag
=
ossUtil
.
uploadFileByStream
(
file
.
getInputStream
(),
key
,
null
);
boolean
flag
=
ossUtil
.
uploadFileByStream
(
file
.
getInputStream
(),
key
,
"yf-hr-efile-source"
);
FileVo
fileVo
;
FileVo
fileVo
;
TAttaInfo
attaInfo
;
TAttaInfo
attaInfo
;
URL
url
;
URL
url
;
if
(
flag
)
{
if
(
flag
)
{
log
.
info
(
"文件:"
+
fileName
+
"上传至存储空间"
+
ossUtil
.
getBucketName
()
+
"成功!"
);
attaInfo
=
initUnitAttaForInsert
(
fileName
,
key
,
file
.
getSize
());
attaInfo
=
initUnitAttaForInsert
(
fileName
,
key
,
file
.
getSize
());
attaInfo
.
setRelationType
(
type
);
attaInfo
.
setRelationType
(
type
);
try
{
try
{
...
@@ -137,16 +146,16 @@ public class FileUploadServiceImpl implements FileUploadService {
...
@@ -137,16 +146,16 @@ public class FileUploadServiceImpl implements FileUploadService {
attaInfo
=
tAttaInfoService
.
add
(
attaInfo
);
attaInfo
=
tAttaInfoService
.
add
(
attaInfo
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"OSS文件上传接口异常:"
+
e
.
getMessage
());
log
.
error
(
"OSS文件上传接口异常:"
+
e
.
getMessage
());
ossUtil
.
deleteObject
(
null
,
key
);
ossUtil
.
deleteObject
(
"yf-hr-efile-source"
,
key
);
return
R
.
failed
(
"fail:"
+
e
.
getMessage
());
return
R
.
failed
(
"fail:"
+
e
.
getMessage
());
}
}
//有实体id则插入关系,用于编辑
//有实体id则插入关系,用于编辑
if
(
Common
.
isNotNull
(
domain
))
{
if
(
Common
.
isNotNull
(
domain
))
{
url
=
ossUtil
.
getObjectUrl
(
null
,
attaInfo
.
getAttaSrc
());
url
=
ossUtil
.
getObjectUrl
(
"yf-hr-efile-source"
,
attaInfo
.
getAttaSrc
());
fileVo
=
new
FileVo
(
attaInfo
.
getId
(),
attaInfo
.
getAttaName
(),
url
.
toString
());
fileVo
=
new
FileVo
(
attaInfo
.
getId
(),
attaInfo
.
getAttaName
(),
url
.
toString
());
return
R
.
ok
(
fileVo
,
"success"
);
return
R
.
ok
(
fileVo
,
"success"
);
}
}
url
=
ossUtil
.
getObjectUrl
(
null
,
attaInfo
.
getAttaSrc
());
url
=
ossUtil
.
getObjectUrl
(
"yf-hr-efile-source"
,
attaInfo
.
getAttaSrc
());
fileVo
=
new
FileVo
(
attaInfo
.
getId
(),
attaInfo
.
getAttaName
(),
url
.
toString
());
fileVo
=
new
FileVo
(
attaInfo
.
getId
(),
attaInfo
.
getAttaName
(),
url
.
toString
());
return
R
.
ok
(
fileVo
,
"success"
);
return
R
.
ok
(
fileVo
,
"success"
);
}
else
{
}
else
{
...
@@ -216,7 +225,7 @@ public class FileUploadServiceImpl implements FileUploadService {
...
@@ -216,7 +225,7 @@ public class FileUploadServiceImpl implements FileUploadService {
@Override
@Override
public
boolean
checkFileExists
(
String
filePath
)
{
public
boolean
checkFileExists
(
String
filePath
)
{
try
{
try
{
return
ossUtil
.
doesObjectExist
(
null
,
filePath
);
return
ossUtil
.
doesObjectExist
(
"yf-hr-efile-source"
,
filePath
,
CommonConstants
.
ZERO_INT
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"检查文件是否存在失败:{}"
,
filePath
,
e
);
log
.
error
(
"检查文件是否存在失败:{}"
,
filePath
,
e
);
return
false
;
return
false
;
...
...
yifu-batch/yifu-batch-biz/src/main/java/com/yifu/cloud/plus/v1/batch/service/impl/TElectronicArchiveDetailServiceImpl.java
View file @
4338a7a0
...
@@ -111,7 +111,7 @@ public class TElectronicArchiveDetailServiceImpl extends ServiceImpl<TElectronic
...
@@ -111,7 +111,7 @@ public class TElectronicArchiveDetailServiceImpl extends ServiceImpl<TElectronic
// 查询该任务上传的附件(domainId为明细ID,附件是在处理ZIP时关联到明细的)
// 查询该任务上传的附件(domainId为明细ID,附件是在处理ZIP时关联到明细的)
List
<
TAttaInfo
>
taskAttachments
=
attaInfoService
.
list
(
Wrappers
.<
TAttaInfo
>
lambdaQuery
()
List
<
TAttaInfo
>
taskAttachments
=
attaInfoService
.
list
(
Wrappers
.<
TAttaInfo
>
lambdaQuery
()
.
eq
(
TAttaInfo:
:
getDomainId
,
id
)
.
eq
(
TAttaInfo:
:
getDomainId
,
id
)
.
eq
(
TAttaInfo:
:
getRelationType
,
ArchiveConstants
.
ATTA_RELATION_TYPE_
ZIP
)
.
eq
(
TAttaInfo:
:
getRelationType
,
ArchiveConstants
.
ATTA_RELATION_TYPE_
PER
)
.
eq
(
TAttaInfo:
:
getStatus
,
ArchiveConstants
.
ATTA_STATUS_ENABLED
));
.
eq
(
TAttaInfo:
:
getStatus
,
ArchiveConstants
.
ATTA_STATUS_ENABLED
));
if
(
CollUtil
.
isEmpty
(
taskAttachments
))
{
if
(
CollUtil
.
isEmpty
(
taskAttachments
))
{
...
@@ -620,9 +620,7 @@ public class TElectronicArchiveDetailServiceImpl extends ServiceImpl<TElectronic
...
@@ -620,9 +620,7 @@ public class TElectronicArchiveDetailServiceImpl extends ServiceImpl<TElectronic
for
(
TAttaInfo
atta
:
attachments
)
{
for
(
TAttaInfo
atta
:
attachments
)
{
try
{
try
{
// 更新附件状态为不可用
boolean
updated
=
attaInfoService
.
removeById
(
atta
);
atta
.
setStatus
(
ArchiveConstants
.
ATTA_STATUS_DISABLED
);
boolean
updated
=
attaInfoService
.
updateById
(
atta
);
if
(
updated
)
{
if
(
updated
)
{
// 删除OSS文件
// 删除OSS文件
...
@@ -1321,4 +1319,101 @@ public class TElectronicArchiveDetailServiceImpl extends ServiceImpl<TElectronic
...
@@ -1321,4 +1319,101 @@ public class TElectronicArchiveDetailServiceImpl extends ServiceImpl<TElectronic
}
}
}
}
}
}
/**
* 删除电子档案明细表
* <p>
* 功能说明:
* 1. 校验明细是否存在
* 2. 查询该明细下所有关联的附件
* 3. 将明细状态更新为不可用(逻辑删除)
* 4. 将所有附件删除
* 5. 同时删除OSS上的附件文件
* 6. 删除任务与档案的关联关系
* </p>
*
* @param id 明细ID
* @return 删除结果
* @author huych
* @date 2025-12-30
*/
@Override
public
R
<
String
>
deleteArchiveDetail
(
String
id
)
{
try
{
// 1. 校验明细是否存在
TElectronicArchiveDetail
detail
=
baseMapper
.
selectById
(
id
);
if
(
Common
.
isEmpty
(
detail
))
{
return
R
.
failed
(
"电子档案明细不存在"
);
}
// 2. 查询该明细下所有的附件(包括可用和不可用的)
List
<
TAttaInfo
>
attachments
=
attaInfoService
.
list
(
Wrappers
.<
TAttaInfo
>
lambdaQuery
()
.
eq
(
TAttaInfo:
:
getDomainId
,
id
)
.
eq
(
TAttaInfo:
:
getRelationType
,
ArchiveConstants
.
ATTA_RELATION_TYPE_ZIP
));
// 3. 删除所有附件并删除OSS文件
int
attachmentSuccessCount
=
0
;
int
attachmentFailCount
=
0
;
if
(
CollUtil
.
isNotEmpty
(
attachments
))
{
for
(
TAttaInfo
atta
:
attachments
)
{
try
{
boolean
updated
=
attaInfoService
.
removeById
(
atta
);
if
(
updated
)
{
// 删除OSS文件
try
{
ossUtil
.
deleteObject
(
"yf-hr-efile-source"
,
atta
.
getAttaSrc
());
attachmentSuccessCount
++;
}
catch
(
Exception
e
)
{
log
.
error
(
"删除OSS文件失败,附件ID:{},路径:{}"
,
atta
.
getId
(),
atta
.
getAttaSrc
(),
e
);
// OSS删除失败不影响整体流程,已经逻辑删除了
attachmentSuccessCount
++;
}
}
else
{
attachmentFailCount
++;
log
.
error
(
"更新附件状态失败,附件ID:{}"
,
atta
.
getId
());
}
}
catch
(
Exception
e
)
{
attachmentFailCount
++;
log
.
error
(
"删除附件失败,附件ID:{}"
,
atta
.
getId
(),
e
);
}
}
}
// 5. 删除任务与档案的关联关系
try
{
relationService
.
remove
(
Wrappers
.<
TTaskArchiveRelation
>
lambdaQuery
()
.
eq
(
TTaskArchiveRelation:
:
getArchiveDetailId
,
id
));
}
catch
(
Exception
e
)
{
log
.
error
(
"删除任务档案关联关系失败,明细ID:{}"
,
id
,
e
);
// 关联关系删除失败不影响主流程
}
// 6. 逻辑删除明细(更新状态为不可用,deleteFlag设为1)
detail
.
setStatus
(
ArchiveConstants
.
DETAIL_STATUS_DISABLED
);
detail
.
setDeleteFlag
(
CommonConstants
.
ONE_STRING
);
boolean
detailUpdated
=
baseMapper
.
updateById
(
detail
)
>
0
;
if
(!
detailUpdated
)
{
return
R
.
failed
(
"删除电子档案明细失败"
);
}
// 7. 构建返回消息
YifuUser
user
=
SecurityUtils
.
getUser
();
String
resultMsg
=
String
.
format
(
"删除成功。明细:%s-%s-%s,附件删除成功:%d个"
,
detail
.
getDeptNo
(),
detail
.
getEmpName
(),
detail
.
getEmpIdcard
(),
attachmentSuccessCount
);
if
(
attachmentFailCount
>
0
)
{
resultMsg
+=
String
.
format
(
",附件删除失败:%d个"
,
attachmentFailCount
);
}
return
R
.
ok
(
null
,
resultMsg
);
}
catch
(
Exception
e
)
{
log
.
error
(
"删除电子档案明细失败,明细ID:{}"
,
id
,
e
);
return
R
.
failed
(
"删除失败:"
+
e
.
getMessage
());
}
}
}
}
yifu-batch/yifu-batch-biz/src/main/resources/mapper/TElectronicArchiveDetailMapper.xml
View file @
4338a7a0
...
@@ -95,13 +95,14 @@
...
@@ -95,13 +95,14 @@
</if>
</if>
</sql>
</sql>
<!--tElectronicArchiveDetail简单分页查询-->
<!--tElectronicArchiveDetail简单分页查询-->
<select
id=
"getTElectronicArchiveDetailPage"
resultMap=
"tElectronicArchiveDetailMap"
>
<select
id=
"getTElectronicArchiveDetailPage"
resultMap=
"tElectronicArchiveDetailMap"
>
SELECT
SELECT
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
FROM t_electronic_archive_detail a
FROM t_electronic_archive_detail a
<where>
<where>
a.DELETE_FLAG = '0'
a.DELETE_FLAG = '0'
<include
refid=
"tElectronicArchiveDetail_where"
/>
<include
refid=
"tElectronicArchiveDetail_where"
/>
</where>
</where>
</select>
ORDER BY a.CREATE_TIME DESC
</select>
</mapper>
</mapper>
yifu-batch/yifu-batch-biz/src/main/resources/mapper/TElectronicArchiveTaskMapper.xml
View file @
4338a7a0
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
<result
property=
"createTime"
column=
"CREATE_TIME"
/>
<result
property=
"createTime"
column=
"CREATE_TIME"
/>
<result
property=
"updateBy"
column=
"UPDATE_BY"
/>
<result
property=
"updateBy"
column=
"UPDATE_BY"
/>
<result
property=
"updateTime"
column=
"UPDATE_TIME"
/>
<result
property=
"updateTime"
column=
"UPDATE_TIME"
/>
<result
property=
"backAttaName"
column=
"backAttaName"
/>
</resultMap>
</resultMap>
<sql
id=
"Base_Column_List"
>
<sql
id=
"Base_Column_List"
>
a.ID,
a.ID,
...
@@ -65,10 +66,14 @@
...
@@ -65,10 +66,14 @@
<select
id=
"getTElectronicArchiveTaskPage"
resultMap=
"tElectronicArchiveTaskMap"
>
<select
id=
"getTElectronicArchiveTaskPage"
resultMap=
"tElectronicArchiveTaskMap"
>
SELECT
SELECT
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
,c.ATTA_NAME as backAttaName
FROM t_electronic_archive_task a
FROM t_electronic_archive_task a
left join t_atta_info c on a.id = c.DOMAIN_ID and c.RELATION_TYPE = '3'
<where>
<where>
a.DELETE_FLAG = '0'
a.DELETE_FLAG = '0'
<include
refid=
"tElectronicArchiveTask_where"
/>
<include
refid=
"tElectronicArchiveTask_where"
/>
</where>
</where>
group by a.ID
ORDER BY a.CREATE_TIME DESC
</select>
</select>
</mapper>
</mapper>
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