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 8157c1b0d..934781095 100644
--- a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/TimeTable.cs
+++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/TimeTable.cs
@@ -202,12 +202,15 @@ namespace Learun.Application.WebApi.Modules
// 校历
var entity = schoolCalendarIbll.GetSchoolCalendarEntityByNo(semesterAndYear.AcademicYearShort, semesterAndYear.Semester);
var StartTime = entity.StartTime.Value;
- startDate = Common.CalculateFirstDateOfWeek(StartTime.AddDays(3)).ToString("yyyy-MM-dd");//StartTime.AddDays(((curWeek - 1) * 14)).ToString("yyyy-MM-dd");
- if (Convert.ToDateTime(startDate) < StartTime)
+ //获取第几周
+ 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(12).ToString("yyyy-MM-dd");
+ endDate = Common.CalculateFirstDateOfWeek(StartTime.AddDays(((curWeek - 1) * 14))).AddDays(9).ToString("yyyy-MM-dd");
param.StartDate = startDate;
param.EndDate = endDate;
}
@@ -311,6 +314,37 @@ 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;
+
+ }
+
+ }
}