using Learun.Application.Organization;
using Learun.Application.TwoDevelopment.EducationalAdministration;
using Learun.Application.TwoDevelopment.LR_Desktop;
using Learun.Util;
using Learun.Util.Operat;
using Microsoft.AspNet.SignalR.Client;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
{
///
/// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
/// Copyright (c) 2013-2018 北京泉江科技有限公司
/// 创 建:超级管理员
/// 日 期:2019-02-27 11:05
/// 描 述:排课
///
public class ArrangeLessonTermController : MvcControllerBase
{
private ArrangeLessonTermIBLL arrangeLessonTermIBLL = new ArrangeLessonTermBLL();
private ArrangeLessonTermOfElectiveIBLL arrangeLessonTermOfElectiveIBLL = new ArrangeLessonTermOfElectiveBLL();
private Sys_InformationPushIBLL sys_InformationPushIBLL = new Sys_InformationPushBLL();
private UserIBLL userIbll = new UserBLL();
private WeChatConfigIBLL weChatConfigIbll = new WeChatConfigBLL();
private WeChatTempletIBLL weChatTempletIbll = new WeChatTempletBLL();
private SchoolCalendarIBLL schoolCalendarIbll = new SchoolCalendarBLL();
private StuInfoBasicIBLL stuInfoBasicIbll = new StuInfoBasicBLL();
private EmpInfoIBLL empInfoIbll = new EmpInfoBLL();
#region 视图功能
///
/// 主页面
///
///
[HttpGet]
public ActionResult Index()
{
return View();
}
///
/// 表单页
///
///
[HttpGet]
public ActionResult Form()
{
return View();
}
///
/// 按条件清空排课数据
///
///
[HttpGet]
public ActionResult EmptyByConditionForm()
{
return View();
}
///
/// 按条件同步排课数据
///
///
[HttpGet]
public ActionResult SyncByConditionForm()
{
return View();
}
[HttpGet]
public ActionResult ClearByConditionForm()
{
return View();
}
[HttpGet]
public ActionResult IndexLessonTerm()
{
return View();
}
///
/// 学生课表
///
///
[HttpGet]
public ActionResult IndexLessonTermStu()
{
var LogInfo = LoginUserInfo.Get();
if (LogInfo.Description == "学生")
{
var StuInfo = stuInfoBasicIbll.GetAllList().Where(x => x.StuNo == LogInfo.account);
if (StuInfo != null)
{
ViewBag.ClassNo = StuInfo.FirstOrDefault().ClassNo;
}
}
return View();
}
///
/// 教师课表
///
///
[HttpGet]
public ActionResult IndexLessonTermTeach()
{
var LogInfo = LoginUserInfo.Get();
if (LogInfo.Description == "教师")
{
var empInfo = empInfoIbll.GetAllList().Where(x => x.EmpNo == LogInfo.account);
if (empInfo != null)
{
ViewBag.EmpNo = empInfo.FirstOrDefault().EmpNo;
}
}
return View();
}
#endregion
#region 获取数据
///
/// 获取列表数据
///
///
[HttpGet]
[AjaxOnly]
public ActionResult GetList(string queryJson)
{
var data = arrangeLessonTermIBLL.GetList(queryJson).ToList()
.OrderBy(x => x.AcademicYearNo).ThenBy(x => x.Semester).ThenBy(x => x.DeptNo).ThenBy(x => x.MajorNo).ThenBy(x => x.LessonNo).ThenBy(x => x.TeachClassNo.Replace(x.LessonName, "")).ThenBy(x => x.EmpNo).ThenBy(x => x.ClassroomNo).ThenBy(x => x.LessonDate);
return Success(data);
}
///
/// 获取列表分页数据
/// 分页参数
///
///
[HttpGet]
[AjaxOnly]
public ActionResult GetPageList(string pagination, string queryJson)
{
Pagination paginationobj = pagination.ToObject();
var data = arrangeLessonTermIBLL.GetPageList(paginationobj, queryJson);
var jsonData = new
{
rows = data,
total = paginationobj.total,
page = paginationobj.page,
records = paginationobj.records
};
return Success(jsonData);
}
///
/// 排课管理 获取左侧树结构
///
///
[HttpGet]
[AjaxOnly]
public ActionResult GetTree()
{
var data = arrangeLessonTermIBLL.GetTree();
return Success(data);
}
///
/// 获取表单数据
/// 主键
///
///
[HttpGet]
[AjaxOnly]
public ActionResult GetFormData(string keyValue)
{
var data = arrangeLessonTermIBLL.GetEntity(keyValue);
return Success(data);
}
///
/// 获取周次
///
///
[HttpGet]
[AjaxOnly]
public ActionResult GetWeekTime()
{
int weekTimes = 0;
int curWeek = 0;
//开始时间
var startdate = DateTime.Today;
var startDate = Common.CalculateFirstDateOfWeek(startdate).ToString("yyyy-MM-dd");
//var endDate = Common.CalculateLastDateOfWeek(startdate).ToString("yyyy-MM-dd");
var semesterAndYear = Common.GetSemesterAndYear(startDate);
//var strAcademicYear = semesterAndYear.AcademicYearShort;
//var strSemester = semesterAndYear.Semester;
var entity = schoolCalendarIbll.GetSchoolCalendarEntityByNo(semesterAndYear.AcademicYearShort, semesterAndYear.Semester);
if (entity.StartTime.HasValue && entity.EndTime.HasValue)
{
weekTimes = GetYearWeekCount(entity.StartTime.Value, entity.EndTime.Value);
curWeek = WeekOfYear(startdate, entity.StartTime.Value, entity.EndTime.Value);
}
var listObj = new List