diff --git a/ant-design-vue-jeecg/src/api/api.js b/ant-design-vue-jeecg/src/api/api.js index 048c6a7..be32270 100644 --- a/ant-design-vue-jeecg/src/api/api.js +++ b/ant-design-vue-jeecg/src/api/api.js @@ -279,6 +279,8 @@ export const flatQuickReceipt = (params) => postAction('/receipt/receiveHeader/f export const quickReceipt = (params) => postAction('/task/taskHeader/quickReceipt', params) //悬臂库入库 export const cantaleverReceipt = (params) => postAction('/task/taskHeader/cantaleverReceipt', params) +//悬臂暂存区入库 +export const receiptStageingReceipt = (params) => postAction('/task/taskHeader/receiptStageingReceipt', params) //快速入库 export const stageingReceipt = (params) => postAction('/task/taskHeader/stageingReceipt', params) //快速出库,批量快速出整托 @@ -337,6 +339,8 @@ export const reduceInventoryDetail = (params) => postAction('/inventory/inventor export const getInventoryDetailByLocationCode = (params) => getAction('/inventory/inventoryDetail/list', params) //快速出库 export const quickShipment = (params) => postAction('/task/taskHeader/quickShipment', params) +//悬臂库出库 +export const cantaleverShipment = (params) => postAction('/task/taskHeader/cantaleverShipment', params) //出库复核 export const shipmentCheck = (params) => postAction('/shipment/shipmentCombination/shipmentCheck', params) //查询盘点明细子表 diff --git a/ant-design-vue-jeecg/src/views/system/task/AllTaskHeaderList.vue b/ant-design-vue-jeecg/src/views/system/task/AllTaskHeaderList.vue index e6794af..5ea9936 100644 --- a/ant-design-vue-jeecg/src/views/system/task/AllTaskHeaderList.vue +++ b/ant-design-vue-jeecg/src/views/system/task/AllTaskHeaderList.vue @@ -90,13 +90,15 @@ <div class="table-operator"> <a-button v-has="'taskHeader:emptyIn'" @click="createEmptyIn()" type="primary">空托入库</a-button> <a-button v-has="'taskHeader:manyEmptyIn'" @click="createManyEmptyIn()" type="primary">空托组入库</a-button> - <a-button v-has="'taskHeader:quickReceipt'" @click="quickReceipt()" type="primary">快速入库</a-button> - <a-button v-has="'taskHeader:quickReceipt'" @click="stageingReceipt()" type="primary">暂存区入库</a-button> + <a-button v-has="'taskHeader:quickReceipt'" @click="quickReceipt()" type="primary">货架库入库</a-button> + <a-button v-has="'taskHeader:quickReceipt'" @click="stageingReceipt()" type="primary">货架暂存区入库</a-button> <a-button v-has="'taskHeader:quickReceipt'" @click="cantaleverReceipt()" type="primary">悬臂库入库</a-button> + <a-button v-has="'taskHeader:quickReceipt'" @click="cantaleverStageingReceipt()" type="primary">悬臂库暂存区入库</a-button> <a-button v-has="'taskHeader:callReceiptBox'" @click="callReceiptBox()" type="primary" >呼叫入库有货托盘</a-button> <a-button v-has="'taskHeader:callReceiptBox'" @click="callReceiptEmptyBox()" type="primary" >呼叫入库空托盘</a-button> <a-button v-has="'taskHeader:emptyOut'" @click="createEmptyOut()" type="primary">空托出库</a-button> - <a-button v-has="'taskHeader:quickShipment'" @click="quickShipment()" type="primary">快速出库</a-button> + <a-button v-has="'taskHeader:quickShipment'" @click="quickShipment()" type="primary">货架库出库</a-button> + <a-button v-has="'taskHeader:quickShipment'" @click="cantaleverShipment()" type="primary">悬臂库出库</a-button> <a-button v-has="'taskHeader:manyEmptyOut'" @click="batchCreateEmptyOut()" type="primary">批量空托出库</a-button> <a-button v-has="'taskHeader:manyEmptyOut'" @click="createManyEmptyOut()" type="primary">空托组出库</a-button> <a-button v-has="'taskHeader:callShipmentBox'" @click="callShipmentBox()" type="primary" >呼叫出库托盘</a-button> @@ -210,6 +212,8 @@ <over-station-task-modal ref="overStationModal" @ok="modalFormOk"></over-station-task-modal> <StageingReceiptModal ref="stageingReceiptModal" @ok="modalFormOk"></StageingReceiptModal> <shipment-material-modal ref="shipmentMaterialModal" @ok="modalFormOk"></shipment-material-modal> + <CantaleverShipmentModal ref="cantaleverShipmentModal" @ok="modalFormOk"></CantaleverShipmentModal> + <CantaleverStageingReceiptModal ref="cantaleverStageingReceiptModal" @ok="modalFormOk"></CantaleverStageingReceiptModal> </a-card> </template> @@ -241,11 +245,15 @@ import OverStationTaskModal from "@views/system/task/modules/OverStationTaskModa import StageingReceiptModal from "@views/system/task/modules/StageingReceiptModal.vue"; import ShipmentMaterialModal from "@views/system/task/modules/ShipmentMaterialModal.vue"; import CantaleverTaskModal from "@views/system/task/modules/CantaleverTaskModal.vue"; +import CantaleverShipmentModal from "@views/system/task/modules/CantaleverShipmentModal.vue"; +import CantaleverStageingReceiptModal from "@views/system/task/modules/CantaleverStageingReceiptModal.vue"; export default { name: "AllTaskHeaderList", mixins: [JeecgListMixin], components: { + CantaleverStageingReceiptModal, + CantaleverShipmentModal, CantaleverTaskModal, ShipmentMaterialModal, StageingReceiptModal, @@ -529,6 +537,10 @@ export default { this.$refs.shipmentMaterialModal.edit(); this.$refs.shipmentMaterialModal.title = "快速出库"; }, + cantaleverShipment(){ + this.$refs.cantaleverShipmentModal.edit(); + this.$refs.cantaleverShipmentModal.title = "悬臂库出库"; + }, stageingReceipt(){ this.$refs.stageingReceiptModal.edit(); this.$refs.stageingReceiptModal.title = "暂存区入库"; @@ -588,6 +600,10 @@ export default { this.$refs.cantaleverTaskModal.edit(); this.$refs.cantaleverTaskModal.title = "悬臂库入库"; }, + cantaleverStageingReceipt(){ + this.$refs.cantaleverStageingReceiptModal.edit(); + this.$refs.cantaleverStageingReceiptModal.title = "悬臂暂存区入库"; + }, callReceiptBox() { this.$refs.modalForm5.edit(); this.$refs.modalForm5.title = "呼叫入库有货托盘"; diff --git a/ant-design-vue-jeecg/src/views/system/task/modules/CantaleverShipmentModal.vue b/ant-design-vue-jeecg/src/views/system/task/modules/CantaleverShipmentModal.vue new file mode 100644 index 0000000..181cb7c --- /dev/null +++ b/ant-design-vue-jeecg/src/views/system/task/modules/CantaleverShipmentModal.vue @@ -0,0 +1,179 @@ +<template> + <a-modal + :title="title" + :width="800" + :visible="visible" + :maskClosable="false" + :confirmLoading="confirmLoading" + @ok="handleOk" + @cancel="handleCancel"> + + <a-spin :spinning="confirmLoading"> + <a-form-model ref="form" :label-col="labelCol" :wrapper-col="wrapperCol" :model="model"> + <!-- 主表单区域 --> +<!-- <a-row class="form-row" :gutter="24">--> +<!-- <a-col :lg="8">--> +<!-- <a-form-model-item label="托盘号" :rules="[{ required: true, message: '请输入托盘号!' }]">--> +<!-- <a-input placeholder="请输入托盘号" v-model="quickMainModel.containerCode"/>--> +<!-- </a-form-model-item>--> +<!-- </a-col>--> +<!-- <a-col :lg="10">--> +<!-- <a-form-model-item label="入库口">--> +<!--<!– <a-input placeholder="请输入入库口" v-model="quickMainModel.toPort"/>–>--> +<!-- <j-search-select-tag--> +<!-- placeholder="请选择入库口"--> +<!-- v-model="quickMainModel.toPort"--> +<!-- dict="port,name,code,type!='2'"--> +<!-- :pageSize="5"--> +<!-- :async="true">--> +<!-- </j-search-select-tag>--> +<!-- </a-form-model-item>--> +<!-- </a-col>--> +<!-- </a-row>--> + <!-- 子表单区域 --> + <a-tabs defaultActiveKey="1"> + <a-tab-pane tab="物料信息" key="1"> + <div> + <a-row type="flex" style="margin-bottom:10px" :gutter="24"> + <a-col :span="12">物料编码</a-col> + <a-col :span="8">数量</a-col> + <a-col :span="4">操作</a-col> + </a-row> + <a-row type="flex" style="margin-bottom:-20px" :gutter="24" v-for="(item, index) in quickMainModel.receiptEntityList" :key="index"> + <a-col style="display: none"> + <a-form-model-item> + <a-input placeholder="id" v-model="item.id"/> + </a-form-model-item> + </a-col> + <a-col :span="12"> + <a-form-model-item> + <j-search-select-tag + placeholder="请选择" + v-model="item.materialCode" + :dict="'material,name,code'" + :pageSize="5" + :async="true"> + </j-search-select-tag> + </a-form-model-item> + </a-col> + <a-col :span="8"> + <a-form-model-item> + <a-input placeholder="数量" v-model="item.qty"/> + </a-form-model-item> + </a-col> + <a-col :span="4"> + <a-form-model-item> + <a-icon type="minus-circle" @click="delRowCustom(index)" style="fontSize :20px"/> + </a-form-model-item> + </a-col> + </a-row> + <a-button type="dashed" style="width: 100%;margin-top: 10px" @click="addRowCustom"><a-icon type="plus"/>添加物料信息</a-button> + </div> + </a-tab-pane> + </a-tabs> + </a-form-model> + </a-spin> + </a-modal> +</template> + +<script> + +import JEditableTable from '@/components/jeecg/JEditableTable' +import {cantaleverShipment, execute, quickReceipt, quickShipment} from '@/api/api' +import JDate from '@/components/jeecg/JDate' +import JSelectMultiCanUseContainer from "../../../../components/jeecgbiz/JSelectMultiCanUseContainer"; + +export default { + name: 'CantaleverShipmentModal', + components: { + JDate, JEditableTable,JSelectMultiCanUseContainer + }, + data() { + return { + title: '悬臂库出库', + visible: false, + confirmLoading: false, + model: {}, + labelCol: { + xs: {span: 24}, + sm: {span: 4} + }, + wrapperCol: { + xs: {span: 24}, + sm: {span: 24} + }, + activeKey: '1', + quickMainModel: { + receiptEntityList: [{}], + }, + // 客户信息 + url: { + add: '/test/jeecgOrderMain/add', + edit: '/test/jeecgOrderMain/edit', + } + } + }, + created() { + }, + methods: { + handleOk() { + this.validateFields() + }, + handleCancel() { + this.visible = false + }, + + addRowCustom() { + this.quickMainModel.receiptEntityList.push({}); + this.$forceUpdate(); + }, + delRowCustom(index) { + console.log(index) + this.quickMainModel.receiptEntityList.splice(index, 1); + this.$forceUpdate(); + }, + addRowTicket() { + this.quickMainModel.jeecgOrderTicketList.push({}); + console.log(this.quickMainModel.jeecgOrderTicketList) + this.$forceUpdate(); + }, + delRowTicket(index) { + console.log(index) + this.quickMainModel.jeecgOrderTicketList.splice(index, 1); + this.$forceUpdate(); + }, + + edit(record) { + this.visible = true + this.activeKey = '1' + this.quickMainModel = Object.assign({ + receiptEntityList: [{}] + }, record); + }, + /** 触发表单验证 */ + validateFields() { + // 触发表单验证 + this.$refs.form.validate(valid => { + //alert(JSON.stringify(this.quickMainModel)); + this.quickShipment(this.quickMainModel); + }) + }, + + quickShipment(record) { + this.confirmLoading = true + this.model = Object.assign({}, record); + cantaleverShipment(this.model).then((res) => { + this.loading = false; + if (res.success) { + this.$message.success(res.message); + this.$emit('ok'); + this.visible = false + } else { + this.$message.error(res.message); + } + this.confirmLoading = false + }); + }, + } +} +</script> \ No newline at end of file diff --git a/ant-design-vue-jeecg/src/views/system/task/modules/CantaleverStageingReceiptModal.vue b/ant-design-vue-jeecg/src/views/system/task/modules/CantaleverStageingReceiptModal.vue new file mode 100644 index 0000000..bbb8879 --- /dev/null +++ b/ant-design-vue-jeecg/src/views/system/task/modules/CantaleverStageingReceiptModal.vue @@ -0,0 +1,172 @@ +<template> + <a-modal + :title="title" + :width="800" + :visible="visible" + :maskClosable="false" + :confirmLoading="confirmLoading" + @ok="handleOk" + @cancel="handleCancel"> + + <a-spin :spinning="confirmLoading"> + <a-form-model ref="form" :label-col="labelCol" :wrapper-col="wrapperCol" :model="model"> + <!-- 主表单区域 --> + <a-row class="form-row" :gutter="24"> +<!-- <a-col :lg="12">--> +<!-- <a-form-model-item label="托盘号" :rules="[{ required: true, message: '请输入托盘号!' }]">--> +<!-- <a-input placeholder="请输入托盘号" v-model="quickMainModel.containerCode"/>--> +<!-- </a-form-model-item>--> +<!-- </a-col>--> + <a-col :lg="12"> + <a-form-model-item label="暂存区" :rules="[{ required: true, message: '请输入暂存区位置!' }]"> + <a-input placeholder="请输入暂存区位置" v-model="quickMainModel.fromPort"/> + </a-form-model-item> + </a-col> + </a-row> + <!-- 子表单区域 --> + <a-tabs defaultActiveKey="1"> + <a-tab-pane tab="物料信息" key="1"> + <div> + <a-row type="flex" style="margin-bottom:10px" :gutter="24"> + <a-col :span="12">物料编码</a-col> + <a-col :span="8">数量</a-col> + <a-col :span="4">操作</a-col> + </a-row> + <a-row type="flex" style="margin-bottom:-20px" :gutter="24" v-for="(item, index) in quickMainModel.receiptEntityList" :key="index"> + <a-col style="display: none"> + <a-form-model-item> + <a-input placeholder="id" v-model="item.id"/> + </a-form-model-item> + </a-col> + <a-col :span="12"> + <a-form-model-item> + <j-search-select-tag + placeholder="请选择" + v-model="item.materialCode" + :dict="'material,name,code'" + :pageSize="5" + :async="true"> + </j-search-select-tag> + </a-form-model-item> + </a-col> + <a-col :span="8"> + <a-form-model-item> + <a-input placeholder="数量" v-model="item.qty"/> + </a-form-model-item> + </a-col> + <a-col :span="4"> + <a-form-model-item> + <a-icon type="minus-circle" @click="delRowCustom(index)" style="fontSize :20px"/> + </a-form-model-item> + </a-col> + </a-row> + <a-button type="dashed" style="width: 100%;margin-top: 10px" @click="addRowCustom"><a-icon type="plus"/>添加物料信息</a-button> + </div> + </a-tab-pane> + </a-tabs> + </a-form-model> + </a-spin> + </a-modal> +</template> + +<script> + +import JEditableTable from '@/components/jeecg/JEditableTable' +import {execute, quickReceipt, receiptStageingReceipt, stageingReceipt} from '@/api/api' +import JDate from '@/components/jeecg/JDate' +import JSelectMultiCanUseContainer from "../../../../components/jeecgbiz/JSelectMultiCanUseContainer"; + +export default { + name: 'CantaleverStageingReceiptModal', + components: { + JDate, JEditableTable,JSelectMultiCanUseContainer + }, + data() { + return { + title: '悬臂暂存区入库', + visible: false, + confirmLoading: false, + model: {}, + labelCol: { + xs: {span: 24}, + sm: {span: 4} + }, + wrapperCol: { + xs: {span: 24}, + sm: {span: 24} + }, + activeKey: '1', + quickMainModel: { + receiptEntityList: [{}], + }, + // 客户信息 + url: { + add: '/test/jeecgOrderMain/add', + edit: '/test/jeecgOrderMain/edit', + } + } + }, + created() { + }, + methods: { + handleOk() { + this.validateFields() + }, + handleCancel() { + this.visible = false + }, + + addRowCustom() { + this.quickMainModel.receiptEntityList.push({}); + this.$forceUpdate(); + }, + delRowCustom(index) { + console.log(index) + this.quickMainModel.receiptEntityList.splice(index, 1); + this.$forceUpdate(); + }, + addRowTicket() { + this.quickMainModel.jeecgOrderTicketList.push({}); + console.log(this.quickMainModel.jeecgOrderTicketList) + this.$forceUpdate(); + }, + delRowTicket(index) { + console.log(index) + this.quickMainModel.jeecgOrderTicketList.splice(index, 1); + this.$forceUpdate(); + }, + + edit(record) { + this.visible = true + this.activeKey = '1' + this.quickMainModel = Object.assign({ + receiptEntityList: [{}] + }, record); + }, + /** 触发表单验证 */ + validateFields() { + // 触发表单验证 + this.$refs.form.validate(valid => { + //alert(JSON.stringify(this.quickMainModel)); + this.receipt(this.quickMainModel); + }) + }, + + receipt(record) { + this.confirmLoading = true + this.model = Object.assign({}, record); + receiptStageingReceipt(this.model).then((res) => { + this.loading = false; + if (res.success) { + this.$message.success(res.message); + this.$emit('ok'); + this.visible = false + } else { + this.$message.error(res.message); + } + this.confirmLoading = false + }); + }, + } +} +</script> \ No newline at end of file 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 9c22e95..46f5480 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 @@ -31,6 +31,8 @@ public interface IShipmentCombinationService { Result autoCombination(String shipmentCode, boolean advice, String warehouseCode); + Result autoCombinationCantalever(String shipmentCode, boolean advice, String warehouseCode); + Result stockUp(List<ShipmentHeader> shipmentHeaderList, String warehouseCode); Result createShipmentTask(ShipmentContainerHeader shipmentContainerHeader, String warehouseCode, long shipmentOrder, int sequence, int sequenceNumber); @@ -54,6 +56,8 @@ public interface IShipmentCombinationService { Result autoCombinationDetail(ShipmentDetail shipmentDetail, boolean advice, BigDecimal shipQty); + Result autoCombinationDetailCantalever(ShipmentDetail shipmentDetail, boolean advice, BigDecimal shipQty); + Result stockUp(ShipmentDetail shipmentDetail); Result stockUpMove(Location location); 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 d9d4125..c637d3f 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 @@ -299,6 +299,40 @@ public class ShipmentCombinationServiceImpl implements IShipmentCombinationServi @Override @Transactional(rollbackFor = Exception.class) + public Result autoCombinationCantalever(String shipmentCode, boolean advice, String warehouseCode) { + log.info("开始自动配盘,单号" + shipmentCode); + ShipmentHeader shipmentHeader = shipmentHeaderService.getShipmentHeaderByCode(shipmentCode, warehouseCode); + if (shipmentHeader == null) { + return Result.error("自动配盘, 系统没有此单据" + shipmentCode); + } + if (shipmentHeader.getLastStatus() >= QuantityConstant.SHIPMENT_HEADER_COMPLETED) { + return Result.OK("自动配盘,出库单已经作业完毕"); + } + LambdaQueryWrapper<ShipmentDetail> shipmentDetailLambdaQueryWrapper = Wrappers.lambdaQuery(); + shipmentDetailLambdaQueryWrapper.eq(ShipmentDetail::getShipmentCode, shipmentCode).eq(ShipmentDetail::getWarehouseCode, warehouseCode); + List<ShipmentDetail> shipmentDetailList = shipmentDetailService.list(shipmentDetailLambdaQueryWrapper); + if (shipmentDetailList.isEmpty()) { + return Result.error("自动配盘, 出库单没有明细", null); + } + boolean over = true; + for (ShipmentDetail shipmentDetail : shipmentDetailList) { + if (shipmentDetail.getTaskQty().compareTo(shipmentDetail.getQty()) < 0) { + over = false; + } + Result result = shipmentCombinationService.autoCombinationDetailCantalever(shipmentDetail, advice, null); + if (!result.isSuccess()) { + throw new JeecgBootException(result.getMessage()); + } + } + log.info("完成自动配盘,单号" + shipmentCode); + if (over) { + return Result.error("出库单已经配盘", null); + } + return Result.OK("自动组盘成功", null); + } + + @Override + @Transactional(rollbackFor = Exception.class) public Result stockUp(List<ShipmentHeader> shipmentHeaderList, String warehouseCode) { log.info("备货,单号" + shipmentHeaderList); List<String> shipmentCodeList = shipmentHeaderList.stream().map(ShipmentHeader::getCode).collect(Collectors.toList()); @@ -453,6 +487,101 @@ public class ShipmentCombinationServiceImpl implements IShipmentCombinationServi return Result.OK("自动配盘成功", null); } + /** + * 出库单据明细自动配盘 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public Result autoCombinationDetailCantalever(ShipmentDetail shipmentDetail, boolean advice, BigDecimal shipQty) { + // 出库数量 + BigDecimal shipmentQty = shipmentDetail.getQty().subtract(shipmentDetail.getTaskQty()); + // 判断是否还有需要出库的物料,如果没有就跳过该物料 + if (shipmentQty.compareTo(BigDecimal.ZERO) <= 0) { + return Result.OK("自动配盘时, 出库数量必须大于0"); + } + if (shipQty != null) { + shipmentQty = shipQty; + } + List<InventoryDetail> inventoryList = shipmentCombinationService.getInventorys(shipmentDetail); + // 去除已锁的库存 + ArrayList<InventoryDetail> removeInventoryList = new ArrayList<>(); + List<ReceiptContainerHeader> receiptContainerHeaderList = receiptContainerHeaderService.getUnCompleteCombineList(); + List<ShipmentContainerHeader> shipmentContainerHeaderList = shipmentContainerHeaderService.getNotCombineList(); + for (InventoryDetail inventoryDetail : inventoryList) { + String containerCode = inventoryDetail.getContainerCode(); + String warehouseCode = inventoryDetail.getWarehouseCode(); + Container container = containerService.getContainerByCode(containerCode, warehouseCode); + if (container == null) { + return Result.error("自动配盘时,没有找到容器:" + containerCode); + } + if (container.getStatus().equals(QuantityConstant.STATUS_CONTAINER_LOCK)) { + removeInventoryList.add(inventoryDetail); + continue; + } + for (ReceiptContainerHeader receiptContainerHeader : receiptContainerHeaderList) { + if (receiptContainerHeader.getContainerCode().equals(containerCode)) { + removeInventoryList.add(inventoryDetail); + continue; + } + } + for (ShipmentContainerHeader shipmentContainerHeader : shipmentContainerHeaderList) { + if (shipmentContainerHeader.getContainerCode().equals(containerCode)) { + removeInventoryList.add(inventoryDetail); + continue; + } + } + } + inventoryList.removeAll(removeInventoryList); + if (inventoryList.size() < 1) { + return Result.error("自动配盘时," + shipmentDetail.getMaterialName() + "没有符合出库条件的库存"); + } + + if (StringUtils.isNotEmpty(inventoryList)) { + inventoryList = inventoryList.stream() + .sorted((o1, o2) -> o2.getPosition().compareTo(o1.getPosition())).collect(Collectors.toList()); + inventoryList = inventoryList.stream() + .collect(Collectors.toMap( + InventoryDetail::getContainerCode, // 以 containerCode 为键 + detail -> detail, // 以 InventoryDetail 对象为值 + (existing, replacement) -> existing // 如果键冲突,保留现有的对象 + )) + .values() + .stream() + .collect(Collectors.toList()); + } + + for (InventoryDetail inventoryDetail : inventoryList) { + BigDecimal inventoryQty = inventoryDetail.getQty().subtract(inventoryDetail.getTaskQty()); + if (inventoryQty.compareTo(BigDecimal.ZERO) == 0) { + continue; + } + // 判断需要配盘数量是否等于0,等于0代表配盘完毕,完毕就退出内循环 + if (shipmentQty.compareTo(BigDecimal.ZERO) == 0) { + break; + } + if (shipmentQty.compareTo(BigDecimal.ZERO) < 0) { + throw new JeecgBootException("配盘时,出库数量不能小于0"); + } + CombinationModel combinationModel = new CombinationModel(); + combinationModel.setShipmentDetail(shipmentDetail); + combinationModel.setInventoryDetail(inventoryDetail); + if (inventoryQty.compareTo(shipmentQty) >= 0) { + combinationModel.setShipQty(shipmentQty); + shipmentQty = BigDecimal.ZERO; + } else { + combinationModel.setShipQty(inventoryQty); + shipmentQty = shipmentQty.subtract(inventoryQty); + } + + Result result = shipmentCombinationService.combination(combinationModel); + if (!result.isSuccess()) { + throw new JeecgBootException(result.getMessage()); + } + + } + return Result.OK("自动配盘成功", null); + } + @Override @Transactional(rollbackFor = Exception.class) public Result stockUp(ShipmentDetail shipmentDetail) { diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/service/IShipmentHeaderService.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/service/IShipmentHeaderService.java index 625b904..cbbed7c 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/service/IShipmentHeaderService.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/service/IShipmentHeaderService.java @@ -50,6 +50,8 @@ public interface IShipmentHeaderService extends IService<ShipmentHeader> { Result autoShipment(String shipmentCode, String warehouseCode); + Result autoShipmentCantalever(String shipmentCode, String warehouseCode); + Result autoShipmentAdvice(String shipmentCode, String warehouseCode); Result autoFlatShipmentAdvice(String shipmentCode, String warehouseCode); diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/service/impl/ShipmentHeaderServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/service/impl/ShipmentHeaderServiceImpl.java index 189cdff..39f985c 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/service/impl/ShipmentHeaderServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/service/impl/ShipmentHeaderServiceImpl.java @@ -542,6 +542,99 @@ public class ShipmentHeaderServiceImpl extends ServiceImpl<ShipmentHeaderMapper, return Result.OK("自动出库成功"); } + @Override + @Transactional(rollbackFor = Exception.class) + public Result autoShipmentCantalever(String shipmentCode, String warehouseCode) { + if (StringUtils.isEmpty(shipmentCode)) { + return Result.error("自动出库, 出库单编码为空"); + } + if (StringUtils.isEmpty(warehouseCode)) { + return Result.error("自动出库, 仓库编码为空"); + } + ShipmentHeader shipmentHeader = shipmentHeaderService.getShipmentHeaderByCode(shipmentCode, warehouseCode); + if (shipmentHeader == null) { + throw new JeecgBootException("自动出库, 没有找到出库单"); + } + String zoneCode = shipmentHeader.getZoneCode(); + if (StringUtils.isEmpty(zoneCode)) { + throw new JeecgBootException("自动出库, 库区编码为空"); + } + Zone zone = zoneService.getZoneByCode(zoneCode, warehouseCode); + if (zone == null) { + throw new JeecgBootException("自动出库, 库区为空"); + } + String zoneType = zone.getType(); + if (StringUtils.isEmpty(zoneType)) { + throw new JeecgBootException("自动出库, 库区类型编码为空"); + } + if (!zoneType.equals(QuantityConstant.ZONE_TYPE_STEREOSCOPIC)) { + throw new JeecgBootException("自动出库, 库区类型必须为立库区类型"); + } + Result result = shipmentCombinationService.autoCombinationCantalever(shipmentCode, false, warehouseCode); + if (!result.isSuccess()) { + throw new JeecgBootException("自动出库," + result.getMessage()); + } + List<ShipmentContainerDetail> shipmentContainerDetailList = shipmentContainerDetailService.getShipmentContainerDetailListByShipmentCode(shipmentCode); + if (CollectionUtils.isEmpty(shipmentContainerDetailList)) { + throw new JeecgBootException("自动出库, 没有找到出库配盘详情"); + } + List<Integer> shipmentContainerIdList = + shipmentContainerDetailList.stream().map(ShipmentContainerDetail::getShipmentContainerId).distinct().collect(Collectors.toList()); + long shipmentOrder = System.currentTimeMillis(); + int sequenceNumber = shipmentContainerIdList.size(); + int sequence = 0; + for (int shipmentContainerId : shipmentContainerIdList) { + sequence++; + ShipmentContainerHeader shipmentContainerHeader = shipmentContainerHeaderService.getById(shipmentContainerId); + if (shipmentContainerHeader == null) { + throw new JeecgBootException("自动出库, 没有找到出库表头:" + shipmentContainerId); + } + if (shipmentContainerHeader.getStatus().intValue() > QuantityConstant.SHIPMENT_CONTAINER_BUILD) { + continue; + } + int taskType = shipmentContainerHeader.getTaskType(); + int type = QuantityConstant.PORT_TYPE_PICK; + if (taskType == QuantityConstant.TASK_TYPE_WHOLESHIPMENT) { + type = QuantityConstant.PORT_TYPE_OUT; + } + if (zoneCode.equals(QuantityConstant.ZONE_B)) { + type = QuantityConstant.PORT_TYPE_OUT; + } + String fromLocationCode = shipmentContainerHeader.getFromLocationCode(); + if (StringUtils.isEmpty(fromLocationCode)) { + throw new JeecgBootException("自动出库, 没有起始库位编码"); + } + Location fromLocation = locationService.getLocationByCode(fromLocationCode, warehouseCode); + if (fromLocation == null) { + throw new JeecgBootException("自动出库, 没有起始库位" + fromLocationCode); + } + Integer roadWay = fromLocation.getRoadWay(); + List<Port> portList = portService.getPortListByType(type, roadWay, zoneCode, warehouseCode); + if (portList == null) { + throw new JeecgBootException("自动出库, 没有合适的出库口"); + } + Port port = portList.get(0); + shipmentContainerHeader.setToPort(port.getCode()); + boolean success = shipmentContainerHeaderService.updateById(shipmentContainerHeader); + if (!success) { + throw new JeecgBootException("自动出库, 更新出库组盘头失败"); + } + result = huahengMultiHandlerService.createShipmentTask(shipmentContainerHeader, warehouseCode, shipmentOrder, sequence, sequenceNumber); + if (!result.isSuccess()) { + throw new JeecgBootException("自动出库, " + result.getMessage()); + } + String containerCode = shipmentContainerHeader.getContainerCode(); + if (StringUtils.isEmpty(containerCode)) { + throw new JeecgBootException("自动出库, 容器号为空"); + } + TaskHeader taskHeader = taskHeaderService.getUnCompleteTaskByContainerCode(containerCode, warehouseCode); + if (taskHeader == null) { + throw new JeecgBootException("自动出库, 没有找到容器号对应任务" + containerCode); + } + } + return Result.OK("自动出库成功"); + } + /** * 自动预配盘出库 */ diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/controller/TaskHeaderController.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/controller/TaskHeaderController.java index 82c25b2..5041eb4 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/controller/TaskHeaderController.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/controller/TaskHeaderController.java @@ -947,6 +947,27 @@ public class TaskHeaderController extends HuahengBaseController { return result; } + + /** + * 快速入库 + * @return + */ + @AutoLog(value = "悬臂库暂存区入库", operateType = 2) + @PostMapping("receiptStageingReceipt") + @ApiOperation("悬臂库暂存区入库") + public Result receiptStageingReceipt(@RequestBody QucikReceiptEntity qucikReceiptEntity, HttpServletRequest req) { + String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(req); + qucikReceiptEntity.setWarehouseCode(warehouseCode); + Result result = handleMultiProcess("receiptStageingReceipt", new MultiProcessListener() { + @Override + public Result<?> doProcess() { + Result result = taskHeaderService.receiptStageingReceipt(qucikReceiptEntity); + return result; + } + }); + return result; + } + /** * 快速出库 * @return @@ -968,6 +989,26 @@ public class TaskHeaderController extends HuahengBaseController { } /** + * 悬臂库出库 + * @return + */ + @AutoLog(value = "悬臂库出库", operateType = 3) + @PostMapping("cantaleverShipment") + @ApiOperation("悬臂库出库") + public Result cantaleverShipment(@RequestBody QucikReceiptEntity qucikReceiptEntity, HttpServletRequest req) { + String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(req); + qucikReceiptEntity.setWarehouseCode(warehouseCode); + Result result = handleMultiProcess("cantaleverShipment", new MultiProcessListener() { + @Override + public Result<?> doProcess() { + Result result = taskHeaderService.cantaleverShipment(qucikReceiptEntity); + return result; + } + }); + return result; + } + + /** * 质检登记 * @return */ diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/QucikReceiptEntity.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/QucikReceiptEntity.java index 1d86621..e93b94d 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/QucikReceiptEntity.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/QucikReceiptEntity.java @@ -8,6 +8,7 @@ import lombok.Data; public class QucikReceiptEntity { private String containerCode; + private String fromPort; private String toPort; private String warehouseCode; private List<ReceiptEntity> receiptEntityList; 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 03b91c0..9a358ca 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 @@ -507,6 +507,12 @@ public interface ITaskHeaderService extends IService<TaskHeader> { */ Result cantaleverReceipt(QucikReceiptEntity qucikReceiptEntity); + /** + * add + * @return + */ + Result receiptStageingReceipt(QucikReceiptEntity qucikReceiptEntity); + /** * add @@ -536,8 +542,14 @@ public interface ITaskHeaderService extends IService<TaskHeader> { Result updatePriority(String id, String priority); /** - * add + * 快速出库 * @return */ Result quickShipment(QucikReceiptEntity qucikReceiptEntity); + + /** + * 悬臂库出库 + * @return + */ + Result cantaleverShipment(QucikReceiptEntity qucikReceiptEntity); } 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 b965ef9..55907e5 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 @@ -3223,7 +3223,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea throw new JeecgBootException("悬臂库入库,每次只能入1个"); } String receiptType = QuantityConstant.RECEIPT_BILL_TYPE_QTR; - String remark = "快速入库"; + String remark = "悬臂库入库"; ReceiptHeader receiptHeader = new ReceiptHeader(); receiptHeader.setWarehouseCode(warehouseCode); receiptHeader.setCompanyCode(QuantityConstant.DEFAULT_COMPANY); @@ -3231,19 +3231,19 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea receiptHeader.setRemark(remark); Result result = receiptHeaderService.saveReceiptHeader(receiptHeader); if (!result.isSuccess()) { - throw new JeecgBootException("快速入库, 创建入库单头失败" + result.getMessage()); + throw new JeecgBootException("悬臂库入库, 创建入库单头失败" + result.getMessage()); } for (ReceiptEntity receiptEntity : receiptEntityList) { BigDecimal qty = receiptEntity.getQty(); String materialCode = receiptEntity.getMaterialCode(); if (StringUtils.isEmpty(materialCode)) { - throw new JeecgBootException("快速入库, 物料编码为空"); + throw new JeecgBootException("悬臂库入库, 物料编码为空"); } if (qty == null) { - throw new JeecgBootException("快速入库, 数量必须填写"); + throw new JeecgBootException("悬臂库入库, 数量必须填写"); } if (qty.compareTo(BigDecimal.ZERO) <= 0) { - throw new JeecgBootException("快速入库, 数量必须大于0"); + throw new JeecgBootException("悬臂库入库, 数量必须大于0"); } ReceiptDetail receiptDetail = new ReceiptDetail(); receiptDetail.setWarehouseCode(warehouseCode); @@ -3254,7 +3254,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea receiptDetail.setQty(qty); Material material = materialService.getMaterialByCode(materialCode); if (material == null) { - throw new JeecgBootException("快速入库, 获取物料:" + materialCode + " 信息失败"); + throw new JeecgBootException("悬臂库入库, 获取物料:" + materialCode + " 信息失败"); } receiptDetail.setInventoryStatus(QuantityConstant.QUALITY_GOOD); receiptDetail.setMaterialCode(materialCode); @@ -3263,7 +3263,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea receiptDetail.setMaterialUnit(material.getUnit()); success = receiptDetailService.save(receiptDetail); if (!success) { - throw new JeecgBootException("快速入库, 保存入库单详情失败"); + throw new JeecgBootException("悬臂库入库, 保存入库单详情失败"); } Receive receive = new Receive(); @@ -3289,7 +3289,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea receiptContainerHeader.setToPort(toPort); success = receiptContainerHeaderService.updateById(receiptContainerHeader); if (!success) { - throw new JeecgBootException("快速入库,更新入库组盘头失败"); + throw new JeecgBootException("悬臂库入库,更新入库组盘头失败"); } result = receiptContainerHeaderService.createReceiptTask(receiptContainerHeader, warehouseCode); if (!result.isSuccess()) { @@ -3302,9 +3302,148 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea // } // } if (!receiptHeaderService.updateReceiptHeader(receiptHeader.getId())) { - throw new JeecgBootException("快速入库, 更新入库表单头失败"); + throw new JeecgBootException("悬臂库入库, 更新入库表单头失败"); } - return Result.OK("快速入库成功"); + return Result.OK("悬臂库入库成功"); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Result receiptStageingReceipt(QucikReceiptEntity qucikReceiptEntity) { + boolean success = false; + String containerCode = qucikReceiptEntity.getContainerCode(); + List<ReceiptEntity> receiptEntityList = qucikReceiptEntity.getReceiptEntityList(); + String toPort = qucikReceiptEntity.getToPort(); + toPort = "P1001"; + String fromPort = qucikReceiptEntity.getFromPort(); + String warehouseCode = qucikReceiptEntity.getWarehouseCode(); + List<Receive> receiveList = new ArrayList<>(); +// if (StringUtils.isEmpty(containerCode)) { +// return Result.error("快速入库,容器编码为空"); +// } + if (StringUtils.isEmpty(warehouseCode)) { + return Result.error("悬臂库入库,仓库编码为空"); + } + if (StringUtils.isEmpty(receiptEntityList)) { + return Result.error("悬臂库入库,入库信息为空"); + } + Container container = containerService.createLSContainer(warehouseCode); + if (container == null) { + return Result.error("悬臂库入库,没有找到容器" + containerCode); + } + containerCode = container.getCode(); +// Port port = portService.getPortByCode(toPort, warehouseCode); +// if (port != null) { +// int portType = Integer.parseInt(port.getType()); +// if (portType == QuantityConstant.PORT_TYPE_OUT) { +// return Result.error("快速入库,不能选择出库口" + toPort); +// } +// } + for (ReceiptEntity receiptEntity : receiptEntityList) { + if(receiptEntity.getQty().compareTo(BigDecimal.ZERO) == 0) { + continue; + } + if(receiptEntity.getQty().compareTo(BigDecimal.ONE) != 0) { + throw new JeecgBootException("悬臂库入库,入库数量只能是1"); + } + } + if (receiptEntityList.size() > 1) { + throw new JeecgBootException("悬臂库入库,每次只能入1个"); + } + String receiptType = QuantityConstant.RECEIPT_BILL_TYPE_QTR; + String remark = "悬臂库入库"; + ReceiptHeader receiptHeader = new ReceiptHeader(); + receiptHeader.setWarehouseCode(warehouseCode); + receiptHeader.setCompanyCode(QuantityConstant.DEFAULT_COMPANY); + receiptHeader.setType(receiptType); + receiptHeader.setRemark(remark); + Result result = receiptHeaderService.saveReceiptHeader(receiptHeader); + if (!result.isSuccess()) { + throw new JeecgBootException("悬臂库入库, 创建入库单头失败" + result.getMessage()); + } + for (ReceiptEntity receiptEntity : receiptEntityList) { + BigDecimal qty = receiptEntity.getQty(); + String materialCode = receiptEntity.getMaterialCode(); + if (StringUtils.isEmpty(materialCode)) { + throw new JeecgBootException("悬臂库入库, 物料编码为空"); + } + if (qty == null) { + throw new JeecgBootException("悬臂库入库, 数量必须填写"); + } + if (qty.compareTo(BigDecimal.ZERO) <= 0) { + throw new JeecgBootException("悬臂库入库, 数量必须大于0"); + } + ReceiptDetail receiptDetail = new ReceiptDetail(); + receiptDetail.setWarehouseCode(warehouseCode); + receiptDetail.setCompanyCode(QuantityConstant.DEFAULT_COMPANY); + receiptDetail.setReceiptCode(receiptHeader.getCode()); + receiptDetail.setReceiptId(receiptHeader.getId()); + receiptDetail.setStatus(QuantityConstant.RECEIPT_HEADER_BUILD); + receiptDetail.setQty(qty); + Material material = materialService.getMaterialByCode(materialCode); + if (material == null) { + throw new JeecgBootException("悬臂库入库, 获取物料:" + materialCode + " 信息失败"); + } + receiptDetail.setInventoryStatus(QuantityConstant.QUALITY_GOOD); + receiptDetail.setMaterialCode(materialCode); + receiptDetail.setMaterialName(material.getName()); + receiptDetail.setMaterialSpec(material.getSpec()); + receiptDetail.setMaterialUnit(material.getUnit()); + success = receiptDetailService.save(receiptDetail); + if (!success) { + throw new JeecgBootException("悬臂库入库, 保存入库单详情失败"); + } + + Receive receive = new Receive(); + receive.setId(receiptDetail.getId()); + receive.setContainerCode(containerCode); + receive.setMaterialCode(materialCode); + receive.setMaterialName(receiptDetail.getMaterialName()); + receive.setMaterialSpec(receiptDetail.getMaterialSpec()); + receive.setMaterialUnit(receiptDetail.getMaterialUnit()); + receive.setInventoryStatus(receiptDetail.getInventoryStatus()); + receive.setQty(receiptDetail.getQty()); + receive.setTaskQty(receiptDetail.getQty()); + receiveList.add(receive); + } + result = receiveService.receiving(receiveList, warehouseCode); + if (!result.isSuccess()) { + throw new JeecgBootException(result.getMessage()); + } + ReceiptContainerHeader receiptContainerHeader = receiptContainerHeaderService.getUnCompleteReceiptContainerByCode(containerCode, warehouseCode); + if (receiptContainerHeader == null) { + throw new JeecgBootException(result.getMessage()); + } + receiptContainerHeader.setToPort(toPort); + success = receiptContainerHeaderService.updateById(receiptContainerHeader); + if (!success) { + throw new JeecgBootException("悬臂库入库,更新入库组盘头失败"); + } + result = receiptContainerHeaderService.createReceiptTask(receiptContainerHeader, warehouseCode); + if (!result.isSuccess()) { + throw new JeecgBootException(result.getMessage()); + } +// TaskHeader taskHeader = (TaskHeader)result.getResult(); +// if (taskHeader.getTaskType() == QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT) { +// if (port == null) { +// throw new JeecgBootException("快速入库, 生成补充任务时必须有入库口"); +// } +// } + if (!receiptHeaderService.updateReceiptHeader(receiptHeader.getId())) { + throw new JeecgBootException("悬臂库入库, 更新入库表单头失败"); + } + + AgvTask agvTask = new AgvTask(); + agvTask.setWarehouseCode(warehouseCode); + agvTask.setTaskType(QuantityConstant.AGV_TYPE_TAKE_AND_RELEASE); + agvTask.setStatus(QuantityConstant.AGV_TASK_STATUS_BUILD); + agvTask.setContainerCode(containerCode); + agvTask.setFromPort(fromPort); + agvTask.setToPort(toPort); + agvTask.setPriority(10); + result = agvTaskService.addAgvTask(agvTask, warehouseCode); + log.info(String.format("AutoCreateAgvTask 生成AGV任务执行:" + result.getMessage())); + return Result.OK("悬臂库入库成功"); } @Override @@ -4906,4 +5045,81 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea } return Result.OK("快速出库成功"); } + + @Override + @Transactional(rollbackFor = Exception.class) + public Result cantaleverShipment(QucikReceiptEntity qucikReceiptEntity) { + boolean success = false; + List<ReceiptEntity> receiptEntityList = qucikReceiptEntity.getReceiptEntityList(); + String warehouseCode = qucikReceiptEntity.getWarehouseCode(); + if (StringUtils.isEmpty(warehouseCode)) { + return Result.error("快速出库,仓库编码为空"); + } + if (StringUtils.isEmpty(receiptEntityList)) { + return Result.error("快速出库,出库信息为空"); + } + String receiptType = QuantityConstant.SHIPMENT_BILL_TYPE_QTC; + String remark = "快速出库"; + String zoneCode = "A"; + for (ReceiptEntity receiptEntity : receiptEntityList) { + BigDecimal qty = receiptEntity.getQty(); + String materialCode = receiptEntity.getMaterialCode(); + List<InventoryDetail> inventoryDetailList = inventoryDetailService.getInventoryDetailListByMaterialCode(materialCode, warehouseCode); + if (CollectionUtils.isNotEmpty(inventoryDetailList)) { + InventoryDetail inventoryDetail = inventoryDetailList.get(0); + zoneCode = inventoryDetail.getZoneCode(); + } + } + ShipmentHeader shipmentHeader = new ShipmentHeader(); + shipmentHeader.setWarehouseCode(warehouseCode); + shipmentHeader.setCompanyCode(QuantityConstant.DEFAULT_COMPANY); + shipmentHeader.setType(receiptType); + shipmentHeader.setRemark(remark); + shipmentHeader.setZoneCode(zoneCode); + shipmentHeader.setZoneType(QuantityConstant.ZONE_TYPE_STEREOSCOPIC); + Result result = shipmentHeaderService.saveShipmentHeader(shipmentHeader); + if (!result.isSuccess()) { + throw new JeecgBootException("快速出库, 创建出库单头失败" + result.getMessage()); + } + for (ReceiptEntity receiptEntity : receiptEntityList) { + BigDecimal qty = receiptEntity.getQty(); + String materialCode = receiptEntity.getMaterialCode(); + if (StringUtils.isEmpty(materialCode)) { + throw new JeecgBootException("快速出库, 物料编码为空"); + } + if (qty.compareTo(BigDecimal.ZERO) <= 0) { + throw new JeecgBootException("快速出库, 单据数量必须大于0"); + } + ShipmentDetail shipmentDetail = new ShipmentDetail(); + shipmentDetail.setWarehouseCode(warehouseCode); + shipmentDetail.setCompanyCode(QuantityConstant.DEFAULT_COMPANY); + shipmentDetail.setShipmentCode(shipmentHeader.getCode()); + shipmentDetail.setShipmentId(shipmentHeader.getId()); + shipmentDetail.setStatus(QuantityConstant.RECEIPT_HEADER_BUILD); + shipmentDetail.setZoneCode(zoneCode); + shipmentDetail.setQty(qty); + Material material = materialService.getMaterialByCode(materialCode); + if (material == null) { + throw new JeecgBootException("快速出库, 获取物料:" + materialCode + " 信息失败"); + } + shipmentDetail.setInventoryStatus(QuantityConstant.QUALITY_GOOD); + shipmentDetail.setMaterialCode(materialCode); + shipmentDetail.setMaterialName(material.getName()); + shipmentDetail.setMaterialSpec(material.getSpec()); + shipmentDetail.setMaterialUnit(material.getUnit()); + success = shipmentDetailService.save(shipmentDetail); + if (!success) { + throw new JeecgBootException("快速出库, 保存出库单详情失败"); + } + + } + if (!shipmentHeaderService.updateShipmentHeader(shipmentHeader.getId())) { + throw new JeecgBootException("快速出库, 更新出库单失败"); + } + result = shipmentHeaderService.autoShipmentCantalever(shipmentHeader.getCode(), warehouseCode); + if (!result.isSuccess()) { + throw new JeecgBootException("快速出库, 更新出库表单头失败"); + } + return Result.OK("快速出库成功"); + } }