UpdateWorkorder 增加逻辑

This commit is contained in:
xiaowei.song
2023-11-15 15:47:23 +08:00
parent ec615329db
commit 68aa2c3673

View File

@@ -177,21 +177,40 @@ namespace ZR.Admin.WebApi.Controllers.MES.pro
int data = 0;
if (proWorkorder != null)
{
string workPlanId = proWorkorder.FkProPlanId;
if (!string.IsNullOrEmpty(workPlanId))
string workorderId = proWorkorder.Id;
if (!string.IsNullOrEmpty(workPlanId) && !string.IsNullOrEmpty(workorderId))
{
// 查询生产计划对象
List<ProWorkplan> lstWorkplan = proWorkplanService.GetProWorkplanById(workPlanId);
// 查询所有生产工单
List<ProWorkorder> lstWorkorder = proWorkplanService.GetWorkorderList(workorderId);
// 计算所有工单的数量和,生产计划的数量:比较
if (lstWorkplan != null && lstWorkplan.Count == 1)
{
int countWorkplan = int.Parse(lstWorkplan[0].ActualplanNumber.Trim());
int countWorkorder = 0;
foreach (ProWorkorder item in lstWorkorder)
{
countWorkorder += item.Actualnumber.GetValueOrDefault();
}
countWorkorder += proWorkorder.Actualnumber.GetValueOrDefault();
// 计划数>0 计划数要大于等于当前工单总数
if (countWorkplan > 0 && (countWorkplan >= countWorkorder))
{
proWorkorder.ToUpdate(HttpContext);
data = proWorkplanService.UpdateWorkorder(proWorkorder);
}
else
{
data = 2;
}
}
}
proWorkorder.ToUpdate(HttpContext);
data = proWorkplanService.UpdateWorkorder(proWorkorder);
}
return ToResponse(new ApiResult(200, "success", data));