添加工序配置

修改入库页面,任务完成,库存页面等
This commit is contained in:
zhougf committed 2025-08-31 15:57:46 +08:00
1 parent c2b039ea47
commit 5a04ca9d59
41 files changed
+1151 -84

No files matched your search

+134 -9
View File
@@ -32,8 +32,6 @@ namespace HHWMS.Web
private readonly IMapper _mapper;
private readonly IMemoryCache _cache;
private const int DEBOUNCE_INTERVAL_MS = 1000; // 防抖间隔1秒
private int ContainerWeight = 500;
private int SmallContainerWeight = 50;
public IWCSController(IUnitWork unitWork, IMapper mapper, IMemoryCache cache)
{
@@ -95,16 +93,14 @@ namespace HHWMS.Web
public IActionResult FullIn(WcsRequest request)
{
var task = _unitWork.FindSingle<TaskHeader>(x => x.TaskNo == request.TaskNo
&& x.Status != TaskStatusEnum.完成);
&& x.Status != TaskStatusEnum.完成
&& x.TaskType != TaskTypeEnum.出库);
if (task == null)
{
return ApiResultError(msg: "未找到任务!");
}
//查找新仓位
var locationVm = Wtm.CreateVM<LocationVM>();
// 更新旧仓位
var oldLoc = _unitWork.FindSingle<Location>(x => x.Code == task.ToLocation);
oldLoc.ContainerCode = "FullIn";
@@ -112,7 +108,31 @@ namespace HHWMS.Web
oldLoc.UpdateTime = DateTime.Now;
_unitWork.Update(oldLoc);
return ApiResult();
//查找新仓位
var locationVm = Wtm.CreateVM<LocationVM>();
var res = locationVm.GetMoveLocation(oldLoc);
if (res.Status)
{
string code = res.Data.LocationCode;
var newLoc = _unitWork.FindSingle<Location>(x => x.Code == code);
newLoc.ContainerCode = task.ContainerCode;
newLoc.Status = oldLoc.Status;
newLoc.ContainerStatus = oldLoc.ContainerStatus;
newLoc.Status = LocationStatusEnum.锁定;
newLoc.UpdateTime = DateTime.Now;
_unitWork.Update(newLoc);
task.ToLocation = newLoc.Code;
task.UpdateBy = "FullIn";
task.UpdateTime = DateTime.Now;
_unitWork.Update(task);
return ApiResult(new { LocationCode = res.Data.LocationCode });
}
else
{
return ApiResultError(msg:res.Message);
}
}
@@ -129,10 +149,101 @@ namespace HHWMS.Web
{
return ApiResultError(msg: "未找到任务!");
}
//1. 更新容器
var container = _unitWork.FindSingle<Container>(x => x.Code == task.ContainerCode);
container.UpdateBy = "EmptyOut";
container.UpdateTime = DateTime.Now;
_unitWork.Update(container);
//2. 更新库位
var location = _unitWork.FindSingle<Location>(x => x.Code == task.FromLocation);
location.UpdateBy = "EmptyOut";
location.UpdateTime = DateTime.Now;
location.ContainerStatus = LocationStatus.空仓位;
_unitWork.Update(location);
//3. 更新任务
task.UpdateBy = "EmptyOut";
task.UpdateTime = DateTime.Now;
task.ErrorMsg = "空出";
var taskHistory = _mapper.Map<TaskHeaderHistory>(task);
_unitWork.Add(taskHistory);
_unitWork.Delete(task);
//4. 更新库存
_unitWork.BatchUpdate<Inventory>(x => x.ContainerCode == task.ContainerCode,x => new Inventory()
{
LocationCode = "空出",
UpdateBy = "EmptyOut",
UpdateTime = DateTime.Now
});
return ApiResult();
}
/// <summary>
/// 取货错处理
/// </summary>
[HttpPost]
public IActionResult PickError(WcsRequest request)
{
var task = _unitWork.FindSingle<TaskHeader>(x => x.TaskNo == request.TaskNo
&& x.Status != TaskStatusEnum.完成);
if (task == null)
{
return ApiResultError(msg: "未找到任务!");
}
var outLoc = _unitWork.FindSingle<Location>(x => x.Code == task.FromLocation);
var outTask = _unitWork.FindSingle<TaskHeader>(x => x.FromLocation == outLoc.ContiguousCode);
if (outTask != null)
{
return ApiResultError(msg: $"外侧仓位 {outLoc.Code} 已有出库任务!");
}
// 生成外侧仓位的移库任务
var locationVm = Wtm.CreateVM<LocationVM>();
var moveLocRes = locationVm.GetMoveLocation(outLoc);
if (moveLocRes.Status)
{
var taskHeader = new TaskHeader()
{
ZoneId = task.ZoneId,
TaskNo = _unitWork.GetSerialNumber("Move"),
TaskType = TaskTypeEnum.移库,
ContainerCode = outLoc.ContainerCode,
RoadWay = 2,
FromLocation = outLoc.Code,
ToLocation = moveLocRes.Data.LocationCode,
Status = TaskStatusEnum.新建,
CreateBy = "PickError",
CreateTime = DateTime.Now,
};
var sendTaskRes = locationVm.SendWcsTask(taskHeader);
if (sendTaskRes.Status)
{
string code = sendTaskRes.Data.LocationCode;
var moveLoc = _unitWork.FindSingle<Location>(x => x.Code == code);
moveLoc.Status = LocationStatusEnum.锁定;
moveLoc.UpdateBy = "PickError";
moveLoc.UpdateTime = DateTime.Now;
_unitWork.Update(moveLoc);
}
else
{
return ApiResultError(msg: sendTaskRes.Message);
}
}
else
{
return ApiResultError(msg: moveLocRes.Message);
}
return ApiResult();
}
/// <summary>
/// 状态返回(带防抖)
/// </summary>
@@ -269,9 +380,15 @@ namespace HHWMS.Web
{
if (task.TaskType == TaskTypeEnum.入库)
{
var containerconfig = _unitWork.Find<SysDictData>(x => x.DictType == "ContainerConfig")
.ToList();
int ContainerWeight = int.Parse(containerconfig.FirstOrDefault(x => x.DictLabelUs.ToLower() == "container")?.DictValue);
int SmallContainerWeight = int.Parse(containerconfig.FirstOrDefault(x => x.ID == inventory.Flag)?.DictValue);
var material =
_unitWork.FindSingle<Material>(x => x.MaterialCode == inventory.MaterialCode);
inventory.Qty = (request.Weight - ContainerWeight - inventory.TaskQty * SmallContainerWeight) / (material.Qty ?? 5);
inventory.Qty = (request.Weight * 100 - ContainerWeight - inventory.TaskQty * SmallContainerWeight) / (material.Qty ?? 1);
inventory.Qty = inventory.Qty > 0 ? inventory.Qty : 0;
}
if (task.TaskType != TaskTypeEnum.移库)
@@ -333,8 +450,16 @@ namespace HHWMS.Web
{
_unitWork.BatchAdd(invTrans);
}
_unitWork.BatchUpdate(inventories);
if (task.TaskType == TaskTypeEnum.出库 && task.ZoneId == 1027)
{
// 线边库出库删掉库存
_unitWork.BatchDelete(inventories);
}
else
{
_unitWork.BatchUpdate(inventories);
}
// 更新容器状态
var container = _unitWork.FindSingle<Container>(x => x.Code == task.ContainerCode);