From 8261210f18ca2dc741a8628ccfdc34c30d33906b Mon Sep 17 00:00:00 2001 From: youjie <272855983@qq.com> Date: Wed, 15 Nov 2023 09:48:39 +0800 Subject: [PATCH] 配盘完成以后 平库出库 --- ant-design-vue-jeecg/src/api/api.js | 2 ++ ant-design-vue-jeecg/src/views/system/inventory/InventoryHeaderList.vue | 5 ----- ant-design-vue-jeecg/src/views/system/shipment/ShipmentContainerHeaderList.vue | 26 +++++++++++++++++++++++++- huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/controller/ShipmentCombinationController.java | 40 ++++++++++++++++++++++++++++++++++++---- huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/IShipmentCombinationService.java | 5 +++++ huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/impl/ShipmentCombinationServiceImpl.java | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 6 files changed, 220 insertions(+), 11 deletions(-) diff --git a/ant-design-vue-jeecg/src/api/api.js b/ant-design-vue-jeecg/src/api/api.js index 88ff3ac..4b39f37 100644 --- a/ant-design-vue-jeecg/src/api/api.js +++ b/ant-design-vue-jeecg/src/api/api.js @@ -280,6 +280,8 @@ export const createShipmentTaskByAgv = (params) => postAction('/shipment/shipmen export const createBatchShipmentTaskByAgv = (params) => postAction('/shipment/shipmentCombination/createBatchShipmentTaskByAgv', params); //创建出库任务和AGV去接 export const createShipmentTaskAndAgvTask = (params) => postAction('/shipment/shipmentCombination/createShipmentTaskAndAgvTask', params); +//完成平库出库 +export const completeFlatShipment = (params) => postAction('/shipment/shipmentCombination/completeFlatShipment', params); // 中转HTTP请求 export const transitRESTful = { diff --git a/ant-design-vue-jeecg/src/views/system/inventory/InventoryHeaderList.vue b/ant-design-vue-jeecg/src/views/system/inventory/InventoryHeaderList.vue index d927b76..8775ef6 100644 --- a/ant-design-vue-jeecg/src/views/system/inventory/InventoryHeaderList.vue +++ b/ant-design-vue-jeecg/src/views/system/inventory/InventoryHeaderList.vue @@ -206,11 +206,6 @@ export default { dataIndex: 'containerCode' }, { - title: '物料编码', - align: "center", - dataIndex: 'materialCode' - }, - { title: '容器状态', align: "center", dataIndex: 'containerStatus_dictText', diff --git a/ant-design-vue-jeecg/src/views/system/shipment/ShipmentContainerHeaderList.vue b/ant-design-vue-jeecg/src/views/system/shipment/ShipmentContainerHeaderList.vue index 93c5fea..8112ef1 100644 --- a/ant-design-vue-jeecg/src/views/system/shipment/ShipmentContainerHeaderList.vue +++ b/ant-design-vue-jeecg/src/views/system/shipment/ShipmentContainerHeaderList.vue @@ -124,6 +124,7 @@ <span slot="action" slot-scope="text, record"> <a v-if="record.status == 0 && record.zoneType =='A'" @click="openCreateShipmentTaskAndAgvTask(record)"><a-button type="primary">生成任务</a-button><a-divider type="vertical"/></a> <a v-if="record.status == 0 && record.zoneType =='L'" @click="selectPort(record)"><a-button type="primary">生成任务</a-button><a-divider type="vertical"/></a> + <a v-if="record.status == 0 && record.zoneType =='P'" @click="completeFlatShipment(record)"><a-button type="primary">平库出库</a-button><a-divider type="vertical"/></a> <!-- <a v-if="record.status == 0 && record.zoneType =='L'" @click="openCreateShipmentTaskAgv(record)"><a-button type="primary">生成任务</a-button><a-divider type="vertical"/></a>--> <a-popconfirm v-if="record.status == 0" v-has="'shipmentContainerHeader:delete'" title="确定取消配盘吗?" @confirm="() => handleDelete(record.id)"> <a><a-button type="danger">取消配盘</a-button> <a-divider type="vertical"/></a> @@ -154,7 +155,16 @@ import {deleteAction, getAction} from '@/api/manage' import ShipmentContainerDetailList from './ShipmentContainerDetailList' import {initDictOptions, filterMultiDictText} from '@/components/dict/JDictSelectUtil' import '@/assets/less/TableExpand.less' -import {createShipmentTask, execute, getCompanyList, getCustomerList, getShipmentTypeList, getZoneList} from '@/api/api' +import { + createShipmentTask, + createShipmentTaskAndAgvTask, + execute, + getCompanyList, + getCustomerList, + getShipmentTypeList, + completeFlatShipment, + getZoneList +} from '@/api/api' import {selectSortingPort, createShipmentTaskByAgv} from '@/api/api' import ShipmentContainerSelectModal from "./modules/ShipmentContainerSelectModal"; import CreateShipmentTaskByAgvModal from "./modules/CreateShipmentTaskByAgvModal"; @@ -356,6 +366,20 @@ export default { this.$refs.modalForm4.edit(record); this.$refs.modalForm4.title = "选择出库口"; }, + completeFlatShipment(record) { + const that = this; + that.confirmLoading = true; + completeFlatShipment(record).then((res) => { + if (res.success) { + that.$message.success(res.message); + } else { + that.$message.warning(res.message); + } + that.searchQuery(); + }).finally(() => { + that.confirmLoading = false; + }); + }, createBatchTask() { if (this.selectedRowKeys.length <= 0) { this.$message.warning('至少选择一条记录!') diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/controller/ShipmentCombinationController.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/controller/ShipmentCombinationController.java index 462ddf9..8ff8a3c 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/controller/ShipmentCombinationController.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/controller/ShipmentCombinationController.java @@ -14,12 +14,14 @@ import org.jeecg.modules.wms.config.port.entity.Port; import org.jeecg.modules.wms.config.port.service.IPortService; import org.jeecg.modules.wms.config.zone.entity.Zone; import org.jeecg.modules.wms.config.zone.service.IZoneService; +import org.jeecg.modules.wms.framework.controller.HuahengBaseController; import org.jeecg.modules.wms.framework.service.IHuahengMultiHandlerService; import org.jeecg.modules.wms.inventory.inventoryHeader.service.IInventoryDetailService; import org.jeecg.modules.wms.shipment.shipmentCombination.entity.FlatShipment; import org.jeecg.modules.wms.shipment.shipmentCombination.entity.Shipment; import org.jeecg.modules.wms.shipment.shipmentCombination.service.IShipmentCombinationService; import org.jeecg.modules.wms.shipment.shipmentContainerHeader.entity.ShipmentContainerHeader; +import org.jeecg.modules.wms.shipment.shipmentContainerHeader.service.IShipmentContainerDetailService; import org.jeecg.modules.wms.shipment.shipmentHeader.entity.CombinationParam; import org.jeecg.modules.wms.shipment.shipmentHeader.entity.ShipmentDetail; import org.jeecg.modules.wms.shipment.shipmentHeader.entity.ShipmentHeader; @@ -43,7 +45,7 @@ import lombok.extern.slf4j.Slf4j; @RestController @RequestMapping("/shipment/shipmentCombination") @Slf4j -public class ShipmentCombinationController { +public class ShipmentCombinationController extends HuahengBaseController { @Resource private IShipmentDetailService shipmentDetailService; @@ -52,6 +54,8 @@ public class ShipmentCombinationController { @Resource private IShipmentCombinationService shipmentCombinationService; @Resource + private IShipmentContainerDetailService shipmentContainerDetailService; + @Resource private ILocationService locationService; @Resource private IZoneService zoneService; @@ -212,7 +216,7 @@ public class ShipmentCombinationController { } /** - * 平库出库,有托盘号 + * 平库出库,通过托盘号,包括配盘和出库 * @return */ @AutoLog(value = "平库出库,通过托盘") @@ -226,7 +230,7 @@ public class ShipmentCombinationController { } /** - * 平库出库,有托盘号 + * 平库出库,通过库位号,包括配盘和出库 * @return */ @AutoLog(value = "平库出库,通过库位") @@ -240,6 +244,26 @@ public class ShipmentCombinationController { } /** + * 平库出库 + * @return + */ + @ApiOperation(value = "平库出库", notes = "平库出库") + @PostMapping("/completeFlatShipment") + @ResponseBody + public Result completeFlatShipment(@RequestBody ShipmentContainerHeader shipmentContainerHeader, HttpServletRequest req) { + String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(req); + String lockKey = warehouseCode; + Result result = handleMultiProcess("createShipmentTaskAndAgvTask", lockKey, new MultiProcessListener() { + @Override + public Result<?> doProcess() { + Result result = shipmentCombinationService.completeFlatShipment(shipmentContainerHeader); + return result; + } + }); + return result; + } + + /** * 立库区 * 创建出库任务, 出库任务完成以后,AGV去接 * @return @@ -282,7 +306,15 @@ public class ShipmentCombinationController { @ResponseBody public Result createShipmentTaskAndAgvTask(@RequestBody ShipmentContainerHeader shipmentContainerHeader, HttpServletRequest req) { String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(req); - Result result = shipmentCombinationService.createShipmentTaskAndAgvTask(shipmentContainerHeader, QuantityConstant.TASK_TYPE_WHOLESHIPMENT, warehouseCode); + String lockKey = warehouseCode; + Result result = handleMultiProcess("createShipmentTaskAndAgvTask", lockKey, new MultiProcessListener() { + @Override + public Result<?> doProcess() { + Result result = + shipmentCombinationService.createShipmentTaskAndAgvTask(shipmentContainerHeader, QuantityConstant.TASK_TYPE_WHOLESHIPMENT, warehouseCode); + return result; + } + }); return result; } } diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/IShipmentCombinationService.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/IShipmentCombinationService.java index aa0d50b..87a1764 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/IShipmentCombinationService.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/IShipmentCombinationService.java @@ -56,4 +56,9 @@ public interface IShipmentCombinationService { * @return */ Result flatShipmentByLocationCode(String locationCode, List<FlatShipment> flatShipments, String warehouseCode); + + /** + * 根据配盘信息,完成平库出库 + */ + Result completeFlatShipment(ShipmentContainerHeader shipmentContainerHeader); } diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/impl/ShipmentCombinationServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/impl/ShipmentCombinationServiceImpl.java index 0ea2b24..395184e 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/impl/ShipmentCombinationServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/impl/ShipmentCombinationServiceImpl.java @@ -638,7 +638,7 @@ public class ShipmentCombinationServiceImpl implements IShipmentCombinationServi } // 出库数量 BigDecimal shipmentQty = shipmentDetail.getQty().subtract(shipmentDetail.getTaskQty()); - // 判断是否还有需要出库的物料,如果没有就跳过该物料 + // 判断是否还有需要出库的物 料,如果没有就跳过该物料 if (shipmentQty.compareTo(BigDecimal.ZERO) <= 0) { throw new JeecgBootException("平库出库失败,出库数量必须大于0"); } @@ -844,6 +844,157 @@ public class ShipmentCombinationServiceImpl implements IShipmentCombinationServi return reuslt; } + /** + * 根据配盘信息,完成平库出库 + * @param shipmentContainerHeader + * @return + */ + @Override + @Transactional(rollbackFor = JeecgBootException.class) + public Result completeFlatShipment(ShipmentContainerHeader shipmentContainerHeader) { + String warehouseCode = shipmentContainerHeader.getWarehouseCode(); + String fromLocationCode = shipmentContainerHeader.getFromLocationCode(); + String toLocationCode = shipmentContainerHeader.getToLocationCode(); + String containerCode = shipmentContainerHeader.getContainerCode(); + String zoneCode = shipmentContainerHeader.getZoneCode(); + boolean success = false; + InventoryHeader inventoryHeader = inventoryHeaderService.getInventoryHeaderByContainerCode(containerCode, warehouseCode); + if (inventoryHeader == null) { + return Result.error("完成平库出库失败, 没有找到库存头" + containerCode); + } + List<InventoryTransaction> inventoryTransactionList = new ArrayList<>(); + List<Integer> shipmentIdList = new ArrayList<>(); + List<ShipmentDetail> shipmentDetailList = new ArrayList<>(); + List<ShipmentDetail> updateStatusShipmentDetailList = new ArrayList<>(); + List<ShipmentContainerDetail> shipmentContainerDetailList = + shipmentContainerDetailService.getShipmentContainerDetailListByHeaderId(shipmentContainerHeader.getId()); + if (CollectionUtils.isEmpty(shipmentContainerDetailList)) { + return Result.error("完成平库出库失败, 配盘明细为空"); + } + for (ShipmentContainerDetail shipmentContainerDetail : shipmentContainerDetailList) { + if (shipmentContainerDetail == null) { + throw new JeecgBootException("完成平库出库失败, 没有找到出库组盘详情"); + } + ShipmentDetail shipmentDetail = shipmentDetailService.getById(shipmentContainerDetail.getShipmentDetailId()); + if (shipmentDetail == null) { + throw new JeecgBootException("完成平库出库失败, 没有找到出库详情" + shipmentContainerDetail.getShipmentDetailId()); + } + ShipmentHeader shipmentHeader = shipmentHeaderService.getById(shipmentDetail.getShipmentId()); + if (shipmentHeader == null) { + throw new JeecgBootException("完成平库出库失败, 没有找到出库单" + shipmentDetail.getShipmentId()); + } + int shipmentDetailId = shipmentDetail.getId(); + BigDecimal shipmentQty = shipmentDetail.getShipmentQty(); + shipmentQty = shipmentQty.add(shipmentContainerDetail.getQty()); + int status = QuantityConstant.SHIPMENT_HEADER_COMPLETED; + if (shipmentDetail.getQty().compareTo(shipmentQty) == 0) { + status = QuantityConstant.SHIPMENT_HEADER_COMPLETED; + } else if (shipmentDetail.getQty().compareTo(shipmentQty) > 0) { + status = QuantityConstant.SHIPMENT_HEADER_OFF_SHELF; + } else if (shipmentDetail.getQty().compareTo(shipmentQty) < 0) { + throw new JeecgBootException("完成平库出库失败, 出库单 单据数量不能小于出库数量"); + } + shipmentDetailList.add(shipmentDetail); + ShipmentDetail updateStatusShipmentDetail = new ShipmentDetail(); + updateStatusShipmentDetail.setId(shipmentDetailId); + updateStatusShipmentDetail.setStatus(status); + updateStatusShipmentDetail.setShipmentQty(shipmentQty); + updateStatusShipmentDetailList.add(updateStatusShipmentDetail); + InventoryDetail inventoryDetail = inventoryDetailService.getById(shipmentContainerDetail.getInventoryDetailId()); + if (inventoryDetail == null) { + throw new JeecgBootException("完成平库出库失败,出库任务没有找到库存详情" + shipmentContainerDetail.getInventoryDetailId()); + } + BigDecimal taskQty = inventoryDetail.getTaskQty().subtract(shipmentContainerDetail.getQty()); + BigDecimal qty = inventoryDetail.getQty().subtract(shipmentContainerDetail.getQty()); + inventoryDetail.setTaskQty(taskQty); + inventoryDetail.setQty(qty); + inventoryDetail.setLocationCode(toLocationCode); + // 扣减后的库存不能小于0 + if (inventoryDetail.getQty().compareTo(BigDecimal.ZERO) < 0) { + throw new JeecgBootException("完成平库出库失败,扣减库存大于wms库存"); + } + if (inventoryDetail.getQty().compareTo(BigDecimal.ZERO) == 0) { + if (inventoryDetail.getTaskQty().compareTo(BigDecimal.ZERO) != 0) { + throw new JeecgBootException("完成平库出库失败,已无库存量可以扣减"); + } + success = inventoryDetailService.removeById(inventoryDetail.getId()); + if (!success) { + throw new JeecgBootException("完成平库出库失败,删除库存详情失败"); + } + } else { + success = inventoryDetailService.updateQtyAndTaskQtyAndLocationCode(qty, taskQty, toLocationCode, inventoryDetail.getId()); + if (!success) { + throw new JeecgBootException("完成平库出库失败,更新库存详情失败"); + } + } + + InventoryTransaction inventoryTransaction = new InventoryTransaction(); + inventoryTransaction.setType(QuantityConstant.INVENTORY_TRANSACTION_SHIPMENT); + inventoryTransaction.setWarehouseCode(warehouseCode); + inventoryTransaction.setCompanyCode(inventoryDetail.getCompanyCode()); + inventoryTransaction.setContainerCode(containerCode); + inventoryTransaction.setZoneCode(zoneCode); + inventoryTransaction.setFromLocationCode(fromLocationCode); + inventoryTransaction.setToLocationCode(toLocationCode); + inventoryTransaction.setMaterialCode(inventoryDetail.getMaterialCode()); + inventoryTransaction.setMaterialName(inventoryDetail.getMaterialName()); + inventoryTransaction.setMaterialSpec(inventoryDetail.getMaterialSpec()); + inventoryTransaction.setMaterialUnit(inventoryDetail.getMaterialUnit()); + inventoryTransaction.setInventoryStatus(inventoryDetail.getInventoryStatus()); + inventoryTransaction.setShipmentId(shipmentContainerDetail.getShipmentId()); + inventoryTransaction.setShipmentCode(shipmentHeader.getCode()); + inventoryTransaction.setShipmentType(shipmentHeader.getType()); + inventoryTransaction.setShipmentDetailId(shipmentContainerDetail.getShipmentDetailId()); + inventoryTransaction.setShipmentContainerDetailId(shipmentContainerDetail.getId()); + inventoryTransaction.setBatch(inventoryDetail.getBatch()); + inventoryTransaction.setLot(inventoryDetail.getLot()); + inventoryTransaction.setProject(inventoryDetail.getProject()); + inventoryTransaction.setQty(shipmentContainerDetail.getQty()); + inventoryTransaction.setShipmentQty(shipmentContainerDetail.getQty()); + BigDecimal inventoryQty = inventoryDetailService.getInventorySumQty(inventoryDetail); + inventoryTransaction.setInventoryQty(inventoryQty); + inventoryTransactionList.add(inventoryTransaction); + shipmentIdList.add(shipmentContainerDetail.getShipmentId()); + } + success = inventoryTransactionService.saveBatch(inventoryTransactionList); + if (!success) { + throw new JeecgBootException("完成平库出库失败,保存库存详情失败"); + } + List<InventoryDetail> inventoryDetailList = inventoryDetailService.getInventoryDetailListByInventoryHeaderId(inventoryHeader.getId()); + if (inventoryDetailList.size() == 0) { + success = inventoryHeaderService.removeById(inventoryHeader.getId()); + if (!success) { + throw new JeecgBootException("完成平库出库失败,删除库存头失败"); + } + } + if (shipmentContainerHeader == null) { + throw new JeecgBootException("完成平库出库失败,获取出库组盘头失败"); + } + shipmentContainerHeader.setStatus(QuantityConstant.SHIPMENT_CONTAINER_FINISHED); + success = shipmentContainerHeaderService.updateStatusById(QuantityConstant.SHIPMENT_CONTAINER_FINISHED, shipmentContainerHeader.getId()); + if (!success) { + throw new JeecgBootException("完成平库出库失败,更新出库组盘头失败"); + } + inventoryDetailList = inventoryDetailService.getInventoryDetailListByInventoryHeaderId(inventoryHeader.getId()); + if (inventoryDetailList.size() != 0) { + if (!taskHeaderService.combineInventoryDetail(containerCode, warehouseCode)) { + throw new JeecgBootException("完成平库出库失败, 合并入库库存失败"); + } + } + success = shipmentDetailService.updateBatchById(updateStatusShipmentDetailList); + if (!success) { + throw new JeecgBootException("完成平库出库失败,更新出库详情失败"); + } + shipmentIdList = shipmentIdList.stream().distinct().collect(Collectors.toList()); + for (Integer shipmentId : shipmentIdList) { + success = shipmentHeaderService.updateShipmentHeaderStatus(shipmentId); + if (!success) { + throw new JeecgBootException("完成平库出库失败,更新出库单头失败"); + } + } + return Result.OK("完成平库出库"); + } + @Override @Transactional(rollbackFor = JeecgBootException.class) @OperationLog(bizId = "''", bizType = "'出库单追踪'", tag = "'出库任务生成'", extra = "#extraJsonString1", -- libgit2 0.22.2