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

@ -216,17 +216,17 @@
methods: { methods: {
//摄像头扫码 //摄像头扫码
cameraScanCode() { cameraScanCode() {
uni.scanCode({ uni.scanCode({
success: (res) => { success: (res) => {
console.log('扫码结果:', res.result); console.log('扫码结果:', res.result);
this.analysisScanCode(res.result); this.analysisScanCode(res.result);
}, },
fail: (err) => { fail: (err) => {
console.error('扫码失败:', err); console.error('扫码失败:', err);
// 处理扫码失败的情况 // 处理扫码失败的情况
} }
}); });
}, },
//扫码枪扫码 //扫码枪扫码
analysisScanCode: function(encodedString) { analysisScanCode: function(encodedString) {
// 去除末尾的逗号和"..."(如果有的话) // 去除末尾的逗号和"..."(如果有的话)
@ -262,7 +262,11 @@
this.selectedShelfTypeIndex = getConfig("bindSelectedShelfTypeIndex", 0); this.selectedShelfTypeIndex = getConfig("bindSelectedShelfTypeIndex", 0);
this.shelfAreaOptions = res.data.data.locationArea; 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) { if (this.shelfId == null) {
this.shelfCode = '(工位无货架,请呼叫!)'; this.shelfCode = '(工位无货架,请呼叫!)';

View File

@ -72,9 +72,10 @@
</view> </view>
<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 class="picker-container1" style="position: relative;">
<view style="color: darkgray;">点击选择送回区域:</view>
<picker ref="shelfAreaPicker" :range="shelfAreaOptions" range-key="locationAreaName" <picker ref="shelfAreaPicker" :range="shelfAreaOptions" range-key="locationAreaName"
:value="selectedShelfAreaIndex" @change="onShelfAreaChange" style="font-size: 35rpx;"> :value="selectedShelfAreaIndex" @change="onShelfAreaChange" style="font-size: 35rpx;">
<view class="uni-input">{{shelfAreaOptions[selectedShelfAreaIndex].locationAreaName}}</view> <view class="uni-input">{{shelfAreaOptions[selectedShelfAreaIndex].locationAreaName}}</view>
@ -83,8 +84,9 @@
<!-- 货架类型选择 --> <!-- 货架类型选择 -->
<view class="picker-container" style="position: relative;"> <view class="picker-container" style="position: relative;">
<view style="color: darkgray;">点击选择:</view>
<picker ref="shelfTypePicker" :range="shelfTypeOptions" range-key="text" :value="selectedShelfTypeIndex" <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> <view class="uni-input">{{shelfTypeOptions[selectedShelfTypeIndex].text}}</view>
</picker> </picker>
</view> </view>
@ -337,7 +339,7 @@
return; return;
} }
//货架送回区域是否选择 //货架送回区域是否选择
if (shelfAreaOptions[selectedShelfAreaIndex].locationAreaName = '请先扫货架码') { if (this.shelfAreaOptions[this.selectedShelfAreaIndex].locationAreaName == '请先扫货架码' || this.shelfAreaOptions[this.selectedShelfAreaIndex].locationAreaName == '请选择') {
uni.showToast({ uni.showToast({
title: '请选择货架送回区域!', title: '请选择货架送回区域!',
icon: 'none', icon: 'none',
@ -345,14 +347,25 @@
}); });
return; return;
} }
//保存选择的区域信息
saveConfig("callOutSelectedShelfAreaIndex", this.selectedShelfAreaIndex);
//请求送回货架 //请求送回货架
var serverIPAndPort = getServerIPAndPort(); var serverIPAndPort = getServerIPAndPort();
uni.request({ uni.request({
url: 'http://' + serverIPAndPort + url: 'http://' + serverIPAndPort +
'/pdaProductionLineCallOut/getShelfInfoForCallOut', // 请求的接口地址 '/pdaProductionLineCallOut/callOut', // 请求的接口地址
method: 'POST', // 设置请求方式为 POST method: 'POST', // 设置请求方式为 POST
data: { data: {
"locationId": this.locationId,
"locationCode": this.locationCode,
"shelfId": this.shelfId,
"shelfCode": this.shelfCode, "shelfCode": this.shelfCode,
"destinationLocationAreaId": this.shelfAreaOptions[this.selectedShelfAreaIndex].id,
"destinationLocationAreaName": this.shelfAreaOptions[this.selectedShelfAreaIndex].locationAreaName,
"ShelfTypeStr": this.shelfTypeOptions[this.selectedShelfTypeIndex].text,
"userName": this.userName, "userName": this.userName,
"deviceType": "PDA" "deviceType": "PDA"
}, },
@ -364,35 +377,20 @@
if (res.statusCode === 200) { if (res.statusCode === 200) {
//接口返回数据为200 表示获取成功! //接口返回数据为200 表示获取成功!
if (res.data.code == 200) { if (res.data.code == 200) {
//未查询到信息 uni.showToast({
if (res.data.data == null) { title: '送回货架呼叫成功!',
uni.showToast({ icon: 'none',
title: '获取失败,请扫码重试!', duration: 1500
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; return;
} else { } else {
uni.showToast({ uni.showToast({
title: '获取失败:' + res.data.message, title: '送回货架呼叫失败:' + res.data.message,
icon: 'none', icon: 'none',
duration: 3500 duration: 3500
}); });
this.clear(); //this.clear();
} }
} else { } else {
@ -401,7 +399,7 @@
icon: 'none', icon: 'none',
duration: 3000 duration: 3000
}); });
this.clear(); //this.clear();
} }
}, },
fail: (err) => { fail: (err) => {
@ -412,7 +410,7 @@
duration: 3000 duration: 3000
}); });
this.clear(); //this.clear();
}, },
complete: (event) => { complete: (event) => {
// 请求完成的回调函数(无论成功或失败都会调用) // 请求完成的回调函数(无论成功或失败都会调用)
@ -422,17 +420,17 @@
}, },
//摄像头扫码 //摄像头扫码
cameraScanCode() { cameraScanCode() {
uni.scanCode({ uni.scanCode({
success: (res) => { success: (res) => {
console.log('扫码结果:', res.result); console.log('扫码结果:', res.result);
this.analysisScanCode(res.result); this.analysisScanCode(res.result);
}, },
fail: (err) => { fail: (err) => {
console.error('扫码失败:', err); console.error('扫码失败:', err);
// 处理扫码失败的情况 // 处理扫码失败的情况
} }
}); });
}, },
//扫码枪扫码 //扫码枪扫码
analysisScanCode: function(encodedString) { analysisScanCode: function(encodedString) {
// 去除末尾的逗号和"..."(如果有的话) // 去除末尾的逗号和"..."(如果有的话)
@ -476,6 +474,11 @@
this.shelfAreaOptions = res.data.data.locationAreas; this.shelfAreaOptions = res.data.data.locationAreas;
var index = getConfig("callOutSelectedShelfAreaIndex", 0);
if (index + 1 < this.shelfAreaOptions.length) {
this.selectedShelfAreaIndex = index;
}
//获取数据 //获取数据
this.getCurrentMatInfo(); this.getCurrentMatInfo();
return; return;
@ -631,6 +634,7 @@
<style> <style>
.picker-container1 { .picker-container1 {
border-radius: 5rpx;
border: 2rpx solid #000; border: 2rpx solid #000;
/* 设置边框宽度和颜色 */ /* 设置边框宽度和颜色 */
padding: 2rpx; padding: 2rpx;
@ -644,6 +648,7 @@
} }
.picker-container { .picker-container {
border-radius: 5rpx;
border: 2rpx solid #000; border: 2rpx solid #000;
/* 设置边框宽度和颜色 */ /* 设置边框宽度和颜色 */
padding: 2rpx; padding: 2rpx;

View File

@ -790,7 +790,10 @@ if (uni.restoreGlobal) {
this.shelfTypeOptions = res.data.data.shelfTypes; this.shelfTypeOptions = res.data.data.shelfTypes;
this.selectedShelfTypeIndex = getConfig("bindSelectedShelfTypeIndex", 0); this.selectedShelfTypeIndex = getConfig("bindSelectedShelfTypeIndex", 0);
this.shelfAreaOptions = res.data.data.locationArea; 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) { if (this.shelfId == null) {
this.shelfCode = "(工位无货架,请呼叫!)"; this.shelfCode = "(工位无货架,请呼叫!)";
this.isNeedScanLocationCode = false; this.isNeedScanLocationCode = false;
@ -842,12 +845,12 @@ if (uni.restoreGlobal) {
} }
}, },
complete: (event) => { complete: (event) => {
formatAppLog("log", "at pages/bind/bind.vue:325", "请求完成", event); formatAppLog("log", "at pages/bind/bind.vue:329", "请求完成", event);
} }
}); });
}, },
bindSelectedMat: function(item) { 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.matCode = item.matCode;
this.matName = item.matName; this.matName = item.matName;
this.matSpec = item.matSpec; this.matSpec = item.matSpec;
@ -911,7 +914,7 @@ if (uni.restoreGlobal) {
}); });
}, },
complete: (event) => { 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) => { 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) => { 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 = ""; this.matSpec = "";
}, },
handlePopupClose() { 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 inputValue = vue.ref("");
const showPopup = (info) => { const showPopup = (info) => {
fixedInfo.infoId = info.id; 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.matName = info.matName;
fixedInfo.value.matCode = info.matCode; fixedInfo.value.matCode = info.matCode;
fixedInfo.value.matSpec = info.matSpec; fixedInfo.value.matSpec = info.matSpec;
@ -4874,10 +4877,10 @@ 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/productionLineCallOut/productionLineCallOut.vue:309", "Success:" + res.data); formatAppLog("log", "at pages/productionLineCallOut/productionLineCallOut.vue:311", "Success:" + res.data);
self.analysisScanCode(res.data); self.analysisScanCode(res.data);
}, function(err) { }, 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: { methods: {
@ -4899,7 +4902,7 @@ if (uni.restoreGlobal) {
}); });
return; return;
} }
if (shelfAreaOptions[selectedShelfAreaIndex].locationAreaName = "请先扫货架码") { if (this.shelfAreaOptions[this.selectedShelfAreaIndex].locationAreaName == "请先扫货架码" || this.shelfAreaOptions[this.selectedShelfAreaIndex].locationAreaName == "请选择") {
uni.showToast({ uni.showToast({
title: "请选择货架送回区域!", title: "请选择货架送回区域!",
icon: "none", icon: "none",
@ -4907,14 +4910,21 @@ if (uni.restoreGlobal) {
}); });
return; return;
} }
saveConfig("callOutSelectedShelfAreaIndex", this.selectedShelfAreaIndex);
var serverIPAndPort = getServerIPAndPort(); var serverIPAndPort = getServerIPAndPort();
uni.request({ uni.request({
url: "http://" + serverIPAndPort + "/pdaProductionLineCallOut/getShelfInfoForCallOut", url: "http://" + serverIPAndPort + "/pdaProductionLineCallOut/callOut",
// 请求的接口地址 // 请求的接口地址
method: "POST", method: "POST",
// 设置请求方式为 POST // 设置请求方式为 POST
data: { data: {
"locationId": this.locationId,
"locationCode": this.locationCode,
"shelfId": this.shelfId,
"shelfCode": this.shelfCode, "shelfCode": this.shelfCode,
"destinationLocationAreaId": this.shelfAreaOptions[this.selectedShelfAreaIndex].id,
"destinationLocationAreaName": this.shelfAreaOptions[this.selectedShelfAreaIndex].locationAreaName,
"ShelfTypeStr": this.shelfTypeOptions[this.selectedShelfTypeIndex].text,
"userName": this.userName, "userName": this.userName,
"deviceType": "PDA" "deviceType": "PDA"
}, },
@ -4925,28 +4935,18 @@ if (uni.restoreGlobal) {
success: (res) => { success: (res) => {
if (res.statusCode === 200) { if (res.statusCode === 200) {
if (res.data.code == 200) { if (res.data.code == 200) {
if (res.data.data == null) { uni.showToast({
uni.showToast({ title: "送回货架呼叫成功!",
title: "获取失败,请扫码重试!", icon: "none",
icon: "none", duration: 1500
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; return;
} else { } else {
uni.showToast({ uni.showToast({
title: "获取失败:" + res.data.message, title: "送回货架呼叫失败:" + res.data.message,
icon: "none", icon: "none",
duration: 3500 duration: 3500
}); });
this.clear();
} }
} else { } else {
uni.showToast({ uni.showToast({
@ -4954,7 +4954,6 @@ if (uni.restoreGlobal) {
icon: "none", icon: "none",
duration: 3e3 duration: 3e3
}); });
this.clear();
} }
}, },
fail: (err) => { fail: (err) => {
@ -4963,10 +4962,9 @@ if (uni.restoreGlobal) {
icon: "none", icon: "none",
duration: 3e3 duration: 3e3
}); });
this.clear();
}, },
complete: (event) => { 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() { cameraScanCode() {
uni.scanCode({ uni.scanCode({
success: (res) => { 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); this.analysisScanCode(res.result);
}, },
fail: (err) => { 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.locationId = res.data.data.locationId;
this.locationCode = res.data.data.locationCode; this.locationCode = res.data.data.locationCode;
this.shelfAreaOptions = res.data.data.locationAreas; this.shelfAreaOptions = res.data.data.locationAreas;
var index = getConfig("callOutSelectedShelfAreaIndex", 0);
if (index + 1 < this.shelfAreaOptions.length) {
this.selectedShelfAreaIndex = index;
}
this.getCurrentMatInfo(); this.getCurrentMatInfo();
return; return;
} else { } else {
@ -5045,7 +5047,7 @@ if (uni.restoreGlobal) {
this.clear(); this.clear();
}, },
complete: (event) => { 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(); this.clear();
}, },
complete: (event) => { 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.createCommentVNode(" 货架区域选择 "),
vue.createElementVNode("view", { vue.createElementVNode("view", {
class: "picker-container1", class: "picker-container1",
style: { "position": "relative" } style: { "position": "relative" }
}, [ }, [
vue.createElementVNode("view", { style: { "color": "darkgray" } }, "点击选择送回区域:"),
vue.createElementVNode("picker", { vue.createElementVNode("picker", {
ref: "shelfAreaPicker", ref: "shelfAreaPicker",
range: $data.shelfAreaOptions, range: $data.shelfAreaOptions,
@ -5359,13 +5362,14 @@ if (uni.restoreGlobal) {
class: "picker-container", class: "picker-container",
style: { "position": "relative" } style: { "position": "relative" }
}, [ }, [
vue.createElementVNode("view", { style: { "color": "darkgray" } }, "点击选择:"),
vue.createElementVNode("picker", { vue.createElementVNode("picker", {
ref: "shelfTypePicker", ref: "shelfTypePicker",
range: $data.shelfTypeOptions, range: $data.shelfTypeOptions,
"range-key": "text", "range-key": "text",
value: $data.selectedShelfTypeIndex, value: $data.selectedShelfTypeIndex,
onChange: _cache[10] || (_cache[10] = (...args) => $options.onShelfTypeChange && $options.onShelfTypeChange(...args)), 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( vue.createElementVNode(
"view", "view",

View File

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

View File

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