25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

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