容器出库

库位禁用
演示逻辑修改 task station=1的出库任务需要自动下发入库任务和AGv任务
This commit is contained in:
zhougf committed 2024-05-29 17:09:03 +08:00
1 parent a6168a75bf
commit a3e91357ee
10 files changed
+166 -33

No files matched your search

@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using HHWMS.Web.Models;
@@ -290,5 +291,89 @@ namespace HHWMS.Web.Controllers
return FFResult().CloseDialog().RefreshGrid();
}
}
[ActionDescription("Inventory.Out")]
public IActionResult Out(int id)
{
var container = _unitwork.FindById<Container>(id);
if (container == null)
{
return FFResult().RefreshGrid().Alert("选定容器不存在!请检查后再执行出库任务!");
}
if (string.IsNullOrEmpty(container.LocationCode))
{
return FFResult().RefreshGrid().Alert("选定容器不在库位!请检查后再执行出库任务!");
}
if (_unitwork.IsExit<TaskHeader>(x => x.ContainerCode.Equals(container.Code)))
{
return FFResult().RefreshGrid().Alert("选定容器已存在任务!请检查后再执行出库任务!");
}
var location = _unitwork.FindSingle<Location>(x => x.Code == container.LocationCode);
if (location != null)
{
location.Status = LocationStatus.任务锁;
location.UpdateTime = DateTime.Now;
location.UpdateBy = Wtm.LoginUserInfo?.ITCode ?? "WMS";
_unitwork.Update(location);
// 查找container,并更新状态
// var container = _unitwork.FindSingle<Container>(x => x.Code == location.ContainerCode);
container.IsLock = ContainerLockEnum.任务锁;
container.UpdateTime = DateTime.Now;
container.UpdateBy = Wtm.LoginUserInfo?.ITCode ?? "WMS";
_unitwork.Update(container);
//创建出库任务
var task = new TaskHeader
{
ZoneCode = ZoneCodeEnum.立库,
TaskNo = _unitwork.GetSerialNumber("Out"),
TaskType = TaskTypeEnum.立库出库,
ContainerCode = location.ContainerCode,
FromLocation = location.Code,
ToLocation = "",
Status = TaskStatusEnum.待下发,
CreateBy = Wtm.LoginUserInfo?.ITCode ?? "WMS",
CreateTime = DateTime.Now
};
_unitwork.Add(task);
// 下发任务到wcs
var postData = new
{
TaskNo = task.TaskNo,
PalletNo = task.ContainerCode,
FromLocation = task.FromLocation,
ToLocation = task.ToLocation
};
try
{
var res = Wtm.CallAPI<ApiJsonResult<dynamic>>("WCS", "TaskAssign", HttpMethodEnum.POST, postData)
.Result.Data;
if (res.Success)
{
task.Status = TaskStatusEnum.已下发;
}
else
{
task.ErrorMsg = res.Msg;
}
}
catch (Exception ex)
{
task.ErrorMsg = ex.Message;
}
task.UpdateTime = DateTime.Now;
task.UpdateBy = "WMS";
_unitwork.Update(task);
}
return FFResult().RefreshGrid().Message("任务创建成功!");
}
}
}
@@ -6,6 +6,7 @@ using WalkingTec.Mvvm.Mvc;
using WalkingTec.Mvvm.Core.Extensions;
using HHWMS.Web;
using System.Collections.Generic;
using System.Linq;
using HHWMS.Web.Models;
namespace HHWMS.Web.Controllers
@@ -287,5 +288,30 @@ namespace HHWMS.Web.Controllers
return Ok();
}
[ActionDescription("Location.StopLocation")]
public ActionResult StopLocation(string[] ids)
{
_unitwork.BatchUpdate<Location>(x => ids.Contains(x.ID.ToString()),
x => new Location
{
IsStop = true,
UpdateBy = Wtm.LoginUserInfo.ITCode,
UpdateTime = DateTime.Now
});
return FFResult().RefreshGrid().Message("库位禁用成功!");
}
[ActionDescription("Location.LiftLocation")]
public ActionResult LiftLocation(string[] ids)
{
_unitwork.BatchUpdate<Location>(x => ids.Contains(x.ID.ToString()),
x => new Location
{
IsStop = false,
UpdateBy = Wtm.LoginUserInfo.ITCode,
UpdateTime = DateTime.Now
});
return FFResult().RefreshGrid().Message("库位解禁成功!");
}
}
}