Browse Source

安排考试新增班级时判断考试时间是否冲突

新疆影视学院高职
zhangli 2 years ago
parent
commit
e720176c9e
4 changed files with 86 additions and 13 deletions
  1. +14
    -13
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/Exam_ExamPlanLessonController.cs
  2. +19
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanClass/Exam_ExamPlanClassBLL.cs
  3. +1
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanClass/Exam_ExamPlanClassIBLL.cs
  4. +52
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanClass/Exam_ExamPlanClassService.cs

+ 14
- 13
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/Exam_ExamPlanLessonController.cs View File

@@ -272,6 +272,7 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
{
return Fail("考场座位数不足!");
}

}

exam_ExamPlanLessonIBLL.Check(keyValue, ELCheckMark);
@@ -308,11 +309,11 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers

entity.EPLId = keyValue;
//判断考试时间是否冲突
var res = exam_ExamPlanLessonIBLL.IsExamTimeClash(entity);
if (res.flag && !string.IsNullOrEmpty(res.lessonname))
{
return Fail("考试时间与课程(" + res.lessonname + ")冲突!");
}
//var res = exam_ExamPlanLessonIBLL.IsExamTimeClash(entity);
//if (res.flag && !string.IsNullOrEmpty(res.lessonname))
//{
// return Fail("考试时间与课程(" + res.lessonname + ")冲突!");
//}

//保存
exam_ExamPlanLessonIBLL.SaveEntity(keyValue, entity);
@@ -325,6 +326,13 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
public ActionResult SaveClass(string EPLId, string strEntity)
{
var list = strEntity.ToObject<List<Exam_ExamPlanClassEntity>>();
//判断排考班级的考试时间是否冲突
var res = exam_ExamPlanClassIBLL.IsExamConflict(list);
if (res.flag && !string.IsNullOrEmpty(res.msg))
{
return Fail(res.msg);
}

exam_ExamPlanClassIBLL.SaveList(list);
return Success("保存成功!");
}
@@ -342,14 +350,7 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
return Success("保存成功!");
}

//[HttpPost]
//[ValidateAntiForgeryToken]
//[AjaxOnly]
//public ActionResult SaveRoom(List<Exam_ExamPlanRoomEntity> list)
//{
// exam_ExamPlanRoomIBLL.SaveList(list);
// return Success("保存成功!");
//}


#endregion



+ 19
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanClass/Exam_ExamPlanClassBLL.cs View File

@@ -163,6 +163,25 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
}
}

public (bool flag, string msg) IsExamConflict(List<Exam_ExamPlanClassEntity> list)
{
try
{
return exam_ExamPlanClassService.IsExamConflict(list);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
#endregion

}


+ 1
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanClass/Exam_ExamPlanClassIBLL.cs View File

@@ -46,6 +46,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
void SaveEntity(string keyValue, Exam_ExamPlanClassEntity entity);

void SaveList(List<Exam_ExamPlanClassEntity> list);
(bool flag, string msg) IsExamConflict(List<Exam_ExamPlanClassEntity> list);
#endregion

}


+ 52
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanClass/Exam_ExamPlanClassService.cs View File

@@ -199,6 +199,58 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
}
}

/// <summary>
/// 判断排考班级的考试时间是否冲突
/// </summary>
/// <param name="list"></param>
public (bool flag, string msg) IsExamConflict(List<Exam_ExamPlanClassEntity> list)
{
try
{
//排考安排课程表Id
var EPLId = list.Select(x => x.EPLId).FirstOrDefault();
var examPlanLesson = this.BaseRepository("CollegeMIS").FindEntity<Exam_ExamPlanLessonEntity>(EPLId);
//开始时间
var startTime = Convert.ToDateTime(examPlanLesson.ExamDate.Value.ToString("yyyy-MM-dd") + " " + examPlanLesson.ExamTime.Split('-')[0]);
//结束时间
var endTime = Convert.ToDateTime(examPlanLesson.ExamDate.Value.ToString("yyyy-MM-dd") + " " + examPlanLesson.ExamTime.Split('-')[1]);
foreach (var classs in list)
{
//查询和entity考试日期同一天的考试课程
string sql = $@"select * from [dbo].[Exam_ExamPlanLesson] where eplid in (
select distinct eplid from [dbo].[Exam_ExamPlanclass] where classno='{classs.ClassNo}') and eplid <> '{examPlanLesson.EPLId}'
and examtime is not null and datediff(day, examdate, '{examPlanLesson.ExamDate}') = 0";
var eplList = this.BaseRepository("CollegeMIS").FindList<Exam_ExamPlanLessonEntity>(sql);
foreach (var epl in eplList)
{
//开始时间
var startTime1 = Convert.ToDateTime(epl.ExamDate.Value.ToString("yyyy-MM-dd") + " " + epl.ExamTime.Split('-')[0]);
//结束时间
var endTime1 = Convert.ToDateTime(epl.ExamDate.Value.ToString("yyyy-MM-dd") + " " + epl.ExamTime.Split('-')[1]);
if ((startTime >= startTime1 && startTime <= endTime1) ||
(endTime >= startTime1 && endTime <= endTime1))
{
var ep = this.BaseRepository("CollegeMIS").FindEntity<Exam_ExamPlanEntity>(epl.EPId);
return (true, classs.ClassName + "与" + ep.PlanName + "--" + epl.LessonName + "的考试时间冲突!");
}
}
}
return (false, "");

}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}

/// <summary>
/// 排考安排班级
/// </summary>


Loading…
Cancel
Save