EvaluationEnterController.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using Bowin.Common.Exceptions;
  7. using Bowin.Common.Utility;
  8. using Bowin.Web.Controls.Mvc;
  9. using EMIS.CommonLogic.EvaluationManage;
  10. using EMIS.ViewModel;
  11. using EMIS.ViewModel.EvaluationManage;
  12. using EMIS.Web.Controls;
  13. using Bowin.Common.Data;
  14. using EMIS.CommonLogic.CalendarManage;
  15. using EMIS.CommonLogic.EducationManagement;
  16. using EMIS.ViewModel.EvaluationManage.EvaluationEnter;
  17. using System.Text;
  18. using System.Collections;
  19. using EMIS.Utility;
  20. using Bowin.Common.JSON;
  21. using EMIS.Entities;
  22. using System.Text.RegularExpressions;
  23. using EMIS.Utility.FormValidate;
  24. namespace EMIS.Web.Controllers.EvaluationManage.EvaluationEnter
  25. {
  26. [Authorization]
  27. public class EvaluationEnterController : Controller
  28. {
  29. public IEvaluationEnterServices EvaluationEnterServices { get; set; }
  30. public IEvaluationTargetServices EvaluationTargetServices { get; set; }
  31. public IEvaluationProjectServices EvaluationProjectServices { get; set; }
  32. public IEvaluationTableServices EvaluationTableServices { get; set; }
  33. public IEvaluationNormServices EvaluationNormServices { get; set; }
  34. //public IEvaluationNeedServices EvaluationNeedServices { get; set; }
  35. public IEvaluationTypeServices EvaluationTypeServices { get; set; }
  36. public IEvaluationSettingServices EvaluationSettingServices { get; set; }
  37. Guid? educationMissionID = Guid.Empty;
  38. /// <summary>
  39. /// 进入评价页面
  40. /// </summary>
  41. /// <returns></returns>
  42. [HttpGet]
  43. public ActionResult List()
  44. {
  45. return View();
  46. }
  47. [HttpPost]
  48. public ActionResult List(QueryParamsModel pararms)
  49. {
  50. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  51. var curUser = CustomPrincipal.Current;
  52. var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown");
  53. var result = EvaluationEnterServices.GetEvaluationEnterViewGrid(configuretView, schoolyearID, curUser.UserID, curUser.RoleID, curUser.IsStudent, (int)pararms.page, (int)pararms.rows);
  54. return Json(result);
  55. }
  56. /// <summary>
  57. /// 学生平台进入评价
  58. /// </summary>
  59. /// <returns></returns>
  60. [HttpGet]
  61. public ActionResult StudentList()
  62. {
  63. return View();
  64. }
  65. /// <summary>
  66. /// 查询列表
  67. /// </summary>
  68. /// <param name="pararms"></param>
  69. /// <returns></returns>
  70. [HttpPost]
  71. public ActionResult StudentList(QueryParamsModel pararms)
  72. {
  73. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  74. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  75. return base.Json(EvaluationEnterServices.GetEvaluationEnterViewGrid(configuretView, null, curUser.UserID, curUser.RoleID, curUser.IsStudent, (int)pararms.page, (int)pararms.rows));
  76. }
  77. /// <summary>
  78. ///
  79. /// </summary>
  80. /// <param name="evaluationSettingID"></param>
  81. /// <param name="evaluationTableID"></param>
  82. /// <param name="evaluationEnterID"></param>
  83. /// <param name="IsEvaluation"></param>
  84. /// <returns></returns>
  85. public ActionResult Edit(Guid? evaluationSettingID, Guid? evaluationTableID, Guid? evaluationEnterID, bool IsEvaluation/*是否在可评时间内*/)
  86. {
  87. var vm = new EvaluationEnterView();
  88. try
  89. {
  90. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  91. bool isStudent = curUser.IsStudent;//获取当前用户是否是学生
  92. // Guid? typeID = isStudent == true ? Guid.Parse("AAF0A913-3A57-431A-8D4B-CAF11B130759")/*学生评*/ : Guid.Parse("B6D2461D-6F6E-4F6A-AF4F-2A9F34830F56")/*同行评*/;
  93. EM_EvaluationTable EvaluationTable = null;
  94. EvaluationEnterView evaluationEnterEntity = EvaluationEnterServices.GetEvaluationSettingOrEnterView(evaluationSettingID, curUser.UserID, curUser.RoleID, isStudent);//加载进入评价的被评教师、课程名称、教研室、相关信息
  95. Guid? educationMissionClassID = evaluationEnterEntity.EducationMissionClassID;
  96. if (evaluationEnterEntity != null)
  97. {
  98. educationMissionClassID = evaluationEnterEntity.EducationMissionClassID;
  99. evaluationTableID = evaluationEnterEntity.EvaluationTableID;
  100. }
  101. if (evaluationTableID == null || evaluationTableID == Guid.Empty)
  102. {
  103. throw new Exception("评价类型与评价表不匹配,请检查。");
  104. }
  105. ViewBag.EducationMissionClassID = educationMissionClassID;
  106. educationMissionID = educationMissionClassID;
  107. ViewBag.EvaluationTableID = evaluationTableID;
  108. EvaluationTable = EvaluationTableServices.GetEvaluationTable(evaluationTableID);
  109. ViewBag.TableWeight = EvaluationTable.Weight;//评价表权重;
  110. ViewBag.TableName = EvaluationTable.Name;
  111. //var evaluationTableLsit = EvaluationEnterServices.GetCreateEvaluationEnterTable(evaluationTableID, configuretView);//评价表ID、获取对应评价表
  112. //ViewData["evaluationTableLsit"] = evaluationTableLsit;
  113. //根据教学任务班ID、获取相关课程、教师、教研室内容
  114. ViewBag.UserNames = evaluationEnterEntity.UserNames;//教师名称
  115. ViewBag.CourseName = evaluationEnterEntity.CourseName;//课程名称
  116. ViewBag.Remark = evaluationEnterEntity.DepartmentName;//教研室
  117. ViewBag.LimitMore = evaluationEnterEntity.LimitMore;//限制评价次数
  118. int modifyTimeCount = 0;//已评次数
  119. if (evaluationEnterID != Guid.Empty)
  120. {
  121. ViewBag.evaluationEnterID = evaluationEnterID;
  122. EM_EvaluationEnter evaluationEnterOrProjectEntity = EvaluationEnterServices.GetEvaluationEnterView(evaluationEnterID);
  123. if (evaluationEnterOrProjectEntity != null)
  124. {
  125. vm.EvaluationTableID = evaluationEnterOrProjectEntity.EvaluationTableID;
  126. vm.EducationMissionClassID = evaluationEnterOrProjectEntity.EducationMissionClassID;
  127. vm.EvaluationEnterID = evaluationEnterOrProjectEntity.EvaluationEnterID;
  128. vm.Remark = evaluationEnterOrProjectEntity.Remark;
  129. ViewBag.evaluationEnterID = evaluationEnterOrProjectEntity.EvaluationEnterID;
  130. modifyTimeCount = EvaluationEnterServices.GetEvaluationEnter_EM_EvaluationProjectList(evaluationEnterOrProjectEntity.EvaluationEnterID).GroupBy(x => x.ModifyTime).Select(x => x).Count();
  131. }
  132. // EvaluationTypeView evaluationTypeEntity = EvaluationTypeServices.GetEvaluationTypeView(EvaluationTable.TypeID);
  133. }
  134. //判断是否是管理员 如果是管理员、那么禁用保存按钮
  135. if (!curUser.IsStudent)
  136. {
  137. IsEvaluation = EvaluationEnterServices.GteDataRange(curUser.RoleID);
  138. }
  139. if (modifyTimeCount >= evaluationEnterEntity.LimitMore)
  140. {
  141. IsEvaluation = false;//如果已评次数大于 限评次数、那么隐藏保存按钮
  142. }
  143. vm.PhotoUrl = evaluationEnterEntity.PhotoUrl;//教师照片
  144. EM_EvaluationNeed evaluationNeedEntity = null;
  145. ViewBag.ContentStr = "评价需知内容";//教师评价需知内容
  146. //EM_EvaluationNeed evaluationNeedEntity = EvaluationNeedServices.GetEvaluationNeedByRole(isStudent == true ? (int)SYS_RoleType.Student : (int)SYS_RoleType.Teacher);
  147. //if (evaluationNeedEntity != null)
  148. //{
  149. // ViewBag.ContentStr = evaluationNeedEntity.Content;//教师评价需知内容
  150. //}
  151. //else
  152. //{
  153. // throw new Exception("对应的评价需知信息不能为空。");
  154. //}
  155. // ViewBag.RoleType = isStudent == true ? "学生用" : "教师用";
  156. ViewBag.YP = modifyTimeCount;
  157. ViewBag.IsEvaluation = IsEvaluation;
  158. }
  159. catch (Exception ex)
  160. {
  161. return RedirectToAction("MsgShow", "Common", new
  162. {
  163. WindowID = Request["WindowID"],
  164. msg = "请求失败:" + ex.Message,
  165. url = Url.Action("List").AddMenuParameter()
  166. });
  167. }
  168. return View(vm);
  169. }
  170. /// <summary>
  171. /// 新增或更新
  172. /// </summary>
  173. /// <param name="vm"></param>
  174. /// <returns></returns>
  175. [HttpPost]
  176. public ActionResult Edit(EvaluationEnterView vm)
  177. {
  178. try
  179. {
  180. vm.UserID = CustomPrincipal.Current.UserID;
  181. EvaluationEnterServices.Save(vm, CustomPrincipal.Current.IsStudent);//保存或更新进入评价数据
  182. return Json(new ReturnMessage()
  183. {
  184. IsSuccess = true,
  185. Message = "保存成功!"
  186. });
  187. }
  188. catch (Exception ex)
  189. {
  190. return Json(new ReturnMessage()
  191. {
  192. IsSuccess = false,
  193. Message = "保存失败:" + ex.Message
  194. });
  195. }
  196. }
  197. /// <summary>
  198. ///
  199. /// </summary>
  200. /// <returns></returns>
  201. public JsonResult GetTitle()
  202. {
  203. ArrayList arUpList = new ArrayList();
  204. arUpList.Add(new { field = "OrderID", title = "次序", align = "center", width = "150" });
  205. arUpList.Add(new { field = "ProjectName", title = "评价项目", align = "center", width = "300" });
  206. arUpList.Add(new { field = "NormNameProjectID", title = "评价项目ID", align = "center", width = "50" });
  207. arUpList.Add(new { field = "TargetID", title = "评价指标ID", align = "center", width = "50" });
  208. arUpList.Add(new { field = "TargetWeight", title = "评价指标分数", align = "center", width = "50" });
  209. arUpList.Add(new { field = "Weight", title = "权重", align = "center", width = "150" });
  210. arUpList.Add(new { field = "NormNames", title = "评分标准", align = "center", width = "250" });
  211. return Json(new { UpTitle = JsonHelper.ToJSON(arUpList) }, JsonRequestBehavior.AllowGet);
  212. }
  213. /// <summary>
  214. /// 根据对应的评价表创建表格
  215. /// </summary>
  216. /// <param name="tableID"></param>
  217. /// <returns></returns>
  218. public JsonResult GetList(string tableID, string evaluationEnterID)
  219. {
  220. StringBuilder strRows = new StringBuilder();
  221. Guid TableID = Guid.Parse(tableID);
  222. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  223. var dataTargetList = EvaluationTargetServices.GetEvaluationTargetViewList(configuretView, TableID, null).Select(x => new
  224. {
  225. x.TargetID,
  226. x.NormID,
  227. x.Name,
  228. x.Weight
  229. }).ToList();
  230. int i = 1;
  231. foreach (var dataTarget in dataTargetList)
  232. {
  233. var NormNames = string.Join(" ", EvaluationNormServices.GetEvaluationNormDetailViewList(dataTarget.NormID.Value).Select(s => s.Name + s.Weight));
  234. var NormNamesWeight = string.Join(",", EvaluationNormServices.GetEvaluationNormDetailViewList(dataTarget.NormID.Value).Select(s => s.Weight));
  235. StringBuilder strRow = new StringBuilder();
  236. strRow.Append("{");
  237. strRow.Append("\"OrderID\":\"" + dataTarget.Name + "\"");
  238. strRow.Append(",\"ProjectName\":\"\"");
  239. strRow.Append(",\"NormNameProjectID\":\"\"");
  240. strRow.Append(",\"TargetID\":\"" + dataTarget.TargetID + "\"");
  241. strRow.Append(",\"TargetWeight\":\"\"");
  242. strRow.Append(",\"Weight\":\"" + dataTarget.Weight + "\"");
  243. strRow.Append(",\"NormNames\":\"" + NormNames + "\"");
  244. strRow.Append("}");
  245. if (string.IsNullOrEmpty(strRows.ToString()))
  246. {
  247. strRows.Append(strRow);
  248. }
  249. else
  250. {
  251. strRows.Append("," + strRow);
  252. }
  253. var dataProjectList = EvaluationProjectServices.GetEvaluationProjectViewList(configuretView, dataTarget.TargetID, TableID, null).Select(x => new
  254. {
  255. x.ProjectID,
  256. x.OrderID,
  257. x.Name,
  258. x.Weight,
  259. x.Code,
  260. x.TargetID,
  261. x.TargetWeight
  262. }).ToList();
  263. int j = 1;
  264. foreach (var dataProject in dataProjectList)
  265. {
  266. string[] NormNamesArry = NormNamesWeight.Split(',').ToArray();
  267. string strSplit1 = "", strSplit2 = "";
  268. //foreach (var NormName in NormNamesArry)
  269. //{
  270. // strSplit2 = Regex.Replace(NormName, "[0-9]", "", RegexOptions.IgnoreCase);//级别
  271. // strSplit1 = Regex.Replace(NormName, "[\u4e00-\u9fa5]", "", RegexOptions.IgnoreCase); //力度
  272. //}
  273. //保存以后加载、默认选中
  274. var NormNames1 = "";
  275. if (evaluationEnterID != "")
  276. {
  277. Guid evaluationEnterIDs = Guid.Parse(evaluationEnterID);
  278. IList<EvaluationEnterView> tieleList = EvaluationEnterServices.GetEvaluationEnterByNormDetail(evaluationEnterIDs, TableID, dataTarget.NormID.Value).Where(x => x.ProjectID == dataProject.ProjectID).ToList();
  279. string htmlStr = "";
  280. string str = "";
  281. if (tieleList.Count > 0)
  282. {
  283. // var evaluationNormList = EvaluationNormServices.GetEvaluationNormDetailViewList(dataTarget.NormID.Value);
  284. //兼容默认还原之前选中值
  285. IList<EvaluationNormDetailView> evaluationNormList = EvaluationNormServices.GetEvaluationNormOrProjectDetailViewList(dataTarget.NormID.Value);
  286. evaluationNormList = evaluationNormList.Where(x => x.ProjectID == dataProject.ProjectID).ToList();
  287. foreach (var evaluationNorm in evaluationNormList)
  288. {
  289. foreach (var tiele in tieleList)
  290. {
  291. if (evaluationNorm.Weight == tiele.EvaluationScore && evaluationNorm.ProjectID == tiele.ProjectID)
  292. {
  293. str = evaluationNorm.Name + "<input type='radio' onclick='getonclick(this)' name='radioButtonName_" + j + "" + i + "_" + dataProject.TargetID + "' value='" + evaluationNorm.Weight + "' checked='checked' >";
  294. }
  295. else
  296. {
  297. str = evaluationNorm.Name + "<input type='radio' onclick='getonclick(this)' name='radioButtonName_" + j + "" + i + "_" + dataProject.TargetID + "' value='" + evaluationNorm.Weight + "'>";
  298. }
  299. }
  300. htmlStr += " " + str;
  301. }
  302. NormNames1 = htmlStr;
  303. }
  304. else
  305. {
  306. NormNames1 = string.Join(" ", EvaluationNormServices.GetEvaluationNormDetailViewList(dataTarget.NormID.Value).Select((s, index) => s.Name + "<input type='radio' onclick='getonclick(this)' name='radioButtonName_" + j + "" + i + "_" + dataProject.TargetID + "' value='" + s.Weight + "'>"));
  307. }
  308. }
  309. else
  310. {
  311. NormNames1 = string.Join(" ", EvaluationNormServices.GetEvaluationNormDetailViewList(dataTarget.NormID.Value).Select((s, index) => s.Name + "<input type='radio' onclick='getonclick(this)' name='radioButtonName_" + j + "" + i + "_" + dataProject.TargetID + "' value='" + s.Weight + "'>"));
  312. }
  313. // string.Join(" ", EvaluationNormServices.GetEvaluationNormDetailViewList(dataTarget.NormID.Value).Select((s, index) => s.Name + "<input type='radio' onclick='getonclick(this)' name='radioButtonName_" + j + "" + i + "' value='" + dataProject.Code + "'>"));
  314. j++;
  315. StringBuilder strRow1 = new StringBuilder();
  316. strRow1.Append("{");
  317. strRow1.Append("\"OrderID\":\"" + dataProject.OrderID + "\"");
  318. strRow1.Append(",\"ProjectName\":\"" + dataProject.Name + "\"");
  319. strRow1.Append(",\"NormNameProjectID\":\"" + dataProject.ProjectID + "\"");
  320. strRow1.Append(",\"TargetID\":\"" + dataTarget.TargetID + "\"");
  321. strRow1.Append(",\"TargetWeight\":\"" + dataTarget.Weight + "\"");
  322. strRow1.Append(",\"Weight\":\"" + dataProject.Weight + "\"");
  323. strRow1.Append(",\"NormNames\":\"" + NormNames1 + "\"");
  324. strRow1.Append("}");
  325. if (string.IsNullOrEmpty(strRows.ToString()))
  326. {
  327. strRows.Append(strRow1);
  328. }
  329. else
  330. {
  331. strRows.Append("," + strRow1);
  332. }
  333. }
  334. i++;
  335. }
  336. return Json(new { rows = strRows.ToString(), total = 0 }, JsonRequestBehavior.AllowGet);
  337. //var tableStrList = strRows.ToString().JsonToObject<List<CreateTable>>();//将json转实体集合
  338. //return tableStrList;
  339. }
  340. /// <summary>
  341. ///
  342. /// </summary>
  343. /// <param name="targetIDs"></param>
  344. /// <returns></returns>
  345. [HttpPost]
  346. public ActionResult GetWeightSum(string targetIDs)
  347. {
  348. List<Guid> list = new List<Guid>();
  349. for (int i = 0; i < targetIDs.Split(',').Length; i++)
  350. {
  351. string id = targetIDs.Split(',')[i];
  352. if (!string.IsNullOrEmpty(id))
  353. {
  354. Guid targetID = new Guid(id);
  355. list.Add(targetID);
  356. }
  357. }
  358. decimal? WeightSum = EvaluationTargetServices.GetEvaluationTargetList(list).Select(x => x.Weight).Sum();
  359. return base.Json(WeightSum.ToString());
  360. }
  361. [HttpPost]
  362. public ActionResult GetProjectWeightSum(string targetID)
  363. {
  364. Guid TargetID = Guid.Parse(targetID);
  365. List<Guid> list = new List<Guid>();
  366. list.Add(TargetID);
  367. decimal? WeightSum = EvaluationTargetServices.GetEvaluationProjectList(TargetID).Select(x => x.Weight).Sum();
  368. return base.Json(WeightSum.ToString());
  369. }
  370. /// <summary>
  371. /// Excel导出
  372. /// </summary>
  373. /// <returns></returns>
  374. [HttpPost]
  375. public ActionResult Excel()
  376. {
  377. try
  378. {
  379. NpoiExcelHelper neh = new NpoiExcelHelper();
  380. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  381. var schoolyearID = Request.Form["SchoolyearDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
  382. var dt = EvaluationEnterServices.GetEvaluationEnterViewList(configuretView, schoolyearID, CustomPrincipal.Current.UserID, CustomPrincipal.Current.RoleID, CustomPrincipal.Current.IsStudent).Select(x => new
  383. {
  384. x.EvaluationSettingCode,
  385. x.CourseName,
  386. x.EvaluationTableTypeName,
  387. x.UserCodes,
  388. x.UserNames,
  389. x.EvaluationTypeName,
  390. x.EvaluationCount
  391. }).ToTable();
  392. string[] liststring = { "评价编号", "课程名称", "评价类型 ", "被评教师号", "被评教师", "参评类型 ", "已评次数" };
  393. neh.Export(dt, liststring, "进入评价信息");
  394. return RedirectToAction("MsgShow", "Common", new
  395. {
  396. msg = "导出成功!",
  397. url = Url.Content("~/EvaluationEnter/List").AddMenuParameter()
  398. });
  399. }
  400. catch (Exception ex)
  401. {
  402. return RedirectToAction("MsgShow", "Common", new
  403. {
  404. msg = "导出失败,原因:" + ex.Message + "!",
  405. url = Url.Content("~/EvaluationEnter/List").AddMenuParameter()
  406. });
  407. }
  408. }
  409. }
  410. }