PDA任务查询功能优化

This commit is contained in:
hehaibing-1996
2025-02-25 19:51:07 +08:00
parent 44fb5831b2
commit f7d15a1f73
3 changed files with 224 additions and 51 deletions

View File

@ -22,9 +22,10 @@
<label>任务状态</label>
<text>{{fixedInfo.taskStatusStr}}</text>
</view>
<view>
<button style="background-color: bisque;margin-top: 10rpx;" @click="saveData">{{fixedInfo.buttonMode}}</button>
<button style="background-color: bisque;margin-top: 10rpx;"
@click="saveData">{{fixedInfo.buttonMode}}</button>
</view>
<view class="button-group">
@ -72,7 +73,14 @@
<view style="display: flex;flex-direction: row;width: 455rpx;">
<view>任务状态</view>
<view>123</view>
<view class="picker-container" style="font-size: 30rpx;">
<picker :range="taskStatusOptions" @change="onTaskStatusChange" range-key="taskStatusName"
:value="selectedtaskStatusIndex">
<view class="uni-input" style="padding-left: 5rpx;">
{{taskStatusOptions[selectedtaskStatusIndex].taskStatusName}}
</view>
</picker>
</view>
</view>
</view>
@ -140,8 +148,8 @@
shelfCode: '',
startLocationCode: '',
endLocationCode: '',
taskStatusStr:'',
buttonMode:'无法操作'
taskStatusStr: '',
buttonMode: '无法操作'
};
const popup = ref(null);
const inputValue = ref('');
@ -153,20 +161,15 @@
fixedInfo.startLocationCode = info.startLocationCode;
fixedInfo.endLocationCode = info.endLocationCode;
fixedInfo.taskStatusStr = info.taskStatusStr;
if(info.taskStatusStr == '已创建' || info.taskStatusStr == '正在执行')
{
if (info.taskStatusStr == '已创建' || info.taskStatusStr == '正在执行') {
fixedInfo.buttonMode = '取消任务';
}
else if(info.taskStatusStr == '取消完成')
{
} else if (info.taskStatusStr == '取消完成') {
fixedInfo.buttonMode = '重新发送';
}
else
{
} else {
fixedInfo.buttonMode = '无法操作';
}
popup.value.open();
};
@ -177,18 +180,13 @@
const saveData = () => {
var url = '';
var serverIPAndPort = getServerIPAndPort();
if(fixedInfo.taskStatusStr == '已创建' || fixedInfo.taskStatusStr == '正在执行')
{
if (fixedInfo.taskStatusStr == '已创建' || fixedInfo.taskStatusStr == '正在执行') {
//取消任务
url = 'http://' + serverIPAndPort + '/agvTask/cancelAGVTask';
}
else if(fixedInfo.taskStatusStr == '取消完成')
{
} else if (fixedInfo.taskStatusStr == '取消完成') {
//重新发送任务
url = 'http://' + serverIPAndPort + '/agvTask/resendAGVTask';
}
else
{
} else {
return;
}
//调用接口进行数量的修改
@ -216,7 +214,7 @@
duration: 2000
});
proxy.analysisScanCode();
} else {
uni.showToast({
title: '操作失败:' + res.data.message,
@ -277,6 +275,13 @@
touchStartX: 0,
touchStartY: 0,
isMove: false, //滑动标识 是否滑动
// 货架区域选项
taskStatusOptions: [{
id: null,
taskStatusName: '全部'
}],
selectedtaskStatusIndex: 0, //
}
},
onShow: function() {
@ -289,17 +294,23 @@
}, function(err) {
console.log("Error:", JSON.stringify(err)); // 正确打印错误信息
});
self.getTaskStatus();
},
methods: {
onTaskStatusChange(e) {
this.selectedtaskStatusIndex = e.detail.value;
this.analysisScanCode();
},
analysisScanCode: function() {
//调用接口获取当前工位信息 当前工位是否有货架
//获取任务
var serverIPAndPort = getServerIPAndPort();
uni.request({
url: 'http://' + serverIPAndPort +
'/agvTask/getAGVTasks', // 请求的接口地址
method: 'POST', // 设置请求方式为 POST
data: {
"taskStatus": null,
"taskStatus": this.taskStatusOptions[this.selectedtaskStatusIndex].id,
"userName": this.userName,
"deviceType": "PDA",
"pageNumber": 1,
@ -316,20 +327,17 @@
//未查询到信息
if (res.data.data == null || res.data.data.count == 0) {
uni.showToast({
title: '未查询到对应状态的任务信息!',
title: '未查询到状态为['+this.taskStatusOptions[this.selectedtaskStatusIndex].taskStatusName+']的任务信息!',
icon: 'none',
duration: 1500
duration: 2500
});
this.clear();
return;
}
//有物料信息
this.cardData = res.data.data.lists;
this.recordCount = res.data.data.count;
uni.showToast({
title: '获取成功!',
icon: 'none',
duration: 100
});
} else {
uni.showToast({
@ -367,9 +375,59 @@
},
getTaskStatus: function() {
//获取任务
var serverIPAndPort = getServerIPAndPort();
uni.request({
url: 'http://' + serverIPAndPort +
'/agvTask/getAGVTaskStatus', // 请求的接口地址
method: 'POST', // 设置请求方式为 POST
data: {
"userName": this.userName,
"deviceType": "PDA",
},
header: {
'Content-Type': 'application/json', // 如果需要以JSON格式发送数据
},
success: (res) => {
// 请求成功的回调函数
if (res.statusCode === 200) {
//接口返回数据为200 表示获取成功!
if (res.data.code == 200) {
//未查询到信息
if (res.data.data == null || res.data.data.count == 0) {
return;
}
this.taskStatusOptions = res.data.data;
this.selectedtaskStatusIndex = 2;//默认查询正在执行的任务
this.analysisScanCode();
} else {
return;
}
} else {
return;
}
},
fail: (err) => {
// 请求失败的回调函数
return;
},
complete: (event) => {
// 请求完成的回调函数(无论成功或失败都会调用)
console.log('请求完成', event);
}
});
},
//清空当前界面所有内容
clear: function() {
this.placeholderText = '请先扫描货架码';
this.placeholderText = '';
this.cardData = null;
this.recordCount = 0;
},
@ -498,4 +556,16 @@
color: #fff;
cursor: pointer;
}
.picker-container {
border-radius: 5rpx;
border: 2rpx solid #000;
/* 设置边框宽度和颜色 */
margin-left: 25rpx;
margin-right: 25rpx;
/* 上下边距为5rpx左右边距自动以实现水平居中 */
width: 200rpx;
/* 设置宽度 */
/* 其他样式保持不变 */
}
</style>

View File

@ -5545,21 +5545,33 @@ if (uni.restoreGlobal) {
//监控滑动的位置
touchStartX: 0,
touchStartY: 0,
isMove: false
isMove: false,
//滑动标识 是否滑动
// 货架区域选项
taskStatusOptions: [{
id: null,
taskStatusName: "全部"
}],
selectedtaskStatusIndex: 0
//
};
},
onShow: function() {
this.userName = getConfig("userName", "admin");
const self = this;
recive(function(res) {
formatAppLog("log", "at pages/agvTasks/agvTasks.vue:287", "Success:" + res.data);
formatAppLog("log", "at pages/agvTasks/agvTasks.vue:292", "Success:" + res.data);
self.analysisScanCode();
}, function(err) {
formatAppLog("log", "at pages/agvTasks/agvTasks.vue:290", "Error:", JSON.stringify(err));
formatAppLog("log", "at pages/agvTasks/agvTasks.vue:295", "Error:", JSON.stringify(err));
});
self.getTaskStatus();
},
methods: {
onTaskStatusChange(e) {
this.selectedtaskStatusIndex = e.detail.value;
this.analysisScanCode();
},
analysisScanCode: function() {
var serverIPAndPort = getServerIPAndPort();
uni.request({
@ -5568,7 +5580,7 @@ if (uni.restoreGlobal) {
method: "POST",
// 设置请求方式为 POST
data: {
"taskStatus": null,
"taskStatus": this.taskStatusOptions[this.selectedtaskStatusIndex].id,
"userName": this.userName,
"deviceType": "PDA",
"pageNumber": 1,
@ -5583,19 +5595,15 @@ if (uni.restoreGlobal) {
if (res.data.code == 200) {
if (res.data.data == null || res.data.data.count == 0) {
uni.showToast({
title: "未查询到对应状态的任务信息!",
title: "未查询到状态为[" + this.taskStatusOptions[this.selectedtaskStatusIndex].taskStatusName + "]的任务信息!",
icon: "none",
duration: 1500
duration: 2500
});
this.clear();
return;
}
this.cardData = res.data.data.lists;
this.recordCount = res.data.data.count;
uni.showToast({
title: "获取成功!",
icon: "none",
duration: 100
});
} else {
uni.showToast({
title: "获取失败:" + res.data.message,
@ -5622,13 +5630,52 @@ if (uni.restoreGlobal) {
this.clear();
},
complete: (event) => {
formatAppLog("log", "at pages/agvTasks/agvTasks.vue:364", "请求完成", event);
formatAppLog("log", "at pages/agvTasks/agvTasks.vue:372", "请求完成", event);
}
});
},
getTaskStatus: function() {
var serverIPAndPort = getServerIPAndPort();
uni.request({
url: "http://" + serverIPAndPort + "/agvTask/getAGVTaskStatus",
// 请求的接口地址
method: "POST",
// 设置请求方式为 POST
data: {
"userName": this.userName,
"deviceType": "PDA"
},
header: {
"Content-Type": "application/json"
// 如果需要以JSON格式发送数据
},
success: (res) => {
if (res.statusCode === 200) {
if (res.data.code == 200) {
if (res.data.data == null || res.data.data.count == 0) {
return;
}
this.taskStatusOptions = res.data.data;
this.selectedtaskStatusIndex = 2;
this.analysisScanCode();
} else {
return;
}
} else {
return;
}
},
fail: (err) => {
return;
},
complete: (event) => {
formatAppLog("log", "at pages/agvTasks/agvTasks.vue:420", "请求完成", event);
}
});
},
//清空当前界面所有内容
clear: function() {
this.placeholderText = "请先扫描货架码";
this.placeholderText = "";
this.cardData = null;
this.recordCount = 0;
},
@ -5799,7 +5846,28 @@ if (uni.restoreGlobal) {
vue.createElementVNode("view", { style: { "width": "10rpx" } }),
vue.createElementVNode("view", { style: { "display": "flex", "flex-direction": "row", "width": "455rpx" } }, [
vue.createElementVNode("view", null, "任务状态:"),
vue.createElementVNode("view", null, "123")
vue.createElementVNode("view", {
class: "picker-container",
style: { "font-size": "30rpx" }
}, [
vue.createElementVNode("picker", {
range: $data.taskStatusOptions,
onChange: _cache[5] || (_cache[5] = (...args) => $options.onTaskStatusChange && $options.onTaskStatusChange(...args)),
"range-key": "taskStatusName",
value: $data.selectedtaskStatusIndex
}, [
vue.createElementVNode(
"view",
{
class: "uni-input",
style: { "padding-left": "5rpx" }
},
vue.toDisplayString($data.taskStatusOptions[$data.selectedtaskStatusIndex].taskStatusName),
1
/* TEXT */
)
], 40, ["range", "value"])
])
])
])
]),
@ -5817,8 +5885,8 @@ if (uni.restoreGlobal) {
vue.renderList($data.cardData, (item, index) => {
return vue.openBlock(), vue.createElementBlock("view", {
key: index,
onTouchstart: _cache[5] || (_cache[5] = (...args) => $options.cardTouchStart && $options.cardTouchStart(...args)),
onTouchmove: _cache[6] || (_cache[6] = (...args) => $options.cardTouchMove && $options.cardTouchMove(...args)),
onTouchstart: _cache[6] || (_cache[6] = (...args) => $options.cardTouchStart && $options.cardTouchStart(...args)),
onTouchmove: _cache[7] || (_cache[7] = (...args) => $options.cardTouchMove && $options.cardTouchMove(...args)),
onLongpress: ($event) => $options.longpress(item)
}, [
vue.createVNode(_component_TaskCard, {

View File

@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using NPOI.POIFS.Crypt.Dsig;
using NPOI.SS.Formula.Functions;
using SqlSugar;
using WCS.BLL;
@ -31,6 +32,40 @@ namespace WCS.WebApi.Controllers
_PDAMatBindService = PDAMatBindService;
}
[Route("getAGVTaskStatus")]
[HttpPost(Name = "getAGVTaskStatus")]
public async Task<ResponseCommon> getAGVTaskStatus(RequestBase request)
{
try
{
var status = new List<GetAGVTasksResponseData>();
status.Add(new GetAGVTasksResponseData{Id = null,TaskStatusName="全部" });
var statusesInDb = Enum.GetValues(typeof(TaskStatusEnum))
.Cast<TaskStatusEnum>()
.ToList();
statusesInDb.ForEach(t => status.Add(new GetAGVTasksResponseData{ Id = (int)t,TaskStatusName = t.ToString()}));
return new ResponseCommon
{
Code=200,
Data = status,
Message = "success"
};
}
catch (Exception ex)
{
return new ResponseCommon
{
Code = 300,
Message = $"操作失败:{ex.Message}",
};
}
}
public class GetAGVTasksResponseData
{
public int? Id { get; set; }
public string TaskStatusName { get; set; }
}
/// <summary>
/// 获取AGV任务列表
/// </summary>
@ -47,7 +82,7 @@ namespace WCS.WebApi.Controllers
.WhereIF(string.IsNullOrEmpty(request.CreateUser), t => t.CreateUser.Contains(request.CreateUser))
.WhereIF(string.IsNullOrEmpty(request.StartLocationCode), t => t.StartLocationCode.Contains(request.StartLocationCode))
.WhereIF(string.IsNullOrEmpty(request.EndLocationCode), t => t.StartLocationCode.Contains(request.EndLocationCode))
.WhereIF(request.TaskStatus !=null, t => t.TaskStatus == request.TaskStatus);
.WhereIF(request.TaskStatus != null, t => t.TaskStatus == request.TaskStatus);
var totalCount = await recordsQueryable.CountAsync();
var records = await recordsQueryable