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
Hide 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 {
...
@@ -19,6 +19,6 @@ public class ResultConstants {
public
static
final
String
REQUEST_LOCK_FAIL
=
"获取锁失败"
;
public
static
final
String
REQUEST_LOCK_FAIL
=
"获取锁失败"
;
public
static
final
String
DATA_IMPORT_PARSING_RESULT
=
"数据导入解析!数据行数:"
;
public
static
final
String
DATA_IMPORT_PARSING_RESULT
=
"数据导入解析!数据行数:"
;
public
static
final
String
NO_SELECT_DATA
=
"请选择数据"
;
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不能为空!"
;
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 {
...
@@ -328,7 +328,13 @@ public class TDispatchInfoController {
throw
new
RuntimeException
(
ResultConstants
.
NO_GETLOCK_DATA
+
CommonConstants
.
DOWN_LINE_STRING
+
e
.
getMessage
());
throw
new
RuntimeException
(
ResultConstants
.
NO_GETLOCK_DATA
+
CommonConstants
.
DOWN_LINE_STRING
+
e
.
getMessage
());
}
}
try
{
try
{
return
tDispatchInfoService
.
importDiy
(
file
.
getInputStream
(),
orderId
);
if
(
Common
.
isNotNull
(
requestId
))
{
Thread
.
sleep
(
1000000
);
//主动释放锁
return
tDispatchInfoService
.
importDiy
(
file
.
getInputStream
(),
orderId
);
}
else
{
return
R
.
failed
(
ResultConstants
.
NO_GETLOCK_DATA
);
}
}
finally
{
}
finally
{
//主动释放锁
//主动释放锁
RedisDistributedLock
.
unlock
(
key
,
requestId
);
RedisDistributedLock
.
unlock
(
key
,
requestId
);
...
@@ -410,7 +416,12 @@ public class TDispatchInfoController {
...
@@ -410,7 +416,12 @@ public class TDispatchInfoController {
throw
new
RuntimeException
(
ResultConstants
.
NO_GETLOCK_DATA
+
CommonConstants
.
DOWN_LINE_STRING
+
e
.
getMessage
());
throw
new
RuntimeException
(
ResultConstants
.
NO_GETLOCK_DATA
+
CommonConstants
.
DOWN_LINE_STRING
+
e
.
getMessage
());
}
}
try
{
try
{
return
tDispatchInfoService
.
importReduceDiy
(
file
.
getInputStream
(),
orderId
);
if
(
Common
.
isNotNull
(
requestId
))
{
//主动释放锁
return
tDispatchInfoService
.
importReduceDiy
(
file
.
getInputStream
(),
orderId
);
}
else
{
return
R
.
failed
(
ResultConstants
.
NO_GETLOCK_DATA
);
}
}
finally
{
}
finally
{
//主动释放锁
//主动释放锁
RedisDistributedLock
.
unlock
(
key
,
requestId
);
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 {
...
@@ -168,7 +168,11 @@ public class TPaymentInfoController {
throw
new
RuntimeException
(
ResultConstants
.
NO_GETLOCK_DATA
+
CommonConstants
.
DOWN_LINE_STRING
+
e
.
getMessage
());
throw
new
RuntimeException
(
ResultConstants
.
NO_GETLOCK_DATA
+
CommonConstants
.
DOWN_LINE_STRING
+
e
.
getMessage
());
}
}
try
{
try
{
return
tPaymentInfoService
.
importSocialDiy
(
file
.
getInputStream
());
if
(
Common
.
isNotNull
(
requestId
))
{
return
tPaymentInfoService
.
importSocialDiy
(
file
.
getInputStream
());
}
else
{
return
R
.
failed
(
ResultConstants
.
NO_GETLOCK_DATA
);
}
}
finally
{
}
finally
{
//主动释放锁
//主动释放锁
RedisDistributedLock
.
unlock
(
key
,
requestId
);
RedisDistributedLock
.
unlock
(
key
,
requestId
);
...
@@ -200,7 +204,11 @@ public class TPaymentInfoController {
...
@@ -200,7 +204,11 @@ public class TPaymentInfoController {
throw
new
RuntimeException
(
ResultConstants
.
NO_GETLOCK_DATA
+
CommonConstants
.
DOWN_LINE_STRING
+
e
.
getMessage
());
throw
new
RuntimeException
(
ResultConstants
.
NO_GETLOCK_DATA
+
CommonConstants
.
DOWN_LINE_STRING
+
e
.
getMessage
());
}
}
try
{
try
{
return
tPaymentInfoService
.
importSocialHeFeiDiy
(
file
.
getInputStream
(),
random
,
type
);
if
(
Common
.
isNotNull
(
requestId
))
{
return
tPaymentInfoService
.
importSocialHeFeiDiy
(
file
.
getInputStream
(),
random
,
type
);
}
else
{
return
R
.
failed
(
ResultConstants
.
NO_GETLOCK_DATA
);
}
}
finally
{
}
finally
{
//主动释放锁
//主动释放锁
RedisDistributedLock
.
unlock
(
key
,
requestId
);
RedisDistributedLock
.
unlock
(
key
,
requestId
);
...
@@ -232,7 +240,11 @@ public class TPaymentInfoController {
...
@@ -232,7 +240,11 @@ public class TPaymentInfoController {
throw
new
RuntimeException
(
ResultConstants
.
NO_GETLOCK_DATA
+
CommonConstants
.
DOWN_LINE_STRING
+
e
.
getMessage
());
throw
new
RuntimeException
(
ResultConstants
.
NO_GETLOCK_DATA
+
CommonConstants
.
DOWN_LINE_STRING
+
e
.
getMessage
());
}
}
try
{
try
{
return
tPaymentInfoService
.
batchImportPaymentFundInfo
(
file
.
getInputStream
());
if
(
Common
.
isNotNull
(
requestId
))
{
return
tPaymentInfoService
.
batchImportPaymentFundInfo
(
file
.
getInputStream
());
}
else
{
return
R
.
failed
(
ResultConstants
.
NO_GETLOCK_DATA
);
}
}
finally
{
}
finally
{
//主动释放锁
//主动释放锁
RedisDistributedLock
.
unlock
(
key
,
requestId
);
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,34 +250,38 @@ public class TPreDispatchInfoController {
...
@@ -250,34 +250,38 @@ public class TPreDispatchInfoController {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
ResultConstants
.
NO_GETLOCK_DATA
+
CommonConstants
.
DOWN_LINE_STRING
+
e
.
getMessage
());
throw
new
RuntimeException
(
ResultConstants
.
NO_GETLOCK_DATA
+
CommonConstants
.
DOWN_LINE_STRING
+
e
.
getMessage
());
}
}
ExcelUtil
<
TPreDispatchInfo
>
util1
=
null
;
if
(
Common
.
isNotNull
(
requestId
))
{
try
{
ExcelUtil
<
TPreDispatchInfo
>
util1
=
null
;
jsonString
=
URLDecoder
.
decode
(
jsonString
,
CommonConstants
.
UTF8
).
replace
(
"="
,
""
);
try
{
util1
=
new
ExcelUtil
<>(
TPreDispatchInfo
.
class
);
jsonString
=
URLDecoder
.
decode
(
jsonString
,
CommonConstants
.
UTF8
).
replace
(
"="
,
""
);
util1
.
getJsonStringToList
(
jsonString
,
null
);
util1
=
new
ExcelUtil
<>(
TPreDispatchInfo
.
class
);
List
<
TPreDispatchInfo
>
listInfo
=
util1
.
getEntityList
();
util1
.
getJsonStringToList
(
jsonString
,
null
);
//用于返回错误信息
List
<
TPreDispatchInfo
>
listInfo
=
util1
.
getEntityList
();
List
<
ErrorMessage
>
errorInfo
=
new
ArrayList
<>();
//用于返回错误信息
if
(
null
!=
util1
.
getErrorInfo
()
&&
!
util1
.
getErrorInfo
().
isEmpty
())
{
List
<
ErrorMessage
>
errorInfo
=
new
ArrayList
<>();
for
(
ErrorMessage
errorMessage:
util1
.
getErrorInfo
())
{
if
(
null
!=
util1
.
getErrorInfo
()
&&
!
util1
.
getErrorInfo
().
isEmpty
())
{
errorInfo
.
add
(
errorMessage
);
for
(
ErrorMessage
errorMessage:
util1
.
getErrorInfo
())
{
errorInfo
.
add
(
errorMessage
);
}
}
}
if
(
null
!=
listInfo
&&
!
listInfo
.
isEmpty
())
{
errorInfo
=
tPreDispatchInfoService
.
batchSavePreDisPatchAdd
(
listInfo
,
user
,
socialHouse
,
fundHouse
,
departId
,
errorInfo
);
}
else
{
errorInfo
.
add
(
new
ErrorMessage
(
null
,
CommonConstants
.
DATA_CAN_NOT_EMPTY
));
}
List
<
ErrorMessage
>
newErrorList
=
errorInfo
.
stream
().
sorted
(
Comparator
.
comparing
(
ErrorMessage:
:
getLineNum
))
.
collect
(
Collectors
.
toList
());
return
R
.
ok
(
newErrorList
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
R
.
failed
(
PreDispatchConstants
.
DATA_IMPORT_ANALYSIS_ERROR
);
}
finally
{
//主动释放锁
RedisDistributedLock
.
unlock
(
key
,
requestId
);
}
}
if
(
null
!=
listInfo
&&
!
listInfo
.
isEmpty
())
{
}
else
{
errorInfo
=
tPreDispatchInfoService
.
batchSavePreDisPatchAdd
(
listInfo
,
user
,
socialHouse
,
fundHouse
,
return
R
.
failed
(
ResultConstants
.
NO_GETLOCK_DATA
);
departId
,
errorInfo
);
}
else
{
errorInfo
.
add
(
new
ErrorMessage
(
null
,
CommonConstants
.
DATA_CAN_NOT_EMPTY
));
}
List
<
ErrorMessage
>
newErrorList
=
errorInfo
.
stream
().
sorted
(
Comparator
.
comparing
(
ErrorMessage:
:
getLineNum
))
.
collect
(
Collectors
.
toList
());
return
R
.
ok
(
newErrorList
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
R
.
failed
(
PreDispatchConstants
.
DATA_IMPORT_ANALYSIS_ERROR
);
}
finally
{
//主动释放锁
RedisDistributedLock
.
unlock
(
key
,
requestId
);
}
}
}
}
...
...
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;
...
@@ -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.CacheConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
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.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.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.util.*
;
import
com.yifu.cloud.plus.v1.yifu.common.core.vo.ErrorDetailVO
;
import
com.yifu.cloud.plus.v1.yifu.common.core.vo.ErrorDetailVO
;
import
com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser
;
import
com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser
;
...
@@ -270,7 +272,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
...
@@ -270,7 +272,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
@Override
@Override
public
R
<
Boolean
>
removeInFoById
(
String
id
)
{
public
R
<
Boolean
>
removeInFoById
(
String
id
)
{
YifuUser
user
=
SecurityUtils
.
getUser
();
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
)))
{
if
(
Common
.
isNotNull
(
redisUtil
.
get
(
key
)))
{
return
R
.
failed
(
"用户正在推送实缴数据中禁止删除!"
);
return
R
.
failed
(
"用户正在推送实缴数据中禁止删除!"
);
}
}
...
@@ -298,7 +300,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
...
@@ -298,7 +300,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
return
R
.
failed
(
CommonConstants
.
NO_DATA_TO_HANDLE
);
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
)))
{
if
(
Common
.
isNotNull
(
redisUtil
.
get
(
key
)))
{
return
R
.
failed
(
"用户正在推送实缴数据中禁止删除!"
);
return
R
.
failed
(
"用户正在推送实缴数据中禁止删除!"
);
}
}
...
@@ -340,7 +342,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
...
@@ -340,7 +342,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
String
socialCreateMonth
,
String
socialPayMonth
)
{
String
socialCreateMonth
,
String
socialPayMonth
)
{
YifuUser
user
=
SecurityUtils
.
getUser
();
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
)))
{
if
(
Common
.
isNotNull
(
redisUtil
.
get
(
key
)))
{
return
R
.
failed
(
"用户正在推送实缴数据中禁止删除!"
);
return
R
.
failed
(
"用户正在推送实缴数据中禁止删除!"
);
}
}
...
@@ -2814,31 +2816,43 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
...
@@ -2814,31 +2816,43 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
@Override
@Override
public
R
<
Boolean
>
pushPaymentSocialFundInfo
(
TPaymentInfoSearchVo
searchVo
)
{
public
R
<
Boolean
>
pushPaymentSocialFundInfo
(
TPaymentInfoSearchVo
searchVo
)
{
YifuUser
user
=
SecurityUtils
.
getUser
();
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
)))
{
if
(
Common
.
isNotNull
(
redisUtil
.
get
(
key
)))
{
return
R
.
failed
(
"用户正在推送实缴数据中,禁止重复推送!"
);
return
R
.
failed
(
"用户正在推送实缴数据中,禁止重复推送!"
);
}
else
{
}
else
{
redisUtil
.
set
(
key
,
user
.
getId
(),
1200L
);
redisUtil
.
set
(
key
,
user
.
getId
(),
1200L
);
}
}
// 获取redis分布式事务锁
Map
<
String
,
TSettleDomainSelectVo
>
mapSelectVo
=
this
.
getSelectVoMap
();
String
requestId
;
//手动推送未推送的社保公积金明细数据
try
{
createPaymentSocialInfoReal
(
user
,
searchVo
,
mapSelectVo
);
requestId
=
RedisDistributedLock
.
getLock
(
key
,
"10"
);
createPaymentFundInfoReal
(
user
,
searchVo
,
mapSelectVo
);
}
catch
(
Exception
e
)
{
//推送社保公积金收入数据
throw
new
RuntimeException
(
ResultConstants
.
NO_GETLOCK_DATA
+
CommonConstants
.
DOWN_LINE_STRING
+
e
.
getMessage
());
String
redisKey
=
String
.
valueOf
(
UUID
.
randomUUID
()).
replaceAll
(
"-"
,
""
)
+
"_incomePush"
;
}
createPaymentInfoIncomeReal
(
user
,
searchVo
,
mapSelectVo
,
redisKey
);
if
(
Common
.
isNotNull
(
requestId
))
{
createPaymentFundIncomeReal
(
user
,
searchVo
,
mapSelectVo
,
redisKey
);
Map
<
String
,
TSettleDomainSelectVo
>
mapSelectVo
=
this
.
getSelectVoMap
();
//推送失败的数据重新推送
//手动推送未推送的社保公积金明细数据
if
(
Common
.
isNotNull
(
redisUtil
.
get
(
redisKey
)))
{
createPaymentSocialInfoReal
(
user
,
searchVo
,
mapSelectVo
);
List
<
TIncome
>
list
=
(
List
<
TIncome
>)
redisUtil
.
get
(
redisKey
);
createPaymentFundInfoReal
(
user
,
searchVo
,
mapSelectVo
);
for
(
TIncome
income
:
list
)
{
//推送社保公积金收入数据
doJointSocialTask
.
asynchronousEkpIncomePaymentT
(
income
);
String
redisKey
=
String
.
valueOf
(
UUID
.
randomUUID
()).
replaceAll
(
"-"
,
""
)
+
"_incomePush"
;
createPaymentInfoIncomeReal
(
user
,
searchVo
,
mapSelectVo
,
redisKey
);
createPaymentFundIncomeReal
(
user
,
searchVo
,
mapSelectVo
,
redisKey
);
//推送失败的数据重新推送
if
(
Common
.
isNotNull
(
redisUtil
.
get
(
redisKey
)))
{
List
<
TIncome
>
list
=
(
List
<
TIncome
>)
redisUtil
.
get
(
redisKey
);
for
(
TIncome
income
:
list
)
{
doJointSocialTask
.
asynchronousEkpIncomePaymentT
(
income
);
}
redisUtil
.
remove
(
redisKey
);
}
}
redisUtil
.
remove
(
redisKey
);
redisUtil
.
remove
(
key
);
//主动释放锁
RedisDistributedLock
.
unlock
(
key
,
requestId
);
return
R
.
ok
();
}
else
{
return
R
.
failed
(
ResultConstants
.
NO_GETLOCK_DATA
);
}
}
redisUtil
.
remove
(
key
);
return
R
.
ok
();
}
}
@Override
@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