EducationMissionClassCheckServices.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Bowin.Common.Linq;
  6. using Bowin.Common.Linq.Entity;
  7. using EMIS.ViewModel.EducationManage;
  8. using EMIS.ViewModel.EducationManagement;
  9. using EMIS.DataLogic.EducationManage;
  10. using System.Linq.Expressions;
  11. using EMIS.Entities;
  12. using EMIS.ViewModel;
  13. namespace EMIS.CommonLogic.EducationManage
  14. {
  15. public class EducationMissionClassCheckServices : BaseServices, IEducationMissionClassCheckServices
  16. {
  17. public EducationMissionClassCheckDAL educationMissionClassCheckDAL { get; set; }
  18. public IGridResultSet<EducationMissionClassCheckView> GetEducationMissionClassCheckViewGrid(ConfiguretView configuretView, Guid? schoolyearID, int? weekNum, int? weekDay, Guid? times, Guid? classroomID, Guid? coursematerialID, Guid? staffID, int? opinionID, int? checkWayID, int pageIndex, int pageSize)
  19. {
  20. Expression<Func<EM_EducationMissionClassCheck, bool>> emccexp = (x => true);
  21. Expression<Func<EM_EducationMission, bool>> emexp = (x => true);
  22. Expression<Func<ES_EducationScheduling, bool>> esexp = (x => true);
  23. Expression<Func<EM_MissionClassTeacher, bool>> mctexp = (x => true);
  24. Expression<Func<EM_EducationMissionClass, bool>> emcexp = (x => true);
  25. Expression<Func<ES_EducationSchedulingWeekNum, bool>> eswnexp = (x => true);
  26. if (schoolyearID.HasValue)
  27. {
  28. emexp = emexp.And(x => x.SchoolyearID == schoolyearID);
  29. }
  30. if (weekNum.HasValue)
  31. {
  32. eswnexp = eswnexp.And(x => x.WeekNum == weekNum);
  33. }
  34. if (weekDay.HasValue)
  35. {
  36. esexp = esexp.And(x => x.Weekday == weekDay);
  37. }
  38. if (times.HasValue)
  39. {
  40. esexp = esexp.And(x => x.CoursesTimeID == times);
  41. }
  42. if (classroomID.HasValue)
  43. {
  44. esexp = esexp.And(x => x.ClassroomID == classroomID);
  45. }
  46. if (coursematerialID.HasValue)
  47. {
  48. emcexp = emcexp.And(x => x.CoursematerialID == coursematerialID);
  49. }
  50. if (staffID.HasValue)
  51. {
  52. emcexp = emcexp.And(x => x.EM_MissionClassTeacher.Any(y => y.UserID == staffID));
  53. }
  54. if (opinionID.HasValue)
  55. {
  56. emccexp = emccexp.And(x => x.OpinionID == opinionID);
  57. }
  58. if (checkWayID.HasValue)
  59. {
  60. emccexp = emccexp.And(x => x.CheckWayID == checkWayID);
  61. }
  62. var query = educationMissionClassCheckDAL.GetEducationMissionClassCheckViewQueryble(emccexp, emexp, esexp, mctexp, emcexp, eswnexp);
  63. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  64. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  65. var result = this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.ClassroomCode).ToGridResultSet<EducationMissionClassCheckView>(pageIndex, pageSize);
  66. var educationMissionClassID = result.rows.Select(x => x.EducationMissionClassID).ToList();
  67. var educationSchedulingID = result.rows.Select(x => x.EducationSchedulingID).ToList();
  68. var missionClassTeacherList = educationMissionClassCheckDAL.GetTeacherByEducationSchedulingID(x => educationSchedulingID.Contains(x.EducationSchedulingID)).ToList();
  69. result.rows.ForEach(x => x.MissionClassTeacherView = new HashSet<MissionClassTeacherView>(missionClassTeacherList.Where(y => y.EducationSchedulingID == x.EducationSchedulingID)));
  70. return result;
  71. }
  72. /// <summary>
  73. /// 获取导出列表
  74. /// </summary>
  75. /// <param name="configuretView"></param>
  76. /// <param name="schoolyearID"></param>
  77. /// <param name="weekNum"></param>
  78. /// <param name="weekDay"></param>
  79. /// <param name="times"></param>
  80. /// <param name="classroomID"></param>
  81. /// <param name="coursematerialID"></param>
  82. /// <param name="staffID"></param>
  83. /// <param name="opinionID"></param>
  84. /// <param name="checkWayID"></param>
  85. /// <param name="pageIndex"></param>
  86. /// <param name="pageSize"></param>
  87. /// <returns></returns>
  88. public List<EducationMissionClassCheckView> GetEducationMissionClassCheckViewList(ConfiguretView configuretView, Guid? schoolyearID, int? weekNum, int? weekDay, Guid? times, Guid? classroomID, Guid? coursematerialID, Guid? staffID, int? opinionID, int? checkWayID, List<Guid?> educationMissionClassCheckIDList)
  89. {
  90. Expression<Func<EM_EducationMissionClassCheck, bool>> emccexp = (x => true);
  91. Expression<Func<EM_EducationMission, bool>> emexp = (x => true);
  92. Expression<Func<ES_EducationScheduling, bool>> esexp = (x => true);
  93. Expression<Func<EM_MissionClassTeacher, bool>> mctexp = (x => true);
  94. Expression<Func<EM_EducationMissionClass, bool>> emcexp = (x => true);
  95. Expression<Func<ES_EducationSchedulingWeekNum, bool>> eswnexp = (x => true);
  96. if (educationMissionClassCheckIDList != null)
  97. {
  98. emccexp = emccexp.And(x => educationMissionClassCheckIDList.Contains(x.EducationMissionClassCheckID));
  99. }
  100. if (schoolyearID.HasValue)
  101. {
  102. emexp = emexp.And(x => x.SchoolyearID == schoolyearID);
  103. }
  104. if (weekNum.HasValue)
  105. {
  106. eswnexp = eswnexp.And(x => x.WeekNum == weekNum);
  107. }
  108. if (weekDay.HasValue)
  109. {
  110. esexp = esexp.And(x => x.Weekday == weekDay);
  111. }
  112. if (times.HasValue)
  113. {
  114. esexp = esexp.And(x => x.CoursesTimeID == times);
  115. }
  116. if (classroomID.HasValue)
  117. {
  118. esexp = esexp.And(x => x.ClassroomID == classroomID);
  119. }
  120. if (coursematerialID.HasValue)
  121. {
  122. emcexp = emcexp.And(x => x.CoursematerialID == coursematerialID);
  123. }
  124. if (staffID.HasValue)
  125. {
  126. mctexp = mctexp.And(x => x.UserID == staffID);
  127. }
  128. if (opinionID.HasValue)
  129. {
  130. emccexp = emccexp.And(x => x.OpinionID == opinionID);
  131. }
  132. if (checkWayID.HasValue)
  133. {
  134. emccexp = emccexp.And(x => x.CheckWayID == checkWayID);
  135. }
  136. var query = educationMissionClassCheckDAL.GetEducationMissionClassCheckViewQueryble(emccexp, emexp, esexp, mctexp, emcexp, eswnexp);
  137. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  138. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  139. var result = this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.ClassroomCode).ToList();
  140. var educationMissionClassID = result.Select(x => x.EducationMissionClassID).ToList();
  141. var educationSchedulingID = result.Select(x => x.EducationSchedulingID).ToList();
  142. var missionClassTeacherList = educationMissionClassCheckDAL.GetTeacherByEducationSchedulingID(x => educationSchedulingID.Contains(x.EducationSchedulingID)).ToList();
  143. result.ForEach(x => x.MissionClassTeacherView = new HashSet<MissionClassTeacherView>(missionClassTeacherList.Where(y => y.EducationSchedulingID == x.EducationSchedulingID)));
  144. return result;
  145. }
  146. public IGridResultSet<EducationMissionClassView> GetEducationMissionClassViewByCondition(ConfiguretView configuretView, Guid? schoolyearID, int? weekNum, int? weekDay, Guid? CoursesTimeID, Guid? ClassroomID, int pageIndex, int pageSize)
  147. {
  148. Expression<Func<ES_EducationSchedulingWeekNum, bool>> eswnexp = x => true;
  149. Expression<Func<ES_EducationScheduling, bool>> esexp = x => true;
  150. Expression<Func<EM_EducationMission, bool>> emexp = (x => true);
  151. Expression<Func<EM_EducationMissionClass, bool>> emcexp = (x => true);
  152. if (schoolyearID.HasValue)
  153. {
  154. emexp = emexp.And(x => x.SchoolyearID == schoolyearID);
  155. }
  156. if (weekNum.HasValue)
  157. {
  158. eswnexp = eswnexp.And(x => x.WeekNum == weekNum);
  159. }
  160. if (weekDay.HasValue)
  161. {
  162. esexp = esexp.And(x => x.Weekday == weekDay);
  163. }
  164. if (CoursesTimeID.HasValue)
  165. {
  166. esexp = esexp.And(x => x.CoursesTimeID == CoursesTimeID);
  167. }
  168. if (ClassroomID.HasValue)
  169. {
  170. esexp = esexp.And(x => x.ClassroomID == ClassroomID);
  171. }
  172. var query = educationMissionClassCheckDAL.GetEducationMissionClassViewByConditionQueryble(emcexp, emexp, eswnexp, esexp);
  173. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  174. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  175. var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.Name).ToGridResultSet<EducationMissionClassView>(pageIndex, pageSize);
  176. //var educationMissionClassID = result.rows.Select(x => x.EducationMissionClassID).ToList();
  177. //var missionClassTeacherList = educationMissionClassCheckDAL.GetTeacherNameQuery(esexp, eswnexp).ToList();
  178. //result.rows.ForEach(x => x.MissionClassTeacherView = new HashSet<MissionClassTeacherView>(missionClassTeacherList.Where(y => y.EducationMissionClassID == x.EducationMissionClassID)));
  179. return result;
  180. }
  181. public IGridResultSet<EducationMissionClassView> GetCoursematerialByCondition(ConfiguretView configuretView, Guid? schoolyearID, int? weekNum, int? weekDay, Guid? CoursesTimeID, Guid? ClassroomID, Guid? educationID, int pageIndex, int pageSize)
  182. {
  183. Expression<Func<ES_EducationSchedulingWeekNum, bool>> eswnexp = x => true;
  184. Expression<Func<ES_EducationScheduling, bool>> esexp = x => true;
  185. Expression<Func<EM_EducationMission, bool>> emexp = (x => true);
  186. Expression<Func<EM_EducationMissionClass, bool>> emcexp = (x => true);
  187. if (educationID.HasValue)
  188. {
  189. emcexp = emcexp.And(x => x.EducationMissionClassID == educationID);
  190. }
  191. if (schoolyearID.HasValue)
  192. {
  193. emexp = emexp.And(x => x.SchoolyearID == schoolyearID);
  194. }
  195. if (weekNum.HasValue)
  196. {
  197. eswnexp = eswnexp.And(x => x.WeekNum == weekNum);
  198. }
  199. if (weekDay.HasValue)
  200. {
  201. esexp = esexp.And(x => x.Weekday == weekDay);
  202. }
  203. if (CoursesTimeID.HasValue)
  204. {
  205. esexp = esexp.And(x => x.CoursesTimeID == CoursesTimeID);
  206. }
  207. if (ClassroomID.HasValue)
  208. {
  209. esexp = esexp.And(x => x.ClassroomID == ClassroomID);
  210. }
  211. var query = educationMissionClassCheckDAL.GetEducationMissionClassViewByConditionQueryble(emcexp, emexp, eswnexp, esexp);
  212. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  213. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  214. var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.Name).ToGridResultSet<EducationMissionClassView>(pageIndex, pageSize);
  215. //var educationMissionClassID = result.rows.Select(x => x.EducationMissionClassID).ToList();
  216. //var missionClassTeacherList = educationMissionClassCheckDAL.GetTeacherNameQuery(esexp, eswnexp).ToList();
  217. //result.rows.ForEach(x => x.MissionClassTeacherView = new HashSet<MissionClassTeacherView>(missionClassTeacherList.Where(y => y.EducationMissionClassID == x.EducationMissionClassID)));
  218. return result;
  219. }
  220. /// <summary>
  221. /// 获取单个信息
  222. /// </summary>
  223. /// <param name="graduationApplyID"></param>
  224. /// <returns></returns>
  225. public EducationMissionClassCheckView GetEducationMissionClassCheckView(Guid? educationMissionClassCheckID)
  226. {
  227. try
  228. {
  229. var graduationApplyView = educationMissionClassCheckDAL.GetEducationMissionClassCheckView(educationMissionClassCheckID);
  230. return graduationApplyView;
  231. }
  232. catch (Exception ex)
  233. {
  234. throw new Exception(ex.Message);
  235. }
  236. }
  237. public void EducationMissionClassCheckEdit(EducationMissionClassCheckView educationMissionClassCheckView, List<EducationMissionClassCheckTeacherView> teacherList)
  238. {
  239. try
  240. {
  241. //根据周次、星期、节次、场地、任务班去找对应的排课周次ID
  242. var educationSchedulingWeekNumID = educationMissionClassCheckDAL.GetEducationSchedulingWeekNumID(educationMissionClassCheckView.WeekNum, educationMissionClassCheckView.Weekday, educationMissionClassCheckView.CoursesTimeID, educationMissionClassCheckView.ClassroomID, (Guid)educationMissionClassCheckView.EducationMissionClassID);
  243. educationMissionClassCheckView.EducationSchedulingWeekNumID = educationSchedulingWeekNumID;
  244. //查询数据库进行验证
  245. var educationMissionClassCheckVerification = educationMissionClassCheckDAL.educationMissionClassCheckRepository
  246. .GetList(x => x.EducationMissionClassCheckID != educationMissionClassCheckView.EducationMissionClassCheckID &&
  247. x.EducationSchedulingWeekNumID == educationMissionClassCheckView.EducationSchedulingWeekNumID)
  248. .SingleOrDefault();
  249. if (educationMissionClassCheckVerification == null)
  250. {
  251. //数据有误验证
  252. if (educationMissionClassCheckView.EducationMissionClassCheckID != Guid.Empty)
  253. {
  254. var educationMissionClassCheck = educationMissionClassCheckDAL.educationMissionClassCheckRepository
  255. .GetList(x => x.EducationMissionClassCheckID == educationMissionClassCheckView.EducationMissionClassCheckID, x => x.Sys_User)
  256. .SingleOrDefault();
  257. if (educationMissionClassCheck == null)
  258. {
  259. throw new Exception("数据有误,请核查");
  260. }
  261. else
  262. {
  263. educationMissionClassCheck.EducationSchedulingWeekNumID = educationMissionClassCheckView.EducationSchedulingWeekNumID;
  264. educationMissionClassCheck.StudentComment = educationMissionClassCheckView.StudentComment;
  265. educationMissionClassCheck.TeacherComment = educationMissionClassCheckView.TeacherComment;
  266. educationMissionClassCheck.DeviceComment = educationMissionClassCheckView.DeviceComment;
  267. educationMissionClassCheck.CheckWayID = educationMissionClassCheckView.CheckWayID;
  268. educationMissionClassCheck.OpinionID = educationMissionClassCheckView.OpinionID;
  269. educationMissionClassCheck.Remark = educationMissionClassCheckView.Remark;
  270. educationMissionClassCheck.Sys_User = new HashSet<Sys_User>();
  271. teacherList.ForEach(x =>
  272. {
  273. Sys_User user = educationMissionClassCheckDAL.userRepository.GetSingle(y => y.UserID == x.UserID);
  274. //educationMissionClassCheck.Sys_User = new HashSet<Sys_User>();
  275. educationMissionClassCheck.Sys_User.Add(user);
  276. });
  277. SetModifyStatus(educationMissionClassCheck);
  278. UnitOfWork.Update(educationMissionClassCheck);
  279. }
  280. }
  281. else
  282. {
  283. //表示新增
  284. EM_EducationMissionClassCheck educationMissionClassCheck = new EM_EducationMissionClassCheck();
  285. educationMissionClassCheck.EducationMissionClassCheckID = Guid.NewGuid();
  286. educationMissionClassCheck.EducationSchedulingWeekNumID = educationMissionClassCheckView.EducationSchedulingWeekNumID;
  287. educationMissionClassCheck.StudentComment = educationMissionClassCheckView.StudentComment;
  288. educationMissionClassCheck.TeacherComment = educationMissionClassCheckView.TeacherComment;
  289. educationMissionClassCheck.DeviceComment = educationMissionClassCheckView.DeviceComment;
  290. educationMissionClassCheck.CheckWayID = educationMissionClassCheckView.CheckWayID;
  291. educationMissionClassCheck.OpinionID = educationMissionClassCheckView.OpinionID;
  292. educationMissionClassCheck.Remark = educationMissionClassCheckView.Remark;
  293. teacherList.ForEach(x =>
  294. {
  295. Sys_User user = educationMissionClassCheckDAL.userRepository.GetSingle(y => y.UserID == x.UserID);
  296. educationMissionClassCheck.Sys_User.Add(user);
  297. });
  298. SetNewStatus(educationMissionClassCheck);
  299. UnitOfWork.Add(educationMissionClassCheck);
  300. }
  301. }
  302. else
  303. {
  304. throw new Exception("已存在相同的教学检查,请核查");
  305. }
  306. //事务提交
  307. UnitOfWork.Commit();
  308. }
  309. catch (Exception ex)
  310. {
  311. throw new Exception(ex.Message);
  312. }
  313. }
  314. /// <summary>
  315. /// 删除
  316. /// </summary>
  317. /// <param name="graduationApplyIDs"></param>
  318. /// <returns></returns>
  319. public bool EducationMissionClassCheckDelete(List<Guid?> educationMissionClassCheckIDs)
  320. {
  321. try
  322. {
  323. List<EM_EducationMissionClassCheck> emccList = educationMissionClassCheckDAL.educationMissionClassCheckRepository.GetList(x => educationMissionClassCheckIDs.Contains(x.EducationMissionClassCheckID), (x => x.Sys_User)).ToList();
  324. foreach (EM_EducationMissionClassCheck emcc in emccList)
  325. {
  326. emcc.Sys_User = new HashSet<Sys_User>();
  327. UnitOfWork.Remove(emcc);
  328. }
  329. //UnitOfWork.Delete<EM_EducationMissionClassCheck>(x => educationMissionClassCheckIDs.Contains(x.EducationMissionClassCheckID));
  330. UnitOfWork.Commit();
  331. return true;
  332. }
  333. catch (Exception ex)
  334. {
  335. throw ex;
  336. }
  337. }
  338. /// <summary>
  339. /// 根据任务班ID获取授课老师姓名
  340. /// </summary>
  341. /// <param name="EducationMissionClassID"></param>
  342. /// <returns></returns>
  343. public string GetTeacherbyEducationMissionClass(Guid EducationMissionClassID)
  344. {
  345. try
  346. {
  347. var missionClassTeacherList = educationMissionClassCheckDAL.GetMissionClassTeacherQuery(x => x.EducationMissionClassID == EducationMissionClassID).ToList();
  348. string TeacherNames = "";
  349. foreach (MissionClassTeacherView mission in missionClassTeacherList)
  350. {
  351. TeacherNames = TeacherNames + mission.Name + ",";
  352. }
  353. TeacherNames = TeacherNames.Substring(0, TeacherNames.Length - 1);
  354. return TeacherNames;
  355. }
  356. catch (Exception ex)
  357. {
  358. throw new Exception(ex.Message);
  359. }
  360. }
  361. /// <summary>
  362. /// 根据学年学期,周次,星期,节次,教室获取排课中的授课老师
  363. /// </summary>
  364. /// <param name="EducationMissionClassID"></param>
  365. /// <returns></returns>
  366. public string GetTeacherByAll(ConfiguretView configuretView, Guid? schoolyearID, int? weekNum, int? weekDay, Guid? coursesTimeID, Guid? classroomID, Guid? educationClassID)
  367. {
  368. try
  369. {
  370. Expression<Func<ES_EducationScheduling, bool>> exp = x => true;
  371. Expression<Func<ES_EducationSchedulingWeekNum, bool>> eswnexp = x => true;
  372. if (schoolyearID.HasValue)
  373. {
  374. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  375. }
  376. if (weekDay.HasValue)
  377. {
  378. exp = exp.And(x => x.Weekday == weekDay);
  379. }
  380. if (coursesTimeID.HasValue)
  381. {
  382. exp = exp.And(x => x.CoursesTimeID == coursesTimeID);
  383. }
  384. if (classroomID.HasValue)
  385. {
  386. exp = exp.And(x => x.ClassroomID == classroomID);
  387. }
  388. if (weekNum.HasValue)
  389. {
  390. eswnexp = eswnexp.And(x => x.WeekNum == weekNum);
  391. }
  392. var missionClassTeacherList = educationMissionClassCheckDAL.GetTeacherNameQuery(exp, eswnexp).ToList();
  393. string TeacherNames = "";
  394. foreach (MissionClassTeacherView mission in missionClassTeacherList)
  395. {
  396. TeacherNames = TeacherNames + mission.Name + ",";
  397. }
  398. TeacherNames = TeacherNames.Substring(0, TeacherNames.Length - 1);
  399. return TeacherNames;
  400. }
  401. catch (Exception ex)
  402. {
  403. throw new Exception(ex.Message);
  404. }
  405. }
  406. public List<EducationMissionClassCheckTeacherView> GetCheckTeacherViewListByCheckID(Guid EducationMissionClassCheckID)
  407. {
  408. return educationMissionClassCheckDAL.GetEducationMissionClassCheckTeacherListViewQueryble(EducationMissionClassCheckID).ToList();
  409. }
  410. }
  411. }