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
213f97a6
Commit
213f97a6
authored
Oct 19, 2023
by
fangxinjiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
权限批量导入
parent
7f973498
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
457 additions
and
0 deletions
+457
-0
CommonConstants.java
...ud/plus/v1/yifu/common/core/constant/CommonConstants.java
+2
-0
UpmsDaprUtils.java
...fu/cloud/plus/v1/yifu/common/dapr/util/UpmsDaprUtils.java
+8
-0
TSocialfundHouseResController.java
...yifu/social/controller/TSocialfundHouseResController.java
+37
-0
TSocialfundHouseResService.java
...us/v1/yifu/social/service/TSocialfundHouseResService.java
+3
-0
TSocialfundHouseResServiceImpl.java
...u/social/service/impl/TSocialfundHouseResServiceImpl.java
+401
-0
UserController.java
...u/cloud/plus/v1/yifu/admin/controller/UserController.java
+6
-0
No files found.
yifu-common/yifu-common-core/src/main/java/com/yifu/cloud/plus/v1/yifu/common/core/constant/CommonConstants.java
View file @
213f97a6
...
...
@@ -532,6 +532,8 @@ public interface CommonConstants {
String
SETTLE_DOMAIN_GET_ERROR
=
"获取结算主体信息失败!"
;
String
SETTLE_DOMAIN_NOT_EXIST
=
"无对应项目信息"
;
/**
* c端机构节点 code
* @Author hgw
...
...
yifu-common/yifu-common-dapr/src/main/java/com/yifu/cloud/plus/v1/yifu/common/dapr/util/UpmsDaprUtils.java
View file @
213f97a6
...
...
@@ -90,4 +90,12 @@ public class UpmsDaprUtils {
}
return
userR
;
}
public
R
<
SysUser
>
getSimpleUserByLoginName
(
String
loginName
)
{
R
<
SysUser
>
userR
=
HttpDaprUtil
.
invokeMethodPost
(
daprUpmsProperties
.
getAppUrl
(),
daprUpmsProperties
.
getAppId
(),
"/user/inner/getSimpleUserByLoginName"
,
loginName
,
SysUser
.
class
,
SecurityConstants
.
FROM_IN
);
if
(
Common
.
isEmpty
(
userR
)){
return
R
.
failed
(
"获取所有用户数据失败!"
);
}
return
userR
;
}
}
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/controller/TSocialfundHouseResController.java
View file @
213f97a6
...
...
@@ -19,15 +19,19 @@ package com.yifu.cloud.plus.v1.yifu.social.controller;
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.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog
;
import
com.yifu.cloud.plus.v1.yifu.social.entity.TSocialfundHouseRes
;
import
com.yifu.cloud.plus.v1.yifu.social.service.TSocialfundHouseResService
;
import
lombok.SneakyThrows
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.List
;
...
...
@@ -119,4 +123,37 @@ public class TSocialfundHouseResController {
public
R
<
Boolean
>
removeById
(
@PathVariable
String
id
)
{
return
R
.
ok
(
tSocialfundHouseResService
.
removeById
(
id
));
}
/**
* @Author fxj
* @Description 批量导入社保公积金审核权限
* @Date 16:59 2023/10/17
* @Param
* @return
**/
@SneakyThrows
@Operation
(
description
=
"批量新增社保公积金审核权限"
)
@SysLog
(
"批量新增社保公积金审核权限"
)
@PostMapping
(
"/importListAdd"
)
public
R
<
List
<
ErrorMessage
>>
importListAdd
(
@RequestBody
MultipartFile
file
)
{
return
tSocialfundHouseResService
.
importDiy
(
file
.
getInputStream
());
}
/**
* @Author fxj
* @Description 批量新增社保|公积金办理权限
* @Date 16:59 2023/10/17
* @Param
* @return
**/
@SneakyThrows
@Operation
(
description
=
"批量新增社保|公积金办理权限"
)
@SysLog
(
"批量新增社保|公积金办理权限"
)
@PostMapping
(
"/importListAddAll"
)
public
R
<
List
<
ErrorMessage
>>
importListAddAll
(
@RequestBody
MultipartFile
file
,
String
type
)
{
if
(
CommonConstants
.
ZERO_STRING
.
equals
(
type
)
&&
CommonConstants
.
ONE_STRING
.
equals
(
type
)){
return
R
.
failed
(
CommonConstants
.
PARAM_INFO_ERROR
);
}
return
tSocialfundHouseResService
.
importDiyAll
(
file
.
getInputStream
(),
type
);
}
}
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/service/TSocialfundHouseResService.java
View file @
213f97a6
...
...
@@ -63,4 +63,7 @@ public interface TSocialfundHouseResService extends IService<TSocialfundHouseRes
**/
void
deleteHandleUser
(
SysHouseHoldInfo
holdInfo
);
R
<
List
<
ErrorMessage
>>
importDiy
(
InputStream
inputStream
);
R
<
List
<
ErrorMessage
>>
importDiyAll
(
InputStream
inputStream
,
String
type
);
}
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/service/impl/TSocialfundHouseResServiceImpl.java
View file @
213f97a6
...
...
@@ -16,21 +16,46 @@
*/
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
social
.
service
.
impl
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.read.listener.ReadListener
;
import
com.alibaba.excel.read.metadata.holder.ReadRowHolder
;
import
com.alibaba.excel.util.ListUtils
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser
;
import
com.yifu.cloud.plus.v1.yifu.archives.vo.SocialAuthHandleImportVo
;
import
com.yifu.cloud.plus.v1.yifu.archives.vo.SocialAuthImportVo
;
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.dapr.util.UpmsDaprUtils
;
import
com.yifu.cloud.plus.v1.yifu.social.entity.SysBaseSetInfo
;
import
com.yifu.cloud.plus.v1.yifu.social.entity.SysHouseHoldInfo
;
import
com.yifu.cloud.plus.v1.yifu.social.entity.TSocialfundHouseRes
;
import
com.yifu.cloud.plus.v1.yifu.social.mapper.TSocialfundHouseResMapper
;
import
com.yifu.cloud.plus.v1.yifu.social.service.SysBaseSetInfoService
;
import
com.yifu.cloud.plus.v1.yifu.social.service.TSocialfundHouseResService
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.log4j.Log4j2
;
import
org.apache.shardingsphere.transaction.annotation.ShardingTransactionType
;
import
org.apache.shardingsphere.transaction.core.TransactionType
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.io.InputStream
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* 社保公积金户权限配置表
...
...
@@ -39,8 +64,12 @@ import java.util.List;
* @date 2022-11-02 09:13:07
*/
@Log4j2
@AllArgsConstructor
@Service
public
class
TSocialfundHouseResServiceImpl
extends
ServiceImpl
<
TSocialfundHouseResMapper
,
TSocialfundHouseRes
>
implements
TSocialfundHouseResService
{
@Autowired
private
UpmsDaprUtils
upmsDaprUtils
;
private
SysBaseSetInfoService
baseSetInfoService
;
/**
* 社保公积金户权限配置表简单分页查询
* @param tSocialfundHouseRes 社保公积金户权限配置表
...
...
@@ -129,4 +158,376 @@ public class TSocialfundHouseResServiceImpl extends ServiceImpl<TSocialfundHouse
}
}
/**
* @Author fxj
* @Description 批量新增社保公积金审核权限
* @Date 16:59 2023/10/17
* @Param
* @return
**/
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ShardingTransactionType
(
TransactionType
.
BASE
)
@Override
public
R
<
List
<
ErrorMessage
>>
importDiy
(
InputStream
inputStream
)
{
List
<
ErrorMessage
>
errorMessageList
=
new
ArrayList
<>();
ExcelUtil
<
SocialAuthImportVo
>
util1
=
new
ExcelUtil
<>(
SocialAuthImportVo
.
class
);
Map
<
String
,
SysBaseSetInfo
>
fundBaseSetMap
=
null
;
Map
<
String
,
SysBaseSetInfo
>
socialBaseSetMap
=
null
;
// 获取社保公积金配置
List
<
SysBaseSetInfo
>
socialSet
=
baseSetInfoService
.
list
(
Wrappers
.<
SysBaseSetInfo
>
query
().
lambda
()
.
eq
(
SysBaseSetInfo:
:
getBaseType
,
CommonConstants
.
ZERO_STRING
)
.
eq
(
SysBaseSetInfo:
:
getDeleteFlag
,
CommonConstants
.
ZERO_STRING
)
.
groupBy
(
SysBaseSetInfo:
:
getDepartName
,
SysBaseSetInfo:
:
getProvince
,
SysBaseSetInfo:
:
getCity
,
SysBaseSetInfo:
:
getTown
));
if
(
Common
.
isNotNull
(
socialSet
)){
socialBaseSetMap
=
socialSet
.
stream
().
collect
(
Collectors
.
toMap
(
k
->
k
.
getDepartName
(),
k
->
k
));
}
List
<
SysBaseSetInfo
>
fundSet
=
baseSetInfoService
.
list
(
Wrappers
.<
SysBaseSetInfo
>
query
().
lambda
()
.
eq
(
SysBaseSetInfo:
:
getBaseType
,
CommonConstants
.
ONE_STRING
)
.
eq
(
SysBaseSetInfo:
:
getDeleteFlag
,
CommonConstants
.
ZERO_STRING
)
.
groupBy
(
SysBaseSetInfo:
:
getDepartName
,
SysBaseSetInfo:
:
getProvince
,
SysBaseSetInfo:
:
getCity
,
SysBaseSetInfo:
:
getTown
));
if
(
Common
.
isNotNull
(
fundSet
)){
fundBaseSetMap
=
fundSet
.
stream
().
collect
(
Collectors
.
toMap
(
k
->
k
.
getDepartName
(),
k
->
k
));
}
if
(
Common
.
isEmpty
(
socialBaseSetMap
)
||
Common
.
isEmpty
(
fundBaseSetMap
)){
return
R
.
failed
(
"获取社保及公积金户配置信息失败!"
);
}
Map
<
String
,
SysUser
>
userMap
=
new
HashMap
<>();
Map
<
String
,
String
>
existMap
=
new
HashMap
<>();
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try
{
Map
<
String
,
SysBaseSetInfo
>
finalSocialBaseSetMap
=
socialBaseSetMap
;
Map
<
String
,
SysBaseSetInfo
>
finalFundBaseSetMap
=
fundBaseSetMap
;
EasyExcel
.
read
(
inputStream
,
SocialAuthImportVo
.
class
,
new
ReadListener
<
SocialAuthImportVo
>()
{
/**
* 单次缓存的数据量
*/
public
static
final
int
BATCH_COUNT
=
CommonConstants
.
BATCH_COUNT
;
/**
*临时存储
*/
private
List
<
SocialAuthImportVo
>
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
@Override
public
void
invoke
(
SocialAuthImportVo
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
());
importEntity
(
cachedDataList
,
errorMessageList
,
finalSocialBaseSetMap
,
finalFundBaseSetMap
,
userMap
,
existMap
);
log
.
info
(
"存储数据库成功!"
);
}
}).
sheet
().
doRead
();
}
catch
(
Exception
e
){
log
.
error
(
CommonConstants
.
IMPORT_DATA_ANALYSIS_ERROR
,
e
);
return
R
.
failed
(
CommonConstants
.
IMPORT_DATA_ANALYSIS_ERROR
);
}
finally
{
// 清理
socialBaseSetMap
.
clear
();
fundBaseSetMap
.
clear
();
}
return
judgeAllMessage
(
errorMessageList
);
}
private
void
importEntity
(
List
<
SocialAuthImportVo
>
excelVOList
,
List
<
ErrorMessage
>
errorMessageList
,
Map
<
String
,
SysBaseSetInfo
>
socialBaseSetMap
,
Map
<
String
,
SysBaseSetInfo
>
fundBaseSetMap
,
Map
<
String
,
SysUser
>
userMap
,
Map
<
String
,
String
>
existMap
)
{
// 执行数据插入操作 组装
TSocialfundHouseRes
save
;
SysUser
user
;
R
<
SysUser
>
res
;
TSocialfundHouseRes
exist
;
String
temp
;
SysBaseSetInfo
baseSet
=
null
;
for
(
int
i
=
0
;
i
<
excelVOList
.
size
();
i
++)
{
SocialAuthImportVo
excel
=
excelVOList
.
get
(
i
);
// 数据合法情况
user
=
userMap
.
get
(
excel
.
getUserLoginName
());
// 用户信息验证
if
(
Common
.
isEmpty
(
user
)){
res
=
upmsDaprUtils
.
getSimpleUserByLoginName
(
excel
.
getUserLoginName
());
if
(
Common
.
isNotNull
(
res
)
&&
Common
.
isNotNull
(
res
.
getData
())){
user
=
res
.
getData
();
userMap
.
put
(
user
.
getUsername
(),
user
);
}
else
{
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
"无有效状态的用户信息!"
));
continue
;
}
}
if
(
Common
.
isEmpty
(
user
.
getDeptName
())){
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
"对应登录账号无部门信息,请完善后导入"
));
continue
;
}
// 户验证
if
(
CommonConstants
.
ZERO_STRING
.
equals
(
excel
.
getType
())){
baseSet
=
socialBaseSetMap
.
get
(
excel
.
getHouseHold
());
if
(
Common
.
isEmpty
(
baseSet
)){
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
"未找到对应社保户数据!"
));
continue
;
}
}
if
(
CommonConstants
.
ONE_STRING
.
equals
(
excel
.
getType
())){
baseSet
=
fundBaseSetMap
.
get
(
excel
.
getHouseHold
());
if
(
Common
.
isEmpty
(
baseSet
)){
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
"未找到对应公积金户数据!"
));
continue
;
}
}
// 重复校验
temp
=
existMap
.
get
(
excel
.
getUserLoginName
()
+
CommonConstants
.
DOWN_LINE_STRING
+
excel
.
getHouseHold
());
if
(
Common
.
isNotNull
(
temp
)){
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
"对应账号的权限已存在,请勿重复导入"
));
continue
;
}
else
{
exist
=
baseMapper
.
selectOne
(
Wrappers
.<
TSocialfundHouseRes
>
query
().
lambda
()
.
eq
(
TSocialfundHouseRes:
:
getFundHousehold
,
excel
.
getHouseHold
())
.
eq
(
TSocialfundHouseRes:
:
getHouseNameType
,
excel
.
getType
())
.
eq
(
TSocialfundHouseRes:
:
getUserId
,
user
.
getUserId
())
.
last
(
CommonConstants
.
LAST_ONE_SQL
));
if
(
Common
.
isNotNull
(
exist
)){
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
"对应账号的权限已存在,请勿重复导入"
));
continue
;
}
}
// 初始化及新增数据
save
=
new
TSocialfundHouseRes
();
save
.
setAuthType
(
CommonConstants
.
ZERO_STRING
);
save
.
setFundHousehold
(
CommonConstants
.
ZERO_STRING
.
equals
(
baseSet
.
getBaseType
())?
null
:
baseSet
.
getDepartName
());
save
.
setSocialHousehold
(
CommonConstants
.
ZERO_STRING
.
equals
(
baseSet
.
getBaseType
())?
baseSet
.
getDepartName
():
null
);
save
.
setStatus
(
CommonConstants
.
ZERO_STRING
);
save
.
setUserId
(
user
.
getUserId
());
save
.
setHouseNameType
(
baseSet
.
getBaseType
());
save
.
setCreateTime
(
LocalDateTime
.
now
());
save
.
setUserName
(
user
.
getUsername
());
save
.
setUserDeptName
(
user
.
getDeptName
());
insertExcel
(
save
);
// 加入map 验证当前表单数据是否重复
existMap
.
put
(
excel
.
getUserLoginName
()
+
CommonConstants
.
DOWN_LINE_STRING
+
excel
.
getHouseHold
(),
excel
.
getHouseHold
());
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
CommonConstants
.
SAVE_SUCCESS
,
CommonConstants
.
GREEN
));
}
}
/**
* 插入excel bad record
*/
private
void
insertExcel
(
TSocialfundHouseRes
entity
)
{
this
.
save
(
entity
);
}
/**
* @Author fxj
* @Description 判断所有返回数据,是否全部为正确的
* @Date 18:01 2023/10/18
* @Param
* @return
**/
private
R
<
List
<
ErrorMessage
>>
judgeAllMessage
(
List
<
ErrorMessage
>
errorMessageList
)
{
if
(!
errorMessageList
.
isEmpty
()
&&
errorMessageList
.
stream
().
noneMatch
(
e
->
e
.
getColor
().
equals
(
CommonConstants
.
RED
)))
{
return
R
.
ok
();
}
return
R
.
ok
(
errorMessageList
);
}
/**
* @Author fxj
* @Description 批量新增社保公积金审核权限
* @Date 16:59 2023/10/17
* @Param
* @return
**/
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ShardingTransactionType
(
TransactionType
.
BASE
)
@Override
public
R
<
List
<
ErrorMessage
>>
importDiyAll
(
InputStream
inputStream
,
String
type
)
{
List
<
ErrorMessage
>
errorMessageList
=
new
ArrayList
<>();
ExcelUtil
<
SocialAuthHandleImportVo
>
util1
=
new
ExcelUtil
<>(
SocialAuthHandleImportVo
.
class
);
Map
<
String
,
SysBaseSetInfo
>
baseSetInfoMap
=
new
HashMap
<>();
List
<
SysBaseSetInfo
>
setInfos
=
baseSetInfoService
.
list
(
Wrappers
.<
SysBaseSetInfo
>
query
().
lambda
()
.
eq
(
SysBaseSetInfo:
:
getBaseType
,
CommonConstants
.
ZERO_STRING
)
.
eq
(
SysBaseSetInfo:
:
getDeleteFlag
,
CommonConstants
.
ZERO_STRING
)
.
groupBy
(
SysBaseSetInfo:
:
getDepartName
,
SysBaseSetInfo:
:
getProvince
,
SysBaseSetInfo:
:
getCity
,
SysBaseSetInfo:
:
getTown
));
if
(
Common
.
isNotNull
(
setInfos
)){
baseSetInfoMap
=
setInfos
.
stream
().
collect
(
Collectors
.
toMap
(
k
->
k
.
getDepartName
(),
k
->
k
));
}
if
(
Common
.
isEmpty
(
baseSetInfoMap
)){
return
R
.
failed
(
"获取户配置信息失败!"
);
}
Map
<
String
,
SysUser
>
userMap
=
new
HashMap
<>();
Map
<
String
,
String
>
existMap
=
new
HashMap
<>();
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try
{
Map
<
String
,
SysBaseSetInfo
>
finalBaseSetInfoMap
=
baseSetInfoMap
;
EasyExcel
.
read
(
inputStream
,
SocialAuthHandleImportVo
.
class
,
new
ReadListener
<
SocialAuthHandleImportVo
>()
{
/**
* 单次缓存的数据量
*/
public
static
final
int
BATCH_COUNT
=
CommonConstants
.
BATCH_COUNT
;
/**
*临时存储
*/
private
List
<
SocialAuthHandleImportVo
>
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
@Override
public
void
invoke
(
SocialAuthHandleImportVo
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
());
importEntity
(
cachedDataList
,
errorMessageList
,
finalBaseSetInfoMap
,
userMap
,
existMap
,
type
);
log
.
info
(
"存储数据库成功!"
);
}
}).
sheet
().
doRead
();
}
catch
(
Exception
e
){
log
.
error
(
CommonConstants
.
IMPORT_DATA_ANALYSIS_ERROR
,
e
);
return
R
.
failed
(
CommonConstants
.
IMPORT_DATA_ANALYSIS_ERROR
);
}
finally
{
// 清理
baseSetInfoMap
.
clear
();
}
return
judgeAllMessage
(
errorMessageList
);
}
private
void
importEntity
(
List
<
SocialAuthHandleImportVo
>
excelVOList
,
List
<
ErrorMessage
>
errorMessageList
,
Map
<
String
,
SysBaseSetInfo
>
baseSetInfoMap
,
Map
<
String
,
SysUser
>
userMap
,
Map
<
String
,
String
>
existMap
,
String
type
)
{
// 执行数据插入操作 组装
TSocialfundHouseRes
save
;
SysUser
user
;
R
<
SysUser
>
res
;
TSocialfundHouseRes
exist
;
String
temp
;
SysBaseSetInfo
baseSet
=
null
;
for
(
int
i
=
0
;
i
<
excelVOList
.
size
();
i
++)
{
SocialAuthHandleImportVo
excel
=
excelVOList
.
get
(
i
);
// 数据合法情况
user
=
userMap
.
get
(
excel
.
getUserLoginName
());
// 用户信息验证
if
(
Common
.
isEmpty
(
user
)){
res
=
upmsDaprUtils
.
getSimpleUserByLoginName
(
excel
.
getUserLoginName
());
if
(
Common
.
isNotNull
(
res
)
&&
Common
.
isNotNull
(
res
.
getData
())){
user
=
res
.
getData
();
userMap
.
put
(
user
.
getUsername
(),
user
);
}
else
{
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
"无有效状态的用户信息!"
));
continue
;
}
}
if
(
Common
.
isEmpty
(
user
.
getDeptName
())){
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
"对应登录账号无部门信息,请完善后导入"
));
continue
;
}
// 户验证
if
(
CommonConstants
.
ZERO_STRING
.
equals
(
type
)){
baseSet
=
baseSetInfoMap
.
get
(
excel
.
getHouseHold
());
if
(
Common
.
isEmpty
(
baseSet
)){
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
"未找到对应社保户数据!"
));
continue
;
}
}
if
(
CommonConstants
.
ONE_STRING
.
equals
(
type
)){
baseSet
=
baseSetInfoMap
.
get
(
excel
.
getHouseHold
());
if
(
Common
.
isEmpty
(
baseSet
)){
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
"未找到对应公积金户数据!"
));
continue
;
}
}
// 重复校验
temp
=
existMap
.
get
(
excel
.
getUserLoginName
()
+
CommonConstants
.
DOWN_LINE_STRING
+
excel
.
getHouseHold
());
if
(
Common
.
isNotNull
(
temp
)){
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
"对应账号的权限已存在,请勿重复导入"
));
continue
;
}
else
{
if
(
CommonConstants
.
ZERO_STRING
.
equals
(
type
)){
exist
=
baseMapper
.
selectOne
(
Wrappers
.<
TSocialfundHouseRes
>
query
().
lambda
()
.
eq
(
TSocialfundHouseRes:
:
getSocialHousehold
,
excel
.
getHouseHold
())
.
eq
(
TSocialfundHouseRes:
:
getUserId
,
user
.
getUserId
())
.
eq
(
TSocialfundHouseRes:
:
getHouseNameType
,
type
)
.
last
(
CommonConstants
.
LAST_ONE_SQL
));
}
else
{
exist
=
baseMapper
.
selectOne
(
Wrappers
.<
TSocialfundHouseRes
>
query
().
lambda
()
.
eq
(
TSocialfundHouseRes:
:
getFundHousehold
,
excel
.
getHouseHold
())
.
eq
(
TSocialfundHouseRes:
:
getUserId
,
user
.
getUserId
())
.
eq
(
TSocialfundHouseRes:
:
getHouseNameType
,
type
)
.
last
(
CommonConstants
.
LAST_ONE_SQL
));
}
if
(
Common
.
isNotNull
(
exist
)){
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
"对应账号的权限已存在,请勿重复导入"
));
continue
;
}
}
// 初始化及新增数据
save
=
new
TSocialfundHouseRes
();
save
.
setAuthType
(
CommonConstants
.
ONE_STRING
);
save
.
setFundHousehold
(
CommonConstants
.
ZERO_STRING
.
equals
(
type
)?
null
:
baseSet
.
getDepartName
());
save
.
setSocialHousehold
(
CommonConstants
.
ZERO_STRING
.
equals
(
type
)?
baseSet
.
getDepartName
():
null
);
save
.
setStatus
(
CommonConstants
.
ZERO_STRING
);
save
.
setUserId
(
user
.
getUserId
());
save
.
setHouseNameType
(
type
);
save
.
setCreateTime
(
LocalDateTime
.
now
());
save
.
setUserName
(
user
.
getUsername
());
save
.
setUserDeptName
(
user
.
getDeptName
());
insertExcel
(
save
);
// 加入map 验证当前表单数据是否重复
existMap
.
put
(
excel
.
getUserLoginName
()
+
CommonConstants
.
DOWN_LINE_STRING
+
excel
.
getHouseHold
(),
excel
.
getUserLoginName
());
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
CommonConstants
.
SAVE_SUCCESS
,
CommonConstants
.
GREEN
));
}
}
}
yifu-upms/yifu-upms-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/admin/controller/UserController.java
View file @
213f97a6
...
...
@@ -415,6 +415,12 @@ public class UserController {
return
userService
.
getById
(
userId
);
}
@Inner
@PostMapping
(
value
=
{
"/inner/getSimpleUserByLoginName"
})
public
SysUser
getSimpleUserByLoginName
(
@RequestBody
String
loginName
)
{
return
userService
.
getOne
(
Wrappers
.<
SysUser
>
query
().
lambda
().
eq
(
SysUser:
:
getUsername
,
loginName
).
last
(
CommonConstants
.
LAST_ONE_SQL
));
}
/**
* @param nickName 用户名称
* @return 上级部门用户列表
...
...
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