| | |
| | | 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) |
| | | { |
| | |
| | | .SetColumns(s => s.Status == TaskStatusEnum.Doing) |
| | | .Where(s => s.Id == modTask.Id) |
| | | .ExecuteCommand(); |
| | | _taskLogHubContext.Clients.All.PublicTask(modTask.Adapt<WcsTaskOutput>()); |
| | | HubUtil.PublicTask(modTask.Adapt<WcsTaskOutput>()); |
| | | WcsTaskMonitor modInsertTaskMonitor; |
| | | if (string.IsNullOrEmpty(taskInfo.EndStation)) |
| | | { |
| | |
| | | // 插入交互日志 |
| | | _db.Insertable(modInsertTaskMonitor).ExecuteCommand(); |
| | | //下发任务日志 |
| | | _taskLogHubContext.Clients.All.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | HubUtil.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | //修改led屏信息 |
| | | //LedDisplay(modDevice.LedIP, "工位:" + modTask.EndLocate, "出库中 " + $"储位地址:{modTask.StartLocate}", "托盘号:" + modTask.PalletNo); |
| | | } |
| | |
| | | // 插入交互日志 |
| | | _db.Insertable(modInsertTaskMonitor).ExecuteCommand(); |
| | | //下发任务日志 |
| | | _taskLogHubContext.Clients.All.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | HubUtil.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | break; |
| | | } |
| | | |
| | |
| | | // 插入交互日志 |
| | | _db.Insertable(modcTaskMonitor).ExecuteCommand(); |
| | | //下发任务日志 |
| | | _taskLogHubContext.Clients.All.PublicTaskMonitor(modcTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | HubUtil.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | } |
| | | |
| | | // 写入流程控制字 |
| | |
| | | // 插入交互日志 |
| | | _db.Insertable(modInsertTaskMonitor).ExecuteCommand(); |
| | | //下发任务日志 |
| | | _taskLogHubContext.Clients.All.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | HubUtil.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | } |
| | | } |
| | | else if (modTask.TaskType == TaskTypeEnum.Out) |
| | |
| | | // 插入交互日志 |
| | | _db.Insertable(modInsertTaskMonitor).ExecuteCommand(); |
| | | //下发任务日志 |
| | | _taskLogHubContext.Clients.All.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | HubUtil.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | //修改led屏信息 |
| | | //LedDisplay(modDevice.LedIP, "工位:" + modTask.EndLocate, "出库中 " + $"储位地址:{modTask.StartLocate}", "托盘号:" + modTask.PalletNo); |
| | | } |
| | |
| | | modTask.Status = TaskStatusEnum.Complete; |
| | | modTask.FinishDate = DateTime.Now; |
| | | _db.Updateable(modTask).ExecuteCommand(); |
| | | _taskLogHubContext.Clients.All.PublicTask(modTask.Adapt<WcsTaskOutput>()); |
| | | var modcTaskMonitor = new WcsTaskMonitor() |
| | | HubUtil.PublicTask(modTask.Adapt<WcsTaskOutput>()); |
| | | var modTaskMonitor = new WcsTaskMonitor() |
| | | { |
| | | TaskNo = modTask.TaskNo, |
| | | PlcId = modDevice.Id, |
| | |
| | | var modResponseTask = httpService.RequestTask(requestMode).Result; |
| | | if (modResponseTask.StatusCode == "0") |
| | | { |
| | | modcTaskMonitor.InteractiveMsg = "任务完成,返回给WMS任务完成"; |
| | | modTaskMonitor.InteractiveMsg = "任务完成,返回给WMS任务完成"; |
| | | } |
| | | } |
| | | // 插入交互日志 |
| | | _db.Insertable(modcTaskMonitor).ExecuteCommand(); |
| | | _db.Insertable(modTaskMonitor).ExecuteCommand(); |
| | | //下发任务日志 |
| | | _taskLogHubContext.Clients.All.PublicTaskMonitor(modcTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | HubUtil.PublicTaskMonitor(modTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | |
| | | // 此处添加不空跑业务 |
| | | } |
| | |
| | | // 插入交互日志 |
| | | _db.Insertable(modcTaskMonitor).ExecuteCommand(); |
| | | //下发任务日志 |
| | | _taskLogHubContext.Clients.All.PublicTaskMonitor(modcTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | HubUtil.PublicTaskMonitor(modcTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | break; |
| | | } |
| | | } |
| | |
| | | modTask.FinishDate = DateTime.Now; |
| | | _db.Updateable(modTask).ExecuteCommand(); |
| | | //下发任务日志 |
| | | _taskLogHubContext.Clients.All.PublicTask(modTask.Adapt<WcsTaskOutput>()); |
| | | |
| | | HubUtil.PublicTask(modTask.Adapt<WcsTaskOutput>()); |
| | | var modcTaskMonitor = new WcsTaskMonitor() |
| | | { |
| | | TaskNo = modTask.TaskNo, |
| | |
| | | // 插入交互日志 |
| | | _db.Insertable(modcTaskMonitor).ExecuteCommand(); |
| | | //下发任务日志 |
| | | _taskLogHubContext.Clients.All.PublicTaskMonitor(modcTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | HubUtil.PublicTaskMonitor(modcTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | |
| | | // 此处添加不空跑业务 |
| | | } |
| | |
| | | break; |
| | | modTask.Status = TaskStatusEnum.Exception; |
| | | _db.Updateable(modTask).UpdateColumns(s => s.Status).ExecuteCommand(); |
| | | _taskLogHubContext.Clients.All.PublicTask(modTask.Adapt<WcsTaskOutput>()); |
| | | HubUtil.PublicTask(modTask.Adapt<WcsTaskOutput>()); |
| | | Log.Information($"【堆垛机】wcs任务变更空取异常,任务号:{modTask.TaskNo}"); |
| | | var modTaskRequest = modTask.Adapt<TaskRequest>(); |
| | | HttpService httpService = new HttpService(); |
| | |
| | | modTask.IsSuccess = TaskSuccessEnum.Success; |
| | | _db.Updateable(modTask).UpdateColumns(s => s.IsSuccess).ExecuteCommand(); |
| | | //下发任务日志 |
| | | _taskLogHubContext.Clients.All.PublicTask(modTask.Adapt<WcsTaskOutput>()); |
| | | HubUtil.PublicTask(modTask.Adapt<WcsTaskOutput>()); |
| | | } |
| | | else |
| | | { |
| | |
| | | modTask.IsSuccess = TaskSuccessEnum.Fail; |
| | | modTask.Information = modResponseTask.Message; |
| | | _db.Updateable(modTask).UpdateColumns(s => new { s.IsSuccess, s.Information }).ExecuteCommand(); |
| | | _taskLogHubContext.Clients.All.PublicTask(modTask.Adapt<WcsTaskOutput>()); |
| | | HubUtil.PublicTask(modTask.Adapt<WcsTaskOutput>()); |
| | | } |
| | | } |
| | | break; |
| | |
| | | } |
| | | modTask.Status = TaskStatusEnum.Exception; |
| | | _db.Updateable(modTask).UpdateColumns(s => s.Status).ExecuteCommand(); |
| | | _taskLogHubContext.Clients.All.PublicTask(modTask.Adapt<WcsTaskOutput>()); |
| | | HubUtil.PublicTask(modTask.Adapt<WcsTaskOutput>()); |
| | | Log.Information($"【堆垛机】wcs任务变更满取异常,任务号:{modTask.TaskNo}"); |
| | | var modTaskRequest = modTask.Adapt<TaskRequest>(); |
| | | HttpService httpService = new HttpService(); |
| | |
| | | // 插入交互日志 |
| | | _db.Insertable(modcTaskMonitor).ExecuteCommand(); |
| | | //下发任务日志 |
| | | _taskLogHubContext.Clients.All.PublicTaskMonitor(modcTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | HubUtil.PublicTaskMonitor(modcTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | } |
| | | |
| | | } |
| | |
| | | _db.Insertable(modInsertTaskMonitor).ExecuteCommand(); |
| | | |
| | | // 通知任务界面任务已存在更新 请更新界面 |
| | | if (PLCTaskAction.boRefresh) |
| | | { |
| | | _taskLogHubContext.Clients.All.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | } |
| | | HubUtil.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | // led更新内容 |
| | | //DataRow ConveyorsRow10 = PlcInfoDt.Select($"Level = '2' and StationNum = '{EndLocat}'")[0]; |
| | | //LedDisplay(ConveyorsRow10["LedIP"].ToString(), "工位:" + EndLocat, "出库中 " + $"储位地址:{StartLocat}", "托盘号:" + PalletNo); |
| | |
| | | _db.Insertable(modInsertTaskMonitor).ExecuteCommand(); |
| | | |
| | | // 通知任务界面任务已存在更新 请更新界面 |
| | | if (PLCTaskAction.boRefresh) |
| | | { |
| | | _taskLogHubContext.Clients.All.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | } |
| | | HubUtil.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | |
| | | // led更新内容 |
| | | //LedDisplay(modDevice.LedIP, "工位:" + modTask.EndLocate, "出库中 " + $"储位地址:{modTask.StartLocate}", "托盘号:" + modTask.PalletNo); |
| | |
| | | _db.Insertable(modInsertTaskMonitor).ExecuteCommand(); |
| | | |
| | | // 通知任务界面任务已存在更新 请更新界面 |
| | | if (PLCTaskAction.boRefresh) |
| | | { |
| | | _taskLogHubContext.Clients.All.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | } |
| | | HubUtil.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | // led更新内容 |
| | | //DataRow ConveyorsRow10 = PlcInfoDt.Select($"Level = '2' and StationNum = '{EndLocat}'")[0]; |
| | | //LedDisplay(ConveyorsRow10["LedIP"].ToString(), "工位:" + EndLocat, "出库中 " + $"储位地址:{StartLocat}", "托盘号:" + PalletNo); |
| | |
| | | // 插入交互日志 |
| | | _db.Insertable(modInsertTaskMonitor).ExecuteCommand(); |
| | | //下发任务日志 |
| | | _taskLogHubContext.Clients.All.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | HubUtil.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | break; |
| | | |
| | | } |
| | |
| | | // 插入交互日志 |
| | | _db.Insertable(modInsertTaskMonitor).ExecuteCommand(); |
| | | if (PLCTaskAction.boRefresh) |
| | | { //下发任务日志 |
| | | _taskLogHubContext.Clients.All.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | { |
| | | //下发任务日志 |
| | | HubUtil.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | } |
| | | |
| | | } |
| | |
| | | _db.Insertable(modInsertTaskMonitor).ExecuteCommand(); |
| | | |
| | | // 通知任务界面任务已存在更新 请更新界面 |
| | | if (PLCTaskAction.boRefresh) |
| | | { |
| | | _taskLogHubContext.Clients.All.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | } |
| | | HubUtil.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | |
| | | // led更新内容 |
| | | //DataRow ConveyorsRow10 = PlcInfoDt.Select($"Level = '2' and StationNum = '{EndLocat}'")[0]; |
| | |
| | | _db.Insertable(modInsertTaskMonitor).ExecuteCommand(); |
| | | |
| | | // 通知任务界面任务已存在更新 请更新界面 |
| | | if (PLCTaskAction.boRefresh) |
| | | { |
| | | _taskLogHubContext.Clients.All.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | } |
| | | HubUtil.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>()); |
| | | // led更新内容 |
| | | //DataRow ConveyorsRow10 = PlcInfoDt.Select($"Level = '2' and StationNum = '{EndLocat}'")[0]; |
| | | //LedDisplay(ConveyorsRow10["LedIP"].ToString(), "工位:" + EndLocat, "出库中 " + $"储位地址:{StartLocat}", "托盘号:" + PalletNo); |