From 2010caa685f79ae977939386084d0ea1871756a5 Mon Sep 17 00:00:00 2001 From: icewint Date: Thu, 14 Nov 2024 12:06:40 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=B7=BB=E5=8A=A0=E5=9B=9B=E5=90=91?= =?UTF-8?q?=E8=BD=A6=E6=8E=A5=E5=8F=A3=202=E3=80=81=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=B8=8B=E5=8F=91=E4=BB=BB=E5=8A=A1=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataEntity/AGVEntity/AGVBucketMove.cs | 83 ++++++ .../DataEntity/AGVEntity/AGVRequestLayout.cs | 63 +++++ .../DataEntity/AGVEntity/AGVResponseLayout.cs | 88 ++++++ .../DataEntity/AGVEntity/AGVTaskRequest.cs | 108 ++++++++ .../DataEntity/AGVEntity/AGVTaskResponse.cs | 29 ++ .../ContainerEntity/ContainerTaskResponse.cs | 26 ++ .../ContainerEntity/ContainerTaskResqust.cs | 53 ++++ .../AGVController/AGVController.cs | 20 ++ .../ContainerController.cs | 35 +++ .../Dto/Container/CreateInstoreTaskRequest.cs | 36 +++ .../Container/CreateInstoreTaskResoponse.cs | 50 ++++ .../Dto/Container/TaskStateNoticeRequest.cs | 52 ++++ .../Dto/Container/TaskStateNoticeResponse.cs | 30 +++ .../ContainerService/ContainerService.cs | 88 ++++++ WcsMain/Business/AGV/AGVAction.cs | 135 ++++++++++ .../CirculationTask/Stacker/ExecuteWmsTask.cs | 251 +++++++++++++++++- ...ResponseAction.cs => ApiResponseAction.cs} | 6 +- .../CommonAction/SendWmsTaskStatus.cs | 5 +- .../CommonAction/WCSTaskExecuteEvent.cs | 27 ++ WcsMain/Business/Container/ContainerAction.cs | 80 ++++++ WcsMain/Constant/ApplicationBaseConfig.cs | 14 + WcsMain/DataBase/Dao/AppLiftInfoDao.cs | 39 +++ WcsMain/DataBase/MixDao/TaskDao.cs | 24 ++ WcsMain/DataBase/TableEntity/AppLiftInfo.cs | 46 ++++ WcsMain/Enum/Stacker/WmsTaskStatusEnum.cs | 4 + WcsMain/Enum/Stacker/WmsTaskTypeEnum.cs | 3 +- .../StackerConvey/StackerConveyOperation.cs | 31 ++- WcsMain/Plugins/AGVWebApiPost.cs | 22 ++ WcsMain/Plugins/ContainerWebApiPost.cs | 20 ++ WcsMain/Plugins/WmsWebApiPost.cs | 4 +- WcsMain/WcsMain.csproj | 2 +- WcsMain/appsettings.json | 2 +- 32 files changed, 1462 insertions(+), 14 deletions(-) create mode 100644 WcsMain/ApiClient/DataEntity/AGVEntity/AGVBucketMove.cs create mode 100644 WcsMain/ApiClient/DataEntity/AGVEntity/AGVRequestLayout.cs create mode 100644 WcsMain/ApiClient/DataEntity/AGVEntity/AGVResponseLayout.cs create mode 100644 WcsMain/ApiClient/DataEntity/AGVEntity/AGVTaskRequest.cs create mode 100644 WcsMain/ApiClient/DataEntity/AGVEntity/AGVTaskResponse.cs create mode 100644 WcsMain/ApiClient/DataEntity/ContainerEntity/ContainerTaskResponse.cs create mode 100644 WcsMain/ApiClient/DataEntity/ContainerEntity/ContainerTaskResqust.cs create mode 100644 WcsMain/ApiServe/Controllers/AGVController/AGVController.cs create mode 100644 WcsMain/ApiServe/Controllers/ContainerController/ContainerController.cs create mode 100644 WcsMain/ApiServe/Controllers/Dto/Container/CreateInstoreTaskRequest.cs create mode 100644 WcsMain/ApiServe/Controllers/Dto/Container/CreateInstoreTaskResoponse.cs create mode 100644 WcsMain/ApiServe/Controllers/Dto/Container/TaskStateNoticeRequest.cs create mode 100644 WcsMain/ApiServe/Controllers/Dto/Container/TaskStateNoticeResponse.cs create mode 100644 WcsMain/ApiServe/Service/ContainerService/ContainerService.cs create mode 100644 WcsMain/Business/AGV/AGVAction.cs rename WcsMain/Business/CommonAction/{WMSApiResponseAction.cs => ApiResponseAction.cs} (88%) create mode 100644 WcsMain/Business/Container/ContainerAction.cs create mode 100644 WcsMain/Constant/ApplicationBaseConfig.cs create mode 100644 WcsMain/DataBase/Dao/AppLiftInfoDao.cs create mode 100644 WcsMain/DataBase/TableEntity/AppLiftInfo.cs create mode 100644 WcsMain/Plugins/AGVWebApiPost.cs create mode 100644 WcsMain/Plugins/ContainerWebApiPost.cs diff --git a/WcsMain/ApiClient/DataEntity/AGVEntity/AGVBucketMove.cs b/WcsMain/ApiClient/DataEntity/AGVEntity/AGVBucketMove.cs new file mode 100644 index 0000000..bfe7d0a --- /dev/null +++ b/WcsMain/ApiClient/DataEntity/AGVEntity/AGVBucketMove.cs @@ -0,0 +1,83 @@ +using Newtonsoft.Json; + +namespace WcsMain.ApiClient.DataEntity.AGVEntity; + +/// +/// AGV 点对点货架搬运 +/// +public class AGVBucketMove +{ + /// + /// 起始点 + /// + [JsonProperty("startPoint")] + public string? StartPoint { get; set; } + + /// + /// 起始点简码 + /// + [JsonProperty("startPointName")] + public string? StartPointName { get; set; } + + /// + /// 作业面 + /// + [JsonProperty("workFaces")] + public string? WorkFaces { get; set; } + + /// + /// 目标区域 + /// + [JsonProperty("endArea")] + public string? EndArea { get; set; } + + /// + /// 目标点 + /// + [JsonProperty("endPoint")] + public string? EndPoint { get; set; } + + /// + /// 目标点简码 + /// + [JsonProperty("endPointName")] + public string? EndPointName { get; set; } + + /// + /// 货架类型编码 + /// + [JsonProperty("buckTypeCode")] + public string? BucketTypeCode { get; set; } + + /// + /// + /// + [JsonProperty("letDownFlag")] + public int? LetDownFlag { get; set; } + + /// + /// 是否需要检验货架 + /// + [JsonProperty("checkCode")] + public int? CheckCode { get; set; } + + /// + /// 实操反馈后是否需要返库 + /// + [JsonProperty("needReset")] + public bool? NeedReset { get; set; } + + /// + /// 是否需要货架出厂 + /// + [JsonProperty("needOut")] + public int? NeedOut { get; set; } + + /// + /// 是否AGV接力模式 + /// + [JsonProperty("isAgvRelay")] + public bool? IsAgvRelay { get; set; } + + +} diff --git a/WcsMain/ApiClient/DataEntity/AGVEntity/AGVRequestLayout.cs b/WcsMain/ApiClient/DataEntity/AGVEntity/AGVRequestLayout.cs new file mode 100644 index 0000000..d73ee3c --- /dev/null +++ b/WcsMain/ApiClient/DataEntity/AGVEntity/AGVRequestLayout.cs @@ -0,0 +1,63 @@ +using Newtonsoft.Json; + +namespace WcsMain.ApiClient.DataEntity.AGVEntity; + +/// +/// AGV 接口请求数据格式 +/// +/// +public class AGVRequestLayout where T : class, new() +{ + /// + /// 头部 + /// + [JsonProperty("header")] + public AGVRequestHeader? Header { get; set; } + + /// + /// 数据 + /// + [JsonProperty("body")] + public T? Body { get; set; } + + +} + +/// +/// AGV 报文请求头 +/// +public class AGVRequestHeader +{ + /// + /// 快仓唯一标识 + /// + [JsonProperty("appKey")] + public string? AppKey { get; set; } + + /// + /// 应用密钥 + /// + [JsonProperty("appSecret")] + public string? AppSecret { get; set; } + + /// + /// 请求ID + /// + [JsonProperty("requestId")] + public string? RequestId { get; set; } + + /// + /// 时间戳 + /// + [JsonProperty("timestamp")] + public string? TimeStamp { get; set; } + + /// + /// 版本号 + /// + [JsonProperty("version")] + public string? version { get; set; } + + + +} diff --git a/WcsMain/ApiClient/DataEntity/AGVEntity/AGVResponseLayout.cs b/WcsMain/ApiClient/DataEntity/AGVEntity/AGVResponseLayout.cs new file mode 100644 index 0000000..39dcb41 --- /dev/null +++ b/WcsMain/ApiClient/DataEntity/AGVEntity/AGVResponseLayout.cs @@ -0,0 +1,88 @@ +using Newtonsoft.Json; + +namespace WcsMain.ApiClient.DataEntity.AGVEntity; + +/// +/// AGV 接口响应数据模板类 +/// +/// +public class AGVResponseLayout where T : class, new() +{ + + /// + /// 头部 + /// + [JsonProperty("header")] + public AGVResponseHeader? Header { get; set; } + + /// + /// 数据 + /// + [JsonProperty("body")] + public AGVResponseBody? Body { get; set; } + + + +} + +/// +/// AGV 报文响应头 +/// +public class AGVResponseHeader +{ + /// + /// 请求ID + /// + [JsonProperty("requestId")] + public string? RequestId { get; set; } + + /// + /// 时间戳 + /// + [JsonProperty("timestamp")] + public string? TimeStamp { get; set; } + + /// + /// 版本号 + /// + [JsonProperty("version")] + public string? version { get; set; } + + + +} + +/// +/// AGV 响应体 +/// +/// +public class AGVResponseBody where T : class, new() +{ + /// + /// 是否成功 + /// + [JsonProperty("success")] + public bool? Success { get; set; } + + /// + /// 条码 + /// + [JsonProperty("code")] + public string? Code { get; set; } + + /// + /// 响应信息 + /// + [JsonProperty("message")] + public string? Message { get; set; } + + /// + /// 响应数据 + /// + [JsonProperty("data")] + public T? Data { get; set; } + + + +} + diff --git a/WcsMain/ApiClient/DataEntity/AGVEntity/AGVTaskRequest.cs b/WcsMain/ApiClient/DataEntity/AGVEntity/AGVTaskRequest.cs new file mode 100644 index 0000000..1db12be --- /dev/null +++ b/WcsMain/ApiClient/DataEntity/AGVEntity/AGVTaskRequest.cs @@ -0,0 +1,108 @@ +using Newtonsoft.Json; + +namespace WcsMain.ApiClient.DataEntity.AGVEntity; + +/// +/// 向 AGV 发送任务模板数据 +/// +public class AGVTaskRequest where T : class, new() +{ + /// + /// 上游任务号,唯一标识 + /// + [JsonProperty("robotJobId")] + public string? RobotJobId { get; set; } + + /// + /// 仓库编号 + /// + [JsonProperty("warehouseId")] + public long? WareHouseId { get; set; } + + /// + /// 任务组号 + /// + [JsonProperty("robotJobGroupId")] + public string? RobotJobGroupId { get; set; } + + /// + /// 任务组序号 + /// + [JsonProperty("sequence")] + public int? Sequence { get; set; } + + /// + /// 任务组数量 + /// + [JsonProperty("robotJobGroupNum")] + public int? RobotJobGroupNum { get; set; } + + /// + /// 任务优先级 + /// + [JsonProperty("jobPriority")] + public int? JobPriority { get; set; } + + /// + /// 任务优先级类型 + /// + [JsonProperty("jobProorytyType")] + public int? JobProorytyType { get; set; } + + /// + /// 截至时间 + /// + [JsonProperty("deadline")] + public string? Deadline { get; set; } + + /// + /// 任务类型 + /// + [JsonProperty("agvType")] + public string? AGVType { get; set; } + + /// + /// AGV 放下对象后移动的地点 + /// + [JsonProperty("agvEndPoint")] + public string? AGVEndPoint { get; set; } + + /// + /// 是否需要实操 + /// + [JsonProperty("needOperation")] + public bool? NeedOperation { get; set; } + + /// + /// 机器人编号 + /// + [JsonProperty("agvCode")] + public string? AGVCode { get; set; } + + /// + /// 任务解锁倒计时 + /// + [JsonProperty("taskCountDown")] + public int? TaskCountDown { get; set; } + + /// + /// 业务类型 + /// + [JsonProperty("businessType")] + public string? BusinessType { get; set; } + + /// + /// 任务类型 + /// + [JsonProperty("jobType")] + public string? JobType { get; set; } + + /// + /// 任务数据 + /// + [JsonProperty("jobData")] + public T? JobData { get; set; } + + + +} diff --git a/WcsMain/ApiClient/DataEntity/AGVEntity/AGVTaskResponse.cs b/WcsMain/ApiClient/DataEntity/AGVEntity/AGVTaskResponse.cs new file mode 100644 index 0000000..4955f57 --- /dev/null +++ b/WcsMain/ApiClient/DataEntity/AGVEntity/AGVTaskResponse.cs @@ -0,0 +1,29 @@ +using Newtonsoft.Json; + +namespace WcsMain.ApiClient.DataEntity.AGVEntity; + +/// +/// 给AGV发送任务的返回类 +/// +public class AGVTaskResponse +{ + /// + /// 响应码 + /// + [JsonProperty("code")] + public string? Code { get; set; } + + /// + /// 响应信息 + /// + [JsonProperty("message")] + public string? Message { get; set; } + + /// + /// 任务号 + /// + [JsonProperty("robotJobId")] + public string? RobotJobId { get; set; } + + +} diff --git a/WcsMain/ApiClient/DataEntity/ContainerEntity/ContainerTaskResponse.cs b/WcsMain/ApiClient/DataEntity/ContainerEntity/ContainerTaskResponse.cs new file mode 100644 index 0000000..2dcd439 --- /dev/null +++ b/WcsMain/ApiClient/DataEntity/ContainerEntity/ContainerTaskResponse.cs @@ -0,0 +1,26 @@ +namespace WcsMain.ApiClient.DataEntity.ContainerEntity; + +/// +/// 四向车库的响应 +/// +public class ContainerTaskResponse +{ + /// + /// 响应码 + /// + public string? Code { get; set; } + + /// + /// WMS 任务号 + /// + public string? WmsTaskId { get; set; } + + /// + /// 信息 + /// + public string? Message { get; set; } + + + + +} diff --git a/WcsMain/ApiClient/DataEntity/ContainerEntity/ContainerTaskResqust.cs b/WcsMain/ApiClient/DataEntity/ContainerEntity/ContainerTaskResqust.cs new file mode 100644 index 0000000..2c41a25 --- /dev/null +++ b/WcsMain/ApiClient/DataEntity/ContainerEntity/ContainerTaskResqust.cs @@ -0,0 +1,53 @@ +namespace WcsMain.ApiClient.DataEntity.ContainerEntity; + +/// +/// 四向车库出库移库请求 +/// +public class ContainerTaskResqust +{ + /// + /// 请求ID + /// + public string? RequestId { get; set; } + + /// + /// 密钥 + /// + public string? Key { get; set; } + + /// + /// WMS 任务号 + /// + public string? WmsTaskId { get; set; } + + /// + /// 载具号 + /// + public string? PalletNo { get; set; } + + /// + /// 起始位置 + /// + public string? FromCellNo { get; set; } + + /// + /// 目标位置 + /// + public string? ToCell { get; set; } + + /// + /// 任务类型 + /// + /// + /// 2 - 出库 + /// 3 - 移库 + /// + public string? TaskType { get; set; } + + + + + + + +} diff --git a/WcsMain/ApiServe/Controllers/AGVController/AGVController.cs b/WcsMain/ApiServe/Controllers/AGVController/AGVController.cs new file mode 100644 index 0000000..c586891 --- /dev/null +++ b/WcsMain/ApiServe/Controllers/AGVController/AGVController.cs @@ -0,0 +1,20 @@ +using Microsoft.AspNetCore.Mvc; +using WcsMain.ApiServe.ControllerFilter; + +namespace WcsMain.ApiServe.Controllers.AGVController; + +/// +/// AGV接口服务 +/// +[Route("api/agv")] +[ApiController] +[ServiceFilter] +public class AGVController : ControllerBase +{ + + + + + + +} diff --git a/WcsMain/ApiServe/Controllers/ContainerController/ContainerController.cs b/WcsMain/ApiServe/Controllers/ContainerController/ContainerController.cs new file mode 100644 index 0000000..cf46017 --- /dev/null +++ b/WcsMain/ApiServe/Controllers/ContainerController/ContainerController.cs @@ -0,0 +1,35 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using WcsMain.ApiServe.ControllerFilter; +using WcsMain.ApiServe.Controllers.Dto.Container; +using WcsMain.ApiServe.Service.ContainerService; + +namespace WcsMain.ApiServe.Controllers.ContainerController; + + +/// +/// 提供给四向车的API接口 +/// +[Route("api/container")] +[ApiController] +[ServiceFilter] +public class ContainerController(ContainerService containerService) : ControllerBase +{ + + /// + /// 四向车请求入库任务 + /// + /// + /// + [HttpPost("CreateInstoreTask")] + public CreateInstoreTaskResoponse CreateInstoreTask([FromBody] CreateInstoreTaskRequest request) => containerService.CreateInstoreTask(request); + + /// + /// 四向车上报任务状态 + /// + /// + /// + [HttpPost("TaskStateNotice")] + public TaskStateNoticeResponse TaskStateNotice([FromBody] TaskStateNoticeRequest request) => containerService.TaskStateNotice(request); + +} diff --git a/WcsMain/ApiServe/Controllers/Dto/Container/CreateInstoreTaskRequest.cs b/WcsMain/ApiServe/Controllers/Dto/Container/CreateInstoreTaskRequest.cs new file mode 100644 index 0000000..10292df --- /dev/null +++ b/WcsMain/ApiServe/Controllers/Dto/Container/CreateInstoreTaskRequest.cs @@ -0,0 +1,36 @@ +using Newtonsoft.Json; +using System.Text.Json.Serialization; + +namespace WcsMain.ApiServe.Controllers.Dto.Container; + +/// +/// 四向车请求入库任务的请求类 +/// +public class CreateInstoreTaskRequest +{ + /// + /// 请求ID + /// + [JsonPropertyName("requestId")] + public string? RequestId { get; set; } + + /// + /// 密钥 + /// + [JsonPropertyName("key")] + public string? Key { get; set; } + + /// + /// 载具号 + /// + [JsonPropertyName("palletno")] + public string? PalleetNo { get; set; } + + /// + /// 请求位置 + /// + [JsonPropertyName("fromcellno")] + public string? FormCellNo { get; set; } + + +} diff --git a/WcsMain/ApiServe/Controllers/Dto/Container/CreateInstoreTaskResoponse.cs b/WcsMain/ApiServe/Controllers/Dto/Container/CreateInstoreTaskResoponse.cs new file mode 100644 index 0000000..19b954a --- /dev/null +++ b/WcsMain/ApiServe/Controllers/Dto/Container/CreateInstoreTaskResoponse.cs @@ -0,0 +1,50 @@ +using Newtonsoft.Json; +using System.Text.Json.Serialization; + +namespace WcsMain.ApiServe.Controllers.Dto.Container; + +/// +/// 四向车请求任务的返回类 +/// +public class CreateInstoreTaskResoponse +{ + /// + /// 响应码 + /// + [JsonPropertyName("code")] + public string? Code { get; set; } + + /// + /// 任务号 + /// + [JsonPropertyName("wmstaskid")] + public string? WmsTaskId { get; set; } + + /// + /// 载具号 + /// + [JsonPropertyName("palletno")] + public string? PalletNo { get; set; } + + /// + /// 起点位置 + /// + [JsonPropertyName("fromcellno")] + public string? FromCellNo { get; set; } + + /// + /// 终点位置 + /// + [JsonPropertyName("tocellno")] + public string? ToCellNo { get;set; } + + /// + /// 响应信息 + /// + [JsonPropertyName("message")] + public string? Message { get; set; } + + + + +} diff --git a/WcsMain/ApiServe/Controllers/Dto/Container/TaskStateNoticeRequest.cs b/WcsMain/ApiServe/Controllers/Dto/Container/TaskStateNoticeRequest.cs new file mode 100644 index 0000000..bec2d22 --- /dev/null +++ b/WcsMain/ApiServe/Controllers/Dto/Container/TaskStateNoticeRequest.cs @@ -0,0 +1,52 @@ +using Newtonsoft.Json; +using System.Text.Json.Serialization; + +namespace WcsMain.ApiServe.Controllers.Dto.Container; + +/// +/// 四向车任务回告请求类 +/// +public class TaskStateNoticeRequest +{ + /// + /// 请求ID + /// + [JsonPropertyName("requestid")] + public string? RequestId { get; set; } + + /// + /// 密钥 + /// + [JsonPropertyName("key")] + public string? Key { get; set; } + + /// + /// WMS任务号 + /// + [JsonPropertyName("wmstaskid")] + public string? WmsTaskId { get; set; } + + /// + /// 最终到达位置 + /// + [JsonPropertyName("factendcell")] + public string? FactendCell { get; set; } + + /// + /// 任务状态 + /// + /// + /// 20 - 完成 + /// 21 - 取消 + /// + [JsonPropertyName("taskstate")] + public string? TaskState { get; set; } + + + + + + + + +} diff --git a/WcsMain/ApiServe/Controllers/Dto/Container/TaskStateNoticeResponse.cs b/WcsMain/ApiServe/Controllers/Dto/Container/TaskStateNoticeResponse.cs new file mode 100644 index 0000000..f2f4d75 --- /dev/null +++ b/WcsMain/ApiServe/Controllers/Dto/Container/TaskStateNoticeResponse.cs @@ -0,0 +1,30 @@ +using System.Text.Json.Serialization; + +namespace WcsMain.ApiServe.Controllers.Dto.Container; + +/// +/// 四向车反馈任务状态的响应类 +/// +public class TaskStateNoticeResponse +{ + /// + /// 响应码 + /// + [JsonPropertyName("code")] + public string? Code { get; set; } + + /// + /// WMS 任务号 + /// + [JsonPropertyName("wmstaskid")] + public string? WmsTaskId { get; set; } + + /// + /// 响应信息 + /// + [JsonPropertyName("message")] + public string? Message { get; set; } + + + +} diff --git a/WcsMain/ApiServe/Service/ContainerService/ContainerService.cs b/WcsMain/ApiServe/Service/ContainerService/ContainerService.cs new file mode 100644 index 0000000..a3c0c34 --- /dev/null +++ b/WcsMain/ApiServe/Service/ContainerService/ContainerService.cs @@ -0,0 +1,88 @@ +using WcsMain.ApiClient.DataEntity.WmsEntity; +using WcsMain.ApiServe.Controllers.Dto.Container; +using WcsMain.Business.CommonAction; +using WcsMain.Common; +using WcsMain.DataBase.Dao; +using WcsMain.DataBase.TableEntity; +using WcsMain.Enum; +using WcsMain.Enum.Stacker; +using WcsMain.Plugins; +using WcsMain.WcsAttribute.AutoFacAttribute; + +namespace WcsMain.ApiServe.Service.ContainerService; + +[Service] +public class ContainerService(AppWmsTaskDao wmsTaskDao, WCSTaskExecuteEvent taskExecuteEvent) +{ + /// + /// 请求四向车任务 + /// + /// + /// + public CreateInstoreTaskResoponse CreateInstoreTask(CreateInstoreTaskRequest request) + { + ConsoleLog.Info($"四向车请求载具入库:{request.PalleetNo},入库点位:{request.FormCellNo}"); + if (string.IsNullOrEmpty(request.FormCellNo) || string.IsNullOrEmpty(request.PalleetNo)) + { + return new() { Code = "400", Message = "缺少必须参数" }; + } + List? wmsTasks = wmsTaskDao.Select(new() { VehicleNo = request.PalleetNo, TaskStatus = (int)WmsTaskStatusEnum.arriveMid })?.OrderByDescending(o => o.CreateTime).ToList(); + if(wmsTasks == null) + { + return new() { Code = "400", Message = "数据连接失败,请重试" }; + } + if(wmsTasks.Count == 0) + { + return new() { Code = "400", Message = "该载具暂无待执行的任务" }; + } + AppWmsTask wmsTask = wmsTasks.First(); + /* 更新状态为前往终点 */ + var updateResult = wmsTaskDao.Update(new() { TaskId = wmsTask.TaskId, TaskStatus = (int)WmsTaskStatusEnum.toMid, ModifyTime = DateTime.Now }); + ConsoleLog.Success($"API更新任务状态结果:{(updateResult > 0 ? "成功" : "失败")},任务号:{wmsTask.TaskId}"); + return new() + { + Code = "200", + Message = "操作成功", + WmsTaskId = wmsTask.TaskId, + PalletNo = wmsTask.VehicleNo, + FromCellNo = request.FormCellNo, + ToCellNo = wmsTask.Destination, + }; + } + + /// + /// 四向车任务反馈 + /// + /// + /// + public TaskStateNoticeResponse TaskStateNotice(TaskStateNoticeRequest request) + { + if(string.IsNullOrEmpty(request.TaskState) || string.IsNullOrEmpty(request.WmsTaskId) || string.IsNullOrEmpty(request.FactendCell)) + { + return new() { Code = "400", Message = "缺少必须的参数" }; + } + List? appWmsTasks = wmsTaskDao.Select(new() { TaskId = request.WmsTaskId }); + if(appWmsTasks == null) + { + return new() { Code = "400", Message = "数据连接异常,请稍后再试" }; + } + if (appWmsTasks.Count < 1) + { + return new() { Code = "400", Message = $"该任务号不存在:{request.WmsTaskId}" }; + } + AppWmsTask wmsTask = appWmsTasks.First(); + if (wmsTask.TaskType == (int)WmsTaskTypeEnum.inTask || wmsTask.TaskType == (int)WmsTaskTypeEnum.moveTask) + { + /* 入库/移库 完成需要反馈WMS任务完成,更新任务状态为完成 */ + string? errText = taskExecuteEvent.CompleteTaskEvent(wmsTask, "四向车上报完成", request.FactendCell); + return new() { Code = string.IsNullOrEmpty(errText) ? "200" : "400", Message = string.IsNullOrEmpty(errText) ? "成功" : errText, WmsTaskId = request.WmsTaskId }; + } + if(wmsTask.TaskType == (int)WmsTaskTypeEnum.outTask) + { + /* 更新任务状态为到达中间点 */ + int updateResult = wmsTaskDao.Update(new() { TaskId = wmsTask.TaskId, TaskStatus = (int)WmsTaskStatusEnum.arriveMid, ModifyTime = DateTime.Now }); + return new() { Code = updateResult > 0 ? "200" : "400", Message = updateResult > 0 ? "成功" : "数据异常", WmsTaskId = request.WmsTaskId }; + } + return new() { Code = "400", Message = $"该任务不支持的类型:{request.WmsTaskId}" }; + } +} diff --git a/WcsMain/Business/AGV/AGVAction.cs b/WcsMain/Business/AGV/AGVAction.cs new file mode 100644 index 0000000..7622c31 --- /dev/null +++ b/WcsMain/Business/AGV/AGVAction.cs @@ -0,0 +1,135 @@ +using WcsMain.ApiClient.DataEntity.AGVEntity; +using WcsMain.Common; +using WcsMain.Constant; +using WcsMain.DataBase.TableEntity; +using WcsMain.Plugins; +using WcsMain.ExtendMethod; +using WcsMain.WcsAttribute.AutoFacAttribute; + +namespace WcsMain.Business.AGV; + +/// +/// AGV 动作 +/// +[Component] +public class AGVAction(AGVWebApiPost webApiPost) +{ + + /// + /// 发送点对点搬运的任务 + /// + /// + /// + public string Send_NO_VERIFY_BUCKET_MOVE(AppWmsTask wmsTask) + { + AGVRequestLayout> request = new() + { + Header = new() + { + AppKey = ApplicationBaseConfig.APP_KEY, + AppSecret = ApplicationBaseConfig.APP_SECRET, + RequestId = wmsTask.TaskId, + TimeStamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), + version = "2.9" + }, + Body = new() + { + RobotJobId = wmsTask.TaskId, + WareHouseId = 100, + RobotJobGroupId = wmsTask.TaskId, + Sequence = 1, + RobotJobGroupNum = 1, + JobPriority = 1, + JobProorytyType = 0, + JobType = "NO_VERIFY_BUCKET_MOVE", + JobData = new() + { + StartPoint = wmsTask.Origin, + StartPointName = null, + WorkFaces = "0", + EndArea = wmsTask.Destination, + EndPoint = wmsTask.Destination, + EndPointName = null, + BucketTypeCode = "00", + LetDownFlag = 2, + } + } + }; + var response = webApiPost.HttpPost>, AGVResponseLayout>(request, CommonData.AppApiBaseInfos.GetAddress("AGV_NO_VERIFY_BUCKET_MOVE") ?? ""); + var responseData = response.ResponseEntity; + if (!response.IsSend || responseData == null) + { + return "请求失败,网络故障"; + } + + if (responseData.Body!.Success == true && responseData.Body!.Code?.ToLower() == "success") + { + // 发送成功 + return string.Empty; + } + return responseData.Body.Message ?? "请求失败,未知原因"; + } + + /// + /// 发送AGV任务 + /// + /// + /// + /// + /// + public string Send_AGV_TASK(string? taskId, string? origin, string? destination) + { + AGVRequestLayout> request = new() + { + Header = new() + { + AppKey = ApplicationBaseConfig.APP_KEY, + AppSecret = ApplicationBaseConfig.APP_SECRET, + RequestId = taskId, + TimeStamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), + version = "2.9" + }, + Body = new() + { + RobotJobId = taskId, + WareHouseId = 100, + RobotJobGroupId = taskId, + Sequence = 1, + RobotJobGroupNum = 1, + JobPriority = 1, + JobProorytyType = 0, + JobType = "NO_VERIFY_BUCKET_MOVE", + JobData = new() + { + StartPoint = origin, + StartPointName = null, + WorkFaces = "0", + EndArea = destination, + EndPoint = destination, + EndPointName = null, + BucketTypeCode = "00", + LetDownFlag = 2, + } + } + }; + var response = webApiPost.HttpPost>, AGVResponseLayout>(request, CommonData.AppApiBaseInfos.GetAddress("AGV_NO_VERIFY_BUCKET_MOVE") ?? ""); + var responseData = response.ResponseEntity; + if (!response.IsSend || responseData == null) + { + return "请求失败,网络故障"; + } + + if (responseData.Body!.Success == true && responseData.Body!.Code?.ToLower() == "success") + { + // 发送成功 + return string.Empty; + } + return responseData.Body.Message ?? "请求失败,未知原因"; + } + + + + + + +} diff --git a/WcsMain/Business/CirculationTask/Stacker/ExecuteWmsTask.cs b/WcsMain/Business/CirculationTask/Stacker/ExecuteWmsTask.cs index 2f8a7e3..a61efed 100644 --- a/WcsMain/Business/CirculationTask/Stacker/ExecuteWmsTask.cs +++ b/WcsMain/Business/CirculationTask/Stacker/ExecuteWmsTask.cs @@ -1,9 +1,254 @@ -namespace WcsMain.Business.CirculationTask.Stacker; +using CirculateTool.Attribute; +using WcsMain.ApiClient.DataEntity.AGVEntity; +using WcsMain.Business.AGV; +using WcsMain.Business.CommonAction; +using WcsMain.Business.Container; +using WcsMain.Constant; +using WcsMain.DataBase.Dao; +using WcsMain.DataBase.TableEntity; +using WcsMain.Enum.General; +using WcsMain.Enum.Stacker; +using WcsMain.EquipOperation.StackerConvey; + +namespace WcsMain.Business.CirculationTask.Stacker; /// -/// 执行立体仓库任务 +/// 执行仓库任务 /// -public class ExecuteWmsTask +[Circulation] +public class ExecuteWmsTask(AppWmsTaskDao wmsTaskDao, StackerConveyOperation stackerConveyOperation, AGVAction agvAction, ContainerAction containerAction, AppLiftInfoDao liftInfoDao) { + /// + /// 开始执行任务 + /// + /// + [Circulation("执行任务", 1000)] + public bool ExecuteWmsTaskStarter() + { + /* 执行任务列表任务 */ + List? wmsTasks = wmsTaskDao.Select(new AppWmsTask() { TaskStatus = (int)WmsTaskStatusEnum.create }); + if(wmsTasks == default) + { + ConsoleLog.Error("【异常】解析Wms任务时拉取任务列表失败,与数据库连接中断"); + Thread.Sleep(5000); + return true; + } + wmsTasks.ForEach(ExecuteTask); + /* 出库站台发送AGV接续任务 */ + ExecuteAGVOutTask(); + return true; + } + + /// + /// 执行对应的任务 + /// + /// + private void ExecuteTask(AppWmsTask wmsTask) + { + switch (wmsTask.TaskType) + { + case (int)WmsTaskTypeEnum.agv: // AGV 点对点搬运 + ExecuteAGVTask(wmsTask); + break; + case (int)WmsTaskTypeEnum.outTask: + ExecuteOutTask(wmsTask); + break; + case (int)WmsTaskTypeEnum.inTask: + ExecuteInTask(wmsTask); + break; + case (int)WmsTaskTypeEnum.moveTask: + ExecuteMoveTask(wmsTask); + break; + default: + break; + } + } + + /// + /// 执行 AGV 任务 + /// + /// + private void ExecuteAGVTask(AppWmsTask wmsTask) + { + string errText = agvAction.Send_NO_VERIFY_BUCKET_MOVE(wmsTask); + if(!string.IsNullOrEmpty(errText)) + { + ConsoleLog.Warning($"【警告】AGV点对点搬运请求AGV服务失败,任务号:{wmsTask.TaskId},异常信息:{errText}"); + return; + } + ConsoleLog.Success($"AGV点对点搬运请求AGV服务成功,任务号:{wmsTask.TaskId}"); + /* 更新任务状态为执行中 */ + var updateResult = wmsTaskDao.Update(new() { TaskId = wmsTask.TaskId, TaskStatus = (int)WmsTaskStatusEnum.running, ModifyTime = DateTime.Now }); + ConsoleLog.Success($"更新任务状态结果:{(updateResult > 0 ? "成功" : "失败")},任务号:{wmsTask.TaskId}"); + } + + + /// + /// 执行入库任务 + /// + /// + private void ExecuteInTask(AppWmsTask wmsTask) + { + string? midPoint = GetEmptyInLift(wmsTask.Destination); + if (string.IsNullOrEmpty(midPoint)) return; // 没有可用的站台 + /* 发送AGV 搬运任务 */ + string errText = agvAction.Send_AGV_TASK(wmsTask.TaskId, wmsTask.Origin, midPoint); + if (!string.IsNullOrEmpty(errText)) + { + ConsoleLog.Warning($"【警告】入库请求AGV搬运失败,任务号:{wmsTask.TaskId},异常信息:{errText}"); + return; + } + ConsoleLog.Success($"入库搬运请求AGV成功,任务号:{wmsTask.TaskId}"); + /* 更新任务状态为前往中间点,更新中间点 */ + var updateResult = wmsTaskDao.Update(new() { TaskId = wmsTask.TaskId, MidPoint = midPoint, TaskStatus = (int)WmsTaskStatusEnum.toMid, ModifyTime = DateTime.Now }); + ConsoleLog.Success($"更新任务状态结果:{(updateResult > 0 ? "成功" : "失败")},任务号:{wmsTask.TaskId}"); + /* 四向车任务有接口返回给四向车 */ + } + + /// + /// 执行出库任务 + /// + /// + private void ExecuteOutTask(AppWmsTask wmsTask) + { + string? midPoint = GetEmptyOutLift(wmsTask.Origin); + if(string.IsNullOrEmpty(midPoint)) return; // 没有可用站台 + /* 发送四向车搬运任务 */ + string? errText = containerAction.ExecuteOutTask(wmsTask.TaskId, wmsTask.Origin, midPoint, wmsTask.VehicleNo); + if (!string.IsNullOrEmpty(errText)) + { + ConsoleLog.Warning($"【警告】入库请求四向车搬运失败,任务号:{wmsTask.TaskId},异常信息:{errText}"); + return; + } + ConsoleLog.Success($"入库搬运请求四向车成功,任务号:{wmsTask.TaskId}"); + /* 更新任务状态为前往中间点,更新中间点 */ + var updateResult = wmsTaskDao.Update(new() { TaskId = wmsTask.TaskId, MidPoint = midPoint, TaskStatus = (int)WmsTaskStatusEnum.toMid, ModifyTime = DateTime.Now }); + ConsoleLog.Success($"更新任务状态结果:{(updateResult > 0 ? "成功" : "失败")},任务号:{wmsTask.TaskId}"); + /* AGV接续任务由定时器触发 */ + } + + + /// + /// 执行 四向车库移库任务 + /// + /// + private void ExecuteMoveTask(AppWmsTask wmsTask) + { + string errText = containerAction.ExecuteMoveTask(wmsTask); + if (!string.IsNullOrEmpty(errText)) + { + ConsoleLog.Warning($"四向车移库任务请求四向车服务失败,任务号:{wmsTask.TaskId},异常信息:{errText}"); + return; + } + ConsoleLog.Success($"四向车移库任务请求四向车服务成功,任务号:{wmsTask.TaskId}"); + /* 更新任务状态为执行中 */ + var updateResult = wmsTaskDao.Update(new() { TaskId = wmsTask.TaskId, TaskStatus = (int)WmsTaskStatusEnum.running, ModifyTime = DateTime.Now }); + ConsoleLog.Success($"更新任务状态结果:{(updateResult > 0 ? "成功" : "失败")},任务号:{wmsTask.TaskId}"); + } + + + /// + /// 执行AGV出库任务 + /// + private void ExecuteAGVOutTask() + { + List? liftInfos = liftInfoDao.Query(new() { Status = (int)TrueFalseEnum.TRUE }); + if (liftInfos == default || liftInfos.Count < 1) return; + foreach (var liftInfo in liftInfos) + { + (string errText, short model, short allowAction, short errCode, string code) = stackerConveyOperation.GetLiftInfo(liftInfo.LiftId ?? ""); + if (!string.IsNullOrEmpty(errText)) + { + ConsoleLog.Warning($"【警告】提升机站台信息获取失败,异常信息:{errText}"); + continue; + } + if (model != 2 || allowAction != (short)TrueFalseEnum.TRUE || errCode != 0) continue; // 不满足执行条件 + /* 查找出库任务 */ + List? tasks = wmsTaskDao.Select(new() { VehicleNo = code, TaskStatus = (int)WmsTaskStatusEnum.arriveMid })?.OrderByDescending(o => o.CreateTime).ToList(); + if(tasks == null || tasks.Count == 0) continue; + var task = tasks.First(); + /* 下发任务 */ + string agvErrText = agvAction.Send_AGV_TASK(task.TaskId, task.MidPoint, task.Destination); + if (!string.IsNullOrEmpty(agvErrText)) + { + ConsoleLog.Warning($"【警告】AGV出库任务请求AGV服务失败,任务号:{task.TaskId},异常信息:{agvErrText}"); + return; + } + /* 更新任务状态为前往终点 */ + var updateResult = wmsTaskDao.Update(new() { TaskId = task.TaskId, TaskStatus = (int)WmsTaskStatusEnum.toDestination, ModifyTime = DateTime.Now }); + ConsoleLog.Success($"更新任务状态结果:{(updateResult > 0 ? "成功" : "失败")},任务号:{task.TaskId}"); + } + } + + + + + /// + /// 获取一个空闲的入库站台 + /// + /// + /// + private string? GetEmptyInLift(string? destination) + { + if (string.IsNullOrEmpty(destination)) return default; + List? liftInfos = liftInfoDao.Query(new() { Status = (int)TrueFalseEnum.TRUE }); + if (liftInfos == default || liftInfos.Count < 1) return default; + foreach (var liftInfo in liftInfos) + { + (string errText, short model, short allowAction, short errCode, string code) = stackerConveyOperation.GetLiftInfo(liftInfo.LiftId ?? ""); + if(!string.IsNullOrEmpty(errText)) + { + ConsoleLog.Warning($"【警告】提升机站台信息获取失败,异常信息:{errText}"); + continue; + } + if (model != 1 || allowAction != (short)TrueFalseEnum.TRUE || errCode != 0) continue; + /* 检验任务是否是第一层,若是不是第一层不能分配第一层出入口 */ + if (destination.StartsWith("1")) // [TODO] + { + if (liftInfo.LiftMode != 2) continue; + } + /* 获取这个站台的任务.没有占用任务即可重新使用 */ + List? tasks = wmsTaskDao.Select(new() { MidPoint = liftInfo.Tag, TaskStatus = (int)WmsTaskStatusEnum.toMid }); + if (tasks == default || tasks.Count > 0) continue; + return liftInfo.Tag; + } + return default; + } + + /// + /// 获取一个空闲的出库站台 + /// + /// + /// + private string? GetEmptyOutLift(string? origin) + { + if (string.IsNullOrEmpty(origin)) return default; + Dictionary liftTaskCount = []; + List? liftInfos = liftInfoDao.Query(new() { Status = (int)TrueFalseEnum.TRUE }); + if (liftInfos == default || liftInfos.Count < 1) return default; + foreach (var liftInfo in liftInfos) + { + (string errText, short model, short allowAction, short errCode, string code) = stackerConveyOperation.GetLiftInfo(liftInfo.LiftId ?? ""); + if (!string.IsNullOrEmpty(errText)) + { + ConsoleLog.Warning($"【警告】提升机站台信息获取失败,异常信息:{errText}"); + continue; + } + if (model != 2 || allowAction != (short)TrueFalseEnum.TRUE || errCode != 0) continue; + /* 检验任务是否是第一层,若是不是第一层不能分配第一层出入口 */ + if (origin.StartsWith("1")) // [TODO] + { + if (liftInfo.LiftMode != 2) continue; + } + /* 获取这个站台的任务.并计数 */ + List? tasks = wmsTaskDao.Select(new() { MidPoint = liftInfo.Tag, TaskStatus = (int)WmsTaskStatusEnum.toMid }); + if (tasks == default) continue; + liftTaskCount.TryAdd(liftInfo.Tag ?? "", tasks.Count); + } + var sortLiftInfos = liftTaskCount.OrderBy(o => o.Value).ToDictionary(); + if(sortLiftInfos.Count > 0) return sortLiftInfos.First().Key; + return default; + } + } diff --git a/WcsMain/Business/CommonAction/WMSApiResponseAction.cs b/WcsMain/Business/CommonAction/ApiResponseAction.cs similarity index 88% rename from WcsMain/Business/CommonAction/WMSApiResponseAction.cs rename to WcsMain/Business/CommonAction/ApiResponseAction.cs index ca15cef..96e8ee4 100644 --- a/WcsMain/Business/CommonAction/WMSApiResponseAction.cs +++ b/WcsMain/Business/CommonAction/ApiResponseAction.cs @@ -8,17 +8,17 @@ using WcsMain.WcsAttribute.AutoFacAttribute; namespace WcsMain.Business.CommonAction; /// -/// WMS 接口响应触发事件 +/// 接口响应触发事件 /// [Component] -public class WMSApiResponseAction(DataBaseData dataBaseData, AppApiRequestDao apiRequestDao) +public class ApiResponseAction(DataBaseData dataBaseData, AppApiRequestDao apiRequestDao) { /// /// 当请求其他系统时触发本方法 /// /// - public void WMSApiResponse(ApiResponseInfo responseInfo) + public void ApiResponse(ApiResponseInfo responseInfo) { try { diff --git a/WcsMain/Business/CommonAction/SendWmsTaskStatus.cs b/WcsMain/Business/CommonAction/SendWmsTaskStatus.cs index fbd8b0a..88e64b6 100644 --- a/WcsMain/Business/CommonAction/SendWmsTaskStatus.cs +++ b/WcsMain/Business/CommonAction/SendWmsTaskStatus.cs @@ -255,7 +255,8 @@ public class SendWmsTaskStatus(AppWmsTaskDao wmsTaskDao, WmsWebApiPost wmsWebApi /// /// /// - public void SendTaskComplete(string? taskId, ushort count = 5) + /// + public void SendTaskComplete(string? taskId, ushort count = 5, string? destination = default) { Task.Factory.StartNew(() => { AppWmsTask? wmsTask = default; @@ -280,7 +281,7 @@ public class SendWmsTaskStatus(AppWmsTaskDao wmsTaskDao, WmsWebApiPost wmsWebApi { TaskId = wmsTask.TaskId, TaskStatus = (int)SendWmsTaskStatusEnum.complete, - Destination = wmsTask.Destination, + Destination = destination ?? wmsTask.Destination, VehicleNo = wmsTask.VehicleNo, Message = "任务完成" }; diff --git a/WcsMain/Business/CommonAction/WCSTaskExecuteEvent.cs b/WcsMain/Business/CommonAction/WCSTaskExecuteEvent.cs index b79164d..089e8f9 100644 --- a/WcsMain/Business/CommonAction/WCSTaskExecuteEvent.cs +++ b/WcsMain/Business/CommonAction/WCSTaskExecuteEvent.cs @@ -108,6 +108,9 @@ public class WCSTaskExecuteEvent(TaskDao taskDao, SendWmsTaskStatus sendWmsTaskS } } + + + private void HandleTaskData(AppWcsTask task, string msg) { string errMsg = taskDao.ComlpeteTask(task, msg); @@ -143,5 +146,29 @@ public class WCSTaskExecuteEvent(TaskDao taskDao, SendWmsTaskStatus sendWmsTaskS #endregion + #region WMS 任务完成时触发 + + /// + /// WMS任务完成时触发 + /// + /// + /// + /// + public string? CompleteTaskEvent(AppWmsTask task, string msg, string? destination) + { + /* 更新任务信息,任务完成 */ + string? errText = taskDao.ComlpeteTask(task, msg); + if (!string.IsNullOrEmpty(errText)) + { + ConsoleLog.Warning($"【异常】任务完成更新WMS任务状态失败,异常信息:{errText}"); + } + /* 上报WMS */ + sendWmsTaskStatus.SendTaskComplete(task.TaskId, destination: destination); + return errText; + } + + + #endregion + } \ No newline at end of file diff --git a/WcsMain/Business/Container/ContainerAction.cs b/WcsMain/Business/Container/ContainerAction.cs new file mode 100644 index 0000000..0292e86 --- /dev/null +++ b/WcsMain/Business/Container/ContainerAction.cs @@ -0,0 +1,80 @@ +using WcsMain.ApiClient.DataEntity.ContainerEntity; +using WcsMain.Common; +using WcsMain.DataBase.TableEntity; +using WcsMain.Plugins; +using WcsMain.ExtendMethod; +using WcsMain.WcsAttribute.AutoFacAttribute; + +namespace WcsMain.Business.Container; + +/// +/// 四向车库 +/// +[Component] +public class ContainerAction(ContainerWebApiPost webApiPost) +{ + /// + /// 四向车库执行移库任务 + /// + /// + /// + public string ExecuteMoveTask(AppWmsTask wmsTask) + { + ContainerTaskResqust containerTaskResqust = new() + { + RequestId = Guid.NewGuid().ToString(), + Key = "", + WmsTaskId = wmsTask.TaskId, + FromCellNo = wmsTask.Origin, + TaskType = "3", + ToCell = wmsTask.Destination, + PalletNo = wmsTask.VehicleNo + }; + var response = webApiPost.HttpPost(containerTaskResqust, CommonData.AppApiBaseInfos.GetAddress("ContainerOutMoveApiAddress") ?? ""); + var responseData = response.ResponseEntity; + if(!response.IsSend || responseData == null) + { + return "请求失败,网络故障"; + } + if(responseData.Code == "200") + { + return string.Empty; + } + return responseData.Message ?? "请求失败,未知异常"; + } + + /// + /// 发送出库任务 + /// + /// + /// + /// + /// + /// + public string ExecuteOutTask(string? taskId, string? origin, string? destination, string? vehicleNo) + { + ContainerTaskResqust containerTaskResqust = new() + { + RequestId = Guid.NewGuid().ToString(), + Key = "", + WmsTaskId = taskId, + FromCellNo = origin, + TaskType = "2", + ToCell = destination, + PalletNo = vehicleNo + }; + var response = webApiPost.HttpPost(containerTaskResqust, CommonData.AppApiBaseInfos.GetAddress("ContainerOutMoveApiAddress") ?? ""); + var responseData = response.ResponseEntity; + if (!response.IsSend || responseData == null) + { + return "请求失败,网络故障"; + } + if (responseData.Code == "200") + { + return string.Empty; + } + return responseData.Message ?? "请求失败,未知异常"; + } + + +} diff --git a/WcsMain/Constant/ApplicationBaseConfig.cs b/WcsMain/Constant/ApplicationBaseConfig.cs new file mode 100644 index 0000000..30fbe02 --- /dev/null +++ b/WcsMain/Constant/ApplicationBaseConfig.cs @@ -0,0 +1,14 @@ +namespace WcsMain.Constant; + +public class ApplicationBaseConfig +{ + /// + /// AGV + /// + public const string APP_KEY = "app"; + + /// + /// AGV + /// + public const string APP_SECRET = ""; +} diff --git a/WcsMain/DataBase/Dao/AppLiftInfoDao.cs b/WcsMain/DataBase/Dao/AppLiftInfoDao.cs new file mode 100644 index 0000000..4ce79bf --- /dev/null +++ b/WcsMain/DataBase/Dao/AppLiftInfoDao.cs @@ -0,0 +1,39 @@ +using WcsMain.Common; +using WcsMain.DataBase.TableEntity; +using WcsMain.WcsAttribute.AutoFacAttribute; + +namespace WcsMain.DataBase.Dao; + +[Component] +public class AppLiftInfoDao +{ + /// + /// 查询 + /// + /// + /// + public List? Query(AppLiftInfo liftInfo) + { + try + { + var sqlFunc = CommonTool.DbServe.Queryable() + .WhereIF(liftInfo.LiftId != default, w => w.LiftId == liftInfo.LiftId) + .WhereIF(liftInfo.LiftName != default, w => w.LiftName == liftInfo.LiftName) + .WhereIF(liftInfo.LiftType != default, w => w.LiftType == liftInfo.LiftType) + .WhereIF(liftInfo.Tag != default, w => w.Tag == liftInfo.Tag) + .WhereIF(liftInfo.Status != default, w => w.Status == liftInfo.Status) + .WhereIF(liftInfo.LiftMode != default, w => w.LiftMode == liftInfo.LiftMode) + .WhereIF(liftInfo.Remark != default, w => w.Remark == liftInfo.Remark) + .OrderBy(o => o.LiftId); + return sqlFunc.ToList(); + } + catch (Exception ex) + { + _ = ex; + return null; + } + } + + + +} diff --git a/WcsMain/DataBase/MixDao/TaskDao.cs b/WcsMain/DataBase/MixDao/TaskDao.cs index 785944f..73d34f8 100644 --- a/WcsMain/DataBase/MixDao/TaskDao.cs +++ b/WcsMain/DataBase/MixDao/TaskDao.cs @@ -208,5 +208,29 @@ public class TaskDao return result.Data ? string.Empty : result.ErrorException.Message; } + /// + /// 完成任务 + /// + /// + /// + /// + public string? ComlpeteTask(AppWmsTask wmsTask, string msg) + { + try + { + var updateResult = CommonTool.DbServe + .Updateable(new AppWmsTask() + { TaskId = wmsTask.TaskId, TaskStatus = (int)WmsTaskStatusEnum.complete, EndTime = DateTime.Now, TaskMsg = msg }) + .IgnoreColumns(ignoreAllNullColumns: true) + .ExecuteCommand(); + return updateResult > 0 ? null : "失败"; + } + catch (Exception ex) + { + return ex.Message; + } + + } + } diff --git a/WcsMain/DataBase/TableEntity/AppLiftInfo.cs b/WcsMain/DataBase/TableEntity/AppLiftInfo.cs new file mode 100644 index 0000000..3700ec0 --- /dev/null +++ b/WcsMain/DataBase/TableEntity/AppLiftInfo.cs @@ -0,0 +1,46 @@ +namespace WcsMain.DataBase.TableEntity; + +/// +/// 提升机信息 +/// +public class AppLiftInfo +{ + /// + /// 提升机ID + /// + public string? LiftId { get; set; } + + /// + /// 提升机名称 + /// + public string? LiftName { get; set; } + + /// + /// 提升机类型 + /// + public string? LiftType { get; set; } + + /// + /// 标记 + /// + public string? Tag { get; set; } + + /// + /// 状态 + /// + public int? Status { get; set; } + + /// + /// 提升机模式 + /// + public int? LiftMode { get; set; } + + /// + /// 备注 + /// + public string? Remark { get; set; } + + + + +} diff --git a/WcsMain/Enum/Stacker/WmsTaskStatusEnum.cs b/WcsMain/Enum/Stacker/WmsTaskStatusEnum.cs index f900203..7396d9d 100644 --- a/WcsMain/Enum/Stacker/WmsTaskStatusEnum.cs +++ b/WcsMain/Enum/Stacker/WmsTaskStatusEnum.cs @@ -9,5 +9,9 @@ public enum WmsTaskStatusEnum queuing = 1, // 排队中 running = 2, // 执行中 complete = 3, // 执行完成 + toMid = 4, // 前往中间点 + toDestination = 5, // 前往终点 + arriveMid = 6, // 到达中间点 + arriveDestination = 7, // 到达终点 err = 9, // 执行异常 } \ No newline at end of file diff --git a/WcsMain/Enum/Stacker/WmsTaskTypeEnum.cs b/WcsMain/Enum/Stacker/WmsTaskTypeEnum.cs index ef50223..750f2d8 100644 --- a/WcsMain/Enum/Stacker/WmsTaskTypeEnum.cs +++ b/WcsMain/Enum/Stacker/WmsTaskTypeEnum.cs @@ -8,6 +8,7 @@ public enum WmsTaskTypeEnum inTask = 1, // 入库任务 outTask = 2, // 出库任务 pick = 4, // 拣选任务 - check = 10, // 盘点任务 + //check = 10, // 盘点任务 moveTask = 9, // 移库任务 + agv = 10, // 移动机器人 } diff --git a/WcsMain/EquipOperation/StackerConvey/StackerConveyOperation.cs b/WcsMain/EquipOperation/StackerConvey/StackerConveyOperation.cs index 7fbe251..b834099 100644 --- a/WcsMain/EquipOperation/StackerConvey/StackerConveyOperation.cs +++ b/WcsMain/EquipOperation/StackerConvey/StackerConveyOperation.cs @@ -1,8 +1,12 @@ -using WcsMain.Common; +using System.Text.RegularExpressions; +using System.Text; +using WcsMain.AppEntity.LED; +using WcsMain.Common; using WcsMain.Enum.Plc; using WcsMain.EquipOperation.Entity; using WcsMain.EquipOperation.Entity.StackerConvey; using WcsMain.WcsAttribute.AutoFacAttribute; +using static System.Runtime.InteropServices.JavaScript.JSType; namespace WcsMain.EquipOperation.StackerConvey; @@ -46,6 +50,31 @@ public class StackerConveyOperation return (string.Empty, stackerConveyInfo); } + /// + /// 获取提升机信息 ---- 上汽项目专用 + /// + /// + /// + public (string errText, short model, short allowAction, short errCode, string code) GetLiftInfo(string stackerConveyName) + { + if (!CommonData.IsConnectPlc || CommonTool.Siemens == default) + { + return ("设备尚未连接", 0, 0, 999, ""); // 未连接PLC + } + var readResult = CommonTool.Siemens.ReadByteWithName($"提升机信息{stackerConveyName}", 36); + if (!readResult.Success || readResult.Value == default) + { + return (readResult.Message ?? "读取失败", 0, 0, 999, ""); // 读取失败 + } + var data = readResult.Value; + short model = Convert.ToInt16(CommonTool.Siemens.Trans(data, 0)); + short allowAction = Convert.ToInt16(CommonTool.Siemens.Trans(data, 2)); + short errCode = Convert.ToInt16(CommonTool.Siemens.Trans(data, 4)); + var str = Encoding.ASCII.GetString(data, 6, 20); + string code = Regex.Replace(str, "\\W", ""); + return (string.Empty, model, allowAction, errCode, code); + } + /// /// 获取输送机任务号 diff --git a/WcsMain/Plugins/AGVWebApiPost.cs b/WcsMain/Plugins/AGVWebApiPost.cs new file mode 100644 index 0000000..935774a --- /dev/null +++ b/WcsMain/Plugins/AGVWebApiPost.cs @@ -0,0 +1,22 @@ +using ApiTool; +using WcsMain.Business.CommonAction; +using WcsMain.Common; +using WcsMain.ExtendMethod; +using WcsMain.WcsAttribute.AutoFacAttribute; + +namespace WcsMain.Plugins; + + +/// +/// AGV 接口工具 +/// +[Component] +public class AGVWebApiPost : WebApiPost +{ + public AGVWebApiPost(ApiResponseAction apiResponseAction) + { + SetResponseAction(apiResponseAction.ApiResponse); + SetBaseUrl(CommonData.AppApiBaseInfos.GetAddress("AGVBaseApiAddress") ?? ""); + } + +} diff --git a/WcsMain/Plugins/ContainerWebApiPost.cs b/WcsMain/Plugins/ContainerWebApiPost.cs new file mode 100644 index 0000000..bb8c639 --- /dev/null +++ b/WcsMain/Plugins/ContainerWebApiPost.cs @@ -0,0 +1,20 @@ +using ApiTool; +using WcsMain.Business.CommonAction; +using WcsMain.Common; +using WcsMain.ExtendMethod; +using WcsMain.WcsAttribute.AutoFacAttribute; + +namespace WcsMain.Plugins; + +/// +/// 四向车库接口请求 +/// +[Component] +public class ContainerWebApiPost : WebApiPost +{ + public ContainerWebApiPost(ApiResponseAction apiResponseAction) + { + SetResponseAction(apiResponseAction.ApiResponse); + SetBaseUrl(CommonData.AppApiBaseInfos.GetAddress("ContainerBaseApiAddress") ?? ""); + } +} diff --git a/WcsMain/Plugins/WmsWebApiPost.cs b/WcsMain/Plugins/WmsWebApiPost.cs index d5ca325..41a2ac2 100644 --- a/WcsMain/Plugins/WmsWebApiPost.cs +++ b/WcsMain/Plugins/WmsWebApiPost.cs @@ -14,9 +14,9 @@ namespace WcsMain.Plugins; [Component] public class WmsWebApiPost : WebApiPost { - public WmsWebApiPost(WMSApiResponseAction wmsApiResponseAction) + public WmsWebApiPost(ApiResponseAction wmsApiResponseAction) { - SetResponseAction(wmsApiResponseAction.WMSApiResponse); + SetResponseAction(wmsApiResponseAction.ApiResponse); SetBaseUrl(CommonData.AppApiBaseInfos.GetAddress("WmsBaseApiAddress") ?? ""); } diff --git a/WcsMain/WcsMain.csproj b/WcsMain/WcsMain.csproj index cc027c9..4715051 100644 --- a/WcsMain/WcsMain.csproj +++ b/WcsMain/WcsMain.csproj @@ -38,12 +38,12 @@ + - diff --git a/WcsMain/appsettings.json b/WcsMain/appsettings.json index cc39f90..ec25b13 100644 --- a/WcsMain/appsettings.json +++ b/WcsMain/appsettings.json @@ -8,7 +8,7 @@ "AllowedHosts": "*", "Settings": { "DBMysql": "server=10.90.36.71;port=3306;user=developer;password=developer;database=wcs_kate_suzhou;", - "DBMysqlLocal": "server=192.168.234.134;port=3306;user=developer;password=developer;database=wcs_kate_suzhou;", + "DBMysqlLocal": "server=192.168.234.134;port=3306;user=developer;password=developer;database=app_wcs_shangqi;", "DBMssql": "Data Source=192.168.142.131;Initial Catalog=wcs;User Id=sa;Password=Sa123;", "DBMssqlLocal": "Data Source=192.168.142.131;Initial Catalog=wcs_stacker;User Id=sa;Password=Sa123;",