diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/Exam_ExamPlanController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/Exam_ExamPlanController.cs
index 649203288..0fe80a537 100644
--- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/Exam_ExamPlanController.cs
+++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/Exam_ExamPlanController.cs
@@ -309,7 +309,16 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
{
return Fail("请先安排课程!");
}
- exam_ExamPlanLessonIBLL.PlanLessonTimeByEPId(keyValue);
+ var res = exam_ExamPlanLessonIBLL.PlanLessonTimeByEPId(keyValue);
+ if (res.flag)
+ {
+ return Success("操作成功!");
+ }
+ else
+ {
+ return Fail(res.msg);
+ }
+
return Success("操作成功!");
}
diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanLesson/Exam_ExamPlanLessonEntity.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanLesson/Exam_ExamPlanLessonEntity.cs
index 01ff1f76d..347d527c6 100644
--- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanLesson/Exam_ExamPlanLessonEntity.cs
+++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanLesson/Exam_ExamPlanLessonEntity.cs
@@ -112,7 +112,17 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
/// 考试时长
///
[NotMapped]
- public int? ExamLength { get; set; }
+ public double? ExamLength { get; set; }
+ ///
+ /// 课程类型
+ ///
+ [NotMapped]
+ public string LessonTypeName { get; set; }
+ ///
+ /// 专业
+ ///
+ [NotMapped]
+ public string TeachMajorNo { get; set; }
#endregion
}
diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanLesson/Exam_ExamPlanLessonService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanLesson/Exam_ExamPlanLessonService.cs
index 33ddb0c9f..a758d7769 100644
--- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanLesson/Exam_ExamPlanLessonService.cs
+++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanLesson/Exam_ExamPlanLessonService.cs
@@ -419,36 +419,108 @@ and AcademicYearNo='{exam_ExamPlan.AcademicYearNo}' and Semester='{exam_ExamPlan
///
public (bool flag, string msg) PlanLessonTimeByEPId(string EPId)
{
+ var db = this.BaseRepository("CollegeMIS");
try
{
/*
- * 1.查询考试记录是否已安排时间
+ * 1.查询考试记录是否已批量安排公共课专业课时间
* 2.查询考试课程的考试时长是否大于0
- * 3.同一时间段内只能一个专业安排一门课程
+ * 3.清除考试课程时间 重新安排
+ * 4.同一时间段内只能一个专业安排一门课程
*/
-
+ db.BeginTrans();
+ //考试记录
+ var examPlan = db.FindEntity(EPId);
//安排时间数据
- var EPTimeList = this.BaseRepository("CollegeMIS")
- .FindList(x => x.EPId == EPId);
+ var EPTimeList = db.FindList(x => x.EPId == EPId);
if (EPTimeList.Count() <= 0)
{
return (false, "请先安排考试记录时间!");
}
//考试课程数据
- var EPLessonList = this.BaseRepository("CollegeMIS")
- .FindList($@"select elesson.ExamTime as ExamLength,t.* from Exam_ExamPlanLesson t
+ var EPLessonList = db.FindList($@" select distinct elesson.ExamTime as ExamLength,ltype.LessonTypeName,info.TeachMajorNo,t.* from Exam_ExamPlanLesson t
join Exam_ExamLesson elesson on t.LessonNo=elesson.LessonNo
- where t.EPId='{EPId}'");
- if (EPLessonList.ToList().Exists(x => x.ExamLength == null || x.ExamLength == 0))
+left join LessonInfo info on t.LessonNo=info.LessonNo
+left join CdLessonType ltype on info.LessonTypeId=ltype.LTId
+ where t.EPId='{EPId}' and info.CheckMark=1 ");
+ if (examPlan.PlanType == "1")
+ {
+ //必修
+ EPLessonList = db.FindList($@" select distinct elesson.ExamTime as ExamLength,ltype.LessonTypeName,info.TeachMajorNo,t.* from Exam_ExamPlanLesson t
+join Exam_ExamLesson elesson on left(t.LessonNo,charindex('(',t.LessonNo)-1)=elesson.LessonNo
+left join LessonInfo info on left(t.LessonNo,charindex('(',t.LessonNo)-1)=info.LessonNo
+left join CdLessonType ltype on info.LessonTypeId=ltype.LTId
+ where t.EPId='{EPId}' and info.CheckMark=1 ");
+ }
+
+ if (EPLessonList.ToList().Exists(x => x.ExamLength == null || x.ExamLength <= 0))
{
return (false, "请先设置考试课程时长!");
}
-
-
+ //清除考试时间
+ db.ExecuteBySql(
+ $"update Exam_ExamPlanLesson set ExamDate=NULL,ExamTime=NULL where EPId='{EPId}'");
+ //循环考试课程数据,设置考试时间
+ foreach (var EPLesson in EPLessonList)
+ {
+ if (EPLesson.LessonTypeName.Contains("公共") || EPLesson.LessonTypeName.Contains("公开"))
+ {
+ var EPTimes = EPTimeList.Where(x => x.ExamType == "2" && x.ExamTimeLength == EPLesson.ExamLength).ToList();
+ foreach (var EPTime in EPTimes)
+ {
+ var time = EPTime.ExamTimeStart + "-" + EPTime.ExamTimeEnd;
+ //不存在同专业同时间段的考试课程,修改考试时间
+ if (!EPLessonList.ToList().Exists(x =>
+ x.TeachMajorNo == EPLesson.TeachMajorNo && x.ExamLength == EPTime.ExamTimeLength && x.ExamDate != null &&
+ x.ExamDate == EPTime.ExamDate && x.ExamTime == time))
+ {
+ EPLesson.ExamDate = EPTime.ExamDate;
+ EPLesson.ExamTime = time;
+ db.ExecuteBySql(
+ $"update Exam_ExamPlanLesson set ExamDate='{EPTime.ExamDate}',ExamTime='{time}' where EPLId='{EPLesson.EPLId}'");
+ break;
+ }
+ else
+ {
+ //存在同专业同时间段的考试课程,继续循环安排时间数据
+ continue;
+ }
+ }
+ }
+ else
+ {
+ //专业课
+ var EPTimes = EPTimeList.Where(x => x.ExamType == "1" && x.ExamTimeLength == EPLesson.ExamLength).ToList();
+ foreach (var EPTime in EPTimes)
+ {
+ var time = EPTime.ExamTimeStart + "-" + EPTime.ExamTimeEnd;
+ //不存在同专业同时间段的考试课程,修改考试时间
+ if (!EPLessonList.ToList().Exists(x =>
+ x.TeachMajorNo == EPLesson.TeachMajorNo && x.ExamLength == EPTime.ExamTimeLength && x.ExamDate != null &&
+ x.ExamDate == EPTime.ExamDate && x.ExamTime == time))
+ {
+
+ EPLesson.ExamDate = EPTime.ExamDate;
+ EPLesson.ExamTime = time;
+ db.ExecuteBySql(
+ $"update Exam_ExamPlanLesson set ExamDate='{EPTime.ExamDate}',ExamTime='{time}' where EPLId='{EPLesson.EPLId}'");
+ break;
+ }
+ else
+ {
+ //存在同专业同时间段的考试课程,继续循环安排时间数据
+ continue;
+ }
+ }
+ }
+ }
+
+ db.Commit();
return (true, "");
}
catch (Exception ex)
{
+ db.Rollback();
if (ex is ExceptionEx)
{
throw;