Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

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