现场调试新增和修改 agv呼叫 点到点调试
This commit is contained in:
@ -36,10 +36,10 @@
|
||||
|
||||
<view style="flex: 35;">工位编码:</view>
|
||||
|
||||
<view style="flex: 50;overflow:hidden;">{{locationCode}}</view>
|
||||
<view style="flex: 60;overflow:hidden;">{{locationCode}}</view>
|
||||
|
||||
<view style="flex: 40;">
|
||||
<button class="mini-btn" type="warn" size="mini">呼叫货架</button>
|
||||
<view style="flex: 30;">
|
||||
<button class="mini-btn" type="warn" size="mini" @click="callEmptyShelf">呼叫货架</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@ -370,6 +370,66 @@
|
||||
this.$refs.proup.show();
|
||||
}
|
||||
},
|
||||
|
||||
//物料绑定
|
||||
callEmptyShelf: function() {
|
||||
this.userName = getConfig('userName', '');
|
||||
var serverIPAndPort = getServerIPAndPort();
|
||||
uni.request({
|
||||
url: 'http://' + serverIPAndPort + '/pdaMatBind/callEmptyShelf', // 请求的接口地址
|
||||
method: 'POST', // 设置请求方式为 POST
|
||||
data: {
|
||||
"locationId": this.locationId,
|
||||
"locationCode": this.locationCode,
|
||||
"userName": this.userName,
|
||||
"deviceType": "PDA"
|
||||
},
|
||||
header: {
|
||||
'Content-Type': 'application/json', // 如果需要以JSON格式发送数据
|
||||
},
|
||||
success: (res) => {
|
||||
// 请求成功的回调函数
|
||||
if (res.statusCode === 200) {
|
||||
//接口返回数据为200 表示获取成功!
|
||||
if (res.data.code == 200) {
|
||||
uni.showToast({
|
||||
title: '呼叫成功,请等待!',
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
});
|
||||
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '呼叫失败:' + res.data.message,
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
});
|
||||
}
|
||||
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '呼叫失败:服务器返回错误状态码' + res.statusCode,
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
// 请求失败的回调函数
|
||||
uni.showToast({
|
||||
title: '呼叫失败:http请求失败' + err,
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
});
|
||||
},
|
||||
complete: (event) => {
|
||||
// 请求完成的回调函数(无论成功或失败都会调用)
|
||||
console.log('请求完成', event);
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
|
||||
//清空当前界面所有内容
|
||||
clear: function() {
|
||||
|
@ -889,6 +889,60 @@ if (uni.restoreGlobal) {
|
||||
this.$refs.proup.show();
|
||||
}
|
||||
},
|
||||
//物料绑定
|
||||
callEmptyShelf: function() {
|
||||
this.userName = getConfig("userName", "");
|
||||
var serverIPAndPort = getServerIPAndPort();
|
||||
uni.request({
|
||||
url: "http://" + serverIPAndPort + "/pdaMatBind/callEmptyShelf",
|
||||
// 请求的接口地址
|
||||
method: "POST",
|
||||
// 设置请求方式为 POST
|
||||
data: {
|
||||
"locationId": this.locationId,
|
||||
"locationCode": this.locationCode,
|
||||
"userName": this.userName,
|
||||
"deviceType": "PDA"
|
||||
},
|
||||
header: {
|
||||
"Content-Type": "application/json"
|
||||
// 如果需要以JSON格式发送数据
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.statusCode === 200) {
|
||||
if (res.data.code == 200) {
|
||||
uni.showToast({
|
||||
title: "呼叫成功,请等待!",
|
||||
icon: "none",
|
||||
duration: 1500
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: "呼叫失败:" + res.data.message,
|
||||
icon: "none",
|
||||
duration: 1500
|
||||
});
|
||||
}
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: "呼叫失败:服务器返回错误状态码" + res.statusCode,
|
||||
icon: "none",
|
||||
duration: 1500
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
uni.showToast({
|
||||
title: "呼叫失败:http请求失败" + err,
|
||||
icon: "none",
|
||||
duration: 1500
|
||||
});
|
||||
},
|
||||
complete: (event) => {
|
||||
formatAppLog("log", "at pages/bind/bind.vue:427", "请求完成", event);
|
||||
}
|
||||
});
|
||||
},
|
||||
//清空当前界面所有内容
|
||||
clear: function() {
|
||||
this.locationId = null;
|
||||
@ -905,7 +959,7 @@ if (uni.restoreGlobal) {
|
||||
this.matSpec = "";
|
||||
},
|
||||
handlePopupClose() {
|
||||
formatAppLog("log", "at pages/bind/bind.vue:391", "弹出层已关闭");
|
||||
formatAppLog("log", "at pages/bind/bind.vue:451", "弹出层已关闭");
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -971,16 +1025,17 @@ if (uni.restoreGlobal) {
|
||||
vue.createElementVNode("view", { style: { "flex": "35" } }, "工位编码:"),
|
||||
vue.createElementVNode(
|
||||
"view",
|
||||
{ style: { "flex": "50", "overflow": "hidden" } },
|
||||
{ style: { "flex": "60", "overflow": "hidden" } },
|
||||
vue.toDisplayString($data.locationCode),
|
||||
1
|
||||
/* TEXT */
|
||||
),
|
||||
vue.createElementVNode("view", { style: { "flex": "40" } }, [
|
||||
vue.createElementVNode("view", { style: { "flex": "30" } }, [
|
||||
vue.createElementVNode("button", {
|
||||
class: "mini-btn",
|
||||
type: "warn",
|
||||
size: "mini"
|
||||
size: "mini",
|
||||
onClick: _cache[3] || (_cache[3] = (...args) => $options.callEmptyShelf && $options.callEmptyShelf(...args))
|
||||
}, "呼叫货架")
|
||||
])
|
||||
]),
|
||||
@ -1056,7 +1111,7 @@ if (uni.restoreGlobal) {
|
||||
class: "uni-input",
|
||||
style: { "font-size": "40rpx" },
|
||||
placeholder: "请输入物料数量",
|
||||
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => $data.matQty = $event)
|
||||
"onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => $data.matQty = $event)
|
||||
},
|
||||
null,
|
||||
512
|
||||
@ -1067,7 +1122,7 @@ if (uni.restoreGlobal) {
|
||||
]),
|
||||
vue.createElementVNode("view", { style: { "flex": "40" } }, [
|
||||
vue.createElementVNode("button", {
|
||||
onClick: _cache[4] || (_cache[4] = (...args) => $options.bind && $options.bind(...args)),
|
||||
onClick: _cache[5] || (_cache[5] = (...args) => $options.bind && $options.bind(...args)),
|
||||
class: "mini-btn",
|
||||
style: { "margin-left": "10rpx" },
|
||||
type: "warn",
|
||||
|
@ -21,11 +21,12 @@ namespace WCS.BLL.DbModels
|
||||
public int Id { get; set; }
|
||||
|
||||
#region 任务属性
|
||||
/// <summary>
|
||||
/// 请求任务时的任务号 需要保证唯一性
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "request_code", Length = 64, IsNullable = false, ColumnDescription = "请求任务时的任务号 需要保证唯一性")]
|
||||
public string RequestCode { get; set; } = Guid.NewGuid().ToString();
|
||||
|
||||
[SugarColumn(ColumnName = "request_code", Length = 64, IsNullable = false, ColumnDescription = "请求任务时的请求号 需要保证唯一性")]
|
||||
public string RequestCode { get; set; }
|
||||
|
||||
[SugarColumn(ColumnName = "task_code", Length = 64, IsNullable = false, ColumnDescription = "请求任务时的任务号 需要保证唯一性")]
|
||||
public string TaskCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务类型
|
||||
@ -55,6 +56,13 @@ namespace WCS.BLL.DbModels
|
||||
[SugarColumn(ColumnName = "end_location_code", Length = 64, IsNullable = true, ColumnDescription = "终点位置编码")]
|
||||
public string EndLocationCode { get; set; } = string.Empty;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 货架码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "shelf_Code", Length = 64, IsNullable = true, ColumnDescription = "AGV编号")]
|
||||
public string ShlefCode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// AGV编号
|
||||
/// </summary>
|
||||
|
@ -3,6 +3,10 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Tool;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
|
||||
namespace WCS.BLL.Manager
|
||||
{
|
||||
@ -10,11 +14,49 @@ namespace WCS.BLL.Manager
|
||||
public static class AGVManager
|
||||
{
|
||||
/// <summary>
|
||||
/// 产生AGV任务
|
||||
/// 产生AGV点到点搬运任务
|
||||
/// </summary>
|
||||
public static AGVResult GenAgvSchedulingTask(int startLocationId,int endLocationId)
|
||||
public static AGVResponseModel GenAgvSchedulingTask(LocationInfo startLocation,LocationInfo endLocation,string shelfCode,string createUser)
|
||||
{
|
||||
return null;
|
||||
var url = @"http://192.168.18.150:8181/rcms/services/rest/hikRpcService/genAgvSchedulingTask";
|
||||
var startPositionCodePathItem = new PositionCodePathItem()
|
||||
{
|
||||
positionCode = startLocation.RcsStoreCode,
|
||||
};
|
||||
var endPositionCodePathItem = new PositionCodePathItem()
|
||||
{
|
||||
positionCode = endLocation.RcsStoreCode,
|
||||
};
|
||||
List<PositionCodePathItem> positionCodePathItems = new List<PositionCodePathItem>();
|
||||
|
||||
positionCodePathItems.Add(startPositionCodePathItem);
|
||||
positionCodePathItems.Add((endPositionCodePathItem));
|
||||
|
||||
var body = new AGVRequestModel()
|
||||
{
|
||||
positionCodePath = positionCodePathItems,
|
||||
};
|
||||
|
||||
var response = ApiHelp.GetDataFromHttp<AGVResponseModel>(url,body,"POST",true);
|
||||
if (response.code == "0" && response.message == "成功")
|
||||
{
|
||||
//生成任务数据
|
||||
var task = new AgvTask()
|
||||
{
|
||||
ShlefCode = shelfCode,
|
||||
RequestCode = body.reqCode,
|
||||
TaskCode = body.taskCode,
|
||||
TaskType = "GenAgvSchedulingTask",
|
||||
StratLocationId = startLocation.Id,
|
||||
StartLocationCode = startLocation.LocationCode,
|
||||
EndLocationId = endLocation.Id,
|
||||
EndLocationCode = endLocation.LocationCode,
|
||||
CreateUser = createUser
|
||||
};
|
||||
DbHelp.db.Insertable(task).ExecuteCommand();
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
|
78
WCS.BLL/Manager/AGVRequestModel.cs
Normal file
78
WCS.BLL/Manager/AGVRequestModel.cs
Normal file
@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.BLL.Manager
|
||||
{
|
||||
//如果好用,请收藏地址,帮忙分享。
|
||||
public class PositionCodePathItem
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string positionCode { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string type { get; set; } = "00";
|
||||
}
|
||||
|
||||
public class AGVRequestModel
|
||||
{
|
||||
/// <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; } = "PDA";
|
||||
|
||||
public string tokenCode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 任务类型
|
||||
/// </summary>
|
||||
public string taskTyp { get; set; } = "F01";
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string interfaceName { get; set; } = "genAgvSchedulingTask";
|
||||
/// <summary>
|
||||
/// 旋转角度
|
||||
/// </summary>
|
||||
public string podDir { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 两个点位 开始点和结束点
|
||||
/// </summary>
|
||||
public List<PositionCodePathItem> positionCodePath { get; set; }
|
||||
/// <summary>
|
||||
/// 货架编码
|
||||
/// </summary>
|
||||
public string podCode { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 优先级
|
||||
/// </summary>
|
||||
public string priority { get; set; } = "1";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string agvCode { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 任务单号(是我自定义的!)
|
||||
/// </summary>
|
||||
public string taskCode { get; set; } = DateTime.Now.ToString("yyyyMMddHHmmfff");
|
||||
|
||||
public string data { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
}
|
32
WCS.BLL/Manager/AGVResponseModel.cs
Normal file
32
WCS.BLL/Manager/AGVResponseModel.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.BLL.Manager
|
||||
{
|
||||
public class AGVResponseModel
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string code { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string data { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string interrupt { get; set; }
|
||||
/// <summary>
|
||||
/// 成功
|
||||
/// </summary>
|
||||
public string message { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string reqCode { get; set; }
|
||||
}
|
||||
}
|
@ -72,7 +72,7 @@ namespace WCS.BLL.Manager
|
||||
|
||||
DbHelp.db.CodeFirst.InitTables(typeof(ShelfInfo), typeof(MatBaseInfo), typeof(ShelfTypeInfo)
|
||||
, typeof(LocationInfo), typeof(LocationAreaInfo), typeof(MatDetailCurrentInfo), typeof(OrderTypeInfo)
|
||||
, typeof(MatDetailStocktakingInfo)
|
||||
, typeof(MatDetailStocktakingInfo), typeof(AgvTask)
|
||||
, typeof(InventoryDetail), typeof(OutOrder), typeof(OutOrderDetail), typeof(OutOrderMatDetail)
|
||||
, typeof(MatInfo), typeof(StoreInfo)
|
||||
, typeof(StockTakingOrder), typeof(StockTakingOrderMatDetail), typeof(InOutRecord)
|
||||
|
@ -180,7 +180,7 @@ namespace WCS.BLL.Services.Service
|
||||
{
|
||||
materialBar = request.MatSn
|
||||
};
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseCommon<List<queryByBarResponse>>>("http://192.168.2.23:9213/integrate/instock/queryBybar", body, "POST", true);
|
||||
var Result = Tool.ApiHelp.GetDataFromHttp<ResponseCommon<List<queryByBarResponse>>>("http://192.168.2.23:9213/integrate/instock/queryBybar", body, "POST", true);
|
||||
|
||||
//查询到物料信息
|
||||
if (Result != null && Result.Code == 200 && Result.Data != null && Result.Data.Count > 0)
|
||||
|
178
WCS.Model/ApiModel/AGV/AGVCallBackRequest.cs
Normal file
178
WCS.Model/ApiModel/AGV/AGVCallBackRequest.cs
Normal file
@ -0,0 +1,178 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.AGV
|
||||
{
|
||||
public class AGVCallBackRequest
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string action { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string areaCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string berthCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string callCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string callTyp { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string clientCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public decimal cooX { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public decimal cooY { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ctnrCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ctnrTyp { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string currentCallCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string currentPositionCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string data { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string dstBinCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string eqpCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string indBind { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string layer { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string mapCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string mapDataCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string mapShortName { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string materialLot { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string materialType { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string method { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string orgCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string podCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string podDir { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string podNum { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string podTyp { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string relatedArea { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string reqCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string reqTime { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string roadWayCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string robotCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string seq { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string stgBinCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string subTaskNum { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string taskCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string taskTyp { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string tokenCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string username { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string wbCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string whCode { get; set; }
|
||||
}
|
||||
}
|
@ -38,6 +38,8 @@ namespace WCS.Model.ApiModel.StoreInfo
|
||||
/// 更新人
|
||||
/// </summary>
|
||||
public string ModifyUser { get; set; } = string.Empty;
|
||||
|
||||
public List<int> AllowDestinationLocationArea { get; set; } = new List<int>();
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
|
95
WCS.WebApi/Controllers/AgvCallbackServiceController.cs
Normal file
95
WCS.WebApi/Controllers/AgvCallbackServiceController.cs
Normal file
@ -0,0 +1,95 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using SqlSugar;
|
||||
using WCS.BLL;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.HardWare;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.BLL.Services.Service;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel.AGV;
|
||||
using WCS.Model.ApiModel.Home;
|
||||
using Mode = WCS.BLL.HardWare.Mode;
|
||||
|
||||
namespace WCS.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 主页面的接口
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class AgvCallbackServiceController : ControllerBase
|
||||
{
|
||||
|
||||
public AgvCallbackServiceController(IHomerService homerService, ISelfCheckService selfCheckService)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// agv任务回调
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Route("agvCallback")]
|
||||
[HttpPost(Name = "agvCallback")]
|
||||
public async Task<object> agvCallback(AGVCallBackRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
Logs.Write("收到AGV回调" + JsonConvert.SerializeObject(request));
|
||||
//找到任务数据
|
||||
var task = await DbHelp.db.Queryable<AgvTask>().Where(t => t.TaskCode == request.taskCode)
|
||||
.FirstAsync();
|
||||
if (task == null)
|
||||
{
|
||||
return new
|
||||
{
|
||||
Code = 0,
|
||||
Message = "成功",
|
||||
reqCode = "123",
|
||||
};
|
||||
}
|
||||
|
||||
//判断并更新数据
|
||||
var shelf = await DbHelp.db.Queryable<ShelfInfo>().Where(t => t.ShelfCode == request.podCode || t.ShelfCode == task.ShlefCode)
|
||||
.FirstAsync();
|
||||
if (shelf != null && request.method == "outbin")
|
||||
{
|
||||
shelf.CurrentLocationId = 0;
|
||||
shelf.CurrentLocaiotnCode = string.Empty;
|
||||
DbHelp.db.Updateable(shelf).ExecuteCommand();
|
||||
}
|
||||
|
||||
if (shelf != null && request.method == "end")
|
||||
{
|
||||
shelf.CurrentLocationId = shelf.DestinationLocationId;
|
||||
shelf.CurrentLocaiotnCode = shelf.DestinationLocaiotnCode;
|
||||
shelf.DestinationLocationId = 0;
|
||||
shelf.DestinationLocaiotnCode = string.Empty;
|
||||
shelf.TransStatus = TransStatusEnum.静止;
|
||||
DbHelp.db.Updateable(shelf).ExecuteCommand();
|
||||
}
|
||||
|
||||
return new
|
||||
{
|
||||
Code = 0,
|
||||
Message = "成功",
|
||||
reqCode = "123",
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseBase()
|
||||
{
|
||||
Code = 300,
|
||||
Message = "获取失败:" + ex.Message,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
@ -57,8 +58,8 @@ namespace WCS.WebApi.Controllers
|
||||
|
||||
//获取当前工位的货架
|
||||
var shelf = await DbHelp.db.Queryable<ShelfInfo>()
|
||||
.Where(t => t.CurrentLocationId == location.Id && t.TransStatus == TransStatusEnum.静止
|
||||
|| t.DestinationLocationId == location.Id && t.TransStatus == TransStatusEnum.运输中)//解决产线人员 呼叫后货架未到的时候绑定的问题
|
||||
.Where(t => (t.CurrentLocationId == location.Id && t.TransStatus == TransStatusEnum.静止)
|
||||
|| (t.DestinationLocationId == location.Id && t.TransStatus == TransStatusEnum.运输中))//解决产线人员 呼叫后货架未到的时候绑定的问题
|
||||
.Where(t => t.IsEnable)
|
||||
.FirstAsync();
|
||||
|
||||
@ -268,6 +269,114 @@ namespace WCS.WebApi.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[Route("callEmptyShelf")]
|
||||
[HttpPost(Name = "callEmptyShelf")]
|
||||
public async Task<ResponseCommon> callEmptyShelf(BindMatDetailRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
#region 参数校验
|
||||
//判断参数
|
||||
if (request.LocationId == 0 || string.IsNullOrEmpty(request.LocationCode))
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "工位或工位编码为空!\r\n请重新扫工位码",
|
||||
Data = null,
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 数据校验
|
||||
//获取是否存在当前工位
|
||||
var endLocation = await DbHelp.db.Queryable<LocationInfo>()
|
||||
.Where(t => t.Id == request.LocationId)
|
||||
.Where(t => t.IsEnable == true)
|
||||
.FirstAsync();
|
||||
if (endLocation == null)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"工位[{request.LocationCode}]不存在或已被禁用!\r\n请联系系统管理人员维护工位信息!",
|
||||
Data = null,
|
||||
};
|
||||
}
|
||||
|
||||
//获取当前工位的货架
|
||||
var shelf = await DbHelp.db.Queryable<ShelfInfo>()
|
||||
.Where(t => t.CurrentLocationId == endLocation.Id && t.TransStatus == TransStatusEnum.静止
|
||||
|| t.DestinationLocationId == endLocation.Id && t.TransStatus == TransStatusEnum.运输中)//解决产线人员 呼叫后货架未到的时候绑定的问题
|
||||
.Where(t => t.IsEnable == true)
|
||||
.FirstAsync();
|
||||
if (shelf != null)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 205,
|
||||
Message = $"货架【{shelf.ShelfCode}】在工位上或即将在工位上,请勿重复呼叫!",
|
||||
Data = null,
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
|
||||
//获取空货架进行呼叫
|
||||
shelf = await DbHelp.db.Queryable<ShelfInfo>()
|
||||
.Where(t => t.TransStatus == TransStatusEnum.静止 && t.CurrentLocationId != 0)
|
||||
.Where(t => t.IsEnable == true)
|
||||
.FirstAsync();
|
||||
if (shelf == null)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"不存在空货架!",
|
||||
Data = null,
|
||||
};
|
||||
}
|
||||
|
||||
var startLocation = await DbHelp.db.Queryable<LocationInfo>()
|
||||
.Where(t => t.Id == shelf.CurrentLocationId)
|
||||
.Where(t => t.IsEnable == true)
|
||||
.FirstAsync();
|
||||
|
||||
var response = AGVManager.GenAgvSchedulingTask(startLocation, endLocation,shelf.ShelfCode,request.UserName);
|
||||
if (response.code == "0" && response.message == "成功")
|
||||
{
|
||||
//更新货架位置信息
|
||||
shelf.TransStatus = TransStatusEnum.运输中;
|
||||
shelf.DestinationLocationId = endLocation.Id;
|
||||
shelf.DestinationLocaiotnCode = endLocation.LocationCode;
|
||||
DbHelp.db.Updateable(shelf).ExecuteCommand();
|
||||
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "success",
|
||||
Data = null,
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"海康RCS返回:{response.message}",
|
||||
Data = null,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = ex.Message,
|
||||
Data = null,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user