Commit 42184f56 zshaohui

原材料Gr手动入库

1 个父辈 0c23fb7a
...@@ -1382,73 +1382,46 @@ public class LiteOrderCache { ...@@ -1382,73 +1382,46 @@ public class LiteOrderCache {
for (LiteOrderItem orderItem : cacheOrder.getOrderItems()) { for (LiteOrderItem orderItem : cacheOrder.getOrderItems()) {
String partNumber = orderItem.getPn();
int taskNum = 0;
int remainNum = orderItem.getNeedNum() - orderItem.getTotalOutNum(); int remainNum = orderItem.getNeedNum() - orderItem.getTotalOutNum();
//1.查找所有符合条件的pn
if (remainNum <= 0) {
continue; while (taskNum < remainNum) {
}
log.info(orderNo + "已分配数量为:"+taskNum+",剩余数量为:"+remainNum);
Collection<String> excludePosIds = excludeOutPosIds(); Collection<String> excludePosIds = excludeOutPosIds();
//找到hold的 if (dataLogList != null && !dataLogList.isEmpty()){
List<String> holdPosIdList = getHoldPosIdList(cacheOrder);
if (holdPosIdList != null && !holdPosIdList.isEmpty()) {
excludePosIds.addAll(holdPosIdList);
}
if (dataLogList != null && !dataLogList.isEmpty()) {
for (DataLog dataLog : dataLogList) { for (DataLog dataLog : dataLogList) {
excludePosIds.add(dataLog.getPosId()); excludePosIds.add(dataLog.getPosId());
} }
} }
//1.先从执行的料箱中出库
String pn = orderItem.getPn(); StoragePos pos = null;
String warehouseCode = orderItem.getWarehouseCode(); if (storagePosList != null && !storagePosList.isEmpty()) {
for (StoragePos storagePos : storagePosList) {
Criteria c = Criteria.where("barcode.partNumber").is(pn) if (excludePosIds.contains(storagePos.getId())) {
.and("id").nin(excludePosIds) continue;
.and("enabled").is(true)
.and("storageId").in(storageIdList)
.and("barcode.warehouseCode").is(warehouseCode);
List<StoragePos> posList = storagePosManager.findByQuery(new Query(c));
if (storageIdList != null && !storageIdList.isEmpty()) {
posList.addAll(0, storagePosList);
} }
if (partNumber.equals(storagePos.getBarcode().getPartNumber())) {
if (posList == null || posList.isEmpty()) { pos = storagePos;
finishedOrderTasks(cacheOrder); break;
throw new ValidateException("", orderItem.getPn() + "库存不足,odn:" + cacheOrder.getOrderNo() + "无法进行出库");
} }
//开始寻找组合数量为needOutNum的库存
List<Integer> amountList = new ArrayList<>();
for (StoragePos storagePos : posList) {
Barcode barcode = storagePos.getBarcode();
amountList.add(barcode.getQty());
} }
//寻找到组合
List<List<Integer>> combinations = CombinationUtil.findCombinationsWithoutDuplicates(amountList, remainNum);
Collections.sort(combinations, Comparator.comparingInt(List::size));
if (combinations.isEmpty()) {
finishedOrderTasks(cacheOrder);
throw new ValidateException("", orderItem.getPn() + "需要出库的数量为:" + remainNum + ",未找到符合条件的组合");
} }
//开始出库 if (pos == null) {
List<Integer> needOutNumList = combinations.get(0); pos = storagePosManager.findPartNumberInStorages(storageIdList, partNumber, excludePosIds, checkoutType, orderItem.getBrand(),orderItem.getWarehouseCode());
while (needOutNumList.size() > 0) {
Integer qty = needOutNumList.get(0);
for (StoragePos pos : posList) {
if (excludePosIds.contains(pos.getId())) {
continue;
} }
if (pos == null) {
break;
} else {
Barcode barcode = pos.getBarcode(); Barcode barcode = pos.getBarcode();
if (barcode.getQty() == qty) { log.info(barcode.getBarcode() + "需要生成出库任务,工单号为:" + orderNo+",数量为:"+barcode.getQty());
log.info(barcode.getBarcode() + "需要生成出库任务,工单号为:" + orderNo + ",数量为:" + barcode.getQty()); taskNum = taskNum + barcode.getQty();
taskReelCount = taskReelCount + 1; taskReelCount = taskReelCount + 1;
DataLog task = newTask(pos); DataLog task = newTask(pos);
task.setSourceId(cacheOrder.getId()); task.setSourceId(cacheOrder.getId());
...@@ -1458,17 +1431,23 @@ public class LiteOrderCache { ...@@ -1458,17 +1431,23 @@ public class LiteOrderCache {
task.setType(OP.CHECKOUT); task.setType(OP.CHECKOUT);
task.setStatus(OP_STATUS.WAIT.name()); task.setStatus(OP_STATUS.WAIT.name());
task.setLoc(TaskLocUtil.OUT); task.setLoc(TaskLocUtil.OUT);
if (StringUtils.isNotEmpty(barcode.getCartonId())) { if (StringUtils.isNotEmpty(barcode.getCartonId())){
task.setCartonId(barcode.getCartonId()); task.setCartonId(barcode.getCartonId());
} }
task.setOdn(true); task.setOdn(true);
dataLogList.add(task); dataLogList.add(task);
excludePosIds.add(pos.getId());
break;
} }
} }
needOutNumList.remove(0);
//如果数量不满足,则提示出来
if (taskNum < remainNum){
finishedOrderTasks(cacheOrder);
throw new ValidateException("", orderItem.getPn()+"库存不足,odn:"+cacheOrder.getOrderNo()+"无法进行出库");
}
} }
for (DataLog dataLog : dataLogList) {
taskService.addTaskToExecute(dataLog);
} }
if (taskReelCount <= 0) { if (taskReelCount <= 0) {
...@@ -1477,9 +1456,6 @@ public class LiteOrderCache { ...@@ -1477,9 +1456,6 @@ public class LiteOrderCache {
throw new ValidateException("smfcore.order.out.noTask", "工单无可执行的任务"); throw new ValidateException("smfcore.order.out.noTask", "工单无可执行的任务");
} }
for (DataLog dataLog : dataLogList) {
taskService.addTaskToExecute(dataLog);
}
cacheOrder.setTaskReelCount(taskReelCount); cacheOrder.setTaskReelCount(taskReelCount);
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!