From 1349b981ba16f8f40c3c7787a86d501a4582d6b1 Mon Sep 17 00:00:00 2001 From: zhaoyf <1783123481@qq.com> Date: Fri, 20 Nov 2026 19:29:49 +0800 Subject: [PATCH] =?UTF-8?q?add:=E5=A7=94=E5=A4=96=E5=87=BA=E5=BA=93?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8D=95=E6=8D=AE=E4=BF=AE=E6=94=B9=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/OutboundDeliveryServiceImpl.java | 53 +++ .../outBoundDelivery/DeliveryOutboundPage.vue | 357 +++++++++++++++++- .../sap/outBoundDelivery/outBoundDelivery.js | 9 +- 3 files changed, 413 insertions(+), 6 deletions(-) diff --git a/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/sap/outBoundDelivery/service/impl/OutboundDeliveryServiceImpl.java b/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/sap/outBoundDelivery/service/impl/OutboundDeliveryServiceImpl.java index 9c91e68d..00682f78 100644 --- a/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/sap/outBoundDelivery/service/impl/OutboundDeliveryServiceImpl.java +++ b/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/sap/outBoundDelivery/service/impl/OutboundDeliveryServiceImpl.java @@ -15,6 +15,7 @@ import org.nl.common.exception.BadRequestException; import org.nl.common.utils.IdUtil; import org.nl.common.utils.SecurityUtils; import org.nl.wms.ext_manage.api.ZDWmsApi; +import org.nl.wms.ext_manage.enums.EXTConstant; import org.nl.wms.ext_manage.sap.api.SapApi; import org.nl.wms.ext_manage.sap.api.dto.SubcontractConfirmBody; import org.nl.wms.ext_manage.sap.api.dto.SubcontractConfirmHeader; @@ -49,6 +50,8 @@ import org.nl.wms.warehouse_manage.enums.IOSEnum; import org.nl.wms.warehouse_manage.inAndOut.service.IOutBillService; import org.nl.wms.warehouse_manage.subcontractReverse.dao.SapSubcontractReverseRecord; import org.nl.wms.warehouse_manage.subcontractReverse.service.ISapSubcontractReverseRecordService; +import org.nl.wms.system_manage.service.param.ISysParamService; +import org.nl.wms.system_manage.service.param.dao.Param; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -97,6 +100,8 @@ public class OutboundDeliveryServiceImpl extends ServiceImpl> grouped = items.stream() .peek(item -> { if (StrUtil.isBlank(item.getLgort())) { @@ -476,6 +482,53 @@ public class OutboundDeliveryServiceImpl extends ServiceImpl items) { + Set zdStors = listZdStors(); + if (zdStors.isEmpty()) { + return; + } + List zdLgorts = items.stream() + .filter(Objects::nonNull) + .map(OutboundDeliveryItem::getLgort) + .filter(StrUtil::isNotBlank) + .map(String::trim) + .distinct() + .filter(zdStors::contains) + .collect(Collectors.toList()); + if (!zdLgorts.isEmpty()) { + throw new BadRequestException("下推失败:交货单" + order.getVbeln() + "的存储地点" + + String.join("、", zdLgorts) + "属于中鼎仓库,不能下推出库"); + } + } + + /** + * 中鼎仓库集合:系统参数 ZD_STOR_SET(仓库编码数组) + */ + private Set listZdStors() { + Param param = sysParamService.findByCode(EXTConstant.ZD_STOR_SET); + if (param == null || StrUtil.isBlank(param.getValue())) { + return Collections.emptySet(); + } + List codes; + try { + codes = JSONObject.parseArray(param.getValue(), String.class); + } catch (Exception e) { + // 兼容逗号分隔配置 + codes = StrUtil.split(param.getValue(), ','); + } + if (CollectionUtils.isEmpty(codes)) { + return Collections.emptySet(); + } + return codes.stream() + .filter(StrUtil::isNotBlank) + .map(String::trim) + .collect(Collectors.toSet()); + } + @Override public void pushZd(String billType, List ids) { if (CollectionUtils.isEmpty(ids)) { diff --git a/nladmin-ui/src/views/wms/pm_manage/sap/outBoundDelivery/DeliveryOutboundPage.vue b/nladmin-ui/src/views/wms/pm_manage/sap/outBoundDelivery/DeliveryOutboundPage.vue index 55a80193..c17e0ad2 100644 --- a/nladmin-ui/src/views/wms/pm_manage/sap/outBoundDelivery/DeliveryOutboundPage.vue +++ b/nladmin-ui/src/views/wms/pm_manage/sap/outBoundDelivery/DeliveryOutboundPage.vue @@ -79,16 +79,23 @@ - + - +
交货单号:{{ currentOrder.vbeln }}  |  供应商:{{ currentOrder.lifnr_name || currentOrder.lifnr || '-' }}  |  @@ -102,14 +109,136 @@ + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 行项目 + 新增行项目 +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 该单据含 {{ componentItems.length }} 条委外组件行,编辑时不显示,保存时原样保留。 +
+ +
@@ -118,7 +247,34 @@ import CRUD, { crud, header, presenter } from '@crud/crud' import crudOperation from '@crud/CRUD.operation' import rrOperation from '@crud/RR.operation' import pagination from '@crud/Pagination' -import { getDetail } from './outBoundDelivery' +import { getDetail, getParamValue } from './outBoundDelivery' + +const createItem = () => ({ + posnr: '', + material: '', + matl_desc: '', + deliv_qty: undefined, + unit: '', + po_number: '', + po_item: '', + werks: '', + lgort: '' +}) + +const createDefaultForm = () => ({ + id: null, + vbeln: '', + lifnr: '', + lifnr_name: '', + lfart: '', + billtype: '', + bldat: '', + wadat: '', + lfdat: '', + wadat_ist: '', + status: 'CREATED', + items: [] +}) export default { name: 'SapDeliveryOutbound', @@ -144,16 +300,35 @@ export default { { value: 'SUBCONTRACT_OUT', label: '委外交货出库' }, { value: 'TRANSFER_IN', label: '公司间调拨收货' }, { value: 'SALES_OUT', label: '原材料销售出库' }, + { value: 'TRANSFER_OUT', label: 'SAP公司间调拨出货' }, { value: 'SALES_RETURN_IN', label: '原材料销售退货' } ], + rules: { + vbeln: [{ required: true, message: '请输入交货单号', trigger: 'blur' }] + }, pushZdLoading: false, multipleSelection: [], + // 中鼎托管仓库(系统参数 ZD_STOR_SET):属于这些仓库的单据不能下推本地出库 + zdStorSet: [], + editVisible: false, + editSaving: false, + editItemLoading: false, + editForm: createDefaultForm(), + componentItems: [], detailVisible: false, detailLoading: false, currentOrder: {}, itemList: [] } }, + computed: { + operationPermission() { + return [].concat(this.permission.edit, this.permission.del) + } + }, + created() { + this.loadZdStorSet() + }, methods: { [CRUD.HOOK.beforeRefresh]() { if (this.query.datepick && this.query.datepick.length) { @@ -176,10 +351,42 @@ export default { const map = { CREATED: 'warning', POSTED: 'primary', COMPLETED: 'success', CANCELED: 'info' } return map[status] || '' }, + canEdit(row) { + return row && (row.status === 'CREATED' || row.status === 'CANCELED') + }, handleSelectionChange(selection) { this.multipleSelection = selection this.crud.selectionChangeHandler(selection) }, + // 中鼎仓库集合,取不到时后端仍会校验,不影响页面使用 + loadZdStorSet() { + getParamValue('ZD_STOR_SET').then(res => { + const value = res.data && res.data.value + this.zdStorSet = this.parseStorSet(value) + }).catch(() => { + this.zdStorSet = [] + }) + }, + parseStorSet(value) { + if (!value) { + return [] + } + try { + const parsed = JSON.parse(value) + if (Array.isArray(parsed)) { + return parsed.filter(item => item != null).map(item => String(item).trim()) + } + } catch (e) { + // 兼容逗号分隔配置 + } + return String(value).split(',').map(item => item.trim()).filter(item => item) + }, + isZdStor(lgort) { + if (!lgort) { + return false + } + return this.zdStorSet.indexOf(String(lgort).trim()) !== -1 + }, isPushDisabled() { if (this.multipleSelection.length !== 1) { return true @@ -192,6 +399,10 @@ export default { return } const row = this.multipleSelection[0] + if (this.isZdStor(row.lgort)) { + this.$message.error('交货单 ' + row.vbeln + ' 的存储地点 ' + row.lgort + ' 属于中鼎仓库,不能下推出库') + return + } this.$confirm('确认下推交货单 ' + row.vbeln + ' 生成出库单?', '下推出库', { confirmButtonText: '确定', cancelButtonText: '取消', @@ -232,6 +443,7 @@ export default { }) }).catch(() => {}) }, + // 点击交货单号查看明细 openDetailDialog(row) { this.currentOrder = { ...row } this.detailVisible = true @@ -250,6 +462,141 @@ export default { this.detailVisible = false this.currentOrder = {} this.itemList = [] + }, + handleEdit(row) { + if (!this.canEdit(row)) { + this.$message.warning('仅已创建或已取消状态的交货单可编辑') + return + } + this.editForm = { + ...createDefaultForm(), + id: row.id, + vbeln: row.vbeln, + lifnr: row.lifnr, + lifnr_name: row.lifnr_name, + lfart: row.lfart, + billtype: row.billtype, + bldat: row.bldat, + wadat: row.wadat, + lfdat: row.lfdat, + wadat_ist: row.wadat_ist, + status: row.status, + items: [] + } + this.componentItems = [] + this.editVisible = true + this.loadEditItems(row.vbeln) + }, + loadEditItems(vbeln) { + this.editItemLoading = true + getDetail(vbeln).then(res => { + const detail = res.data || res || {} + const items = detail.items || [] + this.editForm.items = items + .filter(item => !item.rspos || item.rspos === 0) + .map(item => ({ ...item })) + this.componentItems = items.filter(item => item.rspos && item.rspos !== 0) + }).catch(() => { + this.editForm.items = [] + this.componentItems = [] + }).finally(() => { + this.editItemLoading = false + }) + }, + addItem() { + this.editForm.items.push(createItem()) + }, + removeItem(index) { + this.editForm.items.splice(index, 1) + }, + submitEdit() { + this.$refs.form.validate(valid => { + if (!valid) { + return + } + if (!this.editForm.items.length) { + this.$message.warning('请至少保留一条行项目') + return + } + const empty = this.editForm.items.find(item => !item.material || !String(item.material).trim()) + if (empty) { + this.$message.warning('行项目物料编号不能为空') + return + } + const items = this.editForm.items.concat(this.componentItems).map(item => this.toItemPayload(item)) + this.editSaving = true + this.api.edit({ + id: this.editForm.id, + vbeln: this.editForm.vbeln, + lifnr: this.editForm.lifnr, + lifnr_name: this.editForm.lifnr_name, + lfart: this.editForm.lfart, + billtype: this.editForm.billtype, + bldat: this.editForm.bldat, + wadat: this.editForm.wadat, + lfdat: this.editForm.lfdat, + wadat_ist: this.editForm.wadat_ist, + status: this.editForm.status, + items + }).then(() => { + this.$message.success('修改成功') + this.closeEditDialog() + this.crud.refresh() + }).finally(() => { + this.editSaving = false + }) + }) + }, + toItemPayload(item) { + return { + id: item.id, + posnr: item.posnr, + material: item.material, + matl_desc: item.matl_desc, + deliv_qty: item.deliv_qty, + unit: item.unit, + po_number: item.po_number, + po_item: item.po_item, + werks: item.werks, + lgort: item.lgort, + ntgew: item.ntgew, + brgew: item.brgew, + gewei: item.gewei, + volum: item.volum, + oleh: item.oleh, + uebtk: item.uebtk, + uebto: item.uebto, + untto: item.untto, + lifexpos: item.lifexpos, + rspos: item.rspos, + component_material: item.component_material, + component_qty: item.component_qty + } + }, + closeEditDialog() { + this.editVisible = false + this.editSaving = false + this.editForm = createDefaultForm() + this.componentItems = [] + if (this.$refs.form) { + this.$refs.form.clearValidate() + } + }, + handleDelete(row) { + if (!this.canEdit(row)) { + this.$message.warning('已下发或已完成的交货单不能删除') + return + } + this.$confirm('确认删除交货单 ' + row.vbeln + ' 及其行项目?', '删除交货单', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + this.api.del([row.id]).then(() => { + this.$message.success('删除成功') + this.crud.toQuery() + }) + }).catch(() => {}) } } } diff --git a/nladmin-ui/src/views/wms/pm_manage/sap/outBoundDelivery/outBoundDelivery.js b/nladmin-ui/src/views/wms/pm_manage/sap/outBoundDelivery/outBoundDelivery.js index 10563b14..bee4c898 100644 --- a/nladmin-ui/src/views/wms/pm_manage/sap/outBoundDelivery/outBoundDelivery.js +++ b/nladmin-ui/src/views/wms/pm_manage/sap/outBoundDelivery/outBoundDelivery.js @@ -63,4 +63,11 @@ export function reverse(data) { }) } -export default { add, edit, del, get, getDetail, outPush, pushZd, reverse } +export function getParamValue(code) { + return request({ + url: 'api/param/getValueByCode/' + code, + method: 'post' + }) +} + +export default { add, edit, del, get, getDetail, outPush, pushZd, reverse, getParamValue }