You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

382 lines
14 KiB

  1. using Learun.Util;
  2. using System.Data;
  3. using Learun.Application.TwoDevelopment.EducationalAdministration;
  4. using System.Web.Mvc;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
  8. {
  9. /// <summary>
  10. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  11. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  12. /// 创 建:超级管理员
  13. /// 日 期:2023-05-29 14:28
  14. /// 描 述:线上课程
  15. /// </summary>
  16. public class LessonInfoOfElectiveOnlineController : MvcControllerBase
  17. {
  18. private LessonInfoOfElectiveOnlineIBLL lessonInfoOfElectiveOnlineIBLL = new LessonInfoOfElectiveOnlineBLL();
  19. private StuInfoBasicIBLL stuInfoBasicIBLL = new StuInfoBasicBLL();
  20. CdMajorIBLL CdMajorIBLL = new CdMajorBLL();
  21. private StuSelectLessonListOfElectiveOnlineIBLL stuSelectLessonListOfElectiveOnlineIBLL = new StuSelectLessonListOfElectiveOnlineBLL();
  22. #region 视图功能
  23. /// <summary>
  24. /// 主页面
  25. /// <summary>
  26. /// <returns></returns>
  27. [HttpGet]
  28. public ActionResult Index()
  29. {
  30. return View();
  31. }
  32. /// <summary>
  33. /// 表单页
  34. /// <summary>
  35. /// <returns></returns>
  36. [HttpGet]
  37. public ActionResult Form()
  38. {
  39. return View();
  40. }
  41. /// <summary>
  42. /// 主页面-设置
  43. /// <summary>
  44. /// <returns></returns>
  45. [HttpGet]
  46. public ActionResult SetIndex()
  47. {
  48. return View();
  49. }
  50. /// <summary>
  51. /// 表单页-人数
  52. /// <summary>
  53. /// <returns></returns>
  54. [HttpGet]
  55. public ActionResult FormNum()
  56. {
  57. return View();
  58. }
  59. /// <summary>
  60. /// 学子在线-线上课程选课
  61. /// <summary>
  62. /// <returns></returns>
  63. [HttpGet]
  64. public ActionResult StudentIndex()
  65. {
  66. var loginuser = LoginUserInfo.Get();
  67. var studentinfo = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(loginuser.account);
  68. if (studentinfo != null)
  69. {
  70. ViewBag.StuMajorNo = CdMajorIBLL.GetCdMajorEntityByMajorNo(studentinfo.MajorNo)?.ID;
  71. ViewBag.StuGrade = studentinfo.Grade;
  72. }
  73. ViewBag.WebApiUrl = Config.GetValue("WebApi");
  74. return View();
  75. }
  76. #endregion
  77. #region 获取数据
  78. /// <summary>
  79. /// 获取页面显示列表数据
  80. /// </summary>
  81. /// <param name="pagination">分页参数</param>
  82. /// <param name="queryJson">查询参数</param>
  83. /// <returns></returns>
  84. [HttpGet]
  85. [AjaxOnly]
  86. public ActionResult GetPageList(string pagination, string queryJson)
  87. {
  88. Pagination paginationobj = pagination.ToObject<Pagination>();
  89. var data = lessonInfoOfElectiveOnlineIBLL.GetPageList(paginationobj, queryJson);
  90. var jsonData = new
  91. {
  92. rows = data,
  93. total = paginationobj.total,
  94. page = paginationobj.page,
  95. records = paginationobj.records
  96. };
  97. return Success(jsonData);
  98. }
  99. /// <summary>
  100. /// 获取表单数据
  101. /// </summary>
  102. /// <param name="keyValue">主键</param>
  103. /// <returns></returns>
  104. [HttpGet]
  105. [AjaxOnly]
  106. public ActionResult GetFormData(string keyValue)
  107. {
  108. var LessonInfoOfElectiveOnlineData = lessonInfoOfElectiveOnlineIBLL.GetLessonInfoOfElectiveOnlineEntity(keyValue);
  109. var jsonData = new
  110. {
  111. LessonInfoOfElectiveOnline = LessonInfoOfElectiveOnlineData,
  112. };
  113. return Success(jsonData);
  114. }
  115. /// <summary>
  116. /// 获取页面显示列表数据【学子在线-线上课程选课】
  117. /// <summary>
  118. /// <param name="queryJson">查询参数</param>
  119. /// <returns></returns>
  120. [HttpGet]
  121. [AjaxOnly]
  122. public ActionResult GetPageListOfStudent(string pagination, string queryJson)
  123. {
  124. Pagination paginationobj = pagination.ToObject<Pagination>();
  125. var data = lessonInfoOfElectiveOnlineIBLL.GetPageListOfStudent(paginationobj, queryJson).OrderByDescending(x => x.AcademicYearNo).ThenByDescending(x => x.Semester).ThenBy(x => x.LessonNo).ThenBy(x => x.EmpNo);
  126. var jsonData = new
  127. {
  128. rows = data,
  129. total = paginationobj.total,
  130. page = paginationobj.page,
  131. records = paginationobj.records
  132. };
  133. return Success(jsonData);
  134. }
  135. #endregion
  136. #region 提交数据
  137. /// <summary>
  138. /// 删除实体数据
  139. /// </summary>
  140. /// <param name="keyValue">主键</param>
  141. /// <returns></returns>
  142. [HttpPost]
  143. [AjaxOnly]
  144. public ActionResult DeleteForm(string keyValue)
  145. {
  146. lessonInfoOfElectiveOnlineIBLL.DeleteEntity(keyValue);
  147. return Success("删除成功!");
  148. }
  149. /// <summary>
  150. /// 保存实体数据(新增、修改)
  151. /// </summary>
  152. /// <param name="keyValue">主键</param>
  153. /// <param name="strEntity">实体</param>
  154. /// <returns></returns>
  155. [HttpPost]
  156. [ValidateAntiForgeryToken]
  157. [AjaxOnly]
  158. public ActionResult SaveForm(string keyValue, string strEntity)
  159. {
  160. LessonInfoOfElectiveOnlineEntity entity = strEntity.ToObject<LessonInfoOfElectiveOnlineEntity>();
  161. var model = lessonInfoOfElectiveOnlineIBLL.GetLessonInfoOfElectiveOnlineEntityByLessonNo(entity.LessonNo);
  162. if (string.IsNullOrEmpty(keyValue))
  163. {
  164. if (model != null)
  165. {
  166. return Fail("课程编号已存在!");
  167. }
  168. }
  169. else
  170. {
  171. if (model != null && model.Id != keyValue)
  172. {
  173. return Fail("课程编号已存在!");
  174. }
  175. }
  176. lessonInfoOfElectiveOnlineIBLL.SaveEntity(keyValue, entity);
  177. return Success("保存成功!");
  178. }
  179. #endregion
  180. #region 扩展数据
  181. /// <summary>
  182. /// 启用/停用实体数据
  183. /// </summary>
  184. /// <param name="keyValue">主键</param>
  185. /// <returns></returns>
  186. [HttpPost]
  187. [AjaxOnly]
  188. public ActionResult DoLock(string keyValue, string status)
  189. {
  190. lessonInfoOfElectiveOnlineIBLL.DoLock(keyValue, status);
  191. return Success("操作成功!");
  192. }
  193. /// <summary>
  194. /// 设置可选/取消可选
  195. /// </summary>
  196. /// <param name="keyValue">主键</param>
  197. /// <returns></returns>
  198. [HttpPost]
  199. [AjaxOnly]
  200. public ActionResult SetUpIsAllowSelect(string keyValue, int IsAllowSelect)
  201. {
  202. lessonInfoOfElectiveOnlineIBLL.SetUpIsAllowSelect(keyValue, IsAllowSelect);
  203. return Success("操作成功!");
  204. }
  205. /// <summary>
  206. /// 批量设置管理专业
  207. /// <summary>
  208. /// <returns></returns>
  209. [HttpPost]
  210. public ActionResult SaveStuNumMax(string keyValue, int StuNumMax)
  211. {
  212. lessonInfoOfElectiveOnlineIBLL.SaveStuNumMax(keyValue, StuNumMax);
  213. return Success("保存成功!");
  214. }
  215. /// <summary>
  216. /// 判断选课是否开始
  217. /// </summary>
  218. /// <returns></returns>
  219. public ActionResult IsSelectElectiveLesson()
  220. {
  221. var entity = lessonInfoOfElectiveOnlineIBLL.GetEADateArrangeEntityAboutElective();
  222. if (entity != null)
  223. {
  224. return Fail("线上选课已经开始!");
  225. }
  226. return Success("线上选课还未开始!");
  227. }
  228. /// <summary>
  229. /// 判断队列结果
  230. /// </summary>
  231. /// <returns></returns>
  232. public ActionResult GetApplyResult(string keyvalue)
  233. {
  234. var loginUserInfo = LoginUserInfo.Get();
  235. //学员信息
  236. var stuInfoBasicEntity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(loginUserInfo.enCode);
  237. if (stuInfoBasicEntity == null)
  238. {
  239. return Success("当前学员不存在!");
  240. }
  241. //课程信息
  242. var olpeEntity = lessonInfoOfElectiveOnlineIBLL.GetLessonInfoOfElectiveOnlineEntity(keyvalue);
  243. if (olpeEntity == null)
  244. {
  245. return Success("当前课程不存在!");
  246. }
  247. //当前学员本学期是否有报名课程:每学期一门
  248. //var sslleEntity = stuSelectLessonListOfElectiveOnlineIBLL.GetStuSelectLessonListOfElectiveOnlineEntityByStuNo(loginUserInfo.enCode, "");
  249. //if (sslleEntity != null)
  250. //{
  251. // if (sslleEntity.OLPEId != keyvalue && sslleEntity.Status != 3)
  252. // {
  253. // return Success("已存在报名课程,每学期只能选择一门选修课!如需报名其他课程请先取消。");
  254. // }
  255. // if (sslleEntity.Status == 1)
  256. // {
  257. // return Success("报名审核中,请耐心等待!");
  258. // }
  259. // else if (sslleEntity.Status == 2)
  260. // {
  261. // return Success("已存在报名成功的课程,只能选择一门选修课!");
  262. // }
  263. //}
  264. //else
  265. //{
  266. // //所选课程的报名人数是否已满
  267. // var aa = stuSelectLessonListOfElectiveOnlineIBLL.GetStuSelectLessonListOfElectiveOnlineListByOLPEId(keyvalue);
  268. // var aaa = aa.Count(x => x.Status == 1 || x.Status == 2);
  269. // if (aaa >= olpeEntity.StuNumMax)
  270. // {
  271. // return Success("当前课程报名人数已满,请选择其他课程!");
  272. // }
  273. //}
  274. //每学期两门(几门根据系统配置文件值确定)
  275. var sslleEntity = stuSelectLessonListOfElectiveOnlineIBLL.GetStuSelectLessonListOfElectiveOnlineEntityByStuNo(loginUserInfo.enCode, keyvalue);
  276. if (sslleEntity != null)
  277. {
  278. if (sslleEntity.Status == 1)
  279. {
  280. return Success("当前课程报名审核中,请耐心等待!");
  281. }
  282. else if (sslleEntity.Status == 2)
  283. {
  284. return Success("当前课程已报名成功!");
  285. }
  286. }
  287. else
  288. {
  289. //所选课程的报名人数是否已满
  290. var aa = stuSelectLessonListOfElectiveOnlineIBLL.GetStuSelectLessonListOfElectiveOnlineListByOLPEId(keyvalue);
  291. var aaa = aa.Count(x => x.Status == 1 || x.Status == 2);
  292. if (aaa >= olpeEntity.StuNumMax)
  293. {
  294. return Success("当前课程报名人数已满,请选择其他课程!");
  295. }
  296. //每学期最多两门
  297. var sslleList = stuSelectLessonListOfElectiveOnlineIBLL.GetStuSelectLessonListOfElectiveOnlineListByStuNo(loginUserInfo.enCode);
  298. var sslleListOfNow = sslleList.Where(x => x.AcademicYearNo == olpeEntity.AcademicYearNo && x.Semester == olpeEntity.Semester);
  299. var sslleListOfNow1 = sslleListOfNow.Where(x => x.Status == 1 || x.Status == 2);
  300. //if (sslleListOfNow1.Count() >= 2)
  301. if (sslleListOfNow1.Count() >= Config.GetValue("OnlineElectiveLessonApplyMax").ToInt())
  302. {
  303. return Success("每学期最多选择" + Config.GetValue("OnlineElectiveLessonApplyMax").ToInt() + "门线上选修课!");
  304. }
  305. //相同时间不能报名
  306. if (!string.IsNullOrEmpty(olpeEntity.LessonSection) && sslleListOfNow1.Where(x => x.LessonSection == olpeEntity.LessonSection).Any())
  307. {
  308. //相同时间不能报名
  309. return Success("本学期此时间段已有报名的选修课!");
  310. }
  311. }
  312. return Fail("正在提交,请等待!");
  313. }
  314. /// <summary>
  315. /// 取消报名
  316. /// </summary>
  317. /// <param name="keyvalue"></param>
  318. /// <returns></returns>
  319. public ActionResult CancelApply(string keyvalue)
  320. {
  321. var loginUserInfo = LoginUserInfo.Get();
  322. //学员信息
  323. var stuInfoBasicEntity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(loginUserInfo.enCode);
  324. if (stuInfoBasicEntity == null)
  325. {
  326. return Fail("当前学员不存在!");
  327. }
  328. //课程信息
  329. var olpeEntity = lessonInfoOfElectiveOnlineIBLL.GetLessonInfoOfElectiveOnlineEntity(keyvalue);
  330. if (olpeEntity == null)
  331. {
  332. return Fail("当前课程不存在!");
  333. }
  334. //当前学员是否已经报名该课程
  335. var sslleEntity = stuSelectLessonListOfElectiveOnlineIBLL.GetStuSelectLessonListOfElectiveOnlineEntityByStuNo(loginUserInfo.enCode, keyvalue);
  336. if (sslleEntity != null)
  337. {
  338. if (sslleEntity.Status != 2)
  339. {
  340. stuSelectLessonListOfElectiveOnlineIBLL.DeleteEntity(sslleEntity.Id);
  341. return Success("取消成功");
  342. }
  343. else
  344. {
  345. return Fail("取消失败,当前课程已报名成功!");
  346. }
  347. }
  348. else
  349. {
  350. return Fail("当前课程未报名,无需取消!");
  351. }
  352. }
  353. #endregion
  354. }
  355. }