no message

main
HUOJIN\92525 2026-02-07 21:31:36 +08:00
parent ee6370447c
commit 25c53502b5
2 changed files with 26 additions and 25 deletions

View File

@ -8,19 +8,11 @@ import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.cpte.modules.base.entity.Stock;
import org.cpte.modules.constant.GeneralConstant;
import org.cpte.modules.receive.entity.Asn;
import org.cpte.modules.receive.entity.AsnDetail;
import org.cpte.modules.receive.service.processor.ReceiveBackProcessor;
import org.cpte.modules.serialNumber.PickSerialNumberRule;
import org.cpte.modules.shipping.entity.Task; import org.cpte.modules.shipping.entity.Task;
import org.cpte.modules.shipping.mapper.TaskMapper; import org.cpte.modules.shipping.mapper.TaskMapper;
import org.cpte.modules.shipping.service.ITaskService; import org.cpte.modules.shipping.service.ITaskService;
import org.cpte.modules.shipping.service.processor.PickBackProcessor; import org.cpte.modules.shipping.service.processor.PickBackProcessor;
import org.cpte.modules.shipping.service.processor.PickProcessor;
import org.cpte.modules.shipping.vo.PickData; import org.cpte.modules.shipping.vo.PickData;
import org.jeecg.common.system.query.QueryRuleEnum;
import org.jeecgframework.poi.excel.ExcelImportUtil; import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants; import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams; import org.jeecgframework.poi.excel.entity.ExportParams;

View File

@ -842,34 +842,43 @@ public class AllocateProcessor {
* @param createToTask * @param createToTask
* @param data * @param data
*/ */
private final Object taskCreationLock = new Object();
private void createPickTask(PickDetail pickDetail, Pick pick, Item item, private void createPickTask(PickDetail pickDetail, Pick pick, Item item,
Inventory inventory, InventoryScore inventoryScore, BigDecimal allocateQty, Inventory inventory, InventoryScore inventoryScore, BigDecimal allocateQty,
List<Task> createToTask, AllocationData data) { List<Task> createToTask, AllocationData data) {
synchronized (taskCreationLock) { String lockKey = "lock:createTask" + pickDetail.getId() + "_" + inventory.getId();
String lockValue = null;
try {
lockValue = redissonLock.tryLock(lockKey, 10);
if (StringUtils.isEmpty(lockValue)) {
return; // 直接返回,不重复创建
}
Stock stock = data.getStockMap().get(inventory.getStockId()); Stock stock = data.getStockMap().get(inventory.getStockId());
Point fromPoint = data.getPointMap().get(inventory.getPointId()); Point fromPoint = data.getPointMap().get(inventory.getPointId());
// 判断是否整托分配 // 判断是否整托分配
BigDecimal availableQty = BigDecimalUtil.subtract(inventory.getQuantity(), inventory.getQueuedQty(), 0); BigDecimal availableQty = BigDecimalUtil.subtract(inventory.getQuantity(), inventory.getQueuedQty(), 0);
Integer izAll = availableQty.compareTo(BigDecimal.ZERO) <= 0 ? 0 : 1; Integer izAll = availableQty.compareTo(BigDecimal.ZERO) <= 0 ? 0 : 1;
// 目标库位
//Point toPoint = inventoryScore.getOutPoint();
// 构建拣货任务 // 构建拣货任务
String taskNo = String.format("%s_%d", pick.getNo(), pickDetail.getLineNo()); String taskNo = String.format("%s_%d", pick.getNo(), pickDetail.getLineNo());
Task task = taskService.bulidTask( Task task = taskService.bulidTask(
taskNo, TaskTypeEnum.PICK.getValue(), item, fromPoint, null, taskNo, TaskTypeEnum.PICK.getValue(), item, fromPoint, null,
stock, pick.getId(), pickDetail.getId(), inventory.getItemKeyId(), inventory.getId(), stock, pick.getId(), pickDetail.getId(), inventory.getItemKeyId(), inventory.getId(),
allocateQty, izAll, null); allocateQty, izAll, null);
if (task != null) { if (task != null) {
boolean isDuplicate = createToTask.stream()
.anyMatch(t -> t.getPickDetailId().equals(pickDetail.getId())
&& t.getInventoryId().equals(inventory.getId()));
if (!isDuplicate) {
createToTask.add(task); createToTask.add(task);
log.info("生成拣货任务: {}- 容器:{} - 库位:{} - 类型:{}- 分配数量:{}", log.info("生成拣货任务: {}- 容器:{} - 库位:{} - 分配数量:{}",
task.getTaskNo(), stock.getStockCode(), task.getTaskNo(), stock.getStockCode(), fromPoint.getPointCode(), allocateQty);
fromPoint.getPointCode(), izAll, allocateQty); }
}
} catch (Exception e) {
log.error("生成拣货任务失败", e);
throw e;
} finally {
if (StringUtils.isNotEmpty(lockValue)) {
redissonLock.unlock(lockKey, lockValue);
} }
} }
} }
@ -928,8 +937,8 @@ public class AllocateProcessor {
if (CollectionUtils.isNotEmpty(movePoints)) { if (CollectionUtils.isNotEmpty(movePoints)) {
Set<Long> toPointIds = createToTask.stream().map(Task::getFromPointId).collect(Collectors.toSet()); Set<Long> toPointIds = createToTask.stream().map(Task::getFromPointId).collect(Collectors.toSet());
movePoints = movePoints.stream().filter(point -> !toPointIds.contains(point.getId())).toList(); movePoints = movePoints.stream().filter(point -> !toPointIds.contains(point.getId())).toList();
if(CollectionUtils.isNotEmpty(movePoints)){ if (CollectionUtils.isNotEmpty(movePoints)) {
List<Task> moveToTask = buildMoveTask(currOutPointCode, movePoints,processedStock); List<Task> moveToTask = buildMoveTask(currOutPointCode, movePoints, processedStock);
if (CollectionUtils.isNotEmpty(moveToTask)) { if (CollectionUtils.isNotEmpty(moveToTask)) {
createToTask.addAll(moveToTask); createToTask.addAll(moveToTask);
} }
@ -946,8 +955,8 @@ public class AllocateProcessor {
* @param movePoints * @param movePoints
* @return * @return
*/ */
public List<Task> buildMoveTask(String currOutPointCode, List<Point> movePoints,Set<Long> processedStock) { public List<Task> buildMoveTask(String currOutPointCode, List<Point> movePoints, Set<Long> processedStock) {
if(CollectionUtils.isEmpty(movePoints)){ if (CollectionUtils.isEmpty(movePoints)) {
return new ArrayList<>(); return new ArrayList<>();
} }
List<Task> moveList = new ArrayList<>(); List<Task> moveList = new ArrayList<>();