| | |
| | | /// 批次偏移量 |
| | | /// </summary> |
| | | [Required] |
| | | [SugarColumn(ColumnName = "PlcPos", ColumnDescription = "批次偏移量", Length = 10)] |
| | | [SugarColumn(ColumnName = "PosLot", ColumnDescription = "批次偏移量", Length = 10)] |
| | | public string PosLot { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 批次流程字类型 |
| | | /// </summary> |
| | | [Required] |
| | | [SugarColumn(ColumnName = "PosType", ColumnDescription = "批次流程字类型")] |
| | | [SugarColumn(ColumnName = "PosTypeLot", ColumnDescription = "批次流程字类型")] |
| | | public PLCDataTypeEnum PosTypeLot { get; set; } |
| | | |
| | | /// <summary> |
New file |
| | |
| | | using Furion.InstantMessaging; |
| | | using Microsoft.AspNetCore.SignalR; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WCS.Application.Service.WcsDevice.Dto; |
| | | |
| | | namespace WCS.Application.Hub; |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | [MapHub("/hubs/CheckTask")] |
| | | public class CheckTaskHub : Hub<ICheckTaskHub> |
| | | { |
| | | private readonly IHubContext<CheckTaskHub, ICheckTaskHub> _checkTaskHubContext; |
| | | |
| | | public CheckTaskHub(IHubContext<CheckTaskHub, ICheckTaskHub> checkTaskHubContext) |
| | | { |
| | | _checkTaskHubContext = checkTaskHubContext; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 连接 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public override async Task OnConnectedAsync() |
| | | { |
| | | await base.OnConnectedAsync(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 断开 |
| | | /// </summary> |
| | | /// <param name="exception"></param> |
| | | /// <returns></returns> |
| | | public override async Task OnDisconnectedAsync(Exception exception) |
| | | { |
| | | await base.OnDisconnectedAsync(exception); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 下发分拣任务 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public async Task PublicCheckTask(WcsDeviceTaskOrderDto context) |
| | | { |
| | | await _checkTaskHubContext.Clients.All.PublicCheckTask(context); |
| | | } |
| | | } |
| | |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WCS.Application.Hub; |
| | | using WCS.Application.Service.WcsDevice.Dto; |
| | | |
| | | namespace WCS.Application; |
| | | public static class HubUtil |
| | |
| | | private static readonly IHubContext<PlcHub, IPlcHub> _plcHubContext = App.GetService<IHubContext<PlcHub, IPlcHub>>(); |
| | | private static readonly IHubContext<PlcDeviceHub, IPlcDeviceHub> _plcDeviceHubContext = App.GetService<IHubContext<PlcDeviceHub, IPlcDeviceHub>>(); |
| | | private static readonly IHubContext<TaskLogHub, ITaskLogHub> _taskLogHubContext = App.GetService<IHubContext<TaskLogHub, ITaskLogHub>>(); |
| | | private static readonly IHubContext<CheckTaskHub, ICheckTaskHub> _checkTaskHubContext = App.GetService<IHubContext<CheckTaskHub, ICheckTaskHub>>(); |
| | | |
| | | /// <summary> |
| | | /// 下发PLC连接状态 |
| | |
| | | if (PLCTaskAction.boRefresh) |
| | | await _plcDeviceHubContext.Clients.All.PublicPlcDevice(context); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 下发分拣任务信息 |
| | | /// </summary> |
| | | /// <param name="context"></param> |
| | | /// <returns></returns> |
| | | public static async Task PublicCheckTask(WcsDeviceTaskOrderDto context) |
| | | { |
| | | if (PLCTaskAction.boRefresh) |
| | | await _checkTaskHubContext.Clients.All.PublicCheckTask(context); |
| | | } |
| | | } |
New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WCS.Application.Service.WcsDevice.Dto; |
| | | |
| | | namespace WCS.Application.Hub |
| | | { |
| | | public interface ICheckTaskHub |
| | | { |
| | | /// <summary> |
| | | /// 下发分拣任务信息 |
| | | /// </summary> |
| | | /// <param name="context"></param> |
| | | /// <returns></returns> |
| | | Task PublicCheckTask(WcsDeviceTaskOrderDto context); |
| | | } |
| | | } |
| | |
| | | |
| | | using Admin.NET.Core.Service; |
| | | using AngleSharp.Dom; |
| | | using DocumentFormat.OpenXml.Vml.Office; |
| | | using Elastic.Clients.Elasticsearch.Tasks; |
| | | using Microsoft.AspNetCore.Http; |
| | | using WCS.Application.Entity; |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 手动绑定任务到PLC |
| | | /// 手动绑定任务 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [ApiDescriptionSettings(Name = "BindTaskForPLC")] |
| | | [DisplayName("手动绑定任务到PLC")] |
| | | [DisplayName("手动绑定任务")] |
| | | public async Task BindTaskForPLC(BindTaskPLCInput input) |
| | | { |
| | | var deviceInfo = await _wcsDeviceRep.GetByIdAsync(input.deviceId); |
| | |
| | | #endregion |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 任务结批 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [ApiDescriptionSettings(Name = "CloseTaskForPLC")] |
| | | [DisplayName("任务结批")] |
| | |
| | | //更新分拣任务 |
| | | await _wcsCheckTaskRep.AsUpdateable(item).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); |
| | | } |
| | | |
| | | //Service.WcsDevice.Dto.WcsDeviceTaskOrderDto order= await _wcsDeviceRep.Context.Queryable<WcsDevice>() |
| | | // .InnerJoin<WcsPlc>((device, plc) => device.PlcId == plc.Id) |
| | | // .LeftJoin<WcsCheckTask>((device, plc, task) => device.StationNum == task.Port) |
| | | // .Where((device, plc, task) => device.PlcId == 1000 && task.Port=="") |
| | | // .Select((device, plc, task) => new Service.WcsDevice.Dto.WcsDeviceTaskOrderDto() |
| | | // { |
| | | // Id = device.Id, |
| | | // Text = device.Text, |
| | | // TaskNo = task.TaskNo, |
| | | // OrderNo = task.OrderNo, |
| | | // LotNo = task.LotNo, |
| | | // SkuNo = task.SkuNo, |
| | | // SkuName = task.SkuName, |
| | | // LineNo = task.LineNo, |
| | | // Status = task.Status, |
| | | // PZNo = task.PZNo, |
| | | // Qty = task.Qty, |
| | | |
| | | // Type = plc.Type |
| | | // }) |
| | | // .FirstAsync(); |
| | | ////下发分拣任务 |
| | | //HubUtil.PublicCheckTask(order.Adapt<Service.WcsDevice.Dto.WcsDeviceTaskOrderDto>()); |
| | | |
| | | #endregion |
| | | } |
| | | } |
| | |
| | | </template> |
| | | |
| | | <script lang="ts" setup> |
| | | import { ref } from 'vue'; |
| | | import { ref, onMounted } from 'vue'; |
| | | import { GetWcsPackPlcList,GetWcsPackStationPlcList,BindTaskForPLC,CloseTaskForPLC } from '/@/api/wcs/wcsDevice'; |
| | | import { pageWcsOderTask } from '/@/api/device/wcsOderTask'; |
| | | import { ElMessageBox,ElMessage } from 'element-plus'; |
| | | import { signalR,stopConnection } from './signalR'; |
| | | //连接signalR 监听变更 |
| | | onMounted(async () => { |
| | | signalR.off('PublicCheckTask'); |
| | | signalR.on('PublicCheckTask', (data: any) => { |
| | | //todo 需要测试 |
| | | // if (data.type == 0) { |
| | | |
| | | // } |
| | | var index = devicePointData.value.findIndex(s => s.id == data.id); |
| | | if (index !== -1) { |
| | | devicePointData.value.splice(index, 1, data); |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | //设备数据 |
| | | const deviceList=ref<any>([]); |
New file |
| | |
| | | import * as SignalR from '@microsoft/signalr'; |
| | | import { getToken } from '/@/utils/axios-utils'; |
| | | |
| | | // 初始化SignalR对象 |
| | | const connection = new SignalR.HubConnectionBuilder() |
| | | .configureLogging(SignalR.LogLevel.Information) |
| | | .withUrl(`${window.__env__.VITE_API_URL}/hubs/CheckTask?token=${getToken()}`, { transport: SignalR.HttpTransportType.WebSockets, skipNegotiation: true }) |
| | | .withAutomaticReconnect({ |
| | | nextRetryDelayInMilliseconds: () => { |
| | | return 5000; // 每5秒重连一次 |
| | | }, |
| | | }) |
| | | .build(); |
| | | |
| | | connection.keepAliveIntervalInMilliseconds = 15 * 1000; // 心跳检测15s |
| | | connection.serverTimeoutInMilliseconds = 30 * 60 * 1000; // 超时时间30m |
| | | |
| | | // 启动连接 |
| | | connection.start().then(() => { |
| | | console.log('启动连接checkTask'); |
| | | }); |
| | | // 断开连接 |
| | | connection.onclose(async () => { |
| | | console.log('断开连接checkTask'); |
| | | }); |
| | | // 重连中 |
| | | connection.onreconnecting(() => { |
| | | console.log('服务器已断线checkTask'); |
| | | }); |
| | | // 重连成功 |
| | | connection.onreconnected(() => { |
| | | console.log('重连成功checkTask'); |
| | | }); |
| | | // 关闭连接的方法 |
| | | async function stopConnection() { |
| | | try { |
| | | await connection.stop(); |
| | | console.log('连接已关闭'); |
| | | } catch (error) { |
| | | console.error('关闭连接时发生错误:', error); |
| | | } |
| | | } |
| | | // connection.on('PublicPlcConn', () => {}); |
| | | |
| | | export { connection as signalR,stopConnection }; |