using System; using System.Text; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Collections; using Bowin.Common.Data; using Bowin.Common.Exceptions; using Bowin.Common.Utility; using Bowin.Web.Controls.Mvc; using EMIS.Web.Controls; using EMIS.Utility; using EMIS.ViewModel; using EMIS.ViewModel.EvaluationManage.StudentEvaluation; using EMIS.CommonLogic.StudentWeb.Evaluation; using EMIS.CommonLogic.EvaluationManage.EvaluationSetting; using EMIS.CommonLogic.EvaluationManage.EvaluationTable; namespace EMIS.Web.Controllers.StudentWeb.Evaluation { [Authorization] public class StudentEvaluationEnterController : Controller { public Lazy StudentEvaluationEnterServices { get; set; } public Lazy EvaluationNeedServices { get; set; } public Lazy EvaluationTargetServices { get; set; } public Lazy EvaluationNormServices { get; set; } public Lazy EvaluationProjectServices { get; set; } public Lazy EvaluationControlServices { get; set; } /// /// 进入评价(学生)页面 /// /// public ActionResult List() { return View(); } /// /// 进入评价(学生)列表查询 /// /// /// [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var user = EMIS.Utility.FormValidate.CustomPrincipal.Current; return base.Json(StudentEvaluationEnterServices.Value.GetStudentEvaluationEnterViewGrid(configuretView, user.UserID, (int)pararms.page, (int)pararms.rows)); } /// /// 进入评价编辑 /// /// /// /// [HttpGet] public ActionResult EnterEdit(Guid? evaluationStudentID, Guid? evaluationStudentSettingID) { try { var user = EMIS.Utility.FormValidate.CustomPrincipal.Current; if (user == null) { throw new Exception("登录超时,请退出系统重新登录。"); } var evaluationControlView = EvaluationControlServices.Value.GetEvaluationControlView(); if (evaluationControlView == null) { throw new Exception("当前教学质量评价活动对应的评价学年学期已结束。"); } else { EvaluationStudentView evaluationStudentView = new EvaluationStudentView(); if (evaluationStudentSettingID.HasValue && evaluationStudentSettingID != Guid.Empty) { evaluationStudentView = StudentEvaluationEnterServices.Value.GetStudentEvaluationEnterView(user.UserID, evaluationStudentSettingID); if (evaluationStudentView == null) { throw new Exception("进入评价超时,请刷新页面或退出系统重新登录。"); } if (evaluationStudentView.SchoolyearValue > evaluationControlView.SchoolyearValue) { throw new Exception("当前教学质量评价活动对应的评价学年学期已结束。"); } if (evaluationStudentView.StartTime == null || evaluationStudentView.EndTime == null) { throw new Exception("当前教学质量评价活动对应的评价时间未开始。"); } if (DateTime.Now < evaluationStudentView.StartTime) { throw new Exception("当前教学质量评价活动对应的评价时间未开始。"); } if (DateTime.Now > evaluationStudentView.EndTime) { throw new Exception("当前教学质量评价活动对应的评价时间已结束。"); } if (((evaluationStudentView.Numbered ?? 0) + 1) > (evaluationStudentView.Number ?? 0)) { throw new Exception("当前教学质量评价活动对应的已评次数已评完。"); } var evaluationNeedView = EvaluationNeedServices.Value.GetEvaluationNeedView((int)EMIS.ViewModel.EM_ParticipateType.Student); if (evaluationNeedView == null) { throw new Exception("评价数据有误,请联系辅导员或教学评价负责老师。"); } ViewBag.EvaluationNeedContent = evaluationNeedView.Content; } else { throw new Exception("进入评价超时,请刷新页面或退出系统重新登录。"); } return View(evaluationStudentView); } } catch (Exception ex) { return RedirectToAction("MsgShow", "Common", new { WindowID = Request["WindowID"], msg = "进入教学质量评价活动失败,请按提示原因进行再次尝试操作(原因:" + ex.Message + ")。", url = Url.Action("List").AddMenuParameter() }); } } /// /// 进入评价编辑 /// /// /// [HttpPost] public ActionResult EnterEdit(EvaluationStudentView evaluationStudentView) { try { StudentEvaluationEnterServices.Value.StudentEvaluationEnterEdit(evaluationStudentView); return Json(new ReturnMessage() { IsSuccess = true, Message = "评价成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = true, Message = "评价失败,原因:" + ex.Message }); } } /// /// 评价表格标题 /// /// public JsonResult FormTitle() { ArrayList formTitleList = new ArrayList(); formTitleList.Add(new { field = "OrderNo", title = "次序", align = "center", width = "120" }); formTitleList.Add(new { field = "EvaluationTargetID", title = "评价指标ID", align = "center", width = "20" }); formTitleList.Add(new { field = "EvaluationTargetWeight", title = "评价指标权重", align = "center", width = "20" }); formTitleList.Add(new { field = "EvaluationProjectID", title = "评价项目ID", align = "center", width = "20" }); formTitleList.Add(new { field = "EvaluationProjectName", title = "评价项目", align = "center", width = "350" }); formTitleList.Add(new { field = "Weight", title = "权重", align = "center", width = "50" }); formTitleList.Add(new { field = "EvaluationNormName", title = "评分标准", align = "center", width = "385" }); return Json(new { UpTitle = JsonHelper.ToJSON(formTitleList) }, JsonRequestBehavior.AllowGet); } /// /// 评价表格内容 /// /// /// /// public JsonResult Content(Guid? evaluationStudentID, Guid? evaluationTableID) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var evaluationTargetViewList = EvaluationTargetServices.Value.GetEvaluationTargetViewList(configuretView, null, null, evaluationTableID, null) .Select(x => new { x.EvaluationTargetID, x.EvaluationNormID, x.Name, x.Weight }).ToList(); int i = 1; StringBuilder strRows = new StringBuilder(); foreach (var evaluationTargetView in evaluationTargetViewList) { StringBuilder strRowtg = new StringBuilder(); var tgNormNames = string.Join(" ", EvaluationNormServices.Value.GetEvaluationNormDetailViewList(configuretView, evaluationTargetView.EvaluationNormID).Select(s => s.Name + s.Weight)); strRowtg.Append("{"); strRowtg.Append("\"OrderNo\":\"" + evaluationTargetView.Name + "\""); strRowtg.Append(",\"EvaluationTargetID\":\"" + evaluationTargetView.EvaluationTargetID + "\""); strRowtg.Append(",\"EvaluationTargetWeight\":\"\""); strRowtg.Append(",\"EvaluationProjectID\":\"\""); strRowtg.Append(",\"EvaluationProjectName\":\"\""); strRowtg.Append(",\"Weight\":\"" + evaluationTargetView.Weight + "\""); strRowtg.Append(",\"EvaluationNormName\":\"" + tgNormNames + "\""); strRowtg.Append("}"); if (string.IsNullOrEmpty(strRows.ToString())) { strRows.Append(strRowtg); } else { strRows.Append("," + strRowtg); } var evaluationProjectViewList = EvaluationProjectServices.Value.GetEvaluationProjectViewList(configuretView, null, null, evaluationTableID, evaluationTargetView.EvaluationTargetID) .Select(x => new { x.EvaluationProjectID, x.OrderNo, x.Name, x.Weight, x.Code, x.EvaluationTargetID, x.EvaluationTargetWeight }).ToList(); int j = 1; var evaluationNormDetailViewList = EvaluationNormServices.Value.GetEvaluationNormDetailViewList(configuretView, evaluationTargetView.EvaluationNormID).ToList(); foreach (var evaluationProjectView in evaluationProjectViewList) { var prNormNames = ""; if (evaluationStudentID.HasValue && evaluationStudentID != Guid.Empty) { var evaluationStudentDetailList = StudentEvaluationEnterServices.Value.GetEvaluationStudentDetailList(evaluationStudentID).ToList(); if (evaluationStudentDetailList != null && evaluationStudentDetailList.Count() > 0) { var evaluationStudentDetail = evaluationStudentDetailList.Where(x => x.EvaluationProjectID == evaluationProjectView.EvaluationProjectID).SingleOrDefault(); string normDetailStr = ""; if (evaluationStudentDetail != null) { foreach (var evaluationNormDetailView in evaluationNormDetailViewList) { if (evaluationStudentDetail.Score == evaluationNormDetailView.Weight) { normDetailStr = evaluationNormDetailView.Name + ""; } else { normDetailStr = evaluationNormDetailView.Name + ""; } prNormNames += " " + normDetailStr; } } else { prNormNames = string.Join(" ", evaluationNormDetailViewList.Select((s, index) => s.Name + "")); } } else { prNormNames = string.Join(" ", evaluationNormDetailViewList.Select((s, index) => s.Name + "")); } } else { prNormNames = string.Join(" ", evaluationNormDetailViewList.Select((s, index) => s.Name + "")); } StringBuilder strRowpr = new StringBuilder(); strRowpr.Append("{"); strRowpr.Append("\"OrderNo\":\"" + evaluationProjectView.OrderNo + "\""); strRowpr.Append(",\"EvaluationTargetID\":\"" + evaluationProjectView.EvaluationTargetID + "\""); strRowpr.Append(",\"EvaluationTargetWeight\":\"" + evaluationProjectView.EvaluationTargetWeight + "\""); strRowpr.Append(",\"EvaluationProjectID\":\"" + evaluationProjectView.EvaluationProjectID + "\""); strRowpr.Append(",\"EvaluationProjectName\":\"" + evaluationProjectView.Name + "\""); strRowpr.Append(",\"Weight\":\"" + evaluationProjectView.Weight + "\""); strRowpr.Append(",\"EvaluationNormName\":\"" + prNormNames + "\""); strRowpr.Append("}"); if (string.IsNullOrEmpty(strRows.ToString())) { strRows.Append(strRowpr); } else { strRows.Append("," + strRowpr); } j++; } i++; } return Json(new { rows = strRows.ToString(), total = 0 }, JsonRequestBehavior.AllowGet); } /// /// 查询对应的评价指标权重总和 /// /// /// [HttpPost] public ActionResult GetTargetWeightSum(string evaluationTargetIDs) { List list = evaluationTargetIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); var evaluationTargetWeightSum = EvaluationTargetServices.Value.GetEvaluationTargetList(list).Sum(x => x.Weight ?? 0); return base.Json(evaluationTargetWeightSum.ToString()); } /// /// 查询对应的评价项目权重总和 /// /// /// [HttpPost] public ActionResult GetProjectWeightSum(string evaluationTargetID) { var evaluationProjectWeightSum = EvaluationProjectServices.Value.GetEvaluationProjectList(Guid.Parse(evaluationTargetID)).Sum(x => x.Weight ?? 0); return base.Json(evaluationProjectWeightSum.ToString()); } /// /// Excel导出 /// /// [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var user = EMIS.Utility.FormValidate.CustomPrincipal.Current; var dt = StudentEvaluationEnterServices.Value.GetStudentEvaluationEnterViewList(configuretView, user.UserID) .Select(x => new { x.SchoolyearCode, x.MissionClassName, x.CourseName, x.CourseTypeName, x.HandleModeName, x.TeachingModeName, x.EvaluationTableName, x.ParticipateTypeName, x.EvaluationTypeName, x.StaffName, x.TeachingMethodName, x.Number, x.Numbered }).ToTable(); string[] liststring = { "学年学期", "任务班名称", "课程名称", "课程类型", "处理方式", "授课方式", "评价表名", "参评类型", "评价类型", "任课教师", "任课方式", "可评次数", "已评次数" }; neh.Export(dt, liststring, "进入评价信息(" + user.LoginID + ")" + DateTime.Now.ToString("yyyyMMdd")); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功。" }); } } }