Browse Source

optimize: 优化运算速度,修改实体类配置,添加种子数据

master
fajiao 2 years ago
parent
commit
17e1a4c46f
  1. 5
      Cis.Application/Cb/Entity/CbCamera.cs
  2. 15
      Cis.Application/Cis.Application.xml
  3. 2
      Cis.Application/Cm/Entity/CmMarkGroup.cs
  4. 6
      Cis.Application/Cm/Entity/CmMarkLabel.cs
  5. 9
      Cis.Application/Core/Center/CameraDataCenter.cs
  6. 34
      Cis.Application/Core/Component/MarkSeacher/Seacher/MarkSearcherBase.cs
  7. 11
      Cis.Application/Sys/Entity/SysDictData.cs
  8. 7
      Cis.Application/Sys/Entity/SysDictType.cs
  9. 18
      Cis.Application/Sys/SeedData/SysDictDataSeedData.cs
  10. 13
      Cis.Application/Sys/SeedData/SysDictTypeSeedData.cs
  11. 15
      Cis.Core/Cis.Core.xml
  12. 19
      Cis.Core/Common/Enum/CacheTypeEnum.cs

5
Cis.Application/Cb/Entity/CbCamera.cs

@ -1,4 +1,6 @@
namespace Cis.Application.Cb;
using Furion.DataValidation;
namespace Cis.Application.Cb;
/// <summary>
/// 相机表
@ -19,6 +21,7 @@ public class CbCamera : EntityBase
/// </summary>
[SugarColumn(ColumnDescription = "ip地址", Length = 16)]
[Required, MaxLength(16)]
[DataValidation(ValidationTypes.IPv4)]
public string Ip { get; set; }
/// <summary>

15
Cis.Application/Cis.Application.xml

@ -669,6 +669,16 @@
<param name="zoomPos"></param>
<returns></returns>
</member>
<member name="M:Cis.Application.Core.Component.MarkSeacher.MarkSearcherBase.GetZoomTag(System.Double)">
<summary>
将计算公式存储到数据库,实现动态计算公式
https://github.com/houlongchao/HLC.Expression
https://blog.csdn.net/cxb2011/article/details/100837168
https://github.com/zz1231118/Rabbit
</summary>
<param name="zoomPos"></param>
<returns></returns>
</member>
<member name="M:Cis.Application.Core.Component.MarkSeacher.MarkSearcherBase.UpdateCameraCalcParams(EC.Helper.CameraSDK.PtzInfo)">
<summary>
更新相机计算参数
@ -759,11 +769,6 @@
字典类型Id
</summary>
</member>
<member name="P:Cis.Application.Sys.SysDictData.DictType">
<summary>
字典类型
</summary>
</member>
<member name="P:Cis.Application.Sys.SysDictData.Value">
<summary>

2
Cis.Application/Cm/Entity/CmMarkGroup.cs

@ -11,12 +11,14 @@ public class CmMarkGroup : EntityBase
/// 名称
/// </summary>
[SugarColumn(ColumnDescription = "名称", Length = 64)]
[Required]
public string Name { get; set; }
/// <summary>
/// 排序
/// </summary>
[SugarColumn(ColumnDescription = "排序")]
[Required]
public int Order { get; set; }
/// <summary>

6
Cis.Application/Cm/Entity/CmMarkLabel.cs

@ -11,6 +11,7 @@ public class CmMarkLabel : EntityBase
/// 相机 Id
/// </summary>
[SugarColumn(ColumnDescription = "相机Id")]
[Required]
public long CbCameraId { get; set; }
/// <summary>
@ -23,6 +24,7 @@ public class CmMarkLabel : EntityBase
/// 名称
/// </summary>
[SugarColumn(ColumnDescription = "名称", Length = 64)]
[Required]
public string Name { get; set; }
/// <summary>
@ -47,24 +49,28 @@ public class CmMarkLabel : EntityBase
/// 视频宽度
/// </summary>
[SugarColumn(ColumnDescription = "视频宽度")]
[Required]
public double VideoWidth { get; set; }
/// <summary>
/// 视频高度
/// </summary>
[SugarColumn(ColumnDescription = "视频高度")]
[Required]
public double VideoHeight { get; set; }
/// <summary>
/// 画布 left 距离比例
/// </summary>
[SugarColumn(ColumnDescription = "画布 left 距离比例")]
[Required]
public double CanvasLeftRatio { get; set; }
/// <summary>
/// 画布 top 距离比例
/// </summary>
[SugarColumn(ColumnDescription = "画布 top 距离比例")]
[Required]
public double CanvasTopRatio { get; set; }
/// <summary>

9
Cis.Application/Core/Center/CameraDataCenter.cs

@ -1,6 +1,4 @@
using Cis.Application.Cb;
using Cis.Application.Cm;
using Cis.Application.Core.Component.MarkSeacher;
using Cis.Application.Core.Component.MarkSeacher;
using Cis.Application.Core.Component.PtzServer;
using EC.Helper.CameraSDK;
using StackExchange.Profiling.Internal;
@ -13,10 +11,7 @@ public class CameraDataCenter : ISingleton
{
#region Attr
private readonly SqlSugarRepository<CbCamera> _cbCameraRep;
private readonly SqlSugarRepository<CmMarkLabel> _cmMarkLableRep;
private readonly IDatabase _cache;
private readonly CameraDataOptions _options;
private readonly ICameraSdkServer _cameraSdkServer;
private readonly IMarkSearcherServer _markSearcherServer;
@ -35,8 +30,6 @@ public class CameraDataCenter : ISingleton
IMarkSearcherServer markSearcherServer
)
{
_cbCameraRep = App.GetService<SqlSugarRepository<CbCamera>>();
_cmMarkLableRep = App.GetService<SqlSugarRepository<CmMarkLabel>>();
_cache = cache;
_options = App.GetOptions<CameraDataOptions>();
_cameraSdkServer = cameraSdkServer;

34
Cis.Application/Core/Component/MarkSeacher/Seacher/MarkSearcherBase.cs

@ -147,11 +147,36 @@ public abstract class MarkSearcherBase
public List<MarkLabelCalcResult> Search()
{
List<MarkLabelCalcResult> resultList = new();
if (World2CameraMatrix == null || MarkLabelCalcParamsDict.IsEmpty)
return resultList;
foreach (MarkLabelCalcParams item in MarkLabelCalcParamsDict.Values)
{
MarkLabelCalcResult labelCalcResult = SearchMarkLabel(item);
resultList.Add(labelCalcResult);
}
return resultList;
}
public async Task<List<MarkLabelCalcResult>> SearchAsync()
{
List<MarkLabelCalcResult> resultList = new();
if (World2CameraMatrix == null || MarkLabelCalcParamsDict.IsEmpty)
return resultList;
List<Task> tasks = new();
foreach (MarkLabelCalcParams item in MarkLabelCalcParamsDict.Values)
{
tasks.Add(Task.Run(() =>
{
resultList.Add(SearchMarkLabel(item));
}));
}
await Task.WhenAll(tasks);
return resultList;
}
private MarkLabelCalcResult SearchMarkLabel(MarkLabelCalcParams item)
{
Matrix<double> labelC2WMatrix = ConvertCameraToWorld(item);
Matrix<double> labelPointMatrix = new DenseMatrix(3, 1, new double[]
@ -170,14 +195,7 @@ public abstract class MarkSearcherBase
labelCalcResult = MarkLabelCalcResult.New(item.Id, false);
else
labelCalcResult = MarkLabelCalcResult.New(item.Id, true, x, y);
resultList.Add(labelCalcResult);
}
return resultList;
}
public async Task<List<MarkLabelCalcResult>> SearchAsync()
{
return await Task.Run(Search);
return labelCalcResult;
}
#endregion Calc

11
Cis.Application/Sys/Entity/SysDictData.cs

@ -4,21 +4,16 @@
/// 系统字典值表
/// </summary>
[SugarTable("sys_dict_data", "系统字典值表")]
[Tenant(SysInfo.DbName)]
public class SysDictData : EntityBase
{
/// <summary>
/// 字典类型Id
/// </summary>
[SugarColumn(ColumnDescription = "字典类型Id")]
[Required]
public long DictTypeId { get; set; }
/// <summary>
/// 字典类型
/// </summary>
[SugarColumn(IsIgnore = true)]
[Navigate(NavigateType.OneToOne, nameof(DictTypeId))]
public SysDictType DictType { get; set; }
/// <summary>
/// 值
/// </summary>
@ -37,6 +32,7 @@ public class SysDictData : EntityBase
/// 排序
/// </summary>
[SugarColumn(ColumnDescription = "排序")]
[Required]
public int Order { get; set; }
/// <summary>
@ -50,5 +46,6 @@ public class SysDictData : EntityBase
/// 状态
/// </summary>
[SugarColumn(ColumnDescription = "状态")]
[Required]
public StatusEnum Status { get; set; } = StatusEnum.Enable;
}

7
Cis.Application/Sys/Entity/SysDictType.cs

@ -1,9 +1,12 @@
namespace Cis.Application.Sys;
using Cis.Application.Cm;
namespace Cis.Application.Sys;
/// <summary>
/// 系统字典类型表
/// </summary>
[SugarTable(SysInfo.SysDictTypeTbName, SysInfo.SysDictTypeTbDesc)]
[Tenant(SysInfo.DbName)]
public class SysDictType : EntityBase
{
/// <summary>
@ -24,6 +27,7 @@ public class SysDictType : EntityBase
/// 排序
/// </summary>
[SugarColumn(ColumnDescription = "排序")]
[Required]
public int Order { get; set; }
/// <summary>
@ -37,5 +41,6 @@ public class SysDictType : EntityBase
/// 状态
/// </summary>
[SugarColumn(ColumnDescription = "状态")]
[Required]
public StatusEnum Status { get; set; } = StatusEnum.Enable;
}

18
Cis.Application/Sys/SeedData/SysDictDataSeedData.cs

@ -0,0 +1,18 @@
namespace Cis.Application.Sys.SeedData;
public class SysDictDataSeedData : ISqlSugarEntitySeedData<SysDictData>
{
public IEnumerable<SysDictData> HasData()
{
return new SysDictData[]
{
new(){Id=358769934100001, DictTypeId=358728043100001, Code="HiK", Value="1", Order=100, Remark="海康相机", Status=StatusEnum.Enable, CreateTime=DateTime.Parse("2022-11-30 00:00:00")},
new(){Id=358769934100002, DictTypeId=358728043100001, Code="DaHua", Value="2", Order=100, Remark="大华相机", Status=StatusEnum.Enable, CreateTime=DateTime.Parse("2022-11-30 00:00:00")},
new(){Id=358769934100003, DictTypeId=358728043100001, Code="YuShi", Value="3", Order=100, Remark="宇视相机", Status=StatusEnum.Enable, CreateTime=DateTime.Parse("2022-11-30 00:00:00")},
new(){Id=358769934100011, DictTypeId=358728043100002, Code="HiK", Value="8000", Order=100, Remark="海康sdk端口", Status=StatusEnum.Enable, CreateTime=DateTime.Parse("2022-11-30 00:00:00")},
new(){Id=358769934100012, DictTypeId=358728043100002, Code="DaHua", Value="37777", Order=100, Remark="大华sdk端口", Status=StatusEnum.Enable, CreateTime=DateTime.Parse("2022-11-30 00:00:00")},
new(){Id=358769934100013, DictTypeId=358728043100002, Code="YuShi", Value="8800", Order=100, Remark="宇视sdk端口", Status=StatusEnum.Enable, CreateTime=DateTime.Parse("2022-11-30 00:00:00")},
};
}
}

13
Cis.Application/Sys/SeedData/SysDictTypeSeedData.cs

@ -0,0 +1,13 @@
namespace Cis.Application.Sys.SeedData;
public class SysDictTypeSeedData : ISqlSugarEntitySeedData<SysDictType>
{
public IEnumerable<SysDictType> HasData()
{
return new SysDictType[]
{
new(){ Id=358728043100001, Name="相机类型", Code="camera_type", Order=100, Remark="相机类型", Status=StatusEnum.Enable, CreateTime=DateTime.Parse("2022-11-30 00:00:00")},
new(){ Id=358728043100002, Name="相机SDK端口", Code="camera_sdk_port", Order=100, Remark="相机SDK端口", Status=StatusEnum.Enable, CreateTime=DateTime.Parse("2022-11-30 00:00:00")},
};
}
}

15
Cis.Core/Cis.Core.xml

@ -194,21 +194,6 @@
时间戳
</summary>
</member>
<member name="T:Cis.Core.CacheTypeEnum">
<summary>
缓存类型枚举
</summary>
</member>
<member name="F:Cis.Core.CacheTypeEnum.Memory">
<summary>
内存缓存
</summary>
</member>
<member name="F:Cis.Core.CacheTypeEnum.Redis">
<summary>
Redis缓存
</summary>
</member>
<member name="T:Cis.Core.StatusEnum">
<summary>
通用状态枚举

19
Cis.Core/Common/Enum/CacheTypeEnum.cs

@ -1,19 +0,0 @@
namespace Cis.Core;
/// <summary>
/// 缓存类型枚举
/// </summary>
public enum CacheTypeEnum
{
/// <summary>
/// 内存缓存
/// </summary>
[Description("内存缓存")]
Memory,
/// <summary>
/// Redis缓存
/// </summary>
[Description("Redis缓存")]
Redis
}
Loading…
Cancel
Save