Browse Source

【修改】数据中心-大屏展示,接口优化;

应县
dyy 9 months ago
parent
commit
862fa1e774
4 changed files with 131 additions and 41 deletions
  1. +71
    -41
      Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/StatisticsApi.cs
  2. +25
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuAttendance/StuAttendanceBLL.cs
  3. +7
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuAttendance/StuAttendanceIBLL.cs
  4. +28
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuAttendance/StuAttendanceService.cs

+ 71
- 41
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/StatisticsApi.cs View File

@@ -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 });

}


+ 25
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuAttendance/StuAttendanceBLL.cs View File

@@ -196,6 +196,31 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
}
}
}

/// <summary>
/// 获取课堂考勤总数
/// <param name="keyValue">主键</param>
/// <summary>
/// <returns></returns>
public IEnumerable<ArrangeLessonTermEntity> GetStuAttendanceTotal(string startTime, string endTime)
{
try
{
return stuAttendanceService.GetStuAttendanceTotal(startTime, endTime);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}

#endregion

#region 提交数据


+ 7
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuAttendance/StuAttendanceIBLL.cs View File

@@ -54,6 +54,13 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
/// <param name="queryJson">查询参数</param>
/// <returns></returns>
IEnumerable<StuAttendanceEntity> GetAttendancePageList(Pagination pagination, string queryJson);

/// <summary>
/// 获取课堂考勤总数
/// <param name="keyValue">主键</param>
/// <summary>
/// <returns></returns>
IEnumerable<ArrangeLessonTermEntity> GetStuAttendanceTotal(string startTime, string endTime);
#endregion

#region 提交数据


+ 28
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuAttendance/StuAttendanceService.cs View File

@@ -439,6 +439,34 @@ where 1=1 ");
}
}

/// <summary>
/// 获取课堂考勤总数
/// <param name="keyValue">主键</param>
/// <summary>
/// <returns></returns>
public IEnumerable<ArrangeLessonTermEntity> GetStuAttendanceTotal(string startTime,string endTime)
{
try
{
return this.BaseRepository("CollegeMIS").FindList<ArrangeLessonTermEntity>($@"select * from ArrangeLessonTerm t
left join StuInfoBasic s on REPLACE(t.TeachClassNo, t.LessonName, '') = s.ClassNo
where t.LessonDate >= '{startTime.ToDate()}' and t.LessonDate <= '{endTime.ToDate()}'");
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}



#endregion

#region 提交数据


Loading…
Cancel
Save