增加AGV状态的显示

This commit is contained in:
hehaibing-1996
2025-03-05 16:48:14 +08:00
parent a3a9b9c838
commit 2381624be4
11 changed files with 292 additions and 32 deletions

View File

@ -7,14 +7,14 @@
</view>
</view>
<view class="card-content">
<view class="content-item">
<text>任务单号:</text>
<text>{{item.taskCode}}</text>
</view>
<view class="content-item">
<text>AGV编号:</text>
<text>{{item.agvCode}}</text>
</view>
<view class="content-item">
<text>AGV状态:</text>
<text>{{item.agvStatus}}</text>
</view>
<view class="content-item">
<text>任务状态:</text>
<text>{{item.taskStatusStr}}</text>

View File

@ -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(

View File

@ -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;
/// <summary>
/// AGV编号
/// </summary>
[SugarColumn(ColumnName = "agv_status", Length = 80, IsNullable = true, ColumnDescription = "AGV状态")]
public string AgvStatus { get; set; } = string.Empty;
/// <summary>
/// 任务发起人
/// </summary>

View File

@ -33,7 +33,7 @@ namespace WCS.BLL.Manager
var tasks = DbHelp.db.Queryable<AgvTask>()
.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<AGVQueryTaskStatusResponse>(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;
}
}
/// <summary>
/// RCS取消任务
/// </summary>
@ -311,13 +316,12 @@ namespace WCS.BLL.Manager
}
}
/// <summary>
/// RCS货架绑定 解绑
/// </summary>
/// <param name="agvTask"></param>
/// <returns></returns>
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<AGVResponseModel>(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<AGVQueryAgvStatusResponse>(url, body, "POST", true);
if (response == null)
{
Logs.Write("[刷新AGV状态]Response为空");
return;
}
//response不为空 更新task表的状态
var tasks = DbHelp.db.Queryable<AgvTask>()
.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}");
}
}
}
/// <summary>

View File

@ -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))
{

View File

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace WCS.Model.ApiModel.AGV
{
/// <summary>
/// 取消任务
/// </summary>
public class AGVQueryAgvStatusRequest
{
/// <summary>
/// 请求码 每一次请求唯一
/// </summary>
public string reqCode { get; set; } = Guid.NewGuid().ToString().Replace("-", "");
/// <summary>
/// 请求时间
/// </summary>
public string reqTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
/// <summary>
/// 客户端编号
/// </summary>
public string clientCode { get; set; } = string.Empty;
/// <summary>
/// token
/// </summary>
public string tokenCode { get; set; } = string.Empty;
/// <summary>
/// 地图编号
/// </summary>
public string mapCode { get; set; } = "XY";
}
}

View File

@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace WCS.Model.ApiModel.AGV
{
/// <summary>
/// 取消任务
/// </summary>
public class AGVQueryAgvStatusResponse
{
/// <summary>
///
/// </summary>
public string code { get; set; }
/// <summary>
///
/// </summary>
public List<AGVQueryAgvStatusResponseDataItem> data { get; set; }
/// <summary>
///
/// </summary>
public string interrupt { get; set; }
/// <summary>
///
/// </summary>
public string message { get; set; }
/// <summary>
///
/// </summary>
public string msgErrCode { get; set; }
/// <summary>
///
/// </summary>
public string reqCode { get; set; }
}
public class AGVQueryAgvStatusResponseDataItem
{
/// <summary>
///
/// </summary>
public string robotCode { get; set; }
/// <summary>
///
/// <summary>
///
/// </summary>
public string status { get; set; }
}
}

View File

@ -61,6 +61,8 @@ namespace WCS.Model.ApiModel.AGV
/// </summary>
public string AgvCode { get; set; } = string.Empty;
public string AgvStatus { get; set; } = string.Empty;
/// <summary>
/// 任务发起人
/// </summary>

View File

@ -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;

View File

@ -77,6 +77,11 @@ namespace WCS.WebApi.Controllers
{
try
{
if (request.TaskStatus == TaskStatusEnum.)
{
AGVManager.RefreshAgvStatus();
}
var recordsQueryable = DbHelp.db.Queryable<AgvTask>()
.WhereIF(string.IsNullOrEmpty(request.ShelfCode), t => t.ShelfCode.Contains(request.ShelfCode))
.WhereIF(string.IsNullOrEmpty(request.CreateUser), t => t.CreateUser.Contains(request.CreateUser))

View File

@ -194,6 +194,10 @@
<DataGridTextColumn Header="任务状态"
Binding="{Binding TaskStatus}"></DataGridTextColumn>
<DataGridTextColumn Header="AGV编号"
Binding="{Binding AgvCode}"></DataGridTextColumn>
<DataGridTextColumn Header="AGV状态"
Binding="{Binding AgvStatus}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True"
Header="最后更新时间"
Binding="{Binding ModifyTime ,StringFormat='yyyy-MM-dd HH:mm:ss'}"></DataGridTextColumn>