成品添加单据

This commit is contained in:
zhougf committed 2025-12-14 19:09:54 +08:00
1 parent 287453691b
commit 00119151c9
2 files changed
+134 -35

No files matched your search

@@ -71,6 +71,7 @@ namespace HHWMS.Web.Controllers
MaterialName = x.MaterialType,
MaterialSpec = x.MaterialSpec,
CompanyCode = x.CompanyCode,
x.SourceCode,
Batch = x.Batch,
Qty = (int)x.Qty
})
@@ -133,39 +134,43 @@ namespace HHWMS.Web.Controllers
}
[HttpPost]
public ActionResult AddInventory(string containerCode, string materialCode, string company, string sourceCode, decimal qty, string batch)
public ActionResult AddInventory([FromBody] SimpleReceiptInModel model)
{
try
{
if (string.IsNullOrEmpty(containerCode))
if (string.IsNullOrEmpty(model.ContainerCode))
{
return JsonMore(null, 500, "容器编码为空!");
}
if (string.IsNullOrEmpty(materialCode))
if (string.IsNullOrEmpty(model.MaterialCode))
{
return JsonMore(null, 500, "物料编码为空!");
}
if (qty <= 0)
if (model.Qty <= 0)
{
return JsonMore(null, 500, "数量必须大于0!");
}
// 查询容器
var container = _unitWork.FindSingle<Container>(u => u.Code == containerCode);
var container = _unitWork.FindSingle<Container>(u => u.Code == model.ContainerCode);
if (container == null)
{
return JsonMore(null, 500, $"库内没有编码为 {containerCode} 的容器!");
return JsonMore(null, 500, $"库内没有编码为 {model.ContainerCode} 的容器!");
}
// 查询物料信息
var material = _unitWork.FindSingle<Material>(x => x.MaterialCode == materialCode);
var material = _unitWork.FindSingle<Material>(x => x.MaterialCode == model.MaterialCode);
if (material == null)
{
return JsonMore(null, 500, $"未找到物料编码为 {materialCode} 的物料信息!");
return JsonMore(null, 500, $"未找到物料编码为 {model.MaterialCode} 的物料信息!");
}
var batchCode = _unitWork.Find<MaterialProcess>(x => x.MaterialCode == material.MaterialCode)
.OrderByDescending(x => x.ProcessOrder)
.FirstOrDefault()
?.ProcessCode;
var zone = _unitWork.FindSingle<LocationZone>(x => x.ZoneCode == container.Type);
// 创建库存记录
var inventory = new Inventory()
@@ -177,13 +182,16 @@ namespace HHWMS.Web.Controllers
MaterialType = material.MaterialType,
MaterialSpec = material.MaterialSpec,
MaterialUnit = material.MaterialUnit,
CompanyCode = company,
SourceCode = sourceCode,
CompanyCode = model.CompanyCode,
SourceCode = model.OrderId,
ReceiptDetailId = model.SourceCode, // 优先使用 OrderId
SupplierCode = material.SupplierCode,
Batch = batch,
Qty = qty,
Batch = model.Batch,
Qty = model.Qty,
BatchCode = batchCode,
TaskStatus = InventoryTaskStatusEnum.Locked,
CreateTime = DateTime.Now
CreateTime = DateTime.Now,
CreateBy = Wtm.LoginUserInfo.ITCode
};
_unitWork.Add(inventory);
@@ -542,4 +550,51 @@ namespace HHWMS.Web.Controllers
}
}
/// <summary>
/// 成品入库请求模型
/// </summary>
public class SimpleReceiptInModel
{
/// <summary>
/// 托盘编码
/// </summary>
public string ContainerCode { get; set; }
/// <summary>
/// 物料编码
/// </summary>
public string MaterialCode { get; set; }
/// <summary>
/// 物料名称(图号)
/// </summary>
public string MaterialName { get; set; }
/// <summary>
/// 物料规格
/// </summary>
public string MaterialSpec { get; set; }
/// <summary>
/// 部件名称(批次)
/// </summary>
public string Batch { get; set; }
/// <summary>
/// 订单号(上游单号)
/// </summary>
public string SourceCode { get; set; }
public string OrderId { get; set; }
/// <summary>
/// 公司
/// </summary>
public string CompanyCode { get; set; }
/// <summary>
/// 数量
/// </summary>
public decimal Qty { get; set; }
}
}