Browse Source

自动生成考试课程排考时间

新疆影视学院高职
zhangli 2 years ago
parent
commit
7f210ed12e
3 changed files with 104 additions and 13 deletions
  1. +10
    -1
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/Exam_ExamPlanController.cs
  2. +11
    -1
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanLesson/Exam_ExamPlanLessonEntity.cs
  3. +83
    -11
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanLesson/Exam_ExamPlanLessonService.cs

+ 10
- 1
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/Exam_ExamPlanController.cs View File

@@ -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("操作成功!");
}



+ 11
- 1
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanLesson/Exam_ExamPlanLessonEntity.cs View File

@@ -112,7 +112,17 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
/// 考试时长
/// </summary>
[NotMapped]
public int? ExamLength { get; set; }
public double? ExamLength { get; set; }
/// <summary>
/// 课程类型
/// </summary>
[NotMapped]
public string LessonTypeName { get; set; }
/// <summary>
/// 专业
/// </summary>
[NotMapped]
public string TeachMajorNo { get; set; }

#endregion
}


+ 83
- 11
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanLesson/Exam_ExamPlanLessonService.cs View File

@@ -419,36 +419,108 @@ and AcademicYearNo='{exam_ExamPlan.AcademicYearNo}' and Semester='{exam_ExamPlan
/// <returns></returns>
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<Exam_ExamPlanEntity>(EPId);
//安排时间数据
var EPTimeList = this.BaseRepository("CollegeMIS")
.FindList<Exam_ExamPlanTimeEntity>(x => x.EPId == EPId);
var EPTimeList = db.FindList<Exam_ExamPlanTimeEntity>(x => x.EPId == EPId);
if (EPTimeList.Count() <= 0)
{
return (false, "请先安排考试记录时间!");
}
//考试课程数据
var EPLessonList = this.BaseRepository("CollegeMIS")
.FindList<Exam_ExamPlanLessonEntity>($@"select elesson.ExamTime as ExamLength,t.* from Exam_ExamPlanLesson t
var EPLessonList = db.FindList<Exam_ExamPlanLessonEntity>($@" 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<Exam_ExamPlanLessonEntity>($@" 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;


Loading…
Cancel
Save