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
a1f6c0f0
Commit
a1f6c0f0
authored
Oct 10, 2022
by
hongguangwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
薪资批量更新
parent
9bd4aca7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
215 additions
and
2 deletions
+215
-2
TSalaryEmployeeVo.java
.../yifu/cloud/plus/v1/yifu/salary/vo/TSalaryEmployeeVo.java
+2
-2
TSalaryEmployeeController.java
.../v1/yifu/salary/controller/TSalaryEmployeeController.java
+20
-0
TSalaryEmployeeMapper.java
...oud/plus/v1/yifu/salary/mapper/TSalaryEmployeeMapper.java
+2
-0
TSalaryEmployeeService.java
...d/plus/v1/yifu/salary/service/TSalaryEmployeeService.java
+9
-0
TSalaryEmployeeServiceImpl.java
.../yifu/salary/service/impl/TSalaryEmployeeServiceImpl.java
+163
-0
SalaryConstants.java
.../yifu/cloud/plus/v1/yifu/salary/util/SalaryConstants.java
+5
-0
TSalaryEmployeeMapper.xml
...y-biz/src/main/resources/mapper/TSalaryEmployeeMapper.xml
+14
-0
No files found.
yifu-salary/yifu-salary-api/src/main/java/com/yifu/cloud/plus/v1/yifu/salary/vo/TSalaryEmployeeVo.java
View file @
a1f6c0f0
...
...
@@ -166,7 +166,7 @@ public class TSalaryEmployeeVo extends RowIndex implements Serializable {
@Schema
(
description
=
"开户行省"
)
@HeadFontStyle
(
fontHeightInPoints
=
11
)
@ExcelProperty
(
"开户行省"
)
private
Integer
bankProvince
;
private
String
bankProvince
;
/**
* 开户行市
*/
...
...
@@ -174,7 +174,7 @@ public class TSalaryEmployeeVo extends RowIndex implements Serializable {
@Schema
(
description
=
"开户行市"
)
@HeadFontStyle
(
fontHeightInPoints
=
11
)
@ExcelProperty
(
"开户行市"
)
private
Integer
bankCity
;
private
String
bankCity
;
/**
* 手机号码
*/
...
...
yifu-salary/yifu-salary-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/salary/controller/TSalaryEmployeeController.java
View file @
a1f6c0f0
...
...
@@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
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.R
;
import
com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser
;
import
com.yifu.cloud.plus.v1.yifu.common.dapr.util.MenuUtil
;
...
...
@@ -33,8 +34,10 @@ import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryEmployeeSearchVo;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.RequiredArgsConstructor
;
import
lombok.SneakyThrows
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
...
...
@@ -160,4 +163,21 @@ public class TSalaryEmployeeController {
}
tSalaryEmployeeService
.
listExport
(
response
,
searchVo
);
}
/**
* 批量更新-薪资人员信息
*
* @param file
* @return
* @Author hgw
* @Date 2022-10-10 17:17:11
**/
@SneakyThrows
@Operation
(
description
=
"批量更新-薪资人员信息 hasPermission('tsalaryemployee_batch_update')"
)
@SysLog
(
"批量更新-薪资人员信息"
)
@PostMapping
(
"/batchUpdateSalaryEmployee"
)
@PreAuthorize
(
"@pms.hasPermission('tsalaryemployee_batch_update')"
)
public
R
<
List
<
ErrorMessage
>>
batchUpdateSalaryEmployee
(
@RequestBody
MultipartFile
file
)
{
return
tSalaryEmployeeService
.
batchUpdateSalaryEmployee
(
file
.
getInputStream
());
}
}
yifu-salary/yifu-salary-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/salary/mapper/TSalaryEmployeeMapper.java
View file @
a1f6c0f0
...
...
@@ -44,4 +44,6 @@ public interface TSalaryEmployeeMapper extends BaseMapper<TSalaryEmployee> {
IPage
<
TSalaryEmployee
>
getTSalaryEmployeePage
(
Page
<
TSalaryEmployee
>
page
,
@Param
(
"tSalaryEmployee"
)
TSalaryEmployee
tSalaryEmployee
);
List
<
TSalaryEmployeeExportVo
>
noPageDiy
(
@Param
(
"tSalaryEmployee"
)
TSalaryEmployeeSearchVo
searchVo
,
@Param
(
"idList"
)
List
<
String
>
idList
);
List
<
TSalaryEmployee
>
getListByIdCard
(
@Param
(
"idCardList"
)
List
<
String
>
idCardList
);
}
yifu-salary/yifu-salary-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/salary/service/TSalaryEmployeeService.java
View file @
a1f6c0f0
...
...
@@ -59,4 +59,13 @@ public interface TSalaryEmployeeService extends IService<TSalaryEmployee> {
**/
String
saveNewSalaryEmployee
(
TSalaryEmployee
employee
);
/**
* @param inputStream
* @Description: 批量更新-薪资人员信息
* @Author: hgw
* @Date: 2022/10/10 17:17
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage>>
**/
R
<
List
<
ErrorMessage
>>
batchUpdateSalaryEmployee
(
InputStream
inputStream
);
}
yifu-salary/yifu-salary-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/salary/service/impl/TSalaryEmployeeServiceImpl.java
View file @
a1f6c0f0
...
...
@@ -19,6 +19,7 @@ package com.yifu.cloud.plus.v1.yifu.salary.service.impl;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.util.ArrayUtil
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.EasyExcelFactory
;
import
com.alibaba.excel.ExcelWriter
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.read.listener.ReadListener
;
...
...
@@ -33,6 +34,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import
com.yifu.cloud.plus.v1.check.entity.TCheckBankNo
;
import
com.yifu.cloud.plus.v1.check.entity.TCheckMobile
;
import
com.yifu.cloud.plus.v1.check.vo.CheckBankNoVo
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.*
;
...
...
@@ -56,7 +58,9 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.net.URLEncoder
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* 薪酬人员表
...
...
@@ -333,4 +337,163 @@ public class TSalaryEmployeeServiceImpl extends ServiceImpl<TSalaryEmployeeMappe
this
.
save
(
employee
);
return
null
;
}
/**
* @param inputStream
* @Description: 批量更新-薪资人员信息
* @Author: hgw
* @Date: 2022/10/10 17:17
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage>>
**/
@Override
public
R
<
List
<
ErrorMessage
>>
batchUpdateSalaryEmployee
(
InputStream
inputStream
)
{
List
<
ErrorMessage
>
errorMessageList
=
new
ArrayList
<>();
ExcelUtil
<
TSalaryEmployeeVo
>
util1
=
new
ExcelUtil
<>(
TSalaryEmployeeVo
.
class
);
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try
{
EasyExcelFactory
.
read
(
inputStream
,
TSalaryEmployeeVo
.
class
,
new
ReadListener
<
TSalaryEmployeeVo
>()
{
/**
* 单次缓存的数据量
*/
public
static
final
int
BATCH_COUNT
=
CommonConstants
.
BATCH_COUNT
;
/**
*临时存储
*/
private
List
<
TSalaryEmployeeVo
>
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
@Override
public
void
invoke
(
TSalaryEmployeeVo
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
());
if
(!
cachedDataList
.
isEmpty
())
{
updateTSalaryEmployee
(
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
);
}
boolean
isTrue
=
true
;
for
(
ErrorMessage
message
:
errorMessageList
)
{
if
(!
CommonConstants
.
SAVE_SUCCESS
.
equals
(
message
.
getMessage
()))
{
isTrue
=
false
;
break
;
}
}
if
(
isTrue
)
{
return
R
.
ok
();
}
else
{
return
R
.
ok
(
errorMessageList
);
}
}
/**
* @Description: 批量更新
* @Author: hgw
* @Date: 2022/10/10 17:56
* @return: void
**/
public
void
updateTSalaryEmployee
(
List
<
TSalaryEmployeeVo
>
excelVOList
,
List
<
ErrorMessage
>
errorMessageList
)
{
/// 个性化校验逻辑
TSalaryEmployeeVo
excel
;
List
<
String
>
idCardList
=
new
ArrayList
<>();
// 执行数据插入操作 组装
for
(
TSalaryEmployeeVo
vo
:
excelVOList
)
{
idCardList
.
add
(
vo
.
getEmpIdcard
());
}
List
<
TSalaryEmployee
>
empList
=
baseMapper
.
getListByIdCard
(
idCardList
);
// 人员Map
Map
<
String
,
TSalaryEmployee
>
empMap
=
new
HashMap
<>();
for
(
TSalaryEmployee
e
:
empList
)
{
empMap
.
put
(
e
.
getEmpIdcard
()
+
CommonConstants
.
DOWN_LINE_STRING
+
e
.
getDeptNo
(),
e
);
}
TSalaryEmployee
emp
;
// 开户行省市的区域暂存
String
areaStr
;
for
(
int
i
=
0
;
i
<
excelVOList
.
size
();
i
++)
{
excel
=
excelVOList
.
get
(
i
);
if
(
excel
!=
null
)
{
if
(
Common
.
isNotNull
(
excel
.
getEmpIdcard
())
&&
Common
.
isNotNull
(
excel
.
getDeptNo
()))
{
emp
=
empMap
.
get
(
excel
.
getEmpIdcard
()
+
CommonConstants
.
DOWN_LINE_STRING
+
excel
.
getDeptNo
());
if
(
Common
.
isNotNull
(
emp
))
{
if
(
Common
.
isNotNull
(
emp
.
getTaxMonth
())
&&
Common
.
isNotNull
(
excel
.
getTaxMonth
())
&&
emp
.
getTaxMonth
().
length
()==
6
)
{
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
SalaryConstants
.
TAX_MONTH_CUR
));
}
else
{
if
(
Common
.
isNotNull
(
excel
.
getBankName
()))
{
emp
.
setBankName
(
excel
.
getBankName
());
}
if
(
Common
.
isNotNull
(
excel
.
getBankSubName
()))
{
emp
.
setBankSubName
(
excel
.
getBankSubName
());
}
if
(
Common
.
isNotNull
(
excel
.
getBankProvince
()))
{
areaStr
=
ExcelUtil
.
getRedisAreaValue
(
CacheConstants
.
AREA_VALUE
+
excel
.
getBankProvince
().
trim
());
if
(
Common
.
isNotNull
(
areaStr
))
{
emp
.
setBankProvince
(
areaStr
);
if
(
Common
.
isNotNull
(
excel
.
getBankName
()))
{
areaStr
=
ExcelUtil
.
getRedisAreaValue
(
CacheConstants
.
AREA_VALUE
+
excel
.
getBankCity
().
trim
()
+
CommonConstants
.
DOWN_LINE_STRING
+
excel
.
getBankProvince
().
trim
());
if
(
Common
.
isNotNull
(
areaStr
))
{
emp
.
setBankCity
(
areaStr
);
}
else
{
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
SalaryConstants
.
CITY_ERROR
));
continue
;
}
}
}
else
{
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
SalaryConstants
.
PROVINCE_ERROR
));
continue
;
}
}
if
(
Common
.
isNotNull
(
excel
.
getBankNo
()))
{
emp
.
setBankNo
(
excel
.
getBankNo
());
}
if
(
Common
.
isNotNull
(
excel
.
getEmpPhone
()))
{
emp
.
setEmpPhone
(
excel
.
getEmpPhone
());
}
if
(
Common
.
isNotNull
(
excel
.
getTaxMonth
()))
{
emp
.
setTaxMonth
(
excel
.
getTaxMonth
());
}
baseMapper
.
updateById
(
emp
);
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
CommonConstants
.
SAVE_SUCCESS
));
}
}
else
{
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
SalaryConstants
.
NOT_HAVE_EMP
));
}
}
else
{
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
SalaryConstants
.
IDCARD_DEPT_NO_MUST
));
}
}
else
{
errorMessageList
.
add
(
new
ErrorMessage
(
CommonConstants
.
ZERO_INT
,
SalaryConstants
.
IDCARD_DEPT_NO_MUST
));
}
}
}
}
yifu-salary/yifu-salary-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/salary/util/SalaryConstants.java
View file @
a1f6c0f0
...
...
@@ -168,4 +168,9 @@ public class SalaryConstants {
public
static
final
String
CHECK_NO_RESPONSE
=
"校验服务器未返回,请联系管理员!"
;
public
static
final
String
LINE_EMP
=
"行:员工:"
;
public
static
final
String
IDCARD_DEPT_NO_MUST
=
"身份证、项目编码不可为空!"
;
public
static
final
String
NOT_HAVE_EMP
=
"根据身份证、项目编码未找到人员!"
;
public
static
final
String
TAX_MONTH_CUR
=
"计税月份已存在,不可更新,请清空计税月份单元格内容!"
;
public
static
final
String
PROVINCE_ERROR
=
"开户行省错误!"
;
public
static
final
String
CITY_ERROR
=
"开户行市错误!"
;
}
yifu-salary/yifu-salary-biz/src/main/resources/mapper/TSalaryEmployeeMapper.xml
View file @
a1f6c0f0
...
...
@@ -198,6 +198,7 @@
</if>
</if>
</select>
<sql
id=
"where_export"
>
<include
refid=
"tSalaryEmployee_where"
/>
<if
test=
"idList != null and idList.size>0"
>
...
...
@@ -207,4 +208,17 @@
</foreach>
</if>
</sql>
<!-- 按身份证查询全部人员 -->
<select
id=
"getListByIdCard"
resultMap=
"tSalaryEmployeeMap"
>
<if
test=
"idCardList != null and idCardList.size>0"
>
SELECT
<include
refid=
"Base_Column_List"
/>
FROM t_salary_employee a
where a.EMP_IDCARD in
<foreach
item=
"idStr"
index=
"index"
collection=
"idCardList"
open=
"("
separator=
","
close=
")"
>
#{idCardList}
</foreach>
</if>
</select>
</mapper>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment