From 8ea14f10bfd3ed7a6b445d53feeb399b6bcf5d78 Mon Sep 17 00:00:00 2001 From: yanjinhui <3306209981@qq.com> Date: 星期二, 01 四月 2025 17:02:48 +0800 Subject: [PATCH] 人脸识别 --- 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Server/Controllers/System/Sys_UserController.cs | 48 ++++ 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_ISystemServices/ISys_UserService.cs | 22 ++ 项目代码/WIDESEAWCS_Server 正式/SerialPortService/FaceRecognitionServer .cs | 64 +++++ 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Server/wwwroot/image/1743492809549.png | 0 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_DTO/SerialPort/UserDTO.cs | 2 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_SystemServices/Sys_UserService.cs | 305 ++++++++++++++++++++++++--- 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Server/wwwroot/image/1743492051182.png | 0 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Server/wwwroot/image/1743492263811.png | 0 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Model/LoginInfo.cs | 5 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Server/Controllers/SerialPort/ArticleInfomController.cs | 2 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Server/Controllers/SerialPort/FaceRecognitionController .cs | 33 +++ 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Server/wwwroot/image/1743492760375.png | 0 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Common/WIDESEAWCS_Common.csproj | 2 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Server/wwwroot/image/1743492568523.png | 0 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_DTO/SerialPort/AddUserDTO.cs | 27 ++ 项目代码/WIDESEAWCS_Server 正式/SerialPortRepository/FaceRecognitionRepository.cs | 13 + 项目代码/WIDESEAWCS_Server 正式/ISerialPortService/IFaceRecognitionServer .cs | 17 + 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Server/wwwroot/image/1743492833343.png | 0 项目代码/WIDESEAWCS_Server 正式/ISerialPortRepository/IFaceRecognitionRepository.cs | 10 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Model/Models/SerialPort/Dt_FaceRecognition.cs | 27 ++ 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Model/Models/System/Sys_User.cs | 7 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Common/BaiDuFaceHelper.cs | 2 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_DTO/SerialPort/PaginationDTO.cs | 41 +++ 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Server/wwwroot/image/files | 0 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Server/wwwroot/image/1743492244242.png | 0 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Server/wwwroot/image/1743492791698.png | 0 26 files changed, 583 insertions(+), 44 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/ISerialPortRepository/IFaceRecognitionRepository.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/ISerialPortRepository/IFaceRecognitionRepository.cs" new file mode 100644 index 0000000..4c647d2 --- /dev/null +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/ISerialPortRepository/IFaceRecognitionRepository.cs" @@ -0,0 +1,10 @@ +锘縰sing WIDESEAWCS_Core.BaseRepository; +using WIDESEAWCS_Model.Models; + +namespace WIDESEA_ISerialPortRepository +{ + public interface IFaceRecognitionRepository : IRepository<Dt_FaceRecognition> + { + + } +} diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/ISerialPortService/IFaceRecognitionServer .cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/ISerialPortService/IFaceRecognitionServer .cs" new file mode 100644 index 0000000..d439f23 --- /dev/null +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/ISerialPortService/IFaceRecognitionServer .cs" @@ -0,0 +1,17 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WIDESEAWCS_Core; +using WIDESEAWCS_Core.BaseServices; +using WIDESEAWCS_DTO.Telescopic; +using WIDESEAWCS_Model.Models; + +namespace WIDESEAWCS_ITaskInfoService +{ + public interface IFaceRecognitionServer : IService<Dt_FaceRecognition> + { + WebResponseContent AddGroup(string groupName); + } +} diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/SerialPortRepository/FaceRecognitionRepository.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/SerialPortRepository/FaceRecognitionRepository.cs" new file mode 100644 index 0000000..53ba1a9 --- /dev/null +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/SerialPortRepository/FaceRecognitionRepository.cs" @@ -0,0 +1,13 @@ +锘縰sing WIDESEA_ISerialPortRepository; +using WIDESEAWCS_Core.BaseRepository; +using WIDESEAWCS_Model.Models; + +namespace WIDESEA_SerialPortRepository +{ + public class FaceRecognitionRepository : RepositoryBase<Dt_FaceRecognition>, IFaceRecognitionRepository + { + public FaceRecognitionRepository(IUnitOfWorkManage unitOfWorkManage) : base(unitOfWorkManage) + { + } + } +} diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/SerialPortService/FaceRecognitionServer .cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/SerialPortService/FaceRecognitionServer .cs" new file mode 100644 index 0000000..f4c1150 --- /dev/null +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/SerialPortService/FaceRecognitionServer .cs" @@ -0,0 +1,64 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; +using WIDESEA_ISerialPortRepository; +using WIDESEA_SerialPortRepository; +using WIDESEAWCS_Common; +using WIDESEAWCS_Core; +using WIDESEAWCS_Core.BaseServices; +using WIDESEAWCS_DTO.Telescopic; + +using WIDESEAWCS_ITaskInfoService; +using WIDESEAWCS_Model.Models; + +namespace WIDESEAWCS_TaskInfoService +{ + public class FaceRecognitionServer : ServiceBase<Dt_FaceRecognition, IFaceRecognitionRepository>, IFaceRecognitionServer + { + + public FaceRecognitionServer( IFaceRecognitionRepository BaseDal) : base(BaseDal) + { + + } + + + + + public override PageGridData<Dt_FaceRecognition> GetPageData(PageDataOptions options) + { + OrderByParameters = new Dictionary<string, SqlSugar.OrderByType> { + { nameof(Dt_ArticleInfom.ID),SqlSugar.OrderByType.Asc }, + }; + return base.GetPageData(options); + } + public WebResponseContent AddGroup(string groupName) + { + try + { + // 1. 璋冪敤鐧惧害 API 杩涜鐢ㄦ埛缁勫垱寤� + string apiResult = BaiDuFaceHelper.GroupAdd(groupName); + + // 2. 瑙f瀽 API 杩斿洖鐨� JSON 缁撴灉 + dynamic resultObj = JsonConvert.DeserializeObject(apiResult); + + if (resultObj.error_code == 0) + { + return WebResponseContent.Instance.OK("鐢ㄦ埛缁勫垱寤烘垚鍔�"); + } + else + { + return WebResponseContent.Instance.Error("鐧惧害 API 鍒涘缓澶辫触锛�" + resultObj.error_msg); + } + } + catch (Exception ex) + { + return WebResponseContent.Instance.Error("鍒涘缓鐢ㄦ埛缁勫け璐ワ細" + ex.Message); + } + } + + + } +} diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Common/BaiDuFaceHelper.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Common/BaiDuFaceHelper.cs" index 183ed5b..e6ffa23 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Common/BaiDuFaceHelper.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Common/BaiDuFaceHelper.cs" @@ -22,7 +22,7 @@ NLog.LogManager.GetCurrentClassLogger().Trace("鐧惧害浜鸿劯璇嗗埆杩斿洖锛�" + returnStr); BDToken token = JsonConvert.DeserializeObject<BDToken>(returnStr); - token.getdate = DateTime.Now.ToString(); + token.getdate = DateTime.Now.ToString(); return token.access_token; } diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Common/WIDESEAWCS_Common.csproj" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Common/WIDESEAWCS_Common.csproj" index 7fa6a8d..dcc8804 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Common/WIDESEAWCS_Common.csproj" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Common/WIDESEAWCS_Common.csproj" @@ -7,6 +7,8 @@ </PropertyGroup> <ItemGroup> + <PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> + <PackageReference Include="NLog" Version="5.4.0" /> </ItemGroup> </Project> diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_DTO/SerialPort/AddUserDTO.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_DTO/SerialPort/AddUserDTO.cs" new file mode 100644 index 0000000..5b4e875 --- /dev/null +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_DTO/SerialPort/AddUserDTO.cs" @@ -0,0 +1,27 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WIDESEAWCS_DTO.SerialPort +{ + public class AddUserDTO + { + public string username { get; set; } + + public int log_id { get; set; } + + //public string facetoken { get; set; } + + public string phoneno { get; set; } + + public int roleid { get; set; } + + public string rolename { get; set; } + + public byte enable { get; set; } + + public string path { get; set; } + } +} diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_DTO/SerialPort/PaginationDTO.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_DTO/SerialPort/PaginationDTO.cs" new file mode 100644 index 0000000..a80bc18 --- /dev/null +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_DTO/SerialPort/PaginationDTO.cs" @@ -0,0 +1,41 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WIDESEAWCS_DTO.Telescopic +{ + public class PaginationDTO + { + /// <summary> + /// 绗嚑椤� + /// </summary> + public int pageIndex { get; set; } + + /// <summary> + /// 涓�椤靛灏戜釜鏁版嵁 + /// </summary> + public int pageSize { get; set; } + + /// <summary> + /// 妯$硦鏌ヨ鐨勫瓧娈� + /// </summary> + public string? searchKeyword { get; set; } + + /// <summary> + /// 寮�濮嬫椂闂� + /// </summary> + public DateTime ?startDate { get; set; } + + + /// <summary> + /// 缁撴潫鏃堕棿 + /// </summary> + public DateTime? endDate { get; set; } + + + + + } +} diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_DTO/SerialPort/UserDTO.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_DTO/SerialPort/UserDTO.cs" index a85be62..da59c10 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_DTO/SerialPort/UserDTO.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_DTO/SerialPort/UserDTO.cs" @@ -26,7 +26,7 @@ /// <summary> /// 鐢佃瘽 /// </summary> - public string phone { get; set; } + public string phone { get; set; } /// <summary> /// 鍥剧墖 diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_ISystemServices/ISys_UserService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_ISystemServices/ISys_UserService.cs" index 0c0ac69..97f3644 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_ISystemServices/ISys_UserService.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_ISystemServices/ISys_UserService.cs" @@ -6,9 +6,11 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using WIDESEAWCS_Common; using WIDESEAWCS_Core; using WIDESEAWCS_Core.BaseServices; using WIDESEAWCS_DTO.SerialPort; +using WIDESEAWCS_DTO.Telescopic; using WIDESEAWCS_Model; using WIDESEAWCS_Model.Models; @@ -61,5 +63,25 @@ /// <param name="id"></param> /// <returns></returns> WebResponseContent Upuserbase(UserDTO userDTO); + + /// <summary> + /// 浜鸿劯璇嗗埆 + /// </summary> + /// <param name="paginationDTO"></param> + /// <returns></returns> + WebResponseContent GetUserFace(PaginationDTO paginationDTO); + + /// <summary> + /// 娣诲姞鐢ㄦ埛 + /// </summary> + /// <param name="addUserDTO"></param> + /// <returns></returns> + WebResponseContent AdduserData(AddUserDTO addUserDTO); + + WebResponseContent UpuserData(AddUserDTO addUserDTO); + + WebResponseContent DeleteUserData(DeleteUserImg deleteUserDTO); + + } } diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Model/LoginInfo.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Model/LoginInfo.cs" index dc90d24..95c2482 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Model/LoginInfo.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Model/LoginInfo.cs" @@ -11,5 +11,10 @@ public string UserName { get; set; } public string Password { get; set; } + + /// <summary> + /// 浜鸿劯璇嗗埆 + /// </summary> + public string? path { get; set; } } } diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Model/Models/SerialPort/Dt_FaceRecognition.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Model/Models/SerialPort/Dt_FaceRecognition.cs" new file mode 100644 index 0000000..f09b4a7 --- /dev/null +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Model/Models/SerialPort/Dt_FaceRecognition.cs" @@ -0,0 +1,27 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SqlSugar; +using WIDESEAWCS_Core.DB.Models; +using WIDESEAWCS_Core.Tenants; + +namespace WIDESEAWCS_Model.Models +{ + [SugarTable("Dt_FaceRecognition", "浜鸿劯璇嗗埆琛�"), MultiTenant] + public class Dt_FaceRecognition:BaseEntity + { + /// <summary> + /// id + /// </summary> + [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "涓婚敭")] + public int ID { get; set; } + + /// <summary> + /// 浜鸿劯璇嗗埆缁� + /// </summary> + [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "浜鸿劯璇嗗埆缁�")] + public string GroupID { get; set; } + } +} diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Model/Models/System/Sys_User.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Model/Models/System/Sys_User.cs" index fec93b2..b4faebc 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Model/Models/System/Sys_User.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Model/Models/System/Sys_User.cs" @@ -21,6 +21,13 @@ /// </summary> [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "鐢ㄦ埛ID")] public int User_Id { get; set; } + + [SugarColumn( IsNullable = true, ColumnDescription = "浜鸿劯璇嗗埆id")] + public int Log_id { get; set; } + + + [SugarColumn(Length = 100, IsNullable = true, ColumnDescription = "浜鸿劯璇嗗埆token")] + public string Face_token { get; set; } /// <summary> ///甯愬彿 diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/Controllers/SerialPort/ArticleInfomController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/Controllers/SerialPort/ArticleInfomController.cs" index 445e7fe..dab4c20 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/Controllers/SerialPort/ArticleInfomController.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/Controllers/SerialPort/ArticleInfomController.cs" @@ -17,7 +17,7 @@ public ArticleInfomController(IArticleInfomServer service) : base(service) { } - + } } diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/Controllers/SerialPort/FaceRecognitionController .cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/Controllers/SerialPort/FaceRecognitionController .cs" new file mode 100644 index 0000000..ef7bd7b --- /dev/null +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/Controllers/SerialPort/FaceRecognitionController .cs" @@ -0,0 +1,33 @@ +锘縰sing Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Hosting.Server; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using WIDESEAWCS_Core; +using WIDESEAWCS_Core.BaseController; +using WIDESEAWCS_DTO.TaskInfo; +using WIDESEAWCS_DTO.Telescopic; +using WIDESEAWCS_ITaskInfoService; +using WIDESEAWCS_Model.Models; +using WIDESEAWCS_TaskInfoService; + + +namespace WIDESEAWCS_Server.Controllers.SerialPort +{ + [Route("api/[controller]")] + [ApiController] + public class FaceRecognitionController : ApiBaseController<IFaceRecognitionServer, Dt_FaceRecognition> + { + public FaceRecognitionController(IFaceRecognitionServer service) : base(service) + { + + } + + + [HttpPost,Route("AddGroup"),AllowAnonymous] + public WebResponseContent AddGroup(string groupName) + { + return Service.AddGroup(groupName); + } + + } +} diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/Controllers/System/Sys_UserController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/Controllers/System/Sys_UserController.cs" index f782394..8678587 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/Controllers/System/Sys_UserController.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/Controllers/System/Sys_UserController.cs" @@ -5,6 +5,7 @@ using Microsoft.Extensions.Caching.Memory; using Newtonsoft.Json; using StackExchange.Profiling; +using WIDESEAWCS_Common; using WIDESEAWCS_Core; using WIDESEAWCS_Core.Authorization; using WIDESEAWCS_Core.BaseController; @@ -14,6 +15,7 @@ using WIDESEAWCS_Core.HttpContextUser; using WIDESEAWCS_Core.Utilities; using WIDESEAWCS_DTO.SerialPort; +using WIDESEAWCS_DTO.Telescopic; using WIDESEAWCS_ISystemServices; using WIDESEAWCS_Model; using WIDESEAWCS_Model.Models; @@ -181,6 +183,52 @@ { return Service.Upuserbase(userDTO); } + + + /// <summary> + /// 灞曠ず浜鸿劯鐢ㄦ埛淇℃伅 + /// </summary> + /// <param name="paginationDTO"></param> + /// <returns></returns> + [HttpPost, Route("GetUserFace"), AllowAnonymous] + public WebResponseContent GetUserFace([FromBody] PaginationDTO paginationDTO) + { + return Service.GetUserFace(paginationDTO); + } + + /// <summary> + /// 娣诲姞鐢ㄦ埛 + /// </summary> + /// <param name="addUserDTO"></param> + /// <returns></returns> + [HttpPost, Route("AdduserData"), AllowAnonymous] + public WebResponseContent AdduserData([FromBody]AddUserDTO addUserDTO) + { + return Service.AdduserData(addUserDTO); + } + + /// <summary> + /// 鏇存柊鐢ㄦ埛 + /// </summary> + /// <param name="addUserDTO"></param> + /// <returns></returns> + [HttpPost, Route("UpuserData"), AllowAnonymous] + public WebResponseContent UpuserData([FromBody] AddUserDTO addUserDTO) + { + return Service.UpuserData(addUserDTO); + } + + /// <summary> + /// 鍒犻櫎鐢ㄦ埛 + /// </summary> + /// <param name="deleteUserDTO"></param> + /// <returns></returns> + [HttpPost, Route("DeleteUserData"), AllowAnonymous] + public WebResponseContent DeleteUserData([FromBody] DeleteUserImg deleteUserDTO) + { + return Service.DeleteUserData(deleteUserDTO); + } + } diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/1743492051182.png" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/1743492051182.png" new file mode 100644 index 0000000..3da449a --- /dev/null +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/1743492051182.png" Binary files differ diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/1743492244242.png" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/1743492244242.png" new file mode 100644 index 0000000..fe1dbc9 --- /dev/null +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/1743492244242.png" Binary files differ diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/1743492263811.png" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/1743492263811.png" new file mode 100644 index 0000000..1e18320 --- /dev/null +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/1743492263811.png" Binary files differ diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/1743492568523.png" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/1743492568523.png" new file mode 100644 index 0000000..ab48213 --- /dev/null +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/1743492568523.png" Binary files differ diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/1743492760375.png" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/1743492760375.png" new file mode 100644 index 0000000..5464776 --- /dev/null +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/1743492760375.png" Binary files differ diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/1743492791698.png" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/1743492791698.png" new file mode 100644 index 0000000..ef57e37 --- /dev/null +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/1743492791698.png" Binary files differ diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/1743492809549.png" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/1743492809549.png" new file mode 100644 index 0000000..5d7be73 --- /dev/null +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/1743492809549.png" Binary files differ diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/1743492833343.png" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/1743492833343.png" new file mode 100644 index 0000000..2f8b755 --- /dev/null +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/1743492833343.png" Binary files differ diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/files" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/files" new file mode 100644 index 0000000..3d83fea --- /dev/null +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/wwwroot/image/files" Binary files differ diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_SystemServices/Sys_UserService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_SystemServices/Sys_UserService.cs" index 55c3023..88ddcee 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_SystemServices/Sys_UserService.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_SystemServices/Sys_UserService.cs" @@ -17,6 +17,9 @@ using ICacheService = WIDESEAWCS_Core.Caches.ICacheService; using Microsoft.AspNetCore.Builder; using WIDESEAWCS_DTO.SerialPort; +using WIDESEAWCS_DTO.Telescopic; +using WIDESEAWCS_Common; +using Newtonsoft.Json; namespace WIDESEAWCS_SystemServices { @@ -28,8 +31,11 @@ private readonly ISys_RoleRepository _RoleRepository; private readonly ILoginHistoryRepository _loginHistoryRepository; private readonly IPutakeRepository _putakeRepository; + private readonly IFaceRecognitionRepository _faceRecognitionRepository; - public Sys_UserService(ISys_UserRepository repository, IUnitOfWorkManage unitOfWorkManage, + + + public Sys_UserService(IFaceRecognitionRepository faceRecognitionRepository, ISys_UserRepository repository, IUnitOfWorkManage unitOfWorkManage, ICacheService cacheService, ISys_MenuService menuService, ISys_RoleRepository roleRepository, ILoginHistoryRepository loginHistoryRepository, IPutakeRepository putakeRepository) : base(repository) { _unitOfWorkManage = unitOfWorkManage; @@ -39,6 +45,8 @@ _RoleRepository = roleRepository; _loginHistoryRepository = loginHistoryRepository; _putakeRepository = putakeRepository; + _faceRecognitionRepository = faceRecognitionRepository; + } public WebResponseContent Login(LoginInfo loginInfo) @@ -46,7 +54,7 @@ WebResponseContent content = new WebResponseContent(); try { - //BaseDal.QueryFirst(x => x.UserName == loginInfo.UserName); + // BaseDal.QueryFirst(x => x.UserName == loginInfo.UserName); string msg = string.Empty; @@ -60,51 +68,71 @@ } #endregion - - UserInfo user = BaseDal.GetUserInfo(loginInfo.UserName, loginInfo.Password); - var disbled = BaseDal.QueryFirst(x => x.UserName == loginInfo.UserName);//鏍规嵁杩欎釜鐢ㄦ埛鍚嶆潵鏌ョ湅鐢ㄦ埛 - if (user != null) + if (!string.IsNullOrEmpty(loginInfo.path)) { - object obj = _menuService.GetMenuActionList(user.RoleId); - if (obj is not IEnumerable<object> list) + var faceResult = BaiDuFaceHelper.FaceSearch(loginInfo.path); + + if (faceResult != null && faceResult.error_code == 0) { - return WebResponseContent.Instance.Error("鏃犵櫥褰曟潈闄�"); - } - if (!list.Any()) - { - return WebResponseContent.Instance.Error("鏃犵櫥褰曟潈闄�"); - } - if (disbled.Enable != 1) - { - return WebResponseContent.Instance.Error("浣犵殑璐﹀彿宸茶绂佺敤锛岃鑱旂郴绠$悊鍛�"); + // 鑾峰彇鏈�楂樺尮閰嶅害鐨勭敤鎴� + var bestMatch = faceResult.result.user_list.OrderByDescending(u => u.score).FirstOrDefault();//鎷跨涓�涓渶楂樼殑 + + if (bestMatch != null && double.TryParse(bestMatch.score, out double score) && score > 80) // 璁惧畾80鍒嗕负鍙俊搴﹂槇鍊� + { + return new WebResponseContent { Data = true }; + } } - string token = JwtHelper.IssueJwt(new TokenModelJwt() - { - UserId = user.UserId, - RoleId = user.RoleId, - UserName = user.UserName, - TenantId = user.TenantId, - }); - var loghis = new Dt_LoginHistory - { - Account = user.UserName, - TrurName = user.UserTrueName, - CreateDate = DateTime.Now - - }; - - - _cacheService.AddOrUpdate(user.UserId.ToString(), token); - _loginHistoryRepository.AddData(loghis); - - content = WebResponseContent.Instance.OK(data: new { token, userName = user.UserTrueName, img = user.HeadImageUrl, ID = user.UserId, RoleId=user.RoleId }); + return WebResponseContent.Instance.Error("浜鸿劯璇嗗埆澶辫触锛岃閲嶈瘯"); } else { - content = WebResponseContent.Instance.Error("璐﹀彿鎴栧瘑鐮侀敊璇�"); + UserInfo user = BaseDal.GetUserInfo(loginInfo.UserName, loginInfo.Password); + var disbled = BaseDal.QueryFirst(x => x.UserName == loginInfo.UserName);//鏍规嵁杩欎釜鐢ㄦ埛鍚嶆潵鏌ョ湅鐢ㄦ埛 + if (user != null) + { + object obj = _menuService.GetMenuActionList(user.RoleId); + if (obj is not IEnumerable<object> list) + { + return WebResponseContent.Instance.Error("鏃犵櫥褰曟潈闄�"); + } + if (!list.Any()) + { + return WebResponseContent.Instance.Error("鏃犵櫥褰曟潈闄�"); + } + if (disbled.Enable != 1) + { + return WebResponseContent.Instance.Error("浣犵殑璐﹀彿宸茶绂佺敤锛岃鑱旂郴绠$悊鍛�"); + } + + string token = JwtHelper.IssueJwt(new TokenModelJwt() + { + UserId = user.UserId, + RoleId = user.RoleId, + UserName = user.UserName, + TenantId = user.TenantId, + }); + var loghis = new Dt_LoginHistory + { + Account = user.UserName, + TrurName = user.UserTrueName, + CreateDate = DateTime.Now + + }; + + + _cacheService.AddOrUpdate(user.UserId.ToString(), token); + _loginHistoryRepository.AddData(loghis); + + content = WebResponseContent.Instance.OK(data: new { token, userName = user.UserTrueName, img = user.HeadImageUrl, ID = user.UserId, RoleId = user.RoleId }); + } + else + { + content = WebResponseContent.Instance.Error("璐﹀彿鎴栧瘑鐮侀敊璇�"); + } } } + catch (Exception ex) { content = WebResponseContent.Instance.Error(ex.Message); @@ -355,7 +383,7 @@ if (newPwd.Length < 6) return content.Error("瀵嗙爜涓嶈兘灏戜簬6浣�"); // 鑾峰彇鐢ㄦ埛褰撳墠瀵嗙爜 - string userCurrentPwd = BaseDal.QueryFirst(x => x.User_Id == id, s => s.UserPwd) ?? ""; + string userCurrentPwd = BaseDal.QueryFirst(x => x.User_Id == id, s => s.UserPwd) ?? ""; if (string.IsNullOrEmpty(userCurrentPwd)) return content.Error("鐢ㄦ埛涓嶅瓨鍦ㄦ垨瀵嗙爜鏈缃�"); @@ -398,7 +426,7 @@ try { var user = BaseDal.QueryData(x => x.User_Id == userDTO.id).FirstOrDefault(); - if (user==null) + if (user == null) { return new WebResponseContent { Status = false, Message = "娌℃壘鍒拌鐢ㄦ埛" }; } @@ -411,10 +439,205 @@ catch (Exception ex) { - return new WebResponseContent { Status = false ,Message="澶辫触锛�"+ex}; + return new WebResponseContent { Status = false, Message = "澶辫触锛�" + ex }; } } + + + /// <summary> + /// 鏌ョ湅鐢ㄦ埛淇℃伅鍜屼汉鑴歌瘑鍒〃 + /// </summary> + /// <param name="paginationDTO"></param> + /// <returns></returns> + public WebResponseContent GetUserFace(PaginationDTO paginationDTO) + { + try + { + int totalCount = 0; + var sys = Db.Queryable<Sys_User>(); + var face = _faceRecognitionRepository.Db.Queryable<Dt_FaceRecognition>(); + + if (face == null) + { + return new WebResponseContent { Status = false, Message = "鏁版嵁涓虹┖" }; + } + + var query = sys.LeftJoin<Dt_FaceRecognition>((a, b) => a.Log_id == b.ID); + if (!string.IsNullOrEmpty(paginationDTO.searchKeyword)) + { + query = query.Where((a, b) => + a.UserName.Contains(paginationDTO.searchKeyword) || + a.UserTrueName.Contains(paginationDTO.searchKeyword) || + a.PhoneNo.Contains(paginationDTO.searchKeyword) || + a.RoleName.Contains(paginationDTO.searchKeyword) || + a.Role_Id.ToString().Contains(paginationDTO.searchKeyword) + ); + } + if (paginationDTO.startDate.HasValue && paginationDTO.endDate.HasValue) + { + query = query.Where((a, b) => a.CreateDate >= paginationDTO.startDate && a.CreateDate <= paginationDTO.endDate); + } + + var result = query.Select((a, b) => new + { + a.User_Id, + a.UserName, + a.UserTrueName, + a.PhoneNo, + a.Role_Id, + a.RoleName, + a.HeadImageUrl, + a.Enable, + a.CreateDate, + a.Face_token, + b.GroupID, + }).ToPageList(paginationDTO.pageIndex, paginationDTO.pageSize, ref totalCount); + return new WebResponseContent + { + Status = true, + Data = new + { + TotalCount = totalCount,//鎬绘暟 + PageIndex = paginationDTO.pageIndex,//椤垫暟 + PaseSize = paginationDTO.pageSize,//涓�椤靛灏戞暟鎹� + Items = result//杩斿洖瀛楁 + } + + }; + + } + catch (Exception) + { + + throw; + } + } + + + public WebResponseContent AdduserData(AddUserDTO addUserDTO) + { + try + { + + var baiduResult = BaiDuFaceHelper.AddUser(new BDUserInfo + { + ImgPath = addUserDTO.path, + user_id = addUserDTO.username, + group_id = addUserDTO.log_id // 杩欓噷搴旇濉櫨搴︿汉鑴稿簱鍒嗙粍 + }); + + + // 鍒ゆ柇鐧惧害杩斿洖鏄惁鎴愬姛 + if (baiduResult == null || baiduResult.error_code != 0) + { + return new WebResponseContent { Status = false, Data = "浜鸿劯娉ㄥ唽澶辫触锛�" + baiduResult.error_msg }; + } + + // 鍒涘缓鐢ㄦ埛鏁版嵁 + var sys = new Sys_User + { + UserName = addUserDTO.username, + HeadImageUrl=addUserDTO.path, + Log_id = addUserDTO.log_id, + Face_token = baiduResult.result.face_token, + PhoneNo = addUserDTO.phoneno, + Role_Id = addUserDTO.roleid, + RoleName = addUserDTO.rolename, + Enable = addUserDTO.enable, + UserPwd= "j79rYYvCz4vdhcboB1Ausg==" + }; + BaseDal.AddData(sys); + return new WebResponseContent { Status = true, Data = sys }; + } + catch (Exception ex) + { + + return new WebResponseContent { Status = false, Message = "澶辫触" + ex }; + } + + } + + public WebResponseContent UpuserData(AddUserDTO addUserDTO) + { + try + { + + var baiduResult = BaiDuFaceHelper.AddUser(new BDUserInfo + { + ImgPath = addUserDTO.path, + user_id = addUserDTO.username, + group_id = addUserDTO.log_id // 杩欓噷搴旇濉櫨搴︿汉鑴稿簱鍒嗙粍 + }); + + + // 鍒ゆ柇鐧惧害杩斿洖鏄惁鎴愬姛 + if (baiduResult == null || baiduResult.error_code != 0) + { + return new WebResponseContent { Status = false, Data = "浜鸿劯鏇存柊澶辫触锛�" + baiduResult.error_msg }; + } + + // 鏇存柊鐢ㄦ埛鏁版嵁 + var sys = new Sys_User + { + UserName = addUserDTO.username, + HeadImageUrl = addUserDTO.path, + Log_id = addUserDTO.log_id, + Face_token = baiduResult.result.face_token, + PhoneNo = addUserDTO.phoneno, + Role_Id = addUserDTO.roleid, + RoleName = addUserDTO.rolename, + Enable = addUserDTO.enable, + }; + BaseDal.UpdateData(sys); + + return new WebResponseContent { Status = true, Data = sys }; + } + catch (Exception ex) + { + + return new WebResponseContent { Status = false, Message = "澶辫触" + ex }; + } + + } + + /// <summary> + /// 鍒犻櫎 + /// </summary> + /// <param name="deleteUserDTO"></param> + /// <returns></returns> + public WebResponseContent DeleteUserData(DeleteUserImg deleteUserDTO) + { + try + { + + string apiResult = BaiDuFaceHelper.DeleteUser(deleteUserDTO); + + // 2. 瑙f瀽杩斿洖缁撴灉锛屽垽鏂垹闄ゆ槸鍚︽垚鍔� + dynamic resultObj = JsonConvert.DeserializeObject(apiResult); + if (resultObj.error_code == 0) + { + // 鐧惧害鍒犻櫎鎴愬姛鍚庯紝鍒犻櫎鏁版嵁搴撲腑鐨勭敤鎴� + var user = BaseDal.QueryData(deleteUserDTO.user_id); + if (user != null) + { + BaseDal.DeleteData(user); + } + return WebResponseContent.Instance.OK("鐢ㄦ埛鍒犻櫎鎴愬姛"); + } + else + { + return WebResponseContent.Instance.Error("鐧惧害 API 鍒犻櫎澶辫触锛�" + resultObj.error_msg); + } + } + catch (Exception ex) + { + return WebResponseContent.Instance.Error("鍒犻櫎鐢ㄦ埛澶辫触锛�" + ex.Message); + } + } + + + } } -- Gitblit v1.9.3