StudentEvaluationEnterController.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. using System;
  2. using System.Text;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.Mvc;
  7. using System.Collections;
  8. using Bowin.Common.Data;
  9. using Bowin.Common.Exceptions;
  10. using Bowin.Common.Utility;
  11. using Bowin.Web.Controls.Mvc;
  12. using EMIS.Web.Controls;
  13. using EMIS.Utility;
  14. using EMIS.ViewModel;
  15. using EMIS.ViewModel.EvaluationManage.StudentEvaluation;
  16. using EMIS.CommonLogic.StudentWeb.Evaluation;
  17. using EMIS.CommonLogic.EvaluationManage.EvaluationSetting;
  18. using EMIS.CommonLogic.EvaluationManage.EvaluationTable;
  19. namespace EMIS.Web.Controllers.StudentWeb.Evaluation
  20. {
  21. [Authorization]
  22. public class StudentEvaluationEnterController : Controller
  23. {
  24. public Lazy<IStudentEvaluationEnterServices> StudentEvaluationEnterServices { get; set; }
  25. public Lazy<IEvaluationNeedServices> EvaluationNeedServices { get; set; }
  26. public Lazy<IEvaluationTargetServices> EvaluationTargetServices { get; set; }
  27. public Lazy<IEvaluationNormServices> EvaluationNormServices { get; set; }
  28. public Lazy<IEvaluationProjectServices> EvaluationProjectServices { get; set; }
  29. public Lazy<IEvaluationControlServices> EvaluationControlServices { get; set; }
  30. /// <summary>
  31. /// 进入评价(学生)页面
  32. /// </summary>
  33. /// <returns></returns>
  34. public ActionResult List()
  35. {
  36. return View();
  37. }
  38. /// <summary>
  39. /// 进入评价(学生)列表查询
  40. /// </summary>
  41. /// <param name="pararms"></param>
  42. /// <returns></returns>
  43. [HttpPost]
  44. public ActionResult List(QueryParamsModel pararms)
  45. {
  46. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  47. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  48. return base.Json(StudentEvaluationEnterServices.Value.GetStudentEvaluationEnterViewGrid(configuretView, user.UserID, (int)pararms.page, (int)pararms.rows));
  49. }
  50. /// <summary>
  51. /// 进入评价编辑
  52. /// </summary>
  53. /// <param name="evaluationStudentID"></param>
  54. /// <param name="evaluationStudentSettingID"></param>
  55. /// <returns></returns>
  56. [HttpGet]
  57. public ActionResult EnterEdit(Guid? evaluationStudentID, Guid? evaluationStudentSettingID)
  58. {
  59. try
  60. {
  61. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  62. if (user == null)
  63. {
  64. throw new Exception("登录超时,请退出系统重新登录。");
  65. }
  66. var evaluationControlView = EvaluationControlServices.Value.GetEvaluationControlView();
  67. if (evaluationControlView == null)
  68. {
  69. throw new Exception("当前教学质量评价活动对应的评价学年学期已结束。");
  70. }
  71. else
  72. {
  73. EvaluationStudentView evaluationStudentView = new EvaluationStudentView();
  74. if (evaluationStudentSettingID.HasValue && evaluationStudentSettingID != Guid.Empty)
  75. {
  76. evaluationStudentView = StudentEvaluationEnterServices.Value.GetStudentEvaluationEnterView(user.UserID, evaluationStudentSettingID);
  77. if (evaluationStudentView == null)
  78. {
  79. throw new Exception("进入评价超时,请刷新页面或退出系统重新登录。");
  80. }
  81. if (evaluationStudentView.SchoolyearValue > evaluationControlView.SchoolyearValue)
  82. {
  83. throw new Exception("当前教学质量评价活动对应的评价学年学期已结束。");
  84. }
  85. if (evaluationStudentView.StartTime == null || evaluationStudentView.EndTime == null)
  86. {
  87. throw new Exception("当前教学质量评价活动对应的评价时间未开始。");
  88. }
  89. if (DateTime.Now < evaluationStudentView.StartTime)
  90. {
  91. throw new Exception("当前教学质量评价活动对应的评价时间未开始。");
  92. }
  93. if (DateTime.Now > evaluationStudentView.EndTime)
  94. {
  95. throw new Exception("当前教学质量评价活动对应的评价时间已结束。");
  96. }
  97. if (((evaluationStudentView.Numbered ?? 0) + 1) > (evaluationStudentView.Number ?? 0))
  98. {
  99. throw new Exception("当前教学质量评价活动对应的已评次数已评完。");
  100. }
  101. var evaluationNeedView = EvaluationNeedServices.Value.GetEvaluationNeedView((int)EMIS.ViewModel.EM_ParticipateType.Student);
  102. if (evaluationNeedView == null)
  103. {
  104. throw new Exception("评价数据有误,请联系辅导员或教学评价负责老师。");
  105. }
  106. ViewBag.EvaluationNeedContent = evaluationNeedView.Content;
  107. }
  108. else
  109. {
  110. throw new Exception("进入评价超时,请刷新页面或退出系统重新登录。");
  111. }
  112. return View(evaluationStudentView);
  113. }
  114. }
  115. catch (Exception ex)
  116. {
  117. return RedirectToAction("MsgShow", "Common", new
  118. {
  119. WindowID = Request["WindowID"],
  120. msg = "进入教学质量评价活动失败,请按提示原因进行再次尝试操作(原因:" + ex.Message + ")。",
  121. url = Url.Action("List").AddMenuParameter()
  122. });
  123. }
  124. }
  125. /// <summary>
  126. /// 进入评价编辑
  127. /// </summary>
  128. /// <param name="evaluationStudentView"></param>
  129. /// <returns></returns>
  130. [HttpPost]
  131. public ActionResult EnterEdit(EvaluationStudentView evaluationStudentView)
  132. {
  133. try
  134. {
  135. StudentEvaluationEnterServices.Value.StudentEvaluationEnterEdit(evaluationStudentView);
  136. return Json(new ReturnMessage()
  137. {
  138. IsSuccess = true,
  139. Message = "评价成功。"
  140. });
  141. }
  142. catch (Exception ex)
  143. {
  144. return Json(new ReturnMessage()
  145. {
  146. IsSuccess = true,
  147. Message = "评价失败,原因:" + ex.Message
  148. });
  149. }
  150. }
  151. /// <summary>
  152. /// 评价表格标题
  153. /// </summary>
  154. /// <returns></returns>
  155. public JsonResult FormTitle()
  156. {
  157. ArrayList formTitleList = new ArrayList();
  158. formTitleList.Add(new { field = "OrderNo", title = "次序", align = "center", width = "120" });
  159. formTitleList.Add(new { field = "EvaluationTargetID", title = "评价指标ID", align = "center", width = "20" });
  160. formTitleList.Add(new { field = "EvaluationTargetWeight", title = "评价指标权重", align = "center", width = "20" });
  161. formTitleList.Add(new { field = "EvaluationProjectID", title = "评价项目ID", align = "center", width = "20" });
  162. formTitleList.Add(new { field = "EvaluationProjectName", title = "评价项目", align = "center", width = "350" });
  163. formTitleList.Add(new { field = "Weight", title = "权重", align = "center", width = "50" });
  164. formTitleList.Add(new { field = "EvaluationNormName", title = "评分标准", align = "center", width = "385" });
  165. return Json(new { UpTitle = JsonHelper.ToJSON(formTitleList) }, JsonRequestBehavior.AllowGet);
  166. }
  167. /// <summary>
  168. /// 评价表格内容
  169. /// </summary>
  170. /// <param name="evaluationStudentID"></param>
  171. /// <param name="evaluationTableID"></param>
  172. /// <returns></returns>
  173. public JsonResult Content(Guid? evaluationStudentID, Guid? evaluationTableID)
  174. {
  175. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  176. var evaluationTargetViewList = EvaluationTargetServices.Value.GetEvaluationTargetViewList(configuretView, null, null, evaluationTableID, null)
  177. .Select(x => new { x.EvaluationTargetID, x.EvaluationNormID, x.Name, x.Weight }).ToList();
  178. int i = 1;
  179. StringBuilder strRows = new StringBuilder();
  180. foreach (var evaluationTargetView in evaluationTargetViewList)
  181. {
  182. StringBuilder strRowtg = new StringBuilder();
  183. var tgNormNames = string.Join(" ", EvaluationNormServices.Value.GetEvaluationNormDetailViewList(configuretView, evaluationTargetView.EvaluationNormID).Select(s => s.Name + s.Weight));
  184. strRowtg.Append("{");
  185. strRowtg.Append("\"OrderNo\":\"" + evaluationTargetView.Name + "\"");
  186. strRowtg.Append(",\"EvaluationTargetID\":\"" + evaluationTargetView.EvaluationTargetID + "\"");
  187. strRowtg.Append(",\"EvaluationTargetWeight\":\"\"");
  188. strRowtg.Append(",\"EvaluationProjectID\":\"\"");
  189. strRowtg.Append(",\"EvaluationProjectName\":\"\"");
  190. strRowtg.Append(",\"Weight\":\"" + evaluationTargetView.Weight + "\"");
  191. strRowtg.Append(",\"EvaluationNormName\":\"" + tgNormNames + "\"");
  192. strRowtg.Append("}");
  193. if (string.IsNullOrEmpty(strRows.ToString()))
  194. {
  195. strRows.Append(strRowtg);
  196. }
  197. else
  198. {
  199. strRows.Append("," + strRowtg);
  200. }
  201. var evaluationProjectViewList = EvaluationProjectServices.Value.GetEvaluationProjectViewList(configuretView, null, null, evaluationTableID, evaluationTargetView.EvaluationTargetID)
  202. .Select(x => new { x.EvaluationProjectID, x.OrderNo, x.Name, x.Weight, x.Code, x.EvaluationTargetID, x.EvaluationTargetWeight }).ToList();
  203. int j = 1;
  204. var evaluationNormDetailViewList = EvaluationNormServices.Value.GetEvaluationNormDetailViewList(configuretView, evaluationTargetView.EvaluationNormID).ToList();
  205. foreach (var evaluationProjectView in evaluationProjectViewList)
  206. {
  207. var prNormNames = "";
  208. if (evaluationStudentID.HasValue && evaluationStudentID != Guid.Empty)
  209. {
  210. var evaluationStudentDetailList = StudentEvaluationEnterServices.Value.GetEvaluationStudentDetailList(evaluationStudentID).ToList();
  211. if (evaluationStudentDetailList != null && evaluationStudentDetailList.Count() > 0)
  212. {
  213. var evaluationStudentDetail = evaluationStudentDetailList.Where(x => x.EvaluationProjectID == evaluationProjectView.EvaluationProjectID).SingleOrDefault();
  214. string normDetailStr = "";
  215. if (evaluationStudentDetail != null)
  216. {
  217. foreach (var evaluationNormDetailView in evaluationNormDetailViewList)
  218. {
  219. if (evaluationStudentDetail.Score == evaluationNormDetailView.Weight)
  220. {
  221. normDetailStr = evaluationNormDetailView.Name + "<input type='radio' onclick='getonclick(this)' name='radioButtonName_" + j + "" + i + "_" + evaluationProjectView.EvaluationTargetID + "' value='" + evaluationNormDetailView.Weight + "' checked='checked' >";
  222. }
  223. else
  224. {
  225. normDetailStr = evaluationNormDetailView.Name + "<input type='radio' onclick='getonclick(this)' name='radioButtonName_" + j + "" + i + "_" + evaluationProjectView.EvaluationTargetID + "' value='" + evaluationNormDetailView.Weight + "'>";
  226. }
  227. prNormNames += " " + normDetailStr;
  228. }
  229. }
  230. else
  231. {
  232. prNormNames = string.Join(" ", evaluationNormDetailViewList.Select((s, index) => s.Name + "<input type='radio' onclick='getonclick(this)' name='radioButtonName_" + j + "" + i + "_" + evaluationProjectView.EvaluationTargetID + "' value='" + s.Weight + "'>"));
  233. }
  234. }
  235. else
  236. {
  237. prNormNames = string.Join(" ", evaluationNormDetailViewList.Select((s, index) => s.Name + "<input type='radio' onclick='getonclick(this)' name='radioButtonName_" + j + "" + i + "_" + evaluationProjectView.EvaluationTargetID + "' value='" + s.Weight + "'>"));
  238. }
  239. }
  240. else
  241. {
  242. prNormNames = string.Join(" ", evaluationNormDetailViewList.Select((s, index) => s.Name + "<input type='radio' onclick='getonclick(this)' name='radioButtonName_" + j + "" + i + "_" + evaluationProjectView.EvaluationTargetID + "' value='" + s.Weight + "'>"));
  243. }
  244. StringBuilder strRowpr = new StringBuilder();
  245. strRowpr.Append("{");
  246. strRowpr.Append("\"OrderNo\":\"" + evaluationProjectView.OrderNo + "\"");
  247. strRowpr.Append(",\"EvaluationTargetID\":\"" + evaluationProjectView.EvaluationTargetID + "\"");
  248. strRowpr.Append(",\"EvaluationTargetWeight\":\"" + evaluationProjectView.EvaluationTargetWeight + "\"");
  249. strRowpr.Append(",\"EvaluationProjectID\":\"" + evaluationProjectView.EvaluationProjectID + "\"");
  250. strRowpr.Append(",\"EvaluationProjectName\":\"" + evaluationProjectView.Name + "\"");
  251. strRowpr.Append(",\"Weight\":\"" + evaluationProjectView.Weight + "\"");
  252. strRowpr.Append(",\"EvaluationNormName\":\"" + prNormNames + "\"");
  253. strRowpr.Append("}");
  254. if (string.IsNullOrEmpty(strRows.ToString()))
  255. {
  256. strRows.Append(strRowpr);
  257. }
  258. else
  259. {
  260. strRows.Append("," + strRowpr);
  261. }
  262. j++;
  263. }
  264. i++;
  265. }
  266. return Json(new { rows = strRows.ToString(), total = 0 }, JsonRequestBehavior.AllowGet);
  267. }
  268. /// <summary>
  269. /// 查询对应的评价指标权重总和
  270. /// </summary>
  271. /// <param name="evaluationTargetIDs"></param>
  272. /// <returns></returns>
  273. [HttpPost]
  274. public ActionResult GetTargetWeightSum(string evaluationTargetIDs)
  275. {
  276. List<Guid?> list = evaluationTargetIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  277. var evaluationTargetWeightSum = EvaluationTargetServices.Value.GetEvaluationTargetList(list).Sum(x => x.Weight ?? 0);
  278. return base.Json(evaluationTargetWeightSum.ToString());
  279. }
  280. /// <summary>
  281. /// 查询对应的评价项目权重总和
  282. /// </summary>
  283. /// <param name="evaluationTargetID"></param>
  284. /// <returns></returns>
  285. [HttpPost]
  286. public ActionResult GetProjectWeightSum(string evaluationTargetID)
  287. {
  288. var evaluationProjectWeightSum = EvaluationProjectServices.Value.GetEvaluationProjectList(Guid.Parse(evaluationTargetID)).Sum(x => x.Weight ?? 0);
  289. return base.Json(evaluationProjectWeightSum.ToString());
  290. }
  291. /// <summary>
  292. /// Excel导出
  293. /// </summary>
  294. /// <returns></returns>
  295. [HttpPost]
  296. public ActionResult Excel()
  297. {
  298. NpoiExcelHelper neh = new NpoiExcelHelper();
  299. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  300. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  301. var dt = StudentEvaluationEnterServices.Value.GetStudentEvaluationEnterViewList(configuretView, user.UserID)
  302. .Select(x => new
  303. {
  304. x.SchoolyearCode,
  305. x.MissionClassName,
  306. x.CourseName,
  307. x.CourseTypeName,
  308. x.HandleModeName,
  309. x.TeachingModeName,
  310. x.EvaluationTableName,
  311. x.ParticipateTypeName,
  312. x.EvaluationTypeName,
  313. x.StaffName,
  314. x.TeachingMethodName,
  315. x.Number,
  316. x.Numbered
  317. }).ToTable();
  318. string[] liststring = {
  319. "学年学期", "任务班名称", "课程名称", "课程类型", "处理方式", "授课方式", "评价表名", "参评类型", "评价类型",
  320. "任课教师", "任课方式", "可评次数", "已评次数"
  321. };
  322. neh.Export(dt, liststring, "进入评价信息(" + user.LoginID + ")" + DateTime.Now.ToString("yyyyMMdd"));
  323. return Json(new ReturnMessage()
  324. {
  325. IsSuccess = true,
  326. Message = "导出成功。"
  327. });
  328. }
  329. }
  330. }