Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

487 Zeilen
21 KiB

  1. using System;
  2. using Nancy;
  3. using Learun.Util;
  4. using System.Collections.Generic;
  5. using Learun.Application.TwoDevelopment.EducationalAdministration;
  6. using System.Linq;
  7. namespace Learun.Application.WebApi
  8. {
  9. /// <summary>
  10. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  11. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  12. /// 创 建:超级管理员
  13. /// 日 期:2019-07-01 17:06
  14. /// 描 述:邮件查看
  15. /// </summary>
  16. public class OpenLessonPlanOfElectiveStudentApi : BaseNoAuthentication
  17. {
  18. private OpenLessonPlanOfElectiveIBLL openLessonPlanOfElectiveIbll = new OpenLessonPlanOfElectiveBLL();
  19. private StuSelectLessonListOfElectiveIBLL stuSelectLessonListOfElectiveIBLL = new StuSelectLessonListOfElectiveBLL();
  20. private StuSelectLessonListOfElectivePreIBLL stuSelectLessonListOfElectivePreIBLL = new StuSelectLessonListOfElectivePreBLL();
  21. private StuInfoBasicIBLL stuInfoBasicIBLL = new StuInfoBasicBLL();
  22. LessonInfoIBLL lessonInfoIbll = new LessonInfoBLL();
  23. EmpInfoIBLL empInfoIbll = new EmpInfoBLL();
  24. private OLPElectiveStuSelectCountIBLL oLPElectiveStuSelectCountIBLL = new OLPElectiveStuSelectCountBLL();
  25. private LessonInfoIBLL lessonInfoIBLL = new LessonInfoBLL();
  26. /// <summary>
  27. /// 注册接口
  28. /// <summary>
  29. public OpenLessonPlanOfElectiveStudentApi()
  30. : base("/Learun/OpenLessonPlanOfElectiveStudent")
  31. {
  32. Get["/pagelist"] = GetPageList;
  33. Get["/studentpagelist"] = StudentGetPageList;
  34. Get["/form"] = GetForm;
  35. Post["/Cancel"] = Cancel;
  36. Post["/SignIn"] = SignIn;
  37. Post["/SignInByMobile"] = SignInByMobile;
  38. Post["/CancelPre"] = CancelPre;
  39. Post["/SignInPre"] = SignInPre;
  40. Post["/GetApplyResult"] = GetApplyResult;
  41. }
  42. private Response GetApplyResult(dynamic _)
  43. {
  44. dynamic parameter = this.GetReqData<dynamic>();
  45. string keyValue = parameter.keyValue;
  46. string account = parameter.StuNo;
  47. //学员信息
  48. var stuInfoBasicEntity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(account);
  49. if (stuInfoBasicEntity == null)
  50. {
  51. return Fail("当前学员不存在!");
  52. }
  53. //课程信息
  54. var olpeEntity = openLessonPlanOfElectiveIbll.GetOpenLessonPlanOfElectiveEntity(keyValue);
  55. if (olpeEntity == null)
  56. {
  57. return Fail("当前课程不存在!");
  58. }
  59. //当前学员本学期是否有报名课程:每学期一门
  60. //var sslleEntity = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveEntityByStuNo(account, "");
  61. //if (sslleEntity != null)
  62. //{
  63. // if (sslleEntity.OLPEId != keyValue && sslleEntity.Status != 3)
  64. // {
  65. // return Success("已存在报名课程,每学期只能选择一门选修课!如需报名其他课程请先取消。");
  66. // }
  67. // if (sslleEntity.Status == 1)
  68. // {
  69. // return Success("报名审核中,请耐心等待!");
  70. // }
  71. // else if (sslleEntity.Status == 2)
  72. // {
  73. // return Success("已存在报名成功的课程,只能选择一门选修课!");
  74. // }
  75. //}
  76. //else
  77. //{
  78. // //所选课程的报名人数是否已满
  79. // var aa = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveListByOLPEId(keyValue);
  80. // var aaa = aa.Count(x => x.Status == 1 || x.Status == 2);
  81. // if (aaa >= olpeEntity.StuNumMax)
  82. // {
  83. // return Success("当前课程报名人数已满,请选择其他课程!");
  84. // }
  85. //}
  86. //每学期两门
  87. var sslleEntity = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveEntityByStuNo(account, keyValue);
  88. if (sslleEntity != null)
  89. {
  90. if (sslleEntity.Status == 1)
  91. {
  92. return Fail("当前课程报名审核中,请耐心等待!");
  93. }
  94. else if (sslleEntity.Status == 2)
  95. {
  96. return Fail("当前课程已报名成功!");
  97. }
  98. }
  99. else
  100. {
  101. //所选课程的报名人数是否已满
  102. var aa = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveListByOLPEId(keyValue);
  103. var aaa = aa.Count(x => x.Status == 1 || x.Status == 2);
  104. if (aaa >= olpeEntity.StuNumMax)
  105. {
  106. return Fail("当前课程报名人数已满,请选择其他课程!");
  107. }
  108. //每学期最多两门
  109. var sslleList = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveListByStuNo(account);
  110. var sslleListOfNow = sslleList.Where(x => x.AcademicYearNo == olpeEntity.AcademicYearNo && x.Semester == olpeEntity.Semester);
  111. var sslleListOfNow1 = sslleListOfNow.Where(x => x.Status == 1 || x.Status == 2);
  112. if (sslleListOfNow1.Count() >= Config.GetValue("ElectiveLessonApplyMax").ToInt())
  113. {
  114. return Fail("每学期最多选择" + Config.GetValue("ElectiveLessonApplyMax").ToInt() + "门选修课!");
  115. }
  116. //相同时间不能报名
  117. if (sslleListOfNow1.Where(x => x.LessonSection == olpeEntity.LessonSection).Any())
  118. {
  119. //相同时间不能报名
  120. return Fail("本学期此时间段已有报名的选修课!");
  121. }
  122. //专业选修课根据学生选课次数表判断选课上限
  123. var lesson = lessonInfoIBLL.GetLessonInfoAndTypeByLessonNo(olpeEntity.LessonNo);
  124. if (lesson != null && lesson.LessonTypeCode.Contains("Professional"))
  125. {
  126. var oLPElectiveStuSelectCount = oLPElectiveStuSelectCountIBLL.GetOLPElectiveStuSelectCountEntity(olpeEntity.AcademicYearNo, olpeEntity.Semester, stuInfoBasicEntity.DeptNo);
  127. if (oLPElectiveStuSelectCount != null && sslleListOfNow1.Count() > oLPElectiveStuSelectCount.SelectMaxCount)
  128. {
  129. return Fail("本系部最多选择" + oLPElectiveStuSelectCount.SelectMaxCount + "门专业选修课!");
  130. }
  131. }
  132. }
  133. return Fail("正在提交,请等待!");
  134. }
  135. #region 获取数据
  136. /// <summary>
  137. /// 获取页面显示列表分页数据
  138. /// <summary>
  139. /// <param name="_"></param>
  140. /// <returns></returns>
  141. public Response GetPageList(dynamic _)
  142. {
  143. ReqPageParam parameter = this.GetReqData<ReqPageParam>();
  144. var data = openLessonPlanOfElectiveIbll.GetPageListOfStudent(parameter.pagination, parameter.queryJson).OrderByDescending(x => x.AcademicYearNo).ThenByDescending(x => x.Semester).ThenBy(x => x.LessonNo).ThenBy(x => x.EmpNo);
  145. var jsonData = new
  146. {
  147. rows = data,
  148. total = parameter.pagination.total,
  149. page = parameter.pagination.page,
  150. records = parameter.pagination.records
  151. };
  152. return Success(jsonData);
  153. }
  154. public Response StudentGetPageList(dynamic _)
  155. {
  156. ReqPageParam parameter = this.GetReqData<ReqPageParam>();
  157. var data = stuSelectLessonListOfElectiveIBLL.GetPageList(parameter.pagination, parameter.queryJson).OrderByDescending(x => x.AcademicYearNo).ThenByDescending(x => x.Semester).ThenBy(x => x.LessonNo).ThenBy(x => x.EmpNo);
  158. var jsonData = new
  159. {
  160. rows = data,
  161. total = parameter.pagination.total,
  162. page = parameter.pagination.page,
  163. records = parameter.pagination.records
  164. };
  165. return Success(jsonData);
  166. }
  167. /// <summary>
  168. /// 获取表单数据
  169. /// <summary>
  170. /// <param name="_"></param>
  171. /// <returns></returns>
  172. public Response GetForm(dynamic _)
  173. {
  174. string keyValue = this.GetReqData();
  175. var JournalReceiveData = openLessonPlanOfElectiveIbll.GetOpenLessonPlanOfElectiveEntity(keyValue);
  176. if (lessonInfoIbll.GetLessonInfoEntityByLessonNo(JournalReceiveData.LessonNo) != null)
  177. {
  178. if (!string.IsNullOrEmpty(lessonInfoIbll.GetLessonInfoEntityByLessonNo(JournalReceiveData.LessonNo).Introduction))
  179. JournalReceiveData.Introduction = WebHelper.NoHtml(WebHelper.HtmlDecode(lessonInfoIbll.GetLessonInfoEntityByLessonNo(JournalReceiveData.LessonNo).Introduction)) ?? "";
  180. }
  181. if (empInfoIbll.GetEmpInfoEntityByEmpNo(JournalReceiveData.EmpNo) != null)
  182. {
  183. if (!string.IsNullOrEmpty(empInfoIbll.GetEmpInfoEntityByEmpNo(JournalReceiveData.EmpNo).resume))
  184. JournalReceiveData.resume = WebHelper.NoHtml(WebHelper.HtmlDecode(empInfoIbll.GetEmpInfoEntityByEmpNo(JournalReceiveData.EmpNo).resume)) ?? "";
  185. }
  186. var jsonData = new
  187. {
  188. JournalReceive = JournalReceiveData,
  189. };
  190. return Success(jsonData);
  191. }
  192. #endregion
  193. #region 提交数据
  194. /// <summary>
  195. /// 删除实体数据
  196. /// <param name="_"></param>
  197. /// <summary>
  198. /// <returns></returns>
  199. public Response Cancel(dynamic _)
  200. {
  201. dynamic parameter = this.GetReqData<dynamic>();
  202. string keyValue = parameter.keyValue;
  203. string account = parameter.StuNo;
  204. //学员信息
  205. var stuInfoBasicEntity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(account);
  206. if (stuInfoBasicEntity == null)
  207. {
  208. return Fail("当前学员不存在!");
  209. }
  210. //课程信息
  211. var olpeEntity = openLessonPlanOfElectiveIbll.GetOpenLessonPlanOfElectiveEntity(keyValue);
  212. if (olpeEntity == null)
  213. {
  214. return Fail("当前课程不存在!");
  215. }
  216. //当前学员是否已经报名该课程
  217. var sslleEntity = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveEntityByStuNo(account, keyValue);
  218. if (sslleEntity != null)
  219. {
  220. if (sslleEntity.Status != 2)
  221. {
  222. stuSelectLessonListOfElectiveIBLL.DeleteEntity(sslleEntity.Id);
  223. return Fail("取消成功");
  224. }
  225. else
  226. {
  227. return Fail("取消失败,当前课程已报名成功!");
  228. }
  229. }
  230. else
  231. {
  232. return Fail("当前课程未报名,无需取消!");
  233. }
  234. }
  235. /// <summary>
  236. /// 报名
  237. /// </summary>
  238. /// <param name="_"></param>
  239. /// <returns></returns>
  240. public Response SignIn(dynamic _)
  241. {
  242. //dynamic parameter = this.GetReqData<dynamic>();
  243. //string keyValue = parameter.keyValue;
  244. //string account = parameter.StuNo;
  245. var parameter = this.GetReq<SignModel>();
  246. string keyValue = parameter.keyValue;
  247. string account = parameter.StuNo;
  248. SignUpHelper.Instance.Start();
  249. //进队列
  250. SignUpHelper.AddQueue(account, keyValue);
  251. return Success("操作成功");
  252. }
  253. public Response SignInByMobile(dynamic _)
  254. {
  255. dynamic parameter = this.GetReqData<dynamic>();
  256. string keyValue = parameter.keyValue;
  257. string account = parameter.StuNo;
  258. SignUpHelper.Instance.Start();
  259. //进队列
  260. SignUpHelper.AddQueue(account, keyValue);
  261. return Success("操作成功");
  262. }
  263. /// <summary>
  264. /// 删除实体数据 (预)
  265. /// <param name="_"></param>
  266. /// <summary>
  267. /// <returns></returns>
  268. public Response CancelPre(dynamic _)
  269. {
  270. dynamic parameter = this.GetReqData<dynamic>();
  271. string keyValue = parameter.keyValue;
  272. string account = parameter.StuNo;
  273. //学员信息
  274. var stuInfoBasicEntity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(account);
  275. if (stuInfoBasicEntity == null)
  276. {
  277. return Fail("当前学员不存在!");
  278. }
  279. //课程信息
  280. var olpeEntity = openLessonPlanOfElectiveIbll.GetOpenLessonPlanOfElectiveEntity(keyValue);
  281. if (olpeEntity == null)
  282. {
  283. return Fail("当前课程不存在!");
  284. }
  285. //当前学员是否已经报名该课程
  286. var sslleEntity = stuSelectLessonListOfElectivePreIBLL.GetStuSelectLessonListOfElectivePreEntityByStuNo(account, keyValue);
  287. if (sslleEntity != null)
  288. {
  289. if (sslleEntity.Status != 2)
  290. {
  291. stuSelectLessonListOfElectivePreIBLL.DeleteEntity(sslleEntity.Id);
  292. return Success("取消成功");
  293. }
  294. else
  295. {
  296. return Fail("取消失败,当前课程已报名成功!");
  297. }
  298. }
  299. else
  300. {
  301. return Fail("当前课程未报名,无需取消!");
  302. }
  303. }
  304. /// <summary>
  305. /// 报名(预)
  306. /// </summary>
  307. /// <param name="_"></param>
  308. /// <returns></returns>
  309. public Response SignInPre(dynamic _)
  310. {
  311. dynamic parameter = this.GetReqData<dynamic>();
  312. string keyValue = parameter.keyValue;
  313. string account = parameter.StuNo;
  314. //学员信息
  315. var stuInfoBasicEntity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(account);
  316. if (stuInfoBasicEntity == null)
  317. {
  318. return Fail("当前学员不存在!");
  319. }
  320. //课程信息
  321. var olpeEntity = openLessonPlanOfElectiveIbll.GetOpenLessonPlanOfElectiveEntity(keyValue);
  322. if (olpeEntity == null)
  323. {
  324. return Fail("当前课程不存在!");
  325. }
  326. //所选课程的报名人数是否已满
  327. var aa = stuSelectLessonListOfElectivePreIBLL.GetStuSelectLessonListOfElectivePreListByOLPEId(olpeEntity.Id);
  328. var aaa = aa.Where(x => x.Status == 2).Count();
  329. if (aaa >= olpeEntity.StuNumMax)
  330. {
  331. return Fail("当前课程报名人数已满,请选择其他课程!");
  332. }
  333. //当前学员本学期是否有报名课程:每学期一门
  334. //var sslleEntity = stuSelectLessonListOfElectivePreIBLL.GetStuSelectLessonListOfElectivePreEntityByStuNo(account, "");
  335. //if (sslleEntity != null)
  336. //{
  337. // if (sslleEntity.OLPEId != keyValue && sslleEntity.Status != 3)
  338. // {
  339. // return Fail("已存在报名课程,每学期只能选择一门选修课!如需报名其他课程请先取消。");
  340. // }
  341. // if (sslleEntity.Status == 1)
  342. // {
  343. // return Fail("报名审核中,请耐心等待!");
  344. // }
  345. // else if (sslleEntity.Status == 2)
  346. // {
  347. // return Fail("已存在报名成功的课程,只能选择一门选修课!");
  348. // }
  349. // else if (sslleEntity.Status == 3)//移除报名失败的数据
  350. // {
  351. // stuSelectLessonListOfElectivePreIBLL.DeleteEntity(sslleEntity.Id);
  352. // }
  353. //}
  354. //每学期两门
  355. var sslleList = stuSelectLessonListOfElectivePreIBLL.GetStuSelectLessonListOfElectivePreListByStuNo(account);
  356. var sslleListOfNow = sslleList.Where(x => x.AcademicYearNo == olpeEntity.AcademicYearNo && x.Semester == olpeEntity.Semester);
  357. var sslleListOfNow1 = sslleListOfNow.Where(x => x.Status == 1 || x.Status == 2);
  358. var sslleListOfNow2 = sslleListOfNow.Where(x => x.Status == 3);
  359. if (sslleListOfNow1.Count() >= Config.GetValue("ElectiveLessonApplyMax").ToInt())
  360. {
  361. return Fail("每学期最多选择" + Config.GetValue("ElectiveLessonApplyMax").ToInt() + "门选修课!");
  362. }
  363. else
  364. {
  365. var m = sslleListOfNow1.FirstOrDefault(x => x.OLPEId == olpeEntity.Id);
  366. if (m != null)
  367. {
  368. if (m.Status == 1)
  369. {
  370. return Fail("当前课程报名审核中,请耐心等待!");
  371. }
  372. else if (m.Status == 2)
  373. {
  374. return Fail("当前课程已报名成功!");
  375. }
  376. }
  377. }
  378. //专业选修课根据学生选课次数表判断选课上限
  379. var lesson = lessonInfoIBLL.GetLessonInfoAndTypeByLessonNo(olpeEntity.LessonNo);
  380. if (lesson != null && lesson.LessonTypeCode.Contains("Professional"))
  381. {
  382. var oLPElectiveStuSelectCount = oLPElectiveStuSelectCountIBLL.GetOLPElectiveStuSelectCountEntity(olpeEntity.AcademicYearNo, olpeEntity.Semester, stuInfoBasicEntity.DeptNo);
  383. if (oLPElectiveStuSelectCount != null && sslleListOfNow1.Count() > oLPElectiveStuSelectCount.SelectMaxCount)
  384. {
  385. return Fail("本系部最多选择" + oLPElectiveStuSelectCount.SelectMaxCount + "门专业选修课!");
  386. }
  387. }
  388. if (sslleListOfNow2.Count() > 0)
  389. {
  390. foreach (var item in sslleListOfNow2)
  391. {
  392. stuSelectLessonListOfElectivePreIBLL.DeleteEntity(item.Id);
  393. }
  394. }
  395. //相同时间不能报名
  396. if (sslleListOfNow1.Select(x => x.LessonSection == olpeEntity.LessonSection).Any())
  397. {
  398. //相同时间不能报名
  399. return Success("本学期此时间段已有报名的选修课!");
  400. }
  401. //新增报名数据
  402. var model = new StuSelectLessonListOfElectivePreEntity()
  403. {
  404. OLPEId = olpeEntity.Id,
  405. NoticeBookNo = stuInfoBasicEntity.NoticeNo,
  406. StuNo = stuInfoBasicEntity.StuNo,
  407. DeptNo = stuInfoBasicEntity.DeptNo,
  408. MajorNo = stuInfoBasicEntity.MajorNo,
  409. ClassNo = stuInfoBasicEntity.ClassNo,
  410. MajorDetailNo = stuInfoBasicEntity.MajorDetailNo,
  411. MajorDetailName = stuInfoBasicEntity.MajorDetailName,
  412. StuName = stuInfoBasicEntity.StuName,
  413. GenderNo = stuInfoBasicEntity.GenderNo,
  414. Grade = stuInfoBasicEntity.Grade,
  415. AcademicYearNo = olpeEntity.AcademicYearNo,
  416. Semester = olpeEntity.Semester,
  417. LessonNo = olpeEntity.LessonNo,
  418. LessonName = olpeEntity.LessonName,
  419. LessonSortNo = olpeEntity.LessonSortNo,
  420. LessonSection = olpeEntity.LessonSection,
  421. LessonTime = olpeEntity.LessonTime,
  422. EmpNo = olpeEntity.EmpNo,
  423. EmpName = olpeEntity.EmpName,
  424. ClassRoomNo = olpeEntity.ClassRoomNo,
  425. ClassRoomName = olpeEntity.ClassRoomName,
  426. StudyScore = olpeEntity.StudyScore,
  427. StartWeek = olpeEntity.StartWeek,
  428. EndWeek = olpeEntity.EndWeek,
  429. StartDate = olpeEntity.StartDate,
  430. EndDate = olpeEntity.EndDate,
  431. CreateTime = DateTime.Now,
  432. Status = 1,
  433. OrdinaryScoreScale = 1,
  434. TermInScoreScale = 1,
  435. TermEndScoreScale = 1,
  436. OtherScoreScale = 1,
  437. F_SchoolId = olpeEntity.F_SchoolId
  438. };
  439. stuSelectLessonListOfElectivePreIBLL.SaveEntity("", model);
  440. return Success("报名成功");
  441. }
  442. #endregion
  443. #region 私有类
  444. /// <summary>
  445. /// 表单实体类
  446. /// <summary>
  447. private class ReqFormEntity
  448. {
  449. public string keyValue { get; set; }
  450. public string strEntity { get; set; }
  451. }
  452. /// <summary>
  453. /// 报名模型
  454. /// </summary>
  455. private class SignModel
  456. {
  457. public string keyValue { get; set; }
  458. public string StuNo { get; set; }
  459. }
  460. #endregion
  461. }
  462. }