fix: 锁细粒度扩大
This commit is contained in:
@@ -285,12 +285,17 @@ public class SlitterServiceImpl implements SlitterService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public JSONObject acsFinishLoadShaft(JSONObject param) {
|
||||
log.info("ACS申请套管完成参数: {}", param);
|
||||
String msg = "";
|
||||
JSONObject res = new JSONObject();
|
||||
// 穿拔轴位
|
||||
String deviceCode = param.getString("device_code");
|
||||
List<String> stepTipLogs = getRedisListValue("ERROR" + deviceCode);
|
||||
// 枷锁
|
||||
RLock lock = redissonClient.getLock("doAcsFinishLoadShaft");
|
||||
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
|
||||
try {
|
||||
if (tryLock) {
|
||||
log.info("ACS申请套管完成参数: {}", param);
|
||||
// 纸管
|
||||
String weight1 = param.getString("weight1");
|
||||
String material1 = param.getString("material1");
|
||||
@@ -329,12 +334,6 @@ public class SlitterServiceImpl implements SlitterService {
|
||||
List<BstIvtCutpointivt> exceptionPoints = bcutpointivtService.getAreaNotTaskPointByStatus("1", "1", "0", "0");
|
||||
if (exceptionPoints.size() > 0) {
|
||||
BstIvtCutpointivt exceptionPoint = exceptionPoints.get(0);
|
||||
// 枷锁
|
||||
RLock lockPointR = redissonClient.getLock(exceptionPoint.getPoint_code());
|
||||
boolean tryLockPointR = lockPointR.tryLock(0, TimeUnit.SECONDS);
|
||||
try {
|
||||
if (tryLockPointR) {
|
||||
// 需要枷锁
|
||||
JSONObject exParam = new JSONObject();
|
||||
exParam.put("point_code1", startPoint.getPoint_code());
|
||||
exParam.put("point_code2", ObjectUtil.isEmpty(exceptionPoint.getQzz_no1())
|
||||
@@ -351,14 +350,6 @@ public class SlitterServiceImpl implements SlitterService {
|
||||
res.put("status", HttpStatus.HTTP_OK);
|
||||
res.put("message", "创建送至异常处理位!");
|
||||
return res;
|
||||
} else {
|
||||
throw new BadRequestException("系统繁忙,稍后在试!");
|
||||
}
|
||||
} finally {
|
||||
if (tryLockPointR) {
|
||||
lockPointR.unlock();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
stepTipLogs.add("套轴完成->[" + collect + "]对应的分切计划状态已更改,无暂存位置,创建任务失败!");
|
||||
redisUtils.set("ERROR" + deviceCode, stepTipLogs);
|
||||
@@ -375,7 +366,6 @@ public class SlitterServiceImpl implements SlitterService {
|
||||
res.put("message", "请求成功");
|
||||
res.put("msg", msg);
|
||||
return res;
|
||||
// throw new BadRequestException("[" + collect + "]对应的分切计划状态已更改,无暂存位置!");
|
||||
}
|
||||
}
|
||||
// 分切计划设置纸卷重量
|
||||
@@ -442,11 +432,6 @@ public class SlitterServiceImpl implements SlitterService {
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(cutPoint)) {
|
||||
// 枷锁
|
||||
RLock lockPoint = redissonClient.getLock(cutPoint.getPoint_code());
|
||||
boolean tryLockPoint = lockPoint.tryLock(0, TimeUnit.SECONDS);
|
||||
try {
|
||||
if (tryLockPoint) {
|
||||
// 创建任务
|
||||
JSONObject taskParam = new JSONObject();
|
||||
taskParam.put("point_code1", startPoint.getPoint_code());
|
||||
@@ -458,18 +443,17 @@ public class SlitterServiceImpl implements SlitterService {
|
||||
taskParam.put("product_area", SlitterConstant.SLITTER_TASK_AREA);
|
||||
taskParam.put("immediateNotifyAcs", "1");
|
||||
trussSendAirShaftTask.createTask(taskParam);
|
||||
}
|
||||
} else {
|
||||
stepTipLogs.add("套轴完成->系统繁忙,稍后在试!");
|
||||
redisUtils.set("ERROR" + deviceCode, stepTipLogs);
|
||||
throw new BadRequestException("系统繁忙,稍后在试!");
|
||||
}
|
||||
} finally {
|
||||
if (tryLockPoint) {
|
||||
lockPoint.unlock();
|
||||
if (tryLock) {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res.put("status", HttpStatus.HTTP_OK);
|
||||
res.put("message", "请求成功");
|
||||
res.put("msg", msg);
|
||||
|
||||
Reference in New Issue
Block a user