Commit a806619109a63816ec77b4902e93f43e7581b368
1 parent
6ff609eb
完成出库环节优化
Showing
9 changed files
with
79 additions
and
22 deletions
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/service/IHuahengMultiHandlerService.java
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/service/impl/HuahengMultiHandlerServiceImpl.java
... | ... | @@ -117,4 +117,16 @@ public class HuahengMultiHandlerServiceImpl extends HuahengBaseController implem |
117 | 117 | return result; |
118 | 118 | } |
119 | 119 | |
120 | + @Override | |
121 | + public Result autoCombination(String shipmentCode, String warehouseCode) { | |
122 | + Result result = handleMultiProcess("combination", new MultiProcessListener() { | |
123 | + @Override | |
124 | + public Result<?> doProcess() { | |
125 | + Result result = shipmentCombinationService.autoCombination(shipmentCode, warehouseCode); | |
126 | + return result; | |
127 | + } | |
128 | + }); | |
129 | + return result; | |
130 | + } | |
131 | + | |
120 | 132 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/IInventoryDetailService.java
... | ... | @@ -48,4 +48,6 @@ public interface IInventoryDetailService extends IService<InventoryDetail> { |
48 | 48 | */ |
49 | 49 | boolean updateTaskQtyById(BigDecimal taskQty, int id); |
50 | 50 | |
51 | + boolean updateQtyAndTaskQtyAndLocationCode(BigDecimal qty, BigDecimal taskQty, String locationCode, int id); | |
52 | + | |
51 | 53 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/IInventoryHeaderService.java
... | ... | @@ -32,4 +32,6 @@ public interface IInventoryHeaderService extends IService<InventoryHeader> { |
32 | 32 | boolean updateInventoryLocationAndZoneById(String locationCode, String zoneCode, Integer id); |
33 | 33 | |
34 | 34 | boolean updateContainerStatusById(String containerStatus, Integer id); |
35 | + | |
36 | + boolean updateContainerStatusAndLocationCode(String containerStatus, String locationCode, Integer id); | |
35 | 37 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/impl/InventoryDetailServiceImpl.java
... | ... | @@ -116,7 +116,18 @@ public class InventoryDetailServiceImpl extends ServiceImpl<InventoryDetailMappe |
116 | 116 | InventoryDetail inventoryDetail = new InventoryDetail(); |
117 | 117 | inventoryDetail.setTaskQty(taskQty); |
118 | 118 | inventoryDetail.setId(id); |
119 | - boolean success = updateById(inventoryDetail); | |
119 | + boolean success = this.updateById(inventoryDetail); | |
120 | + return success; | |
121 | + } | |
122 | + | |
123 | + @Override | |
124 | + public boolean updateQtyAndTaskQtyAndLocationCode(BigDecimal qty, BigDecimal taskQty, String locationCode, int id) { | |
125 | + InventoryDetail inventoryDetail = new InventoryDetail(); | |
126 | + inventoryDetail.setQty(qty); | |
127 | + inventoryDetail.setTaskQty(taskQty); | |
128 | + inventoryDetail.setLocationCode(locationCode); | |
129 | + inventoryDetail.setId(id); | |
130 | + boolean success = this.updateById(inventoryDetail); | |
120 | 131 | return success; |
121 | 132 | } |
122 | 133 | |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/impl/InventoryHeaderServiceImpl.java
... | ... | @@ -115,4 +115,14 @@ public class InventoryHeaderServiceImpl extends ServiceImpl<InventoryHeaderMappe |
115 | 115 | return success; |
116 | 116 | } |
117 | 117 | |
118 | + @Override | |
119 | + public boolean updateContainerStatusAndLocationCode(String containerStatus, String locationCode, Integer id) { | |
120 | + InventoryHeader inventoryHeader = new InventoryHeader(); | |
121 | + inventoryHeader.setId(id); | |
122 | + inventoryHeader.setContainerStatus(containerStatus); | |
123 | + inventoryHeader.setLocationCode(locationCode); | |
124 | + boolean success = inventoryHeaderService.updateById(inventoryHeader); | |
125 | + return success; | |
126 | + } | |
127 | + | |
118 | 128 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/controller/ShipmentCombinationController.java
... | ... | @@ -88,7 +88,7 @@ public class ShipmentCombinationController { |
88 | 88 | public Result autoCombination(@RequestBody ShipmentHeader shipmentHeader) { |
89 | 89 | String shipmentCode = shipmentHeader.getCode(); |
90 | 90 | String warehouseCode = shipmentHeader.getWarehouseCode(); |
91 | - return shipmentCombinationService.autoCombination(shipmentCode, warehouseCode); | |
91 | + return huahengMultiHandlerService.autoCombination(shipmentCode, warehouseCode); | |
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/impl/ShipmentCombinationServiceImpl.java
... | ... | @@ -123,6 +123,7 @@ public class ShipmentCombinationServiceImpl implements IShipmentCombinationServi |
123 | 123 | @Override |
124 | 124 | @Transactional(rollbackFor = JeecgBootException.class) |
125 | 125 | public Result autoCombination(String shipmentCode, String warehouseCode) { |
126 | + log.info("开始自动配盘,单号" + shipmentCode); | |
126 | 127 | LambdaQueryWrapper<ShipmentHeader> shipmentHeaderLambdaQueryWrapper = Wrappers.lambdaQuery(); |
127 | 128 | shipmentHeaderLambdaQueryWrapper.eq(ShipmentHeader::getWarehouseCode, warehouseCode).eq(ShipmentHeader::getCode, shipmentCode); |
128 | 129 | ShipmentHeader shipmentHeader = shipmentHeaderService.getOne(shipmentHeaderLambdaQueryWrapper); |
... | ... | @@ -148,6 +149,7 @@ public class ShipmentCombinationServiceImpl implements IShipmentCombinationServi |
148 | 149 | throw new JeecgBootException(result.getMessage()); |
149 | 150 | } |
150 | 151 | } |
152 | + log.info("完成自动配盘,单号" + shipmentCode); | |
151 | 153 | if (over) { |
152 | 154 | return Result.error("出库单已经配盘", null); |
153 | 155 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java
... | ... | @@ -885,7 +885,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
885 | 885 | @Override |
886 | 886 | @Transactional(rollbackFor = Exception.class) |
887 | 887 | public Result cancelTask(Integer taskId) { |
888 | - TaskHeader taskHeader = getById(taskId); | |
888 | + TaskHeader taskHeader = this.getById(taskId); | |
889 | 889 | if (taskHeader == null) { |
890 | 890 | return Result.error("任务" + taskId + "未找到,执行中止"); |
891 | 891 | } |
... | ... | @@ -967,7 +967,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
967 | 967 | @Override |
968 | 968 | @Transactional(rollbackFor = Exception.class) |
969 | 969 | public Result<TaskHeader> createEmptyIn(String containerCode, String toLocationCode, String warehouseCode) { |
970 | - log.info("开始创建空托入库任务"); | |
970 | + log.info("开始创建空托入库任务" + containerCode); | |
971 | 971 | if (StringUtils.isEmpty(containerCode)) { |
972 | 972 | return Result.error("创建空托盘入库时, 托盘号为空"); |
973 | 973 | } |
... | ... | @@ -1030,6 +1030,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1030 | 1030 | @Override |
1031 | 1031 | @Transactional(rollbackFor = Exception.class) |
1032 | 1032 | public Result createEmptyOut(String containerCode, String toPortCode, String warehouseCode) { |
1033 | + log.info("开始创建空托出库任务" + containerCode); | |
1033 | 1034 | if (StringUtils.isEmpty(containerCode)) { |
1034 | 1035 | return Result.error("创建空托盘出库时, 托盘号为空"); |
1035 | 1036 | } |
... | ... | @@ -1080,6 +1081,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1080 | 1081 | taskHeader.setStatus(QuantityConstant.TASK_STATUS_BUILD); |
1081 | 1082 | taskHeader.setToPortCode(toPortCode); |
1082 | 1083 | success = taskHeaderService.save(taskHeader); |
1084 | + log.info("完成创建空托出库任务" + containerCode); | |
1083 | 1085 | if (!success) { |
1084 | 1086 | throw new JeecgBootException("创建空托盘出库时,保存任务失败"); |
1085 | 1087 | } |
... | ... | @@ -1305,6 +1307,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1305 | 1307 | if (taskHeader == null) { |
1306 | 1308 | return Result.error("完成出库任务未找到,执行中止"); |
1307 | 1309 | } |
1310 | + log.info("开始完成出库任务,任务号:" + taskHeader.getId()); | |
1308 | 1311 | String warehouseCode = taskHeader.getWarehouseCode(); |
1309 | 1312 | String fromLocationCode = taskHeader.getFromLocationCode(); |
1310 | 1313 | String toLocationCode = taskHeader.getToLocationCode(); |
... | ... | @@ -1317,21 +1320,22 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1317 | 1320 | return Result.ok("完成出库任务,(" + taskHeader.getId() + ")任务已经是完成的!"); |
1318 | 1321 | } |
1319 | 1322 | if (taskDetailList.isEmpty()) { |
1320 | - throw new JeecgBootException("完成出库任务,任务明细为空"); | |
1323 | + return Result.error("完成出库任务,任务明细为空"); | |
1321 | 1324 | } |
1322 | 1325 | if (StringUtils.isEmpty(fromLocationCode)) { |
1323 | - throw new JeecgBootException("完成出库任务" + taskHeader.getId() + "没有起始库位,执行中止"); | |
1326 | + return Result.error("完成出库任务" + taskHeader.getId() + "没有起始库位,执行中止"); | |
1324 | 1327 | } |
1325 | 1328 | if (StringUtils.isEmpty(toLocationCode) && taskType == QuantityConstant.TASK_TYPE_SORTINGSHIPMENT) { |
1326 | - throw new JeecgBootException("完成出库任务,任务" + taskHeader.getId() + "没有目的库位,执行中止"); | |
1329 | + return Result.error("完成出库任务,任务" + taskHeader.getId() + "没有目的库位,执行中止"); | |
1327 | 1330 | } |
1328 | 1331 | InventoryHeader inventoryHeader = inventoryHeaderService.getInventoryHeaderByContainerCode(containerCode, warehouseCode); |
1329 | 1332 | if (inventoryHeader == null) { |
1330 | - throw new JeecgBootException("完成出库任务,出库任务" + taskHeader.getId() + "没有找到库存头"); | |
1333 | + return Result.error("完成出库任务,出库任务" + taskHeader.getId() + "没有找到库存头"); | |
1331 | 1334 | } |
1332 | 1335 | List<InventoryTransaction> inventoryTransactionList = new ArrayList<>(); |
1333 | 1336 | List<Integer> shipmentIdList = new ArrayList<>(); |
1334 | 1337 | List<ShipmentDetail> shipmentDetailList = new ArrayList<>(); |
1338 | + List<ShipmentDetail> shipmentDetailList1 = new ArrayList<>(); | |
1335 | 1339 | for (TaskDetail taskDetail : taskDetailList) { |
1336 | 1340 | ShipmentContainerDetail shipmentContainerDetail = shipmentContainerDetailService.getById(taskDetail.getShipmentContainerDetailId()); |
1337 | 1341 | if (shipmentContainerDetail == null) { |
... | ... | @@ -1342,20 +1346,28 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1342 | 1346 | throw new JeecgBootException("完成出库任务, 出库任务没有找到出库详情" + taskDetail.getShipmentDetailId()); |
1343 | 1347 | } |
1344 | 1348 | taskDetail.setShipmentCode(shipmentDetail.getShipmentCode()); |
1349 | + int shipmentDetailId = shipmentDetail.getId(); | |
1350 | + int status = QuantityConstant.SHIPMENT_HEADER_COMPLETED; | |
1345 | 1351 | if (shipmentDetail.getQty().compareTo(shipmentDetail.getTaskQty()) == 0) { |
1346 | - shipmentDetail.setStatus(QuantityConstant.SHIPMENT_HEADER_COMPLETED); | |
1352 | + status = QuantityConstant.SHIPMENT_HEADER_COMPLETED; | |
1347 | 1353 | } else if (shipmentDetail.getQty().compareTo(shipmentDetail.getTaskQty()) > 0) { |
1348 | - shipmentDetail.setStatus(QuantityConstant.SHIPMENT_HEADER_OFF_SHELF); | |
1354 | + status = QuantityConstant.SHIPMENT_HEADER_OFF_SHELF; | |
1349 | 1355 | } else if (shipmentDetail.getQty().compareTo(shipmentDetail.getTaskQty()) < 0) { |
1350 | 1356 | throw new JeecgBootException("完成出库任务时, 出库单 单据数量不能小于配盘数量"); |
1351 | 1357 | } |
1352 | 1358 | shipmentDetailList.add(shipmentDetail); |
1359 | + shipmentDetail = new ShipmentDetail(); | |
1360 | + shipmentDetail.setId(shipmentDetailId); | |
1361 | + shipmentDetail.setStatus(status); | |
1362 | + shipmentDetailList1.add(shipmentDetail); | |
1353 | 1363 | InventoryDetail inventoryDetail = inventoryDetailService.getById(taskDetail.getFromInventoryDetailId()); |
1354 | 1364 | if (inventoryDetail == null) { |
1355 | 1365 | throw new JeecgBootException("完成出库任务,出库任务没有找到库存详情" + taskDetail.getFromInventoryDetailId()); |
1356 | 1366 | } |
1357 | - inventoryDetail.setTaskQty(inventoryDetail.getTaskQty().subtract(taskDetail.getQty())); | |
1358 | - inventoryDetail.setQty(inventoryDetail.getQty().subtract(taskDetail.getQty())); | |
1367 | + BigDecimal taskQty = inventoryDetail.getTaskQty().subtract(taskDetail.getQty()); | |
1368 | + BigDecimal qty = inventoryDetail.getQty().subtract(taskDetail.getQty()); | |
1369 | + inventoryDetail.setTaskQty(taskQty); | |
1370 | + inventoryDetail.setQty(qty); | |
1359 | 1371 | inventoryDetail.setLocationCode(toLocationCode); |
1360 | 1372 | // 扣减后的库存不能小于0 |
1361 | 1373 | if (inventoryDetail.getQty().compareTo(BigDecimal.ZERO) < 0) { |
... | ... | @@ -1370,7 +1382,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1370 | 1382 | throw new JeecgBootException("完成出库任务,删除库存详情失败"); |
1371 | 1383 | } |
1372 | 1384 | } else { |
1373 | - success = inventoryDetailService.updateById(inventoryDetail); | |
1385 | + success = inventoryDetailService.updateQtyAndTaskQtyAndLocationCode(qty, taskQty, toLocationCode, inventoryDetail.getId()); | |
1374 | 1386 | if (!success) { |
1375 | 1387 | throw new JeecgBootException("完成出库任务,更新库存详情失败"); |
1376 | 1388 | } |
... | ... | @@ -1409,7 +1421,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1409 | 1421 | } |
1410 | 1422 | inventoryHeader.setContainerStatus(QuantityConstant.STATUS_CONTAINER_EMPTY); |
1411 | 1423 | inventoryHeader.setLocationCode(toLocationCode); |
1412 | - success = inventoryHeaderService.updateById(inventoryHeader); | |
1424 | + success = inventoryHeaderService.updateContainerStatusAndLocationCode(QuantityConstant.STATUS_CONTAINER_EMPTY, toLocationCode, inventoryHeader.getId()); | |
1413 | 1425 | if (!success) { |
1414 | 1426 | throw new JeecgBootException("完成出库任务,更新库存头失败"); |
1415 | 1427 | } |
... | ... | @@ -1419,7 +1431,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1419 | 1431 | throw new JeecgBootException("完成出库任务,保存库存详情失败"); |
1420 | 1432 | } |
1421 | 1433 | taskHeader.setStatus(QuantityConstant.TASK_STATUS_COMPLETED); |
1422 | - success = taskHeaderService.updateById(taskHeader); | |
1434 | + success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId()); | |
1423 | 1435 | if (!success) { |
1424 | 1436 | throw new JeecgBootException("完成出库任务,保存任务头失败"); |
1425 | 1437 | } |
... | ... | @@ -1440,9 +1452,11 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1440 | 1452 | if (!success) { |
1441 | 1453 | throw new JeecgBootException("完成分拣出库任务,更新源库位失败"); |
1442 | 1454 | } |
1443 | - success = locationService.updateContainerCodeAndStatus(toLocationCode, containerCode, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); | |
1444 | - if (!success) { | |
1445 | - throw new JeecgBootException("完成分拣出库任务,更新目标库位失败"); | |
1455 | + if (StringUtils.isNotEmpty(fromLocationCode) && !fromLocationCode.equals(toLocationCode)) { | |
1456 | + success = locationService.updateContainerCodeAndStatus(toLocationCode, containerCode, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); | |
1457 | + if (!success) { | |
1458 | + throw new JeecgBootException("完成分拣出库任务,更新目标库位失败"); | |
1459 | + } | |
1446 | 1460 | } |
1447 | 1461 | success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY, |
1448 | 1462 | inventoryDetailList.size() == 0 ? QuantityConstant.STATUS_CONTAINER_FILL_EMPTY : QuantityConstant.STATUS_CONTAINER_FILL_SOME, warehouseCode); |
... | ... | @@ -1455,12 +1469,12 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1455 | 1469 | throw new JeecgBootException("完成出库任务,获取出库组盘头失败"); |
1456 | 1470 | } |
1457 | 1471 | shipmentContainerHeader.setStatus(QuantityConstant.SHIPMENT_CONTAINER_FINISHED); |
1458 | - success = shipmentContainerHeaderService.updateById(shipmentContainerHeader); | |
1472 | + success = shipmentContainerHeaderService.updateStatusById(QuantityConstant.SHIPMENT_CONTAINER_FINISHED, shipmentContainerHeader.getId()); | |
1459 | 1473 | if (!success) { |
1460 | 1474 | throw new JeecgBootException("完成出库任务,更新出库组盘头失败"); |
1461 | 1475 | } |
1462 | 1476 | if (inventoryDetailList.size() != 0) { |
1463 | - if (!combineInventoryDetail(taskHeader)) { | |
1477 | + if (!taskHeaderService.combineInventoryDetail(taskHeader)) { | |
1464 | 1478 | throw new JeecgBootException("合并入库库存失败"); |
1465 | 1479 | } |
1466 | 1480 | } |
... | ... | @@ -1487,6 +1501,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1487 | 1501 | LogRecordContext.putVariable("extraJsonString1", JSON.toJSONString(taskDetailList)); |
1488 | 1502 | LogRecordContext.putVariable("shipmentDetailList", shipmentDetailList); |
1489 | 1503 | LogRecordContext.putVariable("extraJsonString2", JSON.toJSONString(shipmentDetailList)); |
1504 | + log.info("完成出库任务,任务号:" + taskHeader.getId()); | |
1490 | 1505 | return Result.ok("完成出库任务"); |
1491 | 1506 | } |
1492 | 1507 | |
... | ... | @@ -1854,6 +1869,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1854 | 1869 | String containerCode = taskHeader.getContainerCode(); |
1855 | 1870 | String toPortCode = taskHeader.getToPortCode(); |
1856 | 1871 | String zoneCode = taskHeader.getZoneCode(); |
1872 | + log.info("开始完成空托盘出库任务" + taskHeader.getId()); | |
1857 | 1873 | if (StringUtils.isEmpty(containerCode)) { |
1858 | 1874 | return Result.error("完成空托盘出库任务时, 托盘号为空"); |
1859 | 1875 | } |
... | ... | @@ -1888,8 +1904,8 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1888 | 1904 | if (!success) { |
1889 | 1905 | throw new JeecgBootException("完成空托盘出库任务时, 更新库位的容器编码和状态失败"); |
1890 | 1906 | } |
1891 | - taskHeader.setStatus(QuantityConstant.TASK_STATUS_COMPLETED); | |
1892 | - success = taskHeaderService.updateById(taskHeader); | |
1907 | + success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId()); | |
1908 | + log.info("完成空托盘出库任务" + taskHeader.getId()); | |
1893 | 1909 | if (!success) { |
1894 | 1910 | throw new JeecgBootException("完成空托盘出库任务时, 更新任务失败"); |
1895 | 1911 | } |
... | ... |