using Nancy;
using Learun.Util;
using System.Collections.Generic;
using Learun.Application.TwoDevelopment.EducationalAdministration;
using static Learun.Application.WebApi.Modules.StuInfoFreshApi;
using System;
using System.IO;
using System.Linq;
using Learun.Application.Base.SystemModule;
using Learun.Application.OA;
using Learun.Application.OA.File.FileInfo;
using Learun.Application.TwoDevelopment.LogisticsManagement;
using Learun.Application.TwoDevelopment.LR_Desktop;
using Learun.Application.WorkFlow;
using Microsoft.Ajax.Utilities;
namespace Learun.Application.WebApi
{
///
/// 版 本 Learun-ADMS-Ultimate V7.0.0 力软敏捷开发框架
/// Copyright (c) 2013-2018 上海力软信息技术有限公司
/// 创 建:超级管理员
/// 日 期:2019-08-19 17:50
/// 描 述:教师注册
///
public class StatisticsApi : BaseNoLoginApi
{
private EmpInfoIBLL empInfoIBLL = new EmpInfoBLL();
private StuInfoBasicIBLL stuInfoBasicIBLL = new StuInfoBasicBLL();
private ClassInfoIBLL classInfoIBLL = new ClassInfoBLL();
private ClassroomInfoIBLL classroomInfoIBLL = new ClassroomInfoBLL();
private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
private TeachSwitchIBLL teachSwitchIBLL = new TeachSwitchBLL();
private OpenLessonPlanOfElectiveIBLL openLessonPlanOfElectiveIBLL = new OpenLessonPlanOfElectiveBLL();
private StuScoreIBLL stuScoreIBLL = new StuScoreBLL();
private ArrangeLessonTermIBLL arrangeLessonTermIBLL = new ArrangeLessonTermBLL();
private StuScoreNotPassIBLL stuScoreNotPassIBLL = new StuScoreNotPassBLL();
private StuScoreNotPassTwoIBLL stuScoreNotPassTwoIBLL = new StuScoreNotPassTwoBLL();
private EADateArrangeIBLL eADateArrangeIBLL = new EADateArrangeBLL();
private NewsIBLL newsIbll = new NewsBLL();
private NoticeIBLL noticeIBLL = new NoticeBLL();
private SYS_SendMessageIBLL sendMessageIBLL = new SYS_SendMessageBLL();
private Sys_SendFileIBLL sys_SendFileIBLL = new Sys_SendFileBLL();
private FileInfoIBLL fileInfoIBLL = new FileInfoBLL();
private Sys_UpdateRecordIBLL sys_UpdateRecordIBLL = new Sys_UpdateRecordBLL();
private LessonInfoIBLL lessonInfoIBLL = new LessonInfoBLL();
private CdLessonSortDetailIBLL cdLessonSortDetailIBLL = new CdLessonSortDetailBLL();
private NWFSchemeIBLL nWFSchemeIBLL = new NWFSchemeBLL();
private NWFProcessIBLL processIbll = new NWFProcessBLL();
private DataItemIBLL dataItemIbll = new DataItemBLL();
private StuPunishmentIBLL stuPunishmentIBLL = new StuPunishmentBLL();
private StuEncourgementIBLL stuEncourgementIBLL = new StuEncourgementBLL();
private AccommodationIBLL accommodationIBLL = new AccommodationBLL();
private StuAttendanceIBLL stuAttendanceIBLL = new StuAttendanceBLL();
StuInfoBasicTwoIBLL stuInfoBasicTwoIbll=new StuInfoBasicTwoBLL();
///
/// 注册接口
///
public StatisticsApi()
: base("/Statistics")
{
Get["/electiveCcourse"] = ElectiveCourse;//选修课
Get["/semesterAndYear"] = SemesterAndYear;//当前学年学期
Get["/scoreEntry"] = ScoreEntry;//成绩录入
Post["/classHour"] = ClassHour;//课时
Post["/teacherWorkload"] = TeacherWorkload;//教师工作量
Get["/makeUpExam"] = MakeUpExam;//补考
Post["/eaDateArrange"] = EADateArrange;//教学工作安排
Get["/oaNews"] = OaNews;//新闻公告
Get["/oaEmails"] = OaEmails;//邮件
Get["/sendFiles"] = SendFiles;//公文
Get["/cloudFiles"] = CloudFiles;//云盘
Get["/operationLog"] = OperationLog;//操作日志
Get["/schoolInfo"] = SchoolInfo;//学校信息
Get["/nwfInfo"] = NwfInfo;//流程信息
Get["/stuPunishment"] = StuPunishmentInfo;//学生班级处分
Get["/stuEncourgement"] = StuEncourgementInfo;//学生班级奖励
Get["/dormitoryInfo"] = DormitoryInfo;//宿舍信息
Get["/stuAttendance"] = StuAttendance;//全校考勤
Post["/getStuInfo"] = GetStuNoByAccount;
Post["/getEmpInfo"] = GetEmpNoByAccount;
}
private Response SemesterAndYear(dynamic _)
{
var b = Common.GetSemesterAndYear();
object result = new { b.Semester, b.AcademicYearLong, b.AcademicYearShort };
return Success(result);
}
private Response ElectiveCourse(dynamic _)
{
string pagination =
"{\"rows\":1000,\"page\":1,\"sidx\":\"AcademicYearNo,Semester\",\"sord\":\"desc\",\"records\":0,\"total\":0}";
string queryJson = "{}";
Pagination paginationobj = pagination.ToObject();
var data = openLessonPlanOfElectiveIBLL.GetPageListOfMerge(paginationobj, queryJson).OrderByDescending(x => x.AcademicYearNo).ThenByDescending(x => x.Semester).ThenBy(x => x.LessonNo);
//选修课数量
var lessonNum = data.Count();
//选修课报名人数
var peopleNum = data.Sum(a => a.StuNumOfApply);
//课程名称
List nameList = data.Select(a => a.LessonName).ToList();
//各个课程的报名人数上限
List maxNumList = data.Select(a => a.StuNumMax).ToList();
//各个课程的报名人数
List numList = data.Select(a => a.StuNumOfApply).ToList();
object result = new { lessonNum, peopleNum, nameList, maxNumList, numList };
return Success(result);
}
public Response GetEmpNoByAccount(dynamic _)
{
string account = this.Request.Form.account.ToString();
var stuEntity = empInfoIBLL.GetEmpInfoEntityByEmpNo(account);
return Success(stuEntity);
}
public Response GetStuNoByAccount(dynamic _)
{
string account = this.Request.Form.account.ToString();
var stuEntity = stuInfoBasicIBLL.GetStuNoByAccount(account);
return Success(stuEntity);
}
private Response ScoreEntry(dynamic _)
{
var data = stuScoreIBLL.GetList("{}");
//已完成录入
var finishNum = data.Count(a => a.CheckMark == "1");
//未完成录入
var unFinishNum = data.Count(a => a.CheckMark == "0");
//录入率
var finishRate = (Convert.ToDouble(finishNum) / Convert.ToDouble(data.Count())).ToString("0.00%");
var unFinishRate = (Convert.ToDouble(unFinishNum) / Convert.ToDouble(data.Count())).ToString("0.00%");
object result = new { finishNum, unFinishNum, finishRate, unFinishRate };
return Success(result);
}
private Response ClassHour(dynamic _)
{
string semester = this.Request.Form.semester.ToString();
string year = this.Request.Form.year.ToString();
var data = arrangeLessonTermIBLL.GetList("{}").ToList()
.Where(a => a.AcademicYearNo == year && a.Semester == semester);
var data1 = data.GroupBy(a => a.LessonDate.ToDate().Month)
.Select(a => new { a.Key, num = a.Count() })
.OrderBy(a => a.Key);
//总课时数
var allNum = data.Count();
var month = data1.Select(a => a.Key).ToList();
var num = data1.Select(a => a.num);
object result = new { allNum, month, num };
return Success(result);
}
private Response TeacherWorkload(dynamic _)
{
string semester = this.Request.Form.semester.ToString();
string year = this.Request.Form.year.ToString();
var data = arrangeLessonTermIBLL.GetList("{}").ToList()
.Where(a => a.AcademicYearNo == year && a.Semester == semester)
.GroupBy(a => a.EmpNo).Select(a => new { a.Key, num = a.Count() }).OrderByDescending(a => a.num).Take(10);
List