diff --git a/nladmin-system/wms-server/src/main/java/org/nl/wms/ext_manage/sap/README.md b/nladmin-system/wms-server/src/main/java/org/nl/wms/ext_manage/sap/README.md index 7b86887c..71aff7ba 100644 --- a/nladmin-system/wms-server/src/main/java/org/nl/wms/ext_manage/sap/README.md +++ b/nladmin-system/wms-server/src/main/java/org/nl/wms/ext_manage/sap/README.md @@ -181,6 +181,14 @@ MES 下推退料单 `app/restful/api/v3/wms/mesReturnSync` 携带 `WorkOrder`( > `KG` 只改变过账口径,WMS/PDA 侧流程不变(仍是 PDA 扫码入库后按退料单明细触发 `SapReturnCallBack`); > 回传记录 `request_type` 与 `Product` 同为 `生产退料(1006)`,靠请求报文里的 `tl`(空)区分投料/退料。 +#### 退料批次(R004 海监品库) + +- 海监品库 `R004` 做批次管理:退料单「分配」时目标仓库选 `R004` **必须录入批次号**(前端未填不允许保存, + 后端 `PmReturnServiceImpl#allocate` 同样校验),落 `pm_return.batch_no`。 +- 回传 PP055(`Product` 退料 / `KG` 投料)时批次写入报文 `charg`;`batch_no` 为空则报文不下发 `charg`。 +- 目标仓库改分配到非 `R004` 仓库时会清空 `batch_no`,避免 PP055 误带批次。 +- 建表脚本 `sql/20261202_pm_return_batch_no.sql`(`pm_return.batch_no varchar(50)`)。 + 两条触发链路: 1. **退回本系统**:PDA `/api/pda/inbound/returnInbound` 入库完成后,`SapReturnCallBack` 在整单收满时调用 `PmReturnSapPoster` 过账; diff --git a/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/pmreturn/service/dao/PmReturn.java b/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/pmreturn/service/dao/PmReturn.java index 7529d14a..a5e13901 100644 --- a/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/pmreturn/service/dao/PmReturn.java +++ b/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/pmreturn/service/dao/PmReturn.java @@ -67,6 +67,10 @@ public class PmReturn extends Model { @TableField("target_house_code") private String target_house_code; + /** 批次号:目标仓库为 R004(海监品库)时分配必填,回传 PP055 的 charg */ + @TableField("batch_no") + private String batch_no; + private Integer status; @TableField("update_time") diff --git a/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/pmreturn/service/dao/mapper/xml/PmReturnMapper.xml b/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/pmreturn/service/dao/mapper/xml/PmReturnMapper.xml index 00fb06b9..f5920f95 100644 --- a/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/pmreturn/service/dao/mapper/xml/PmReturnMapper.xml +++ b/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/pmreturn/service/dao/mapper/xml/PmReturnMapper.xml @@ -20,6 +20,7 @@ + diff --git a/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/pmreturn/service/dto/PmReturnDto.java b/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/pmreturn/service/dto/PmReturnDto.java index b761de6f..f60e1912 100644 --- a/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/pmreturn/service/dto/PmReturnDto.java +++ b/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/pmreturn/service/dto/PmReturnDto.java @@ -27,6 +27,8 @@ public class PmReturnDto implements Serializable { private String createTime; private String sourceHouseCode; private String targetHouseCode; + /** 批次号:目标仓库为 R004(海监品库)时分配必填,回传 PP055 的 charg */ + private String batchNo; private Integer status; private String updateTime; private String updateName; diff --git a/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/pmreturn/service/dto/PmReturnParam.java b/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/pmreturn/service/dto/PmReturnParam.java index 443fcabe..0d5d4c53 100644 --- a/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/pmreturn/service/dto/PmReturnParam.java +++ b/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/pmreturn/service/dto/PmReturnParam.java @@ -84,6 +84,13 @@ public class PmReturnParam { @JsonProperty("TargetHouseCode") private String targetHouseCode; + /** + * 批次号:目标仓库为 R004(海监品库)时必填,回传 PP055 的 charg; + * MES 可不传,由仓库在「分配」时录入 + */ + @JsonProperty("BatchNo") + private String batchNo; + @NotNull(message = "状态不能为空") @JsonProperty("Status") private Integer status; diff --git a/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/pmreturn/service/impl/PmReturnServiceImpl.java b/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/pmreturn/service/impl/PmReturnServiceImpl.java index 6ccc27ca..411c791a 100644 --- a/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/pmreturn/service/impl/PmReturnServiceImpl.java +++ b/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/pmreturn/service/impl/PmReturnServiceImpl.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.pagehelper.PageHelper; import org.apache.commons.lang3.StringUtils; +import org.nl.common.domain.constant.RegionConstant; import org.nl.common.domain.query.PageQuery; import org.nl.common.exception.BadRequestException; import org.nl.wms.basedata_manage.service.IStructattrService; @@ -87,6 +88,7 @@ public class PmReturnServiceImpl extends ServiceImpl i entity.setCreate_time(param.getCreateTime()); entity.setSource_house_code(param.getSourceHouseCode()); entity.setTarget_house_code(param.getTargetHouseCode()); + entity.setBatch_no(StringUtils.trimToNull(param.getBatchNo())); entity.setStatus(param.getStatus()); entity.setUpdate_name(param.getUpdateName()); entity.setUpdate_time(DateUtil.now()); @@ -117,6 +119,7 @@ public class PmReturnServiceImpl extends ServiceImpl i entity.setCreate_time(param.getCreateTime()); entity.setTarget_house_code(param.getTargetHouseCode()); entity.setSource_house_code(param.getSourceHouseCode()); + entity.setBatch_no(StringUtils.trimToNull(param.getBatchNo())); entity.setStatus(param.getStatus()); entity.setUpdate_name(param.getUpdateName()); entity.setUpdate_time(DateUtil.now()); @@ -147,8 +150,21 @@ public class PmReturnServiceImpl extends ServiceImpl i if (param.getStatus() != 0) { throw new BadRequestException("分配失败,当前单子状态已经分配"); } + // 海监品库(R004)按批次管理:分配时必须录入批次号,后续按 PP055 的 charg 回传 SAP + String targetHouse = targetHouseCode.trim(); + String batchNo = StringUtils.trimToNull(param.getBatchNo()); + boolean batchHouse = RegionConstant.R004.equals(targetHouse); + if (batchHouse && batchNo == null) { + throw new BadRequestException("分配失败,目标仓库为海监品库(R004)时必须输入批次号"); + } + param.setBatchNo(batchHouse ? batchNo : null); param.setStatus(10); this.update(param); + if (!batchHouse) { + // 改分配到非批次管理仓库时清空历史批次,避免 PP055 误带 charg + this.lambdaUpdate().set(PmReturn::getBatch_no, null) + .eq(PmReturn::getId, param.getId()).update(); + } } @Override @@ -248,6 +264,7 @@ public class PmReturnServiceImpl extends ServiceImpl i dto.setCreateTime(entity.getCreate_time()); dto.setSourceHouseCode(entity.getSource_house_code()); dto.setTargetHouseCode(entity.getTarget_house_code()); + dto.setBatchNo(entity.getBatch_no()); dto.setStatus(entity.getStatus()); dto.setUpdateTime(entity.getUpdate_time()); dto.setUpdateName(entity.getUpdate_name()); diff --git a/nladmin-system/wms-server/src/main/java/org/nl/wms/warehouse_manage/stockReturn/strategy/core/impl/sap/PmReturnSapPoster.java b/nladmin-system/wms-server/src/main/java/org/nl/wms/warehouse_manage/stockReturn/strategy/core/impl/sap/PmReturnSapPoster.java index 48440386..ae4c3169 100644 --- a/nladmin-system/wms-server/src/main/java/org/nl/wms/warehouse_manage/stockReturn/strategy/core/impl/sap/PmReturnSapPoster.java +++ b/nladmin-system/wms-server/src/main/java/org/nl/wms/warehouse_manage/stockReturn/strategy/core/impl/sap/PmReturnSapPoster.java @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; +import org.nl.common.domain.constant.RegionConstant; import org.nl.common.exception.BadRequestException; import org.nl.wms.ext_manage.sap.api.SapApi; import org.nl.wms.ext_manage.sap.api.dto.*; @@ -253,6 +254,14 @@ public class PmReturnSapPoster { body.setRsnum(bom == null ? "" : StrUtil.blankToDefault(StrUtil.trim(bom.getRsnum()), "")); body.setRspos(bom == null ? "" : StrUtil.blankToDefault(StrUtil.trim(bom.getRspos()), "")); body.setTl(tl); + // 批次:海监品库(R004)分配时录入,PP055 按 charg 回传;其余仓库不带批次(保持字段不下发) + String charg = StrUtil.trim(pmReturn.getBatch_no()); + if (StrUtil.isNotBlank(charg)) { + body.setCharg(charg); + } else if (RegionConstant.R004.equals(StrUtil.trim(pmReturn.getTarget_house_code()))) { + throw new BadRequestException("退料单" + pmReturn.getOrder_code() + + "目标仓库为海监品库(R004)但未录入批次号,无法按" + scene + "回传SAP"); + } body.setBackup1(""); body.setBackup2(""); body.setBackup3(""); diff --git a/nladmin-ui/src/views/wms/pm_manage/pmReturn/index.vue b/nladmin-ui/src/views/wms/pm_manage/pmReturn/index.vue index 90abd2cf..6d455559 100644 --- a/nladmin-ui/src/views/wms/pm_manage/pmReturn/index.vue +++ b/nladmin-ui/src/views/wms/pm_manage/pmReturn/index.vue @@ -79,6 +79,7 @@ + @@ -130,6 +131,8 @@ + + @@ -180,6 +183,14 @@ /> + + + @@ -250,6 +261,7 @@ export default { storList: [], storLoading: false, selectedHouseCode: '', + selectedBatchNo: '', currentRow: {}, currentReturn: {}, multipleSelection: [], @@ -289,6 +301,12 @@ export default { } } }, + computed: { + // 海监品库(R004)按批次管理,分配时必须录入批次号 + needBatch() { + return this.selectedHouseCode === 'R004' + } + }, created() { this.loadStorList() }, @@ -369,8 +387,9 @@ export default { }, openAllocateDialog(row) { this.currentReturn = { ...row } - // 已分配过的单据回显当前目标仓库,方便只做修改 + // 已分配过的单据回显当前目标仓库/批次,方便只做修改 this.selectedHouseCode = row.targetHouseCode || '' + this.selectedBatchNo = row.batchNo || '' this.allocateVisible = true this.loadStorList() }, @@ -378,6 +397,7 @@ export default { this.allocateVisible = false this.currentReturn = {} this.selectedHouseCode = '' + this.selectedBatchNo = '' this.allocateSaving = false }, saveAllocate() { @@ -385,11 +405,16 @@ export default { this.$message.warning('请选择目标仓库') return } + if (this.needBatch && !this.selectedBatchNo) { + this.$message.warning('目标仓库为海监品库(R004),请输入批次号') + return + } if (this.allocateSaving) { return } this.allocateSaving = true - allocate({ ...this.currentReturn, targetHouseCode: this.selectedHouseCode }).then(res => { + const batchNo = this.needBatch ? this.selectedBatchNo : '' + allocate({ ...this.currentReturn, targetHouseCode: this.selectedHouseCode, batchNo }).then(res => { if (res && res.code === 400) { this.$message.warning('分配失败:' + res.message) return diff --git a/sql/20261202_pm_return_batch_no.sql b/sql/20261202_pm_return_batch_no.sql new file mode 100644 index 00000000..366a5c5f --- /dev/null +++ b/sql/20261202_pm_return_batch_no.sql @@ -0,0 +1,3 @@ +-- 生产退料单:新增批次号,目标仓库为 R004(海监品库)时分配必填,回传 PP055 的 charg +ALTER TABLE `pm_return` + ADD COLUMN `batch_no` varchar(50) DEFAULT NULL COMMENT '批次号:目标仓库为R004(海监品库)时分配必填,回传PP055的charg' AFTER `target_house_code`;