add:差异对账新增盘点平账功能
This commit is contained in:
@@ -3,9 +3,12 @@ package org.nl.wms.bi_manage.controller;
|
|||||||
import org.nl.common.base.ResponseData;
|
import org.nl.common.base.ResponseData;
|
||||||
import org.nl.common.logging.annotation.Log;
|
import org.nl.common.logging.annotation.Log;
|
||||||
import org.nl.wms.bi_manage.service.IBiStockService;
|
import org.nl.wms.bi_manage.service.IBiStockService;
|
||||||
|
import org.nl.wms.bi_manage.service.dto.BiStockBalanceRequest;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@@ -28,6 +31,15 @@ public class BiController {
|
|||||||
return ResponseData.build(biStockService.reconcile(storCode, materialCode, onlyDiff));
|
return ResponseData.build(biStockService.reconcile(storCode, materialCode, onlyDiff));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 库存平账:勾选差异行,把本地库存作为盘点数量调用 SAP MM026 差异过账
|
||||||
|
*/
|
||||||
|
@PostMapping("/balance")
|
||||||
|
@Log("库存平账")
|
||||||
|
public ResponseEntity<Object> balance(@RequestBody BiStockBalanceRequest request) {
|
||||||
|
return ResponseData.build(biStockService.balance(request.getStorCode(), request.getItems()));
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/reconcile/download")
|
@GetMapping("/reconcile/download")
|
||||||
@Log("导出库存对账")
|
@Log("导出库存对账")
|
||||||
public void download(@RequestParam String storCode,
|
public void download(@RequestParam String storCode,
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package org.nl.wms.bi_manage.service;
|
package org.nl.wms.bi_manage.service;
|
||||||
|
|
||||||
|
import org.nl.wms.bi_manage.service.dto.BiStockBalanceItem;
|
||||||
|
import org.nl.wms.bi_manage.service.dto.BiStockBalanceResult;
|
||||||
import org.nl.wms.bi_manage.service.dto.BiStockReconcileResult;
|
import org.nl.wms.bi_manage.service.dto.BiStockReconcileResult;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface IBiStockService {
|
public interface IBiStockService {
|
||||||
|
|
||||||
@@ -13,4 +16,9 @@ public interface IBiStockService {
|
|||||||
BiStockReconcileResult reconcile(String storCode, String materialCode, Boolean onlyDiff);
|
BiStockReconcileResult reconcile(String storCode, String materialCode, Boolean onlyDiff);
|
||||||
|
|
||||||
void download(String storCode, String materialCode, Boolean onlyDiff, HttpServletResponse response) throws IOException;
|
void download(String storCode, String materialCode, Boolean onlyDiff, HttpServletResponse response) throws IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 库存平账:按勾选行把本地库存作为盘点数量调用 SAP MM026 差异过账,保证两边库存一致
|
||||||
|
*/
|
||||||
|
BiStockBalanceResult balance(String storCode, List<BiStockBalanceItem> items);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package org.nl.wms.bi_manage.service.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 库存平账行:把 WMS(或中鼎)库存作为盘点数量同步给 SAP
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class BiStockBalanceItem {
|
||||||
|
|
||||||
|
/** 物料编码 */
|
||||||
|
private String materialCode;
|
||||||
|
|
||||||
|
/** 物料名称,仅用于日志 */
|
||||||
|
private String materialName;
|
||||||
|
|
||||||
|
/** 盘点数量(取对账页面的本地库存列) */
|
||||||
|
private BigDecimal qty;
|
||||||
|
|
||||||
|
/** 基本计量单位 */
|
||||||
|
private String unitName;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package org.nl.wms.bi_manage.service.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 库存平账请求:页面勾选的对账行
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class BiStockBalanceRequest {
|
||||||
|
|
||||||
|
/** 仓库编码,作为 MM026 的 LGORT */
|
||||||
|
private String storCode;
|
||||||
|
|
||||||
|
private List<BiStockBalanceItem> items = new ArrayList<>();
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package org.nl.wms.bi_manage.service.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 库存平账结果
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class BiStockBalanceResult {
|
||||||
|
|
||||||
|
/** 仓库编码 */
|
||||||
|
private String storCode;
|
||||||
|
|
||||||
|
/** 过账物料数 */
|
||||||
|
private int materialCount;
|
||||||
|
|
||||||
|
/** 过账数量合计 */
|
||||||
|
private BigDecimal totalQty = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
/** SAP 返回信息 */
|
||||||
|
private String sapMessage;
|
||||||
|
|
||||||
|
/** SAP 响应报文(便于排查) */
|
||||||
|
private String sapResponse;
|
||||||
|
}
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
package org.nl.wms.bi_manage.service.impl;
|
package org.nl.wms.bi_manage.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.poi.excel.ExcelUtil;
|
import cn.hutool.poi.excel.ExcelUtil;
|
||||||
import cn.hutool.poi.excel.ExcelWriter;
|
import cn.hutool.poi.excel.ExcelWriter;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -21,9 +24,17 @@ import org.nl.wms.basedata_manage.service.dao.BsrealStorattr;
|
|||||||
import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase;
|
import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase;
|
||||||
import org.nl.wms.basedata_manage.service.dao.Sectattr;
|
import org.nl.wms.basedata_manage.service.dao.Sectattr;
|
||||||
import org.nl.wms.bi_manage.service.IBiStockService;
|
import org.nl.wms.bi_manage.service.IBiStockService;
|
||||||
|
import org.nl.wms.bi_manage.service.dto.BiStockBalanceItem;
|
||||||
|
import org.nl.wms.bi_manage.service.dto.BiStockBalanceResult;
|
||||||
import org.nl.wms.bi_manage.service.dto.BiStockReconcileResult;
|
import org.nl.wms.bi_manage.service.dto.BiStockReconcileResult;
|
||||||
import org.nl.wms.bi_manage.service.dto.BiStockReconcileRow;
|
import org.nl.wms.bi_manage.service.dto.BiStockReconcileRow;
|
||||||
|
import org.nl.wms.ext_manage.sap.api.SapApi;
|
||||||
|
import org.nl.wms.ext_manage.sap.api.dto.StockCountPostBody;
|
||||||
|
import org.nl.wms.ext_manage.sap.api.dto.StockCountPostHeader;
|
||||||
|
import org.nl.wms.ext_manage.sap.api.dto.StockCountPostItem;
|
||||||
|
import org.nl.wms.ext_manage.sap.api.dto.StockCountPostRequest;
|
||||||
import org.nl.wms.ext_manage.sap.dto.SapStockQueryResult;
|
import org.nl.wms.ext_manage.sap.dto.SapStockQueryResult;
|
||||||
|
import org.nl.wms.ext_manage.sap.enums.SapConstant;
|
||||||
import org.nl.wms.ext_manage.enums.EXTConstant;
|
import org.nl.wms.ext_manage.enums.EXTConstant;
|
||||||
import org.nl.wms.ext_manage.sap.service.SapStockQueryService;
|
import org.nl.wms.ext_manage.sap.service.SapStockQueryService;
|
||||||
import org.nl.wms.ext_manage.service.WmsToZDWmdService;
|
import org.nl.wms.ext_manage.service.WmsToZDWmdService;
|
||||||
@@ -45,6 +56,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
@@ -56,6 +68,11 @@ import java.util.Set;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class BiStockServiceImpl implements IBiStockService {
|
public class BiStockServiceImpl implements IBiStockService {
|
||||||
|
|
||||||
|
/** 物料单位取不到时的默认基本计量单位 */
|
||||||
|
private static final String DEFAULT_MEINS = "PCS";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SapApi sapApi;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SapStockQueryService sapStockQueryService;
|
private SapStockQueryService sapStockQueryService;
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -272,6 +289,126 @@ public class BiStockServiceImpl implements IBiStockService {
|
|||||||
IoUtil.close(out);
|
IoUtil.close(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiStockBalanceResult balance(String storCode, List<BiStockBalanceItem> items) {
|
||||||
|
if (StringUtils.isBlank(storCode)) {
|
||||||
|
throw new BadRequestException("请选择仓库");
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isEmpty(items)) {
|
||||||
|
throw new BadRequestException("请勾选需要平账的物料");
|
||||||
|
}
|
||||||
|
String targetStor = storCode.trim();
|
||||||
|
|
||||||
|
// 同一物料重复勾选时以最后一次的数量为准
|
||||||
|
Map<String, BiStockBalanceItem> materialMap = new LinkedHashMap<>();
|
||||||
|
for (BiStockBalanceItem item : items) {
|
||||||
|
if (item == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String materialCode = StringUtils.trimToNull(item.getMaterialCode());
|
||||||
|
if (materialCode == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (item.getQty() == null) {
|
||||||
|
throw new BadRequestException("物料" + materialCode + "缺少盘点数量,无法平账");
|
||||||
|
}
|
||||||
|
BiStockBalanceItem exists = materialMap.get(materialCode);
|
||||||
|
if (exists != null) {
|
||||||
|
exists.setQty(item.getQty());
|
||||||
|
exists.setUnitName(StringUtils.defaultIfBlank(item.getUnitName(), exists.getUnitName()));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
BiStockBalanceItem copy = new BiStockBalanceItem();
|
||||||
|
copy.setMaterialCode(materialCode);
|
||||||
|
copy.setMaterialName(item.getMaterialName());
|
||||||
|
copy.setQty(item.getQty());
|
||||||
|
copy.setUnitName(item.getUnitName());
|
||||||
|
materialMap.put(materialCode, copy);
|
||||||
|
}
|
||||||
|
if (materialMap.isEmpty()) {
|
||||||
|
throw new BadRequestException("请勾选需要平账的物料");
|
||||||
|
}
|
||||||
|
|
||||||
|
Date now = new Date();
|
||||||
|
String date = DateUtil.format(now, "yyyyMMdd");
|
||||||
|
|
||||||
|
StockCountPostHeader header = new StockCountPostHeader();
|
||||||
|
header.setIntfId(SapConstant.INTF_MM026);
|
||||||
|
header.setSrcSystem(SapConstant.SRC_SYSTEM);
|
||||||
|
header.setDestSystem(SapConstant.DEST_SYSTEM);
|
||||||
|
header.setSrcMsgid(String.valueOf(System.currentTimeMillis()));
|
||||||
|
header.setRequesttime(DateUtil.format(now, "yyyy-MM-dd HH:mm:ss"));
|
||||||
|
header.setBackup1("");
|
||||||
|
header.setBackup2("");
|
||||||
|
|
||||||
|
List<StockCountPostItem> sapItems = new ArrayList<>();
|
||||||
|
BigDecimal totalQty = BigDecimal.ZERO;
|
||||||
|
int lineNo = 1;
|
||||||
|
for (BiStockBalanceItem item : materialMap.values()) {
|
||||||
|
StockCountPostItem sapItem = new StockCountPostItem();
|
||||||
|
sapItem.setZeili(String.valueOf(lineNo++));
|
||||||
|
sapItem.setMatnr(item.getMaterialCode());
|
||||||
|
// 盘点数量:直接把本地库存作为盘点结果,SAP 侧按差异过账
|
||||||
|
sapItem.setMenge(normalize(item.getQty()).toPlainString());
|
||||||
|
sapItem.setMeins(StringUtils.defaultIfBlank(StringUtils.trimToNull(item.getUnitName()), DEFAULT_MEINS));
|
||||||
|
sapItem.setSernr("");
|
||||||
|
sapItem.setXnull("");
|
||||||
|
sapItem.setKdauf("");
|
||||||
|
sapItem.setKdpos("");
|
||||||
|
sapItem.setLifnr("");
|
||||||
|
sapItem.setPsPspPnr("");
|
||||||
|
sapItems.add(sapItem);
|
||||||
|
totalQty = totalQty.add(item.getQty());
|
||||||
|
}
|
||||||
|
|
||||||
|
StockCountPostBody body = new StockCountPostBody();
|
||||||
|
// 凭证号为空表示新增一张差异过账凭证
|
||||||
|
body.setIblnr("");
|
||||||
|
body.setWerks(SapConstant.WERKS);
|
||||||
|
body.setLgort(targetStor);
|
||||||
|
body.setCtime(date);
|
||||||
|
body.setCdate(date);
|
||||||
|
body.setSobkz("");
|
||||||
|
body.setIbltxt(SapConstant.MM026_IBLTXT_BALANCE);
|
||||||
|
body.setItems(sapItems);
|
||||||
|
|
||||||
|
StockCountPostRequest request = new StockCountPostRequest();
|
||||||
|
request.setHeader(header);
|
||||||
|
request.setBody(Collections.singletonList(body));
|
||||||
|
|
||||||
|
log.info("库存平账:仓库{},物料{}个,数量合计{}", targetStor, sapItems.size(), totalQty);
|
||||||
|
JSONObject response = sapApi.stockCountPost(request);
|
||||||
|
if (response == null) {
|
||||||
|
throw new BadRequestException("SAP盘点差异过账失败:响应为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
String sapMessage = "";
|
||||||
|
String iblnr = "";
|
||||||
|
JSONArray responseBody = response.getJSONArray("body");
|
||||||
|
if (responseBody != null && !responseBody.isEmpty()) {
|
||||||
|
JSONObject first = responseBody.getJSONObject(0);
|
||||||
|
if (first != null) {
|
||||||
|
sapMessage = StringUtils.trimToEmpty(first.getString("message"));
|
||||||
|
iblnr = StringUtils.trimToEmpty(first.getString("iblnr"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(sapMessage)) {
|
||||||
|
sapMessage = "平账成功";
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(iblnr)) {
|
||||||
|
sapMessage = sapMessage + "(差异过账凭证号:" + iblnr + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
BiStockBalanceResult result = new BiStockBalanceResult();
|
||||||
|
result.setStorCode(targetStor);
|
||||||
|
result.setMaterialCount(sapItems.size());
|
||||||
|
result.setTotalQty(normalize(totalQty));
|
||||||
|
result.setSapMessage(sapMessage);
|
||||||
|
result.setSapResponse(JSON.toJSONString(response));
|
||||||
|
log.info("库存平账完成:仓库{},物料{}个,SAP返回:{}", targetStor, sapItems.size(), sapMessage);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private void markDiffRows(ExcelWriter writer, List<BiStockReconcileRow> rows) {
|
private void markDiffRows(ExcelWriter writer, List<BiStockReconcileRow> rows) {
|
||||||
if (CollectionUtils.isEmpty(rows)) {
|
if (CollectionUtils.isEmpty(rows)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -80,6 +80,19 @@
|
|||||||
不传 `materials` 时(如定时任务)物料范围 = 该库区已有库存物料 ∪ `pm_material_warehouse_mapping`。
|
不传 `materials` 时(如定时任务)物料范围 = 该库区已有库存物料 ∪ `pm_material_warehouse_mapping`。
|
||||||
查询失败的物料不参与"删除本地库存"判断,避免接口异常误删。
|
查询失败的物料不参与"删除本地库存"判断,避免接口异常误删。
|
||||||
|
|
||||||
|
## SAP 盘点差异过账(MM026,库存平账)
|
||||||
|
|
||||||
|
- `SapApi#stockCountPost(StockCountPostRequest)`,报文 `header + body[]`(`body` 为差异过账抬头数组,
|
||||||
|
抬头里 `items[]` 为行项目),响应走 `postInbound` 的 `body[].status` = S/E 校验。
|
||||||
|
- 请求:`intf_id=MM026`、`src_system=WMS5`、`dest_system=SAP`;抬头 `iblnr` 空表示新增凭证、
|
||||||
|
`werks=1060`、`lgort`=仓库编码、`ctime/cdate=yyyyMMdd`、`ibltxt=WMS库存平账`;
|
||||||
|
行项目 `matnr`、`menge`(字符串)、`meins`(取不到默认 `PCS`)、`zeili`=行序号,其余字段留空。
|
||||||
|
- 业务入口:库存对账页面 `wms/statement/bi/index` 的「平账」按钮(支持跨页批量勾选),
|
||||||
|
`POST /api/bi/balance`,body `{storCode, items:[{materialCode, qty, unitName}]}`;
|
||||||
|
`qty` 取对账页面的本地库存列(WMS 库存或中鼎库存),即把本地库存作为盘点数量过账给 SAP,
|
||||||
|
过账后两边库存一致。库存已一致的行前端自动跳过;成功后页面自动重新对账。
|
||||||
|
该操作直接生成 SAP 差异过账凭证,不做 `pm_stock_return` 记录,失败时前端提示 SAP 返回信息,用户可重试。
|
||||||
|
|
||||||
## 业务模块位置
|
## 业务模块位置
|
||||||
|
|
||||||
业务 CRUD、下推、回传策略等均在 `org.nl.wms.pm_manage.sap` 下:
|
业务 CRUD、下推、回传策略等均在 `org.nl.wms.pm_manage.sap` 下:
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import org.nl.wms.ext_manage.sap.api.dto.ManualPickingRequest;
|
|||||||
import org.nl.wms.ext_manage.sap.api.dto.ProductionInboundRequest;
|
import org.nl.wms.ext_manage.sap.api.dto.ProductionInboundRequest;
|
||||||
import org.nl.wms.ext_manage.sap.api.dto.ProductionOutboundRequest;
|
import org.nl.wms.ext_manage.sap.api.dto.ProductionOutboundRequest;
|
||||||
import org.nl.wms.ext_manage.sap.api.dto.ReceiptConfirmRequest;
|
import org.nl.wms.ext_manage.sap.api.dto.ReceiptConfirmRequest;
|
||||||
|
import org.nl.wms.ext_manage.sap.api.dto.StockCountPostRequest;
|
||||||
import org.nl.wms.ext_manage.sap.api.dto.SubcontractConfirmRequest;
|
import org.nl.wms.ext_manage.sap.api.dto.SubcontractConfirmRequest;
|
||||||
import org.nl.wms.ext_manage.sap.api.dto.SubcontractReverseRequest;
|
import org.nl.wms.ext_manage.sap.api.dto.SubcontractReverseRequest;
|
||||||
import org.nl.wms.pm_manage.sap.sapDelivery.service.SapDeliveryService;
|
import org.nl.wms.pm_manage.sap.sapDelivery.service.SapDeliveryService;
|
||||||
@@ -110,6 +111,13 @@ public class SapApi {
|
|||||||
return postInbound("SAP手工领料出库[" + SapConstant.INTF_MM022 + "]", request);
|
return postInbound("SAP手工领料出库[" + SapConstant.INTF_MM022 + "]", request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MM026 盘点差异过账:以盘点数量(WMS 库存)过账到 SAP,使两边库存一致
|
||||||
|
*/
|
||||||
|
public JSONObject stockCountPost(StockCountPostRequest request) {
|
||||||
|
return postInbound("SAP盘点差异过账[" + SapConstant.INTF_MM026 + "]", request);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MDG019 成本中心主数据查询(表名固定 CSKS)
|
* MDG019 成本中心主数据查询(表名固定 CSKS)
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package org.nl.wms.ext_manage.sap.api.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MM026 盘点差异过账 - 差异过账抬头(一张凭证)
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class StockCountPostBody {
|
||||||
|
|
||||||
|
/** 差异过账凭证号,空表示新增 */
|
||||||
|
@JSONField(name = "iblnr")
|
||||||
|
@JsonProperty("iblnr")
|
||||||
|
private String iblnr;
|
||||||
|
|
||||||
|
/** 工厂 */
|
||||||
|
@JSONField(name = "werks")
|
||||||
|
@JsonProperty("werks")
|
||||||
|
private String werks;
|
||||||
|
|
||||||
|
/** 库存地点(仓库编码) */
|
||||||
|
@JSONField(name = "lgort")
|
||||||
|
@JsonProperty("lgort")
|
||||||
|
private String lgort;
|
||||||
|
|
||||||
|
/** 创建时间 yyyyMMdd */
|
||||||
|
@JSONField(name = "ctime")
|
||||||
|
@JsonProperty("ctime")
|
||||||
|
private String ctime;
|
||||||
|
|
||||||
|
/** 创建日期 yyyyMMdd */
|
||||||
|
@JSONField(name = "cdate")
|
||||||
|
@JsonProperty("cdate")
|
||||||
|
private String cdate;
|
||||||
|
|
||||||
|
/** 特殊库存标识,可选 */
|
||||||
|
@JSONField(name = "sobkz")
|
||||||
|
@JsonProperty("sobkz")
|
||||||
|
private String sobkz;
|
||||||
|
|
||||||
|
/** 凭证抬头文本 / 差异过账说明 */
|
||||||
|
@JSONField(name = "ibltxt")
|
||||||
|
@JsonProperty("ibltxt")
|
||||||
|
private String ibltxt;
|
||||||
|
|
||||||
|
/** 差异过账行项目,接口字段名为 items */
|
||||||
|
@JSONField(name = "items")
|
||||||
|
@JsonProperty("items")
|
||||||
|
private List<StockCountPostItem> items;
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package org.nl.wms.ext_manage.sap.api.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MM026 盘点差异过账 - 报文头
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class StockCountPostHeader {
|
||||||
|
|
||||||
|
/** 接口名称 */
|
||||||
|
@JSONField(name = "intf_id")
|
||||||
|
@JsonProperty("intf_id")
|
||||||
|
private String intfId;
|
||||||
|
|
||||||
|
/** 源系统 */
|
||||||
|
@JSONField(name = "src_system")
|
||||||
|
@JsonProperty("src_system")
|
||||||
|
private String srcSystem;
|
||||||
|
|
||||||
|
/** 目标系统 */
|
||||||
|
@JSONField(name = "dest_system")
|
||||||
|
@JsonProperty("dest_system")
|
||||||
|
private String destSystem;
|
||||||
|
|
||||||
|
/** 消息ID,SAP 发起时带过来,反馈时原样返回 */
|
||||||
|
@JSONField(name = "src_msgid")
|
||||||
|
@JsonProperty("src_msgid")
|
||||||
|
private String srcMsgid;
|
||||||
|
|
||||||
|
/** 请求时间 yyyy-MM-dd HH:mm:ss */
|
||||||
|
@JSONField(name = "requesttime")
|
||||||
|
@JsonProperty("requesttime")
|
||||||
|
private String requesttime;
|
||||||
|
|
||||||
|
@JSONField(name = "backup1")
|
||||||
|
@JsonProperty("backup1")
|
||||||
|
private String backup1;
|
||||||
|
|
||||||
|
@JSONField(name = "backup2")
|
||||||
|
@JsonProperty("backup2")
|
||||||
|
private String backup2;
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package org.nl.wms.ext_manage.sap.api.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MM026 盘点差异过账 - 行项目
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class StockCountPostItem {
|
||||||
|
|
||||||
|
/** 盘点明细行编号 */
|
||||||
|
@JSONField(name = "zeili")
|
||||||
|
@JsonProperty("zeili")
|
||||||
|
private String zeili;
|
||||||
|
|
||||||
|
/** 物料编号 */
|
||||||
|
@JSONField(name = "matnr")
|
||||||
|
@JsonProperty("matnr")
|
||||||
|
private String matnr;
|
||||||
|
|
||||||
|
/** 盘点数量(字符串) */
|
||||||
|
@JSONField(name = "menge")
|
||||||
|
@JsonProperty("menge")
|
||||||
|
private String menge;
|
||||||
|
|
||||||
|
/** 基本计量单位 */
|
||||||
|
@JSONField(name = "meins")
|
||||||
|
@JsonProperty("meins")
|
||||||
|
private String meins;
|
||||||
|
|
||||||
|
/** 序列号列表,每个序列号对应一个物料 */
|
||||||
|
@JSONField(name = "sernr")
|
||||||
|
@JsonProperty("sernr")
|
||||||
|
private String sernr;
|
||||||
|
|
||||||
|
/** 空值标识,备用字段 */
|
||||||
|
@JSONField(name = "xnull")
|
||||||
|
@JsonProperty("xnull")
|
||||||
|
private String xnull;
|
||||||
|
|
||||||
|
/** 销售订单号 */
|
||||||
|
@JSONField(name = "kdauf")
|
||||||
|
@JsonProperty("kdauf")
|
||||||
|
private String kdauf;
|
||||||
|
|
||||||
|
/** 销售订单行项目 */
|
||||||
|
@JSONField(name = "kdpos")
|
||||||
|
@JsonProperty("kdpos")
|
||||||
|
private String kdpos;
|
||||||
|
|
||||||
|
/** 供应商编号 */
|
||||||
|
@JSONField(name = "lifnr")
|
||||||
|
@JsonProperty("lifnr")
|
||||||
|
private String lifnr;
|
||||||
|
|
||||||
|
/** WBS 要素 */
|
||||||
|
@JSONField(name = "ps_psp_pnr")
|
||||||
|
@JsonProperty("ps_psp_pnr")
|
||||||
|
private String psPspPnr;
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package org.nl.wms.ext_manage.sap.api.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MM026 盘点差异过账请求
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class StockCountPostRequest {
|
||||||
|
|
||||||
|
private StockCountPostHeader header;
|
||||||
|
|
||||||
|
private List<StockCountPostBody> body;
|
||||||
|
}
|
||||||
@@ -33,6 +33,12 @@ public class SapConstant {
|
|||||||
/** 接口编号:库存查询 */
|
/** 接口编号:库存查询 */
|
||||||
public static final String INTF_MM027 = "MM027";
|
public static final String INTF_MM027 = "MM027";
|
||||||
|
|
||||||
|
/** 接口编号:盘点差异过账(WMS 库存平账到 SAP) */
|
||||||
|
public static final String INTF_MM026 = "MM026";
|
||||||
|
|
||||||
|
/** MM026 差异过账凭证抬头文本(库存对账平账场景) */
|
||||||
|
public static final String MM026_IBLTXT_BALANCE = "WMS库存平账";
|
||||||
|
|
||||||
/** 接口编号:生产投料 */
|
/** 接口编号:生产投料 */
|
||||||
public static final String INTF_PP055 = "PP055";
|
public static final String INTF_PP055 = "PP055";
|
||||||
|
|
||||||
|
|||||||
@@ -8,4 +8,15 @@ export function reconcile(params) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default { reconcile }
|
/**
|
||||||
|
* 库存平账:以本地库存作为盘点数量调用 SAP MM026 差异过账
|
||||||
|
*/
|
||||||
|
export function balance(data) {
|
||||||
|
return request({
|
||||||
|
url: 'api/bi/balance',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default { reconcile, balance }
|
||||||
|
|||||||
@@ -49,6 +49,17 @@
|
|||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button
|
||||||
|
type="warning"
|
||||||
|
size="mini"
|
||||||
|
class="filter-item"
|
||||||
|
icon="el-icon-refresh-left"
|
||||||
|
:loading="balanceLoading"
|
||||||
|
:disabled="!selection.length"
|
||||||
|
@click="balanceStock"
|
||||||
|
>平账{{ selection.length ? '(' + selection.length + ')' : '' }}</el-button>
|
||||||
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<div v-if="queried" class="summary">
|
<div v-if="queried" class="summary">
|
||||||
@@ -56,15 +67,22 @@
|
|||||||
<span v-if="failedMaterials.length" style="color: #e6a23c; margin-left: 8px;">
|
<span v-if="failedMaterials.length" style="color: #e6a23c; margin-left: 8px;">
|
||||||
({{ failedMaterials.length }} 个物料查询SAP库存失败,已按无库存处理)
|
({{ failedMaterials.length }} 个物料查询SAP库存失败,已按无库存处理)
|
||||||
</span>
|
</span>
|
||||||
|
<span style="color: #909399; margin-left: 8px;">
|
||||||
|
勾选行后点「平账」,将以本地库存为盘点数量调用 SAP MM026 差异过账
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-table
|
<el-table
|
||||||
|
ref="reconcileTable"
|
||||||
v-loading="loading"
|
v-loading="loading"
|
||||||
:data="pageData"
|
:data="pageData"
|
||||||
size="mini"
|
size="mini"
|
||||||
style="width: 100%;"
|
style="width: 100%;"
|
||||||
|
row-key="materialCode"
|
||||||
:row-class-name="rowClassName"
|
:row-class-name="rowClassName"
|
||||||
|
@selection-change="onSelectionChange"
|
||||||
>
|
>
|
||||||
|
<el-table-column type="selection" width="45" reserve-selection />
|
||||||
<el-table-column prop="warehouseCode" label="仓库编号" min-width="120" />
|
<el-table-column prop="warehouseCode" label="仓库编号" min-width="120" />
|
||||||
<el-table-column label="物料编码" min-width="160">
|
<el-table-column label="物料编码" min-width="160">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
@@ -123,7 +141,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getStor } from '@/views/wms/basedata/bsrealstorattr/bsrealstorattr'
|
import { getStor } from '@/views/wms/basedata/bsrealstorattr/bsrealstorattr'
|
||||||
import { reconcile } from './bi'
|
import { reconcile, balance } from './bi'
|
||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
import { download } from '@/api/data'
|
import { download } from '@/api/data'
|
||||||
import { downloadFile } from '@/utils'
|
import { downloadFile } from '@/utils'
|
||||||
@@ -138,6 +156,8 @@ export default {
|
|||||||
onlyDiff: false,
|
onlyDiff: false,
|
||||||
loading: false,
|
loading: false,
|
||||||
downloadLoading: false,
|
downloadLoading: false,
|
||||||
|
balanceLoading: false,
|
||||||
|
selection: [],
|
||||||
queried: false,
|
queried: false,
|
||||||
compareSourceName: '对比库存',
|
compareSourceName: '对比库存',
|
||||||
failedMaterials: [],
|
failedMaterials: [],
|
||||||
@@ -181,6 +201,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onStorChange() {
|
onStorChange() {
|
||||||
|
this.clearSelection()
|
||||||
if (!this.storCode) {
|
if (!this.storCode) {
|
||||||
this.tableData = []
|
this.tableData = []
|
||||||
this.queried = false
|
this.queried = false
|
||||||
@@ -193,6 +214,65 @@ export default {
|
|||||||
this.exportExcel()
|
this.exportExcel()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
onSelectionChange(selection) {
|
||||||
|
this.selection = selection || []
|
||||||
|
},
|
||||||
|
clearSelection() {
|
||||||
|
this.selection = []
|
||||||
|
const table = this.$refs.reconcileTable
|
||||||
|
if (table) {
|
||||||
|
table.clearSelection()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 平账:勾选行以本地库存为盘点数量,调用 SAP MM026 差异过账,使两边库存一致
|
||||||
|
*/
|
||||||
|
balanceStock() {
|
||||||
|
if (!this.storCode) {
|
||||||
|
this.$message.warning('请选择仓库')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 库存已一致的行无需过账,自动跳过
|
||||||
|
const rows = this.selection.filter(row => row.diff)
|
||||||
|
const skipped = this.selection.length - rows.length
|
||||||
|
if (!rows.length) {
|
||||||
|
this.$message.warning('所选行库存已一致,无需平账')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const totalQty = rows.reduce((sum, row) => sum + Number(row.compareQty || 0), 0)
|
||||||
|
const tip = `将以【${this.compareSourceName}】作为盘点数量调用 SAP MM026 差异过账,把 SAP 库存调整为本地库存。` +
|
||||||
|
`本次共 ${rows.length} 个物料,数量合计 ${totalQty}` +
|
||||||
|
(skipped ? `;另有 ${skipped} 行库存一致,将自动跳过` : '') +
|
||||||
|
'。是否继续?'
|
||||||
|
this.$confirm(tip, '库存平账', {
|
||||||
|
type: 'warning',
|
||||||
|
confirmButtonText: '确认平账',
|
||||||
|
cancelButtonText: '取消'
|
||||||
|
}).then(() => {
|
||||||
|
this.balanceLoading = true
|
||||||
|
balance({
|
||||||
|
storCode: this.storCode,
|
||||||
|
items: rows.map(row => ({
|
||||||
|
materialCode: row.materialCode,
|
||||||
|
materialName: row.materialName,
|
||||||
|
qty: row.compareQty,
|
||||||
|
unitName: row.unitName
|
||||||
|
}))
|
||||||
|
}).then(res => {
|
||||||
|
// 业务失败已由请求拦截器统一提示,这里只处理成功返回
|
||||||
|
if (!res) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const result = res.data || {}
|
||||||
|
this.$message.success(
|
||||||
|
`平账成功:${result.materialCount || rows.length} 个物料,数量合计 ${result.totalQty === undefined ? totalQty : result.totalQty}。${result.sapMessage || ''}`
|
||||||
|
)
|
||||||
|
this.queryReconcile()
|
||||||
|
}).catch(() => {}).finally(() => {
|
||||||
|
this.balanceLoading = false
|
||||||
|
})
|
||||||
|
}).catch(() => {})
|
||||||
|
},
|
||||||
queryReconcile() {
|
queryReconcile() {
|
||||||
if (!this.storCode) {
|
if (!this.storCode) {
|
||||||
this.$message.warning('请选择仓库')
|
this.$message.warning('请选择仓库')
|
||||||
@@ -207,6 +287,7 @@ export default {
|
|||||||
this.tableData = data.rows || []
|
this.tableData = data.rows || []
|
||||||
this.page.page = 1
|
this.page.page = 1
|
||||||
this.queried = true
|
this.queried = true
|
||||||
|
this.clearSelection()
|
||||||
if (this.failedMaterials.length) {
|
if (this.failedMaterials.length) {
|
||||||
const preview = this.failedMaterials.slice(0, 5).join('、')
|
const preview = this.failedMaterials.slice(0, 5).join('、')
|
||||||
this.$message.warning(
|
this.$message.warning(
|
||||||
|
|||||||
Reference in New Issue
Block a user