25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

ElectiveMergeService.cs 10 KiB

4 yıl önce
4 yıl önce
4 yıl önce
4 yıl önce
4 yıl önce
4 yıl önce
4 yıl önce
4 yıl önce
4 yıl önce
4 yıl önce
4 yıl önce
4 yıl önce
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. using Dapper;
  2. using Learun.DataBase.Repository;
  3. using Learun.Util;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Linq;
  8. using System.Text;
  9. namespace Learun.Application.TwoDevelopment.EducationalAdministration
  10. {
  11. /// <summary>
  12. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  13. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  14. /// 创 建:超级管理员
  15. /// 日 期:2019-08-26 16:58
  16. /// 描 述:选修合班设置
  17. /// </summary>
  18. public class ElectiveMergeService : RepositoryFactory
  19. {
  20. #region 获取数据
  21. /// <summary>
  22. /// 获取页面显示列表数据
  23. /// <summary>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<ElectiveMergeEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append(@"select distinct a.*,d.StudyScore from ElectiveMerge a left join
  32. ElectiveMergeItem b
  33. on a.EMId = b.EmId left join lessoninfo d on a.LessonId=d.LessonId
  34. ");
  35. strSql.Append(" WHERE 1=1 ");
  36. var queryParam = queryJson.ToJObject();
  37. // 虚拟参数
  38. var dp = new DynamicParameters(new { });
  39. if (!queryParam["AcademicYearNo"].IsEmpty())
  40. {
  41. dp.Add("AcademicYearNo", "" + queryParam["AcademicYearNo"].ToString() + "", DbType.String);
  42. strSql.Append(" AND a.AcademicYearNo =@AcademicYearNo ");
  43. }
  44. if (!queryParam["Semester"].IsEmpty())
  45. {
  46. dp.Add("Semester", "" + queryParam["Semester"].ToString() + "", DbType.String);
  47. strSql.Append(" AND a.Semester = @Semester ");
  48. }
  49. if (!queryParam["LessonName"].IsEmpty())
  50. {
  51. dp.Add("LessonName", "" + queryParam["LessonName"].ToString() + "", DbType.String);
  52. strSql.Append(" AND a.LessonNo = @LessonName ");
  53. }
  54. return this.BaseRepository("CollegeMIS").FindList<ElectiveMergeEntity>(strSql.ToString(), dp, pagination);
  55. }
  56. catch (Exception ex)
  57. {
  58. if (ex is ExceptionEx)
  59. {
  60. throw;
  61. }
  62. else
  63. {
  64. throw ExceptionEx.ThrowServiceException(ex);
  65. }
  66. }
  67. }
  68. /// <summary>
  69. /// 获取ElectiveMerge表实体数据
  70. /// <param name="keyValue">主键</param>
  71. /// <summary>
  72. /// <returns></returns>
  73. public ElectiveMergeEntity GetElectiveMergeEntity(string keyValue)
  74. {
  75. try
  76. {
  77. var ementity = this.BaseRepository("CollegeMIS").FindEntity<ElectiveMergeEntity>(keyValue);
  78. var stumax = this.BaseRepository("CollegeMIS").FindObject(@"select distinct isnull(c.StuNumMax,0) from ElectiveMerge a left join
  79. ElectiveMergeItem b
  80. on a.EMId = b.EmId left join OpenLessonPlanOfElective c
  81. on b.OLPOEId = c.Id where a.EMId = '" + keyValue + "'");
  82. ementity.StuNumMax = Convert.ToInt32(stumax);
  83. return ementity;
  84. }
  85. catch (Exception ex)
  86. {
  87. if (ex is ExceptionEx)
  88. {
  89. throw;
  90. }
  91. else
  92. {
  93. throw ExceptionEx.ThrowServiceException(ex);
  94. }
  95. }
  96. }
  97. #endregion
  98. #region 提交数据
  99. /// <summary>
  100. /// 删除实体数据
  101. /// <param name="keyValue">主键</param>
  102. /// <summary>
  103. /// <returns></returns>
  104. public void DeleteEntity(string keyValue)
  105. {
  106. var db = this.BaseRepository("CollegeMIS");
  107. try
  108. {
  109. db.BeginTrans();
  110. var deldatalist = db.FindList<ElectiveMergeItemEntity>(m => m.EmId == keyValue).OrderBy(m => Convert.ToInt32(m.LessonSection));
  111. var deldatafirst = deldatalist.First();
  112. var deldatalast = deldatalist.Last();
  113. var opfirst = db.FindEntity<OpenLessonPlanOfElectiveEntity>(m => m.Id == deldatafirst.OLPOEId);
  114. opfirst.LessonSection = deldatafirst.LessonSection;
  115. opfirst.LessonTime = deldatafirst.LessonTime;
  116. db.Update(opfirst);
  117. db.ExecuteBySql(@"insert into OpenLessonPlanOfElective(Id, MakeDate, AcademicYearNo, Semester, LessonNo, PartCode, LessonName, LessonSortNo, LessonSortDetailNo, LessonSection, LessonTime, StudyScore, StartWeek, EndWeek, StartDate, EndDate, CheckStyleNo, ScoreRecordStyleNo, EmpNo, EmpName, ClassRoomNo, ClassRoomName, CheckMark, StuNumMax, StuNum, ModifyTime, ModifyUserId, ModifyUserName, F_SchoolId)
  118. select Id, MakeDate, AcademicYearNo, Semester, LessonNo, PartCode, LessonName, LessonSortNo, LessonSortDetailNo, LessonSection, LessonTime, StudyScore, StartWeek, EndWeek, StartDate, EndDate, CheckStyleNo, ScoreRecordStyleNo, EmpNo, EmpName, ClassRoomNo, ClassRoomName, CheckMark, StuNumMax, StuNum, ModifyTime, ModifyUserId, ModifyUserName, F_SchoolId
  119. from OpenLessonPlanOfElectiveDel where id='" + deldatalast.OLPOEId + "'");
  120. db.ExecuteBySql("delete from OpenLessonPlanOfElectiveDel where id='" + deldatalast.OLPOEId + "'");
  121. db.Delete<ElectiveMergeItemEntity>(m => m.EmId == keyValue);
  122. db.Delete<ElectiveMergeEntity>(t => t.EMId == keyValue);
  123. db.Commit();
  124. }
  125. catch (Exception ex)
  126. {
  127. db.Rollback();
  128. if (ex is ExceptionEx)
  129. {
  130. throw;
  131. }
  132. else
  133. {
  134. throw ExceptionEx.ThrowServiceException(ex);
  135. }
  136. }
  137. }
  138. /// <summary>
  139. /// 保存实体数据(新增、修改)
  140. /// <param name="keyValue">主键</param>
  141. /// <summary>
  142. /// <returns></returns>
  143. public void SaveEntity(string keyValue, ElectiveMergeEntity entity, List<ElectiveMergeItemEntity> electiveMergeItemEntity)
  144. {
  145. var db = this.BaseRepository("CollegeMIS");
  146. try
  147. {
  148. if (!string.IsNullOrEmpty(keyValue))
  149. {
  150. entity.Modify(keyValue);
  151. this.BaseRepository("CollegeMIS").Update(entity);
  152. }
  153. else
  154. {
  155. db.BeginTrans();
  156. db.Insert(entity);
  157. db.Insert(electiveMergeItemEntity);
  158. var ids = string.Join(",", electiveMergeItemEntity.Select(n => n.OLPOEId));
  159. var olplist = db.FindList<OpenLessonPlanOfElectiveEntity>(m =>
  160. ids.Contains(m.Id)).OrderBy(c => Convert.ToInt32(c.LessonSection));
  161. var opfirst = olplist.First();
  162. var oplast = olplist.Last();
  163. opfirst.LessonSection += "," + oplast.LessonSection;
  164. opfirst.LessonTime += "," + oplast.LessonTime;
  165. db.Update(opfirst);
  166. db.ExecuteBySql($@"insert into OpenLessonPlanOfElectiveDel(Id, MakeDate, AcademicYearNo, Semester, LessonNo, PartCode, LessonName, LessonSortNo, LessonSortDetailNo, LessonSection, LessonTime, StudyScore, StartWeek, EndWeek, StartDate, EndDate, CheckStyleNo, ScoreRecordStyleNo, EmpNo, EmpName, ClassRoomNo, ClassRoomName, CheckMark, StuNumMax, StuNum, ModifyTime, ModifyUserId, ModifyUserName, F_SchoolId )
  167. select Id, MakeDate, AcademicYearNo, Semester, LessonNo, PartCode, LessonName, LessonSortNo, LessonSortDetailNo, LessonSection, LessonTime, StudyScore, StartWeek, EndWeek, StartDate, EndDate, CheckStyleNo, ScoreRecordStyleNo, EmpNo, EmpName, ClassRoomNo, ClassRoomName, CheckMark, StuNumMax, StuNum, ModifyTime, ModifyUserId, ModifyUserName, F_SchoolId from OpenLessonPlanOfElective
  168. where id ='" + oplast.Id + "'");
  169. db.Delete(oplast);
  170. db.Commit();
  171. }
  172. }
  173. catch (Exception ex)
  174. {
  175. db.Rollback();
  176. if (ex is ExceptionEx)
  177. {
  178. throw;
  179. }
  180. else
  181. {
  182. throw ExceptionEx.ThrowServiceException(ex);
  183. }
  184. }
  185. }
  186. #endregion
  187. public void SetStuNumMax(string keyValue, int entityStuNumMax)
  188. {
  189. var db = this.BaseRepository("CollegeMIS");
  190. try
  191. {
  192. db.BeginTrans();
  193. var datetimenow = DateTime.Now;
  194. var loginuserinfo = LoginUserInfo.Get();
  195. var olpl = db.FindList<OpenLessonPlanOfElectiveEntity>(@"select c.id from ElectiveMerge a left join
  196. ElectiveMergeItem b
  197. on a.EMId = b.EmId left join OpenLessonPlanOfElective c
  198. on b.OLPOEId = c.Id where a.EMId = '" + keyValue + "'");
  199. foreach (var opitem in olpl)
  200. {
  201. opitem.StuNumMax = entityStuNumMax;
  202. opitem.ModifyTime = datetimenow;
  203. opitem.ModifyUserId = loginuserinfo.userId;
  204. opitem.ModifyUserName = loginuserinfo.realName;
  205. db.Update(opitem);
  206. }
  207. db.Commit();
  208. }
  209. catch (Exception ex)
  210. {
  211. db.Rollback();
  212. if (ex is ExceptionEx)
  213. {
  214. throw;
  215. }
  216. else
  217. {
  218. throw ExceptionEx.ThrowServiceException(ex);
  219. }
  220. }
  221. }
  222. }
  223. }