Merge remote-tracking branch 'origin/master_merge' into master_merge
This commit is contained in:
@@ -4,12 +4,17 @@ import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.b_lms.sch.tasks.slitter.service.SlitterService;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.logging.annotation.Log;
|
||||
import org.redisson.api.RLock;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description:
|
||||
@@ -22,6 +27,8 @@ public class SlitterPdaController {
|
||||
|
||||
@Autowired
|
||||
private SlitterService slitterService;
|
||||
@Autowired
|
||||
private RedissonClient redissonClient;
|
||||
|
||||
@PostMapping("/slitterDevices")
|
||||
@Log("获取分切设备")
|
||||
@@ -41,7 +48,26 @@ public class SlitterPdaController {
|
||||
@Log("下卷2")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> downRolls2(@RequestBody JSONObject param) {
|
||||
return new ResponseEntity<>(slitterService.downRolls2(param), HttpStatus.OK);
|
||||
RLock open = redissonClient.getLock("doDownRoll");
|
||||
JSONObject res;
|
||||
boolean openLock;
|
||||
try {
|
||||
openLock = open.tryLock(0, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try {
|
||||
if (openLock) {
|
||||
res = slitterService.downRolls2(param);
|
||||
} else {
|
||||
throw new BadRequestException("请勿多次下卷!");
|
||||
}
|
||||
} finally {
|
||||
if (open.isLocked() && open.isHeldByCurrentThread()) {
|
||||
open.unlock();
|
||||
}
|
||||
}
|
||||
return new ResponseEntity<>(res, HttpStatus.OK);
|
||||
}
|
||||
@PostMapping("/downRollsCheck")
|
||||
@Log("下卷2提示确认")
|
||||
|
||||
Reference in New Issue
Block a user