From a3cef7ac2a163e804e203b2690eb102f9f6af171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=81=20=E4=BB=BB?= Date: Fri, 30 Jan 2026 11:11:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E4=BA=BA=E5=91=98=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FireManagement/FireManagementApp.cs | 147 +++++++++++++++++- .../FireManagement/Response/RYResApp.cs | 19 +++ .../FmPreventionPlanApp.cs | 45 ++++-- .../Domain/FireManagement/FmOnOffLine.cs | 2 +- .../Domain/FireManagement/FmPrePlanGeom.cs | 2 +- OpenAuth.Repository/Domain/SysUser.cs | 4 + OpenAuth.Repository/SugarDbContext.cs | 1 + .../FireManagementController.cs | 23 +++ ...y-77f56063-5f6b-498f-949f-25a720cb0e30.xml | 16 ++ 9 files changed, 243 insertions(+), 16 deletions(-) create mode 100644 OpenAuth.WebApi/temp-keys/key-77f56063-5f6b-498f-949f-25a720cb0e30.xml diff --git a/OpenAuth.App/ServiceApp/FireManagement/FireManagementApp.cs b/OpenAuth.App/ServiceApp/FireManagement/FireManagementApp.cs index cf43553..4a31aa3 100644 --- a/OpenAuth.App/ServiceApp/FireManagement/FireManagementApp.cs +++ b/OpenAuth.App/ServiceApp/FireManagement/FireManagementApp.cs @@ -39,6 +39,7 @@ using static Org.BouncyCastle.Math.EC.ECCurve; using DocumentFormat.OpenXml.Wordprocessing; using Newtonsoft.Json.Linq; using DocumentFormat.OpenXml.Vml.Wordprocessing; +using Infrastructure.Cache; namespace OpenAuth.App.ServiceApp.FireManagement { @@ -49,9 +50,10 @@ namespace OpenAuth.App.ServiceApp.FireManagement IOptions _options; IOptions _options2; IOptions _jpoptions; + private ICacheContext _cacheContext; public FireManagementApp(IConfiguration configuration, IOptions options, IOptions options2, - IOptions jpoptions, ISugarUnitOfWork unitWork, + IOptions jpoptions, ICacheContext cacheContext, ISugarUnitOfWork unitWork, ISimpleClient repository, IAuth auth) : base(unitWork, repository, auth) { _auth = auth; @@ -59,6 +61,7 @@ namespace OpenAuth.App.ServiceApp.FireManagement _options2 = options2; _configuration = configuration; _jpoptions = jpoptions; + _cacheContext = cacheContext; } /// @@ -1277,7 +1280,7 @@ namespace OpenAuth.App.ServiceApp.FireManagement await db.Insertable(new FmOnOffLine { Id = YitIdHelper.NextId(), - IdentifyId = user.Id, + IdentifyId = user.Id.ToString(), OnOffTime = DateTime.Now, Name = user.Name, Type = true @@ -2435,5 +2438,145 @@ ORDER BY } } #endregion + + + #region 在线人员 + public async Task GetPointByUserTypeAsync(string unitname, int type) + { + TableData data = new TableData(); + using (var db = base.UnitWork.CreateContext()) + { + if (type == 0) + { + List reslist = new List(); + var info = await db.FmInterphonePoint.AsQueryable() + .Where(a => a.time.AddMinutes(20) > DateTime.Now) + .Select((a) => new RYResApp + { + CreateId = a.account, + Name = string.IsNullOrEmpty(a.username) ? a.account : a.username, + Lat = a.lat.ToString(), + Lng = a.lng.ToString(), + CreateTime = a.time, + Type = "对讲机", + Phone = string.IsNullOrEmpty(a.phone) ? a.account : a.phone, + top = a.top, + UnitName = "", + iscontacts = a.iscontacts, + }).ToListAsync(); + + var userinfo = await db.FmUserPoint.AsQueryable() + .LeftJoin((a, b) => a.CreateId == b.Id) + .Where((a, b) => a.CreateTime.AddMinutes(2) > DateTime.Now) + .Select((a, b) => new RYResApp + { + CreateId = a.CreateId.ToString(), + Name = b.Name, + Lat = a.Lat, + Lng = a.Lng, + CreateTime = a.CreateTime, + Phone = b.Account, + Identity = b.Identity, + top = a.Top, + iscontacts = a.IsContacts, + UnitName = b.UnitName == null ? "" : b.UnitName + }) + .Mapper(a => a.Type = ((UserIdentity)a.Identity).GetDescription()) + .ToListAsync(); + reslist = info.Union(userinfo).Where(r => r.Name != null).OrderByDescending(r => r.top).ToList(); + if (!string.IsNullOrEmpty(unitname)) + { + reslist = reslist.Where(r => r.UnitName == unitname).ToList(); + } + data.data = reslist; + data.count = reslist.Count; + + //查询是否有下线人员 + List createids = reslist.Select(r => r.CreateId).ToList(); + var rylist = _cacheContext.Get>("renyuanxinxi"); + if (rylist != null) + { + var leave = rylist.Where(r => !createids.Contains(r.CreateId)).Select(r => new + { + identifyid = r.CreateId, + name = r.Name + }).ToList(); + if (leave.Count > 0) + { + //添加上下线记录 + List userlist = new List(); + foreach (var item in leave) + { + var onoff = new FmOnOffLine + { + Id = YitIdHelper.NextId(), + IdentifyId = item.identifyid, + OnOffTime = DateTime.Now, + Name = item.name, + Type = false + }; + userlist.Add(onoff); + } + await db.FmOnOffLine.InsertRangeAsync(userlist); + //websocket推送下线消息 + WebSocketModel wsModel = new WebSocketModel + { + Module = "下线", + Data = leave + }; + //SendWebSocketMessage(wsModel); + sendsocket(wsModel); + } + } + _cacheContext.Set("renyuanxinxi", info, DateTime.Now.AddDays(1)); + + } + else if (type == 10) + { + var info = await db.FmInterphonePoint.AsQueryable() + .Where(a => a.time.AddMinutes(20) > DateTime.Now) + .Select((a) => new RYResApp + { + CreateId = a.account, + Name = string.IsNullOrEmpty(a.username) ? a.account : a.username, + Lat = a.lat.ToString(), + Lng = a.lng.ToString(), + CreateTime = a.time, + Type = "对讲机", + Phone = string.IsNullOrEmpty(a.phone) ? a.account : a.phone, + top = a.top, + iscontacts = a.iscontacts, + }).ToListAsync(); + data.data = info; + data.count = info.Count; + } + else + { + string typename = ((UserIdentity)type).GetDescription(); + var userinfo = await db.FmUserPoint.AsQueryable() + .LeftJoin((a, b) => a.CreateId == b.Id) + .Where((a, b) => a.CreateTime.AddMinutes(2) > DateTime.Now) + .Where((a, b) => b.Identity == type) + .WhereIF(!string.IsNullOrEmpty(unitname), (a, b) => b.UnitName == unitname) + .Select((a, b) => new RYResApp + { + CreateId = a.CreateId.ToString(), + Name = b.Name, + Lat = a.Lat, + Lng = a.Lng, + CreateTime = a.CreateTime, + Type = typename, + Phone = b.Account, + top = a.Top, + iscontacts = a.IsContacts, + UnitName = b.UnitName + }).ToListAsync(); + data.data = userinfo; + data.count = userinfo.Count; + } + } + return data; + } + #endregion } } \ No newline at end of file diff --git a/OpenAuth.App/ServiceApp/FireManagement/Response/RYResApp.cs b/OpenAuth.App/ServiceApp/FireManagement/Response/RYResApp.cs index cb6c937..bcdb5f5 100644 --- a/OpenAuth.App/ServiceApp/FireManagement/Response/RYResApp.cs +++ b/OpenAuth.App/ServiceApp/FireManagement/Response/RYResApp.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -26,4 +27,22 @@ namespace OpenAuth.App.ServiceApp.FireManagement.Response /// public int iscontacts { get; set; } } + + public enum UserIdentity + { + [Description("系统管理员")] + XTGLY = 0, + [Description("管理员")] + GLY = 1, + [Description("护林员")] + HLY = 2, + [Description("巡查员")] + XCY = 3, + [Description("网格员")] + WGY = 4, + [Description("其他")] + QT = 5, + [Description("国有林场护林员")] + GYLCHLY = 6 + } } diff --git a/OpenAuth.App/ServiceApp/FmPreventionPlanManage/FmPreventionPlanApp.cs b/OpenAuth.App/ServiceApp/FmPreventionPlanManage/FmPreventionPlanApp.cs index de6c7e6..b2fd618 100644 --- a/OpenAuth.App/ServiceApp/FmPreventionPlanManage/FmPreventionPlanApp.cs +++ b/OpenAuth.App/ServiceApp/FmPreventionPlanManage/FmPreventionPlanApp.cs @@ -24,6 +24,7 @@ using System.IO.Compression; using Org.BouncyCastle.Ocsp; using DocumentFormat.OpenXml.EMMA; using DocumentFormat.OpenXml.Office2010.Excel; +using DocumentFormat.OpenXml.Spreadsheet; namespace OpenAuth.App.ServiceApp.FmPreventionPlanManage { @@ -133,28 +134,48 @@ namespace OpenAuth.App.ServiceApp.FmPreventionPlanManage } FmPrePlanGeom geom = new FmPrePlanGeom(); - geom.Id= Guid.NewGuid().ToString(); + geom.Id = Guid.NewGuid().ToString(); geom.PrePlanId = info.Id; string _wktModel = req.geom; geom.geom = null; - - StringBuilder geomSql = new StringBuilder(); - geomSql.AppendFormat( - $" update lasa_shpdata set \"Geom\" = st_geomfromtext('{_wktModel}',4326) where \"Id\" = '{geom.Id}'"); - var flag=await db.FmPreventionplan.InsertAsync(info); - var geomflag = await db.FmPrePlanGeom.InsertAsync(geom); - var flag1= db.Db.Ado.ExecuteCommandAsync(geomSql.ToString()); - - if (db.Commit()&&flag&&geomflag) + if (!string.IsNullOrEmpty(req.geom)) { - return new Response { Result = true, Message = "操作成功" }; + StringBuilder geomSql = new StringBuilder(); + geomSql.AppendFormat( + $" update fm_preplangeom set \"geom\" = st_geomfromtext('{_wktModel}',4326) where \"Id\" = '{geom.Id}'"); + var flag = await db.FmPreventionplan.InsertAsync(info); + var geomflag = await db.FmPrePlanGeom.InsertAsync(geom); + // 然后更新几何字段 + if (flag && geomflag) + { + // 等待异步操作完成 + var affectedRows = await db.Db.Ado.ExecuteCommandAsync(geomSql.ToString()); + + if (affectedRows > 0) + { + if (db.Commit()) + { + return new Response { Result = true, Message = "操作成功" }; + } + } + } } else { - return new Response { Result = false, Message = "操作失败" }; + // 如果没有几何数据,只插入主记录 + var flag = await db.FmPreventionplan.InsertAsync(info); + var geomFlag = await db.FmPrePlanGeom.InsertAsync(geom); + + if (flag && geomFlag && db.Commit()) + { + return new Response { Result = true, Message = "操作成功" }; + } } + + // 如果执行到这里,说明操作失败 + return new Response { Result = false, Message = "操作失败" }; } } diff --git a/OpenAuth.Repository/Domain/FireManagement/FmOnOffLine.cs b/OpenAuth.Repository/Domain/FireManagement/FmOnOffLine.cs index d1ec430..cd5d663 100644 --- a/OpenAuth.Repository/Domain/FireManagement/FmOnOffLine.cs +++ b/OpenAuth.Repository/Domain/FireManagement/FmOnOffLine.cs @@ -17,7 +17,7 @@ namespace OpenAuth.Repository.Domain.FireManagement /// /// 人员id或者对讲机account /// - public long IdentifyId { get; set; } + public string IdentifyId { get; set; } /// /// 上下线时间 /// diff --git a/OpenAuth.Repository/Domain/FireManagement/FmPrePlanGeom.cs b/OpenAuth.Repository/Domain/FireManagement/FmPrePlanGeom.cs index a62a15e..1cac81d 100644 --- a/OpenAuth.Repository/Domain/FireManagement/FmPrePlanGeom.cs +++ b/OpenAuth.Repository/Domain/FireManagement/FmPrePlanGeom.cs @@ -10,7 +10,7 @@ namespace OpenAuth.Repository.Domain.FireManagement /// /// 站点信息 /// - [SugarTable("fm_siteinfo")] + [SugarTable("fm_preplangeom")] public class FmPrePlanGeom { /// diff --git a/OpenAuth.Repository/Domain/SysUser.cs b/OpenAuth.Repository/Domain/SysUser.cs index 79b9630..0320477 100644 --- a/OpenAuth.Repository/Domain/SysUser.cs +++ b/OpenAuth.Repository/Domain/SysUser.cs @@ -55,6 +55,10 @@ namespace OpenAuth.Repository.Domain /// [Description("创建人")] public long CreateId { get; set; } + + [Description("1审核,2林场管理员")] + public short Identity { get; set; } + [Description("加密密钥")] public string Secretkey { get; set; } /// diff --git a/OpenAuth.Repository/SugarDbContext.cs b/OpenAuth.Repository/SugarDbContext.cs index 5da7711..0d379be 100644 --- a/OpenAuth.Repository/SugarDbContext.cs +++ b/OpenAuth.Repository/SugarDbContext.cs @@ -88,6 +88,7 @@ namespace OpenAuth.Repository public SugarRepositiry FmPreventionplan { get; set; } public SugarRepositiry FmPrePlanGeom { get; set; } public SugarRepositiry FmInterphonePoint { get; set; } + public SugarRepositiry FmOnOffLine { get; set; } #endregion diff --git a/OpenAuth.WebApi/Controllers/ServiceControllers/FireManagement/FireManagementController.cs b/OpenAuth.WebApi/Controllers/ServiceControllers/FireManagement/FireManagementController.cs index 123d9ef..a0b9bdd 100644 --- a/OpenAuth.WebApi/Controllers/ServiceControllers/FireManagement/FireManagementController.cs +++ b/OpenAuth.WebApi/Controllers/ServiceControllers/FireManagement/FireManagementController.cs @@ -12,6 +12,8 @@ using OpenAuth.App.ServiceApp.FireManagement.Response; using OpenAuth.Repository.Domain.FireManagement; using DocumentFormat.OpenXml.EMMA; using OpenAuth.Repository.Domain; +using Hopetry.App.SugarModel.CommonModel; +using Yitter.IdGenerator; namespace OpenAuth.WebApi.Controllers.ServiceControllers.FireManagement { @@ -977,6 +979,27 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers.FireManagement } return response; } + #endregion + #region 在线人员获取 + [HttpGet] + [AllowAnonymous] + public async Task GetPointByUserTypeAsync(string unitname, int type) + { + TableData response = new TableData(); + try + { + return await _app.GetPointByUserTypeAsync(unitname,type); + } + catch (Exception ex) + { + response.code = 500; + response.msg = ex.InnerException?.Message ?? ex.Message; + } + return response; + } + + #endregion + } } diff --git a/OpenAuth.WebApi/temp-keys/key-77f56063-5f6b-498f-949f-25a720cb0e30.xml b/OpenAuth.WebApi/temp-keys/key-77f56063-5f6b-498f-949f-25a720cb0e30.xml new file mode 100644 index 0000000..89b6c16 --- /dev/null +++ b/OpenAuth.WebApi/temp-keys/key-77f56063-5f6b-498f-949f-25a720cb0e30.xml @@ -0,0 +1,16 @@ + + + 2026-01-30T02:03:37.7444472Z + 2026-02-01T01:16:49.075783Z + 2026-04-30T02:03:37.7179563Z + + + + + + + u3um4FFYNmyO5oSPsvUbNgiT7sD+Jj4tRRqrNTmRwsqfk5FVnTSi1DPdU6DrKpl/S7/wtdNY9jBDq28hgqGiyQ== + + + + \ No newline at end of file