Commit e617e0fa authored by 黄奎's avatar 黄奎

班课签到修改

parent 22542a4b
......@@ -4,39 +4,34 @@ using Edu.Common;
using Edu.Common.Enum;
using Edu.Common.Enum.Course;
using Edu.Common.Plugin;
using Edu.Common.SignalR;
using Edu.Model.CacheModel;
using Edu.Model.Entity.Course;
using Edu.Model.Entity.Grade;
using Edu.Model.Entity.Mall;
using Edu.Model.Entity.Sell;
using Edu.Model.ViewModel.Course;
using Edu.Model.ViewModel.Mall;
using Edu.Model.ViewModel.Grade;
using Edu.Model.ViewModel.Mall;
using Edu.Model.ViewModel.Reserve;
using Edu.Model.ViewModel.Scroll;
using Edu.Model.ViewModel.Sell;
using Edu.Model.ViewModel.User;
using Edu.Repository.BackClass;
using Edu.Repository.Course;
using Edu.Repository.Finance;
using Edu.Repository.Grade;
using Edu.Repository.Log;
using Edu.Repository.Reserve;
using Edu.Repository.Scroll;
using Edu.Repository.Sell;
using Edu.Repository.User;
using Microsoft.AspNetCore.SignalR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using VT.FW.DB;
using Edu.Model.Entity.Mall;
using Edu.Repository.BackClass;
using Edu.Repository.Grade;
using Edu.Repository.Sell;
using Edu.Module.User;
using System.Web;
using Edu.Common.Enum.System;
using Edu.Repository.Exam;
using Edu.Model.ViewModel.Exam;
using Edu.Model.ViewModel.Scroll;
using Edu.Repository.Scroll;
using Edu.Common.SignalR;
using Microsoft.AspNetCore.SignalR;
using VT.FW.DB;
namespace Edu.Module.Course
{
......@@ -221,6 +216,11 @@ namespace Edu.Module.Course
/// </summary>
private readonly RB_Course_ChapterRepository course_ChapterRepository = new RB_Course_ChapterRepository();
/// <summary>
/// 学员签到仓储层
/// </summary>
private readonly RB_Class_CheckRepository class_CheckRepository = new RB_Class_CheckRepository();
/// <summary>
/// 获取班级列表
......@@ -1643,17 +1643,34 @@ namespace Edu.Module.Course
var planModel = class_PlanRepository.GetEntity(ClassPlanId);
if (planModel != null)
{
string logStr = "删除【" + Common.ConvertHelper.FormatDate(planModel?.ClassDate) + "】上课计划";
flag = UpdateClassEndDateModule(planModel.ClassId);
flag = class_PlanRepository.DeleteOne(new WhereHelper(nameof(RB_Class_Plan_ViewModel.ClassPlanId), ClassPlanId));
var classTimeList = class_TimeRepository.GetClassTimeListRepository(new RB_Class_Time_ViewModel() { ClassPlanId = ClassPlanId });
if (classTimeList != null && classTimeList.Count > 0)
{
string classTimeStr = string.Join(",", classTimeList.Select(qitem => qitem.ClassTimeId));
if (!string.IsNullOrEmpty(classTimeStr))
{
var checkList = class_CheckRepository.GetClassCheckListRepository(new RB_Class_Check_ViewModel() { Q_ClassTimeIds = classTimeStr });
if (checkList != null && checkList.Count > 0)
{
logStr += string.Format(",删除学员{0} 签到 ", classTimeStr);
class_CheckRepository.DeleteStudentCheckRepository(checkList);
}
}
}
classLogRepository.AddClassLogRepository(new Model.Entity.Log.RB_Class_Log()
{
LogType = Common.Enum.Course.ClassLogTypeEnum.Class,
LogContent = "删除【" + Common.ConvertHelper.FormatDate(planModel?.ClassDate) + "】上课计划",
LogContent = logStr,
ClassId = planModel.ClassId,
CreateBy = UserInfo.Id,
Group_Id = UserInfo.Group_Id,
School_Id = UserInfo.School_Id,
});
flag = UpdateClassEndDateModule(planModel.ClassId);
flag = class_PlanRepository.DeleteOne(new WhereHelper(nameof(RB_Class_Plan_ViewModel.ClassPlanId), ClassPlanId));
}
else
{
......
......@@ -45,7 +45,6 @@ WHERE 1=1 AND A.Status=0 ");
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Check_ViewModel.Group_Id), query.Group_Id);
}
if (query.ClassId > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Check_ViewModel.ClassId), query.ClassId);
......@@ -62,6 +61,10 @@ WHERE 1=1 AND A.Status=0 ");
{
builder.AppendFormat(" AND ct.ClassPlanId IN({0}) ", query.QClassPlanIds);
}
if (!string.IsNullOrEmpty(query.Q_ClassTimeIds))
{
builder.AppendFormat(" AND A.ClassTimeId IN({0}) ", query.Q_ClassTimeIds);
}
if (!string.IsNullOrEmpty(query.QOrderGuestIds))
{
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Class_Check_ViewModel.OrderGuestId), query.QOrderGuestIds);
......@@ -1336,6 +1339,66 @@ WHERE 1=1 AND A.Status=0 {1} ", builderMakeUp.ToString(), builderWhere.ToString
return flag;
}
/// <summary>
/// 【班课】删除上课计划,重新计算学员签到
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public bool DeleteStudentCheckRepository(List<RB_Class_Check_ViewModel> list)
{
bool flag = false;
List<RB_Order_Guest_Extend> guestList = new List<RB_Order_Guest_Extend>();
List<RB_Class_Check_ViewModel> oldCheckList = new List<RB_Class_Check_ViewModel>();
foreach (var item in list)
{
base.Delete(item.ClassCheckId);
}
if (list != null && list.Count > 0)
{
string orderGuestIds = string.Join(",", list.Select(qitem => qitem.OrderGuestId).Distinct());
if (!string.IsNullOrEmpty(orderGuestIds))
{
guestList = GetOrderGuestListRepository(orderGuestIds);
oldCheckList = GetClassCheckList(new RB_Class_Check_ViewModel() { QOrderGuestIds = orderGuestIds });
}
}
foreach (var item in guestList)
{
var guestOldCheckList = oldCheckList?.Where(qitem => qitem.OrderGuestId == item.Id)?.ToList() ?? new List<RB_Class_Check_ViewModel>();
decimal guestOldFinishHours = 0;
if (guestOldCheckList != null && guestOldCheckList.Count > 0)
{
guestOldFinishHours = guestOldCheckList.Sum(qitem => qitem.CurrentDeductionHours);
}
DynamicParameters guestParamters = new DynamicParameters();
//更新学员完成课时
var completeHours = guestOldFinishHours;
Dictionary<string, object> orderFileds = new Dictionary<string, object>()
{
{nameof(RB_Order_Guest_ViewModel.CompleteHours),completeHours }
};
string guestSql = "UPDATE RB_Order_Guest SET ";
int guestIndex = 0;
foreach (var gItem in orderFileds)
{
if (guestIndex > 0)
{
guestSql += ",";
}
guestSql += string.Format("{0}=@{0} ", gItem.Key);
guestParamters.Add(string.Format("@{0}", gItem.Key), gItem.Value);
guestIndex++;
}
guestSql += string.Format(" WHERE 1=1 AND Id=@Id ");
guestParamters.Add("@Id", item.Id);
flag = base.Execute(guestSql, guestParamters) > 0;
}
return flag;
}
/// <summary>
/// 约课学员签到
/// </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