diff --git a/PDA/PDA/components/TaskCard.vue b/PDA/PDA/components/TaskCard.vue index 579c1da..6703fac 100644 --- a/PDA/PDA/components/TaskCard.vue +++ b/PDA/PDA/components/TaskCard.vue @@ -7,14 +7,14 @@ - - 任务单号: - {{item.taskCode}} - AGV编号: {{item.agvCode}} + + AGV状态: + {{item.agvStatus}} + 任务状态: {{item.taskStatusStr}} diff --git a/PDA/PDA/unpackage/dist/dev/app-plus/app-service.js b/PDA/PDA/unpackage/dist/dev/app-plus/app-service.js index dadd505..f07bd14 100644 --- a/PDA/PDA/unpackage/dist/dev/app-plus/app-service.js +++ b/PDA/PDA/unpackage/dist/dev/app-plus/app-service.js @@ -863,6 +863,7 @@ if (uni.restoreGlobal) { success: (res) => { if (res.statusCode === 200) { if (res.data.code == 200) { + this.matCodeCondition = ""; this.locationId = res.data.data.locationId; this.locationCode = res.data.data.locationCode; this.shelfId = res.data.data.shelfId; @@ -925,12 +926,12 @@ if (uni.restoreGlobal) { } }, complete: (event) => { - formatAppLog("log", "at pages/bind/bind.vue:347", "请求完成", event); + formatAppLog("log", "at pages/bind/bind.vue:349", "请求完成", event); } }); }, bindSelectedMat: function(item) { - formatAppLog("log", "at pages/bind/bind.vue:353", "用户选择了项目:", item); + formatAppLog("log", "at pages/bind/bind.vue:355", "用户选择了项目:", item); this.matCode = item.matCode; this.matName = item.matName; this.matSpec = item.matSpec; @@ -995,7 +996,7 @@ if (uni.restoreGlobal) { }); }, complete: (event) => { - formatAppLog("log", "at pages/bind/bind.vue:422", "请求完成", event); + formatAppLog("log", "at pages/bind/bind.vue:424", "请求完成", event); } }); }, @@ -1100,7 +1101,7 @@ if (uni.restoreGlobal) { }); }, complete: (event) => { - formatAppLog("log", "at pages/bind/bind.vue:536", "请求完成", event); + formatAppLog("log", "at pages/bind/bind.vue:538", "请求完成", event); } }); }, @@ -1191,7 +1192,7 @@ if (uni.restoreGlobal) { }); }, complete: (event) => { - formatAppLog("log", "at pages/bind/bind.vue:638", "请求完成", event); + formatAppLog("log", "at pages/bind/bind.vue:640", "请求完成", event); } }); }, @@ -1215,10 +1216,11 @@ if (uni.restoreGlobal) { this.matCode = ""; this.matName = ""; this.matSpec = ""; + this.matBatch = ""; this.matQty = 0; }, handlePopupClose() { - formatAppLog("log", "at pages/bind/bind.vue:669", "弹出层已关闭"); + formatAppLog("log", "at pages/bind/bind.vue:672", "弹出层已关闭"); } } }; @@ -3049,6 +3051,7 @@ if (uni.restoreGlobal) { }); return; } + this.matCodeCondition = ""; this.cardData = res.data.data.lists; this.recordCount = res.data.data.count; uni.showToast({ @@ -3082,7 +3085,7 @@ if (uni.restoreGlobal) { this.clear(); }, complete: (event) => { - formatAppLog("log", "at pages/queryBindList/queryBindList.vue:451", "请求完成", event); + formatAppLog("log", "at pages/queryBindList/queryBindList.vue:452", "请求完成", event); } }); }, @@ -3157,7 +3160,7 @@ if (uni.restoreGlobal) { this.clear(); }, complete: (event) => { - formatAppLog("log", "at pages/queryBindList/queryBindList.vue:536", "请求完成", event); + formatAppLog("log", "at pages/queryBindList/queryBindList.vue:537", "请求完成", event); } }); }, @@ -5158,6 +5161,7 @@ if (uni.restoreGlobal) { }); return; } + this.matCodeCondition = ""; this.shelfId = res.data.data.shelfId; this.shelfCode = res.data.data.shelfCode; this.locationId = res.data.data.locationId; @@ -5195,7 +5199,7 @@ if (uni.restoreGlobal) { this.clear(); }, complete: (event) => { - formatAppLog("log", "at pages/productionLineCallOut/productionLineCallOut.vue:515", "请求完成", event); + formatAppLog("log", "at pages/productionLineCallOut/productionLineCallOut.vue:516", "请求完成", event); } }); }, @@ -5270,7 +5274,7 @@ if (uni.restoreGlobal) { this.clear(); }, complete: (event) => { - formatAppLog("log", "at pages/productionLineCallOut/productionLineCallOut.vue:598", "请求完成", event); + formatAppLog("log", "at pages/productionLineCallOut/productionLineCallOut.vue:599", "请求完成", event); } }); }, @@ -5582,16 +5586,6 @@ if (uni.restoreGlobal) { ]) ]), vue.createElementVNode("view", { class: "card-content" }, [ - vue.createElementVNode("view", { class: "content-item" }, [ - vue.createElementVNode("text", null, "任务单号:"), - vue.createElementVNode( - "text", - null, - vue.toDisplayString($props.item.taskCode), - 1 - /* TEXT */ - ) - ]), vue.createElementVNode("view", { class: "content-item" }, [ vue.createElementVNode("text", null, "AGV编号:"), vue.createElementVNode( @@ -5602,6 +5596,16 @@ if (uni.restoreGlobal) { /* TEXT */ ) ]), + vue.createElementVNode("view", { class: "content-item" }, [ + vue.createElementVNode("text", null, "AGV状态:"), + vue.createElementVNode( + "text", + null, + vue.toDisplayString($props.item.agvStatus), + 1 + /* TEXT */ + ) + ]), vue.createElementVNode("view", { class: "content-item" }, [ vue.createElementVNode("text", null, "任务状态:"), vue.createElementVNode( diff --git a/WCS.BLL/DbModels/STZL/AgvTask.cs b/WCS.BLL/DbModels/STZL/AgvTask.cs index 73f245c..e0fdb77 100644 --- a/WCS.BLL/DbModels/STZL/AgvTask.cs +++ b/WCS.BLL/DbModels/STZL/AgvTask.cs @@ -70,6 +70,12 @@ namespace WCS.BLL.DbModels [SugarColumn(ColumnName = "agv_code", Length = 64, IsNullable = true, ColumnDescription = "AGV编号")] public string AgvCode { get; set; } = string.Empty; + /// + /// AGV编号 + /// + [SugarColumn(ColumnName = "agv_status", Length = 80, IsNullable = true, ColumnDescription = "AGV状态")] + public string AgvStatus { get; set; } = string.Empty; + /// /// 任务发起人 /// diff --git a/WCS.BLL/Manager/AGVManager.cs b/WCS.BLL/Manager/AGVManager.cs index 8d55cd4..2364563 100644 --- a/WCS.BLL/Manager/AGVManager.cs +++ b/WCS.BLL/Manager/AGVManager.cs @@ -33,7 +33,7 @@ namespace WCS.BLL.Manager var tasks = DbHelp.db.Queryable() .Where(t => t.CreateTime > DateTime.Now.AddDays(-7)) //只查询7天内agv任务数据 - .Where(t =>t.TaskStatus != TaskStatusEnum.取消完成 && t.TaskStatus!= TaskStatusEnum.已结束) + .Where(t => t.TaskStatus != TaskStatusEnum.取消完成 && t.TaskStatus != TaskStatusEnum.已结束) .OrderBy(t => t.Id) .ToList(); if (tasks != null && tasks.Count > 0) @@ -47,7 +47,7 @@ namespace WCS.BLL.Manager data.taskCodes.Add(tasks[i].TaskCode); var result = ApiHelp.GetDataFromHttp(url, data, "POST", true); - if (result != null && result.code == "0" && result.data !=null && result.data.Count > 0) + if (result != null && result.code == "0" && result.data != null && result.data.Count > 0) { var isUpdate = false; //获取成功 是否与当前任务状态一致 如果不一致 进行更新 @@ -82,9 +82,13 @@ namespace WCS.BLL.Manager } } - if (isUpdate) + if (isUpdate) { tasks[i].ModifyTime = DateTime.Now; + if (tasks[i].TaskStatus != TaskStatusEnum.已创建 && tasks[i].TaskStatus != TaskStatusEnum.正在执行 ) + { + tasks[i].AgvStatus = "-"; + } DbHelp.db.Updateable(tasks[i]).ExecuteCommand(); } } @@ -188,7 +192,7 @@ namespace WCS.BLL.Manager } } - public static AGVResponseModel GenAgvSchedulingTaskForResend(LocationInfo startLocation, LocationInfo endLocation, AgvTask agvTask,string shelfCode, string createUser) + public static AGVResponseModel GenAgvSchedulingTaskForResend(LocationInfo startLocation, LocationInfo endLocation, AgvTask agvTask, string shelfCode, string createUser) { var url = @"http://192.168.18.150:8181/rcms/services/rest/hikRpcService/genAgvSchedulingTask"; var startPositionCodePathItem = new PositionCodePathItem() @@ -271,6 +275,7 @@ namespace WCS.BLL.Manager return response; } } + /// /// RCS取消任务 /// @@ -311,13 +316,12 @@ namespace WCS.BLL.Manager } } - /// /// RCS货架绑定 解绑 /// /// /// - public static AGVResponseModel BindPodAndBerth(string shelfCode,string locationCode , BindPodAndBerthMethod bindPodAndBerthMethod) + public static AGVResponseModel BindPodAndBerth(string shelfCode, string locationCode, BindPodAndBerthMethod bindPodAndBerthMethod) { try { @@ -337,7 +341,7 @@ namespace WCS.BLL.Manager var response = ApiHelp.GetDataFromHttp(url, body, "POST", true); //if (response.code == "0" && response.message == "成功") //{ - + //} return response; } @@ -351,6 +355,150 @@ namespace WCS.BLL.Manager }; } } + + public static void RefreshAgvStatus() + { + try + { + Logs.Write("[刷新AGV状态]开始刷新AGV状态"); + var url = @"http://192.168.18.150:8181/rcms-dps/rest/queryAgvStatus"; + var body = new AGVQueryAgvStatusRequest(); + var response = ApiHelp.GetDataFromHttpShortTime(url, body, "POST", true); + if (response == null) + { + Logs.Write("[刷新AGV状态]Response为空!"); + return; + } + //response不为空 更新task表的状态 + var tasks = DbHelp.db.Queryable() + .Where(t => t.TaskStatus == TaskStatusEnum.已创建 || t.TaskStatus == TaskStatusEnum.正在执行) + .ToList(); + if (tasks == null || tasks.Count == 0) + { + Logs.Write("[刷新AGV状态]状态为执行中或者已创建的任务为空!"); + } + foreach (var task in tasks) + { + var agvCode = task.AgvCode; + if (string.IsNullOrEmpty(agvCode)) + { + continue; + } + var dataItem = response?.data.Where(t => t.robotCode == agvCode).FirstOrDefault(); + if (dataItem == null) + { + continue ; + } + + var str = string.Empty; + switch (dataItem.status) + { + case "1": + str = "任务完成"; + break; + case "2": + str = "任务执行中"; + break; + case "3": + str = "任务异常"; + break; + case "4": + str = "任务空闲"; + break; + case "5": + str = "机器人暂停"; + break; + case "6": + str = "举升货架状态"; + break; + case "7": + str = "充电状态"; + break; + case "8": + str = "弧线行走中"; + break; + case "9": + str = "充满维护"; + break; + case "11": + str = "背货未识别"; + break; + case "12": + str = "货架偏角过大"; + break; + case "13": + str = "运动库异常"; + break; + case "14": + str = "货码无法识别"; + break; + case "15": + str = "货码不匹配"; + break; + case "16": + str = "举升异常"; + break; + case "17": + str = "充电桩异常"; + break; + case "18": + str = "电量无增加"; + break; + case "20": + str = "充电指令角度错误"; + break; + case "21": + str = "平台下发指令错误"; + break; + case "23": + str = "外力下放"; + break; + case "24": + str = "货架位置偏移"; + break; + case "25": + str = "小车不在锁定区"; + break; + case "26": + str = "下放重试失败"; + break; + case "27": + str = "货架摆歪"; + break; + case "28": + str = "举升电池电量太低"; + break; + case "29": + str = "后退角度偏大"; + break; + case "30": + str = "未背货架举升"; + break; + case "31": + str = "区域锁定失败"; + break; + case "33": + str = "旋转申请暂时失败"; + break; + case "34": + str = "地图切换点地码未识别"; + break; + default: + str = "未知状态"; + break; + } + //更新状态 + task.AgvStatus = str; + } + DbHelp.db.Updateable(tasks).UpdateColumns(t => new { t.AgvStatus }).ExecuteCommand(); + Logs.Write("[刷新AGV状态]结束刷新AGV状态"); + } + catch (Exception ex) + { + Logs.Write($"[刷新AGV状态]遇到异常{ex.Message}\r\n{ex.StackTrace}"); + } + } + } /// diff --git a/WCS.BLL/Tool/Api/ApiHelp.cs b/WCS.BLL/Tool/Api/ApiHelp.cs index 4ce9b0f..4d5400d 100644 --- a/WCS.BLL/Tool/Api/ApiHelp.cs +++ b/WCS.BLL/Tool/Api/ApiHelp.cs @@ -324,7 +324,7 @@ namespace WCS.BLL.Tool HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = httpMethod; request.ContentType = "application/json"; - request.Timeout = 2000; + request.Timeout = 1000; if (!string.IsNullOrEmpty(data)) { diff --git a/WCS.Model/ApiModel/AGV/AGVQueryAgvStatusRequest.cs b/WCS.Model/ApiModel/AGV/AGVQueryAgvStatusRequest.cs new file mode 100644 index 0000000..bc9c99d --- /dev/null +++ b/WCS.Model/ApiModel/AGV/AGVQueryAgvStatusRequest.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WCS.Model.ApiModel.AGV +{ + /// + /// 取消任务 + /// + public class AGVQueryAgvStatusRequest + { + /// + /// 请求码 每一次请求唯一 + /// + public string reqCode { get; set; } = Guid.NewGuid().ToString().Replace("-", ""); + + /// + /// 请求时间 + /// + public string reqTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + + /// + /// 客户端编号 + /// + public string clientCode { get; set; } = string.Empty; + + /// + /// token + /// + public string tokenCode { get; set; } = string.Empty; + + /// + /// 地图编号 + /// + public string mapCode { get; set; } = "XY"; + } +} diff --git a/WCS.Model/ApiModel/AGV/AGVQueryAgvStatusResponse.cs b/WCS.Model/ApiModel/AGV/AGVQueryAgvStatusResponse.cs new file mode 100644 index 0000000..7786219 --- /dev/null +++ b/WCS.Model/ApiModel/AGV/AGVQueryAgvStatusResponse.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WCS.Model.ApiModel.AGV +{ + /// + /// 取消任务 + /// + public class AGVQueryAgvStatusResponse + { + /// + /// + /// + public string code { get; set; } + /// + /// + /// + public List data { get; set; } + /// + /// + /// + public string interrupt { get; set; } + /// + /// + /// + public string message { get; set; } + /// + /// + /// + public string msgErrCode { get; set; } + /// + /// + /// + public string reqCode { get; set; } + } + + public class AGVQueryAgvStatusResponseDataItem + { + /// + /// + /// + public string robotCode { get; set; } + /// + /// + + /// + /// + /// + public string status { get; set; } + + } +} diff --git a/WCS.Model/ApiModel/AGV/AGVTaskModel.cs b/WCS.Model/ApiModel/AGV/AGVTaskModel.cs index 6ebaeba..a0d83c2 100644 --- a/WCS.Model/ApiModel/AGV/AGVTaskModel.cs +++ b/WCS.Model/ApiModel/AGV/AGVTaskModel.cs @@ -61,6 +61,8 @@ namespace WCS.Model.ApiModel.AGV /// public string AgvCode { get; set; } = string.Empty; + public string AgvStatus { get; set; } = string.Empty; + /// /// 任务发起人 /// diff --git a/WCS.WebApi/Controllers/AgvCallbackServiceController.cs b/WCS.WebApi/Controllers/AgvCallbackServiceController.cs index eb6bd44..8c76b2e 100644 --- a/WCS.WebApi/Controllers/AgvCallbackServiceController.cs +++ b/WCS.WebApi/Controllers/AgvCallbackServiceController.cs @@ -106,6 +106,7 @@ namespace WCS.WebApi.Controllers if (shelf != null && request.method == "end" && shelf.TransStatus == TransStatusEnum.运输中) { task.TaskStatus = TaskStatusEnum.已结束; + task.AgvStatus = "-"; DbHelp.db.Updateable(task).ExecuteCommand(); shelf.CurrentLocationId = shelf.DestinationLocationId; diff --git a/WCS.WebApi/Controllers/AgvTaskController.cs b/WCS.WebApi/Controllers/AgvTaskController.cs index 4fcc504..fb92130 100644 --- a/WCS.WebApi/Controllers/AgvTaskController.cs +++ b/WCS.WebApi/Controllers/AgvTaskController.cs @@ -77,6 +77,11 @@ namespace WCS.WebApi.Controllers { try { + if (request.TaskStatus == TaskStatusEnum.正在执行) + { + AGVManager.RefreshAgvStatus(); + } + var recordsQueryable = DbHelp.db.Queryable() .WhereIF(string.IsNullOrEmpty(request.ShelfCode), t => t.ShelfCode.Contains(request.ShelfCode)) .WhereIF(string.IsNullOrEmpty(request.CreateUser), t => t.CreateUser.Contains(request.CreateUser)) diff --git a/货架标准上位机/Views/AGVTaskView.xaml b/货架标准上位机/Views/AGVTaskView.xaml index e959cc0..1c54251 100644 --- a/货架标准上位机/Views/AGVTaskView.xaml +++ b/货架标准上位机/Views/AGVTaskView.xaml @@ -194,6 +194,10 @@ + +