fix:全部分配加上并发锁
This commit is contained in:
@@ -3,6 +3,7 @@ package org.nl.wms.st.outbill.rest;
|
|||||||
import cn.dev33.satoken.annotation.SaIgnore;
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.b_lms.storage_manage.ios.enums.IOSEnum;
|
import org.nl.b_lms.storage_manage.ios.enums.IOSEnum;
|
||||||
import org.nl.b_lms.storage_manage.ios.service.iostorInv.IStIvtIostorinvOutService;
|
import org.nl.b_lms.storage_manage.ios.service.iostorInv.IStIvtIostorinvOutService;
|
||||||
@@ -12,9 +13,12 @@ import org.nl.b_lms.storage_manage.ios.service.iostorInv.util.service.InBussMana
|
|||||||
import org.nl.b_lms.storage_manage.ios.service.iostorInv.util.service.LashManageService;
|
import org.nl.b_lms.storage_manage.ios.service.iostorInv.util.service.LashManageService;
|
||||||
import org.nl.b_lms.storage_manage.ios.service.iostorInv.util.service.OutBoxManageService;
|
import org.nl.b_lms.storage_manage.ios.service.iostorInv.util.service.OutBoxManageService;
|
||||||
import org.nl.common.utils.RedissonUtils;
|
import org.nl.common.utils.RedissonUtils;
|
||||||
|
import org.nl.modules.common.exception.BadRequestException;
|
||||||
import org.nl.modules.logging.annotation.Log;
|
import org.nl.modules.logging.annotation.Log;
|
||||||
import org.nl.modules.wql.util.SpringContextHolder;
|
import org.nl.modules.wql.util.SpringContextHolder;
|
||||||
import org.nl.wms.st.inbill.service.CheckOutBillService;
|
import org.nl.wms.st.inbill.service.CheckOutBillService;
|
||||||
|
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.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
@@ -26,6 +30,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@@ -52,6 +57,9 @@ public class CheckOutBillController {
|
|||||||
|
|
||||||
private final OutBoxManageService outBoxManageService;
|
private final OutBoxManageService outBoxManageService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedissonClient redissonClient;
|
||||||
|
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@Log("查询出库单")
|
@Log("查询出库单")
|
||||||
@@ -114,12 +122,25 @@ public class CheckOutBillController {
|
|||||||
|
|
||||||
@PostMapping("/allDiv")
|
@PostMapping("/allDiv")
|
||||||
@Log("出库单全部分配")
|
@Log("出库单全部分配")
|
||||||
|
@SneakyThrows
|
||||||
public ResponseEntity<Object> allDiv(@RequestBody JSONObject whereJson) {
|
public ResponseEntity<Object> allDiv(@RequestBody JSONObject whereJson) {
|
||||||
if (whereJson.getString("stor_id").equals(IOSEnum.STOR_ID.code("二期"))) {
|
String iostorinv_id = whereJson.getString("iostorinv_id");
|
||||||
iStIvtIostorinvOutService.allDiv(whereJson);
|
RLock lock = redissonClient.getLock("allDiv----"+iostorinv_id);
|
||||||
} else {
|
boolean tryLock = lock.tryLock(0, 60, TimeUnit.SECONDS);
|
||||||
checkOutBillService.allDiv(whereJson);
|
try {
|
||||||
|
if (tryLock) {
|
||||||
|
if (whereJson.getString("stor_id").equals(IOSEnum.STOR_ID.code("二期"))) {
|
||||||
|
iStIvtIostorinvOutService.allDiv(whereJson);
|
||||||
|
} else {
|
||||||
|
checkOutBillService.allDiv(whereJson);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new BadRequestException("当前出库单当前正在分配库存中,请勿重复操作!");
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (lock.isLocked() && lock.isHeldByCurrentThread()) {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
@@ -211,13 +232,13 @@ public class CheckOutBillController {
|
|||||||
@Log("一键设置")
|
@Log("一键设置")
|
||||||
|
|
||||||
public ResponseEntity<Object> allSetPoint(@RequestBody JSONObject whereJson) {
|
public ResponseEntity<Object> allSetPoint(@RequestBody JSONObject whereJson) {
|
||||||
RedissonUtils.lock(c->{
|
RedissonUtils.lock(c -> {
|
||||||
if (whereJson.getString("stor_id").equals(IOSEnum.STOR_ID.code("二期"))) {
|
if (whereJson.getString("stor_id").equals(IOSEnum.STOR_ID.code("二期"))) {
|
||||||
iStIvtIostorinvOutService.allSetPoint2(whereJson);
|
iStIvtIostorinvOutService.allSetPoint2(whereJson);
|
||||||
} else {
|
} else {
|
||||||
checkOutBillService.allSetPointByNoTran(whereJson);
|
checkOutBillService.allSetPointByNoTran(whereJson);
|
||||||
}
|
}
|
||||||
},"出库一键设置",1,120,null);
|
}, "出库一键设置", 1, 120, null);
|
||||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,7 +396,7 @@ public class CheckOutBillController {
|
|||||||
@PostMapping("/updataIsOverdue")
|
@PostMapping("/updataIsOverdue")
|
||||||
@Log("更新是否超期")
|
@Log("更新是否超期")
|
||||||
public ResponseEntity<Object> updataIsOverdue(@RequestBody JSONObject whereJson) {
|
public ResponseEntity<Object> updataIsOverdue(@RequestBody JSONObject whereJson) {
|
||||||
return new ResponseEntity<>(checkOutBillService.updataIsOverdue(whereJson),HttpStatus.OK);
|
return new ResponseEntity<>(checkOutBillService.updataIsOverdue(whereJson), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/importExcel")
|
@PostMapping("/importExcel")
|
||||||
|
|||||||
Reference in New Issue
Block a user