2025-06-06 16:00:39 +08:00
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using System.Text.Json;
|
|
|
|
|
using VOL.Core.Extensions.AutofacManager;
|
|
|
|
|
using VOL.Core.ManageUser;
|
|
|
|
|
using VOL.Core.Utilities;
|
|
|
|
|
using VOL.Entity.DomainModels;
|
|
|
|
|
using VOL.Entity.DomainModels.Business.People;
|
|
|
|
|
using VOL.Entity.Enum;
|
|
|
|
|
using VOL.IOT.IServices;
|
|
|
|
|
using VOL.Model;
|
|
|
|
|
using VOL.Model.IOT.Request;
|
|
|
|
|
using VOL.Model.IOT.Response;
|
|
|
|
|
using VOL.System.IRepositories;
|
|
|
|
|
|
|
|
|
|
namespace VOL.IOT.Services
|
|
|
|
|
{
|
|
|
|
|
public class IOTUserService : IIOTUserService, IDependency
|
|
|
|
|
{
|
|
|
|
|
private readonly ISys_UserRepository _userRepository;
|
|
|
|
|
private readonly IS_TeacherRepository _teacherRepository;
|
|
|
|
|
private readonly IS_GradeRepository _gradeRepository;
|
|
|
|
|
private readonly IN_SportsTestCategoryRepository _sportsTestCategoryRepository;
|
|
|
|
|
private readonly IN_SportsTrainingCategoryRepository _sportsTrainingCategoryRepository;
|
|
|
|
|
private readonly IN_HealthStandardsRepository _healthStandardsRepository;
|
|
|
|
|
private readonly IN_SportsTestResultRepository _sportsTestResultRepository;
|
|
|
|
|
[ActivatorUtilitiesConstructor]
|
|
|
|
|
public IOTUserService(
|
|
|
|
|
ISys_UserRepository repository,
|
|
|
|
|
IS_TeacherRepository teacherRepository,
|
|
|
|
|
IS_GradeRepository gradeRepository,
|
|
|
|
|
IN_SportsTestCategoryRepository sportsTestCategoryRepository,
|
|
|
|
|
IN_HealthStandardsRepository healthStandardsRepository,
|
|
|
|
|
IN_SportsTestResultRepository sportsTestResultRepository,
|
|
|
|
|
IN_SportsTrainingCategoryRepository sportsTrainingCategoryRepository)
|
|
|
|
|
{
|
|
|
|
|
_userRepository = repository;
|
|
|
|
|
_teacherRepository = teacherRepository;
|
|
|
|
|
_gradeRepository = gradeRepository;
|
|
|
|
|
_sportsTestCategoryRepository = sportsTestCategoryRepository;
|
|
|
|
|
_healthStandardsRepository = healthStandardsRepository;
|
|
|
|
|
_sportsTestResultRepository = sportsTestResultRepository;
|
|
|
|
|
_sportsTrainingCategoryRepository = sportsTrainingCategoryRepository;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<IOT_LoginInfoModel> Login(LoginInfo loginInfo, bool verificationCode = true)
|
|
|
|
|
{
|
|
|
|
|
var res = new IOT_LoginInfoModel();
|
|
|
|
|
|
|
|
|
|
Sys_User user = await _userRepository.FindAsIQueryable(x => x.UserName == loginInfo.UserName).FirstOrDefaultAsync();
|
|
|
|
|
|
|
|
|
|
if (user == null || loginInfo.Password.Trim() != (user.UserPwd ?? ""))
|
|
|
|
|
throw new Exception("未找到用户信息");
|
|
|
|
|
|
|
|
|
|
string token = JwtHelper.IssueJwt(new UserInfo()
|
|
|
|
|
{
|
|
|
|
|
User_Id = user.User_Id,
|
|
|
|
|
UserName = user.UserName,
|
|
|
|
|
Role_Id = user.Role_Id
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
res.Token = token;
|
|
|
|
|
res.UserTrueName = user.UserTrueName;
|
|
|
|
|
res.UserName = user.UserName;
|
|
|
|
|
|
|
|
|
|
var school = await (from t in _teacherRepository.DbContext.Set<S_Teacher>()
|
|
|
|
|
join c in _teacherRepository.DbContext.Set<S_School>() on t.SchoolCode equals c.SchoolCode
|
|
|
|
|
where t.TeacherPhoneNo.Equals(user.PhoneNo)
|
|
|
|
|
select new { t, c })
|
|
|
|
|
.Select(x => new
|
|
|
|
|
{
|
|
|
|
|
x.c.SchoolName,
|
|
|
|
|
x.c.SchoolCode
|
|
|
|
|
})
|
|
|
|
|
.FirstOrDefaultAsync();
|
|
|
|
|
res.SchoolName = school?.SchoolName;
|
|
|
|
|
res.SchoolCode = school?.SchoolCode;
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<WebResponseContent> ModifyPwd(string oldPwd, string newPwd)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<WebResponseContent> ReplaceToken()
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<List<IOT_GradeListModel>> GradePageList(IOT_GradeListParam paramDto)
|
|
|
|
|
{
|
|
|
|
|
var res = await (from s in _gradeRepository.DbContext.Set<S_School>()
|
|
|
|
|
join a in _gradeRepository.DbContext.Set<S_SchoolAssocGrade>() on s.SchoolCode equals a.SchoolCode
|
|
|
|
|
join g in _gradeRepository.DbContext.Set<S_Grade>() on a.GradeId equals g.Id
|
|
|
|
|
where s.SchoolCode.Equals(paramDto.SchoolCode)
|
|
|
|
|
select new { s, g })
|
|
|
|
|
.Select(x => new IOT_GradeListModel()
|
|
|
|
|
{
|
|
|
|
|
GradeId = x.g.Id,
|
|
|
|
|
GradeName = x.g.GradeName,
|
|
|
|
|
GradeState = 1,
|
|
|
|
|
})
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
//var res = await (
|
|
|
|
|
// from h in _gradeRepository.DbContext.Set<S_School>()
|
|
|
|
|
// join g in _gradeRepository.DbContext.Set<S_Grade>() on h.SchoolCode equals g.SchoolCode
|
|
|
|
|
// join c in _gradeRepository.DbContext.Set<S_Class>() on g.Id equals c.GradeId into classGroup
|
|
|
|
|
// from c in classGroup.DefaultIfEmpty()
|
|
|
|
|
// join s in _gradeRepository.DbContext.Set<S_Student>() on c.Id equals s.ClassId into studentGroup
|
|
|
|
|
// from s in studentGroup.DefaultIfEmpty()
|
|
|
|
|
// where h.SchoolCode.Equals(paramDto.SchoolCode)
|
|
|
|
|
// group new { c, s } by new { g.Id, g.GradeName } into groupedData
|
|
|
|
|
// select new IOT_GradeListModel()
|
|
|
|
|
// {
|
|
|
|
|
// GradeId = groupedData.Key.Id,
|
|
|
|
|
// GradeName = groupedData.Key.GradeName,
|
|
|
|
|
// GradeState = 1,
|
|
|
|
|
// TotalClass = groupedData.Select(x => x.c.Id).Distinct().Count(),
|
|
|
|
|
// TotalStudent = groupedData.Select(x => x.s.Id).Distinct().Count(),
|
|
|
|
|
// TotalTrainNumber = groupedData.Select(x => x.s.TotalTrainNumber).Sum(),
|
|
|
|
|
// TotalTrainTime = groupedData.Select(x => x.s.TotalTrainTime).Sum()
|
|
|
|
|
// }).OrderBy(x => x.GradeId).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//var res = await _gradeRepository.DbContext.Set<S_Grade>()
|
|
|
|
|
// .Where(x => x.SchoolCode.Equals(paramDto.SchoolCode))
|
|
|
|
|
// .Select(x => new IOT_GradeListModel()
|
|
|
|
|
// {
|
|
|
|
|
// GradeId = x.Id,
|
|
|
|
|
// GradeName = x.GradeName,
|
|
|
|
|
// GradeState = 1
|
|
|
|
|
// })
|
|
|
|
|
// .ToListAsync();
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<List<IOT_ClassListModel>> ClassPageList(IOT_ClassListParam paramDto)
|
|
|
|
|
{
|
|
|
|
|
var query = from c in _gradeRepository.DbContext.Set<S_Class>()
|
|
|
|
|
join g in _gradeRepository.DbContext.Set<S_Grade>() on c.GradeId equals g.Id
|
|
|
|
|
join a in _gradeRepository.DbContext.Set<S_ClassAssocTeacher>() on c.Id equals a.ClassId into associations
|
|
|
|
|
from association in associations.DefaultIfEmpty()
|
|
|
|
|
join t in _gradeRepository.DbContext.Set<S_Teacher>() on association.TeacherId equals t.Id into teachers
|
|
|
|
|
from t in teachers.DefaultIfEmpty()
|
|
|
|
|
where c.SchoolCode.Equals(paramDto.SchoolCode)
|
|
|
|
|
select new
|
|
|
|
|
{
|
|
|
|
|
c.Id,
|
|
|
|
|
c.ClassName,
|
|
|
|
|
c.GradeId,
|
|
|
|
|
g.GradeName,
|
|
|
|
|
TeacherId = t != null ? t.Id : (int?)null,
|
|
|
|
|
TeacherName = t != null ? t.TeacherName : null,
|
|
|
|
|
TeacherPhoneNo = t != null ? t.TeacherPhoneNo : null
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var groupedResult = await query
|
|
|
|
|
.GroupBy(c => new { c.Id, c.ClassName, c.GradeId, c.GradeName })
|
|
|
|
|
.Select(group => new IOT_ClassListModel
|
|
|
|
|
{
|
|
|
|
|
ClassId = group.Key.Id,
|
|
|
|
|
ClassName = group.Key.ClassName,
|
|
|
|
|
GradeId = group.Key.GradeId,
|
|
|
|
|
GradeName = group.Key.GradeName,
|
|
|
|
|
Teachers = group
|
|
|
|
|
.Where(x => x.TeacherId.HasValue)
|
|
|
|
|
.Select(x => new IOT_TeacherModel
|
|
|
|
|
{
|
|
|
|
|
TeacherId = x.TeacherId,
|
|
|
|
|
TeacherName = x.TeacherName,
|
|
|
|
|
TeacherPhoneNo = x.TeacherPhoneNo
|
|
|
|
|
}).ToList()
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
return groupedResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<List<IOT_StudentListModel>> StudentPageList(IOT_StudentListParam paramDto)
|
|
|
|
|
{
|
|
|
|
|
var res = await (from s in _gradeRepository.DbContext.Set<S_Student>()
|
|
|
|
|
join c in _gradeRepository.DbContext.Set<S_Class>() on s.ClassId equals c.Id
|
|
|
|
|
join g in _gradeRepository.DbContext.Set<S_Grade>() on c.GradeId equals g.Id
|
|
|
|
|
|
|
|
|
|
where s.SchoolCode.Equals(paramDto.SchoolCode)
|
|
|
|
|
|
|
|
|
|
select new IOT_StudentListModel()
|
|
|
|
|
{
|
|
|
|
|
StudentId = s.Id,
|
|
|
|
|
StudentName = s.StudentName,
|
|
|
|
|
StudentNo = s.StudentNo,
|
|
|
|
|
Age = s.Age,
|
|
|
|
|
ClassId = c.Id,
|
|
|
|
|
ClassName = c.ClassName,
|
|
|
|
|
GradeName = g.GradeName,
|
|
|
|
|
Gender = (int)s.Sex,
|
|
|
|
|
StudentState = (int)StudentStatus.Normal,
|
|
|
|
|
TotalTrainNumber = s.TotalTrainNumber,
|
|
|
|
|
TotalTrainTime = s.TotalTrainTime
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<List<IOT_TeacherListModel>> TeacherPageList(IOT_SchoolParam paramDto)
|
|
|
|
|
{
|
|
|
|
|
var res = await _gradeRepository.DbContext.Set<S_Teacher>()
|
|
|
|
|
.Where(x => x.SchoolCode.Equals(paramDto.SchoolCode))
|
|
|
|
|
.Join(
|
|
|
|
|
_gradeRepository.DbContext.Set<Sys_User>(),
|
|
|
|
|
teacher => teacher.TeacherPhoneNo,
|
|
|
|
|
user => user.PhoneNo,
|
|
|
|
|
(teacher, user) => new { teacher, user }
|
|
|
|
|
)
|
|
|
|
|
.Select(x => new IOT_TeacherListModel()
|
|
|
|
|
{
|
|
|
|
|
TeacherId = x.teacher.Id,
|
|
|
|
|
TeacherName = x.teacher.TeacherName,
|
|
|
|
|
TeacherPhoneNo = x.teacher.TeacherPhoneNo,
|
|
|
|
|
TeacherState = (int)x.teacher.TeacherStatus,
|
|
|
|
|
Gender = (int)x.teacher.Sex,
|
|
|
|
|
TeacherPwd = x.user.UserPwd
|
|
|
|
|
})
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<IOT_TeacherDetailsModel> TeacherDetails()
|
|
|
|
|
{
|
|
|
|
|
var user = await _userRepository.FindAsyncFirst(x => x.User_Id == UserContext.Current.UserId);
|
|
|
|
|
|
|
|
|
|
if (user == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
var res = await (from t in _teacherRepository.DbContext.Set<S_Teacher>()
|
|
|
|
|
join a in _teacherRepository.DbContext.Set<S_ClassAssocTeacher>() on t.Id equals a.TeacherId into assocTeachers
|
|
|
|
|
from at in assocTeachers.DefaultIfEmpty()
|
|
|
|
|
join s in _teacherRepository.DbContext.Set<S_Student>() on at.ClassId equals s.ClassId into students
|
|
|
|
|
from s in students.DefaultIfEmpty()
|
|
|
|
|
where t.TeacherPhoneNo == user.PhoneNo && t.SchoolCode.Equals(UserContext.Current.TenantId)
|
|
|
|
|
group new { t, at, s } by new { t.Id } into groupedData
|
|
|
|
|
select new IOT_TeacherDetailsModel()
|
|
|
|
|
{
|
|
|
|
|
TeacherId = groupedData.Key.Id,
|
|
|
|
|
TeacherPhoneNo = groupedData.Select(x => x.t.TeacherPhoneNo).FirstOrDefault(),
|
|
|
|
|
TeacherName = groupedData.Select(x => x.t.TeacherName).FirstOrDefault(),
|
|
|
|
|
Gender = (int)groupedData.Select(x => x.t.Sex).FirstOrDefault(),
|
|
|
|
|
TotalStudentNumber = groupedData.Count(x => x.s.StudentNo != null),
|
|
|
|
|
TotalClassNumber = groupedData.Select(x => x.at.ClassId).Distinct().Count(),
|
|
|
|
|
TotalTrainNumber = groupedData.Sum(x => x.s.TotalTrainNumber),
|
|
|
|
|
TotalTrainTime = groupedData.Sum(x => x.s.TotalTrainTime),
|
|
|
|
|
TeacherState = (int)groupedData.Select(x => x.t.TeacherStatus).FirstOrDefault()
|
|
|
|
|
}).FirstOrDefaultAsync();
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<List<IOT_TrainTypeListModel>> TrainTypeList()
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(Tool.GetEnumDescriptions<IOT_TrainTypeListModel, TrainType>((id, description)
|
|
|
|
|
=> new IOT_TrainTypeListModel { Id = id, TrainTypeName = description }));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<List<IOT_CategoryListtModel>> CategoryList()
|
|
|
|
|
{
|
|
|
|
|
var res = await _sportsTestCategoryRepository.FindAsIQueryable(x => true).Select(x => new IOT_CategoryListtModel()
|
|
|
|
|
{
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
CategoryName = x.CategoryName
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<List<IOT_ItemTypeModel>> ItemTypeList()
|
|
|
|
|
{
|
|
|
|
|
var res = await (from t in _sportsTestCategoryRepository.DbContext.Set<N_TrainingAssocCategory>()
|
|
|
|
|
join a in _sportsTrainingCategoryRepository.DbContext.Set<N_SportsTrainingCategory>() on t.CategoryValue equals a.CategoryValue
|
|
|
|
|
where t.ModeId == 2 && t.DataSource == DataSource.IOT
|
|
|
|
|
select new IOT_ItemTypeModel()
|
|
|
|
|
{
|
|
|
|
|
Id = a.CategoryValue,
|
|
|
|
|
ItemTypeName = a.CategoryName
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task TankingLData(TankingDataParam paramDto)
|
|
|
|
|
{
|
|
|
|
|
if (paramDto == null || string.IsNullOrWhiteSpace(paramDto.Data))
|
|
|
|
|
throw new Exception("参数错误");
|
|
|
|
|
|
|
|
|
|
var classTrain = JsonSerializer.Deserialize<JsonClassTrainListEntity>(paramDto.Data);
|
|
|
|
|
if (classTrain == null || classTrain.tankingList == null)
|
|
|
|
|
throw new Exception("data参数解析失败");
|
|
|
|
|
|
|
|
|
|
var entity = new I_TrainingData()
|
|
|
|
|
{
|
|
|
|
|
DataSource = DataSource.IOT,
|
|
|
|
|
ClassId = paramDto.tc_id,
|
|
|
|
|
TeacherId = paramDto.u_id,
|
|
|
|
|
ItemType = paramDto.type,
|
|
|
|
|
InsertTime = Convert.ToDateTime(paramDto.insertTime),
|
|
|
|
|
EndTime = Convert.ToDateTime(paramDto.endTime),
|
|
|
|
|
TotalNumber = paramDto.totalNumber,
|
|
|
|
|
TtotalGroup = paramDto.totalGroup,
|
|
|
|
|
TrainType = paramDto.trainType,
|
2025-06-06 16:55:14 +08:00
|
|
|
|
ModeType = (int)Ai_ModeEnum.ClassRoomMode,
|
2025-06-06 16:00:39 +08:00
|
|
|
|
ModelName = paramDto.modelName,
|
|
|
|
|
GradeId = paramDto.grade,
|
|
|
|
|
LimitNumber = paramDto.limitNumber,
|
|
|
|
|
ClassScore = paramDto.classScore,
|
|
|
|
|
BoyLevelHigh = Convert.ToDouble(paramDto.boyLevelHigh),
|
|
|
|
|
BoyLevelLow = Convert.ToDouble(paramDto.boyLevelLow),
|
|
|
|
|
BoyLevelMiddle = Convert.ToDouble(paramDto.boyLevelMiddle),
|
|
|
|
|
GirlLevelHigh = Convert.ToDouble(paramDto.girlLevelHigh),
|
|
|
|
|
GirlLevelLow = Convert.ToDouble(paramDto.girlLevelLow),
|
|
|
|
|
GirlLevelMiddle = Convert.ToDouble(paramDto.girlLevelMiddle),
|
|
|
|
|
SchoolCode = paramDto.sid,
|
|
|
|
|
LimitTime = paramDto.limitTime,
|
|
|
|
|
|
|
|
|
|
Level1 = classTrain.level1,
|
|
|
|
|
Level2 = classTrain.level2,
|
|
|
|
|
Level3 = classTrain.level3,
|
|
|
|
|
Level4 = classTrain.level4,
|
|
|
|
|
Level5 = classTrain.level5,
|
|
|
|
|
Level6 = classTrain.level6,
|
|
|
|
|
Level7 = classTrain.level7,
|
|
|
|
|
Level8 = classTrain.level8,
|
|
|
|
|
Level9 = classTrain.level9,
|
|
|
|
|
Level10 = classTrain.level10,
|
|
|
|
|
AvgEff = classTrain.avgEff,
|
|
|
|
|
AvgNumMan = classTrain.avgNumMan,
|
|
|
|
|
AvgNumWom = classTrain.avgNumWom,
|
|
|
|
|
ClassAvgKcal = classTrain.classAvgKcal,
|
|
|
|
|
ClassAvgTime = classTrain.classAvgTime,
|
|
|
|
|
ClassDate = classTrain.classDate,
|
|
|
|
|
ClassHightPer = classTrain.classHightPer,
|
|
|
|
|
ClassLowNum = classTrain.classLowNum,
|
|
|
|
|
ClassMaxNum = Convert.ToInt32(classTrain.classMaxNum),
|
|
|
|
|
ClassMedian = Convert.ToInt32(classTrain.classMedian),
|
|
|
|
|
ClassMinNum = Convert.ToInt32(classTrain.classMinNum),
|
|
|
|
|
ClassName = classTrain.className,
|
|
|
|
|
ClassNum = Convert.ToInt32(classTrain.classNum),
|
|
|
|
|
ClassNumAvg = Convert.ToDouble(classTrain.classNumAvg),
|
|
|
|
|
ClassTime = classTrain.classTime,
|
|
|
|
|
ClassTimeMedian = classTrain.classTimeMedian,
|
|
|
|
|
ClassTotal = classTrain.classTotal,
|
|
|
|
|
ClassWellNum = classTrain.classWellNum,
|
|
|
|
|
Distance = classTrain.distance,
|
|
|
|
|
DistanceUseTime = classTrain.distanceUseTime,
|
|
|
|
|
GradeName = "",
|
|
|
|
|
MaxEff = classTrain.maxEff,
|
|
|
|
|
MaxNumMan = classTrain.maxNumMan,
|
|
|
|
|
MaxNumWom = classTrain.maxNumWom,
|
|
|
|
|
MaxUseTime = classTrain.maxUseTime,
|
|
|
|
|
MedianNumMan = classTrain.medianNumMan,
|
|
|
|
|
MedianNumWom = classTrain.medianNumWom,
|
|
|
|
|
MinEff = classTrain.minEff,
|
|
|
|
|
TrainTimer = classTrain.trainTimer,
|
|
|
|
|
MinNumMan = classTrain.minNumMan,
|
|
|
|
|
MinUseTime = classTrain.minUseTime,
|
|
|
|
|
MinNumWom = classTrain.minNumWom,
|
|
|
|
|
ModelType = classTrain.modelType,
|
|
|
|
|
Speed = classTrain.speed,
|
|
|
|
|
StuName = classTrain.stuName,
|
|
|
|
|
TotalRound = classTrain.totalRound,
|
|
|
|
|
TotalTime = classTrain.totalTime,
|
2025-06-06 16:55:14 +08:00
|
|
|
|
IsDisplay = true,
|
2025-06-06 16:00:39 +08:00
|
|
|
|
|
|
|
|
|
TrainingTime = classTrain.trainingTime,
|
|
|
|
|
KoTimeR = JsonSerializer.Serialize(classTrain.koTimeR),
|
|
|
|
|
KoTimeY = JsonSerializer.Serialize(classTrain.koTimeY),
|
|
|
|
|
TotalR = JsonSerializer.Serialize(classTrain.totalR),
|
|
|
|
|
TotalY = JsonSerializer.Serialize(classTrain.totalY)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
foreach (var data in classTrain.tankingList)
|
|
|
|
|
{
|
|
|
|
|
entity.TrainRankingData.Add(new I_TrainRanking()
|
|
|
|
|
{
|
|
|
|
|
SchoolCode = paramDto.sid,
|
|
|
|
|
GradeId = paramDto.grade,
|
|
|
|
|
ClassId = paramDto.tc_id,
|
|
|
|
|
ClassName = classTrain.className,
|
|
|
|
|
StudentNo = data.studentId,
|
|
|
|
|
StudentName = data.name,
|
|
|
|
|
Gender = int.Parse(data.gender),
|
|
|
|
|
Efficiency = data.efficiency,
|
|
|
|
|
ErrorNumber = data.errorNumber,
|
|
|
|
|
HeartRatePercentage = data.heartRatePercentage,
|
|
|
|
|
JumpValue = data.jumpValue,
|
|
|
|
|
HighHeartRate = data.highHeartRate,
|
|
|
|
|
Kcal = data.kcal,
|
|
|
|
|
LowHeartRate = data.lowHeartRate,
|
|
|
|
|
ResultLevel = data.resultLevel,
|
|
|
|
|
SecondsNumber = data.secondsNumber,
|
|
|
|
|
SpeedTime = data.speedTime,
|
2025-06-06 16:55:14 +08:00
|
|
|
|
StuAgileSpeedTimeNumber = data.stuAgileSpeedTimeNumber,
|
|
|
|
|
IsDisplay = true
|
|
|
|
|
|
2025-06-06 16:00:39 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if (classTrain.trainGroupList != null)
|
|
|
|
|
//{
|
|
|
|
|
// foreach (var trainGroup in classTrain.trainGroupList)
|
|
|
|
|
// {
|
|
|
|
|
// var stuList = new List<I_StuDetailInfoEntity>();
|
|
|
|
|
|
|
|
|
|
// foreach (var stu in trainGroup.stuList)
|
|
|
|
|
// {
|
|
|
|
|
// stuList.Add(new I_StuDetailInfoEntity()
|
|
|
|
|
// {
|
|
|
|
|
// ClassRanking = stu.ClassRanking,
|
|
|
|
|
// Efficiency = stu.Efficiency,
|
|
|
|
|
// GroupNumber = stu.GroupNumber,
|
|
|
|
|
// GroupRanking = stu.GroupRanking,
|
|
|
|
|
// IsGroup = stu.IsGroup,
|
|
|
|
|
// Kcal = stu.Kcal,
|
|
|
|
|
// Level = stu.Level,
|
|
|
|
|
// PowerMax = stu.PowerMax,
|
|
|
|
|
// PowerTotal = stu.PowerTotal,
|
|
|
|
|
// Speed = stu.Speed,
|
|
|
|
|
// SpeedTime = stu.SpeedTime,
|
|
|
|
|
// TotalNumber = stu.TotalNumber,
|
|
|
|
|
// UseTime = stu.UseTime
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// entity.TrainGroupData.Add(new I_TrainGroup()
|
|
|
|
|
// {
|
|
|
|
|
// SchoolCode = paramDto.sid,
|
|
|
|
|
// AvgEff = trainGroup.avgEff,
|
|
|
|
|
// DevicesName = trainGroup.devicesName,
|
|
|
|
|
// GroupAvg = trainGroup.groupAvg,
|
|
|
|
|
// GroupAvgKcal = trainGroup.groupAvg,
|
|
|
|
|
// GroupAvgTime = trainGroup.groupAvgTime,
|
|
|
|
|
// GroupHigh = trainGroup.groupHigh,
|
|
|
|
|
// GroupLow = trainGroup.groupLow,
|
|
|
|
|
// GroupM = trainGroup.groupM,
|
|
|
|
|
// GroupMax = trainGroup.groupMax,
|
|
|
|
|
// GroupMedianNum = trainGroup.groupMedianNum,
|
|
|
|
|
// GroupMin = trainGroup.groupMin,
|
|
|
|
|
// GroupName = trainGroup.groupName,
|
|
|
|
|
// GroupSpeed = trainGroup.groupSpeed,
|
|
|
|
|
// GroupSpeedAvgTime = trainGroup.groupSpeedAvgTime,
|
|
|
|
|
// GroupSpeedCompleteNum = trainGroup.groupSpeedCompleteNum,
|
|
|
|
|
// GroupSpeedCompletePre = trainGroup.groupSpeedCompletePre,
|
|
|
|
|
// GroupSpeedMaxime = trainGroup.groupSpeedMaxime,
|
|
|
|
|
// GroupSpeedMedianTime = trainGroup.groupSpeedMedianTime,
|
|
|
|
|
// GroupSpeedMinTime = trainGroup.groupSpeedMinTime,
|
|
|
|
|
// GroupSpeedTotalTime = trainGroup.groupSpeedTotalTime,
|
|
|
|
|
// GroupTimeMedian = trainGroup.groupTimeMedian,
|
|
|
|
|
// GroupTotalNum = trainGroup.groupTotalNum,
|
|
|
|
|
// GroupUseTime = trainGroup.groupUseTime,
|
|
|
|
|
// IsGroup = trainGroup.isGroup,
|
|
|
|
|
// Level1 = trainGroup.level1,
|
|
|
|
|
// Level2 = trainGroup.level2,
|
|
|
|
|
// Level3 = trainGroup.level3,
|
|
|
|
|
// Level4 = trainGroup.level4,
|
|
|
|
|
// Level5 = trainGroup.level5,
|
|
|
|
|
// Level6 = trainGroup.level6,
|
|
|
|
|
// Level7 = trainGroup.level7,
|
|
|
|
|
// Level8 = trainGroup.level8,
|
|
|
|
|
// Level9 = trainGroup.level9,
|
|
|
|
|
// Level10 = trainGroup.level10,
|
|
|
|
|
// StuName = trainGroup.stuName,
|
|
|
|
|
// MaxEff = trainGroup.maxEff,
|
|
|
|
|
// MinEff = trainGroup.minEff,
|
|
|
|
|
// MaxUseTime = trainGroup.maxUseTime,
|
|
|
|
|
// MinUseTime = trainGroup.minUseTime,
|
|
|
|
|
// SecondsNumber = trainGroup.secondsNumber,
|
|
|
|
|
// StuList = stuList
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
await _gradeRepository.DbContext.Set<I_TrainingData>().AddRangeAsync(entity);
|
|
|
|
|
await _gradeRepository.SaveChangesAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task SportsTestData(SportsTestDataParam paramDto)
|
|
|
|
|
{
|
|
|
|
|
if (paramDto == null || paramDto.Data == null)
|
|
|
|
|
throw new Exception("参数错误");
|
|
|
|
|
|
|
|
|
|
var sportsTestValueEntinys = new List<N_SportsTestValue>();
|
|
|
|
|
|
|
|
|
|
var distinctCategoryTypes = new List<string>()
|
|
|
|
|
{
|
|
|
|
|
Enum.GetName(typeof(SportsTestItemType), SportsTestItemType.BMI),
|
|
|
|
|
Enum.GetName(typeof(SportsTestItemType), SportsTestItemType.MeterRun_1000),
|
|
|
|
|
Enum.GetName(typeof(SportsTestItemType), SportsTestItemType.MeterRun_800),
|
|
|
|
|
Enum.GetName(typeof(SportsTestItemType), SportsTestItemType.Sit_And_Reach),
|
|
|
|
|
Enum.GetName(typeof(SportsTestItemType), SportsTestItemType.VitalCapacity),
|
|
|
|
|
Enum.GetName(typeof(SportsTestItemType), SportsTestItemType.OneMinuteJumpRope),
|
|
|
|
|
Enum.GetName(typeof(SportsTestItemType), SportsTestItemType.ShuttleRun_50x8),
|
|
|
|
|
Enum.GetName(typeof(SportsTestItemType), SportsTestItemType.MeterRun_50),
|
|
|
|
|
Enum.GetName(typeof(SportsTestItemType), SportsTestItemType.Pull_Up),
|
|
|
|
|
Enum.GetName(typeof(SportsTestItemType), SportsTestItemType.StandingLongJump),
|
|
|
|
|
Enum.GetName(typeof(SportsTestItemType), SportsTestItemType.Pull_Up)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var healthStandards = await _healthStandardsRepository.FindAsync(x => distinctCategoryTypes.Contains(x.CategoryEnum));
|
|
|
|
|
|
|
|
|
|
var sportsTestEntitys = new List<I_SportsTestData>();
|
|
|
|
|
|
|
|
|
|
var nowTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
foreach (var data in paramDto.Data)
|
|
|
|
|
{
|
2025-06-06 16:55:14 +08:00
|
|
|
|
double bmi = (data.height.HasValue && data.weight.HasValue && data.height.Value > 0)
|
|
|
|
|
? Math.Round(data.weight.Value / Math.Pow(data.height.Value / 100.0, 2), 1, MidpointRounding.AwayFromZero)
|
|
|
|
|
: 0;
|
|
|
|
|
|
|
|
|
|
data.bmi = bmi;
|
|
|
|
|
|
2025-06-06 16:00:39 +08:00
|
|
|
|
sportsTestEntitys.Add(new I_SportsTestData()
|
|
|
|
|
{
|
|
|
|
|
ClassId = data.classId,
|
|
|
|
|
ClassName = data.className,
|
|
|
|
|
Gender = data.studentGender,
|
|
|
|
|
GradeId = data.gradeId,
|
|
|
|
|
GradeName = data.gradeName,
|
|
|
|
|
Hectometer = data.hectometer,
|
|
|
|
|
Height = data.height,
|
2025-06-06 16:55:14 +08:00
|
|
|
|
Bmi = bmi,
|
2025-06-06 16:00:39 +08:00
|
|
|
|
Kilometer = data.kilometer,
|
|
|
|
|
Pliable = data.pliable,
|
|
|
|
|
Pulmonary = data.pulmonary,
|
|
|
|
|
Chinning = data.chinning,
|
|
|
|
|
Rope = data.rope,
|
|
|
|
|
SchoolCode = data.schoolId,
|
|
|
|
|
SchoolName = data.schoolName,
|
2025-06-06 16:55:14 +08:00
|
|
|
|
ScoreTime = string.IsNullOrWhiteSpace(data.scoreTime) ? DateTime.Now : Convert.ToDateTime(data.scoreTime),
|
2025-06-06 16:00:39 +08:00
|
|
|
|
Speedeight = data.speedeight,
|
|
|
|
|
Speed = data.speed,
|
|
|
|
|
Situp = data.situp,
|
|
|
|
|
Standing = data.standing,
|
|
|
|
|
StudentName = data.studentName,
|
|
|
|
|
StudentNo = data.studenNumber,
|
|
|
|
|
Weight = data.weight,
|
|
|
|
|
TeacherName = data.teacherName,
|
|
|
|
|
StudenNumber = data.studenNumber,
|
|
|
|
|
TeacherId = data.teacherId,
|
|
|
|
|
CreateDate = nowTime
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var categoryValues = new List<(Func<SportsTestData, double?> GetValue, SportsTestItemType Category)>
|
|
|
|
|
{
|
|
|
|
|
(d => d.hectometer, SportsTestItemType.MeterRun_800),
|
|
|
|
|
(d => d.bmi, SportsTestItemType.BMI),
|
|
|
|
|
(d => d.chinning, SportsTestItemType.Pull_Up),
|
|
|
|
|
(d => d.kilometer, SportsTestItemType.MeterRun_1000),
|
|
|
|
|
(d => d.pliable, SportsTestItemType.Sit_And_Reach),
|
|
|
|
|
(d => d.pulmonary, SportsTestItemType.VitalCapacity),
|
|
|
|
|
(d => d.rope, SportsTestItemType.OneMinuteJumpRope),
|
|
|
|
|
(d => d.speedeight, SportsTestItemType.ShuttleRun_50x8),
|
|
|
|
|
(d => d.speed, SportsTestItemType.MeterRun_50),
|
|
|
|
|
(d => d.situp, SportsTestItemType.Pull_Up),
|
|
|
|
|
(d => d.standing, SportsTestItemType.StandingLongJump)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
foreach (var (getValue, category) in categoryValues)
|
|
|
|
|
{
|
|
|
|
|
AddSportsTestValueEntity(getValue(data), category, data, sportsTestValueEntinys, healthStandards, nowTime);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-06 16:55:14 +08:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
await _gradeRepository.DbContext.Set<I_SportsTestData>().AddRangeAsync(sportsTestEntitys);
|
2025-06-06 16:00:39 +08:00
|
|
|
|
|
2025-06-06 16:55:14 +08:00
|
|
|
|
await _sportsTestResultRepository.AddRangeAsync(sportsTestValueEntinys);
|
2025-06-06 16:00:39 +08:00
|
|
|
|
|
2025-06-06 16:55:14 +08:00
|
|
|
|
await _gradeRepository.SaveChangesAsync();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
throw;
|
|
|
|
|
}
|
2025-06-06 16:00:39 +08:00
|
|
|
|
}
|
|
|
|
|
private void AddSportsTestValueEntity(double? value, SportsTestItemType SportsTestItemType, SportsTestData data, List<N_SportsTestValue> sportsTestValueEntinys, List<N_HealthStandards> healthStandards, DateTime nowTime)
|
|
|
|
|
{
|
|
|
|
|
if (value.HasValue && value > 0)
|
|
|
|
|
{
|
|
|
|
|
var sportsTestValueEntity = new N_SportsTestValue();
|
|
|
|
|
string categoryEnum = Enum.GetName(typeof(SportsTestItemType), SportsTestItemType);
|
|
|
|
|
|
|
|
|
|
var standard = healthStandards.Where(x =>
|
|
|
|
|
x.CategoryEnum.Equals(categoryEnum) &&
|
|
|
|
|
x.GradeId == data.gradeId &&
|
|
|
|
|
x.Sex == (SexType)data.studentGender &&
|
|
|
|
|
value >= x.MinValue &&
|
|
|
|
|
value < x.MaxValue
|
|
|
|
|
).FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
if (standard != null)
|
|
|
|
|
{
|
|
|
|
|
sportsTestValueEntity.Score = standard.Score;
|
|
|
|
|
sportsTestValueEntity.Rank = standard.Rank;
|
|
|
|
|
}
|
2025-06-06 16:55:14 +08:00
|
|
|
|
|
|
|
|
|
sportsTestValueEntity.Height = data.height != null ? (float)data.height : 0f;
|
|
|
|
|
sportsTestValueEntity.Weight = data.weight != null ? (float)data.weight : 0f;
|
|
|
|
|
|
2025-06-06 16:00:39 +08:00
|
|
|
|
sportsTestValueEntity.SchoolCode = data.schoolId;
|
|
|
|
|
sportsTestValueEntity.DataSource = DataSource.IOT;
|
|
|
|
|
sportsTestValueEntity.CategoryValue = (int)SportsTestItemType;
|
|
|
|
|
sportsTestValueEntity.CategoryEnum = categoryEnum;
|
|
|
|
|
sportsTestValueEntity.GradeId = data.gradeId;
|
|
|
|
|
sportsTestValueEntity.GradeName = data.gradeName;
|
|
|
|
|
sportsTestValueEntity.ClassId = data.classId;
|
|
|
|
|
sportsTestValueEntity.ClassName = data.className;
|
|
|
|
|
sportsTestValueEntity.TeacherId = data.teacherId;
|
|
|
|
|
sportsTestValueEntity.TeacherName = data.teacherName;
|
|
|
|
|
sportsTestValueEntity.StudentNo = data.studenNumber;
|
|
|
|
|
sportsTestValueEntity.StudentName = data.studentName;
|
|
|
|
|
sportsTestValueEntity.Value = (float)value;
|
|
|
|
|
sportsTestValueEntity.Creator = UserContext.Current.UserId;
|
|
|
|
|
sportsTestValueEntity.CreateDate = nowTime;
|
|
|
|
|
sportsTestValueEntity.IsDisplay = true;
|
2025-06-06 16:55:14 +08:00
|
|
|
|
sportsTestValueEntity.ScoreTime = string.IsNullOrWhiteSpace(data.scoreTime) ? DateTime.Now : Convert.ToDateTime(data.scoreTime);
|
|
|
|
|
sportsTestValueEntity.AdditionalScore = sportsTestValueEntity.Score == 100 ? 20 : 0;
|
2025-06-06 16:00:39 +08:00
|
|
|
|
|
|
|
|
|
SemesterDto semesterDto = new SemesterDto();
|
|
|
|
|
sportsTestValueEntity.Year = semesterDto.Year;
|
|
|
|
|
sportsTestValueEntity.Semester = semesterDto.Semester;
|
|
|
|
|
|
|
|
|
|
sportsTestValueEntinys.Add(sportsTestValueEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|