Commit d2102905 authored by 吴春's avatar 吴春

提交代码

parent 16cb091c
......@@ -48,6 +48,9 @@ namespace Edu.Model.ViewModel.Course
/// </summary>
public int ClassRoomId { get; set; }
public string RoomName { get; set; }
/// <summary>
/// 集团
/// </summary>
......
......@@ -1543,7 +1543,20 @@ namespace Edu.Module.Course
return class_TimeRepository.GetClassTimeByRoomId(RoomId, Group_Id);
}
public int GetNowClassHours(RB_Class_Time_Extend model)
/// <summary>
/// 获取班级上课时间
/// </summary>
/// <param name="classIds"></param>
/// <returns></returns>
public List<RB_Class_Time_Extend> GetClassTimeByTId(int TId, int Group_Id)
{
return class_TimeRepository.GetClassTimeByTId(TId, Group_Id);
}
public int GetNowClassHours(RB_Class_Time_Extend model)
{
int classHours = 0;
//班级完成的总分钟数
......
......@@ -530,5 +530,15 @@ namespace Edu.Module.User
return teacherRepository.GetListByStudentId(Student_Id, Group_Id);
}
}
/// <summary>
/// 获取教师账户
/// </summary>
/// <param name="teacherIds"></param>
/// <returns></returns>
public List<RB_Teacher_ViewModel> GetTeacherByTId(int AccountId,int Group_Id)
{
return teacherRepository.GetTeacherByTId(AccountId, Group_Id);
}
}
}
......@@ -127,6 +127,27 @@ where a.`Status`=0 and c.ClassStatus =2 and a.ClassRoomId={RoomId} and a.Group_
return Get<RB_Class_Time_Extend>(builder.ToString()).ToList();
}
/// <summary>
/// 获取班级上课时间
/// </summary>
/// <param name="classIds"></param>
/// <returns></returns>
public List<RB_Class_Time_Extend> GetClassTimeByTId(int TId, int Group_Id)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat($@"SELECT t.TeacherName,croom.RoomName,t.TeacherIcon,c.ClassHours,c.ClassName,cou.CourseName,lp.LessonPlanId,A.ClassPlanId,A.ClassId,A.`Status`,A.ClassRoomId,A.Group_Id,A.School_Id,A.TeacherId,B.ClassTimeId,CONCAT( DATE_FORMAT(A.ClassDate,'%Y-%m-%d') ,' ',B.StartTime,':00') AS NewPlanDateTime,
B.EndTime,B.StartTime,B.SuiPai,B.ClassStatus,CONCAT( DATE_FORMAT(A.ClassDate,'%Y-%m-%d') ,' ',B.EndTime,':00') AS NewEndPlanDateTime
FROM rb_class_plan AS A INNER JOIN rb_class_time AS B ON A.ClassPlanId=B.ClassPlanId
LEFT JOIN rb_teacher as t on a.TeacherId=t.TId
LEFT JOIN rb_class as c on c.ClassId=a.ClassId
LEFT JOIN rb_course as cou on cou.CourseId=c.CouseId
LEFT JOIN rb_class_room as croom on croom.RoomId=a.ClassRoomId
LEFT JOIN (SELECT ClassPlanId,MAX(LessonPlanId) as LessonPlanId from rb_class_lessonplan where `Status`=0 GROUP BY ClassPlanId) as lp on lp.ClassPlanId=a.ClassPlanId
where a.`Status`=0 and c.ClassStatus =2 and a.TeacherId={TId} and a.Group_Id={Group_Id} and DATE_FORMAT(A.ClassDate,'%Y-%m-%d')>=DATE_FORMAT(NOW(),'%Y-%m-%d') ORDER BY CONCAT( DATE_FORMAT(A.ClassDate,'%Y-%m-%d') ,' ',B.EndTime,':00') asc LIMIT 10");
return Get<RB_Class_Time_Extend>(builder.ToString()).ToList();
}
#endregion
}
}
......@@ -202,7 +202,33 @@ where t.`Status`=0 and c.`Status`=0 and sog.`Status`=0 and c.ClassStatus in(1,2
return Get<RB_Teacher_ViewModel>(builder.ToString(), parameters).ToList();
}
/// <summary>
/// 获取教师账户
/// </summary>
/// <param name="teacherIds"></param>
/// <returns></returns>
public List<RB_Teacher_ViewModel> GetTeacherByTId(int Id, int Group_Id)
{
var parameters = new DynamicParameters();
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT t.*,a.Id as AccountId,s.SName,d.DeptName
FROM rb_teacher AS t
LEFT JOIN rb_account as a ON (t.TId=a.AccountId AND a.AccountType=2)
LEFT JOIN rb_school AS s ON t.School_Id=s.SId
left join rb_department as d on t.Dept_Id = d.DeptId
WHERE 1=1
");
builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Teacher_ViewModel.Status), (int)DateStateEnum.Normal);
builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Teacher_ViewModel.AuditStatus), (int)AccountStatusEnum.Pass);
builder.AppendFormat(" AND t.{0} ={1} ", nameof(RB_Teacher_ViewModel.TId), Id);
if (Group_Id > 0)
{
builder.AppendFormat(" AND a.Group_Id ={0} ", Group_Id);
}
return Get<RB_Teacher_ViewModel>(builder.ToString(), parameters).ToList();
}
}
}
\ No newline at end of file
......@@ -1381,5 +1381,6 @@ namespace Edu.WebApi.Controllers.Course
return retult ? ApiResult.Success("课堂视频更新成功") : ApiResult.Failed("课堂视频更新失败");
}
#endregion
}
}
......@@ -41,6 +41,10 @@ namespace Edu.WebApi.Controllers.User
/// 公用处理类
/// </summary>
private readonly PublicModule publicModule = new PublicModule();
/// <summary>
/// 教师处理类
/// </summary>
private readonly TeacherModule teacherModule = new TeacherModule();
[HttpGet]
[HttpPost]
......@@ -345,5 +349,145 @@ namespace Edu.WebApi.Controllers.User
return ApiResult.Success(data: obj);
}
}
/// <summary>
/// 人脸识别登录
/// </summary>
/// <returns></returns>
[HttpGet]
[HttpPost]
[AllowAnonymous]
public ApiResult LoginTeacherById()
{
JObject jobj = JObject.Parse(RequestParm.Msg.ToString());
int tId = jobj.GetInt("TId");
int classRoomId = jobj.GetInt("ClassRoomId", 0);
if (classRoomId == 0)
{
return ApiResult.Failed("请传入教室id");
}
var modelTeacher = teacherModule.GetTeacherByTId(tId, 0);
if (modelTeacher == null)
{
return ApiResult.Failed("老师不存在");
}
var model = accountModule.GetAccountListExtModule(new RB_Account_ViewModel()
{
AccountId = tId,
AccountType = AccountTypeEnum.Teacher
})?.FirstOrDefault();
if (model.Status == Common.Enum.DateStateEnum.Delete)
{
return ApiResult.Failed(message: $"此账号【{ model.Account }】已禁用,如需使用请联系管理员!");
}
var list = new Module.Course.ClassModule().GetClassTimeByRoomId(classRoomId, model.Group_Id);
var tempList = list.OrderBy(x => x.NewEndPlanDateTime).Where(x => x.TeacherId == model.AccountId && x.NewPlanDateTime.HasValue && System.DateTime.Now >= x.NewPlanDateTime.Value.AddMinutes(-10) && x.NewEndPlanDateTime.HasValue && System.DateTime.Now < x.NewEndPlanDateTime.Value.AddMinutes(30));
if (tempList == null || !tempList.Any())
{
list = new Module.Course.ClassModule().GetClassTimeByTId(tId, model.Group_Id);
tempList = list.OrderBy(x => x.NewEndPlanDateTime).Where(x => x.TeacherId == model.AccountId && x.NewPlanDateTime.HasValue && System.DateTime.Now >= x.NewPlanDateTime.Value.AddMinutes(-10) && x.NewEndPlanDateTime.HasValue && System.DateTime.Now < x.NewEndPlanDateTime.Value);
if (tempList==null|| !tempList.Any())
{
tempList = list.OrderBy(x => x.NewEndPlanDateTime).Where(x => x.TeacherId == model.AccountId && x.NewEndPlanDateTime.HasValue && System.DateTime.Now < x.NewEndPlanDateTime.Value && x.NewEndPlanDateTime.HasValue && System.DateTime.Now.ToString("yyyy-MM-dd") == x.NewEndPlanDateTime.Value.ToString("yyyy-MM-dd"));
}
var result = tempList.Select(x => new {x.RoomName, NewPlanDateTime=x.NewPlanDateTime.HasValue? x.NewPlanDateTime.Value.ToString("yyyy-MM-dd HH:mm"):"", NewEndPlanDateTime = x.NewEndPlanDateTime.HasValue ? x.NewEndPlanDateTime.Value.ToString("yyyy-MM-dd HH:mm") : "" });
return ApiResult.Failed(message: $"本教室没有找到您的课",data: result);
}
else {
var classModel = tempList.OrderBy(x => x.NewPlanDateTime).FirstOrDefault();
var extModel = new Module.Course.ClassRoomModule().GetClassRoomModule(classModel.ClassRoomId);
var classInfo = new
{
ClassName = classModel.ClassName ?? "",
CourseName = classModel.CourseName ?? "",
ClassTime = classModel.NewPlanDateTime.HasValue ? classModel.NewPlanDateTime.Value.ToString("yyyy-MM-dd HH:mm") : "",
ClassHours = new Module.Course.ClassModule().GetNowClassHours(classModel),
IsLessPlan = classModel.LessonPlanId > 0 ? 1 : 0,
RoomPicList = string.IsNullOrWhiteSpace(extModel.RoomPic) ? new List<string>() : JsonHelper.DeserializeObject<List<string>>(extModel.RoomPic),
SuiPaiList = string.IsNullOrWhiteSpace(classModel.SuiPai) ? new List<string>() : JsonHelper.DeserializeObject<List<string>>(classModel.SuiPai),
classModel.ClassId,
classModel.ClassTimeId,
classModel.ClassPlanId,
classModel.ClassRoomId,
classModel.ClassStatus,
ClassEndTime = classModel.NewEndPlanDateTime.HasValue ? classModel.NewEndPlanDateTime.Value.ToString("HH:mm") : "",
};
//生成教育token
IUserInfoToken eduUserInfo = new EduUserInfoToken()
{
requestFrom = Common.Enum.ApiRequestFromEnum.WebAdmin,
uid = model.Id.ToString()
};
//生成ERP-Token
IUserInfoToken erpUserInfo = new ErpTokenUserInfo()
{
requestFrom = Common.Enum.ApiRequestFromEnum.ERP,
uid = model.Id.ToString(),
groupId = model.Group_Id
};
string token = WebApiTokenHelper.CreateToken(Common.GlobalKey.JWT_User_Key, eduUserInfo);
string erpToken = WebApiTokenHelper.CreateToken(Common.GlobalKey.JWT_ERP_User_Key, erpUserInfo);
var treeList = menuModule.GetPostMenuTreeModule(new Model.ViewModel.System.RB_Menu_ViewModel()
{
MenuType = 2
}, out List<RB_Menu_ViewModel> userCenterList, postIds: model.Post_Id.ToString());
//获取功能权限列表
var actionList = menuModule.GetPostMenuFunctionListModule(model.Post_Id.ToString());
//上传配置
var uploadConfig = publicModule.GetFileStoreList(new Model.Public.RB_File_Store() { Group_Id = model.Group_Id, IsDefault = 1 })?.FirstOrDefault();
UserInfo obj = new UserInfo
{
Id = model.Id,
AccountId = model.AccountId,
UserMobile = model.Account,
AccountType = model.AccountType,
Group_Id = model.Group_Id,
GroupName = model.GroupName,
School_Id = model.School_Id,
AccountName = model.AccountName,
SchoolName = model.SchoolName,
Token = token,
ErpToken = erpToken,
MenuList = treeList,
UserCenterList = userCenterList,
GroupLogo = model.GroupLogo,
UserIcon = model.UserIcon,
ApiRequestFromEnum = Common.Enum.ApiRequestFromEnum.WebAdmin,
DeptId = model.Dept_Id,
DeptName = model.DeptName,
PostId = model.Post_Id,
PostName = model.PostName,
ActionMenuList = actionList?.Select(qitem => new { qitem.FunctionCode, qitem.FunctionName, qitem.MenuName, qitem.MenuUrl }),
UploadConfig = new
{
uploadConfig?.Bucket,
uploadConfig?.StoreType,
uploadConfig?.Region,
uploadConfig?.CustomDomain,
uploadConfig?.SecretKey,
uploadConfig?.SecretId,
uploadConfig?.UploadDomain
},
ClassInfo = classInfo,
StudyAbroadObj = publicModule.GetStudyAbroadListModule()
};
UserReidsCache.UserInfoSet(Cache.CacheKey.User_Login_Key + model.Id, obj, Common.Config.JwtExpirTime);
return ApiResult.Success(data: obj);
}
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment