1
z8018
2025-05-08 b2e04d15e8284aa23af89200075b6fd52a77477e
1
已修改13个文件
已添加5个文件
999 ■■■■■ 文件已修改
.vs/ShenSuoGanKongZhi/v17/.wsuo 补丁 | 查看 | 原始文档 | blame | 历史
.vs/ShenSuoGanKongZhi/v17/DocumentLayout.json 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.vs/VSWorkspaceState.json 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
project/WCS/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_UserService.cs 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs 408 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/LoginhsyService.cs 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/MaintenanceService.cs 69 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs 103 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
project/后台管理/WIDESEAWCS_Server/WIDESEAWCS_ITelescopicService/IParametersService.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
project/后台管理/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/Telescopic/Dt_Parameters.cs 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
project/后台管理/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/Telescopic/ParametersController.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
project/后台管理/WIDESEAWCS_Server/WIDESEAWCS_Server/Program.cs 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
project/后台管理/WIDESEAWCS_Server/WIDESEAWCS_Server/Properties/PublishProfiles/FolderProfile1.pubxml 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
project/后台管理/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
project/后台管理/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
project/后台管理/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/MaintenanceService.cs 70 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
project/后台管理/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs 197 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Properties/PublishProfiles/FolderProfile1.pubxml 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.vs/ShenSuoGanKongZhi/v17/.wsuo
Binary files differ
.vs/ShenSuoGanKongZhi/v17/DocumentLayout.json
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,23 @@
{
  "Version": 1,
  "WorkspaceRootPath": "E:\\ssg\\ShenSuoGanKongZhi\\",
  "Documents": [],
  "DocumentGroupContainers": [
    {
      "Orientation": 0,
      "VerticalTabListWidth": 256,
      "DocumentGroups": [
        {
          "DockedWidth": 200,
          "SelectedChildIndex": -1,
          "Children": [
            {
              "$type": "Bookmark",
              "Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}"
            }
          ]
        }
      ]
    }
  ]
}
.vs/VSWorkspaceState.json
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,7 @@
{
  "ExpandedNodes": [
    ""
  ],
  "SelectedNode": "\\WIDESEAWCS_Server.sln (project\\\u540E\u53F0\u7BA1\u7406\\WIDESEAWCS_Server\\WIDESEAWCS_Server.sln)",
  "PreviewInSolutionExplorer": false
}
project/WCS/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_UserService.cs
@@ -218,6 +218,9 @@
                        img = user.HeadImageUrl,
                        ID = user.UserId,
                        RoleId = user.RoleId,
                        depid = disbled.Dept_Id,
                    });
                }
project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
@@ -1,117 +1,319 @@
using HslCommunication.WebSocket;
using Newtonsoft.Json;
using Quartz;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Core.HttpContextUser;
using WIDESEAWCS_Core;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
using WIDESEAWCS_TelescopicService;
using WIDESEAWCS_ISystemServices;
// using HslCommunication.WebSocket;
// using Newtonsoft.Json;
// using Quartz;
// using SqlSugar;
// using System;
// using System.Collections.Generic;
// using System.Linq;
// using System.Text;
// using System.Threading.Tasks;
// using WIDESEAWCS_Core.HttpContextUser;
// using WIDESEAWCS_Core;
// using WIDESEAWCS_ITaskInfoService;
// using WIDESEAWCS_Model.Models;
// using WIDESEAWCS_QuartzJob;
// using WIDESEAWCS_TelescopicService;
// <<<<<<< HEAD:project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
// using WIDESEAWCS_ISystemServices;
// =======
// <<<<<<< Updated upstream:项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
// =======
// using WIDESEAWCS_ISystemServices;
// using WIDESEAWCS_Core.Helper;
// >>>>>>> Stashed changes:project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
// >>>>>>> qy0318:项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
namespace WIDESEAWCS_Tasks
{
    [DisallowConcurrentExecution]
    public class AlarmResetJob : JobBase, IJob
    {
// namespace WIDESEAWCS_Tasks
// {
//     [DisallowConcurrentExecution]
//     public class AlarmResetJob : JobBase, IJob
//     {
        private readonly IAlarmResetHsyServer _alarmResetHsyServer;
        private readonly ISys_UserService _UserService;
        WebSocketServer _webSocketServer;
//         private readonly IAlarmResetHsyServer _alarmResetHsyServer;
//         private readonly ISys_UserService _UserService;
//         WebSocketServer _webSocketServer;
        
        
        
        public AlarmResetJob(WebSocketServer webSocketServer, IAlarmResetHsyServer alarmResetHsyServer, ISys_UserService UserService)
        {
            _webSocketServer = webSocketServer;
            _alarmResetHsyServer = alarmResetHsyServer;
            _UserService = UserService;
        }
//         public AlarmResetJob(WebSocketServer webSocketServer, IAlarmResetHsyServer alarmResetHsyServer, ISys_UserService UserService)
//         {
//             _webSocketServer = webSocketServer;
//             _alarmResetHsyServer = alarmResetHsyServer;
//             _UserService = UserService;
//         }
        public Task Execute(IJobExecutionContext context)
        {
            try
            {
//         /// <summary>
//         /// è¿™ä¸ªåˆ°æ—¶å€™æ ¹æ®çŽ°åœºæƒ…å†µæ¥é…ç½®ï¼Œè®¾å¤‡å·å’ŒçŽ°åœºæƒ…å†µæ¥å®šã€‚
//         /// ä¸€ä¸ªè½¨é“俩个plc
//         /// </summary>
//         /// <param name="context"></param>
//         /// <returns></returns>
//         //public Task Execute(IJobExecutionContext context)
//         //{
//         //    try
//         //    {
//         //        //获取设备号
//         //        // èŽ·å–è®¾å¤‡é…ç½®
//         //        OtherDevice serialPortDevice = (OtherDevice)context.JobDetail.JobDataMap.Get("JobParams");
//         //        if (serialPortDevice!=null)
//         //        {
//         //            //首先要一直读,如果发生了故障要写到_alarmResetHsyServer中记录下来并且给到前端数据
//         //            //å·¦plc
//         //            if (serialPortDevice.DeviceCode == "SSG001")
//         //            {
//         //                var leftPLcstuck = serialPortDevice.Communicator.Read<bool>("M104"); //卡住报警
//         //                var leftPLcOher = serialPortDevice.Communicator.Read<bool>("M105");  //其他报警 //默认是false
//         //                Console.WriteLine($"{serialPortDevice.DeviceName}:卡住报警{leftPLcstuck},其他报警{leftPLcOher}");
//         //                if (leftPLcstuck == true && leftPLcOher == false)
//         //                   //if (leftPLcOher == false)
//         //                    {
//         //                    string text = "轨道一:伸缩卡住报警";
//         //                    //报警了在这调用添加方法,并传给前端
//         //                     var reslut = _alarmResetHsyServer.AddAlarmHsy(text, leftPLcstuck);
//         //                }
//         //                if (leftPLcOher == true && leftPLcstuck == false)
//         //                {
//         //                    string text = "轨道一:其他故障报警";
//         //                    var reslut = _alarmResetHsyServer.AddAlarmHsy(text, leftPLcstuck);
//         //                }
//         //                if (leftPLcstuck == true && leftPLcOher == true)//如果报警了
//         //                {
//         //                    string text = "轨道一:报警伸缩卡住报警和其他故障报警";
//         //                    var reslut = _alarmResetHsyServer.AddAlarmHsy(text, leftPLcstuck);
//         //                }
//         //                var alrt = _alarmResetHsyServer.GetWebSocketInfo();
//         //                _webSocketServer.PublishAllClientPayload(JsonConvert.SerializeObject(alrt));//websocketserver这种只能传给前端json格式
//         //            }
//         //            else if (serialPortDevice.DeviceCode == "SSG002")
//         //            {
//         //                //右plc
//         //                var rightPLcSuck = serialPortDevice.Communicator.Read<bool>("M104"); //卡住报警
//         //                var rightPLcOher = serialPortDevice.Communicator.Read<bool>("M105");//其他报警
//         //                Console.WriteLine($"{serialPortDevice.DeviceName}:卡住报警{rightPLcSuck},其他报警{rightPLcOher}");
//         //                if (rightPLcSuck == true && rightPLcOher == false)
//         //                {
//         //                    string text = "轨道一:报警伸缩卡住报警";
//         //                    //报警了在这调用添加方法,并传给前端
//         //                     var reslut = _alarmResetHsyServer.AddAlarmHsy(text, rightPLcSuck);
//         //                    // _webSocketServer.PublishAllClientPayload(JsonConvert.SerializeObject(reslut));//websocketserver这种只能传给前端json格式
//         //                }
//         //                if (rightPLcOher == true && rightPLcSuck == false)
//         //                {
//         //                    string text = "轨道一:其他故障报警";
//         //                    var reslut = _alarmResetHsyServer.AddAlarmHsy(text, rightPLcOher);
//         //                }
//         //                if (rightPLcSuck == true && rightPLcOher == true)//如果报警了
//         //                {
//         //                    string text = "轨道一:报警伸缩卡住报警和其他故障报警";
//         //                    var reslut = _alarmResetHsyServer.AddAlarmHsy(text, rightPLcOher);//添加数据
//         //                }
//         //                var alrt = _alarmResetHsyServer.GetWebSocketInfo();
//         //                _webSocketServer.PublishAllClientPayload(JsonConvert.SerializeObject(alrt));
//         //            }
//         //        }
//         //    }
//         //    catch (Exception ex)
//         //    {
//         //        Console.WriteLine("错误信息:" + ex.Message);
//         //        Console.WriteLine(ex.StackTrace);
//         //    }
//         //    return Task.CompletedTask;
//         //}
//         public Task Execute(IJobExecutionContext context)
//         {
//             try
//             {
// <<<<<<< HEAD:project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
              
                //获取设备号
                // èŽ·å–è®¾å¤‡é…ç½®
                OtherDevice serialPortDevice = (OtherDevice)context.JobDetail.JobDataMap.Get("JobParams");
                if (serialPortDevice!=null)
                {
                    //首先要一直读,如果发生了故障要写到_alarmResetHsyServer中记录下来并且给到前端数据
                    //å·¦plc
// =======
// <<<<<<< Updated upstream:项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
// =======
// >>>>>>> Stashed changes:project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
// >>>>>>> qy0318:项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
//                 //获取设备号
//                 // èŽ·å–è®¾å¤‡é…ç½®
//                 //OtherDevice serialPortDevice = (OtherDevice)context.JobDetail.JobDataMap.Get("JobParams");
//                 if (!int.TryParse(AppSettings.Get("DepartmentID"), out int deid))
//                 {
//                     Console.WriteLine("配置项 DepartmentID æ— æ³•转换为整数");
//                 }
//                 var devices = GetDevicesByDeptId(deid);
//                 if (devices != null)
//                 {
//                     //首先要一直读,如果发生了故障要写到_alarmResetHsyServer中记录下来并且给到前端数据
// <<<<<<< HEAD:project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
//                     //å·¦plc
                   
                    if (serialPortDevice.DeviceCode == "SSG001")
                    {
                        var leftPLcstuck = serialPortDevice.Communicator.Read<bool>("M104"); //卡住报警
                        var leftPLcOher = serialPortDevice.Communicator.Read<bool>("M105");  //其他报警 //默认是false
                        Console.WriteLine($"{serialPortDevice.DeviceName}:卡住报警{leftPLcstuck},其他报警{leftPLcOher}");
                        if (leftPLcstuck == true && leftPLcOher == false)
                           //if (leftPLcOher == false)
                            {
                            string text = "轨道一:伸缩卡住报警";
                            //报警了在这调用添加方法,并传给前端
                             var reslut = _alarmResetHsyServer.AddAlarmHsy(text, leftPLcstuck);
//                     if (serialPortDevice.DeviceCode == "SSG001")
// =======
// <<<<<<< Updated upstream:项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
//                     if (serialPortDevice.DeviceName=="左汇川PLC")
// >>>>>>> qy0318:项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
//                     {
//                         var leftPLcstuck = serialPortDevice.Communicator.Read<bool>("M104"); //卡住报警
//                         var leftPLcOher = serialPortDevice.Communicator.Read<bool>("M105");  //其他报警 //默认是false
//                         Console.WriteLine($"{serialPortDevice.DeviceName}:卡住报警{leftPLcstuck},其他报警{leftPLcOher}");
//                         if (leftPLcstuck == true && leftPLcOher == false)
//                            //if (leftPLcOher == false)
//                             {
// <<<<<<< HEAD:project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
//                             string text = "轨道一:伸缩卡住报警";
//                             //报警了在这调用添加方法,并传给前端
//                              var reslut = _alarmResetHsyServer.AddAlarmHsy(text, leftPLcstuck);
                           
                        }
                        if (leftPLcOher == true && leftPLcstuck == false)
                        {
                            string text = "轨道一:其他故障报警";
                            var reslut = _alarmResetHsyServer.AddAlarmHsy(text, leftPLcstuck);
//                         }
//                         if (leftPLcOher == true && leftPLcstuck == false)
//                         {
//                             string text = "轨道一:其他故障报警";
// =======
//                             string text = "伸缩卡住报警";
// =======
//                     //å·¦plc
//                     var leftPLcstuck1 = devices.Value.left.Communicator.Read<bool>("M104"); //卡住报警
//                         var leftPLcOher1 = devices.Value.left.Communicator.Read<bool>("M105");  //其他报警 //默认是false
//                         Console.WriteLine($"{devices.Value.left.DeviceName}:默认是false,现在卡住报警值:{leftPLcstuck1},现在其他报警值:{leftPLcOher1}");
//                         if (leftPLcstuck1 == true && leftPLcOher1 == false)
//                         //if (leftPLcOher1 == false)
//                         {
//                             string text =$"轨道{deid}:伸缩卡住报警";
// >>>>>>> Stashed changes:project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
//                             //报警了在这调用添加方法,并传给前端
//                             var reslut = _alarmResetHsyServer.AddAlarmHsy(text, leftPLcstuck1);
//                         }
//                         if (leftPLcstuck1 == true && leftPLcOher1 == false)
//                         {
// <<<<<<< Updated upstream:项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
//                             string text = "其他故障报警";
// >>>>>>> qy0318:项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
//                             var reslut = _alarmResetHsyServer.AddAlarmHsy(text, leftPLcstuck);
                            
                        }
                        if (leftPLcstuck == true && leftPLcOher == true)//如果报警了
                        {
                            string text = "轨道一:报警伸缩卡住报警和其他故障报警";
                            var reslut = _alarmResetHsyServer.AddAlarmHsy(text, leftPLcstuck);
// =======
//                             string text = $"轨道{deid}:其他故障报警";
//                             var reslut = _alarmResetHsyServer.AddAlarmHsy(text, leftPLcstuck1);
// >>>>>>> Stashed changes:project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
//                         }
//                         if (leftPLcstuck1 == true && leftPLcOher1 == true)//如果报警了
//                         {
// <<<<<<< HEAD:project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
//                             string text = "轨道一:报警伸缩卡住报警和其他故障报警";
// =======
// <<<<<<< Updated upstream:项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
//                             string text = "报警伸缩卡住报警和其他故障报警";
// >>>>>>> qy0318:项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
//                             var reslut = _alarmResetHsyServer.AddAlarmHsy(text, leftPLcstuck);
                          
                        }
//                         }
                        var alrt = _alarmResetHsyServer.GetWebSocketInfo();
                        _webSocketServer.PublishAllClientPayload(JsonConvert.SerializeObject(alrt));//websocketserver这种只能传给前端json格式
                    }
                    else if (serialPortDevice.DeviceCode == "SSG002")
                    {
                        //右plc
                        var rightPLcSuck = serialPortDevice.Communicator.Read<bool>("M104"); //卡住报警
                        var rightPLcOher = serialPortDevice.Communicator.Read<bool>("M105");//其他报警
                        Console.WriteLine($"{serialPortDevice.DeviceName}:卡住报警{rightPLcSuck},其他报警{rightPLcOher}");
                        if (rightPLcSuck == true && rightPLcOher == false)
                        {
                            string text = "轨道一:报警伸缩卡住报警";
                            //报警了在这调用添加方法,并传给前端
                             var reslut = _alarmResetHsyServer.AddAlarmHsy(text, rightPLcSuck);
                            // _webSocketServer.PublishAllClientPayload(JsonConvert.SerializeObject(reslut));//websocketserver这种只能传给前端json格式
                        }
                        if (rightPLcOher == true && rightPLcSuck == false)
                        {
                            string text = "轨道一:其他故障报警";
                            var reslut = _alarmResetHsyServer.AddAlarmHsy(text, rightPLcOher);
                        }
                        if (rightPLcSuck == true && rightPLcOher == true)//如果报警了
                        {
                            string text = "轨道一:报警伸缩卡住报警和其他故障报警";
                            var reslut = _alarmResetHsyServer.AddAlarmHsy(text, rightPLcOher);//添加数据
                        }
                        var alrt = _alarmResetHsyServer.GetWebSocketInfo();
                        _webSocketServer.PublishAllClientPayload(JsonConvert.SerializeObject(alrt));
                    }
//                         var alrt = _alarmResetHsyServer.GetWebSocketInfo();
//                         _webSocketServer.PublishAllClientPayload(JsonConvert.SerializeObject(alrt));//websocketserver这种只能传给前端json格式
//                     }
//                     else if (serialPortDevice.DeviceCode == "SSG002")
//                     {
//                         //右plc
//                         var rightPLcSuck = serialPortDevice.Communicator.Read<bool>("M104"); //卡住报警
//                         var rightPLcOher = serialPortDevice.Communicator.Read<bool>("M105");//其他报警
//                         Console.WriteLine($"{serialPortDevice.DeviceName}:卡住报警{rightPLcSuck},其他报警{rightPLcOher}");
//                         if (rightPLcSuck == true && rightPLcOher == false)
//                         {
// <<<<<<< HEAD:project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
//                             string text = "轨道一:报警伸缩卡住报警";
// =======
//                             string text = "报警伸缩卡住报警";
// =======
//                             string text = $"轨道{deid}:报警伸缩卡住报警和其他故障报警";
//                             var reslut = _alarmResetHsyServer.AddAlarmHsy(text, leftPLcstuck1);
//                         }
//                         //右plc
//                         var rightPLcSuck = devices.Value.right.Communicator.Read<bool>("M104"); //卡住报警
//                         var rightPLcOher = devices.Value.right.Communicator.Read<bool>("M105");//其他报警
//                         Console.WriteLine($"{devices.Value.right.DeviceName}::默认是false,现在卡住报警值:{rightPLcSuck},:现在其他报警值:{rightPLcOher}");
//                         if (rightPLcSuck == true && rightPLcOher == false)
//                         {
//                             string text = $"轨道{deid}:报警伸缩卡住报警";
// >>>>>>> Stashed changes:project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
// >>>>>>> qy0318:项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
//                             //报警了在这调用添加方法,并传给前端
//                             var reslut = _alarmResetHsyServer.AddAlarmHsy(text, rightPLcSuck);
//                         }
//                         if (rightPLcOher == true && rightPLcSuck == false)
//                         {
// <<<<<<< HEAD:project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
//                             string text = "轨道一:其他故障报警";
// =======
// <<<<<<< Updated upstream:项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
//                             string text = "其他故障报警";
// =======
//                             string text = $"轨道{deid}:其他故障报警";
// >>>>>>> Stashed changes:project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
// >>>>>>> qy0318:项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
//                             var reslut = _alarmResetHsyServer.AddAlarmHsy(text, rightPLcOher);
//                         }
//                         if (rightPLcSuck == true && rightPLcOher == true)//如果报警了
//                         {
// <<<<<<< HEAD:project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
//                             string text = "轨道一:报警伸缩卡住报警和其他故障报警";
// =======
// <<<<<<< Updated upstream:项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
//                             string text = "报警伸缩卡住报警和其他故障报警";
// =======
//                             string text = $"轨道{deid}:报警伸缩卡住报警和其他故障报警";
// >>>>>>> Stashed changes:project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
// >>>>>>> qy0318:项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
//                             var reslut = _alarmResetHsyServer.AddAlarmHsy(text, rightPLcOher);//添加数据
//                         }
//                         var alrt = _alarmResetHsyServer.GetWebSocketInfo();
//                         _webSocketServer.PublishAllClientPayload(JsonConvert.SerializeObject(alrt));
// <<<<<<< HEAD:project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
//                     }
                  
                }
            }
            catch (Exception ex)
            {
// =======
// <<<<<<< Updated upstream:项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
//                     }
// >>>>>>> qy0318:项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
//                 }
// =======
//                     }
// >>>>>>> Stashed changes:project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
//             }
//             catch (Exception ex)
//             {
                Console.WriteLine("错误信息:" + ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
            return Task.CompletedTask;
        }
    }
}
//                 Console.WriteLine("错误信息:" + ex.Message);
//                 Console.WriteLine(ex.StackTrace);
//             }
//             return Task.CompletedTask;
//         }
//         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);
//         }
//     }
// }
project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/LoginhsyService.cs
@@ -76,6 +76,23 @@
                    query = query.OrderBy((a, b) => b.LoginTiem, OrderByType.Desc);
                }
                // å¦‚果不是管理员,根据部门过滤
                if (pagination.account != "admin")
                {
                    var currentUser = _user.Db.Queryable<Sys_User>()
                        .Where(u => u.UserName == pagination.account)
                        .First();
                    if (currentUser == null)
                    {
                        return new WebResponseContent { Status = false, Data = "未获取到用户信息" };
                    }
                    int? deptId = currentUser.Dept_Id;
                    query = query.Where((a, b) => a.Dept_Id == deptId);
                }
                //返回结果
                var result = query.Select((a, b) => new
project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/MaintenanceService.cs
@@ -13,20 +13,30 @@
using WIDESEAWCS_DTO;
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
using WIDESEAWCS_DTO.Telescopic;
using SqlSugar.DistributedSystem.Snowflake;
using System.IO;
namespace WIDESEAWCS_TelescopicService
{
    public class MaintenanceService : ServiceBase<Dt_Maintenance, IRepository<Dt_Maintenance>>, IMaintenanceService
    {
        public IRepository<Dt_Maintenance> Repository => BaseDal;
        public readonly IRepository<Dt_MaintenanceTeam> _team;
        private readonly IRepository<Sys_User> _user;
        public MaintenanceService(IRepository<Dt_Maintenance> BaseDal, IRepository<Sys_User> user) : base(BaseDal)
        public MaintenanceService(IRepository<Dt_Maintenance> BaseDal, IRepository<Sys_User> user, IRepository<Dt_MaintenanceTeam> team) : base(BaseDal)
        {
            _user = user;
            _team = team;
        }
        /// <summary>
        /// è®¾ç½®æ£€ä¿®æƒé™
        /// </summary>
        /// <param name="pagination"></param>
        /// <returns></returns>
        public WebResponseContent ShowMaintence(PaginationDTO pagination)
        {
            try
@@ -110,28 +120,47 @@
        {
            try
            {
                // ç¬¬ä¸€æ­¥ï¼šè‡ªåŠ¨æ¸…ç†è¿‡æœŸæ£€ä¿®çŠ¶æ€
                var today = DateTime.Today;
                var recordsToUpdate = Db.Queryable<Dt_Maintenance>()
                    .Where(b => b.MaintenancStartTime != null &&
                                b.MaintenancStartTime.Value.Date < today  )
                    .ToList();
                if (recordsToUpdate.Count > 0)
                {
                    foreach (var record in recordsToUpdate)//更新
                    {
                        record.MaintenancStartTime = null;//清空开始时间
                        record.MaintenancEendTime = null;//清空结束时间
                        record.MaintenanceStatus = 0; // Set to false
                        record.IsPossible = "NULL"; //更改状态为false不运行检修//默认为NULL
                    }
                    Db.Updateable(recordsToUpdate).ExecuteCommand();
                }
                int totalCount = 0;
                var sys = _user.Db.Queryable<Sys_User>();
                var main = Db.Queryable<Dt_Maintenance>();
                var query = sys.InnerJoin<Dt_Maintenance>((a, b) => a.UserName == b.UserAccount)
                               .Where((a, b) => b.IsPossible == "true"); // å…ˆç­›é€‰ IsPossible ä¸º true çš„æ•°æ®
                              .Where((a, b) => b.IsPossible == "true"); // å±•示运行检修的
                // å¦‚果提供了搜索关键字,则进行模糊查询
                // æœç´¢å…³é”®å­—
                if (!string.IsNullOrEmpty(pagination.searchKeyword))
                {
                    query = query.Where((a, b) =>
                        a.UserTrueName.Contains(pagination.searchKeyword) ||   // æŒ‰çœŸå®žå§“名模糊搜索
                        a.Userteam.Contains(pagination.searchKeyword));        // æŒ‰ç”¨æˆ·ç­ç»„模糊搜索
                        a.UserTrueName.Contains(pagination.searchKeyword) ||
                        a.Userteam.Contains(pagination.searchKeyword));
                }
                // å¦‚果提供了 status å‚数,则按状态筛选
                if (pagination.status.HasValue)//等价if(status!=null)
                // çŠ¶æ€å‚æ•°
                if (pagination.status.HasValue)
                {
                    query = query.Where((a, b) => b.MaintenanceStatus == pagination.status.Value);
                }
                // å¦‚果不是管理员,根据部门过滤
                // å¦‚果不是管理员,请按部门过滤
                if (pagination.account != "admin")
                {
                    var currentUser = _user.Db.Queryable<Sys_User>()
@@ -144,7 +173,6 @@
                    }
                    int? deptId = currentUser.Dept_Id;
                    query = query.Where((a, b) => a.Dept_Id == deptId);
                }
@@ -158,16 +186,16 @@
                        b.MaintenanceDate,
                        b.IsPossible,
                    })
                    .ToPageList(pagination.pageIndex, pagination.pageSize, ref totalCount); // åˆ†é¡µ
                    .ToPageList(pagination.pageIndex, pagination.pageSize, ref totalCount);
                return new WebResponseContent
                {
                    Status = true,
                    Data = new
                    {
                        TotalCount = totalCount, // æ€»æ•°
                        PageIndex = pagination.pageIndex,   // å½“前页码
                        PageSize = pagination.pageSize,     // æ¯é¡µæ•°æ®é‡
                        TotalCount = totalCount,
                        PageIndex = pagination.pageIndex,
                        PageSize = pagination.pageSize,
                        Items = result
                    }
                };
@@ -193,11 +221,26 @@
            try
            {
                var mon = BaseDal.QueryFirst(x => x.ID == id);
                if (mon == null)
                {
                    return new WebResponseContent { Status = false, Message = "无法更改,没有找到该用户" };
                }
                var sysuer = _user.QueryData(x => x.UserName == mon.UserAccount).FirstOrDefault();
                if (ispossible == "true")
                {
                    mon.IsPossible = "true";
                    mon.MaintenanceDate = DateTime.Now;
                    BaseDal.UpdateData(mon);
                    var recording = new Dt_MaintenanceTeam
                    {
                        OperatorName = sysuer.UserTrueName,
                        TeamName = sysuer.RoleName,
                        DistributionTime = DateTime.Now,
                        Creater = "admin",
                        CreateDate = DateTime.Now,
                    };
                    _team.AddData(recording);
                }
                else
                {
project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs
@@ -9,6 +9,7 @@
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_ITelescopicService;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
@@ -31,35 +32,21 @@
        /// è‡ªåŠ¨æŽ§åˆ¶ä¼¸ç¼©æ†çš„ä¼¸å‡ºå’Œç¼©å›žé€Ÿåº¦
        /// </summary>
        /// <param name="ExtendedState">伸/出状态</param>
        /// <param name="account">用户账号</param>
        /// <returns></returns>
        public WebResponseContent automation(string ExtendedState, string account)
        public WebResponseContent automation(string ExtendedState)
        {
            try
            {
                var loginer = _user.QueryData(x => x.UserName == account).FirstOrDefault();
                if (loginer == null)
                    return new WebResponseContent { Status = false, Message = "登录用户不存在" };
                // è®¾å¤‡ç¼–号规则是按部门编号依次为 SSG001~SSG010
                string liftDeviceCode = $"SSG{(loginer.Dept_Id * 2 - 1):D3}";
                string rightDeviceCode = $"SSG{(loginer.Dept_Id * 2):D3}";
                OtherDevice liftDevice = (OtherDevice)Storage.Devices.Find(x => x.DeviceCode == liftDeviceCode);
                OtherDevice rightDevice = (OtherDevice)Storage.Devices.Find(x => x.DeviceCode == rightDeviceCode);
                if (liftDevice == null || rightDevice == null)
                //根据int.TryParse(AppSettings.Get("DepartmentID")读取到当前是轨道几,所有人都只能操作当前
                if (!int.TryParse(AppSettings.Get("DepartmentID"), out int deid))
                {
                    return new WebResponseContent { Status = false, Message = $"设备 {liftDeviceCode} æˆ– {rightDeviceCode} æœªæ‰¾åˆ°" };
                }
                if (liftDevice.Communicator == null || rightDevice.Communicator == null)
                {
                    return new WebResponseContent { Status = false, Message = "设备通讯未初始化" };
                }
                    return new WebResponseContent { Status = false, Message = "配置项 DepartmentID æ— æ³•转换为整数" };
                };
                var devices = GetDevicesByDeptId(deid);
                //找到Dt_Parameters中的最新一条数据
                var para = BaseDal.QueryData().OrderByDescending(x => x.CreateDate).FirstOrDefault();
                var para = BaseDal.QueryData().Where(x=>x.Deptid== deid).OrderByDescending(x => x.CreateDate).FirstOrDefault();
                if (para == null)
                    return new WebResponseContent { Status = false, Message = "未找到参数配置" };
@@ -68,19 +55,19 @@
                if (ExtendedState == "伸出")
                {
                    liftDevice.Communicator.Write<int>("D500", ext);
                    liftDevice.Communicator.Write<bool>("M100", true);
                    rightDevice.Communicator.Write<int>("D500", ext);
                    rightDevice.Communicator.Write<bool>("M100", true);
                    Console.WriteLine($"伸缩杆伸出 {ext}");
                    devices.Value.left.Communicator.Write<int>("D500", ext);//伸出速度
                    devices.Value.left.Communicator.Write<bool>("M100", true);//伸出按钮
                    devices.Value.right.Communicator.Write<int>("D500", ext);//伸出速度
                    devices.Value.right.Communicator.Write<bool>("M100", true);//伸出按钮
                    Console.WriteLine($"自动伸缩杆伸出 {ext}");
                }
                else if (ExtendedState == "缩回")
                {
                    liftDevice.Communicator.Write<int>("D501", ret);
                    liftDevice.Communicator.Write<bool>("M101", true);
                    rightDevice.Communicator.Write<int>("D501", ret);
                    rightDevice.Communicator.Write<bool>("M101", true);
                    Console.WriteLine($"伸缩杆缩回 {ret}");
                    devices.Value.left.Communicator.Write<int>("D501", ext);//伸出速度
                    devices.Value.left.Communicator.Write<bool>("M101", true);//伸出按钮
                    devices.Value.right.Communicator.Write<int>("D501", ext);//伸出速度
                    devices.Value.right.Communicator.Write<bool>("M101", true);//伸出按钮
                    Console.WriteLine($"自动伸缩杆缩回 {ret}");
                }
                else
                {
@@ -99,53 +86,55 @@
            public WebResponseContent ManualOperation(string position, string ExtendedState,string account)
                {
        /// <summary>
        /// æ‰‹åŠ¨æŽ§åˆ¶ï¼Œä¼¸ç¼©æ†çš„ç¼©å›žå’Œä¼¸å‡ºé€Ÿåº¦
        /// </summary>
        /// <param name="position">伸缩杆的位置(左右)</param>
        /// <param name="ExtendedState">伸/缩状态</param>
        /// <returns></returns>
        ///
        public WebResponseContent ManualOperation(string position, string ExtendedState)
        {
            try
            {
                var loginer = _user.QueryData(x => x.UserName == account).FirstOrDefault();
                if (loginer == null)
                    return new WebResponseContent { Status = false, Message = "用户不存在" };
                if (!int.TryParse(AppSettings.Get("DepartmentID"), out int deid))
                {
                    return new WebResponseContent { Status = false, Message = "配置项 DepartmentID æ— æ³•转换为整数" };
                }
                var devices = GetDevicesByDeptId(deid);
                var devices = GetDevicesByDeptId((int)loginer.Dept_Id);
                if (devices == null)
                    return new WebResponseContent { Status = false, Message = "设备未找到" };
                var para = BaseDal.QueryData().OrderByDescending(x => x.CreateDate).FirstOrDefault();
                if (para == null)
                    return new WebResponseContent { Status = false, Message = "参数未配置" };
                int ext = (int)para.ExtendSpeed;
                int ret = (int)para.RetractionSpeed;
                //俩个plc左右各一个
                //OtherDevice liftotherDevice = (OtherDevice)Storage.Devices.Find(x => x.DeviceCode == "SSG001");
                //OtherDevice rightotherDevice = (OtherDevice)Storage.Devices.Find(x => x.DeviceCode == "SSG002");
                //找到Dt_Parameters中的最新一条数据根据当前的deid
                var para = BaseDal.QueryData().Where(x => x.Deptid == deid).OrderByDescending(x => x.CreateDate).FirstOrDefault();
                int ext = (int)para.ManualExtend;//手动伸出速度
                int ret = (int)para.ManualRetraction;//手动缩回速度
                if (position == "å·¦" && ExtendedState == "伸出")
                {
                    devices.Value.left.Communicator.Write<int>("D500", ext);
                    devices.Value.left.Communicator.Write<bool>("M100", true);
                    devices.Value.left.Communicator.Write<int>("D500", ext);//伸出速度
                    devices.Value.left.Communicator.Write<bool>("M100", true);//伸出按钮
                    Console.WriteLine($"{position}伸缩杆手动伸出{ext}");
                }
                else if (position == "å·¦" && ExtendedState == "缩回")
                {
                    devices.Value.left.Communicator.Write<int>("D501", ret);
                    devices.Value.left.Communicator.Write<int>("D501", ret);//缩回速度
                    devices.Value.left.Communicator.Write<bool>("M101", true);
                    Console.WriteLine($"{position}伸缩杆手动缩回{ret}");
                }
                else if (position == "右" && ExtendedState == "伸出")
                {
                    devices.Value.right.Communicator.Write<int>("D500", ext);
                    devices.Value.right.Communicator.Write<bool>("M100", true);
                    Console.WriteLine($"{position}伸缩杆手动伸出{ext}");
                }
                else if (position == "右" && ExtendedState == "缩回")
                {
                    devices.Value.right.Communicator.Write<int>("D501", ret);
                    devices.Value.right.Communicator.Write<bool>("M101", true);
                    Console.WriteLine($"{position}伸缩杆手动缩回{ret}");
                }
                else
                {
                    return new WebResponseContent { Status = false, Message = "状态参数错误" };
                }
                return new WebResponseContent { Status = true, Message = "成功" };
            }
            catch (Exception ex)
            {
project/ºǫ́¹ÜÀí/WIDESEAWCS_Server/WIDESEAWCS_ITelescopicService/IParametersService.cs
@@ -20,7 +20,7 @@
        /// </summary>
        /// <param name="ExtendedState">伸/出状态</param>
        /// <returns></returns>
        WebResponseContent automation(string ExtendedState, string account);
        WebResponseContent automation(string ExtendedState);
        /// <summary>
        /// æ‰‹åŠ¨æŽ§åˆ¶ï¼Œä¼¸ç¼©æ†çš„ç¼©å›žå’Œä¼¸å‡ºé€Ÿåº¦
@@ -29,7 +29,7 @@
        /// <param name="ExtendedState">伸/缩状态</param>
        /// <returns></returns>
        /// 
        WebResponseContent ManualOperation(string position, string ExtendedState, string account);
        WebResponseContent ManualOperation(string position, string ExtendedState, int DeptId);
    }
}
project/ºǫ́¹ÜÀí/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/Telescopic/Dt_Parameters.cs
@@ -42,5 +42,12 @@
        /// </summary>
        [SugarColumn(Length = 50, IsNullable = true, ColumnDescription = "手动缩回速度")]
        public double ManualRetraction { get; set; }
        /// <summary>
        /// éƒ¨é—¨id
        /// </summary>
        [SugarColumn(Length = 50, IsNullable = true, ColumnDescription = "部门id")]
        public int Deptid { get; set; }
    }
}
project/ºǫ́¹ÜÀí/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/Telescopic/ParametersController.cs
@@ -25,9 +25,9 @@
        /// <returns></returns>
        /// 
        [HttpPost,Route("ManualOperation"),AllowAnonymous]
        public  WebResponseContent ManualOperation(string position, string ExtendedState, string account)
        public  WebResponseContent ManualOperation(string position, string ExtendedState, int DeptId)
        {
            return Service.ManualOperation(position, ExtendedState, account);
            return Service.ManualOperation(position, ExtendedState, DeptId);
        }
        /// <summary>
@@ -37,9 +37,9 @@
        /// <returns></returns>
        [HttpPost,Route("automation"),AllowAnonymous]
        public WebResponseContent automation(string ExtendedState, string account)
        public WebResponseContent automation(string ExtendedState)
        {
            return Service.automation(ExtendedState, account);
            return Service.automation(ExtendedState);
        }
    }
}
project/ºǫ́¹ÜÀí/WIDESEAWCS_Server/WIDESEAWCS_Server/Program.cs
@@ -30,7 +30,7 @@
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory()).ConfigureContainer<ContainerBuilder>(builder =>
{
    builder.RegisterModule(new AutofacModuleRegister());//带有接口层的服务注入
    builder.RegisterModule(new AutofacModuleRegister());//���нӿڲ�ķ���ע��
    builder.RegisterModule(new QuartzJobAutofacModuleRegister());
    builder.RegisterModule<AutofacPropertityModuleReg>();//
}).ConfigureAppConfiguration((hostingContext, config) =>
@@ -41,14 +41,14 @@
}); ;
builder.ConfigureApplication();
// 2、配置服务
builder.Services.AddSingleton(new AppSettings(builder.Configuration));//注册
builder.Services.AddAllOptionRegister();//读取配置文件
builder.Services.AddMemoryCacheSetup();//缓存
builder.Services.AddSqlsugarSetup();//SqlSugar å¯åŠ¨æœåŠ¡
//builder.Services.AddInitializationHostServiceSetup();//应用初始化服务注入
// 2�����÷���
builder.Services.AddSingleton(new AppSettings(builder.Configuration));//ע��
builder.Services.AddAllOptionRegister();//��ȡ�����ļ�
builder.Services.AddMemoryCacheSetup();//����
builder.Services.AddSqlsugarSetup();//SqlSugar ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½
//builder.Services.AddInitializationHostServiceSetup();//Ӧ�ó�ʼ������ע��
builder.Services.AddHostedService<SeedDataHostedService>();
builder.Services.AddDbSetup();//Db å¯åŠ¨æœåŠ¡
builder.Services.AddDbSetup();//Db ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½
builder.Services.AddScoped<QuartzJobCreateDataTabel>();
builder.Services.AddHostedService<QuartzJobDataTableHostedService>();
@@ -65,7 +65,7 @@
builder.Services.AddSwaggerSetup();
builder.Services.AddJobSetup();//任务调度 å¯åŠ¨æœåŠ¡
builder.Services.AddJobSetup();//������� ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½
builder.Services.AddHttpContextSetup();
@@ -79,7 +79,7 @@
builder.Services.AddAuthorizationSetup();
builder.Services.AddIpPolicyRateLimitSetup(builder.Configuration);//IPLimit限流 å¯åŠ¨æœåŠ¡
builder.Services.AddIpPolicyRateLimitSetup(builder.Configuration);//IPLimit���� ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½
builder.Services.AddScoped<UseServiceDIAttribute>();
@@ -89,7 +89,7 @@
builder.Services.AddControllers(o =>
{
    o.Filters.Add(typeof(GlobalExceptionsFilter));//全局异常
    o.Filters.Add(typeof(GlobalExceptionsFilter));//ȫ���쳣
})
.AddNewtonsoftJson(options =>
{
@@ -110,20 +110,20 @@
var app = builder.Build();
// 3、配置中间件
app.UseMiniProfiler();//性能分析器
app.ConfigureApplication();//配置文件
app.UseApplicationSetup();//启动配置
// 3��������
app.UseMiniProfiler();//���ܷ�����
app.ConfigureApplication();//�����ļ�
app.UseApplicationSetup();//��������
app.UseAllServicesMiddle(builder.Services);
//FaceAI.Face.Main();//人脸识别
//FaceAI.Face.sdk_init(null);//����ʶ��
app.UseSession();
//if (app.Environment.IsDevelopment())
{
    //todo
    app.UseSwaggerAuthorized();
    app.UseSwaggerMiddle(() => Assembly.GetExecutingAssembly().GetManifestResourceStream("WIDESEAWCS_Server.index.html") ?? throw new Exception("未找到WIDESEAWCS_Server.index.html文件"));
}//判断是否需要打开swagger
    app.UseSwaggerMiddle(() => Assembly.GetExecutingAssembly().GetManifestResourceStream("WIDESEAWCS_Server.index.html") ?? throw new Exception("δ�ҵ�WIDESEAWCS_Server.index.html�ļ�"));
}//�ж��Ƿ���Ҫ��swagger
app.UseIpLimitMiddle();
app.UseApiLogMiddleware();
project/ºǫ́¹ÜÀí/WIDESEAWCS_Server/WIDESEAWCS_Server/Properties/PublishProfiles/FolderProfile1.pubxml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
  <PropertyGroup>
    <DeleteExistingFiles>false</DeleteExistingFiles>
    <ExcludeApp_Data>false</ExcludeApp_Data>
    <LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <PublishProvider>FileSystem</PublishProvider>
    <PublishUrl>E:\发布文件\后台</PublishUrl>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <_TargetId>Folder</_TargetId>
  </PropertyGroup>
</Project>
project/ºǫ́¹ÜÀí/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json
@@ -38,5 +38,8 @@
  "LogAOPEnable": true, //是否记录AOP日志
  "WebSocketEnable": true,
  //"WebSocketPort": 9260
  "WebSocketPort": 5173
  "WebSocketPort": 5173,
  "DepartmentID": "1" //这个是伸出/伸回的部门id
}
//单机版
project/ºǫ́¹ÜÀí/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SSG/AlarmResetJob.cs
@@ -66,7 +66,7 @@
            try
            {
                var stuck = device.Communicator.Read<bool>("M104");//伸缩杆报警//默认是false
                var other = device.Communicator.Read<bool>("M105");//其他报警 //默认是
                var other = device.Communicator.Read<bool>("M105");//其他报警 //默认是false
                Console.WriteLine($"{device.DeviceName}:卡住报警的默认值为{stuck},其他报警的默认值为{other}");
                string location = device.DeviceCode switch
                {
@@ -74,11 +74,11 @@
                    "SSG002" => "轨道一-右",
                    "SSG003" => "轨道二-å·¦",
                    "SSG004" => "轨道二-右",
                    "SSG005" => "轨道三-右",
                    "SSG005" => "轨道三-å·¦",
                    "SSG006" => "轨道三-右",
                    "SSG007" => "轨道四-右",
                    "SSG007" => "轨道四-å·¦",
                    "SSG008" => "轨道四-右",
                    "SSG009" => "轨道五-右",
                    "SSG009" => "轨道五-å·¦",
                    "SSG0010" => "轨道五-右",
                    // ä¾æ­¤ç±»æŽ¨...
                    _ => $"未知设备({device.DeviceCode})"
project/ºǫ́¹ÜÀí/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/MaintenanceService.cs
@@ -13,17 +13,20 @@
using WIDESEAWCS_DTO;
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
using WIDESEAWCS_DTO.Telescopic;
using Microsoft.AspNetCore.Mvc.ModelBinding;
namespace WIDESEAWCS_TelescopicService
{
    public class MaintenanceService : ServiceBase<Dt_Maintenance, IRepository<Dt_Maintenance>>, IMaintenanceService
    {
        public IRepository<Dt_Maintenance> Repository => BaseDal;
        public readonly IRepository<Dt_MaintenanceTeam> _team;
        private readonly IRepository<Sys_User> _user;
        public MaintenanceService(IRepository<Dt_Maintenance> BaseDal, IRepository<Sys_User> user) : base(BaseDal)
        public MaintenanceService(IRepository<Dt_Maintenance> BaseDal, IRepository<Sys_User> user, IRepository<Dt_MaintenanceTeam> team) : base(BaseDal)
        {
            _user = user;
            _team = team;
        }
@@ -53,7 +56,10 @@
                               a.CardNumber,
                               a.Userteam,
                               a.HeadImageUrl,
                               b.IsPossible
                               a.Dept_Id,
                               b.IsPossible,
                           }).ToPageList(pagination.pageIndex, pagination.pageSize, ref totalCount);
                return new WebResponseContent
                {
@@ -87,26 +93,48 @@
        {
            try
            {
                // ç¬¬ä¸€æ­¥ï¼šè‡ªåŠ¨æ¸…ç†è¿‡æœŸæ£€ä¿®çŠ¶æ€
                var today = DateTime.Today;
                var recordsToUpdate = Db.Queryable<Dt_Maintenance>()
                    .Where(b => b.MaintenancStartTime != null &&
                                b.MaintenancStartTime.Value.Date < today) // Assuming 0 is false
                    .ToList();
                if (recordsToUpdate.Count > 0)
                {
                    foreach (var record in recordsToUpdate)//更新
                    {
                        record.MaintenancStartTime = null;//清空开始时间
                        record.MaintenancEendTime = null;//清空结束时间
                        record.MaintenanceStatus = 0; // Set to false
                        record.IsPossible = "NULL"; //更改状态为false不运行检修//默认为NULL
                    }
                    Db.Updateable(recordsToUpdate).ExecuteCommand();
                }
                int totalCount = 0;
                var sys = _user.Db.Queryable<Sys_User>();
                var main = Db.Queryable<Dt_Maintenance>();
                var query = sys.InnerJoin<Dt_Maintenance>((a, b) => a.UserName == b.UserAccount)
                               .Where((a, b) => b.IsPossible == "true"); // å…ˆç­›é€‰ IsPossible ä¸º true çš„æ•°æ®
                              .Where((a, b) => b.IsPossible == "true"); // Filter IsPossible true first
                // å¦‚果提供了搜索关键字,则进行模糊查询
                // æœç´¢å…³é”®å­—
                if (!string.IsNullOrEmpty(pagination.searchKeyword))
                {
                    query = query.Where((a, b) =>
                        a.UserTrueName.Contains(pagination.searchKeyword) ||   // æŒ‰çœŸå®žå§“名模糊搜索
                        a.Userteam.Contains(pagination.searchKeyword));        // æŒ‰ç”¨æˆ·ç­ç»„模糊搜索
                        a.UserTrueName.Contains(pagination.searchKeyword) ||
                        a.Userteam.Contains(pagination.searchKeyword));
                }
                // å¦‚果提供了 status å‚数,则按状态筛选
                if (pagination.status.HasValue)//等价if(status!=null)
                // çŠ¶æ€å‚æ•°
                if (pagination.status.HasValue)
                {
                    query = query.Where((a, b) => b.MaintenanceStatus == pagination.status.Value);
                }
                var result = query
                    .Select((a, b) => new
@@ -118,16 +146,16 @@
                        b.MaintenanceDate,
                        b.IsPossible,
                    })
                    .ToPageList(pagination.pageIndex, pagination.pageSize, ref totalCount); // åˆ†é¡µ
                    .ToPageList(pagination.pageIndex, pagination.pageSize, ref totalCount);
                return new WebResponseContent
                {
                    Status = true,
                    Data = new
                    {
                        TotalCount = totalCount, // æ€»æ•°
                        PageIndex = pagination.pageIndex,   // å½“前页码
                        PageSize = pagination.pageSize,     // æ¯é¡µæ•°æ®é‡
                        TotalCount = totalCount,
                        PageIndex = pagination.pageIndex,
                        PageSize = pagination.pageSize,
                        Items = result
                    }
                };
@@ -153,17 +181,35 @@
            try
            {
                var mon = BaseDal.QueryFirst(x => x.ID == id);
                if (mon==null)
                {
                    return new WebResponseContent { Status = false, Message = "无法更改,没有找到该用户" };
                }
                var sysuer = _user.QueryData(x => x.UserName == mon.UserAccount).FirstOrDefault();
                if (ispossible == "true")
                {
                    mon.IsPossible = "true";
                    mon.MaintenanceDate = DateTime.Now;
                    BaseDal.UpdateData(mon);
                    var recording = new Dt_MaintenanceTeam
                    {
                        OperatorName = sysuer.UserTrueName,
                        TeamName = sysuer.RoleName,
                        DistributionTime = DateTime.Now,
                        Creater = "admin",
                        CreateDate = DateTime.Now,
                    };
                    _team.AddData(recording);
                }
                else
                {
                    mon.IsPossible = "false";
                    BaseDal.UpdateData(mon);
                }
                return new WebResponseContent { Status = true, Data = mon };
            }
            catch (Exception ex)
project/ºǫ́¹ÜÀí/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs
@@ -9,6 +9,7 @@
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_ITelescopicService;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
@@ -28,72 +29,73 @@
        /// <summary>
        /// è‡ªåŠ¨æŽ§åˆ¶ä¼¸ç¼©æ†çš„ä¼¸å‡ºå’Œç¼©å›žé€Ÿåº¦
        /// è‡ªåŠ¨æŽ§åˆ¶ä¼¸ç¼©æ†çš„ä¼¸å‡ºå’Œç¼©å›žé€Ÿåº¦ï¼ˆä¸€æ¬¡æ€§æŽ§åˆ¶æ‰€æœ‰çš„ï¼‰
        /// </summary>
        /// <param name="ExtendedState">伸/出状态</param>
        /// <param name="account">用户账号</param>
        /// <returns></returns>
        public WebResponseContent automation(string ExtendedState, string account)
        public WebResponseContent automation(string extendedState)
        {
            try
            {
                var loginer = _user.QueryData(x => x.UserName == account).FirstOrDefault();
                if (loginer == null)
                    return new WebResponseContent { Status = false, Message = "登录用户不存在" };
                // è®¾å¤‡ç¼–号规则是按部门编号依次为 SSG001~SSG010
                string liftDeviceCode = $"SSG{(loginer.Dept_Id * 2 - 1):D3}";
                string rightDeviceCode = $"SSG{(loginer.Dept_Id * 2):D3}";
                OtherDevice liftDevice = (OtherDevice)Storage.Devices.Find(x => x.DeviceCode == liftDeviceCode);
                OtherDevice rightDevice = (OtherDevice)Storage.Devices.Find(x => x.DeviceCode == rightDeviceCode);
                if (liftDevice == null || rightDevice == null)
                for (int deptId = 1; deptId <= 5; deptId++)
                {
                    return new WebResponseContent { Status = false, Message = $"设备 {liftDeviceCode} æˆ– {rightDeviceCode} æœªæ‰¾åˆ°" };
                    var devices = GetDevicesByDeptId(deptId);
                    if (devices == null)
                    {
                        Console.WriteLine($"DeptId={deptId} æœªæ‰¾åˆ°è®¾å¤‡ï¼Œè·³è¿‡");
                        continue;
                    }
                    var para = BaseDal.QueryData()
                        .Where(x => x.Deptid == deptId)
                        .OrderByDescending(x => x.CreateDate)
                        .FirstOrDefault();
                    if (para == null)
                    {
                        Console.WriteLine($"DeptId={deptId} æœªæ‰¾åˆ°å‚数配置,跳过");
                        continue;
                    }
                    int ext = (int)para.ExtendSpeed;
                    int ret = (int)para.RetractionSpeed;
                    if (extendedState == "伸出")
                    {
                        devices.Value.left.Communicator.Write<int>("D500", ext);//伸出速度
                        devices.Value.left.Communicator.Write<bool>("M100", true);//伸出按钮
                        devices.Value.right.Communicator.Write<int>("D500", ext);
                        devices.Value.right.Communicator.Write<bool>("M100", true);
                        Console.WriteLine($"DeptId={deptId} ä¼¸å‡ºæ“ä½œï¼Œé€Ÿåº¦={ext}");
                    }
                    else if (extendedState == "缩回")
                    {
                        devices.Value.left.Communicator.Write<int>("D501", ret);//伸出速度
                        devices.Value.left.Communicator.Write<bool>("M101", true);//伸出按钮
                        devices.Value.right.Communicator.Write<int>("D501", ret);
                        devices.Value.right.Communicator.Write<bool>("M101", true);
                        Console.WriteLine($"DeptId={deptId} ç¼©å›žæ“ä½œï¼Œé€Ÿåº¦={ret}");
                    }
                    else
                    {
                        return new WebResponseContent { Status = false, Message = "未知的操作命令" };
                    }
                }
                if (liftDevice.Communicator == null || rightDevice.Communicator == null)
                {
                    return new WebResponseContent { Status = false, Message = "设备通讯未初始化" };
                }
                //找到Dt_Parameters中的最新一条数据
                var para = BaseDal.QueryData().OrderByDescending(x => x.CreateDate).FirstOrDefault();
                if (para == null)
                    return new WebResponseContent { Status = false, Message = "未找到参数配置" };
                int ext = (int)para.ExtendSpeed;
                int ret = (int)para.RetractionSpeed;
                if (ExtendedState == "伸出")
                {
                    liftDevice.Communicator.Write<int>("D500", ext);
                    liftDevice.Communicator.Write<bool>("M100", true);
                    rightDevice.Communicator.Write<int>("D500", ext);
                    rightDevice.Communicator.Write<bool>("M100", true);
                    Console.WriteLine($"伸缩杆伸出 {ext}");
                }
                else if (ExtendedState == "缩回")
                {
                    liftDevice.Communicator.Write<int>("D501", ret);
                    liftDevice.Communicator.Write<bool>("M101", true);
                    rightDevice.Communicator.Write<int>("D501", ret);
                    rightDevice.Communicator.Write<bool>("M101", true);
                    Console.WriteLine($"伸缩杆缩回 {ret}");
                }
                else
                {
                    return new WebResponseContent { Status = false, Message = "未知的操作命令" };
                }
                return new WebResponseContent { Status = true, Message = "成功" };
                return new WebResponseContent { Status = true, Message = "全部设备操作完成" };
            }
            catch (Exception ex)
            {
                return new WebResponseContent { Status = false, Message = ex.Message };
                return new WebResponseContent { Status = false, Message = $"操作异常:{ex.Message}" };
            }
        }
@@ -116,53 +118,58 @@
        //        var para = BaseDal.QueryData().OrderBy(x => x.CreateDate).FirstOrDefault();
        //        int ext = (int)para.ManualExtend;//自动伸出速度
        //        int ret = (int)para.ManualRetraction;//自动缩回速度
    //            if (position == "å·¦" && ExtendedState == "伸出")
    //            {
    //                var values = liftotherDevice.Communicator.Write<int>("D500", ext);//速度
    //    var button = liftotherDevice.Communicator.Write<bool>("M100", true);//伸出按钮
    //    Console.WriteLine($"{position}伸缩杆伸出{ext}");
    //            }
    //            if (position == "å·¦" && ExtendedState == "缩回")
    //            {
    //                var values = liftotherDevice.Communicator.Write<int>("D501", ret);
    //var button = liftotherDevice.Communicator.Write<bool>("M101", true);//缩回按钮
    //Console.WriteLine($"{position}伸缩杆缩回{ret}");
    //            }
//        if (position == "右" && ExtendedState == "伸出")
//        {
//            var values = rightotherDevice.Communicator.Write<int>("D500", ext);//速度
//            var button = rightotherDevice.Communicator.Write<bool>("M100", true);//伸出按钮
//            Console.WriteLine($"{position}伸缩杆伸出{ext}");
//        }
//        if (position == "右" && ExtendedState == "缩回")
//        {
//            var values = rightotherDevice.Communicator.Write<int>("D501", ret);
//            var button = rightotherDevice.Communicator.Write<bool>("M101", true);//缩回按钮
//            Console.WriteLine($"{position}伸缩杆缩回{ret}");
//        }
//        return new WebResponseContent { Status = true, Message = "成功" };
//    }
//    catch (Exception ex)
//    {
//        return new WebResponseContent { Status = false, Message = ex.Message };
        //            if (position == "å·¦" && ExtendedState == "伸出")
        //            {
        //                var values = liftotherDevice.Communicator.Write<int>("D500", ext);//速度
        //    var button = liftotherDevice.Communicator.Write<bool>("M100", true);//伸出按钮
        //    Console.WriteLine($"{position}伸缩杆伸出{ext}");
        //            }
        //            if (position == "å·¦" && ExtendedState == "缩回")
        //            {
        //                var values = liftotherDevice.Communicator.Write<int>("D501", ret);
        //var button = liftotherDevice.Communicator.Write<bool>("M101", true);//缩回按钮
        //Console.WriteLine($"{position}伸缩杆缩回{ret}");
        //            }
        //        if (position == "右" && ExtendedState == "伸出")
        //        {
        //            var values = rightotherDevice.Communicator.Write<int>("D500", ext);//速度
        //            var button = rightotherDevice.Communicator.Write<bool>("M100", true);//伸出按钮
        //            Console.WriteLine($"{position}伸缩杆伸出{ext}");
        //        }
        //        if (position == "右" && ExtendedState == "缩回")
        //        {
        //            var values = rightotherDevice.Communicator.Write<int>("D501", ret);
        //            var button = rightotherDevice.Communicator.Write<bool>("M101", true);//缩回按钮
        //            Console.WriteLine($"{position}伸缩杆缩回{ret}");
        //        }
        //        return new WebResponseContent { Status = true, Message = "成功" };
        //    }
        //    catch (Exception ex)
        //    {
        //        return new WebResponseContent { Status = false, Message = ex.Message };
//    }
//}
        //    }
        //}
            public WebResponseContent ManualOperation(string position, string ExtendedState,string account)
        /// <summary>
        /// æ‰‹åŠ¨æŽ§åˆ¶ï¼Œä¼¸ç¼©æ†çš„ç¼©å›žå’Œä¼¸å‡ºé€Ÿåº¦
        /// </summary>
        /// <param name="position">伸缩杆的位置(左右)</param>
        /// <param name="ExtendedState">伸/缩状态</param>
        /// <param name="DeptId">股道号</param>
        /// <returns></returns>
        public WebResponseContent ManualOperation(string position, string ExtendedState,int DeptId)
                {
            try
            {
                var loginer = _user.QueryData(x => x.UserName == account).FirstOrDefault();
                if (loginer == null)
                    return new WebResponseContent { Status = false, Message = "用户不存在" };
                var devices = GetDevicesByDeptId((int)loginer.Dept_Id);
                var devices = GetDevicesByDeptId(DeptId);
                if (devices == null)
                    return new WebResponseContent { Status = false, Message = "设备未找到" };
                var para = BaseDal.QueryData().OrderByDescending(x => x.CreateDate).FirstOrDefault();
                var para = BaseDal.QueryData(x=>x.Deptid== DeptId).OrderByDescending(x => x.CreateDate).FirstOrDefault();
                if (para == null)
                    return new WebResponseContent { Status = false, Message = "参数未配置" };
@@ -171,23 +178,27 @@
                if (position == "å·¦" && ExtendedState == "伸出")
                {
                    devices.Value.left.Communicator.Write<int>("D500", ext);
                    devices.Value.left.Communicator.Write<bool>("M100", true);
                    devices.Value.left.Communicator.Write<int>("D500", ext);//伸出速度
                    devices.Value.left.Communicator.Write<bool>("M100", true);//伸出按钮
                    Console.WriteLine($"{position}伸缩杆手动伸出{ext}");
                }
                else if (position == "å·¦" && ExtendedState == "缩回")
                {
                    devices.Value.left.Communicator.Write<int>("D501", ret);
                    devices.Value.left.Communicator.Write<int>("D501", ret);//缩回速度
                    devices.Value.left.Communicator.Write<bool>("M101", true);
                    Console.WriteLine($"{position}伸缩杆手动缩回{ret}");
                }
                else if (position == "右" && ExtendedState == "伸出")
                {
                    devices.Value.right.Communicator.Write<int>("D500", ext);
                    devices.Value.right.Communicator.Write<bool>("M100", true);
                    Console.WriteLine($"{position}伸缩杆手动伸出{ext}");
                }
                else if (position == "右" && ExtendedState == "缩回")
                {
                    devices.Value.right.Communicator.Write<int>("D501", ret);
                    devices.Value.right.Communicator.Write<bool>("M101", true);
                    Console.WriteLine($"{position}伸缩杆手动缩回{ret}");
                }
                else
@@ -216,8 +227,8 @@
            // å·¦è®¾å¤‡å·ï¼š1 -> 001,2 -> 003,3 -> 005...
            int baseCode = 1 + (deptId - 1) * 2;
            string leftCode = $"SSG{baseCode.ToString("D3")}";
            //右设备:1->002 ,2->004
            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);
ÏîÄ¿´úÂë/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Properties/PublishProfiles/FolderProfile1.pubxml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
  <PropertyGroup>
    <DeleteExistingFiles>false</DeleteExistingFiles>
    <ExcludeApp_Data>false</ExcludeApp_Data>
    <LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <PublishProvider>FileSystem</PublishProvider>
    <PublishUrl>bin\Release\net6.0\publish\</PublishUrl>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <_TargetId>Folder</_TargetId>
  </PropertyGroup>
</Project>