From 07223f68b4cf74786269115b290f073e0fc97354 Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期一, 03 三月 2025 09:47:27 +0800
Subject: [PATCH] 1

---
 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Tasks/SerialPort/SerialPortTestJob.cs                 |   11 +----
 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_IBasicInfoRepository/IProcessRepository.cs            |    1 
 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_TaskInfoService/NjTaskServer.cs                       |    8 ++--
 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_BasicInfoRepository/ProcessRepository .cs             |    1 
 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_IBasicInfoService/IProcessServer.cs                   |    1 
 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_BasicInfoService/ProcessServer.cs                     |    1 
 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Server/Controllers/Task/NjTaskController.cs           |   10 ++--
 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_ITaskInfoService/INjTaskServer.cs                     |    2 
 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Tasks/SerialPort/SerialPortJob.cs                     |   68 ++++++++++++++++++++++++++++++++++
 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Model/Models/SerialPort/Dt_TorqueOp.cs                |    4 +-
 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Model/Models/SerialPort/Dt_Process.cs                 |    2 
 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Server/Controllers/SerialPort/SerialPortController.cs |    2 
 12 files changed, 89 insertions(+), 22 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_BasicInfoRepository/ProcessRepository .cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_BasicInfoRepository/ProcessRepository .cs"
index 034b503..5646cf4 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_BasicInfoRepository/ProcessRepository .cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_BasicInfoRepository/ProcessRepository .cs"
@@ -1,5 +1,6 @@
 锘縰sing WIDESEA_ISerialPortRepository;
 using WIDESEAWCS_Core.BaseRepository;
+using WIDESEAWCS_Model.Models;
 using WIDESEAWCS_Model.Models.SerialPort;
 
 namespace WIDESEA_SerialPortRepository
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_BasicInfoService/ProcessServer.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_BasicInfoService/ProcessServer.cs"
index 9025ecd..e53709f 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_BasicInfoService/ProcessServer.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_BasicInfoService/ProcessServer.cs"
@@ -6,6 +6,7 @@
 using WIDESEA_ISerialPortRepository;
 using WIDESEAWCS_Core.BaseServices;
 using WIDESEAWCS_ITaskInfoService;
+using WIDESEAWCS_Model.Models;
 using WIDESEAWCS_Model.Models.SerialPort;
 
 namespace WIDESEAWCS_TaskInfoService
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_IBasicInfoRepository/IProcessRepository.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_IBasicInfoRepository/IProcessRepository.cs"
index 5f23fe8..7de340d 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_IBasicInfoRepository/IProcessRepository.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_IBasicInfoRepository/IProcessRepository.cs"
@@ -1,4 +1,5 @@
 锘縰sing WIDESEAWCS_Core.BaseRepository;
+using WIDESEAWCS_Model.Models;
 using WIDESEAWCS_Model.Models.SerialPort;
 
 namespace WIDESEA_ISerialPortRepository
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_IBasicInfoService/IProcessServer.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_IBasicInfoService/IProcessServer.cs"
index cd539c1..7bf244c 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_IBasicInfoService/IProcessServer.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_IBasicInfoService/IProcessServer.cs"
@@ -6,6 +6,7 @@
 using WIDESEAWCS_Core;
 using WIDESEAWCS_Core.BaseServices;
 using WIDESEAWCS_DTO.TaskInfo;
+using WIDESEAWCS_Model.Models;
 using WIDESEAWCS_Model.Models.SerialPort;
 
 namespace WIDESEAWCS_ITaskInfoService
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_ITaskInfoService/INjTaskServer.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_ITaskInfoService/INjTaskServer.cs"
index 89e561b..695ad00 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_ITaskInfoService/INjTaskServer.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_ITaskInfoService/INjTaskServer.cs"
@@ -17,6 +17,6 @@
         //娣诲姞
         //鏇存柊
         //鍒犻櫎
-        WebResponseContent ReceiveWMSTask(List<WMSTaskDTO> taskDTOs);
+        //WebResponseContent ReceiveWMSTask(List<WMSTaskDTO> taskDTOs);
     }
 }
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Model/Models/SerialPort/Dt_Process.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Model/Models/SerialPort/Dt_Process.cs"
index 479933b..fe60ba2 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Model/Models/SerialPort/Dt_Process.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Model/Models/SerialPort/Dt_Process.cs"
@@ -6,7 +6,7 @@
 using SqlSugar;
 using WIDESEAWCS_Core.Tenants;
 
-namespace WIDESEAWCS_Model.Models.SerialPort
+namespace WIDESEAWCS_Model.Models
 {
     [SugarTable("Dt_Process","宸ヨ壓姝ラ琛�"),MultiTenant]
     public class Dt_Process
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Model/Models/SerialPort/Dt_TorqueOp.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Model/Models/SerialPort/Dt_TorqueOp.cs"
index e758f80..5d052b9 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Model/Models/SerialPort/Dt_TorqueOp.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Model/Models/SerialPort/Dt_TorqueOp.cs"
@@ -6,9 +6,9 @@
 using SqlSugar;
 using WIDESEAWCS_Core.Tenants;
 
-namespace WIDESEAWCS_Model.Models.SerialPort
+namespace WIDESEAWCS_Model.Models
 {
-    //[SugarTable("Dt_Process", "姣忔鎵ц鎴愬姛瀛樺偍鐨勫��"), MultiTenant]
+    [SugarTable("Dt_TorqueOp", "姣忔鎵ц鎴愬姛瀛樺偍鐨勫��"), MultiTenant]
     public class Dt_TorqueOp
     {
         [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "涓婚敭")]
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/Controllers/SerialPort/SerialPortController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/Controllers/SerialPort/SerialPortController.cs"
index 60ee8de..17707a7 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/Controllers/SerialPort/SerialPortController.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/Controllers/SerialPort/SerialPortController.cs"
@@ -6,7 +6,7 @@
 using WIDESEA_SerialPortService;
 using WIDESEAWCS_Core;
 using WIDESEAWCS_Core.BaseController;
-using WIDESEAWCS_Model.Models.SerialPort;
+using WIDESEAWCS_Model.Models;
 using WIDESEAWCS_QuartzJob.Service;
 //using WIDESEA_ISerialPortService.ISerialPortService;
 
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/Controllers/Task/NjTaskController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/Controllers/Task/NjTaskController.cs"
index 7f32f4e..67be50c 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/Controllers/Task/NjTaskController.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/Controllers/Task/NjTaskController.cs"
@@ -18,10 +18,10 @@
         {
         }
 
-        [HttpPost, Route("ReceiveTask"), AllowAnonymous]
-        public WebResponseContent ReceiveWMSTask([FromBody] List<WMSTaskDTO> taskDTOs)
-        {
-            return Service.ReceiveWMSTask(taskDTOs);
-        }
+        //[HttpPost, Route("ReceiveTask"), AllowAnonymous]
+        //public WebResponseContent ReceiveWMSTask([FromBody] List<WMSTaskDTO> taskDTOs)
+        //{
+        //    return Service.ReceiveWMSTask(taskDTOs);
+        //}
     }
 }
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_TaskInfoService/NjTaskServer.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_TaskInfoService/NjTaskServer.cs"
index 0a42e24..040f796 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_TaskInfoService/NjTaskServer.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_TaskInfoService/NjTaskServer.cs"
@@ -18,9 +18,9 @@
         {
         }
 
-        public WebResponseContent ReceiveWMSTask(List<WMSTaskDTO> taskDTOs)
-        {
-            throw new NotImplementedException();
-        }
+        //public WebResponseContent ReceiveWMSTask(List<WMSTaskDTO> taskDTOs)
+        //{
+        //    throw new NotImplementedException();
+        //}
     }
 }
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Tasks/SerialPort/SerialPortJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Tasks/SerialPort/SerialPortJob.cs"
new file mode 100644
index 0000000..40462f4
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Tasks/SerialPort/SerialPortJob.cs"
@@ -0,0 +1,68 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.IO.Ports;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Quartz;
+using WIDESEAWCS_QuartzJob;
+
+namespace WIDESEAWCS_Tasks
+{
+    public class SerialPortJob : JobBase, IJob
+    {
+        public enum CommandType
+        {
+            None = 0,
+            Get = 1,
+            Set = 2,
+        }
+        private SerialPort serialPort;
+        private CommandType commandType = CommandType.None;
+        private string commandGet = "";//璇诲��
+        private string commandSet = "";//璁惧��
+        private string setOK = "";
+        private string getOK = "";
+        public Task Execute(IJobExecutionContext context)
+        {
+            try
+            {
+                if (serialPort == null) { serialPort = new SerialPort("COM1"); serialPort.DataReceived += SerialPort_DataReceived;}
+                if (!serialPort.IsOpen)
+                {
+                    serialPort.Open();
+
+                    serialPort.Write(commandSet);//鎵撳紑涓插彛鏃跺厛璁惧��
+                    commandType = CommandType.Set;
+                }
+                switch (commandType)
+                {
+                    case CommandType.Get:
+                        serialPort.Write(commandGet);
+                        break;
+                    case CommandType.Set:
+                        serialPort.Write(commandSet);
+                        break;
+                }
+            }
+            catch (Exception ex) { }            return Task.CompletedTask;
+        }
+        private void SerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
+        {
+            byte[] buffers = new byte[1024];
+            while (serialPort.BytesToRead > 0)
+            {
+                serialPort.Read(buffers, 0, serialPort.BytesToRead > buffers.Length ? buffers.Length : serialPort.BytesToRead);
+                string data = Encoding.Default.GetString(buffers);
+                if (data.Contains(setOK) && commandType == CommandType.Set)
+                {
+                    commandType = CommandType.Get;
+                }
+                else if (data.Contains(getOK) && commandType == CommandType.Get)
+                {
+                    commandType = CommandType.Set;
+                }
+            }
+        }
+    }
+}
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Tasks/SerialPort/SerialPortTestJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Tasks/SerialPort/SerialPortTestJob.cs"
index 51b4d47..5a33896 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Tasks/SerialPort/SerialPortTestJob.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Tasks/SerialPort/SerialPortTestJob.cs"
@@ -2,14 +2,13 @@
 using System.Text;
 using Quartz;
 using WIDESEA_ISerialPortService;
-using WIDESEAWCS_Model.Models.SerialPort;
+using WIDESEAWCS_Model.Models;
 
 
 namespace WIDESEAWCS_Tasks
 {
     public class SerialPortTestJob:IJob
     {
-
         // 鍦� SerialPortTestService 绫讳腑娣诲姞瀵� ISerialPortService 鐨勫紩鐢�
         private readonly ISerialPortService _serialPortService;
         public readonly string _port;
@@ -23,17 +22,13 @@
 
             SerialPort = new SerialPort(_port);
 
-
-
             //涓插彛鎺ユ敹鍒版暟鎹椂锛孲erialPort 浼氳嚜鍔ㄨЕ鍙� DataReceived 浜嬩欢
             //SerialPort.DataReceived += OnDataReceived; //鎺ユ敹涓插彛鍙戝嚭鐨勬暟鎹�
         }
 
         private CancellationTokenSource _cancellationTokenSource;
         private Task _sendTask;
-        private int commandType = 2;
-
-    
+        private int commandType = 2;    
 
         // 鍛戒护瀛楃涓�
         private string command0 = "";  // 涓嶅彂閫佸懡浠�
@@ -43,7 +38,7 @@
         public Task Execute(IJobExecutionContext context)
         {
 
-            OpenSerialPort();
+            //OpenSerialPort();
             SerialPort.DataReceived += OnDataReceived;
 
             return Task.CompletedTask;

--
Gitblit v1.9.3