Commit 2693f41e4caa17d9f760815cb2a22051e7ab73e3

Authored by 肖超群
1 parent 4cffe7ee

完善悬臂库移库

ant-design-vue-jeecg/src/views/system/receipt/ReceiptHeaderList.vue
... ... @@ -197,7 +197,7 @@
197 197 <a-button type="primary">组盘</a-button>
198 198 </a>
199 199 <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'">
200   - <a-button type="primary">线圈组盘</a-button>
  200 + <a-button type="primary">悬臂库组盘</a-button>
201 201 </a>
202 202 <a v-show="record.firstStatus == '0' && flowOff == '1'" @click="createAudit(record)"><a-button type="primary">提交审核</a-button></a>
203 203 <a v-show="record.nextAuditor == username && flowOff == '1'" @click="audit(record)"><a-button type="primary">审核</a-button></a>
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/IInventoryDetailService.java
... ... @@ -165,7 +165,7 @@ public interface IInventoryDetailService extends IService&lt;InventoryDetail&gt; {
165 165  
166 166 Result shipmentCheck(List<ShipmentContainerAdvice> shipmentContainerAdviceList, String warehouseCode);
167 167  
168   - boolean updateInventoryDetailPositionByContainerCode(String containerCode, String warehouseCode);
  168 + boolean updateInventoryDetailPositionByLocationCode(String locationCode, String warehouseCode);
169 169  
170 170  
171 171 }
... ...
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&lt;InventoryDetailMappe
838 838 }
839 839  
840 840 @Override
841   - public boolean updateInventoryDetailPositionByContainerCode(String containerCode, String warehouseCode) {
842   - List<InventoryDetail> inventoryDetailList = inventoryDetailService.getInventoryDetailListByContainerCode(containerCode, warehouseCode);
  841 + public boolean updateInventoryDetailPositionByLocationCode(String location, String warehouseCode) {
  842 + List<InventoryDetail> inventoryDetailList = inventoryDetailService.getInventoryDetailListByLocationCode(location, warehouseCode);
843 843 int position = 1;
  844 + if (CollectionUtils.isEmpty(inventoryDetailList)) {
  845 + return true;
  846 + }
844 847 List<InventoryDetail> updateInventoryDetailList = new ArrayList<>();
845 848 for (InventoryDetail inventoryDetail : inventoryDetailList) {
846 849 InventoryDetail updateInventoryDetail = new InventoryDetail();
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/TaskDetail.java
... ... @@ -204,6 +204,11 @@ public class TaskDetail implements Serializable {
204 204 @ApiModelProperty(value = "备用字段3")
205 205 private String userdef3;
206 206  
  207 + /** 位置 */
  208 + @Excel(name = "位置", width = 15)
  209 + @ApiModelProperty(value = "位置")
  210 + private Integer position;
  211 +
207 212 /** 创建人 */
208 213 @ApiModelProperty(value = "创建人")
209 214 private String createBy;
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/ITaskHeaderService.java
... ... @@ -113,6 +113,12 @@ public interface ITaskHeaderService extends IService&lt;TaskHeader&gt; {
113 113 Result calculateLocationThickness(List<InventoryDetail> inventoryDetailList, String locationCode, int maxThickness, String warehouseCode);
114 114  
115 115 /**
  116 + * 判断库位长度是否超限
  117 + * @return
  118 + */
  119 + boolean judgeLocationThickness(List<InventoryDetail> inventoryDetailList, String locationCode, int maxThickness, String warehouseCode);
  120 +
  121 + /**
116 122 * 取消任务,恢复数据
117 123 * @param taskHeader
118 124 * @return
... ...
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&lt;TaskHeaderMapper, TaskHea
1153 1153  
1154 1154 if (taskHeader.getZoneCode().equals(QuantityConstant.ZONE_B)) {
1155 1155 taskHeaderService.freshLocationThickness(taskId);
1156   - if(!inventoryDetailService.updateInventoryDetailPositionByContainerCode(taskHeader.getContainerCode(), taskHeader.getWarehouseCode())) {
1157   - throw new JeecgBootException("完成任务,更新库存位置失败");
  1156 + if(!inventoryDetailService.updateInventoryDetailPositionByLocationCode(taskHeader.getFromLocationCode(), taskHeader.getWarehouseCode())) {
  1157 + throw new JeecgBootException("完成任务,更新起始库存位置失败");
  1158 + }
  1159 + if(!inventoryDetailService.updateInventoryDetailPositionByLocationCode(taskHeader.getToLocationCode(), taskHeader.getWarehouseCode())) {
  1160 + throw new JeecgBootException("完成任务,更新目标库存位置失败");
1158 1161 }
1159 1162 }
1160 1163 return result;
... ... @@ -1213,6 +1216,27 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
1213 1216  
1214 1217 @Override
1215 1218 @Transactional(rollbackFor = Exception.class)
  1219 + public boolean judgeLocationThickness(List<InventoryDetail> inventoryDetailList, String locationCode, int maxThickness, String warehouseCode) {
  1220 + int totalThickness = 0;
  1221 + for (InventoryDetail inventoryDetail : inventoryDetailList) {
  1222 + String materialCode = inventoryDetail.getMaterialCode();
  1223 + BigDecimal qty = inventoryDetail.getQty();
  1224 + Material material = materialService.getMaterialByCode(materialCode);
  1225 + if (material == null) {
  1226 + throw new JeecgBootException("判断库位厚度失败,没有找到物料信息" + materialCode);
  1227 + }
  1228 + int thickness = material.getThickness();
  1229 + int gap = material.getGap();
  1230 + totalThickness = totalThickness + (thickness + gap) * qty.intValue();
  1231 + }
  1232 + if (totalThickness > maxThickness) {
  1233 + throw new JeecgBootException("判断库位厚度失败,计算出的长度" + totalThickness + "超过最大值" + maxThickness);
  1234 + }
  1235 + return true;
  1236 + }
  1237 +
  1238 + @Override
  1239 + @Transactional(rollbackFor = Exception.class)
1216 1240 public Result cancelTask(Integer taskId) {
1217 1241 TaskHeader taskHeader = this.getById(taskId);
1218 1242 if (taskHeader == null) {
... ... @@ -1532,6 +1556,17 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
1532 1556 return Result.error("创建移库任务失败,起始库位:" + fromLocationCode + "和目标库位:" + toLocationCode + "是同一个");
1533 1557 }
1534 1558 String containerCode = fromLocation.getContainerCode();
  1559 +
  1560 + List<InventoryDetail> toInventoryDetailList = inventoryDetailService.getInventoryDetailListByLocationCode(toLocationCode, warehouseCode);
  1561 + List<InventoryDetail> totalInventoryDetailList = new ArrayList<>();
  1562 + if (CollectionUtils.isNotEmpty(toInventoryDetailList)) {
  1563 + totalInventoryDetailList.addAll(toInventoryDetailList);
  1564 + }
  1565 + totalInventoryDetailList.addAll(fromInventoryDetailList);
  1566 + if(!taskHeaderService.judgeLocationThickness(totalInventoryDetailList, toLocationCode, toLocation.getMaxThickness(), warehouseCode)) {
  1567 + return Result.error("创建移库任务时,校验库位厚度失败,移库后库位超出最大凑度");
  1568 + }
  1569 +
1535 1570 // 这里增加组盘校验,如果此托盘存在未完成的组盘数据,则不能移库
1536 1571 // 校验入库组盘
1537 1572 if (receiptContainerHeaderService.havaUnCompleteCombineByLocationCode(fromLocationCode, warehouseCode)) {
... ... @@ -1612,6 +1647,12 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
1612 1647 throw new JeecgBootException("创建任务时,更新巷道值失败");
1613 1648 }
1614 1649 List<TaskDetail> taskDetailList = new ArrayList<>();
  1650 + fromInventoryDetailList = fromInventoryDetailList.stream().sorted(new Comparator<InventoryDetail>() {
  1651 + @Override
  1652 + public int compare(InventoryDetail o1, InventoryDetail o2) {
  1653 + return o1.getPosition() - o2.getPosition();
  1654 + }
  1655 + }).collect(Collectors.toList());
1615 1656 for (InventoryDetail inventoryDetail : fromInventoryDetailList) {
1616 1657 TaskDetail taskDetail = new TaskDetail();
1617 1658 taskDetail.setTaskHeaderId(taskHeader.getId());
... ... @@ -1628,6 +1669,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
1628 1669 taskDetail.setMaterialName(inventoryDetail.getMaterialName());
1629 1670 taskDetail.setMaterialUnit(inventoryDetail.getMaterialUnit());
1630 1671 taskDetail.setQty(inventoryDetail.getQty());
  1672 + taskDetail.setPosition(inventoryDetail.getPosition());
1631 1673 taskDetailList.add(taskDetail);
1632 1674 }
1633 1675 success = taskDetailService.saveBatch(taskDetailList);
... ... @@ -2027,9 +2069,9 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
2027 2069 if (!success) {
2028 2070 throw new JeecgBootException("完成入库任务时,保存库存交易失败");
2029 2071 }
2030   - if (!taskHeaderService.combineInventoryDetail(containerCode, warehouseCode)) {
2031   - throw new JeecgBootException("完成入库任务时, 合并入库库存失败");
2032   - }
  2072 +// if (!taskHeaderService.combineInventoryDetail(containerCode, warehouseCode)) {
  2073 +// throw new JeecgBootException("完成入库任务时, 合并入库库存失败");
  2074 +// }
2033 2075 List<Integer> receiptIdList = receiptDetaiList.stream().map(ReceiptDetail::getReceiptId).distinct().collect(Collectors.toList());
2034 2076 for (Integer receiptId : receiptIdList) {
2035 2077 success = receiptHeaderService.updateReceiptHeaderStatus(receiptId);
... ... @@ -2377,6 +2419,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
2377 2419 InventoryDetail inventoryDetail2 = inventoryDetailList.get(j);
2378 2420 if (inventoryDetail1.getMaterialCode().equals(inventoryDetail2.getMaterialCode()) && inventoryDetail1.getBatch().equals(inventoryDetail2.getBatch())
2379 2421 && inventoryDetail1.getLot().equals(inventoryDetail2.getLot()) && inventoryDetail1.getProject().equals(inventoryDetail2.getProject())
  2422 + && inventoryDetail1.getPosition().equals(inventoryDetail2.getPosition())
2380 2423 && inventoryDetail1.getInventoryStatus().equals(inventoryDetail2.getInventoryStatus())) {
2381 2424 // 属性一样的库存,相加合并。
2382 2425 if (StringUtils.isNotEmpty(inventoryDetail1.getSn())) {
... ... @@ -2602,8 +2645,11 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
2602 2645 if (toLocation == null) {
2603 2646 return Result.error("创建分拣任务时," + toLocationCode + "目标库位不存在");
2604 2647 }
2605   - if (StringUtils.isNotEmpty(toLocation.getContainerCode())) {
2606   - return Result.error("创建分拣任务时," + toLocationCode + "上已存在容器" + toLocation.getContainerCode());
  2648 + String toZoneCode = toLocation.getZoneCode();
  2649 + if (!toZoneCode.equals(QuantityConstant.ZONE_B)) {
  2650 + if (StringUtils.isNotEmpty(toLocation.getContainerCode())) {
  2651 + return Result.error("创建分拣任务时," + toLocationCode + "上已存在容器" + toLocation.getContainerCode());
  2652 + }
2607 2653 }
2608 2654 if (!QuantityConstant.STATUS_LOCATION_EMPTY.equals(toLocation.getStatus())) {
2609 2655 return Result.error("创建分拣任务时, 目标库位非空闲");
... ... @@ -3480,6 +3526,12 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
3480 3526 if (CollectionUtils.isEmpty(taskDetailList)) {
3481 3527 return Result.error("完成移库任务时, 任务详情为空");
3482 3528 }
  3529 + taskDetailList = taskDetailList.stream().sorted(new Comparator<TaskDetail>() {
  3530 + @Override
  3531 + public int compare(TaskDetail o1, TaskDetail o2) {
  3532 + return o1.getPosition() - o2.getPosition();
  3533 + }
  3534 + }).collect(Collectors.toList());
3483 3535 List<InventoryTransaction> inventoryTransactionList = new ArrayList<>();
3484 3536 for (TaskDetail taskDetail : taskDetailList) {
3485 3537 int inventoryDetailId = taskDetail.getFromInventoryDetailId();
... ... @@ -3534,43 +3586,98 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
3534 3586 if(!inventoryDetailService.saveBatch(inventoryDetailList)) {
3535 3587 throw new JeecgBootException("完成移库任务时,保存库存失败");
3536 3588 }
3537   - Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), QuantityConstant.TASK_TYPE_TRANSFER,
3538   - containerCode, fromLocationCode, toLocationCode, warehouseCode);
3539   - if (!result.isSuccess()) {
3540   - throw new JeecgBootException(result.getMessage());
3541   - }
  3589 +// Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), QuantityConstant.TASK_TYPE_TRANSFER,
  3590 +// containerCode, fromLocationCode, toLocationCode, warehouseCode);
  3591 +// if (!result.isSuccess()) {
  3592 +// throw new JeecgBootException(result.getMessage());
  3593 +// }
3542 3594 success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId());
3543 3595 if (!success) {
3544 3596 throw new JeecgBootException("完成移库任务时, 更新任务失败");
3545 3597 }
3546 3598 List<InventoryDetail> fromInventoryDetailList = inventoryDetailService.getInventoryDetailListByLocationCode(fromLocationCode, warehouseCode);
3547   - if (CollectionUtils.isNotEmpty(fromInventoryDetailList)) {
3548   - Container fromContainer = containerService.createLSContainer(warehouseCode);
3549   - String fromContainerCode = fromContainer.getCode();
3550   - if (!containerService.updateLocationCode(fromContainerCode, fromLocationCode, warehouseCode)) {
3551   - throw new JeecgBootException("完成移库任务时,更新容器失败");
3552   - }
3553   - if (!locationService.updateContainerCode(fromLocationCode, fromContainerCode, warehouseCode)) {
3554   - throw new JeecgBootException("完成移库任务时,更新库位失败");
  3599 + InventoryHeader toInventoryHeader = inventoryHeaderService.getInventoryHeaderByLocationCode(toLocationCode, warehouseCode);
  3600 + String toContainerCode = null;
  3601 + if (toInventoryHeader == null) {
  3602 + Container toContainer = containerService.createLSContainer(warehouseCode);
  3603 + toContainerCode = toContainer.getCode();
  3604 + } else {
  3605 + toContainerCode = toInventoryHeader.getContainerCode();
  3606 + }
  3607 + if (CollectionUtils.isEmpty(fromInventoryDetailList)) {
  3608 + if (!containerService.updateLocationCodeAndStatus(containerCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode)) {
  3609 + throw new JeecgBootException("完成移库任务时,更新起始容器失败");
3555 3610 }
3556   - InventoryHeader inventoryHeader = inventoryHeaderService.getInventoryHeaderByLocationCode(fromLocationCode, warehouseCode);
3557   - if (inventoryHeader == null) {
3558   - throw new JeecgBootException("完成移库任务时,没有找到库存头" + fromContainerCode);
  3611 + if (!locationService.updateContainerCodeAndStatus(fromLocationCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode)) {
  3612 + throw new JeecgBootException("完成移库任务时,更新起始库位失败");
3559 3613 }
3560   - if (!inventoryHeaderService.updateContainerCodeById(containerCode, inventoryHeader.getId())) {
3561   - throw new JeecgBootException("完成移库任务时,更新库存头失败");
  3614 + } else {
  3615 + if (!containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode)) {
  3616 + throw new JeecgBootException("完成移库任务时,更新起始容器失败");
3562 3617 }
3563   - List<InventoryDetail> updateInventoryList = new ArrayList<>();
3564   - for (InventoryDetail inventoryDetail : fromInventoryDetailList) {
3565   - InventoryDetail inventoryDetail1 = new InventoryDetail();
3566   - inventoryDetail1.setContainerCode(fromContainerCode);
3567   - inventoryDetail1.setId(inventoryDetail.getId());
3568   - updateInventoryList.add(inventoryDetail1);
  3618 + if (!locationService.updateStatus(fromLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode)) {
  3619 + throw new JeecgBootException("完成移库任务时,更新起始库位失败");
3569 3620 }
3570   - if (!inventoryDetailService.updateBatchById(updateInventoryList)) {
3571   - throw new JeecgBootException("完成移库任务时,更新库存明细失败");
  3621 + }
  3622 + if (!containerService.updateLocationCode(toContainerCode, toLocationCode, warehouseCode)) {
  3623 + throw new JeecgBootException("完成移库任务时,更新目标容器失败");
  3624 + }
  3625 + if (!locationService.updateContainerCodeAndStatus(toLocationCode, toContainerCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode)) {
  3626 + throw new JeecgBootException("完成移库任务时,更新目标库位失败");
  3627 + }
  3628 + if (toInventoryHeader == null) {
  3629 + InventoryHeader inventoryHeader = new InventoryHeader();
  3630 + inventoryHeader.setContainerCode(toContainerCode);
  3631 + inventoryHeader.setLocationCode(toLocationCode);
  3632 + inventoryHeader.setWarehouseCode(warehouseCode);
  3633 + inventoryHeader.setContainerStatus(QuantityConstant.STATUS_CONTAINER_EMPTY);
  3634 + inventoryHeader.setEnable(QuantityConstant.STATUS_ENABLE);
  3635 + inventoryHeader.setRoadWay(taskHeader.getRoadWay());
  3636 + if(!inventoryHeaderService.save(inventoryHeader)) {
  3637 + throw new JeecgBootException("完成移库任务时,完成库存头失败");
3572 3638 }
  3639 + toInventoryHeader = inventoryHeader;
  3640 + }
  3641 + List<InventoryDetail> updateInventoryList = new ArrayList<>();
  3642 + for (InventoryDetail inventoryDetail : inventoryDetailList) {
  3643 + InventoryDetail inventoryDetail1 = new InventoryDetail();
  3644 + inventoryDetail1.setContainerCode(toContainerCode);
  3645 + inventoryDetail1.setInventoryHeaderId(toInventoryHeader.getId());
  3646 + inventoryDetail1.setId(inventoryDetail.getId());
  3647 + updateInventoryList.add(inventoryDetail1);
  3648 + }
  3649 + if (!inventoryDetailService.updateBatchById(updateInventoryList)) {
  3650 + throw new JeecgBootException("完成移库任务时,更新库存明细失败");
  3651 + }
3573 3652  
  3653 + if (!inventoryHeaderService.updateInventoryContainerStatusByContainerCode(containerCode, warehouseCode)) {
  3654 + throw new JeecgBootException("完成移库任务时,更新托盘状态失败1");
  3655 + }
  3656 + if (!inventoryHeaderService.updateInventoryContainerStatusByContainerCode(toContainerCode, warehouseCode)) {
  3657 + throw new JeecgBootException("完成移库任务时,更新托盘状态失败2");
  3658 + }
  3659 + success = inventoryHeaderService.updateInventory(containerCode, fromLocationCode, warehouseCode);
  3660 + if (!success) {
  3661 + throw new JeecgBootException("完成移库任务时, 更新库存信息失败1");
  3662 + }
  3663 + success = inventoryHeaderService.updateInventory(toContainerCode, toLocationCode, warehouseCode);
  3664 + if (!success) {
  3665 + throw new JeecgBootException("完成移库任务时, 更新库存信息失败2");
  3666 + }
  3667 + if (CollectionUtils.isNotEmpty(fromInventoryDetailList)) {
  3668 + success = taskHeaderService.combineInventoryDetail(containerCode, warehouseCode);
  3669 + if (!success) {
  3670 + throw new JeecgBootException("完成移库任务时, 更新库存失败1");
  3671 + }
  3672 + } else {
  3673 + InventoryHeader fromInventoryHeader = inventoryHeaderService.getInventoryHeaderByLocationCode(fromLocationCode, warehouseCode);
  3674 + if (!inventoryHeaderService.removeById(fromInventoryHeader.getId())) {
  3675 + throw new JeecgBootException("调整库存,删除托盘:" + containerCode + "库存失败");
  3676 + }
  3677 + }
  3678 + success = taskHeaderService.combineInventoryDetail(toContainerCode, warehouseCode);
  3679 + if (!success) {
  3680 + throw new JeecgBootException("完成移库任务时, 更新库存失败2");
3574 3681 }
3575 3682 log.info("完成移库任务" + taskHeader.getId());
3576 3683 return Result.OK("完成移库任务成功");
... ...