From d9f83f95e0e34fbaa4264e8a6a37f978654d28e4 Mon Sep 17 00:00:00 2001 From: hehaibing-1996 Date: Wed, 26 Feb 2025 15:10:15 +0800 Subject: [PATCH] =?UTF-8?q?PDA=E4=BA=A7=E7=BA=BF=E5=91=BC=E5=8F=AB?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../productionLineCallIn.vue | 94 ++++++------ .../productionLineCallOut.vue | 2 +- .../dist/dev/app-plus/app-service.js | 92 +++++++----- .../PDAProductionLineCallInController.cs | 138 ++++++++++++++---- 4 files changed, 220 insertions(+), 106 deletions(-) diff --git a/PDA/PDA/pages/productionLineCallIn/productionLineCallIn.vue b/PDA/PDA/pages/productionLineCallIn/productionLineCallIn.vue index 9130d53..547c0ba 100644 --- a/PDA/PDA/pages/productionLineCallIn/productionLineCallIn.vue +++ b/PDA/PDA/pages/productionLineCallIn/productionLineCallIn.vue @@ -2,10 +2,10 @@ - + - + {{fixedInfo.shelfCode}} @@ -33,7 +33,7 @@ - + @@ -155,10 +155,7 @@ //接口返回数据为200 表示获取成功! if (res.data.code == 200) { hidePopup(); - - - proxy.queryMatList(); - + proxy.queryMatList(false); uni.showToast({ title: '呼叫成功!', icon: 'none', @@ -166,9 +163,9 @@ }); } else { uni.showToast({ - title: res.data.message, + title: '呼叫失败:' + res.data.message, icon: 'none', - duration: 2500 + duration: 4000 }); } @@ -240,6 +237,7 @@ }); }, methods: { + //扫码获取工位信息 analysisScanCode: function(encodedString) { // 去除末尾的逗号和"..."(如果有的话) encodedString = encodedString.replace(/,\s*\.\.\.$/, ''); @@ -323,18 +321,21 @@ }, //搜索获取物料信息 - queryMatList: function() { + queryMatList: function(isTip) { if (this.locationCode == null || this.locationCode == '') { - uni.showToast({ - title: '请先扫描工位码!', - icon: 'none', - duration: 1000 - }); + if (isTip) { + uni.showToast({ + title: '请先扫描工位码!', + icon: 'none', + duration: 1000 + }); + } return; } if (this.matCodeCondition == this.locationCode) { this.matCodeCondition = ''; + return; } var serverIPAndPort = getServerIPAndPort(); uni.request({ @@ -358,51 +359,62 @@ if (res.data.code == 200) { //未查询到信息 if (res.data.data == null || res.data.data.count == 0) { - uni.showToast({ - title: '获取失败!', - icon: 'none', - duration: 1500 - }); + if (isTip) { + uni.showToast({ + title: '获取失败!', + icon: 'none', + duration: 1500 + }); + + } this.clear(); return; } //有物料信息 this.cardData = res.data.data.lists; this.recordCount = res.data.data.count; - uni.showToast({ - title: '获取成功!', - icon: 'none', - duration: 100 - }); + if (isTip) { + uni.showToast({ + title: '获取成功!', + icon: 'none', + duration: 100 + }); + } } else { - uni.showToast({ - title: '获取失败:' + res.data.message, - icon: 'none', - duration: 3500 - }); + if (isTip) { + uni.showToast({ + title: '获取失败:' + res.data.message, + icon: 'none', + duration: 3500 + }); + + } this.clear(); } } else { + if (isTip) { + uni.showToast({ + title: '服务器返回错误状态码' + res.statusCode, + icon: 'none', + duration: 3000 + }); + this.clear(); + } + } + }, + fail: (err) => { + if (isTip) { + // 请求失败的回调函数 uni.showToast({ - title: '服务器返回错误状态码' + res.statusCode, + title: '请求失败:' + err.errMsg, icon: 'none', duration: 3000 }); this.clear(); } }, - fail: (err) => { - // 请求失败的回调函数 - uni.showToast({ - title: '请求失败:' + err.errMsg, - icon: 'none', - duration: 3000 - }); - - this.clear(); - }, complete: (event) => { // 请求完成的回调函数(无论成功或失败都会调用) console.log('请求完成', event); diff --git a/PDA/PDA/pages/productionLineCallOut/productionLineCallOut.vue b/PDA/PDA/pages/productionLineCallOut/productionLineCallOut.vue index 795793c..3a3f1b1 100644 --- a/PDA/PDA/pages/productionLineCallOut/productionLineCallOut.vue +++ b/PDA/PDA/pages/productionLineCallOut/productionLineCallOut.vue @@ -546,7 +546,7 @@ uni.showToast({ title: '获取成功!', icon: 'none', - duration: 100 + duration: 500 }); } else { 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 9fd97ea..34b1168 100644 --- a/PDA/PDA/unpackage/dist/dev/app-plus/app-service.js +++ b/PDA/PDA/unpackage/dist/dev/app-plus/app-service.js @@ -4239,7 +4239,7 @@ if (uni.restoreGlobal) { if (res.statusCode === 200) { if (res.data.code == 200) { hidePopup(); - proxy.queryMatList(); + proxy.queryMatList(false); uni.showToast({ title: "呼叫成功!", icon: "none", @@ -4247,9 +4247,9 @@ if (uni.restoreGlobal) { }); } else { uni.showToast({ - title: res.data.message, + title: "呼叫失败:" + res.data.message, icon: "none", - duration: 2500 + duration: 4e3 }); } } else { @@ -4308,13 +4308,14 @@ if (uni.restoreGlobal) { this.userName = getConfig("userName", "admin"); const self = this; recive(function(res) { - formatAppLog("log", "at pages/productionLineCallIn/productionLineCallIn.vue:235", "Success:" + res.data); + formatAppLog("log", "at pages/productionLineCallIn/productionLineCallIn.vue:232", "Success:" + res.data); self.analysisScanCode(res.data); }, function(err) { - formatAppLog("log", "at pages/productionLineCallIn/productionLineCallIn.vue:239", "Error:", JSON.stringify(err)); + formatAppLog("log", "at pages/productionLineCallIn/productionLineCallIn.vue:236", "Error:", JSON.stringify(err)); }); }, methods: { + //扫码获取工位信息 analysisScanCode: function(encodedString) { encodedString = encodedString.replace(/,\s*\.\.\.$/, ""); this.locationCode = encodedString; @@ -4375,22 +4376,25 @@ if (uni.restoreGlobal) { this.clearLocation(); }, complete: (event) => { - formatAppLog("log", "at pages/productionLineCallIn/productionLineCallIn.vue:318", "请求完成", event); + formatAppLog("log", "at pages/productionLineCallIn/productionLineCallIn.vue:316", "请求完成", event); } }); }, //搜索获取物料信息 - queryMatList: function() { + queryMatList: function(isTip) { if (this.locationCode == null || this.locationCode == "") { - uni.showToast({ - title: "请先扫描工位码!", - icon: "none", - duration: 1e3 - }); + if (isTip) { + uni.showToast({ + title: "请先扫描工位码!", + icon: "none", + duration: 1e3 + }); + } return; } if (this.matCodeCondition == this.locationCode) { this.matCodeCondition = ""; + return; } var serverIPAndPort = getServerIPAndPort(); uni.request({ @@ -4413,48 +4417,58 @@ if (uni.restoreGlobal) { if (res.statusCode === 200) { if (res.data.code == 200) { if (res.data.data == null || res.data.data.count == 0) { - uni.showToast({ - title: "获取失败!", - icon: "none", - duration: 1500 - }); + if (isTip) { + uni.showToast({ + title: "获取失败!", + icon: "none", + duration: 1500 + }); + } this.clear(); return; } this.cardData = res.data.data.lists; this.recordCount = res.data.data.count; - uni.showToast({ - title: "获取成功!", - icon: "none", - duration: 100 - }); + if (isTip) { + uni.showToast({ + title: "获取成功!", + icon: "none", + duration: 100 + }); + } } else { - uni.showToast({ - title: "获取失败:" + res.data.message, - icon: "none", - duration: 3500 - }); + if (isTip) { + uni.showToast({ + title: "获取失败:" + res.data.message, + icon: "none", + duration: 3500 + }); + } this.clear(); } } else { + if (isTip) { + uni.showToast({ + title: "服务器返回错误状态码" + res.statusCode, + icon: "none", + duration: 3e3 + }); + this.clear(); + } + } + }, + fail: (err) => { + if (isTip) { uni.showToast({ - title: "服务器返回错误状态码" + res.statusCode, + title: "请求失败:" + err.errMsg, icon: "none", duration: 3e3 }); this.clear(); } }, - fail: (err) => { - uni.showToast({ - title: "请求失败:" + err.errMsg, - icon: "none", - duration: 3e3 - }); - this.clear(); - }, complete: (event) => { - formatAppLog("log", "at pages/productionLineCallIn/productionLineCallIn.vue:408", "请求完成", event); + formatAppLog("log", "at pages/productionLineCallIn/productionLineCallIn.vue:420", "请求完成", event); } }); }, @@ -4564,7 +4578,7 @@ if (uni.restoreGlobal) { vue.createElementVNode("view", { style: { "flex": "3" } }), vue.createElementVNode("view", { style: { "flex": "30" } }, [ vue.createElementVNode("button", { - onClick: _cache[4] || (_cache[4] = (...args) => $options.queryMatList && $options.queryMatList(...args)) + onClick: _cache[4] || (_cache[4] = ($event) => $options.queryMatList(true)) }, "查询") ]) ]) @@ -4993,7 +5007,7 @@ if (uni.restoreGlobal) { uni.showToast({ title: "获取成功!", icon: "none", - duration: 100 + duration: 500 }); } else { uni.showToast({ diff --git a/WCS.WebApi/Controllers/PDAProductionLineCallInController.cs b/WCS.WebApi/Controllers/PDAProductionLineCallInController.cs index e9f4502..f2f9da7 100644 --- a/WCS.WebApi/Controllers/PDAProductionLineCallInController.cs +++ b/WCS.WebApi/Controllers/PDAProductionLineCallInController.cs @@ -1,5 +1,7 @@ using Microsoft.AspNetCore.Mvc; +using System; using WCS.BLL.DbModels; +using WCS.BLL.Manager; using WCS.BLL.Services.IService; using WCS.BLL.Services.Service; using WCS.DAL.Db; @@ -117,7 +119,7 @@ namespace WCS.WebApi.Controllers return new ResponseCommon() { Code = 201, - Message = $"参数错误:请重新扫描工位码!", + Message = $"参数错误,请重新扫描工位码!", Data = null, }; } @@ -130,7 +132,7 @@ namespace WCS.WebApi.Controllers return new ResponseCommon() { Code = 201, - Message = $"获取失败:工位{request.LocationCode}不存在!", + Message = $"工位{request.LocationCode}不存在!", Data = null, }; } @@ -139,20 +141,24 @@ namespace WCS.WebApi.Controllers return new ResponseCommon() { Code = 201, - Message = $"获取失败:工位{locationInfo.LocationCode}已被禁用!", + Message = $"工位{locationInfo.LocationCode}已被禁用!", Data = null, }; } var shelfInfo = await DbHelp.db.Queryable() - .Where(t => t.CurrentLocationId == locationInfo.Id) + .Where(t => t.CurrentLocationId == locationInfo.Id || t.DestinationLocationId == locationInfo.Id) .FirstAsync(); if (shelfInfo != null) { + if (shelfInfo.TransStatus == TransStatusEnum.运输中) + { + shelfInfo.ShelfCode = shelfInfo.ShelfCode + "(运输中)"; + } return new ResponseCommon() { Code = 301, - Message = $"获取失败:工位{locationInfo.LocationCode}已被货架{shelfInfo.ShelfCode}占用!", + Message = $"当前工位[{locationInfo.LocationCode}]\r\n已被货架[{shelfInfo.ShelfCode}]占用\r\n无法通过此功能进行呼叫!", Data = null, }; } @@ -163,7 +169,7 @@ namespace WCS.WebApi.Controllers .LeftJoin((mci, si) => mci.ShelfId == si.Id) //货架状态是静止的 代表这个货架没有被呼叫走哦 .LeftJoin((mci, si, li) => (si.TransStatus == TransStatusEnum.静止 && si.CurrentLocationId == li.Id)) - .WhereIF(!string.IsNullOrEmpty(request.MatCodeCondition), (mci, si, li) => mci.MatCode.Contains(request.MatCodeCondition)) + .WhereIF(!string.IsNullOrEmpty(request.MatCodeCondition), (mci, si, li) => mci.MatCode.Contains(request.MatCodeCondition) || mci.MatName.Contains(request.MatCodeCondition)) .Select((mci, si, li) => new MatDetailCurrentInfoModel() { Id = mci.Id, @@ -235,42 +241,55 @@ namespace WCS.WebApi.Controllers return new ResponseCommon() { Code = 201, - Message = $"呼叫失败:请重新扫描工位码!", + Message = $"请重新扫描工位码!", Data = null, }; } //获取位置信息 - var locationInfo = await DbHelp.db.Queryable() + var endLocation = await DbHelp.db.Queryable() .Where(t => t.Id == request.LocationId) .FirstAsync(); - if (locationInfo == null) + if (endLocation == null) { return new ResponseCommon() { Code = 201, - Message = $"呼叫失败:工位{request.LocationCode}不存在!", + Message = $"当前工位{request.LocationCode}不存在!", Data = null, }; } - if (locationInfo.IsEnable == false) + if (endLocation.IsEnable == false) { return new ResponseCommon() { Code = 201, - Message = $"呼叫失败:工位{locationInfo.LocationCode}已被禁用!", + Message = $"当前工位{endLocation.LocationCode}已被禁用!", Data = null, }; } var shelfInfo = await DbHelp.db.Queryable() - .Where(t => t.CurrentLocationId == locationInfo.Id) + .Where(t => t.CurrentLocationId == endLocation.Id && t.TransStatus == TransStatusEnum.静止) .FirstAsync(); if (shelfInfo != null) { return new ResponseCommon() { Code = 301, - Message = $"呼叫失败:工位{locationInfo.LocationCode}已被货架{shelfInfo.ShelfCode}占用!", + Message = $"当前工位{endLocation.LocationCode}已被货架{shelfInfo.ShelfCode}占用!", + Data = null, + }; + } + + shelfInfo = await DbHelp.db.Queryable() + .Where(t => t.DestinationLocationId == endLocation.Id && t.TransStatus == TransStatusEnum.运输中) + .FirstAsync(); + if (shelfInfo != null) + { + return new ResponseCommon() + { + Code = 301, + Message = $"当前工位{endLocation.LocationCode}已呼叫货架{shelfInfo.ShelfCode}!\r\n请勿重新呼叫!", Data = null, }; } @@ -286,31 +305,100 @@ namespace WCS.WebApi.Controllers return new ResponseCommon() { Code = 201, - Message = $"呼叫失败:货架{shelfInfo.ShelfCode}不存在或已被禁用!", + Message = $"货架{shelfInfo.ShelfCode}不存在或已被禁用!", Data = null, }; } - if (shelfInfo.TransStatus == TransStatusEnum.运输中) + { + if (shelfInfo.DestinationLocationId == request.LocationId) + { + return new ResponseCommon() + { + Code = 201, + Message = $"呼叫失败:货架{shelfInfo.ShelfCode}已呼叫至当前工位,请等待!", + Data = null, + }; + } + else + { + return new ResponseCommon() + { + Code = 201, + Message = $"呼叫失败:货架{shelfInfo.ShelfCode}正在被运输中,请选择其他货架!", + Data = null, + }; + } + } + + //获取起点位置 + if (shelfInfo.CurrentLocationId == 0 || string.IsNullOrEmpty(shelfInfo.CurrentLocaiotnCode)) { return new ResponseCommon() { Code = 201, - Message = $"呼叫失败:货架{shelfInfo.ShelfCode}正在运输中!", + Message = $"货架{shelfInfo.ShelfCode}未与位置绑定,无法呼叫!", + Data = null, + }; + } + var startLocation = await DbHelp.db.Queryable() + .Where(t => t.Id == shelfInfo.CurrentLocationId) + .FirstAsync(); + if (startLocation == null) + { + return new ResponseCommon() + { + Code = 201, + Message = $"货架{shelfInfo.ShelfCode}未与位置绑定,无法呼叫!", + Data = null, + }; + } + if (startLocation.IsEnable == false) + { + return new ResponseCommon() + { + Code = 201, + Message = $"货架{shelfInfo.ShelfCode}所在位置已被禁用,无法呼叫!", Data = null, }; } #endregion - #region - //TO DO 调用AGV接口开始呼叫 呼叫成功更新运输状态和目标库位 - - return new ResponseCommon() + #region 调用AGV接口 + var response = AGVManager.GenAgvSchedulingTask(startLocation, endLocation, shelfInfo.ShelfCode, request.UserName); + if (response.code == "0" && response.message == "成功") { - Code = 200, - Message = $"呼叫成功!", - Data = null, - }; + //更新货架位置信息 + shelfInfo.TransStatus = TransStatusEnum.运输中; + shelfInfo.DestinationLocationId = endLocation.Id; + shelfInfo.DestinationLocaiotnCode = endLocation.LocationCode; + DbHelp.db.Updateable(shelfInfo).ExecuteCommand(); + + return new ResponseCommon() + { + Code = 200, + Message = "success", + Data = null, + }; + } + else if (response.code == "-999") + { + return new ResponseCommon() + { + Code = 201, + Message = $"{response.message}\r\n请重试或等待上一个任务完成", + Data = null, + }; + } + else + { + return new ResponseCommon() + { + Code = 201, + Message = $"海康RCS返回:{response.message}", + Data = null, + }; + } #endregion } catch (Exception ex)