Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
O
OZT-Integration
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
许俊
OZT-Integration
Commits
3e61ad32
提交
3e61ad32
authored
12月 21, 2021
作者:
许俊
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化
上级
0e5727e6
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
123 行增加
和
20 行删除
+123
-20
AutoLogAspect.java
.../src/main/java/org/jeecg/common/aspect/AutoLogAspect.java
+3
-1
NotCommitRedisLockAspect.java
...va/org/jeecg/modules/aspect/NotCommitRedisLockAspect.java
+96
-0
NotCommitRedisLock.java
...g/jeecg/modules/aspect/annotation/NotCommitRedisLock.java
+21
-0
WebApi.java
...in/java/org/jeecg/modules/iost/ims/controller/WebApi.java
+3
-19
没有找到文件。
jeecg-boot-base-common/src/main/java/org/jeecg/common/aspect/AutoLogAspect.java
浏览文件 @
3e61ad32
...
...
@@ -24,6 +24,7 @@ import org.jeecg.common.util.IPUtils;
import
org.jeecg.common.util.SpringContextUtils
;
import
org.jeecg.common.util.oConvertUtils
;
import
org.springframework.core.LocalVariableTableParameterNameDiscoverer
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
...
...
@@ -46,6 +47,7 @@ import java.util.Map;
@Aspect
@Component
@Data
@Order
(
1
)
public
class
AutoLogAspect
{
@Resource
...
...
@@ -69,7 +71,7 @@ public class AutoLogAspect {
//保存日志
saveSysLog
(
point
,
time
,
result
);
ThreadLocalConfig
.
remove
();
return
result
;
}
...
...
jeecg-boot-module-system/src/main/java/org/jeecg/modules/aspect/NotCommitRedisLockAspect.java
0 → 100644
浏览文件 @
3e61ad32
package
org
.
jeecg
.
modules
.
aspect
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.serializer.PropertyFilter
;
import
lombok.Data
;
import
org.apache.shiro.SecurityUtils
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.AfterThrowing
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.aspectj.lang.reflect.MethodSignature
;
import
org.jeecg.common.api.dto.LogDTO
;
import
org.jeecg.common.api.vo.Result
;
import
org.jeecg.common.aspect.annotation.AutoLog
;
import
org.jeecg.common.constant.CommonConstant
;
import
org.jeecg.common.constant.enums.ModuleType
;
import
org.jeecg.common.exception.*
;
import
org.jeecg.common.util.*
;
import
org.jeecg.modules.base.service.BaseCommonService
;
import
org.jeecg.common.system.vo.LoginUser
;
import
org.jeecg.modules.iost.ims.entity.ImsPurchaseOrder
;
import
org.jeecg.modules.iost.ims.entity.Vo.ImsRequestVo
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.LocalVariableTableParameterNameDiscoverer
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
javax.servlet.ServletRequest
;
import
javax.servlet.ServletResponse
;
import
javax.servlet.http.HttpServletRequest
;
import
java.lang.reflect.Method
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* 防止短时间内并发提交或者重复提交
*
* @Author scott
* @email jeecgos@163.com
* @Date 2018年1月14日
*/
@Aspect
@Component
@Data
@Order
(
2
)
public
class
NotCommitRedisLockAspect
{
@Resource
private
BaseCommonService
baseCommonService
;
@Pointcut
(
"@annotation(org.jeecg.modules.aspect.annotation.NotCommitRedisLock)"
)
public
void
logPointCut
()
{
}
@Autowired
RedisLock
redisLock
;
@Around
(
"logPointCut()"
)
public
Object
around
(
ProceedingJoinPoint
point
)
throws
Throwable
{
Object
result
=
null
;
Object
[]
args
=
point
.
getArgs
();
for
(
Object
arg
:
args
)
{
if
(
arg
instanceof
ImsRequestVo
)
{
ImsRequestVo
request
=
(
ImsRequestVo
)
arg
;
System
.
out
.
println
(
"test-----"
+
request
);
String
token
=
redisLock
.
tryLock
(
request
.
getDocType
()+
request
.
getData
().
get
(
0
).
get
(
"QUEUE_ID"
).
toString
(),
1000
*
60
*
2
);
if
(
token
==
null
)
{
return
Result
.
fail
(
"操作失败"
,
"请勿提交相同数据!"
,
request
.
getDocType
());
}
Map
<
String
,
String
>
map
=
ThreadLocalConfig
.
get
();
if
(
map
==
null
)
{
map
=
new
HashMap
<>();
}
map
.
put
(
"key"
,
request
.
getDocType
()+
request
.
getData
().
get
(
0
).
get
(
"QUEUE_ID"
).
toString
());
map
.
put
(
"token"
,
token
);
ThreadLocalConfig
.
set
(
map
);
try
{
//执行方法
result
=
point
.
proceed
();
}
finally
{
redisLock
.
unlock
(
request
.
getDocType
()+
request
.
getData
().
get
(
0
).
get
(
"QUEUE_ID"
).
toString
(),
token
);
}
}
}
return
result
;
}
}
jeecg-boot-module-system/src/main/java/org/jeecg/modules/aspect/annotation/NotCommitRedisLock.java
0 → 100644
浏览文件 @
3e61ad32
package
org
.
jeecg
.
modules
.
aspect
.
annotation
;
import
org.jeecg.common.constant.CommonConstant
;
import
org.jeecg.common.constant.enums.ModuleType
;
import
java.lang.annotation.*
;
/**
* 防止短时间内并发提交或者重复提交
*
* @Author
* @email
* @Date 2021年12月21日
*/
@Target
(
ElementType
.
METHOD
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
public
@interface
NotCommitRedisLock
{
}
jeecg-boot-module-system/src/main/java/org/jeecg/modules/iost/ims/controller/WebApi.java
浏览文件 @
3e61ad32
...
...
@@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.jeecg.common.api.vo.Result
;
import
org.jeecg.common.aspect.annotation.AutoLog
;
import
org.jeecg.common.util.RedisLock
;
import
org.jeecg.modules.aspect.annotation.NotCommitRedisLock
;
import
org.jeecg.modules.base.service.BaseCommonService
;
import
org.jeecg.modules.iost.ims.Dao.CategoryDao
;
import
org.jeecg.common.exception.ConnectConstant.KingDeeConstant
;
...
...
@@ -30,7 +31,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.*
;
import
java.text.ParseException
;
import
java.util.*
;
...
...
@@ -126,22 +126,9 @@ public class WebApi {
@AutoLog
(
value
=
"第三方通用接口-updateThirdData"
)
@ApiOperation
(
value
=
"第三方通用接口-updateThirdData"
,
notes
=
"第三方通用接口-updateThirdData"
)
@PostMapping
(
value
=
"/updateThirdData"
)
@NotCommitRedisLock
public
Result
<?>
updateData
(
@RequestBody
ImsRequestVo
request
)
throws
ParseException
{
String
token
=
redisLock
.
tryLock
(
request
.
getDocType
()+
request
.
getData
().
get
(
0
).
get
(
"QUEUE_ID"
).
toString
(),
1000
*
60
*
2
);
if
(
token
==
null
)
{
return
Result
.
fail
(
"操作失败"
,
"请勿提交相同数据!"
,
request
.
getDocType
());
}
Map
<
String
,
String
>
map
=
ThreadLocalConfig
.
get
();
if
(
map
==
null
)
{
map
=
new
HashMap
<>();
}
map
.
put
(
"key"
,
request
.
getDocType
()+
request
.
getData
().
get
(
0
).
get
(
"QUEUE_ID"
).
toString
());
map
.
put
(
"token"
,
token
);
ThreadLocalConfig
.
set
(
map
);
String
result
=
new
String
();
try
{
//根据doctype调用不同的业务service
if
(
request
.
getDocType
().
equals
(
"BS0001"
))
//采购订单收料
{
...
...
@@ -188,11 +175,8 @@ public class WebApi {
result
=
result
.
replace
(
"\t"
,
""
);
result
=
result
.
replace
(
"\r"
,
""
);
result
=
result
.
replace
(
" "
,
""
);
ThreadLocalConfig
.
remove
();
return
Result
.
OK
(
result
,
request
.
getDocType
());
}
finally
{
redisLock
.
unlock
(
request
.
getDocType
()+
request
.
getData
().
get
(
0
).
get
(
"QUEUE_ID"
).
toString
(),
token
);
}
}
/*List<Map<String,Object>>转换Map<String,Object>*/
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论