z8018
2025-06-09 0aac30d1c6f1ca0c2bf7662fb9ca4f0d98b3bca7
project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/AlarmResetHsyServer.cs
@@ -1,5 +1,6 @@
using HslCommunication.WebSocket;
using Newtonsoft.Json;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using SqlSugar;
using System;
using System.Collections;
@@ -14,6 +15,7 @@
using WIDESEAWCS_DTO.Telescopic;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
namespace WIDESEAWCS_TelescopicService
{
@@ -92,12 +94,35 @@
            {
                return new WebResponseContent { Status = false, Message = "配置项 DepartmentID 无法转换为整数" };
            }
            var devices = GetDevicesByDeptId(deid);
            var query = BaseDal.QueryData(x => x.ResetStatus == true && x.Deptid== deid).ToList();
            // 如果没有找到符合条件的数据
            if (query.Count == 0)
            {
                return new WebResponseContent { Status = false, Message = "没有要复位数据" };
            }
            try
            {
                var left = devices.Value.left.Communicator.Write<bool>("M105", true); //重启报警复位
                Console.WriteLine($"左报警信号复位写入{left}");
            }
            catch (Exception)
            {
            }
            try
            {
                var right = devices.Value.right.Communicator.Write<bool>("M105", true);
                Console.WriteLine($"右报警信号复位写入{right}");
            }
            catch (Exception)
            {
            }
            foreach (var item in query)
            {
@@ -168,5 +193,23 @@
                return new WebResponseContent { Status = false, Message = ex.Message };
            }
        }
        public (OtherDevice left, OtherDevice right)? GetDevicesByDeptId(int deptId)
        {
            // 左设备号:1 -> 001,2 -> 003,3 -> 005...
            int baseCode = 1 + (deptId - 1) * 2;
            string leftCode = $"SSG{baseCode.ToString("D3")}";
            string rightCode = $"SSG{(baseCode + 1).ToString("D3")}";
            var left = (OtherDevice)Storage.Devices.Find(x => x.DeviceCode == leftCode);
            var right = (OtherDevice)Storage.Devices.Find(x => x.DeviceCode == rightCode);
            //if (left == null || right == null)
            //    return null;
            return (left, right);
        }
    }
}