Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
head_group
xyqb-user2
Commits
8b97a22d
Commit
8b97a22d
authored
Jul 28, 2023
by
唐峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
合同签署
parent
5175d8a5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
17 deletions
+52
-17
RedisKeyConstant.java
...in/java/cn/quantgroup/xyqb/constant/RedisKeyConstant.java
+5
-0
BlackHoleRegisteredEventListener.java
...antgroup/xyqb/event/BlackHoleRegisteredEventListener.java
+12
-1
UserServiceImpl.java
...cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
+35
-16
No files found.
src/main/java/cn/quantgroup/xyqb/constant/RedisKeyConstant.java
View file @
8b97a22d
...
...
@@ -3,4 +3,9 @@ package cn.quantgroup.xyqb.constant;/**
* @Created by tangfeng 2023/7/27 18:23
*/
public
class
RedisKeyConstant
{
// 注册登录签署合同 userId-contractId
public
static
final
String
USER_REGISTER_LOGIN_CONTRACT
=
"user:register.login.contract:sign:%s-%s"
;
public
static
final
String
USER_REGISTER_LOGIN_CONTRACT_LOCK
=
"user:register.login.contract:lock:%s"
;
}
src/main/java/cn/quantgroup/xyqb/event/BlackHoleRegisteredEventListener.java
View file @
8b97a22d
package
cn
.
quantgroup
.
xyqb
.
event
;
import
cn.quantgroup.xyqb.config.data.ContractTemplateConfiguration
;
import
cn.quantgroup.xyqb.constant.RedisKeyConstant
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.util.RedisLock
;
import
com.alibaba.fastjson.JSONArray
;
...
...
@@ -19,6 +20,7 @@ import javax.annotation.Resource;
import
java.time.LocalDate
;
import
java.time.format.DateTimeFormatter
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
/**
* 用户注册发送给合同中心事件监听
...
...
@@ -51,7 +53,7 @@ public class BlackHoleRegisteredEventListener implements ApplicationListener<Reg
List
<
Long
>
templates
=
contractTemplateConfiguration
.
getByTenantIdAndRegisteredFrom
(
user
.
getTenantId
(),
user
.
getRegisteredFrom
());
if
(
CollectionUtils
.
isNotEmpty
(
templates
))
{
//补签合同,如果需要补签
String
lockKey
=
"user:signcontrac:"
.
concat
(
user
.
getId
().
toString
());
String
lockKey
=
RedisKeyConstant
.
USER_REGISTER_LOGIN_CONTRACT_LOCK
.
concat
(
user
.
getId
().
toString
());
RedisLock
lock
=
new
RedisLock
(
redisTemplate
,
lockKey
);
try
{
...
...
@@ -62,6 +64,12 @@ public class BlackHoleRegisteredEventListener implements ApplicationListener<Reg
templates
.
forEach
(
templateId
->
{
String
redisKey
=
String
.
format
(
RedisKeyConstant
.
USER_REGISTER_LOGIN_CONTRACT
,
user
.
getId
(),
templateId
);
String
redisValue
=
redisTemplate
.
opsForValue
().
get
(
redisKey
);
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isEmpty
(
redisValue
))
{
return
;
}
JSONArray
array
=
new
JSONArray
();
JSONObject
json
=
new
JSONObject
();
if
(
templateId
==
8
||
templateId
==
280
)
{
...
...
@@ -83,6 +91,9 @@ public class BlackHoleRegisteredEventListener implements ApplicationListener<Reg
log
.
info
(
"注册签合同事件:{},模板:{}"
,
JSONObject
.
toJSONString
(
event
),
templateId
);
registeredNotifyBlackHoleRabbitTemplate
.
convertAndSend
(
exchange
,
routingKey
,
array
.
toString
());
redisTemplate
.
opsForValue
().
set
(
redisKey
,
array
.
toJSONString
());
redisTemplate
.
expire
(
redisKey
,
1L
,
TimeUnit
.
MINUTES
);
});
}
}
catch
(
Exception
e
)
{
...
...
src/main/java/cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
View file @
8b97a22d
...
...
@@ -3,6 +3,7 @@ package cn.quantgroup.xyqb.service.user.impl;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.aspect.lock.RedisLock
;
import
cn.quantgroup.xyqb.config.data.ContractTemplateConfiguration
;
import
cn.quantgroup.xyqb.constant.RedisKeyConstant
;
import
cn.quantgroup.xyqb.constant.UserConstant
;
import
cn.quantgroup.xyqb.constant.enums.LoginType
;
import
cn.quantgroup.xyqb.controller.IBaseController
;
...
...
@@ -567,22 +568,40 @@ public class UserServiceImpl implements IUserService, IBaseController {
return
;
}
templates
.
forEach
(
templateId
->
{
ContractRecordReq
contractRecordReq
=
new
ContractRecordReq
();
contractRecordReq
.
setTemplateId
(
templateId
);
contractRecordReq
.
setUserId
(
user
.
getId
());
JsonResult
<
ContractsRes
>
result
=
pdfRemoteService
.
getContractRecord
(
contractRecordReq
);
ContractsRes
data
=
result
.
getData
();
if
(
Objects
.
nonNull
(
data
))
{
return
;
String
lockKey
=
RedisKeyConstant
.
USER_REGISTER_LOGIN_CONTRACT_LOCK
.
concat
(
user
.
getId
().
toString
());
cn
.
quantgroup
.
xyqb
.
util
.
RedisLock
lock
=
new
cn
.
quantgroup
.
xyqb
.
util
.
RedisLock
(
stringRedisTemplate
,
lockKey
);
try
{
if
(
lock
.
lock
())
{
templates
.
forEach
(
templateId
->
{
String
redisKey
=
String
.
format
(
RedisKeyConstant
.
USER_REGISTER_LOGIN_CONTRACT
,
user
.
getId
(),
templateId
);
String
redisValue
=
stringRedisTemplate
.
opsForValue
().
get
(
redisKey
);
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isEmpty
(
redisValue
))
{
return
;
}
ContractRecordReq
contractRecordReq
=
new
ContractRecordReq
();
contractRecordReq
.
setTemplateId
(
templateId
);
contractRecordReq
.
setUserId
(
user
.
getId
());
JsonResult
<
ContractsRes
>
result
=
pdfRemoteService
.
getContractRecord
(
contractRecordReq
);
ContractsRes
data
=
result
.
getData
();
if
(
Objects
.
nonNull
(
data
))
{
return
;
}
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"userId"
,
user
.
getId
());
json
.
put
(
"templateId"
,
templateId
);
JSONArray
array
=
new
JSONArray
();
array
.
add
(
json
);
registeredNotifyBlackHoleRabbitTemplate
.
convertAndSend
(
exchange
,
routingKey
,
array
.
toString
());
log
.
info
(
"登录补签合同事件:userId:{},templateIds:{}"
,
user
.
getId
(),
templateId
);
stringRedisTemplate
.
opsForValue
().
set
(
redisKey
,
array
.
toJSONString
());
stringRedisTemplate
.
expire
(
redisKey
,
1L
,
TimeUnit
.
MINUTES
);
});
}
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"userId"
,
user
.
getId
());
json
.
put
(
"templateId"
,
templateId
);
JSONArray
array
=
new
JSONArray
();
array
.
add
(
json
);
registeredNotifyBlackHoleRabbitTemplate
.
convertAndSend
(
exchange
,
routingKey
,
array
.
toString
());
log
.
info
(
"登录补签合同事件:userId:{},templateIds:{}"
,
user
.
getId
(),
templateId
);
});
}
catch
(
Exception
e
)
{
log
.
error
(
"补签合同事件异常:事件:user:{},loginFrom:{},tenantId:{},异常:{}"
,
user
.
getId
(),
loginFrom
,
tenantId
,
e
.
getMessage
(),
e
);
}
finally
{
lock
.
unlock
();
}
}
}
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