Commit f0f886e3 authored by 吴春's avatar 吴春

提交代码

parent e5618a96
using Edu.Common.Enum;
using System;
using VT.FW.DB;
namespace Edu.Model.Entity.Course
{
/// <summary>
/// 教室管理实体类
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Class_Check
{
/// <summary>
/// 主键编号
/// </summary>
public int ClassCheckId { get; set; }
/// <summary>
/// 班级编号
/// </summary>
public int ClassId { get; set; }
/// <summary>
/// 上课日期
/// </summary>
public DateTime ClassDate { get; set; }
/// <summary>
/// 状态
/// </summary>
public DateStateEnum Status { get; set; }
/// <summary>
/// 教室编号
/// </summary>
public int ClassRoomId { get; set; }
/// <summary>
/// 集团编号
/// </summary>
public int Group_Id { get; set; }
/// <summary>
/// 所属校区
/// </summary>
public int School_Id { get; set; }
/// <summary>
/// 教师编号
/// </summary>
public int TeacherId { get; set; }
/// <summary>
/// 学员id
/// </summary>
public int OrderGuestId { get; set; }
/// <summary>
/// 0-正常,1-缺席 签到状态
/// </summary>
public int CheckStatus { get; set; }
/// <summary>
/// 创建人
/// </summary>
public int CreateBy { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
using Edu.Model.Entity.Course;
namespace Edu.Model.ViewModel.Course
{
public class RB_Class_Check_ViewModel: RB_Class_Check
{
/// <summary>
/// 【查询使用】
/// </summary>
public string EndDate { get; set; }
/// <summary>
///【查询使用】
/// </summary>
public string StartDate { get; set; }
}
}
......@@ -42,5 +42,10 @@ namespace Edu.Model.ViewModel.Course
/// 周几
/// </summary>
public string WeekDay { get; set; }
/// <summary>
/// 班级对应的老师id
/// </summary>
public int Teacher_Id { get; set; }
}
}
......@@ -54,6 +54,10 @@ namespace Edu.Module.Course
/// 课程日志记录表
/// </summary>
private readonly RB_Class_LogRepository classLogRepository = new RB_Class_LogRepository();
/// <summary>
/// 课程签到记录表
/// </summary>
private readonly RB_Class_CheckRepository classCheckRepository = new RB_Class_CheckRepository();
/// <summary>
/// 课程日志记录表
......@@ -581,7 +585,7 @@ namespace Edu.Module.Course
var orderStudentList = order_GuestRepository.GetList(new RB_Order_Guest_ViewModel()
{
ClassId = classId
});
}).Where(x => x.GuestState == 1).ToList();
var classModel = GetClassModule(classId);
var courseModel = courseRepository.GetEntity((classModel?.CouseId ?? 0));
if (orderStudentList != null && orderStudentList.Count > 0)
......@@ -606,6 +610,17 @@ namespace Edu.Module.Course
return list;
}
/// <summary>
/// 根据班级id获取订单学员信息
/// </summary>
/// <param name="classId"></param>
/// <returns></returns>
public List<RB_Order_Guest_ViewModel> GetOrderGuest(RB_Order_Guest_ViewModel model)
{
return order_GuestRepository.GetList(model);
}
/// <summary>
/// 更新学生的退课信息
/// </summary>
......@@ -616,14 +631,20 @@ namespace Edu.Module.Course
public bool UpdateClassStudentDropOutModule(string ids, string dropOutRemark, int classId, int createBy, int group_Id, int school_Id, string studentName)
{
bool flag = false;
Dictionary<string, object> fileds = new Dictionary<string, object>()
foreach (var item in ids.Split(","))
{
if (!string.IsNullOrWhiteSpace(item))
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Order_Guest_ViewModel.GuestState),2},
{nameof(RB_Order_Guest_ViewModel.DropOutRemark),dropOutRemark}
};
//写日志
flag = order_GuestRepository.Update(fileds, new WhereHelper(nameof(RB_Order_Guest_ViewModel.Id), ids, OperatorEnum.IN));
//写日志
flag = order_GuestRepository.Update(fileds, new WhereHelper(nameof(RB_Order_Guest_ViewModel.Id), item));
}
}
if (flag)
{
......@@ -660,5 +681,79 @@ namespace Edu.Module.Course
}
/// <summary>
/// 新增签到
/// </summary>
/// <param name="Ids"></param>
/// <param name="DropOutRemark"></param>
/// <returns></returns>
[TransactionCallHandler]
public bool AddClassCheckModule(List<RB_Class_Check_ViewModel> list)
{
bool flag = false;
//写日志
flag = classCheckRepository.InsertBatch(list);
return flag;
}
/// <summary>
/// 获取班级上课记录
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Class_Plan_ViewModel> GetClassPlanLogPageListRepository(int pageIndex, int pageSize, out long rowsCount, RB_Class_Plan_ViewModel query)
{
return class_PlanRepository.GetClassPlanLogPageListRepository(pageIndex, pageSize, out rowsCount, query);
}
/// <summary>
/// 获取班级上课计划
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Class_Plan_ViewModel> GetClassPlanModelRepository(RB_Class_Plan_ViewModel query)
{
return class_PlanRepository.GetClassPlanModelRepository(query);
}
/// <summary>
/// 获取每天签到记录
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Class_Check_ViewModel> GetClassCheckListRepository(RB_Class_Check_ViewModel query)
{
return classCheckRepository.GetClassCheckListRepository(query);
}
/// <summary>
/// 获取班级上课计划列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Class_Plan_ViewModel> GetClassPlanListRepository(RB_Class_Plan_ViewModel query)
{
return class_PlanRepository.GetClassPlanListRepository(query);
}
/// <summary>
/// 获取学生列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Student_ViewModel> GetStudentListRepository(RB_Student_ViewModel query)
{
return studentRepository.GetStudentListRepository(query);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Edu.Model.Entity.Course;
using Edu.Model.ViewModel.Course;
using VT.FW.DB.Dapper;
namespace Edu.Repository.Course
{
public class RB_Class_CheckRepository:BaseRepository<RB_Class_Check>
{
/// <summary>
/// 获取教室列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Class_Check_ViewModel> GetClassCheckListRepository(RB_Class_Check_ViewModel query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@" SELECT A.* FROM RB_Class_Check AS A WHERE 1=1 ");
if (query != null)
{
if (query.Group_Id > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Check_ViewModel.Group_Id), query.Group_Id);
}
if (query.School_Id > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Check_ViewModel.School_Id), query.School_Id);
}
if (query.ClassId > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Check_ViewModel.ClassId), query.ClassId);
}
if (!string.IsNullOrWhiteSpace(query.StartDate))
{
builder.AppendFormat(" AND DATE_FORMAT(A.{0},'%Y-%m-%d')>=DATE_FORMAT('{1}','%Y-%m-%d') ", nameof(RB_Class_Check_ViewModel.CreateTime), query.StartDate);
}
if (!string.IsNullOrWhiteSpace(query.EndDate))
{
builder.AppendFormat(" AND DATE_FORMAT(A.{0},'%Y-%m-%d')>=DATE_FORMAT('{1}','%Y-%m-%d') ", nameof(RB_Class_Check_ViewModel.CreateTime), query.EndDate);
}
}
return Get<RB_Class_Check_ViewModel>(builder.ToString()).ToList();
}
}
}
......@@ -34,6 +34,18 @@ WHERE 1=1
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Plan_ViewModel.ClassId), query.ClassId);
}
if (query.ClassPlanId > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Plan_ViewModel.ClassPlanId), query.ClassPlanId);
}
if (query.Group_Id > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Plan_ViewModel.Group_Id), query.Group_Id);
}
if (query.School_Id > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Plan_ViewModel.School_Id), query.School_Id);
}
if (!string.IsNullOrEmpty(query.QClassIds))
{
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Class_Plan_ViewModel.ClassId), query.QClassIds);
......@@ -91,5 +103,84 @@ WHERE c.ClassStyle =2 AND p.`Status`=0 and p.ClassId in({classIds}) GROUP BY p.
list1.AddRange(list2);
return list1;
}
/// <summary>
/// 获取班级上课记录
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Class_Plan_ViewModel> GetClassPlanLogPageListRepository(int pageIndex, int pageSize, out long rowsCount, RB_Class_Plan_ViewModel query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@" SELECT a.*,b.Teacher_Id,c.TeacherName from rb_class_plan as a
LEFT JOIN rb_class as b on a.ClassId=b.ClassId
LEFT JOIN rb_teacher as c on c.TId=a.TeacherId
where a.`Status`=0 and DATE_FORMAT(a.ClassDate,'%Y-%m-%d')<=DATE_FORMAT(NOW(),'%Y-%m-%d') ");
if (query != null)
{
if (query.Group_Id > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Plan_ViewModel.Group_Id), query.Group_Id);
}
if (query.School_Id > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Plan_ViewModel.School_Id), query.School_Id);
}
if (query.ClassId > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Plan_ViewModel.ClassId), query.ClassId);
}
if (query.Status >= 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Plan_ViewModel.Status), (int)query.Status);
}
}
builder.AppendFormat(@" order by ClassDate desc ");
return GetPage<RB_Class_Plan_ViewModel>(pageIndex, pageSize, out rowsCount, builder.ToString()).ToList();
}
/// <summary>
/// 获取班级上课计划
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Class_Plan_ViewModel> GetClassPlanModelRepository(RB_Class_Plan_ViewModel query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@" SELECT a.* from rb_class_plan as a
where a.`Status`=0 and DATE_FORMAT(a.ClassDate,'%Y-%m-%d')=DATE_FORMAT(NOW(),'%Y-%m-%d') ");
if (query != null)
{
if (query.Group_Id > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Plan_ViewModel.Group_Id), query.Group_Id);
}
if (query.School_Id > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Plan_ViewModel.School_Id), query.School_Id);
}
if (query.ClassId > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Plan_ViewModel.ClassId), query.ClassId);
}
if (query.Status >= 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Plan_ViewModel.Status), (int)query.Status);
}
}
builder.AppendFormat(@" order by ClassDate desc ");
return Get<RB_Class_Plan_ViewModel>(builder.ToString()).ToList();
}
}
}
......@@ -60,6 +60,13 @@ WHERE 1=1
{
builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Student_ViewModel.AreaId), query.AreaId);
}
if (query.StuStatus > 0)
{
builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Student_ViewModel.StuStatus), query.StuStatus);
}
else {
builder.AppendFormat(" AND t.{0} in({1}) ", nameof(RB_Student_ViewModel.StuStatus), "1,2");
}
}
return Get<RB_Student_ViewModel>(builder.ToString(),parameters).ToList();
}
......
......@@ -311,6 +311,28 @@ namespace Edu.WebApi.Controllers.Course
return ApiResult.Success(data: data);
}
/// <summary>
/// 获取某一天的上课计划列表
/// </summary>
/// <returns></returns>
public ApiResult GetDayClassPlan()
{
var classId = base.ParmJObj.GetInt("ClassId");
var classPlanId = base.ParmJObj.GetInt("ClassPlanId");
var schoolId = base.ParmJObj.GetInt("SchoolId");
if (classId == 0 || classPlanId == 0 || schoolId == 0)
{
return ApiResult.ParamIsNull();
}
var data = classModule.GetClassPlanListRepository(new RB_Class_Plan_ViewModel { ClassId = classId, ClassPlanId = classPlanId, Group_Id = base.UserInfo.Group_Id, School_Id = schoolId }).FirstOrDefault();
if (data == null || data.ClassPlanId == 0)
{
return ApiResult.Failed("数据不存在");
}
return ApiResult.Success(data: new { data.TeacherName, data.RoomName, ClassDate = data.ClassDate.ToString("yyyy-MM-dd") });
}
/// <summary>
/// 更新学生的退课状态
/// </summary>
......@@ -352,8 +374,106 @@ namespace Edu.WebApi.Controllers.Course
bool result = classModule.AddClassStudentDropOutModule(model, base.UserInfo.AccountName);
return ApiResult.Success();
}
/// <summary>
/// 获取教室页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetClassPlanLogPageList()
{
var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
var query = new RB_Class_Plan_ViewModel()
{
Group_Id = base.UserInfo.Group_Id,
School_Id = base.ParmJObj.GetInt("School_Id"),
ClassId = base.ParmJObj.GetInt("ClassId")
};
var list = classModule.GetClassPlanLogPageListRepository(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
List<RB_Class_Check_ViewModel> checkLogList = new List<RB_Class_Check_ViewModel>();
if (list != null && list.Any())
{
checkLogList = classModule.GetClassCheckListRepository(new RB_Class_Check_ViewModel { Group_Id = query.Group_Id, School_Id = query.School_Id, ClassId = query.ClassId, StartDate = list.Min(x => x.ClassDate).ToString("yyyy-MM-dd HH:mm:ss"), EndDate = list.Max(x => x.ClassDate).ToString("yyyy-MM-dd HH:mm:ss") });
}
List<object> resultList = new List<object>();
foreach (var item in list)
{
int totalNum = checkLogList.Where(x => x.ClassId == item.ClassId && x.ClassRoomId == item.ClassRoomId && x.Group_Id == item.Group_Id && x.School_Id == item.School_Id).Count();
int CheckNum = checkLogList.Where(x => x.CheckStatus == 0 && x.ClassId == item.ClassId && x.ClassRoomId == item.ClassRoomId && x.Group_Id == item.Group_Id && x.School_Id == item.School_Id).Count();
int NoCheckNum = checkLogList.Where(x => x.CheckStatus == 1 && x.ClassId == item.ClassId && x.ClassRoomId == item.ClassRoomId && x.Group_Id == item.Group_Id && x.School_Id == item.School_Id).Count();
var planCheckObj = new
{
item.TeacherName,
IsAlternate = item.TeacherId == item.Teacher_Id ? 0 : 1,//是否代课老师
MonthStr = item.ClassDate.ToString("MM"),
DayStr = item.ClassDate.ToString("dd"),
YearStr = item.ClassDate.ToString("yyyy"),
CheckNum,
NoCheckNum,
ColorType = item.TeacherId != item.Teacher_Id ? 1 : (totalNum == CheckNum ? 2 : 3),
};
resultList.Add(planCheckObj);
}
pageModel.Count = rowsCount;
pageModel.PageData = resultList;
return ApiResult.Success(data: pageModel);
}
/// <summary>
/// 签到
/// </summary>
/// <returns></returns>
public ApiResult AddClassCheck()
{
List<RB_Class_Check_ViewModel> list = Common.Plugin.JsonHelper.DeserializeObject<List<RB_Class_Check_ViewModel>>(RequestParm.Msg.ToString());
if (list == null || !list.Any())
{
return ApiResult.ParamIsNull("");
}
//获取班级的学员信息
var orderGuestList = classModule.GetOrderGuest(new RB_Order_Guest_ViewModel { Group_Id = base.UserInfo.Group_Id, School_Id = list.FirstOrDefault().School_Id, ClassId = list.FirstOrDefault().ClassId });
if (list.Count() != orderGuestList.Where(x => x.GuestState == 1).Count())
{
return ApiResult.Failed("签到总人数错误,请先检查信息");
}
//判断今天有课没有
var planList = classModule.GetClassPlanModelRepository(new RB_Class_Plan_ViewModel { Group_Id = base.UserInfo.Group_Id, School_Id = list.FirstOrDefault().School_Id, ClassId = list.FirstOrDefault().ClassId });
if (planList == null || !planList.Any())
{
return ApiResult.Failed("今日无课程,无须签到");
}
//判断今天是否已签到
var checkLogList = classModule.GetClassCheckListRepository(new RB_Class_Check_ViewModel { Group_Id = base.UserInfo.Group_Id, School_Id = list.FirstOrDefault().School_Id, ClassId = list.FirstOrDefault().ClassId, StartDate = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), EndDate = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") });
if (checkLogList != null && checkLogList.Any())
{
return ApiResult.Failed("今日已签到,请勿重复操作");
}
list.ForEach(x => x.Group_Id = base.UserInfo.Group_Id);
list.ForEach(x => x.CreateTime = System.DateTime.Now);
list.ForEach(x => x.CreateBy = base.UserInfo.Id);
list.ForEach(x => x.Status = 0);
bool result = classModule.AddClassCheckModule(list);
return result ? ApiResult.Success() : ApiResult.Failed("签到失败");
}
#endregion
#region 获取学员信息
public ApiResult GetStudentList()
{
var schoolId = base.ParmJObj.GetInt("SchoolId");
var data = classModule.GetStudentListRepository(new Model.ViewModel.User.RB_Student_ViewModel { School_Id = schoolId, Group_Id = base.UserInfo.Group_Id });
return ApiResult.Success(data: data);
}
#endregion
#region 枚举相关列表
/// <summary>
/// 获取班级状态列表
......
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