Commit 68dfe2ac authored by 黄奎's avatar 黄奎

新增日志

parent b7f2193e
......@@ -25,7 +25,6 @@ namespace Edu.Common.Enum.Course
/// </summary>
[EnumField("上课记录")]
Class = 3,
/// <summary>
/// 创建班级
/// </summary>
......
......@@ -37,5 +37,10 @@ namespace Edu.Model.ViewModel.Course
/// 状态字符串
/// </summary>
public string StatusStr { get { return this.Status.ToName(); } }
/// <summary>
/// 教室编号【查询使用】
/// </summary>
public string QRoomIds { get; set; }
}
}
......@@ -74,5 +74,10 @@ namespace Edu.Model.ViewModel.User
/// 岗位名称
/// </summary>
public string PostName { get; set; }
/// <summary>
/// 教师编号
/// </summary>
public string QTIds { get; set; }
}
}
\ No newline at end of file
using Edu.AOP.CustomerAttribute;
using Edu.Common.Enum;
using Edu.Model.CacheModel;
using Edu.Model.ViewModel.Course;
using Edu.Model.ViewModel.User;
using Edu.Repository.Course;
using Edu.Repository.Log;
using Edu.Repository.User;
using System;
using System.Collections.Generic;
using System.Linq;
......@@ -63,6 +65,17 @@ namespace Edu.Module.Course
/// 课程日志记录表
/// </summary>
private readonly Repository.User.RB_StudentRepository studentRepository = new Repository.User.RB_StudentRepository();
/// <summary>
/// 教室仓储层对象
/// </summary>
private readonly RB_Class_RoomRepository class_RoomRepository = new RB_Class_RoomRepository();
/// <summary>
/// 教师仓储层对象
/// </summary>
private readonly RB_TeacherRepository teacherRepository = new RB_TeacherRepository();
/// <summary>
/// 获取班级列表
/// </summary>
......@@ -174,7 +187,6 @@ namespace Edu.Module.Course
{ nameof(RB_Class_ViewModel.ClassType),model.ClassType},
{ nameof(RB_Class_ViewModel.DefaultTimeJson),model.DefaultTimeJson},
{ nameof(RB_Class_ViewModel.DateJson),model.DateJson},
//{ nameof(RB_Class_ViewModel.CompleteProgress),model.CompleteProgress},
};
flag = classRepository.Update(fileds, new WhereHelper(nameof(RB_Class_ViewModel.ClassId), model.ClassId));
}
......@@ -288,6 +300,7 @@ namespace Edu.Module.Course
}
}
#endregion
return flag;
}
......@@ -520,7 +533,6 @@ namespace Edu.Module.Course
{
extModel.DefaultTimeList = Common.Plugin.JsonHelper.DeserializeObject<List<RB_Class_Time_ViewModel>>(extModel.DefaultTimeJson);
}
if (!string.IsNullOrEmpty(extModel.DateJson) && extModel.ClassStyle!= Common.Enum.Course.ClassStyleEnum.OnLine)
{
extModel.WeekDayList= Common.Plugin.JsonHelper.DeserializeObject<List<string>>(extModel.DateJson);
......@@ -588,9 +600,12 @@ namespace Edu.Module.Course
/// 根据计划编号删除上课计划
/// </summary>
/// <param name="ClassPlanId"></param>
/// <param name="UserInfo">用户信息</param>
/// <returns></returns>
public bool RemoveClassPlanModule(int ClassPlanId)
public bool RemoveClassPlanModule(int ClassPlanId, UserInfo UserInfo)
{
var planModel = class_PlanRepository.GetEntity(ClassPlanId);
classLogRepository.AddClassLogRepository(Common.Enum.Course.ClassLogTypeEnum.Class, "删除【"+ Common.ConvertHelper.FormatDate(planModel?.ClassDate) + "】上课计划", ClassPlanId, UserInfo.Group_Id, UserInfo.School_Id, UserInfo.Id);
return class_PlanRepository.DeleteOne(new WhereHelper(nameof(RB_Class_Plan_ViewModel.ClassPlanId), ClassPlanId));
}
......@@ -617,18 +632,45 @@ namespace Edu.Module.Course
/// 新增修改班级上课计划
/// </summary>
/// <param name="extModel"></param>
/// <param name="createBy">操作人</param>
/// <returns></returns>
public virtual bool SetClassPlanModule(RB_Class_Plan_ViewModel extModel)
public virtual bool SetClassPlanModule(RB_Class_Plan_ViewModel extModel,int createBy)
{
bool flag;
string logContent = "";
if (extModel.ClassPlanId > 0)
{
var oldPlanModel = class_PlanRepository.GetEntity(extModel.ClassPlanId);
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Class_Plan_ViewModel.ClassRoomId),extModel.ClassRoomId },
{nameof(RB_Class_Plan_ViewModel.TeacherId),extModel.TeacherId },
{nameof(RB_Class_Plan_ViewModel.ClassDate),extModel.ClassDate },
};
if (oldPlanModel.ClassRoomId != extModel.ClassRoomId)
{
string roomIds = oldPlanModel.ClassRoomId + "," + extModel.ClassRoomId;
var roomList = class_RoomRepository.GetClassRoomListRepository(new RB_Class_Room_ViewModel() { QRoomIds = roomIds });
logContent += string.Format(",教室由【{0}】修改为【{1}】.",
(roomList?.Where(qitem => qitem.RoomId == oldPlanModel.ClassRoomId)?.FirstOrDefault()?.RoomName ?? ""),
(roomList?.Where(qitem => qitem.RoomId == extModel.ClassRoomId)?.FirstOrDefault()?.RoomName ?? "")
);
}
if (oldPlanModel.TeacherId != extModel.TeacherId)
{
string tIds = oldPlanModel.TeacherId + "," + extModel.TeacherId;
var teacherList = teacherRepository.GetTeacherListRepository(new RB_Teacher_ViewModel() {QTIds=tIds});
logContent += string.Format(",讲师由【{0}】修改为【{1}】.",
(teacherList?.Where(qitem => qitem.TId == oldPlanModel.TeacherId)?.FirstOrDefault()?.TeacherName ?? ""),
(teacherList?.Where(qitem => qitem.TId == extModel.TeacherId)?.FirstOrDefault()?.TeacherName ?? "")
);
}
if (oldPlanModel.ClassDate != extModel.ClassDate)
{
logContent += string.Format(",日期由【{0}】修改为【{1}】.", Common.ConvertHelper.FormatDate(oldPlanModel.ClassDate), Common.ConvertHelper.FormatDate(extModel.ClassDate));
}
flag = class_PlanRepository.Update(fileds, new WhereHelper(nameof(RB_Class_Plan_ViewModel.ClassPlanId), extModel.ClassPlanId));
}
else
......@@ -636,6 +678,7 @@ namespace Edu.Module.Course
var newId = class_PlanRepository.Insert(extModel);
extModel.ClassPlanId = newId;
flag = newId > 0;
logContent = "新增【" + Common.ConvertHelper.FormatDate(extModel?.ClassDate) + "】上课计划";
}
var oldPlanList = class_TimeRepository.GetClassTimeListRepository(new RB_Class_Time_ViewModel()
{
......@@ -670,6 +713,7 @@ namespace Edu.Module.Course
{
if (dItem.ClassTimeId > 0)
{
logContent += string.Format(",删除{0}上课时间【{1} - {2}】", Common.ConvertHelper.FormatDate(extModel.ClassDate),dItem.StartTime, dItem.EndTime);
class_TimeRepository.Delete(dItem.ClassTimeId);
}
}
......@@ -681,14 +725,31 @@ namespace Edu.Module.Course
item.School_Id = extModel.School_Id;
if (item.ClassTimeId == 0)
{
logContent += string.Format(",新增{0}上课时间【{1} - {2}】", Common.ConvertHelper.FormatDate(extModel.ClassDate), item.StartTime, item.EndTime);
flag = class_TimeRepository.Insert(item) > 0;
}
else
{
var oldModel = oldPlanList?.Where(qitem => qitem.ClassTimeId == item.ClassTimeId)?.FirstOrDefault();
if (oldModel != null)
{
if (oldModel.StartTime != item.StartTime)
{
logContent += string.Format(",{0}上课开始时间由【{1}】修改为【{2}】", Common.ConvertHelper.FormatDate(extModel.ClassDate), oldModel.StartTime, item.EndTime);
}
if (oldModel.EndTime != item.EndTime)
{
logContent += string.Format(",{0}上课结束时间由【{1}】修改为【{2}】", Common.ConvertHelper.FormatDate(extModel.ClassDate), oldModel.EndTime, item.EndTime);
}
}
flag = class_TimeRepository.Update(item);
}
}
}
if (!string.IsNullOrEmpty(logContent))
{
classLogRepository.AddClassLogRepository(Common.Enum.Course.ClassLogTypeEnum.Class, logContent, extModel.ClassPlanId, extModel.Group_Id, extModel.School_Id, createBy);
}
return flag;
}
......
......@@ -82,6 +82,10 @@ WHERE 1=1
builder.AppendFormat(" AND A.{0} LIKE @RoomName ", nameof(RB_Class_Room_ViewModel.RoomName));
parameters.Add("RoomName", "%" + query.RoomName.Trim() + "%");
}
if (!string.IsNullOrEmpty(query.QRoomIds))
{
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Class_Room_ViewModel.RoomId), query.QRoomIds);
}
}
return Get<RB_Class_Room_ViewModel>(builder.ToString(), parameters).ToList();
}
......
using Edu.Common.Enum.Course;
using Edu.Model.Entity.Log;
using Edu.Model.ViewModel.Course;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
......@@ -61,11 +62,12 @@ WHERE 1=1
var model = new RB_Class_Log()
{
LogType = logType,
LogContent = LogContent,
LogContent = LogContent.TrimStart(',').TrimEnd(',').TrimStart('、').TrimEnd('、'),
ClassId = ClassId,
Group_Id = Group_Id,
School_Id = School_Id,
CreateBy = CreateBy
CreateBy = CreateBy,
CreateTime=DateTime.Now,
};
return base.Insert(model) > 0;
}
......
......@@ -69,6 +69,10 @@ WHERE 1=1
{
builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Teacher_ViewModel.TId), query.TId);
}
if (!string.IsNullOrEmpty(query.QTIds))
{
builder.AppendFormat(" AND t.{0} IN({1}) ", nameof(RB_Teacher_ViewModel.TId), query.QTIds);
}
}
return Get<RB_Teacher_ViewModel>(builder.ToString(), parameters).ToList();
}
......
......@@ -287,7 +287,7 @@ namespace Edu.WebApi.Controllers.Course
public ApiResult RemoveClassPlan()
{
var ClassPlanId = base.ParmJObj.GetInt("ClassPlanId");
var flag = classModule.RemoveClassPlanModule(ClassPlanId);
var flag = classModule.RemoveClassPlanModule(ClassPlanId,base.UserInfo);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
......@@ -343,7 +343,7 @@ namespace Edu.WebApi.Controllers.Course
}
}
}
var flag = classModule.SetClassPlanModule(extModel);
var flag = classModule.SetClassPlanModule(extModel,base.UserInfo.Id);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
......
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