110 lines
4.9 KiB
C#
110 lines
4.9 KiB
C#
using WcsMain.Business.Convey.HistoryDataHandler.HisGetData.I;
|
||
using WcsMain.Common;
|
||
using WcsMain.DataBase.Dao;
|
||
using WcsMain.DataBase.TableEntity;
|
||
using WcsMain.DataService;
|
||
using WcsMain.Enum.Stacker;
|
||
using WcsMain.EquipOperation.Convey;
|
||
using WcsMain.EquipOperation.Entity;
|
||
using WcsMain.ExtendMethod;
|
||
|
||
namespace WcsMain.Business.Convey.HistoryDataHandler.HisGetData;
|
||
|
||
/// <summary>
|
||
/// 入库异常异常口判定
|
||
/// </summary>
|
||
/// <remarks>
|
||
/// R3
|
||
/// </remarks>
|
||
public class StackerInErr(ConveyOperation conveyOperation, DataBaseData dataBaseData, AppWmsTaskDao wmsTaskDao) : IBaseGetData
|
||
{
|
||
/// <summary>
|
||
/// 读码失败
|
||
/// </summary>
|
||
/// <param name="disPlayName"></param>
|
||
/// <param name="msg"></param>
|
||
/// <param name="area"></param>
|
||
/// <param name="routerMethodData"></param>
|
||
public void ReadFail(string? disPlayName, string msg, string? area, AppRouterMethod routerMethodData)
|
||
{
|
||
var plcId = dataBaseData.GetNewPlcTaskId() ?? StaticData.StaticInt.ErrPlcId;
|
||
ConveyPLCTask plcTask = new(plcId, 3);
|
||
var errText = conveyOperation.WriteTask(area, plcTask);
|
||
if (string.IsNullOrEmpty(errText))
|
||
{
|
||
ConsoleLog.Warning($"入库异常校验口:{area} 读码失败,写入PLC成功,{plcTask}");
|
||
return;
|
||
}
|
||
ConsoleLog.Warning($"【警告】入库异常校验口:{area} 读码失败,写入PLC失败,{plcTask},信息:{errText}");
|
||
}
|
||
|
||
/// <summary>
|
||
/// 读码成功
|
||
/// </summary>
|
||
/// <param name="disPlayName"></param>
|
||
/// <param name="msg"></param>
|
||
/// <param name="area"></param>
|
||
/// <param name="routerMethodData"></param>
|
||
public void ReadSuccess(string? disPlayName, string msg, string? area, AppRouterMethod routerMethodData)
|
||
{
|
||
var plcId = dataBaseData.GetNewPlcTaskId() ?? StaticData.StaticInt.ErrPlcId; // 获取一个 plcId
|
||
/* 查询任务 */
|
||
var wmsTasks = wmsTaskDao.Select(new AppWmsTask { VehicleNo = msg, TaskStatus = (int)WmsTaskStatusEnum.create });
|
||
if (wmsTasks == null)
|
||
{
|
||
// 数据库服务器连接失败
|
||
ConsoleLog.Exception($"【异常】入库异常口:{area} 箱码:{msg} 查询任务失败,请检查服务器网络");
|
||
ConveyPLCTask plcTask = new(plcId, 3);
|
||
var errText = conveyOperation.WriteTask(area, plcTask);
|
||
if (string.IsNullOrEmpty(errText))
|
||
{
|
||
ConsoleLog.Success($"入库异常口:{area} 箱码:{msg},写入PLC成功,{plcTask}");
|
||
return;
|
||
}
|
||
ConsoleLog.Warning($"【警告】入库异常口:{area} 箱码:{msg},写入PLC失败,{plcTask},信息:{errText}");
|
||
return;
|
||
}
|
||
if (wmsTasks.Count < 1)
|
||
{
|
||
// 不存在任务
|
||
ConsoleLog.Exception($"【异常】入库异常口:{area} 箱码:{msg} 不存在入库任务");
|
||
ConveyPLCTask plcTask = new(plcId, 3);
|
||
var errText = conveyOperation.WriteTask(area, plcTask);
|
||
if (string.IsNullOrEmpty(errText))
|
||
{
|
||
ConsoleLog.Success($"入库异常口:{area} 箱码:{msg},写入PLC成功,{plcTask}");
|
||
return;
|
||
}
|
||
ConsoleLog.Warning($"【警告】入库异常口:{area} 箱码:{msg},写入PLC失败,{plcTask},信息:{errText}");
|
||
return;
|
||
}
|
||
var wmsTask = wmsTasks.First(); // 取得任务
|
||
var locationDetail = CommonData.AppLocations.DetailWithWmsLocation(wmsTask.Destination);
|
||
if (locationDetail == null)
|
||
{
|
||
// 点位不存在
|
||
ConsoleLog.Exception($"【异常】入库分流:{area} 箱码:{msg} 终点:{wmsTask.Destination} 不存在,请重试");
|
||
ConveyPLCTask plcTask = new(plcId, 3);
|
||
var errText = conveyOperation.WriteTask(area, plcTask);
|
||
if (string.IsNullOrEmpty(errText))
|
||
{
|
||
ConsoleLog.Success($"入库异常口:{area} 箱码:{msg},写入PLC成功,{plcTask}");
|
||
return;
|
||
}
|
||
ConsoleLog.Warning($"【警告】入库异常口:{area} 箱码:{msg},写入PLC失败,{plcTask},信息:{errText}");
|
||
return;
|
||
}
|
||
// 点位存在
|
||
var successRouter = (short)(locationDetail.TunnelNo ?? 0);
|
||
ConsoleLog.Success($"入库分流:{area} 箱码:{msg} 终点:{wmsTask.Destination} 巷道:{locationDetail.TunnelNo}");
|
||
ConveyPLCTask plcTaskOk = new(plcId, successRouter);
|
||
var errTextOk = conveyOperation.WriteTask(area, plcTaskOk);
|
||
if (string.IsNullOrEmpty(errTextOk))
|
||
{
|
||
ConsoleLog.Success($"入库异常口:{area} 箱码:{msg},写入PLC成功,{plcTaskOk}");
|
||
return;
|
||
}
|
||
ConsoleLog.Warning($"【警告】入库异常口:{area} 箱码:{msg},写入PLC失败,{plcTaskOk},信息:{errTextOk}");
|
||
}
|
||
}
|