| | |
| | | using HslCommunication.WebSocket; |
| | | using Newtonsoft.Json; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections; |
| | |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseRepository; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_DTO.Telescopic; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob; |
| | | |
| | | namespace WIDESEAWCS_TelescopicService |
| | | { |
| | |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent AddAlarmHsy(string alarmContent, bool resetStatus) |
| | | public WebResponseContent AddAlarmHsy(int deptid,string alarmContent, bool resetStatus) |
| | | { |
| | | var alarm = new Dt_AlarmResetHsy |
| | | { |
| | | AlarmContent= alarmContent, |
| | | Deptid= deptid, |
| | | AlarmContent = alarmContent, |
| | | ResetStatus= resetStatus, |
| | | AlarmTime=DateTime.Now, |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | public WebResponseContent GetWebSocketInfo() |
| | | public WebResponseContent GetWebSocketInfo(int deptid) |
| | | { |
| | | try |
| | | { |
| | |
| | | // var query = Db.Queryable<Dt_AlarmResetHsy>() |
| | | // .OrderBy(x => new { ResetStatus = SqlFunc.IsNull(x.ResetStatus, false), x.CreateDate }, OrderByType.Desc); // 按 ResetStatus 为 true 排在前,并按 CreateDate 降序 |
| | | |
| | | var query = BaseDal.QueryData().OrderByDescending(x => x.ResetStatus). ThenByDescending(x => x.CreateDate); // 再按 CreateDate 降序; |
| | | var query = BaseDal.QueryData(x=>x.Deptid==deptid).OrderByDescending(x => x.ResetStatus). ThenByDescending(x => x.CreateDate); // 再按 CreateDate 降序; |
| | | |
| | | // 如果需要根据其他字段进行过滤或模糊查询,可以在此添加 |
| | | |
| | |
| | | /// </summary> |
| | | /// <param name="status"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent BecomeTrue(string account) |
| | | public WebResponseContent BecomeTrue() |
| | | { |
| | | //找到登入人的deptid |
| | | var loginer = _user.QueryFirst(x => x.UserName == account); |
| | | ////找到登入人的deptid |
| | | //var loginer = _user.QueryFirst(x => x.UserName == account); |
| | | if (!int.TryParse(AppSettings.Get("DepartmentID"), out int deid)) |
| | | { |
| | | return new WebResponseContent { Status = false, Message = "配置项 DepartmentID 无法转换为整数" }; |
| | | } |
| | | var devices = GetDevicesByDeptId(deid); |
| | | |
| | | |
| | | var query = BaseDal.QueryData(x => x.ResetStatus == true && x.Deptid==loginer.Dept_Id ).ToList(); |
| | | |
| | | 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) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | public WebResponseContent DeleteAllinform() |
| | | { |
| | | try |
| | | { |
| | | |
| | | if (!int.TryParse(AppSettings.Get("DepartmentID"), out int deid)) //获取轨道站号 |
| | | { |
| | | Console.WriteLine("配置项 DepartmentID 无法转换为整数"); |
| | | } |
| | | //找到该轨道站的全部信息 |
| | | var alarm = BaseDal.QueryData(x => x.Deptid == deid).ToList(); |
| | | if (alarm.Count<=0) |
| | | { |
| | | return new WebResponseContent { Status = false, Message = $"没有要删除的{deid}轨道站的报警信息" }; |
| | | } |
| | | //找到后全部删除 |
| | | var reslut= BaseDal.DeleteData(alarm); |
| | | return new WebResponseContent { Status = true, Message = "删除成功", Data = reslut }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | 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); |
| | | } |
| | | } |
| | | } |