|
|
@@ -290,7 +290,7 @@ namespace Learun.Application.WebApi |
|
|
|
private Response OaNews(dynamic _) |
|
|
|
{ |
|
|
|
var beginTime = DateTime.Now.AddMonths(-12); |
|
|
|
var data = noticeIBLL.GetList("", ""); |
|
|
|
var data = newsIbll.GetNews(); |
|
|
|
var news = data.Where(a => a.F_ReleaseTime >= beginTime && a.F_ReleaseTime <= DateTime.Now); |
|
|
|
var monthNews = news.GroupBy(a => a.F_ReleaseTime.ToDate().Month).Select(a => new { a.Key, num = a.Count() }).OrderBy(a => a.Key); |
|
|
|
var monthList = monthNews.Select(a => a.Key).ToList(); |
|
|
@@ -491,56 +491,86 @@ namespace Learun.Application.WebApi |
|
|
|
{ |
|
|
|
var beginTime = DateTime.Now.AddMonths(-12); |
|
|
|
var monthList = new List<DateTime>(); |
|
|
|
for (int i = 0; i <= 12; i++) |
|
|
|
for (int i = 0; i < 12; i++) |
|
|
|
{ |
|
|
|
monthList.Add(beginTime.AddMonths(i)); |
|
|
|
} |
|
|
|
|
|
|
|
var data = stuAttendanceIBLL.GetAllList().Where(a => a.LessonDate >= beginTime && a.LessonDate <= DateTime.Now); |
|
|
|
var monthData = data.GroupBy(a => Convert.ToDateTime(a.LessonDate).Month).OrderBy(a => a.Key); |
|
|
|
var allattendanceNum = data.Count(); |
|
|
|
var allAttendanceYesNum = data.Count(a => a.AttendOrNo == "是"); |
|
|
|
var allAttendanceNoNum = allattendanceNum - allAttendanceYesNum; |
|
|
|
|
|
|
|
var allAttendanceYesRate = |
|
|
|
(Convert.ToDouble(allAttendanceYesNum) / Convert.ToDouble(allattendanceNum)).ToString("0.00"); |
|
|
|
var allAttendanceNoRate = |
|
|
|
(Convert.ToDouble(allAttendanceNoNum) / Convert.ToDouble(allattendanceNum)).ToString("0.00"); |
|
|
|
|
|
|
|
var attendanceNumList = monthData.Select(a => new { a.Key, allNum = a.Count(), yesNum = a.Count(b => b.AcademicYearNo == "是") }).ToList(); |
|
|
|
|
|
|
|
var monthInfo = new List<string>(); |
|
|
|
var currentYesValue = new List<string>(); |
|
|
|
var currentNoValue = new List<string>(); |
|
|
|
foreach (var monthItem in monthList) |
|
|
|
//总数 |
|
|
|
var totaldata = stuAttendanceIBLL.GetStuAttendanceTotal(beginTime.ToDateString(), DateTime.Now.ToDateString()); |
|
|
|
var totalNum = totaldata.Count(); |
|
|
|
//总出勤数 |
|
|
|
var data = stuAttendanceIBLL.GetAllList().Where(a => a.LessonDate >= beginTime && a.LessonDate <= DateTime.Now && a.AttendOrNo == "是"); |
|
|
|
var yesNum = data.Count(); |
|
|
|
//总出勤率、总缺勤率 |
|
|
|
decimal allAttendanceYesRate = 0; |
|
|
|
decimal allAttendanceNoRate = 0; |
|
|
|
if (totalNum > 0) |
|
|
|
{ |
|
|
|
var currentInfo = attendanceNumList.FirstOrDefault(a => a.Key == monthItem.Month); |
|
|
|
if (currentInfo != null) |
|
|
|
{ |
|
|
|
currentYesValue.Add((Convert.ToDouble(currentInfo.yesNum) / Convert.ToDouble(currentInfo.allNum)).ToString("0.00")); |
|
|
|
currentNoValue.Add((Convert.ToDouble(currentInfo.allNum - currentInfo.yesNum) / Convert.ToDouble(currentInfo.allNum)).ToString("0.00")); |
|
|
|
allAttendanceYesRate = (yesNum / totalNum).ToDecimal(2); |
|
|
|
allAttendanceNoRate = 1 - allAttendanceYesRate; |
|
|
|
} |
|
|
|
//各月份总数、出勤数、出勤率 |
|
|
|
var totalMonth = totaldata.GroupBy(x => new { x.LessonDate.Value.Year, x.LessonDate.Value.Month }).Select(x => new |
|
|
|
{ |
|
|
|
year = x.Key.Year, |
|
|
|
month = x.Key.Month, |
|
|
|
num = x.Count() |
|
|
|
}); |
|
|
|
var yesMonth = data.GroupBy(x => new { x.LessonDate.Value.Year, x.LessonDate.Value.Month }).Select(x => new |
|
|
|
{ |
|
|
|
year = x.Key.Year, |
|
|
|
month = x.Key.Month, |
|
|
|
num = x.Count() |
|
|
|
}); |
|
|
|
var monthInfo = new List<string>();//月统计值 |
|
|
|
var currentYesValue = new List<decimal>();//月出勤率 |
|
|
|
var currentNoValue = new List<decimal>();//月缺勤率 |
|
|
|
foreach (var item in monthList) |
|
|
|
{ |
|
|
|
monthInfo.Add(item.ToString("yy-MM")); |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
decimal yesrate = 0; |
|
|
|
decimal norate = 0; |
|
|
|
var total = totalMonth.FirstOrDefault(x => x.year == item.Year && x.month == item.Month); |
|
|
|
if (total != null && total.num > 0) |
|
|
|
{ |
|
|
|
currentYesValue.Add("0.00"); |
|
|
|
currentNoValue.Add("0.00"); |
|
|
|
var yes = yesMonth.FirstOrDefault(x => x.year == item.Year && x.month == item.Month); |
|
|
|
if (yes != null) |
|
|
|
{ |
|
|
|
yesrate = (yes.num) / (total.num).ToDecimal(2); |
|
|
|
norate = 1 - yesrate; |
|
|
|
} |
|
|
|
} |
|
|
|
monthInfo.Add(monthItem.ToString("yy-MM")); |
|
|
|
currentYesValue.Add(yesrate); |
|
|
|
currentNoValue.Add(norate); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var majorAttendanceInfo = data.GroupBy(a => a.MajorName).Select(a => |
|
|
|
new { a.Key, allNum = a.Count(), yesNum = a.Count(b => b.AttendOrNo == "是") }); |
|
|
|
var majorNameList = new List<string>(); |
|
|
|
var majorValue = new List<string>(); |
|
|
|
foreach (var majorItem in majorAttendanceInfo) |
|
|
|
//各专业总数、出勤数、出勤率 |
|
|
|
var totalMajor = totaldata.GroupBy(x => x.MajorNo).Select(x => new |
|
|
|
{ |
|
|
|
majorNameList.Add(majorItem.Key); |
|
|
|
majorValue.Add((Convert.ToDouble(majorItem.yesNum) / Convert.ToDouble(majorItem.allNum)).ToString("0.00")); |
|
|
|
} |
|
|
|
majorNo = x.Key, |
|
|
|
num = x.Count() |
|
|
|
}); |
|
|
|
var yesMajor = data.GroupBy(x => x.MajorNo).Select(x => new |
|
|
|
{ |
|
|
|
majorNo = x.Key, |
|
|
|
majorName = x.FirstOrDefault().MajorName, |
|
|
|
num = x.Count() |
|
|
|
}); |
|
|
|
var majorNameList = new List<string>();//专业名称值 |
|
|
|
var majorValue = new List<decimal>();//专业出勤率 |
|
|
|
foreach (var item in yesMajor) |
|
|
|
{ |
|
|
|
majorNameList.Add(item.majorName); |
|
|
|
|
|
|
|
decimal yesRate = 0; |
|
|
|
var total = totalMajor.FirstOrDefault(x => x.majorNo == item.majorNo); |
|
|
|
if (total != null && total.num > 0) |
|
|
|
{ |
|
|
|
yesRate = (item.num) / (total.num).ToDecimal(2); |
|
|
|
} |
|
|
|
majorValue.Add(yesRate); |
|
|
|
} |
|
|
|
|
|
|
|
return Success(new { allAttendanceYesRate, allAttendanceNoRate, monthInfo, currentYesValue, currentNoValue, majorNameList, majorValue }); |
|
|
|
|
|
|
|
} |
|
|
|