From 0d9fb6555efa42e27de4d57d3fb7b8d82a78ef45 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期四, 27 三月 2025 14:10:43 +0800
Subject: [PATCH] 优化任务处理逻辑并清理代码
---
CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs | 44 +++++++++++++++++++++++---------------------
1 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs b/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
index c753604..1138106 100644
--- a/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
+++ b/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
@@ -1,14 +1,9 @@
锘縰sing AutoMapper;
using HslCommunication;
-using Microsoft.AspNetCore.Components.Routing;
-using NetTaste;
using Newtonsoft.Json;
using Quartz;
using SqlSugar;
-using System.Drawing;
using System.Reflection;
-using System.Security.Policy;
-using System.Threading.Tasks;
using WIDESEAWCS_BasicInfoRepository;
using WIDESEAWCS_BasicInfoService;
using WIDESEAWCS_Common;
@@ -31,7 +26,6 @@
using WIDESEAWCS_QuartzJob.Service;
using WIDESEAWCS_SignalR;
using WIDESEAWCS_Tasks.ConveyorLineJob;
-using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
using ICacheService = WIDESEAWCS_Core.Caches.ICacheService;
namespace WIDESEAWCS_Tasks
@@ -353,15 +347,23 @@
}
else
{
- // 濡傛灉浠诲姟涓虹┖涓旀潯鐮佷笉涓�"NoRead"涓旀潯鐮佷笉涓虹┖锛屽垯澶勭悊鏂颁换鍔�
- if (task == null && command.Barcode != "NoRead" && command.Barcode.IsNotEmptyOrNull())
+ task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
+ if (task != null)
{
- // 鏌ヨ鏉$爜瀵瑰簲鐨勪换鍔�
- task = _taskService.QueryBarcodeTask(command.Barcode, childDeviceCode);
- if (task == null)
+ RequestInNextAddress(conveyorLine, command, childDeviceCode, ProtocalDetailValue);
+ }
+ else
+ {
+ // 濡傛灉浠诲姟涓虹┖涓旀潯鐮佷笉涓�"NoRead"涓旀潯鐮佷笉涓虹┖锛屽垯澶勭悊鏂颁换鍔�
+ if (task == null && command.Barcode != "NoRead" && command.Barcode.IsNotEmptyOrNull())
{
- // 寮傛澶勭悊鏂颁换鍔�
- await HandleNewTaskAsync(conveyorLine, command, childDeviceCode, ProtocalDetailValue);
+ // 鏌ヨ鏉$爜瀵瑰簲鐨勪换鍔�
+ task = _taskService.QueryBarcodeTask(command.Barcode, childDeviceCode);
+ if (task == null)
+ {
+ // 寮傛澶勭悊鏂颁换鍔�
+ await HandleNewTaskAsync(conveyorLine, command, childDeviceCode, ProtocalDetailValue);
+ }
}
}
}
@@ -385,28 +387,26 @@
IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == platform.PLCCode);
if (device != null)
{
- int x = 3;
CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
foreach (var item in Location)
{
- x--;
ConveyorLineTaskCommand command1 = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(item);
if (command1.InteractiveSignal != 2)
{
var tasks = _taskRepository.QueryData(x => (x.TaskType == (int)TaskInboundTypeEnum.InTray || x.TaskType == (int)TaskOutboundTypeEnum.OutTray) && x.TargetAddress == childDeviceCode);
// 濡傛灉宸叉湁浠诲姟鏁伴噺灏忎簬鎸囧畾绱㈠紩
- if (tasks.Count < Location.Count && tasks.Count < x)
+ if (tasks.Count < Location.Count)
{
return childDeviceCode;
}
else
{
- var Hastask = _taskRepository.QueryData(x => x.TaskType == (int)TaskOutboundTypeEnum.OutTray && x.TargetAddress == childDeviceCode && x.Roadway.Contains("CH") && x.TaskState == (int)TaskOutStatusEnum.OutNew);
- if (Hastask != null && Hastask.Count > 0)
- {
- //doto澶勭悊闄堝寲鏈墽琛岀殑绌烘墭鍑哄簱浠诲姟
- }
+ //var Hastask = _taskRepository.QueryData(x => x.TaskType == (int)TaskOutboundTypeEnum.OutTray && x.TargetAddress == childDeviceCode && x.Roadway.Contains("CH") && x.TaskState == (int)TaskOutStatusEnum.OutNew);
+ //if (Hastask != null && Hastask.Count > 0)
+ //{
+ // //doto澶勭悊闄堝寲鏈墽琛岀殑绌烘墭鍑哄簱浠诲姟
+ //}
return null;
}
}
@@ -470,6 +470,8 @@
WriteInfo(conveyorLine.DeviceName, logs);
conveyorLine.SendCommand(taskCommand, childDeviceCode);
+
+ ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
}
}
}
--
Gitblit v1.9.3