Commit d41bea82 authored by fangxinjiang's avatar fangxinjiang

批量办理 & 批量审核 分布式锁

parent 1a9dea92
......@@ -477,7 +477,30 @@ public class TDispatchInfoController {
@RequestParam(name = "auditStatus", required = true) String auditStatus,
@RequestParam(name = "auditRemark", required = false) String auditRemark,
@RequestParam(name = "remark", required = false) String remark) {
return tDispatchInfoService.addApplyAudit(idList,auditStatus,auditRemark,remark);
YifuUser user = SecurityUtils.getUser();
if (Common.isEmpty(user)){
return R.failed(CommonConstants.USER_FAIL);
}
// 获取redis分布式事务锁
String key = CacheConstants.DISPATCH_BATCH_AUDIT + CommonConstants.DOWN_LINE_STRING + user.getId();
String requestId;
try {
requestId = RedisDistributedLock.getLock(key,"10");
} catch (Exception e) {
throw new RuntimeException(ResultConstants.NO_GETLOCK_DATA+CommonConstants.DOWN_LINE_STRING+e.getMessage());
}
try {
if (Common.isNotNull(requestId)) {
//主动释放锁
return tDispatchInfoService.addApplyAudit(idList,auditStatus,auditRemark,remark);
} else {
return R.failed(ResultConstants.NO_GETLOCK_DATA);
}
}finally {
//主动释放锁
RedisDistributedLock.unlock(key, requestId);
}
}
/**
......@@ -501,7 +524,29 @@ public class TDispatchInfoController {
@RequestParam(name = "handleRemark", required = false) String handleRemark,
@RequestParam(name = "socialType", required = false) String socialType,
@RequestParam(name = "remark", required = false) String remark) {
return tDispatchInfoService.addApplyHandle(idList,typeSub,handleStatus,handleRemark,socialType,remark);
YifuUser user = SecurityUtils.getUser();
if (Common.isEmpty(user)){
return R.failed(CommonConstants.USER_FAIL);
}
// 获取redis分布式事务锁
String key = CacheConstants.DISPATCH_BATCH_HANDLED + CommonConstants.DOWN_LINE_STRING + user.getId();
String requestId;
try {
requestId = RedisDistributedLock.getLock(key,"10");
} catch (Exception e) {
throw new RuntimeException(ResultConstants.NO_GETLOCK_DATA+CommonConstants.DOWN_LINE_STRING+e.getMessage());
}
try {
if (Common.isNotNull(requestId)) {
//主动释放锁
return tDispatchInfoService.addApplyHandle(idList,typeSub,handleStatus,handleRemark,socialType,remark);
} else {
return R.failed(ResultConstants.NO_GETLOCK_DATA);
}
}finally {
//主动释放锁
RedisDistributedLock.unlock(key, requestId);
}
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment