货架绑定功能优化 呼叫空货架选择货架类型 送回货架选择区域

This commit is contained in:
hehaibing-1996
2025-02-25 18:58:03 +08:00
parent b3e8beeeee
commit 44fb5831b2
11 changed files with 653 additions and 120 deletions

View File

@ -34,15 +34,35 @@
<view class="diy-flex-inforow" style="flex: 1;"> <view class="diy-flex-inforow" style="flex: 1;">
<view style="flex: 5;"></view> <view style="flex: 5;"></view>
<view style="flex: 35;">工位编码</view> <view style="flex: 35;font-weight: 700;">货架类型</view>
<view class="shelf-type-picker-container" style="flex: 55;font-size: 30rpx;font-weight: 700;">
<picker :range="shelfTypeOptions" @change="shelfTypeOptionChange" range-key="shelfTypeName"
:value="selectedShelfTypeIndex" style="font-size: 35rpx;">
<view class="uni-input" style="padding-left: 5rpx;">
{{shelfTypeOptions[selectedShelfTypeIndex].shelfTypeName}}
</view>
</picker>
</view>
<view style="flex: 60;overflow:hidden;">{{locationCode}}</view> <view style="flex: 3;"></view>
<view style="flex: 30;"> <view style="flex: 32;">
<button class="mini-btn" type="warn" size="mini" @click="callEmptyShelf">呼叫货架</button> <button class="mini-btn" type="warn" size="mini" @click="callEmptyShelf">呼叫货架</button>
</view> </view>
</view> </view>
<view class="diy-flex-inforow" style="flex: 1;">
<view style="flex: 5;"></view>
<view style="flex: 35;">工位编码</view>
<view style="flex: 90;overflow:hidden;">{{locationCode}}</view>
<!--
<view style="flex: 30;">
<button class="mini-btn" type="warn" size="mini" @click="callEmptyShelf">呼叫货架</button>
</view> -->
</view>
<view class="diy-flex-inforow" style="flex: 1;"> <view class="diy-flex-inforow" style="flex: 1;">
<view style="flex: 5;"></view> <view style="flex: 5;"></view>
@ -111,7 +131,8 @@
</picker> </picker>
</view> </view>
<button style="font-size: 40rpx;margin: 15rpx;background-color: green;" size="mini">送货架</button> <button style="font-size: 40rpx;margin: 15rpx;background-color: green;" size="mini"
@click="sendShelfBack">送货架</button>
</view> </view>
</view> </view>
</view> </view>
@ -171,6 +192,13 @@
}], }],
selectedShelfAreaIndex: 0, // 选择的货架区域索引 selectedShelfAreaIndex: 0, // 选择的货架区域索引
// 需要的空货架类型选项
shelfTypeOptions: [{
id: 1,
shelfTypeName: '请先获取工位码'
}],
selectedShelfTypeIndex: 0, // 选择的货架类型索引
userName: '', //当前登录的用户名 userName: '', //当前登录的用户名
} }
}, },
@ -189,25 +217,10 @@
analysisScanCode: function(encodedString) { analysisScanCode: function(encodedString) {
// 去除末尾的逗号和"..."(如果有的话) // 去除末尾的逗号和"..."(如果有的话)
encodedString = encodedString.replace(/,\s*\.\.\.$/, ''); encodedString = encodedString.replace(/,\s*\.\.\.$/, '');
// // 分割字符串并转换为字节数组
// let byteStrings = encodedString.split(',');
// let byteArray = [];
// for (let byteString of byteStrings) {
// byteArray.push(parseInt(byteString, 10)); // 将字符串转换为十进制整数
// }
// // 将字节数组转换为UTF-8字符串
// // 注意这里使用了一个简单的循环来构建字符串因为String.fromCharCode.apply可能在大数据上性能不佳
// let originalString = '';
// for (let i = 0; i < byteArray.length; i++) {
// // 对于每个字节使用fromCharCode转换为对应的字符
// // 注意这里假设你的字节数组已经是正确的UTF-8编码并且不需要额外的处理来组合多字节字符
// originalString += String.fromCharCode(byteArray[i]);
// }
this.locationCode = encodedString; this.locationCode = encodedString;
this.getShelfInfoByLocationCode(); this.getShelfInfoByLocationCode(true);
}, },
getShelfInfoByLocationCode: function() { getShelfInfoByLocationCode: function(isTip) {
//调用接口获取当前工位信息 当前工位是否有货架 //调用接口获取当前工位信息 当前工位是否有货架
var serverIPAndPort = getServerIPAndPort(); var serverIPAndPort = getServerIPAndPort();
uni.request({ uni.request({
@ -231,6 +244,11 @@
this.locationCode = res.data.data.locationCode; 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;
this.shelfTypeOptions = res.data.data.shelfTypes;
this.selectedShelfTypeIndex = getConfig("bindSelectedShelfTypeIndex", 0);
this.shelfAreaOptions = res.data.data.locationArea;
this.selectedShelfAreaIndex = getConfig("bindSelectedShelfAreaIndex", 0);
if (this.shelfId == null) { if (this.shelfId == null) {
this.shelfCode = '(工位无货架,请呼叫!)'; this.shelfCode = '(工位无货架,请呼叫!)';
@ -246,40 +264,47 @@
this.isNeedCallShelfCode = false; this.isNeedCallShelfCode = false;
this.placeholderText = '输入编码或名称'; this.placeholderText = '输入编码或名称';
} }
if (isTip) {
uni.showToast({ uni.showToast({
title: '获取成功!', title: '获取成功!',
icon: 'none', icon: 'none',
duration: 1500 duration: 1500
}); });
}
} else { } else {
uni.showToast({ if (isTip) {
title: '获取失败:' + res.data.message, uni.showToast({
icon: 'none', title: '获取失败:' + res.data.message,
duration: 3600 icon: 'none',
}); duration: 3600
this.clear(); });
this.clear();
}
} }
} else { } else {
uni.showToast({ if (isTip) {
title: '服务器返回错误状态码' + res.statusCode, uni.showToast({
icon: 'none', title: '服务器返回错误状态码' + res.statusCode,
duration: 3000 icon: 'none',
}); duration: 3000
this.clear(); });
this.clear();
}
} }
}, },
fail: (err) => { fail: (err) => {
// 请求失败的回调函数 // 请求失败的回调函数
uni.showToast({ if (isTip) {
title: '请求失败' + err, uni.showToast({
icon: 'none', title: '请求失败' + err.errMsg,
duration: 3000 icon: 'none',
}); duration: 3000
});
this.clear(); this.clear();
}
}, },
complete: (event) => { complete: (event) => {
// 请求完成的回调函数(无论成功或失败都会调用) // 请求完成的回调函数(无论成功或失败都会调用)
@ -293,6 +318,7 @@
this.matCode = item.matCode; this.matCode = item.matCode;
this.matName = item.matName; this.matName = item.matName;
this.matSpec = item.matSpec; this.matSpec = item.matSpec;
this.matQty = item.matDefaultQty;
this.matBaseInfoId = item.id; this.matBaseInfoId = item.id;
}, },
@ -349,9 +375,9 @@
fail: (err) => { fail: (err) => {
// 请求失败的回调函数 // 请求失败的回调函数
uni.showToast({ uni.showToast({
title: '绑定失败:请求失败' + err, title: '请求失败' + err.errMsg,
icon: 'none', icon: 'none',
duration: 1500 duration: 3000
}); });
}, },
complete: (event) => { complete: (event) => {
@ -378,7 +404,7 @@
duration: 1000 duration: 1000
}); });
this.getShelfInfoByLocationCode(); this.getShelfInfoByLocationCode(false);
return; return;
} }
if (this.matCodeCondition == null || this.matCodeCondition == '') { if (this.matCodeCondition == null || this.matCodeCondition == '') {
@ -395,8 +421,27 @@
} }
}, },
//物料绑定 //呼叫空货架
callEmptyShelf: function() { callEmptyShelf: function() {
if (this.isNeedScanLocationCode) {
uni.showToast({
title: '请先扫描工位码!',
icon: 'none',
duration: 3000
});
return;
}
if (this.selectedShelfTypeIndex == 0) {
uni.showToast({
title: '请选择需要呼叫的货架类型!',
icon: 'none',
duration: 3000
});
return;
}
saveConfig("bindSelectedShelfTypeIndex", this.selectedShelfTypeIndex);
this.userName = getConfig('userName', ''); this.userName = getConfig('userName', '');
var serverIPAndPort = getServerIPAndPort(); var serverIPAndPort = getServerIPAndPort();
uni.request({ uni.request({
@ -405,6 +450,8 @@
data: { data: {
"locationId": this.locationId, "locationId": this.locationId,
"locationCode": this.locationCode, "locationCode": this.locationCode,
'needShelfTypeId': this.shelfTypeOptions[this.selectedShelfTypeIndex].id,
'needShelfTypeName': this.shelfTypeOptions[this.selectedShelfTypeIndex].shelfTypeName,
"userName": this.userName, "userName": this.userName,
"deviceType": "PDA" "deviceType": "PDA"
}, },
@ -419,14 +466,14 @@
uni.showToast({ uni.showToast({
title: '呼叫成功,请等待!', title: '呼叫成功,请等待!',
icon: 'none', icon: 'none',
duration: 1500 duration: 2500
}); });
this.getShelfInfoByLocationCode(false);
} else { } else {
uni.showToast({ uni.showToast({
title: '呼叫失败:' + res.data.message, title: '呼叫失败:' + res.data.message,
icon: 'none', icon: 'none',
duration: 1500 duration: 2500
}); });
} }
@ -434,16 +481,16 @@
uni.showToast({ uni.showToast({
title: '呼叫失败:服务器返回错误状态码' + res.statusCode, title: '呼叫失败:服务器返回错误状态码' + res.statusCode,
icon: 'none', icon: 'none',
duration: 1500 duration: 2500
}); });
} }
}, },
fail: (err) => { fail: (err) => {
// 请求失败的回调函数 // 请求失败的回调函数
uni.showToast({ uni.showToast({
title: '呼叫失败:http请求失败' + err, title: 'http请求失败' + err.errMsg,
icon: 'none', icon: 'none',
duration: 1500 duration: 2500
}); });
}, },
complete: (event) => { complete: (event) => {
@ -454,6 +501,107 @@
}, },
//送回货架
sendShelfBack: function() {
if (this.isNeedScanLocationCode) {
uni.showToast({
title: '请先扫描工位码!',
icon: 'none',
duration: 3000
});
return;
}
if (this.shelfId == null) {
uni.showToast({
title: '当前工位无货架!无法送货架!',
icon: 'none',
duration: 3000
});
return;
} else if (this.shelfId != null && this.shelfCode != null && this
.shelfCode.includes('运输中')) {
uni.showToast({
title: '当前工位无货架!无法送货架!',
icon: 'none',
duration: 3000
});
return;
}
if (this.selectedShelfAreaIndex == 0) {
uni.showToast({
title: '请选择需要送回的位置区域',
icon: 'none',
duration: 3000
});
return;
}
saveConfig("bindSelectedShelfAreaIndex", this.selectedShelfAreaIndex);
this.userName = getConfig('userName', '');
var serverIPAndPort = getServerIPAndPort();
uni.request({
url: 'http://' + serverIPAndPort + '/pdaMatBind/bindSendBackShelf', // 请求的接口地址
method: 'POST', // 设置请求方式为 POST
data: {
"locationId": this.locationId,
"locationCode": this.locationCode,
"shelfId": this.shelfId,
"shelfCode": this.shelfCode,
'sendBackLocationAreaId': this.shelfAreaOptions[this.selectedShelfAreaIndex].id,
'sendBackLocationAreaName': this.shelfAreaOptions[this.selectedShelfAreaIndex]
.locationAreaName,
"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: 2500
});
this.getShelfInfoByLocationCode(false);
} else {
uni.showToast({
title: '送货架呼叫失败:' + res.data.message,
icon: 'none',
duration: 2500
});
}
} else {
uni.showToast({
title: '送货架呼叫失败:服务器返回错误状态码' + res.statusCode,
icon: 'none',
duration: 2500
});
}
},
fail: (err) => {
// 请求失败的回调函数
uni.showToast({
title: 'http请求失败' + err.errMsg,
icon: 'none',
duration: 2500
});
},
complete: (event) => {
// 请求完成的回调函数(无论成功或失败都会调用)
console.log('请求完成', event);
}
});
},
//清空当前界面所有内容 //清空当前界面所有内容
clear: function() { clear: function() {
@ -465,6 +613,13 @@
this.isNeedScanLocationCode = true; this.isNeedScanLocationCode = true;
this.placeholderText = '请先扫描工位码'; this.placeholderText = '请先扫描工位码';
}, },
shelfTypeOptionChange(e) {
this.selectedShelfTypeIndex = e.detail.value;
},
onShelfAreaChange(e) {
this.selectedShelfAreaIndex = e.detail.value;
},
clearMatInfo: function() { clearMatInfo: function() {
this.matCode = ''; this.matCode = '';
this.matName = ''; this.matName = '';
@ -480,6 +635,7 @@
<style> <style>
.picker-container { .picker-container {
border-radius: 5rpx;
border: 2rpx solid #000; border: 2rpx solid #000;
/* 设置边框宽度和颜色 */ /* 设置边框宽度和颜色 */
margin: 25rpx auto; margin: 25rpx auto;
@ -489,6 +645,18 @@
/* 其他样式保持不变 */ /* 其他样式保持不变 */
} }
.shelf-type-picker-container {
border-radius: 5rpx;
border: 2rpx solid #000;
/* 设置边框宽度和颜色 */
margin-left: 25rpx auto;
margin-right: 25rpx auto;
/* 上下边距为5rpx左右边距自动以实现水平居中 */
width: 400rpx;
/* 设置宽度 */
/* 其他样式保持不变 */
}
.uni-input-wrapper { .uni-input-wrapper {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;

View File

@ -723,6 +723,13 @@ if (uni.restoreGlobal) {
}], }],
selectedShelfAreaIndex: 0, selectedShelfAreaIndex: 0,
// 选择的货架区域索引 // 选择的货架区域索引
// 需要的空货架类型选项
shelfTypeOptions: [{
id: 1,
shelfTypeName: "请先获取工位码"
}],
selectedShelfTypeIndex: 0,
// 选择的货架类型索引
userName: "" userName: ""
//当前登录的用户名 //当前登录的用户名
}; };
@ -731,19 +738,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:182", "Success:" + res.data); formatAppLog("log", "at pages/bind/bind.vue:210", "Success:" + res.data);
self.analysisScanCode(res.data); self.analysisScanCode(res.data);
}, function(err) { }, function(err) {
formatAppLog("log", "at pages/bind/bind.vue:185", "Error:", JSON.stringify(err)); formatAppLog("log", "at pages/bind/bind.vue:213", "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(); this.getShelfInfoByLocationCode(true);
}, },
getShelfInfoByLocationCode: function() { getShelfInfoByLocationCode: function(isTip) {
var serverIPAndPort = getServerIPAndPort(); var serverIPAndPort = getServerIPAndPort();
uni.request({ uni.request({
url: "http://" + serverIPAndPort + "/pdaMatBind/getShelfInfoByLocationCode", url: "http://" + serverIPAndPort + "/pdaMatBind/getShelfInfoByLocationCode",
@ -767,6 +774,10 @@ if (uni.restoreGlobal) {
this.locationCode = res.data.data.locationCode; 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;
this.shelfTypeOptions = res.data.data.shelfTypes;
this.selectedShelfTypeIndex = getConfig("bindSelectedShelfTypeIndex", 0);
this.shelfAreaOptions = res.data.data.locationArea;
this.selectedShelfAreaIndex = getConfig("bindSelectedShelfAreaIndex", 0);
if (this.shelfId == null) { if (this.shelfId == null) {
this.shelfCode = "(工位无货架,请呼叫!)"; this.shelfCode = "(工位无货架,请呼叫!)";
this.isNeedScanLocationCode = false; this.isNeedScanLocationCode = false;
@ -779,46 +790,55 @@ if (uni.restoreGlobal) {
this.isNeedCallShelfCode = false; this.isNeedCallShelfCode = false;
this.placeholderText = "输入编码或名称"; this.placeholderText = "输入编码或名称";
} }
uni.showToast({ if (isTip) {
title: "获取成功!", uni.showToast({
icon: "none", title: "获取成功!",
duration: 1500 icon: "none",
}); duration: 1500
});
}
} else { } else {
if (isTip) {
uni.showToast({
title: "获取失败:" + res.data.message,
icon: "none",
duration: 3600
});
this.clear();
}
}
} else {
if (isTip) {
uni.showToast({ uni.showToast({
title: "获取失败:" + res.data.message, title: "服务器返回错误状态码" + res.statusCode,
icon: "none", icon: "none",
duration: 3600 duration: 3e3
}); });
this.clear(); this.clear();
} }
} else { }
},
fail: (err) => {
if (isTip) {
uni.showToast({ uni.showToast({
title: "服务器返回错误状态码" + res.statusCode, title: "请求失败" + err.errMsg,
icon: "none", icon: "none",
duration: 3e3 duration: 3e3
}); });
this.clear(); this.clear();
} }
}, },
fail: (err) => {
uni.showToast({
title: "请求失败" + err,
icon: "none",
duration: 3e3
});
this.clear();
},
complete: (event) => { complete: (event) => {
formatAppLog("log", "at pages/bind/bind.vue:286", "请求完成", event); formatAppLog("log", "at pages/bind/bind.vue:311", "请求完成", event);
} }
}); });
}, },
bindSelectedMat: function(item) { bindSelectedMat: function(item) {
formatAppLog("log", "at pages/bind/bind.vue:292", "用户选择了项目:", item); formatAppLog("log", "at pages/bind/bind.vue:317", "用户选择了项目:", 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;
this.matQty = item.matDefaultQty;
this.matBaseInfoId = item.id; this.matBaseInfoId = item.id;
}, },
//物料绑定 //物料绑定
@ -872,13 +892,13 @@ if (uni.restoreGlobal) {
}, },
fail: (err) => { fail: (err) => {
uni.showToast({ uni.showToast({
title: "绑定失败:请求失败" + err, title: "请求失败" + err.errMsg,
icon: "none", icon: "none",
duration: 1500 duration: 3e3
}); });
}, },
complete: (event) => { complete: (event) => {
formatAppLog("log", "at pages/bind/bind.vue:359", "请求完成", event); formatAppLog("log", "at pages/bind/bind.vue:385", "请求完成", event);
} }
}); });
}, },
@ -897,7 +917,7 @@ if (uni.restoreGlobal) {
icon: "none", icon: "none",
duration: 1e3 duration: 1e3
}); });
this.getShelfInfoByLocationCode(); this.getShelfInfoByLocationCode(false);
return; return;
} }
if (this.matCodeCondition == null || this.matCodeCondition == "") { if (this.matCodeCondition == null || this.matCodeCondition == "") {
@ -913,8 +933,25 @@ if (uni.restoreGlobal) {
this.$refs.proup.show(); this.$refs.proup.show();
} }
}, },
//物料绑定 //呼叫空货架
callEmptyShelf: function() { callEmptyShelf: function() {
if (this.isNeedScanLocationCode) {
uni.showToast({
title: "请先扫描工位码!",
icon: "none",
duration: 3e3
});
return;
}
if (this.selectedShelfTypeIndex == 0) {
uni.showToast({
title: "请选择需要呼叫的货架类型!",
icon: "none",
duration: 3e3
});
return;
}
saveConfig("bindSelectedShelfTypeIndex", this.selectedShelfTypeIndex);
this.userName = getConfig("userName", ""); this.userName = getConfig("userName", "");
var serverIPAndPort = getServerIPAndPort(); var serverIPAndPort = getServerIPAndPort();
uni.request({ uni.request({
@ -925,6 +962,8 @@ if (uni.restoreGlobal) {
data: { data: {
"locationId": this.locationId, "locationId": this.locationId,
"locationCode": this.locationCode, "locationCode": this.locationCode,
"needShelfTypeId": this.shelfTypeOptions[this.selectedShelfTypeIndex].id,
"needShelfTypeName": this.shelfTypeOptions[this.selectedShelfTypeIndex].shelfTypeName,
"userName": this.userName, "userName": this.userName,
"deviceType": "PDA" "deviceType": "PDA"
}, },
@ -938,32 +977,124 @@ if (uni.restoreGlobal) {
uni.showToast({ uni.showToast({
title: "呼叫成功,请等待!", title: "呼叫成功,请等待!",
icon: "none", icon: "none",
duration: 1500 duration: 2500
}); });
this.getShelfInfoByLocationCode(false);
} else { } else {
uni.showToast({ uni.showToast({
title: "呼叫失败:" + res.data.message, title: "呼叫失败:" + res.data.message,
icon: "none", icon: "none",
duration: 1500 duration: 2500
}); });
} }
} else { } else {
uni.showToast({ uni.showToast({
title: "呼叫失败:服务器返回错误状态码" + res.statusCode, title: "呼叫失败:服务器返回错误状态码" + res.statusCode,
icon: "none", icon: "none",
duration: 1500 duration: 2500
}); });
} }
}, },
fail: (err) => { fail: (err) => {
uni.showToast({ uni.showToast({
title: "呼叫失败:http请求失败" + err, title: "http请求失败" + err.errMsg,
icon: "none", icon: "none",
duration: 1500 duration: 2500
}); });
}, },
complete: (event) => { complete: (event) => {
formatAppLog("log", "at pages/bind/bind.vue:451", "请求完成", event); formatAppLog("log", "at pages/bind/bind.vue:498", "请求完成", event);
}
});
},
//送回货架
sendShelfBack: function() {
if (this.isNeedScanLocationCode) {
uni.showToast({
title: "请先扫描工位码!",
icon: "none",
duration: 3e3
});
return;
}
if (this.shelfId == null) {
uni.showToast({
title: "当前工位无货架!无法送货架!",
icon: "none",
duration: 3e3
});
return;
} else if (this.shelfId != null && this.shelfCode != null && this.shelfCode.includes("运输中")) {
uni.showToast({
title: "当前工位无货架!无法送货架!",
icon: "none",
duration: 3e3
});
return;
}
if (this.selectedShelfAreaIndex == 0) {
uni.showToast({
title: "请选择需要送回的位置区域",
icon: "none",
duration: 3e3
});
return;
}
saveConfig("bindSelectedShelfAreaIndex", this.selectedShelfAreaIndex);
this.userName = getConfig("userName", "");
var serverIPAndPort = getServerIPAndPort();
uni.request({
url: "http://" + serverIPAndPort + "/pdaMatBind/bindSendBackShelf",
// 请求的接口地址
method: "POST",
// 设置请求方式为 POST
data: {
"locationId": this.locationId,
"locationCode": this.locationCode,
"shelfId": this.shelfId,
"shelfCode": this.shelfCode,
"sendBackLocationAreaId": this.shelfAreaOptions[this.selectedShelfAreaIndex].id,
"sendBackLocationAreaName": this.shelfAreaOptions[this.selectedShelfAreaIndex].locationAreaName,
"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: 2500
});
this.getShelfInfoByLocationCode(false);
} else {
uni.showToast({
title: "送货架呼叫失败:" + res.data.message,
icon: "none",
duration: 2500
});
}
} else {
uni.showToast({
title: "送货架呼叫失败:服务器返回错误状态码" + res.statusCode,
icon: "none",
duration: 2500
});
}
},
fail: (err) => {
uni.showToast({
title: "http请求失败" + err.errMsg,
icon: "none",
duration: 2500
});
},
complete: (event) => {
formatAppLog("log", "at pages/bind/bind.vue:600", "请求完成", event);
} }
}); });
}, },
@ -977,13 +1108,19 @@ if (uni.restoreGlobal) {
this.isNeedScanLocationCode = true; this.isNeedScanLocationCode = true;
this.placeholderText = "请先扫描工位码"; this.placeholderText = "请先扫描工位码";
}, },
shelfTypeOptionChange(e) {
this.selectedShelfTypeIndex = e.detail.value;
},
onShelfAreaChange(e) {
this.selectedShelfAreaIndex = e.detail.value;
},
clearMatInfo: function() { clearMatInfo: function() {
this.matCode = ""; this.matCode = "";
this.matName = ""; this.matName = "";
this.matSpec = ""; this.matSpec = "";
}, },
handlePopupClose() { handlePopupClose() {
formatAppLog("log", "at pages/bind/bind.vue:475", "弹出层已关闭"); formatAppLog("log", "at pages/bind/bind.vue:630", "弹出层已关闭");
} }
} }
}; };
@ -1046,23 +1183,55 @@ if (uni.restoreGlobal) {
style: { "flex": "1" } style: { "flex": "1" }
}, [ }, [
vue.createElementVNode("view", { style: { "flex": "5" } }), vue.createElementVNode("view", { style: { "flex": "5" } }),
vue.createElementVNode("view", { style: { "flex": "35" } }, "工位编码"), vue.createElementVNode("view", { style: { "flex": "35", "font-weight": "700" } }, "货架类型"),
vue.createElementVNode( vue.createElementVNode("view", {
"view", class: "shelf-type-picker-container",
{ style: { "flex": "60", "overflow": "hidden" } }, style: { "flex": "55", "font-size": "30rpx", "font-weight": "700" }
vue.toDisplayString($data.locationCode), }, [
1 vue.createElementVNode("picker", {
/* TEXT */ range: $data.shelfTypeOptions,
), onChange: _cache[3] || (_cache[3] = (...args) => $options.shelfTypeOptionChange && $options.shelfTypeOptionChange(...args)),
vue.createElementVNode("view", { style: { "flex": "30" } }, [ "range-key": "shelfTypeName",
value: $data.selectedShelfTypeIndex,
style: { "font-size": "35rpx" }
}, [
vue.createElementVNode(
"view",
{
class: "uni-input",
style: { "padding-left": "5rpx" }
},
vue.toDisplayString($data.shelfTypeOptions[$data.selectedShelfTypeIndex].shelfTypeName),
1
/* TEXT */
)
], 40, ["range", "value"])
]),
vue.createElementVNode("view", { style: { "flex": "3" } }),
vue.createElementVNode("view", { style: { "flex": "32" } }, [
vue.createElementVNode("button", { vue.createElementVNode("button", {
class: "mini-btn", class: "mini-btn",
type: "warn", type: "warn",
size: "mini", size: "mini",
onClick: _cache[3] || (_cache[3] = (...args) => $options.callEmptyShelf && $options.callEmptyShelf(...args)) onClick: _cache[4] || (_cache[4] = (...args) => $options.callEmptyShelf && $options.callEmptyShelf(...args))
}, "呼叫货架") }, "呼叫货架")
]) ])
]), ]),
vue.createElementVNode("view", {
class: "diy-flex-inforow",
style: { "flex": "1" }
}, [
vue.createElementVNode("view", { style: { "flex": "5" } }),
vue.createElementVNode("view", { style: { "flex": "35" } }, "工位编码:"),
vue.createElementVNode(
"view",
{ style: { "flex": "90", "overflow": "hidden" } },
vue.toDisplayString($data.locationCode),
1
/* TEXT */
),
vue.createCommentVNode(' \r\n <view style="flex: 30;">\r\n <button class="mini-btn" type="warn" size="mini" @click="callEmptyShelf">呼叫货架</button>\r\n </view> ')
]),
vue.createElementVNode("view", { vue.createElementVNode("view", {
class: "diy-flex-inforow", class: "diy-flex-inforow",
style: { "flex": "1" } style: { "flex": "1" }
@ -1135,7 +1304,7 @@ if (uni.restoreGlobal) {
class: "uni-input", class: "uni-input",
style: { "font-size": "40rpx" }, style: { "font-size": "40rpx" },
placeholder: "请输入物料数量", placeholder: "请输入物料数量",
"onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => $data.matQty = $event) "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => $data.matQty = $event)
}, },
null, null,
512 512
@ -1146,7 +1315,7 @@ if (uni.restoreGlobal) {
]), ]),
vue.createElementVNode("view", { style: { "flex": "40" } }, [ vue.createElementVNode("view", { style: { "flex": "40" } }, [
vue.createElementVNode("button", { vue.createElementVNode("button", {
onClick: _cache[5] || (_cache[5] = (...args) => $options.bind && $options.bind(...args)), onClick: _cache[6] || (_cache[6] = (...args) => $options.bind && $options.bind(...args)),
class: "mini-btn", class: "mini-btn",
style: { "margin-left": "10rpx" }, style: { "margin-left": "10rpx" },
type: "warn", type: "warn",
@ -1163,7 +1332,7 @@ if (uni.restoreGlobal) {
range: $data.shelfAreaOptions, range: $data.shelfAreaOptions,
"range-key": "locationAreaName", "range-key": "locationAreaName",
value: $data.selectedShelfAreaIndex, value: $data.selectedShelfAreaIndex,
onChange: _cache[6] || (_cache[6] = (...args) => _ctx.onShelfAreaChange && _ctx.onShelfAreaChange(...args)), onChange: _cache[7] || (_cache[7] = (...args) => $options.onShelfAreaChange && $options.onShelfAreaChange(...args)),
style: { "font-size": "35rpx" } style: { "font-size": "35rpx" }
}, [ }, [
vue.createElementVNode( vue.createElementVNode(
@ -1177,7 +1346,8 @@ if (uni.restoreGlobal) {
]), ]),
vue.createElementVNode("button", { vue.createElementVNode("button", {
style: { "font-size": "40rpx", "margin": "15rpx", "background-color": "green" }, style: { "font-size": "40rpx", "margin": "15rpx", "background-color": "green" },
size: "mini" size: "mini",
onClick: _cache[8] || (_cache[8] = (...args) => $options.sendShelfBack && $options.sendShelfBack(...args))
}, "送货架") }, "送货架")
]) ])
]) ])
@ -3795,9 +3965,9 @@ if (uni.restoreGlobal) {
}, },
fail: (err) => { fail: (err) => {
uni.showToast({ uni.showToast({
title: "请求失败" + err, title: "请求失败:" + err.errMsg,
icon: "none", icon: "none",
duration: 4e3 duration: 3e3
}); });
this.clear(); this.clear();
}, },
@ -3861,9 +4031,9 @@ if (uni.restoreGlobal) {
}, },
fail: (err) => { fail: (err) => {
uni.showToast({ uni.showToast({
title: "请求失败" + err, title: "请求失败:" + err.errMsg,
icon: "none", icon: "none",
duration: 4e3 duration: 3e3
}); });
this.clear(); this.clear();
}, },
@ -4335,13 +4505,10 @@ if (uni.restoreGlobal) {
{ {
default: vue.withCtx(() => [ default: vue.withCtx(() => [
vue.createElementVNode("view", { class: "popup-content" }, [ vue.createElementVNode("view", { class: "popup-content" }, [
vue.createElementVNode("view", { class: "info-item" }, [ vue.createElementVNode("view", { style: { "margin": "3rpx" } }, [
vue.createElementVNode("label", null, "是否呼叫以下货架:") vue.createElementVNode("label", null, "是否呼叫以下货架:")
]), ]),
vue.createElementVNode("view", { vue.createElementVNode("view", { style: { "font-size": "52rpx", "text-align": "center", "margin-top": "15rpx", "margin-bottom": "10rpx" } }, [
class: "info-item",
style: { "font-size": "50rpx" }
}, [
vue.createElementVNode( vue.createElementVNode(
"text", "text",
null, null,

View File

@ -57,7 +57,7 @@ namespace WCS.DAL.DbModels
/// 可放置货架类型 /// 可放置货架类型
/// </summary> /// </summary>
[SugarColumn(ColumnName = "allow_shelf_types", Length = 256, IsNullable = true, ColumnDescription = "可放置货架类型", IsJson = true)] [SugarColumn(ColumnName = "allow_shelf_types", Length = 256, IsNullable = true, ColumnDescription = "可放置货架类型", IsJson = true)]
public List<string> AllowShelfTypes { get; set; } public List<int> AllowShelfTypes { get; set; }
/// <summary> /// <summary>
/// 作为起点时 允许的目的地类型 /// 作为起点时 允许的目的地类型

View File

@ -44,6 +44,12 @@ namespace WCS.BLL.DbModels
[SugarColumn(ColumnName = "mat_unit", Length = 64, IsNullable = true, ColumnDescription = "物料单位")] [SugarColumn(ColumnName = "mat_unit", Length = 64, IsNullable = true, ColumnDescription = "物料单位")]
public string? MatUnit { get; set; } public string? MatUnit { get; set; }
/// <summary>
/// 物料默认数量
/// </summary>
[SugarColumn(ColumnName = "mat_default_qty", IsNullable = true, ColumnDescription = "物料默认数量")]
public int? MatDefaultQty { get; set; }
/// <summary> /// <summary>
/// 物料供应商 /// 物料供应商
/// </summary> /// </summary>

View File

@ -16,6 +16,7 @@ namespace WCS.BLL.Services.IService
public interface IPDAMatBindService public interface IPDAMatBindService
{ {
public Task<ResponseCommon> callEmptyShelf(BindMatDetailRequest request); public Task<ResponseCommon> callEmptyShelf(BindMatDetailRequest request);
public Task<ResponseCommon> bindSendBackShelf(BindMatDetailRequest request);
public Task<ResponseBase> resendAGVTask(ResendAGVTasksRequest request); public Task<ResponseBase> resendAGVTask(ResendAGVTasksRequest request);
} }

View File

@ -62,7 +62,7 @@ namespace WCS.BLL.Services.Service
return new ResponseCommon() return new ResponseCommon()
{ {
Code = 205, Code = 205,
Message = $"货架【{shelf.ShelfCode}】静止在工位上,请勿重复呼叫", Message = $"货架【{shelf.ShelfCode}】在工位上,无法呼叫新货架",
Data = null, Data = null,
}; };
} }
@ -82,6 +82,7 @@ namespace WCS.BLL.Services.Service
//获取空货架进行呼叫 //获取空货架进行呼叫
shelf = await DbHelp.db.Queryable<ShelfInfo>() shelf = await DbHelp.db.Queryable<ShelfInfo>()
.Where(t => t.TransStatus == TransStatusEnum. && t.CurrentLocationId != 0) .Where(t => t.TransStatus == TransStatusEnum. && t.CurrentLocationId != 0)
.Where(t => t.ShelfTypeId == request.NeedShelfTypeId)
.Where(t => t.IsEnable == true) .Where(t => t.IsEnable == true)
.FirstAsync(); .FirstAsync();
if (shelf == null) if (shelf == null)
@ -89,7 +90,7 @@ namespace WCS.BLL.Services.Service
return new ResponseCommon() return new ResponseCommon()
{ {
Code = 201, Code = 201,
Message = $"不存在空货架!", Message = $"货架类型[{request.NeedShelfTypeName}]不存在空货架!",
Data = null, Data = null,
}; };
} }
@ -115,7 +116,120 @@ namespace WCS.BLL.Services.Service
Data = null, Data = null,
}; };
} }
else if(response.code == "-999") 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,
};
}
}
catch (Exception ex)
{
return new ResponseCommon()
{
Code = 201,
Message = ex.Message,
Data = null,
};
}
}
public async Task<ResponseCommon> bindSendBackShelf(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 startLocation = await DbHelp.db.Queryable<LocationInfo>()
.Where(t => t.Id == request.LocationId)
.Where(t => t.IsEnable == true)
.FirstAsync();
if (startLocation == null)
{
return new ResponseCommon()
{
Code = 201,
Message = $"工位[{request.LocationCode}]不存在或已被禁用!\r\n请联系系统管理人员维护工位信息",
Data = null,
};
}
//获取当前工位的货架
var shelf = await DbHelp.db.Queryable<ShelfInfo>()
.Where(t => t.CurrentLocationId == startLocation.Id && t.TransStatus == TransStatusEnum.)
.Where(t => t.IsEnable == true)
.FirstAsync();
if (shelf == null)
{
return new ResponseCommon()
{
Code = 201,
Message = $"当前工位上不存在货架【{request.ShelfCode}】,请确认!",
Data = null,
};
}
#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.SendBackLocationAreaId)
.Where((li, si) => li.IsEnable == true)
.Select((li, si) => li)
.FirstAsync();
if (endLocation == null)
{
return new ResponseCommon()
{
Code = 201,
Message = $"区域[{request.SendBackLocationAreaName}]不存在空闲位置!",
Data = null,
};
}
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 if (response.code == "-999")
{ {
return new ResponseCommon() return new ResponseCommon()
{ {
@ -200,7 +314,7 @@ namespace WCS.BLL.Services.Service
if (startLocation == null) if (startLocation == null)
{ {
return new ResponseBase() return new ResponseBase()
{ {
Code = 201, Code = 201,
Message = "任务重新发送失败:起点位置不存在或已被禁用!", Message = "任务重新发送失败:起点位置不存在或已被禁用!",
}; };
@ -221,7 +335,7 @@ namespace WCS.BLL.Services.Service
//货架 //货架
var shelf = await DbHelp.db.Queryable<ShelfInfo>() var shelf = await DbHelp.db.Queryable<ShelfInfo>()
.Where(t => t.ShelfCode == agvTask.ShelfCode) .Where(t => t.ShelfCode == agvTask.ShelfCode)
.Where (t => t.IsEnable == true) .Where(t => t.IsEnable == true)
.FirstAsync(); .FirstAsync();
if (shelf == null) if (shelf == null)
{ {

View File

@ -37,7 +37,7 @@ namespace WCS.BLL.Services.Service
.FirstAsync(); .FirstAsync();
if (shelfInfo == null) if (shelfInfo == null)
{ {
//通过货架编码匹配不到就通过当前位置码去匹配 获取当前位置上的货架等相关信息 //通过货架编码匹配不到就通过当前位置码去匹配 获取当前位置上的货架信息
shelfInfo = await DbHelp.db.Queryable<ShelfInfo>() shelfInfo = await DbHelp.db.Queryable<ShelfInfo>()
.Where(t => t.CurrentLocaiotnCode == request.ShelfCode || t.DestinationLocaiotnCode == request.ShelfCode) .Where(t => t.CurrentLocaiotnCode == request.ShelfCode || t.DestinationLocaiotnCode == request.ShelfCode)
.Where(t => t.IsEnable) .Where(t => t.IsEnable)

View File

@ -21,6 +21,11 @@ namespace WCS.BLL.DbModels
public string MatBatch { get; set; } public string MatBatch { get; set; }
/// <summary>
/// 物料默认数量
/// </summary>
public int MatDefaultQty { get; set; } = 100;
public string MatSupplier { get; set; } public string MatSupplier { get; set; }
public string MatCustomer { get; set; } public string MatCustomer { get; set; }

View File

@ -40,5 +40,14 @@ namespace WCS.Model.ApiModel.PDAMatBind
/// 物料数量 /// 物料数量
/// </summary> /// </summary>
public int Qty { get; set; } public int Qty { get; set; }
public int NeedShelfTypeId { get; set; }
public string NeedShelfTypeName { get; set; }
public int SendBackLocationAreaId { get; set; }
public string SendBackLocationAreaName { get; set; }
} }
} }

View File

@ -1,6 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using WCS.Model.ApiModel.Home;
using WCS.Model.ApiModel.LocationInfo;
namespace WCS.Model.ApiModel.PDAMatBind namespace WCS.Model.ApiModel.PDAMatBind
{ {
@ -25,5 +27,15 @@ namespace WCS.Model.ApiModel.PDAMatBind
/// 货架编码 /// 货架编码
/// </summary> /// </summary>
public string ShelfCode { get; set;} = string.Empty; public string ShelfCode { get; set;} = string.Empty;
/// <summary>
/// 空货架的类型
/// </summary>
public List<ShelfTypeModel> ShelfTypes { get; set; }
/// <summary>
/// 货架送回的区域
/// </summary>
public List<LocationAreaInfoModel> LocationArea { get; set; }
} }
} }

View File

@ -6,6 +6,8 @@ using WCS.DAL.Db;
using WCS.DAL.DbModels; using WCS.DAL.DbModels;
using WCS.Model; using WCS.Model;
using WCS.Model.ApiModel; using WCS.Model.ApiModel;
using WCS.Model.ApiModel.Home;
using WCS.Model.ApiModel.LocationInfo;
using WCS.Model.ApiModel.MatDetailHistoryInfo; using WCS.Model.ApiModel.MatDetailHistoryInfo;
using WCS.Model.ApiModel.PDAMatBind; using WCS.Model.ApiModel.PDAMatBind;
using WCS.Model.ApiModel.User; using WCS.Model.ApiModel.User;
@ -137,6 +139,34 @@ namespace WCS.WebApi.Controllers
shelf.ShelfCode = shelf.ShelfCode + "(运输中)"; shelf.ShelfCode = shelf.ShelfCode + "(运输中)";
} }
//允许放置的货架类型
var shelfTypes = new List<ShelfTypeModel>();
shelfTypes.Add(new ShelfTypeModel()
{
Id = 0,
ShelfTypeName = "请选择"
});
var shelfTypeInDb = await DbHelp.db.Queryable<ShelfTypeInfo>()
.WhereIF(location.AllowShelfTypes != null && location.AllowShelfTypes.Count > 0, t => location.AllowShelfTypes.Contains(t.Id))
.ToListAsync();
shelfTypeInDb.ForEach(t =>
{
shelfTypes.Add(new ShelfTypeModel() { Id = t.Id, ShelfTypeName = t.ShelfTypeName });
});
//货架送回的区域
var locationAreas = new List<LocationAreaInfoModel>();
locationAreas.Add(new LocationAreaInfoModel {
Id = 0,
LocationAreaName = "请选择"
});
var locationAreaInDb = await DbHelp.db.Queryable<LocationAreaInfo>()
.WhereIF(location.AllowDestinationLocationArea != null && location.AllowDestinationLocationArea.Count > 0, t => location.AllowDestinationLocationArea.Contains(t.Id))
.ToListAsync();
locationAreaInDb.ForEach(t =>
{
locationAreas.Add(new LocationAreaInfoModel() { Id = t.Id, LocationAreaName = t.LocationAreaName });
});
return new ResponseBase<GetShelfInfoByLocationReturnData>() return new ResponseBase<GetShelfInfoByLocationReturnData>()
{ {
Code = 200, Code = 200,
@ -147,6 +177,8 @@ namespace WCS.WebApi.Controllers
LocationCode = location.LocationCode, LocationCode = location.LocationCode,
ShelfId = shelf?.Id, ShelfId = shelf?.Id,
ShelfCode = shelf?.ShelfCode, ShelfCode = shelf?.ShelfCode,
ShelfTypes = shelfTypes,
LocationArea = locationAreas
}, },
}; };
@ -413,5 +445,24 @@ namespace WCS.WebApi.Controllers
}; };
} }
} }
[Route("bindSendBackShelf")]
[HttpPost(Name = "bindSendBackShelf")]
public async Task<ResponseCommon> bindSendBackShelf(BindMatDetailRequest request)
{
try
{
return await _PDAMatBindService.bindSendBackShelf(request);
}
catch (Exception ex)
{
return new ResponseCommon()
{
Code = 201,
Message = ex.Message,
Data = null,
};
}
}
} }
} }