fix:冲销入库

This commit is contained in:
zhaoyf
2026-11-23 19:28:46 +08:00
parent e6b97d6516
commit 2002124e88
10 changed files with 285 additions and 41 deletions

View File

@@ -9,6 +9,7 @@ import org.nl.common.logging.annotation.Log;
import org.nl.wms.pm_manage.sap.manualPicking.service.ManualPickingService;
import org.nl.wms.pm_manage.sap.manualPicking.service.dto.ManualPickingOrderDto;
import org.nl.wms.pm_manage.sap.manualPicking.service.dto.ManualPickingQuery;
import org.nl.wms.pm_manage.sap.manualPicking.service.dto.ManualPickingReverseInboundDto;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
@@ -79,8 +80,8 @@ public class ManualPickingController {
@PostMapping("/reverseInbound")
@Log("冲销入库SAP手工领料出库单")
public ResponseEntity<Object> reverseInbound(@RequestBody JSONObject dto) {
String billCode = manualPickingService.reverseInbound(dto.getLong("id"));
public ResponseEntity<Object> reverseInbound(@RequestBody ManualPickingReverseInboundDto dto) {
String billCode = manualPickingService.reverseInbound(dto);
JSONObject result = new JSONObject();
result.put("billCode", billCode);
return ResponseData.build(result);

View File

@@ -8,6 +8,7 @@ import org.nl.wms.pm_manage.sap.manualPicking.service.dao.ManualPickingOrder;
import org.nl.wms.pm_manage.sap.manualPicking.service.dto.CostCenterVo;
import org.nl.wms.pm_manage.sap.manualPicking.service.dto.ManualPickingOrderDto;
import org.nl.wms.pm_manage.sap.manualPicking.service.dto.ManualPickingQuery;
import org.nl.wms.pm_manage.sap.manualPicking.service.dto.ManualPickingReverseInboundDto;
import java.util.List;
@@ -42,7 +43,7 @@ public interface ManualPickingService {
*
* @return 生成的入库单号
*/
String reverseInbound(Long id);
String reverseInbound(ManualPickingReverseInboundDto dto);
/**
* 中鼎WMS完成单据后的回调:置单据完成/已冲销,并按 MM022(201/202)回传 SAP。

View File

@@ -52,6 +52,15 @@ public class ManualPickingOrder implements Serializable {
/** 冲销人 */
private String reverse_by;
/** 冲销入库方式:FLAT/SHELF */
private String reverse_inbound_mode;
/** 冲销入库托盘码 */
private String reverse_storagevehicle_code;
/** 冲销入库库位码 */
private String reverse_struct_code;
private String remark;
private String create_id;

View File

@@ -42,6 +42,12 @@ public class ManualPickingOrderDto {
/** 冲销人 */
private String reverse_by;
private String reverse_inbound_mode;
private String reverse_storagevehicle_code;
private String reverse_struct_code;
private String remark;
private String create_id;

View File

@@ -0,0 +1,21 @@
package org.nl.wms.pm_manage.sap.manualPicking.service.dto;
import lombok.Data;
/**
* SAP手工领料冲销入库参数。
*/
@Data
public class ManualPickingReverseInboundDto {
private Long id;
/** 入库方式:FLAT 平库,SHELF 货架库位。 */
private String inbound_mode;
/** 货架入库托盘码;平库使用仓库固定绑定托盘。 */
private String storagevehicle_code;
/** 货架入库库位码;平库由仓库固定库位确定。 */
private String struct_code;
}

View File

@@ -14,8 +14,10 @@ import org.nl.common.domain.query.PageQuery;
import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.SecurityUtils;
import org.nl.wms.basedata_manage.service.IBsrealStorattrService;
import org.nl.wms.basedata_manage.service.IStructattrService;
import org.nl.wms.basedata_manage.service.IMdMeMaterialbaseService;
import org.nl.wms.basedata_manage.service.dao.BsrealStorattr;
import org.nl.wms.basedata_manage.service.dao.Structattr;
import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase;
import org.nl.wms.ext_manage.api.ZDWmsApi;
import org.nl.wms.ext_manage.enums.EXTConstant;
@@ -36,6 +38,7 @@ import org.nl.wms.pm_manage.sap.manualPicking.service.dto.CostCenterVo;
import org.nl.wms.pm_manage.sap.manualPicking.service.dto.ManualPickingItemDto;
import org.nl.wms.pm_manage.sap.manualPicking.service.dto.ManualPickingOrderDto;
import org.nl.wms.pm_manage.sap.manualPicking.service.dto.ManualPickingQuery;
import org.nl.wms.pm_manage.sap.manualPicking.service.dto.ManualPickingReverseInboundDto;
import org.nl.wms.system_manage.service.param.ISysParamService;
import org.nl.wms.system_manage.service.param.dao.Param;
import org.nl.wms.warehouse_manage.enums.IOSEnum;
@@ -43,7 +46,14 @@ import org.nl.wms.warehouse_manage.inAndOut.service.IInBillService;
import org.nl.wms.warehouse_manage.inAndOut.service.IOutBillService;
import org.nl.wms.warehouse_manage.inAndOut.service.dao.IOStorInv;
import org.nl.wms.warehouse_manage.inAndOut.service.dao.IOStorInvDtl;
import org.nl.wms.warehouse_manage.inAndOut.service.dao.IOStorInvDis;
import org.nl.wms.warehouse_manage.inAndOut.service.dao.mapper.IOStorInvDtlMapper;
import org.nl.wms.warehouse_manage.inAndOut.service.dao.mapper.IOStorInvDisMapper;
import org.nl.wms.warehouse_manage.inAndOut.service.dao.mapper.IOStorInvMapper;
import org.nl.wms.warehouse_manage.inventory.IStInventoryService;
import org.nl.wms.warehouse_manage.inventory.core.enums.InventoryChangeType;
import org.nl.wms.warehouse_manage.inventory.core.param.impl.DirectInFinishParam;
import org.nl.wms.warehouse_manage.stockReturn.strategy.CallbackStrategyPublish;
import org.nl.wms.warehouse_manage.stockReturn.service.IPmStockReturnService;
import org.nl.wms.warehouse_manage.stockReturn.service.dao.PmStockReturn;
import org.nl.wms.warehouse_manage.stockReturn.service.enums.StockReturnStatusEnum;
@@ -91,8 +101,13 @@ public class ManualPickingServiceImpl implements ManualPickingService {
private final IOutBillService outBillService;
private final IInBillService inBillService;
private final IOStorInvDtlMapper ioStorInvDtlMapper;
private final IOStorInvDisMapper ioStorInvDisMapper;
private final IOStorInvMapper ioStorInvMapper;
private final IStInventoryService inventoryService;
private final CallbackStrategyPublish callbackStrategyPublish;
private final IMdMeMaterialbaseService materialbaseService;
private final IBsrealStorattrService bsrealStorattrService;
private final IStructattrService structattrService;
private final SapApi sapApi;
private final ISysParamService sysParamService;
private final ZDWmsApi zdWmsApi;
@@ -194,8 +209,8 @@ public class ManualPickingServiceImpl implements ManualPickingService {
if (order == null) {
throw new BadRequestException("修改失败:手工领料单不存在");
}
if (!ManualPickingStatus.CREATED.getCode().equals(order.getStatus())) {
throw new BadRequestException("修改失败:单据" + order.getOrder_no() + "已下发或已完成");
if (!canEditStatus(order.getStatus())) {
throw new BadRequestException("修改失败:单据" + order.getOrder_no() + "当前状态不允许修改");
}
BsrealStorattr stor = requireStor(dto.getStor_code());
List<ManualPickingItemDto> items = validateItems(dto.getItems());
@@ -206,6 +221,14 @@ public class ManualPickingServiceImpl implements ManualPickingService {
order.setItem_count(items.size());
order.setTotal_qty(sumQty(items));
order.setRemark(dto.getRemark());
if (StrUtil.isNotBlank(dto.getStatus())) {
ManualPickingStatus target = ManualPickingStatus.ofCode(dto.getStatus().trim());
if (target == null) {
throw new BadRequestException("修改失败:单据状态不合法");
}
validateStatusChange(order.getStatus(), target.getCode());
order.setStatus(target.getCode());
}
order.setUpdate_id(SecurityUtils.getCurrentUserId());
order.setUpdate_name(StrUtil.blankToDefault(SecurityUtils.getCurrentNickName(), SecurityUtils.getCurrentUsername()));
order.setUpdate_time(DateUtil.now());
@@ -272,11 +295,11 @@ public class ManualPickingServiceImpl implements ManualPickingService {
@Override
@Transactional(rollbackFor = Exception.class)
public String reverseInbound(Long id) {
if (id == null) {
public String reverseInbound(ManualPickingReverseInboundDto dto) {
if (dto == null || dto.getId() == null) {
throw new BadRequestException("冲销入库失败:未选择单据");
}
ManualPickingOrder order = orderMapper.selectById(id);
ManualPickingOrder order = orderMapper.selectById(dto.getId());
if (order == null) {
throw new BadRequestException("冲销入库失败:单据不存在");
}
@@ -302,6 +325,10 @@ public class ManualPickingServiceImpl implements ManualPickingService {
if (CollectionUtils.isEmpty(items)) {
throw new BadRequestException("冲销入库失败:单据明细不存在");
}
String inboundMode = StrUtil.blankToDefault(StrUtil.trim(dto.getInbound_mode()), "FLAT").toUpperCase();
if (!"FLAT".equals(inboundMode) && !"SHELF".equals(inboundMode)) {
throw new BadRequestException("冲销入库失败:入库方式只能是平库或货架");
}
String billCode;
if (isZdStor(order.getStor_code())) {
// 中鼎托管仓库:不生成WMS入库单,只把冲销单据下推给中鼎WMS(billType=1 入库);
@@ -310,7 +337,13 @@ public class ManualPickingServiceImpl implements ManualPickingService {
billCode = null;
} else {
BsrealStorattr stor = requireStor(order.getStor_code());
String billId = inBillService.insertDtl(convertToInBill(order, items, stor));
JSONObject inboundBill = "SHELF".equals(inboundMode)
? convertToShelfInBill(order, items, stor, dto.getStoragevehicle_code(), dto.getStruct_code())
: convertToFlatInBill(order, items, stor);
String billId = inBillService.insertDtl(inboundBill);
completeDirectInbound(billId, order, items,
"SHELF".equals(inboundMode) ? dto.getStoragevehicle_code().trim() : findFlatStruct(order.getStor_code()).getStoragevehicle_code(),
"SHELF".equals(inboundMode) ? dto.getStruct_code().trim() : findFlatStruct(order.getStor_code()).getStruct_code());
IOStorInv bill = inBillService.getById(billId);
if (bill == null || StrUtil.isBlank(bill.getBill_code())) {
throw new BadRequestException("冲销入库失败:入库单生成异常");
@@ -319,6 +352,9 @@ public class ManualPickingServiceImpl implements ManualPickingService {
billCode = bill.getBill_code();
}
order.setStatus(ManualPickingStatus.REVERSING.getCode());
order.setReverse_inbound_mode(inboundMode);
order.setReverse_storagevehicle_code("SHELF".equals(inboundMode) ? dto.getStoragevehicle_code().trim() : findFlatStruct(order.getStor_code()).getStoragevehicle_code());
order.setReverse_struct_code("SHELF".equals(inboundMode) ? dto.getStruct_code().trim() : findFlatStruct(order.getStor_code()).getStruct_code());
order.setUpdate_id(SecurityUtils.getCurrentUserId());
order.setUpdate_name(StrUtil.blankToDefault(SecurityUtils.getCurrentNickName(), SecurityUtils.getCurrentUsername()));
order.setUpdate_time(DateUtil.now());
@@ -328,6 +364,26 @@ public class ManualPickingServiceImpl implements ManualPickingService {
return billCode;
}
private boolean canEditStatus(String status) {
return ManualPickingStatus.CREATED.getCode().equals(status)
|| ManualPickingStatus.POSTED.getCode().equals(status)
|| ManualPickingStatus.COMPLETED.getCode().equals(status);
}
private void validateStatusChange(String current, String target) {
if (Objects.equals(current, target)) {
return;
}
if (ManualPickingStatus.COMPLETED.getCode().equals(current)
&& ManualPickingStatus.REVERSING.getCode().equals(target)) {
throw new BadRequestException("修改失败:已完成单据请使用冲销入库功能");
}
if (ManualPickingStatus.REVERSED.getCode().equals(target)
|| ManualPickingStatus.REVERSING.getCode().equals(target)) {
throw new BadRequestException("修改失败:冲销状态只能由冲销入库流程产生");
}
}
/* ==================== 中鼎WMS:只下推单据,完成后回调再回传 SAP ==================== */
/**
@@ -526,7 +582,46 @@ public class ManualPickingServiceImpl implements ManualPickingService {
/**
* 冲销入库单:同一仓库、一条明细一行,分配一个虚拟托盘,入库完成后按 MM022(202)回传 SAP
*/
private JSONObject convertToInBill(ManualPickingOrder order, List<ManualPickingItem> items, BsrealStorattr stor) {
private JSONObject convertToFlatInBill(ManualPickingOrder order, List<ManualPickingItem> items, BsrealStorattr stor) {
Structattr fixedStruct = findFlatStruct(order.getStor_code());
return convertToInBill(order, items, stor, fixedStruct.getStoragevehicle_code(), fixedStruct.getStruct_code());
}
private JSONObject convertToShelfInBill(ManualPickingOrder order, List<ManualPickingItem> items, BsrealStorattr stor,
String vehicleCode, String structCode) {
if (StrUtil.isBlank(vehicleCode) || StrUtil.isBlank(structCode)) {
throw new BadRequestException("冲销入库失败:货架入库必须填写托盘码和库位码");
}
Structattr struct = structattrService.findByCode(structCode.trim());
if (struct == null) {
throw new BadRequestException("冲销入库失败:库位" + structCode + "不存在");
}
if (!order.getStor_code().equals(struct.getStor_code())) {
throw new BadRequestException("冲销入库失败:库位不属于仓库" + order.getStor_code());
}
if (StrUtil.isNotBlank(struct.getStoragevehicle_code())
&& !vehicleCode.trim().equals(struct.getStoragevehicle_code().trim())) {
throw new BadRequestException("冲销入库失败:库位已绑定其他托盘");
}
return convertToInBill(order, items, stor, vehicleCode.trim(), struct.getStruct_code());
}
/** 平库:一个仓库固定一个库位、一个托盘,库区编码与仓库编码一致。 */
private Structattr findFlatStruct(String storCode) {
Structattr struct = structattrService.getOne(new LambdaQueryWrapper<Structattr>()
.eq(Structattr::getStor_code, storCode)
.eq(Structattr::getSect_code, storCode)
.eq(Structattr::getIs_used, true)
.isNotNull(Structattr::getStoragevehicle_code)
.last("LIMIT 1"));
if (struct == null) {
throw new BadRequestException("冲销入库失败:仓库" + storCode + "未配置平库固定库位和托盘");
}
return struct;
}
private JSONObject convertToInBill(ManualPickingOrder order, List<ManualPickingItem> items, BsrealStorattr stor,
String vehicleCode, String structCode) {
List<String> materialCodes = items.stream()
.map(ManualPickingItem::getMatnr)
.filter(StrUtil::isNotBlank)
@@ -540,8 +635,6 @@ public class ManualPickingServiceImpl implements ManualPickingService {
Map<String, MdMeMaterialbase> materialsByCode = materials.stream()
.collect(Collectors.toMap(MdMeMaterialbase::getMaterial_code, Function.identity(), (a, b) -> a));
// 冲销入库没有实际载具,使用虚拟托盘,分配货位时按虚拟托盘处理
String vehicleCode = "VTP" + System.currentTimeMillis();
List<HashMap> tableData = new ArrayList<>();
for (ManualPickingItem item : items) {
MdMeMaterialbase material = materialsByCode.get(item.getMatnr());
@@ -555,6 +648,8 @@ public class ManualPickingServiceImpl implements ManualPickingService {
throw new BadRequestException("冲销入库失败:物料" + item.getMatnr() + "的可冲销数量为0");
}
row.put("storagevehicle_code", vehicleCode);
row.put("struct_code", structCode);
row.put("sect_code", order.getStor_code());
row.put("material_id", material.getMaterial_id());
row.put("material_code", item.getMatnr());
row.put("material_name", StrUtil.blankToDefault(item.getMaktx(), material.getMaterial_name()));
@@ -569,6 +664,7 @@ public class ManualPickingServiceImpl implements ManualPickingService {
// 明细主键传给回传策略,用于取成本中心等信息组装 MM022
row.put("source_billdtl_id", String.valueOf(item.getId()));
row.put("callback_strategy", REVERSE_CALLBACK_STRATEGY);
row.put("allow_existing_vehicle", true);
tableData.add(row);
}
JSONObject billParam = new JSONObject();
@@ -576,11 +672,68 @@ public class ManualPickingServiceImpl implements ManualPickingService {
billParam.put("biz_date", DateUtil.today());
billParam.put("bill_status", IOSEnum.BILL_STATUS.code("生成"));
billParam.put("bill_type", IOSEnum.BILL_TYPE.code("其他入库"));
billParam.put("inbound_direct", true);
billParam.put("remark", "SAP手工领料冲销入库,领料单:" + order.getOrder_no());
billParam.put("tableData", tableData);
return billParam;
}
/** 直接完成已生成入库单,跳过入库管理页面的人工分配。 */
private void completeDirectInbound(String billId, ManualPickingOrder order, List<ManualPickingItem> items,
String vehicleCode, String structCode) {
List<IOStorInvDis> distributions = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<IOStorInvDis>()
.eq(IOStorInvDis::getIostorinv_id, billId));
if (CollectionUtils.isEmpty(distributions)) {
throw new BadRequestException("冲销入库失败:入库分配明细生成异常");
}
for (IOStorInvDis distribution : distributions) {
Structattr struct = structattrService.findByCode(structCode);
if (struct == null) {
throw new BadRequestException("冲销入库失败:库位" + structCode + "不存在");
}
distribution.setStoragevehicle_code(vehicleCode);
distribution.setSect_id(struct.getSect_id());
distribution.setSect_code(struct.getSect_code());
distribution.setSect_name(struct.getSect_name());
distribution.setStruct_id(struct.getStruct_id());
distribution.setStruct_code(struct.getStruct_code());
distribution.setStruct_name(struct.getStruct_name());
distribution.setWork_status(IOSEnum.INBILL_DIS_STATUS.code("完成"));
distribution.setReal_qty(distribution.getPlan_qty());
ioStorInvDisMapper.updateById(distribution);
}
List<DirectInFinishParam> params = new ArrayList<>();
for (IOStorInvDis distribution : distributions) {
DirectInFinishParam param = new DirectInFinishParam();
param.setStoragevehicleCode(vehicleCode);
param.setMaterialCode(distribution.getMaterial_code());
param.setPcsn(distribution.getPcsn());
param.setQty(distribution.getPlan_qty());
param.setExtCode(order.getOrder_no());
param.setExtType(SourceBillTypeEnum.SAP_MANUAL_PICKING_REVERSE.getBillType());
param.setStorCode(order.getStor_code());
param.setSectCode(distribution.getSect_code());
param.setStructCode(structCode);
param.setUnitId(distribution.getQty_unit_id());
param.setUnitName(distribution.getQty_unit_name());
param.setRemark("SAP手工领料冲销直接入库");
params.add(param);
}
inventoryService.changeInventory(InventoryChangeType.DIRECT_ADD_INV, params);
ioStorInvDtlMapper.update(null, new com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper<IOStorInvDtl>()
.set(IOStorInvDtl::getBill_status, IOSEnum.BILL_STATUS.code("完成"))
.setSql("real_qty = plan_qty")
.eq(IOStorInvDtl::getIostorinv_id, billId));
ioStorInvMapper.update(null, new com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper<IOStorInv>()
.set(IOStorInv::getBill_status, IOSEnum.BILL_STATUS.code("完成"))
.eq(IOStorInv::getIostorinv_id, billId));
for (IOStorInvDtl detail : ioStorInvDtlMapper.selectList(new LambdaQueryWrapper<IOStorInvDtl>().eq(IOStorInvDtl::getIostorinv_id, billId))) {
if (StrUtil.isNotBlank(detail.getCallback_strategy())) {
callbackStrategyPublish.callbackStrategy(detail.getCallback_strategy(), detail);
}
}
}
/**
* 冲销数量:优先取下推生成的出库明细实际出库数量,没有则用领料数量
*/
@@ -840,6 +993,9 @@ public class ManualPickingServiceImpl implements ManualPickingService {
dto.setIn_bill_code(order.getIn_bill_code());
dto.setReverse_time(order.getReverse_time());
dto.setReverse_by(order.getReverse_by());
dto.setReverse_inbound_mode(order.getReverse_inbound_mode());
dto.setReverse_storagevehicle_code(order.getReverse_storagevehicle_code());
dto.setReverse_struct_code(order.getReverse_struct_code());
dto.setRemark(order.getRemark());
dto.setCreate_id(order.getCreate_id());
dto.setCreate_name(order.getCreate_name());

View File

@@ -173,7 +173,8 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i
io_mst.put("stor_code", stor_code);
io_mst.put("stor_name", stor_name);
io_mst.put("remark", whereJson.get("remark"));
io_mst.put("bill_status", whereJson.get("bill_status"));
io_mst.put("bill_status", Boolean.TRUE.equals(whereJson.get("inbound_direct"))
? IOSEnum.BILL_STATUS.code("分配完") : whereJson.get("bill_status"));
io_mst.put("create_mode", IOSEnum.CREATE_MODE.code("PC产生"));
io_mst.put("input_optid", currentUserId + "");
io_mst.put("input_optname", nickName);
@@ -219,7 +220,7 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i
//判断该载具编号是否已经存在库内
String storagevehicleCode = row.get("storagevehicle_code").toString();
if (!storagevehicleCode.startsWith("VTP")) {
if (!storagevehicleCode.startsWith("VTP") && !Boolean.TRUE.equals(row.get("allow_existing_vehicle"))) {
Structattr structattr = iStructattrService.getOne(new LambdaQueryWrapper<>(Structattr.class).eq(Structattr::getStoragevehicle_code, storagevehicleCode));
if (ObjectUtil.isNotEmpty(structattr)) {
throw new BadRequestException("载具编码:" + row.get("storagevehicle_code") + "已存在库内,请对数据进行核实!");
@@ -240,8 +241,10 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i
JSONObject dis = new JSONObject();
dis.put("iostorinvdis_id", IdUtil.getStringId());
dis.put("iostorinv_id", iostorinv_id);
dis.put("iostorinvdtl_id", ObjectUtil.isEmpty(dtl_dto) ? ioStorInvDtl.getString("iostorinvdtl_id") : dtl_dto.getIostorinvdtl_id());
dis.put("seq_no", 1);
dis.put("iostorinvdtl_id", ObjectUtil.isEmpty(dtl_dto) ? ioStorInvDtl.getString("iostorinvdtl_id") : dtl_dto.getIostorinvdtl_id());
dis.put("struct_code", row.get("struct_code"));
dis.put("sect_code", row.get("sect_code"));
dis.put("seq_no", 1);
dis.put("material_id", row.get("material_id"));
dis.put("material_code", row.get("material_code"));
dis.put("pcsn", row.get("pcsn"));

View File

@@ -84,6 +84,13 @@
<el-input v-model.trim="form.remark" placeholder="备注" />
</el-form-item>
</el-col>
<el-col v-if="dialogMode === 'edit'" :span="8">
<el-form-item label="单据状态">
<el-select v-model="form.status" style="width: 100%;" placeholder="请选择状态">
<el-option v-for="item in statusOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
@@ -151,6 +158,31 @@
</el-dialog>
<!-- 明细 -->
<!-- 冲销入库参数 -->
<el-dialog :visible.sync="reverseVisible" title="冲销入库" width="520px" :close-on-click-modal="false">
<el-form :model="reverseForm" size="mini" label-width="100px" label-suffix=":">
<el-form-item label="入库方式">
<el-radio-group v-model="reverseForm.inbound_mode">
<el-radio label="FLAT">平库</el-radio>
<el-radio label="SHELF">货架</el-radio>
</el-radio-group>
</el-form-item>
<el-alert v-if="reverseForm.inbound_mode === 'FLAT'" title="平库按仓库编码作为库区编码,仓库固定库位和固定托盘永久绑定,入库后直接完成。" type="info" :closable="false" show-icon />
<template v-else>
<el-form-item label="托盘码">
<el-input v-model.trim="reverseForm.storagevehicle_code" placeholder="请输入托盘码" />
</el-form-item>
<el-form-item label="库位码">
<el-input v-model.trim="reverseForm.struct_code" placeholder="请输入库位码" />
</el-form-item>
</template>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button size="mini" @click="reverseVisible = false">取消</el-button>
<el-button size="mini" type="primary" :loading="reversing" @click="submitReverseInbound">确认入库</el-button>
</div>
</el-dialog>
<el-dialog :visible.sync="detailVisible" title="手工领料单明细" width="1150px" :close-on-click-modal="false" @close="closeDetail">
<div style="margin-bottom: 10px; color: #606266; font-size: 13px;">
单据号:<strong>{{ currentOrder.order_no }}</strong> &nbsp;|&nbsp;
@@ -288,6 +320,8 @@ export default {
dialogVisible: false,
dialogMode: 'add',
form: createForm(),
reverseVisible: false,
reverseForm: { id: null, inbound_mode: 'FLAT', storagevehicle_code: '', struct_code: '' },
detailVisible: false,
detailLoading: false,
currentOrder: {},
@@ -344,7 +378,7 @@ export default {
return map[status] || ''
},
canEdit(row) {
return row.status === 'CREATED' || row.status === 'POSTED'
return row.status === 'CREATED' || row.status === 'POSTED' || row.status === 'COMPLETED'
},
handleSelectionChange(selection) {
this.multipleSelection = selection
@@ -385,6 +419,10 @@ export default {
const detail = res.data || {}
this.form = {
id: detail.id,
status: detail.status,
reverseInboundMode: detail.reverse_inbound_mode,
reverseStoragevehicleCode: detail.reverse_storagevehicle_code,
reverseStructCode: detail.reverse_struct_code,
storCode: detail.stor_code,
bldat: detail.bldat,
remark: detail.remark,
@@ -456,6 +494,10 @@ export default {
}
const payload = {
id: this.form.id,
status: this.form.status,
reverse_inbound_mode: this.form.reverseInboundMode,
reverse_storagevehicle_code: this.form.reverseStoragevehicleCode,
reverse_struct_code: this.form.reverseStructCode,
stor_code: this.form.storCode,
bldat: this.form.bldat,
remark: this.form.remark,
@@ -530,28 +572,24 @@ export default {
return
}
const row = this.multipleSelection[0]
this.$confirm(
'确认对单据 ' + row.order_no + ' 执行冲销入库?中鼎仓库的冲销单直接下推至中鼎WMS,其余仓库生成入库单,入库完成后按 MM022(移动类型 202)回传 SAP 冲销。',
'冲销入库',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}
).then(() => {
this.reversing = true
reverseInbound(row.id).then(res => {
const billCode = (res.data || {}).billCode
if (billCode) {
this.$message.success('冲销入库单已生成:' + billCode + ',请到入库单页面完成入库')
} else {
this.$message.success('冲销单已下推至中鼎WMS,中鼎完成入库后将自动按 MM022(202)回传 SAP')
}
this.crud.toQuery()
}).finally(() => {
this.reversing = false
})
}).catch(() => {})
this.reverseForm = { id: row.id, inbound_mode: 'FLAT', storagevehicle_code: '', struct_code: '' }
this.reverseVisible = true
},
submitReverseInbound() {
if (this.reverseForm.inbound_mode === 'SHELF' &&
(!this.reverseForm.storagevehicle_code || !this.reverseForm.struct_code)) {
this.$message.warning('货架入库必须填写托盘码和库位码')
return
}
this.reversing = true
reverseInbound(this.reverseForm).then(res => {
const billCode = (res.data || {}).billCode
this.$message.success(billCode ? '冲销入库已完成,入库单号:' + billCode : '冲销单已提交,完成后将自动按 MM022(202)回传 SAP')
this.reverseVisible = false
this.crud.toQuery()
}).finally(() => {
this.reversing = false
})
},
handleDelete(row) {
this.$confirm('确认删除单据 ' + row.order_no + ' ?', '删除', {

View File

@@ -26,8 +26,8 @@ export function outPush(id) {
/**
* 冲销入库:中鼎仓库只下推冲销单给中鼎WMS,其余仓库生成 WMS 入库单,入库完成后按 MM022(202)回传 SAP
*/
export function reverseInbound(id) {
return request({ url: 'api/sapManualPicking/reverseInbound', method: 'post', data: { id }})
export function reverseInbound(data) {
return request({ url: 'api/sapManualPicking/reverseInbound', method: 'post', data })
}
export function getCostCenters() {

View File

@@ -0,0 +1,9 @@
-- SAP手工领料冲销入库重构:状态编辑、平库/货架入库由页面直接完成
-- 已存在字段无需重复执行;以下字段用于保留入库方式和实际库位信息,便于审计和追溯。
ALTER TABLE `sap_manual_picking`
ADD COLUMN `reverse_inbound_mode` varchar(10) DEFAULT NULL COMMENT '冲销入库方式:FLAT平库/SHELF货架' AFTER `reverse_by`,
ADD COLUMN `reverse_storagevehicle_code` varchar(64) DEFAULT NULL COMMENT '冲销入库托盘码' AFTER `reverse_inbound_mode`,
ADD COLUMN `reverse_struct_code` varchar(64) DEFAULT NULL COMMENT '冲销入库库位码' AFTER `reverse_storagevehicle_code`;
-- 平库配置约定:st_ivt_sectattr.sect_code = st_ivt_bsrealstorattr.stor_code,
-- 且每个仓库配置唯一的固定库位;st_ivt_structattr.storagevehicle_code 为永久绑定托盘。