Commit 9d9d66a5 by lixian7

分布式锁调整

parent af5cd4be
...@@ -61,6 +61,9 @@ public class BindInfoControlller extends BaseController { ...@@ -61,6 +61,9 @@ public class BindInfoControlller extends BaseController {
} catch ( DistributedLockException e ) { } catch ( DistributedLockException e ) {
log.error("分布式锁超时"); log.error("分布式锁超时");
return ResultGenerator.fail(ResultCode.REPEAT_SUBMIT); return ResultGenerator.fail(ResultCode.REPEAT_SUBMIT);
} catch ( Exception e ) {
log.error("系统异常:{}", e);
return ResultGenerator.fail(ResultCode.SYSTEM_ERROR);
} }
return response; return response;
} }
...@@ -77,7 +80,16 @@ public class BindInfoControlller extends BaseController { ...@@ -77,7 +80,16 @@ public class BindInfoControlller extends BaseController {
@PostMapping( "unbind" ) @PostMapping( "unbind" )
@BodyDecryptAnnotation @BodyDecryptAnnotation
public Result unbindInfo( @RequestBody @Validated UnBindReq req ) { public Result unbindInfo( @RequestBody @Validated UnBindReq req ) {
return service.unbindInfo(req); Result result = null;
try {
result = service.unbindInfo(req);
} catch ( DistributedLockException e ) {
return ResultGenerator.fail(ResultCode.REPEAT_SUBMIT);
} catch ( Exception e ) {
log.error("系统异常:{}", e);
return ResultGenerator.fail(ResultCode.SYSTEM_ERROR);
}
return result;
} }
/** /**
......
...@@ -176,13 +176,12 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i ...@@ -176,13 +176,12 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@DistributedLock(key = "'park:extend:lock:unbind:unqId:'+#req.unqId+':userId:'+#req.userId+':timestamp:'+#req" + @DistributedLock(key = "'park:extend:lock:unbind:unqId:'+#req.unqId+':userId:'+#req.userId+':timestamp:'+#req" +
".timestamp", expireTime = 3000, waitTime = 2000, retryTimes = 50) ".timestamp", isSpin = false)
public Result unbindInfo(UnBindReq req) { public Result unbindInfo(UnBindReq req) {
ParkBindInfo bindInfo = bindCache.getById(req.getUnqId()); ParkBindInfo bindInfo = bindCache.getById(req.getUnqId());
if (bindInfo == null || "0".equals(bindInfo.getStatus())) { if (bindInfo == null || "0".equals(bindInfo.getStatus())) {
return ResultGenerator.fail(ResultCode.BIND_INFO_UNKNOWN); return ResultGenerator.fail(ResultCode.BIND_INFO_UNKNOWN);
} }
if (!bindCache.unBind(req.getUnqId(), req.getUserId())) { if (!bindCache.unBind(req.getUnqId(), req.getUserId())) {
//手动回滚 //手动回滚
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
......
...@@ -23,12 +23,12 @@ public class Result<T> { ...@@ -23,12 +23,12 @@ public class Result<T> {
/** /**
* 状态码 * 状态码
*/ */
private long code; private long code = ResultCode.SUCCESS.getCode();
/** /**
* 描述 * 描述
*/ */
private String msg; private String msg = ResultCode.SUCCESS.getMsg();
/** /**
* 挂载数据 * 挂载数据
......
...@@ -25,8 +25,7 @@ public class ViolationCache { ...@@ -25,8 +25,7 @@ public class ViolationCache {
* @param req 号牌+号牌类型,时间开始-结束 * @param req 号牌+号牌类型,时间开始-结束
* @return * @return
*/ */
@Cacheable(value = "violations", key = "'plateNum:'+#req.plateNum+':plateType:'+#req.plateType+':timeStart:'+#req" + @Cacheable(value = "violations", key = "'plateNum:'+#req.plateNum+':plateType:'+#req.plateType", unless = "#result==null or #result.size()==0")
".timeStart.toString()+':timeEnd:'+#req.timeEnd.toString()", unless = "#result==null or #result.size()==0")
public List<ViolationMicRes> getByPlateNumAndType(ViolationListByTimeReq req) { public List<ViolationMicRes> getByPlateNumAndType(ViolationListByTimeReq req) {
return violatio.listByTime(req).getData(); return violatio.listByTime(req).getData();
} }
......
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