wcs_serve_wuxikate/WcsMain/Business/Convey/HistoryDataHandler/HisGetData/PickStandEnd.cs
2025-01-03 14:36:27 +08:00

107 lines
4.9 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using WcsMain.Business.Convey.HistoryDataHandler.HisGetData.I;
using WcsMain.DataBase.Dao;
using WcsMain.DataBase.TableEntity;
using WcsMain.DataService;
using WcsMain.Enum.Convey;
using WcsMain.EquipOperation.Convey;
using WcsMain.EquipOperation.Entity;
using WcsMain.Plugins;
namespace WcsMain.Business.Convey.HistoryDataHandler.HisGetData;
/// <summary>
/// 1~5 站台环线的出口
/// </summary>
/// <param name="conveyOperation"></param>
/// <param name="dataBaseData"></param>
/// <param name="conveyTaskDao"></param>
public class PickStandEnd(ConveyOperation conveyOperation, DataBaseData dataBaseData, AppConveyTaskDao conveyTaskDao) : 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, 1); // 读码失败,移栽进拣选站台
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 conveyTasks = conveyTaskDao.Query(new AppConveyTask { VehicleNo = msg, TaskStatus = (int)ConveyTaskStatusEnum.create });
if (conveyTasks == null)
{
ConsoleLog.Warning($"【警告】拣选出口站台:{area} 箱码:{msg} 查询任务失败,数据服务异常");
ConveyPLCTask plcTask = new(plcId, 2); // 连接中断环线运行
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 (conveyTasks.Count < 1)
{
ConsoleLog.Warning($"【警告】拣选出口站台:{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 pickStand1Task = conveyTasks.Find(f => f.Location == "P3");
if (pickStand1Task == null) // 不存在这个站台任务
{
ConsoleLog.Warning($"【警告】拣选出口站台:{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}");
}
else
{
ConsoleLog.Info($"拣选出口站台:{area} 箱码:{msg} 存在此站台任务");
ConveyPLCTask plcTask = new(plcId, 1); // 存在拣选台任务
var errText = conveyOperation.WriteTask(area, plcTask);
if (string.IsNullOrEmpty(errText))
{
ConsoleLog.Success($"拣选出口站台:{area} 箱码:{msg}写入PLC成功{plcTask}");
return;
}
ConsoleLog.Warning($"【警告】拣选出口站台:{area} 箱码:{msg}写入PLC失败{plcTask},信息:{errText}");
}
}
}