From d59b540dd78d49ddf1f2e1c6dfb7b19a7d3e3d7c Mon Sep 17 00:00:00 2001
From: 肖洋 <cathay_xy@163.com>
Date: 星期日, 19 一月 2025 11:19:24 +0800
Subject: [PATCH] 优化代码结构和错误处理
---
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs | 8 ++--
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs | 76 +++++++++++++++++++-------------------
.gitignore | 12 ++++++
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs | 15 +++++--
4 files changed, 65 insertions(+), 46 deletions(-)
diff --git a/.gitignore b/.gitignore
index 1e9bd3d..1c1e893 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1654,3 +1654,15 @@
/Code Management/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/copilot-chat/bef6627e/sessions/36708593-3f69-4656-815a-651b3ad17c7d
*.xml
/Code Management/WMS/WIDESEA_WMSClient/report_form_rollup-plugin-visualizer.html
+/Code Management/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.12.53.23981/CodeChunks.db
+/Code Management/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.12.53.23981/CodeChunks.db-shm
+/Code Management/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.12.53.23981/CodeChunks.db-wal
+/Code Management/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.12.53.23981/SemanticSymbols.db
+/Code Management/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.12.53.23981/SemanticSymbols.db-shm
+/Code Management/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.12.53.23981/SemanticSymbols.db-wal
+/Code Management/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.53.23981/CodeChunks.db
+/Code Management/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.53.23981/CodeChunks.db-shm
+/Code Management/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.53.23981/CodeChunks.db-wal
+/Code Management/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.53.23981/SemanticSymbols.db
+/Code Management/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.53.23981/SemanticSymbols.db-shm
+/Code Management/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.53.23981/SemanticSymbols.db-wal
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 099a9bb..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,7 +77,7 @@
CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams");
if (conveyorLine != null)
{
- ConsoleHelper.WriteColorLine("寮�濮嬶細" + DateTime.Now, ConsoleColor.Cyan);
+ //ConsoleHelper.WriteColorLine("寮�濮嬶細" + DateTime.Now, ConsoleColor.Cyan);
// 鏌ヨ鎵�鏈夊瓙璁惧鐨勪綅缃�
List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode);
// 鑾峰彇鎵�鏈夌珯鐐圭鐞嗗櫒
@@ -185,7 +185,7 @@
await Task.WhenAll(tasks);
- ConsoleHelper.WriteColorLine("缁撴潫锛�" + DateTime.Now, ConsoleColor.Cyan);
+ //ConsoleHelper.WriteColorLine("缁撴潫锛�" + DateTime.Now, ConsoleColor.Cyan);
}
}
catch (Exception ex)
@@ -768,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璇锋眰鑾峰彇浠诲姟鏁版嵁
@@ -798,7 +798,7 @@
var content = _taskService.ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO });
if (content.Status)
{
- Console.WriteLine($"{taskDTO.TaskType}鍛煎彨鎴愬姛");
+ Console.WriteLine($"{taskDTO.TargetAddress}鍛煎彨鎴愬姛");
}
return content;
}
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs
index 16bde53..ca89b74 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs
@@ -238,50 +238,50 @@
{
if (command.ConveyorLineBarcode != "NoRead")
{
- var config = _sys_ConfigService.GetByConfigKey("SYS_BASE", "ISFRINTRAY");
- if (config.ConfigValue == "1")
+ //var config = _sys_ConfigService.GetByConfigKey("SYS_BASE", "ISFRINTRAY");
+ //if (config.ConfigValue == "1")
+ //{
+ // Random random = new Random();
+ // var task = new Dt_Task()
+ // {
+ // CurrentAddress = childDeviceCode,
+ // Grade = 1,
+ // NextAddress = "2066",
+ // PalletCode = command.ConveyorLineBarcode,
+ // Roadway = "FR",
+ // SourceAddress = childDeviceCode,
+ // TargetAddress = "2066",
+ // TaskNum = random.Next(1,9999),
+ // TaskType = (int)TaskInboundTypeEnum.InTray,
+ // TaskState = (int)TaskInStatusEnum.Line_InExecuting,
+ // WMSId = 0
+ // };
+ // var taskCommand = MapTaskCommand(task, command);
+ // conveyorLine.SendCommand(taskCommand, childDeviceCode);
+ //}
+ //else
+ //{
+ var taskDTO = CreateEmptyTrayTaskDto(command.ConveyorLineBarcode, childDeviceCode);
+
+ if (_taskRepository.QueryFirst(x => x.PalletCode == taskDTO.PalletCode) != null)
{
- Random random = new Random();
- var task = new Dt_Task()
- {
- CurrentAddress = childDeviceCode,
- Grade = 1,
- NextAddress = "2066",
- PalletCode = command.ConveyorLineBarcode,
- Roadway = "FR",
- SourceAddress = childDeviceCode,
- TargetAddress = "2066",
- TaskNum = random.Next(1,9999),
- TaskType = (int)TaskInboundTypeEnum.InTray,
- TaskState = (int)TaskInStatusEnum.Line_InExecuting,
- WMSId = 0
- };
- var taskCommand = MapTaskCommand(task, command);
- conveyorLine.SendCommand(taskCommand, childDeviceCode);
+ WriteInfo(conveyorLine.DeviceName, "褰撳墠鎵樼洏瀛樺湪浠诲姟");
+ return;
}
- else
+
+ var content = CreateAndSendTask(taskDTO);
+ if (content.Status)
{
- var taskDTO = CreateEmptyTrayTaskDto(command.ConveyorLineBarcode, childDeviceCode);
-
- if (_taskRepository.QueryFirst(x => x.PalletCode == taskDTO.PalletCode) != null)
+ var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
+ if (task != null)
{
- WriteInfo(conveyorLine.DeviceName, "褰撳墠鎵樼洏瀛樺湪浠诲姟");
- return;
- }
-
- var content = CreateAndSendTask(taskDTO);
- if (content.Status)
- {
- var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
- if (task != null)
- {
- var taskCommand = MapTaskCommand(task, command);
- conveyorLine.SendCommand(taskCommand, childDeviceCode);
- //ConveyorLineSendFinish(conveyorLine, childDeviceCode, true);
- _taskService.UpdateTaskStatusToNext(task);
- }
+ var taskCommand = MapTaskCommand(task, command);
+ conveyorLine.SendCommand(taskCommand, childDeviceCode);
+ //ConveyorLineSendFinish(conveyorLine, childDeviceCode, true);
+ _taskService.UpdateTaskStatusToNext(task);
}
}
+ //}
}
}
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
index 54cb5c1..5499743 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
@@ -168,7 +168,6 @@
if (content.Status)
{
var result = JsonConvert.DeserializeObject<BasicResult>(content.Data.ToString());
- task.Remark = result.Success ? null : "NG";
if (!result.Success && result.MessageCode == "E10001")
{
@@ -178,9 +177,17 @@
else
{
task.Remark = "NG";
+ ConsoleHelper.WriteErrorLine("MOM閫氭姤鐐硅姱NG");
+ return content.Error("MOM閫氭姤鐐硅姱NG");
}
}
}
+ }
+
+ if (task.Remark == "NG")
+ {
+ ConsoleHelper.WriteErrorLine("MOM閫氭姤鐐硅姱NG");
+ return content.Error("MOM閫氭姤鐐硅姱NG");
}
// 鏇存柊搴撳瓨鐘舵�佸拰浠诲姟鐘舵��
@@ -738,7 +745,7 @@
return content.Error(result.MOMMessage);
// 鑾峰彇寮傚父鐢佃姱
- List<SerialNoDto>? serialNosError = result.SerialNos.Where(x => x.SerialNoStatus != 1).ToList();
+ List<SerialNoDto>? serialNosError = result.SerialNos.Where(x => x.SerialNoStatus != 1 && x.SerialNoStatus != 4).ToList();
if (serialNosError.Count > 0)
{
// TODO 鍒涘缓浠诲姟閫佽嚦NG鎺掑嚭鍙�
@@ -1089,7 +1096,7 @@
throw new Exception("鏈壘鍒扮┖鎵樼洏鍏ュ簱绔欏彴鍜屽叆搴撶珯鍙伴厤缃�");
}
List<string> strings = stationManagers.Roadway.Split(',').ToList();
- Console.WriteLine(strings.ToJsonString() + "b-----------------------");
+ //Console.WriteLine(strings.ToJsonString() + "b-----------------------");
return await CreateNewTask(input, strings, 1);
}
@@ -1265,7 +1272,7 @@
/// <summary>
/// 鏌ヨ绌虹洏搴撳瓨淇℃伅
/// </summary>
- private async Task<DtStockInfo> QueryStockInfoForEmptyTrayAsync(string areaCode,string position)
+ private async Task<DtStockInfo> QueryStockInfoForEmptyTrayAsync(string areaCode, string position)
{
var area = await _areaInfoRepository.QueryFirstAsync(x => x.AreaCode == areaCode);
--
Gitblit v1.9.3