修改库存会穿ERP

This commit is contained in:
zhougf committed 2026-04-22 22:19:31 +08:00
1 parent d156650264
commit 6729d5fd7d
3 files changed
+13 -78

No files matched your search

@@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
@@ -554,53 +554,17 @@ namespace HHWMS.Web.Controllers
return FFResult().Alert("所选库存已报工回传,无需再次回传!").RefreshGrid();
}
// 构建ERP请求
// 字段映射参照 ReceiptInController:
// SourceCode = 单号 -> InCode
// ReceiptDetailId = erpdetailid -> MoDetailId
// BatchCode = 工序编码 -> StepCode
// CreateBy = 操作员 -> WorkerCode
// ReceiptCode = 校验员 -> Maker
// CompanyCode = 公司 -> ErpCode
var request = new FinishInRequest
{
Main = new FinishInMain
{
ErpCode = "003", // 账套号
InCode = _unitWork.GetSerialNumber("RW"), // 报工单号(上游单号)
InDate = (inv.CreateTime ?? DateTime.Now).ToString("yyyy-MM-dd"), // 报工日期
StepCode = inv.BatchCode, // 工序(批次编码)
WorkerCode = inv.CreateBy, // 工人编码(创建人)
Maker = _unitWork.FindSingle<FrameworkUser>(x =>
x.ITCode == inv.CreateBy).Name, // 制单人(校验员)
Type = inv.ZoneId == 1027 ? 1: 2,
WhCode = inv.ZoneId == 1027 ? "xb": "cp",
},
Details = new List<FinishInDetail>()
};
// 根据库存构建明细
request.Details.Add(new FinishInDetail
{
MoDetailId = inv.ReceiptDetailId, // 生产订单明细(ERP明细ID)
InvCode = inv.MaterialCode, // 物料号
Qty = inv.Qty ?? 0 // 完工数量
});
// 调用ERP接口
var apiResult = await Wtm.CallAPI<FinishInResponse>("ERP", "FinishIn", HttpMethodEnum.POST, request);
// 使用通用的ProcessErpFinishIn方法
var invVM = Wtm.CreateVM<InventoryVM>();
var success = await invVM.ProcessErpFinishIn(inv, TaskTypeEnum.入库);
if (apiResult.Data is { Result: true })
if (success)
{
inv.UploadErpFlag = 1;
_unitWork.Update(inv);
return FFResult().Alert("回传ERP成功").RefreshGrid();
}
else
{
inv.UploadErpFlag = 0;
_unitWork.Update(inv);
return FFResult().Alert($"调用ERP接口失败 {(apiResult.Data != null ? apiResult.Data.Message : apiResult.ErrorMsg)}")
.RefreshGrid();
return FFResult().Alert("回传ERP失败").RefreshGrid();
}
}
catch (Exception ex)