Browse Source

app2.0手机端获取课程表 默认查询当前周次的课表

临城职教中职
ndbs 2 years ago
parent
commit
7c8d3f8e3b
1 changed files with 37 additions and 4 deletions
  1. +37
    -4
      Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/TimeTable.cs

+ 37
- 4
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/TimeTable.cs View File

@@ -202,12 +202,16 @@ 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(13).ToString("yyyy-MM-dd");
endDate = Common.CalculateFirstDateOfWeek(StartTime.AddDays(((curWeek - 1) * 14))).AddDays(13)
.ToString("yyyy-MM-dd");
param.StartDate = startDate;
param.EndDate = endDate;
}
@@ -311,10 +315,39 @@ 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


Loading…
Cancel
Save