You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

StuAttendanceLeaveService.cs 12 KiB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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-05-24 15:40
  16. /// 描 述:学生请假记录
  17. /// </summary>
  18. public class StuAttendanceLeaveService : RepositoryFactory
  19. {
  20. #region 获取数据
  21. /// <summary>
  22. /// 获取页面显示列表数据
  23. /// <summary>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<StuAttendanceLeaveEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT ");
  32. strSql.Append(@"
  33. t.ID,
  34. t.AcademicYearNo,
  35. t.Semester,
  36. t.StuNo,
  37. t.StuName,
  38. t.Grade,
  39. t.DeptNo,
  40. t.DeptName,
  41. t.MajorNo,
  42. t.MajorName,
  43. t.ClassNo,
  44. t.ClassName,
  45. t.LessonNo,
  46. t.LessonName,
  47. t.TeachClassNo,
  48. t.LessonSortNo,
  49. t.LessonSortName,
  50. t.LessonDate,
  51. t.LessonTime,
  52. t.LeaveType,
  53. t.EmpNo,
  54. t.Remark,
  55. t.IsCheck,
  56. t.TecRemark
  57. ");
  58. strSql.Append(" FROM StuAttendanceLeave t ");
  59. strSql.Append(" WHERE 1=1 ");
  60. var queryParam = queryJson.ToJObject();
  61. // 虚拟参数
  62. var dp = new DynamicParameters(new { });
  63. if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty())
  64. {
  65. dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
  66. dp.Add("endTime", queryParam["EndTime"].ToDate(), DbType.DateTime);
  67. strSql.Append(" AND ( t.LessonDate >= @startTime AND t.LessonDate <= @endTime ) ");
  68. }
  69. if (!queryParam["LessonName"].IsEmpty())
  70. {
  71. dp.Add("LessonName", "%" + queryParam["LessonName"].ToString() + "%", DbType.String);
  72. strSql.Append(" AND t.LessonName Like @LessonName ");
  73. }
  74. if (!queryParam["Grade"].IsEmpty())
  75. {
  76. dp.Add("Grade", "%" + queryParam["Grade"].ToString() + "%", DbType.String);
  77. strSql.Append(" AND t.Grade Like @Grade ");
  78. }
  79. if (!queryParam["StuName"].IsEmpty())
  80. {
  81. dp.Add("StuName", "%" + queryParam["StuName"].ToString() + "%", DbType.String);
  82. strSql.Append(" AND t.StuName Like @StuName ");
  83. }
  84. if (!queryParam["EmpNo"].IsEmpty())
  85. {
  86. dp.Add("EmpNo", "%" + queryParam["EmpNo"].ToString() + "%", DbType.String);
  87. strSql.Append(" AND t.EmpNo Like @EmpNo ");
  88. }
  89. var result = this.BaseRepository("CollegeMIS").FindList<StuAttendanceLeaveEntity>(strSql.ToString(), dp, pagination);
  90. //var result = this.BaseRepository("CollegeMIS").FindList<StuAttendanceLeaveEntity>(strSql.ToString(), dp, pagination);
  91. //获取登录帐号
  92. var userInfo = LoginUserInfo.Get();
  93. //获取当前帐号所管理的班级
  94. var classes = this.BaseRepository("CollegeMIS").FindList<ClassInfoEntity>(a => a.ClassDiredctorNo == userInfo.account).Select(a => a.ClassNo);
  95. var list = result.Where(a => classes.Contains(a.ClassNo)).ToList();
  96. return list;
  97. //var stuSelectLessons = this.BaseRepository("CollegeMIS").FindList<StuSelectLessonListEntity>(a => a.EmpNo == userInfo.account).ToList();
  98. ////获取当前教师所教的课程
  99. //var lessons = stuSelectLessons.GroupBy(a => a.LessonNo).Select(a => a.Key).ToList();
  100. ////获取要上当前教师所教课程的学生
  101. //var students = stuSelectLessons.GroupBy(a => a.StuNo).Select(a => a.Key).ToList();
  102. //var list2 = result.Where(a => students.Contains(a.StuNo))
  103. // .Where(a => lessons.Contains(a.LessonNo)).ToList();
  104. //list.AddRange(list2);
  105. //return list.Distinct().ToList();
  106. }
  107. catch (Exception ex)
  108. {
  109. if (ex is ExceptionEx)
  110. {
  111. throw;
  112. }
  113. else
  114. {
  115. throw ExceptionEx.ThrowServiceException(ex);
  116. }
  117. }
  118. }
  119. /// <summary>
  120. /// 获取页面显示列表数据
  121. /// <summary>
  122. /// <param name="queryJson">查询参数</param>
  123. /// <returns></returns>
  124. public IEnumerable<StuAttendanceLeaveEntity> GetList(string queryJson)
  125. {
  126. try
  127. {
  128. var strSql = new StringBuilder();
  129. strSql.Append("SELECT ");
  130. strSql.Append(@"
  131. t.ID,
  132. t.AcademicYearNo,
  133. t.Semester,
  134. t.StuNo,
  135. t.StuName,
  136. t.Grade,
  137. t.DeptNo,
  138. t.DeptName,
  139. t.MajorNo,
  140. t.MajorName,
  141. t.ClassNo
  142. ");
  143. strSql.Append(" FROM StuAttendanceLeave t ");
  144. strSql.Append(" WHERE 1=1 ");
  145. var queryParam = queryJson.ToJObject();
  146. // 虚拟参数
  147. var dp = new DynamicParameters(new { });
  148. var result = this.BaseRepository("CollegeMIS").FindList<StuAttendanceLeaveEntity>(strSql.ToString(), dp);
  149. //获取登录帐号
  150. var userInfo = LoginUserInfo.Get();
  151. //获取当前帐号所管理的班级
  152. var classes = this.BaseRepository("CollegeMIS").FindList<ClassInfoEntity>(a => a.ClassDiredctorNo == userInfo.account).Select(a => a.ClassNo);
  153. var list = result.Where(a => classes.Contains(a.ClassNo)).ToList();
  154. return list;
  155. }
  156. catch (Exception ex)
  157. {
  158. if (ex is ExceptionEx)
  159. {
  160. throw;
  161. }
  162. else
  163. {
  164. throw ExceptionEx.ThrowServiceException(ex);
  165. }
  166. }
  167. }
  168. internal void Check(string keyValue, string checkValue)
  169. {
  170. try
  171. {
  172. var entity = this.BaseRepository("CollegeMIS").FindEntity<StuAttendanceLeaveEntity>(a => a.ID == keyValue);
  173. if (null != entity)
  174. {
  175. entity.IsCheck = checkValue;
  176. }
  177. entity.Modify(keyValue);
  178. }
  179. catch (Exception ex)
  180. {
  181. if (ex is ExceptionEx)
  182. {
  183. throw;
  184. }
  185. else
  186. {
  187. throw ExceptionEx.ThrowServiceException(ex);
  188. }
  189. }
  190. }
  191. public List<StuAttendanceLeaveEntity> GetList()
  192. {
  193. try
  194. {
  195. return this.BaseRepository("CollegeMIS").FindList<StuAttendanceLeaveEntity>().ToList();
  196. }
  197. catch (Exception ex)
  198. {
  199. if (ex is ExceptionEx)
  200. {
  201. throw;
  202. }
  203. else
  204. {
  205. throw ExceptionEx.ThrowServiceException(ex);
  206. }
  207. }
  208. }
  209. /// <summary>
  210. /// 获取StuAttendanceLeave表实体数据
  211. /// <param name="keyValue">主键</param>
  212. /// <summary>
  213. /// <returns></returns>
  214. public StuAttendanceLeaveEntity GetStuAttendanceLeaveEntity(string keyValue)
  215. {
  216. try
  217. {
  218. return this.BaseRepository("CollegeMIS").FindEntity<StuAttendanceLeaveEntity>(keyValue);
  219. }
  220. catch (Exception ex)
  221. {
  222. if (ex is ExceptionEx)
  223. {
  224. throw;
  225. }
  226. else
  227. {
  228. throw ExceptionEx.ThrowServiceException(ex);
  229. }
  230. }
  231. }
  232. #endregion
  233. #region 提交数据
  234. /// <summary>
  235. /// 删除实体数据
  236. /// <param name="keyValue">主键</param>
  237. /// <summary>
  238. /// <returns></returns>
  239. public void DeleteEntity(string keyValue)
  240. {
  241. try
  242. {
  243. this.BaseRepository("CollegeMIS").Delete<StuAttendanceLeaveEntity>(t => t.ID == keyValue);
  244. }
  245. catch (Exception ex)
  246. {
  247. if (ex is ExceptionEx)
  248. {
  249. throw;
  250. }
  251. else
  252. {
  253. throw ExceptionEx.ThrowServiceException(ex);
  254. }
  255. }
  256. }
  257. /// <summary>
  258. /// 保存实体数据(新增、修改)
  259. /// <param name="keyValue">主键</param>
  260. /// <summary>
  261. /// <returns></returns>
  262. public void SaveEntity(string keyValue, StuAttendanceLeaveEntity entity)
  263. {
  264. try
  265. {
  266. entity.UpdateDate = DateTime.Now;
  267. if (!string.IsNullOrEmpty(keyValue))
  268. {
  269. entity.Modify(keyValue);
  270. this.BaseRepository("CollegeMIS").Update(entity);
  271. }
  272. else
  273. {
  274. entity.Create();
  275. this.BaseRepository("CollegeMIS").Insert(entity);
  276. }
  277. }
  278. catch (Exception ex)
  279. {
  280. if (ex is ExceptionEx)
  281. {
  282. throw;
  283. }
  284. else
  285. {
  286. throw ExceptionEx.ThrowServiceException(ex);
  287. }
  288. }
  289. }
  290. /// <summary>
  291. /// 保存实体数据(新增、修改)
  292. /// <param name="keyValue">主键</param>
  293. /// <summary>
  294. /// <returns></returns>
  295. public void SaveEntity(UserInfo userInfo, string keyValue, StuAttendanceLeaveEntity entity)
  296. {
  297. try
  298. {
  299. if (!string.IsNullOrEmpty(keyValue))
  300. {
  301. entity.Modify(keyValue, userInfo);
  302. this.BaseRepository("CollegeMIS").Update(entity);
  303. }
  304. else
  305. {
  306. entity.Create(userInfo);
  307. this.BaseRepository("CollegeMIS").Insert(entity);
  308. }
  309. }
  310. catch (Exception ex)
  311. {
  312. if (ex is ExceptionEx)
  313. {
  314. throw;
  315. }
  316. else
  317. {
  318. throw ExceptionEx.ThrowServiceException(ex);
  319. }
  320. }
  321. }
  322. #endregion
  323. }
  324. }