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
eb102d78
Commit
eb102d78
authored
Mar 08, 2023
by
fangxinjiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
分布式锁
parent
a57b9a73
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
94 additions
and
53 deletions
+94
-53
ResultConstants.java
...ud/plus/v1/yifu/common/core/constant/ResultConstants.java
+1
-1
TDispatchInfoController.java
...us/v1/yifu/social/controller/TDispatchInfoController.java
+13
-2
TPaymentInfoController.java
...lus/v1/yifu/social/controller/TPaymentInfoController.java
+15
-3
TPreDispatchInfoController.java
...v1/yifu/social/controller/TPreDispatchInfoController.java
+30
-26
TPaymentInfoServiceImpl.java
.../v1/yifu/social/service/impl/TPaymentInfoServiceImpl.java
+35
-21
No files found.
yifu-common/yifu-common-core/src/main/java/com/yifu/cloud/plus/v1/yifu/common/core/constant/ResultConstants.java
View file @
eb102d78
...
...
@@ -19,6 +19,6 @@ public class ResultConstants {
public
static
final
String
REQUEST_LOCK_FAIL
=
"获取锁失败"
;
public
static
final
String
DATA_IMPORT_PARSING_RESULT
=
"数据导入解析!数据行数:"
;
public
static
final
String
NO_SELECT_DATA
=
"请选择数据"
;
public
static
final
String
NO_GETLOCK_DATA
=
"
获取锁失败,10秒
后重试!"
;
public
static
final
String
NO_GETLOCK_DATA
=
"
当前用户操作处理中,请稍
后重试!"
;
public
static
final
String
NO_ID
=
"操作失败,id不能为空!"
;
}
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/controller/TDispatchInfoController.java
View file @
eb102d78
...
...
@@ -328,7 +328,13 @@ public class TDispatchInfoController {
throw
new
RuntimeException
(
ResultConstants
.
NO_GETLOCK_DATA
+
CommonConstants
.
DOWN_LINE_STRING
+
e
.
getMessage
());
}
try
{
if
(
Common
.
isNotNull
(
requestId
))
{
Thread
.
sleep
(
1000000
);
//主动释放锁
return
tDispatchInfoService
.
importDiy
(
file
.
getInputStream
(),
orderId
);
}
else
{
return
R
.
failed
(
ResultConstants
.
NO_GETLOCK_DATA
);
}
}
finally
{
//主动释放锁
RedisDistributedLock
.
unlock
(
key
,
requestId
);
...
...
@@ -410,7 +416,12 @@ public class TDispatchInfoController {
throw
new
RuntimeException
(
ResultConstants
.
NO_GETLOCK_DATA
+
CommonConstants
.
DOWN_LINE_STRING
+
e
.
getMessage
());
}
try
{
if
(
Common
.
isNotNull
(
requestId
))
{
//主动释放锁
return
tDispatchInfoService
.
importReduceDiy
(
file
.
getInputStream
(),
orderId
);
}
else
{
return
R
.
failed
(
ResultConstants
.
NO_GETLOCK_DATA
);
}
}
finally
{
//主动释放锁
RedisDistributedLock
.
unlock
(
key
,
requestId
);
...
...
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/controller/TPaymentInfoController.java
View file @
eb102d78
...
...
@@ -168,7 +168,11 @@ public class TPaymentInfoController {
throw
new
RuntimeException
(
ResultConstants
.
NO_GETLOCK_DATA
+
CommonConstants
.
DOWN_LINE_STRING
+
e
.
getMessage
());
}
try
{
if
(
Common
.
isNotNull
(
requestId
))
{
return
tPaymentInfoService
.
importSocialDiy
(
file
.
getInputStream
());
}
else
{
return
R
.
failed
(
ResultConstants
.
NO_GETLOCK_DATA
);
}
}
finally
{
//主动释放锁
RedisDistributedLock
.
unlock
(
key
,
requestId
);
...
...
@@ -200,7 +204,11 @@ public class TPaymentInfoController {
throw
new
RuntimeException
(
ResultConstants
.
NO_GETLOCK_DATA
+
CommonConstants
.
DOWN_LINE_STRING
+
e
.
getMessage
());
}
try
{
if
(
Common
.
isNotNull
(
requestId
))
{
return
tPaymentInfoService
.
importSocialHeFeiDiy
(
file
.
getInputStream
(),
random
,
type
);
}
else
{
return
R
.
failed
(
ResultConstants
.
NO_GETLOCK_DATA
);
}
}
finally
{
//主动释放锁
RedisDistributedLock
.
unlock
(
key
,
requestId
);
...
...
@@ -232,7 +240,11 @@ public class TPaymentInfoController {
throw
new
RuntimeException
(
ResultConstants
.
NO_GETLOCK_DATA
+
CommonConstants
.
DOWN_LINE_STRING
+
e
.
getMessage
());
}
try
{
if
(
Common
.
isNotNull
(
requestId
))
{
return
tPaymentInfoService
.
batchImportPaymentFundInfo
(
file
.
getInputStream
());
}
else
{
return
R
.
failed
(
ResultConstants
.
NO_GETLOCK_DATA
);
}
}
finally
{
//主动释放锁
RedisDistributedLock
.
unlock
(
key
,
requestId
);
...
...
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/controller/TPreDispatchInfoController.java
View file @
eb102d78
...
...
@@ -250,6 +250,7 @@ public class TPreDispatchInfoController {
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
ResultConstants
.
NO_GETLOCK_DATA
+
CommonConstants
.
DOWN_LINE_STRING
+
e
.
getMessage
());
}
if
(
Common
.
isNotNull
(
requestId
))
{
ExcelUtil
<
TPreDispatchInfo
>
util1
=
null
;
try
{
jsonString
=
URLDecoder
.
decode
(
jsonString
,
CommonConstants
.
UTF8
).
replace
(
"="
,
""
);
...
...
@@ -279,6 +280,9 @@ public class TPreDispatchInfoController {
//主动释放锁
RedisDistributedLock
.
unlock
(
key
,
requestId
);
}
}
else
{
return
R
.
failed
(
ResultConstants
.
NO_GETLOCK_DATA
);
}
}
/**
...
...
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/service/impl/TPaymentInfoServiceImpl.java
View file @
eb102d78
...
...
@@ -38,7 +38,9 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.TSettleDomainSelectVo;
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.ExcelAttributeConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.ResultConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes
;
import
com.yifu.cloud.plus.v1.yifu.common.core.redis.RedisDistributedLock
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.*
;
import
com.yifu.cloud.plus.v1.yifu.common.core.vo.ErrorDetailVO
;
import
com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser
;
...
...
@@ -270,7 +272,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
@Override
public
R
<
Boolean
>
removeInFoById
(
String
id
)
{
YifuUser
user
=
SecurityUtils
.
getUser
();
String
key
=
user
.
getId
()
+
CommonConstants
.
DOWN_LINE_STRING
+
CacheConstants
.
PAYMENT_SOCIAL_PUSH
;
String
key
=
CacheConstants
.
PAYMENT_SOCIAL_PUSH
+
CommonConstants
.
DOWN_LINE_STRING
+
user
.
getId
()
;
if
(
Common
.
isNotNull
(
redisUtil
.
get
(
key
)))
{
return
R
.
failed
(
"用户正在推送实缴数据中禁止删除!"
);
}
...
...
@@ -298,7 +300,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
return
R
.
failed
(
CommonConstants
.
NO_DATA_TO_HANDLE
);
}
String
key
=
user
.
getId
()
+
CommonConstants
.
DOWN_LINE_STRING
+
CacheConstants
.
PAYMENT_SOCIAL_PUSH
;
String
key
=
CacheConstants
.
PAYMENT_SOCIAL_PUSH
+
CommonConstants
.
DOWN_LINE_STRING
+
user
.
getId
()
;
if
(
Common
.
isNotNull
(
redisUtil
.
get
(
key
)))
{
return
R
.
failed
(
"用户正在推送实缴数据中禁止删除!"
);
}
...
...
@@ -340,7 +342,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
String
socialCreateMonth
,
String
socialPayMonth
)
{
YifuUser
user
=
SecurityUtils
.
getUser
();
String
key
=
user
.
getId
()
+
CommonConstants
.
DOWN_LINE_STRING
+
CacheConstants
.
PAYMENT_SOCIAL_PUSH
;
String
key
=
CacheConstants
.
PAYMENT_SOCIAL_PUSH
+
CommonConstants
.
DOWN_LINE_STRING
+
user
.
getId
()
;
if
(
Common
.
isNotNull
(
redisUtil
.
get
(
key
)))
{
return
R
.
failed
(
"用户正在推送实缴数据中禁止删除!"
);
}
...
...
@@ -2814,13 +2816,20 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
@Override
public
R
<
Boolean
>
pushPaymentSocialFundInfo
(
TPaymentInfoSearchVo
searchVo
)
{
YifuUser
user
=
SecurityUtils
.
getUser
();
String
key
=
user
.
getId
()
+
CommonConstants
.
DOWN_LINE_STRING
+
CacheConstants
.
PAYMENT_SOCIAL_PUSH
;
String
key
=
CacheConstants
.
PAYMENT_SOCIAL_PUSH
+
CommonConstants
.
DOWN_LINE_STRING
+
user
.
getId
()
;
if
(
Common
.
isNotNull
(
redisUtil
.
get
(
key
)))
{
return
R
.
failed
(
"用户正在推送实缴数据中,禁止重复推送!"
);
}
else
{
redisUtil
.
set
(
key
,
user
.
getId
(),
1200L
);
}
// 获取redis分布式事务锁
String
requestId
;
try
{
requestId
=
RedisDistributedLock
.
getLock
(
key
,
"10"
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
ResultConstants
.
NO_GETLOCK_DATA
+
CommonConstants
.
DOWN_LINE_STRING
+
e
.
getMessage
());
}
if
(
Common
.
isNotNull
(
requestId
))
{
Map
<
String
,
TSettleDomainSelectVo
>
mapSelectVo
=
this
.
getSelectVoMap
();
//手动推送未推送的社保公积金明细数据
createPaymentSocialInfoReal
(
user
,
searchVo
,
mapSelectVo
);
...
...
@@ -2838,7 +2847,12 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
redisUtil
.
remove
(
redisKey
);
}
redisUtil
.
remove
(
key
);
//主动释放锁
RedisDistributedLock
.
unlock
(
key
,
requestId
);
return
R
.
ok
();
}
else
{
return
R
.
failed
(
ResultConstants
.
NO_GETLOCK_DATA
);
}
}
@Override
...
...
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