去掉无关数据,更新设备时候,重新连接
This commit is contained in:
parent
a17cf970cb
commit
c5ca6696eb
|
|
@ -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))
|
if (_devices.TryRemove(deviceId, out var device))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ namespace LY.App.Model
|
||||||
{
|
{
|
||||||
[SplitTable(SplitType.Month)]//按年分表 (自带分表支持 年、季、月、周、日)
|
[SplitTable(SplitType.Month)]//按年分表 (自带分表支持 年、季、月、周、日)
|
||||||
[SugarTable("ly_alarm_{year}{month}{day}")]
|
[SugarTable("ly_alarm_{year}{month}{day}")]
|
||||||
|
[SugarIndex("index_ly_alarm_batchid", nameof(BatchId), OrderByType.Asc)]
|
||||||
public class Alarm : BaseEntity
|
public class Alarm : BaseEntity
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,6 @@ namespace LY.App.Model
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MultPolygonEntity : BaseEntity
|
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>
|
||||||
/// 空间面数据
|
/// 空间面数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -32,16 +24,6 @@ namespace LY.App.Model
|
||||||
[SugarColumn(IsIgnore = true)]
|
[SugarColumn(IsIgnore = true)]
|
||||||
public string RegionJson { get; set; }
|
public string RegionJson { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 空间位置点经度
|
|
||||||
/// </summary>
|
|
||||||
public double Lon { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 空间位置点纬度
|
|
||||||
/// </summary>
|
|
||||||
public double Lat { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 空间位置点Json数据
|
/// 空间位置点Json数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -68,18 +50,6 @@ namespace LY.App.Model
|
||||||
Region = region.AsText();
|
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>
|
||||||
/// 设置空间位置点
|
/// 设置空间位置点
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -96,12 +66,5 @@ namespace LY.App.Model
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// 设置空间位置点
|
|
||||||
/// </summary>
|
|
||||||
public void SetLocation()
|
|
||||||
{
|
|
||||||
Location = $"POINT({Lon} {Lat})";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,8 @@ namespace LY.App.Service
|
||||||
{
|
{
|
||||||
var entity = input.Adapt<DeviceEntity>();
|
var entity = input.Adapt<DeviceEntity>();
|
||||||
await _db.Updateable(entity).ExecuteCommandAsync();
|
await _db.Updateable(entity).ExecuteCommandAsync();
|
||||||
|
await deviceManager.RemoveDevice(entity.Id);
|
||||||
|
await AddDevice2Manager(entity);
|
||||||
return new ApiResult()
|
return new ApiResult()
|
||||||
{
|
{
|
||||||
code = 0,
|
code = 0,
|
||||||
|
|
@ -109,7 +111,7 @@ namespace LY.App.Service
|
||||||
var entity = await _db.Queryable<DeviceEntity>().FirstAsync(s => s.Id == Id);
|
var entity = await _db.Queryable<DeviceEntity>().FirstAsync(s => s.Id == Id);
|
||||||
entity.IsDeleted = true;
|
entity.IsDeleted = true;
|
||||||
await _db.Updateable(entity).ExecuteCommandAsync();
|
await _db.Updateable(entity).ExecuteCommandAsync();
|
||||||
deviceManager.RemoveDevice(entity.Id);
|
await deviceManager.RemoveDevice(entity.Id);
|
||||||
return new ApiResult()
|
return new ApiResult()
|
||||||
{
|
{
|
||||||
code = 0,
|
code = 0,
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,6 @@ namespace LY.App.Service
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 位置
|
// 位置
|
||||||
entity.SetLocation();
|
|
||||||
await _db.Insertable(entity).ExecuteReturnSnowflakeIdAsync();
|
await _db.Insertable(entity).ExecuteReturnSnowflakeIdAsync();
|
||||||
return new ApiResult(true, "添加成功");
|
return new ApiResult(true, "添加成功");
|
||||||
}
|
}
|
||||||
|
|
@ -69,8 +68,6 @@ namespace LY.App.Service
|
||||||
return new ApiResult(false, "空间数据无效");
|
return new ApiResult(false, "空间数据无效");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 位置
|
|
||||||
entity.SetLocation();
|
|
||||||
await _db.Updateable(entity).ExecuteCommandAsync();
|
await _db.Updateable(entity).ExecuteCommandAsync();
|
||||||
return new ApiResult(true, "添加成功");
|
return new ApiResult(true, "添加成功");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -242,9 +242,6 @@ namespace LY.App.Service
|
||||||
var entity = input.Adapt<UserEntity>();
|
var entity = input.Adapt<UserEntity>();
|
||||||
await _db.Updateable(entity).UpdateColumns(it => new
|
await _db.Updateable(entity).UpdateColumns(it => new
|
||||||
{
|
{
|
||||||
it.UpdatePwdTime,
|
|
||||||
it.Password,
|
|
||||||
it.Email,
|
|
||||||
it.IsAdmin
|
it.IsAdmin
|
||||||
}).ExecuteCommandAsync();
|
}).ExecuteCommandAsync();
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue