add:退料入库批次

This commit is contained in:
zhaoyf
2026-12-02 15:49:34 +08:00
parent 03e5be4a0b
commit 2074aed81e
9 changed files with 79 additions and 3 deletions

View File

@@ -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` 过账;

View File

@@ -67,6 +67,10 @@ public class PmReturn extends Model<PmReturn> {
@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")

View File

@@ -20,6 +20,7 @@
<result property="createTime" column="create_time"/>
<result property="sourceHouseCode" column="source_house_code"/>
<result property="targetHouseCode" column="target_house_code"/>
<result property="batchNo" column="batch_no"/>
<result property="status" column="status"/>
<result property="updateTime" column="update_time"/>
<result property="updateName" column="update_name"/>

View File

@@ -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;

View File

@@ -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;

View File

@@ -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<PmReturnMapper, PmReturn> 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<PmReturnMapper, PmReturn> 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<PmReturnMapper, PmReturn> 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<PmReturnMapper, PmReturn> 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());

View File

@@ -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("");