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
638af99a
Commit
638af99a
authored
Jul 11, 2022
by
huyuchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
huyc 项目档案代码提交
parent
1bdf468e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
33 deletions
+69
-33
EmployeeXProjectVO.java
...fu/cloud/plus/v1/yifu/archives/vo/EmployeeXProjectVO.java
+1
-1
TEmployeeProjectController.java
.../yifu/archives/controller/TEmployeeProjectController.java
+3
-2
TEmployeeProjectService.java
...lus/v1/yifu/archives/service/TEmployeeProjectService.java
+1
-1
TEmployeeProjectServiceImpl.java
...fu/archives/service/impl/TEmployeeProjectServiceImpl.java
+64
-29
No files found.
yifu-archives/yifu-archives-api/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/vo/EmployeeXProjectVO.java
View file @
638af99a
...
@@ -65,7 +65,7 @@ public class EmployeeXProjectVO extends RowIndex implements Serializable {
...
@@ -65,7 +65,7 @@ public class EmployeeXProjectVO extends RowIndex implements Serializable {
*/
*/
@ExcelProperty
(
value
=
"减项原因"
)
@ExcelProperty
(
value
=
"减项原因"
)
@NotNull
(
message
=
"减项原因不能为空"
)
@NotNull
(
message
=
"减项原因不能为空"
)
@ExcelAttribute
(
name
=
"减项原因"
,
isNotEmpty
=
true
,
errorInfo
=
"减项原因不能为空"
,
maxLength
=
100
)
@ExcelAttribute
(
name
=
"减项原因"
,
isNotEmpty
=
true
,
errorInfo
=
"减项原因不能为空"
,
maxLength
=
100
,
isDataId
=
true
,
dataType
=
"reduce_project_reason"
)
private
String
leaveReason
;
private
String
leaveReason
;
/**
/**
...
...
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/controller/TEmployeeProjectController.java
View file @
638af99a
...
@@ -186,12 +186,13 @@ public class TEmployeeProjectController {
...
@@ -186,12 +186,13 @@ public class TEmployeeProjectController {
* @Author huyc
* @Author huyc
* @Date 2022-06-20
* @Date 2022-06-20
*/
*/
@SneakyThrows
@Operation
(
summary
=
"批量减项"
,
description
=
"批量减项"
)
@Operation
(
summary
=
"批量减项"
,
description
=
"批量减项"
)
@SysLog
(
"批量减项"
)
@SysLog
(
"批量减项"
)
@PostMapping
(
"/batchDeleteEmpPro"
)
@PostMapping
(
"/batchDeleteEmpPro"
)
@PreAuthorize
(
"@pms.hasPermission('archives_temployeeproject_batchdelempproinfo')"
)
@PreAuthorize
(
"@pms.hasPermission('archives_temployeeproject_batchdelempproinfo')"
)
public
R
<
List
<
ErrorMessage
>>
batchDeleteEmpPro
(
@Request
Excel
List
<
EmployeeXProjectVO
>
excelVOList
,
BindingResult
bindingResult
)
{
public
R
<
List
<
ErrorMessage
>>
batchDeleteEmpPro
(
@Request
Body
MultipartFile
file
)
{
return
tEmployeeProjectService
.
batchDeleteEmpPro
(
excelVOList
,
bindingResult
);
return
tEmployeeProjectService
.
batchDeleteEmpPro
(
file
.
getInputStream
()
);
}
}
/**
/**
...
...
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/TEmployeeProjectService.java
View file @
638af99a
...
@@ -103,7 +103,7 @@ public interface TEmployeeProjectService extends IService<TEmployeeProject> {
...
@@ -103,7 +103,7 @@ public interface TEmployeeProjectService extends IService<TEmployeeProject> {
* @Date: 2022/6/21 10:30
* @Date: 2022/6/21 10:30
* @return: R
* @return: R
**/
**/
R
<
List
<
ErrorMessage
>>
batchDeleteEmpPro
(
List
<
EmployeeXProjectVO
>
list
,
BindingResult
bindingResult
);
R
<
List
<
ErrorMessage
>>
batchDeleteEmpPro
(
InputStream
inputStream
);
/**
/**
* @param inputStream
* @param inputStream
...
...
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/impl/TEmployeeProjectServiceImpl.java
View file @
638af99a
...
@@ -395,6 +395,10 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
...
@@ -395,6 +395,10 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
}
}
}
}
tEmployeeInfo
.
setProjectNum
(
tEmployeeInfo
.
getProjectNum
()
-
CommonConstants
.
ONE_INT
);
tEmployeeInfo
.
setProjectNum
(
tEmployeeInfo
.
getProjectNum
()
-
CommonConstants
.
ONE_INT
);
tEmployeeInfo
.
setLeaveReason
(
tEmployeeProject
.
getLeaveReason
());
if
(
Common
.
isNotNull
(
tEmployeeProject
.
getLeaveRemark
()))
{
tEmployeeInfo
.
setLeaveRemark
(
tEmployeeProject
.
getLeaveRemark
());
}
tEmployeeInfoMapper
.
updateById
(
tEmployeeInfo
);
tEmployeeInfoMapper
.
updateById
(
tEmployeeInfo
);
tEmployeeLogService
.
saveModificationRecord
(
CommonConstants
.
dingleDigitIntArray
[
0
],
tEmployeeInfo
.
getId
(),
""
,
tEmployeeInfoOld
,
tEmployeeInfo
);
tEmployeeLogService
.
saveModificationRecord
(
CommonConstants
.
dingleDigitIntArray
[
0
],
tEmployeeInfo
.
getId
(),
""
,
tEmployeeInfoOld
,
tEmployeeInfo
);
...
@@ -410,9 +414,64 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
...
@@ -410,9 +414,64 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
}
}
@Override
@Override
public
R
<
List
<
ErrorMessage
>>
batchDeleteEmpPro
(
List
<
EmployeeXProjectVO
>
excelVOList
,
BindingResult
bindingResult
)
{
public
R
<
List
<
ErrorMessage
>>
batchDeleteEmpPro
(
InputStream
inputStream
)
{
// 通用校验获取失败的数据
List
<
ErrorMessage
>
errorMessageList
=
new
ArrayList
<>();
List
<
ErrorMessage
>
errorMessageList
=
(
List
<
ErrorMessage
>)
bindingResult
.
getTarget
();
ExcelUtil
<
EmployeeXProjectVO
>
util1
=
new
ExcelUtil
<>(
EmployeeXProjectVO
.
class
);
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try
{
EasyExcel
.
read
(
inputStream
,
EmployeeXProjectVO
.
class
,
new
ReadListener
<
EmployeeXProjectVO
>()
{
/**
* 单次缓存的数据量
*/
public
static
final
int
BATCH_COUNT
=
CommonConstants
.
BATCH_COUNT
;
/**
*临时存储
*/
private
List
<
EmployeeXProjectVO
>
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
@Override
public
void
invoke
(
EmployeeXProjectVO
data
,
AnalysisContext
context
)
{
ReadRowHolder
readRowHolder
=
context
.
readRowHolder
();
Integer
rowIndex
=
readRowHolder
.
getRowIndex
();
data
.
setRowIndex
(
rowIndex
+
1
);
ErrorMessage
errorMessage
=
util1
.
checkEntity
(
data
,
data
.
getRowIndex
());
if
(
Common
.
isNotNull
(
errorMessage
))
{
errorMessageList
.
add
(
errorMessage
);
}
else
{
cachedDataList
.
add
(
data
);
}
if
(
cachedDataList
.
size
()
>=
BATCH_COUNT
)
{
saveData
();
// 存储完成清理 list
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
}
}
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
context
)
{
saveData
();
}
/**
* 加上存储数据库
*/
private
void
saveData
()
{
log
.
info
(
"{}条数据,开始存储数据库!"
,
cachedDataList
.
size
());
deleteListAdd
(
cachedDataList
,
errorMessageList
);
log
.
info
(
"存储数据库成功!"
);
}
}).
sheet
().
doRead
();
}
catch
(
Exception
e
)
{
log
.
error
(
CommonConstants
.
IMPORT_DATA_ANALYSIS_ERROR
,
e
);
return
R
.
failed
(
CommonConstants
.
IMPORT_DATA_ANALYSIS_ERROR
);
}
return
R
.
ok
(
errorMessageList
);
}
public
R
<
List
<
ErrorMessage
>>
deleteListAdd
(
List
<
EmployeeXProjectVO
>
excelVOList
,
List
<
ErrorMessage
>
errorMessageList
)
{
//项目档案更新list
//项目档案更新list
List
<
TEmployeeProject
>
updProjectList
=
new
ArrayList
<>();
List
<
TEmployeeProject
>
updProjectList
=
new
ArrayList
<>();
...
@@ -423,24 +482,6 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
...
@@ -423,24 +482,6 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
// 新老项目档案List
// 新老项目档案List
List
<
EmployeeProjectNewOldVO
>
updateProjectList
=
new
ArrayList
<>();
List
<
EmployeeProjectNewOldVO
>
updateProjectList
=
new
ArrayList
<>();
// 调用字典服务,渲染字典值
R
<
Map
<
String
,
Map
<
String
,
Map
<
String
,
String
>>>>
dictR
=
HttpDaprUtil
.
invokeMethodPost
(
daprUpmsProperties
.
getAppUrl
(),
daprUpmsProperties
.
getAppId
()
,
"/dict/inner/getDictToLable"
,
null
,
Map
.
class
,
SecurityConstants
.
FROM_IN
);
Map
<
String
,
Map
<
String
,
Map
<
String
,
String
>>>
dictDataMap
;
Map
<
String
,
Map
<
String
,
String
>>
dictMap
;
// 民族
Map
<
String
,
String
>
empLabelMap
;
if
(
dictR
==
null
||
dictR
.
getData
()
==
null
)
{
return
R
.
failed
(
"获取字典失败!"
);
}
else
{
dictDataMap
=
dictR
.
getData
();
dictMap
=
dictDataMap
.
get
(
"data"
);
if
(
dictMap
==
null
)
{
return
R
.
failed
(
"获取字典失败!!"
);
}
empLabelMap
=
dictMap
.
get
(
"reduce_project_reason"
);
}
// 执行数据插入操作 组装 PostDto
// 执行数据插入操作 组装 PostDto
for
(
int
i
=
0
;
i
<
excelVOList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
excelVOList
.
size
();
i
++)
{
EmployeeXProjectVO
excel
=
excelVOList
.
get
(
i
);
EmployeeXProjectVO
excel
=
excelVOList
.
get
(
i
);
...
@@ -460,14 +501,8 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
...
@@ -460,14 +501,8 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
}
else
{
}
else
{
TEmployeeProject
tEmployeeProjectOld
=
this
.
getById
(
tEmployeeProject
.
getId
());
TEmployeeProject
tEmployeeProjectOld
=
this
.
getById
(
tEmployeeProject
.
getId
());
tEmployeeProject
.
setProjectStatus
(
CommonConstants
.
dingleDigitIntArray
[
1
]);
tEmployeeProject
.
setProjectStatus
(
CommonConstants
.
dingleDigitIntArray
[
1
]);
// 校验字典数据是否正确-减项原因
if
(
Common
.
isNotNull
(
excel
.
getLeaveReason
()))
{
tEmployeeProject
.
setLeaveReason
(
excel
.
getLeaveReason
());
if
(
empLabelMap
.
get
(
excel
.
getLeaveReason
())
==
null
)
{
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_IMPORT_EMP_REDUCE_ERROR
)));
}
else
{
tEmployeeProject
.
setLeaveReason
(
empLabelMap
.
get
(
excel
.
getLeaveReason
()));
}
}
tEmployeeProject
.
setLeaveRemark
(
excel
.
getLeaveRemark
());
tEmployeeProject
.
setLeaveRemark
(
excel
.
getLeaveRemark
());
tEmployeeProject
.
setLeaveTime
(
LocalDateTime
.
now
());
tEmployeeProject
.
setLeaveTime
(
LocalDateTime
.
now
());
updProjectList
.
add
(
tEmployeeProject
);
updProjectList
.
add
(
tEmployeeProject
);
...
...
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