更新叫料,领料逻辑

This commit is contained in:
赵正易 2025-08-05 17:39:36 +08:00
parent e2d81a0929
commit 9248ab9d9d
2 changed files with 57 additions and 16 deletions

View File

@ -35,6 +35,8 @@ namespace DOAN.Model.MES.mm.paintedparts_call.Dto
public DateTime? WorkOrderDate { get; set; }
// 料号
public string MaterialCode { get; set; }
// 数量
public int? Quantity { get; set; }
// ID
public string Id { get; set; }
}

View File

@ -7,6 +7,7 @@ using DOAN.Model.MES.ERP;
using DOAN.Model.MES.mm.paintedparts_call;
using DOAN.Model.MES.mm.paintedparts_call.Dto;
using DOAN.Model.MES.product;
using DOAN.Model.Mobile.Dto;
using DOAN.Repository;
using DOAN.Service.MES.mm.paintedparts_call.IService;
using Infrastructure.Attribute;
@ -29,8 +30,9 @@ namespace DOAN.Service.MES.mm.paintedparts_call
/// <returns></returns>
public PagedInfo<MmCallDto> GetList(MmCallQueryDto parm)
{
var predicate = Expressionable.Create<MmCallMrp>()
.AndIF(!string.IsNullOrEmpty(parm.LineCode),it=>it.LineCode == parm.LineCode)
var predicate = Expressionable
.Create<MmCallMrp>()
.AndIF(!string.IsNullOrEmpty(parm.LineCode), it => it.LineCode == parm.LineCode)
.AndIF(parm.WorkOrderDate != null, it => it.WorkorderDate == parm.WorkOrderDate);
var response = Queryable()
@ -234,6 +236,10 @@ namespace DOAN.Service.MES.mm.paintedparts_call
{
throw new Exception("没有找到对应的叫料信息");
}
if (parm.Quantity > mmCallRequest.Quantity)
{
throw new Exception("叫料数量超出");
}
// 2.新增叫料信息
MmCallReceive newMmCallReceive =
new()
@ -245,7 +251,7 @@ namespace DOAN.Service.MES.mm.paintedparts_call
ReceiveTime = null,
MaterialCode = mmCallRequest.MaterialCode,
MaterialName = mmCallRequest.MaterialName,
Quantity = mmCallRequest.Quantity,
Quantity = parm.Quantity,
CreatedBy = "PDA",
CreatedTime = DateTime.Now,
};
@ -260,25 +266,58 @@ namespace DOAN.Service.MES.mm.paintedparts_call
/// <exception cref="NotImplementedException"></exception>
public int DoLineReceiveMaterial(MmCallAndReceiveDto parm)
{
if ( parm == null || string.IsNullOrEmpty(parm.Id))
if (parm == null || string.IsNullOrEmpty(parm.Id))
{
throw new ArgumentException("参数无效MmCallReceiveId 必须有值", nameof(parm.Id));
}
// 1.获取对应叫料信息
var mmCallReceive = Context
.Queryable<MmCallReceive>()
.Where(it => it.Id == parm.Id)
.First();
if (mmCallReceive == null)
try
{
throw new Exception("没有找到对应的叫料信息");
Context.Ado.BeginTran();
// 1.获取对应叫料信息
var mmCallReceive = Context
.Queryable<MmCallReceive>()
.Where(it => it.Id == parm.Id)
.First();
if (mmCallReceive == null)
{
Context.Ado.RollbackTran();
throw new Exception("没有找到对应的叫料信息");
}
// 2.变更状态为已完成
mmCallReceive.ReceiveTime = DateTime.Now;
Context.Updateable(mmCallReceive).ExecuteCommand();
// 3.扣减对应MRP数量
var mmCallRequest = Context
.Queryable<MmCallMrp>()
.Where(it =>
it.LineCode == mmCallReceive.LineCode
&& it.WorkorderDate == mmCallReceive.WorkorderDate
)
.Where(it => it.MaterialCode == mmCallReceive.MaterialCode)
.First();
if (mmCallRequest == null)
{
Context.Ado.RollbackTran();
throw new Exception("没有找到对应的叫料信息");
}
mmCallRequest.Quantity -= mmCallReceive.Quantity;
int result = Context.Updateable(mmCallRequest).ExecuteCommand();
Context.Ado.CommitTran();
return result > 0 ? 1 : 0;
}
catch (Exception)
{
Context.Ado.RollbackTran();
throw;
}
// 2.变更状态为已完成
mmCallReceive.ReceiveTime = DateTime.Now;
Context.Updateable(mmCallReceive).ExecuteCommand();
return 1;
}
/// <summary>
/// 产线退料
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public int DoLineReturnBackMaterial(MmCallAndReceiveDto parm)
{
if (parm == null || string.IsNullOrEmpty(parm.Id))
@ -303,7 +342,7 @@ namespace DOAN.Service.MES.mm.paintedparts_call
throw new InvalidOperationException("没有找到对应的叫料信息");
}
// 2. 更新叫料记录(清空 ReceiveTime
// 2. 更新叫料记录(清空 ReceiveTime,使其重新领料
mmCallReceive.ReceiveTime = null;
Context.Updateable(mmCallReceive).ExecuteCommand();