Merge remote-tracking branch 'origin/master_merge' into master_merge

This commit is contained in:
zhouz
2025-10-13 09:50:16 +08:00

View File

@@ -4,12 +4,17 @@ import cn.dev33.satoken.annotation.SaIgnore;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.b_lms.sch.tasks.slitter.service.SlitterService; 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.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.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.concurrent.TimeUnit;
/** /**
* @Author: lyd * @Author: lyd
* @Description: * @Description:
@@ -22,6 +27,8 @@ public class SlitterPdaController {
@Autowired @Autowired
private SlitterService slitterService; private SlitterService slitterService;
@Autowired
private RedissonClient redissonClient;
@PostMapping("/slitterDevices") @PostMapping("/slitterDevices")
@Log("获取分切设备") @Log("获取分切设备")
@@ -41,7 +48,26 @@ public class SlitterPdaController {
@Log("下卷2") @Log("下卷2")
@SaIgnore @SaIgnore
public ResponseEntity<Object> downRolls2(@RequestBody JSONObject param) { 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") @PostMapping("/downRollsCheck")
@Log("下卷2提示确认") @Log("下卷2提示确认")