From 88fe391fb9ca2ccb25ab70f945e2190b95a11fb9 Mon Sep 17 00:00:00 2001
From: xxyy <cathay_xy@163.com>
Date: 星期三, 05 三月 2025 10:45:07 +0800
Subject: [PATCH] 更新配置和数据模型,添加物料管理功能
---
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs | 187 +++++++++++++++++++++++++++++-----------------
1 files changed, 119 insertions(+), 68 deletions(-)
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
index 5104d55..3589d01 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
@@ -77,79 +77,115 @@
CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams");
if (conveyorLine != null)
{
+ //ConsoleHelper.WriteColorLine("寮�濮嬶細" + DateTime.Now, ConsoleColor.Cyan);
// 鏌ヨ鎵�鏈夊瓙璁惧鐨勪綅缃�
List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode);
+ // 鑾峰彇鎵�鏈夌珯鐐圭鐞嗗櫒
+ List<Dt_StationManager> stationManagers = _stationManagerService.GetAllStationByDeviceCode(conveyorLine.DeviceCode);
// 骞惰澶勭悊姣忎釜瀛愯澶�
var tasks = childDeviceCodes.Select(childDeviceCode => ProcessDeviceAsync(conveyorLine, childDeviceCode)).ToList();
+
+ // 骞惰澶勭悊姣忎釜绔欑偣绠$悊鍣�
+ tasks = stationManagers.Select(station => Task.Run(async () =>
+ {
+ var (command, commandWrite) = ReadCommands(station, conveyorLine);
+ if (command == null || commandWrite == null)
+ {
+ return;
+ }
+
+ IStationHandler handler = StationHandlerFactory.GetHandler(station.stationType, this);
+ await handler.HandleStationAsync(conveyorLine, station, command, commandWrite);
+ })).ToList();
+
+ #region
+ //foreach (var station in stationManagers)
+ //{
+ // #region
+ // //tasks.Add(Task.Run(async () =>
+ // //{
+ // // if (station.stationType == 11)
+ // // {
+ // // // 璇诲彇浠诲姟鍛戒护鍜岃澶囧懡浠�
+ // // ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(station.stationChildCode);
+ // // ConveyorLineTaskCommandWrite commandWrite = conveyorLine.ReadCustomer<ConveyorLineTaskCommandWrite>(station.stationChildCode, "DeviceCommand");
+ // // if (command != null && commandWrite != null)
+ // // {
+ // // // 灏嗕氦浜掍俊鍙疯浆鎹负甯冨皵鏁扮粍
+ // // var structs = BitConverter.GetBytes(commandWrite.WriteInteractiveSignal).Reverse().ToArray().ToBoolArray();
+ // // if (structs[0] == true)
+ // // {
+ // // // 杈撳嚭璀﹀憡淇℃伅
+ // // var log = $"銆恵conveyorLine.DeviceName}銆戜换鍔″彿锛氥�恵command.TaskNum}銆�,鎵樼洏鏉$爜锛氥�恵command.Barcode}銆戝凡鍒拌揪銆恵station.stationChildCode}銆戠┖鎵樼洏璇锋眰鎵爜鍏ュ簱";
+ // // ConsoleHelper.WriteWarningLine(log);
+
+ // // await _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
+ // // WriteInfo(conveyorLine.DeviceName, log);
+
+ // // // 澶勭悊鍏ュ簱璇锋眰
+ // // NGRequestTaskInbound(conveyorLine, command, station, 0);
+ // // }
+ // // else
+ // // {
+ // // // 鍙戦�佸畬鎴愪俊鍙�
+ // // ConveyorLineSendFinish(conveyorLine, station.stationChildCode, 0, false);
+ // // }
+ // // }
+ // // }
+ // // else if (station.stationType == 5)
+ // // {
+ // // // 璇诲彇浠诲姟鍛戒护鍜岃澶囧懡浠�
+ // // ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(station.stationChildCode);
+ // // ConveyorLineTaskCommandWrite commandWrite = conveyorLine.ReadCustomer<ConveyorLineTaskCommandWrite>(station.stationChildCode, "DeviceCommand");
+ // // if (command != null && commandWrite != null)
+ // // {
+ // // // 灏嗕氦浜掍俊鍙疯浆鎹负甯冨皵鏁扮粍
+ // // var structs = BitConverter.GetBytes(commandWrite.WriteInteractiveSignal).Reverse().ToArray().ToBoolArray();
+ // // if (structs[0] == true)
+ // // {
+ // // // 妫�鏌ユ槸鍚﹀瓨鍦ㄤ换鍔�
+ // // if (_taskRepository.QueryData(x => x.SourceAddress == station.stationChildCode).Count() > 0)
+ // // {
+ // // return;
+ // // }
+ // // // 杈撳嚭璀﹀憡淇℃伅
+ // // var log = $"銆恵conveyorLine.DeviceName}銆戜换鍔″彿锛氥�恵command.TaskNum}銆�,鎵樼洏鏉$爜锛氥�恵command.Barcode}銆戝凡鍒拌揪銆恵station.stationChildCode}銆戝紓甯稿彛璇锋眰鎵爜鍏ュ簱";
+ // // ConsoleHelper.WriteWarningLine(log);
+
+ // // await _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
+ // // WriteInfo(conveyorLine.DeviceName, log);
+
+ // // // 澶勭悊鏂颁换鍔�
+ // // await HandleNewTaskAsync(conveyorLine, command, station.stationChildCode, 0);
+ // // }
+ // // else
+ // // {
+ // // // 鍙戦�佸畬鎴愪俊鍙�
+ // // ConveyorLineSendFinish(conveyorLine, station.stationChildCode, 0, false);
+ // // }
+ // // }
+ // // }
+ // //}));
+ // #endregion
+
+ // tasks.Add(Task.Run(async () =>
+ // {
+ // var (command, commandWrite) = ReadCommands(station, conveyorLine);
+ // if (command == null || commandWrite == null)
+ // {
+ // return;
+ // }
+
+ // IStationHandler handler = StationHandlerFactory.GetHandler(station.stationType, this);
+ // await handler.HandleStationAsync(conveyorLine, station, command, commandWrite);
+ // }));
+ //}
+ #endregion
+
await Task.WhenAll(tasks);
- // 鑾峰彇鎵�鏈夌珯鐐圭鐞嗗櫒
- List<Dt_StationManager> stationManagers = _stationManagerService.GetAllStationByDeviceCode(conveyorLine.DeviceCode);
- foreach (var station in stationManagers)
- {
- if (station.stationType == 11)
- {
- // 璇诲彇浠诲姟鍛戒护鍜岃澶囧懡浠�
- ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(station.stationChildCode);
- ConveyorLineTaskCommandWrite commandWrite = conveyorLine.ReadCustomer<ConveyorLineTaskCommandWrite>(station.stationChildCode, "DeviceCommand");
- if (command != null && commandWrite != null)
- {
- // 灏嗕氦浜掍俊鍙疯浆鎹负甯冨皵鏁扮粍
- var structs = BitConverter.GetBytes(commandWrite.WriteInteractiveSignal).Reverse().ToArray().ToBoolArray();
- if (structs[0] == true)
- {
- // 杈撳嚭璀﹀憡淇℃伅
- var log = $"銆恵conveyorLine.DeviceName}銆戜换鍔″彿锛氥�恵command.TaskNum}銆�,鎵樼洏鏉$爜锛氥�恵command.Barcode}銆戝凡鍒拌揪銆恵station.stationChildCode}銆戠┖鎵樼洏璇锋眰鎵爜鍏ュ簱";
- ConsoleHelper.WriteWarningLine(log);
-
- await _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
- WriteInfo(conveyorLine.DeviceName, log);
-
- // 澶勭悊鍏ュ簱璇锋眰
- NGRequestTaskInbound(conveyorLine, command, station, 0);
- }
- else
- {
- // 鍙戦�佸畬鎴愪俊鍙�
- ConveyorLineSendFinish(conveyorLine, station.stationChildCode, 0, false);
- }
- }
- }
- else if (station.stationType == 5)
- {
- // 璇诲彇浠诲姟鍛戒护鍜岃澶囧懡浠�
- ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(station.stationChildCode);
- ConveyorLineTaskCommandWrite commandWrite = conveyorLine.ReadCustomer<ConveyorLineTaskCommandWrite>(station.stationChildCode, "DeviceCommand");
- if (command != null && commandWrite != null)
- {
- // 灏嗕氦浜掍俊鍙疯浆鎹负甯冨皵鏁扮粍
- var structs = BitConverter.GetBytes(commandWrite.WriteInteractiveSignal).Reverse().ToArray().ToBoolArray();
- if (structs[0] == true)
- {
- // 妫�鏌ユ槸鍚﹀瓨鍦ㄤ换鍔�
- if (_taskRepository.QueryData(x => x.SourceAddress == station.stationChildCode).Count() > 0)
- {
- return;
- }
- // 杈撳嚭璀﹀憡淇℃伅
- var log = $"銆恵conveyorLine.DeviceName}銆戜换鍔″彿锛氥�恵command.TaskNum}銆�,鎵樼洏鏉$爜锛氥�恵command.Barcode}銆戝凡鍒拌揪銆恵station.stationChildCode}銆戝紓甯稿彛璇锋眰鎵爜鍏ュ簱";
- ConsoleHelper.WriteWarningLine(log);
-
- await _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
- WriteInfo(conveyorLine.DeviceName, log);
-
- // 澶勭悊鏂颁换鍔�
- await HandleNewTaskAsync(conveyorLine, command, station.stationChildCode, 0);
- }
- else
- {
- // 鍙戦�佸畬鎴愪俊鍙�
- ConveyorLineSendFinish(conveyorLine, station.stationChildCode, 0, false);
- }
- }
- }
- }
+ //ConsoleHelper.WriteColorLine("缁撴潫锛�" + DateTime.Now, ConsoleColor.Cyan);
}
}
catch (Exception ex)
@@ -732,7 +768,7 @@
}
var wmsIpAddress = wmsBase + requestTrayOutTask;
- var device = _deviceInfoRepository.QueryData(x => x.DeviceStatus == "1" && x.DeviceRemark == platform.Id.ToString());
+ var device = _deviceInfoRepository.QueryData(x => x.DeviceStatus == "1");
var deviceCode = device.Select(x => x.DeviceCode).ToList();
// 鍙戦�丠TTP POST璇锋眰鑾峰彇浠诲姟鏁版嵁
@@ -762,7 +798,7 @@
var content = _taskService.ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO });
if (content.Status)
{
- Console.WriteLine($"{taskDTO.TaskType}鍛煎彨鎴愬姛");
+ Console.WriteLine($"{taskDTO.TargetAddress}鍛煎彨鎴愬姛");
}
return content;
}
@@ -853,5 +889,20 @@
}
#endregion 璁惧NG鍙e叆搴�
+
+ public async Task LogAndWarn(string deviceName, string log, string color = "red")
+ {
+ ConsoleHelper.WriteWarningLine(log);
+ await _noticeService.Logs(userTokenIds, new { deviceName, log = log, time = DateTime.Now.ToString("G"), color = color });
+ WriteInfo(deviceName, log);
+ }
+
+ private (ConveyorLineTaskCommand, ConveyorLineTaskCommandWrite) ReadCommands(Dt_StationManager station, CommonConveyorLine conveyorLine)
+ {
+ ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(station.stationChildCode);
+ ConveyorLineTaskCommandWrite commandWrite = conveyorLine.ReadCustomer<ConveyorLineTaskCommandWrite>(station.stationChildCode, "DeviceCommand");
+ return (command, commandWrite);
+ }
+
}
}
\ No newline at end of file
--
Gitblit v1.9.3