|
|
@@ -6,6 +6,7 @@ using System.Data.SqlClient; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using System.Web; |
|
|
|
using System.Web.Helpers; |
|
|
|
using Learun.Application.Organization; |
|
|
|
using Learun.Application.TwoDevelopment.EducationalAdministration; |
|
|
|
using Learun.Util; |
|
|
@@ -13,7 +14,7 @@ using Nancy; |
|
|
|
|
|
|
|
namespace Learun.Application.WebApi.Modules |
|
|
|
{ |
|
|
|
public class TimeTable : BaseNoLoginApi |
|
|
|
public class TimeTable : BaseApi |
|
|
|
{ |
|
|
|
public TimeTable() |
|
|
|
: base("/learun/adms/timetable") |
|
|
@@ -22,11 +23,72 @@ namespace Learun.Application.WebApi.Modules |
|
|
|
Get["/StuList"] = GetStuInfo; |
|
|
|
Get["/StuLessonInfo"] = GetStuLessonInfo; |
|
|
|
Get["/timeTableData"] = GetTimeTableData; |
|
|
|
Get["/weeklist"] = GetWeeksData; |
|
|
|
Get["/currentweek"] = GetCurrentWeek; |
|
|
|
Get["/TenDay"] = GetTenDay; |
|
|
|
} |
|
|
|
private ArrangeLessonTermIBLL arrangeLessonTermIBLL = new ArrangeLessonTermBLL(); |
|
|
|
private ArrangeLessonTermOfElectiveIBLL arrangeLessonTermOfElectiveIBLL = new ArrangeLessonTermOfElectiveBLL(); |
|
|
|
private StuAttendanceLeaveIBLL stuAttendanceLeaveIBLL = new StuAttendanceLeaveBLL(); |
|
|
|
private StuAttendanceIBLL stuAttendanceIBLL = new StuAttendanceBLL(); |
|
|
|
private EmpInfoIBLL empInfoIbll = new EmpInfoBLL(); |
|
|
|
private StuInfoBasicIBLL stuInfoBasicIBLL = new StuInfoBasicBLL(); |
|
|
|
private SchoolCalendarIBLL schoolCalendarIbll = new SchoolCalendarBLL(); |
|
|
|
|
|
|
|
public class WeekDate |
|
|
|
{ |
|
|
|
public int week { get; set; } |
|
|
|
public string startdate { get; set; } |
|
|
|
public string enddate { get; set; } |
|
|
|
public string textweek { get; set; } |
|
|
|
} |
|
|
|
public Response GetWeeksData(dynamic _) |
|
|
|
{ |
|
|
|
var weekdatelist = new List<WeekDate>(); |
|
|
|
var yearsemester = Common.GetSemesterAndYear(); |
|
|
|
var arrangelessonlist = arrangeLessonTermIBLL.GetListForTimeTable("{\"AcademicYearNo\":\"" + yearsemester.AcademicYearShort + "\",\"Semester\":\"" + yearsemester.Semester + "\"}").OrderBy(m => m.LessonDate); |
|
|
|
if (arrangelessonlist.Any()) |
|
|
|
{ |
|
|
|
var firstday = arrangelessonlist.First(); |
|
|
|
var lastday = arrangelessonlist.Last(); |
|
|
|
var monday = firstday.LessonDate.Value.AddDays(-Convert.ToInt32(firstday.LessonDate.Value.DayOfWeek) + 1); |
|
|
|
var sunday = lastday.LessonDate.Value.AddDays(7 - Convert.ToInt32(lastday.LessonDate.Value.DayOfWeek)); |
|
|
|
//总周数 |
|
|
|
var weekCount = Math.Ceiling(Convert.ToDouble((sunday - monday).Days + 1) / 7); |
|
|
|
for (var i = 0; i < weekCount; i++) |
|
|
|
{ |
|
|
|
var wentity = new WeekDate(); |
|
|
|
wentity.week = i + 1; |
|
|
|
wentity.startdate = monday.AddDays(i * 7).ToString("yyyy-MM-dd"); |
|
|
|
wentity.enddate = monday.AddDays(i * 7 + 6).ToString("yyyy-MM-dd"); |
|
|
|
wentity.textweek = "第" + wentity.week + "周 (" + wentity.startdate + "~" + wentity.enddate + ")"; |
|
|
|
weekdatelist.Add(wentity); |
|
|
|
} |
|
|
|
return Success(weekdatelist); |
|
|
|
} |
|
|
|
else |
|
|
|
return Success(new { }); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 获取当前日期是第几周 |
|
|
|
/// </summary> |
|
|
|
/// <returns></returns> |
|
|
|
public Response GetCurrentWeek(dynamic _) |
|
|
|
{ |
|
|
|
var yearsemester = Common.GetSemesterAndYear(); |
|
|
|
var arrangelessonlist = arrangeLessonTermIBLL.GetListForTimeTable("{\"AcademicYearNo\":\"" + yearsemester.AcademicYearShort + "\",\"Semester\":\"" + yearsemester.Semester + "\"}").OrderBy(m => m.LessonDate); |
|
|
|
if (arrangelessonlist.Any()) |
|
|
|
{ |
|
|
|
var firstday = arrangelessonlist.First(); |
|
|
|
var lastday = arrangelessonlist.Last(); |
|
|
|
var monday = firstday.LessonDate.Value.AddDays(-(Convert.ToInt32(firstday.LessonDate.Value.DayOfWeek) == 0 ? 7 : Convert.ToInt32(firstday.LessonDate.Value.DayOfWeek)) + 1); |
|
|
|
var sunday = lastday.LessonDate.Value.AddDays(7 - (Convert.ToInt32(lastday.LessonDate.Value.DayOfWeek) == 0 ? 7 : Convert.ToInt32(lastday.LessonDate.Value.DayOfWeek))); |
|
|
|
var currentweek = Util.Time.GetWeekOfDay(monday, sunday); |
|
|
|
return Success(new { currentweek }); |
|
|
|
} |
|
|
|
return Success(new { currentweek = 1 }); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 课程表【教师功能、学生功能】 |
|
|
@@ -112,7 +174,7 @@ namespace Learun.Application.WebApi.Modules |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 全院课程表【按班级分组】 |
|
|
|
/// </summary> |
|
|
@@ -170,11 +232,120 @@ namespace Learun.Application.WebApi.Modules |
|
|
|
}).OrderBy(x => x.LessonSortNo).ThenBy(x => x.ClassNo).ToList(); |
|
|
|
|
|
|
|
result.ClassDataList = dataTemp; |
|
|
|
|
|
|
|
|
|
|
|
return Success(result); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 课程表【教师功能、学生功能】 |
|
|
|
/// </summary> |
|
|
|
/// <param name="_"></param> |
|
|
|
/// <returns></returns> |
|
|
|
public Response GetTenDay(dynamic _) |
|
|
|
{ |
|
|
|
var param = this.GetReqData<TimeParameter>(); |
|
|
|
var startdate = DateTime.Today; |
|
|
|
var startDate = Common.CalculateFirstDateOfWeek(startdate).ToString("yyyy-MM-dd"); |
|
|
|
var endDate = Common.CalculateLastDateOfWeek(startdate).ToString("yyyy-MM-dd"); |
|
|
|
|
|
|
|
// 获取学年,学期 |
|
|
|
var strAcademicYear = ""; |
|
|
|
var strSemester = ""; |
|
|
|
var AcademicYearShort = ""; |
|
|
|
if (!param.StartDate.IsEmpty()) |
|
|
|
{ |
|
|
|
var NewsemesterAndYear = Common.GetSemesterAndYear(param.StartDate); |
|
|
|
strAcademicYear = NewsemesterAndYear.AcademicYearLong; |
|
|
|
strSemester = NewsemesterAndYear.Semester; |
|
|
|
AcademicYearShort = NewsemesterAndYear.AcademicYearShort; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var semesterAndYear = Common.GetSemesterAndYear(startDate); |
|
|
|
strAcademicYear = semesterAndYear.AcademicYearLong; |
|
|
|
strSemester = semesterAndYear.Semester; |
|
|
|
AcademicYearShort = semesterAndYear.AcademicYearShort; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (param.StartDate.IsEmpty() && param.EndDate.IsEmpty()) |
|
|
|
{ |
|
|
|
// 校历 |
|
|
|
var entity = schoolCalendarIbll.GetSchoolCalendarEntityByNo(AcademicYearShort, strSemester); |
|
|
|
var StartTime = entity.StartTime.Value; |
|
|
|
//获取第几周 |
|
|
|
var curWeek = WeekOfYear(startdate, entity.StartTime.Value, entity.EndTime.Value); |
|
|
|
///获取当前周次开始时间 |
|
|
|
startDate = Common.CalculateFirstDateOfWeek(StartTime.AddDays(((curWeek - 1) * 14))).ToString("yyyy-MM-dd"); |
|
|
|
if (curWeek == 1 && Convert.ToDateTime(startDate) < StartTime)//判断第几周 |
|
|
|
{ |
|
|
|
startDate = StartTime.ToString("yyyy-MM-dd"); |
|
|
|
} |
|
|
|
endDate = Common.CalculateFirstDateOfWeek(StartTime.AddDays(((curWeek - 1) * 14))).AddDays(13).ToString("yyyy-MM-dd"); |
|
|
|
param.StartDate = startDate; |
|
|
|
param.EndDate = endDate; |
|
|
|
} |
|
|
|
var Data = new List<TwoDevelopment.EducationalAdministration.TimeTable>(); |
|
|
|
if (param.Description == "学生") |
|
|
|
{ |
|
|
|
var Stulist = stuInfoBasicIBLL.GetAllList().Where(x => x.StuNo == param.Account).FirstOrDefault(); |
|
|
|
if (Stulist != null) |
|
|
|
{ |
|
|
|
Data = arrangeLessonTermIBLL.GetTimeTableInEducation(param.StartDate, param.EndDate, Stulist.ClassNo, "", "").ToList(); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (param.Description == "教师") |
|
|
|
{ |
|
|
|
//教师 |
|
|
|
var empInfo = empInfoIbll.GetAllList().Where(x => x.EmpNo == param.Account).FirstOrDefault().EmpNo; |
|
|
|
if (empInfo != null) |
|
|
|
{ |
|
|
|
Data = arrangeLessonTermIBLL.GetTimeTableInEducation(param.StartDate, param.EndDate, "", param.Account, "").ToList(); |
|
|
|
} |
|
|
|
} |
|
|
|
//学生课表请假记录 |
|
|
|
var leaveList = stuAttendanceLeaveIBLL.GetListByJson("{\"StuNo\":\"" + userInfo.account + "\"}"); |
|
|
|
var formatData = from d in Data.AsEnumerable() |
|
|
|
let tt = d.LessonTime.Split('-')[0] |
|
|
|
group d by tt into g |
|
|
|
orderby g.Key |
|
|
|
select new |
|
|
|
{ |
|
|
|
time = g.Key, |
|
|
|
list = from e in Data.AsEnumerable() |
|
|
|
let ee = e.LessonTime.Split('-')[0] |
|
|
|
where ee == g.Key |
|
|
|
select new |
|
|
|
{ |
|
|
|
ALTId = e.ALTId, |
|
|
|
day = e.LessonTime.Split('-')[0], |
|
|
|
jc = e.LessonTime.Split('-')[1], |
|
|
|
curriculum = e.LessonSortNo == "2" ? e.LessonName + "[选修]" : e.LessonName, |
|
|
|
teacher = e?.EmpName, |
|
|
|
classRoom = string.IsNullOrEmpty(e.ClassroomName) ? "" : e.ClassroomName.Trim(), |
|
|
|
academicyear = e.AcademicYear, |
|
|
|
semester = e.Semester, |
|
|
|
lessonNo = e?.LessonNo, |
|
|
|
teachClassNo = e?.TeachClassNo, |
|
|
|
empno = e?.EmpNo, |
|
|
|
lessonTime = e.LessonTime, |
|
|
|
lessonDate = e.LessonDate.ToString("yyyy-MM-dd"), |
|
|
|
classRoomNo = string.IsNullOrEmpty(e.ClassRoomNo) ? "" : e.ClassRoomNo.Trim(), |
|
|
|
lessonSortNo = e.LessonSortNo, |
|
|
|
e?.OLPEId, |
|
|
|
className = string.IsNullOrEmpty(e.ClassName) ? "" : e.ClassName, |
|
|
|
leaveType = leaveList.Any(c => c.LessonNo == e?.LessonNo && c.LessonDate == e.LessonDate && c.LessonTime == e.LessonTime) ? 1 : 0, |
|
|
|
checkType = leaveList.FirstOrDefault(c => c.LessonNo == e?.LessonNo && c.LessonDate == e.LessonDate && c.LessonTime == e.LessonTime)?.IsCheck, |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
; |
|
|
|
var result = new |
|
|
|
{ schoolName = "课程表", semester = $"{strAcademicYear}学年度 第{strSemester}学期", startDate = param.StartDate, endDate = param.EndDate, weekList = formatData }; |
|
|
|
return Success(result); |
|
|
|
|
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// 数字转中文 |
|
|
|
/// </summary> |
|
|
@@ -219,40 +390,71 @@ namespace Learun.Application.WebApi.Modules |
|
|
|
} |
|
|
|
return res; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 换算周次 |
|
|
|
/// </summary> |
|
|
|
/// <param name="curDay"></param> |
|
|
|
/// <param name="startTime"></param> |
|
|
|
/// <param name="endTime"></param> |
|
|
|
/// <returns></returns> |
|
|
|
private static int WeekOfYear(DateTime curDay, DateTime startTime, DateTime endTime) |
|
|
|
{ |
|
|
|
int firstdayofweek = Convert.ToInt32(startTime.DayOfWeek); |
|
|
|
var startDate = DateTime.Parse(Common.CalculateFirstDateOfWeek(startTime).ToString("yyyy-MM-dd")); |
|
|
|
int k = Convert.ToInt32(startTime.DayOfWeek);//得到开始时间的第一天是周几 |
|
|
|
int days = curDay.Subtract(startTime).Days; |
|
|
|
//int days = curDay.DayOfYear; |
|
|
|
int daysOutOneWeek = days - (14 - firstdayofweek); |
|
|
|
|
|
|
|
if (daysOutOneWeek <= 0) |
|
|
|
{ |
|
|
|
return 1; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
int weeks = daysOutOneWeek / 14; |
|
|
|
if (daysOutOneWeek % 14 != 0) |
|
|
|
weeks++; |
|
|
|
|
|
|
|
return weeks + 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public class TimeParameter |
|
|
|
{ |
|
|
|
public string StartDate { get; set; } |
|
|
|
public string EndDate { get; set; } |
|
|
|
/// <summary> |
|
|
|
/// 班级编号 |
|
|
|
/// </summary> |
|
|
|
public string ClassNo { get; set; } |
|
|
|
/// <summary> |
|
|
|
/// 教师编号 |
|
|
|
/// </summary> |
|
|
|
public string EmpNo { get; set; } |
|
|
|
} |
|
|
|
public class TimeTableData |
|
|
|
{ |
|
|
|
public string AcademicYearNo { get; set; } |
|
|
|
public string Semester { get; set; } |
|
|
|
public string StartDate { get; set; } |
|
|
|
public string EndDate { get; set; } |
|
|
|
public List<ClassDataList> ClassDataList { get; set; } |
|
|
|
} |
|
|
|
public class ClassDataList |
|
|
|
{ |
|
|
|
public string ClassNo { get; set; } |
|
|
|
public string ClassName { get; set; } |
|
|
|
public string LessonSortNo { get; set; } |
|
|
|
public List<TwoDevelopment.EducationalAdministration.TimeTable> TimeTableList { get; set; } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class TimeParameter |
|
|
|
{ |
|
|
|
public string StartDate { get; set; } |
|
|
|
public string EndDate { get; set; } |
|
|
|
/// <summary> |
|
|
|
/// 班级编号 |
|
|
|
/// </summary> |
|
|
|
public string ClassNo { get; set; } |
|
|
|
/// <summary> |
|
|
|
/// 教师编号 |
|
|
|
/// </summary> |
|
|
|
public string EmpNo { get; set; } |
|
|
|
public string Description { get; set; } |
|
|
|
public string Account { get; set; } |
|
|
|
} |
|
|
|
public class TimeTableData |
|
|
|
{ |
|
|
|
public string AcademicYearNo { get; set; } |
|
|
|
public string Semester { get; set; } |
|
|
|
public string StartDate { get; set; } |
|
|
|
public string EndDate { get; set; } |
|
|
|
public List<ClassDataList> ClassDataList { get; set; } |
|
|
|
} |
|
|
|
public class ClassDataList |
|
|
|
{ |
|
|
|
public string ClassNo { get; set; } |
|
|
|
public string ClassName { get; set; } |
|
|
|
public string LessonSortNo { get; set; } |
|
|
|
public List<Learun.Application.TwoDevelopment.EducationalAdministration.TimeTable> TimeTableList { get; set; } |
|
|
|
} |