PlanApplicationApproveController.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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.Exceptions;
  8. using Bowin.Common.Utility;
  9. using Bowin.Common.Data;
  10. using Bowin.Common.JSON;
  11. using EMIS.Web.Controls;
  12. using EMIS.Utility;
  13. using EMIS.ViewModel;
  14. using EMIS.CommonLogic.CultureplanManage.PlanManagement;
  15. using EMIS.ViewModel.CultureplanManage.PlanManagement;
  16. using EMIS.ViewModel.WorkflowManage;
  17. namespace EMIS.Web.Controllers.CultureplanManage.PlanManagement
  18. {
  19. [Authorization]
  20. public class PlanApplicationApproveController : Controller
  21. {
  22. public IPlanApplicationApproveServices PlanApplicationApproveServices { get; set; }
  23. /// <summary>
  24. /// 计划审核页面
  25. /// </summary>
  26. /// <returns></returns>
  27. public ActionResult List()
  28. {
  29. return View();
  30. }
  31. /// <summary>
  32. /// 计划审核页面列表查询
  33. /// </summary>
  34. /// <param name="pararms"></param>
  35. /// <returns></returns>
  36. [HttpPost]
  37. public ActionResult List(QueryParamsModel pararms)
  38. {
  39. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  40. var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown");
  41. var campusID = pararms.getExtraGuid("CampusDropdown");
  42. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  43. var yearID = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear");
  44. var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
  45. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  46. var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  47. var learnSystem = pararms.getExtraString("DictionaryLearnSystem");
  48. var grademajorID = pararms.getExtraGuid("GrademajorComboGrid");
  49. var coursematerialID = pararms.getExtraGuid("CourseComboGrid");
  50. var handleModeID = pararms.getExtraInt("DictionaryHandleMode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryHandleMode");
  51. var approvalStatus = pararms.getExtraInt("DictionaryApprovalStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryApprovalStatus");
  52. return base.Json(PlanApplicationApproveServices.GetPlanApplicationApproveViewGrid(configuretView, schoolyearID, campusID, collegeID,
  53. yearID, standardID, educationID, learningformID, learnSystem, grademajorID, coursematerialID, handleModeID,
  54. approvalStatus, (int)pararms.page, (int)pararms.rows));
  55. }
  56. /// <summary>
  57. /// 编辑
  58. /// </summary>
  59. /// <param name="planApplicationID"></param>
  60. /// <returns></returns>
  61. public ActionResult Edit(Guid? planApplicationID)
  62. {
  63. PlanApplicationView planApplicationView = new PlanApplicationView();
  64. if (planApplicationID.HasValue && planApplicationID != Guid.Empty)
  65. {
  66. planApplicationView = PlanApplicationApproveServices.GetPlanApplicationApproveView(planApplicationID);
  67. }
  68. else
  69. {
  70. planApplicationView.SchoolyearID = BaseExtensions.GetCurrentSchoolYearID();
  71. planApplicationView.CourseStructureID = (int)CF_CourseStructure.ClassroomTeaching;
  72. planApplicationView.CourseCategoryID = (int)CF_CourseCategory.Publiccourse;
  73. planApplicationView.CourseQualityID = (int)CF_CourseQuality.Required;
  74. planApplicationView.Credit = 0;
  75. planApplicationView.TheoryCourse = 0;
  76. planApplicationView.Practicehours = 0;
  77. planApplicationView.Trialhours = 0;
  78. planApplicationView.Totalhours = 0;
  79. planApplicationView.TheoryWeeklyNum = 0;
  80. planApplicationView.PracticeWeeklyNum = 0;
  81. planApplicationView.TrialWeeklyNum = 0;
  82. planApplicationView.SchoolweeksNum = 0;
  83. planApplicationView.WeeklyHours = 0;
  84. planApplicationView.WeeklyNum = 0;
  85. planApplicationView.StartWeeklyNum = 1;
  86. planApplicationView.EndWeeklyNum = 16;
  87. planApplicationView.IsNeedMaterial = true;
  88. planApplicationView.CourseFineID = (int)CF_CourseFine.No;
  89. planApplicationView.TeachinglanguageID = (int)CF_Teachinglanguage.Chinese;
  90. planApplicationView.ExaminationModeID = (int)CF_ExaminationMode.WrittenExam;
  91. planApplicationView.ResultTypeID = (int)CF_ResultType.Percentage;
  92. planApplicationView.HandleModeID = (int)CF_HandleMode.RequiredCourse;
  93. planApplicationView.ResultTypeID = (int)CF_ResultType.Percentage;
  94. }
  95. return View(planApplicationView);
  96. }
  97. /// <summary>
  98. /// 编辑
  99. /// </summary>
  100. /// <param name="planApplicationView"></param>
  101. /// <returns></returns>
  102. [HttpPost]
  103. public ActionResult Edit(PlanApplicationView planApplicationView)
  104. {
  105. try
  106. {
  107. //暂时无效
  108. PlanApplicationApproveServices.PlanApplicationApproveEdit(planApplicationView);
  109. return Json(new ReturnMessage()
  110. {
  111. IsSuccess = true,
  112. Message = "保存成功。"
  113. });
  114. }
  115. catch (Exception ex)
  116. {
  117. return Json(new ReturnMessage()
  118. {
  119. IsSuccess = false,
  120. Message = "保存失败:" + ex.Message
  121. });
  122. }
  123. }
  124. /// <summary>
  125. /// 删除
  126. /// </summary>
  127. /// <param name="planApplicationIDs"></param>
  128. /// <returns></returns>
  129. [HttpPost]
  130. public ActionResult Delete(string planApplicationIDs)
  131. {
  132. try
  133. {
  134. List<Guid?> list = planApplicationIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  135. .Select(x => (Guid?)new Guid(x)).ToList();
  136. PlanApplicationApproveServices.PlanApplicationApproveDelete(list);
  137. return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
  138. }
  139. catch (Exception ex)
  140. {
  141. string mge = ex.Message;
  142. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  143. if (num != null)
  144. {
  145. if (num.Number == 547)
  146. {
  147. mge = "请先删除与其关联的数据,如:专业计划等。";
  148. }
  149. }
  150. return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + mge });
  151. }
  152. }
  153. /// <summary>
  154. /// 审核(单个页面)
  155. /// </summary>
  156. /// <param name="planApplicationID"></param>
  157. /// <returns></returns>
  158. [HttpGet]
  159. public ActionResult Approve(Guid? planApplicationID)
  160. {
  161. //查询对应的计划审核信息
  162. var planApplicationApproveView = PlanApplicationApproveServices.GetPlanApplicationApproveView(planApplicationID);
  163. if (planApplicationApproveView == null)
  164. {
  165. return RedirectToAction("MsgShow", "Common", new
  166. {
  167. WindowID = Request["WindowID"],
  168. msg = "操作失败,原因:数据有误。",
  169. url = Url.Action("List").AddMenuParameter()
  170. });
  171. }
  172. //对已结束的流程状态进行判断(包括正常结束、非正常结束[BP]标识)
  173. var endStatusList = PlanApplicationApproveServices.GetBackpointStatus();
  174. var correctEndStatusID = PlanApplicationApproveServices.GetCorrectEndStatus();
  175. endStatusList.Add(correctEndStatusID);
  176. foreach (var endStatus in endStatusList)
  177. {
  178. if (planApplicationApproveView.RecordStatus == endStatus)
  179. {
  180. return RedirectToAction("MsgShow", "Common", new
  181. {
  182. WindowID = Request["WindowID"],
  183. msg = "无法对已结束的流程进行审核。",
  184. url = Url.Action("List").AddMenuParameter()
  185. });
  186. }
  187. }
  188. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  189. //根据当前环节ID、用户ID查询下一步审批动作信息List(ActionView)
  190. var actionViewList = PlanApplicationApproveServices.GetActionView((Guid)planApplicationID, user.UserID);
  191. if (actionViewList == null || actionViewList.Count() <= 0)
  192. {
  193. return RedirectToAction("MsgShow", "Common", new
  194. {
  195. WindowID = Request["WindowID"],
  196. msg = "对不起,您没权限操作。",
  197. url = Url.Action("List").AddMenuParameter()
  198. });
  199. }
  200. var dropList = actionViewList.Select(x => new DropdownListItem { Text = x.ActionName, Value = x.ToJson() }).ToList();
  201. ViewBag.ListAction = dropList;
  202. return View(planApplicationApproveView);
  203. }
  204. /// <summary>
  205. /// 审核(单个页面)
  206. /// </summary>
  207. /// <param name="planApplicationView"></param>
  208. /// <returns></returns>
  209. [HttpPost]
  210. public ActionResult Approve(PlanApplicationView planApplicationView)
  211. {
  212. try
  213. {
  214. List<Guid?> list = new List<Guid?>();
  215. list.Add(planApplicationView.PlanApplicationID);
  216. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  217. string action = Request.Form["ddlAction"];
  218. if (string.IsNullOrEmpty(action))
  219. {
  220. throw new Exception("请选择处理动作");
  221. }
  222. var actionID = action.JsonToObject<ActionView>().ActionID;
  223. string result = PlanApplicationApproveServices.PlanApplicationApproveConfirm(list, user.UserID, actionID, planApplicationView.Comment);
  224. return Json(new ReturnMessage()
  225. {
  226. IsSuccess = true,
  227. Message = "审核成功" + result + "。"
  228. });
  229. }
  230. catch (Exception ex)
  231. {
  232. return Json(new ReturnMessage()
  233. {
  234. IsSuccess = false,
  235. Message = "审核失败,原因:" + ex.Message
  236. });
  237. }
  238. }
  239. /// <summary>
  240. /// 查询对应的流程环节动作List(ActionView)
  241. /// </summary>
  242. /// <param name="planApplicationID"></param>
  243. /// <returns></returns>
  244. [HttpPost]
  245. public ActionResult ApprovalHandle(Guid? planApplicationID)
  246. {
  247. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  248. //根据当前环节ID、用户ID查询下一步审批动作信息List(ActionView)
  249. var actionViewList = PlanApplicationApproveServices.GetActionView((Guid)planApplicationID, user.UserID);
  250. var dropList = actionViewList.Select(x => new DropdownListItem
  251. {
  252. Text = x.ActionName,
  253. Value = x.ToJson()
  254. }).ToList();
  255. return View(dropList);
  256. }
  257. /// <summary>
  258. /// 审批确定(批量)
  259. /// </summary>
  260. /// <param name="planApplicationIDs"></param>
  261. /// <param name="actionID"></param>
  262. /// <param name="comment"></param>
  263. /// <returns></returns>
  264. [HttpPost]
  265. public ActionResult ApproveConfirm(string planApplicationIDs, Guid actionID, string comment)
  266. {
  267. try
  268. {
  269. List<Guid?> list = planApplicationIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  270. .Select(x => (Guid?)new Guid(x)).ToList();
  271. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  272. string result = PlanApplicationApproveServices.PlanApplicationApproveConfirm(list, user.UserID, actionID, comment);
  273. return Json(new ReturnMessage()
  274. {
  275. IsSuccess = true,
  276. Message = "审核成功" + result + "。"
  277. });
  278. }
  279. catch (Exception ex)
  280. {
  281. return Json(new ReturnMessage()
  282. {
  283. IsSuccess = false,
  284. Message = "审核失败,原因:" + ex.Message
  285. });
  286. }
  287. }
  288. /// <summary>
  289. /// 查询对应的授课方式List
  290. /// </summary>
  291. /// <param name="pararms"></param>
  292. /// <returns></returns>
  293. [HttpPost]
  294. public ActionResult TeachingModeTypeList(QueryParamsModel pararms)
  295. {
  296. List<string> list = new List<string>();
  297. var planApplicationID = Request["planApplicationID"].ParseStrTo<Guid>();
  298. if (planApplicationID.HasValue && planApplicationID != Guid.Empty)
  299. {
  300. list = PlanApplicationApproveServices.GetTeachingModeTypeList(planApplicationID);
  301. }
  302. else
  303. {
  304. list.Add(((int)EMIS.ViewModel.CF_TeachingMode.Theory).ToString());
  305. }
  306. return base.Json(list);
  307. }
  308. /// <summary>
  309. /// 查询对应的授课地点List
  310. /// </summary>
  311. /// <param name="specialtyCourseID"></param>
  312. /// <returns></returns>
  313. [HttpPost]
  314. public ActionResult TeachingPlaceList(QueryParamsModel pararms)
  315. {
  316. List<string> list = new List<string>();
  317. var planApplicationID = Request["planApplicationID"].ParseStrTo<Guid>();
  318. if (planApplicationID.HasValue && planApplicationID != Guid.Empty)
  319. {
  320. list = PlanApplicationApproveServices.GetTeachingPlaceList(planApplicationID);
  321. }
  322. else
  323. {
  324. list.Add(((int)EMIS.ViewModel.EM_TeachingPlace.Multimedia).ToString());
  325. }
  326. return base.Json(list);
  327. }
  328. /// <summary>
  329. /// 导出Excel
  330. /// </summary>
  331. /// <returns></returns>
  332. [HttpPost]
  333. public ActionResult Excel()
  334. {
  335. NpoiExcelHelper neh = new NpoiExcelHelper();
  336. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  337. var schoolyearID = Request.Form["SchoolyearDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
  338. var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  339. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  340. var yearID = Request.Form["DictionarySchoolyear"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolyear"].ParseStrTo<int>();
  341. var standardID = Request.Form["DictionaryStandard"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStandard"].ParseStrTo<int>();
  342. var educationID = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  343. var learningformID = Request.Form["DictionaryLearningform"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo<int>();
  344. var learnSystem = Request.Form["DictionaryLearnSystem"].ToString();
  345. var grademajorID = Request.Form["GrademajorComboGrid"].ParseStrTo<Guid>();
  346. var coursematerialID = Request.Form["CourseComboGrid"].ParseStrTo<Guid>();
  347. var handleModeID = Request.Form["DictionaryHandleMode"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryHandleMode"].ParseStrTo<int>();
  348. var approvalStatus = Request.Form["DictionaryApprovalStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryApprovalStatus"].ParseStrTo<int>();
  349. var dt = PlanApplicationApproveServices.GetPlanApplicationApproveViewList(configuretView, schoolyearID, campusID, collegeID, yearID,
  350. standardID, educationID, learningformID, learnSystem, grademajorID, coursematerialID, handleModeID, approvalStatus)
  351. .Select(x => new
  352. {
  353. x.SchoolyearCode,
  354. x.CollegeCode,
  355. x.CollegeName,
  356. x.GradeID,
  357. x.GrademajorCode,
  358. x.GrademajorName,
  359. x.SchoolyearNumName,
  360. x.SchoolcodeName,
  361. x.StarttermName,
  362. x.CourseCode,
  363. x.CourseName,
  364. x.CourseStructureName,
  365. x.CourseCategoryName,
  366. x.CourseTypeName,
  367. x.CourseQualityName,
  368. Credit = x.Credit.HasValue ? x.Credit.Value.ToString("#.#") : null,
  369. x.TheoryCourse,
  370. x.Practicehours,
  371. x.Trialhours,
  372. x.Totalhours,
  373. x.TheoryWeeklyNum,
  374. x.PracticeWeeklyNum,
  375. x.TrialWeeklyNum,
  376. x.SchoolweeksNum,
  377. x.WeeklyHours,
  378. x.WeeklyNum,
  379. x.StartWeeklyNum,
  380. x.EndWeeklyNum,
  381. x.DepartmentName,
  382. x.IsSpecialtycoreName,
  383. x.IsCooperationName,
  384. x.IsRequiredName,
  385. x.IsElectiveName,
  386. x.IsNetworkCourseName,
  387. x.IsMainCourseName,
  388. x.IsNeedMaterialName,
  389. x.CourseFineName,
  390. x.PracticeTypeName,
  391. x.TeachinglanguageName,
  392. x.ExaminationModeName,
  393. x.ResultTypeName,
  394. x.HandleModeName,
  395. x.TeachingModeIDListName,
  396. x.TeachingPlaceIDListName,
  397. x.CreateTime,
  398. x.ApprovalStatusName,
  399. x.Remark
  400. }).ToTable();
  401. string[] liststring = {
  402. "学年学期", RSL.Get("CollegeCode"), RSL.Get("CollegeName"), "年级", "年级专业编号", "年级专业名称",
  403. "开课学年", "学期", "开课学期", "课程代码", "课程名称", "课程结构", "课程属性", "课程类型",
  404. "课程性质", "课程学分", "理论学时", "实践学时", "实验学时", "总学时", "理论周次", "实践周次",
  405. "实验周次", "总周次", "周学时", "每周次数", "开始周次", "结束周次", "开课教研室", "是否专业核心",
  406. "是否合作开发", RSL.Get("IsRequired"), "是否网上选修", "是否网络课程", "是否学位课程", "是否需要教材",
  407. "精品课程", "实践类型", "授课语言", "考试方式", "成绩类型", "处理方式", "授课方式", "授课地点",
  408. "申请时间", "审核状态", "备注"
  409. };
  410. neh.Export(dt, liststring, "计划审核信息" + DateTime.Now.ToString("yyyyMMdd"));
  411. return Json(new ReturnMessage()
  412. {
  413. IsSuccess = true,
  414. Message = "导出成功。"
  415. });
  416. }
  417. }
  418. }