PDA物料绑定功能优化

This commit is contained in:
hehaibing-1996
2025-02-23 14:46:12 +08:00
parent f9d832ef6c
commit 60e996ebd2
5 changed files with 225 additions and 50 deletions

View File

@ -102,8 +102,16 @@
<view style="flex: 1;">
<view style="flex: 40;text-align: center;">
<button style="margin: 50rpx;font-size: 40rpx;" size="mini">送货架</button>
<button style="margin: 50rpx;font-size: 40rpx;" size="mini">送货架</button>
<view class="picker-container">
<view> 点击选择送回区域</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>
</picker>
</view>
<button style="font-size: 40rpx;margin: 15rpx;background-color: green;" size="mini">送货架</button>
</view>
</view>
</view>
@ -156,6 +164,13 @@
matSpec: '',
matQty: 100, //默认数量值
// 货架区域选项
shelfAreaOptions: [{
id: 1,
locationAreaName: '请先获取工位码'
}],
selectedShelfAreaIndex: 0, // 选择的货架区域索引
userName: '', //当前登录的用户名
}
},
@ -189,6 +204,10 @@
// originalString += String.fromCharCode(byteArray[i]);
// }
this.locationCode = encodedString;
this.getShelfInfoByLocationCode();
},
getShelfInfoByLocationCode: function() {
//调用接口获取当前工位信息 当前工位是否有货架
var serverIPAndPort = getServerIPAndPort();
uni.request({
@ -196,6 +215,7 @@
method: 'POST', // 设置请求方式为 POST
data: {
"locationCode": this.locationCode,
"shelfCode": this.locationCode,
"userName": this.userName,
"deviceType": "PDA"
},
@ -208,6 +228,7 @@
//接口返回数据为200 表示获取成功!
if (res.data.code == 200) {
this.locationId = res.data.data.locationId;
this.locationCode = res.data.data.locationCode;
this.shelfId = res.data.data.shelfId;
this.shelfCode = res.data.data.shelfCode;
@ -216,9 +237,11 @@
this.isNeedScanLocationCode = false;
this.isNeedCallShelfCode = true;
this.placeholderText = '请呼叫货架';
}
else
{
} else if (this.shelfId != null && this.shelfCode != null && this
.shelfCode.includes('运输中')) {
this.placeholderText = '请等待货架运输';
} else {
this.isNeedScanLocationCode = false;
this.isNeedCallShelfCode = false;
this.placeholderText = '输入编码或名称';
@ -234,7 +257,7 @@
uni.showToast({
title: '获取失败:' + res.data.message,
icon: 'none',
duration: 3500
duration: 3600
});
this.clear();
}
@ -263,7 +286,6 @@
console.log('请求完成', event);
}
});
},
bindSelectedMat: function(item) {
@ -355,6 +377,8 @@
icon: 'none',
duration: 1000
});
this.getShelfInfoByLocationCode();
return;
}
if (this.matCodeCondition == null || this.matCodeCondition == '') {
@ -455,6 +479,16 @@
</script>
<style>
.picker-container {
border: 2rpx solid #000;
/* 设置边框宽度和颜色 */
margin: 25rpx auto;
/* 上下边距为5rpx左右边距自动以实现水平居中 */
width: 400rpx;
/* 设置宽度 */
/* 其他样式保持不变 */
}
.uni-input-wrapper {
/* #ifndef APP-NVUE */
display: flex;

View File

@ -715,6 +715,13 @@ if (uni.restoreGlobal) {
matSpec: "",
matQty: 100,
//默认数量值
// 货架区域选项
shelfAreaOptions: [{
id: 1,
locationAreaName: "请先获取工位码"
}],
selectedShelfAreaIndex: 0,
// 选择的货架区域索引
userName: ""
//当前登录的用户名
};
@ -723,16 +730,19 @@ if (uni.restoreGlobal) {
this.userName = getConfig("userName", "admin");
const self = this;
recive(function(res) {
formatAppLog("log", "at pages/bind/bind.vue:167", "Success:" + res.data);
formatAppLog("log", "at pages/bind/bind.vue:182", "Success:" + res.data);
self.analysisScanCode(res.data);
}, function(err) {
formatAppLog("log", "at pages/bind/bind.vue:170", "Error:", JSON.stringify(err));
formatAppLog("log", "at pages/bind/bind.vue:185", "Error:", JSON.stringify(err));
});
},
methods: {
analysisScanCode: function(encodedString) {
encodedString = encodedString.replace(/,\s*\.\.\.$/, "");
this.locationCode = encodedString;
this.getShelfInfoByLocationCode();
},
getShelfInfoByLocationCode: function() {
var serverIPAndPort = getServerIPAndPort();
uni.request({
url: "http://" + serverIPAndPort + "/pdaMatBind/getShelfInfoByLocationCode",
@ -741,6 +751,7 @@ if (uni.restoreGlobal) {
// 设置请求方式为 POST
data: {
"locationCode": this.locationCode,
"shelfCode": this.locationCode,
"userName": this.userName,
"deviceType": "PDA"
},
@ -752,6 +763,7 @@ if (uni.restoreGlobal) {
if (res.statusCode === 200) {
if (res.data.code == 200) {
this.locationId = res.data.data.locationId;
this.locationCode = res.data.data.locationCode;
this.shelfId = res.data.data.shelfId;
this.shelfCode = res.data.data.shelfCode;
if (this.shelfId == null) {
@ -759,6 +771,8 @@ if (uni.restoreGlobal) {
this.isNeedScanLocationCode = false;
this.isNeedCallShelfCode = true;
this.placeholderText = "请呼叫货架";
} else if (this.shelfId != null && this.shelfCode != null && this.shelfCode.includes("运输中")) {
this.placeholderText = "请等待货架运输";
} else {
this.isNeedScanLocationCode = false;
this.isNeedCallShelfCode = false;
@ -773,7 +787,7 @@ if (uni.restoreGlobal) {
uni.showToast({
title: "获取失败:" + res.data.message,
icon: "none",
duration: 3500
duration: 3600
});
this.clear();
}
@ -795,12 +809,12 @@ if (uni.restoreGlobal) {
this.clear();
},
complete: (event) => {
formatAppLog("log", "at pages/bind/bind.vue:263", "请求完成", event);
formatAppLog("log", "at pages/bind/bind.vue:286", "请求完成", event);
}
});
},
bindSelectedMat: function(item) {
formatAppLog("log", "at pages/bind/bind.vue:270", "用户选择了项目:", item);
formatAppLog("log", "at pages/bind/bind.vue:292", "用户选择了项目:", item);
this.matCode = item.matCode;
this.matName = item.matName;
this.matSpec = item.matSpec;
@ -863,7 +877,7 @@ if (uni.restoreGlobal) {
});
},
complete: (event) => {
formatAppLog("log", "at pages/bind/bind.vue:337", "请求完成", event);
formatAppLog("log", "at pages/bind/bind.vue:359", "请求完成", event);
}
});
},
@ -882,6 +896,7 @@ if (uni.restoreGlobal) {
icon: "none",
duration: 1e3
});
this.getShelfInfoByLocationCode();
return;
}
if (this.matCodeCondition == null || this.matCodeCondition == "") {
@ -947,7 +962,7 @@ if (uni.restoreGlobal) {
});
},
complete: (event) => {
formatAppLog("log", "at pages/bind/bind.vue:427", "请求完成", event);
formatAppLog("log", "at pages/bind/bind.vue:451", "请求完成", event);
}
});
},
@ -967,7 +982,7 @@ if (uni.restoreGlobal) {
this.matSpec = "";
},
handlePopupClose() {
formatAppLog("log", "at pages/bind/bind.vue:451", "弹出层已关闭");
formatAppLog("log", "at pages/bind/bind.vue:475", "弹出层已关闭");
}
}
};
@ -1140,12 +1155,27 @@ if (uni.restoreGlobal) {
]),
vue.createElementVNode("view", { style: { "flex": "1" } }, [
vue.createElementVNode("view", { style: { "flex": "40", "text-align": "center" } }, [
vue.createElementVNode("view", { class: "picker-container" }, [
vue.createElementVNode("view", null, " 点击选择送回区域:"),
vue.createElementVNode("picker", {
ref: "shelfAreaPicker",
range: $data.shelfAreaOptions,
"range-key": "locationAreaName",
value: $data.selectedShelfAreaIndex,
onChange: _cache[6] || (_cache[6] = (...args) => _ctx.onShelfAreaChange && _ctx.onShelfAreaChange(...args)),
style: { "font-size": "35rpx" }
}, [
vue.createElementVNode(
"view",
{ class: "uni-input" },
vue.toDisplayString($data.shelfAreaOptions[$data.selectedShelfAreaIndex].locationAreaName),
1
/* TEXT */
)
], 40, ["range", "value"])
]),
vue.createElementVNode("button", {
style: { "margin": "50rpx", "font-size": "40rpx" },
size: "mini"
}, "送货架"),
vue.createElementVNode("button", {
style: { "margin": "50rpx", "font-size": "40rpx" },
style: { "font-size": "40rpx", "margin": "15rpx", "background-color": "green" },
size: "mini"
}, "送货架")
])

View File

@ -54,14 +54,27 @@ namespace WCS.BLL.Services.Service
.Where(t => t.IsEnable == true)
.FirstAsync();
if (shelf != null)
{
if (shelf.TransStatus == TransStatusEnum.)
{
return new ResponseCommon()
{
Code = 205,
Message = $"货架【{shelf.ShelfCode}】在工位上或即将在工位上,请勿重复呼叫!",
Message = $"货架【{shelf.ShelfCode}】静止在工位上,请勿重复呼叫!",
Data = null,
};
}
//运输中
else
{
return new ResponseCommon()
{
Code = 205,
Message = $"货架【{shelf.ShelfCode}】运输中,请勿重复呼叫!\r\n货架到达后扫货架码即可继续绑定。",
Data = null,
};
}
}
#endregion
//获取空货架进行呼叫

View File

@ -10,5 +10,10 @@ namespace WCS.Model.ApiModel.PDAMatBind
/// 位置编码 工位编码
/// </summary>
public string LocationCode { get; set; }
/// <summary>
/// 货架编码
/// </summary>
public string ShelfCode { get; set; }
}
}

View File

@ -30,19 +30,32 @@ namespace WCS.WebApi.Controllers
[HttpPost(Name = "getShelfInfoByLocationCode")]
public async Task<ResponseBase> getShelfInfoByLocationCode(GetShelfInfoByLocationCodeRequest request)
{
//不含XY就不是工位
if (!request.LocationCode.Contains("XY"))
{
request.LocationCode = string.Empty;
}
//判断参数
if (string.IsNullOrEmpty(request.LocationCode))
if (string.IsNullOrEmpty(request.LocationCode) && string.IsNullOrEmpty(request.ShelfCode))
{
return new ResponseCommon()
{
Code = 201,
Message = "工位编码为空",
Message = "工位码或货架码为空,请重新扫码",
Data = null,
};
}
//获取是否存在当前工位
var location = await DbHelp.db.Queryable<LocationInfo>()
//扫的工位码
LocationInfo? location;
ShelfInfo? shelf;
if (!string.IsNullOrEmpty(request.LocationCode))
{
//TO DO 在哪些物料区域才能进行物料绑定
location = await DbHelp.db.Queryable<LocationInfo>()
.Where(t => t.LocationCode == request.LocationCode)
.Where(t => t.IsEnable == true)
.FirstAsync();
@ -57,11 +70,71 @@ namespace WCS.WebApi.Controllers
}
//获取当前工位的货架
var shelf = await DbHelp.db.Queryable<ShelfInfo>()
shelf = await DbHelp.db.Queryable<ShelfInfo>()
.Where(t => (t.CurrentLocationId == location.Id && t.TransStatus == TransStatusEnum.)
|| (t.DestinationLocationId == location.Id && t.TransStatus == TransStatusEnum.))//解决产线人员 呼叫后货架未到的时候绑定的问题
|| (t.DestinationLocationId == location.Id && t.TransStatus == TransStatusEnum.)//解决产线人员 呼叫后货架未到的时候绑定的问题
)
.Where(t => t.IsEnable)
.FirstAsync();
}
//货架到位置了 扫的货架码
else
{
//获取当前工位的货架
shelf = await DbHelp.db.Queryable<ShelfInfo>()
.Where(t => t.ShelfCode == request.ShelfCode)
.Where(t => t.IsEnable)
.FirstAsync();
if (shelf == null)
{
return new ResponseCommon()
{
Code = 201,
Message = $"货架[{request.ShelfCode}]不存在或已被禁用!",
Data = null,
};
}
if (shelf.TransStatus != TransStatusEnum.)
{
return new ResponseCommon()
{
Code = 201,
Message = $"货架[{request.ShelfCode}]处于运输中状态!\r\n请等待货架运输完成再进行操作",
Data = null,
};
}
if (shelf.CurrentLocationId == 0 || string.IsNullOrEmpty(shelf.CurrentLocaiotnCode))
{
return new ResponseCommon()
{
Code = 201,
Message = $"货架[{request.ShelfCode}]未绑定工位!请尝试将货架与位置绑定后进行操作!",
Data = null,
};
}
location = await DbHelp.db.Queryable<LocationInfo>()
.Where(t => t.LocationCode == shelf.CurrentLocaiotnCode)
.Where(t => t.IsEnable == true)
.FirstAsync();
if (location == null)
{
return new ResponseCommon()
{
Code = 201,
Message = $"工位[{shelf.CurrentLocaiotnCode}]不存在或已被禁用!\r\n请联系系统管理人员维护工位信息",
Data = null,
};
}
}
if (shelf != null && shelf.TransStatus == TransStatusEnum.)
{
shelf.ShelfCode = shelf.ShelfCode + "(运输中)";
}
return new ResponseBase<GetShelfInfoByLocationReturnData>()
{
@ -70,7 +143,7 @@ namespace WCS.WebApi.Controllers
Data = new GetShelfInfoByLocationReturnData()
{
LocationId = location.Id,
LocationCode = request.LocationCode,
LocationCode = location.LocationCode,
ShelfId = shelf?.Id,
ShelfCode = shelf?.ShelfCode,
},
@ -150,6 +223,16 @@ namespace WCS.WebApi.Controllers
};
}
if (request.ShelfCode.Contains("运输中"))
{
return new ResponseCommon()
{
Code = 201,
Message = "货架运输中!\r\n请等待运输完成后扫货架码或点查询后再进行绑定",
Data = null,
};
}
if (request.MatBaseInfoId == 0 || string.IsNullOrEmpty(request.MatCode))
{
return new ResponseCommon()
@ -215,6 +298,16 @@ namespace WCS.WebApi.Controllers
};
}
if (shelf.TransStatus == TransStatusEnum.)
{
return new ResponseCommon()
{
Code = 201,
Message = "货架运输中!\r\n请等待运输完成后扫货架码或点查询后再进行绑定",
Data = null,
};
}
//获取物料基础信息
var matBaseInfo = await DbHelp.db.Queryable<MatBaseInfo>()
.Where(t => t.Id == request.MatBaseInfoId)