在线人员获取接口
parent
c462dad962
commit
a3cef7ac2a
|
|
@ -39,6 +39,7 @@ using static Org.BouncyCastle.Math.EC.ECCurve;
|
||||||
using DocumentFormat.OpenXml.Wordprocessing;
|
using DocumentFormat.OpenXml.Wordprocessing;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using DocumentFormat.OpenXml.Vml.Wordprocessing;
|
using DocumentFormat.OpenXml.Vml.Wordprocessing;
|
||||||
|
using Infrastructure.Cache;
|
||||||
|
|
||||||
namespace OpenAuth.App.ServiceApp.FireManagement
|
namespace OpenAuth.App.ServiceApp.FireManagement
|
||||||
{
|
{
|
||||||
|
|
@ -49,9 +50,10 @@ namespace OpenAuth.App.ServiceApp.FireManagement
|
||||||
IOptions<KikvisionConfig> _options;
|
IOptions<KikvisionConfig> _options;
|
||||||
IOptions<KikvisionConfig2> _options2;
|
IOptions<KikvisionConfig2> _options2;
|
||||||
IOptions<JPushClientConfig> _jpoptions;
|
IOptions<JPushClientConfig> _jpoptions;
|
||||||
|
private ICacheContext _cacheContext;
|
||||||
|
|
||||||
public FireManagementApp(IConfiguration configuration, IOptions<KikvisionConfig> options, IOptions<KikvisionConfig2> options2,
|
public FireManagementApp(IConfiguration configuration, IOptions<KikvisionConfig> options, IOptions<KikvisionConfig2> options2,
|
||||||
IOptions<JPushClientConfig> jpoptions, ISugarUnitOfWork<SugarDbContext> unitWork,
|
IOptions<JPushClientConfig> jpoptions, ICacheContext cacheContext, ISugarUnitOfWork<SugarDbContext> unitWork,
|
||||||
ISimpleClient<FmFireclueTask> repository, IAuth auth) : base(unitWork, repository, auth)
|
ISimpleClient<FmFireclueTask> repository, IAuth auth) : base(unitWork, repository, auth)
|
||||||
{
|
{
|
||||||
_auth = auth;
|
_auth = auth;
|
||||||
|
|
@ -59,6 +61,7 @@ namespace OpenAuth.App.ServiceApp.FireManagement
|
||||||
_options2 = options2;
|
_options2 = options2;
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
_jpoptions = jpoptions;
|
_jpoptions = jpoptions;
|
||||||
|
_cacheContext = cacheContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1277,7 +1280,7 @@ namespace OpenAuth.App.ServiceApp.FireManagement
|
||||||
await db.Insertable(new FmOnOffLine
|
await db.Insertable(new FmOnOffLine
|
||||||
{
|
{
|
||||||
Id = YitIdHelper.NextId(),
|
Id = YitIdHelper.NextId(),
|
||||||
IdentifyId = user.Id,
|
IdentifyId = user.Id.ToString(),
|
||||||
OnOffTime = DateTime.Now,
|
OnOffTime = DateTime.Now,
|
||||||
Name = user.Name,
|
Name = user.Name,
|
||||||
Type = true
|
Type = true
|
||||||
|
|
@ -2435,5 +2438,145 @@ ORDER BY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region 在线人员
|
||||||
|
public async Task<TableData> GetPointByUserTypeAsync(string unitname, int type)
|
||||||
|
{
|
||||||
|
TableData data = new TableData();
|
||||||
|
using (var db = base.UnitWork.CreateContext())
|
||||||
|
{
|
||||||
|
if (type == 0)
|
||||||
|
{
|
||||||
|
List<RYResApp> reslist = new List<RYResApp>();
|
||||||
|
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<SysUser>((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<RYResApp>(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<string> createids = reslist.Select(r => r.CreateId).ToList();
|
||||||
|
var rylist = _cacheContext.Get<List<RYResApp>>("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<FmOnOffLine> userlist = new List<FmOnOffLine>();
|
||||||
|
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<SysUser>((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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
@ -26,4 +27,22 @@ namespace OpenAuth.App.ServiceApp.FireManagement.Response
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int iscontacts { get; set; }
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ using System.IO.Compression;
|
||||||
using Org.BouncyCastle.Ocsp;
|
using Org.BouncyCastle.Ocsp;
|
||||||
using DocumentFormat.OpenXml.EMMA;
|
using DocumentFormat.OpenXml.EMMA;
|
||||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||||
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
|
|
||||||
namespace OpenAuth.App.ServiceApp.FmPreventionPlanManage
|
namespace OpenAuth.App.ServiceApp.FmPreventionPlanManage
|
||||||
{
|
{
|
||||||
|
|
@ -133,28 +134,48 @@ namespace OpenAuth.App.ServiceApp.FmPreventionPlanManage
|
||||||
}
|
}
|
||||||
|
|
||||||
FmPrePlanGeom geom = new FmPrePlanGeom();
|
FmPrePlanGeom geom = new FmPrePlanGeom();
|
||||||
geom.Id= Guid.NewGuid().ToString();
|
geom.Id = Guid.NewGuid().ToString();
|
||||||
geom.PrePlanId = info.Id;
|
geom.PrePlanId = info.Id;
|
||||||
|
|
||||||
string _wktModel = req.geom;
|
string _wktModel = req.geom;
|
||||||
|
|
||||||
geom.geom = null;
|
geom.geom = null;
|
||||||
|
if (!string.IsNullOrEmpty(req.geom))
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
return new Response<bool> { 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<bool> { Result = true, Message = "操作成功" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return new Response<bool> { 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<bool> { Result = true, Message = "操作成功" };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果执行到这里,说明操作失败
|
||||||
|
return new Response<bool> { Result = false, Message = "操作失败" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ namespace OpenAuth.Repository.Domain.FireManagement
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 人员id或者对讲机account
|
/// 人员id或者对讲机account
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long IdentifyId { get; set; }
|
public string IdentifyId { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 上下线时间
|
/// 上下线时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ namespace OpenAuth.Repository.Domain.FireManagement
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 站点信息
|
/// 站点信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarTable("fm_siteinfo")]
|
[SugarTable("fm_preplangeom")]
|
||||||
public class FmPrePlanGeom
|
public class FmPrePlanGeom
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,10 @@ namespace OpenAuth.Repository.Domain
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Description("创建人")]
|
[Description("创建人")]
|
||||||
public long CreateId { get; set; }
|
public long CreateId { get; set; }
|
||||||
|
|
||||||
|
[Description("1审核,2林场管理员")]
|
||||||
|
public short Identity { get; set; }
|
||||||
|
|
||||||
[Description("加密密钥")]
|
[Description("加密密钥")]
|
||||||
public string Secretkey { get; set; }
|
public string Secretkey { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ namespace OpenAuth.Repository
|
||||||
public SugarRepositiry<FmPreventionplan> FmPreventionplan { get; set; }
|
public SugarRepositiry<FmPreventionplan> FmPreventionplan { get; set; }
|
||||||
public SugarRepositiry<FmPrePlanGeom> FmPrePlanGeom { get; set; }
|
public SugarRepositiry<FmPrePlanGeom> FmPrePlanGeom { get; set; }
|
||||||
public SugarRepositiry<FmInterphonePoint> FmInterphonePoint { get; set; }
|
public SugarRepositiry<FmInterphonePoint> FmInterphonePoint { get; set; }
|
||||||
|
public SugarRepositiry<FmOnOffLine> FmOnOffLine { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@ using OpenAuth.App.ServiceApp.FireManagement.Response;
|
||||||
using OpenAuth.Repository.Domain.FireManagement;
|
using OpenAuth.Repository.Domain.FireManagement;
|
||||||
using DocumentFormat.OpenXml.EMMA;
|
using DocumentFormat.OpenXml.EMMA;
|
||||||
using OpenAuth.Repository.Domain;
|
using OpenAuth.Repository.Domain;
|
||||||
|
using Hopetry.App.SugarModel.CommonModel;
|
||||||
|
using Yitter.IdGenerator;
|
||||||
|
|
||||||
namespace OpenAuth.WebApi.Controllers.ServiceControllers.FireManagement
|
namespace OpenAuth.WebApi.Controllers.ServiceControllers.FireManagement
|
||||||
{
|
{
|
||||||
|
|
@ -977,6 +979,27 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers.FireManagement
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
#region 在线人员获取
|
||||||
|
[HttpGet]
|
||||||
|
[AllowAnonymous]
|
||||||
|
public async Task<TableData> 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
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<key id="77f56063-5f6b-498f-949f-25a720cb0e30" version="1">
|
||||||
|
<creationDate>2026-01-30T02:03:37.7444472Z</creationDate>
|
||||||
|
<activationDate>2026-02-01T01:16:49.075783Z</activationDate>
|
||||||
|
<expirationDate>2026-04-30T02:03:37.7179563Z</expirationDate>
|
||||||
|
<descriptor deserializerType="Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">
|
||||||
|
<descriptor>
|
||||||
|
<encryption algorithm="AES_256_CBC" />
|
||||||
|
<validation algorithm="HMACSHA256" />
|
||||||
|
<masterKey p4:requiresEncryption="true" xmlns:p4="http://schemas.asp.net/2015/03/dataProtection">
|
||||||
|
<!-- Warning: the key below is in an unencrypted form. -->
|
||||||
|
<value>u3um4FFYNmyO5oSPsvUbNgiT7sD+Jj4tRRqrNTmRwsqfk5FVnTSi1DPdU6DrKpl/S7/wtdNY9jBDq28hgqGiyQ==</value>
|
||||||
|
</masterKey>
|
||||||
|
</descriptor>
|
||||||
|
</descriptor>
|
||||||
|
</key>
|
||||||
Loading…
Reference in New Issue