2025-01-14 16:04:33 +08:00
|
|
|
|
using AutoMapper;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using System.Collections.Generic;
|
2025-01-21 16:01:50 +08:00
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
|
using VOL.Entity.DomainModels.XinWei;
|
2025-01-14 16:04:33 +08:00
|
|
|
|
using YD_XinWei.Api.Context;
|
|
|
|
|
using YD_XinWei.Api.Services.Interface;
|
|
|
|
|
using YD_XinWei.Api.SmartSportsEntitys;
|
|
|
|
|
using YD_XinWei.Api.Utilities;
|
|
|
|
|
using YD_XinWei.Commons.Dto.Common;
|
|
|
|
|
using YD_XinWei.Commons.Dto.HomeWork;
|
2025-01-15 09:32:35 +08:00
|
|
|
|
using YD_XinWei.Commons.Dto.Open;
|
2025-01-14 16:04:33 +08:00
|
|
|
|
using YD_XinWei.Commons.Dto.School;
|
2025-01-21 16:01:50 +08:00
|
|
|
|
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
|
2025-01-14 16:04:33 +08:00
|
|
|
|
|
|
|
|
|
namespace YD_XinWei.Api.Services.Impl
|
|
|
|
|
{
|
2025-01-15 09:32:35 +08:00
|
|
|
|
/// <summary>
|
2025-01-21 16:01:50 +08:00
|
|
|
|
/// 服务实现
|
2025-01-15 09:32:35 +08:00
|
|
|
|
/// </summary>
|
2025-01-14 16:04:33 +08:00
|
|
|
|
public class XinWeiService : IXinWeiService
|
|
|
|
|
{
|
|
|
|
|
public SmartSportsContext _sportsContext;
|
|
|
|
|
private readonly IMapper _mapper;
|
|
|
|
|
|
2025-01-15 09:32:35 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 构造
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sportsContext"></param>
|
|
|
|
|
/// <param name="mapper"></param>
|
2025-01-14 16:04:33 +08:00
|
|
|
|
public XinWeiService(SmartSportsContext sportsContext, IMapper mapper)
|
|
|
|
|
{
|
|
|
|
|
_sportsContext = sportsContext;
|
|
|
|
|
_mapper = mapper;
|
|
|
|
|
}
|
2025-01-15 09:32:35 +08:00
|
|
|
|
|
2025-01-21 16:01:50 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取设备信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="deviceSerial"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
|
|
|
public async Task<DeviceInfoDto> DeviceInfo(string deviceSerial)
|
|
|
|
|
{
|
2025-02-12 19:31:23 +08:00
|
|
|
|
var deviceInfo = await _sportsContext.XW_Device.FirstOrDefaultAsync(x => x.DeviceSerial == deviceSerial);
|
2025-01-21 16:01:50 +08:00
|
|
|
|
var res = _mapper.Map<DeviceInfoDto>(deviceInfo);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
2025-01-15 09:32:35 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 项目模式
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2025-01-14 16:04:33 +08:00
|
|
|
|
public async Task<List<ProjectModeDto>> SportsModelTypeList()
|
|
|
|
|
{
|
|
|
|
|
var res = await _sportsContext.XW_ProjectMode.Select(x => new ProjectModeDto()
|
|
|
|
|
{
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
ProjectKind = x.ProjectKind,
|
|
|
|
|
Name = x.Name
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-15 09:32:35 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 体育项目
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="orgId">学校Id</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
2025-01-14 16:04:33 +08:00
|
|
|
|
public async Task<List<TestingProjectDto>> OrgSportsProjectList(int orgId)
|
|
|
|
|
{
|
|
|
|
|
var res = await _sportsContext.XW_TestingProject.Where(x => x.OrgId == orgId).Select(x => new TestingProjectDto()
|
|
|
|
|
{
|
|
|
|
|
ProjectId = x.ProjectId,
|
|
|
|
|
IsOpen = x.IsOpen,
|
|
|
|
|
IsShow = x.IsShow,
|
|
|
|
|
ProjectName = x.ProjectName
|
|
|
|
|
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
2025-01-15 09:32:35 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取学生信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="orgId">学校Id</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<List<StudentInfoDto>> MinimumOfStudentInfoList(int orgId)
|
|
|
|
|
{
|
2025-01-15 10:10:13 +08:00
|
|
|
|
string schoolCode = await _sportsContext.School.Where(x => x.Id == orgId).Select(x => x.SchoolCode).FirstAsync();
|
2025-01-15 09:32:35 +08:00
|
|
|
|
|
2025-01-15 10:10:13 +08:00
|
|
|
|
var res = await (from s in _sportsContext.Student
|
|
|
|
|
join c in _sportsContext.Class on s.ClassId equals c.Id
|
|
|
|
|
join g in _sportsContext.Grade on c.GradeId equals g.Id
|
|
|
|
|
where s.SchoolCode == schoolCode
|
|
|
|
|
select new StudentInfoDto()
|
|
|
|
|
{
|
|
|
|
|
Id = s.Id,
|
|
|
|
|
OrgId = orgId,
|
2025-02-13 22:46:22 +08:00
|
|
|
|
UserId = s.Id,
|
2025-01-15 10:10:13 +08:00
|
|
|
|
StudentNo = s.StudentNo,
|
|
|
|
|
Name = s.StudentName,
|
|
|
|
|
Sex = s.Sex == 1 ? "男" : "女",
|
|
|
|
|
ClassId = c.Id,
|
|
|
|
|
GradeId = g.Id,
|
|
|
|
|
RuleGradeId = g.Id,
|
|
|
|
|
ClassName = c.ClassName,
|
|
|
|
|
GradeName = g.GradeName,
|
2025-02-13 22:46:22 +08:00
|
|
|
|
CardNo = new List<string>()
|
2025-01-15 10:10:13 +08:00
|
|
|
|
}).ToListAsync();
|
2025-01-15 09:32:35 +08:00
|
|
|
|
|
2025-01-15 10:10:13 +08:00
|
|
|
|
return res;
|
|
|
|
|
}
|
2025-01-21 16:01:50 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取人脸信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="dto"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<FaceListOfDevicePageDto> FaceListOfDevicePage(FaceListOfDeviceDto dto)
|
|
|
|
|
{
|
|
|
|
|
var total = await _sportsContext.Student.CountAsync();
|
|
|
|
|
|
|
|
|
|
string schoolCode = await _sportsContext.School.Where(x => x.Id == dto.OrgId).Select(x => x.SchoolCode).FirstAsync();
|
|
|
|
|
|
|
|
|
|
var list = await _sportsContext.Student
|
|
|
|
|
.Where(x => x.SchoolCode == schoolCode)
|
|
|
|
|
.Select(s => new DeviceUserFaceVo()
|
|
|
|
|
{
|
|
|
|
|
FaceId = s.StudentNo,
|
|
|
|
|
FaceType = 1,
|
|
|
|
|
FaceUrl = s.Photo,
|
|
|
|
|
PersonId = s.IDCard,
|
|
|
|
|
UserId = s.Id
|
|
|
|
|
})
|
|
|
|
|
.Skip((dto.PageNo - 1) * dto.PageSize)
|
|
|
|
|
.Take(dto.PageSize)
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
return new FaceListOfDevicePageDto()
|
|
|
|
|
{
|
|
|
|
|
Total = total,
|
|
|
|
|
PageNum = dto.PageNo,
|
|
|
|
|
Pages = dto.PageSize,
|
|
|
|
|
List = list
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取训练评分规则
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="orgId">学校Id</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<List<ScoreRuleDto>> ScoreRules(int orgId)
|
|
|
|
|
{
|
2025-02-07 22:22:24 +08:00
|
|
|
|
return new List<ScoreRuleDto>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 新增训练
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="dto"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task AddTrain(AddTrainDto dto)
|
|
|
|
|
{
|
|
|
|
|
var entity = _mapper.Map<XW_SportsTestData>(dto);
|
|
|
|
|
|
|
|
|
|
if (entity != null)
|
|
|
|
|
{
|
|
|
|
|
await _sportsContext.XW_SportsTestData.AddAsync(entity);
|
|
|
|
|
await _sportsContext.SaveChangesAsync();
|
|
|
|
|
}
|
2025-01-21 16:01:50 +08:00
|
|
|
|
}
|
2025-01-14 16:04:33 +08:00
|
|
|
|
}
|
|
|
|
|
}
|