任务添加zoneid

添加物料打印
添加物料工序
添加库存出库
修改状态返回接口
wcs请求添加 重量和入口
This commit is contained in:
zhougf committed 2025-07-09 01:11:10 +08:00
1 parent 42c26b2800
commit b12ed2d5e5
54 files changed
+1442 -393

No files matched your search

+51 -29
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AutoMapper;
@@ -31,6 +32,7 @@ namespace HHWMS.Web
private readonly IMapper _mapper;
private readonly IMemoryCache _cache;
private const int DEBOUNCE_INTERVAL_MS = 1000; // 防抖间隔1秒
private int ContainerWeight = 500;
public IWCSController(IUnitWork unitWork, IMapper mapper, IMemoryCache cache)
{
@@ -133,7 +135,7 @@ namespace HHWMS.Web
private async Task<IActionResult> ProcessTaskStatusResult(WcsRequest request)
{
// 1. 根据托盘号查找对应的任务
var task = _unitWork.FindSingle<TaskHeader>(x => x.ContainerCode == request.PalletNo
var task = _unitWork.FindSingle<TaskHeader>(x => x.TaskNo == request.TaskNo
&& x.Status != TaskStatusEnum.完成);
if (task == null)
@@ -166,7 +168,7 @@ namespace HHWMS.Web
// 根据请求的高度,分配仓位
var locationVm = Wtm.CreateVM<LocationVM>();
request.RoadWay = 2;
var container = _unitWork.FindSingle<Container>(x => x.Code == request.PalletNo);
var container = _unitWork.FindSingle<Container>(x => x.Code == task.ContainerCode);
if (container != null)
{
request.LocationType = container.Type switch
@@ -208,52 +210,72 @@ namespace HHWMS.Web
{
try
{
// 1. 更新库存
var inventories = _unitWork.Find<Inventory>(x => x.ContainerCode == request.PalletNo);
// 更新库存
var inventories = _unitWork.Find<Inventory>(x => x.ContainerCode == task.ContainerCode).ToList();
var invTrans = new List<InventoryTransaction>();
foreach (var inventory in inventories)
{
// 更新库存的库位编码
var material = _unitWork.FindSingle<Material>(x => x.MaterialCode == inventory.MaterialCode);
inventory.LocationCode = task.ToLocation;
// 更新库存任务状态为空闲
if(task.TaskType == TaskTypeEnum.入库)
inventory.Qty = (request.Weight - ContainerWeight) / material.Qty;
inventory.TaskStatus = InventoryTaskStatusEnum.Idle;
}
// 2. 更新容器状态
var container = _unitWork.FindSingle<Container>(x => x.Code == request.PalletNo);
// 创建库存交易记录 放到任务完成,计算数量信息
var invTransaction = new InventoryTransaction
{
Type = task.TaskType == TaskTypeEnum.入库 ? InventoryTranType.入库 : InventoryTranType.出库,
ContainerCode = task.ContainerCode,
LocationCode = task.ToLocation,
MaterialCode = inventory.MaterialCode,
MaterialName = inventory.MaterialName,
MaterialSpec = inventory.MaterialSpec,
MaterialUnit = inventory.MaterialUnit,
Qty = inventory.Qty,
CreateTime = DateTime.Now
};
invTrans.Add(invTransaction);
}
_unitWork.BatchAdd(invTrans);
_unitWork.BatchUpdate(inventories);
// 更新容器状态
var container = _unitWork.FindSingle<Container>(x => x.Code == task.ContainerCode);
if (container != null)
{
// 更新容器的库位编码
container.LocationCode = task.ToLocation;
// 更新容器状态为有货
container.Status = ContainerStatus.有;
// 解除容器的任务锁
container.IsLock = ContainerLockEnum.未锁;
container.UpdateTime = DateTime.Now;
}
_unitWork.Update(container);
// 3. 更新库位状态
var location = _unitWork.FindSingle<Location>(x => x.Code == task.ToLocation);
// 更新库位状态
var location = task.TaskType == TaskTypeEnum.入库
? _unitWork.FindSingle<Location>(x => x.Code == task.ToLocation)
: _unitWork.FindSingle<Location>(x => x.Code == task.FromLocation);
if (location != null)
{
// 更新库位的容器编码
location.ContainerCode = request.PalletNo;
// 更新库位状态为有货
location.Status = LocationStatusEnum.Some;
location.ContainerCode = task.TaskType == TaskTypeEnum.入库 ? request.PalletNo : "";
location.Status = LocationStatusEnum.未锁;
location.ContainerStatus = LocationStatus.空仓位;
location.UpdateTime = DateTime.Now;
}
_unitWork.Update(location);
// 4. 更新任务状态为完成
// 更新任务状态为完成
task.Status = TaskStatusEnum.完成;
// 5. 保存所有更改
_unitWork.Save();
// 6. 将任务复制到历史任务表
// 将任务复制到历史任务表
var taskHistory = _mapper.Map<TaskHeaderHistory>(task);
_unitWork.Add(taskHistory);
// 7. 删除原任务
// 删除原任务
_unitWork.Delete(task);
// 8. 提交事务
// 提交事务
await transaction.CommitAsync();
}
catch (System.Exception ex)
@@ -281,7 +303,7 @@ namespace HHWMS.Web
return Task.FromResult<IActionResult>(ApiResultError("巷道不能为空"));
}
return WithDebounce($"RequestLocation_{request.PalletNo}", () =>
return WithDebounce($"RequestLocation_{request.TaskNo}", () =>
{
var vm = Wtm.CreateVM<LocationVM>();
var code = vm.GetLocation(request);
@@ -321,11 +343,11 @@ namespace HHWMS.Web
var container = _unitWork.Find<Container>(x => x.Code == palletNo).FirstOrDefault();
if (container != null)
{
container.LocationCode = location.Code;
container.LocationCode = location?.Code;
_unitWork.Update(container);
}
return ApiResult(new { LocationCode = location.Code });
return ApiResult(new { LocationCode = location?.Code });
}
}
}