fix: 查询库存接口,按照入库时间降序返回
This commit is contained in:
1 parent
471300768e
commit
57ce5eb5a2
7 files changed
+273
-71
No files matched your search
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using HHWMS.Web.Models;
|
||||
using HHWMS.Web.Support;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
@@ -688,6 +689,10 @@ namespace HHWMS.Web.Controllers
|
||||
if (!result.Status)
|
||||
{
|
||||
task.Status = TaskStatusEnum.待下发;
|
||||
// 记录最后一次下发失败原因,列表中可直接看出"从未下发成功"的任务
|
||||
task.ErrorMsg = string.IsNullOrWhiteSpace(result.Message)
|
||||
? "WCS任务下发失败"
|
||||
: result.Message;
|
||||
_unitwork.Update(task);
|
||||
transaction.Commit();
|
||||
return JsonMore(null, 500, result.Message ?? "WCS任务下发失败");
|
||||
@@ -805,82 +810,30 @@ namespace HHWMS.Web.Controllers
|
||||
|
||||
private void RecalculateShipmentDetail(int shipmentDetailId)
|
||||
{
|
||||
var detail = _unitwork.FindSingle<ShipmentDetail>(x => x.ID == shipmentDetailId);
|
||||
if (detail == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RecalculateShipmentDetail(detail);
|
||||
ShipmentStatusCalculator.RecalculateDetail(_unitwork, shipmentDetailId, GetOperatorCode());
|
||||
}
|
||||
|
||||
private void RecalculateShipmentDetail(ShipmentDetail detail)
|
||||
{
|
||||
|
||||
detail.DividedQty = _unitwork.Find<TaskDetail>(x =>
|
||||
x.OrderDetailId == detail.ID
|
||||
&& x.Status != TaskStatusEnum.完成)
|
||||
.Sum(x => x.Qty) ?? 0;
|
||||
var qty = detail.Qty ?? 0;
|
||||
var completedQty = detail.CompletedQty ?? 0;
|
||||
var dividedQty = detail.DividedQty ?? 0;
|
||||
detail.Status = completedQty >= qty
|
||||
? ShipStatusEnum.拣货完成
|
||||
: completedQty > 0
|
||||
? ShipStatusEnum.拣货中
|
||||
: dividedQty >= qty && qty > 0
|
||||
? ShipStatusEnum.分配完成
|
||||
: dividedQty > 0
|
||||
? ShipStatusEnum.分配中
|
||||
: ShipStatusEnum.新建;
|
||||
detail.UpdateTime = DateTime.Now;
|
||||
detail.UpdateBy = Wtm.LoginUserInfo?.ITCode ?? "WMS";
|
||||
_unitwork.Update(detail);
|
||||
ShipmentStatusCalculator.RecalculateDetail(_unitwork, detail, GetOperatorCode());
|
||||
}
|
||||
|
||||
private void RecalculateShipmentHeader(int shipmentHeaderId)
|
||||
{
|
||||
var header = _unitwork.FindSingle<ShipmentHeader>(x => x.ID == shipmentHeaderId);
|
||||
if (header == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RecalculateShipmentHeader(header);
|
||||
ShipmentStatusCalculator.RecalculateHeader(_unitwork, shipmentHeaderId, GetOperatorCode());
|
||||
}
|
||||
|
||||
private void RecalculateShipmentHeader(ShipmentHeader header)
|
||||
{
|
||||
ShipmentStatusCalculator.RecalculateHeader(_unitwork, header, GetOperatorCode());
|
||||
}
|
||||
|
||||
var details = _unitwork.Find<ShipmentDetail>(x => x.HeaderId == header.ID).ToList();
|
||||
ShipStatusEnum status;
|
||||
if (details.Any() && details.All(x => (x.CompletedQty ?? 0) >= (x.Qty ?? 0)))
|
||||
{
|
||||
status = ShipStatusEnum.拣货完成;
|
||||
}
|
||||
else if (details.Any(x => (x.CompletedQty ?? 0) > 0))
|
||||
{
|
||||
status = ShipStatusEnum.拣货中;
|
||||
}
|
||||
else if (details.Any() && details.All(x =>
|
||||
(x.CompletedQty ?? 0) + (x.DividedQty ?? 0) >= (x.Qty ?? 0)))
|
||||
{
|
||||
status = ShipStatusEnum.分配完成;
|
||||
}
|
||||
else if (details.Any(x => (x.DividedQty ?? 0) > 0))
|
||||
{
|
||||
status = ShipStatusEnum.分配中;
|
||||
}
|
||||
else
|
||||
{
|
||||
status = ShipStatusEnum.新建;
|
||||
}
|
||||
|
||||
header.FirstStatus = status;
|
||||
header.LastStatus = status;
|
||||
header.UpdateTime = DateTime.Now;
|
||||
header.UpdateBy = Wtm.LoginUserInfo?.ITCode ?? "WMS";
|
||||
_unitwork.Update(header);
|
||||
/// <summary>
|
||||
/// 当前操作人账号,用于写更新人
|
||||
/// </summary>
|
||||
private string GetOperatorCode()
|
||||
{
|
||||
return Wtm.LoginUserInfo?.ITCode ?? "WMS";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user