线边操作添加ERP关联

This commit is contained in:
zhougf committed 2025-12-05 21:01:27 +08:00
1 parent 713c3528ad
commit 0e5d0247bf
19 files changed
+1467 -139

No files matched your search

@@ -1,6 +1,9 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Mvc;
using WalkingTec.Mvvm.Core.Extensions;
@@ -359,7 +362,7 @@ namespace HHWMS.Web.Controllers
}
#endregion
#region InvOut 成品出库
#region InvOut 成品出库
[ActionDescription("TaskType.Out")]
public ActionResult InvOut2(string id)
{
@@ -518,5 +521,81 @@ namespace HHWMS.Web.Controllers
}
}
#endregion
#region FinishIn 回传ERP入库信息
/// <summary>
/// 回传ERP入库信息
/// </summary>
/// <param name="ids">库存ID数组</param>
/// <returns></returns>
[ActionDescription("回传ERP入库")]
public async Task<ActionResult> FinishIn(string id)
{
try
{
// 参数校验
// 校验库存
var inv = _unitWork.FindSingle<Inventory>(x => x.ID == int.Parse(id));
if (inv == null)
{
return FFResult().Alert("所选库存不存在,请检查后重试!").RefreshGrid();
}
if (inv.TaskStatus == InventoryTaskStatusEnum.Locked)
{
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 = "001", // 账套号
InCode = inv.SourceCode, // 报工单号(上游单号)
InDate = (inv.CreateTime ?? DateTime.Now).ToString("yyyy-MM-dd"), // 报工日期
StepCode = inv.BatchCode, // 工序(批次编码)
WorkerCode = inv.CreateBy, // 工人编码(创建人)
Maker = inv.ReceiptCode // 制单人(校验员)
},
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", "Api/FinishIn", HttpMethodEnum.POST, request);
if (apiResult.Data != null)
{
inv.UploadErpFlag = 1;
_unitWork.Update(inv);
return FFResult().Alert("回传ERP成功").RefreshGrid();
}
else
{
inv.UploadErpFlag = 0;
_unitWork.Update(inv);
return FFResult().Alert(apiResult.ErrorMsg?? "调用ERP接口失败").RefreshGrid();
}
}
catch (Exception ex)
{
return FFResult().Alert($"回传ERP失败:{ex.Message}" ).RefreshGrid();
}
}
#endregion
}
}