From a4e1e9fbea03e50f38f5c19d417f04038e082fd0 Mon Sep 17 00:00:00 2001 From: gwbvipvip Date: Tue, 15 Aug 2023 15:16:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BPA.MES.Base.Application.xml | 135 ++++++++++++ .../AGVService/Dtos/AGVThirdPartyDto.cs | 200 ++++++++++++++++++ .../Services/AGVThirdPartyService.cs | 2 +- .../BPA.MES.Base.Core.csproj | 2 + backend/BPA.MES.Base.Web.Core/Startup.cs | 43 +++- 5 files changed, 380 insertions(+), 2 deletions(-) create mode 100644 backend/BPA.MES.Base.Application/Services/AGVService/Dtos/AGVThirdPartyDto.cs diff --git a/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml b/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml index 94500a3..2eb3925 100644 --- a/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml +++ b/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml @@ -1602,6 +1602,141 @@ 主键 + + + 上游系统任务号,全局唯一 + + + + + 仓库编号 + + + + + 任务快仓系统编号 + + + + + + + + + + 内部任务类型 + + + + + 数据字段 + + + + + AGV编号 + + + + + 容器编号 + + + + + 上料点位 + + + + + 上料货位编号 + + + + + 下料点位 + + + + + 下料货位编号 + + + + + 是否需要上料交互 + + + + + 点到点 + + + + + AGV编号 + + + + + 容器编号 + + + + + 上料点位 + + + + + 下料点位 + + + + + 是否需要上料交互 + + + + + 顶升完成 + + + + + 开始移动 + + + + + 放下完成 + + + + + 任务完成 + + + + + 任务取消 + + + + + 任务异常取消 + + + + + 任务异常完成 + + + + + 1) 辊筒货位到货位搬运 + + 名 称 :AGV线路管理 diff --git a/backend/BPA.MES.Base.Application/Services/AGVService/Dtos/AGVThirdPartyDto.cs b/backend/BPA.MES.Base.Application/Services/AGVService/Dtos/AGVThirdPartyDto.cs new file mode 100644 index 0000000..212d7ea --- /dev/null +++ b/backend/BPA.MES.Base.Application/Services/AGVService/Dtos/AGVThirdPartyDto.cs @@ -0,0 +1,200 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.MES.Base.Application.Services.AGVService.Dtos +{ + public class AGVThirdPartyInputBaseDto + { + /// + /// 上游系统任务号,全局唯一 + /// + public string robotJobId { get; set; } + + /// + /// 仓库编号 + /// + public long warehouseId { get; set; } + + /// + /// 任务快仓系统编号 + /// + public string jobId { get; set; } + + /// + /// + /// + public AGVState state { get; set; } + + /// + /// 内部任务类型 + /// + public jobType jobType { get; set; } + + /// + /// 数据字段 + /// + public Object jobData { get; set; } + + } + + + public class GoodsToGoods + { + /// + /// AGV编号 + /// + public string agvCode { get; set; } + + /// + /// 容器编号 + /// + public string containerCode { get; set; } + + /// + /// 上料点位 + /// + public string startPointCode { get; set; } + + /// + /// 上料货位编号 + /// + public string startSlotCode { get; set; } + + /// + /// 下料点位 + /// + public string targetPointCode { get; set; } + + /// + /// 下料货位编号 + /// + public string targetSlotCode { get; set; } + + /// + /// 是否需要上料交互 + /// + public bool loadInteractive { get; set; } + } + + /// + /// 点到点 + /// + public class PointToPoint + { + /// + /// AGV编号 + /// + public string agvCode { get; set; } + + /// + /// 容器编号 + /// + public string containerCode { get; set; } + + /// + /// 上料点位 + /// + public string startPointCode { get; set; } + + /// + /// 下料点位 + /// + public string targetPointCode { get; set; } + + /// + /// 是否需要上料交互 + /// + public bool loadInteractive { get; set; } + } + + public enum AGVState + { + + //任务状态: + //1)货架/货位/点到点货架搬运任务枚举: + //LIFT_UP_DONE:顶升完成 + //MOVE_BEGIN:开始移动 + //PUT_DOWN_DONE:放下完成 + //DONE:任务完成 + //CANCEL:任务取消 + //ABNORMAL_CANCEL:任务异常取消 + //ABNORMAL_COMPLETED:任务异常完成 + //2)货位到货位/点到点辊筒料箱搬运任务枚举: + //ROLLER_LOAD_DOING:正在上料 + //ROLLER_LOAD_FINISH:上料完成 + //ROLLER_UNLOAD_DOING:正在下料 + //DONE:下料完成 + //ABNORMAL_CANCEL:任务异常取消 + //ABNORMAL_COMPLETED:任务异常完成 + //3)AGV移动任务枚举: + //DONE:任务完成 + //CANCEL:任务取消 + //ABNORMAL_CANCEL:任务异常取消 + //ABNORMAL_COMPLETED:任务异常完成 + //4) 纯料箱任务枚举: + //MOVE_BEGIN:开始移动(仅单插臂或单夹报,2.8.1后) + //ENTER_STATION:到站 + //DONE:任务完成 + //LOAD_COMPLETED:取料完成 + //UNLOAD_COMPLETED:放料完成 + //ABNORMAL_CANCEL:任务异常取消ABNORMAL_COMPLETED:任务异常完成 + //5) 小皮带任务枚举: + //DONE:任务完成 + //6) QuickPick任务枚举: + //ENTER_STATION:到站 + //DONE:任务完成 + //CANCEL:任务取消 + //LEAVE_STATION离站 + //ROLLBACK 回滚(有其他任务,当前任务可不执行) + + + /// + /// 顶升完成 + /// + LIFT_UP_DONE = 1, + + /// + /// 开始移动 + /// + MOVE_BEGIN = 2, + + /// + /// 放下完成 + /// + PUT_DOWN_DONE = 3, + + /// + /// 任务完成 + /// + DONE = 4, + + + /// + /// 任务取消 + /// + CANCEL = 5, + + /// + /// 任务异常取消 + /// + ABNORMAL_CANCEL = 6, + + /// + /// 任务异常完成 + /// + ABNORMAL_COMPLETED = 7 + + } + + public enum jobType + { + /// + /// 1) 辊筒货位到货位搬运 + /// + SLOT_ROLLER_MOVE = 1, + } + +} diff --git a/backend/BPA.MES.Base.Application/Services/AGVService/Services/AGVThirdPartyService.cs b/backend/BPA.MES.Base.Application/Services/AGVService/Services/AGVThirdPartyService.cs index 82e1e9f..64860a3 100644 --- a/backend/BPA.MES.Base.Application/Services/AGVService/Services/AGVThirdPartyService.cs +++ b/backend/BPA.MES.Base.Application/Services/AGVService/Services/AGVThirdPartyService.cs @@ -54,6 +54,6 @@ namespace BPA.MES.Base.Application.Services.AGVService.Services return await _aGVHandler.CancelAsync(kCCancelRequest); } - + } } diff --git a/backend/BPA.MES.Base.Core/BPA.MES.Base.Core.csproj b/backend/BPA.MES.Base.Core/BPA.MES.Base.Core.csproj index 9d3d482..c91d436 100644 --- a/backend/BPA.MES.Base.Core/BPA.MES.Base.Core.csproj +++ b/backend/BPA.MES.Base.Core/BPA.MES.Base.Core.csproj @@ -14,6 +14,8 @@ + + diff --git a/backend/BPA.MES.Base.Web.Core/Startup.cs b/backend/BPA.MES.Base.Web.Core/Startup.cs index f8c14c9..ffd0aad 100644 --- a/backend/BPA.MES.Base.Web.Core/Startup.cs +++ b/backend/BPA.MES.Base.Web.Core/Startup.cs @@ -1,12 +1,21 @@ -using BPA.AGV; +using System; +using System.Threading.Tasks; +using BPA.AGV; +using BPA.ApiClient; using BPA.MES.Base.Application; using BPA.MES.Base.Application.Subscriber; using BPA.MES.Base.Core; +using BPA.MQTTClient; using Furion; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using MQTTnet.Client; +using MQTTnet.Client.Connecting; +using MQTTnet.Client.Disconnecting; +using MQTTnet.Client.Options; +using Newtonsoft.Json.Linq; using Yitter.IdGenerator; namespace BPA.MES.Base.Web.Core; @@ -15,6 +24,7 @@ public class Startup : AppStartup { public void ConfigureServices(IServiceCollection services) { + services.AddConsoleFormatter(); services.AddJwt(enableGlobalAuthorize: true); services.AddCorsAccessor(); @@ -31,6 +41,8 @@ public class Startup : AppStartup builder.AddSubscriber(typeof(ToDoEventSubscriber)); }); services.AddRemoteRequest(); + + services.AddWebApiClient(); services.AddAGV(op => { op = new AGVOptions() @@ -46,6 +58,35 @@ public class Startup : AppStartup }; }); + services.AddMqttClientHostedService(op => + { + op.Port = 1883; + op.Server = "10.2.1.21"; + op.UserName = "emqx_u_block"; + op.Password = "emqx_p_admin8765490789"; + op.mqttClientConnectedHandlerDelegate = new MqttClientConnectedHandlerDelegate(async e => + { + Console.WriteLine("MQTT连接成功"); + }); + op.mqttClientDisconnectedHandlerDelegate = new MqttClientDisconnectedHandlerDelegate(async e => + { + Console.WriteLine("MQTT断开连接"); + await Task.Delay(TimeSpan.FromSeconds(5)); + try + { + //var options = builder.Build().Services.GetService(); + //await builder.Build().Services.GetService().ConnectAsync(options); + } + catch (global::System.Exception) + { + } + }); + op.MqttApplicationMessageReceivedHandler = new MQTTnet.Client.Receiving.MqttApplicationMessageReceivedHandlerDelegate(async e => + { + + }); + }); + services.AddControllers() .AddInjectWithUnifyResult(); }