diff --git a/HHWMS.Web/Areas/Api/IWCSController.cs b/HHWMS.Web/Areas/Api/IWCSController.cs
index e9b30f5..568517f 100644
--- a/HHWMS.Web/Areas/Api/IWCSController.cs
+++ b/HHWMS.Web/Areas/Api/IWCSController.cs
@@ -57,7 +57,8 @@ namespace HHWMS.Web
var timeSinceLastRequest = DateTime.Now - lastRequestTime;
if (timeSinceLastRequest.TotalMilliseconds < DEBOUNCE_INTERVAL_MS)
{
- var remainingSeconds = Math.Ceiling((DEBOUNCE_INTERVAL_MS - timeSinceLastRequest.TotalMilliseconds) / 1000);
+ var remainingSeconds =
+ Math.Ceiling((DEBOUNCE_INTERVAL_MS - timeSinceLastRequest.TotalMilliseconds) / 1000);
return ApiResultError($"请求过于频繁,请等待{remainingSeconds}秒后重试");
}
}
@@ -115,18 +116,17 @@ namespace HHWMS.Web
///
/// 状态返回(带防抖)
///
+ [Public]
[HttpPost]
public Task TaskStatusResult(WcsRequest request)
{
- if (request == null || string.IsNullOrEmpty(request.PalletNo))
+ if (request == null || string.IsNullOrEmpty(request.TaskNo))
{
return Task.FromResult(ApiResultError("请求参数无效"));
}
- return WithDebounce($"TaskStatus_{request.PalletNo}", async () =>
- {
- return await ProcessTaskStatusResult(request);
- });
+ return WithDebounce($"TaskStatus_{request.PalletNo}",
+ async () => { return await ProcessTaskStatusResult(request); });
}
///
@@ -135,14 +135,14 @@ namespace HHWMS.Web
private async Task ProcessTaskStatusResult(WcsRequest request)
{
// 1. 根据托盘号查找对应的任务
- var task = _unitWork.FindSingle(x => x.TaskNo == request.TaskNo
+ var task = _unitWork.FindSingle(x => x.TaskNo == request.TaskNo
&& x.Status != TaskStatusEnum.完成);
if (task == null)
{
return ApiResultError("未找到对应的任务");
}
-
+
/* 根据任务的巷道号来判断
* 1.线边库1号巷道只有任务完成,任务下发的时候已经分配仓位
* 2.成品库2号巷道有任务请求(10)和任务完成(100)
@@ -151,7 +151,7 @@ namespace HHWMS.Web
* 任务完成(100):完成任务,更新库存,更新容器状态,更新库位状态,更新任务状态(线边库需要根据重量计算库存的数量),更新对应的工单
* 任务完成后,删除任务并放到历史任务中
*/
-
+
// 根据任务的巷道号和状态来执行不同的逻辑
if (task.RoadWay == 1) // 线边库1号巷道
{
@@ -165,9 +165,24 @@ namespace HHWMS.Web
{
if (request.State == 10) // 任务请求,需要分配仓位
{
+ if (!string.IsNullOrWhiteSpace(task.ToLocation))
+ {
+ return ApiResult(new { LocationCode = task.ToLocation });
+ }
+
// 根据请求的高度,分配仓位
var locationVm = Wtm.CreateVM();
+
request.RoadWay = 2;
+
+ // 默认1 模具2 低仓位3 高仓位4 成品大于4 超限 模具大于2 超限
+ if(request.Height == 2)
+ request.Height = 999;
+ else if (request.Height == 3)
+ request.Height = 1100;
+ else
+ request.Height = 0;
+
var container = _unitWork.FindSingle(x => x.Code == task.ContainerCode);
if (container != null)
{
@@ -179,16 +194,29 @@ namespace HHWMS.Web
_ => request.LocationType
};
}
- var location = await locationVm.GetLocation(request).Data;
+
+ // 模具库 高度超限直接返回失败
+ if (request.LocationType == LocationTypeEnum.M && request.Height >= 2)
+ {
+ return ApiResultError(msg: "模具超高,未找到合适的仓位");
+ }
+ var location = locationVm.GetLocation(request).Data;
if (location != null)
{
// 更新任务的目标仓位
task.ToLocation = location.LocationCode;
_unitWork.Update(task);
+
+ var loc = _unitWork.FindSingle(x => x.Code == task.ToLocation);
+ loc.Status = LocationStatusEnum.锁定;
+ loc.Version = Guid.NewGuid();
+ loc.UpdateTime = DateTime.Now;
+ _unitWork.Update(loc);
+ return ApiResult(new { LocationCode = location.LocationCode });
}
else
{
- return ApiResultError("未找到合适的仓位");
+ return ApiResultError(msg: "未找到合适的仓位");
}
}
else if (request.State == 100) // 任务完成
@@ -215,30 +243,76 @@ namespace HHWMS.Web
var invTrans = new List();
foreach (var inventory in inventories)
{
- var material = _unitWork.FindSingle(x => x.MaterialCode == inventory.MaterialCode);
-
inventory.LocationCode = task.ToLocation;
- if(task.TaskType == TaskTypeEnum.入库)
- inventory.Qty = (request.Weight - ContainerWeight) / material.Qty;
- inventory.TaskStatus = InventoryTaskStatusEnum.Idle;
-
-
- // 创建库存交易记录 放到任务完成,计算数量信息
- var invTransaction = new InventoryTransaction
+ // 线边库
+ if (inventory.ZoneId == 1027)
{
- 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);
+ if (task.TaskType == TaskTypeEnum.入库)
+ {
+ var material =
+ _unitWork.FindSingle(x => x.MaterialCode == inventory.MaterialCode);
+ inventory.Qty = (request.Weight - ContainerWeight) / material.Qty;
+ }
+
+ if (task.TaskType != TaskTypeEnum.移库)
+ {
+ // 创建库存交易记录 放到任务完成,计算数量信息
+ 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);
+ }
+ else
+ {
+ // 创建库存交易记录 放到任务完成,计算数量信息
+ var invTransaction = new InventoryTransaction
+ {
+ Type = 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);
+
+ var invTransaction2 = new InventoryTransaction
+ {
+ Type = 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(invTransaction2);
+ }
+ }
+
+ inventory.TaskStatus = InventoryTaskStatusEnum.Idle;
+ }
+
+ if (invTrans.Any())
+ {
+ _unitWork.BatchAdd(invTrans);
}
- _unitWork.BatchAdd(invTrans);
_unitWork.BatchUpdate(inventories);
@@ -246,24 +320,73 @@ namespace HHWMS.Web
var container = _unitWork.FindSingle(x => x.Code == task.ContainerCode);
if (container != null)
{
- container.LocationCode = task.ToLocation;
+ container.LocationCode = task.TaskType == TaskTypeEnum.出库 ? "" : task.ToLocation;
container.IsLock = ContainerLockEnum.未锁;
container.UpdateTime = DateTime.Now;
}
+
_unitWork.Update(container);
- // 更新库位状态
- var location = task.TaskType == TaskTypeEnum.入库
- ? _unitWork.FindSingle(x => x.Code == task.ToLocation)
- : _unitWork.FindSingle(x => x.Code == task.FromLocation);
- if (location != null)
+ // 更新库位状态(区分入库、出库、移库)
+ switch (task.TaskType)
{
- location.ContainerCode = task.TaskType == TaskTypeEnum.入库 ? request.PalletNo : "";
- location.Status = LocationStatusEnum.未锁;
- location.ContainerStatus = LocationStatus.空仓位;
- location.UpdateTime = DateTime.Now;
+ case TaskTypeEnum.入库:
+ // 处理入库:更新目标库位
+ var inLocation = _unitWork.FindSingle(x => x.Code == task.ToLocation);
+ if (inLocation != null)
+ {
+ inLocation.ContainerCode = task.ContainerCode; // 绑定容器编码
+ inLocation.Status = LocationStatusEnum.未锁; // 标记为未锁状态
+ inLocation.ContainerStatus = inventories.Any() ? LocationStatus.有货 : LocationStatus.空容器;
+ inLocation.UpdateTime = DateTime.Now;
+ _unitWork.Update(inLocation);
+ }
+
+ break;
+
+ case TaskTypeEnum.出库:
+ // 处理出库:更新源库位
+ var outLocation = _unitWork.FindSingle(x => x.Code == task.FromLocation);
+ if (outLocation != null)
+ {
+ outLocation.ContainerCode = ""; // 清空容器编码
+ outLocation.Status = LocationStatusEnum.未锁; // 标记为未锁状态
+ outLocation.ContainerStatus = LocationStatus.空仓位; // 标记为空仓位
+ outLocation.UpdateTime = DateTime.Now;
+ _unitWork.Update(outLocation);
+ }
+
+ break;
+
+ case TaskTypeEnum.移库:
+ // 处理移库:同时更新源库位和目标库位
+ // 1. 更新源库位(移出后变为空)
+ var sourceLocation = _unitWork.FindSingle(x => x.Code == task.FromLocation);
+ if (sourceLocation != null)
+ {
+ sourceLocation.ContainerCode = "";
+ sourceLocation.Status = LocationStatusEnum.未锁;
+ sourceLocation.ContainerStatus = LocationStatus.空仓位;
+ sourceLocation.UpdateTime = DateTime.Now;
+ _unitWork.Update(sourceLocation);
+ }
+
+ // 2. 更新目标库位(移入后有容器)
+ var targetLocation = _unitWork.FindSingle(x => x.Code == task.ToLocation);
+ if (targetLocation != null)
+ {
+ targetLocation.ContainerCode = task.ContainerCode;
+ targetLocation.Status = LocationStatusEnum.未锁;
+ targetLocation.UpdateTime = DateTime.Now;
+ _unitWork.Update(targetLocation);
+ }
+
+ break;
+
+ default:
+ // 处理未定义的任务类型(可选)
+ throw new ArgumentOutOfRangeException($"未处理的任务类型:{task.TaskType}");
}
- _unitWork.Update(location);
// 更新任务状态为完成
task.Status = TaskStatusEnum.完成;
@@ -285,7 +408,7 @@ namespace HHWMS.Web
}
}
}
-
+
///
/// 请求空闲库位(带防抖)
@@ -297,7 +420,7 @@ namespace HHWMS.Web
{
return Task.FromResult(ApiResultError("容器编码不能为空"));
}
-
+
if (!request.RoadWay.HasValue)
{
return Task.FromResult(ApiResultError("巷道不能为空"));
@@ -312,10 +435,11 @@ namespace HHWMS.Web
var updateResult = UpdateLocationAndContainer(code.Data.LocationCode, request.PalletNo);
return Task.FromResult(updateResult);
}
+
return Task.FromResult(ApiResultError("没有符合条件的可用库位"));
});
}
-
+
///
/// 更新库位和容器
///
@@ -325,15 +449,16 @@ namespace HHWMS.Web
private IActionResult UpdateLocationAndContainer(string locationCode, string palletNo)
{
var location = _unitWork.Find(x => x.Code == locationCode).FirstOrDefault();
- var resultNum = _unitWork.BatchUpdate(x => x.Code == locationCode && x.Version == location.Version,
+ var resultNum = _unitWork.BatchUpdate(
+ x => x.Code == locationCode && x.Version == location.Version,
x => new Location()
- {
- ContainerCode = palletNo,
- // Status = LocationStatus.任务锁,
- UpdateTime = DateTime.Now,
- UpdateBy = "WMS",
- Version = Guid.NewGuid()
- });
+ {
+ ContainerCode = palletNo,
+ // Status = LocationStatus.任务锁,
+ UpdateTime = DateTime.Now,
+ UpdateBy = "WMS",
+ Version = Guid.NewGuid()
+ });
if (resultNum == 0)
{
//失败
@@ -350,4 +475,4 @@ namespace HHWMS.Web
return ApiResult(new { LocationCode = location?.Code });
}
}
-}
+}
\ No newline at end of file
diff --git a/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationVM.cs b/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationVM.cs
index db81d36..7e9470d 100644
--- a/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationVM.cs
+++ b/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationVM.cs
@@ -87,62 +87,90 @@ namespace HHWMS.Web
///
/// 查找双伸位巷道的空仓位
///
- private string GetEmptyLocationByDouble(int roadway, LocationTypeEnum locationType, decimal? height = 0)
+ private string GetEmptyLocationByDouble(int roadway, LocationTypeEnum locationType, string inPort,
+ decimal? height = 0)
{
// 一次性获取所需的所有数据,避免多次查询数据库
var locationPairs = DC.Set()
- .Where(l => l.RoadWay == roadway
- && l.Type == locationType
+ .Where(l => l.Type == locationType
+ && l.Status == LocationStatusEnum.未锁
&& !l.IsStop
&& l.Height >= height)
- .Select(l => new
- {
- l.Code,
- l.ContiguousCode,
- l.Status,
- l.ContainerStatus,
- l.RowFlag,
- l.Height,
- l.Layer,
- l.Line
- })
.AsNoTracking()
.ToDictionary(l => l.Code);
+ if (locationPairs.Count <= 20)
+ {
+ return "";
+ }
// 1. 优先查找里外仓位都为空的里仓位
- var emptyInnerLocation = locationPairs.Values
+ /// 1 7 8 优先1巷道
+ /// 4 9 10 优先2 巷道
+ var availableLocation = locationPairs.Values
.Where(l => l.RowFlag == RowFlagEnum.Inner
- && l.Status == LocationStatusEnum.未锁
&& l.ContainerStatus == LocationStatus.空仓位
&& locationPairs.TryGetValue(l.ContiguousCode, out var outer)
- && outer.Status == LocationStatusEnum.未锁
&& outer.ContainerStatus == LocationStatus.空仓位)
.OrderBy(l => l.Height)
- .ThenBy(l => l.Layer)
- .ThenBy(l => l.Line)
- .FirstOrDefault();
+ .ToList();
- if (emptyInnerLocation != null)
+ if (availableLocation.Any())
{
- return emptyInnerLocation.Code;
+ return GetSortedLocationCode(availableLocation, inPort) ?? availableLocation.First().Code;
}
// 2. 查找里仓位有货,外仓位为空的外仓位
- var availableOuterLocation = locationPairs.Values
- .Where(l => l.RowFlag == 0
+ availableLocation = locationPairs.Values
+ .Where(l => l.RowFlag == RowFlagEnum.Outer
&& l.Status == LocationStatusEnum.未锁
&& l.ContainerStatus == LocationStatus.空仓位
&& locationPairs.TryGetValue(l.ContiguousCode, out var inner)
&& inner.Status == LocationStatusEnum.未锁
&& inner.ContainerStatus == LocationStatus.有货)
.OrderBy(l => l.Height)
- .ThenBy(l => l.Layer)
- .ThenBy(l => l.Line)
- .FirstOrDefault();
-
- return availableOuterLocation?.Code;
+ .ToList();
+
+ return GetSortedLocationCode(availableLocation, inPort) ?? availableLocation.First().Code;
}
+ private string GetSortedLocationCode(List locations, string inPort)
+ {
+ if (locations == null || !locations.Any())
+ return null;
+
+ // 定义端口组与排序规则的映射(键:端口数组,值:排序函数)
+ var portSortMappings = new Dictionary, IOrderedEnumerable>>
+ {
+ {
+ new[] { "EnterExit_P1001" },
+ locs => locs.OrderBy(x => x.Height).ThenBy(x => x.RoadWay).ThenBy(l => l.Layer).ThenByDescending(x => x.Line)
+ },
+ {
+ new[] { "EnterExit_P1007", "EnterExit_P1008" },
+ locs => locs.OrderBy(x => x.Height).ThenBy(x => x.RoadWay).ThenBy(l => l.Layer).ThenBy(x => x.Line)
+ },
+ {
+ new[] { "EnterExit_P1004" },
+ locs => locs.OrderBy(x => x.Height).ThenByDescending(x => x.RoadWay).ThenBy(l => l.Layer).ThenByDescending(x => x.Line)
+ },
+ {
+ new[] { "EnterExit_P1009", "EnterExit_P1010" },
+ locs => locs.OrderBy(x => x.Height).ThenByDescending(x => x.RoadWay).ThenBy(l => l.Layer).ThenBy(x => x.Line)
+ }
+ };
+
+ // 查找匹配的端口组,应用排序规则
+ foreach (var (ports, sortFunc) in portSortMappings)
+ {
+ if (ports.Contains(inPort))
+ {
+ return sortFunc(locations).FirstOrDefault()?.Code;
+ }
+ }
+
+ // 无匹配端口时,返回默认排序的第一个
+ return locations.FirstOrDefault()?.Code;
+ }
///
/// 根据巷道类型查找可用仓位
///
@@ -169,7 +197,8 @@ namespace HHWMS.Web
break;
case 4: // 双伸位
locationCode =
- GetEmptyLocationByDouble(request.RoadWay.Value, request.LocationType, request.Height);
+ GetEmptyLocationByDouble(request.RoadWay.Value, request.LocationType, request.InPort,
+ request.Height);
break;
default:
return ResponseResult.Error("未知的巷道类型");
@@ -364,5 +393,181 @@ namespace HHWMS.Web
Total = availableLocations.Count
});
}
+
+ ///
+ /// 下发任务到wcs
+ ///
+ ///
+ ///
+ public ResponseResult SendWcsTask(TaskHeader task)
+ {
+ // 下发任务到wcs
+ // 1.入库任务直接下发
+ // 2.出库任务 判断是否为双伸位库位
+ // 2.1 单伸位:直接下发
+ // 2.2 双伸位:判断出库库位是否为里仓位
+ // 2.2.1 里仓位,判断是否需要移库,先生成移库任务,再下发出库任务
+ // 2.2.2 外仓位,直接下发
+
+ var _unitWork = new UnitWork(Wtm);
+ if (task.TaskType != TaskTypeEnum.入库)
+ {
+ var loc = DC.Set().Where(x => x.Code == task.FromLocation)
+ .AsNoTracking()
+ .FirstOrDefault();
+ // 双伸位 并且里仓位
+ if (loc != null && loc.RowFlag == RowFlagEnum.Inner && !string.IsNullOrWhiteSpace(loc.ContiguousCode))
+ {
+ var outter = DC.Set().FirstOrDefault(x => x.Code == loc.ContiguousCode);
+ if (outter != null && outter.Status == LocationStatusEnum.未锁 &&
+ outter.ContainerStatus != LocationStatus.空仓位)
+ {
+ // 查找移库仓位
+ var moveloc = GetMoveLocation(outter);
+ if (moveloc.Status)
+ {
+ string code = moveloc.Data.Code;
+ var movelocation = _unitWork.FindSingle(x => x.Code == code);
+
+
+ // 生成outter移库任务
+ var outterTask = new TaskHeader()
+ {
+ ZoneId = outter.ZoneId,
+ TaskNo = _unitWork.GetSerialNumber("Move"),
+ TaskType = TaskTypeEnum.移库,
+ ContainerCode = outter.ContainerCode,
+ FromLocation = outter.Code,
+ ToLocation = movelocation.Code,
+ Status = TaskStatusEnum.待下发,
+ CreateTime = DateTime.Now,
+ CreateBy = Wtm?.LoginUserInfo?.ITCode ?? "WMS",
+ };
+ var result = SendWcsTask(outterTask);
+ if (result.Status)
+ {
+ movelocation.Status = LocationStatusEnum.锁定;
+ _unitWork.Update(movelocation);
+
+ outter.Status = LocationStatusEnum.锁定;
+ _unitWork.Update(outter);
+ }
+ else
+ {
+ return result;
+ }
+ }
+ else
+ {
+ return moveloc;
+ }
+ }
+ }
+ }
+
+ // 下发任务到wcs
+ var postData = new
+ {
+ TaskNo = task.TaskNo,
+ PalletNo = task.ContainerCode,
+ FromLocation = task.FromLocation,
+ ToLocation = task.ToLocation
+ };
+ task.Status = TaskStatusEnum.已下发;
+ task.UpdateTime = DateTime.Now;
+ task.UpdateBy = "WMS";
+ _unitWork.Add(task);
+ /*try
+ {
+ var domain = task.ZoneId == 1027 ? "WCSXB" : "WCSCP";
+ var res = Wtm.CallAPI>(domain, "TaskAssign", HttpMethodEnum.POST, postData)
+ .Result?.Data;
+
+ if (res != null && res.Success)
+ {
+ task.Status = TaskStatusEnum.已下发;
+ task.UpdateTime = DateTime.Now;
+ task.UpdateBy = "WMS";
+ _unitWork.Add(task);
+ }
+ else
+ {
+ task.ErrorMsg = res?.Msg;
+ return ResponseResult.Error(res?.Msg);
+ }
+ }
+ catch (Exception ex)
+ {
+ task.ErrorMsg = ex.Message;
+ return ResponseResult.Error("任务下发失败!");
+ }*/
+
+ return ResponseResult.Success();
+ }
+
+ public ResponseResult GetMoveLocation(Location outter)
+ {
+ // 查找移库仓位
+ // 一次性获取所需的所有数据,避免多次查询数据库
+ var locationPairs = DC.Set()
+ .Where(l => l.Type == outter.Type
+ && !l.IsStop
+ && l.Status == LocationStatusEnum.未锁
+ && l.Height >= outter.Height)
+ .Select(l => new
+ {
+ l.RoadWay,
+ l.Code,
+ l.ContiguousCode,
+ l.Status,
+ l.ContainerStatus,
+ l.RowFlag,
+ l.Height,
+ l.Layer,
+ l.Line
+ })
+ .AsNoTracking()
+ .ToDictionary(l => l.Code);
+
+ // 1. 优先查找里外仓位都为空的里仓位
+ var moveloc = locationPairs.Values
+ .Where(l => l.RowFlag == RowFlagEnum.Inner
+ && l.ContainerStatus == LocationStatus.空仓位
+ && locationPairs.TryGetValue(l.ContiguousCode, out var outer)
+ && outer.ContainerStatus == LocationStatus.空仓位)
+ .OrderBy(l => l.Height)
+ .ThenBy(l => Math.Abs(outter.RoadWay - l.RoadWay))
+ .ThenBy(l => Math.Abs(outter.Line - l.Line))
+ .ThenBy(l => l.Layer)
+ .FirstOrDefault();
+
+ if (moveloc == null)
+ {
+ // 2. 查找里仓位有货,外仓位为空的外仓位
+ moveloc = locationPairs.Values
+ .Where(l => l.RowFlag == RowFlagEnum.Outer
+ && l.ContainerStatus == LocationStatus.空仓位
+ && locationPairs.TryGetValue(l.ContiguousCode, out var inner)
+ && inner.Status == LocationStatusEnum.未锁
+ && inner.ContainerStatus == LocationStatus.有货)
+ .OrderBy(l => Math.Abs((decimal)outter.Height - (decimal)l.Height))
+ .ThenBy(l => Math.Abs(outter.RoadWay - l.RoadWay))
+ .ThenBy(l => Math.Abs(outter.Line - l.Line))
+ .ThenBy(l => l.Layer)
+ .FirstOrDefault();
+ if (moveloc == null)
+ {
+ return ResponseResult.Error("找不到可用的移库仓位!");
+ }
+ else
+ {
+ return ResponseResult.Success(new { LocationCode = moveloc.Code });
+ }
+ }
+ else
+ {
+ return ResponseResult.Success(new { LocationCode = moveloc.Code });
+ }
+ }
}
}
\ No newline at end of file
diff --git a/HHWMS.Web/Areas/Inventory/Controllers/InventoryController.cs b/HHWMS.Web/Areas/Inventory/Controllers/InventoryController.cs
index a5edf52..c57dc46 100644
--- a/HHWMS.Web/Areas/Inventory/Controllers/InventoryController.cs
+++ b/HHWMS.Web/Areas/Inventory/Controllers/InventoryController.cs
@@ -345,5 +345,150 @@ namespace HHWMS.Web.Controllers
}
#endregion
+
+ #region InvOut 成品出库
+ [ActionDescription("TaskType.Out")]
+ public ActionResult InvOut2(string id)
+ {
+ var vm = Wtm.CreateVM(id);
+ if (vm.Entity.TaskStatus == InventoryTaskStatusEnum.Locked)
+ {
+ return FFResult().Alert("所选库存已被锁定!,请检查后重试!").RefreshGrid();
+ }
+ return PartialView(vm);
+ }
+
+ [HttpPost]
+ [ActionDescription("TaskType.Out")]
+ public ActionResult InvOut2(InventoryVM vm)
+ {
+ var id = vm.Entity.ID;
+ // 校验参数
+ if (string.IsNullOrWhiteSpace(vm.OutPort))
+ {
+ return FFResult().Alert("出口必选,请选择后重试!");
+ }
+ // 校验库存
+ var inv = _unitWork.FindSingle(x => x.ID == id);
+ if (inv == null)
+ {
+ return FFResult().CloseDialog().Alert("所选库存不存在,请检查后重试!").RefreshGrid();
+ }
+ if (inv.TaskStatus == InventoryTaskStatusEnum.Locked)
+ {
+ return FFResult().CloseDialog().Alert("所选库存已被锁定!,请检查后重试!").RefreshGrid();
+ }
+
+ // 校验容器
+ var container = _unitWork.FindSingle(x => x.Code == inv.ContainerCode);
+ if (container == null)
+ {
+ return FFResult().CloseDialog().Alert("所选库存的容器不存在,请检查后重试!").RefreshGrid();
+ }
+
+ if (container.IsLock == ContainerLockEnum.任务锁)
+ {
+ return FFResult().CloseDialog().Alert("库存所在容器已被锁定!,请检查后重试!").RefreshGrid();
+ }
+
+ // 校验库位
+ var location = _unitWork.FindSingle(x => x.Code == inv.LocationCode);
+ if (location == null)
+ {
+ return FFResult().CloseDialog().Alert("所选库存不在库内,请检查后重试!").RefreshGrid();
+ }
+
+ if (location.Status == LocationStatusEnum.锁定)
+ {
+ return FFResult().CloseDialog().Alert("库存所在仓位已被锁定!,请检查后重试!").RefreshGrid();
+ }
+
+ // 创建任务
+ var task = new TaskHeader()
+ {
+ TaskNo = _unitWork.GetSerialNumber("Out", 6),
+ ZoneId = inv.ZoneId,
+ TaskType = TaskTypeEnum.出库,
+ FromLocation = inv.LocationCode,
+ ToLocation = vm.OutPort,
+ ContainerCode = inv.ContainerCode,
+ RoadWay = 2,
+ Status = TaskStatusEnum.新建,
+ CreateBy = Wtm.LoginUserInfo.ITCode,
+ CreateTime = DateTime.Now
+ };
+
+ var locationVm = Wtm.CreateVM();
+ var result = locationVm.SendWcsTask(task);
+ if (result.Status)
+ {
+ // 更新库存
+ inv.TaskStatus = InventoryTaskStatusEnum.Locked;
+ inv.UpdateTime = DateTime.Now;
+ _unitWork.Update(inv);
+
+ // 更新容器
+ container.IsLock = ContainerLockEnum.任务锁;
+ container.UpdateTime = DateTime.Now;
+ _unitWork.Update(container);
+
+ // 更新库位
+ location.Status = LocationStatusEnum.锁定;
+ location.UpdateTime = DateTime.Now;
+ _unitWork.Update(location);
+ return FFResult().CloseDialog().Message("出库任务创建成功").RefreshGrid();
+ }
+ else
+ {
+ return FFResult().CloseDialog().Message(result.Message?? "WCS任务下发失败").RefreshGrid();
+ }
+ /*// 6. 调用WCS接口下发任务
+ var wcsTaskModel = new WCSTaskModel
+ {
+ TaskNo = task.TaskNo,
+ PalletNo = task.ContainerCode,
+ FromLocation = task.FromLocation, // 入库任务起始位置为空
+ ToLocation = task.ToLocation,
+ };
+
+ //调用WCS任务下发接口
+ var wcsResult = Wtm.CallAPI("WCSCP", "TaskAssign", HttpMethodEnum.POST, wcsTaskModel).Result.Data;
+
+ if (wcsResult != null && wcsResult.Success)
+ {
+ // WCS任务下发成功
+ task.Status = TaskStatusEnum.已下发;
+ _unitWork.Add(task);
+
+ // 更新库存
+ inv.TaskStatus = InventoryTaskStatusEnum.Locked;
+ inv.UpdateTime = DateTime.Now;
+ _unitWork.Update(inv);
+
+ // 更新容器
+ // _unitWork.BatchUpdate(x => x.Code == task.ContainerCode, x => new Container()
+ // {
+ // IsLock = ContainerLockEnum.任务锁,
+ // UpdateTime = DateTime.Now
+ // });
+ container.IsLock = ContainerLockEnum.任务锁;
+ container.UpdateTime = DateTime.Now;
+ _unitWork.Update(container);
+
+ // 更新库位
+ location.Status = LocationStatusEnum.锁定;
+ location.UpdateTime = DateTime.Now;
+ _unitWork.Update(location);
+
+ return FFResult().CloseDialog().Message("出库任务创建成功").RefreshGrid();
+ }
+ else
+ {
+ // WCS任务下发失败
+ return FFResult().CloseDialog().Message(wcsResult?.Msg ?? "WCS任务下发失败").RefreshGrid();
+ }*/
+
+ }
+ #endregion
}
}
diff --git a/HHWMS.Web/Areas/Inventory/ViewModels/InventoryVMs/InventoryListVM.cs b/HHWMS.Web/Areas/Inventory/ViewModels/InventoryVMs/InventoryListVM.cs
index 6661b95..499af6a 100644
--- a/HHWMS.Web/Areas/Inventory/ViewModels/InventoryVMs/InventoryListVM.cs
+++ b/HHWMS.Web/Areas/Inventory/ViewModels/InventoryVMs/InventoryListVM.cs
@@ -27,6 +27,8 @@ namespace HHWMS.Web
this.MakeStandardAction("Inventory", GridActionStandardTypesEnum.ExportExcel, Localizer["Sys.Export"], "inventory"),
this.MakeAction("Inventory","InvOut",Localizer["TaskType.Out"],"",GridActionParameterTypesEnum.SingleId,"inventory")
.SetSize(500,400),
+ this.MakeAction("Inventory","InvOut2",Localizer["TaskType.Out1"],"",GridActionParameterTypesEnum.SingleId,"inventory")
+ .SetSize(500,400),
};
}
diff --git a/HHWMS.Web/Areas/Inventory/ViewModels/InventoryVMs/InventoryVM.cs b/HHWMS.Web/Areas/Inventory/ViewModels/InventoryVMs/InventoryVM.cs
index 04ab70a..4dbfc66 100644
--- a/HHWMS.Web/Areas/Inventory/ViewModels/InventoryVMs/InventoryVM.cs
+++ b/HHWMS.Web/Areas/Inventory/ViewModels/InventoryVMs/InventoryVM.cs
@@ -14,6 +14,7 @@ namespace HHWMS.Web
{
public List AllZones { get; set; }
public List AllOutPorts { get; set; }
+ public List AllOutPorts2 { get; set; }
[Display(Name = "Location.OutPort", Description = "拣货口")]
public string OutPort { get; set; }
@@ -26,16 +27,26 @@ namespace HHWMS.Web
protected override void InitVM()
{
AllZones = DC.Set().GetSelectListItems(Wtm, y => y.Name);
- AllOutPorts = new List
- {
- new ComboSelectListItem { Text = "拣货口1", Value = "EnterExit_P2001" },
- new ComboSelectListItem { Text = "拣货口2", Value = "EnterExit_P2003" },
- new ComboSelectListItem { Text = "拣货口3", Value = "EnterExit_P2005" },
- new ComboSelectListItem { Text = "拣货口4", Value = "EnterExit_P2007" },
- new ComboSelectListItem { Text = "拣货口5", Value = "EnterExit_P2009" },
- new ComboSelectListItem { Text = "拣货口6", Value = "EnterExit_P2011" },
- new ComboSelectListItem { Text = "拣货口7", Value = "EnterExit_P2013" }
- };
+
+ AllOutPorts = new List
+ {
+ new ComboSelectListItem { Text = "拣货口1", Value = "EnterExit_P2001" },
+ new ComboSelectListItem { Text = "拣货口2", Value = "EnterExit_P2003" },
+ new ComboSelectListItem { Text = "拣货口3", Value = "EnterExit_P2005" },
+ new ComboSelectListItem { Text = "拣货口4", Value = "EnterExit_P2007" },
+ new ComboSelectListItem { Text = "拣货口5", Value = "EnterExit_P2009" },
+ new ComboSelectListItem { Text = "拣货口6", Value = "EnterExit_P2011" },
+ new ComboSelectListItem { Text = "拣货口7", Value = "EnterExit_P2013" }
+ };
+ AllOutPorts2 = new List
+ {
+ new ComboSelectListItem { Text = "拣货口1", Value = "EnterExit_P1001" },
+ new ComboSelectListItem { Text = "拣货口2", Value = "EnterExit_P1004" },
+ new ComboSelectListItem { Text = "拣货口3", Value = "EnterExit_P1007" },
+ new ComboSelectListItem { Text = "拣货口4", Value = "EnterExit_P1008" },
+ new ComboSelectListItem { Text = "拣货口5", Value = "EnterExit_P1009" },
+ new ComboSelectListItem { Text = "拣货口6", Value = "EnterExit_P1010" }
+ };
}
public override void DoAdd()
diff --git a/HHWMS.Web/Areas/Inventory/Views/Inventory/InvOut.cshtml b/HHWMS.Web/Areas/Inventory/Views/Inventory/InvOut.cshtml
index d826d7c..9653b1f 100644
--- a/HHWMS.Web/Areas/Inventory/Views/Inventory/InvOut.cshtml
+++ b/HHWMS.Web/Areas/Inventory/Views/Inventory/InvOut.cshtml
@@ -3,6 +3,7 @@
+
@@ -11,3 +12,4 @@
+
diff --git a/HHWMS.Web/Areas/Inventory/Views/Inventory/InvOut2.cshtml b/HHWMS.Web/Areas/Inventory/Views/Inventory/InvOut2.cshtml
new file mode 100644
index 0000000..0f649aa
--- /dev/null
+++ b/HHWMS.Web/Areas/Inventory/Views/Inventory/InvOut2.cshtml
@@ -0,0 +1,15 @@
+@model HHWMS.Web.InventoryVM
+@inject IStringLocalizer Localizer;
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/HHWMS.Web/Areas/Receipt/Controllers/SimpleReceiptInController.cs b/HHWMS.Web/Areas/Receipt/Controllers/SimpleReceiptInController.cs
new file mode 100644
index 0000000..dad4c96
--- /dev/null
+++ b/HHWMS.Web/Areas/Receipt/Controllers/SimpleReceiptInController.cs
@@ -0,0 +1,541 @@
+using System;
+using System.Linq;
+using HHWMS.Web.Models;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.EntityFrameworkCore;
+using WalkingTec.Mvvm.Core;
+using WalkingTec.Mvvm.Mvc;
+
+namespace HHWMS.Web.Controllers
+{
+ [Area("receipt")]
+ [ActionDescription("成品出入库操作")]
+ public partial class SimpleReceiptInController : BaseController
+ {
+ private readonly IUnitWork _unitWork;
+ private readonly WTMContext _context;
+
+ public SimpleReceiptInController(IUnitWork unitWork, WTMContext wtmContext)
+ {
+ _unitWork = unitWork;
+ _context = wtmContext;
+ }
+
+ #region Index
+
+ [ActionDescription("Sys.Search")]
+ public ActionResult Index()
+ {
+ return PartialView("Index");
+ }
+
+ #endregion Index
+
+ [HttpGet]
+ public JsonResult ValidateContainer(string containerCode)
+ {
+ try
+ {
+ if (string.IsNullOrEmpty(containerCode))
+ {
+ return Json(new { Code = 400, Msg = "容器编码不能为空" });
+ }
+
+ var container = _unitWork.FindSingle(u => u.Code == containerCode);
+ if (container == null)
+ {
+ return Json(new { Code = 400, Msg = "容器不存在" });
+ }
+
+ if (!string.IsNullOrWhiteSpace(container.LocationCode))
+ {
+ return Json(new { Code = 400, Msg = $"{containerCode} 容器状态不正确!已存在任务或者已在库内" });
+ }
+
+ // var task = _unitWork.FindSingle(u => u.ContainerCode == containerCode);
+ // if (task != null && !string.IsNullOrWhiteSpace(task.ToLocation))
+ // {
+ // return Json(new { Code = 400, Msg = $"{containerCode} 容器已存在任务!" });
+ // }
+
+ // 获取容器内的物料信息
+ var inventories = _unitWork.Find(x => x.ContainerCode == containerCode)
+ .Select(x => new {
+ Id = x.ID,
+ ContainerCode = x.ContainerCode,
+ MaterialCode = x.MaterialCode,
+ MaterialName = x.MaterialName,
+ MaterialSpec = x.MaterialSpec,
+ Company = x.CompanyCode,
+ Qty = x.Qty
+ })
+ .ToList();
+
+ return Json(new {
+ Code = 200,
+ Msg = "验证成功",
+ Data = inventories
+ });
+ }
+ catch (Exception ex)
+ {
+ return Json(new { Code = 500, Msg = ex.Message });
+ }
+ }
+
+ [HttpGet]
+ public ActionResult SearchMaterials(string keyword)
+ {
+ if (string.IsNullOrEmpty(keyword))
+ {
+ return JsonMore(new { Data = new object[] { } });
+ }
+
+ var materials = _unitWork.Find(x =>
+ x.MaterialCode.Contains(keyword) ||
+ x.MaterialName.Contains(keyword))
+ .Take(10)
+ .Select(x => new {
+ MaterialCode = x.MaterialCode,
+ MaterialName = x.MaterialName,
+ MaterialSpec = x.MaterialSpec,
+ MaterialUnit = x.MaterialUnit
+ })
+ .ToList();
+
+ return JsonMore( materials );
+ }
+
+ [HttpPost]
+ public ActionResult AddInventory(string containerCode, string materialCode, string company, decimal qty)
+ {
+ try
+ {
+ if (string.IsNullOrEmpty(containerCode))
+ {
+ return JsonMore(null, 500, "容器编码为空!");
+ }
+ if (string.IsNullOrEmpty(materialCode))
+ {
+ return JsonMore(null, 500, "物料编码为空!");
+ }
+ if (qty <= 0)
+ {
+ return JsonMore(null, 500, "数量必须大于0!");
+ }
+
+ // 查询容器
+ var container = _unitWork.FindSingle(u => u.Code == containerCode);
+ if (container == null)
+ {
+ return JsonMore(null, 500, $"库内没有编码为 {containerCode} 的容器!");
+ }
+
+ // 查询物料信息
+ var material = _unitWork.FindSingle(x => x.MaterialCode == materialCode);
+ if (material == null)
+ {
+ return JsonMore(null, 500, $"未找到物料编码为 {materialCode} 的物料信息!");
+ }
+
+ var zone = _unitWork.FindSingle(x => x.ZoneCode == container.Type);
+ // 创建库存记录
+ var inventory = new Inventory()
+ {
+ ZoneId = zone.ID,
+ ContainerCode = containerCode,
+ MaterialCode = material.MaterialCode,
+ MaterialName = material.MaterialName,
+ MaterialType = material.MaterialType,
+ MaterialSpec = material.MaterialSpec,
+ MaterialUnit = material.MaterialUnit,
+ CompanyCode = company,
+ Qty = qty,
+ TaskStatus = InventoryTaskStatusEnum.Locked,
+ CreateTime = DateTime.Now
+ };
+ _unitWork.Add(inventory);
+
+ // 创建入库交易记录
+ var transaction = new InventoryTransaction
+ {
+ ZoneCode = zone.ZoneCode,
+ BillType = InventoryTranType.入库,
+ MaterialCode = material.MaterialCode,
+ MaterialName = material.MaterialName,
+ MaterialUnit = material.MaterialUnit,
+ ContainerCode = containerCode,
+ Qty = qty,
+ CreateTime = DateTime.Now,
+ CreateBy = "WMS",
+ UpdateTime = DateTime.Now,
+ UpdateBy = "WMS"
+ };
+ _unitWork.Add(transaction);
+
+ return JsonMore(new { Id = inventory.ID });
+ }
+ catch (Exception ex)
+ {
+ return JsonMore(null, 500, ex.Message);
+ }
+ }
+
+ [HttpPost]
+ public ActionResult TaskIn(string containerCode)
+ {
+ try
+ {
+ if (string.IsNullOrEmpty(containerCode))
+ {
+ return JsonMore(null, 500, "容器编码为空!");
+ }
+
+ // 查询容器
+ var container = _unitWork.FindSingle(u => u.Code == containerCode);
+ if (container == null)
+ {
+ return JsonMore(null, 500, $"库内没有编码为 {containerCode} 的容器!");
+ }
+
+ // 查询容器的库存
+ var inventories = _unitWork.Find(x => x.ContainerCode == containerCode).ToList();
+
+ // 根据库存情况设置容器状态
+ if (inventories.Any())
+ {
+ container.Status = ContainerStatus.有;
+ }
+ else
+ {
+ container.Status = ContainerStatus.空;
+ }
+
+ // 更新容器状态
+ container.IsLock = ContainerLockEnum.任务锁;
+ container.UpdateTime = DateTime.Now;
+ container.UpdateBy = Wtm?.LoginUserInfo?.ITCode ?? "WMS";
+
+
+ // 创建入库任务
+ var task = new TaskHeader
+ {
+ ZoneId = inventories.First().ZoneId,
+ TaskNo = _unitWork.GetSerialNumber("In"),
+ TaskType = TaskTypeEnum.入库,
+ RoadWay = 2,
+ ContainerCode = containerCode,
+ FromLocation = "",
+ ToLocation = "",
+ Status = TaskStatusEnum.待下发,
+ CreateTime = DateTime.Now,
+ CreateBy = Wtm?.LoginUserInfo?.ITCode??"WMS",
+ };
+
+ // 下发任务到wcs
+ var postData = new
+ {
+ TaskNo = task.TaskNo,
+ PalletNo = task.ContainerCode,
+ FromLocation = task.FromLocation,
+ ToLocation = task.ToLocation
+ };
+ _unitWork.Add(task);
+
+ _unitWork.Update(container);
+ /*try
+ {
+ var res = Wtm.CallAPI>("WCSCP", "TaskAssign", HttpMethodEnum.POST, postData)
+ .Result?.Data;
+
+ if (res.Success)
+ {
+ task.Status = TaskStatusEnum.已下发;
+ task.UpdateTime = DateTime.Now;
+ task.UpdateBy = "WMS";
+ _unitWork.Add(task);
+
+ _unitWork.Update(container);
+ }
+ else
+ {
+ task.ErrorMsg = res.Msg;
+ return JsonMore(null, 500, res.Msg);
+ }
+ }
+ catch (Exception ex)
+ {
+ task.ErrorMsg = ex.Message;
+ return JsonMore(null, 500, "任务下发失败!");
+ }*/
+
+ return JsonMore(null);
+ }
+ catch (Exception ex)
+ {
+ return JsonMore(null, 500, ex.Message);
+ }
+ }
+
+ [HttpPost]
+ public ActionResult DeleteInventory(int id)
+ {
+ try
+ {
+ // 查询库存记录
+ var inventory = _unitWork.Find(x => x.ID == id).FirstOrDefault();
+
+ if (inventory == null)
+ {
+ return JsonMore(null, 500, "未找到对应的库存记录!");
+ }
+
+ // 创建出库交易记录
+ var transaction = new InventoryTransaction
+ {
+ BillType = InventoryTranType.出库,
+ MaterialCode = inventory.MaterialCode,
+ MaterialName = inventory.MaterialName,
+ MaterialUnit = inventory.MaterialUnit,
+ ContainerCode = inventory.ContainerCode,
+ Qty = inventory.Qty,
+ CreateTime = DateTime.Now,
+ CreateBy = "WMS",
+ UpdateTime = DateTime.Now,
+ UpdateBy = "WMS"
+ };
+ _unitWork.Add(transaction);
+
+ // 删除库存记录
+ _unitWork.Delete(inventory);
+
+ return JsonMore(null);
+ }
+ catch (Exception ex)
+ {
+ return JsonMore(null, 500, ex.Message);
+ }
+ }
+
+ [HttpPost]
+ public ActionResult UpdateInventory(int id, decimal qty)
+ {
+ try
+ {
+ if (qty <= 0)
+ {
+ return JsonMore(null, 500, "数量必须大于0!");
+ }
+
+ // 查询库存记录
+ var inventory = _unitWork.Find(x => x.ID == id).FirstOrDefault();
+
+ if (inventory == null)
+ {
+ return JsonMore(null, 500, "未找到对应的库存记录!");
+ }
+
+ // 创建出库交易记录(原数量)
+ var outTransaction = new InventoryTransaction
+ {
+ BillType = InventoryTranType.出库,
+ MaterialCode = inventory.MaterialCode,
+ MaterialName = inventory.MaterialName,
+ MaterialUnit = inventory.MaterialUnit,
+ ContainerCode = inventory.ContainerCode,
+ Qty = inventory.Qty,
+ CreateTime = DateTime.Now,
+ CreateBy = "WMS",
+ UpdateTime = DateTime.Now,
+ UpdateBy = "WMS"
+ };
+ _unitWork.Add(outTransaction);
+
+ // 创建入库交易记录(新数量)
+ var inTransaction = new InventoryTransaction
+ {
+ BillType = InventoryTranType.入库,
+ MaterialCode = inventory.MaterialCode,
+ MaterialName = inventory.MaterialName,
+ MaterialUnit = inventory.MaterialUnit,
+ ContainerCode = inventory.ContainerCode,
+ Qty = qty,
+ CreateTime = DateTime.Now,
+ CreateBy = "WMS",
+ UpdateTime = DateTime.Now,
+ UpdateBy = "WMS"
+ };
+ _unitWork.Add(inTransaction);
+
+ // 更新库存数量
+ inventory.Qty = qty;
+ inventory.UpdateTime = DateTime.Now;
+ inventory.UpdateBy = Wtm?.LoginUserInfo?.ITCode ?? "WMS";
+ _unitWork.Update(inventory);
+
+ return JsonMore(null);
+ }
+ catch (Exception ex)
+ {
+ return JsonMore(null, 500, ex.Message);
+ }
+ }
+
+ [HttpPost]
+ public ActionResult EmptyIn(string containerCode)
+ {
+ try
+ {
+ if (string.IsNullOrEmpty(containerCode))
+ {
+ return JsonMore(null, 500, "容器编码为空!");
+ }
+ // 查询容器
+ var container = _unitWork.FindSingle(u => u.Code == containerCode);
+ if (container == null)
+ {
+ return JsonMore(null, 500, $"库内没有编码为 {containerCode} 的容器!");
+ }
+
+ // 查询容器
+ var taskHeader = _unitWork.FindSingle(u => u.ContainerCode == containerCode);
+ if (taskHeader != null)
+ {
+ return JsonMore(null, 500, $"容器 {containerCode} 已存在任务,请检查后再试!");
+ }
+
+ // 空托盘入库逻辑(如直接生成入库任务,状态置空等)
+ container.Status = ContainerStatus.空;
+ container.IsLock = ContainerLockEnum.任务锁;
+ container.UpdateTime = DateTime.Now;
+ container.UpdateBy = Wtm?.LoginUserInfo?.ITCode ?? "WMS";
+
+ var zone = _unitWork.FindSingle(x => x.ZoneCode == container.Type);
+ // 创建入库任务
+ var task = new TaskHeader
+ {
+ ZoneId = zone.ID,
+ TaskNo = _unitWork.GetSerialNumber("In"),
+ TaskType = TaskTypeEnum.入库,
+ RoadWay = 2,
+ ContainerCode = containerCode,
+ FromLocation = "",
+ ToLocation = "",
+ Status = TaskStatusEnum.待下发,
+ CreateTime = DateTime.Now,
+ CreateBy = Wtm?.LoginUserInfo?.ITCode??"WMS",
+ };
+
+ var locationVm = Wtm.CreateVM();
+ var result = locationVm.SendWcsTask(task);
+ if (result.Status)
+ {
+ _unitWork.Update(container);
+ }
+ else
+ {
+ return JsonMore(null, 500, result.Message);
+ }
+
+ return JsonMore(null);
+ }
+ catch (Exception ex)
+ {
+ return JsonMore(null, 500, ex.Message);
+ }
+ }
+
+ [HttpPost]
+ public ActionResult CallOut(string level, string port)
+ {
+ try
+ {
+ var locationType = level == "mid" ? LocationTypeEnum.M : LocationTypeEnum.C;
+ var height = 0;
+ if (level == "mid")
+ height = 0;
+ else if (level == "high")
+ height = 1250;
+ else if (level == "low")
+ height = 1000;
+
+
+ // 一次性获取所需的所有数据,避免多次查询数据库
+ var locationPairs = DC.Set()
+ .Where(l => l.Type == locationType
+ && l.Status == LocationStatusEnum.未锁
+ && !l.IsStop
+ && l.Height == height)
+ .Select(l => new
+ {
+ l.Code,
+ l.ContiguousCode,
+ l.Status,
+ l.ContainerStatus,
+ l.RowFlag,
+ l.Height,
+ l.Layer,
+ l.Line
+ })
+ .AsNoTracking()
+ .ToDictionary(l => l.Code);
+
+ // 1. 优先查找里外仓位都为空的里仓位
+ var outloc = locationPairs.Values
+ .Where(l => l.RowFlag == RowFlagEnum.Inner
+ && l.ContainerStatus == LocationStatus.空容器
+ && locationPairs.TryGetValue(l.ContiguousCode, out var outer)
+ && outer.ContainerStatus == LocationStatus.空仓位)
+ .OrderBy(l => l.Layer)
+ .ThenBy(l => l.Line)
+ .FirstOrDefault();
+
+ if (outloc == null)
+ {
+ outloc = locationPairs.Values
+ .Where(l => l.ContainerStatus == LocationStatus.空容器)
+ .OrderBy(l => l.RowFlag)
+ .ThenBy(l => l.Layer)
+ .ThenBy(l => l.Line)
+ .FirstOrDefault();
+ }
+
+ if (outloc == null)
+ {
+ return JsonMore(null, 500, "库内暂无可用空托盘!");
+ }
+ var code = outloc?.Code;
+ var location = _unitWork.FindSingle(l => l.Code == code);
+ location.Status = LocationStatusEnum.锁定;
+ location.UpdateTime = DateTime.Now;
+ // 创建任务
+ var task = new TaskHeader
+ {
+ ZoneId = location.ZoneId,
+ TaskNo = _unitWork.GetSerialNumber("Out"),
+ TaskType = TaskTypeEnum.出库,
+ RoadWay = 2,
+ ContainerCode = location.ContainerCode,
+ FromLocation = location.Code,
+ ToLocation = port,
+ Status = TaskStatusEnum.待下发,
+ CreateTime = DateTime.Now,
+ CreateBy = Wtm?.LoginUserInfo?.ITCode??"WMS",
+ };
+
+ var locationVm = Wtm.CreateVM();
+ var result = locationVm.SendWcsTask(task);
+ if (!result.Status)
+ {
+ return JsonMore(null, 500, result.Message);
+ }
+ return JsonMore(null);
+ }
+ catch (Exception ex)
+ {
+ return JsonMore(null, 500, ex.Message);
+ }
+ }
+
+ }
+}
diff --git a/HHWMS.Web/Areas/Receipt/Views/SimpleReceiptIn/Index.cshtml b/HHWMS.Web/Areas/Receipt/Views/SimpleReceiptIn/Index.cshtml
new file mode 100644
index 0000000..7970173
--- /dev/null
+++ b/HHWMS.Web/Areas/Receipt/Views/SimpleReceiptIn/Index.cshtml
@@ -0,0 +1,580 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 绑定
+ 入库
+ 空托入库
+ 呼叫出库
+
+
+
+
+
+
+
+ 删除
+ 修改
+ @* 扣料 *@
+
+
+
+ {{ Math.floor(record.Qty) }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 高货位
+ 低货位
+
+
+
+
+ {{ item.label }}
+
+
+
+
+
+
+
+
diff --git a/HHWMS.Web/DataContext.cs b/HHWMS.Web/DataContext.cs
index 02d25be..98b7934 100644
--- a/HHWMS.Web/DataContext.cs
+++ b/HHWMS.Web/DataContext.cs
@@ -125,7 +125,7 @@ namespace HHWMS.Web
{
public DataContext CreateDbContext(string[] args)
{
- return new DataContext("Server=127.0.0.1;Port=3306;Database=WMS2;Uid=root;Password=abc123*;Character Set=utf8mb4;", DBTypeEnum.MySql);
+ return new DataContext("Server=127.0.0.1;Port=3306;Database=wms2;Uid=root;Password=123456;Character Set=utf8mb4;", DBTypeEnum.MySql);
}
}
}
diff --git a/HHWMS.Web/Models/Enum/WMSEnum.cs b/HHWMS.Web/Models/Enum/WMSEnum.cs
index c7ab4bc..3a795b1 100644
--- a/HHWMS.Web/Models/Enum/WMSEnum.cs
+++ b/HHWMS.Web/Models/Enum/WMSEnum.cs
@@ -89,7 +89,7 @@ namespace HHWMS.Web.Models
public static class ContainerTypeEnum
{
public const string 线边库 = "X";
- public const string 成品库 = "L";
+ public const string 成品库 = "C";
public const string 模具库 = "M";
}
diff --git a/HHWMS.Web/Models/Request/Request/WcsRequest.cs b/HHWMS.Web/Models/Request/Request/WcsRequest.cs
index 2e9a29c..4e4f4c9 100644
--- a/HHWMS.Web/Models/Request/Request/WcsRequest.cs
+++ b/HHWMS.Web/Models/Request/Request/WcsRequest.cs
@@ -11,7 +11,7 @@ namespace HHWMS.Web
public string PalletNo { get; set; }
public decimal? Length { get; set; }
public decimal? Width { get; set; }
- public decimal? Height { get; set; }
+ public int? Height { get; set; }
public int Weight { get; set; }
public string InPort { get; set; }
public LocationTypeEnum LocationType { get; set; }
diff --git a/HHWMS.Web/Resources/Program.zh.resx b/HHWMS.Web/Resources/Program.zh.resx
index d7dcfd0..e8cfc8f 100644
--- a/HHWMS.Web/Resources/Program.zh.resx
+++ b/HHWMS.Web/Resources/Program.zh.resx
@@ -1022,6 +1022,9 @@
出库
+
+
+ 出 库
移库