no message
parent
fc6417acd2
commit
01b476b84b
|
|
@ -116,9 +116,7 @@ public class BatchProcessor {
|
|||
* 批量处理分配操作
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean batchAllocate(Map<Long, Inventory> inventoryUpdateMap, Map<Long, PickDetail> pickDetailUpdateMap, List<Task> createToTask) {
|
||||
List<Inventory> updateToInventory = new ArrayList<>(inventoryUpdateMap.values());
|
||||
List<PickDetail> updateToPickDetail = new ArrayList<>(pickDetailUpdateMap.values());
|
||||
public boolean batchAllocate(List<Inventory> updateToInventory, List<PickDetail> updateToPickDetail, List<Task> createToTask) {
|
||||
if (CollectionUtils.isNotEmpty(updateToInventory)) {
|
||||
batchUtil.updateBatchInventory(updateToInventory);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,14 +78,16 @@ public class IConveyorLineServiceImpl implements IConveyorLineService {
|
|||
public void updateResMessageAsn(ScanTrayRequest scanTrayRequest) {
|
||||
ScanTrayData data = scanTrayProcessor.prepareScanTrayData(scanTrayRequest);
|
||||
Asn asn = data.getAsn();
|
||||
if (asn != null) {
|
||||
if (asn.getResMessage().equals("检测成功")) {
|
||||
if (asn == null) {
|
||||
return;
|
||||
}
|
||||
if ("检测成功".equals(asn.getResMessage())) {
|
||||
return;
|
||||
}
|
||||
|
||||
asn.setResMessage(scanTrayRequest.getContent().getSignal().getErrorReason().toString());
|
||||
asnMapper.updateById(asn);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject showConveyorLine(String conveyorLine) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import org.cpte.modules.conveyorLine.service.processor.ScanTrayProcessor;
|
|||
import org.cpte.modules.conveyorLine.vo.Station;
|
||||
import org.cpte.modules.inventory.entity.Inventory;
|
||||
import org.cpte.modules.inventory.mapper.InventoryMapper;
|
||||
import org.cpte.modules.inventoryLog.service.IInventoryLogService;
|
||||
import org.cpte.modules.serialNumber.MoveSerialNumberRule;
|
||||
import org.cpte.modules.shipping.entity.Pick;
|
||||
import org.cpte.modules.shipping.entity.PickDetail;
|
||||
|
|
@ -81,9 +80,6 @@ public class AllocateProcessor {
|
|||
@Autowired
|
||||
private ITaskService taskService;
|
||||
|
||||
@Autowired
|
||||
private IInventoryLogService inventoryLogService;
|
||||
|
||||
@Autowired
|
||||
private BaseCommonService baseCommonService;
|
||||
|
||||
|
|
@ -125,19 +121,19 @@ public class AllocateProcessor {
|
|||
}
|
||||
|
||||
//3.创建数据结构
|
||||
Map<Long, Inventory> inventoryUpdateMap = new HashMap<>();
|
||||
Map<Long, PickDetail> pickDetailUpdateMap = new HashMap<>();
|
||||
List<Inventory> updateToInventory = new ArrayList<>();
|
||||
List<PickDetail> updateToPickDetail = new ArrayList<>();
|
||||
List<Task> createToTask = new ArrayList<>();
|
||||
List<Point> movePoints = new ArrayList<>();
|
||||
|
||||
//4.分配
|
||||
allocate(data, inventoryUpdateMap, pickDetailUpdateMap, createToTask, movePoints, errorMsgSet);
|
||||
allocate(data, updateToInventory, updateToPickDetail, createToTask, movePoints, errorMsgSet);
|
||||
|
||||
//5.生成移位任务
|
||||
moveTask(createToTask, movePoints);
|
||||
|
||||
//6.批量操作
|
||||
batchProcessor.batchAllocate(inventoryUpdateMap, pickDetailUpdateMap, createToTask);
|
||||
batchProcessor.batchAllocate(updateToInventory, updateToPickDetail, createToTask);
|
||||
|
||||
//7.刷新出库单
|
||||
refreshData(data);
|
||||
|
|
@ -164,19 +160,19 @@ public class AllocateProcessor {
|
|||
}
|
||||
|
||||
//3.创建数据结构
|
||||
Map<Long, Inventory> inventoryUpdateMap = new HashMap<>();
|
||||
Map<Long, PickDetail> pickDetailUpdateMap = new HashMap<>();
|
||||
List<Inventory> updateToInventory = new ArrayList<>();
|
||||
List<PickDetail> updateToPickDetail = new ArrayList<>();
|
||||
List<Task> createToTask = new ArrayList<>();
|
||||
List<Point> movePoints = new ArrayList<>();
|
||||
|
||||
//4.分配
|
||||
allocate(data, inventoryUpdateMap, pickDetailUpdateMap, createToTask, movePoints, errorMsgSet);
|
||||
allocate(data, updateToInventory, updateToPickDetail, createToTask, movePoints, errorMsgSet);
|
||||
|
||||
//5.生成移位任务
|
||||
moveTask(createToTask, movePoints);
|
||||
|
||||
//6.批量操作
|
||||
boolean result = batchProcessor.batchAllocate(inventoryUpdateMap, pickDetailUpdateMap, createToTask);
|
||||
boolean result = batchProcessor.batchAllocate(updateToInventory, updateToPickDetail, createToTask);
|
||||
|
||||
//7.刷新出库单
|
||||
refreshData(data);
|
||||
|
|
@ -395,10 +391,10 @@ public class AllocateProcessor {
|
|||
/**
|
||||
* 分配
|
||||
*/
|
||||
private void allocate(AllocationData data, Map<Long, Inventory> inventoryUpdateMap, Map<Long, PickDetail> pickDetailUpdateMap, List<Task> createToTask, List<Point> movePoints, Set<String> errorMsgSet) {
|
||||
private void allocate(AllocationData data, List<Inventory> updateToInventory, List<PickDetail> updateToPickDetail, List<Task> createToTask, List<Point> movePoints, Set<String> errorMsgSet) {
|
||||
for (PickDetail pickDetail : data.getPickDetails()) {
|
||||
try {
|
||||
allocatePickDetail(pickDetail, data, errorMsgSet, inventoryUpdateMap, pickDetailUpdateMap, createToTask, movePoints);
|
||||
allocatePickDetail(pickDetail, data, errorMsgSet, updateToInventory, updateToPickDetail, createToTask, movePoints);
|
||||
} catch (Exception e) {
|
||||
errorMsgSet.add(String.format("分配异常,明细ID:%s,原因:%s",
|
||||
pickDetail.getId(), e.getMessage()));
|
||||
|
|
@ -412,13 +408,13 @@ public class AllocateProcessor {
|
|||
* @param pickDetail 出库明细
|
||||
* @param data 数据
|
||||
* @param errorMsgSet 错误信息
|
||||
* @param inventoryUpdateMap 更新库存
|
||||
* @param pickDetailUpdateMap 更新出库明细
|
||||
* @param updateToInventory 更新库存
|
||||
* @param updateToPickDetail 更新出库明细
|
||||
* @param createToTask 创建任务
|
||||
*/
|
||||
private void allocatePickDetail(PickDetail pickDetail, AllocationData data,
|
||||
Set<String> errorMsgSet, Map<Long, Inventory> inventoryUpdateMap,
|
||||
Map<Long, PickDetail> pickDetailUpdateMap, List<Task> createToTask, List<Point> movePoints) {
|
||||
Set<String> errorMsgSet, List<Inventory> updateToInventory,
|
||||
List<PickDetail> updateToPickDetail, List<Task> createToTask, List<Point> movePoints) {
|
||||
|
||||
Pick pick = data.getPickMap().get(pickDetail.getPickId());
|
||||
Item item = data.getItemMap().get(pickDetail.getItemId());
|
||||
|
|
@ -435,14 +431,14 @@ public class AllocateProcessor {
|
|||
}
|
||||
|
||||
// 分配库存
|
||||
String lockKey = "allocate:" + pick.getId();
|
||||
String lockKey = "allocate:" + pickDetail.getId();
|
||||
String lockValue = null;
|
||||
try {
|
||||
lockValue = redissonLock.tryLock(lockKey, 10);
|
||||
if (StringUtils.isEmpty(lockValue)) {
|
||||
throw new RuntimeException("分配处理中,请稍后重试");
|
||||
}
|
||||
allocateInventory(pickDetail, item, pick, matchedInventories, inventoryUpdateMap, pickDetailUpdateMap,
|
||||
allocateInventory(pickDetail, item, pick, matchedInventories, updateToInventory, updateToPickDetail,
|
||||
createToTask, movePoints, data, unAllocatedQty, errorMsgSet);
|
||||
} catch (Exception e) {
|
||||
log.error("分配异常,出库单ID: {}", pick.getId(), e);
|
||||
|
|
@ -510,15 +506,15 @@ public class AllocateProcessor {
|
|||
* @param item 物料
|
||||
* @param pick 拣货单
|
||||
* @param matchedInventories 匹配库存
|
||||
* @param inventoryUpdateMap 更新库存
|
||||
* @param pickDetailUpdateMap 更新出库明细
|
||||
* @param updateToInventory 更新库存
|
||||
* @param updateToPickDetail 更新出库明细
|
||||
* @param createToTask 创建任务
|
||||
* @param data 数据
|
||||
* @param totalUnAllocatedQty 未分配数量
|
||||
*/
|
||||
private void allocateInventory(PickDetail pickDetail, Item item, Pick pick,
|
||||
List<Inventory> matchedInventories, Map<Long, Inventory> inventoryUpdateMap,
|
||||
Map<Long, PickDetail> pickDetailUpdateMap, List<Task> createToTask, List<Point> movePoints,
|
||||
List<Inventory> matchedInventories, List<Inventory> updateToInventory,
|
||||
List<PickDetail> updateToPickDetail, List<Task> createToTask, List<Point> movePoints,
|
||||
AllocationData data, BigDecimal totalUnAllocatedQty, Set<String> errorMsgSet) {
|
||||
|
||||
// 智能排序库存
|
||||
|
|
@ -556,9 +552,9 @@ public class AllocateProcessor {
|
|||
//本次分配数量(取最小值)
|
||||
BigDecimal allocateQty = remainingQty.min(availableQty);
|
||||
// 更新库存
|
||||
updateInventoryAllocation(inventory, allocateQty, inventoryUpdateMap);
|
||||
updateInventoryAllocation(inventory, allocateQty, updateToInventory);
|
||||
// 更新拣货明细
|
||||
updatePickDetailAllocation(pickDetail, allocateQty, pickDetailUpdateMap);
|
||||
updatePickDetailAllocation(pickDetail, allocateQty, updateToPickDetail);
|
||||
// 创建任务
|
||||
createPickTask(pickDetail, pick, item, inventory, inventoryScore, allocateQty, createToTask, data);
|
||||
// 获取需要移位的库位
|
||||
|
|
@ -769,15 +765,16 @@ public class AllocateProcessor {
|
|||
*
|
||||
* @param inventory 库存
|
||||
* @param allocateQty 分配数量
|
||||
* @param inventoryUpdateMap 库更新集合
|
||||
* @param updateToInventory 库更新集合
|
||||
*/
|
||||
private void updateInventoryAllocation(Inventory inventory, BigDecimal allocateQty,
|
||||
Map<Long, Inventory> inventoryUpdateMap) {
|
||||
Inventory targetInventory = inventoryUpdateMap.getOrDefault(inventory.getId(), inventory);
|
||||
BigDecimal newQueuedQty = BigDecimalUtil.add(targetInventory.getQueuedQty(), allocateQty, 0);
|
||||
targetInventory.setQueuedQty(newQueuedQty);
|
||||
targetInventory.setStatus(InventoryStatusEnum.ALLOCATED.getValue());
|
||||
inventoryUpdateMap.put(targetInventory.getId(), targetInventory);
|
||||
List<Inventory> updateToInventory) {
|
||||
BigDecimal quantity = BigDecimalUtil.add(inventory.getQuantity(), allocateQty, 0);
|
||||
BigDecimal queuedQty = BigDecimalUtil.add(inventory.getQueuedQty(), allocateQty, 0);
|
||||
inventory.setQuantity(quantity);
|
||||
inventory.setQueuedQty(queuedQty);
|
||||
inventory.setStatus(InventoryStatusEnum.ALLOCATED.getValue());
|
||||
updateToInventory.add(inventory);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -785,50 +782,48 @@ public class AllocateProcessor {
|
|||
*
|
||||
* @param pickDetail 出库明细
|
||||
* @param allocateQty 分配数量
|
||||
* @param pickDetailUpdateMap 拣货明细更新集合
|
||||
* @param updateToPickDetail 拣货明细更新集合
|
||||
*/
|
||||
private void updatePickDetailAllocation(PickDetail pickDetail, BigDecimal allocateQty,
|
||||
Map<Long, PickDetail> pickDetailUpdateMap) {
|
||||
PickDetail targetPickDetail = pickDetailUpdateMap.getOrDefault(pickDetail.getId(), pickDetail);
|
||||
BigDecimal newAllocatedQty = BigDecimalUtil.add(targetPickDetail.getAllocatedQty(), allocateQty, 0);
|
||||
Integer status = newAllocatedQty.compareTo(targetPickDetail.getOrderQty()) >= 0 ?
|
||||
PickStatusEnum.ASSIGNED.getValue() : PickStatusEnum.PARTIAL.getValue();
|
||||
targetPickDetail.setAllocatedQty(newAllocatedQty);
|
||||
targetPickDetail.setStatus(status);
|
||||
pickDetailUpdateMap.put(targetPickDetail.getId(), targetPickDetail);
|
||||
List<PickDetail> updateToPickDetail) {
|
||||
if (pickDetail == null) {
|
||||
return; // 安全保护
|
||||
}
|
||||
|
||||
/* PickDetail detailToUpdate = pickDetailUpdateMap.computeIfAbsent(
|
||||
pickDetail.getId(), id -> {
|
||||
// 2. 用Builder实现拷贝
|
||||
return PickDetail.builder()
|
||||
.id(pickDetail.getId())
|
||||
.pickId(pickDetail.getPickId())
|
||||
.itemId(pickDetail.getItemId())
|
||||
.lineNo(pickDetail.getLineNo())
|
||||
.unit(pickDetail.getUnit())
|
||||
.project(pickDetail.getProject())
|
||||
.taskNo(pickDetail.getTaskNo())
|
||||
.orderQty(pickDetail.getOrderQty())
|
||||
.allocatedQty(BigDecimal.ZERO)
|
||||
.pickedQty(pickDetail.getPickedQty())
|
||||
.status(pickDetail.getStatus())
|
||||
.propC1(pickDetail.getPropC1())
|
||||
.propC3(pickDetail.getPropC3())
|
||||
.description(pickDetail.getDescription())
|
||||
.tenantId(pickDetail.getTenantId())
|
||||
.sysOrgCode(pickDetail.getSysOrgCode())
|
||||
.createBy(pickDetail.getCreateBy())
|
||||
.createTime(pickDetail.getCreateTime())
|
||||
.build();
|
||||
});
|
||||
// 累加分配数量
|
||||
BigDecimal existingQty = pickDetail.getAllocatedQty() == null
|
||||
? BigDecimal.ZERO
|
||||
: pickDetail.getAllocatedQty();
|
||||
|
||||
BigDecimal newAllocatedQty = BigDecimalUtil.add(detailToUpdate.getAllocatedQty(), allocateQty, 0);
|
||||
detailToUpdate.setAllocatedQty(newAllocatedQty);
|
||||
BigDecimal newAllocateQty = existingQty.add(allocateQty);
|
||||
|
||||
// 订单总数量
|
||||
BigDecimal orderQty = pickDetail.getOrderQty() == null
|
||||
? BigDecimal.ZERO
|
||||
: pickDetail.getOrderQty();
|
||||
|
||||
// 确保 newAllocateQty 不超过 orderQty
|
||||
if (newAllocateQty.compareTo(orderQty) > 0) {
|
||||
newAllocateQty = orderQty;
|
||||
}
|
||||
|
||||
// 更新数量
|
||||
pickDetail.setAllocatedQty(newAllocateQty);
|
||||
|
||||
// 计算状态:是否完全拣完
|
||||
Integer status;
|
||||
if (newAllocateQty.compareTo(orderQty) >= 0) {
|
||||
status = PickStatusEnum.ASSIGNED.getValue();
|
||||
} else if (newAllocateQty.compareTo(BigDecimal.ZERO) > 0) {
|
||||
status = PickStatusEnum.PARTIAL.getValue();
|
||||
} else {
|
||||
status = pickDetail.getStatus();
|
||||
}
|
||||
|
||||
pickDetail.setStatus(status);
|
||||
|
||||
updateToPickDetail.add(pickDetail);
|
||||
|
||||
// 更新状态
|
||||
Integer status = newAllocatedQty.compareTo(detailToUpdate.getOrderQty()) >= 0 ?
|
||||
PickStatusEnum.ASSIGNED.getValue() : PickStatusEnum.PARTIAL.getValue();
|
||||
detailToUpdate.setStatus(status);*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue