From e1717145a9cd6689826aad150e4203844d90ffa7 Mon Sep 17 00:00:00 2001 From: hehaibing-1996 Date: Fri, 21 Feb 2025 18:32:43 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8E=B0=E5=9C=BA=E8=B0=83=E8=AF=95=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=92=8C=E4=BF=AE=E6=94=B9=20agv=E5=91=BC=E5=8F=AB=20?= =?UTF-8?q?=E7=82=B9=E5=88=B0=E7=82=B9=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PDA/PDA/pages/bind/bind.vue | 66 ++++++- .../dist/dev/app-plus/app-service.js | 67 ++++++- WCS.BLL/DbModels/STZL/AgvTask.cs | 18 +- WCS.BLL/Manager/AGVManager.cs | 48 ++++- WCS.BLL/Manager/AGVRequestModel.cs | 78 ++++++++ WCS.BLL/Manager/AGVResponseModel.cs | 32 ++++ WCS.BLL/Manager/DbInit.cs | 2 +- WCS.BLL/Services/Service/InstoreService.cs | 2 +- WCS.Model/ApiModel/AGV/AGVCallBackRequest.cs | 178 ++++++++++++++++++ .../LocationInfo/LocationInfoModel.cs | 2 + .../AgvCallbackServiceController.cs | 95 ++++++++++ .../Controllers/PDAMatBindController.cs | 113 ++++++++++- 12 files changed, 680 insertions(+), 21 deletions(-) create mode 100644 WCS.BLL/Manager/AGVRequestModel.cs create mode 100644 WCS.BLL/Manager/AGVResponseModel.cs create mode 100644 WCS.Model/ApiModel/AGV/AGVCallBackRequest.cs create mode 100644 WCS.WebApi/Controllers/AgvCallbackServiceController.cs diff --git a/PDA/PDA/pages/bind/bind.vue b/PDA/PDA/pages/bind/bind.vue index 65f495c..6f9e1c4 100644 --- a/PDA/PDA/pages/bind/bind.vue +++ b/PDA/PDA/pages/bind/bind.vue @@ -36,10 +36,10 @@ 工位编码: - {{locationCode}} + {{locationCode}} - - + + @@ -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() { 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 4f360e7..534b639 100644 --- a/PDA/PDA/unpackage/dist/dev/app-plus/app-service.js +++ b/PDA/PDA/unpackage/dist/dev/app-plus/app-service.js @@ -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", diff --git a/WCS.BLL/DbModels/STZL/AgvTask.cs b/WCS.BLL/DbModels/STZL/AgvTask.cs index 74c59f6..4906a64 100644 --- a/WCS.BLL/DbModels/STZL/AgvTask.cs +++ b/WCS.BLL/DbModels/STZL/AgvTask.cs @@ -21,11 +21,12 @@ namespace WCS.BLL.DbModels public int Id { get; set; } #region 任务属性 - /// - /// 请求任务时的任务号 需要保证唯一性 - /// - [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; } /// /// 任务类型 @@ -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; + + /// + /// 货架码 + /// + [SugarColumn(ColumnName = "shelf_Code", Length = 64, IsNullable = true, ColumnDescription = "AGV编号")] + public string ShlefCode { get; set; } = string.Empty; + /// /// AGV编号 /// diff --git a/WCS.BLL/Manager/AGVManager.cs b/WCS.BLL/Manager/AGVManager.cs index cd419be..ce0b371 100644 --- a/WCS.BLL/Manager/AGVManager.cs +++ b/WCS.BLL/Manager/AGVManager.cs @@ -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 { /// - /// 产生AGV任务 + /// 产生AGV点到点搬运任务 /// - 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 positionCodePathItems = new List(); + + positionCodePathItems.Add(startPositionCodePathItem); + positionCodePathItems.Add((endPositionCodePathItem)); + + var body = new AGVRequestModel() + { + positionCodePath = positionCodePathItems, + }; + + var response = ApiHelp.GetDataFromHttp(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; } } diff --git a/WCS.BLL/Manager/AGVRequestModel.cs b/WCS.BLL/Manager/AGVRequestModel.cs new file mode 100644 index 0000000..642ac4e --- /dev/null +++ b/WCS.BLL/Manager/AGVRequestModel.cs @@ -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 + { + /// + /// + /// + public string positionCode { get; set; } = string.Empty; + /// + /// + /// + public string type { get; set; } = "00"; + } + + public class AGVRequestModel + { + /// + /// 请求码 每一次请求唯一 + /// + 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; } = "PDA"; + + public string tokenCode { get; set; } = string.Empty; + + /// + /// 任务类型 + /// + public string taskTyp { get; set; } = "F01"; + + /// + /// + /// + public string interfaceName { get; set; } = "genAgvSchedulingTask"; + /// + /// 旋转角度 + /// + public string podDir { get; set; } = string.Empty; + /// + /// 两个点位 开始点和结束点 + /// + public List positionCodePath { get; set; } + /// + /// 货架编码 + /// + public string podCode { get; set; } = string.Empty; + /// + /// 优先级 + /// + public string priority { get; set; } = "1"; + /// + /// + /// + public string agvCode { get; set; } = string.Empty; + /// + /// 任务单号(是我自定义的!) + /// + public string taskCode { get; set; } = DateTime.Now.ToString("yyyyMMddHHmmfff"); + + public string data { get; set; } = string.Empty; + } + +} diff --git a/WCS.BLL/Manager/AGVResponseModel.cs b/WCS.BLL/Manager/AGVResponseModel.cs new file mode 100644 index 0000000..cceed0d --- /dev/null +++ b/WCS.BLL/Manager/AGVResponseModel.cs @@ -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 + { + /// + /// + /// + public string code { get; set; } + /// + /// + /// + public string data { get; set; } + /// + /// + /// + public string interrupt { get; set; } + /// + /// 成功 + /// + public string message { get; set; } + /// + /// + /// + public string reqCode { get; set; } + } +} diff --git a/WCS.BLL/Manager/DbInit.cs b/WCS.BLL/Manager/DbInit.cs index 951050f..0d0ebc0 100644 --- a/WCS.BLL/Manager/DbInit.cs +++ b/WCS.BLL/Manager/DbInit.cs @@ -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) diff --git a/WCS.BLL/Services/Service/InstoreService.cs b/WCS.BLL/Services/Service/InstoreService.cs index 52914bb..7d15f5f 100644 --- a/WCS.BLL/Services/Service/InstoreService.cs +++ b/WCS.BLL/Services/Service/InstoreService.cs @@ -180,7 +180,7 @@ namespace WCS.BLL.Services.Service { materialBar = request.MatSn }; - var Result = ApiHelp.GetDataFromHttp>>("http://192.168.2.23:9213/integrate/instock/queryBybar", body, "POST", true); + var Result = Tool.ApiHelp.GetDataFromHttp>>("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) diff --git a/WCS.Model/ApiModel/AGV/AGVCallBackRequest.cs b/WCS.Model/ApiModel/AGV/AGVCallBackRequest.cs new file mode 100644 index 0000000..ae34748 --- /dev/null +++ b/WCS.Model/ApiModel/AGV/AGVCallBackRequest.cs @@ -0,0 +1,178 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WCS.Model.ApiModel.AGV +{ + public class AGVCallBackRequest + { + /// + /// + /// + public string action { get; set; } + /// + /// + /// + public string areaCode { get; set; } + /// + /// + /// + public string berthCode { get; set; } + /// + /// + /// + public string callCode { get; set; } + /// + /// + /// + public string callTyp { get; set; } + /// + /// + /// + public string clientCode { get; set; } + /// + /// + /// + public decimal cooX { get; set; } + /// + /// + /// + public decimal cooY { get; set; } + /// + /// + /// + public string ctnrCode { get; set; } + /// + /// + /// + public string ctnrTyp { get; set; } + /// + /// + /// + public string currentCallCode { get; set; } + /// + /// + /// + public string currentPositionCode { get; set; } + /// + /// + /// + public string data { get; set; } + /// + /// + /// + public string dstBinCode { get; set; } + /// + /// + /// + public string eqpCode { get; set; } + /// + /// + /// + public string indBind { get; set; } + /// + /// + /// + public string layer { get; set; } + /// + /// + /// + public string mapCode { get; set; } + /// + /// + /// + public string mapDataCode { get; set; } + /// + /// + /// + public string mapShortName { get; set; } + /// + /// + /// + public string materialLot { get; set; } + /// + /// + /// + public string materialType { get; set; } + /// + /// + /// + public string method { get; set; } + /// + /// + /// + public string orgCode { get; set; } + /// + /// + /// + public string podCode { get; set; } + /// + /// + /// + public string podDir { get; set; } + /// + /// + /// + public string podNum { get; set; } + /// + /// + /// + public string podTyp { get; set; } + /// + /// + /// + public string relatedArea { get; set; } + /// + /// + /// + public string reqCode { get; set; } + /// + /// + /// + public string reqTime { get; set; } + /// + /// + /// + public string roadWayCode { get; set; } + /// + /// + /// + public string robotCode { get; set; } + /// + /// + /// + public string seq { get; set; } + /// + /// + /// + public string stgBinCode { get; set; } + /// + /// + /// + public string subTaskNum { get; set; } + /// + /// + /// + public string taskCode { get; set; } + /// + /// + /// + public string taskTyp { get; set; } + /// + /// + /// + public string tokenCode { get; set; } + /// + /// + /// + public string username { get; set; } + /// + /// + /// + public string wbCode { get; set; } + /// + /// + /// + public string whCode { get; set; } + } +} diff --git a/WCS.Model/ApiModel/LocationInfo/LocationInfoModel.cs b/WCS.Model/ApiModel/LocationInfo/LocationInfoModel.cs index e707c23..4ff6afc 100644 --- a/WCS.Model/ApiModel/LocationInfo/LocationInfoModel.cs +++ b/WCS.Model/ApiModel/LocationInfo/LocationInfoModel.cs @@ -38,6 +38,8 @@ namespace WCS.Model.ApiModel.StoreInfo /// 更新人 /// public string ModifyUser { get; set; } = string.Empty; + + public List AllowDestinationLocationArea { get; set; } = new List(); /// /// 更新时间 /// diff --git a/WCS.WebApi/Controllers/AgvCallbackServiceController.cs b/WCS.WebApi/Controllers/AgvCallbackServiceController.cs new file mode 100644 index 0000000..9f09877 --- /dev/null +++ b/WCS.WebApi/Controllers/AgvCallbackServiceController.cs @@ -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 +{ + /// + /// 主页面的接口 + /// + [ApiController] + [Route("[controller]")] + public class AgvCallbackServiceController : ControllerBase + { + + public AgvCallbackServiceController(IHomerService homerService, ISelfCheckService selfCheckService) + { + + } + + /// + /// agv任务回调 + /// + /// + /// + [Route("agvCallback")] + [HttpPost(Name = "agvCallback")] + public async Task agvCallback(AGVCallBackRequest request) + { + try + { + Logs.Write("收到AGV回调" + JsonConvert.SerializeObject(request)); + //找到任务数据 + var task = await DbHelp.db.Queryable().Where(t => t.TaskCode == request.taskCode) + .FirstAsync(); + if (task == null) + { + return new + { + Code = 0, + Message = "成功", + reqCode = "123", + }; + } + + //判断并更新数据 + var shelf = await DbHelp.db.Queryable().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, + }; + } + } + } +} diff --git a/WCS.WebApi/Controllers/PDAMatBindController.cs b/WCS.WebApi/Controllers/PDAMatBindController.cs index 49210b4..c87a85c 100644 --- a/WCS.WebApi/Controllers/PDAMatBindController.cs +++ b/WCS.WebApi/Controllers/PDAMatBindController.cs @@ -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() - .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 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() + .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() + .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() + .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() + .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, + }; + } + } } }