Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
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
项目统一框架
amos-boot-biz
Commits
d71104ee
Commit
d71104ee
authored
Oct 18, 2024
by
suhuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.生产环境身份信息重复问题处理
parent
7b66c4a9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
113 additions
and
19 deletions
+113
-19
RedissonManager.java
...join/amos/boot/module/tcm/biz/config/RedissonManager.java
+68
-0
TzBaseEnterpriseInfoServiceImpl.java
...tcm/biz/service/impl/TzBaseEnterpriseInfoServiceImpl.java
+45
-19
No files found.
amos-boot-system-tzs/amos-boot-module-tcm/amos-boot-module-tcm-biz/src/main/java/com/yeejoin/amos/boot/module/tcm/biz/config/RedissonManager.java
0 → 100644
View file @
d71104ee
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tcm
.
biz
.
config
;
import
lombok.extern.slf4j.Slf4j
;
import
org.redisson.Redisson
;
import
org.redisson.api.RedissonClient
;
import
org.redisson.config.Config
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
@Slf4j
public
class
RedissonManager
{
/**
* 集群环境使用-节点信息
*/
@Value
(
"${spring.redis.cluster.nodes:default}"
)
private
String
clusterNodes
;
/**
* 公共-密码
*/
@Value
(
"${spring.redis.password}"
)
private
String
password
;
/**
* 单机环境使用
*/
@Value
(
"${spring.redis.host:default}"
)
private
String
host
;
/**
* 单机环境使用
*/
@Value
(
"${spring.redis.port:default}"
)
private
String
port
;
/**
* 单机环境使用
*/
@Value
(
"${spring.redis.database:0}"
)
private
int
database
;
@Bean
@ConditionalOnProperty
(
name
=
"spring.redis.mode"
,
havingValue
=
"cluster"
)
public
RedissonClient
redissonClient
()
{
// 集群环境使用
Config
config
=
new
Config
();
config
.
useClusterServers
()
.
addNodeAddress
(
clusterNodes
.
split
(
","
))
.
setPassword
(
password
);
return
Redisson
.
create
(
config
);
}
@Bean
@ConditionalOnProperty
(
name
=
"spring.redis.mode"
,
havingValue
=
"singleton"
,
matchIfMissing
=
true
)
public
RedissonClient
redissonSingletonClient
()
{
// 单机环境使用
Config
config
=
new
Config
();
config
.
useSingleServer
().
setAddress
(
host
+
":"
+
port
).
setPassword
(
password
).
setDatabase
(
database
);
return
Redisson
.
create
(
config
);
}
}
amos-boot-system-tzs/amos-boot-module-tcm/amos-boot-module-tcm-biz/src/main/java/com/yeejoin/amos/boot/module/tcm/biz/service/impl/TzBaseEnterpriseInfoServiceImpl.java
View file @
d71104ee
...
...
@@ -46,19 +46,24 @@ import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import
com.yeejoin.amos.feign.privilege.model.CompanyModel
;
import
org.apache.commons.compress.utils.Lists
;
import
org.apache.commons.lang3.StringUtils
;
import
org.redisson.api.RLock
;
import
org.redisson.api.RedissonClient
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.foundation.exception.BaseException
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
org.typroject.tyboot.core.restful.exception.instance.TooManyRequests
;
import
javax.servlet.http.HttpServletResponse
;
import
java.text.ParseException
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.function.Predicate
;
import
java.util.stream.Collectors
;
...
...
@@ -80,7 +85,7 @@ public class TzBaseEnterpriseInfoServiceImpl
/**
* 企业管理员变更缓存key前缀
*/
private
final
String
adminChange
=
"ADMIN_CHANGE_"
;
private
final
static
String
adminChange
=
"ADMIN_CHANGE_"
;
@Autowired
RedisUtil
redisUtil
;
@Autowired
...
...
@@ -114,12 +119,15 @@ public class TzBaseEnterpriseInfoServiceImpl
@Autowired
private
TzsUserInfoServiceImpl
userInfoService
;
private
static
Map
<
String
,
String
>
JYJC_CERT_MAP
=
new
HashMap
<>();
@Autowired
private
RedissonClient
redissonClient
;
private
static
final
Map
<
String
,
String
>
JYJC_CERT_MAP
=
new
HashMap
<>();
/**
* 公司类型下的资质类型map:key为登录人的公司类型、value为包含的资质枚举
*/
private
static
Map
<
String
,
String
>
COMPANY_TYPE_CERT_TYPE_MAP
=
new
HashMap
<>();
private
static
final
Map
<
String
,
String
>
COMPANY_TYPE_CERT_TYPE_MAP
=
new
HashMap
<>();
// 数据来源cb_data_dictionary type='UNIT_TYPE_NEW'
static
{
COMPANY_TYPE_CERT_TYPE_MAP
.
put
(
"使用单位"
,
"1232"
);
...
...
@@ -886,31 +894,49 @@ public class TzBaseEnterpriseInfoServiceImpl
@Override
public
Map
<
String
,
Object
>
adminInfoUpdate
(
Map
<
String
,
Object
>
map
)
{
//每一个企业只有一个管理员,所以当前登录用户即管理员用户
AgencyUserModel
me
=
Privilege
.
agencyUserClient
.
getme
().
getResult
();
//自己不能修改自己 所以需要设置为机器人
platformTokenService
.
setRequestContext
();
// 按照用户进行加锁,解决用户重复提交导致的身份信息重复问题
String
userId
=
RequestContext
.
getExeUserId
();
RLock
lock
=
redissonClient
.
getLock
(
this
.
buildUserUpdateLockKey
(
userId
));
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
RegUnitInfo
regUnitInfo
=
new
RegUnitInfo
();
String
unitCode
=
String
.
valueOf
(
map
.
get
(
"unitCode"
));
regUnitInfo
.
setAdminName
(
String
.
valueOf
(
map
.
get
(
"adminName"
)));
regUnitInfo
.
setAdminIdNumber
(
String
.
valueOf
(
map
.
get
(
"adminIdNumber"
)));
regUnitInfo
.
setAdminIdCardPhoto
(
JSON
.
toJSONString
(
map
.
get
(
"adminIdCardPhoto"
)));
regUnitInfo
.
setAdminTel
(
String
.
valueOf
(
map
.
get
(
"adminTel"
)));
me
.
setMobile
(
regUnitInfo
.
getAdminTel
());
me
.
setRealName
(
String
.
valueOf
(
map
.
get
(
"adminName"
)));
try
{
boolean
isLocked
=
lock
.
tryLock
(
0
,
180
,
TimeUnit
.
SECONDS
);
if
(!
isLocked
)
{
throw
new
TooManyRequests
(
"信息正在保存中,请稍后重试!"
);
}
//每一个企业只有一个管理员,所以当前登录用户即管理员用户
AgencyUserModel
me
=
Privilege
.
agencyUserClient
.
getme
().
getResult
();
//自己不能修改自己 所以需要设置为机器人
platformTokenService
.
setRequestContext
();
RegUnitInfo
regUnitInfo
=
new
RegUnitInfo
();
String
unitCode
=
String
.
valueOf
(
map
.
get
(
"unitCode"
));
regUnitInfo
.
setAdminName
(
String
.
valueOf
(
map
.
get
(
"adminName"
)));
regUnitInfo
.
setAdminIdNumber
(
String
.
valueOf
(
map
.
get
(
"adminIdNumber"
)));
regUnitInfo
.
setAdminIdCardPhoto
(
JSON
.
toJSONString
(
map
.
get
(
"adminIdCardPhoto"
)));
regUnitInfo
.
setAdminTel
(
String
.
valueOf
(
map
.
get
(
"adminTel"
)));
me
.
setMobile
(
regUnitInfo
.
getAdminTel
());
me
.
setRealName
(
String
.
valueOf
(
map
.
get
(
"adminName"
)));
Privilege
.
agencyUserClient
.
update
(
me
,
me
.
getUserId
());
regUnitInfoService
.
update
(
regUnitInfo
,
new
LambdaQueryWrapper
<
RegUnitInfo
>().
eq
(
RegUnitInfo:
:
getUnitCode
,
unitCode
));
}
catch
(
Exception
e
)
{
resultMap
.
put
(
"success"
,
regUnitInfo
);
redisUtil
.
del
(
adminChange
+
map
.
get
(
"adminTel"
));
}
catch
(
InterruptedException
e
)
{
log
.
error
(
"tryLock获取锁失败:"
,
e
);
throw
new
BadRequest
(
"系统繁忙,请稍后重试!"
);
}
catch
(
TooManyRequests
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
BadRequest
(
e
.
getMessage
());
throw
e
;
}
finally
{
if
(
lock
.
isHeldByCurrentThread
())
{
lock
.
unlock
();
}
}
resultMap
.
put
(
"success"
,
regUnitInfo
);
redisUtil
.
del
(
adminChange
+
map
.
get
(
"adminTel"
));
return
resultMap
;
}
private
String
buildUserUpdateLockKey
(
String
userId
)
{
return
String
.
format
(
"TCM_USER_UPDATE_LOCK_KEY:%s"
,
userId
);
}
public
void
setSpeUseUnitState
(
int
state
,
SpeUseUnit
speUseUnit
){
speUseUnit
.
setSyncState
(
state
);
speUseUnitService
.
updateById
(
speUseUnit
);
...
...
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