| | |
| | | using System; |
| | | using HslCommunication.WebSocket; |
| | | using Newtonsoft.Json; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseRepository; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | | using WIDESEAWCS_DTO.Telescopic; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | |
| | |
| | | public class AlarmResetHsyServer : ServiceBase<Dt_AlarmResetHsy, IRepository<Dt_AlarmResetHsy>>, IAlarmResetHsyServer |
| | | { |
| | | public IRepository<Dt_AlarmResetHsy> Repository => BaseDal; |
| | | public AlarmResetHsyServer(IRepository<Dt_AlarmResetHsy> BaseDal) : base(BaseDal) |
| | | private readonly WebSocketServer _webSocketServer; |
| | | public AlarmResetHsyServer(IRepository<Dt_AlarmResetHsy> BaseDal, WebSocketServer webSocketServer) : base(BaseDal) |
| | | { |
| | | |
| | | _webSocketServer = webSocketServer; |
| | | } |
| | | |
| | | |
| | |
| | | AlarmTime=DateTime.Now, |
| | | |
| | | }; |
| | | BaseDal.AddData(alarm); |
| | | |
| | | |
| | | return base.AddData(alarm); |
| | | return new WebResponseContent { Status=true, Data = alarm }; |
| | | } |
| | | |
| | | |
| | | public WebResponseContent GetWebSocketInfo() |
| | | { |
| | | try |
| | | { |
| | | |
| | | |
| | | |
| | | |
| | | // æ¥è¯¢å¹¶æåºï¼ç¡®ä¿ ResetStatus 为 true çè®°å½æå¨åé¢ï¼å¹¶æ CreateDate éåºæå |
| | | // 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 éåº; |
| | | |
| | | // 妿éè¦æ ¹æ®å
¶ä»å段è¿è¡è¿æ»¤ææ¨¡ç³æ¥è¯¢ï¼å¯ä»¥å¨æ¤æ·»å |
| | | |
| | | |
| | | return new WebResponseContent |
| | | { |
| | | Status = true, |
| | | Message = "æ¥è¯¢æå", |
| | | Data = query |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | // å¼å¸¸æè·åé误è¿å |
| | | return new WebResponseContent { Status = false, Message = "é误ï¼" + ex.Message }; |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// å°è¡¨ä¸ç¶æå
¨é¨ä¸ºtrueçæ¹ä¸ºfalse |
| | | /// </summary> |
| | | /// <param name="status"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent BecomeTrue() |
| | | { |
| | | var query=BaseDal.QueryData(x=>x.ResetStatus==true).ToList(); |
| | | // å¦ææ²¡ææ¾å°ç¬¦åæ¡ä»¶çæ°æ® |
| | | if (query.Count == 0) |
| | | { |
| | | return new WebResponseContent { Status = false, Message = "没æè¦å¤ä½æ°æ®" }; |
| | | } |
| | | foreach (var item in query) |
| | | { |
| | | item.ResetStatus = false; |
| | | item.ResetTime = DateTime.Now; |
| | | } |
| | | |
| | | // æ§è¡æ¹éæ´æ°æä½ |
| | | var updateResult = BaseDal.UpdateData(query); |
| | | |
| | | // æ£æ¥æ´æ°æ¯å¦æå |
| | | if (updateResult) |
| | | { |
| | | return new WebResponseContent { Status = true, Message = "æ°æ®å·²æåå¤ä½", Data = query }; |
| | | } |
| | | else |
| | | { |
| | | return new WebResponseContent { Status = false, Message = "å¤ä½æä½å¤±è´¥" }; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | public WebResponseContent UpstreamInspectionRoad(UpstreamIDTO upstreamIDTO) |
| | | { |
| | | try |
| | | { |
| | | // å° upstreamIDTO 转æ JSON å符串 |
| | | var json = JsonConvert.SerializeObject(upstreamIDTO); |
| | | |
| | | // æ¨éå°ææ WebSocket 客æ·ç«¯ |
| | | _webSocketServer.PublishAllClientPayload(json); |
| | | |
| | | return new WebResponseContent { Status = true, Message = "æ¨éæå" }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | // åºç°å¼å¸¸ï¼è¿å失败 |
| | | return new WebResponseContent { Status = false, Message = "æ¨é失败ï¼" + ex.Message }; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |