Browse Source

【增加】驾驶舱学生信息分析;

应县
dyy 9 months ago
parent
commit
adbc04d04a
2 changed files with 172 additions and 0 deletions
  1. +1
    -0
      Learun.Framework.Ultimate V7/Learun.Application.WebApi/Learun.Application.WebApi.csproj
  2. +171
    -0
      Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/Echarts/StudentEchartsApi.cs

+ 1
- 0
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Learun.Application.WebApi.csproj View File

@@ -191,6 +191,7 @@
<ItemGroup>
<Compile Include="Bootstraper.cs" />
<Compile Include="Modules\Echarts\EchartsApi.cs" />
<Compile Include="Modules\Echarts\StudentEchartsApi.cs" />
<Compile Include="Modules\EducationalAdministration\ArrangeExamTermApi.cs" />
<Compile Include="Modules\EducationalAdministration\ArrangeExamTermNewApi.cs" />
<Compile Include="Modules\SSOApi.cs" />


+ 171
- 0
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/Echarts/StudentEchartsApi.cs View File

@@ -0,0 +1,171 @@
using Learun.Application.Base.SystemModule;
using Learun.Application.TwoDevelopment.EducationalAdministration;
using Nancy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace Learun.Application.WebApi.Modules.Echarts
{
public class StudentEchartsApi : BaseNoAuthentication
{
private StuInfoBasicIBLL stuInfoBasicIBLL = new StuInfoBasicBLL();
private DataItemIBLL dataItemIBLL = new DataItemBLL();

public StudentEchartsApi() : base("/api/studentEcharts/")
{
Get["/stuTotalNum"] = stuTotalNum;
Get["/stuManNum"] = stuManNum;
Get["/stuWomanNum"] = stuWomanNum;
Get["/stuSexEchart"] = stuSexEchart;
Get["/stuAgeEchart"] = stuAgeEchart;
Get["/stuNationalityEchart"] = stuNationalityEchart;

}

/// <summary>
/// 在校学生人数
/// </summary>
/// <param name="_"></param>
/// <returns></returns>
public Response stuTotalNum(dynamic _)
{
var sum = stuInfoBasicIBLL.GetAllList().Count();
var res = new { value = sum };

return Res(res);
}
/// <summary>
/// 在校学生人数-男
/// </summary>
/// <param name="_"></param>
/// <returns></returns>
public Response stuManNum(dynamic _)
{
var sum = stuInfoBasicIBLL.GetAllList().Where(x => x.GenderNo == true).Count();
var res = new { value = sum };

return Res(res);
}
/// <summary>
/// 在校学生人数-女
/// </summary>
/// <param name="_"></param>
/// <returns></returns>
public Response stuWomanNum(dynamic _)
{
var sum = stuInfoBasicIBLL.GetAllList().Where(x => x.GenderNo == false).Count();
var res = new { value = sum };

return Res(res);
}
/// <summary>
/// 在校学生人数-性别图表
/// </summary>
/// <param name="_"></param>
/// <returns></returns>
public Response stuSexEchart(dynamic _)
{
var stuList = stuInfoBasicIBLL.GetAllList();
var stuManNum = stuList.Where(x => x.GenderNo == true).Count();
var stuWomanNum = stuList.Where(x => x.GenderNo == false).Count();

var res = new BarModel()
{
categories = new List<string>(),
series = new List<seriesModel>()
};
res.categories.Add("性别");
var s1data = new List<int>();
s1data.Add(stuManNum);
res.series.Add(new seriesModel { name = "男", data = s1data });
var s2data = new List<int>();
s2data.Add(stuWomanNum);
res.series.Add(new seriesModel { name = "女", data = s2data });

return Res(res);
}
/// <summary>
/// 学生年龄分布
/// </summary>
/// <param name="_"></param>
/// <returns></returns>
public Response stuAgeEchart(dynamic _)
{
var res = new List<PieModel>();
var stuList = stuInfoBasicIBLL.GetAllList();
var num1820 = stuList.Where(x => Math.Abs(x.Birthday.Value.Year - DateTime.Now.Year) >= 18 && Math.Abs(x.Birthday.Value.Year - DateTime.Now.Year) <= 20).Count();
res.Add(new PieModel() { name = "18-20", value = num1820 });
var num2123 = stuList.Where(x => Math.Abs(x.Birthday.Value.Year - DateTime.Now.Year) >= 21 && Math.Abs(x.Birthday.Value.Year - DateTime.Now.Year) <= 23).Count();
res.Add(new PieModel() { name = "21-23", value = num2123 });
var num2426 = stuList.Where(x => Math.Abs(x.Birthday.Value.Year - DateTime.Now.Year) >= 24 && Math.Abs(x.Birthday.Value.Year - DateTime.Now.Year) <= 26).Count();
res.Add(new PieModel() { name = "24-26", value = num2426 });

return Res(res);
}
/// <summary>
/// 学生民族分布
/// </summary>
/// <param name="_"></param>
/// <returns></returns>
public Response stuNationalityEchart(dynamic _)
{
var stuList = stuInfoBasicIBLL.GetAllList().Where(x => x.NationalityNo.Length > 0).GroupBy(x => x.NationalityNo).Select(x => new
{
NationalityNo = x.Key,
manNum = x.Where(y => y.GenderNo == true).Count(),
womanNum = x.Where(y => y.GenderNo == false).Count()
});
var nationalityList = dataItemIBLL.GetDetailList2("National", null);

var res = new BarModel()
{
categories = new List<string>(),
series = new List<seriesModel>()
};
var s1data = new List<int>();
var s2data = new List<int>();
foreach (var item in stuList)
{
res.categories.Add(nationalityList.FirstOrDefault(x => x.F_ItemValue == item.NationalityNo).F_ItemName);
s1data.Add(item.manNum);
s2data.Add(item.womanNum);
}
res.series.Add(new seriesModel { name = "男", data = s1data });
res.series.Add(new seriesModel { name = "女", data = s2data });

return Res(res);
}





/// <summary>
/// 柱状图数据
/// </summary>
public class BarModel
{
public List<string> categories { get; set; }
public List<seriesModel> series { get; set; }
}
public class seriesModel
{
public string name { get; set; }
public List<int> data { get; set; }
}
/// <summary>
/// 饼图数据
/// </summary>
public class PieModel
{
public string name { get; set; }
public int value { get; set; }
}


}
}

Loading…
Cancel
Save