Commit 41ab783cd03e292a798120ed33fc39271f7eb310

Authored by 肖超群
1 parent 4433fd16

完善 任务完成时,统一解锁库位和容器

huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java
@@ -1121,27 +1121,10 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea @@ -1121,27 +1121,10 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea
1121 throw new JeecgBootException("完成入库任务时,保存库存交易失败"); 1121 throw new JeecgBootException("完成入库任务时,保存库存交易失败");
1122 } 1122 }
1123 1123
1124 - if (StringUtils.isNotEmpty(fromLocationCode) && !fromLocationCode.equals(toLocationCode)) {  
1125 - success =  
1126 - locationService.updateContainerCodeAndStatus(fromLocationCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode);  
1127 - if (!success) {  
1128 - throw new JeecgBootException("完成入库任务时,更新源库位失败");  
1129 - }  
1130 - }  
1131 -  
1132 - success = locationService.updateContainerCodeAndStatus(toLocationCode, containerCode, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode);  
1133 - if (!success) {  
1134 - throw new JeecgBootException("完成入库任务时,更新库位失败");  
1135 - }  
1136 -  
1137 - success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId());  
1138 - if (!success) {  
1139 - throw new JeecgBootException("完成入库任务时,更新任务失败");  
1140 - }  
1141 - success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY,  
1142 - taskHeader.getContainerFillStatus(), warehouseCode);  
1143 - if (!success) {  
1144 - throw new JeecgBootException("完成入库任务时,更新容器失败"); 1124 + Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), taskType, containerCode, fromLocationCode,
  1125 + toLocationCode, warehouseCode);
  1126 + if (!result.isSuccess()) {
  1127 + throw new JeecgBootException(result.getMessage());
1145 } 1128 }
1146 if (!taskHeaderService.combineInventoryDetail(taskHeader)) { 1129 if (!taskHeaderService.combineInventoryDetail(taskHeader)) {
1147 throw new JeecgBootException("合并入库库存失败"); 1130 throw new JeecgBootException("合并入库库存失败");
@@ -1159,6 +1142,10 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea @@ -1159,6 +1142,10 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea
1159 if (!inventoryHeaderService.updateInventoryContainerStatusByContainerCode(containerCode, warehouseCode)) { 1142 if (!inventoryHeaderService.updateInventoryContainerStatusByContainerCode(containerCode, warehouseCode)) {
1160 throw new JeecgBootException("完成入库任务时,更新托盘状态失败"); 1143 throw new JeecgBootException("完成入库任务时,更新托盘状态失败");
1161 } 1144 }
  1145 + success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId());
  1146 + if (!success) {
  1147 + throw new JeecgBootException("完成出库任务,保存任务头失败");
  1148 + }
1162 receiptDetaiList = receiptDetaiList.stream().filter(t -> t.getStatus().equals(QuantityConstant.RECEIPT_HEADER_COMPLETED)).collect(Collectors.toList()); 1149 receiptDetaiList = receiptDetaiList.stream().filter(t -> t.getStatus().equals(QuantityConstant.RECEIPT_HEADER_COMPLETED)).collect(Collectors.toList());
1163 LogRecordContext.putVariable("taskHeader", taskHeader); 1150 LogRecordContext.putVariable("taskHeader", taskHeader);
1164 LogRecordContext.putVariable("taskDetailList", taskDetailList); 1151 LogRecordContext.putVariable("taskDetailList", taskDetailList);
@@ -1311,44 +1298,10 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea @@ -1311,44 +1298,10 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea
1311 if (!success) { 1298 if (!success) {
1312 throw new JeecgBootException("完成出库任务,保存库存详情失败"); 1299 throw new JeecgBootException("完成出库任务,保存库存详情失败");
1313 } 1300 }
1314 - taskHeader.setStatus(QuantityConstant.TASK_STATUS_COMPLETED);  
1315 - success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId());  
1316 - if (!success) {  
1317 - throw new JeecgBootException("完成出库任务,保存任务头失败");  
1318 - }  
1319 - if (taskType == QuantityConstant.TASK_TYPE_WHOLESHIPMENT) {  
1320 - success =  
1321 - locationService.updateContainerCodeAndStatus(fromLocationCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode);  
1322 - if (!success) {  
1323 - throw new JeecgBootException("完成整盘出库任务,更新源库位失败");  
1324 - }  
1325 - success = containerService.updateLocationCodeAndStatus(containerCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_CONTAINER_EMPTY,  
1326 - QuantityConstant.STATUS_CONTAINER_FILL_EMPTY, warehouseCode);  
1327 - if (!success) {  
1328 - throw new JeecgBootException("完成整盘出库任务,更新容器失败");  
1329 - }  
1330 - } else if (taskType == QuantityConstant.TASK_TYPE_SORTINGSHIPMENT) {  
1331 - if (!fromLocationCode.equals(toLocationCode)) {  
1332 - success = locationService.updateContainerCodeAndStatus(fromLocationCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_LOCATION_EMPTY,  
1333 - warehouseCode);  
1334 - if (!success) {  
1335 - throw new JeecgBootException("完成分拣出库任务,更新源库位失败");  
1336 - }  
1337 - success = locationService.updateContainerCodeAndStatus(toLocationCode, containerCode, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode);  
1338 - if (!success) {  
1339 - throw new JeecgBootException("完成分拣出库任务,更新目标库位失败");  
1340 - }  
1341 - } else {  
1342 - success = locationService.updateStatus(fromLocationCode, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode);  
1343 - if (!success) {  
1344 - throw new JeecgBootException("完成分拣出库任务,更新源库位失败");  
1345 - }  
1346 - }  
1347 - success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY,  
1348 - inventoryDetailList.size() == 0 ? QuantityConstant.STATUS_CONTAINER_FILL_EMPTY : QuantityConstant.STATUS_CONTAINER_FILL_SOME, warehouseCode);  
1349 - if (!success) {  
1350 - throw new JeecgBootException("完成分拣出库任务,更新容器失败");  
1351 - } 1301 + Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), taskType, containerCode, fromLocationCode,
  1302 + toLocationCode, warehouseCode);
  1303 + if (!result.isSuccess()) {
  1304 + throw new JeecgBootException(result.getMessage());
1352 } 1305 }
1353 ShipmentContainerHeader shipmentContainerHeader = shipmentContainerHeaderService.getById(taskHeader.getShipmentContainerHeaderId()); 1306 ShipmentContainerHeader shipmentContainerHeader = shipmentContainerHeaderService.getById(taskHeader.getShipmentContainerHeaderId());
1354 if (shipmentContainerHeader == null) { 1307 if (shipmentContainerHeader == null) {
@@ -1380,6 +1333,10 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea @@ -1380,6 +1333,10 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea
1380 throw new JeecgBootException("完成出库任务,更新库存状态失败"); 1333 throw new JeecgBootException("完成出库任务,更新库存状态失败");
1381 } 1334 }
1382 } 1335 }
  1336 + success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId());
  1337 + if (!success) {
  1338 + throw new JeecgBootException("完成出库任务,保存任务头失败");
  1339 + }
1383 // 操作记录添加 1340 // 操作记录添加
1384 shipmentDetailList = shipmentDetailList.stream().filter(t -> t.getStatus().equals(QuantityConstant.SHIPMENT_HEADER_COMPLETED)).collect(Collectors.toList()); 1341 shipmentDetailList = shipmentDetailList.stream().filter(t -> t.getStatus().equals(QuantityConstant.SHIPMENT_HEADER_COMPLETED)).collect(Collectors.toList());
1385 LogRecordContext.putVariable("taskHeader", taskHeader); 1342 LogRecordContext.putVariable("taskHeader", taskHeader);
@@ -1657,8 +1614,15 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea @@ -1657,8 +1614,15 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea
1657 String toLocationCode, String warehouseCode) { 1614 String toLocationCode, String warehouseCode) {
1658 Result result = null; 1615 Result result = null;
1659 boolean success = false; 1616 boolean success = false;
1660 - if (StringUtils.isEmpty(toLocationCode) && taskType == QuantityConstant.TASK_TYPE_OVER_STATION) {  
1661 - return Result.error("完成任务时, 目标库位号为空"); 1617 + if (StringUtils.isEmpty(toLocationCode) && taskType != QuantityConstant.TASK_TYPE_OVER_STATION) {
  1618 + return Result.error("任务类型" + taskType + "完成任务时, 目标库位号为空");
  1619 + }
  1620 + if (StringUtils.isEmpty(containerCode)) {
  1621 + return Result.error("任务类型" + taskType + "完成任务时, 容器号为空");
  1622 + }
  1623 + Container container = containerService.getContainerByCode(containerCode, warehouseCode);
  1624 + if (container == null) {
  1625 + return Result.error("任务类型" + taskType + "完成任务时, 没有找到托盘" + containerCode);
1662 } 1626 }
1663 switch (taskType) { 1627 switch (taskType) {
1664 case QuantityConstant.TASK_TYPE_WHOLERECEIPT: 1628 case QuantityConstant.TASK_TYPE_WHOLERECEIPT:
@@ -1677,6 +1641,9 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea @@ -1677,6 +1641,9 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea
1677 case QuantityConstant.TASK_TYPE_WHOLESHIPMENT: 1641 case QuantityConstant.TASK_TYPE_WHOLESHIPMENT:
1678 case QuantityConstant.TASK_TYPE_EMPTYSHIPMENT: 1642 case QuantityConstant.TASK_TYPE_EMPTYSHIPMENT:
1679 case QuantityConstant.TASK_TYPE_MANY_EMPTYSHIPMENT: 1643 case QuantityConstant.TASK_TYPE_MANY_EMPTYSHIPMENT:
  1644 + if (StringUtils.isEmpty(fromLocationCode)) {
  1645 + return Result.error("任务类型" + taskType + "完成任务时, 起始库位号为空");
  1646 + }
1680 success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY, 1647 success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY,
1681 QuantityConstant.STATUS_CONTAINER_FILL_EMPTY, warehouseCode); 1648 QuantityConstant.STATUS_CONTAINER_FILL_EMPTY, warehouseCode);
1682 break; 1649 break;
@@ -1684,13 +1651,24 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea @@ -1684,13 +1651,24 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea
1684 case QuantityConstant.TASK_TYPE_CYCLECOUNT: 1651 case QuantityConstant.TASK_TYPE_CYCLECOUNT:
1685 case QuantityConstant.TASK_TYPE_TRANSFER: 1652 case QuantityConstant.TASK_TYPE_TRANSFER:
1686 case QuantityConstant.TASK_TYPE_CHECK_OUT: 1653 case QuantityConstant.TASK_TYPE_CHECK_OUT:
  1654 + if (StringUtils.isEmpty(fromLocationCode)) {
  1655 + return Result.error("任务类型" + taskType + "完成任务时, 起始库位号为空");
  1656 + }
1687 InventoryHeader inventoryHeader = inventoryHeaderService.getInventoryHeaderByContainerCode(containerCode, warehouseCode); 1657 InventoryHeader inventoryHeader = inventoryHeaderService.getInventoryHeaderByContainerCode(containerCode, warehouseCode);
1688 if (inventoryHeader != null) { 1658 if (inventoryHeader != null) {
1689 - success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY,  
1690 - QuantityConstant.STATUS_CONTAINER_FILL_SOME, warehouseCode); 1659 + if (fromLocationCode.equals(toLocationCode)) {
  1660 + success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode);
  1661 + } else {
  1662 + success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY,
  1663 + QuantityConstant.STATUS_CONTAINER_FILL_SOME, warehouseCode);
  1664 + }
1691 } else { 1665 } else {
1692 - success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY,  
1693 - QuantityConstant.STATUS_CONTAINER_FILL_EMPTY, warehouseCode); 1666 + if (fromLocationCode.equals(toLocationCode)) {
  1667 + success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode);
  1668 + } else {
  1669 + success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY,
  1670 + QuantityConstant.STATUS_CONTAINER_FILL_EMPTY, warehouseCode);
  1671 + }
1694 } 1672 }
1695 break; 1673 break;
1696 case QuantityConstant.TASK_TYPE_OVER_STATION: 1674 case QuantityConstant.TASK_TYPE_OVER_STATION:
@@ -1699,20 +1677,30 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea @@ -1699,20 +1677,30 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea
1699 break; 1677 break;
1700 } 1678 }
1701 if (!success) { 1679 if (!success) {
1702 - throw new JeecgBootException("完成任务时,更新容器失败"); 1680 + throw new JeecgBootException("任务类型" + taskType + "完成任务时, 更新容器失败");
1703 } 1681 }
1704 if (StringUtils.isNotEmpty(fromLocationCode) && !fromLocationCode.equals(toLocationCode)) { 1682 if (StringUtils.isNotEmpty(fromLocationCode) && !fromLocationCode.equals(toLocationCode)) {
  1683 + Location toLocation = locationService.getLocationByCode(fromLocationCode, warehouseCode);
  1684 + if (toLocation == null) {
  1685 + return Result.error("完成任务时," + toLocationCode + "目标库位不存在");
  1686 + }
1705 success = 1687 success =
1706 locationService.updateContainerCodeAndStatus(fromLocationCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); 1688 locationService.updateContainerCodeAndStatus(fromLocationCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode);
1707 if (!success) { 1689 if (!success) {
1708 - throw new JeecgBootException("完成任务时,更新源库位失败"); 1690 + throw new JeecgBootException("任务类型" + taskType + "完成任务时,更新源库位失败");
1709 } 1691 }
1710 } 1692 }
1711 - success = locationService.updateContainerCodeAndStatus(toLocationCode, containerCode, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode);  
1712 - if (!success) {  
1713 - throw new JeecgBootException("完成任务时,更新库位失败"); 1693 + if (StringUtils.isNotEmpty(toLocationCode)) {
  1694 + Location toLocation = locationService.getLocationByCode(toLocationCode, warehouseCode);
  1695 + if (toLocation == null) {
  1696 + return Result.error("任务类型" + taskType + "完成任务时, " + toLocationCode + "目标库位不存在");
  1697 + }
  1698 + success = locationService.updateContainerCodeAndStatus(toLocationCode, containerCode, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode);
  1699 + if (!success) {
  1700 + throw new JeecgBootException("任务类型" + taskType + "完成任务时,更新库位失败");
  1701 + }
1714 } 1702 }
1715 - return Result.OK("完成任务成功"); 1703 + return Result.OK("任务类型" + taskType + "完成任务成功");
1716 } 1704 }
1717 1705
1718 /** 1706 /**
@@ -1736,27 +1724,16 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea @@ -1736,27 +1724,16 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea
1736 if (StringUtils.isEmpty(toLocationCode)) { 1724 if (StringUtils.isEmpty(toLocationCode)) {
1737 return Result.error("完成空托盘入库任务时, 目标库位号为空"); 1725 return Result.error("完成空托盘入库任务时, 目标库位号为空");
1738 } 1726 }
1739 - Container container = containerService.getContainerByCode(containerCode, warehouseCode);  
1740 - if (container == null) {  
1741 - return Result.error("完成空托盘入库任务时, 没有找到托盘" + containerCode);  
1742 - }  
1743 - Location toLocation = locationService.getLocationByCode(toLocationCode, warehouseCode);  
1744 - if (toLocation == null) {  
1745 - return Result.error("完成空托盘入库任务时," + toLocationCode + "目标库位不存在");  
1746 - }  
1747 - boolean success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode);  
1748 - if (!success) {  
1749 - throw new JeecgBootException("完成空托盘入库任务时, 更新容器的库位号和状态失败"); 1727 + Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), QuantityConstant.TASK_TYPE_EMPTYRECEIPT,
  1728 + containerCode, QuantityConstant.EMPTY_STRING, toLocationCode, warehouseCode);
  1729 + if (!result.isSuccess()) {
  1730 + throw new JeecgBootException(result.getMessage());
1750 } 1731 }
1751 - success = locationService.updateContainerCodeAndStatus(toLocationCode, containerCode, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); 1732 + boolean success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId());
1752 if (!success) { 1733 if (!success) {
1753 - throw new JeecgBootException("完成空托盘入库任务时, 更新库位的容器编码和状态失败"); 1734 + throw new JeecgBootException("完成空托盘出库任务时, 更新任务失败");
1754 } 1735 }
1755 - success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId());  
1756 log.info("完成空托入库任务"); 1736 log.info("完成空托入库任务");
1757 - if (!success) {  
1758 - throw new JeecgBootException("完成空托盘入库任务时, 更新任务失败");  
1759 - }  
1760 return Result.OK("完成空托盘入库成功"); 1737 return Result.OK("完成空托盘入库成功");
1761 } 1738 }
1762 1739
@@ -1790,7 +1767,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea @@ -1790,7 +1767,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea
1790 // 1.先拿到盘点单主单据 1767 // 1.先拿到盘点单主单据
1791 CycleCountDetail cycleCountDetail = cycleCountDetailService.getById(taskHeader.getShipmentContainerHeaderId()); 1768 CycleCountDetail cycleCountDetail = cycleCountDetailService.getById(taskHeader.getShipmentContainerHeaderId());
1792 1769
1793 - if ((cycleCountDetail.getCountedQty().add(cycleCountDetail.getGapQty())).compareTo(BigDecimal.ZERO) == 0) { 1770 + if (cycleCountDetail.getGapQty().compareTo(BigDecimal.ZERO) == 0) {
1794 return Result.error("盘点单据系统实盘数量跟差异数量0,不能完成 单据号" + cycleCountDetail.getCycleCountHeadCode()); 1771 return Result.error("盘点单据系统实盘数量跟差异数量0,不能完成 单据号" + cycleCountDetail.getCycleCountHeadCode());
1795 } 1772 }
1796 1773
@@ -2045,17 +2022,12 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea @@ -2045,17 +2022,12 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea
2045 if (port == null) { 2022 if (port == null) {
2046 return Result.error("完成空托盘出库任务时," + toPortCode + "目标出库口不存在"); 2023 return Result.error("完成空托盘出库任务时," + toPortCode + "目标出库口不存在");
2047 } 2024 }
2048 - boolean success =  
2049 - containerService.updateLocationCodeAndStatus(containerCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode);  
2050 - if (!success) {  
2051 - throw new JeecgBootException("完成空托盘出库任务时, 更新容器的库位号和状态失败");  
2052 - }  
2053 - success =  
2054 - locationService.updateContainerCodeAndStatus(fromLocationCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode);  
2055 - if (!success) {  
2056 - throw new JeecgBootException("完成空托盘出库任务时, 更新库位的容器编码和状态失败"); 2025 + Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), QuantityConstant.TASK_TYPE_EMPTYRECEIPT,
  2026 + containerCode, fromLocationCode, QuantityConstant.EMPTY_STRING, warehouseCode);
  2027 + if (!result.isSuccess()) {
  2028 + throw new JeecgBootException(result.getMessage());
2057 } 2029 }
2058 - success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId()); 2030 + boolean success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId());
2059 log.info("完成空托盘出库任务" + taskHeader.getId()); 2031 log.info("完成空托盘出库任务" + taskHeader.getId());
2060 if (!success) { 2032 if (!success) {
2061 throw new JeecgBootException("完成空托盘出库任务时, 更新任务失败"); 2033 throw new JeecgBootException("完成空托盘出库任务时, 更新任务失败");
@@ -2122,24 +2094,6 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea @@ -2122,24 +2094,6 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea
2122 throw new JeecgBootException("完成移库任务时,保存库存交易失败"); 2094 throw new JeecgBootException("完成移库任务时,保存库存交易失败");
2123 } 2095 }
2124 } 2096 }
2125 - taskHeader.setStatus(QuantityConstant.TASK_STATUS_COMPLETED);  
2126 - success = taskHeaderService.updateById(taskHeader);  
2127 - if (!success) {  
2128 - throw new JeecgBootException("完成移库任务时, 更新任务失败");  
2129 - }  
2130 - success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode);  
2131 - if (!success) {  
2132 - throw new JeecgBootException("完成移库任务时, 更新容器状态失败");  
2133 - }  
2134 - success =  
2135 - locationService.updateContainerCodeAndStatus(fromLocationCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode);  
2136 - if (!success) {  
2137 - throw new JeecgBootException("完成移库任务时, 更新起始库位状态失败");  
2138 - }  
2139 - success = locationService.updateContainerCodeAndStatus(toLocationCode, containerCode, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode);  
2140 - if (!success) {  
2141 - throw new JeecgBootException("完成移库任务时, 更新目标库位状态失败");  
2142 - }  
2143 LambdaUpdateWrapper<InventoryHeader> inventoryHeaderLambdaUpdateWrapper = Wrappers.lambdaUpdate(); 2097 LambdaUpdateWrapper<InventoryHeader> inventoryHeaderLambdaUpdateWrapper = Wrappers.lambdaUpdate();
2144 inventoryHeaderLambdaUpdateWrapper.eq(InventoryHeader::getWarehouseCode, warehouseCode).eq(InventoryHeader::getContainerCode, containerCode) 2098 inventoryHeaderLambdaUpdateWrapper.eq(InventoryHeader::getWarehouseCode, warehouseCode).eq(InventoryHeader::getContainerCode, containerCode)
2145 .eq(InventoryHeader::getLocationCode, fromLocationCode); 2099 .eq(InventoryHeader::getLocationCode, fromLocationCode);
@@ -2157,6 +2111,16 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea @@ -2157,6 +2111,16 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
2157 throw new JeecgBootException("完成移库任务时, 更新库存详情失败"); 2111 throw new JeecgBootException("完成移库任务时, 更新库存详情失败");
2158 } 2112 }
2159 } 2113 }
  2114 + Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), QuantityConstant.TASK_TYPE_OVER_STATION,
  2115 + containerCode, fromLocationCode, toLocationCode, warehouseCode);
  2116 + if (!result.isSuccess()) {
  2117 + throw new JeecgBootException(result.getMessage());
  2118 + }
  2119 + taskHeader.setStatus(QuantityConstant.TASK_STATUS_COMPLETED);
  2120 + success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId());
  2121 + if (!success) {
  2122 + throw new JeecgBootException("完成移库任务时, 更新任务失败");
  2123 + }
2160 log.info("完成移库任务" + taskHeader.getId()); 2124 log.info("完成移库任务" + taskHeader.getId());
2161 return Result.OK("完成移库任务成功"); 2125 return Result.OK("完成移库任务成功");
2162 } 2126 }
@@ -2221,42 +2185,12 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea @@ -2221,42 +2185,12 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
2221 if (!success) { 2185 if (!success) {
2222 throw new JeecgBootException("完成出库查看任务时,更新库存头失败"); 2186 throw new JeecgBootException("完成出库查看任务时,更新库存头失败");
2223 } 2187 }
2224 - if (fromLocationCode.equals(toLocationCode)) {  
2225 - success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode);  
2226 - } else {  
2227 - success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode);  
2228 - }  
2229 - if (!success) {  
2230 - throw new JeecgBootException("完成出库查看任务时,更新容器状态失败");  
2231 - }  
2232 - } else {  
2233 - if (fromLocationCode.equals(toLocationCode)) {  
2234 - success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode);  
2235 - } else {  
2236 - success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode);  
2237 - }  
2238 - if (!success) {  
2239 - throw new JeecgBootException("完成出库查看任务时,更新容器状态失败");  
2240 - }  
2241 } 2188 }
2242 2189
2243 - if (!fromLocationCode.equals(toLocationCode)) {  
2244 - success =  
2245 - locationService.updateContainerCodeAndStatus(fromLocationCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode);  
2246 - if (!success) {  
2247 - throw new JeecgBootException("完成出库查看任务时,更新源库位失败");  
2248 - }  
2249 - } else {  
2250 - success = locationService.updateStatus(fromLocationCode, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode);  
2251 - if (!success) {  
2252 - throw new JeecgBootException("完成出库查看任务时,更新源库位失败");  
2253 - }  
2254 - }  
2255 - if (StringUtils.isNotEmpty(fromLocationCode) && !fromLocationCode.equals(toLocationCode)) {  
2256 - success = locationService.updateContainerCodeAndStatus(toLocationCode, containerCode, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode);  
2257 - if (!success) {  
2258 - throw new JeecgBootException("完成出库查看任务时,更新目标库位失败");  
2259 - } 2190 + Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), QuantityConstant.TASK_TYPE_EMPTYRECEIPT,
  2191 + containerCode, fromLocationCode, toLocationCode, warehouseCode);
  2192 + if (!result.isSuccess()) {
  2193 + throw new JeecgBootException(result.getMessage());
2260 } 2194 }
2261 taskHeader.setStatus(QuantityConstant.TASK_STATUS_COMPLETED); 2195 taskHeader.setStatus(QuantityConstant.TASK_STATUS_COMPLETED);
2262 success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId()); 2196 success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId());
@@ -2304,16 +2238,21 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea @@ -2304,16 +2238,21 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
2304 if (toPort == null) { 2238 if (toPort == null) {
2305 return Result.error("创建跨站任务时,目标站台为空"); 2239 return Result.error("创建跨站任务时,目标站台为空");
2306 } 2240 }
  2241 + Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), QuantityConstant.TASK_TYPE_OVER_STATION,
  2242 + containerCode, QuantityConstant.EMPTY_STRING, QuantityConstant.EMPTY_STRING, warehouseCode);
  2243 + if (!result.isSuccess()) {
  2244 + throw new JeecgBootException(result.getMessage());
  2245 + }
2307 taskHeader.setStatus(QuantityConstant.TASK_STATUS_COMPLETED); 2246 taskHeader.setStatus(QuantityConstant.TASK_STATUS_COMPLETED);
2308 boolean success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId()); 2247 boolean success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId());
2309 if (!success) { 2248 if (!success) {
2310 throw new JeecgBootException("创建跨站任务时, 更新任务失败"); 2249 throw new JeecgBootException("创建跨站任务时, 更新任务失败");
2311 } 2250 }
2312 - success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode); 2251 +// success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode);
  2252 +// if (!success) {
  2253 +// throw new JeecgBootException("创建跨站任务时, 更新容器状态失败");
  2254 +// }
2313 log.info("完成跨站任务" + taskHeader.getId()); 2255 log.info("完成跨站任务" + taskHeader.getId());
2314 - if (!success) {  
2315 - throw new JeecgBootException("创建跨站任务时, 更新容器状态失败");  
2316 - }  
2317 return Result.OK("完成跨站任务成功"); 2256 return Result.OK("完成跨站任务成功");
2318 } 2257 }
2319 2258
@@ -2346,21 +2285,17 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea @@ -2346,21 +2285,17 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
2346 if (toLocation == null) { 2285 if (toLocation == null) {
2347 return Result.error("完成空托盘组入库任务时,没有找到库位" + toLocationCode); 2286 return Result.error("完成空托盘组入库任务时,没有找到库位" + toLocationCode);
2348 } 2287 }
  2288 + Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), QuantityConstant.TASK_TYPE_MANY_EMPTYRECEIPT,
  2289 + containerCode, QuantityConstant.EMPTY_STRING, toLocationCode, warehouseCode);
  2290 + if (!result.isSuccess()) {
  2291 + throw new JeecgBootException(result.getMessage());
  2292 + }
2349 taskHeader.setStatus(QuantityConstant.TASK_STATUS_COMPLETED); 2293 taskHeader.setStatus(QuantityConstant.TASK_STATUS_COMPLETED);
2350 boolean success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId()); 2294 boolean success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId());
2351 if (!success) { 2295 if (!success) {
2352 throw new JeecgBootException("完成空托盘组入库任务时, 更新任务失败"); 2296 throw new JeecgBootException("完成空托盘组入库任务时, 更新任务失败");
2353 } 2297 }
2354 - success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_LOCATION_EMPTY,  
2355 - QuantityConstant.STATUS_CONTAINER_FILL_MANY, warehouseCode);  
2356 - if (!success) {  
2357 - throw new JeecgBootException("完成空托盘组入库任务时, 更新容器失败");  
2358 - }  
2359 - success = locationService.updateContainerCodeAndStatus(toLocationCode, containerCode, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode);  
2360 log.info("完成空托盘组入库任务" + taskHeader.getId()); 2298 log.info("完成空托盘组入库任务" + taskHeader.getId());
2361 - if (!success) {  
2362 - throw new JeecgBootException("完成空托盘组入库任务时, 更新库位失败");  
2363 - }  
2364 return Result.ok("完成空托盘组入库任务成功"); 2299 return Result.ok("完成空托盘组入库任务成功");
2365 } 2300 }
2366 2301