hwh
2024-08-28 0347d14e06fb92ff4d64fad22b73fce78de98e88
Admin.NET/WCS.Application/PLC/PLCService.cs
@@ -1,12 +1,19 @@

using Furion.Logging;
using IoTClient;
using Microsoft.AspNetCore.SignalR;
using System.Data;
namespace WCS.Application;
public static class PLCService
{
    private static readonly ISqlSugarClient _db = SqlSugarSetup.ITenant.GetConnectionScope(SqlSugarConst.MainConfigId);
    private static readonly IHubContext<TaskLogHub, ITaskLogHub> _taskLogHubContext;
    static PLCService()
    {
        _taskLogHubContext = App.GetService<IHubContext<TaskLogHub, ITaskLogHub>>();
    }
    public static void OnChangeEvent(object sender, EventArgs e)
    {
@@ -107,12 +114,8 @@
                                    modTaskMonitor.InteractiveMsg = "起始储位为空!";
                                    _db.Insertable(modTaskMonitor).ExecuteCommand();
                                    // 通知任务界面任务已存在更新 请更新界面
                                    //if (TaskAction.refresh)
                                    //{
                                    //    wSChat.AlarmInformation("1");
                                    //}
                                    //下发任务日志
                                    _taskLogHubContext.Clients.All.PublicTaskMonitor(modTaskMonitor.Adapt<WcsTaskMonitorOutput>());
                                    break;
                                }
                                //给PLC写入任务数据
@@ -165,11 +168,8 @@
                                        EndLocat = outStationNum,
                                    };
                                    _db.Insertable(modInsertTaskMonitor).ExecuteCommand();
                                    // 通知任务界面任务已存在更新 请更新界面
                                    //if (TaskAction.refresh)
                                    //{
                                    //    wSChat.AlarmInformation("1");
                                    //}
                                    //下发任务日志
                                    _taskLogHubContext.Clients.All.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>());
                                    //修改led屏信息
                                    //LedDisplay(modDevice.LedIP, "工位:" + modTask.EndLocate, "出库中 " + $"储位地址:{modTask.StartLocate}", "托盘号:" + modTask.PalletNo);
                                }
@@ -236,11 +236,8 @@
                            Status = TaskStatusEnum.Complete
                        };
                        _db.Insertable(modTaskMonitor).ExecuteCommand();
                        //通知任务界面任务已存在更新 请更新界面
                        //if (TaskAction.refresh)
                        //{
                        //    wSChat.AlarmInformation("1");
                        //}
                        //下发任务日志
                        _taskLogHubContext.Clients.All.PublicTaskMonitor(modTaskMonitor.Adapt<WcsTaskMonitorOutput>());
                    }
                    else if (modTask.TaskType.Value == TaskTypeEnum.Out)
@@ -277,11 +274,8 @@
                            Status = TaskStatusEnum.Complete
                        };
                        _db.Insertable(modTaskMonitor).ExecuteCommand();
                        //通知任务界面任务已存在更新 请更新界面
                        //if (TaskAction.refresh)
                        //{
                        //    wSChat.AlarmInformation("1");
                        //}
                        //下发任务日志
                        _taskLogHubContext.Clients.All.PublicTaskMonitor(modTaskMonitor.Adapt<WcsTaskMonitorOutput>());
                    }
                }
                break;
@@ -344,11 +338,8 @@
                                        Status = TaskStatusEnum.Complete
                                    };
                                    _db.Insertable(modTaskMonitor).ExecuteCommand();
                                    // 通知任务界面任务已存在更新 请更新界面
                                    //if (TaskAction.refresh)
                                    //{
                                    //    wSChat.AlarmInformation("1");
                                    //}
                                    //下发任务日志
                                    _taskLogHubContext.Clients.All.PublicTaskMonitor(modTaskMonitor.Adapt<WcsTaskMonitorOutput>());
                                }
                                else
                                {
@@ -427,11 +418,8 @@
                                };
                                _db.Insertable(modTaskMonitor).ExecuteCommand();
                                // 通知任务界面任务已存在更新 请更新界面
                                //if (TaskAction.refresh)
                                //{
                                //    wSChat.AlarmInformation("1");
                                //}
                                //下发任务日志
                                _taskLogHubContext.Clients.All.PublicTaskMonitor(modTaskMonitor.Adapt<WcsTaskMonitorOutput>());
                                //todo:垛机出库不空跑
                            }