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
c30637b5
Commit
c30637b5
authored
Feb 07, 2023
by
fangxinjiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
分布式锁调试
parent
f8f9ef51
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
65 additions
and
3 deletions
+65
-3
TEmpFamilyController.java
...lus/v1/yifu/archives/controller/TEmpFamilyController.java
+20
-0
pom.xml
yifu-common/yifu-common-core/pom.xml
+5
-0
MyLockFailureStrategy.java
.../yifu/common/core/redis/lock4j/MyLockFailureStrategy.java
+22
-0
spring.factories
...-common-core/src/main/resources/META-INF/spring.factories
+2
-1
GlobalExceptionHandler.java
...ifu/common/security/exception/GlobalExceptionHandler.java
+14
-0
TSocialFundInfo.java
...ifu/cloud/plus/v1/yifu/social/entity/TSocialFundInfo.java
+1
-1
logback-spring.xml
...ial/yifu-social-biz/src/main/resources/logback-spring.xml
+1
-1
No files found.
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/controller/TEmpFamilyController.java
View file @
c30637b5
...
...
@@ -17,6 +17,7 @@
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
archives
.
controller
;
import
com.baomidou.lock.annotation.Lock4j
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpFamily
;
...
...
@@ -26,6 +27,7 @@ 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.R
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.RedisUtil
;
import
com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprCheckProperties
;
import
com.yifu.cloud.plus.v1.yifu.common.dapr.util.ArchivesDaprUtil
;
import
com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog
;
...
...
@@ -60,6 +62,7 @@ public class TEmpFamilyController {
private
final
TEmpFamilyService
tEmpFamilyService
;
@Autowired
private
final
ArchivesDaprUtil
archivesDaprUtil
;
int
i
=
0
;
/**
* 分页查询
* @param page 分页对象
...
...
@@ -173,4 +176,21 @@ public class TEmpFamilyController {
public
R
<
List
<
ErrorMessage
>>
importListAdd
(
@RequestBody
MultipartFile
file
){
return
tEmpFamilyService
.
importEmpFamilyDiy
(
file
.
getInputStream
());
}
@Autowired
private
RedisUtil
redisUtil
;
@Lock4j
(
keys
=
{
"#tEmpFamily.mId"
},
expire
=
60000
,
acquireTimeout
=
1000
)
@Operation
(
description
=
"lockTest"
)
@GetMapping
(
"/page"
)
public
R
<
String
>
lockTest
(
Page
page
,
FamilySearchVO
tEmpFamily
)
{
Object
obj
=
redisUtil
.
get
(
"lockTest"
);
int
lockValue
;
if
(
Common
.
isNotNull
(
obj
)){
lockValue
=
(
int
)
obj
;
}
else
{
lockValue
=
1
;
}
lockValue
=
lockValue
+
1
;
redisUtil
.
set
(
"lockTest"
,
lockValue
);
return
R
.
ok
(
CommonConstants
.
SUCCESS_MSG_PREFIX
,
String
.
valueOf
(
lockValue
));
}
}
yifu-common/yifu-common-core/pom.xml
View file @
c30637b5
...
...
@@ -110,5 +110,10 @@
<version>
4.5.30
</version>
<scope>
compile
</scope>
</dependency>
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
lock4j-redis-template-spring-boot-starter
</artifactId>
<version>
2.2.4
</version>
</dependency>
</dependencies>
</project>
yifu-common/yifu-common-core/src/main/java/com/yifu/cloud/plus/v1/yifu/common/core/redis/lock4j/MyLockFailureStrategy.java
0 → 100644
View file @
c30637b5
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
common
.
core
.
redis
.
lock4j
;
import
com.baomidou.lock.LockFailureStrategy
;
import
com.baomidou.lock.exception.LockFailureException
;
import
org.springframework.stereotype.Component
;
import
java.lang.reflect.Method
;
/**
* @Author fxj
* @Date 2023/2/7
* @Description lock4j 分布式锁 异常 自定义异常策略
* @Version 1.0
*/
@Component
public
class
MyLockFailureStrategy
implements
LockFailureStrategy
{
@Override
public
void
onLockFailure
(
String
key
,
Method
method
,
Object
[]
arguments
)
{
throw
new
LockFailureException
(
"业务执行中,请稍后重试"
);
}
}
yifu-common/yifu-common-core/src/main/resources/META-INF/spring.factories
View file @
c30637b5
...
...
@@ -6,4 +6,5 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.yifu.cloud.plus.v1.yifu.common.core.util.SpringContextHolder,\
com.yifu.cloud.plus.v1.yifu.common.core.config.WebMvcConfiguration,\
com.yifu.cloud.plus.v1.yifu.common.core.util.OSSUtil,\
com.yifu.cloud.plus.v1.yifu.common.core.util.RedisUtil
com.yifu.cloud.plus.v1.yifu.common.core.util.RedisUtil,\
com.yifu.cloud.plus.v1.yifu.common.core.redis.lock4j.MyLockFailureStrategy
yifu-common/yifu-common-security/src/main/java/com/yifu/cloud/plus/v1/yifu/common/security/exception/GlobalExceptionHandler.java
View file @
c30637b5
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
common
.
security
.
exception
;
import
com.baomidou.lock.exception.LockFailureException
;
import
com.fasterxml.jackson.databind.exc.InvalidFormatException
;
import
com.yifu.cloud.plus.v1.yifu.common.core.exception.ValidateCodeException
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.Common
;
...
...
@@ -152,4 +153,17 @@ public class GlobalExceptionHandler {
log
.
error
(
"全局异常信息 触发用户:获取失败 ex={}"
,
exception
.
getMessage
(),
exception
);
}
}
/**
* 获取锁异常 lockException
*
* @param e
* @return R
*/
@ExceptionHandler
({
LockFailureException
.
class
})
@ResponseStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
)
public
R
lockFailExceptionHandler
(
Exception
e
)
{
errorLog
(
e
);
R
result
=
R
.
failed
(
"业务处理锁异常:"
+
e
.
getMessage
());
return
result
;
}
}
yifu-social/yifu-social-api/src/main/java/com/yifu/cloud/plus/v1/yifu/social/entity/TSocialFundInfo.java
View file @
c30637b5
...
...
@@ -292,7 +292,7 @@ public class TSocialFundInfo extends BaseEntity {
@ExcelProperty
(
"公积金派增状态"
)
private
String
fundAddStatus
;
/**
* 社保派
增
状态:0待审核、1待办理、2办理成功、3办理失败 4 审核不通过 5 办理中 6部分办理失败 202230231 派减分项办理逻辑 fxj
* 社保派
减
状态:0待审核、1待办理、2办理成功、3办理失败 4 审核不通过 5 办理中 6部分办理失败 202230231 派减分项办理逻辑 fxj
*/
@ExcelAttribute
(
name
=
"社保派减状态"
,
maxLength
=
1
)
@Schema
(
description
=
"社保派减状态:0待审核、1待办理、2办理成功、3办理失败 4 审核不通过 5 办理中 6 部分办理失败 "
)
...
...
yifu-social/yifu-social-biz/src/main/resources/logback-spring.xml
View file @
c30637b5
...
...
@@ -50,7 +50,7 @@
<!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
<root
level=
"
INFO
"
>
<root
level=
"
debug
"
>
<appender-ref
ref=
"console"
/>
<appender-ref
ref=
"debug"
/>
<appender-ref
ref=
"error"
/>
...
...
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