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

View File

@ -715,6 +715,13 @@ if (uni.restoreGlobal) {
matSpec: "", matSpec: "",
matQty: 100, matQty: 100,
//默认数量值 //默认数量值
// 货架区域选项
shelfAreaOptions: [{
id: 1,
locationAreaName: "请先获取工位码"
}],
selectedShelfAreaIndex: 0,
// 选择的货架区域索引
userName: "" userName: ""
//当前登录的用户名 //当前登录的用户名
}; };
@ -723,16 +730,19 @@ if (uni.restoreGlobal) {
this.userName = getConfig("userName", "admin"); this.userName = getConfig("userName", "admin");
const self = this; const self = this;
recive(function(res) { 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); self.analysisScanCode(res.data);
}, function(err) { }, 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: { methods: {
analysisScanCode: function(encodedString) { analysisScanCode: function(encodedString) {
encodedString = encodedString.replace(/,\s*\.\.\.$/, ""); encodedString = encodedString.replace(/,\s*\.\.\.$/, "");
this.locationCode = encodedString; this.locationCode = encodedString;
this.getShelfInfoByLocationCode();
},
getShelfInfoByLocationCode: function() {
var serverIPAndPort = getServerIPAndPort(); var serverIPAndPort = getServerIPAndPort();
uni.request({ uni.request({
url: "http://" + serverIPAndPort + "/pdaMatBind/getShelfInfoByLocationCode", url: "http://" + serverIPAndPort + "/pdaMatBind/getShelfInfoByLocationCode",
@ -741,6 +751,7 @@ if (uni.restoreGlobal) {
// 设置请求方式为 POST // 设置请求方式为 POST
data: { data: {
"locationCode": this.locationCode, "locationCode": this.locationCode,
"shelfCode": this.locationCode,
"userName": this.userName, "userName": this.userName,
"deviceType": "PDA" "deviceType": "PDA"
}, },
@ -752,6 +763,7 @@ if (uni.restoreGlobal) {
if (res.statusCode === 200) { if (res.statusCode === 200) {
if (res.data.code == 200) { if (res.data.code == 200) {
this.locationId = res.data.data.locationId; this.locationId = res.data.data.locationId;
this.locationCode = res.data.data.locationCode;
this.shelfId = res.data.data.shelfId; this.shelfId = res.data.data.shelfId;
this.shelfCode = res.data.data.shelfCode; this.shelfCode = res.data.data.shelfCode;
if (this.shelfId == null) { if (this.shelfId == null) {
@ -759,6 +771,8 @@ if (uni.restoreGlobal) {
this.isNeedScanLocationCode = false; this.isNeedScanLocationCode = false;
this.isNeedCallShelfCode = true; this.isNeedCallShelfCode = true;
this.placeholderText = "请呼叫货架"; this.placeholderText = "请呼叫货架";
} else if (this.shelfId != null && this.shelfCode != null && this.shelfCode.includes("运输中")) {
this.placeholderText = "请等待货架运输";
} else { } else {
this.isNeedScanLocationCode = false; this.isNeedScanLocationCode = false;
this.isNeedCallShelfCode = false; this.isNeedCallShelfCode = false;
@ -773,7 +787,7 @@ if (uni.restoreGlobal) {
uni.showToast({ uni.showToast({
title: "获取失败:" + res.data.message, title: "获取失败:" + res.data.message,
icon: "none", icon: "none",
duration: 3500 duration: 3600
}); });
this.clear(); this.clear();
} }
@ -795,12 +809,12 @@ if (uni.restoreGlobal) {
this.clear(); this.clear();
}, },
complete: (event) => { complete: (event) => {
formatAppLog("log", "at pages/bind/bind.vue:263", "请求完成", event); formatAppLog("log", "at pages/bind/bind.vue:286", "请求完成", event);
} }
}); });
}, },
bindSelectedMat: function(item) { 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.matCode = item.matCode;
this.matName = item.matName; this.matName = item.matName;
this.matSpec = item.matSpec; this.matSpec = item.matSpec;
@ -863,7 +877,7 @@ if (uni.restoreGlobal) {
}); });
}, },
complete: (event) => { 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", icon: "none",
duration: 1e3 duration: 1e3
}); });
this.getShelfInfoByLocationCode();
return; return;
} }
if (this.matCodeCondition == null || this.matCodeCondition == "") { if (this.matCodeCondition == null || this.matCodeCondition == "") {
@ -947,7 +962,7 @@ if (uni.restoreGlobal) {
}); });
}, },
complete: (event) => { 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 = ""; this.matSpec = "";
}, },
handlePopupClose() { 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": "1" } }, [
vue.createElementVNode("view", { style: { "flex": "40", "text-align": "center" } }, [ 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", { vue.createElementVNode("button", {
style: { "margin": "50rpx", "font-size": "40rpx" }, style: { "font-size": "40rpx", "margin": "15rpx", "background-color": "green" },
size: "mini"
}, "送货架"),
vue.createElementVNode("button", {
style: { "margin": "50rpx", "font-size": "40rpx" },
size: "mini" size: "mini"
}, "送货架") }, "送货架")
]) ])

View File

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

View File

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

View File

@ -30,38 +30,111 @@ namespace WCS.WebApi.Controllers
[HttpPost(Name = "getShelfInfoByLocationCode")] [HttpPost(Name = "getShelfInfoByLocationCode")]
public async Task<ResponseBase> getShelfInfoByLocationCode(GetShelfInfoByLocationCodeRequest request) 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() return new ResponseCommon()
{ {
Code = 201, Code = 201,
Message = "工位编码为空", Message = "工位码或货架码为空,请重新扫码",
Data = null, Data = null,
}; };
} }
//获取是否存在当前工位 //获取是否存在当前工位
var location = await DbHelp.db.Queryable<LocationInfo>() //扫的工位码
.Where(t => t.LocationCode == request.LocationCode) LocationInfo? location;
.Where(t => t.IsEnable == true) ShelfInfo? shelf;
.FirstAsync();
if (location == null) if (!string.IsNullOrEmpty(request.LocationCode))
{ {
return new ResponseCommon() //TO DO 在哪些物料区域才能进行物料绑定
location = await DbHelp.db.Queryable<LocationInfo>()
.Where(t => t.LocationCode == request.LocationCode)
.Where(t => t.IsEnable == true)
.FirstAsync();
if (location == null)
{ {
Code = 201, return new ResponseCommon()
Message = $"工位[{request.LocationCode}]不存在或已被禁用!\r\n请联系系统管理人员维护工位信息", {
Data = null, Code = 201,
}; Message = $"工位[{request.LocationCode}]不存在或已被禁用!\r\n请联系系统管理人员维护工位信息",
Data = null,
};
}
//获取当前工位的货架
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.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.)
var shelf = await DbHelp.db.Queryable<ShelfInfo>() {
.Where(t => (t.CurrentLocationId == location.Id && t.TransStatus == TransStatusEnum.) shelf.ShelfCode = shelf.ShelfCode + "(运输中)";
|| (t.DestinationLocationId == location.Id && t.TransStatus == TransStatusEnum.))//解决产线人员 呼叫后货架未到的时候绑定的问题 }
.Where(t => t.IsEnable)
.FirstAsync();
return new ResponseBase<GetShelfInfoByLocationReturnData>() return new ResponseBase<GetShelfInfoByLocationReturnData>()
{ {
@ -70,7 +143,7 @@ namespace WCS.WebApi.Controllers
Data = new GetShelfInfoByLocationReturnData() Data = new GetShelfInfoByLocationReturnData()
{ {
LocationId = location.Id, LocationId = location.Id,
LocationCode = request.LocationCode, LocationCode = location.LocationCode,
ShelfId = shelf?.Id, ShelfId = shelf?.Id,
ShelfCode = shelf?.ShelfCode, 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)) if (request.MatBaseInfoId == 0 || string.IsNullOrEmpty(request.MatCode))
{ {
return new ResponseCommon() 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>() var matBaseInfo = await DbHelp.db.Queryable<MatBaseInfo>()
.Where(t => t.Id == request.MatBaseInfoId) .Where(t => t.Id == request.MatBaseInfoId)