Commit 9d9d66a5 by lixian7

分布式锁调整

parent af5cd4be
......@@ -61,6 +61,9 @@ public class BindInfoControlller extends BaseController {
} catch ( DistributedLockException e ) {
log.error("分布式锁超时");
return ResultGenerator.fail(ResultCode.REPEAT_SUBMIT);
} catch ( Exception e ) {
log.error("系统异常:{}", e);
return ResultGenerator.fail(ResultCode.SYSTEM_ERROR);
}
return response;
}
......@@ -77,7 +80,16 @@ public class BindInfoControlller extends BaseController {
@PostMapping( "unbind" )
@BodyDecryptAnnotation
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
@Override
@Transactional(rollbackFor = Exception.class)
@DistributedLock(key = "'park:extend:lock:unbind:unqId:'+#req.unqId+':userId:'+#req.userId+':timestamp:'+#req" +
".timestamp", expireTime = 3000, waitTime = 2000, retryTimes = 50)
public Result unbindInfo(UnBindReq req) {
".timestamp", isSpin = false)
public Result unbindInfo(UnBindReq req) {
ParkBindInfo bindInfo = bindCache.getById(req.getUnqId());
if (bindInfo == null || "0".equals(bindInfo.getStatus())) {
return ResultGenerator.fail(ResultCode.BIND_INFO_UNKNOWN);
}
if (!bindCache.unBind(req.getUnqId(), req.getUserId())) {
//手动回滚
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
......
......@@ -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 {
* @param req 号牌+号牌类型,时间开始-结束
* @return
*/
@Cacheable(value = "violations", key = "'plateNum:'+#req.plateNum+':plateType:'+#req.plateType+':timeStart:'+#req" +
".timeStart.toString()+':timeEnd:'+#req.timeEnd.toString()", unless = "#result==null or #result.size()==0")
@Cacheable(value = "violations", key = "'plateNum:'+#req.plateNum+':plateType:'+#req.plateType", unless = "#result==null or #result.size()==0")
public List<ViolationMicRes> getByPlateNumAndType(ViolationListByTimeReq req) {
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