diff --git a/ant-design-vue-jeecg/src/views/system/receipt/ReceiptHeaderList.vue b/ant-design-vue-jeecg/src/views/system/receipt/ReceiptHeaderList.vue index d1ae08d..f2e9dbe 100644 --- a/ant-design-vue-jeecg/src/views/system/receipt/ReceiptHeaderList.vue +++ b/ant-design-vue-jeecg/src/views/system/receipt/ReceiptHeaderList.vue @@ -197,7 +197,7 @@ <a-button type="primary">组盘</a-button> </a> <a v-show="(record.lastStatus < 800 && record.firstStatus >= 15 && record.firstStatus != '20' && record.totallines != null ) || (flowOff == '0' && record.lastStatus < 800 && record.totallines != null) " @click="receiveB(record)" v-has="'receiptHeader:receive'"> - <a-button type="primary">线圈组盘</a-button> + <a-button type="primary">悬臂库组盘</a-button> </a> <a v-show="record.firstStatus == '0' && flowOff == '1'" @click="createAudit(record)"><a-button type="primary">提交审核</a-button></a> <a v-show="record.nextAuditor == username && flowOff == '1'" @click="audit(record)"><a-button type="primary">审核</a-button></a> diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/IInventoryDetailService.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/IInventoryDetailService.java index adf5204..818d7e7 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/IInventoryDetailService.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/IInventoryDetailService.java @@ -165,7 +165,7 @@ public interface IInventoryDetailService extends IService<InventoryDetail> { Result shipmentCheck(List<ShipmentContainerAdvice> shipmentContainerAdviceList, String warehouseCode); - boolean updateInventoryDetailPositionByContainerCode(String containerCode, String warehouseCode); + boolean updateInventoryDetailPositionByLocationCode(String locationCode, String warehouseCode); } diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/impl/InventoryDetailServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/impl/InventoryDetailServiceImpl.java index 996983b..4ef6a4c 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/impl/InventoryDetailServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/impl/InventoryDetailServiceImpl.java @@ -838,9 +838,12 @@ public class InventoryDetailServiceImpl extends ServiceImpl<InventoryDetailMappe } @Override - public boolean updateInventoryDetailPositionByContainerCode(String containerCode, String warehouseCode) { - List<InventoryDetail> inventoryDetailList = inventoryDetailService.getInventoryDetailListByContainerCode(containerCode, warehouseCode); + public boolean updateInventoryDetailPositionByLocationCode(String location, String warehouseCode) { + List<InventoryDetail> inventoryDetailList = inventoryDetailService.getInventoryDetailListByLocationCode(location, warehouseCode); int position = 1; + if (CollectionUtils.isEmpty(inventoryDetailList)) { + return true; + } List<InventoryDetail> updateInventoryDetailList = new ArrayList<>(); for (InventoryDetail inventoryDetail : inventoryDetailList) { InventoryDetail updateInventoryDetail = new InventoryDetail(); diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/TaskDetail.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/TaskDetail.java index 8f58ffb..d8bf1f0 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/TaskDetail.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/TaskDetail.java @@ -204,6 +204,11 @@ public class TaskDetail implements Serializable { @ApiModelProperty(value = "备用字段3") private String userdef3; + /** 位置 */ + @Excel(name = "位置", width = 15) + @ApiModelProperty(value = "位置") + private Integer position; + /** 创建人 */ @ApiModelProperty(value = "创建人") private String createBy; diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/ITaskHeaderService.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/ITaskHeaderService.java index ba710f4..b8ea396 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/ITaskHeaderService.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/ITaskHeaderService.java @@ -113,6 +113,12 @@ public interface ITaskHeaderService extends IService<TaskHeader> { Result calculateLocationThickness(List<InventoryDetail> inventoryDetailList, String locationCode, int maxThickness, String warehouseCode); /** + * 判断库位长度是否超限 + * @return + */ + boolean judgeLocationThickness(List<InventoryDetail> inventoryDetailList, String locationCode, int maxThickness, String warehouseCode); + + /** * 取消任务,恢复数据 * @param taskHeader * @return diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java index a15a523..f256ba3 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java @@ -1153,8 +1153,11 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea if (taskHeader.getZoneCode().equals(QuantityConstant.ZONE_B)) { taskHeaderService.freshLocationThickness(taskId); - if(!inventoryDetailService.updateInventoryDetailPositionByContainerCode(taskHeader.getContainerCode(), taskHeader.getWarehouseCode())) { - throw new JeecgBootException("完成任务,更新库存位置失败"); + if(!inventoryDetailService.updateInventoryDetailPositionByLocationCode(taskHeader.getFromLocationCode(), taskHeader.getWarehouseCode())) { + throw new JeecgBootException("完成任务,更新起始库存位置失败"); + } + if(!inventoryDetailService.updateInventoryDetailPositionByLocationCode(taskHeader.getToLocationCode(), taskHeader.getWarehouseCode())) { + throw new JeecgBootException("完成任务,更新目标库存位置失败"); } } return result; @@ -1213,6 +1216,27 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea @Override @Transactional(rollbackFor = Exception.class) + public boolean judgeLocationThickness(List<InventoryDetail> inventoryDetailList, String locationCode, int maxThickness, String warehouseCode) { + int totalThickness = 0; + for (InventoryDetail inventoryDetail : inventoryDetailList) { + String materialCode = inventoryDetail.getMaterialCode(); + BigDecimal qty = inventoryDetail.getQty(); + Material material = materialService.getMaterialByCode(materialCode); + if (material == null) { + throw new JeecgBootException("判断库位厚度失败,没有找到物料信息" + materialCode); + } + int thickness = material.getThickness(); + int gap = material.getGap(); + totalThickness = totalThickness + (thickness + gap) * qty.intValue(); + } + if (totalThickness > maxThickness) { + throw new JeecgBootException("判断库位厚度失败,计算出的长度" + totalThickness + "超过最大值" + maxThickness); + } + return true; + } + + @Override + @Transactional(rollbackFor = Exception.class) public Result cancelTask(Integer taskId) { TaskHeader taskHeader = this.getById(taskId); if (taskHeader == null) { @@ -1532,6 +1556,17 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea return Result.error("创建移库任务失败,起始库位:" + fromLocationCode + "和目标库位:" + toLocationCode + "是同一个"); } String containerCode = fromLocation.getContainerCode(); + + List<InventoryDetail> toInventoryDetailList = inventoryDetailService.getInventoryDetailListByLocationCode(toLocationCode, warehouseCode); + List<InventoryDetail> totalInventoryDetailList = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(toInventoryDetailList)) { + totalInventoryDetailList.addAll(toInventoryDetailList); + } + totalInventoryDetailList.addAll(fromInventoryDetailList); + if(!taskHeaderService.judgeLocationThickness(totalInventoryDetailList, toLocationCode, toLocation.getMaxThickness(), warehouseCode)) { + return Result.error("创建移库任务时,校验库位厚度失败,移库后库位超出最大凑度"); + } + // 这里增加组盘校验,如果此托盘存在未完成的组盘数据,则不能移库 // 校验入库组盘 if (receiptContainerHeaderService.havaUnCompleteCombineByLocationCode(fromLocationCode, warehouseCode)) { @@ -1612,6 +1647,12 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea throw new JeecgBootException("创建任务时,更新巷道值失败"); } List<TaskDetail> taskDetailList = new ArrayList<>(); + fromInventoryDetailList = fromInventoryDetailList.stream().sorted(new Comparator<InventoryDetail>() { + @Override + public int compare(InventoryDetail o1, InventoryDetail o2) { + return o1.getPosition() - o2.getPosition(); + } + }).collect(Collectors.toList()); for (InventoryDetail inventoryDetail : fromInventoryDetailList) { TaskDetail taskDetail = new TaskDetail(); taskDetail.setTaskHeaderId(taskHeader.getId()); @@ -1628,6 +1669,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea taskDetail.setMaterialName(inventoryDetail.getMaterialName()); taskDetail.setMaterialUnit(inventoryDetail.getMaterialUnit()); taskDetail.setQty(inventoryDetail.getQty()); + taskDetail.setPosition(inventoryDetail.getPosition()); taskDetailList.add(taskDetail); } success = taskDetailService.saveBatch(taskDetailList); @@ -2027,9 +2069,9 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea if (!success) { throw new JeecgBootException("完成入库任务时,保存库存交易失败"); } - if (!taskHeaderService.combineInventoryDetail(containerCode, warehouseCode)) { - throw new JeecgBootException("完成入库任务时, 合并入库库存失败"); - } +// if (!taskHeaderService.combineInventoryDetail(containerCode, warehouseCode)) { +// throw new JeecgBootException("完成入库任务时, 合并入库库存失败"); +// } List<Integer> receiptIdList = receiptDetaiList.stream().map(ReceiptDetail::getReceiptId).distinct().collect(Collectors.toList()); for (Integer receiptId : receiptIdList) { success = receiptHeaderService.updateReceiptHeaderStatus(receiptId); @@ -2377,6 +2419,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea InventoryDetail inventoryDetail2 = inventoryDetailList.get(j); if (inventoryDetail1.getMaterialCode().equals(inventoryDetail2.getMaterialCode()) && inventoryDetail1.getBatch().equals(inventoryDetail2.getBatch()) && inventoryDetail1.getLot().equals(inventoryDetail2.getLot()) && inventoryDetail1.getProject().equals(inventoryDetail2.getProject()) + && inventoryDetail1.getPosition().equals(inventoryDetail2.getPosition()) && inventoryDetail1.getInventoryStatus().equals(inventoryDetail2.getInventoryStatus())) { // 属性一样的库存,相加合并。 if (StringUtils.isNotEmpty(inventoryDetail1.getSn())) { @@ -2602,8 +2645,11 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea if (toLocation == null) { return Result.error("创建分拣任务时," + toLocationCode + "目标库位不存在"); } - if (StringUtils.isNotEmpty(toLocation.getContainerCode())) { - return Result.error("创建分拣任务时," + toLocationCode + "上已存在容器" + toLocation.getContainerCode()); + String toZoneCode = toLocation.getZoneCode(); + if (!toZoneCode.equals(QuantityConstant.ZONE_B)) { + if (StringUtils.isNotEmpty(toLocation.getContainerCode())) { + return Result.error("创建分拣任务时," + toLocationCode + "上已存在容器" + toLocation.getContainerCode()); + } } if (!QuantityConstant.STATUS_LOCATION_EMPTY.equals(toLocation.getStatus())) { return Result.error("创建分拣任务时, 目标库位非空闲"); @@ -3480,6 +3526,12 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea if (CollectionUtils.isEmpty(taskDetailList)) { return Result.error("完成移库任务时, 任务详情为空"); } + taskDetailList = taskDetailList.stream().sorted(new Comparator<TaskDetail>() { + @Override + public int compare(TaskDetail o1, TaskDetail o2) { + return o1.getPosition() - o2.getPosition(); + } + }).collect(Collectors.toList()); List<InventoryTransaction> inventoryTransactionList = new ArrayList<>(); for (TaskDetail taskDetail : taskDetailList) { int inventoryDetailId = taskDetail.getFromInventoryDetailId(); @@ -3534,43 +3586,98 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea if(!inventoryDetailService.saveBatch(inventoryDetailList)) { throw new JeecgBootException("完成移库任务时,保存库存失败"); } - Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), QuantityConstant.TASK_TYPE_TRANSFER, - containerCode, fromLocationCode, toLocationCode, warehouseCode); - if (!result.isSuccess()) { - throw new JeecgBootException(result.getMessage()); - } +// Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), QuantityConstant.TASK_TYPE_TRANSFER, +// containerCode, fromLocationCode, toLocationCode, warehouseCode); +// if (!result.isSuccess()) { +// throw new JeecgBootException(result.getMessage()); +// } success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId()); if (!success) { throw new JeecgBootException("完成移库任务时, 更新任务失败"); } List<InventoryDetail> fromInventoryDetailList = inventoryDetailService.getInventoryDetailListByLocationCode(fromLocationCode, warehouseCode); - if (CollectionUtils.isNotEmpty(fromInventoryDetailList)) { - Container fromContainer = containerService.createLSContainer(warehouseCode); - String fromContainerCode = fromContainer.getCode(); - if (!containerService.updateLocationCode(fromContainerCode, fromLocationCode, warehouseCode)) { - throw new JeecgBootException("完成移库任务时,更新容器失败"); - } - if (!locationService.updateContainerCode(fromLocationCode, fromContainerCode, warehouseCode)) { - throw new JeecgBootException("完成移库任务时,更新库位失败"); + InventoryHeader toInventoryHeader = inventoryHeaderService.getInventoryHeaderByLocationCode(toLocationCode, warehouseCode); + String toContainerCode = null; + if (toInventoryHeader == null) { + Container toContainer = containerService.createLSContainer(warehouseCode); + toContainerCode = toContainer.getCode(); + } else { + toContainerCode = toInventoryHeader.getContainerCode(); + } + if (CollectionUtils.isEmpty(fromInventoryDetailList)) { + if (!containerService.updateLocationCodeAndStatus(containerCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode)) { + throw new JeecgBootException("完成移库任务时,更新起始容器失败"); } - InventoryHeader inventoryHeader = inventoryHeaderService.getInventoryHeaderByLocationCode(fromLocationCode, warehouseCode); - if (inventoryHeader == null) { - throw new JeecgBootException("完成移库任务时,没有找到库存头" + fromContainerCode); + if (!locationService.updateContainerCodeAndStatus(fromLocationCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode)) { + throw new JeecgBootException("完成移库任务时,更新起始库位失败"); } - if (!inventoryHeaderService.updateContainerCodeById(containerCode, inventoryHeader.getId())) { - throw new JeecgBootException("完成移库任务时,更新库存头失败"); + } else { + if (!containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode)) { + throw new JeecgBootException("完成移库任务时,更新起始容器失败"); } - List<InventoryDetail> updateInventoryList = new ArrayList<>(); - for (InventoryDetail inventoryDetail : fromInventoryDetailList) { - InventoryDetail inventoryDetail1 = new InventoryDetail(); - inventoryDetail1.setContainerCode(fromContainerCode); - inventoryDetail1.setId(inventoryDetail.getId()); - updateInventoryList.add(inventoryDetail1); + if (!locationService.updateStatus(fromLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode)) { + throw new JeecgBootException("完成移库任务时,更新起始库位失败"); } - if (!inventoryDetailService.updateBatchById(updateInventoryList)) { - throw new JeecgBootException("完成移库任务时,更新库存明细失败"); + } + if (!containerService.updateLocationCode(toContainerCode, toLocationCode, warehouseCode)) { + throw new JeecgBootException("完成移库任务时,更新目标容器失败"); + } + if (!locationService.updateContainerCodeAndStatus(toLocationCode, toContainerCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode)) { + throw new JeecgBootException("完成移库任务时,更新目标库位失败"); + } + if (toInventoryHeader == null) { + InventoryHeader inventoryHeader = new InventoryHeader(); + inventoryHeader.setContainerCode(toContainerCode); + inventoryHeader.setLocationCode(toLocationCode); + inventoryHeader.setWarehouseCode(warehouseCode); + inventoryHeader.setContainerStatus(QuantityConstant.STATUS_CONTAINER_EMPTY); + inventoryHeader.setEnable(QuantityConstant.STATUS_ENABLE); + inventoryHeader.setRoadWay(taskHeader.getRoadWay()); + if(!inventoryHeaderService.save(inventoryHeader)) { + throw new JeecgBootException("完成移库任务时,完成库存头失败"); } + toInventoryHeader = inventoryHeader; + } + List<InventoryDetail> updateInventoryList = new ArrayList<>(); + for (InventoryDetail inventoryDetail : inventoryDetailList) { + InventoryDetail inventoryDetail1 = new InventoryDetail(); + inventoryDetail1.setContainerCode(toContainerCode); + inventoryDetail1.setInventoryHeaderId(toInventoryHeader.getId()); + inventoryDetail1.setId(inventoryDetail.getId()); + updateInventoryList.add(inventoryDetail1); + } + if (!inventoryDetailService.updateBatchById(updateInventoryList)) { + throw new JeecgBootException("完成移库任务时,更新库存明细失败"); + } + if (!inventoryHeaderService.updateInventoryContainerStatusByContainerCode(containerCode, warehouseCode)) { + throw new JeecgBootException("完成移库任务时,更新托盘状态失败1"); + } + if (!inventoryHeaderService.updateInventoryContainerStatusByContainerCode(toContainerCode, warehouseCode)) { + throw new JeecgBootException("完成移库任务时,更新托盘状态失败2"); + } + success = inventoryHeaderService.updateInventory(containerCode, fromLocationCode, warehouseCode); + if (!success) { + throw new JeecgBootException("完成移库任务时, 更新库存信息失败1"); + } + success = inventoryHeaderService.updateInventory(toContainerCode, toLocationCode, warehouseCode); + if (!success) { + throw new JeecgBootException("完成移库任务时, 更新库存信息失败2"); + } + if (CollectionUtils.isNotEmpty(fromInventoryDetailList)) { + success = taskHeaderService.combineInventoryDetail(containerCode, warehouseCode); + if (!success) { + throw new JeecgBootException("完成移库任务时, 更新库存失败1"); + } + } else { + InventoryHeader fromInventoryHeader = inventoryHeaderService.getInventoryHeaderByLocationCode(fromLocationCode, warehouseCode); + if (!inventoryHeaderService.removeById(fromInventoryHeader.getId())) { + throw new JeecgBootException("调整库存,删除托盘:" + containerCode + "库存失败"); + } + } + success = taskHeaderService.combineInventoryDetail(toContainerCode, warehouseCode); + if (!success) { + throw new JeecgBootException("完成移库任务时, 更新库存失败2"); } log.info("完成移库任务" + taskHeader.getId()); return Result.OK("完成移库任务成功");