using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using EMIS.ViewModel; using EMIS.Web.Controls; using EMIS.CommonLogic.ScoreManage; using Bowin.Web.Controls.Mvc; using EMIS.Entities; using EMIS.ViewModel.ScoreManage; using EMIS.Utility; using EMIS.ViewModel.CacheManage; using System.Dynamic; using Bowin.Common.JSON; using Bowin.Common.Utility; using Bowin.Common.Data; using EMIS.CommonLogic.CalendarManage; using EMIS.ViewModel.WorkflowManage; namespace EMIS.Web.Controllers.ScoreManage { [Authorization] public class ScoreAuditController : Controller { public Lazy scoreServices { get; set; } public Lazy finalExaminationServices { get; set; } public Lazy scoreParameterSettingServices { get; set; } public Lazy creditFormulaServices { get; set; } public Lazy gradePointFormulaServices { get; set; } public Lazy scoreFormulaServices { get; set; } public Lazy SchoolYearServices { get; set; } /// /// 报表 /// /// /// public ActionResult Report(Guid? FinalExaminationID) { ViewBag.FinalExaminationID = FinalExaminationID; return View(); } /// /// 成绩审核页面 /// /// public ActionResult List() { var schoolYear = SchoolYearServices.Value.GetSchoolYearIsCurrent(true); var ApprovalStatus = scoreServices.Value.ApprovalStatus(); ViewBag.SchoolYearID = schoolYear == null ? "-1" : schoolYear.SchoolyearID.ToString();//默认当前学年 ViewBag.ApprovalStatus = ApprovalStatus.ToString(); return View(); } /// /// 列表 /// /// /// [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var collegeID = pararms.getExtraGuid("CollegeComboGrid"); var departmentID = pararms.getExtraGuid("DepartmentComboGrid"); var coursematerialID = pararms.getExtraGuid("CoursematerialComboGrid"); var courseTypeID = pararms.getExtraInt("DictionaryCourseType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryCourseType"); var examsCategoryID = pararms.getExtraInt("DictionaryExamsCategory") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryExamsCategory"); var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown"); var gradeYearID = pararms.getExtraInt("DictionaryGrade") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryGrade"); var approvalStatus = pararms.getExtraInt("DictionaryScoreState") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryScoreState"); return Json(scoreServices.Value.GetFinalExaminationScoreAuditViewGrid(configuretView, collegeID, departmentID, schoolyearID, coursematerialID, courseTypeID, examsCategoryID, gradeYearID,approvalStatus, (int)pararms.page, (int)pararms.rows)); } /// ///审核状态排查 /// public ActionResult ApprovalStatus(string ApprovalStatus) { try { List List = new List(); for (int i = 0; i < ApprovalStatus.Split(',').Length; i++) { if (!string.IsNullOrEmpty(ApprovalStatus.Split(',')[i])) { int Status = Convert.ToInt32(ApprovalStatus.Split(',')[i]); List.Add(Status); } } scoreServices.Value.CheckApprovalStatus(List); return Json("成功"); } catch (Exception ex) { return Json(ex.Message); } } /// /// 审核动作 /// /// public ActionResult ApprovalHandle(string finalExaminationIDs) { var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal; Guid finalExaminationID = new Guid(finalExaminationIDs.Split(',')[0]); List listAction = scoreServices.Value.GetAuditingActionView(finalExaminationID, user.UserID); List list = new List(); List firstListAction = new List(); //默认动作 if (listAction.Count == 0) { return RedirectToAction("MsgShow", "Common", new { WindowID = Request["WindowID"], msg = "对不起,您无权限进行审核操作。" }); } foreach (var item in listAction) { DropdownListItem dli = new DropdownListItem { Text = item.ActionName, Value = item.ToJson() }; list.Add(dli); } var firstAction = listAction.OrderBy(x => x.Sort).FirstOrDefault(); //以排序获取第一个动作为默认动作 firstListAction.Add(new DropdownListItem { Text = firstAction.ActionName, Value = firstAction.ToJson() }); ViewData["firstListAction"] = firstListAction; ViewData["listAction"] = list; return View(); } /// /// 审核动作 /// /// [HttpPost] public ActionResult ApprovalHandle(string finalExaminationIDs, string opinioncomment) { try { string action = Request.Form["Action"]; ActionView actionView = action.JsonToObject(); string comment = Request.Form["txtOpinioncomment"]; List list = new List(); for (int i = 0; i < finalExaminationIDs.Split(',').Length; i++) { if (!string.IsNullOrEmpty(finalExaminationIDs.Split(',')[i])) { Guid FinalExaminationID = new Guid(finalExaminationIDs.Split(',')[i]); list.Add(FinalExaminationID); } } //scoreServices.Value.GetFinalExaminationApprovalStatus(list, action, opinioncomment); scoreServices.Value.Approve(list, EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID, actionView.ActionID, opinioncomment); return Json(new ReturnMessage() { IsSuccess = true, Message = "审核成功!" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = true, Message = "审核失败,原因:" + ex.Message + "!" }); } } /// /// 导出 /// /// public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var collegeID = Request.Form["CollegeComboGrid"].ParseStrTo(); var departmentID = Request.Form["DepartmentComboGrid"].ParseStrTo(); var coursematerialID = Request.Form["CoursematerialComboGrid"].ParseStrTo(); var courseTypeID = Request.Form["DictionaryCourseType"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryCourseType"].ParseStrTo(); var examsCategoryID = Request.Form["DictionaryExamsCategory"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryExamsCategory"].ParseStrTo(); var schoolyearID = Request.Form["SchoolyearDropdown"].ParseStrTo(); var gradeYearID = Request.Form["DictionaryGrade"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGrade"].ParseStrTo(); var approvalStatus = Request.Form["DictionaryScoreState"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryScoreState"].ParseStrTo(); var dt = scoreServices.Value.GetFinalExaminationScoreAuditViewList(configuretView, collegeID, departmentID, schoolyearID, coursematerialID, courseTypeID, examsCategoryID, gradeYearID, approvalStatus).Select(x => new { x.SchoolyearCode, x.GradeYearID, x.ClassName, x.CourseCode, x.CourseName, x.CourseTypeName, x.ExamsCategoryName, x.CreatorUserNo, x.CreatorUserName, x.EntryDeadlineTime, x.StudentCount, x.SAPunlogStudentCount, x.ApprovalStatusName }).ToTable(); string[] liststring = { "学年学期", "年级", "录入班级名称", "课程代码", "课程名称","课程类型", "考试性质","录入人编号", "录入人姓名", "录入截止日期","学生数","未录入人数","状态" }; neh.Export(dt, liststring, "成绩录入信息"); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功!" }); } /// /// 学生名单 /// /// public ActionResult StudentList(Guid? finalExaminationID, int? recordStatus) { ViewBag.FinalExaminationID = finalExaminationID; var IsColor = 0; var status = finalExaminationServices.Value.GetRebutStatus(); if (status.Count > 0) { if (status.Any(x => x.Value == recordStatus)) { IsColor = 1; } } ViewBag.IsColor = IsColor; return View(); } /// /// 学生名单 /// /// /// [HttpPost] public ActionResult FinalExaminationStudentList() { var finalExaminationID = Request["finalExaminationID"].ParseStrTo(); return Json(finalExaminationServices.Value.GetFinalExaminationStudent(finalExaminationID)); } } }