1.PDA端送回货架功能完善

2.选择默认区域功能优化(若选择区域索引小于选项值时会界面会跳到空白)
This commit is contained in:
hehaibing-1996
2025-02-26 19:40:17 +08:00
parent 1788149145
commit 025703fe94
5 changed files with 173 additions and 113 deletions

View File

@ -262,7 +262,11 @@
this.selectedShelfTypeIndex = getConfig("bindSelectedShelfTypeIndex", 0);
this.shelfAreaOptions = res.data.data.locationArea;
this.selectedShelfAreaIndex = getConfig("bindSelectedShelfAreaIndex", 0);
var index = getConfig("bindSelectedShelfAreaIndex", 0);
if (index + 1 < this.shelfAreaOptions.length) {
this.selectedShelfAreaIndex = index;
}
if (this.shelfId == null) {
this.shelfCode = '(工位无货架,请呼叫!)';

View File

@ -72,9 +72,10 @@
</view>
<view
style="position: fixed; bottom: 0; left: 0; width: 100%; display: flex; justify-content: space-between; align-items: center; z-index: 100;">
style="position: fixed; bottom: 5rpx; left: 0; width: 100%; display: flex; justify-content: space-between; align-items: center; z-index: 100;">
<!-- 货架区域选择 -->
<view class="picker-container1" style="position: relative;">
<view style="color: darkgray;">点击选择送回区域:</view>
<picker ref="shelfAreaPicker" :range="shelfAreaOptions" range-key="locationAreaName"
:value="selectedShelfAreaIndex" @change="onShelfAreaChange" style="font-size: 35rpx;">
<view class="uni-input">{{shelfAreaOptions[selectedShelfAreaIndex].locationAreaName}}</view>
@ -83,8 +84,9 @@
<!-- 货架类型选择 -->
<view class="picker-container" style="position: relative;">
<view style="color: darkgray;">点击选择:</view>
<picker ref="shelfTypePicker" :range="shelfTypeOptions" range-key="text" :value="selectedShelfTypeIndex"
@change="onShelfTypeChange" style="font-size: 35rpx;width: 200rpx;">
@change="onShelfTypeChange" style="font-size: 35rpx;width: 200rpx;font-weight: ;">
<view class="uni-input">{{shelfTypeOptions[selectedShelfTypeIndex].text}}</view>
</picker>
</view>
@ -337,7 +339,7 @@
return;
}
//货架送回区域是否选择
if (shelfAreaOptions[selectedShelfAreaIndex].locationAreaName = '请先扫货架码') {
if (this.shelfAreaOptions[this.selectedShelfAreaIndex].locationAreaName == '请先扫货架码' || this.shelfAreaOptions[this.selectedShelfAreaIndex].locationAreaName == '请选择') {
uni.showToast({
title: '请选择货架送回区域!',
icon: 'none',
@ -345,14 +347,25 @@
});
return;
}
//保存选择的区域信息
saveConfig("callOutSelectedShelfAreaIndex", this.selectedShelfAreaIndex);
//请求送回货架
var serverIPAndPort = getServerIPAndPort();
uni.request({
url: 'http://' + serverIPAndPort +
'/pdaProductionLineCallOut/getShelfInfoForCallOut', // 请求的接口地址
'/pdaProductionLineCallOut/callOut', // 请求的接口地址
method: 'POST', // 设置请求方式为 POST
data: {
"locationId": this.locationId,
"locationCode": this.locationCode,
"shelfId": this.shelfId,
"shelfCode": this.shelfCode,
"destinationLocationAreaId": this.shelfAreaOptions[this.selectedShelfAreaIndex].id,
"destinationLocationAreaName": this.shelfAreaOptions[this.selectedShelfAreaIndex].locationAreaName,
"ShelfTypeStr": this.shelfTypeOptions[this.selectedShelfTypeIndex].text,
"userName": this.userName,
"deviceType": "PDA"
},
@ -364,35 +377,20 @@
if (res.statusCode === 200) {
//接口返回数据为200 表示获取成功!
if (res.data.code == 200) {
//未查询到信息
if (res.data.data == null) {
uni.showToast({
title: '获取失败,请扫码重试!',
title: '送回货架呼叫成功!',
icon: 'none',
duration: 1500
});
return;
}
//绑定货架等信息
this.shelfId = res.data.data.shelfId;
this.shelfCode = res.data.data.shelfCode;
this.locationId = res.data.data.locationId;
this.locationCode = res.data.data.locationCode;
this.shelfAreaOptions = res.data.data.locationAreas;
//获取数据
this.getCurrentMatInfo();
return;
} else {
uni.showToast({
title: '获取失败:' + res.data.message,
title: '送回货架呼叫失败:' + res.data.message,
icon: 'none',
duration: 3500
});
this.clear();
//this.clear();
}
} else {
@ -401,7 +399,7 @@
icon: 'none',
duration: 3000
});
this.clear();
//this.clear();
}
},
fail: (err) => {
@ -412,7 +410,7 @@
duration: 3000
});
this.clear();
//this.clear();
},
complete: (event) => {
// 请求完成的回调函数(无论成功或失败都会调用)
@ -476,6 +474,11 @@
this.shelfAreaOptions = res.data.data.locationAreas;
var index = getConfig("callOutSelectedShelfAreaIndex", 0);
if (index + 1 < this.shelfAreaOptions.length) {
this.selectedShelfAreaIndex = index;
}
//获取数据
this.getCurrentMatInfo();
return;
@ -631,6 +634,7 @@
<style>
.picker-container1 {
border-radius: 5rpx;
border: 2rpx solid #000;
/* 设置边框宽度和颜色 */
padding: 2rpx;
@ -644,6 +648,7 @@
}
.picker-container {
border-radius: 5rpx;
border: 2rpx solid #000;
/* 设置边框宽度和颜色 */
padding: 2rpx;

View File

@ -790,7 +790,10 @@ if (uni.restoreGlobal) {
this.shelfTypeOptions = res.data.data.shelfTypes;
this.selectedShelfTypeIndex = getConfig("bindSelectedShelfTypeIndex", 0);
this.shelfAreaOptions = res.data.data.locationArea;
this.selectedShelfAreaIndex = getConfig("bindSelectedShelfAreaIndex", 0);
var index = getConfig("bindSelectedShelfAreaIndex", 0);
if (index + 1 < this.shelfAreaOptions.length) {
this.selectedShelfAreaIndex = index;
}
if (this.shelfId == null) {
this.shelfCode = "(工位无货架,请呼叫!)";
this.isNeedScanLocationCode = false;
@ -842,12 +845,12 @@ if (uni.restoreGlobal) {
}
},
complete: (event) => {
formatAppLog("log", "at pages/bind/bind.vue:325", "请求完成", event);
formatAppLog("log", "at pages/bind/bind.vue:329", "请求完成", event);
}
});
},
bindSelectedMat: function(item) {
formatAppLog("log", "at pages/bind/bind.vue:331", "用户选择了项目:", item);
formatAppLog("log", "at pages/bind/bind.vue:335", "用户选择了项目:", item);
this.matCode = item.matCode;
this.matName = item.matName;
this.matSpec = item.matSpec;
@ -911,7 +914,7 @@ if (uni.restoreGlobal) {
});
},
complete: (event) => {
formatAppLog("log", "at pages/bind/bind.vue:399", "请求完成", event);
formatAppLog("log", "at pages/bind/bind.vue:403", "请求完成", event);
}
});
},
@ -1016,7 +1019,7 @@ if (uni.restoreGlobal) {
});
},
complete: (event) => {
formatAppLog("log", "at pages/bind/bind.vue:512", "请求完成", event);
formatAppLog("log", "at pages/bind/bind.vue:516", "请求完成", event);
}
});
},
@ -1107,7 +1110,7 @@ if (uni.restoreGlobal) {
});
},
complete: (event) => {
formatAppLog("log", "at pages/bind/bind.vue:614", "请求完成", event);
formatAppLog("log", "at pages/bind/bind.vue:618", "请求完成", event);
}
});
},
@ -1133,7 +1136,7 @@ if (uni.restoreGlobal) {
this.matSpec = "";
},
handlePopupClose() {
formatAppLog("log", "at pages/bind/bind.vue:644", "弹出层已关闭");
formatAppLog("log", "at pages/bind/bind.vue:648", "弹出层已关闭");
}
}
};
@ -4736,7 +4739,7 @@ if (uni.restoreGlobal) {
const inputValue = vue.ref("");
const showPopup = (info) => {
fixedInfo.infoId = info.id;
formatAppLog("log", "at pages/productionLineCallOut/productionLineCallOut.vue:155", fixedInfo.infoId);
formatAppLog("log", "at pages/productionLineCallOut/productionLineCallOut.vue:157", fixedInfo.infoId);
fixedInfo.value.matName = info.matName;
fixedInfo.value.matCode = info.matCode;
fixedInfo.value.matSpec = info.matSpec;
@ -4874,10 +4877,10 @@ if (uni.restoreGlobal) {
this.userName = getConfig("userName", "admin");
const self = this;
recive(function(res) {
formatAppLog("log", "at pages/productionLineCallOut/productionLineCallOut.vue:309", "Success:" + res.data);
formatAppLog("log", "at pages/productionLineCallOut/productionLineCallOut.vue:311", "Success:" + res.data);
self.analysisScanCode(res.data);
}, function(err) {
formatAppLog("log", "at pages/productionLineCallOut/productionLineCallOut.vue:312", "Error:", JSON.stringify(err));
formatAppLog("log", "at pages/productionLineCallOut/productionLineCallOut.vue:314", "Error:", JSON.stringify(err));
});
},
methods: {
@ -4899,7 +4902,7 @@ if (uni.restoreGlobal) {
});
return;
}
if (shelfAreaOptions[selectedShelfAreaIndex].locationAreaName = "请先扫货架码") {
if (this.shelfAreaOptions[this.selectedShelfAreaIndex].locationAreaName == "请先扫货架码" || this.shelfAreaOptions[this.selectedShelfAreaIndex].locationAreaName == "请选择") {
uni.showToast({
title: "请选择货架送回区域!",
icon: "none",
@ -4907,14 +4910,21 @@ if (uni.restoreGlobal) {
});
return;
}
saveConfig("callOutSelectedShelfAreaIndex", this.selectedShelfAreaIndex);
var serverIPAndPort = getServerIPAndPort();
uni.request({
url: "http://" + serverIPAndPort + "/pdaProductionLineCallOut/getShelfInfoForCallOut",
url: "http://" + serverIPAndPort + "/pdaProductionLineCallOut/callOut",
// 请求的接口地址
method: "POST",
// 设置请求方式为 POST
data: {
"locationId": this.locationId,
"locationCode": this.locationCode,
"shelfId": this.shelfId,
"shelfCode": this.shelfCode,
"destinationLocationAreaId": this.shelfAreaOptions[this.selectedShelfAreaIndex].id,
"destinationLocationAreaName": this.shelfAreaOptions[this.selectedShelfAreaIndex].locationAreaName,
"ShelfTypeStr": this.shelfTypeOptions[this.selectedShelfTypeIndex].text,
"userName": this.userName,
"deviceType": "PDA"
},
@ -4925,28 +4935,18 @@ if (uni.restoreGlobal) {
success: (res) => {
if (res.statusCode === 200) {
if (res.data.code == 200) {
if (res.data.data == null) {
uni.showToast({
title: "获取失败,请扫码重试!",
title: "送回货架呼叫成功!",
icon: "none",
duration: 1500
});
return;
}
this.shelfId = res.data.data.shelfId;
this.shelfCode = res.data.data.shelfCode;
this.locationId = res.data.data.locationId;
this.locationCode = res.data.data.locationCode;
this.shelfAreaOptions = res.data.data.locationAreas;
this.getCurrentMatInfo();
return;
} else {
uni.showToast({
title: "获取失败:" + res.data.message,
title: "送回货架呼叫失败:" + res.data.message,
icon: "none",
duration: 3500
});
this.clear();
}
} else {
uni.showToast({
@ -4954,7 +4954,6 @@ if (uni.restoreGlobal) {
icon: "none",
duration: 3e3
});
this.clear();
}
},
fail: (err) => {
@ -4963,10 +4962,9 @@ if (uni.restoreGlobal) {
icon: "none",
duration: 3e3
});
this.clear();
},
complete: (event) => {
formatAppLog("log", "at pages/productionLineCallOut/productionLineCallOut.vue:419", "请求完成", event);
formatAppLog("log", "at pages/productionLineCallOut/productionLineCallOut.vue:417", "请求完成", event);
}
});
},
@ -4974,11 +4972,11 @@ if (uni.restoreGlobal) {
cameraScanCode() {
uni.scanCode({
success: (res) => {
formatAppLog("log", "at pages/productionLineCallOut/productionLineCallOut.vue:427", "扫码结果:", res.result);
formatAppLog("log", "at pages/productionLineCallOut/productionLineCallOut.vue:425", "扫码结果:", res.result);
this.analysisScanCode(res.result);
},
fail: (err) => {
formatAppLog("error", "at pages/productionLineCallOut/productionLineCallOut.vue:431", "扫码失败:", err);
formatAppLog("error", "at pages/productionLineCallOut/productionLineCallOut.vue:429", "扫码失败:", err);
}
});
},
@ -5017,6 +5015,10 @@ if (uni.restoreGlobal) {
this.locationId = res.data.data.locationId;
this.locationCode = res.data.data.locationCode;
this.shelfAreaOptions = res.data.data.locationAreas;
var index = getConfig("callOutSelectedShelfAreaIndex", 0);
if (index + 1 < this.shelfAreaOptions.length) {
this.selectedShelfAreaIndex = index;
}
this.getCurrentMatInfo();
return;
} else {
@ -5045,7 +5047,7 @@ if (uni.restoreGlobal) {
this.clear();
},
complete: (event) => {
formatAppLog("log", "at pages/productionLineCallOut/productionLineCallOut.vue:512", "请求完成", event);
formatAppLog("log", "at pages/productionLineCallOut/productionLineCallOut.vue:515", "请求完成", event);
}
});
},
@ -5120,7 +5122,7 @@ if (uni.restoreGlobal) {
this.clear();
},
complete: (event) => {
formatAppLog("log", "at pages/productionLineCallOut/productionLineCallOut.vue:595", "请求完成", event);
formatAppLog("log", "at pages/productionLineCallOut/productionLineCallOut.vue:598", "请求完成", event);
}
});
},
@ -5331,12 +5333,13 @@ if (uni.restoreGlobal) {
))
])
]),
vue.createElementVNode("view", { style: { "position": "fixed", "bottom": "0", "left": "0", "width": "100%", "display": "flex", "justify-content": "space-between", "align-items": "center", "z-index": "100" } }, [
vue.createElementVNode("view", { style: { "position": "fixed", "bottom": "5rpx", "left": "0", "width": "100%", "display": "flex", "justify-content": "space-between", "align-items": "center", "z-index": "100" } }, [
vue.createCommentVNode(" 货架区域选择 "),
vue.createElementVNode("view", {
class: "picker-container1",
style: { "position": "relative" }
}, [
vue.createElementVNode("view", { style: { "color": "darkgray" } }, "点击选择送回区域:"),
vue.createElementVNode("picker", {
ref: "shelfAreaPicker",
range: $data.shelfAreaOptions,
@ -5359,13 +5362,14 @@ if (uni.restoreGlobal) {
class: "picker-container",
style: { "position": "relative" }
}, [
vue.createElementVNode("view", { style: { "color": "darkgray" } }, "点击选择:"),
vue.createElementVNode("picker", {
ref: "shelfTypePicker",
range: $data.shelfTypeOptions,
"range-key": "text",
value: $data.selectedShelfTypeIndex,
onChange: _cache[10] || (_cache[10] = (...args) => $options.onShelfTypeChange && $options.onShelfTypeChange(...args)),
style: { "font-size": "35rpx", "width": "200rpx" }
style: { "font-size": "35rpx", "width": "200rpx", "font-weight": "" }
}, [
vue.createElementVNode(
"view",

View File

@ -11,7 +11,9 @@ namespace WCS.Model.ApiModel.PDAProductionLineCallOut
public int ShelfId { get; set; }
public string ShelfCode { get; set; }
//目标区域ID
public int LocationAreaId { get; set; }
public int DestinationLocationAreaId { get; set; }
//目标区域名称
public string DestinationLocationAreaName { get; set; }
//空货架/非空货架字符串
public string ShelfTypeStr { get; set; }
}

View File

@ -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;
@ -108,6 +110,9 @@ namespace WCS.WebApi.Controllers
LocationAreaName = t.LocationAreaName,
})
.ToListAsync();
locationAreas = locationAreas.Append(new LocationAreaInfoModel() { Id = 0, LocationAreaName = "请选择" })
.OrderBy(t => t.Id).ToList();
return new ResponseCommon()
{
Code = 200,
@ -239,26 +244,26 @@ namespace WCS.WebApi.Controllers
Data = null,
};
}
//获取位置信息
var locationInfo = await DbHelp.db.Queryable<LocationInfo>()
//获取当前工位-起点工
var startLocation = await DbHelp.db.Queryable<LocationInfo>()
.Where(t => t.Id == request.LocationId)
.FirstAsync();
if (locationInfo == null)
if (startLocation == null)
{
return new ResponseCommon()
{
Code = 201,
Message = $"送回失败:工位{request.LocationCode}不存在!",
Message = $"当前工位{request.LocationCode}不存在!",
Data = null,
};
}
if (locationInfo.IsEnable == false)
if (startLocation.IsEnable == false)
{
return new ResponseCommon()
{
Code = 201,
Message = $"送回失败:工位{locationInfo.LocationCode}已被禁用!",
Message = $"当前工位{startLocation.LocationCode}已被禁用!",
Data = null,
};
}
@ -276,7 +281,7 @@ namespace WCS.WebApi.Controllers
return new ResponseCommon()
{
Code = 301,
Message = $"送回失败:货架{request.ShelfCode}不存在或已被禁用!",
Message = $"当前货架{request.ShelfCode}不存在或已被禁用!",
Data = null,
};
}
@ -286,33 +291,29 @@ namespace WCS.WebApi.Controllers
return new ResponseCommon()
{
Code = 201,
Message = $"呼叫失败:货架{shelfInfo.ShelfCode}已有任务在运输中!",
Message = $"当前货架{shelfInfo.ShelfCode}已有任务在运输中!",
Data = null,
};
}
if (shelfInfo.CurrentLocationId != locationInfo.Id)
if (shelfInfo.CurrentLocationId != startLocation.Id)
{
return new ResponseCommon()
{
Code = 201,
Message = $"呼叫失败:货架{shelfInfo.ShelfCode}已不在工位{locationInfo.LocationCode}上!",
Message = $"当前货架{shelfInfo.ShelfCode}已不在工位{startLocation.LocationCode}上!",
Data = null,
};
}
#endregion
#region
if (request.ShelfTypeStr == "空货架")
#region
if (request.ShelfTypeStr == "空货架" || request.ShelfTypeStr == "empty")
{
var matCurrentInfos = await DbHelp.db.Queryable<MatDetailCurrentInfo>()
.Where(t => t.ShelfId == shelfInfo.Id)
.ToListAsync();
//库存更新记录
////全部删除
//DbHelp.db.Deleteable(matCurrentInfos).ExecuteCommand();
//执行删除
try
{
@ -348,13 +349,12 @@ namespace WCS.WebApi.Controllers
catch (Exception ex)
{
DbHelp.db.RollbackTran();
var response = new ResponseCommon
return new ResponseCommon
{
Code = 300,
Message = $"操作失败:{ex.Message}",
Data = null
};
return response;
}
}
//如果不是非空货架 那么就清除数量为0的库存
@ -370,14 +370,59 @@ namespace WCS.WebApi.Controllers
}
#endregion
//根据选择的区域信息获取终点
var endLocation = await DbHelp.db.Queryable<LocationInfo>()
.LeftJoin<ShelfInfo>((li, si) => (li.Id == si.CurrentLocationId && si.TransStatus == TransStatusEnum.) || (li.Id == si.DestinationLocationId && si.TransStatus == TransStatusEnum.))
.Where((li, si) => li.LocationAreaId == request.DestinationLocationAreaId)
.Where((li, si) => li.IsEnable == true)
.Select((li, si) => li)
.FirstAsync();
if (endLocation == null)
{
return new ResponseCommon()
{
Code = 201,
Message = $"目标库区[{request.DestinationLocationAreaName}]不存在空闲位置!",
Data = null,
};
}
#region AGV接口
//TO DO 调用AGV接口开始呼叫 呼叫成功更新运输状态和目标库位
var response = AGVManager.GenAgvSchedulingTask(startLocation, endLocation, shelfInfo.ShelfCode, request.UserName);
if (response.code == "0" && response.message == "成功")
{
//更新货架位置信息
shelfInfo.TransStatus = TransStatusEnum.;
shelfInfo.DestinationLocationId = endLocation.Id;
shelfInfo.DestinationLocaiotnCode = endLocation.LocationCode;
DbHelp.db.Updateable(shelfInfo).ExecuteCommand();
return new ResponseCommon()
{
Code = 200,
Message = $"送回任务发送成功!",
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)