TeachersOrderController.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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.JSON;
  7. using EMIS.ViewModel;
  8. using EMIS.Web.Controls;
  9. using EMIS.CommonLogic.TeachingMaterial;
  10. using Bowin.Web.Controls.Mvc;
  11. using EMIS.ViewModel.TeachingMaterial;
  12. using Bowin.Common.Utility;
  13. using Bowin.Common.Data;
  14. using EMIS.ViewModel.WorkflowManage;
  15. using EMIS.CommonLogic.CalendarManage;
  16. using Newtonsoft.Json;
  17. using EMIS.Utility;
  18. namespace EMIS.Web.Controllers.TeachingMaterial
  19. {
  20. [Authorization]
  21. public class TeachersOrderController : Controller
  22. {
  23. public ITeachersOrderServices TeachersOrderServices { get; set; }
  24. public ITeachersOrderExamineServices TeachersOrderExamineServices { get; set; }
  25. public ISchoolYearServices schoolYearServices { get; set; }
  26. /// <summary>
  27. /// 征订申请页面列表查询
  28. /// </summary>
  29. /// <returns></returns>
  30. [HttpGet]
  31. public ActionResult List()
  32. {
  33. //默认加载当前校历下学年学期的下一个学期
  34. var schoolYearView = schoolYearServices.GetSchoolYearIsCurrent(true);
  35. var schoolyear = schoolYearServices.GetSchoolYearViewListAfterCurrent().OrderBy(x => x.Code).Where(x => x.Value > schoolYearView.Value).FirstOrDefault();
  36. ViewBag.SchoolYearID = schoolyear.SchoolYearID;
  37. return View();
  38. }
  39. /// <summary>
  40. /// 列表查询
  41. /// </summary>
  42. /// <param name="pararms"></param>
  43. /// <returns></returns>
  44. [HttpPost]
  45. public ActionResult List(QueryParamsModel pararms)
  46. {
  47. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  48. //避开全选值
  49. Guid? publishID = null;
  50. Guid? coursematerialID = null;
  51. publishID = pararms.getExtraGuid("PublishDropdown");
  52. coursematerialID = pararms.getExtraGuid("CourseDropdown");
  53. var schoolYearID = pararms.getExtraGuid("SchoolYearDropdown");
  54. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  55. var approvalStatus = pararms.getExtraInt("StatusDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StatusDropdown");
  56. return base.Json(TeachersOrderServices.GetTeachersOrderViewGrid(configuretView, schoolYearID, collegeID, coursematerialID, publishID, approvalStatus, (int)pararms.page, (int)pararms.rows));
  57. }
  58. /// <summary>
  59. /// 编辑页面
  60. /// </summary>
  61. /// <returns></returns>
  62. [HttpGet]
  63. public ActionResult Edit(Guid? teachersOrderID)
  64. {
  65. TeachersOrderView TeachersOrderView;
  66. if (teachersOrderID != null && teachersOrderID != Guid.Empty)
  67. {
  68. TeachersOrderView = null;
  69. TeachersOrderView = TeachersOrderServices.GetSingleTeachersOrder(teachersOrderID.Value);
  70. }
  71. else
  72. {
  73. TeachersOrderView = new TeachersOrderView()
  74. {
  75. TeachersOrderID = Guid.Empty
  76. };
  77. }
  78. return View(TeachersOrderView);
  79. }
  80. /// <summary>
  81. /// 编辑
  82. /// </summary>
  83. /// <param name="TeachersOrderID"></param>
  84. /// <returns></returns>
  85. [HttpPost]
  86. public ActionResult Edit(TeachersOrderView teachersOrderView)
  87. {
  88. try
  89. {
  90. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  91. TeachersOrderView teachersOrder = new TeachersOrderView();
  92. if (teachersOrderView.TeachersOrderID != null)
  93. {
  94. TeachersOrderServices.EditTeachersOrder(teachersOrderView, user.UserID);
  95. }
  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 = true,
  107. Message = "保存失败,原因:" + ex.Message + "!"
  108. });
  109. }
  110. }
  111. [HttpPost]
  112. public ActionResult TeachersSave(string orderJson, TeachersOrderView teachersOrderView)
  113. {
  114. try
  115. {
  116. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  117. orderJson = Request.Form["hid_orderJsonStr"];
  118. var collegeID = user.CollegeID;//获取当前登录用户对应的院系所
  119. if (collegeID == null)
  120. {
  121. throw new Exception("该用户没有对应的" + RSL.Get("College") + ",请联系相关人员!");
  122. }
  123. var orderList = orderJson.JsonToObject<List<TeachingMaterialPoolView>>();
  124. List<TeachersOrderView> teachersOrderList = new List<TeachersOrderView>();
  125. orderList.ForEach(x =>
  126. {
  127. TeachersOrderView order = new TeachersOrderView
  128. {
  129. TeachingMaterialPoolID = x.TeachingMaterialPoolID,
  130. SchoolyearID = teachersOrderView.SchoolyearID,
  131. CollegeID = collegeID == null ? Guid.Empty : collegeID,
  132. OrderQty = x.OrderQty,
  133. OrderUserID = user.UserID,
  134. OrderDate = DateTime.Now,
  135. OrderDesc = teachersOrderView.OrderDesc
  136. };
  137. teachersOrderList.Add(order);
  138. });
  139. TeachersOrderServices.AddTeachersOrder(teachersOrderList, user.UserID);
  140. //return base.Json("征订成功");
  141. return Json(new ReturnMessage()
  142. {
  143. IsSuccess = true,
  144. Message = "保存成功!"
  145. });
  146. }
  147. catch (Exception ex)
  148. {
  149. return Json(new ReturnMessage()
  150. {
  151. IsSuccess = true,
  152. Message = "保存失败,原因:" + ex.Message + "!"
  153. });
  154. }
  155. }
  156. /// <summary>
  157. /// 提交申请
  158. /// </summary>
  159. /// <param name="TeachersOrderIDs">申请征订ID</param>
  160. /// <returns></returns>
  161. [HttpPost]
  162. public ActionResult SubmitTeachersOrder(string TeachersOrderIDs)
  163. {
  164. try
  165. {
  166. List<Guid> list = new List<Guid>();
  167. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  168. for (int i = 0; i < TeachersOrderIDs.Split(',').Length; i++)
  169. {
  170. string id = TeachersOrderIDs.Split(',')[i];
  171. if (!string.IsNullOrEmpty(id))
  172. {
  173. Guid TeachersOrderID = new Guid(id);
  174. list.Add(TeachersOrderID);
  175. }
  176. }
  177. TeachersOrderServices.SubmitTeachersOrder(list, user.UserID, "");
  178. return base.Json("成功");
  179. }
  180. catch (Exception ex)
  181. {
  182. return base.Json("失败,原因:" + ex.Message);
  183. }
  184. }
  185. /// <summary>
  186. /// 删除
  187. /// </summary>
  188. /// <param name="teachersOrderIDs">征订ID</param>
  189. /// <returns></returns>
  190. [HttpPost]
  191. public ActionResult Delete(string teachersOrderIDs)
  192. {
  193. try
  194. {
  195. List<Guid> list = new List<Guid>();
  196. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  197. for (int i = 0; i < teachersOrderIDs.Split(',').Length; i++)
  198. {
  199. string id = teachersOrderIDs.Split(',')[i];
  200. if (!string.IsNullOrEmpty(id))
  201. {
  202. Guid specialtyApplyID = new Guid(id);
  203. list.Add(specialtyApplyID);
  204. }
  205. }
  206. TeachersOrderServices.DeleteTeachersOrder(list);
  207. return base.Json("删除成功");
  208. }
  209. catch (Exception ex)
  210. {
  211. return base.Json("删除失败,原因:" + ex.Message);
  212. }
  213. }
  214. /// <summary>
  215. /// Excel导出
  216. /// </summary>
  217. /// <returns></returns>
  218. [HttpPost]
  219. public ActionResult Excel()
  220. {
  221. //避开全选值
  222. Guid? publishID = null;
  223. Guid? coursematerialID = null;
  224. publishID = Request.Form["PublishDropdown"].ParseStrTo<Guid>();
  225. coursematerialID = Request.Form["CourseDropdown"].ParseStrTo<Guid>();
  226. Guid? schoolYearID = Request.Form["SchoolYearDropdown"].ParseStrTo<Guid>();
  227. Guid? collegeID = Request.Form["CollegeDropdownListBanids"].ParseStrTo<Guid>();
  228. int? approvalStatus = Request.Form["StatusDropdown"].ParseStrTo<int>();
  229. NpoiExcelHelper neh = new NpoiExcelHelper();
  230. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  231. if (Request.Form["ExcelType"] == "1")
  232. {
  233. var dt = TeachersOrderServices.GetTeachersOrderViewList(configuretView, schoolYearID, collegeID, coursematerialID, publishID, approvalStatus).Select(x => new
  234. {
  235. x.SchoolyearName,
  236. x.TeachingMaterialCode,
  237. x.CoursematerialCode,
  238. x.CoursematerialName,
  239. x.CoursematerialLevelName,
  240. x.CoursematerialTypeName,
  241. x.ISBN,
  242. x.TeachingMaterialName,
  243. x.PublishTime,
  244. x.PublishName,
  245. x.Author,
  246. x.OrderQty,
  247. x.OrderUserName,
  248. x.CollegeName,
  249. x.OrderDate,
  250. x.OrderDesc,
  251. x.ApproveStatusName
  252. }).ToTable();
  253. string[] liststring = { "学年学期","教材编号","课程代码","课程名称","课程级别","课程科类","ISBN","教材名称"
  254. ,"版本时间","出版单位","作者","征订数量","征订人",RSL.Get("College"),"征订日期","征订说明","审核状态 "};
  255. neh.Export(dt, liststring, "征订申请信息");
  256. }
  257. else
  258. {
  259. var dt = TeachersOrderServices.GetTeachersOrderViewList(configuretView, schoolYearID, collegeID, coursematerialID, publishID, approvalStatus).Select(x => new
  260. {
  261. x.SchoolyearName,
  262. x.CollegeName,
  263. x.CoursematerialName,
  264. x.TeachingMaterialCode,
  265. x.TeachingMaterialName,
  266. x.Price,
  267. x.ISBN,
  268. x.PublishTime,
  269. x.PublishName,
  270. x.Author,
  271. x.OrderQty,
  272. x.OrderUserName
  273. }).ToTable();
  274. string[] liststring = { "学年学期",RSL.Get("College"),"课程名称","教材编号","教材名称","单价","ISBN","版本时间","出版单位"
  275. ,"作者","征订数量","征订人"};
  276. neh.Export(dt, liststring, "征订申请预订汇总导出");
  277. }
  278. return RedirectToAction("MsgShow", "Common", new
  279. {
  280. msg = "导出成功!",
  281. url = Url.Content("~/TeachersOrder/List").AddMenuParameter()
  282. });
  283. }
  284. /// <summary>
  285. /// 页面数据增加
  286. /// </summary>
  287. /// <returns></returns>
  288. [HttpGet]
  289. public ActionResult Add(Guid? teachersOrderID)
  290. {
  291. TeachersOrderView TeachersOrderView;
  292. if (teachersOrderID != null && teachersOrderID != Guid.Empty)
  293. {
  294. TeachersOrderView = null;
  295. TeachersOrderView = TeachersOrderServices.GetSingleTeachersOrder(teachersOrderID.Value);
  296. }
  297. else
  298. {
  299. TeachersOrderView = new TeachersOrderView()
  300. {
  301. SchoolyearID = schoolYearServices.GetSchoolYearIsCurrent(true).SchoolyearID,//默认当前学年
  302. TeachersOrderID = Guid.Empty
  303. };
  304. }
  305. EMIS.Entities.CF_Schoolyear schoolyear = schoolYearServices.GetSchoolYearIsCurrent(true);
  306. if (schoolyear != null)
  307. ViewData["SchoolyearID"] = schoolyear.SchoolyearID;
  308. return View(TeachersOrderView);
  309. }
  310. /// <summary>
  311. /// 页面数据增加
  312. /// </summary>
  313. /// <param name="TeachersOrderID"></param>
  314. /// <returns></returns>
  315. [HttpPost]
  316. public ActionResult Add(TeachersOrderView teachersOrderView)
  317. {
  318. try
  319. {
  320. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  321. TeachersOrderServices.EditTeachersOrder(teachersOrderView, user.UserID);
  322. return Json(new ReturnMessage()
  323. {
  324. IsSuccess = true,
  325. Message = "保存成功!"
  326. });
  327. }
  328. catch (Exception ex)
  329. {
  330. return Json(new ReturnMessage()
  331. {
  332. IsSuccess = false,
  333. Message = "保存失败,原因:" + ex.Message + "!"
  334. });
  335. }
  336. }
  337. [HttpGet]
  338. public ActionResult AuditStatusView(Guid? teachersOrderID)
  339. {
  340. List<DropdownListItem> list = new List<DropdownListItem>();
  341. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  342. TeachersOrderView teachersOrderView = new TeachersOrderView();
  343. if (teachersOrderID.HasValue)
  344. teachersOrderView = TeachersOrderExamineServices.GetTeachersOrderExamineView(teachersOrderID);
  345. List<ActionView> listAction = TeachersOrderExamineServices.GetAuditingActionView((Guid)teachersOrderID, user.UserID);
  346. foreach (var item in listAction)
  347. {
  348. DropdownListItem dli = new DropdownListItem { Text = item.ActionName, Value = item.ToJson() };
  349. list.Add(dli);
  350. }
  351. ViewData["listAction"] = list;
  352. ViewData["endStatus"] = TeachersOrderServices.GetCorrectEndStatus();
  353. return View(teachersOrderView);
  354. }
  355. [HttpPost]
  356. public ActionResult AuditStatusView(TeachersOrderView teachersOrderView)
  357. {
  358. try
  359. {
  360. List<Guid> list = new List<Guid>();
  361. string action = Request.Form["ddlAction"];
  362. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  363. ActionView actionView = action.JsonToObject<ActionView>();
  364. string comment = Request.Form["txtOpinioncomment"];
  365. list.Add(teachersOrderView.TeachersOrderID);
  366. TeachersOrderExamineServices.ApproveTeachersOrderExamine(list, user.UserID, actionView, comment);
  367. return RedirectToAction("MsgShow", "Common", new
  368. {
  369. msg = "审核成功!",
  370. url = Url.Content("~/TeachersOrderExamine/List").AddMenuParameter()
  371. });
  372. }
  373. catch (Exception ex)
  374. {
  375. return RedirectToAction("MsgShow", "Common", new
  376. {
  377. msg = "审核失败,原因:" + ex.Message,
  378. url = Url.Content("~/TeachersOrderExamine/List").AddMenuParameter()
  379. });
  380. }
  381. }
  382. [HttpGet]
  383. public ActionResult GetTeachingMaterialPoolList()
  384. {
  385. ViewData["SchoolyearID"] = Guid.Empty;
  386. return View();
  387. }
  388. /// <summary>
  389. /// 列表查询
  390. /// </summary>
  391. /// <param name="pararms"></param>
  392. /// <returns></returns>
  393. [HttpPost]
  394. public ActionResult GetTeachingMaterialPoolList(QueryParamsModel pararms)
  395. {
  396. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  397. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  398. //避开全选值
  399. Guid? publishID = null;
  400. Guid? coursematerialID = null;
  401. Guid? teachingMaterialID = null;
  402. bool? isLate = false;
  403. teachingMaterialID = pararms.getExtraGuid("TeachingMaterialDropdown");
  404. publishID = pararms.getExtraGuid("PublishDropdown");
  405. coursematerialID = pararms.getExtraGuid("CourseDropdown");
  406. var schoolyearID = pararms.getExtraGuid("SchoolyearID");
  407. if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  408. return base.Json(TeachersOrderServices.GetTeachersOrderOrTeachingMaterialPoolViewGrid(configuretView, teachingMaterialID, coursematerialID, isLate, user.CollegeID, schoolyearID, (int)pararms.page, (int)pararms.rows));
  409. }
  410. [HttpGet]
  411. public ActionResult DetailList()
  412. {
  413. ViewData["TeachersOrderID"] = Request.Params["TeachersOrderID"];
  414. return View();
  415. }
  416. /// <summary>
  417. /// 列表查询
  418. /// </summary>
  419. /// <param name="pararms"></param>
  420. /// <returns></returns>
  421. [HttpPost]
  422. public ActionResult DetailList(QueryParamsModel pararms)
  423. {
  424. Guid? teachersOrderID = new Guid(Request.Params["teachersOrderID"]);
  425. return base.Json(TeachersOrderServices.GetTeachersOrderDetailViewList(teachersOrderID, (int)pararms.page, (int)pararms.rows));
  426. }
  427. }
  428. }