同上 优化出库自检错误流程
This commit is contained in:
@ -308,6 +308,179 @@ namespace WCS.BLL.HardWare
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 由自检异常等错误导致的 手动操作处理后重新进入出库模式
|
||||
/// </summary>
|
||||
/// <param name="ModuleId"></param>
|
||||
public void GoInOutstoreByWebSocket(int moduleId)
|
||||
{
|
||||
try
|
||||
{
|
||||
//找到对应的模组
|
||||
var module = Modules.Where(t => t.ModuleId == moduleId).First();
|
||||
if (module == null)
|
||||
{
|
||||
Logs.Write($"GoInOutstoreByModule货架【{ShelfCode}】,未找到MouduleId为{moduleId}的模组", LogsType.Outstore);
|
||||
return;
|
||||
}
|
||||
//判断删除后是否还有继续需要亮灯的情况
|
||||
if (module.CurrentOutSns == null || module.CurrentOutSns.Count == 0)
|
||||
{
|
||||
Logs.Write($"GoInOutstoreByModule货架【{ShelfCode}】,模组【{module.ModuleCode}】,不存在需要继续出的物料,给其复位。", LogsType.Outstore);
|
||||
//不需要这个模组继续亮灯了
|
||||
module.Reset(TcpCleint);
|
||||
|
||||
//判断此货架是否还有出库模式的模块
|
||||
var isExistOuting = Modules.Where(t => t.CurrentMode == Mode.出库模式).Any();
|
||||
if (isExistOuting)
|
||||
{
|
||||
//还有继续出的就不管
|
||||
}
|
||||
//这里的处理逻辑应与出库出了最后一盘料相同
|
||||
else
|
||||
{
|
||||
#region 继续出库进程
|
||||
Logs.Write($"GoInOutstoreByModule货架【{ShelfCode}】,丢失删除的料刚好为货架需要出库的最后一盘料", LogsType.Outstore);
|
||||
CurrentOutOrder = null;
|
||||
|
||||
//退出出库模式
|
||||
var taskGoOut = Task.Run(() =>
|
||||
{
|
||||
GoOutOutstore();
|
||||
});
|
||||
|
||||
//看是否是分批次出库的情况 分批次亮灯
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await Task.WhenAll(taskGoOut);
|
||||
if (LocalFile.Config.IsSameMatCodeOut)
|
||||
{
|
||||
#region 触发下一批次的物料发料
|
||||
//查一下是否是当前发料单最后一个货架(在出库模式 同一个发料单下)
|
||||
var isLastShelf = ShelfManager.Shelves
|
||||
.Where(t => t.OrderNumber == OrderNumber)
|
||||
.Where(t => t.CurrentMode == Mode.出库模式)
|
||||
.Any();
|
||||
if (!isLastShelf)
|
||||
{
|
||||
Logs.Write($"GoInOutstoreByModule发料单{OrderNumber},最后一个出库货架,触发精准发料机制!查询是否还存在待出库物料", LogsType.Outstore);
|
||||
var outOrder = DbHelp.db.Queryable<OutOrder>()
|
||||
.Where(t => t.OrderNumber == OrderNumber)
|
||||
.First();
|
||||
if (outOrder != null)
|
||||
{
|
||||
var outOrderMatDetails = DbHelp.db.Queryable<OutOrderMatDetail>()
|
||||
.Where(t => t.OrderId == outOrder.Id)
|
||||
.Where(t => t.IsSended == false)
|
||||
.Includes(t => t.StoreInfo)
|
||||
.ToList();
|
||||
|
||||
if (outOrderMatDetails != null && outOrderMatDetails.Count > 0)
|
||||
{
|
||||
//相邻物料亮不同颜色 这里绿色和蓝色互相切换
|
||||
LocalStatic.CurrentOutStoreColor = LocalStatic.CurrentOutStoreColor == (byte)0x02 ? (byte)0x04 : (byte)0x02;
|
||||
|
||||
//存在待出库 然后之前又没亮灯的情况 => 继续分批次亮灯
|
||||
Logs.Write($"GoInOutstoreByModule发料单{OrderNumber},还有物料未出!", LogsType.Outstore);
|
||||
var outOrderDetailCount = outOrderMatDetails.GroupBy(t => t.MatCode)
|
||||
.Select(o => new { count = o.Count(), bb = o })
|
||||
.Where(o => o.count >= 2)
|
||||
.OrderByDescending(o => o.count)
|
||||
.ToList();
|
||||
//相同物料存在盘数超过2的情况,亮下一个盘数多的物料
|
||||
if (outOrderDetailCount.Count > 0)
|
||||
{
|
||||
var matCode = outOrderDetailCount.First().bb.Key;
|
||||
outOrderMatDetails = outOrderMatDetails.Where(t => t.MatCode == matCode)
|
||||
.ToList();
|
||||
Logs.Write($"GoInOutstoreByModule发料单{OrderNumber},本次亮灯物料{matCode}!", LogsType.Outstore);
|
||||
}
|
||||
//相同物料不存在盘数超过n的情况,剩余物料全部亮灯
|
||||
else
|
||||
{
|
||||
//剩余物料全出
|
||||
Logs.Write($"GoInOutstoreByModule发料单{OrderNumber},剩余物料灯全亮!", LogsType.Outstore);
|
||||
}
|
||||
|
||||
var shelfIds = outOrderMatDetails.Select(t => t.StoreInfo.ShelfId)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
var shelfs = ShelfManager.Shelves.Where(t => shelfIds.Contains(t.ShelfId)).ToList();
|
||||
|
||||
var otherModeShelfs = shelfs.Where(t => t.CurrentMode != HardWare.Mode.待机模式).ToList();
|
||||
if (otherModeShelfs != null && otherModeShelfs.Count > 0)
|
||||
{
|
||||
otherModeShelfs.ForEach(t =>
|
||||
{
|
||||
t.Reset();
|
||||
});
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
//对应的货架对应位置 进入出库模式 亮灯
|
||||
shelfs.ForEach(shelf =>
|
||||
{
|
||||
var matDetails = outOrderMatDetails.Where(t => t.StoreInfo.ShelfCode == shelf.ShelfCode)
|
||||
|
||||
.Distinct()
|
||||
.ToList();
|
||||
shelf.GoInOutstore(matDetails, outOrder);
|
||||
shelf.OrderNumber = outOrder.OrderNumber;
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Logs.Write($"GoInOutstoreByModule发料单{OrderNumber},当前物料已发完!", LogsType.Outstore);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logs.Write($"GoInOutstoreByModule发料单{OrderNumber},OutOrder为null,肯定是有问题", LogsType.Outstore);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logs.Write($"GoInOutstoreByModule发料单{OrderNumber},非最后一个出库货架!", LogsType.Outstore);
|
||||
var otherShelfs = ShelfManager.Shelves
|
||||
.Where(t => t.OrderNumber == OrderNumber)
|
||||
.Where(t => t.CurrentMode == Mode.出库模式)
|
||||
.ToList();
|
||||
|
||||
otherShelfs.ForEach(shelf =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (shelf is SmartShelf)
|
||||
{
|
||||
var smartShelf = (SmartShelf)shelf;
|
||||
Logs.Write($"GoInOutstoreByModule货架【{smartShelf.ShelfCode}】待取物料{string.Join(",", smartShelf.CurrentOutStoreMatSNs)}", LogsType.Outstore);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
});
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
//继续亮灯
|
||||
Logs.Write($"GoInOutstoreByModule货架【{ShelfCode}】,模组【{module.ModuleCode}】,存在需要继续出的物料,继续亮灯。", LogsType.Outstore);
|
||||
module.GoInOutStoreMode(TcpCleint, module.CurrentOutSns);
|
||||
WarningLight.GreenLight(TcpCleint);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logs.Write($"GoInOutstoreByModule货架【{ShelfCode}】进入出库模式发生异常!", LogsType.Outstore);
|
||||
GoOutOutstore();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
public void GoInOutstore(List<OutOrderMatDetail> MatDetails, OutOrder outOrder)
|
||||
{
|
||||
try
|
||||
|
Reference in New Issue
Block a user