CollegePriorityController.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using Bowin.Web.Controls.Mvc;
  7. using Bowin.Common.Utility;
  8. using Bowin.Common.Data;
  9. using Bowin.Common.JSON;
  10. using EMIS.Utility;
  11. using EMIS.Web.Controls;
  12. using EMIS.ViewModel;
  13. using EMIS.ViewModel.SchedulingManage;
  14. using EMIS.CommonLogic.SchedulingManage.SchedulingSettings;
  15. namespace EMIS.Web.Controllers.SchedulingManage.SchedulingSettings
  16. {
  17. [Authorization]
  18. public class CollegePriorityController : Controller
  19. {
  20. public ICollegePriorityServices CollegePriorityServices { get; set; }
  21. /// <summary>
  22. /// 院系控制页面
  23. /// </summary>
  24. /// <returns></returns>
  25. public ActionResult List()
  26. {
  27. return View();
  28. }
  29. /// <summary>
  30. /// 院系控制列表查询
  31. /// </summary>
  32. /// <returns></returns>
  33. [HttpPost]
  34. public ActionResult List(QueryParamsModel pararms)
  35. {
  36. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  37. var campusID = pararms.getExtraGuid("CampusDropdown");
  38. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  39. var dateRange = pararms.getExtraDateTime("txtDateRange");
  40. return Json(CollegePriorityServices.GetCollegePriorityViewGrid(configuretView, campusID, collegeID,
  41. dateRange, (int)pararms.page, (int)pararms.rows));
  42. }
  43. /// <summary>
  44. /// 复制新增
  45. /// </summary>
  46. /// <param name="collegePriorityID"></param>
  47. /// <returns></returns>
  48. public ActionResult CopyAdd(Guid collegePriorityID)
  49. {
  50. CollegePriorityView collegePriorityView = new CollegePriorityView();
  51. collegePriorityView = CollegePriorityServices.GetCollegePriorityView(collegePriorityID);
  52. return View("Edit", collegePriorityView);
  53. }
  54. /// <summary>
  55. /// 复制新增
  56. /// </summary>
  57. /// <param name="collegePriorityView"></param>
  58. /// <returns></returns>
  59. [HttpPost]
  60. public ActionResult CopyAdd(CollegePriorityView collegePriorityView)
  61. {
  62. collegePriorityView.CollegePriorityID = Guid.Empty;
  63. return this.Edit(collegePriorityView);
  64. }
  65. /// <summary>
  66. /// 编辑(新增、修改)
  67. /// </summary>
  68. /// <param name="collegePriorityID"></param>
  69. /// <returns></returns>
  70. public ActionResult Edit(Guid? collegePriorityID)
  71. {
  72. CollegePriorityView collegePriorityView = new CollegePriorityView();
  73. if (collegePriorityID.HasValue && collegePriorityID != Guid.Empty)
  74. {
  75. collegePriorityView = CollegePriorityServices.GetCollegePriorityView(collegePriorityID);
  76. }
  77. else
  78. {
  79. collegePriorityView.Priority = 1;
  80. collegePriorityView.StartDate = DateTime.Now;
  81. collegePriorityView.EndDate = DateTime.Now.AddMonths(1);
  82. }
  83. return View(collegePriorityView);
  84. }
  85. /// <summary>
  86. /// 编辑(新增、修改)
  87. /// </summary>
  88. /// <param name="collegePriorityView"></param>
  89. /// <returns></returns>
  90. [HttpPost]
  91. public ActionResult Edit(CollegePriorityView collegePriorityView)
  92. {
  93. try
  94. {
  95. CollegePriorityServices.CollegePriorityEdit(collegePriorityView);
  96. return Json(new ReturnMessage()
  97. {
  98. IsSuccess = true,
  99. Message = "保存成功。"
  100. });
  101. }
  102. catch (Exception ex)
  103. {
  104. return Json(new ReturnMessage()
  105. {
  106. IsSuccess = false,
  107. Message = "保存失败,原因:" + ex.Message
  108. });
  109. }
  110. }
  111. /// <summary>
  112. /// 院系控制信息批量新增
  113. /// </summary>
  114. /// <returns></returns>
  115. [HttpGet]
  116. public ActionResult CollegePriorityBatchAdd()
  117. {
  118. CollegePriorityView collegePriorityView = new CollegePriorityView();
  119. collegePriorityView.Priority = 1;
  120. collegePriorityView.StartDate = DateTime.Now;
  121. collegePriorityView.EndDate = DateTime.Now.AddMonths(1);
  122. return View(collegePriorityView);
  123. }
  124. /// <summary>
  125. /// 院系控制信息批量新增
  126. /// </summary>
  127. /// <param name="collegePriorityView"></param>
  128. /// <returns></returns>
  129. public ActionResult CollegePriorityBatchAdd(CollegePriorityView collegePriorityView)
  130. {
  131. try
  132. {
  133. var collegeIDList = Request["collegeIDList"].JsonToObject<List<Guid?>>();
  134. string result = CollegePriorityServices.CollegePriorityBatchAdd(collegeIDList, collegePriorityView);
  135. return Json(new ReturnMessage()
  136. {
  137. IsSuccess = true,
  138. Message = "新增成功" + result + "。"
  139. });
  140. }
  141. catch (Exception ex)
  142. {
  143. return Json(new ReturnMessage()
  144. {
  145. IsSuccess = false,
  146. Message = "新增失败,原因:" + ex.Message
  147. });
  148. }
  149. }
  150. /// <summary>
  151. /// 查询对应的未新增院系所信息CollegeView
  152. /// </summary>
  153. /// <param name="pararms"></param>
  154. /// <returns></returns>
  155. [HttpPost]
  156. public ActionResult CollegeNoAddList(QueryParamsModel pararms)
  157. {
  158. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  159. var campusID = pararms.getExtraGuid("CampusDropdown");
  160. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  161. var unitCategoryID = pararms.getExtraInt("DictionaryUnitCategory") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryUnitCategory");
  162. return base.Json(CollegePriorityServices.GetCollegeViewNoAddGrid(configuretView, campusID, collegeID,
  163. unitCategoryID, (int)pararms.page, (int)pararms.rows));
  164. }
  165. /// <summary>
  166. /// 删除
  167. /// </summary>
  168. /// <param name="collegePriorityIDs"></param>
  169. /// <returns></returns>
  170. [HttpPost]
  171. public ActionResult Delete(string collegePriorityIDs)
  172. {
  173. try
  174. {
  175. List<Guid?> list = collegePriorityIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  176. .Select(x => (Guid?)new Guid(x)).ToList();
  177. CollegePriorityServices.CollegePriorityDelete(list);
  178. return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
  179. }
  180. catch (Exception ex)
  181. {
  182. return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + ex.Message });
  183. }
  184. }
  185. /// <summary>
  186. /// Excel导出
  187. /// </summary>
  188. /// <returns></returns>
  189. [HttpPost]
  190. public ActionResult Excel()
  191. {
  192. NpoiExcelHelper neh = new NpoiExcelHelper();
  193. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  194. var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  195. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  196. var dateRange = Request.Form["txtDateRange"].ParseStrTo<DateTime>();
  197. var dt = CollegePriorityServices.GetCollegePriorityViewList(configuretView, campusID, collegeID, dateRange)
  198. .Select(x => new
  199. {
  200. x.CollegeNo,
  201. x.CollegeName,
  202. x.UnitCategoryName,
  203. x.Priority,
  204. x.CampusNo,
  205. x.CampusName,
  206. StartDate = x.StartDate == null ? null : x.StartDate.Value.ToString("yyyy-MM-dd"),
  207. EndDate = x.EndDate == null ? null : x.EndDate.Value.ToString("yyyy-MM-dd"),
  208. x.OpenDays,
  209. x.CreateUserName
  210. }).ToTable();
  211. string[] liststring = {
  212. RSL.Get("CollegeCode"), RSL.Get("CollegeName"), "单位类别", "优先级",
  213. RSL.Get("CampusCode"), RSL.Get("CampusName"), "开始日期", "结束日期",
  214. "开放天数", "创建人"
  215. };
  216. neh.Export(dt, liststring, "院系控制信息" + DateTime.Now.ToString("yyyyMMdd"));
  217. return Json(new ReturnMessage()
  218. {
  219. IsSuccess = true,
  220. Message = "导出成功。"
  221. });
  222. }
  223. }
  224. }