修改库存会穿ERP
This commit is contained in:
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 Microsoft.AspNetCore.Mvc;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -554,53 +554,17 @@ namespace HHWMS.Web.Controllers
|
|||||||
return FFResult().Alert("所选库存已报工回传,无需再次回传!").RefreshGrid();
|
return FFResult().Alert("所选库存已报工回传,无需再次回传!").RefreshGrid();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 构建ERP请求
|
// 使用通用的ProcessErpFinishIn方法
|
||||||
// 字段映射参照 ReceiptInController:
|
var invVM = Wtm.CreateVM<InventoryVM>();
|
||||||
// SourceCode = 单号 -> InCode
|
var success = await invVM.ProcessErpFinishIn(inv, TaskTypeEnum.入库);
|
||||||
// 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);
|
|
||||||
|
|
||||||
if (apiResult.Data is { Result: true })
|
if (success)
|
||||||
{
|
{
|
||||||
inv.UploadErpFlag = 1;
|
|
||||||
_unitWork.Update(inv);
|
|
||||||
return FFResult().Alert("回传ERP成功").RefreshGrid();
|
return FFResult().Alert("回传ERP成功").RefreshGrid();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
inv.UploadErpFlag = 0;
|
return FFResult().Alert("回传ERP失败").RefreshGrid();
|
||||||
_unitWork.Update(inv);
|
|
||||||
return FFResult().Alert($"调用ERP接口失败 {(apiResult.Data != null ? apiResult.Data.Message : apiResult.ErrorMsg)}")
|
|
||||||
.RefreshGrid();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -116,6 +116,9 @@ namespace HHWMS.Web
|
|||||||
{
|
{
|
||||||
finishInRequest.Details.Add(new FinishInDetail
|
finishInRequest.Details.Add(new FinishInDetail
|
||||||
{
|
{
|
||||||
|
MoDetailId = inventory.ZoneId == 1027 ? "" : inventory.ReceiptDetailId, // 生产订单明细(ERP明细ID)
|
||||||
|
InvCode = inventory.MaterialCode, // 物料号
|
||||||
|
Qty = inventory.Qty ?? 0 ,// 完工数量
|
||||||
MaterialDetails = new List<MaterialDetail>
|
MaterialDetails = new List<MaterialDetail>
|
||||||
{
|
{
|
||||||
new MaterialDetail
|
new MaterialDetail
|
||||||
|
|||||||
@@ -22,44 +22,12 @@ namespace HHWMS.Web
|
|||||||
|
|
||||||
var inv = _unitwork.FindSingle<Inventory>(x => x.UploadErpFlag == 0
|
var inv = _unitwork.FindSingle<Inventory>(x => x.UploadErpFlag == 0
|
||||||
&& x.TaskStatus != InventoryTaskStatusEnum.Locked
|
&& x.TaskStatus != InventoryTaskStatusEnum.Locked
|
||||||
&& !string.IsNullOrEmpty(x.ReceiptDetailId)
|
// && !string.IsNullOrEmpty(x.ReceiptDetailId)
|
||||||
);
|
);
|
||||||
|
|
||||||
var request = new FinishInRequest
|
// 使用通用的ProcessErpFinishIn方法
|
||||||
{
|
var invVM = Wtm.CreateVM<InventoryVM>();
|
||||||
Main = new FinishInMain
|
await invVM.ProcessErpFinishIn(inv, TaskTypeEnum.入库);
|
||||||
{
|
|
||||||
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 // 制单人(校验员)
|
|
||||||
},
|
|
||||||
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);
|
|
||||||
|
|
||||||
if (apiResult.Data != null && apiResult.Data.Result)
|
|
||||||
{
|
|
||||||
inv.UploadErpFlag = 1;
|
|
||||||
_unitwork.Update(inv);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
inv.UploadErpFlag = 0;
|
|
||||||
_unitwork.Update(inv);
|
|
||||||
}
|
|
||||||
#region 更新时间
|
#region 更新时间
|
||||||
var job = _unitwork.FindSingle<SysJob>(x =>
|
var job = _unitwork.FindSingle<SysJob>(x =>
|
||||||
x.JobName == context.JobDetail.Key.Name
|
x.JobName == context.JobDetail.Key.Name
|
||||||
|
|||||||
Reference in new issue
Block a user