From 37acb8358f5602a9013ee29c04a45e33483c2329 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期四, 09 四月 2026 15:21:40 +0800
Subject: [PATCH] fix: 修复PLC字符串解析和任务处理逻辑
---
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Communicator/Siemens/SiemensS7Communicator.cs | 17 +++++
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Communicator/Siemens/SiemensDBDataType.cs | 5 +
Code/WCS/WIDESEAWCS_Server/.vscode/tasks.json | 41 +++++++++++++
Code/WCS/WIDESEAWCS_Server/.gitignore | 8 --
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/DeviceBase/DeviceCommand.cs | 26 +++++---
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/CommonConveyorLineNewJob.cs | 9 +-
Code/WCS/WIDESEAWCS_Server/.vscode/launch.json | 35 +++++++++++
Code/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/LocationInfoService.cs | 3
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLine/ConveyorLineTaskCommandNew.cs | 4
Code/WCS/WIDESEAWCS_Server/.editorconfig | 4
10 files changed, 125 insertions(+), 27 deletions(-)
diff --git a/Code/WCS/WIDESEAWCS_Server/.editorconfig b/Code/WCS/WIDESEAWCS_Server/.editorconfig
index 65054c9..5076f37 100644
--- a/Code/WCS/WIDESEAWCS_Server/.editorconfig
+++ b/Code/WCS/WIDESEAWCS_Server/.editorconfig
@@ -1,4 +1,4 @@
锘縖*.cs]
-# CS8618: 鍦ㄩ��鍑烘瀯閫犲嚱鏁版椂锛屼笉鍙负 null 鐨勫瓧娈靛繀椤诲寘鍚潪 null 鍊笺�傝鑰冭檻澹版槑涓哄彲浠ヤ负 null銆�
-dotnet_diagnostic.CS8618.severity = none
+# CS8600: 灏� null 瀛楅潰閲忔垨鍙兘涓� null 鐨勫�艰浆鎹负闈� null 绫诲瀷銆�
+dotnet_diagnostic.CS8600.severity = silent
diff --git a/Code/WCS/WIDESEAWCS_Server/.gitignore b/Code/WCS/WIDESEAWCS_Server/.gitignore
index 3c18c7d..eee8f31 100644
--- a/Code/WCS/WIDESEAWCS_Server/.gitignore
+++ b/Code/WCS/WIDESEAWCS_Server/.gitignore
@@ -13,14 +13,8 @@
[Ll]og/
[Ll]ogs/
-# Visual Studio
+# Visual Studio and User-specific files
.vs/
-*.user
-*.suo
-*.userosscache
-*.sln.docstates
-
-# User-specific files
*.rsuser
*.suo
*.user
diff --git a/Code/WCS/WIDESEAWCS_Server/.vscode/launch.json b/Code/WCS/WIDESEAWCS_Server/.vscode/launch.json
new file mode 100644
index 0000000..4788adc
--- /dev/null
+++ b/Code/WCS/WIDESEAWCS_Server/.vscode/launch.json
@@ -0,0 +1,35 @@
+{
+ "version": "0.2.0",
+ "configurations": [
+ {
+ // 浣跨敤 IntelliSense 鎵惧嚭 C# 璋冭瘯瀛樺湪鍝簺灞炴��
+ // 灏嗘偓鍋滅敤浜庣幇鏈夊睘鎬х殑璇存槑
+ // 鏈夊叧璇︾粏淇℃伅锛岃璁块棶 https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md銆�
+ "name": ".NET Core Launch (web)",
+ "type": "coreclr",
+ "request": "launch",
+ "preLaunchTask": "build",
+ // 濡傛灉宸叉洿鏀圭洰鏍囨鏋讹紝璇风‘淇濇洿鏂扮▼搴忚矾寰勩��
+ "program": "${workspaceFolder}/WIDESEAWCS_Server/bin/Debug/net8.0/WIDESEAWCS_Server.dll",
+ "args": [],
+ "cwd": "${workspaceFolder}/WIDESEAWCS_Server",
+ "stopAtEntry": false,
+ // 鍚敤鍦ㄥ惎鍔� ASP.NET Core 鏃跺惎鍔� Web 娴忚鍣ㄣ�傛湁鍏宠缁嗕俊鎭�: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
+ "serverReadyAction": {
+ "action": "openExternally",
+ "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
+ },
+ "env": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ },
+ "sourceFileMap": {
+ "/Views": "${workspaceFolder}/Views"
+ }
+ },
+ {
+ "name": ".NET Core Attach",
+ "type": "coreclr",
+ "request": "attach"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/Code/WCS/WIDESEAWCS_Server/.vscode/tasks.json b/Code/WCS/WIDESEAWCS_Server/.vscode/tasks.json
new file mode 100644
index 0000000..5090817
--- /dev/null
+++ b/Code/WCS/WIDESEAWCS_Server/.vscode/tasks.json
@@ -0,0 +1,41 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "build",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "build",
+ "${workspaceFolder}/WIDESEAWCS_Server/WIDESEAWCS_Server.csproj",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary;ForceNoAlign"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ {
+ "label": "publish",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "publish",
+ "${workspaceFolder}/WIDESEAWCS_Server/WIDESEAWCS_Server.csproj",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary;ForceNoAlign"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ {
+ "label": "watch",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "watch",
+ "run",
+ "--project",
+ "${workspaceFolder}/WIDESEAWCS_Server/WIDESEAWCS_Server.csproj"
+ ],
+ "problemMatcher": "$msCompile"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Communicator/Siemens/SiemensDBDataType.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Communicator/Siemens/SiemensDBDataType.cs
index 8640e1c..1e678f5 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Communicator/Siemens/SiemensDBDataType.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Communicator/Siemens/SiemensDBDataType.cs
@@ -84,6 +84,11 @@
/// 32浣嶆棤绗﹀彿鏁村瀷
/// </summary>
public const string DataType_UDInt = "udint";
+
+ /// <summary>
+ /// 瀛楄妭鏁扮粍
+ /// </summary>
+ public const string DataType_ByteArray = "byte[]";
#endregion <Const>
/// <summary>
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Communicator/Siemens/SiemensS7Communicator.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Communicator/Siemens/SiemensS7Communicator.cs
index 142601b..cdfdee9 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Communicator/Siemens/SiemensS7Communicator.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Communicator/Siemens/SiemensS7Communicator.cs
@@ -242,6 +242,8 @@
return plc.Write(address, Convert.ToString(value));
case TypeCode.Char:
return plc.Write(address, Convert.ToChar(value));
+ //case TypeCode.arr:
+ // return plc.Write(address, Convert.ToChar(value));
default:
if (value is int[])
{
@@ -673,6 +675,21 @@
case SiemensDBDataType.DataType_Char:
break;
+
+ case SiemensDBDataType.DataType_ByteArray:
+ {
+ byte[] writeVal;
+ try
+ {
+ writeVal = Encoding.UTF8.GetBytes(value.ToString());
+ }
+ catch (Exception ex)
+ {
+ throw new CommunicationException(string.Format(CommunicationExceptionMessage.TypeConvertError, dataType, address, value, ex.Message), CommunicationErrorType.TypeError, innerException: ex);
+ }
+ obj = GetResult(Write(address, writeVal), address, writeVal);
+ }
+ break;
default:
throw new CommunicationException(string.Format(CommunicationExceptionMessage.DataTypeErrorException, dataType, address), CommunicationErrorType.TypeError);
}
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/DeviceBase/DeviceCommand.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/DeviceBase/DeviceCommand.cs
index 61eca74..f81c8e3 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/DeviceBase/DeviceCommand.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/DeviceBase/DeviceCommand.cs
@@ -23,6 +23,7 @@
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
+using WIDESEAWCS_Core.LogHelper;
namespace WIDESEAWCS_QuartzJob.DeviceBase
{
@@ -160,18 +161,23 @@
case TypeCode.String:
ushort dataLength = CheckStringAttribute(propertyInfo);
- //if (dataLength - 2 != Content[index])
- //{
- // throw new Exception($"璇诲彇PLC瀛楃涓插畾涔夐暱搴︺�恵Content[index]}銆戜笌瀵硅薄銆恵GetType().Name}銆戝睘鎬с�恵propertyInfo.Name}銆戠壒鎬у畾涔夊瓧绗︿覆闀垮害銆恵dataLength}銆戜笉涓�鑷�");
- //}
+ if (dataLength - 2 != Content[index])
+ {
+ //throw new Exception($"璇诲彇PLC瀛楃涓插畾涔夐暱搴︺�恵Content[index]}銆戜笌瀵硅薄銆恵GetType().Name}銆戝睘鎬с�恵propertyInfo.Name}銆戠壒鎬у畾涔夊瓧绗︿覆闀垮害銆恵dataLength}銆戜笉涓�鑷�");
+ //QuartzLogger.Debug($"璇诲彇PLC瀛楃涓插畾涔夐暱搴︺�恵Content[index]}銆戜笌瀵硅薄銆恵GetType().Name}銆戝睘鎬с�恵propertyInfo.Name}銆戠壒鎬у畾涔夊瓧绗︿覆闀垮害銆恵dataLength}銆戜笉涓�鑷�");
- //if (Content[index + 1] > Content.Length - index - 2)
- //{
- // throw new Exception($"璇诲彇PLC瀛楃涓插疄闄呴暱搴︺�恵Content[index + 1]}銆戣秴鍑哄綋鍓峛yte鏁扮粍闀垮害锛岀储寮曪細銆恵index}銆戯紝瀛楃涓茶捣濮嬬储寮曪細銆恵index + 2}銆戯紝鏁扮粍闀垮害锛氥�恵Content.Length}銆戯紝瑙f瀽闀垮害锛氥�恵Content.Length - index - 2}銆�");
- //}
+ propertyInfo.SetValue(this, Encoding.Default.GetString(Content, index, dataLength).Trim().Replace("\0", "").Replace("\\u000","").Trim());
+ index += dataLength;
+ break;
+ }
- // propertyInfo.SetValue(this, Encoding.Default.GetString(Content, index + 2, Content[index + 1] > 0 ? Content[index + 1] : dataLength - 2));
- propertyInfo.SetValue(this, Encoding.Default.GetString(Content, index, dataLength - 2));
+ if (Content[index + 1] > Content.Length - index - 2)
+ {
+ throw new Exception($"璇诲彇PLC瀛楃涓插疄闄呴暱搴︺�恵Content[index + 1]}銆戣秴鍑哄綋鍓峛yte鏁扮粍闀垮害锛岀储寮曪細銆恵index}銆戯紝瀛楃涓茶捣濮嬬储寮曪細銆恵index + 2}銆戯紝鏁扮粍闀垮害锛氥�恵Content.Length}銆戯紝瑙f瀽闀垮害锛氥�恵Content.Length - index - 2}銆�");
+ }
+
+ propertyInfo.SetValue(this, Encoding.Default.GetString(Content, index + 2, Content[index + 1] > 0 ? Content[index + 1] : dataLength - 2));
+ //propertyInfo.SetValue(this, Encoding.Default.GetString(Content, index, dataLength - 2));
index += dataLength;
break;
default:
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/CommonConveyorLineNewJob.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/CommonConveyorLineNewJob.cs
index d4d915d..3c5271a 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/CommonConveyorLineNewJob.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/CommonConveyorLineNewJob.cs
@@ -4,6 +4,7 @@
using Newtonsoft.Json;
using Quartz;
using SqlSugar;
+using System.Text;
using System.Text.Json;
using WIDESEA_Core;
using WIDESEAWCS_Common.TaskEnum;
@@ -157,7 +158,7 @@
{
_logger.LogDebug("Execute锛氬瓙璁惧 {ChildDeviceCode} 鍛戒护涓虹┖锛岃烦杩�", childDeviceCode);
QuartzLogger.Debug($"瀛愯澶� {childDeviceCode} 鍛戒护涓虹┖锛岃烦杩�", conveyorLine.DeviceCode);
- return Task.CompletedTask;
+ continue;
}
// 濡傛灉 WCS_ACK 涓� 1锛屽厛娓呴櫎锛堣〃绀哄鐞嗚繃涓婁竴娆¤姹傦級
@@ -173,7 +174,7 @@
if (checkPalletPositions.Any(x => x.Code == childDeviceCode))
{
// 妫�鏌ヨ緭閫佺嚎鐘舵�侊紙鏄惁鏈夋墭鐩橈級
- if (command.CV_State == 1)
+ if (command.CV_State == 2)
{
// 妫�鏌ヨ浣嶇疆鏄惁宸叉湁浠诲姟
var existingTask = _taskService.Db.Queryable<Dt_Task>().First(x => x.TargetAddress == childDeviceCode);
@@ -206,8 +207,6 @@
// 鍙湁褰� PLC_STB 涓� 1 鏃舵墠澶勭悊浠诲姟
if (command.PLC_STB != 1)
{
- //_logger.LogDebug("Execute锛氬瓙璁惧 {ChildDeviceCode} PLC_STB 涓嶄负1锛岃烦杩�", childDeviceCode);
- //QuartzLogger.Debug($"瀛愯澶� {childDeviceCode} PLC_STB 涓嶄负1锛岃烦杩�", conveyorLine.DeviceCode);
return Task.CompletedTask;
}
@@ -222,7 +221,7 @@
}
// ========== 澶勭悊宸叉湁浠诲姟鍙风殑鎯呭喌 ==========
- if (command.TaskNo > 0)
+ if (command.TaskNo > 0 && !command.Barcode.IsNullOrEmpty())
{
// 鏌ヨ姝e湪鎵ц鐨勪换鍔�
Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNo, childDeviceCode);
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLine/ConveyorLineTaskCommandNew.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLine/ConveyorLineTaskCommandNew.cs
index da3a0fa..0f66ecd 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLine/ConveyorLineTaskCommandNew.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLine/ConveyorLineTaskCommandNew.cs
@@ -154,12 +154,12 @@
public byte Last_pallet { get; set; }
/// <summary>
- /// 鎵樼洏鏉$爜锛�22涓瓧绗︼級
+ /// 鎵樼洏鏉$爜锛�20涓瓧绗︼級
/// </summary>
/// <remarks>
/// 瀛樺偍鎵樼洏鐨勬潯鐮佷俊鎭紝鐢ㄤ簬璐х墿杩借釜鍜屽簱浣嶇鐞嗐��
/// </remarks>
- [DataLength(22)]
+ [DataLength(20)]
public string Barcode { get; set; }
}
}
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/LocationInfoService.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/LocationInfoService.cs
index 935624b..53ef4b5 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/LocationInfoService.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/LocationInfoService.cs
@@ -527,7 +527,8 @@
EnableStatus = EnableStatusEnum.Normal.GetHashCode(),
LocationStatus = LocationStatusEnum.Free.GetHashCode(),
LocationType = LocationTypeEnum.Undefined.GetHashCode(),
- LocationCode = $"{roadwayNo}-{row:D3}-{col:D3}-{layer:D3}",
+ //LocationCode = $"{roadwayNo}-{row:D3}-{col:D3}-{layer:D3}",
+ LocationCode = $"{row:D3}-{col:D3}-{layer:D3}",
LocationName = $"{roadwayNo}宸烽亾{row:D3}琛寋col:D3}鍒梴layer:D3}灞倇depth:D2}娣�"
};
}
--
Gitblit v1.9.3