Commit 9833fb3c authored by 黄奎's avatar 黄奎

新增异步方法

parent 0cb7a2eb
......@@ -13,6 +13,7 @@ using Edu.Repository.User;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using VT.FW.DB;
namespace Edu.Module.Course
......@@ -429,36 +430,48 @@ namespace Edu.Module.Course
//班级上课计划列表
List<RB_Class_Plan_ViewModel> classPlanList = CreateClassPlanList(model, defaultPlanTimeList);
model.ClassPlanList = classPlanList;
if (model.ClassPlanList != null && model.ClassPlanList.Count > 0)
AddClassPlanModule(model);
#endregion
return flag;
}
/// <summary>
/// 添加上课计划
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public void AddClassPlanModule(RB_Class_ViewModel model)
{
Task.Run(() =>
{
foreach (var item in model.ClassPlanList)
if (model.ClassPlanList != null && model.ClassPlanList.Count > 0)
{
item.ClassPlanId = 0;
if (!class_PlanRepository.CheckExistsRepository(item))
foreach (var item in model.ClassPlanList)
{
//添加班级上课计划
var newClassPlanId = class_PlanRepository.Insert(item);
if (item.PlanTimeList != null && item.PlanTimeList.Count > 0)
item.ClassPlanId = 0;
if (!class_PlanRepository.CheckExistsRepository(item))
{
foreach (var subItem in item.PlanTimeList)
//添加班级上课计划
var newClassPlanId = class_PlanRepository.Insert(item);
if (item.PlanTimeList != null && item.PlanTimeList.Count > 0)
{
subItem.ClassTimeId = 0;
subItem.ClassPlanId = newClassPlanId;
subItem.ClassId = model.ClassId;
subItem.Group_Id = model.Group_Id;
subItem.School_Id = model.School_Id;
//添加班级上课计划的上课时间
class_TimeRepository.Insert(subItem);
foreach (var subItem in item.PlanTimeList)
{
subItem.ClassTimeId = 0;
subItem.ClassPlanId = newClassPlanId;
subItem.ClassId = model.ClassId;
subItem.Group_Id = model.Group_Id;
subItem.School_Id = model.School_Id;
//添加班级上课计划的上课时间
class_TimeRepository.Insert(subItem);
}
}
}
}
}
}
#endregion
return flag;
});
}
/// <summary>
......@@ -550,6 +563,7 @@ namespace Edu.Module.Course
if (model.ClassHours > 0)
{
var srartDate = model.OpenTime;
var BasicMinutes= class_ConfigRepository.GetBasicMinutesRepository(model.Group_Id);
//按周排课和按月排课
if (model.ClassStyle == ClassStyleEnum.Week || model.ClassStyle == ClassStyleEnum.Month)
{
......@@ -581,7 +595,7 @@ namespace Edu.Module.Course
var timeList = defaultPlanTimeList.Where(qitem => qitem.DateList.Contains(item))?.FirstOrDefault()?.TimeList;
if (timeList != null && timeList.Count > 0)
{
var dayHours = CalcDayClassHoursModule(timeList, planModel.PlanTimeList, model);
var dayHours = CalcDayClassHoursModule(timeList, planModel.PlanTimeList, model, BasicMinutes);
totalHours += dayHours;
classPlanList.Add(planModel);
}
......@@ -593,7 +607,7 @@ namespace Edu.Module.Course
var timeList = defaultPlanTimeList.Where(qitem => qitem.DateList.Contains(item))?.FirstOrDefault()?.TimeList;
if (timeList != null && timeList.Count > 0)
{
var dayHours = CalcDayClassHoursModule(timeList, planModel.PlanTimeList, model);
var dayHours = CalcDayClassHoursModule(timeList, planModel.PlanTimeList, model, BasicMinutes);
totalHours += dayHours;
classPlanList.Add(planModel);
}
......@@ -605,7 +619,7 @@ namespace Edu.Module.Course
var timeList = defaultPlanTimeList.Where(qitem => qitem.DateList.Contains(item))?.FirstOrDefault()?.TimeList;
if (timeList != null && timeList.Count > 0)
{
var dayHours = CalcDayClassHoursModule(timeList, planModel.PlanTimeList, model);
var dayHours = CalcDayClassHoursModule(timeList, planModel.PlanTimeList, model, BasicMinutes);
totalHours += dayHours;
classPlanList.Add(planModel);
}
......@@ -617,7 +631,7 @@ namespace Edu.Module.Course
var timeList = defaultPlanTimeList.Where(qitem => qitem.DateList.Contains(item))?.FirstOrDefault()?.TimeList;
if (timeList != null && timeList.Count > 0)
{
var dayHours = CalcDayClassHoursModule(timeList, planModel.PlanTimeList, model);
var dayHours = CalcDayClassHoursModule(timeList, planModel.PlanTimeList, model, BasicMinutes);
totalHours += dayHours;
classPlanList.Add(planModel);
}
......@@ -629,7 +643,7 @@ namespace Edu.Module.Course
var timeList = defaultPlanTimeList.Where(qitem => qitem.DateList.Contains(item))?.FirstOrDefault()?.TimeList;
if (timeList != null && timeList.Count > 0)
{
var dayHours = CalcDayClassHoursModule(timeList, planModel.PlanTimeList, model);
var dayHours = CalcDayClassHoursModule(timeList, planModel.PlanTimeList, model, BasicMinutes);
totalHours += dayHours;
classPlanList.Add(planModel);
}
......@@ -641,7 +655,7 @@ namespace Edu.Module.Course
var timeList = defaultPlanTimeList.Where(qitem => qitem.DateList.Contains(item))?.FirstOrDefault()?.TimeList;
if (timeList != null && timeList.Count > 0)
{
var dayHours = CalcDayClassHoursModule(timeList, planModel.PlanTimeList, model);
var dayHours = CalcDayClassHoursModule(timeList, planModel.PlanTimeList, model, BasicMinutes);
totalHours += dayHours;
classPlanList.Add(planModel);
}
......@@ -653,7 +667,7 @@ namespace Edu.Module.Course
var timeList = defaultPlanTimeList.Where(qitem => qitem.DateList.Contains(item))?.FirstOrDefault()?.TimeList;
if (timeList != null && timeList.Count > 0)
{
var dayHours = CalcDayClassHoursModule(timeList, planModel.PlanTimeList, model);
var dayHours = CalcDayClassHoursModule(timeList, planModel.PlanTimeList, model,BasicMinutes);
totalHours += dayHours;
classPlanList.Add(planModel);
}
......@@ -668,7 +682,7 @@ namespace Edu.Module.Course
var timeList = defaultPlanTimeList.Where(qitem => qitem.DateList.Contains(item))?.FirstOrDefault()?.TimeList;
if (timeList != null && timeList.Count > 0)
{
var dayHours = CalcDayClassHoursModule(timeList, planModel.PlanTimeList, model);
var dayHours = CalcDayClassHoursModule(timeList, planModel.PlanTimeList, model,BasicMinutes);
totalHours += dayHours;
classPlanList.Add(planModel);
}
......@@ -697,7 +711,7 @@ namespace Edu.Module.Course
var timeList = defaultPlanTimeList.Where(qitem => qitem.DateList.Contains(item))?.FirstOrDefault()?.TimeList;
if (timeList != null && timeList.Count > 0)
{
CalcDayClassHoursModule(timeList, planModel.PlanTimeList, model);
CalcDayClassHoursModule(timeList, planModel.PlanTimeList, model, BasicMinutes);
classPlanList.Add(planModel);
}
}
......@@ -718,7 +732,7 @@ namespace Edu.Module.Course
/// <param name="classTimeList"></param>
/// <param name="model"></param>
/// <returns></returns>
private double CalcDayClassHoursModule(List<TimeItem> timeList, List<RB_Class_Time_ViewModel> classTimeList, RB_Class_ViewModel model)
private double CalcDayClassHoursModule(List<TimeItem> timeList, List<RB_Class_Time_ViewModel> classTimeList, RB_Class_ViewModel model,int BasicMinutes)
{
double dayClassHours = 0;
double dayMinutes = 0;
......@@ -743,7 +757,7 @@ namespace Edu.Module.Course
}
else
{
dayClassHours = dayMinutes / class_ConfigRepository.GetBasicMinutesRepository(model.Group_Id);
dayClassHours = dayMinutes / BasicMinutes;
}
return dayClassHours;
}
......
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