diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/TimeTable.cs b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/TimeTable.cs index 457e01c62..802e4e02f 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/TimeTable.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/TimeTable.cs @@ -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(); + 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 { }); + } + + /// + /// 获取当前日期是第几周 + /// + /// + 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 }); + } /// /// 课程表【教师功能、学生功能】 @@ -112,7 +174,7 @@ namespace Learun.Application.WebApi.Modules } - + /// /// 全院课程表【按班级分组】 /// @@ -170,11 +232,120 @@ namespace Learun.Application.WebApi.Modules }).OrderBy(x => x.LessonSortNo).ThenBy(x => x.ClassNo).ToList(); result.ClassDataList = dataTemp; - + return Success(result); } + /// + /// 课程表【教师功能、学生功能】 + /// + /// + /// + public Response GetTenDay(dynamic _) + { + var param = this.GetReqData(); + 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(); + 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); + + } /// /// 数字转中文 /// @@ -219,40 +390,71 @@ namespace Learun.Application.WebApi.Modules } return res; } - } + /// + /// 换算周次 + /// + /// + /// + /// + /// + 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; } - /// - /// 班级编号 - /// - public string ClassNo { get; set; } - /// - /// 教师编号 - /// - 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 { get; set; } - } - public class ClassDataList - { - public string ClassNo { get; set; } - public string ClassName { get; set; } - public string LessonSortNo { get; set; } - public List TimeTableList { get; set; } + } } +} + + +public class TimeParameter +{ + public string StartDate { get; set; } + public string EndDate { get; set; } + /// + /// 班级编号 + /// + public string ClassNo { get; set; } + /// + /// 教师编号 + /// + 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 { get; set; } +} +public class ClassDataList +{ + public string ClassNo { get; set; } + public string ClassName { get; set; } + public string LessonSortNo { get; set; } + public List TimeTableList { get; set; } } \ No newline at end of file diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermBLL.cs index d3c1b684a..68c3624c4 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermBLL.cs @@ -43,7 +43,24 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } } } - + public IEnumerable GetListForTimeTable(string queryJson) + { + try + { + return arrangeLessonTermService.GetListForTimeTable(queryJson); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } /// /// 获取列表分页数据 /// 分页参数 diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermIBLL.cs index 0e921fd08..ce5281fcc 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermIBLL.cs @@ -48,6 +48,8 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration /// /// IEnumerable GetList(string queryJson); + + IEnumerable GetListForTimeTable(string queryJson); Task AsyncArrangeLessonData(); Task AsyncModifyArrangeLessonData(); diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermService.cs index 12e74d8e0..fc56e63a5 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermService.cs @@ -110,7 +110,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } if (!queryParam["TeachClassNo"].IsEmpty()) { - dp.Add("TeachClassNo", "%"+queryParam["TeachClassNo"].ToString(), DbType.String); + dp.Add("TeachClassNo", "%" + queryParam["TeachClassNo"].ToString(), DbType.String); strSql.Append(" AND t.TeachClassNo like @TeachClassNo "); } if (!queryParam["EmpNo"].IsEmpty()) @@ -124,7 +124,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration strSql.Append(" AND t.ClassroomNo = @ClassroomNo "); } - return this.BaseRepository("CollegeMIS").FindList(strSql.ToString(),dp); + return this.BaseRepository("CollegeMIS").FindList(strSql.ToString(), dp); } catch (Exception ex) { @@ -139,6 +139,74 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } } + public IEnumerable GetListForTimeTable(string queryJson) + { + try + { + //参考写法 + var queryParam = queryJson.ToJObject(); + // 虚拟参数 + var dp = new DynamicParameters(new { }); + + var strSql = new StringBuilder(); + strSql.Append("SELECT LessonDate,AcademicYearNo,Semester"); + strSql.Append(" FROM ArrangeLessonTerm t where 1=1 "); + + if (!queryParam["AcademicYearNo"].IsEmpty()) + { + dp.Add("AcademicYearNo", queryParam["AcademicYearNo"].ToString(), DbType.String); + strSql.Append(" AND t.AcademicYearNo = @AcademicYearNo "); + } + if (!queryParam["Semester"].IsEmpty()) + { + dp.Add("Semester", queryParam["Semester"].ToString(), DbType.String); + strSql.Append(" AND t.Semester = @Semester "); + } + if (!queryParam["DeptNo"].IsEmpty()) + { + dp.Add("DeptNo", queryParam["DeptNo"].ToString(), DbType.String); + strSql.Append(" AND t.DeptNo = @DeptNo "); + } + if (!queryParam["MajorNo"].IsEmpty()) + { + dp.Add("MajorNo", queryParam["MajorNo"].ToString(), DbType.String); + strSql.Append(" AND t.MajorNo = @MajorNo "); + } + if (!queryParam["LessonNo"].IsEmpty()) + { + dp.Add("LessonNo", queryParam["LessonNo"].ToString(), DbType.String); + strSql.Append(" AND t.LessonNo = @LessonNo "); + } + if (!queryParam["TeachClassNo"].IsEmpty()) + { + dp.Add("TeachClassNo", "%" + queryParam["TeachClassNo"].ToString(), DbType.String); + strSql.Append(" AND t.TeachClassNo like @TeachClassNo "); + } + if (!queryParam["EmpNo"].IsEmpty()) + { + dp.Add("EmpNo", queryParam["EmpNo"].ToString(), DbType.String); + strSql.Append(" AND t.EmpNo = @EmpNo "); + } + if (!queryParam["ClassroomNo"].IsEmpty()) + { + dp.Add("ClassroomNo", queryParam["ClassroomNo"].ToString(), DbType.String); + strSql.Append(" AND t.ClassroomNo = @ClassroomNo "); + } + + return this.BaseRepository("CollegeMIS").FindList(strSql.ToString(), dp); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowServiceException(ex); + } + } + } internal IEnumerable GetListByEmpNo(List empNos) { try @@ -2063,6 +2131,8 @@ group by AcademicYearNo,Semester,DeptNo,MajorNo,LessonNo,TeachClassNo,EmpNo,Les { public DateTime LessonDate { get; set; } public string EnName { get; set; } + public string ALTId { get; set; } + public string AcademicYear { get; set; } public string LessonNo { get; set; } public string LessonName { get; set; } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/SchoolCalendar/SchoolCalendarBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/SchoolCalendar/SchoolCalendarBLL.cs index 8567cd653..1e76289f1 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/SchoolCalendar/SchoolCalendarBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/SchoolCalendar/SchoolCalendarBLL.cs @@ -90,7 +90,24 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } } } - + public SchoolCalendarEntity GetSchoolCalendarEntityByNo(string academicYearNo, string semester) + { + try + { + return schoolCalendarService.GetSchoolCalendarEntityByNo(academicYearNo, semester); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } #endregion #region 提交数据 diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/SchoolCalendar/SchoolCalendarIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/SchoolCalendar/SchoolCalendarIBLL.cs index a17ed9417..1d9f65391 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/SchoolCalendar/SchoolCalendarIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/SchoolCalendar/SchoolCalendarIBLL.cs @@ -34,6 +34,12 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration /// /// SchoolCalendarEntity GetSchoolCalendarEntity(string keyValue); + /// + /// 根据学年获取SchoolCalendar表实体数据 + /// 主键 + /// + /// + SchoolCalendarEntity GetSchoolCalendarEntityByNo(string academicYearNo, string semester); #endregion #region 提交数据 diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/SchoolCalendar/SchoolCalendarService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/SchoolCalendar/SchoolCalendarService.cs index 2ba4e5aff..d52577f53 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/SchoolCalendar/SchoolCalendarService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/SchoolCalendar/SchoolCalendarService.cs @@ -141,7 +141,29 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } } } - + /// + /// 获取SchoolCalendar表实体数据 + /// 主键 + /// + /// + public SchoolCalendarEntity GetSchoolCalendarEntityByNo(string academicYearNo, string semester) + { + try + { + return this.BaseRepository().FindEntity(x => x.AcademicYearNo == academicYearNo && x.Semester == semester); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowServiceException(ex); + } + } + } #endregion #region 提交数据 diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuAttendanceLeave/StuAttendanceLeaveBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuAttendanceLeave/StuAttendanceLeaveBLL.cs index 2eee75bfe..fe5e46fdf 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuAttendanceLeave/StuAttendanceLeaveBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuAttendanceLeave/StuAttendanceLeaveBLL.cs @@ -110,6 +110,29 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } } } + /// + /// 获取页面显示列表数据 + /// + /// 查询参数 + /// + public IEnumerable GetListByJson(string queryJson) + { + try + { + return stuAttendanceLeaveService.GetListByJson(queryJson); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } #endregion diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuAttendanceLeave/StuAttendanceLeaveIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuAttendanceLeave/StuAttendanceLeaveIBLL.cs index 99d81538e..8b6b5827f 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuAttendanceLeave/StuAttendanceLeaveIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuAttendanceLeave/StuAttendanceLeaveIBLL.cs @@ -36,6 +36,8 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration /// /// StuAttendanceLeaveEntity GetStuAttendanceLeaveEntity(string keyValue); + IEnumerable GetListByJson(string queryJson); + #endregion #region 提交数据 diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuAttendanceLeave/StuAttendanceLeaveService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuAttendanceLeave/StuAttendanceLeaveService.cs index fbce92265..93210fd67 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuAttendanceLeave/StuAttendanceLeaveService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuAttendanceLeave/StuAttendanceLeaveService.cs @@ -211,6 +211,74 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } } + /// + /// 获取页面显示列表数据 + /// + /// 查询参数 + /// + public IEnumerable GetListByJson(string queryJson) + { + try + { + var strSql = new StringBuilder(); + strSql.Append("SELECT t.* "); + strSql.Append(" FROM StuAttendanceLeave t"); + strSql.Append(" WHERE 1=1 "); + var queryParam = queryJson.ToJObject(); + // 虚拟参数 + var dp = new DynamicParameters(new { }); + if (!queryParam["LessonName"].IsEmpty()) + { + dp.Add("LessonName", "%" + queryParam["LessonName"].ToString() + "%", DbType.String); + strSql.Append(" AND t.LessonName Like @LessonName "); + } + if (!queryParam["Grade"].IsEmpty()) + { + dp.Add("Grade", queryParam["Grade"].ToString(), DbType.String); + strSql.Append(" AND t.Grade = @Grade "); + } + if (!queryParam["StuNo"].IsEmpty()) + { + dp.Add("StuNo", queryParam["StuNo"].ToString(), DbType.String); + strSql.Append(" AND t.StuNo = @StuNo "); + } + if (!queryParam["StuName"].IsEmpty()) + { + dp.Add("StuName", "%" + queryParam["StuName"].ToString() + "%", DbType.String); + strSql.Append(" AND t.StuName Like @StuName "); + } + if (!queryParam["EmpNo"].IsEmpty()) + { + dp.Add("EmpNo", "%" + queryParam["EmpNo"].ToString() + "%", DbType.String); + strSql.Append(" AND t.EmpNo Like @EmpNo "); + } + if (!queryParam["AcademicYearNo"].IsEmpty()) + { + dp.Add("AcademicYearNo", queryParam["AcademicYearNo"].ToString(), DbType.String); + strSql.Append(" AND t.AcademicYearNo = @AcademicYearNo "); + } + if (!queryParam["Semester"].IsEmpty()) + { + dp.Add("Semester", queryParam["Semester"].ToString(), DbType.String); + strSql.Append(" AND t.Semester = @Semester "); + } + var result = this.BaseRepository("CollegeMIS").FindList(strSql.ToString(), dp); + + return result; + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowServiceException(ex); + } + } + } + #endregion #region 提交数据 diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Time/Time.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Time/Time.cs index f0eaa54f6..efbcfa636 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Time/Time.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Time/Time.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Globalization; namespace Learun.Util @@ -503,6 +504,32 @@ namespace Learun.Util return strDate; } #endregion + + /// + /// 获取当前日期在指定时间范围内是第几周 + /// + /// + /// + /// + public static int GetWeekOfDay(DateTime start, DateTime end) + { + //总周数 + var weekCount = Math.Ceiling(Convert.ToDouble((end - start).Days / 7)); + //用于存储日期 + var weekDic = new Dictionary(); + + var today = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); + + for (var i = 0; i < weekCount; i++) + { + for (var j = 0; j < 7; j++) + { + weekDic.Add(start.AddDays(i * 7 + j), i + 1); + } + } + + return weekDic.ContainsKey(today) ? weekDic[today] : 1; + } /// /// 获取当前日期是星期几 ///