去掉无关数据,更新设备时候,重新连接

This commit is contained in:
yanghongwei 2025-03-31 23:06:20 +08:00
parent a17cf970cb
commit c5ca6696eb
6 changed files with 10 additions and 45 deletions

View File

@ -97,7 +97,12 @@ namespace LY.App.Device
}
}
public async void RemoveDevice(long deviceId)
/// <summary>
/// 删除
/// </summary>
/// <param name="deviceId"></param>
/// <returns></returns>
public async Task RemoveDevice(long deviceId)
{
if (_devices.TryRemove(deviceId, out var device))
{

View File

@ -6,6 +6,7 @@ namespace LY.App.Model
{
[SplitTable(SplitType.Month)]//按年分表 (自带分表支持 年、季、月、周、日)
[SugarTable("ly_alarm_{year}{month}{day}")]
[SugarIndex("index_ly_alarm_batchid", nameof(BatchId), OrderByType.Asc)]
public class Alarm : BaseEntity
{
/// <summary>

View File

@ -12,14 +12,6 @@ namespace LY.App.Model
/// </summary>
public class MultPolygonEntity : BaseEntity
{
/// <summary>
/// 空间位置点数据
/// </summary>
[SugarColumn(QuerySql = "st_astext(location)", ColumnDataType = "point", ColumnName = "location",
UpdateSql = "ST_GeomFromText(@location)",
InsertSql = "ST_GeomFromText(@location)", IsNullable = true, ColumnDescription = "空间位置点数据")]
[JsonIgnore]
public string? Location { get; set; } // Geometry
/// <summary>
/// 空间面数据
/// </summary>
@ -32,16 +24,6 @@ namespace LY.App.Model
[SugarColumn(IsIgnore = true)]
public string RegionJson { get; set; }
/// <summary>
/// 空间位置点经度
/// </summary>
public double Lon { get; set; }
/// <summary>
/// 空间位置点纬度
/// </summary>
public double Lat { get; set; }
/// <summary>
/// 空间位置点Json数据
/// </summary>
@ -68,18 +50,6 @@ namespace LY.App.Model
Region = region.AsText();
}
}
/// <summary>
/// 设置空间位置点
/// </summary>
/// <param name="lon"></param>
/// <param name="lat"></param>
public void SetLocation(double lon, double lat)
{
Lon = lon;
Lat = lat;
SetLocation();
}
/// <summary>
/// 设置空间位置点
/// </summary>
@ -96,12 +66,5 @@ namespace LY.App.Model
}
}
}
/// <summary>
/// 设置空间位置点
/// </summary>
public void SetLocation()
{
Location = $"POINT({Lon} {Lat})";
}
}
}

View File

@ -93,6 +93,8 @@ namespace LY.App.Service
{
var entity = input.Adapt<DeviceEntity>();
await _db.Updateable(entity).ExecuteCommandAsync();
await deviceManager.RemoveDevice(entity.Id);
await AddDevice2Manager(entity);
return new ApiResult()
{
code = 0,
@ -109,7 +111,7 @@ namespace LY.App.Service
var entity = await _db.Queryable<DeviceEntity>().FirstAsync(s => s.Id == Id);
entity.IsDeleted = true;
await _db.Updateable(entity).ExecuteCommandAsync();
deviceManager.RemoveDevice(entity.Id);
await deviceManager.RemoveDevice(entity.Id);
return new ApiResult()
{
code = 0,

View File

@ -48,7 +48,6 @@ namespace LY.App.Service
}
}
// 位置
entity.SetLocation();
await _db.Insertable(entity).ExecuteReturnSnowflakeIdAsync();
return new ApiResult(true, "添加成功");
}
@ -69,8 +68,6 @@ namespace LY.App.Service
return new ApiResult(false, "空间数据无效");
}
}
// 位置
entity.SetLocation();
await _db.Updateable(entity).ExecuteCommandAsync();
return new ApiResult(true, "添加成功");
}

View File

@ -242,9 +242,6 @@ namespace LY.App.Service
var entity = input.Adapt<UserEntity>();
await _db.Updateable(entity).UpdateColumns(it => new
{
it.UpdatePwdTime,
it.Password,
it.Email,
it.IsAdmin
}).ExecuteCommandAsync();
return null;