GraduationCourseServices.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.ViewModel;
  6. using Bowin.Common.Linq.Entity;
  7. using EMIS.ViewModel.GraduationManage.GraduationRequirement;
  8. using EMIS.Entities;
  9. using Bowin.Common.Linq;
  10. using System.Linq.Expressions;
  11. using EMIS.DataLogic.GraduationManage.GraduationRequirement;
  12. using EMIS.DataLogic.Repositories;
  13. namespace EMIS.CommonLogic.GraduationManage.GraduationRequirement
  14. {
  15. public class GraduationCourseServices : BaseServices, IGraduationCourseServices
  16. {
  17. public GraduationCourseDAL GraduationCourseDAL { get; set; }
  18. /// <summary>
  19. /// 查询毕业课程信息View
  20. /// </summary>
  21. /// <param name="configuretView"></param>
  22. /// <param name="gradSchoolyearID"></param>
  23. /// <param name="collegeID"></param>
  24. /// <param name="yearID"></param>
  25. /// <param name="standardID"></param>
  26. /// <param name="educationID"></param>
  27. /// <param name="learningformID"></param>
  28. /// <param name="learnSystem"></param>
  29. /// <param name="courseTypeID"></param>
  30. /// <param name="pageIndex"></param>
  31. /// <param name="pageSize"></param>
  32. /// <returns></returns>
  33. public IGridResultSet<GraduationCourseView> GetGraduationCourseViewGird(ConfiguretView configuretView, Guid? gradSchoolyearID,
  34. Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
  35. int? courseTypeID, int pageIndex, int pageSize)
  36. {
  37. //毕业课程
  38. Expression<Func<ER_GraduationCourse, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  39. if (courseTypeID.HasValue)
  40. {
  41. //课程类型
  42. exp = exp.And(x => x.CourseTypeID == courseTypeID);
  43. }
  44. var query = GraduationCourseDAL.GetGraduationCourseQueryable(exp);
  45. if (gradSchoolyearID.HasValue)
  46. {
  47. query = query.Where(x => x.GraduatingSemesterID == gradSchoolyearID);
  48. }
  49. if (collegeID.HasValue)
  50. {
  51. query = query.Where(x => x.CollegeID == collegeID);
  52. }
  53. if (yearID.HasValue)
  54. {
  55. query = query.Where(x => x.SchoolyearID == yearID);
  56. }
  57. if (standardID.HasValue)
  58. {
  59. query = query.Where(x => x.StandardID == standardID);
  60. }
  61. if (educationID.HasValue)
  62. {
  63. query = query.Where(x => x.EducationID == educationID);
  64. }
  65. if (learningformID.HasValue)
  66. {
  67. query = query.Where(x => x.LearningformID == learningformID);
  68. }
  69. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  70. {
  71. var LearnSystems = Convert.ToDecimal(learnSystem);
  72. query = query.Where(x => x.LearnSystem == LearnSystems);
  73. }
  74. //查询条件
  75. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  76. {
  77. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  78. }
  79. return this.GetQueryByDataRangeByCollege(query)
  80. .OrderByDescending(x => x.SchoolyearID).OrderBy(x => x.StandardID)
  81. .ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID)
  82. .ThenBy(x => x.CourseTypeID)
  83. .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  84. .ToGridResultSet<GraduationCourseView>(pageIndex, pageSize);
  85. }
  86. /// <summary>
  87. /// 查询毕业课程信息List
  88. /// </summary>
  89. /// <param name="configuretView"></param>
  90. /// <param name="gradSchoolyearID"></param>
  91. /// <param name="collegeID"></param>
  92. /// <param name="yearID"></param>
  93. /// <param name="standardID"></param>
  94. /// <param name="educationID"></param>
  95. /// <param name="learningformID"></param>
  96. /// <param name="learnSystem"></param>
  97. /// <param name="courseTypeID"></param>
  98. /// <returns></returns>
  99. public IList<GraduationCourseView> GetGraduationCourseViewList(ConfiguretView configuretView, Guid? gradSchoolyearID,
  100. Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, int? courseTypeID)
  101. {
  102. //毕业课程
  103. Expression<Func<ER_GraduationCourse, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  104. if (courseTypeID.HasValue)
  105. {
  106. //课程类型
  107. exp = exp.And(x => x.CourseTypeID == courseTypeID);
  108. }
  109. var query = GraduationCourseDAL.GetGraduationCourseQueryable(exp);
  110. if (gradSchoolyearID.HasValue)
  111. {
  112. query = query.Where(x => x.GraduatingSemesterID == gradSchoolyearID);
  113. }
  114. if (collegeID.HasValue)
  115. {
  116. query = query.Where(x => x.CollegeID == collegeID);
  117. }
  118. if (yearID.HasValue)
  119. {
  120. query = query.Where(x => x.SchoolyearID == yearID);
  121. }
  122. if (standardID.HasValue)
  123. {
  124. query = query.Where(x => x.StandardID == standardID);
  125. }
  126. if (educationID.HasValue)
  127. {
  128. query = query.Where(x => x.EducationID == educationID);
  129. }
  130. if (learningformID.HasValue)
  131. {
  132. query = query.Where(x => x.LearningformID == learningformID);
  133. }
  134. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  135. {
  136. var LearnSystems = Convert.ToDecimal(learnSystem);
  137. query = query.Where(x => x.LearnSystem == LearnSystems);
  138. }
  139. //查询条件
  140. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  141. {
  142. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  143. }
  144. return this.GetQueryByDataRangeByCollege(query)
  145. .OrderByDescending(x => x.SchoolyearID).OrderBy(x => x.StandardID)
  146. .ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID)
  147. .ThenBy(x => x.CourseTypeID)
  148. .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  149. .ToList();
  150. }
  151. /// <summary>
  152. /// 根据毕业课程ID查询对应的毕业课程信息GraduationCourseView
  153. /// </summary>
  154. /// <param name="GraduationCourseID"></param>
  155. /// <returns></returns>
  156. public GraduationCourseView GetGraduationCourseView(Guid? GraduationCourseID)
  157. {
  158. try
  159. {
  160. var query = GraduationCourseDAL.GetGraduationCourseQueryable(x => x.GraduationCourseID == GraduationCourseID)
  161. .SingleOrDefault();
  162. return query;
  163. }
  164. catch (Exception ex)
  165. {
  166. throw new Exception(ex.Message);
  167. }
  168. }
  169. /// <summary>
  170. /// 查询对应的专业计划信息View(需与毕业课程信息进行对比)
  171. /// </summary>
  172. /// <param name="configuretView"></param>
  173. /// <param name="gradSchoolyearID"></param>
  174. /// <param name="collegeID"></param>
  175. /// <param name="yearID"></param>
  176. /// <param name="standardID"></param>
  177. /// <param name="educationID"></param>
  178. /// <param name="learningformID"></param>
  179. /// <param name="learnSystem"></param>
  180. /// <param name="coursematerialID"></param>
  181. /// <param name="courseTypeID"></param>
  182. /// <param name="pageIndex"></param>
  183. /// <param name="pageSize"></param>
  184. /// <returns></returns>
  185. public IGridResultSet<GradSpecialtyPlanView> GetGradSpecialtyPlanViewGrid(ConfiguretView configuretView, Guid? gradSchoolyearID,
  186. Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
  187. Guid? coursematerialID, int? courseTypeID, int pageIndex, int pageSize)
  188. {
  189. //专业计划
  190. Expression<Func<EM_SpecialtyPlan, bool>> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  191. if (coursematerialID.HasValue)
  192. {
  193. //课程信息
  194. expSpecialtyPlan = expSpecialtyPlan.And(x => x.CoursematerialID == coursematerialID);
  195. }
  196. if (courseTypeID.HasValue)
  197. {
  198. //课程类型
  199. expSpecialtyPlan = expSpecialtyPlan.And(x => x.CourseTypeID == courseTypeID);
  200. }
  201. //年级专业
  202. Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  203. if (gradSchoolyearID.HasValue)
  204. {
  205. //毕业学期
  206. expGrademajor = expGrademajor.And(x => x.GraduateSchoolyearID == gradSchoolyearID);
  207. }
  208. var query = GraduationCourseDAL.GetGradSpecialtyPlanQueryable(expSpecialtyPlan, expGrademajor);
  209. if (collegeID.HasValue)
  210. {
  211. query = query.Where(x => x.CollegeID == collegeID);
  212. }
  213. if (yearID.HasValue)
  214. {
  215. query = query.Where(x => x.GradeID == yearID);
  216. }
  217. if (standardID.HasValue)
  218. {
  219. query = query.Where(x => x.StandardID == standardID);
  220. }
  221. if (educationID.HasValue)
  222. {
  223. query = query.Where(x => x.EducationID == educationID);
  224. }
  225. if (learningformID.HasValue)
  226. {
  227. query = query.Where(x => x.LearningformID == learningformID);
  228. }
  229. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  230. {
  231. var LearnSystems = Convert.ToDecimal(learnSystem);
  232. query = query.Where(x => x.LearnSystem == LearnSystems);
  233. }
  234. //查询条件
  235. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  236. {
  237. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  238. }
  239. return this.GetQueryByDataRangeByCollege(query)
  240. .OrderByDescending(x => x.GradeID).ThenBy(x => x.GrademajorCode.Length)
  241. .ThenBy(x => x.GrademajorCode).ThenBy(x => x.StarttermID)
  242. .ToGridResultSet<GradSpecialtyPlanView>(pageIndex, pageSize);
  243. }
  244. /// <summary>
  245. /// 查询对应的专业计划信息List(需与毕业课程信息进行对比)
  246. /// </summary>
  247. /// <param name="configuretView"></param>
  248. /// <param name="gradSchoolyearID"></param>
  249. /// <param name="collegeID"></param>
  250. /// <param name="yearID"></param>
  251. /// <param name="standardID"></param>
  252. /// <param name="educationID"></param>
  253. /// <param name="learningformID"></param>
  254. /// <param name="learnSystem"></param>
  255. /// <param name="coursematerialID"></param>
  256. /// <param name="courseTypeID"></param>
  257. /// <returns></returns>
  258. public IList<GradSpecialtyPlanView> GetGradSpecialtyPlanViewList(ConfiguretView configuretView, Guid? gradSchoolyearID,
  259. Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
  260. Guid? coursematerialID, int? courseTypeID)
  261. {
  262. //专业计划
  263. Expression<Func<EM_SpecialtyPlan, bool>> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  264. if (coursematerialID.HasValue)
  265. {
  266. //课程信息
  267. expSpecialtyPlan = expSpecialtyPlan.And(x => x.CoursematerialID == coursematerialID);
  268. }
  269. if (courseTypeID.HasValue)
  270. {
  271. //课程类型
  272. expSpecialtyPlan = expSpecialtyPlan.And(x => x.CourseTypeID == courseTypeID);
  273. }
  274. //年级专业
  275. Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  276. if (gradSchoolyearID.HasValue)
  277. {
  278. //毕业学期
  279. expGrademajor = expGrademajor.And(x => x.GraduateSchoolyearID == gradSchoolyearID);
  280. }
  281. var query = GraduationCourseDAL.GetGradSpecialtyPlanQueryable(expSpecialtyPlan, expGrademajor);
  282. if (collegeID.HasValue)
  283. {
  284. query = query.Where(x => x.CollegeID == collegeID);
  285. }
  286. if (yearID.HasValue)
  287. {
  288. query = query.Where(x => x.GradeID == yearID);
  289. }
  290. if (standardID.HasValue)
  291. {
  292. query = query.Where(x => x.StandardID == standardID);
  293. }
  294. if (educationID.HasValue)
  295. {
  296. query = query.Where(x => x.EducationID == educationID);
  297. }
  298. if (learningformID.HasValue)
  299. {
  300. query = query.Where(x => x.LearningformID == learningformID);
  301. }
  302. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  303. {
  304. var LearnSystems = Convert.ToDecimal(learnSystem);
  305. query = query.Where(x => x.LearnSystem == LearnSystems);
  306. }
  307. //查询条件
  308. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  309. {
  310. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  311. }
  312. return this.GetQueryByDataRangeByCollege(query)
  313. .OrderByDescending(x => x.GradeID).ThenBy(x => x.GrademajorCode.Length)
  314. .ThenBy(x => x.GrademajorCode).ThenBy(x => x.StarttermID)
  315. .ToList();
  316. }
  317. /// <summary>
  318. /// 计划生成(专业计划)
  319. /// </summary>
  320. /// <param name="graduationCourseView"></param>
  321. /// <param name="gradSpecialtyPlanViewList"></param>
  322. /// <returns></returns>
  323. public string GraduationCourseBatchAdd(GraduationCourseView graduationCourseView, List<GradSpecialtyPlanView> gradSpecialtyPlanViewList)
  324. {
  325. try
  326. {
  327. //毕业课程信息List
  328. var chargeStandardList = GraduationCourseDAL.GraduationCourseRepository
  329. .GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
  330. int success = 0; //成功
  331. int fail = 0; //失败
  332. string tipMessage = null; //提示消息
  333. List<ER_GraduationCourse> graduationCourseInList = new List<ER_GraduationCourse>();
  334. //注:毕业课程业务主键(年级专业ID、课程信息ID、课程类型ID、课程学分)
  335. foreach (var gradSpecialtyPlanView in gradSpecialtyPlanViewList)
  336. {
  337. //查询数据库进行验证
  338. var graduationCourseVerification = chargeStandardList
  339. .Where(x => x.GrademajorID == gradSpecialtyPlanView.GrademajorID
  340. && x.CoursematerialID == gradSpecialtyPlanView.CoursematerialID
  341. && x.CourseTypeID == gradSpecialtyPlanView.CourseTypeID
  342. && x.CourseCredit == gradSpecialtyPlanView.Credit)
  343. .SingleOrDefault();
  344. if (graduationCourseVerification == null)
  345. {
  346. //表示不存在对应的毕业课程(新增)
  347. ER_GraduationCourse graduationCourse = new ER_GraduationCourse();
  348. graduationCourse.GraduationCourseID = Guid.NewGuid();
  349. graduationCourse.GrademajorID = gradSpecialtyPlanView.GrademajorID;
  350. graduationCourse.CoursematerialID = gradSpecialtyPlanView.CoursematerialID;
  351. graduationCourse.CourseTypeID = gradSpecialtyPlanView.CourseTypeID;
  352. graduationCourse.CourseCredit = gradSpecialtyPlanView.Credit;
  353. SetNewStatus(graduationCourse);
  354. graduationCourseInList.Add(graduationCourse);
  355. success++;
  356. }
  357. else
  358. {
  359. //表示已存在相同的毕业课程
  360. fail++;
  361. }
  362. }
  363. //批量插入
  364. UnitOfWork.BulkInsert<ER_GraduationCourse>(graduationCourseInList);
  365. if (success > 0 && fail <= 0)
  366. {
  367. tipMessage = success + "条";
  368. }
  369. else
  370. {
  371. tipMessage = success + "条," + fail + "条失败,原因:已存在相同的毕业课程,请检查";
  372. }
  373. return tipMessage;
  374. }
  375. catch (Exception ex)
  376. {
  377. throw new Exception(ex.Message);
  378. }
  379. }
  380. /// <summary>
  381. /// 编辑(新增、修改,业务主键:年级专业、课程信息、课程类型、课程学分)
  382. /// </summary>
  383. /// <param name="graduationCourseView"></param>
  384. public void GraduationCourseEdit(GraduationCourseView graduationCourseView)
  385. {
  386. try
  387. {
  388. //查询数据库进行验证
  389. var graduationCourseVerification = GraduationCourseDAL.GraduationCourseRepository
  390. .GetList(x => x.GraduationCourseID != graduationCourseView.GraduationCourseID
  391. && x.GrademajorID == graduationCourseView.GrademajorID
  392. && x.CoursematerialID == graduationCourseView.CoursematerialID
  393. && x.CourseTypeID == graduationCourseView.CourseTypeID
  394. && x.CourseCredit == graduationCourseView.CourseCredit)
  395. .SingleOrDefault();
  396. if (graduationCourseVerification == null)
  397. {
  398. //数据有误验证
  399. if (graduationCourseView.GraduationCourseID != Guid.Empty)
  400. {
  401. var graduationCourse = GraduationCourseDAL.GraduationCourseRepository
  402. .GetList(x => x.GraduationCourseID == graduationCourseView.GraduationCourseID)
  403. .SingleOrDefault();
  404. if (graduationCourse == null)
  405. {
  406. throw new Exception("数据有误,请核查");
  407. }
  408. else
  409. {
  410. //表示修改
  411. graduationCourse.GrademajorID = graduationCourseView.GrademajorID;
  412. graduationCourse.CoursematerialID = graduationCourseView.CoursematerialID;
  413. graduationCourse.CourseTypeID = graduationCourseView.CourseTypeID;
  414. graduationCourse.CourseCredit = graduationCourseView.CourseCredit;
  415. SetModifyStatus(graduationCourse);
  416. }
  417. }
  418. else
  419. {
  420. //表示新增
  421. ER_GraduationCourse graduationCourse = new ER_GraduationCourse();
  422. graduationCourse.GraduationCourseID = Guid.NewGuid();
  423. graduationCourse.GrademajorID = graduationCourseView.GrademajorID;
  424. graduationCourse.CoursematerialID = graduationCourseView.CoursematerialID;
  425. graduationCourse.CourseTypeID = graduationCourseView.CourseTypeID;
  426. graduationCourse.CourseCredit = graduationCourseView.CourseCredit;
  427. SetNewStatus(graduationCourse);
  428. UnitOfWork.Add(graduationCourse);
  429. }
  430. }
  431. else
  432. {
  433. throw new Exception("已存在相同的毕业课程,请核查");
  434. }
  435. //事务提交
  436. UnitOfWork.Commit();
  437. }
  438. catch (Exception ex)
  439. {
  440. throw new Exception(ex.Message);
  441. }
  442. }
  443. /// <summary>
  444. /// 删除
  445. /// </summary>
  446. /// <param name="graduationCourseIDList"></param>
  447. /// <returns></returns>
  448. public bool GraduationCourseDelete(IList<Guid?> graduationCourseIDList)
  449. {
  450. try
  451. {
  452. UnitOfWork.Delete<ER_GraduationCourse>(x => graduationCourseIDList.Contains(x.GraduationCourseID));
  453. UnitOfWork.Commit();
  454. return true;
  455. }
  456. catch (Exception ex)
  457. {
  458. throw new Exception(ex.Message);
  459. }
  460. }
  461. }
  462. }