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
97242b45
Commit
97242b45
authored
Jun 24, 2022
by
fangxinjiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
excel导入导出组件
parent
d1527afa
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
722 additions
and
581 deletions
+722
-581
EmpCertificateExcelVO.java
...cloud/plus/v1/yifu/archives/vo/EmpCertificateExcelVO.java
+12
-1
EmpDisabilityExcelVO.java
.../cloud/plus/v1/yifu/archives/vo/EmpDisabilityExcelVO.java
+19
-7
EmpEducationExcelVO.java
...u/cloud/plus/v1/yifu/archives/vo/EmpEducationExcelVO.java
+15
-1
EmpEducationUpdateExcelVo.java
...d/plus/v1/yifu/archives/vo/EmpEducationUpdateExcelVo.java
+14
-1
EmpFamilyExcelVO.java
...yifu/cloud/plus/v1/yifu/archives/vo/EmpFamilyExcelVO.java
+7
-5
EmpWorkRecordExcelVO.java
.../cloud/plus/v1/yifu/archives/vo/EmpWorkRecordExcelVO.java
+18
-7
ConverterDiy.java
.../plus/v1/yifu/common/security/util/dict/ConverterDiy.java
+0
-65
DictValidator.java
...plus/v1/yifu/common/security/util/dict/DictValidator.java
+0
-43
DictValuesConstraintValidator.java
...mon/security/util/dict/DictValuesConstraintValidator.java
+0
-42
ExcelListenerDiy.java
...s/v1/yifu/common/security/util/dict/ExcelListenerDiy.java
+0
-66
TEmpDisabilityInfoController.java
...ifu/archives/controller/TEmpDisabilityInfoController.java
+84
-6
TEmpEducationController.java
.../v1/yifu/archives/controller/TEmpEducationController.java
+125
-8
TEmpFamilyController.java
...lus/v1/yifu/archives/controller/TEmpFamilyController.java
+49
-46
TEmpProfessionalQualificationController.java
...s/controller/TEmpProfessionalQualificationController.java
+84
-6
TEmpWorkRecordingController.java
...yifu/archives/controller/TEmpWorkRecordingController.java
+68
-6
TEmpDisabilityInfoService.java
...s/v1/yifu/archives/service/TEmpDisabilityInfoService.java
+2
-3
TEmpEducationService.java
...d/plus/v1/yifu/archives/service/TEmpEducationService.java
+3
-4
TEmpFamilyService.java
...loud/plus/v1/yifu/archives/service/TEmpFamilyService.java
+4
-3
TEmpProfessionalQualificationService.java
...rchives/service/TEmpProfessionalQualificationService.java
+2
-2
TEmpWorkRecordingService.java
...us/v1/yifu/archives/service/TEmpWorkRecordingService.java
+2
-3
TEmpDisabilityInfoServiceImpl.java
.../archives/service/impl/TEmpDisabilityInfoServiceImpl.java
+19
-41
TEmpEducationServiceImpl.java
.../yifu/archives/service/impl/TEmpEducationServiceImpl.java
+35
-66
TEmpFamilyServiceImpl.java
.../v1/yifu/archives/service/impl/TEmpFamilyServiceImpl.java
+30
-40
TEmpProfessionalQualificationServiceImpl.java
...ervice/impl/TEmpProfessionalQualificationServiceImpl.java
+18
-42
TEmpWorkRecordingServiceImpl.java
...u/archives/service/impl/TEmpWorkRecordingServiceImpl.java
+19
-40
CommonConstants.java
...ud.plus.v1/yifu/common/core/constant/CommonConstants.java
+2
-0
ExcelAttribute.java
...oud.plus.v1/yifu/common/core/constant/ExcelAttribute.java
+1
-0
ExcelUtil.java
...m/yifu.cloud.plus.v1/yifu/common/core/util/ExcelUtil.java
+83
-20
ErrorMessage.java
...ifu/cloud/plus/v1/yifu/common/core/util/ErrorMessage.java
+7
-7
No files found.
yifu-archives/yifu-archives-api/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/vo/EmpCertificateExcelVO.java
View file @
97242b45
...
...
@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.archives.vo;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.alibaba.excel.annotation.write.style.ColumnWidth
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute
;
import
lombok.Data
;
import
javax.validation.constraints.NotNull
;
...
...
@@ -15,18 +16,20 @@ import java.io.Serializable;
*/
@Data
@ColumnWidth
(
30
)
public
class
EmpCertificateExcelVO
implements
Serializable
{
public
class
EmpCertificateExcelVO
extends
RowIndex
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 员工姓名
*/
@ExcelAttribute
(
name
=
"员工姓名"
,
errorInfo
=
"员工姓名不可为空"
)
@NotNull
(
message
=
"员工姓名不可为空"
)
@ExcelProperty
(
value
=
"员工姓名"
)
private
String
empName
;
/**
* 员工身份证
*/
@ExcelAttribute
(
name
=
"身份证号"
,
errorInfo
=
"员工身份证不可为空"
)
@NotNull
(
message
=
"员工身份证不可为空"
)
@ExcelProperty
(
value
=
"身份证号"
)
private
String
empIdcard
;
...
...
@@ -34,6 +37,7 @@ public class EmpCertificateExcelVO implements Serializable {
/**
* 资格类型
*/
@ExcelAttribute
(
name
=
"资格类型"
,
errorInfo
=
"资格类型不可为空"
)
@NotNull
(
message
=
"资格类型不可为空"
)
@ExcelProperty
(
value
=
"资格类型"
)
private
String
qualificationType
;
...
...
@@ -41,6 +45,7 @@ public class EmpCertificateExcelVO implements Serializable {
/**
* 资格等级
*/
@ExcelAttribute
(
name
=
"资格等级"
,
errorInfo
=
"资格等级不可为空"
)
@NotNull
(
message
=
"资格等级不可为空"
)
@ExcelProperty
(
value
=
"资格等级"
)
private
String
qualificationLevel
;
...
...
@@ -48,36 +53,42 @@ public class EmpCertificateExcelVO implements Serializable {
/**
* 证书编号
*/
@ExcelAttribute
(
name
=
"证书编号"
)
@ExcelProperty
(
value
=
"证书编号"
)
private
String
certificationNo
;
/**
* 获取方式
*/
@ExcelAttribute
(
name
=
"获取方式"
)
@ExcelProperty
(
value
=
"获取方式"
)
private
String
obtainType
;
/**
* 评定机构
*/
@ExcelAttribute
(
name
=
"评定机构"
)
@ExcelProperty
(
value
=
"评定机构"
)
private
String
assessmentUnit
;
/**
* 申报年度
*/
@ExcelAttribute
(
name
=
"申报年度"
)
@ExcelProperty
(
value
=
"申报年度"
)
private
String
declareYear
;
/**
* 是否最高资格0是/1否
*/
@ExcelAttribute
(
name
=
"是否最高资格"
,
errorInfo
=
"是否最高资格不可为空"
)
@NotNull
(
message
=
"是否最高资格不可为空"
)
@ExcelProperty
(
value
=
"是否最高资格"
)
private
String
heightIdentification
;
/**
* 备注
*/
@ExcelAttribute
(
name
=
"备注"
)
@ExcelProperty
(
value
=
"备注"
)
private
String
remark
;
}
yifu-archives/yifu-archives-api/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/vo/EmpDisabilityExcelVO.java
View file @
97242b45
...
...
@@ -4,6 +4,7 @@ import com.alibaba.excel.annotation.ExcelProperty;
import
com.alibaba.excel.annotation.format.DateTimeFormat
;
import
com.alibaba.excel.annotation.write.style.ColumnWidth
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
...
...
@@ -23,25 +24,30 @@ import java.util.Date;
*/
@Data
@ColumnWidth
(
30
)
public
class
EmpDisabilityExcelVO
implements
Serializable
{
public
class
EmpDisabilityExcelVO
extends
RowIndex
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 员工身份证
*/
@NotNull
(
message
=
"员工身份证不能为空"
)
@ExcelProperty
(
value
=
"身份证号"
)
private
String
empIdcard
;
/**
* 员工姓名
*/
@ExcelAttribute
(
name
=
"员工姓名"
,
errorInfo
=
"员工姓名不可为空"
)
@NotNull
(
message
=
"员工姓名不能为空"
)
@ExcelProperty
(
value
=
"员工姓名"
)
private
String
empName
;
/**
* 员工身份证
*/
@ExcelAttribute
(
name
=
"身份证号"
,
errorInfo
=
"员工身份证不能为空"
)
@NotNull
(
message
=
"员工身份证不能为空"
)
@ExcelProperty
(
value
=
"身份证号"
)
private
String
empIdcard
;
/**
* 伤残病名称
*/
@ExcelAttribute
(
name
=
"伤残病名称"
,
errorInfo
=
"伤残病名称不能为空"
)
@NotNull
(
message
=
"伤残病名称不能为空"
)
@ExcelProperty
(
value
=
"伤残病名称"
)
private
String
disabilityName
;
...
...
@@ -49,12 +55,14 @@ public class EmpDisabilityExcelVO implements Serializable {
/**
* 职业病名称
*/
@ExcelAttribute
(
name
=
"职业病名称"
)
@ExcelProperty
(
value
=
"职业病名称"
)
private
String
occupationalDisease
;
/**
* 伤残等级
*/
@ExcelAttribute
(
name
=
"伤残等级"
,
errorInfo
=
"伤残等级不能为空"
)
@NotNull
(
message
=
"伤残等级不能为空"
)
@ExcelProperty
(
value
=
"伤残等级"
)
private
String
disabilityLevel
;
...
...
@@ -62,6 +70,7 @@ public class EmpDisabilityExcelVO implements Serializable {
/**
* 伤残开始日期
*/
@ExcelAttribute
(
name
=
"伤残开始日期"
,
errorInfo
=
"伤残开始日期不能为空"
,
isDate
=
true
)
@NotNull
(
message
=
"伤残开始日期不能为空"
)
@Past
@DateTimeFormat
(
"YYYY-MM-dd"
)
...
...
@@ -71,6 +80,7 @@ public class EmpDisabilityExcelVO implements Serializable {
/**
* 伤残结束日期
*/
@ExcelAttribute
(
name
=
"伤残结束日期"
,
errorInfo
=
"伤残结束日期不能为空"
,
isDate
=
true
)
@NotNull
(
message
=
"伤残结束日期不能为空"
)
@Past
@DateTimeFormat
(
"YYYY-MM-dd"
)
...
...
@@ -80,6 +90,7 @@ public class EmpDisabilityExcelVO implements Serializable {
/**
* 是否工伤标识0是/1否
*/
@ExcelAttribute
(
name
=
"是否工伤"
,
errorInfo
=
"是否工伤不可为空"
)
@NotNull
(
message
=
"是否工伤标识(0是/1否)不能为空"
)
@ExcelProperty
(
value
=
"是否工伤"
)
private
String
injuryIdentification
;
...
...
@@ -87,6 +98,7 @@ public class EmpDisabilityExcelVO implements Serializable {
/**
* 备注
*/
@ExcelAttribute
(
name
=
"备注"
)
@ExcelProperty
(
value
=
"备注"
)
private
String
remark
;
...
...
yifu-archives/yifu-archives-api/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/vo/EmpEducationExcelVO.java
View file @
97242b45
...
...
@@ -3,6 +3,7 @@ package com.yifu.cloud.plus.v1.yifu.archives.vo;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.alibaba.excel.annotation.format.DateTimeFormat
;
import
com.alibaba.excel.annotation.write.style.ColumnWidth
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute
;
import
lombok.Data
;
import
javax.validation.constraints.NotNull
;
...
...
@@ -19,13 +20,14 @@ import java.util.Date;
*/
@Data
@ColumnWidth
(
30
)
public
class
EmpEducationExcelVO
implements
Serializable
{
public
class
EmpEducationExcelVO
extends
RowIndex
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 员工姓名
*/
@ExcelAttribute
(
name
=
"员工姓名"
,
errorInfo
=
"员工姓名不可为空"
)
@NotNull
(
message
=
"员工姓名不可为空"
)
@ExcelProperty
(
value
=
"员工姓名"
)
private
String
empName
;
...
...
@@ -33,6 +35,7 @@ public class EmpEducationExcelVO implements Serializable {
/**
* 身份证号
*/
@ExcelAttribute
(
name
=
"身份证号"
,
errorInfo
=
"员工身份证不可为空"
)
@NotNull
(
message
=
"员工身份证不可为空"
)
@ExcelProperty
(
value
=
"身份证号"
)
private
String
empIdcard
;
...
...
@@ -40,6 +43,7 @@ public class EmpEducationExcelVO implements Serializable {
/**
* 学校名称
*/
@ExcelAttribute
(
name
=
"学校"
,
errorInfo
=
"学校不可为空"
)
@NotNull
(
message
=
"学校不可为空"
)
@ExcelProperty
(
value
=
"学校"
)
private
String
school
;
...
...
@@ -47,12 +51,14 @@ public class EmpEducationExcelVO implements Serializable {
/**
* 院系名称
*/
@ExcelAttribute
(
name
=
"院系名称"
)
@ExcelProperty
(
value
=
"院系名称"
)
private
String
collageSystem
;
/**
* 专业
*/
@ExcelAttribute
(
name
=
"专业"
,
errorInfo
=
"专业不可为空"
)
@NotNull
(
message
=
"专业不可为空"
)
@ExcelProperty
(
value
=
"专业"
)
private
String
major
;
...
...
@@ -60,6 +66,7 @@ public class EmpEducationExcelVO implements Serializable {
/**
* 学历名称
*/
@ExcelAttribute
(
name
=
"学历"
,
errorInfo
=
"学历不可为空"
,
isDataId
=
true
,
dataType
=
"system_degree_dict"
)
@NotNull
(
message
=
"学历不可为空"
)
@ExcelProperty
(
value
=
"学历"
)
private
String
educationName
;
...
...
@@ -67,12 +74,14 @@ public class EmpEducationExcelVO implements Serializable {
/**
* 学历类型:全日制、自考、函授等
*/
@ExcelAttribute
(
name
=
"学历类型"
)
@ExcelProperty
(
value
=
"学历类型"
)
private
String
type
;
/**
* 最高学历标识0是/1否
*/
@ExcelAttribute
(
name
=
"最高学历"
,
errorInfo
=
"最高学历不可为空"
,
readConverterExp
=
"是:0,否:1"
)
@NotNull
(
message
=
"最高学历标识不可为空"
)
@ExcelProperty
(
value
=
"最高学历"
)
private
String
highIdentification
;
...
...
@@ -80,12 +89,14 @@ public class EmpEducationExcelVO implements Serializable {
/**
* 学制类型:四年、三年、五年、二年
*/
@ExcelAttribute
(
name
=
"学制类型"
)
@ExcelProperty
(
value
=
"学制类型"
)
private
String
educationSystem
;
/**
* 入学时间
*/
@ExcelAttribute
(
name
=
"入学时间"
,
errorInfo
=
"入学时间不可为空"
,
isDate
=
true
)
@NotNull
(
message
=
"入学时间不可为空"
)
@DateTimeFormat
(
"YYYY-MM-dd"
)
@ExcelProperty
(
value
=
"入学时间"
)
...
...
@@ -94,6 +105,7 @@ public class EmpEducationExcelVO implements Serializable {
/**
* 结业日期
*/
@ExcelAttribute
(
name
=
"毕业时间"
,
errorInfo
=
"毕业时间不可为空"
,
isDate
=
true
)
@NotNull
(
message
=
"毕业时间不可为空"
)
@DateTimeFormat
(
"YYYY-MM-dd"
)
@ExcelProperty
(
value
=
"毕业时间"
)
...
...
@@ -102,11 +114,13 @@ public class EmpEducationExcelVO implements Serializable {
/**
* 证书名称
*/
@ExcelAttribute
(
name
=
"证书名称"
)
@ExcelProperty
(
value
=
"证书名称"
)
private
String
certificationName
;
/**
* 备注
*/
@ExcelAttribute
(
name
=
"备注"
)
@ExcelProperty
(
value
=
"备注"
)
private
String
remark
;
...
...
yifu-archives/yifu-archives-api/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/vo/EmpEducationUpdateExcelVo.java
View file @
97242b45
...
...
@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.archives.vo;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.alibaba.excel.annotation.format.DateTimeFormat
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute
;
import
lombok.Data
;
import
javax.validation.constraints.NotNull
;
...
...
@@ -14,11 +15,12 @@ import java.util.Date;
* @Version 1.0
*/
@Data
public
class
EmpEducationUpdateExcelVo
{
public
class
EmpEducationUpdateExcelVo
extends
RowIndex
{
/**
* @Author fxj
* @Description 主键
**/
@ExcelAttribute
(
name
=
"主键"
,
errorInfo
=
"主键不可为空"
)
@NotNull
(
message
=
"主键不可为空"
)
@ExcelProperty
(
value
=
"主键"
)
private
String
id
;
...
...
@@ -26,6 +28,7 @@ public class EmpEducationUpdateExcelVo{
/**
* 学校名称
*/
@ExcelAttribute
(
name
=
"学校"
,
errorInfo
=
"学校不可为空"
)
@NotNull
(
message
=
"学校不可为空"
)
@ExcelProperty
(
value
=
"学校"
)
private
String
school
;
...
...
@@ -33,6 +36,7 @@ public class EmpEducationUpdateExcelVo{
/**
* 院系名称
*/
@ExcelAttribute
(
name
=
"院系名称"
)
@ExcelProperty
(
value
=
"院系名称"
)
private
String
collageSystem
;
...
...
@@ -40,6 +44,7 @@ public class EmpEducationUpdateExcelVo{
/**
* 专业
*/
@ExcelAttribute
(
name
=
"专业"
,
errorInfo
=
"专业不可为空"
)
@NotNull
(
message
=
"专业不可为空"
)
@ExcelProperty
(
value
=
"专业"
)
private
String
major
;
...
...
@@ -47,6 +52,7 @@ public class EmpEducationUpdateExcelVo{
/**
* 学历名称
*/
@ExcelAttribute
(
name
=
"学历"
,
errorInfo
=
"学历不可为空"
)
@NotNull
(
message
=
"学历不可为空"
)
@ExcelProperty
(
value
=
"学历"
)
private
String
educationName
;
...
...
@@ -54,12 +60,14 @@ public class EmpEducationUpdateExcelVo{
/**
* 学历类型:全日制、自考、函授等
*/
@ExcelAttribute
(
name
=
"学历类型"
)
@ExcelProperty
(
value
=
"学历类型"
)
private
String
type
;
/**
* 最高学历标识0是/1否
*/
@ExcelAttribute
(
name
=
"最高学历"
,
errorInfo
=
"最高学历标识不可为空"
,
readConverterExp
=
"0:是,1:否"
)
@NotNull
(
message
=
"最高学历标识不可为空"
)
@ExcelProperty
(
value
=
"最高学历"
)
private
String
highIdentification
;
...
...
@@ -67,12 +75,14 @@ public class EmpEducationUpdateExcelVo{
/**
* 学制类型:四年、三年、五年、二年
*/
@ExcelAttribute
(
name
=
"学制类型"
)
@ExcelProperty
(
value
=
"学制类型"
)
private
String
educationSystem
;
/**
* 入学时间
*/
@ExcelAttribute
(
name
=
"入学时间"
,
errorInfo
=
"入学时间不可为空"
,
isDate
=
true
)
@NotNull
(
message
=
"入学时间不可为空"
)
@DateTimeFormat
(
"YYYY-MM-dd"
)
@ExcelProperty
(
value
=
"入学时间"
)
...
...
@@ -81,6 +91,7 @@ public class EmpEducationUpdateExcelVo{
/**
* 结业日期
*/
@ExcelAttribute
(
name
=
"毕业时间"
,
errorInfo
=
"毕业时间不可为空"
,
isDate
=
true
)
@NotNull
(
message
=
"毕业时间不可为空"
)
@DateTimeFormat
(
"YYYY-MM-dd"
)
@ExcelProperty
(
value
=
"毕业时间"
)
...
...
@@ -89,11 +100,13 @@ public class EmpEducationUpdateExcelVo{
/**
* 证书名称
*/
@ExcelAttribute
(
name
=
"证书名称"
)
@ExcelProperty
(
value
=
"证书名称"
)
private
String
certificationName
;
/**
* 备注
*/
@ExcelAttribute
(
name
=
"remark"
)
@ExcelProperty
(
value
=
"备注"
)
private
String
remark
;
}
yifu-archives/yifu-archives-api/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/vo/EmpFamilyExcelVO.java
View file @
97242b45
...
...
@@ -4,8 +4,6 @@ import com.alibaba.excel.annotation.ExcelProperty;
import
com.alibaba.excel.annotation.format.DateTimeFormat
;
import
com.alibaba.excel.annotation.write.style.ColumnWidth
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute
;
import
com.yifu.cloud.plus.v1.yifu.common.security.util.dict.ConverterDiy
;
import
com.yifu.cloud.plus.v1.yifu.common.security.util.dict.DictValidator
;
import
lombok.Data
;
import
javax.validation.constraints.NotNull
;
...
...
@@ -23,10 +21,10 @@ import java.util.Date;
@ColumnWidth
(
30
)
public
class
EmpFamilyExcelVO
extends
RowIndex
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 员工姓名
*/
@ExcelAttribute
(
name
=
"员工姓名"
,
errorInfo
=
"员工姓名不可为空"
)
@NotNull
(
message
=
"员工姓名不可为空"
)
@ExcelProperty
(
value
=
"员工姓名"
)
private
String
empName
;
...
...
@@ -34,6 +32,7 @@ public class EmpFamilyExcelVO extends RowIndex implements Serializable {
/**
* 员工身份证
*/
@ExcelAttribute
(
name
=
"身份证号"
,
errorInfo
=
"身份证号不可为空"
)
@NotNull
(
message
=
"员工身份证不可为空"
)
@ExcelProperty
(
value
=
"身份证号"
)
private
String
empIdcard
;
...
...
@@ -41,6 +40,7 @@ public class EmpFamilyExcelVO extends RowIndex implements Serializable {
/**
* 家庭成员姓名
*/
@ExcelAttribute
(
name
=
"成员姓名"
,
errorInfo
=
"成员姓名不可为空"
)
@NotNull
(
message
=
"家庭成员姓名不可为空"
)
@ExcelProperty
(
value
=
"成员姓名"
)
private
String
familyName
;
...
...
@@ -48,15 +48,15 @@ public class EmpFamilyExcelVO extends RowIndex implements Serializable {
/**
* 与本人关系
*/
@ExcelAttribute
(
name
=
"与本人关系"
,
is
DataId
=
true
,
dataType
=
"family_relation
"
)
@ExcelAttribute
(
name
=
"与本人关系"
,
is
NotEmpty
=
true
,
isDataId
=
true
,
dataType
=
"family_relation"
,
errorInfo
=
"与本人关系不可为空
"
)
//@DictValidator(dictType = "family_relation",message = "与本人关系字典不匹配")
@NotNull
(
message
=
"与本人关系不可为空"
)
@ExcelProperty
(
value
=
"与本人关系"
,
converter
=
ConverterDiy
.
class
)
private
String
relationshipSelf
;
/**
* 出生日期
*/
@ExcelAttribute
(
name
=
"出生日期"
,
isDate
=
true
)
@Past
@DateTimeFormat
(
"YYYY-MM-dd"
)
@ExcelProperty
(
value
=
"出生日期"
)
...
...
@@ -65,12 +65,14 @@ public class EmpFamilyExcelVO extends RowIndex implements Serializable {
/**
* 工作/学习单位
*/
@ExcelAttribute
(
name
=
"工作单位"
)
@ExcelProperty
(
value
=
"工作单位"
)
private
String
workUnit
;
/**
* 联系电话
*/
@ExcelAttribute
(
name
=
"手机号码"
,
isNotEmpty
=
true
,
isPhone
=
true
,
errorInfo
=
"手机号码不可为空"
)
@NotNull
(
message
=
"手机号码不可为空"
)
@ExcelProperty
(
value
=
"手机号码"
)
private
String
contractTel
;
...
...
yifu-archives/yifu-archives-api/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/vo/EmpWorkRecordExcelVO.java
View file @
97242b45
...
...
@@ -3,6 +3,7 @@ package com.yifu.cloud.plus.v1.yifu.archives.vo;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.alibaba.excel.annotation.format.DateTimeFormat
;
import
com.alibaba.excel.annotation.write.style.ColumnWidth
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
...
...
@@ -21,25 +22,29 @@ import java.util.Date;
*/
@Data
@ColumnWidth
(
30
)
public
class
EmpWorkRecordExcelVO
implements
Serializable
{
public
class
EmpWorkRecordExcelVO
extends
RowIndex
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 员工身份证
*/
@NotNull
(
message
=
"员工身份证不可为空"
)
@ExcelProperty
(
value
=
"身份证号"
)
private
String
empIdcard
;
/**
* 员工姓名
*/
@ExcelAttribute
(
name
=
"员工姓名"
,
errorInfo
=
"员工姓名不可为空"
)
@NotNull
(
message
=
"员工姓名不可为空"
)
@ExcelProperty
(
value
=
"员工姓名"
)
private
String
empName
;
/**
* 员工身份证
*/
@ExcelAttribute
(
name
=
"身份证号"
,
errorInfo
=
"员工身份证不可为空"
)
@NotNull
(
message
=
"员工身份证不可为空"
)
@ExcelProperty
(
value
=
"身份证号"
)
private
String
empIdcard
;
/**
* 工作单位
*/
@ExcelAttribute
(
name
=
"工作单位"
,
errorInfo
=
"工作单位不可为空"
)
@NotNull
(
message
=
"工作单位不可为空"
)
@ExcelProperty
(
value
=
"工作单位"
)
private
String
workUnit
;
...
...
@@ -47,6 +52,7 @@ public class EmpWorkRecordExcelVO implements Serializable {
/**
* 工作部门
*/
@ExcelAttribute
(
name
=
"工作部门"
,
errorInfo
=
"工作部门不可为空"
)
@NotNull
(
message
=
"工作部门不可为空"
)
@ExcelProperty
(
value
=
"工作部门"
)
private
String
workDepart
;
...
...
@@ -54,18 +60,21 @@ public class EmpWorkRecordExcelVO implements Serializable {
/**
* 工作岗位
*/
@ExcelAttribute
(
name
=
"工作岗位"
)
@ExcelProperty
(
value
=
"工作岗位"
)
private
String
workJob
;
/**
* 工作类型
*/
@ExcelAttribute
(
name
=
"工作类型"
)
@ExcelProperty
(
value
=
"工作类型"
)
private
String
workingType
;
/**
* 是否在岗:0是/1否
*/
@ExcelAttribute
(
name
=
"在职状态"
,
errorInfo
=
"在职状态不可为空"
)
@NotNull
(
message
=
"是否在岗不可为空"
)
@ExcelProperty
(
value
=
"在职状态"
)
private
String
workingStatus
;
...
...
@@ -73,6 +82,7 @@ public class EmpWorkRecordExcelVO implements Serializable {
/**
* 开始工作日期
*/
@ExcelAttribute
(
name
=
"开始工作日期"
,
errorInfo
=
"开始工作日期不可为空"
,
isDate
=
true
)
@DateTimeFormat
(
"YYYY-MM-dd"
)
@NotNull
(
message
=
"开始工作日期不可为空"
)
@ExcelProperty
(
value
=
"开始工作日期"
)
...
...
@@ -81,6 +91,7 @@ public class EmpWorkRecordExcelVO implements Serializable {
/**
* 结束工作日期
*/
@ExcelAttribute
(
name
=
"结束工作日期"
,
isDate
=
true
)
@DateTimeFormat
(
"YYYY-MM-dd"
)
@ExcelProperty
(
value
=
"结束工作日期"
)
private
Date
endDate
;
...
...
yifu-archives/yifu-archives-api/src/main/java/com/yifu/cloud/plus/v1/yifu/common/security/util/dict/ConverterDiy.java
deleted
100644 → 0
View file @
d1527afa
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
common
.
security
.
util
.
dict
;
import
com.alibaba.excel.converters.Converter
;
import
com.alibaba.excel.converters.ReadConverterContext
;
import
com.alibaba.excel.converters.WriteConverterContext
;
import
com.alibaba.excel.enums.CellDataTypeEnum
;
import
com.alibaba.excel.metadata.data.WriteCellData
;
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.RedisUtil
;
import
java.lang.reflect.Field
;
import
java.util.Map
;
/**
* @Author fxj
* @Date 2022/6/23
* @Description
* @Version 1.0
*/
public
class
ConverterDiy
implements
Converter
<
String
>
{
@Override
public
Class
<?>
supportJavaTypeKey
()
{
return
String
.
class
;
}
@Override
public
CellDataTypeEnum
supportExcelTypeKey
()
{
return
CellDataTypeEnum
.
STRING
;
}
/**
* 这里是读的时候会调用 不用管
*
* @return
*/
@Override
public
String
convertToJavaData
(
ReadConverterContext
<?>
context
)
{
Field
field
=
context
.
getContentProperty
().
getField
();
String
converRes
=
context
.
getReadCellData
().
getStringValue
();
if
(
Common
.
isNotNull
(
field
)){
DictValidator
attr
=
field
.
getAnnotation
(
DictValidator
.
class
);
if
(
Common
.
isNotNull
(
attr
)
&&
Common
.
isNotNull
(
attr
.
dictType
())){
Map
<
String
,
String
>
dicObj
=
(
Map
<
String
,
String
>)
RedisUtil
.
redis
.
opsForValue
().
get
(
attr
.
dictType
());
for
(
Map
.
Entry
<
String
,
String
>
entry:
dicObj
.
entrySet
()){
if
(
Common
.
isNotNull
(
entry
.
getValue
())
&&
entry
.
getValue
().
equals
(
converRes
)){
converRes
=
entry
.
getKey
();
break
;
}
}
}
}
return
converRes
;
}
/**
* 这里是写的时候会调用 不用管
*
* @return
*/
@Override
public
WriteCellData
<?>
convertToExcelData
(
WriteConverterContext
<
String
>
context
)
{
return
new
WriteCellData
<>(
""
+
context
.
getValue
());
}
}
yifu-archives/yifu-archives-api/src/main/java/com/yifu/cloud/plus/v1/yifu/common/security/util/dict/DictValidator.java
deleted
100644 → 0
View file @
d1527afa
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
common
.
security
.
util
.
dict
;
import
javax.validation.Constraint
;
import
javax.validation.Payload
;
import
java.lang.annotation.*
;
/**
* @Author fxj
* @Date 2022/6/22
* @Description 数据字典注解
* @Version 1.0
*/
@Target
({
ElementType
.
METHOD
,
ElementType
.
FIELD
,
ElementType
.
ANNOTATION_TYPE
,
ElementType
.
CONSTRUCTOR
,
ElementType
.
PARAMETER
,
ElementType
.
TYPE_USE
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
@Constraint
(
validatedBy
=
{
DictValuesConstraintValidator
.
class
})
public
@interface
DictValidator
{
/**
* return message
*
* @return
*/
String
message
()
default
"字典不匹配"
;
/**
* a groups element that specifies the processing groups with which the constraint declaration is associated
*/
Class
<?>[]
groups
()
default
{};
/**
* specifies the payload with which the the constraint declaration is associated
*/
Class
<?
extends
Payload
>[]
payload
()
default
{};
/**
* 注解传参
*/
String
dictType
()
default
""
;
/**
* 读取内容转表达式 (如: 0=男,1=女,2=未知)
*/
String
readConverterExp
()
default
"父子"
;
}
yifu-archives/yifu-archives-api/src/main/java/com/yifu/cloud/plus/v1/yifu/common/security/util/dict/DictValuesConstraintValidator.java
deleted
100644 → 0
View file @
d1527afa
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
common
.
security
.
util
.
dict
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.Common
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.RedisUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Component
;
import
javax.validation.ConstraintValidator
;
import
javax.validation.ConstraintValidatorContext
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.Set
;
/**
* @Author fxj
* @Date 2022/6/22
* @Description
* @Version 1.0
*/
public
class
DictValuesConstraintValidator
implements
ConstraintValidator
<
DictValidator
,
String
>
{
Set
<
String
>
values
=
new
HashSet
<>();
@Override
public
void
initialize
(
DictValidator
constraintAnnotation
)
{
/*String readConverterExp = constraintAnnotation.readConverterExp();
values.add(readConverterExp);*/
// 获取注解中传入的values信息
String
dictType
=
constraintAnnotation
.
dictType
();
Map
<
String
,
String
>
dicObj
=
(
Map
<
String
,
String
>)
RedisUtil
.
redis
.
opsForValue
().
get
(
dictType
);
// 遍历values信息,放到set中
if
(
Common
.
isNotNull
(
dicObj
)){
values
.
addAll
(
dicObj
.
keySet
());
}
}
@Override
public
boolean
isValid
(
String
value
,
ConstraintValidatorContext
constraintValidatorContext
)
{
// 当用户传进来的值符合给定的值才允许通过(return true)
return
values
.
contains
(
value
);
}
}
yifu-archives/yifu-archives-api/src/main/java/com/yifu/cloud/plus/v1/yifu/common/security/util/dict/ExcelListenerDiy.java
deleted
100644 → 0
View file @
d1527afa
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
common
.
security
.
util
.
dict
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.event.AnalysisEventListener
;
import
com.alibaba.excel.exception.ExcelDataConvertException
;
import
com.alibaba.excel.metadata.CellExtra
;
import
com.alibaba.excel.metadata.data.ReadCellData
;
import
com.alibaba.excel.read.metadata.holder.ReadRowHolder
;
import
com.alibaba.fastjson.JSON
;
import
com.yifu.cloud.plus.v1.yifu.archives.vo.EmpFamilyExcelVO
;
import
lombok.extern.log4j.Log4j2
;
import
java.util.List
;
import
java.util.Map
;
/**
* @Author fxj
* @Date 2022/6/23
* @Description
* @Version 1.0
*/
@Log4j2
public
class
ExcelListenerDiy
extends
AnalysisEventListener
<
EmpFamilyExcelVO
>
{
List
<
EmpFamilyExcelVO
>
res
;
public
ExcelListenerDiy
(
List
<
EmpFamilyExcelVO
>
res
){
this
.
res
=
res
;
}
//解析异常调用
@Override
public
void
onException
(
Exception
exception
,
AnalysisContext
context
)
throws
Exception
{
log
.
error
(
"解析失败,但是继续解析下一行:{}"
,
exception
.
getMessage
());
if
(
exception
instanceof
ExcelDataConvertException
)
{
ExcelDataConvertException
excelDataConvertException
=
(
ExcelDataConvertException
)
exception
;
log
.
error
(
"第{}行,第{}列解析异常,数据为:{}"
,
excelDataConvertException
.
getRowIndex
(),
excelDataConvertException
.
getColumnIndex
(),
excelDataConvertException
.
getCellData
());
}
}
//解析表头
@Override
public
void
invokeHead
(
Map
<
Integer
,
ReadCellData
<?>>
headMap
,
AnalysisContext
context
)
{
}
//解析每行数据调用
@Override
public
void
invoke
(
EmpFamilyExcelVO
data
,
AnalysisContext
context
)
{
ReadRowHolder
readRowHolder
=
context
.
readRowHolder
();
Integer
rowIndex
=
readRowHolder
.
getRowIndex
();
data
.
setRowIndex
(
rowIndex
+
1
);
res
.
add
(
data
);
}
@Override
public
void
extra
(
CellExtra
extra
,
AnalysisContext
context
)
{
}
//所有数据解析完成后调用
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
context
)
{
log
.
info
(
"所有数据解析完成!"
);
log
.
info
(
"解析数据:{}"
,
JSON
.
toJSONString
(
res
));
}
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/controller/TEmpDisabilityInfoController.java
View file @
97242b45
...
...
@@ -17,18 +17,23 @@
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.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.pig4cloud.plugin.excel.annotation.RequestExcel
;
import
com.pig4cloud.plugin.excel.vo.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpDisabilityInfo
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpEducation
;
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.archives.vo.EmpFamilyExcelVO
;
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
;
...
...
@@ -38,7 +43,9 @@ import lombok.extern.log4j.Log4j2;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -140,10 +147,27 @@ public class TEmpDisabilityInfoController {
return
R
.
ok
(
tEmpDisabilityInfoService
.
removeById
(
id
));
}
/**
* 通过ids删除员工伤残信息表
* @param ids id
* @return R
*/
@Operation
(
description
=
"通过ids删除员工伤残信息表hasPermission('archives_tempdisabilityinfo_del_batch')"
)
@SysLog
(
"通过ids删除员工伤残信息表"
)
@DeleteMapping
(
"/removeByIds"
)
@PreAuthorize
(
"@pms.hasPermission('archives_tempdisabilityinfo_del_batch')"
)
public
R
<
Boolean
>
removeByIds
(
@RequestParam
String
ids
)
{
List
<
String
>
idList
=
null
;
if
(
Common
.
isNotNull
(
ids
)){
idList
=
Common
.
initStrToList
(
ids
,
CommonConstants
.
COMMA_STRING
);
}
return
R
.
ok
(
tEmpDisabilityInfoService
.
removeByIds
(
idList
));
}
/**
* 批量新增员工伤残信息
*
* @param
excelVOList
* @param
file
* @return
* @Author fxj
* @Date 2019-08-16
...
...
@@ -152,8 +176,62 @@ public class TEmpDisabilityInfoController {
@SysLog
(
"批量新增员工伤残信息"
)
@PostMapping
(
"/importListAdd"
)
@PreAuthorize
(
"@pms.hasPermission('archives_tempdisabilityinfo_importListAdd')"
)
public
R
<
List
<
ErrorMessage
>>
importListAdd
(
@RequestExcel
List
<
EmpDisabilityExcelVO
>
excelVOList
,
BindingResult
bindingResult
)
{
return
tEmpDisabilityInfoService
.
importTmpDisability
(
excelVOList
,
bindingResult
);
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
);
}
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/controller/TEmpEducationController.java
View file @
97242b45
...
...
@@ -17,27 +17,36 @@
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.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.pig4cloud.plugin.excel.annotation.RequestExcel
;
import
com.pig4cloud.plugin.excel.vo.ErrorMessage
;
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.EmpEducationExcelVO
;
import
com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateExcelVo
;
import
com.yifu.cloud.plus.v1.yifu.archives.vo.EmpFamilyExcelVO
;
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.extern.log4j.Log4j2
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -47,6 +56,7 @@ import java.util.List;
* @author fxj
* @date 2022-06-18 09:39:46
*/
@Log4j2
@RestController
@RequiredArgsConstructor
@RequestMapping
(
"/tempeducation"
)
...
...
@@ -155,7 +165,7 @@ public class TEmpEducationController {
/**
* 批量新增员工学历信息
*
* @param
excelVOList
* @param
file
* @return
* @Author fxj
* @Date 2019-08-16
...
...
@@ -164,14 +174,68 @@ public class TEmpEducationController {
@SysLog
(
"批量新增员工学历信息"
)
@PostMapping
(
"/importListAdd"
)
@PreAuthorize
(
"@pms.hasPermission('archives_education_importListAdd')"
)
public
R
<
List
<
ErrorMessage
>>
importListAdd
(
@RequestExcel
List
<
EmpEducationExcelVO
>
excelVOList
,
BindingResult
bindingResult
)
{
return
tEmpEducationService
.
importEmpEducation
(
excelVOList
,
bindingResult
);
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
);
}
/**
* 批量更新员工学历信息
*
* @param
excelVOList
* @param
file
* @return
* @Author fxj
* @Date 2019-08-16
...
...
@@ -180,7 +244,60 @@ public class TEmpEducationController {
@SysLog
(
"批量更新员工学历信息"
)
@PostMapping
(
"/importListUpate"
)
@PreAuthorize
(
"@pms.hasPermission('archives_education_importListUpdate')"
)
public
R
<
List
<
ErrorMessage
>>
importListUpate
(
@RequestExcel
List
<
EmpEducationUpdateExcelVo
>
excelVOList
,
BindingResult
bindingResult
)
{
return
tEmpEducationService
.
importEmpEducationUpdate
(
excelVOList
,
bindingResult
);
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
);
}
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/controller/TEmpFamilyController.java
View file @
97242b45
...
...
@@ -43,6 +43,7 @@ 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
;
...
...
@@ -166,7 +167,7 @@ public class TEmpFamilyController {
if
(
Common
.
isNotNull
(
ids
)){
idList
=
Common
.
initStrToList
(
ids
,
CommonConstants
.
COMMA_STRING
);
}
return
R
.
ok
(
tEmpFamilyService
.
removeByIds
(
idList
)
);
return
tEmpFamilyService
.
removeByIdsDiy
(
idList
);
}
...
...
@@ -198,59 +199,61 @@ public class TEmpFamilyController {
@SysLog
(
"批量新增员工家庭信息"
)
@PostMapping
(
"/importListAdd"
)
@PreAuthorize
(
"@pms.hasPermission('archives-family-batch-import')"
)
public
R
<
List
<
ErrorMessage
>>
importListAdd
(
@RequestBody
MultipartFile
file
)
throws
Exception
{
/*
List<EmpFamilyExcelVO> excelVOList = new ArrayList<>();
EasyExcel.read(file.getInputStream(),EmpFamilyExcelVO.class,new ExcelListenerDiy(excelVOList)).sheet(0);
return tEmpFamilyService.importEmpFamily(excelVOList, bindingResult);
*/
ExcelUtil
<
EmpFamilyExcelVO
>
util1
=
null
;
public
R
<
List
<
ErrorMessage
>>
importListAdd
(
@RequestBody
MultipartFile
file
){
List
<
ErrorMessage
>
errorMessageList
=
new
ArrayList
<>();
ExcelUtil
<
EmpFamilyExcelVO
>
util1
=
new
ExcelUtil
<>(
EmpFamilyExcelVO
.
class
);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
EasyExcel
.
read
(
file
.
getInputStream
(),
EmpFamilyExcelVO
.
class
,
new
ReadListener
<
EmpFamilyExcelVO
>()
{
/**
* 单次缓存的数据量
*/
public
static
final
int
BATCH_COUNT
=
1
;
/**
*临时存储
*/
private
List
<
EmpFamilyExcelVO
>
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
try
{
@Override
public
void
invoke
(
EmpFamilyExcelVO
data
,
AnalysisContext
context
)
{
//List<ObjectError> errorMessages = bindingResult.getAllErrors();
ReadRowHolder
readRowHolder
=
context
.
readRowHolder
();
Integer
rowIndex
=
readRowHolder
.
getRowIndex
();
data
.
setRowIndex
(
rowIndex
+
1
);
util1
.
checkEntity
(
data
,
rowIndex
);
cachedDataList
.
add
(
data
);
if
(
cachedDataList
.
size
()
>=
BATCH_COUNT
)
{
saveData
();
// 存储完成清理 list
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
}
}
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
());
log
.
info
(
"存储数据库成功!"
);
}
}).
sheet
().
doRead
();
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
context
)
{
saveData
();
}
if
(
null
!=
util1
.
getErrorInfo
()
&&
!
util1
.
getErrorInfo
().
isEmpty
())
{
return
R
.
failed
(
util1
.
getErrorInfo
());
/**
* 加上存储数据库
*/
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
null
;
return
R
.
ok
(
errorMessageList
)
;
}
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/controller/TEmpProfessionalQualificationController.java
View file @
97242b45
...
...
@@ -17,26 +17,34 @@
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.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.pig4cloud.plugin.excel.annotation.RequestExcel
;
import
com.pig4cloud.plugin.excel.vo.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpProfessionalQualification
;
import
com.yifu.cloud.plus.v1.yifu.archives.service.TEmpProfessionalQualificationService
;
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.archives.vo.EmpFamilyExcelVO
;
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.extern.log4j.Log4j2
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -46,6 +54,7 @@ import java.util.List;
* @author fxj
* @date 2022-06-18 09:39:46
*/
@Log4j2
@RestController
@RequiredArgsConstructor
@RequestMapping
(
"/tempprofessionalqualification"
)
...
...
@@ -135,10 +144,27 @@ public class TEmpProfessionalQualificationController {
public
R
removeById
(
@PathVariable
String
id
)
{
return
R
.
ok
(
qualificationService
.
removeById
(
id
));
}
/**
* 通过ids删除员工职业资格信息表
* @param ids id
* @return R
*/
@Operation
(
description
=
"通过ids删除员工职业资格信息表hasPermission('archives_tempprofessionalqualification_del_batch')"
)
@SysLog
(
"通过ids删除员工职业资格信息表"
)
@DeleteMapping
(
"/removeByIds"
)
@PreAuthorize
(
"@pms.hasPermission('archives_tempprofessionalqualification_del_batch')"
)
public
R
removeByIds
(
@RequestParam
String
ids
)
{
List
<
String
>
idList
=
null
;
if
(
Common
.
isNotNull
(
ids
)){
idList
=
Common
.
initStrToList
(
ids
,
CommonConstants
.
COMMA_STRING
);
}
return
R
.
ok
(
qualificationService
.
removeByIds
(
idList
));
}
/**
* 批量新增员工证书信息
*
* @param
excelVOList
* @param
file
* @return
* @Author fxj
* @Date 2019-08-16
...
...
@@ -147,7 +173,59 @@ public class TEmpProfessionalQualificationController {
@SysLog
(
"批量新增员工证书信息"
)
@PostMapping
(
"/importListAdd"
)
@PreAuthorize
(
"@pms.hasPermission('archives-professionalqualification-batch-import')"
)
public
R
<
List
<
ErrorMessage
>>
importListAdd
(
@RequestExcel
List
<
EmpCertificateExcelVO
>
excelVOList
,
BindingResult
bindingResult
)
{
return
qualificationService
.
importEmpCertificate
(
excelVOList
,
bindingResult
);
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
);
}
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/controller/TEmpWorkRecordingController.java
View file @
97242b45
...
...
@@ -17,26 +17,33 @@
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.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.pig4cloud.plugin.excel.annotation.RequestExcel
;
import
com.pig4cloud.plugin.excel.vo.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpWorkRecording
;
import
com.yifu.cloud.plus.v1.yifu.archives.service.TEmpWorkRecordingService
;
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.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.extern.log4j.Log4j2
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -46,6 +53,7 @@ import java.util.List;
* @author fxj
* @date 2022-06-18 09:39:46
*/
@Log4j2
@RestController
@RequiredArgsConstructor
@RequestMapping
(
"/tempworkrecording"
)
...
...
@@ -155,7 +163,7 @@ public class TEmpWorkRecordingController {
/**
* 批量新增员工工作信息
*
* @param
excelVOList
* @param
file
* @return
* @Author fxj
* @Date 2019-08-16
...
...
@@ -164,7 +172,61 @@ public class TEmpWorkRecordingController {
@SysLog
(
"批量新增员工工作信息"
)
@PostMapping
(
"/importListAdd"
)
@PreAuthorize
(
"@pms.hasPermission('archives_tempworkrecording_importListAdd')"
)
public
R
<
List
<
ErrorMessage
>>
importListAdd
(
@RequestExcel
List
<
EmpWorkRecordExcelVO
>
excelVOList
,
BindingResult
bindingResult
)
{
return
tEmpWorkRecordingService
.
importEmpWorkRecord
(
excelVOList
,
bindingResult
);
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
);
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
common
.
core
.
util
.
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
);
}
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/TEmpDisabilityInfoService.java
View file @
97242b45
...
...
@@ -18,11 +18,10 @@
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
archives
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.pig4cloud.plugin.excel.vo.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpDisabilityInfo
;
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
org.springframework.validation.BindingResult
;
import
java.util.List
;
...
...
@@ -34,7 +33,7 @@ import java.util.List;
*/
public
interface
TEmpDisabilityInfoService
extends
IService
<
TEmpDisabilityInfo
>
{
R
<
List
<
ErrorMessage
>>
importTmpDisability
(
List
<
EmpDisabilityExcelVO
>
excelVOList
,
BindingResult
bindingResult
);
void
importTmpDisability
(
List
<
EmpDisabilityExcelVO
>
excelVOList
,
List
<
ErrorMessage
>
errorMessages
);
R
<
Boolean
>
saveDiy
(
TEmpDisabilityInfo
tEmpDisabilityInfo
);
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/TEmpEducationService.java
View file @
97242b45
...
...
@@ -18,12 +18,11 @@
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
archives
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.pig4cloud.plugin.excel.vo.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpEducation
;
import
com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationExcelVO
;
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
org.springframework.validation.BindingResult
;
import
java.util.List
;
...
...
@@ -35,13 +34,13 @@ import java.util.List;
*/
public
interface
TEmpEducationService
extends
IService
<
TEmpEducation
>
{
R
<
List
<
ErrorMessage
>>
importEmpEducation
(
List
<
EmpEducationExcelVO
>
excelVOList
,
BindingResult
bindingResul
t
);
void
importEmpEducation
(
List
<
EmpEducationExcelVO
>
excelVOList
,
List
<
ErrorMessage
>
errorMessageLis
t
);
R
<
Boolean
>
updateByIdDiy
(
TEmpEducation
tEmpEducation
);
R
<
Boolean
>
saveDiy
(
TEmpEducation
tEmpEducation
);
R
<
List
<
ErrorMessage
>>
importEmpEducationUpdate
(
List
<
EmpEducationUpdateExcelVo
>
excelVOList
,
BindingResult
bindingResul
t
);
void
importEmpEducationUpdate
(
List
<
EmpEducationUpdateExcelVo
>
excelVOList
,
List
<
ErrorMessage
>
errorMessageLis
t
);
R
<
Boolean
>
insertEducationOfEmp
(
TEmpEducation
education
);
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/TEmpFamilyService.java
View file @
97242b45
...
...
@@ -18,11 +18,10 @@
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
archives
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.pig4cloud.plugin.excel.vo.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpFamily
;
import
com.yifu.cloud.plus.v1.yifu.archives.vo.EmpFamilyExcelVO
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
org.springframework.validation.BindingResult
;
import
java.util.List
;
...
...
@@ -34,7 +33,9 @@ import java.util.List;
*/
public
interface
TEmpFamilyService
extends
IService
<
TEmpFamily
>
{
R
<
List
<
ErrorMessage
>>
importEmpFamily
(
List
<
EmpFamilyExcelVO
>
excelVOList
,
BindingResult
bindingResul
t
);
void
importEmpFamily
(
List
<
EmpFamilyExcelVO
>
excelVOList
,
List
<
ErrorMessage
>
errorMessageLis
t
);
String
checkRepeat
(
String
empIdcard
,
String
familyName
,
String
updateId
);
R
<
Boolean
>
removeByIdsDiy
(
List
<
String
>
idList
);
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/TEmpProfessionalQualificationService.java
View file @
97242b45
...
...
@@ -18,9 +18,9 @@
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
archives
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.pig4cloud.plugin.excel.vo.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpProfessionalQualification
;
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
org.springframework.validation.BindingResult
;
...
...
@@ -36,5 +36,5 @@ public interface TEmpProfessionalQualificationService extends IService<TEmpProfe
R
<
Boolean
>
saveDiy
(
TEmpProfessionalQualification
tEmpProfessionalQualification
);
R
<
List
<
ErrorMessage
>>
importEmpCertificate
(
List
<
EmpCertificateExcelVO
>
excelVOList
,
BindingResult
bindingResul
t
);
void
importEmpCertificate
(
List
<
EmpCertificateExcelVO
>
excelVOList
,
List
<
ErrorMessage
>
errorMessageLis
t
);
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/TEmpWorkRecordingService.java
View file @
97242b45
...
...
@@ -18,11 +18,10 @@
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
archives
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.pig4cloud.plugin.excel.vo.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpWorkRecording
;
import
com.yifu.cloud.plus.v1.yifu.archives.vo.EmpWorkRecordExcelVO
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
org.springframework.validation.BindingResult
;
import
java.util.List
;
...
...
@@ -34,7 +33,7 @@ import java.util.List;
*/
public
interface
TEmpWorkRecordingService
extends
IService
<
TEmpWorkRecording
>
{
R
<
List
<
ErrorMessage
>>
importEmpWorkRecord
(
List
<
EmpWorkRecordExcelVO
>
excelVOList
,
BindingResult
bindingResul
t
);
void
importEmpWorkRecord
(
List
<
EmpWorkRecordExcelVO
>
excelVOList
,
List
<
ErrorMessage
>
errorMessageLis
t
);
R
<
Boolean
>
updateByIdDiy
(
TEmpWorkRecording
tEmpWorkRecording
);
...
...
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/impl/TEmpDisabilityInfoServiceImpl.java
View file @
97242b45
...
...
@@ -17,10 +17,8 @@
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
archives
.
service
.
impl
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.pig4cloud.plugin.excel.vo.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpDisabilityInfo
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo
;
import
com.yifu.cloud.plus.v1.yifu.archives.mapper.TAttaInfoMapper
;
...
...
@@ -31,11 +29,11 @@ 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
lombok.RequiredArgsConstructor
;
import
org.springframework.stereotype.Service
;
import
org.springframework.validation.BindingResult
;
import
java.util.*
;
...
...
@@ -60,74 +58,54 @@ public class TEmpDisabilityInfoServiceImpl extends ServiceImpl<TEmpDisabilityInf
* @return
**/
@Override
public
R
<
List
<
ErrorMessage
>>
importTmpDisability
(
List
<
EmpDisabilityExcelVO
>
excelVOList
,
BindingResult
bindingResult
)
{
// 通用校验获取失败的数据
List
<
ErrorMessage
>
errorList
=
(
List
<
ErrorMessage
>)
bindingResult
.
getTarget
();
Map
<
Long
,
ErrorMessage
>
errorMsgMap
=
new
HashMap
<>();
if
(
Common
.
isNotNull
(
errorList
)){
errorList
.
stream
().
forEach
(
errorMessage
->
errorMsgMap
.
put
(
errorMessage
.
getLineNum
(),
errorMessage
));
}
public
void
importTmpDisability
(
List
<
EmpDisabilityExcelVO
>
excelVOList
,
List
<
ErrorMessage
>
errorMessageList
)
{
// 个性化校验逻辑
List
<
TEmpDisabilityInfo
>
list
=
this
.
list
();
TEmployeeInfo
emp
;
TEmpDisabilityInfo
exist
;
Set
<
String
>
errorMsg
;
List
<
ErrorMessage
>
temp
=
new
ArrayList
<>();
ErrorMessage
errorMessage
;
TEmpDisabilityInfo
exist
;
ErrorMessage
errorMsg
;
// 执行数据插入操作 组装
for
(
int
i
=
0
;
i
<
excelVOList
.
size
();
i
++)
{
// 已有验证报错直接下一个
errorMessage
=
errorMsgMap
.
get
(
i
+
2
);
if
(
Common
.
isNotNull
(
errorMessage
)){
temp
.
add
(
errorMessage
);
errorMsgMap
.
remove
(
i
+
2
);
continue
;
}
errorMsg
=
new
HashSet
<>();
EmpDisabilityExcelVO
excel
=
excelVOList
.
get
(
i
);
emp
=
employeeInfoMapper
.
selectOne
(
Wrappers
.<
TEmployeeInfo
>
query
().
lambda
()
.
eq
(
TEmployeeInfo:
:
getEmpIdcard
,
excel
.
getEmpIdcard
())
.
eq
(
TEmployeeInfo:
:
getDeleteFlag
,
CommonConstants
.
ZERO_STRING
)
.
last
(
CommonConstants
.
LAST_ONE_SQL
));
checkRes
(
list
,
emp
,
errorMsg
,
excel
);
errorMsg
=
checkRes
(
list
,
emp
,
excel
);
if
(
Common
.
isNotNull
(
errorMsg
)){
errorMessageList
.
add
(
errorMsg
);
continue
;
}
exist
=
baseMapper
.
selectOne
(
Wrappers
.<
TEmpDisabilityInfo
>
query
().
lambda
()
.
eq
(
TEmpDisabilityInfo:
:
getEmpIdcard
,
excel
.
getEmpIdcard
())
.
eq
(
TEmpDisabilityInfo:
:
getDisabilityName
,
excel
.
getDisabilityName
())
.
eq
(
TEmpDisabilityInfo:
:
getDeleteFlag
,
CommonConstants
.
ZERO_STRING
)
.
last
(
CommonConstants
.
LAST_ONE_SQL
));
if
(
Common
.
isNotNull
(
exist
)){
errorM
sg
.
add
(
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_DISABILITY_NAME_EXISTING
,
excel
.
getEmpName
(
)));
errorM
essageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_DISABILITY_NAME_EXISTING
)));
}
// 数据合法情况
if
(
CollUtil
.
isEmpty
(
errorMsg
))
{
insertExcelPost
(
excel
,
emp
);
errorMsg
.
add
(
CommonConstants
.
SAVE_SUCCESS
);
temp
.
add
(
new
ErrorMessage
((
long
)
(
i
+
2
),
errorMsg
));
}
else
{
// 数据不合法
temp
.
add
(
new
ErrorMessage
((
long
)
(
i
+
2
),
errorMsg
));
}
// 数据合法情况
insertExcel
(
excel
,
emp
);
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
CommonConstants
.
SAVE_SUCCESS
));
}
temp
.
addAll
(
errorMsgMap
.
values
());
return
R
.
ok
(
temp
);
}
private
void
checkRes
(
List
<
TEmpDisabilityInfo
>
list
,
TEmployeeInfo
emp
,
Set
<
String
>
errorMsg
,
EmpDisabilityExcelVO
excel
)
{
private
ErrorMessage
checkRes
(
List
<
TEmpDisabilityInfo
>
list
,
TEmployeeInfo
emp
,
EmpDisabilityExcelVO
excel
)
{
if
(
Common
.
isEmpty
(
emp
)){
errorMsg
.
add
(
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_NOT_EXIST
,
excel
.
getEmpIdcard
()));
return
;
return
new
ErrorMessage
(
excel
.
getRowIndex
(),
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_NOT_EXIST
));
}
if
(
CommonConstants
.
ONE_STRING
.
equals
(
emp
.
getFileStatus
())){
errorMsg
.
add
(
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_REDUCED
,
excel
.
getEmpIdcard
()));
return
;
return
new
ErrorMessage
(
excel
.
getRowIndex
(),
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_REDUCED
));
}
// 检查添加是否已经存在
boolean
match
=
list
.
stream
().
anyMatch
(
info
->
excel
.
getDisabilityName
().
equals
(
info
.
getDisabilityName
())
&&
excel
.
getEmpIdcard
().
equals
(
info
.
getEmpIdcard
()));
if
(
match
)
{
errorMsg
.
add
(
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_DISABILITY_NAME_EXISTING
,
excel
.
getEmpName
()));
return
;
return
new
ErrorMessage
(
excel
.
getRowIndex
(),
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_DISABILITY_NAME_EXISTING
));
}
return
null
;
}
@Override
public
R
<
Boolean
>
saveDiy
(
TEmpDisabilityInfo
tEmpDisabilityInfo
)
{
...
...
@@ -149,7 +127,7 @@ public class TEmpDisabilityInfoServiceImpl extends ServiceImpl<TEmpDisabilityInf
/**
* 插入excel
*/
private
void
insertExcel
Post
(
EmpDisabilityExcelVO
excel
,
TEmployeeInfo
emp
)
{
private
void
insertExcel
(
EmpDisabilityExcelVO
excel
,
TEmployeeInfo
emp
)
{
TEmpDisabilityInfo
insert
=
new
TEmpDisabilityInfo
();
BeanUtil
.
copyProperties
(
excel
,
insert
);
insert
.
setDeleteFlag
(
CommonConstants
.
ZERO_STRING
);
...
...
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/impl/TEmpEducationServiceImpl.java
View file @
97242b45
...
...
@@ -20,8 +20,8 @@ import cn.hutool.core.bean.BeanUtil;
import
cn.hutool.core.collection.CollUtil
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.pig4cloud.plugin.excel.vo.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpEducation
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpFamily
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo
;
import
com.yifu.cloud.plus.v1.yifu.archives.mapper.TAttaInfoMapper
;
import
com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmpEducationMapper
;
...
...
@@ -30,9 +30,11 @@ import com.yifu.cloud.plus.v1.yifu.archives.service.TEmpEducationService;
import
com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationExcelVO
;
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.archives.vo.EmpFamilyExcelVO
;
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
lombok.RequiredArgsConstructor
;
...
...
@@ -63,56 +65,37 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T
**/
@Transactional
@Override
public
R
<
List
<
ErrorMessage
>>
importEmpEducation
(
List
<
EmpEducationExcelVO
>
excelVOList
,
BindingResult
bindingResult
)
{
// 通用校验获取失败的数据
List
<
ErrorMessage
>
errorMessageList
=
(
List
<
ErrorMessage
>)
bindingResult
.
getTarget
();
Map
<
Long
,
ErrorMessage
>
errorMsgMap
=
new
HashMap
<>();
if
(
Common
.
isNotNull
(
errorMessageList
)){
errorMessageList
.
stream
().
forEach
(
errorMessage
->
errorMsgMap
.
put
(
errorMessage
.
getLineNum
(),
errorMessage
));
}
// 个性化校验逻辑
public
void
importEmpEducation
(
List
<
EmpEducationExcelVO
>
excelVOList
,
List
<
ErrorMessage
>
errorMessageList
)
{
/// 个性化校验逻辑
List
<
TEmpEducation
>
list
=
this
.
list
();
TEmployeeInfo
emp
;
TEmpEducation
exist
;
Set
<
String
>
errorMsg
;
ErrorMessage
errorMessage
;
List
<
ErrorMessage
>
temp
=
new
ArrayList
<>();
ErrorMessage
errorMsg
;
// 执行数据插入操作 组装
for
(
int
i
=
0
;
i
<
excelVOList
.
size
();
i
++)
{
errorMessage
=
errorMsgMap
.
get
(
i
+
2
);
// 已有验证报错直接下一个
if
(
Common
.
isNotNull
(
errorMsgMap
.
get
(
i
+
2
))){
temp
.
add
(
errorMessage
);
errorMsgMap
.
remove
(
i
+
2
);
continue
;
}
errorMsg
=
new
HashSet
<>();
EmpEducationExcelVO
excel
=
excelVOList
.
get
(
i
);
emp
=
employeeInfoMapper
.
selectOne
(
Wrappers
.<
TEmployeeInfo
>
query
().
lambda
()
.
eq
(
TEmployeeInfo:
:
getEmpIdcard
,
excel
.
getEmpIdcard
())
.
eq
(
TEmployeeInfo:
:
getDeleteFlag
,
CommonConstants
.
ZERO_STRING
)
.
eq
(
TEmployeeInfo:
:
getDeleteFlag
,
CommonConstants
.
ZERO_STRING
)
.
last
(
CommonConstants
.
LAST_ONE_SQL
));
checkRes
(
emp
,
errorMsg
,
excel
,
list
);
errorMsg
=
checkRes
(
emp
,
excel
,
list
);
if
(
Common
.
isNotNull
(
errorMsg
)){
errorMessageList
.
add
(
errorMsg
);
continue
;
}
exist
=
baseMapper
.
selectOne
(
Wrappers
.<
TEmpEducation
>
query
().
lambda
()
.
eq
(
TEmpEducation:
:
getEmpIdcard
,
excel
.
getEmpIdcard
())
.
eq
(
TEmpEducation:
:
getEducationName
,
excel
.
getEducationName
())
.
eq
(
TEmpEducation:
:
getDeleteFlag
,
CommonConstants
.
ZERO_STRING
)
.
last
(
CommonConstants
.
LAST_ONE_SQL
));
if
(
Common
.
isNotNull
(
exist
)){
errorM
sg
.
add
(
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_EDUCATION_EXISTING
,
excel
.
getEducationName
(
)));
errorM
essageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_EDUCATION_EXISTING
)));
}
// 数据合法情况
if
(
CollUtil
.
isEmpty
(
errorMsg
))
{
insertExcel
(
excel
,
emp
);
errorMsg
.
add
(
CommonConstants
.
SAVE_SUCCESS
);
temp
.
add
(
new
ErrorMessage
((
long
)
(
i
+
2
),
errorMsg
));
}
else
{
// 数据不合法
temp
.
add
(
new
ErrorMessage
((
long
)
(
i
+
2
),
errorMsg
));
}
insertExcel
(
excel
,
emp
);
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
CommonConstants
.
SAVE_SUCCESS
));
}
temp
.
addAll
(
errorMsgMap
.
values
());
return
R
.
ok
(
temp
);
}
/**
...
...
@@ -170,39 +153,27 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T
* @Date 16:25 2022/6/20
**/
@Override
public
R
<
List
<
ErrorMessage
>>
importEmpEducationUpdate
(
List
<
EmpEducationUpdateExcelVo
>
excelVOList
,
BindingResult
bindingResult
)
{
// 通用校验获取失败的数据
List
<
ErrorMessage
>
errorMessageList
=
(
List
<
ErrorMessage
>)
bindingResult
.
getTarget
();
Map
<
Long
,
ErrorMessage
>
errorMsgMap
=
new
HashMap
<>();
if
(
Common
.
isNotNull
(
errorMessageList
)){
errorMessageList
.
stream
().
forEach
(
errorMessage
->
errorMsgMap
.
put
(
errorMessage
.
getLineNum
(),
errorMessage
));
}
// 个性化校验逻辑
Set
<
String
>
errorMsg
;
ErrorMessage
errorMessage
;
List
<
ErrorMessage
>
temp
=
new
ArrayList
<>();
public
void
importEmpEducationUpdate
(
List
<
EmpEducationUpdateExcelVo
>
excelVOList
,
List
<
ErrorMessage
>
errorMessageList
)
{
List
<
TEmpEducation
>
list
=
this
.
list
();
TEmployeeInfo
emp
;
TEmpEducation
exist
;
ErrorMessage
errorMsg
;
// 执行数据插入操作 组装
for
(
int
i
=
0
;
i
<
excelVOList
.
size
();
i
++)
{
// 已有验证报错直接下一个
errorMessage
=
errorMsgMap
.
get
(
i
+
2
);
if
(
Common
.
isNotNull
(
errorMessage
)){
temp
.
add
(
errorMessage
);
continue
;
}
errorMsg
=
new
HashSet
<>();
EmpEducationUpdateExcelVo
excel
=
excelVOList
.
get
(
i
);
// 数据合法情况
if
(
CollUtil
.
isEmpty
(
errorMsg
))
{
updateExcel
(
excel
);
errorMsg
.
add
(
CommonConstants
.
UPDATE_SUCCESS
);
temp
.
add
(
new
ErrorMessage
((
long
)
(
i
+
2
),
errorMsg
));
}
else
{
// 数据不合法
temp
.
add
(
new
ErrorMessage
((
long
)
(
i
+
2
),
errorMsg
));
exist
=
baseMapper
.
selectOne
(
Wrappers
.<
TEmpEducation
>
query
().
lambda
()
.
eq
(
TEmpEducation:
:
getEducationName
,
excel
.
getEducationName
())
.
eq
(
TEmpEducation:
:
getDeleteFlag
,
CommonConstants
.
ZERO_STRING
)
.
last
(
CommonConstants
.
LAST_ONE_SQL
));
if
(
Common
.
isNotNull
(
exist
)){
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_EDUCATION_EXISTING
)));
}
// 数据合法情况
updateExcel
(
excel
);
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
CommonConstants
.
UPDATE_SUCCESS
));
}
temp
.
addAll
(
errorMsgMap
.
values
());
return
R
.
ok
(
temp
);
}
private
void
updateExcel
(
EmpEducationUpdateExcelVo
excel
)
{
...
...
@@ -213,23 +184,21 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T
this
.
updateById
(
update
);
}
private
void
checkRes
(
TEmployeeInfo
emp
,
Set
<
String
>
errorMsg
,
EmpEducationExcelVO
excel
,
List
<
TEmpEducation
>
list
)
{
private
ErrorMessage
checkRes
(
TEmployeeInfo
emp
,
EmpEducationExcelVO
excel
,
List
<
TEmpEducation
>
list
)
{
if
(
Common
.
isEmpty
(
emp
)){
errorMsg
.
add
(
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_NOT_EXIST
,
excel
.
getEmpIdcard
()));
return
;
return
new
ErrorMessage
(
excel
.
getRowIndex
(),
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_NOT_EXIST
));
}
if
(
CommonConstants
.
ONE_STRING
.
equals
(
emp
.
getFileStatus
())){
errorMsg
.
add
(
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_REDUCED
,
excel
.
getEmpIdcard
()));
return
;
return
new
ErrorMessage
(
excel
.
getRowIndex
(),
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_REDUCED
));
}
// 检查添加是否已经存在
boolean
match
=
list
.
stream
().
anyMatch
(
info
->
excel
.
getEducationName
().
equals
(
info
.
getEducationName
())
&&
excel
.
getEmpIdcard
().
equals
(
info
.
getEmpIdcard
()));
if
(
match
)
{
errorMsg
.
add
(
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_EDUCATION_EXISTING
,
excel
.
getEmpName
()));
return
;
return
new
ErrorMessage
(
excel
.
getRowIndex
(),
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_EDUCATION_EXISTING
));
}
return
null
;
}
private
void
updateEducationOfEmp
(
TEmpEducation
education
)
{
...
...
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/impl/TEmpFamilyServiceImpl.java
View file @
97242b45
...
...
@@ -17,12 +17,12 @@
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
archives
.
service
.
impl
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.pig4cloud.plugin.excel.vo.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpFamily
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo
;
import
com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmpFamilyMapper
;
...
...
@@ -32,11 +32,12 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpFamilyExcelVO;
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
lombok.RequiredArgsConstructor
;
import
org.springframework.stereotype.Service
;
import
org.springframework.
validation.BindingResult
;
import
org.springframework.
transaction.annotation.Transactional
;
import
java.util.*
;
...
...
@@ -58,76 +59,58 @@ public class TEmpFamilyServiceImpl extends ServiceImpl<TEmpFamilyMapper, TEmpFam
* @Param
* @return
**/
@Transactional
@Override
public
R
<
List
<
ErrorMessage
>>
importEmpFamily
(
List
<
EmpFamilyExcelVO
>
excelVOList
,
BindingResult
bindingResult
)
{
// 通用校验获取失败的数据
List
<
ErrorMessage
>
errorList
=
(
List
<
ErrorMessage
>)
bindingResult
.
getTarget
();
Map
<
Long
,
ErrorMessage
>
errorMsgMap
=
new
HashMap
<>();
if
(
Common
.
isNotNull
(
errorList
)){
errorList
.
stream
().
forEach
(
errorMessage
->
errorMsgMap
.
put
(
errorMessage
.
getLineNum
(),
errorMessage
));
}
public
void
importEmpFamily
(
List
<
EmpFamilyExcelVO
>
excelVOList
,
List
<
ErrorMessage
>
errorMessageList
)
{
// 个性化校验逻辑
List
<
TEmpFamily
>
list
=
this
.
list
();
TEmployeeInfo
emp
;
TEmpFamily
exist
;
Set
<
String
>
errorMsg
;
List
<
ErrorMessage
>
temp
=
new
ArrayList
<>();
ErrorMessage
errorMessage
;
ErrorMessage
errorMsg
;
// 执行数据插入操作 组装
for
(
int
i
=
0
;
i
<
excelVOList
.
size
();
i
++)
{
// 已有验证报错直接下一个
errorMessage
=
errorMsgMap
.
get
(
i
+
2
);
if
(
Common
.
isNotNull
(
errorMessage
)){
temp
.
add
(
errorMessage
);
errorMsgMap
.
remove
(
i
+
2
);
continue
;
}
errorMsg
=
new
HashSet
<>();
EmpFamilyExcelVO
excel
=
excelVOList
.
get
(
i
);
emp
=
employeeInfoMapper
.
selectOne
(
Wrappers
.<
TEmployeeInfo
>
query
().
lambda
()
.
eq
(
TEmployeeInfo:
:
getEmpIdcard
,
excel
.
getEmpIdcard
())
.
eq
(
TEmployeeInfo:
:
getDeleteFlag
,
CommonConstants
.
ZERO_STRING
)
.
last
(
CommonConstants
.
LAST_ONE_SQL
));
checkRes
(
list
,
emp
,
errorMsg
,
excel
);
errorMsg
=
checkRes
(
list
,
emp
,
excel
);
if
(
Common
.
isNotNull
(
errorMsg
)){
errorMessageList
.
add
(
errorMsg
);
continue
;
}
exist
=
baseMapper
.
selectOne
(
Wrappers
.<
TEmpFamily
>
query
().
lambda
()
.
eq
(
TEmpFamily:
:
getEmpIdcard
,
excel
.
getEmpIdcard
())
.
eq
(
TEmpFamily:
:
getFamilyName
,
excel
.
getFamilyName
())
.
eq
(
TEmpFamily:
:
getDeleteFlag
,
CommonConstants
.
ZERO_STRING
)
.
last
(
CommonConstants
.
LAST_ONE_SQL
));
if
(
Common
.
isNotNull
(
exist
)){
errorMsg
.
add
(
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_FAMILY_NAME_EXISTING
,
excel
.
getFamilyName
()));
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_FAMILY_NAME_EXISTING
)));
continue
;
}
// 数据合法情况
if
(
CollUtil
.
isEmpty
(
errorMsg
))
{
insertExcelPost
(
excel
,
emp
);
errorMsg
.
add
(
CommonConstants
.
SAVE_SUCCESS
);
temp
.
add
(
new
ErrorMessage
((
long
)
(
i
+
2
),
errorMsg
));
}
else
{
// 数据不合法
temp
.
add
(
new
ErrorMessage
((
long
)
(
i
+
2
),
errorMsg
));
}
insertExcel
(
excel
,
emp
);
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
CommonConstants
.
SAVE_SUCCESS
));
}
temp
.
addAll
(
errorMsgMap
.
values
());
return
R
.
ok
(
temp
);
}
private
void
checkRes
(
List
<
TEmpFamily
>
list
,
TEmployeeInfo
emp
,
Set
<
String
>
errorMsg
,
EmpFamilyExcelVO
excel
)
{
private
ErrorMessage
checkRes
(
List
<
TEmpFamily
>
list
,
TEmployeeInfo
emp
,
EmpFamilyExcelVO
excel
)
{
if
(
Common
.
isEmpty
(
emp
)){
errorMsg
.
add
(
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_NOT_EXIST
,
excel
.
getEmpIdcard
()));
return
;
return
new
ErrorMessage
(
excel
.
getRowIndex
(),
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_NOT_EXIST
));
}
if
(
CommonConstants
.
ONE_STRING
.
equals
(
emp
.
getFileStatus
())){
errorMsg
.
add
(
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_REDUCED
,
excel
.
getEmpIdcard
()
));
return
;
return
new
ErrorMessage
(
excel
.
getRowIndex
(),
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_REDUCED
));
}
// 检查添加是否已经存在
boolean
match
=
list
.
stream
().
anyMatch
(
info
->
excel
.
getFamilyName
().
equals
(
info
.
getFamilyName
())
&&
excel
.
getEmpIdcard
().
equals
(
info
.
getEmpIdcard
()));
if
(
match
)
{
errorMsg
.
add
(
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_FAMILY_NAME_EXISTING
,
excel
.
getFamilyName
()));
return
;
return
new
ErrorMessage
(
excel
.
getRowIndex
(),
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_FAMILY_NAME_EXISTING
));
}
return
null
;
}
@Override
...
...
@@ -149,10 +132,17 @@ public class TEmpFamilyServiceImpl extends ServiceImpl<TEmpFamilyMapper, TEmpFam
return
null
;
}
@Override
public
R
<
Boolean
>
removeByIdsDiy
(
List
<
String
>
idList
)
{
LambdaUpdateWrapper
<
TEmpFamily
>
updateWrapper
=
new
UpdateWrapper
<
TEmpFamily
>().
lambda
();
updateWrapper
.
set
(
TEmpFamily:
:
getDeleteFlag
,
CommonConstants
.
ONE_STRING
).
in
(
TEmpFamily:
:
getId
,
idList
);
return
R
.
ok
(
this
.
update
(
updateWrapper
));
}
/**
* 插入excel family
*/
private
void
insertExcel
Post
(
EmpFamilyExcelVO
excel
,
TEmployeeInfo
emp
)
{
private
void
insertExcel
(
EmpFamilyExcelVO
excel
,
TEmployeeInfo
emp
)
{
TEmpFamily
insert
=
new
TEmpFamily
();
BeanUtil
.
copyProperties
(
excel
,
insert
);
insert
.
setDeleteFlag
(
CommonConstants
.
ZERO_STRING
);
...
...
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/impl/TEmpProfessionalQualificationServiceImpl.java
View file @
97242b45
...
...
@@ -17,10 +17,8 @@
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
archives
.
service
.
impl
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.pig4cloud.plugin.excel.vo.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpProfessionalQualification
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo
;
import
com.yifu.cloud.plus.v1.yifu.archives.mapper.TAttaInfoMapper
;
...
...
@@ -31,11 +29,11 @@ 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
lombok.RequiredArgsConstructor
;
import
org.springframework.stereotype.Service
;
import
org.springframework.validation.BindingResult
;
import
java.util.*
;
...
...
@@ -70,61 +68,41 @@ public class TEmpProfessionalQualificationServiceImpl extends ServiceImpl<TEmpPr
}
@Override
public
R
<
List
<
ErrorMessage
>>
importEmpCertificate
(
List
<
EmpCertificateExcelVO
>
excelVOList
,
BindingResult
bindingResult
)
{
// 通用校验获取失败的数据
List
<
ErrorMessage
>
errorList
=
(
List
<
ErrorMessage
>)
bindingResult
.
getTarget
();
Map
<
Long
,
ErrorMessage
>
errorMsgMap
=
new
HashMap
<>();
if
(
Common
.
isNotNull
(
errorList
)){
errorList
.
stream
().
forEach
(
errorMessage
->
errorMsgMap
.
put
(
errorMessage
.
getLineNum
(),
errorMessage
));
}
// 个性化校验逻辑
public
void
importEmpCertificate
(
List
<
EmpCertificateExcelVO
>
excelVOList
,
List
<
ErrorMessage
>
errorMessageList
)
{
List
<
TEmpProfessionalQualification
>
list
=
this
.
list
();
TEmployeeInfo
emp
;
TEmpProfessionalQualification
exist
;
Set
<
String
>
errorMsg
;
List
<
ErrorMessage
>
temp
=
new
ArrayList
<>();
ErrorMessage
errorMessage
=
null
;
ErrorMessage
errorMsg
;
// 执行数据插入操作 组装
for
(
int
i
=
0
;
i
<
excelVOList
.
size
();
i
++)
{
// 已有验证报错直接下一个
errorMessage
=
errorMsgMap
.
get
(
i
+
2
);
if
(
Common
.
isNotNull
(
errorMessage
)){
temp
.
add
(
errorMessage
);
errorMsgMap
.
remove
(
i
+
2
);
continue
;
}
errorMsg
=
new
HashSet
<>();
EmpCertificateExcelVO
excel
=
excelVOList
.
get
(
i
);
emp
=
employeeInfoMapper
.
selectOne
(
Wrappers
.<
TEmployeeInfo
>
query
().
lambda
()
.
eq
(
TEmployeeInfo:
:
getEmpIdcard
,
excel
.
getEmpIdcard
())
.
eq
(
TEmployeeInfo:
:
getDeleteFlag
,
CommonConstants
.
ZERO_STRING
)
.
last
(
CommonConstants
.
LAST_ONE_SQL
));
checkRes
(
list
,
emp
,
errorMsg
,
excel
);
errorMsg
=
checkRes
(
list
,
emp
,
excel
);
if
(
Common
.
isNotNull
(
errorMsg
)){
errorMessageList
.
add
(
errorMsg
);
continue
;
}
exist
=
baseMapper
.
selectOne
(
Wrappers
.<
TEmpProfessionalQualification
>
query
().
lambda
()
.
eq
(
TEmpProfessionalQualification:
:
getQualificationLevel
,
excel
.
getQualificationLevel
())
.
eq
(
TEmpProfessionalQualification:
:
getQualificationType
,
excel
.
getQualificationType
())
.
eq
(
TEmpProfessionalQualification:
:
getDeleteFlag
,
CommonConstants
.
ZERO_STRING
)
.
last
(
CommonConstants
.
LAST_ONE_SQL
));
if
(
Common
.
isNotNull
(
exist
)){
errorMsg
.
add
(
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_CERTIFICATE_NAME_EXISTING
,
excel
.
getEmpName
()));
}
// 数据合法情况
if
(
CollUtil
.
isEmpty
(
errorMsg
))
{
insertExcelPost
(
excel
,
emp
);
errorMsg
.
add
(
CommonConstants
.
SAVE_SUCCESS
);
temp
.
add
(
new
ErrorMessage
((
long
)
(
i
+
2
),
errorMsg
));
}
else
{
// 数据不合法
temp
.
add
(
new
ErrorMessage
((
long
)
(
i
+
2
),
errorMsg
));
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_CERTIFICATE_NAME_EXISTING
)));
continue
;
}
insertExcel
(
excel
,
emp
);
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
CommonConstants
.
SAVE_SUCCESS
));
}
temp
.
addAll
(
errorMsgMap
.
values
());
return
R
.
ok
(
temp
);
}
/**
* 插入excel
*/
private
void
insertExcel
Post
(
EmpCertificateExcelVO
excel
,
TEmployeeInfo
emp
)
{
private
void
insertExcel
(
EmpCertificateExcelVO
excel
,
TEmployeeInfo
emp
)
{
TEmpProfessionalQualification
insert
=
new
TEmpProfessionalQualification
();
BeanUtil
.
copyProperties
(
excel
,
insert
);
insert
.
setDeleteFlag
(
CommonConstants
.
ZERO_STRING
);
...
...
@@ -132,14 +110,12 @@ public class TEmpProfessionalQualificationServiceImpl extends ServiceImpl<TEmpPr
insert
.
setEmpId
(
emp
.
getId
());
this
.
save
(
insert
);
}
private
void
checkRes
(
List
<
TEmpProfessionalQualification
>
list
,
TEmployeeInfo
emp
,
Set
<
String
>
errorMsg
,
EmpCertificateExcelVO
excel
)
{
private
ErrorMessage
checkRes
(
List
<
TEmpProfessionalQualification
>
list
,
TEmployeeInfo
emp
,
EmpCertificateExcelVO
excel
)
{
if
(
Common
.
isEmpty
(
emp
)){
errorMsg
.
add
(
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_NOT_EXIST
,
excel
.
getEmpIdcard
()));
return
;
return
new
ErrorMessage
(
excel
.
getRowIndex
(),
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_NOT_EXIST
));
}
if
(
CommonConstants
.
ONE_STRING
.
equals
(
emp
.
getFileStatus
())){
errorMsg
.
add
(
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_REDUCED
,
excel
.
getEmpIdcard
()));
return
;
return
new
ErrorMessage
(
excel
.
getRowIndex
(),
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_REDUCED
));
}
// 检查添加是否已经存在
boolean
match
=
list
.
stream
().
anyMatch
(
info
->
excel
.
getQualificationLevel
()
...
...
@@ -148,9 +124,9 @@ public class TEmpProfessionalQualificationServiceImpl extends ServiceImpl<TEmpPr
&&
excel
.
getQualificationType
().
equals
(
info
.
getQualificationType
()));
if
(
match
)
{
errorMsg
.
add
(
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_CERTIFICATE_NAME_EXISTING
,
excel
.
getEmpName
()));
return
;
return
new
ErrorMessage
(
excel
.
getRowIndex
(),
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_CERTIFICATE_NAME_EXISTING
));
}
return
null
;
}
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/impl/TEmpWorkRecordingServiceImpl.java
View file @
97242b45
...
...
@@ -22,7 +22,6 @@ import cn.hutool.core.util.StrUtil;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.pig4cloud.plugin.excel.vo.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpWorkRecording
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo
;
import
com.yifu.cloud.plus.v1.yifu.archives.mapper.TAttaInfoMapper
;
...
...
@@ -33,13 +32,13 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpWorkRecordExcelVO;
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
lombok.RequiredArgsConstructor
;
import
org.springframework.stereotype.Service
;
import
org.springframework.validation.BindingResult
;
import
java.util.
*
;
import
java.util.
List
;
/**
* 员工工作履历信息表
...
...
@@ -56,36 +55,25 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM
private
final
TAttaInfoMapper
attaInfoMapper
;
@Override
public
R
<
List
<
ErrorMessage
>>
importEmpWorkRecord
(
List
<
EmpWorkRecordExcelVO
>
excelVOList
,
BindingResult
bindingResult
)
{
// 通用校验获取失败的数据
List
<
ErrorMessage
>
errorMessageList
=
(
List
<
ErrorMessage
>)
bindingResult
.
getTarget
();
Map
<
Long
,
ErrorMessage
>
errorMsgMap
=
new
HashMap
<>();
if
(
Common
.
isNotNull
(
errorMessageList
)){
errorMessageList
.
stream
().
forEach
(
errorMessage
->
errorMsgMap
.
put
(
errorMessage
.
getLineNum
(),
errorMessage
));
}
public
void
importEmpWorkRecord
(
List
<
EmpWorkRecordExcelVO
>
excelVOList
,
List
<
ErrorMessage
>
errorMessageList
)
{
// 个性化校验逻辑
List
<
TEmpWorkRecording
>
list
=
this
.
list
();
TEmployeeInfo
emp
;
TEmpWorkRecording
exist
;
Set
<
String
>
errorMsg
;
ErrorMessage
errorMessage
;
List
<
ErrorMessage
>
temp
=
new
ArrayList
<>();
ErrorMessage
errorMsg
;
// 执行数据插入操作 组装
for
(
int
i
=
0
;
i
<
excelVOList
.
size
();
i
++)
{
errorMessage
=
errorMsgMap
.
get
(
i
+
2
);
// 已有验证报错直接下一个
if
(
Common
.
isNotNull
(
errorMsgMap
.
get
(
i
+
2
))){
temp
.
add
(
errorMessage
);
errorMsgMap
.
remove
(
i
+
2
);
continue
;
}
errorMsg
=
new
HashSet
<>();
EmpWorkRecordExcelVO
excel
=
excelVOList
.
get
(
i
);
emp
=
employeeInfoMapper
.
selectOne
(
Wrappers
.<
TEmployeeInfo
>
query
().
lambda
()
.
eq
(
TEmployeeInfo:
:
getEmpIdcard
,
excel
.
getEmpIdcard
())
.
eq
(
TEmployeeInfo:
:
getDeleteFlag
,
CommonConstants
.
ZERO_STRING
)
.
eq
(
TEmployeeInfo:
:
getDeleteFlag
,
CommonConstants
.
ZERO_STRING
)
.
last
(
CommonConstants
.
LAST_ONE_SQL
));
checkRes
(
list
,
emp
,
errorMsg
,
excel
);
errorMsg
=
checkRes
(
list
,
emp
,
excel
);
if
(
Common
.
isNotNull
(
errorMsg
)){
errorMessageList
.
add
(
errorMsg
);
continue
;
}
exist
=
baseMapper
.
selectOne
(
Wrappers
.<
TEmpWorkRecording
>
query
().
lambda
()
.
eq
(
TEmpWorkRecording:
:
getEmpIdcard
,
excel
.
getEmpIdcard
())
.
eq
(
TEmpWorkRecording:
:
getWorkUnit
,
excel
.
getWorkUnit
())
...
...
@@ -93,20 +81,13 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM
.
eq
(
TEmpWorkRecording:
:
getDeleteFlag
,
CommonConstants
.
ZERO_STRING
)
.
last
(
CommonConstants
.
LAST_ONE_SQL
));
if
(
Common
.
isNotNull
(
exist
)){
errorMsg
.
add
(
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_WORK_RECORD_EXISTING
,
excel
.
getEmpName
()));
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_WORK_RECORD_EXISTING
)));
continue
;
}
// 数据合法情况
if
(
CollUtil
.
isEmpty
(
errorMsg
))
{
insertExcelPost
(
excel
,
emp
);
errorMsg
.
add
(
CommonConstants
.
SAVE_SUCCESS
);
temp
.
add
(
new
ErrorMessage
((
long
)
(
i
+
2
),
errorMsg
));
}
else
{
// 数据不合法
temp
.
add
(
new
ErrorMessage
((
long
)
(
i
+
2
),
errorMsg
));
}
insertExcelPost
(
excel
,
emp
);
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
CommonConstants
.
SAVE_SUCCESS
));
}
temp
.
addAll
(
errorMsgMap
.
values
());
return
R
.
ok
(
temp
);
}
@Override
...
...
@@ -153,14 +134,12 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM
return
null
;
}
private
void
checkRes
(
List
<
TEmpWorkRecording
>
list
,
TEmployeeInfo
emp
,
Set
<
String
>
errorMsg
,
EmpWorkRecordExcelVO
excel
)
{
private
ErrorMessage
checkRes
(
List
<
TEmpWorkRecording
>
list
,
TEmployeeInfo
emp
,
EmpWorkRecordExcelVO
excel
)
{
if
(
Common
.
isEmpty
(
emp
)){
errorMsg
.
add
(
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_NOT_EXIST
,
excel
.
getEmpIdcard
()));
return
;
return
new
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
common
.
core
.
util
.
ErrorMessage
(
excel
.
getRowIndex
(),
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_NOT_EXIST
));
}
if
(
CommonConstants
.
ONE_STRING
.
equals
(
emp
.
getFileStatus
())){
errorMsg
.
add
(
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_REDUCED
,
excel
.
getEmpIdcard
()));
return
;
return
new
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
common
.
core
.
util
.
ErrorMessage
(
excel
.
getRowIndex
(),
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_REDUCED
));
}
// 检查添加是否已经存在
boolean
match
=
list
.
stream
().
anyMatch
(
info
->
excel
.
getWorkDepart
().
equals
(
info
.
getWorkDepart
())
...
...
@@ -168,9 +147,9 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM
&&
excel
.
getEmpIdcard
().
equals
(
info
.
getEmpIdcard
()));
if
(
match
)
{
errorMsg
.
add
(
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_WORK_RECORD_EXISTING
,
excel
.
getEmpName
()));
return
;
return
new
ErrorMessage
(
excel
.
getRowIndex
(),
MsgUtils
.
getMessage
(
ErrorCodes
.
ARCHIVES_EMP_WORK_RECORD_EXISTING
));
}
return
null
;
}
/**
...
...
yifu-common/yifu-common-core/src/main/java/com/yifu.cloud.plus.v1/yifu/common/core/constant/CommonConstants.java
View file @
97242b45
...
...
@@ -240,4 +240,6 @@ public interface CommonConstants {
String
IS_TRUE
=
"是"
;
int
SIX_INT
=
6
;
int
EIGHT_INT
=
8
;
int
BATCH_COUNT
=
100
;
String
IMPORT_DATA_ANALYSIS_ERROR
=
"数据导入解析异常,请检查表数据格式"
;
}
yifu-common/yifu-common-core/src/main/java/com/yifu.cloud.plus.v1/yifu/common/core/constant/ExcelAttribute.java
View file @
97242b45
...
...
@@ -11,6 +11,7 @@ import java.lang.annotation.Target;
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
({
java
.
lang
.
annotation
.
ElementType
.
FIELD
})
public
@interface
ExcelAttribute
{
/**
* Excel中的列名
*
...
...
yifu-common/yifu-common-core/src/main/java/com/yifu.cloud.plus.v1/yifu/common/core/util/ExcelUtil.java
View file @
97242b45
...
...
@@ -37,10 +37,14 @@ public class ExcelUtil <T> implements Serializable {
public
ExcelUtil
(
Class
<
T
>
clazz
)
{
this
.
clazz
=
clazz
;
this
.
fields
=
clazz
.
getDeclaredFields
();
}
private
Field
[]
fields
;
public
void
checkEntity
(
T
data
,
Integer
rowNum
)
{
public
ErrorMessage
checkEntity
(
T
data
,
Integer
rowNum
)
{
if
(!
Common
.
isNotNull
(
fields
)){
return
null
;
}
//存储错误数据
Class
<?>
fieldType
;
String
error
=
""
;
...
...
@@ -48,15 +52,23 @@ public class ExcelUtil <T> implements Serializable {
//临时存储单元格数据
String
tempStr
=
""
;
ErrorMessage
errorTemp
=
null
;
errorMessageHashMap
=
new
HashMap
<>();
// 参数校验
Field
[]
fields
=
data
.
getClass
().
getDeclaredFields
();
ExcelAttribute
attr
=
null
;
try
{
for
(
Field
field
:
fields
)
{
field
.
getAnnotation
(
ExcelAttribute
.
class
);
if
(
field
==
null
)
{
continue
;
}
// 设置实体类私有属性可访问
field
.
setAccessible
(
true
);
attr
=
field
.
getAnnotation
(
ExcelAttribute
.
class
);
if
(
Common
.
isEmpty
(
attr
)){
continue
;
}
// 单元格中的内容.
c
=
getStringValByObject
(
getFieldValueByName
(
attr
.
name
(),
data
,
DateUtil
.
ISO_EXPANDED_DATE_FORMAT
));
c
=
getStringValByObject
(
field
.
get
(
data
));
if
(
c
!=
null
)
{
c
=
c
.
trim
();
}
...
...
@@ -66,24 +78,18 @@ public class ExcelUtil <T> implements Serializable {
errorMessageHashMap
=
initErrorMessage
(
errorMessageHashMap
,
new
ErrorMessage
(
rowNum
,
error
),
errorTemp
);
continue
;
}
if
(
field
==
null
)
{
continue
;
}
//单元格数据为空不需要处理了
if
(!
StringUtils
.
isNotBlank
(
c
))
{
continue
;
}
//如果是需要从字典表取值数据的话在这里处理即可
if
(
attr
.
isDataId
())
{
if
(
Common
.
isNotNull
(
attr
.
readConverterExp
()))
{
tempStr
=
reverseByExp
(
c
,
attr
.
readConverterExp
());
}
else
if
(
attr
.
isDataId
())
{
if
(
Common
.
isNotNull
(
attr
.
dataType
()))
{
//非区域字段处理 TODO
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
())){
tempStr
=
entry
.
getKey
();
break
;
}
}
tempStr
=
getDicValue
(
c
,
tempStr
,
attr
,
rowNum
,
errorTemp
);
/*if (Common.isNotNull(attr.parentField())){
tempStr = dicMap.get(attr.dataType() + "_" + c.trim() + "_" + getFieldValueByName(attr.parentField(), entity, DateUtil.ISO_EXPANDED_DATE_FORMAT));
}else {
...
...
@@ -181,8 +187,65 @@ public class ExcelUtil <T> implements Serializable {
}
}
catch
(
Exception
e
){
errorMessageHashMap
=
initErrorMessage
(
errorMessageHashMap
,
new
ErrorMessage
(
rowNum
,
attr
.
name
()
+
":"
+
c
.
trim
()
+
"校验异常,请联系管理人员"
),
errorTemp
);
}
finally
{
}
return
errorMessageHashMap
.
get
(
rowNum
);
}
/**
* 例如:解析值 0=男,1=女,2=未知
*
* @param propertyValue 参数值
* @param converterExp 翻译注解
* @return 解析后值
* @throws Exception
*/
public
static
String
reverseByExp
(
String
propertyValue
,
String
converterExp
)
throws
Exception
{
try
{
String
[]
convertSource
=
converterExp
.
split
(
","
);
if
(
propertyValue
.
contains
(
","
)){
String
[]
valueSource
=
propertyValue
.
split
(
","
);
propertyValue
=
""
;
for
(
String
value:
valueSource
){
for
(
String
item
:
convertSource
)
{
String
[]
itemArray
=
item
.
split
(
"="
);
if
(
itemArray
[
0
].
equals
(
value
))
{
propertyValue
+=
itemArray
[
1
]
+
","
;
break
;
}
}
}
if
(
propertyValue
.
endsWith
(
","
)){
propertyValue
=
propertyValue
.
substring
(
CommonConstants
.
dingleDigitIntArray
[
0
],
propertyValue
.
length
()-
1
);
}
}
else
{
for
(
String
item
:
convertSource
)
{
String
[]
itemArray
=
item
.
split
(
"="
);
if
(
itemArray
[
0
].
equals
(
propertyValue
))
{
return
itemArray
[
1
];
}
}
}
}
catch
(
Exception
e
)
{
throw
e
;
}
return
propertyValue
;
}
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
;
for
(
Map
.
Entry
<
String
,
String
>
entry:
dicObj
.
entrySet
()){
if
(
Common
.
isNotNull
(
entry
.
getValue
())
&&
entry
.
getValue
().
equals
(
c
.
trim
())){
tempStr
=
entry
.
getKey
();
flag
=
false
;
break
;
}
}
if
(
flag
){
errorMessageHashMap
=
initErrorMessage
(
errorMessageHashMap
,
new
ErrorMessage
(
rowNum
,
attr
.
name
()
+
":"
+
c
.
trim
()
+
"校验异常,请联系管理人员"
),
errorTemp
);
return
CommonConstants
.
EMPTY_STRING
;
}
this
.
setErrorMessageHashMap
(
errorMessageHashMap
)
;
return
tempStr
;
}
/**
...
...
@@ -438,12 +501,12 @@ public class ExcelUtil <T> implements Serializable {
private
HashMap
<
Integer
,
ErrorMessage
>
initErrorMessage
(
HashMap
<
Integer
,
ErrorMessage
>
errorMessageHashMap
,
ErrorMessage
errorMessage
,
ErrorMessage
temp
)
{
if
(
null
!=
errorMessageHashMap
&&
null
!=
errorMessage
)
{
temp
=
errorMessageHashMap
.
get
(
errorMessage
.
getLine
());
temp
=
errorMessageHashMap
.
get
(
errorMessage
.
getLine
Num
());
if
(
null
!=
temp
)
{
temp
.
setMessage
(
temp
.
getMessage
()
+
CommonConstants
.
DOWN_LINE_STRING
+
errorMessage
.
getMessage
());
errorMessageHashMap
.
put
(
temp
.
getLine
(),
temp
);
errorMessageHashMap
.
put
(
temp
.
getLine
Num
(),
temp
);
}
else
{
errorMessageHashMap
.
put
(
errorMessage
.
getLine
(),
errorMessage
);
errorMessageHashMap
.
put
(
errorMessage
.
getLine
Num
(),
errorMessage
);
}
}
return
errorMessageHashMap
;
...
...
yifu-common/yifu-common-core/src/main/java/com/yifu/cloud/plus/v1/yifu/common/core/util/ErrorMessage.java
View file @
97242b45
...
...
@@ -12,7 +12,7 @@ public class ErrorMessage implements Serializable {
/**
* 行数或INDEX
*/
private
Integer
line
;
private
Integer
line
Num
;
//默认红色 success green
private
String
color
=
"red"
;
...
...
@@ -26,18 +26,18 @@ public class ErrorMessage implements Serializable {
*/
private
String
message
;
public
ErrorMessage
(
Integer
line
,
String
message
)
{
this
.
line
=
line
;
public
ErrorMessage
(
Integer
line
Num
,
String
message
)
{
this
.
line
Num
=
lineNum
;
this
.
message
=
message
;
}
public
ErrorMessage
(
Integer
line
,
String
message
,
String
color
)
{
this
.
line
=
line
;
public
ErrorMessage
(
Integer
line
Num
,
String
message
,
String
color
)
{
this
.
line
Num
=
lineNum
;
this
.
color
=
color
;
this
.
message
=
message
;
}
public
ErrorMessage
(
Integer
line
,
String
message
,
String
color
,
String
name
)
{
this
.
line
=
line
;
public
ErrorMessage
(
Integer
line
Num
,
String
message
,
String
color
,
String
name
)
{
this
.
line
Num
=
lineNum
;
this
.
color
=
color
;
this
.
message
=
message
;
this
.
name
=
name
;
...
...
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