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
b0bdf982
Commit
b0bdf982
authored
Jun 27, 2022
by
fangxinjiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码优化
parent
97698bc7
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
477 additions
and
365 deletions
+477
-365
TEmpDisabilityInfoController.java
...ifu/archives/controller/TEmpDisabilityInfoController.java
+3
-64
TEmpEducationController.java
.../v1/yifu/archives/controller/TEmpEducationController.java
+5
-116
TEmpFamilyController.java
...lus/v1/yifu/archives/controller/TEmpFamilyController.java
+4
-53
TEmpProfessionalQualificationController.java
...s/controller/TEmpProfessionalQualificationController.java
+3
-53
TEmpWorkRecordingController.java
...yifu/archives/controller/TEmpWorkRecordingController.java
+3
-55
TEmpDisabilityInfoService.java
...s/v1/yifu/archives/service/TEmpDisabilityInfoService.java
+3
-0
TEmpEducationService.java
...d/plus/v1/yifu/archives/service/TEmpEducationService.java
+6
-0
TEmpFamilyService.java
...loud/plus/v1/yifu/archives/service/TEmpFamilyService.java
+3
-0
TEmpProfessionalQualificationService.java
...rchives/service/TEmpProfessionalQualificationService.java
+3
-0
TEmpWorkRecordingService.java
...us/v1/yifu/archives/service/TEmpWorkRecordingService.java
+3
-0
TEmpDisabilityInfoServiceImpl.java
.../archives/service/impl/TEmpDisabilityInfoServiceImpl.java
+69
-4
TEmpEducationServiceImpl.java
.../yifu/archives/service/impl/TEmpEducationServiceImpl.java
+127
-4
TEmpFamilyServiceImpl.java
.../v1/yifu/archives/service/impl/TEmpFamilyServiceImpl.java
+67
-4
TEmpProfessionalQualificationServiceImpl.java
...ervice/impl/TEmpProfessionalQualificationServiceImpl.java
+68
-4
TEmpWorkRecordingServiceImpl.java
...u/archives/service/impl/TEmpWorkRecordingServiceImpl.java
+68
-4
TEmployeeProjectServiceImpl.java
...fu/archives/service/impl/TEmployeeProjectServiceImpl.java
+7
-0
ExcelUtil.java
...m/yifu.cloud.plus.v1/yifu/common/core/util/ExcelUtil.java
+20
-3
DictItemRedisInit.java
...yifu/cloud/plus/v1/yifu/admin/init/DictItemRedisInit.java
+15
-1
No files found.
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/controller/TEmpDisabilityInfoController.java
View file @
b0bdf982
...
...
@@ -17,32 +17,24 @@
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
archives
.
controller
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.read.listener.ReadListener
;
import
com.alibaba.excel.read.metadata.holder.ReadRowHolder
;
import
com.alibaba.excel.util.ListUtils
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpDisabilityInfo
;
import
com.yifu.cloud.plus.v1.yifu.archives.service.TEmpDisabilityInfoService
;
import
com.yifu.cloud.plus.v1.yifu.archives.vo.DisabilitySearchVo
;
import
com.yifu.cloud.plus.v1.yifu.archives.vo.EmpDisabilityExcelVO
;
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.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.ExcelUtil
;
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.tags.Tag
;
import
lombok.RequiredArgsConstructor
;
import
lombok.SneakyThrows
;
import
lombok.extern.log4j.Log4j2
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -158,66 +150,13 @@ public class TEmpDisabilityInfoController {
* @Author fxj
* @Date 2019-08-16
**/
@SneakyThrows
@Operation
(
description
=
"批量新增员工伤残信息 hasPermission('archives_tempdisabilityinfo_importListAdd')"
)
@SysLog
(
"批量新增员工伤残信息"
)
@PostMapping
(
"/importListAdd"
)
@PreAuthorize
(
"@pms.hasPermission('archives_tempdisabilityinfo_importListAdd')"
)
public
R
<
List
<
ErrorMessage
>>
importListAdd
(
@RequestBody
MultipartFile
file
){
List
<
ErrorMessage
>
errorMessageList
=
new
ArrayList
<>();
ExcelUtil
<
EmpDisabilityExcelVO
>
util1
=
new
ExcelUtil
<>(
EmpDisabilityExcelVO
.
class
);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try
{
EasyExcel
.
read
(
file
.
getInputStream
(),
EmpDisabilityExcelVO
.
class
,
new
ReadListener
<
EmpDisabilityExcelVO
>()
{
/**
* 单次缓存的数据量
*/
public
static
final
int
BATCH_COUNT
=
CommonConstants
.
BATCH_COUNT
;
/**
*临时存储
*/
private
List
<
EmpDisabilityExcelVO
>
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
@Override
public
void
invoke
(
EmpDisabilityExcelVO
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
());
tEmpDisabilityInfoService
.
importTmpDisability
(
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
);
return
tEmpDisabilityInfoService
.
importTmpDisabilityDiy
(
file
.
getInputStream
());
}
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/controller/TEmpEducationController.java
View file @
b0bdf982
...
...
@@ -17,32 +17,25 @@
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
archives
.
controller
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.read.listener.ReadListener
;
import
com.alibaba.excel.read.metadata.holder.ReadRowHolder
;
import
com.alibaba.excel.util.ListUtils
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpEducation
;
import
com.yifu.cloud.plus.v1.yifu.archives.service.TEmpEducationService
;
import
com.yifu.cloud.plus.v1.yifu.archives.vo.EducationSearchVo
;
import
com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateExcelVo
;
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.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.ExcelUtil
;
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.tags.Tag
;
import
lombok.RequiredArgsConstructor
;
import
lombok.SneakyThrows
;
import
lombok.extern.log4j.Log4j2
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -159,66 +152,13 @@ public class TEmpEducationController {
* @Author fxj
* @Date 2019-08-16
**/
@SneakyThrows
@Operation
(
description
=
"批量新增员工学历信息 hasPermission('archives_education_importListAdd')"
)
@SysLog
(
"批量新增员工学历信息"
)
@PostMapping
(
"/importListAdd"
)
@PreAuthorize
(
"@pms.hasPermission('archives_education_importListAdd')"
)
public
R
<
List
<
ErrorMessage
>>
importListAdd
(
@RequestBody
MultipartFile
file
)
{
List
<
ErrorMessage
>
errorMessageList
=
new
ArrayList
<>();
ExcelUtil
<
EmpEducationUpdateExcelVo
>
util1
=
new
ExcelUtil
<>(
EmpEducationUpdateExcelVo
.
class
);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try
{
EasyExcel
.
read
(
file
.
getInputStream
(),
EmpEducationUpdateExcelVo
.
class
,
new
ReadListener
<
EmpEducationUpdateExcelVo
>()
{
/**
* 单次缓存的数据量
*/
public
static
final
int
BATCH_COUNT
=
CommonConstants
.
BATCH_COUNT
;
/**
*临时存储
*/
private
List
<
EmpEducationUpdateExcelVo
>
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
@Override
public
void
invoke
(
EmpEducationUpdateExcelVo
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
());
tEmpEducationService
.
importEmpEducationUpdate
(
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
);
return
tEmpEducationService
.
importEmpEducationDiy
(
file
.
getInputStream
());
}
/**
...
...
@@ -229,63 +169,12 @@ public class TEmpEducationController {
* @Author fxj
* @Date 2019-08-16
**/
@SneakyThrows
@Operation
(
description
=
"批量更新员工学历信息 hasPermission('archives_education_importListUpdate')"
)
@SysLog
(
"批量更新员工学历信息"
)
@PostMapping
(
"/importListUpate"
)
@PreAuthorize
(
"@pms.hasPermission('archives_education_importListUpdate')"
)
public
R
<
List
<
ErrorMessage
>>
importListUpate
(
@RequestBody
MultipartFile
file
)
{
List
<
ErrorMessage
>
errorMessageList
=
new
ArrayList
<>();
ExcelUtil
<
EmpEducationUpdateExcelVo
>
util1
=
new
ExcelUtil
<>(
EmpEducationUpdateExcelVo
.
class
);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try
{
EasyExcel
.
read
(
file
.
getInputStream
(),
EmpEducationUpdateExcelVo
.
class
,
new
ReadListener
<
EmpEducationUpdateExcelVo
>()
{
/**
* 单次缓存的数据量
*/
public
static
final
int
BATCH_COUNT
=
CommonConstants
.
BATCH_COUNT
;
/**
*临时存储
*/
private
List
<
EmpEducationUpdateExcelVo
>
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
@Override
public
void
invoke
(
EmpEducationUpdateExcelVo
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
());
tEmpEducationService
.
importEmpEducationUpdate
(
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
);
return
tEmpEducationService
.
importEmpEducationUpdateDiy
(
file
.
getInputStream
());
}
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/controller/TEmpFamilyController.java
View file @
b0bdf982
...
...
@@ -37,11 +37,13 @@ import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.RequiredArgsConstructor
;
import
lombok.SneakyThrows
;
import
lombok.extern.log4j.Log4j2
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -183,63 +185,12 @@ public class TEmpFamilyController {
* @Author fxj
* @Date 2019-08-16
**/
@SneakyThrows
@Operation
(
description
=
"批量新增员工家庭信息 hasPermission('archives-family-batch-import')"
)
@SysLog
(
"批量新增员工家庭信息"
)
@PostMapping
(
"/importListAdd"
)
@PreAuthorize
(
"@pms.hasPermission('archives-family-batch-import')"
)
public
R
<
List
<
ErrorMessage
>>
importListAdd
(
@RequestBody
MultipartFile
file
){
List
<
ErrorMessage
>
errorMessageList
=
new
ArrayList
<>();
ExcelUtil
<
EmpFamilyExcelVO
>
util1
=
new
ExcelUtil
<>(
EmpFamilyExcelVO
.
class
);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try
{
EasyExcel
.
read
(
file
.
getInputStream
(),
EmpFamilyExcelVO
.
class
,
new
ReadListener
<
EmpFamilyExcelVO
>()
{
/**
* 单次缓存的数据量
*/
public
static
final
int
BATCH_COUNT
=
CommonConstants
.
BATCH_COUNT
;
/**
*临时存储
*/
private
List
<
EmpFamilyExcelVO
>
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
@Override
public
void
invoke
(
EmpFamilyExcelVO
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
());
tEmpFamilyService
.
importEmpFamily
(
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
);
return
tEmpFamilyService
.
importEmpFamilyDiy
(
file
.
getInputStream
());
}
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/controller/TEmpProfessionalQualificationController.java
View file @
b0bdf982
...
...
@@ -37,6 +37,7 @@ import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.RequiredArgsConstructor
;
import
lombok.SneakyThrows
;
import
lombok.extern.log4j.Log4j2
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -155,63 +156,12 @@ public class TEmpProfessionalQualificationController {
* @Author fxj
* @Date 2019-08-16
**/
@SneakyThrows
@Operation
(
description
=
"批量新增员工证书信息 hasPermission('archives-professionalqualification-batch-import')"
)
@SysLog
(
"批量新增员工证书信息"
)
@PostMapping
(
"/importListAdd"
)
@PreAuthorize
(
"@pms.hasPermission('archives-professionalqualification-batch-import')"
)
public
R
<
List
<
ErrorMessage
>>
importListAdd
(
@RequestBody
MultipartFile
file
)
{
List
<
ErrorMessage
>
errorMessageList
=
new
ArrayList
<>();
ExcelUtil
<
EmpCertificateExcelVO
>
util1
=
new
ExcelUtil
<>(
EmpCertificateExcelVO
.
class
);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try
{
EasyExcel
.
read
(
file
.
getInputStream
(),
EmpCertificateExcelVO
.
class
,
new
ReadListener
<
EmpCertificateExcelVO
>()
{
/**
* 单次缓存的数据量
*/
public
static
final
int
BATCH_COUNT
=
CommonConstants
.
BATCH_COUNT
;
/**
*临时存储
*/
private
List
<
EmpCertificateExcelVO
>
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
@Override
public
void
invoke
(
EmpCertificateExcelVO
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
());
qualificationService
.
importEmpCertificate
(
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
);
return
qualificationService
.
importEmpCertificateDiy
(
file
.
getInputStream
());
}
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/controller/TEmpWorkRecordingController.java
View file @
b0bdf982
...
...
@@ -37,6 +37,7 @@ import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.RequiredArgsConstructor
;
import
lombok.SneakyThrows
;
import
lombok.extern.log4j.Log4j2
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -156,65 +157,12 @@ public class TEmpWorkRecordingController {
* @Author fxj
* @Date 2019-08-16
**/
@SneakyThrows
@Operation
(
description
=
"批量新增员工工作信息 hasPermission('archives_tempworkrecording_importListAdd')"
)
@SysLog
(
"批量新增员工工作信息"
)
@PostMapping
(
"/importListAdd"
)
@PreAuthorize
(
"@pms.hasPermission('archives_tempworkrecording_importListAdd')"
)
public
R
<
List
<
ErrorMessage
>>
importListAdd
(
@RequestBody
MultipartFile
file
)
{
List
<
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
common
.
core
.
util
.
ErrorMessage
>
errorMessageList
=
new
ArrayList
<>();
ExcelUtil
<
EmpWorkRecordExcelVO
>
util1
=
new
ExcelUtil
<>(
EmpWorkRecordExcelVO
.
class
);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try
{
EasyExcel
.
read
(
file
.
getInputStream
(),
EmpWorkRecordExcelVO
.
class
,
new
ReadListener
<
EmpWorkRecordExcelVO
>()
{
/**
* 单次缓存的数据量
*/
public
static
final
int
BATCH_COUNT
=
CommonConstants
.
BATCH_COUNT
;
/**
*临时存储
*/
private
List
<
EmpWorkRecordExcelVO
>
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
@Override
public
void
invoke
(
EmpWorkRecordExcelVO
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
());
tEmpWorkRecordingService
.
importEmpWorkRecord
(
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
);
return
tEmpWorkRecordingService
.
importEmpWorkRecordDiy
(
file
.
getInputStream
());
}
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/TEmpDisabilityInfoService.java
View file @
b0bdf982
...
...
@@ -26,6 +26,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpDisabilityExcelVO;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
java.io.InputStream
;
import
java.util.List
;
/**
...
...
@@ -45,4 +46,6 @@ public interface TEmpDisabilityInfoService extends IService<TEmpDisabilityInfo>
List
<
TEmpDisabilityInfo
>
getTEmpDisabilityInfoNoPage
(
DisabilitySearchVo
searchVo
);
R
<
Boolean
>
updateByIdDiy
(
TEmpDisabilityInfo
tEmpDisabilityInfo
);
R
<
List
<
ErrorMessage
>>
importTmpDisabilityDiy
(
InputStream
inputStream
);
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/TEmpEducationService.java
View file @
b0bdf982
...
...
@@ -27,6 +27,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateExcelVo;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
java.io.InputStream
;
import
java.util.List
;
/**
...
...
@@ -50,4 +51,9 @@ public interface TEmpEducationService extends IService<TEmpEducation> {
IPage
<
TEmpEducation
>
pageDiy
(
Page
page
,
EducationSearchVo
tEmpEducation
);
List
<
TEmpEducation
>
getTEmpEducationNoPage
(
EducationSearchVo
searchVo
);
R
<
List
<
ErrorMessage
>>
importEmpEducationDiy
(
InputStream
inputStream
);
R
<
List
<
ErrorMessage
>>
importEmpEducationUpdateDiy
(
InputStream
inputStream
);
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/TEmpFamilyService.java
View file @
b0bdf982
...
...
@@ -26,6 +26,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.FamilySearchVO;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
java.io.InputStream
;
import
java.util.List
;
/**
...
...
@@ -45,4 +46,6 @@ public interface TEmpFamilyService extends IService<TEmpFamily> {
IPage
<
TEmpFamily
>
pageDiy
(
Page
page
,
FamilySearchVO
tEmpFamily
);
List
<
TEmpFamily
>
getTEmpFamilyNoPage
(
FamilySearchVO
family
);
R
<
List
<
ErrorMessage
>>
importEmpFamilyDiy
(
InputStream
fileInputStream
);
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/TEmpProfessionalQualificationService.java
View file @
b0bdf982
...
...
@@ -26,6 +26,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpCertificateExcelVO;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
java.io.InputStream
;
import
java.util.List
;
/**
...
...
@@ -43,4 +44,6 @@ public interface TEmpProfessionalQualificationService extends IService<TEmpProfe
List
<
TEmpProfessionalQualification
>
getDataNoPage
(
CertifySearchVo
searchVo
);
IPage
<
TEmpProfessionalQualification
>
pageDiy
(
Page
page
,
CertifySearchVo
searchVo
);
R
<
List
<
ErrorMessage
>>
importEmpCertificateDiy
(
InputStream
inputStream
);
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/TEmpWorkRecordingService.java
View file @
b0bdf982
...
...
@@ -26,6 +26,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.WorkRecordSearchVO;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
java.io.InputStream
;
import
java.util.List
;
/**
...
...
@@ -45,4 +46,6 @@ public interface TEmpWorkRecordingService extends IService<TEmpWorkRecording> {
IPage
<
TEmpWorkRecording
>
pageDiy
(
Page
page
,
WorkRecordSearchVO
tEmpWorkRecording
);
List
<
TEmpWorkRecording
>
getTEmpWorkRecordingNoPage
(
WorkRecordSearchVO
searchVo
);
R
<
List
<
ErrorMessage
>>
importEmpWorkRecordDiy
(
InputStream
inputStream
);
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/impl/TEmpDisabilityInfoServiceImpl.java
View file @
b0bdf982
...
...
@@ -18,6 +18,11 @@ package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.util.ArrayUtil
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.read.listener.ReadListener
;
import
com.alibaba.excel.read.metadata.holder.ReadRowHolder
;
import
com.alibaba.excel.util.ListUtils
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
...
...
@@ -33,14 +38,14 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.DisabilitySearchVo;
import
com.yifu.cloud.plus.v1.yifu.archives.vo.EmpDisabilityExcelVO
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.Common
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.MsgUtils
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.*
;
import
com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.log4j.Log4j2
;
import
org.springframework.stereotype.Service
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
...
...
@@ -49,6 +54,7 @@ import java.util.List;
* @author fxj
* @date 2022-06-18 09:39:46
*/
@Log4j2
@RequiredArgsConstructor
@Service
public
class
TEmpDisabilityInfoServiceImpl
extends
ServiceImpl
<
TEmpDisabilityInfoMapper
,
TEmpDisabilityInfo
>
implements
TEmpDisabilityInfoService
{
...
...
@@ -170,6 +176,65 @@ public class TEmpDisabilityInfoServiceImpl extends ServiceImpl<TEmpDisabilityInf
return
R
.
ok
();
}
@Override
public
R
<
List
<
ErrorMessage
>>
importTmpDisabilityDiy
(
InputStream
inputStream
)
{
List
<
ErrorMessage
>
errorMessageList
=
new
ArrayList
<>();
ExcelUtil
<
EmpDisabilityExcelVO
>
util1
=
new
ExcelUtil
<>(
EmpDisabilityExcelVO
.
class
);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try
{
EasyExcel
.
read
(
inputStream
,
EmpDisabilityExcelVO
.
class
,
new
ReadListener
<
EmpDisabilityExcelVO
>()
{
/**
* 单次缓存的数据量
*/
public
static
final
int
BATCH_COUNT
=
CommonConstants
.
BATCH_COUNT
;
/**
*临时存储
*/
private
List
<
EmpDisabilityExcelVO
>
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
@Override
public
void
invoke
(
EmpDisabilityExcelVO
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
());
importTmpDisability
(
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
);
}
private
LambdaQueryWrapper
buildQueryWrapper
(
DisabilitySearchVo
entity
){
LambdaQueryWrapper
<
TEmpDisabilityInfo
>
wrapper
=
Wrappers
.
lambdaQuery
();
wrapper
.
eq
(
TEmpDisabilityInfo:
:
getDeleteFlag
,
CommonConstants
.
ZERO_STRING
);
...
...
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/impl/TEmpEducationServiceImpl.java
View file @
b0bdf982
...
...
@@ -18,6 +18,11 @@ package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.util.ArrayUtil
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.read.listener.ReadListener
;
import
com.alibaba.excel.read.metadata.holder.ReadRowHolder
;
import
com.alibaba.excel.util.ListUtils
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
...
...
@@ -35,15 +40,15 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateExcelVo;
import
com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateVO
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.Common
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.MsgUtils
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.*
;
import
com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.log4j.Log4j2
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
...
...
@@ -52,6 +57,7 @@ import java.util.List;
* @author fxj
* @date 2022-06-18 09:39:46
*/
@Log4j2
@RequiredArgsConstructor
@Service
public
class
TEmpEducationServiceImpl
extends
ServiceImpl
<
TEmpEducationMapper
,
TEmpEducation
>
implements
TEmpEducationService
{
...
...
@@ -295,6 +301,123 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T
}
return
baseMapper
.
selectList
(
wrapper
);
}
@Override
public
R
<
List
<
ErrorMessage
>>
importEmpEducationDiy
(
InputStream
inputStream
)
{
List
<
ErrorMessage
>
errorMessageList
=
new
ArrayList
<>();
ExcelUtil
<
EmpEducationExcelVO
>
util1
=
new
ExcelUtil
<>(
EmpEducationExcelVO
.
class
);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try
{
EasyExcel
.
read
(
inputStream
,
EmpEducationExcelVO
.
class
,
new
ReadListener
<
EmpEducationExcelVO
>()
{
/**
* 单次缓存的数据量
*/
public
static
final
int
BATCH_COUNT
=
CommonConstants
.
BATCH_COUNT
;
/**
*临时存储
*/
private
List
<
EmpEducationExcelVO
>
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
@Override
public
void
invoke
(
EmpEducationExcelVO
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
());
importEmpEducation
(
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
);
}
@Override
public
R
<
List
<
ErrorMessage
>>
importEmpEducationUpdateDiy
(
InputStream
inputStream
)
{
List
<
ErrorMessage
>
errorMessageList
=
new
ArrayList
<>();
ExcelUtil
<
EmpEducationUpdateExcelVo
>
util1
=
new
ExcelUtil
<>(
EmpEducationUpdateExcelVo
.
class
);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try
{
EasyExcel
.
read
(
inputStream
,
EmpEducationUpdateExcelVo
.
class
,
new
ReadListener
<
EmpEducationUpdateExcelVo
>()
{
/**
* 单次缓存的数据量
*/
public
static
final
int
BATCH_COUNT
=
CommonConstants
.
BATCH_COUNT
;
/**
*临时存储
*/
private
List
<
EmpEducationUpdateExcelVo
>
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
@Override
public
void
invoke
(
EmpEducationUpdateExcelVo
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
());
importEmpEducationUpdate
(
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
);
}
private
LambdaQueryWrapper
buildQueryWrapper
(
EducationSearchVo
entity
){
LambdaQueryWrapper
<
TEmpEducation
>
wrapper
=
Wrappers
.
lambdaQuery
();
wrapper
.
eq
(
TEmpEducation:
:
getDeleteFlag
,
CommonConstants
.
ZERO_STRING
);
...
...
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/impl/TEmpFamilyServiceImpl.java
View file @
b0bdf982
...
...
@@ -19,6 +19,11 @@ package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.util.ArrayUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.read.listener.ReadListener
;
import
com.alibaba.excel.read.metadata.holder.ReadRowHolder
;
import
com.alibaba.excel.util.ListUtils
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
...
...
@@ -35,15 +40,15 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpFamilyExcelVO;
import
com.yifu.cloud.plus.v1.yifu.archives.vo.FamilySearchVO
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.Common
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.MsgUtils
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.*
;
import
com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.log4j.Log4j2
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
...
...
@@ -52,6 +57,7 @@ import java.util.List;
* @author fxj
* @date 2022-06-18 09:39:46
*/
@Log4j2
@RequiredArgsConstructor
@Service
public
class
TEmpFamilyServiceImpl
extends
ServiceImpl
<
TEmpFamilyMapper
,
TEmpFamily
>
implements
TEmpFamilyService
{
...
...
@@ -161,6 +167,63 @@ public class TEmpFamilyServiceImpl extends ServiceImpl<TEmpFamilyMapper, TEmpFam
return
baseMapper
.
selectList
(
wrapper
);
}
@Override
public
R
<
List
<
ErrorMessage
>>
importEmpFamilyDiy
(
InputStream
fileInputStream
)
{
List
<
ErrorMessage
>
errorMessageList
=
new
ArrayList
<>();
ExcelUtil
<
EmpFamilyExcelVO
>
util1
=
new
ExcelUtil
<>(
EmpFamilyExcelVO
.
class
);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try
{
EasyExcel
.
read
(
fileInputStream
,
EmpFamilyExcelVO
.
class
,
new
ReadListener
<
EmpFamilyExcelVO
>()
{
/**
* 单次缓存的数据量
*/
public
static
final
int
BATCH_COUNT
=
CommonConstants
.
BATCH_COUNT
;
/**
*临时存储
*/
private
List
<
EmpFamilyExcelVO
>
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
@Override
public
void
invoke
(
EmpFamilyExcelVO
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
());
importEmpFamily
(
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
);
}
private
LambdaQueryWrapper
buildQueryWrapper
(
FamilySearchVO
entity
){
LambdaQueryWrapper
<
TEmpFamily
>
wrapper
=
Wrappers
.
lambdaQuery
();
wrapper
.
eq
(
TEmpFamily:
:
getDeleteFlag
,
CommonConstants
.
ZERO_STRING
);
...
...
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/impl/TEmpProfessionalQualificationServiceImpl.java
View file @
b0bdf982
...
...
@@ -18,6 +18,11 @@ package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.util.ArrayUtil
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.read.listener.ReadListener
;
import
com.alibaba.excel.read.metadata.holder.ReadRowHolder
;
import
com.alibaba.excel.util.ListUtils
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
...
...
@@ -33,14 +38,14 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.CertifySearchVo;
import
com.yifu.cloud.plus.v1.yifu.archives.vo.EmpCertificateExcelVO
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.Common
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.MsgUtils
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.*
;
import
com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.log4j.Log4j2
;
import
org.springframework.stereotype.Service
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
...
...
@@ -49,6 +54,7 @@ import java.util.List;
* @author fxj
* @date 2022-06-18 09:39:46
*/
@Log4j2
@RequiredArgsConstructor
@Service
public
class
TEmpProfessionalQualificationServiceImpl
extends
ServiceImpl
<
TEmpProfessionalQualificationMapper
,
TEmpProfessionalQualification
>
implements
TEmpProfessionalQualificationService
{
...
...
@@ -151,6 +157,64 @@ public class TEmpProfessionalQualificationServiceImpl extends ServiceImpl<TEmpPr
wrapper
.
orderByDesc
(
BaseEntity:
:
getCreateTime
);
return
baseMapper
.
selectPage
(
page
,
wrapper
);
}
@Override
public
R
<
List
<
ErrorMessage
>>
importEmpCertificateDiy
(
InputStream
inputStream
)
{
List
<
ErrorMessage
>
errorMessageList
=
new
ArrayList
<>();
ExcelUtil
<
EmpCertificateExcelVO
>
util1
=
new
ExcelUtil
<>(
EmpCertificateExcelVO
.
class
);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try
{
EasyExcel
.
read
(
inputStream
,
EmpCertificateExcelVO
.
class
,
new
ReadListener
<
EmpCertificateExcelVO
>()
{
/**
* 单次缓存的数据量
*/
public
static
final
int
BATCH_COUNT
=
CommonConstants
.
BATCH_COUNT
;
/**
*临时存储
*/
private
List
<
EmpCertificateExcelVO
>
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
@Override
public
void
invoke
(
EmpCertificateExcelVO
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
());
importEmpCertificate
(
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
);
}
private
LambdaQueryWrapper
buildQueryWrapper
(
CertifySearchVo
entity
){
LambdaQueryWrapper
<
TEmpProfessionalQualification
>
wrapper
=
Wrappers
.
lambdaQuery
();
wrapper
.
eq
(
TEmpProfessionalQualification:
:
getDeleteFlag
,
CommonConstants
.
ZERO_STRING
);
...
...
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/impl/TEmpWorkRecordingServiceImpl.java
View file @
b0bdf982
...
...
@@ -19,6 +19,11 @@ package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.util.ArrayUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.read.listener.ReadListener
;
import
com.alibaba.excel.read.metadata.holder.ReadRowHolder
;
import
com.alibaba.excel.util.ListUtils
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
...
...
@@ -34,14 +39,14 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpWorkRecordExcelVO;
import
com.yifu.cloud.plus.v1.yifu.archives.vo.WorkRecordSearchVO
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.Common
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.MsgUtils
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.*
;
import
com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.log4j.Log4j2
;
import
org.springframework.stereotype.Service
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
...
...
@@ -50,6 +55,7 @@ import java.util.List;
* @author fxj
* @date 2022-06-18 09:39:46
*/
@Log4j2
@RequiredArgsConstructor
@Service
public
class
TEmpWorkRecordingServiceImpl
extends
ServiceImpl
<
TEmpWorkRecordingMapper
,
TEmpWorkRecording
>
implements
TEmpWorkRecordingService
{
...
...
@@ -185,6 +191,64 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM
return
baseMapper
.
selectList
(
wrapper
);
}
@Override
public
R
<
List
<
ErrorMessage
>>
importEmpWorkRecordDiy
(
InputStream
inputStream
)
{
List
<
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
common
.
core
.
util
.
ErrorMessage
>
errorMessageList
=
new
ArrayList
<>();
ExcelUtil
<
EmpWorkRecordExcelVO
>
util1
=
new
ExcelUtil
<>(
EmpWorkRecordExcelVO
.
class
);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try
{
EasyExcel
.
read
(
inputStream
,
EmpWorkRecordExcelVO
.
class
,
new
ReadListener
<
EmpWorkRecordExcelVO
>()
{
/**
* 单次缓存的数据量
*/
public
static
final
int
BATCH_COUNT
=
CommonConstants
.
BATCH_COUNT
;
/**
*临时存储
*/
private
List
<
EmpWorkRecordExcelVO
>
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
@Override
public
void
invoke
(
EmpWorkRecordExcelVO
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
());
importEmpWorkRecord
(
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
);
}
private
LambdaQueryWrapper
buildQueryWrapper
(
WorkRecordSearchVO
entity
){
LambdaQueryWrapper
<
TEmpWorkRecording
>
wrapper
=
Wrappers
.
lambdaQuery
();
wrapper
.
eq
(
TEmpWorkRecording:
:
getDeleteFlag
,
CommonConstants
.
ZERO_STRING
);
...
...
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/impl/TEmployeeProjectServiceImpl.java
View file @
b0bdf982
...
...
@@ -572,6 +572,13 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
//获取记录
list
=
gettEmpProInfoExportVos
(
idstr
,
projectDTO
);
if
(
Common
.
isNotNull
(
list
)){
ExcelUtil
<
EmployeeProjectExportVO
>
util
=
new
ExcelUtil
<>(
EmployeeProjectExportVO
.
class
);
for
(
EmployeeProjectExportVO
vo:
list
){
util
.
convertEntity
(
vo
,
null
,
null
,
null
);
}
}
ServletOutputStream
out
=
null
;
try
{
if
(
list
.
size
()>
0
)
{
...
...
yifu-common/yifu-common-core/src/main/java/com/yifu.cloud.plus.v1/yifu/common/core/util/ExcelUtil.java
View file @
b0bdf982
...
...
@@ -59,7 +59,7 @@ public class ExcelUtil <T> implements Serializable {
}
fields
=
getFiledsByParamFiled
(
fields
,
exportFields
);
ExcelAttribute
attr
=
null
;
ExcelAttribute
attr
;
Field
field
;
//分割符
String
divider
;
...
...
@@ -102,8 +102,16 @@ public class ExcelUtil <T> implements Serializable {
//如果是字典数据ID或区域ID 去dicMap(包含了区域) 取值 取不到返回空
value
=
getLableById
(
attr
,
diyDicMap
,
field
.
get
(
vo
)
==
null
?
""
:
String
.
valueOf
(
field
.
get
(
vo
)));
}
}
else
if
(
attr
.
isArea
()){
//区域字段处理 TODO
if
(!
Common
.
isNotNull
(
attr
.
parentField
()))
{
value
=
getAreaLabel
(
"area_"
+
field
.
get
(
vo
)
+
"_0"
,
attr
);
}
else
{
// TODO
value
=
getAreaLabel
(
"area_"
+
field
.
get
(
vo
)+
"_"
+
getFieldValueByName
(
attr
.
parentField
(),
vo
,
null
),
attr
);
}
}
field
.
set
(
vo
,
value
);
field
.
set
(
vo
,
Common
.
isNotNull
(
value
)?
value:
field
.
get
(
vo
)
);
}
catch
(
Exception
e
){
log
.
error
(
"字典数据解析异常"
);
}
...
...
@@ -238,7 +246,7 @@ public class ExcelUtil <T> implements Serializable {
if
(
attr
.
isArea
())
{
//区域字段处理 TODO
if
(!
Common
.
isNotNull
(
attr
.
parentField
()))
{
tempStr
=
getDicValue
(
"area_"
+
c
.
trim
()
+
"_0"
,
tempStr
,
attr
,
rowNum
,
errorTemp
);
tempStr
=
getDicValue
(
"area_"
+
c
.
trim
(),
tempStr
,
attr
,
rowNum
,
errorTemp
);
}
else
{
// TODO
tempStr
=
getDicValue
(
"area_"
+
c
.
trim
()+
"_"
+
getFieldValueByName
(
attr
.
parentField
(),
data
,
DateUtil
.
ISO_EXPANDED_DATE_FORMAT
),
tempStr
,
attr
,
rowNum
,
errorTemp
);
...
...
@@ -411,6 +419,15 @@ public class ExcelUtil <T> implements Serializable {
}
return
propertyValue
;
}
private
String
getAreaLabel
(
String
c
,
ExcelAttribute
attr
)
{
Map
<
String
,
String
>
dicObj
=
(
Map
<
String
,
String
>)
RedisUtil
.
redis
.
opsForValue
().
get
(
attr
.
dataType
());
for
(
Map
.
Entry
<
String
,
String
>
entry:
dicObj
.
entrySet
()){
if
(
Common
.
isNotNull
(
entry
.
getValue
())
&&
entry
.
getValue
().
equals
(
c
.
trim
())){
return
entry
.
getKey
();
}
}
return
null
;
}
private
String
getDicValue
(
String
c
,
String
tempStr
,
ExcelAttribute
attr
,
Integer
rowNum
,
ErrorMessage
errorTemp
)
{
Map
<
String
,
String
>
dicObj
=
(
Map
<
String
,
String
>)
RedisUtil
.
redis
.
opsForValue
().
get
(
attr
.
dataType
());
boolean
flag
=
true
;
...
...
yifu-upms/yifu-upms-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/admin/init/DictItemRedisInit.java
View file @
b0bdf982
...
...
@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PostConstruct
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -46,10 +47,23 @@ public class DictItemRedisInit {
log
.
info
(
"区域数据加入缓存初始化开始..."
);
List
<
SysArea
>
allAreas
=
sysAreaService
.
getAllArea
();
if
(
Common
.
isNotNull
(
allAreas
)){
Map
<
String
,
SysArea
>
areaMap
=
new
HashMap
<>();
for
(
SysArea
area:
allAreas
){
redisUtil
.
set
(
"area_"
+
area
.
getId
()
+
CommonConstants
.
DOWN_LINE_STRING
+(
Common
.
isEmpty
(
area
.
getParentId
())?
"0"
:
area
.
getParentId
()),
area
.
getId
());
+(
Common
.
isEmpty
(
area
.
getParentId
())?
"0"
:
area
.
getParentId
()),
area
.
getAreaName
());
areaMap
.
put
(
area
.
getId
().
toString
(),
area
);
}
SysArea
temp
;
for
(
SysArea
area:
allAreas
){
if
(
Common
.
isNotNull
(
area
.
getParentId
())
&&
area
.
getParentId
().
intValue
()
>
0
){
temp
=
areaMap
.
get
(
area
.
getParentId
());
redisUtil
.
set
(
"area_"
+
area
.
getAreaName
()
+
CommonConstants
.
DOWN_LINE_STRING
+(
Common
.
isNotNull
(
temp
)?
temp
.
getAreaName
():
""
),
area
.
getId
());
}
else
{
redisUtil
.
set
(
"area_"
+
area
.
getAreaName
(),
area
.
getId
());
}
}
}
log
.
info
(
"区域数据加入缓存初始化结束..."
);
...
...
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