PDA产线呼叫功能优化

This commit is contained in:
hehaibing-1996
2025-02-26 15:10:15 +08:00
parent f7d15a1f73
commit d9f83f95e0
4 changed files with 220 additions and 106 deletions

View File

@ -2,10 +2,10 @@
<view class="bg-image">
<uni-popup ref="popup" type="dialog">
<view class="popup-content">
<view style="margin: 3rpx;">
<view style="margin: 3rpx;">
<label>是否呼叫以下货架</label>
</view>
<view style="font-size: 52rpx;text-align: center;margin-top: 15rpx;margin-bottom: 10rpx;">
<view style="font-size: 52rpx;text-align: center;margin-top: 15rpx;margin-bottom: 10rpx;">
<text>{{fixedInfo.shelfCode}}</text>
</view>
<view class="button-group">
@ -33,7 +33,7 @@
</view>
<view style="flex: 30;">
<button @click="queryMatList">查询</button>
<button @click="queryMatList(true)">查询</button>
</view>
</view>
</view>
@ -155,10 +155,7 @@
//接口返回数据为200 表示获取成功!
if (res.data.code == 200) {
hidePopup();
proxy.queryMatList();
proxy.queryMatList(false);
uni.showToast({
title: '呼叫成功!',
icon: 'none',
@ -166,9 +163,9 @@
});
} else {
uni.showToast({
title: res.data.message,
title: '呼叫失败:' + res.data.message,
icon: 'none',
duration: 2500
duration: 4000
});
}
@ -240,6 +237,7 @@
});
},
methods: {
//扫码获取工位信息
analysisScanCode: function(encodedString) {
// 去除末尾的逗号和"..."(如果有的话)
encodedString = encodedString.replace(/,\s*\.\.\.$/, '');
@ -323,18 +321,21 @@
},
//搜索获取物料信息
queryMatList: function() {
queryMatList: function(isTip) {
if (this.locationCode == null || this.locationCode == '') {
uni.showToast({
title: '请先扫描工位码!',
icon: 'none',
duration: 1000
});
if (isTip) {
uni.showToast({
title: '请先扫描工位码!',
icon: 'none',
duration: 1000
});
}
return;
}
if (this.matCodeCondition == this.locationCode) {
this.matCodeCondition = '';
return;
}
var serverIPAndPort = getServerIPAndPort();
uni.request({
@ -358,51 +359,62 @@
if (res.data.code == 200) {
//未查询到信息
if (res.data.data == null || res.data.data.count == 0) {
uni.showToast({
title: '获取失败!',
icon: 'none',
duration: 1500
});
if (isTip) {
uni.showToast({
title: '获取失败!',
icon: 'none',
duration: 1500
});
}
this.clear();
return;
}
//有物料信息
this.cardData = res.data.data.lists;
this.recordCount = res.data.data.count;
uni.showToast({
title: '获取成功!',
icon: 'none',
duration: 100
});
if (isTip) {
uni.showToast({
title: '获取成功!',
icon: 'none',
duration: 100
});
}
} else {
uni.showToast({
title: '获取失败:' + res.data.message,
icon: 'none',
duration: 3500
});
if (isTip) {
uni.showToast({
title: '获取失败:' + res.data.message,
icon: 'none',
duration: 3500
});
}
this.clear();
}
} else {
if (isTip) {
uni.showToast({
title: '服务器返回错误状态码' + res.statusCode,
icon: 'none',
duration: 3000
});
this.clear();
}
}
},
fail: (err) => {
if (isTip) {
// 请求失败的回调函数
uni.showToast({
title: '服务器返回错误状态码' + res.statusCode,
title: '请求失败:' + err.errMsg,
icon: 'none',
duration: 3000
});
this.clear();
}
},
fail: (err) => {
// 请求失败的回调函数
uni.showToast({
title: '请求失败:' + err.errMsg,
icon: 'none',
duration: 3000
});
this.clear();
},
complete: (event) => {
// 请求完成的回调函数(无论成功或失败都会调用)
console.log('请求完成', event);

View File

@ -546,7 +546,7 @@
uni.showToast({
title: '获取成功!',
icon: 'none',
duration: 100
duration: 500
});
} else {

View File

@ -4239,7 +4239,7 @@ if (uni.restoreGlobal) {
if (res.statusCode === 200) {
if (res.data.code == 200) {
hidePopup();
proxy.queryMatList();
proxy.queryMatList(false);
uni.showToast({
title: "呼叫成功!",
icon: "none",
@ -4247,9 +4247,9 @@ if (uni.restoreGlobal) {
});
} else {
uni.showToast({
title: res.data.message,
title: "呼叫失败:" + res.data.message,
icon: "none",
duration: 2500
duration: 4e3
});
}
} else {
@ -4308,13 +4308,14 @@ if (uni.restoreGlobal) {
this.userName = getConfig("userName", "admin");
const self = this;
recive(function(res) {
formatAppLog("log", "at pages/productionLineCallIn/productionLineCallIn.vue:235", "Success:" + res.data);
formatAppLog("log", "at pages/productionLineCallIn/productionLineCallIn.vue:232", "Success:" + res.data);
self.analysisScanCode(res.data);
}, function(err) {
formatAppLog("log", "at pages/productionLineCallIn/productionLineCallIn.vue:239", "Error:", JSON.stringify(err));
formatAppLog("log", "at pages/productionLineCallIn/productionLineCallIn.vue:236", "Error:", JSON.stringify(err));
});
},
methods: {
//扫码获取工位信息
analysisScanCode: function(encodedString) {
encodedString = encodedString.replace(/,\s*\.\.\.$/, "");
this.locationCode = encodedString;
@ -4375,22 +4376,25 @@ if (uni.restoreGlobal) {
this.clearLocation();
},
complete: (event) => {
formatAppLog("log", "at pages/productionLineCallIn/productionLineCallIn.vue:318", "请求完成", event);
formatAppLog("log", "at pages/productionLineCallIn/productionLineCallIn.vue:316", "请求完成", event);
}
});
},
//搜索获取物料信息
queryMatList: function() {
queryMatList: function(isTip) {
if (this.locationCode == null || this.locationCode == "") {
uni.showToast({
title: "请先扫描工位码!",
icon: "none",
duration: 1e3
});
if (isTip) {
uni.showToast({
title: "请先扫描工位码!",
icon: "none",
duration: 1e3
});
}
return;
}
if (this.matCodeCondition == this.locationCode) {
this.matCodeCondition = "";
return;
}
var serverIPAndPort = getServerIPAndPort();
uni.request({
@ -4413,48 +4417,58 @@ if (uni.restoreGlobal) {
if (res.statusCode === 200) {
if (res.data.code == 200) {
if (res.data.data == null || res.data.data.count == 0) {
uni.showToast({
title: "获取失败!",
icon: "none",
duration: 1500
});
if (isTip) {
uni.showToast({
title: "获取失败!",
icon: "none",
duration: 1500
});
}
this.clear();
return;
}
this.cardData = res.data.data.lists;
this.recordCount = res.data.data.count;
uni.showToast({
title: "获取成功!",
icon: "none",
duration: 100
});
if (isTip) {
uni.showToast({
title: "获取成功!",
icon: "none",
duration: 100
});
}
} else {
uni.showToast({
title: "获取失败:" + res.data.message,
icon: "none",
duration: 3500
});
if (isTip) {
uni.showToast({
title: "获取失败:" + res.data.message,
icon: "none",
duration: 3500
});
}
this.clear();
}
} else {
if (isTip) {
uni.showToast({
title: "服务器返回错误状态码" + res.statusCode,
icon: "none",
duration: 3e3
});
this.clear();
}
}
},
fail: (err) => {
if (isTip) {
uni.showToast({
title: "服务器返回错误状态码" + res.statusCode,
title: "请求失败:" + err.errMsg,
icon: "none",
duration: 3e3
});
this.clear();
}
},
fail: (err) => {
uni.showToast({
title: "请求失败:" + err.errMsg,
icon: "none",
duration: 3e3
});
this.clear();
},
complete: (event) => {
formatAppLog("log", "at pages/productionLineCallIn/productionLineCallIn.vue:408", "请求完成", event);
formatAppLog("log", "at pages/productionLineCallIn/productionLineCallIn.vue:420", "请求完成", event);
}
});
},
@ -4564,7 +4578,7 @@ if (uni.restoreGlobal) {
vue.createElementVNode("view", { style: { "flex": "3" } }),
vue.createElementVNode("view", { style: { "flex": "30" } }, [
vue.createElementVNode("button", {
onClick: _cache[4] || (_cache[4] = (...args) => $options.queryMatList && $options.queryMatList(...args))
onClick: _cache[4] || (_cache[4] = ($event) => $options.queryMatList(true))
}, "查询")
])
])
@ -4993,7 +5007,7 @@ if (uni.restoreGlobal) {
uni.showToast({
title: "获取成功!",
icon: "none",
duration: 100
duration: 500
});
} else {
uni.showToast({

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;
@ -117,7 +119,7 @@ namespace WCS.WebApi.Controllers
return new ResponseCommon()
{
Code = 201,
Message = $"参数错误:请重新扫描工位码!",
Message = $"参数错误,请重新扫描工位码!",
Data = null,
};
}
@ -130,7 +132,7 @@ namespace WCS.WebApi.Controllers
return new ResponseCommon()
{
Code = 201,
Message = $"获取失败:工位{request.LocationCode}不存在!",
Message = $"工位{request.LocationCode}不存在!",
Data = null,
};
}
@ -139,20 +141,24 @@ namespace WCS.WebApi.Controllers
return new ResponseCommon()
{
Code = 201,
Message = $"获取失败:工位{locationInfo.LocationCode}已被禁用!",
Message = $"工位{locationInfo.LocationCode}已被禁用!",
Data = null,
};
}
var shelfInfo = await DbHelp.db.Queryable<ShelfInfo>()
.Where(t => t.CurrentLocationId == locationInfo.Id)
.Where(t => t.CurrentLocationId == locationInfo.Id || t.DestinationLocationId == locationInfo.Id)
.FirstAsync();
if (shelfInfo != null)
{
if (shelfInfo.TransStatus == TransStatusEnum.)
{
shelfInfo.ShelfCode = shelfInfo.ShelfCode + "(运输中)";
}
return new ResponseCommon()
{
Code = 301,
Message = $"获取失败:工位{locationInfo.LocationCode}已被货架{shelfInfo.ShelfCode}占用!",
Message = $"当前工位[{locationInfo.LocationCode}]\r\n已被货架[{shelfInfo.ShelfCode}]占用\r\n无法通过此功能进行呼叫!",
Data = null,
};
}
@ -163,7 +169,7 @@ namespace WCS.WebApi.Controllers
.LeftJoin<ShelfInfo>((mci, si) => mci.ShelfId == si.Id)
//货架状态是静止的 代表这个货架没有被呼叫走哦
.LeftJoin<LocationInfo>((mci, si, li) => (si.TransStatus == TransStatusEnum. && si.CurrentLocationId == li.Id))
.WhereIF(!string.IsNullOrEmpty(request.MatCodeCondition), (mci, si, li) => mci.MatCode.Contains(request.MatCodeCondition))
.WhereIF(!string.IsNullOrEmpty(request.MatCodeCondition), (mci, si, li) => mci.MatCode.Contains(request.MatCodeCondition) || mci.MatName.Contains(request.MatCodeCondition))
.Select((mci, si, li) => new MatDetailCurrentInfoModel()
{
Id = mci.Id,
@ -235,42 +241,55 @@ namespace WCS.WebApi.Controllers
return new ResponseCommon()
{
Code = 201,
Message = $"呼叫失败:请重新扫描工位码!",
Message = $"请重新扫描工位码!",
Data = null,
};
}
//获取位置信息
var locationInfo = await DbHelp.db.Queryable<LocationInfo>()
var endLocation = await DbHelp.db.Queryable<LocationInfo>()
.Where(t => t.Id == request.LocationId)
.FirstAsync();
if (locationInfo == null)
if (endLocation == null)
{
return new ResponseCommon()
{
Code = 201,
Message = $"呼叫失败:工位{request.LocationCode}不存在!",
Message = $"当前工位{request.LocationCode}不存在!",
Data = null,
};
}
if (locationInfo.IsEnable == false)
if (endLocation.IsEnable == false)
{
return new ResponseCommon()
{
Code = 201,
Message = $"呼叫失败:工位{locationInfo.LocationCode}已被禁用!",
Message = $"当前工位{endLocation.LocationCode}已被禁用!",
Data = null,
};
}
var shelfInfo = await DbHelp.db.Queryable<ShelfInfo>()
.Where(t => t.CurrentLocationId == locationInfo.Id)
.Where(t => t.CurrentLocationId == endLocation.Id && t.TransStatus == TransStatusEnum.)
.FirstAsync();
if (shelfInfo != null)
{
return new ResponseCommon()
{
Code = 301,
Message = $"呼叫失败:工位{locationInfo.LocationCode}已被货架{shelfInfo.ShelfCode}占用!",
Message = $"当前工位{endLocation.LocationCode}已被货架{shelfInfo.ShelfCode}占用!",
Data = null,
};
}
shelfInfo = await DbHelp.db.Queryable<ShelfInfo>()
.Where(t => t.DestinationLocationId == endLocation.Id && t.TransStatus == TransStatusEnum.)
.FirstAsync();
if (shelfInfo != null)
{
return new ResponseCommon()
{
Code = 301,
Message = $"当前工位{endLocation.LocationCode}已呼叫货架{shelfInfo.ShelfCode}!\r\n请勿重新呼叫",
Data = null,
};
}
@ -286,31 +305,100 @@ namespace WCS.WebApi.Controllers
return new ResponseCommon()
{
Code = 201,
Message = $"呼叫失败:货架{shelfInfo.ShelfCode}不存在或已被禁用!",
Message = $"货架{shelfInfo.ShelfCode}不存在或已被禁用!",
Data = null,
};
}
if (shelfInfo.TransStatus == TransStatusEnum.)
{
if (shelfInfo.DestinationLocationId == request.LocationId)
{
return new ResponseCommon()
{
Code = 201,
Message = $"呼叫失败:货架{shelfInfo.ShelfCode}已呼叫至当前工位,请等待!",
Data = null,
};
}
else
{
return new ResponseCommon()
{
Code = 201,
Message = $"呼叫失败:货架{shelfInfo.ShelfCode}正在被运输中,请选择其他货架!",
Data = null,
};
}
}
//获取起点位置
if (shelfInfo.CurrentLocationId == 0 || string.IsNullOrEmpty(shelfInfo.CurrentLocaiotnCode))
{
return new ResponseCommon()
{
Code = 201,
Message = $"呼叫失败:货架{shelfInfo.ShelfCode}正在运输中!",
Message = $"货架{shelfInfo.ShelfCode}未与位置绑定,无法呼叫!",
Data = null,
};
}
var startLocation = await DbHelp.db.Queryable<LocationInfo>()
.Where(t => t.Id == shelfInfo.CurrentLocationId)
.FirstAsync();
if (startLocation == null)
{
return new ResponseCommon()
{
Code = 201,
Message = $"货架{shelfInfo.ShelfCode}未与位置绑定,无法呼叫!",
Data = null,
};
}
if (startLocation.IsEnable == false)
{
return new ResponseCommon()
{
Code = 201,
Message = $"货架{shelfInfo.ShelfCode}所在位置已被禁用,无法呼叫!",
Data = null,
};
}
#endregion
#region
//TO DO 调用AGV接口开始呼叫 呼叫成功更新运输状态和目标库位
return new ResponseCommon()
#region AGV接口
var response = AGVManager.GenAgvSchedulingTask(startLocation, endLocation, shelfInfo.ShelfCode, request.UserName);
if (response.code == "0" && response.message == "成功")
{
Code = 200,
Message = $"呼叫成功!",
Data = null,
};
//更新货架位置信息
shelfInfo.TransStatus = TransStatusEnum.;
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
}
catch (Exception ex)