using SqlSugar.Extensions; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using WIDESEAWCS_Common.TaskEnum; using WIDESEAWCS_Core; using WIDESEAWCS_ITaskInfoRepository; using WIDESEAWCS_ITaskInfoService; using WIDESEAWCS_Model.Models; using WIDESEAWCS_QuartzJob; using WIDESEAWCS_QuartzJob.Service; using WIDESEAWCS_Tasks.ShuttleCarJob; using WIDESEAWCS_Tasks.StackerCraneJob; namespace WIDESEAWCS_Tasks { public partial class CommonStackerCraneJob { /// /// 心跳 /// /// public void Heartbeat(SpeStackerCrane commonStackerCrane) { var HeartBeat = commonStackerCrane.GetValue(StackerCraneDBName.HeartBeat); commonStackerCrane.SetValue(StackerCraneDBName.WCSHeartBeat, !HeartBeat); } /// /// 堆垛机与穿梭车信息交互 /// /// public void ShuttleCarSignal(SpeStackerCrane commonStackerCrane) { var ASRSRqtGetAGV = commonStackerCrane.GetValue(StackerCraneDBName.ASRSRqtGetAGV); var ASRSRqtGetGoods = commonStackerCrane.GetValue(StackerCraneDBName.ASRSRqtGetGoods); var ASRSRqtPutGoods = commonStackerCrane.GetValue(StackerCraneDBName.ASRSRqtPutGoods); var ASRSRqtPutAGV = commonStackerCrane.GetValue(StackerCraneDBName.ASRSRqtPutAGV); var ASRSGetAGVDone = commonStackerCrane.GetValue(StackerCraneDBName.ASRSGetAGVDone); var ASRSGetGoodsDone = commonStackerCrane.GetValue(StackerCraneDBName.ASRSGetGoodsDone); var ASRSPutAGoodsDone = commonStackerCrane.GetValue(StackerCraneDBName.ASRSPutAGoodsDone); var ASRSPutAGVDone = commonStackerCrane.GetValue(StackerCraneDBName.ASRSPutAGVDone); //任务查询目的地找到车 if (ASRSRqtGetAGV || ASRSRqtGetGoods || ASRSRqtPutGoods || ASRSRqtPutAGV || ASRSGetAGVDone || ASRSGetGoodsDone || ASRSPutAGoodsDone || ASRSPutAGVDone) { Dt_Task? task = GetTaskInfo(commonStackerCrane); if (task != null) { if ((_taskService.TaskInboundTypes.Contains(task.TaskType) || task.TaskType == TaskRelocationTypeEnum.Relocation.ObjToInt()) && task.TargetIsPickPlace && ASRSRqtPutGoods)//请求放货 { commonStackerCrane.SetValue(StackerCraneDBName.AGVAlwASRSPuttGoods, ASRSRqtPutGoods); WriteDebug($"{commonStackerCrane.DeviceName}请求放货", $"WCS允许放货,任务号【{task.TaskNum}】"); } else if ((_taskService.TaskOutboundTypes.Contains(task.TaskType) || task.TaskType == TaskRelocationTypeEnum.Relocation.ObjToInt()) && ASRSRqtGetGoods && task.SourceIsPickPlace)//请求取货 { commonStackerCrane.SetValue(StackerCraneDBName.AGVAlwASRSGetGoods, ASRSRqtGetGoods); WriteDebug($"{commonStackerCrane.DeviceName}请求取货", $"WCS允许取货,任务号【{task.TaskNum}】"); } else { if (task.TaskType == TaskRelocationTypeEnum.Relocation.ObjToInt()) { var shuttleCar2 = _shuttleCarService.QueryNoCode(task.ShuttleCarCode); ShuttleCar shuttleCarA = Storage.Devices.FirstOrDefault(x => x.DeviceCode == shuttleCar2.ShuttleCarCode) as ShuttleCar; ShuttleCar shuttleCarB = Storage.Devices.FirstOrDefault(x => x.DeviceCode == task.ShuttleCarCode) as ShuttleCar; #region 取货 if (ASRSRqtGetGoods) { shuttleCarA.SetValue(ShuttleCarDBName.ASRSRqtGetGoods, ASRSRqtGetGoods, shuttleCarA.DeviceCode); var AGVAlwASRSGetGoods = shuttleCarA.GetValue(ShuttleCarDBName.AGVAlwASRSGetGoods, shuttleCarA.DeviceCode);//允许取货 if (AGVAlwASRSGetGoods) commonStackerCrane.SetValue(StackerCraneDBName.AGVAlwASRSGetGoods, AGVAlwASRSGetGoods); WriteDebug($"{commonStackerCrane.DeviceName}请求取货", $"【{shuttleCarA.DeviceName}】{(AGVAlwASRSGetGoods ? "允许" : "不允许")}取货,任务号【{task.TaskNum}】"); } #endregion #region 取货完成 if (ASRSGetGoodsDone) { shuttleCarA.SetValue(ShuttleCarDBName.ASRSGetGoodsDone, ASRSGetGoodsDone, shuttleCarA.DeviceCode); WriteDebug($"{commonStackerCrane.DeviceName}取货完成", $"【{shuttleCarA.DeviceName}】,任务号【{task.TaskNum}】"); } #endregion #region 放货 if (ASRSRqtPutGoods) { shuttleCarB.SetValue(ShuttleCarDBName.ASRSRqtPutGoods, ASRSRqtPutGoods, shuttleCarB.DeviceCode); var AGVAlwASRSPuttGoods = shuttleCarB.GetValue(ShuttleCarDBName.AGVAlwASRSPuttGoods, shuttleCarB.DeviceCode);//允许放货 if (AGVAlwASRSPuttGoods) commonStackerCrane.SetValue(StackerCraneDBName.AGVAlwASRSPuttGoods, AGVAlwASRSPuttGoods); WriteDebug($"{commonStackerCrane.DeviceName}请求放货", $"【{shuttleCarB.DeviceName}】{(AGVAlwASRSPuttGoods ? "允许" : "不允许")}放货,任务号【{task.TaskNum}】"); } #endregion #region 放货完成 if (ASRSPutAGoodsDone) { shuttleCarB.SetValue(ShuttleCarDBName.ASRSPutAGoodsDone, ASRSPutAGoodsDone, shuttleCarB.DeviceCode); WriteDebug($"{commonStackerCrane.DeviceName}放货完成", $"【{shuttleCarA.DeviceName}】,任务号【{task.TaskNum}】"); } #endregion } else { ShuttleCar shuttleCar = Storage.Devices.FirstOrDefault(x => x.DeviceCode == task.ShuttleCarCode) as ShuttleCar; if (shuttleCar != null) { shuttleCar.SetValue(ShuttleCarDBName.ASRSRqtGetAGV, ASRSRqtGetAGV, shuttleCar.DeviceCode); shuttleCar.SetValue(ShuttleCarDBName.ASRSRqtGetGoods, ASRSRqtGetGoods, shuttleCar.DeviceCode); shuttleCar.SetValue(ShuttleCarDBName.ASRSRqtPutGoods, ASRSRqtPutGoods, shuttleCar.DeviceCode); var AGVAlwASRSGetAGV = shuttleCar.GetValue(ShuttleCarDBName.AGVAlwASRSGetAGV, shuttleCar.DeviceCode);//允许取车 commonStackerCrane.SetValue(StackerCraneDBName.AGVAlwASRSGetAGV, AGVAlwASRSGetAGV); if (ASRSRqtGetAGV) WriteDebug($"{commonStackerCrane.DeviceName}请求取车", $"【{shuttleCar.DeviceName}】{(AGVAlwASRSGetAGV ? "允许" : "不允许")}取车,任务号【{task.TaskNum}】"); var AGVAlwASRSGetGoods = shuttleCar.GetValue(ShuttleCarDBName.AGVAlwASRSGetGoods, shuttleCar.DeviceCode);//允许取货 commonStackerCrane.SetValue(StackerCraneDBName.AGVAlwASRSGetGoods, AGVAlwASRSGetGoods); if (ASRSRqtGetGoods) WriteDebug($"{commonStackerCrane.DeviceName}请求取货", $"【{shuttleCar.DeviceName}】{(AGVAlwASRSGetGoods ? "允许" : "不允许")}取货,任务号【{task.TaskNum}】"); var AGVAlwASRSPuttGoods = shuttleCar.GetValue(ShuttleCarDBName.AGVAlwASRSPuttGoods, shuttleCar.DeviceCode);//允许放货 commonStackerCrane.SetValue(StackerCraneDBName.AGVAlwASRSPuttGoods, AGVAlwASRSPuttGoods); if (ASRSRqtPutGoods) WriteDebug($"{commonStackerCrane.DeviceName}请求放货", $"【{shuttleCar.DeviceName}】{(AGVAlwASRSPuttGoods ? "允许" : "不允许")}放货,任务号【{task.TaskNum}】"); commonStackerCrane.SetValue(StackerCraneDBName.AGVAlwASRSPutAGV, ASRSRqtPutAGV); if (ASRSRqtPutAGV) WriteDebug($"{commonStackerCrane.DeviceName}请求放车", $"WCS允许放车,任务号【{task.TaskNum}】"); shuttleCar.SetValue(ShuttleCarDBName.ASRSGetAGVDone, ASRSGetAGVDone, shuttleCar.DeviceCode); if (ASRSGetAGVDone) WriteDebug($"{commonStackerCrane.DeviceName}取车完成", $"【{shuttleCar.DeviceName}】,任务号【{task.TaskNum}】"); shuttleCar.SetValue(ShuttleCarDBName.ASRSGetGoodsDone, ASRSGetGoodsDone, shuttleCar.DeviceCode); if (ASRSGetGoodsDone) WriteDebug($"{commonStackerCrane.DeviceName}取货完成", $"【{shuttleCar.DeviceName}】,任务号【{task.TaskNum}】"); shuttleCar.SetValue(ShuttleCarDBName.ASRSPutAGoodsDone, ASRSPutAGoodsDone, shuttleCar.DeviceCode); if (ASRSPutAGoodsDone) WriteDebug($"{commonStackerCrane.DeviceName}放货完成", $"【{shuttleCar.DeviceName}】,任务号【{task.TaskNum}】"); } } } } } } /// /// 获取任务信息 /// /// /// /// public Dt_Task GetTaskInfo(SpeStackerCrane commonStackerCrane) { return _taskService.GetTaskInfo(commonStackerCrane.CurrentTaskNum); } /// /// 获取穿梭车信息 /// /// /// public Dt_ShuttleCar GetShuttleCarInfo(string Address) { return _shuttleCarService.QueryShuttleCar(Address); } } }