From c74365968798215773e55f18306ed823e97fe97e Mon Sep 17 00:00:00 2001 From: tanglong <842690096@qq.com> Date: Tue, 8 Jul 2025 14:30:49 +0800 Subject: [PATCH 1/3] d --- .../DomainModels/Ai/Ai_ScanCodeLogin.cs | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 VOL.Entity/DomainModels/Ai/Ai_ScanCodeLogin.cs diff --git a/VOL.Entity/DomainModels/Ai/Ai_ScanCodeLogin.cs b/VOL.Entity/DomainModels/Ai/Ai_ScanCodeLogin.cs new file mode 100644 index 0000000..27d864a --- /dev/null +++ b/VOL.Entity/DomainModels/Ai/Ai_ScanCodeLogin.cs @@ -0,0 +1,65 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VOL.Entity.SystemModels; + +namespace VOL.Entity.DomainModels +{ + [Table("Ai_ScanCodeLogin")] + [Entity(TableCnName = "Ai设备扫码登录", TableName = "Ai_ScanCodeLogin")] + public class Ai_ScanCodeLogin : BaseEntity + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + [Display(Description = "主键Id")] + [Comment("Id")] + public int Id { get; set; } + + /// + /// AI设备的唯一编码 + /// + [Display(Name = "AI设备的唯一编码")] + [Comment("AI设备的唯一编码")] + [Column(TypeName = "nvarchar(100)")] + public string Code { get; set; } + + /// + ///学校编号 + /// + [Display(Name = "学校编号")] + [Comment("学校编号")] + [Column(TypeName = "nvarchar(100)")] + public string SchoolCode { get; set; } + + /// + ///老师Id + /// + [Display(Name = "老师Id")] + [Comment("老师Id")] + [Column(TypeName = "int")] + public int TeacherId { get; set; } + + + /// + ///老师联系方式 + /// + [Display(Name = "老师联系方式")] + [Comment("老师联系方式")] + [Column(TypeName = "nvarchar(20)")] + public string TeacherPhoneNo { get; set; } + + /// + ///创建时间 + /// + [Display(Name = "创建时间")] + [Comment("创建时间")] + [Column(TypeName = "datetime")] + [Editable(true)] + public DateTime? CreateDate { get; set; } + } +} From 0849a3eb2b80fdbe69fba693e010354bb2ebd928 Mon Sep 17 00:00:00 2001 From: tanglong <842690096@qq.com> Date: Tue, 8 Jul 2025 15:19:19 +0800 Subject: [PATCH 2/3] sss --- VOL.Ai/IServices/IAiAppService.cs | 15 +++++ VOL.Ai/Services/AiAppService.cs | 62 ++++++++++++++++++++ VOL.Model/Ai/Request/Ai_Request.cs | 13 ++++ VOL.WebApi/Controllers/AI/AiAppController.cs | 26 ++++++++ 4 files changed, 116 insertions(+) diff --git a/VOL.Ai/IServices/IAiAppService.cs b/VOL.Ai/IServices/IAiAppService.cs index 3e22cb8..b70d08d 100644 --- a/VOL.Ai/IServices/IAiAppService.cs +++ b/VOL.Ai/IServices/IAiAppService.cs @@ -191,6 +191,21 @@ namespace VOL.Ai.IServices /// Task IsActivityInList(IsActivityInListRequest paramDto); + + /// + /// Ai一体机扫描那登录轮询 + /// + /// + /// + Task ScanCodeLogin(Ai_Request paramDto); + + /// + /// 退出登录 + /// + /// + /// + Task LogOut(LoginOutDto paramDto); + #endregion } } diff --git a/VOL.Ai/Services/AiAppService.cs b/VOL.Ai/Services/AiAppService.cs index f89a39a..317b3b6 100644 --- a/VOL.Ai/Services/AiAppService.cs +++ b/VOL.Ai/Services/AiAppService.cs @@ -1199,5 +1199,67 @@ namespace VOL.Ai.Services return res; } + + /// + /// Ai一体机扫描那登录轮询 + /// + /// + /// + public async Task ScanCodeLogin(Ai_Request paramDto) + { + var loginInfo = await _teacherRepository.DbContext.Set().Where(x => x.Code == paramDto.Code && x.SchoolCode == paramDto.SchoolCode).FirstOrDefaultAsync(); + + if (loginInfo == null) + return new Ai_TeacherFaceInfo(); + + + var res = await _teacherRepository.FindAsIQueryable(x => x.SchoolCode == paramDto.SchoolCode && x.TeacherStatus != TeacherStatus.Depart && x.TeacherPhoneNo == loginInfo.TeacherPhoneNo && x.Id == loginInfo.TeacherId) + .Select(x => + new Ai_TeacherFaceInfo() + { + Id = x.Id, + Age = x.Age, + //SchoolCode = x.SchoolCode, + Sex = x.Sex, + Phone = x.TeacherPhoneNo, + TeacherName = x.TeacherName, + Photo = x.TeacherPhoto, + }).FirstOrDefaultAsync(); + + if (res == null) + throw new Exception("未查询到登陆信息"); + + + var grades = await ( + from t in _studentRepository.DbContext.Set() + join c in _studentRepository.DbContext.Set() on t.ClassId equals c.Id into classGroup + from c in classGroup.DefaultIfEmpty() + where t.TeacherId == res.Id && c != null + select new Classes() + { + Id = c.Id, + Name = $"{c.GradeName}-{c.ClassName}", + }).ToListAsync(); + + res.GradeAndClassList = grades; + + return res; + } + + /// + /// 退出登录 + /// + /// + /// + + public async Task LogOut(LoginOutDto paramDto) + { + var teacher = await _teacherRepository.DbContext.Set().Where(x => x.Code == paramDto.Code && x.SchoolCode == paramDto.SchoolCode).FirstOrDefaultAsync(); + + if (teacher == null) return true; + + _teacherRepository.DbContext.Set().Remove(teacher); + return await _teacherRepository.SaveChangesAsync() > 0; + } } } diff --git a/VOL.Model/Ai/Request/Ai_Request.cs b/VOL.Model/Ai/Request/Ai_Request.cs index 276f9c8..a617da4 100644 --- a/VOL.Model/Ai/Request/Ai_Request.cs +++ b/VOL.Model/Ai/Request/Ai_Request.cs @@ -77,4 +77,17 @@ namespace VOL.Model.Ai /// //public string StudentNo { get; set; } } + + /// + /// 退出登录 + /// + public class LoginOutDto : Ai_Request + { + /// + /// 教师Id + /// + public int TeacherId { get; set; } + + } + } diff --git a/VOL.WebApi/Controllers/AI/AiAppController.cs b/VOL.WebApi/Controllers/AI/AiAppController.cs index cd5cf7c..bb681fa 100644 --- a/VOL.WebApi/Controllers/AI/AiAppController.cs +++ b/VOL.WebApi/Controllers/AI/AiAppController.cs @@ -436,5 +436,31 @@ namespace VOL.WebApi.Controllers var result = await _aiAppService.FastJumpRopeRanking(paramDto); return result; } + + /// + /// Ai一体机扫描那登录轮询 + /// + /// + /// + [HttpPost(nameof(ScanCodeLogin))] + public async Task ScanCodeLogin([FromBody] Ai_Request paramDto) + { + var result = await _aiAppService.ScanCodeLogin(paramDto); + + return result; + } + + /// + /// 退出登录 + /// + /// + /// + [HttpPost(nameof(LogOut))] + public async Task LogOut([FromBody] LoginOutDto paramDto) + { + var result = await _aiAppService.LogOut(paramDto); + + return result; + } } } From 5e3d8b2f6202eca9f1c1d008b0d5e9bc8188dbf2 Mon Sep 17 00:00:00 2001 From: tanglong <842690096@qq.com> Date: Wed, 9 Jul 2025 10:01:31 +0800 Subject: [PATCH 3/3] dd --- .../IRepositories/IScanCodeLoginRepository.cs | 19 ++++++++++++ .../Repositories/ScanCodeLoginRepository.cs | 31 +++++++++++++++++++ VOL.Ai/Services/AiAppService.cs | 16 +++++----- 3 files changed, 57 insertions(+), 9 deletions(-) create mode 100644 VOL.Ai/IRepositories/IScanCodeLoginRepository.cs create mode 100644 VOL.Ai/Repositories/ScanCodeLoginRepository.cs diff --git a/VOL.Ai/IRepositories/IScanCodeLoginRepository.cs b/VOL.Ai/IRepositories/IScanCodeLoginRepository.cs new file mode 100644 index 0000000..85f7068 --- /dev/null +++ b/VOL.Ai/IRepositories/IScanCodeLoginRepository.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VOL.Core.BaseProvider; +using VOL.Core.Extensions.AutofacManager; +using VOL.Entity.DomainModels; + +namespace VOL.Ai.IRepositories +{ + /// + /// Ai扫码登陆 + /// + public interface IScanCodeLoginRepository : IDependency, IRepository + { + + } +} diff --git a/VOL.Ai/Repositories/ScanCodeLoginRepository.cs b/VOL.Ai/Repositories/ScanCodeLoginRepository.cs new file mode 100644 index 0000000..4d36bcd --- /dev/null +++ b/VOL.Ai/Repositories/ScanCodeLoginRepository.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VOL.Ai.IRepositories; +using VOL.Business.IRepositories; +using VOL.Core.BaseProvider; +using VOL.Core.EFDbContext; +using VOL.Core.Extensions.AutofacManager; +using VOL.Entity.DomainModels; + +namespace VOL.Ai.Repositories +{ + /// + /// Ai扫码登陆 + /// + public partial class ScanCodeLoginRepository : RepositoryBase, IScanCodeLoginRepository + { + public ScanCodeLoginRepository(VOLContext dbContext) + : base(dbContext) + { + + } + + public static IScanCodeLoginRepository Instance + { + get { return AutofacContainerModule.GetService(); } + } + } +} diff --git a/VOL.Ai/Services/AiAppService.cs b/VOL.Ai/Services/AiAppService.cs index 317b3b6..a63ee49 100644 --- a/VOL.Ai/Services/AiAppService.cs +++ b/VOL.Ai/Services/AiAppService.cs @@ -33,7 +33,7 @@ namespace VOL.Ai.Services private readonly IS_ClassRepository _classRepository; private readonly IN_SportsTestCategoryRepository _sportsTestCategoryRepository; private readonly IN_HealthStandardsRepository _healthStandardsRepository; - private readonly IN_SportsTestResultRepository _sportsTestResultRepository; + private readonly IScanCodeLoginRepository _scanCodeLoginRepository; private readonly IN_SportsTrainingCategoryRepository _sportsTrainingCategoryRepository; private readonly IClassRoomRecordRepository _classRoomRecordRepository; private readonly IHeartRateDataRepository _heartRateDataRepository; @@ -50,7 +50,7 @@ namespace VOL.Ai.Services IS_ClassRepository classRepository, IN_SportsTestCategoryRepository sportsTestCategoryRepository, IN_HealthStandardsRepository healthStandardsRepository, - IN_SportsTestResultRepository sportsTestResultRepository, + IScanCodeLoginRepository scanCodeLoginRepository, IN_SportsTrainingCategoryRepository sportsTrainingCategoryRepository, IClassRoomRecordRepository classRoomRecordRepository, IHeartRateDataRepository heartRateDataRepository, @@ -65,7 +65,7 @@ namespace VOL.Ai.Services _studentRepository = studentRepository; _sportsTestCategoryRepository = sportsTestCategoryRepository; _healthStandardsRepository = healthStandardsRepository; - _sportsTestResultRepository = sportsTestResultRepository; + _scanCodeLoginRepository = scanCodeLoginRepository; _teacherRepository = teacherRepository; _sportsTrainingCategoryRepository = sportsTrainingCategoryRepository; _classRoomRecordRepository = classRoomRecordRepository; @@ -842,7 +842,7 @@ namespace VOL.Ai.Services entity.Year = semesterDto.Year; entity.Semester = semesterDto.Semester; var student = await (from s in _studentRepository.FindAsIQueryable(x => x.SchoolCode == paramDto.SchoolCode && x.StudentNo == paramDto.StudentNo) - join c in _studentRepository.DbContext.Set() on s.ClassId equals c.Id + join c in _classRepository.DbContext.Set() on s.ClassId equals c.Id select new { s.ClassId, @@ -1207,12 +1207,11 @@ namespace VOL.Ai.Services /// public async Task ScanCodeLogin(Ai_Request paramDto) { - var loginInfo = await _teacherRepository.DbContext.Set().Where(x => x.Code == paramDto.Code && x.SchoolCode == paramDto.SchoolCode).FirstOrDefaultAsync(); + var loginInfo = await _scanCodeLoginRepository.FindAsIQueryable(x => x.Code == paramDto.Code && x.SchoolCode == paramDto.SchoolCode).FirstOrDefaultAsync(); if (loginInfo == null) return new Ai_TeacherFaceInfo(); - var res = await _teacherRepository.FindAsIQueryable(x => x.SchoolCode == paramDto.SchoolCode && x.TeacherStatus != TeacherStatus.Depart && x.TeacherPhoneNo == loginInfo.TeacherPhoneNo && x.Id == loginInfo.TeacherId) .Select(x => new Ai_TeacherFaceInfo() @@ -1251,14 +1250,13 @@ namespace VOL.Ai.Services /// /// /// - public async Task LogOut(LoginOutDto paramDto) { - var teacher = await _teacherRepository.DbContext.Set().Where(x => x.Code == paramDto.Code && x.SchoolCode == paramDto.SchoolCode).FirstOrDefaultAsync(); + var teacher = await _scanCodeLoginRepository.FindAsIQueryable(x => x.Code == paramDto.Code && x.SchoolCode == paramDto.SchoolCode).FirstOrDefaultAsync(); if (teacher == null) return true; - _teacherRepository.DbContext.Set().Remove(teacher); + _scanCodeLoginRepository.Delete(teacher); return await _teacherRepository.SaveChangesAsync() > 0; } }