Browse Source

feat: commit some changes

master
fajiao 2 years ago
parent
commit
b9c2ff0398
  1. 2
      Cis.Application/Cb/Common/CbInfo.cs
  2. 3
      Cis.Application/Cb/Service/CbCameraService.cs
  3. 121
      Cis.Application/Cis.Application.xml
  4. 12
      Cis.Application/Cm/Common/CmInfo.cs
  5. 52
      Cis.Application/Cm/Entity/CmMarkLabel.cs
  6. 42
      Cis.Application/Cm/Service/CmMarkGroupService.cs
  7. 55
      Cis.Application/Cm/Service/CmMarkLabelService.cs
  8. 6
      Cis.Application/Core/Algo/MarkSearcherBase.cs
  9. 9
      Cis.Application/Core/Api/IPtzApi.cs
  10. 198
      Cis.Application/Core/Api/PtzServerApi.cs
  11. 113
      Cis.Application/Core/Center/CameraDataCenter.cs
  12. 22
      Cis.Application/Core/Common/Options.cs
  13. 32
      Cis.Application/Core/Entity/CameraCalcInfo.cs
  14. 22
      Cis.Application/Core/Service/MarkSearchService.cs
  15. 1
      Cis.Application/GlobalUsings.cs
  16. 6
      Cis.Application/Startup.cs
  17. 2
      Cis.Application/Sys/Common/SysInfo.cs
  18. 41
      Cis.Application/Sys/Service/SysDictDataService.cs
  19. 43
      Cis.Application/Sys/Service/SysDictTypeService.cs
  20. 29
      Cis.Application/Tb/Common/TbInfo.cs
  21. 28
      Cis.Application/Tb/Entity/TbPtzCamera.cs
  22. 51
      Cis.Application/Tb/Service/TbPtzCameraService.cs
  23. 5
      Cis.Core/Cis.Core.csproj
  24. 168
      Cis.Core/Cis.Core.xml
  25. 43
      Cis.Core/CoreConfig.json
  26. 0
      Cis.Core/Entity/RespParamProvider.cs
  27. 22
      Cis.Web.Core/Startup.cs
  28. 4
      Cis.Web.Entry/Cis.Web.Entry.csproj
  29. BIN
      Cis.Web.Entry/wwwroot/images/logo.png

2
Cis.Application/Cb/Common/CbInfo.cs

@ -22,7 +22,7 @@ public class CbInfo
#region Database Info #region Database Info
/// <summary> /// <summary>
/// 数据库 /// 数据库标识
/// </summary> /// </summary>
public const string DbName = SqlSugarConst.DefaultConfigId; public const string DbName = SqlSugarConst.DefaultConfigId;

3
Cis.Application/Cb/Service/CbCameraService.cs

@ -1,5 +1,4 @@
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using System.Runtime.InteropServices;
namespace Cis.Application.Cb; namespace Cis.Application.Cb;
@ -22,7 +21,7 @@ public class CbCameraService : IDynamicApiController, ITransient
return entity; return entity;
} }
public async Task<List<CbCamera>> GetList(string queryJson) public async Task<List<CbCamera>> GetList(string queryJson = "")
{ {
JObject queryObj = queryJson.ToJObject(); JObject queryObj = queryJson.ToJObject();
List<CbCamera> list = await _cbCameraRep.AsQueryable() List<CbCamera> list = await _cbCameraRep.AsQueryable()

121
Cis.Application/Cis.Application.xml

@ -21,7 +21,7 @@
</member> </member>
<member name="F:Cis.Application.Cb.CbInfo.DbName"> <member name="F:Cis.Application.Cb.CbInfo.DbName">
<summary> <summary>
数据库 数据库标识
</summary> </summary>
</member> </member>
<member name="F:Cis.Application.Cb.CbInfo.CbCameraTbName"> <member name="F:Cis.Application.Cb.CbInfo.CbCameraTbName">
@ -86,7 +86,7 @@
</member> </member>
<member name="F:Cis.Application.Cm.CmInfo.DbName"> <member name="F:Cis.Application.Cm.CmInfo.DbName">
<summary> <summary>
数据库 数据库标识
</summary> </summary>
</member> </member>
<member name="F:Cis.Application.Cm.CmInfo.CmMarkGroupTbName"> <member name="F:Cis.Application.Cm.CmInfo.CmMarkGroupTbName">
@ -99,6 +99,16 @@
CmMarkGroup 表描述 CmMarkGroup 表描述
</summary> </summary>
</member> </member>
<member name="F:Cis.Application.Cm.CmInfo.CmMarkLabelTbName">
<summary>
CmMarkLabel 表名
</summary>
</member>
<member name="F:Cis.Application.Cm.CmInfo.CmMarkLabelTbDesc">
<summary>
CmMarkLabel 表描述
</summary>
</member>
<member name="T:Cis.Application.Cm.CmMarkGroup"> <member name="T:Cis.Application.Cm.CmMarkGroup">
<summary> <summary>
标记分组表 标记分组表
@ -119,11 +129,106 @@
备注 备注
</summary> </summary>
</member> </member>
<member name="T:Cis.Application.Cm.CmMarkLabel">
<summary>
标记标签表
</summary>
</member>
<member name="P:Cis.Application.Cm.CmMarkLabel.Name">
<summary>
名称
</summary>
</member>
<member name="P:Cis.Application.Cm.CmMarkLabel.PanPosition">
<summary>
Pan 位置
</summary>
</member>
<member name="P:Cis.Application.Cm.CmMarkLabel.TiltPosition">
<summary>
Tilt 位置
</summary>
</member>
<member name="P:Cis.Application.Cm.CmMarkLabel.ZoomPosition">
<summary>
Zoom 位置
</summary>
</member>
<member name="P:Cis.Application.Cm.CmMarkLabel.Remark">
<summary>
备注
</summary>
</member>
<member name="P:Cis.Application.Cm.CmMarkLabel.CbCameraId">
<summary>
相机 Id
</summary>
</member>
<member name="P:Cis.Application.Cm.CmMarkLabel.CmMarkGroupId">
<summary>
标记组 Id
</summary>
</member>
<member name="T:Cis.Application.Cm.CmMarkGroupService"> <member name="T:Cis.Application.Cm.CmMarkGroupService">
<summary> <summary>
标记分组服务 标记分组服务
</summary> </summary>
</member> </member>
<member name="T:Cis.Application.Cm.CmMarkLabelService">
<summary>
标记标签服务
</summary>
</member>
<member name="T:Cis.Application.Core.PtzInfo">
<summary>
Ptz 信息
</summary>
</member>
<member name="P:Cis.Application.Core.PtzInfo.Pan">
<summary>
Pan
</summary>
</member>
<member name="P:Cis.Application.Core.PtzInfo.Tilt">
<summary>
Tilt
</summary>
</member>
<member name="P:Cis.Application.Core.PtzInfo.Zoom">
<summary>
Zoom
</summary>
</member>
<member name="T:Cis.Application.Core.IPtzApi">
<summary>
Ptz Api 接口
</summary>
</member>
<member name="T:Cis.Application.Core.PtzServerApi">
<summary>
Ptz Api
</summary>
</member>
<member name="T:Cis.Application.Core.PtzServerOptions">
<summary>
PtzServer选项
</summary>
</member>
<member name="P:Cis.Application.Core.PtzServerOptions.Type">
<summary>
服务类别
</summary>
</member>
<member name="P:Cis.Application.Core.PtzServerOptions.Ip">
<summary>
服务IP
</summary>
</member>
<member name="P:Cis.Application.Core.PtzServerOptions.Port">
<summary>
服务端口
</summary>
</member>
<member name="M:Cis.Application.Startup.ConfigureServices(Microsoft.Extensions.DependencyInjection.IServiceCollection)"> <member name="M:Cis.Application.Startup.ConfigureServices(Microsoft.Extensions.DependencyInjection.IServiceCollection)">
<summary> <summary>
配置应用所需服务,在该方法中可以添加应用所需要的功能或服务 配置应用所需服务,在该方法中可以添加应用所需要的功能或服务
@ -154,7 +259,7 @@
</member> </member>
<member name="F:Cis.Application.Sys.SysInfo.DbName"> <member name="F:Cis.Application.Sys.SysInfo.DbName">
<summary> <summary>
数据库 数据库标识
</summary> </summary>
</member> </member>
<member name="F:Cis.Application.Sys.SysInfo.SysDictTypeTbName"> <member name="F:Cis.Application.Sys.SysInfo.SysDictTypeTbName">
@ -257,5 +362,15 @@
系统字典类型服务 系统字典类型服务
</summary> </summary>
</member> </member>
<member name="F:Cis.Application.Tb.TbInfo.DbName">
<summary>
数据库标识
</summary>
</member>
<member name="F:Cis.Application.Tb.TbInfo.TbPtzCameraTbName">
<summary>
TbPtzCamera 表名
</summary>
</member>
</members> </members>
</doc> </doc>

12
Cis.Application/Cm/Common/CmInfo.cs

@ -22,7 +22,7 @@ public class CmInfo
#region Database Info #region Database Info
/// <summary> /// <summary>
/// 数据库 /// 数据库标识
/// </summary> /// </summary>
public const string DbName = SqlSugarConst.DefaultConfigId; public const string DbName = SqlSugarConst.DefaultConfigId;
@ -40,5 +40,15 @@ public class CmInfo
/// </summary> /// </summary>
public const string CmMarkGroupTbDesc = "标记分组表"; public const string CmMarkGroupTbDesc = "标记分组表";
/// <summary>
/// CmMarkLabel 表名
/// </summary>
public const string CmMarkLabelTbName = "cm_mark_label";
/// <summary>
/// CmMarkLabel 表描述
/// </summary>
public const string CmMarkLabelTbDesc = "标记标签表";
#endregion Table Info #endregion Table Info
} }

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

@ -0,0 +1,52 @@
namespace Cis.Application.Cm;
/// <summary>
/// 标记标签表
/// </summary>
[SugarTable(CmInfo.CmMarkLabelTbName, CmInfo.CmMarkLabelTbDesc)]
[Tenant(CmInfo.DbName)]
public class CmMarkLabel : EntityBase
{
/// <summary>
/// 名称
/// </summary>
[SugarColumn(ColumnDescription = "名称", Length = 64)]
public string Name { get; set; }
/// <summary>
/// Pan 位置
/// </summary>
[SugarColumn(ColumnDescription = "Pan位置")]
public double PanPosition { get; set; }
/// <summary>
/// Tilt 位置
/// </summary>
[SugarColumn(ColumnDescription = "Tilt位置")]
public double TiltPosition { get; set; }
/// <summary>
/// Zoom 位置
/// </summary>
[SugarColumn(ColumnDescription = "Zoom位置")]
public double ZoomPosition { get; set; }
/// <summary>
/// 备注
/// </summary>
[SugarColumn(ColumnDescription = "备注", Length = 256)]
[MaxLength(256)]
public string Remark { get; set; }
/// <summary>
/// 相机 Id
/// </summary>
[SugarColumn(ColumnDescription = "相机Id")]
public long CbCameraId { get; set; }
/// <summary>
/// 标记组 Id
/// </summary>
[SugarColumn(ColumnDescription = "标记组Id")]
public long CmMarkGroupId { get; set; }
}

42
Cis.Application/Cm/Service/CmMarkGroupService.cs

@ -1,4 +1,6 @@
namespace Cis.Application.Cm; using Newtonsoft.Json.Linq;
namespace Cis.Application.Cm;
/// <summary> /// <summary>
/// 标记分组服务 /// 标记分组服务
@ -12,4 +14,42 @@ public class CmMarkGroupService : IDynamicApiController, ITransient
{ {
_cmMarkGroupRep = cmMarkGroupRep; _cmMarkGroupRep = cmMarkGroupRep;
} }
public async Task<CmMarkGroup> Get(long id)
{
CmMarkGroup entity = await _cmMarkGroupRep.GetByIdAsync(id);
return entity;
}
public async Task<List<CmMarkGroup>> GetList(string queryJson)
{
JObject queryObj = queryJson.ToJObject();
List<CmMarkGroup> list = await _cmMarkGroupRep.AsQueryable()
.ToListAsync();
return list;
}
public async Task<List<CmMarkGroup>> GetPageList(string queryJson, string pagination)
{
Pagination pageObj = pagination.ToObject<Pagination>();
JObject queryObj = queryJson.ToJObject();
List<CmMarkGroup> list = await _cmMarkGroupRep.AsQueryable()
.ToPageListAsync(pageObj.Index, pageObj.Size);
return list;
}
public async Task Add(CmMarkGroup entity)
{
await _cmMarkGroupRep.InsertAsync(entity);
}
public async Task Update(CmMarkGroup entity)
{
await _cmMarkGroupRep.UpdateAsync(entity);
}
public async Task Delete(CmMarkGroup entity)
{
await _cmMarkGroupRep.DeleteAsync(entity);
}
} }

55
Cis.Application/Cm/Service/CmMarkLabelService.cs

@ -0,0 +1,55 @@
using Newtonsoft.Json.Linq;
namespace Cis.Application.Cm;
/// <summary>
/// 标记标签服务
/// </summary>
[ApiDescriptionSettings(CmInfo.GroupName, Order = CmInfo.GroupOrder)]
public class CmMarkLabelService : IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<CmMarkLabel> _cmMarkLabelRep;
public CmMarkLabelService(SqlSugarRepository<CmMarkLabel> cmMarkLabelRep)
{
_cmMarkLabelRep = cmMarkLabelRep;
}
public async Task<CmMarkLabel> Get(long id)
{
CmMarkLabel entity = await _cmMarkLabelRep.GetByIdAsync(id);
return entity;
}
public async Task<List<CmMarkLabel>> GetList(string queryJson = "")
{
JObject queryObj = queryJson.ToJObject();
List<CmMarkLabel> list = await _cmMarkLabelRep.AsQueryable()
.ToListAsync();
return list;
}
public async Task<List<CmMarkLabel>> GetPageList(string queryJson, string pagination)
{
Pagination pageObj = pagination.ToObject<Pagination>();
JObject queryObj = queryJson.ToJObject();
List<CmMarkLabel> list = await _cmMarkLabelRep.AsQueryable()
.ToPageListAsync(pageObj.Index, pageObj.Size);
return list;
}
public async Task Add(CmMarkLabel entity)
{
await _cmMarkLabelRep.InsertAsync(entity);
}
public async Task Update(CmMarkLabel entity)
{
await _cmMarkLabelRep.UpdateAsync(entity);
}
public async Task Delete(CmMarkLabel entity)
{
await _cmMarkLabelRep.DeleteAsync(entity);
}
}

6
Cis.Application/Core/Algo/MarkSearcherBase.cs

@ -0,0 +1,6 @@
namespace Cis.Application.Core;
public class MarkSearcherBase
{
}

9
Cis.Application/Core/Api/IPtzApi.cs

@ -0,0 +1,9 @@
namespace Cis.Application.Core;
/// <summary>
/// Ptz Api 接口
/// </summary>
public interface IPtzApi
{
}

198
Cis.Application/Core/Api/PtzServerApi.cs

@ -0,0 +1,198 @@
using System.Net.Sockets;
using System.Runtime.InteropServices;
namespace Cis.Application.Core;
/// <summary>
/// Ptz Api
/// </summary>
public class PtzServerApi : IPtzApi, ISingleton
{
#region Attr
private TcpClient _tcpClient { get; set; }
private NetworkStream _stream { get; set; }
#endregion Attr
public PtzServerApi()
{
PtzServerOptions options = App.GetOptions<PtzServerOptions>();
_tcpClient = new TcpClient(options.Ip, options.Port);
//创建一个 networkstream 用来写入和读取数据
_stream = _tcpClient.GetStream();
}
public RequestRealControl GetPtzInfo(int cameraId)
{
RequestRealControl realControl = new();
try
{
string recieve_string = string.Empty;
realControl.token = 666;
realControl.CameraInfo.cameraid = cameraId;
realControl.Status = true;
realControl.realControlType = RealControlType.PTZINFO_GET_;
byte[] data = StructToByte(realControl);
_stream.Write(data, 0, data.Length);
byte[] recieve_byte = new byte[_tcpClient.ReceiveBufferSize];
_stream.Read(recieve_byte, 0, (int)_tcpClient.ReceiveBufferSize);
//stream.BeginRead(recieve_byte, 0, (int)tcp_client.ReceiveBufferSize,EndRead, stream);
realControl = (RequestRealControl)BytetoStruct(recieve_byte, typeof(RequestRealControl));
if (realControl.PTZPositionInfo.FT < 0)
{
realControl.PTZPositionInfo.FT = 3600 + realControl.PTZPositionInfo.FT;
}
}
catch (Exception)
{
realControl = default;
}
return realControl;
}
public static byte[] StructToByte(object structObj)
{
//获取结构体大小
int size = Marshal.SizeOf(structObj);
byte[] data = new byte[size];
//分配内存空间
IntPtr structPtr = Marshal.AllocHGlobal(size);
// 将结构体数据复制到内存空间
Marshal.StructureToPtr(structObj, structPtr, false);
// 将内存空间的数据拷贝到byte数组
Marshal.Copy(structPtr, data, 0, size);
//释放内存
Marshal.FreeHGlobal(structPtr);
return data;
}
public static object BytetoStruct(byte[] bytes, Type type)
{
object obj = new object();
try
{
byte[] temp = bytes;
// 获取结构体大小
int size = Marshal.SizeOf(type);
if (size > bytes.Length)
return null;
// 分配结构体内存空间
IntPtr structPtr = Marshal.AllocHGlobal(size);
// 将byte数组内容拷贝到内存中
Marshal.Copy(temp, 0, structPtr, size);
// 将内存空间转化为目标结构体
obj = Marshal.PtrToStructure(structPtr, type);
//释放内存
Marshal.FreeHGlobal(structPtr);
}
catch (Exception)
{
}
return obj;
}
}
#region 与ptz服务交互使用结构体
//----------------------------------------------------------------------------------------
// 与ptz服务交互使用结构体
//----------------------------------------------------------------------------------------
//注意这个属性不能少
[StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct RequestRealControl
{
public int token;
public CameraInfo CameraInfo;
public RealControlType realControlType;
//请求时 状态 true:开始;false:结束 答复时:true:成功;其他:失败
public bool Status;
public PresentInfo PresentInfo;
public PTZPosInfo PTZPositionInfo;
//int数组,SizeConst表示数组的个数,在转换成
//byte数组前必须先初始化数组,再使用,初始化
//的数组长度必须和SizeConst一致,例test = new int[6];
//[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
//public int[] test;
}
[StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 4)]
public struct CameraInfo
{
public int cameraid;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 40)]
public char[] ip;
public ushort port;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 80)]
private char[] user;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 80)]
private char[] password;
}
[StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 4)]
public struct PresentInfo
{
public int presentNo;//预置位编号
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
private char[] PresentName; // 预置位名称
}
[StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 4)]
public struct PTZPosInfo
{
public int FP;//p信息
public int FT;//T信息
public int FZ;//Z信息
public int TitlePosMin;//描述点垂直参数min
public int ZoomPosMin;//描述点变倍参数min
public float FHorWidth;//水平宽度 精确到小数点后两位 *10000
public float FVerWidth;//垂直宽度 精确到小数点后两位 *10000
public float FFold;//zoom=1没变时的焦距 精确到小数点后两位 *100
public int CameraType;
}
public enum RealControlType
{
MOVE_UP_ = 1,
MOVE_DOWN_,
MOVE_LEFT_,
MOVE_RIGHT_,
MOVE_LEFTUP_,
MOVE_LEFTDOWN_,
MOVE_RIGHTUP_,
MOVE_RIGHTDOWN_,
ZOOM_IN_,
ZOOM_OUT_,
FOCUS_NEAR_,
FOCUS_FAR_,
IRIS_OPEN_,
IRIS_CLOSE_,
PRESET_SET_,
PRESET_CALL_,
PTZINFO_GET_,
PTZINFO_SET_
}
#endregion 与ptz服务交互使用结构体

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

@ -0,0 +1,113 @@
using Cis.Application.Cb;
using Cis.Application.Cm;
using Cis.Application.Tb;
using System.Collections.Concurrent;
namespace Cis.Application.Core;
public class CameraDataCenter
{
#region Attr
private Thread _thread { get; set; }
private List<TbPtzCamera> _tbPtzCameraList { get; set; }
private ConcurrentDictionary<string, CameraCalcInfo> _cameraPtzInfoDict { get; set; }
private readonly SqlSugarRepository<CbCamera> _cbCameraRep;
private readonly SqlSugarRepository<CmMarkLabel> _cmMarkLableRep;
private readonly SqlSugarRepository<TbPtzCamera> _tbPtzCameraRep;
private readonly PtzServerApi _ptzServerApi;
#endregion Attr
public CameraDataCenter()
{
_cbCameraRep = App.GetService<SqlSugarRepository<CbCamera>>();
_cmMarkLableRep = App.GetService<SqlSugarRepository<CmMarkLabel>>();
_tbPtzCameraRep = App.GetService<SqlSugarRepository<TbPtzCamera>>();
_ptzServerApi = App.GetService<PtzServerApi>();
Init();
}
private void Init()
{
// 初始化 tbPtzCameraList
_tbPtzCameraList = _tbPtzCameraRep.GetList();
// 根据 Ip 去重
_tbPtzCameraList = _tbPtzCameraList.Where((a, i) => _tbPtzCameraList.FindIndex(b => b.Ip == a.Ip) == i).ToList();
// 初始化 ptzInfoDict
_cameraPtzInfoDict = new ConcurrentDictionary<string, CameraCalcInfo>();
// 初始化 thread
_thread = new Thread(WorkLoop)
{
IsBackground = true// 设置后台线程
};
_thread.Start();
}
private void LazyInit()
{
// 初始化 tbPtzCameraList
_tbPtzCameraList = new();
// 初始化 ptzInfoDict
_cameraPtzInfoDict = new ConcurrentDictionary<string, CameraCalcInfo>();
// 初始化 thread
_thread = new Thread(WorkLoop)
{
IsBackground = true// 设置后台线程
};
_thread.Start();
}
#region Loop
private void WorkLoop()
{
while (true)
{
GetPtzInfoByApi();
Thread.Sleep(10000);
}
}
private void GetPtzInfoByApi()
{
foreach (TbPtzCamera item in _tbPtzCameraList)
{
RequestRealControl rrc = _ptzServerApi.GetPtzInfo(item.CameraId);
CameraCalcInfo ptzInfo = new()
{
Pan = rrc.PTZPositionInfo.FP,
Tilt = rrc.PTZPositionInfo.FT,
Zoom = rrc.PTZPositionInfo.FZ
};
_cameraPtzInfoDict[item.Ip] = ptzInfo;
}
}
private void Calc()
{
}
#endregion Loop
#region external call
public bool GetCamera(string ip)
{
return false;
}
public bool ActiveCamera(string ip)
{
return false;
}
#endregion external call
}

22
Cis.Application/Core/Common/Options.cs

@ -0,0 +1,22 @@
namespace Cis.Application.Core;
/// <summary>
/// PtzServer选项
/// </summary>
public class PtzServerOptions : IConfigurableOptions
{
/// <summary>
/// 服务类别
/// </summary>
public string Type { get; set; }
/// <summary>
/// 服务IP
/// </summary>
public string Ip { get; set; }
/// <summary>
/// 服务端口
/// </summary>
public int Port { get; set; }
}

32
Cis.Application/Core/Entity/CameraCalcInfo.cs

@ -0,0 +1,32 @@
namespace Cis.Application.Core;
/// <summary>
/// 相机 Ptz 信息
/// </summary>
public class CameraCalcInfo
{
/// <summary>
/// 图像的宽度
/// </summary>
public int ImageWidth { get; set; } = 1920;
/// <summary>
/// 图像的宽度
/// </summary>
public int ImageHeight { get; set; } = 1080;
/// <summary>
/// Pan
/// </summary>
public double Pan { get; set; }
/// <summary>
/// Tilt
/// </summary>
public double Tilt { get; set; }
/// <summary>
/// Zoom
/// </summary>
public double Zoom { get; set; }
}

22
Cis.Application/Core/Service/MarkSearchService.cs

@ -0,0 +1,22 @@
using Cis.Application.Cm;
namespace Cis.Application.Core;
[ApiDescriptionSettings(CmInfo.GroupName, Order = CmInfo.GroupOrder)]
public class MarkSearchService : IDynamicApiController, ITransient
{
#region Attr
private CameraDataCenter _cameraDataCenter { get; set; }
#endregion Attr
public MarkSearchService(CameraDataCenter cameraDataCenter)
{
_cameraDataCenter = cameraDataCenter;
}
public void ActivateCamera()
{
}
}

1
Cis.Application/GlobalUsings.cs

@ -1,5 +1,6 @@
global using Cis.Core; global using Cis.Core;
global using Furion; global using Furion;
global using Furion.ConfigurableOptions;
global using Furion.DependencyInjection; global using Furion.DependencyInjection;
global using Furion.DynamicApiController; global using Furion.DynamicApiController;
global using Microsoft.AspNetCore.Mvc; global using Microsoft.AspNetCore.Mvc;

6
Cis.Application/Startup.cs

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Builder; using Cis.Application.Core;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -13,6 +14,9 @@ public class Startup : AppStartup
/// <param name="services"></param> /// <param name="services"></param>
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.AddConfigurableOptions<PtzServerOptions>();
services.AddSingleton<CameraDataCenter>(new CameraDataCenter());
} }
/// <summary> /// <summary>

2
Cis.Application/Sys/Common/SysInfo.cs

@ -22,7 +22,7 @@ public class SysInfo
#region Database Info #region Database Info
/// <summary> /// <summary>
/// 数据库 /// 数据库标识
/// </summary> /// </summary>
public const string DbName = SqlSugarConst.DefaultConfigId; public const string DbName = SqlSugarConst.DefaultConfigId;

41
Cis.Application/Sys/Service/SysDictDataService.cs

@ -1,4 +1,6 @@
namespace Cis.Application.Sys; using Newtonsoft.Json.Linq;
namespace Cis.Application.Sys;
/// <summary> /// <summary>
/// 系统字典值服务 /// 系统字典值服务
@ -13,4 +15,41 @@ public class SysDictDataService : IDynamicApiController, ITransient
_sysDictDataRep = sysDictDataRep; _sysDictDataRep = sysDictDataRep;
} }
public async Task<SysDictData> Get(long id)
{
SysDictData entity = await _sysDictDataRep.GetByIdAsync(id);
return entity;
}
public async Task<List<SysDictData>> GetList(string queryJson)
{
JObject queryObj = queryJson.ToJObject();
List<SysDictData> list = await _sysDictDataRep.AsQueryable()
.ToListAsync();
return list;
}
public async Task<List<SysDictData>> GetPageList(string queryJson, string pagination)
{
Pagination pageObj = pagination.ToObject<Pagination>();
JObject queryObj = queryJson.ToJObject();
List<SysDictData> list = await _sysDictDataRep.AsQueryable()
.ToPageListAsync(pageObj.Index, pageObj.Size);
return list;
}
public async Task Add(SysDictData entity)
{
await _sysDictDataRep.InsertAsync(entity);
}
public async Task Update(SysDictData entity)
{
await _sysDictDataRep.UpdateAsync(entity);
}
public async Task Delete(SysDictData entity)
{
await _sysDictDataRep.DeleteAsync(entity);
}
} }

43
Cis.Application/Sys/Service/SysDictTypeService.cs

@ -1,4 +1,7 @@
namespace Cis.Application.Sys; using Cis.Application.Cm;
using Newtonsoft.Json.Linq;
namespace Cis.Application.Sys;
/// <summary> /// <summary>
/// 系统字典类型服务 /// 系统字典类型服务
@ -12,4 +15,42 @@ public class SysDictTypeService : IDynamicApiController, ITransient
{ {
_sysDictTypeRep = sysDictTypeRep; _sysDictTypeRep = sysDictTypeRep;
} }
public async Task<SysDictType> Get(long id)
{
SysDictType entity = await _sysDictTypeRep.GetByIdAsync(id);
return entity;
}
public async Task<List<SysDictType>> GetList(string queryJson)
{
JObject queryObj = queryJson.ToJObject();
List<SysDictType> list = await _sysDictTypeRep.AsQueryable()
.ToListAsync();
return list;
}
public async Task<List<SysDictType>> GetPageList(string queryJson, string pagination)
{
Pagination pageObj = pagination.ToObject<Pagination>();
JObject queryObj = queryJson.ToJObject();
List<SysDictType> list = await _sysDictTypeRep.AsQueryable()
.ToPageListAsync(pageObj.Index, pageObj.Size);
return list;
}
public async Task Add(SysDictType entity)
{
await _sysDictTypeRep.InsertAsync(entity);
}
public async Task Update(SysDictType entity)
{
await _sysDictTypeRep.UpdateAsync(entity);
}
public async Task Delete(SysDictType entity)
{
await _sysDictTypeRep.DeleteAsync(entity);
}
} }

29
Cis.Application/Tb/Common/TbInfo.cs

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Cis.Application.Tb;
public class TbInfo
{
#region Database Info
/// <summary>
/// 数据库标识
/// </summary>
public const string DbName = "serverdb";
#endregion Database Info
#region Table Info
/// <summary>
/// TbPtzCamera 表名
/// </summary>
public const string TbPtzCameraTbName = "tb_ptzcamera";
#endregion Table Info
}

28
Cis.Application/Tb/Entity/TbPtzCamera.cs

@ -0,0 +1,28 @@
namespace Cis.Application.Tb;
[SugarTable(TbInfo.TbPtzCameraTbName)]
[Tenant(TbInfo.DbName)]
public class TbPtzCamera
{
public int Id { get; set; }
public int Type { get; set; }
public string Ip { get; set; }
public int Port { get; set; }
public string User { get; set; }
public string Pass { get; set; }
public int CameraId { get; set; }
public double PanPosition { get; set; }
public double TitlePosition { get; set; }
public double ZoomPosition { get; set; }
public byte Request { get; set; }
}

51
Cis.Application/Tb/Service/TbPtzCameraService.cs

@ -0,0 +1,51 @@
using Newtonsoft.Json.Linq;
namespace Cis.Application.Tb;
public class TbPtzCameraService : ITransient
{
private readonly SqlSugarRepository<TbPtzCamera> _tbPtzCameraRep;
public TbPtzCameraService(SqlSugarRepository<TbPtzCamera> tbPtzCameraRep)
{
_tbPtzCameraRep = tbPtzCameraRep;
}
public async Task<TbPtzCamera> Get(int id)
{
TbPtzCamera entity = await _tbPtzCameraRep.GetByIdAsync(id);
return entity;
}
public async Task<List<TbPtzCamera>> GetList(string queryJson = "")
{
JObject queryObj = !string.IsNullOrEmpty(queryJson) ? queryJson.ToJObject():default;
List<TbPtzCamera> list = await _tbPtzCameraRep.AsQueryable()
.ToListAsync();
return list;
}
public async Task<List<TbPtzCamera>> GetPageList(string pagination, string queryJson = "")
{
Pagination pageObj = pagination.ToObject<Pagination>();
JObject queryObj = queryJson.ToJObject();
List<TbPtzCamera> list = await _tbPtzCameraRep.AsQueryable()
.ToPageListAsync(pageObj.Index, pageObj.Size);
return list;
}
public async Task Add(TbPtzCamera entity)
{
await _tbPtzCameraRep.InsertAsync(entity);
}
public async Task Update(TbPtzCamera entity)
{
await _tbPtzCameraRep.UpdateAsync(entity);
}
public async Task Delete(TbPtzCamera entity)
{
await _tbPtzCameraRep.DeleteAsync(entity);
}
}

5
Cis.Core/Cis.Core.csproj

@ -22,11 +22,16 @@
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.4.9" /> <PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.4.9" />
<PackageReference Include="Furion.Pure" Version="4.4.9" /> <PackageReference Include="Furion.Pure" Version="4.4.9" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.9" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.9" />
<PackageReference Include="NewLife.Core" Version="10.0.2022.1001" />
<PackageReference Include="NewLife.Redis" Version="5.0.2022.901" /> <PackageReference Include="NewLife.Redis" Version="5.0.2022.901" />
<PackageReference Include="SqlSugarCore" Version="5.1.3.1" /> <PackageReference Include="SqlSugarCore" Version="5.1.3.1" />
<PackageReference Include="StackExchange.Redis" Version="2.6.66" />
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" /> <PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
</ItemGroup> </ItemGroup>
<ItemGroup>
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties /></VisualStudio></ProjectExtensions> <ProjectExtensions><VisualStudio><UserProperties /></VisualStudio></ProjectExtensions>
</Project> </Project>

168
Cis.Core/Cis.Core.xml

@ -110,6 +110,90 @@
页码数 页码数
</summary> </summary>
</member> </member>
<member name="T:Cis.Core.RespParamProvider">
<summary>
全局规范化结果
</summary>
</member>
<member name="M:Cis.Core.RespParamProvider.OnException(Microsoft.AspNetCore.Mvc.Filters.ExceptionContext,Furion.FriendlyException.ExceptionMetadata)">
<summary>
异常返回值
</summary>
<param name="context"></param>
<param name="metadata"></param>
<returns></returns>
</member>
<member name="M:Cis.Core.RespParamProvider.OnSucceeded(Microsoft.AspNetCore.Mvc.Filters.ActionExecutedContext,System.Object)">
<summary>
成功返回值
</summary>
<param name="context"></param>
<param name="data"></param>
<returns></returns>
</member>
<member name="M:Cis.Core.RespParamProvider.OnValidateFailed(Microsoft.AspNetCore.Mvc.Filters.ActionExecutingContext,Furion.DataValidation.ValidationMetadata)">
<summary>
验证失败返回值
</summary>
<param name="context"></param>
<param name="metadata"></param>
<returns></returns>
</member>
<member name="M:Cis.Core.RespParamProvider.OnResponseStatusCodes(Microsoft.AspNetCore.Http.HttpContext,System.Int32,Furion.UnifyResult.UnifyResultSettingsOptions)">
<summary>
特定状态码返回值
</summary>
<param name="context"></param>
<param name="statusCode"></param>
<param name="unifyResultSettings"></param>
<returns></returns>
</member>
<member name="M:Cis.Core.RespParamProvider.RESTfulResult(System.Int32,System.Boolean,System.Object,System.Object)">
<summary>
返回 RESTful 风格结果集
</summary>
<param name="statusCode"></param>
<param name="succeeded"></param>
<param name="data"></param>
<param name="errors"></param>
<returns></returns>
</member>
<member name="T:Cis.Core.RespParam`1">
<summary>
全局返回结果
</summary>
<typeparam name="T"></typeparam>
</member>
<member name="P:Cis.Core.RespParam`1.Code">
<summary>
状态码
</summary>
</member>
<member name="P:Cis.Core.RespParam`1.Type">
<summary>
类型success、warning、error
</summary>
</member>
<member name="P:Cis.Core.RespParam`1.Message">
<summary>
错误信息
</summary>
</member>
<member name="P:Cis.Core.RespParam`1.Data">
<summary>
数据
</summary>
</member>
<member name="P:Cis.Core.RespParam`1.Extras">
<summary>
附加数据
</summary>
</member>
<member name="P:Cis.Core.RespParam`1.Timestamp">
<summary>
时间戳
</summary>
</member>
<member name="T:Cis.Core.CacheTypeEnum"> <member name="T:Cis.Core.CacheTypeEnum">
<summary> <summary>
缓存类型枚举 缓存类型枚举
@ -397,89 +481,5 @@
<param name="resultContext"></param> <param name="resultContext"></param>
<exception cref="T:System.NotImplementedException"></exception> <exception cref="T:System.NotImplementedException"></exception>
</member> </member>
<member name="T:Cis.Core.RespParamProvider">
<summary>
全局规范化结果
</summary>
</member>
<member name="M:Cis.Core.RespParamProvider.OnException(Microsoft.AspNetCore.Mvc.Filters.ExceptionContext,Furion.FriendlyException.ExceptionMetadata)">
<summary>
异常返回值
</summary>
<param name="context"></param>
<param name="metadata"></param>
<returns></returns>
</member>
<member name="M:Cis.Core.RespParamProvider.OnSucceeded(Microsoft.AspNetCore.Mvc.Filters.ActionExecutedContext,System.Object)">
<summary>
成功返回值
</summary>
<param name="context"></param>
<param name="data"></param>
<returns></returns>
</member>
<member name="M:Cis.Core.RespParamProvider.OnValidateFailed(Microsoft.AspNetCore.Mvc.Filters.ActionExecutingContext,Furion.DataValidation.ValidationMetadata)">
<summary>
验证失败返回值
</summary>
<param name="context"></param>
<param name="metadata"></param>
<returns></returns>
</member>
<member name="M:Cis.Core.RespParamProvider.OnResponseStatusCodes(Microsoft.AspNetCore.Http.HttpContext,System.Int32,Furion.UnifyResult.UnifyResultSettingsOptions)">
<summary>
特定状态码返回值
</summary>
<param name="context"></param>
<param name="statusCode"></param>
<param name="unifyResultSettings"></param>
<returns></returns>
</member>
<member name="M:Cis.Core.RespParamProvider.RESTfulResult(System.Int32,System.Boolean,System.Object,System.Object)">
<summary>
返回 RESTful 风格结果集
</summary>
<param name="statusCode"></param>
<param name="succeeded"></param>
<param name="data"></param>
<param name="errors"></param>
<returns></returns>
</member>
<member name="T:Cis.Core.RespParam`1">
<summary>
全局返回结果
</summary>
<typeparam name="T"></typeparam>
</member>
<member name="P:Cis.Core.RespParam`1.Code">
<summary>
状态码
</summary>
</member>
<member name="P:Cis.Core.RespParam`1.Type">
<summary>
类型success、warning、error
</summary>
</member>
<member name="P:Cis.Core.RespParam`1.Message">
<summary>
错误信息
</summary>
</member>
<member name="P:Cis.Core.RespParam`1.Data">
<summary>
数据
</summary>
</member>
<member name="P:Cis.Core.RespParam`1.Extras">
<summary>
附加数据
</summary>
</member>
<member name="P:Cis.Core.RespParam`1.Timestamp">
<summary>
时间戳
</summary>
</member>
</members> </members>
</doc> </doc>

43
Cis.Core/CoreConfig.json

@ -10,7 +10,13 @@
//"ConnectionString": "DataSource=./cis.db", //"ConnectionString": "DataSource=./cis.db",
//"DbType": "PostgreSQL", //"DbType": "PostgreSQL",
//"ConnectionString": "HOST=127.0.0.1;PORT=5432;USER ID=pgsql;PASSWORD=123456;DATABASE=cis;", //"ConnectionString": "HOST=127.0.0.1;PORT=5432;USER ID=pgsql;PASSWORD=123456;DATABASE=cis;",
"EnableInitDb": false, // "EnableInitDb": false //
},
{
"ConfigId": "serverdb",
"DbType": "MySql",
"ConnectionString": "Data Source=127.0.0.1;port=3306;User ID=root;Password=123456;Database=serverdb;pooling=true;sslmode=none;CharSet=utf8;",
"EnableInitDb": false //
} }
] ]
}, },
@ -18,8 +24,13 @@
"CacheType": "Redis", // MemoryRedis "CacheType": "Redis", // MemoryRedis
"RedisConnectionString": "127.0.0.1:6379;password=123456;db=2" "RedisConnectionString": "127.0.0.1:6379;password=123456;db=2"
}, },
"SnowId": { "PTZServer": {
"WorkerId": 5 // 0~63,1 "Type": "",
"Ip": "127.0.0.1",
"Port": "7022"
},
"AppSettings": {
"InjectSpecificationDocument": true // Swagger
}, },
"SpecificationDocumentSettings": { "SpecificationDocumentSettings": {
"DocumentTitle": "Swagger", // "DocumentTitle": "Swagger", //
@ -33,8 +44,30 @@
"AsLowerCamelCase": true, // "AsLowerCamelCase": true, //
"UrlParameterization": true // "UrlParameterization": true //
}, },
"AppSettings": { "Logging": {
"InjectSpecificationDocument": true // Swagger "LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
},
"File": {
"Enabled": true, //
"FileName": "logs/{0:yyyyMMdd}_{1}.log", //
"Append": true, //
// "MinimumLevel": "Information", //
"FileSizeLimitBytes": 10485760, // 10M=10*1024*1024
"MaxRollingFiles": 30 // 30
},
"Monitor": {
"GlobalEnabled": true, //
"IncludeOfMethods": [], // GlobalEnabled=false
"ExcludeOfMethods": [], // GlobalEnabled=true
"BahLogLevel": "Information", // Oops.Oh Oops.Bah
"WithReturnValue": true, // true
"ReturnValueThreshold": 0 // 0
}
},
"SnowId": {
"WorkerId": 5 // 0~63,1
}, },
"CorsAccessorSettings": { "CorsAccessorSettings": {
"WithExposedHeaders": [ "WithExposedHeaders": [

0
Cis.Core/Util/RespParamProvider.cs → Cis.Core/Entity/RespParamProvider.cs

22
Cis.Web.Core/Startup.cs

@ -4,12 +4,16 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
using System;
using System.IO;
using Yitter.IdGenerator; using Yitter.IdGenerator;
namespace Cis.Web.Core; namespace Cis.Web.Core;
[AppStartup(1000)]
public class Startup : AppStartup public class Startup : AppStartup
{ {
/// <summary> /// <summary>
@ -39,12 +43,30 @@ public class Startup : AppStartup
.AddNewtonsoftJson(options => .AddNewtonsoftJson(options =>
{ {
options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); // 首字母小写(驼峰样式) options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); // 首字母小写(驼峰样式)
options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local;// 设置本地时区
options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss"; // 时间格式化 options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss"; // 时间格式化
options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; // 忽略循环引用 options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; // 忽略循环引用
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; // 忽略空值 options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; // 忽略空值
}) })
.AddInjectWithUnifyResult<RespParamProvider>(); .AddInjectWithUnifyResult<RespParamProvider>();
// 日志记录
if (App.GetConfig<bool>("Logging:File:Enabled")) // 日志写入文件
{
Array.ForEach(new[] { LogLevel.Information, LogLevel.Warning, LogLevel.Error }, logLevel =>
{
services.AddFileLogging(options =>
{
options.FileNameRule = fileName => string.Format(fileName, DateTime.Now, logLevel.ToString()); // 每天创建一个文件
options.WriteFilter = logMsg => logMsg.LogLevel == logLevel; // 日志级别
options.HandleWriteError = (writeError) => // 写入失败时启用备用文件
{
writeError.UseRollbackFileName(Path.GetFileNameWithoutExtension(writeError.CurrentFileName) + "-oops" + Path.GetExtension(writeError.CurrentFileName));
};
});
});
}
// 配置雪花Id算法机器码 // 配置雪花Id算法机器码
YitIdHelper.SetIdGenerator(new IdGeneratorOptions YitIdHelper.SetIdGenerator(new IdGeneratorOptions
{ {

4
Cis.Web.Entry/Cis.Web.Entry.csproj

@ -10,8 +10,4 @@
<ProjectReference Include="..\Cis.Web.Core\Cis.Web.Core.csproj" /> <ProjectReference Include="..\Cis.Web.Core\Cis.Web.Core.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="wwwroot\images\" />
</ItemGroup>
</Project> </Project>

BIN
Cis.Web.Entry/wwwroot/images/logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Loading…
Cancel
Save