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.
 
 
 
 
 
 

437 lines
21 KiB

  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.Text;
  8. namespace Learun.Application.TwoDevelopment.EducationalAdministration
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  12. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2019-10-28 11:48
  15. /// 描 述:学籍异动
  16. /// </summary>
  17. public class StuInfoBasicChangeService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<StuInfoBasicChangeEntity> GetPageList(Pagination pagination, string queryJson)
  26. {
  27. try
  28. {
  29. var strSql = new StringBuilder();
  30. strSql.Append("SELECT t.* FROM StuInfoBasicChange t ");
  31. strSql.Append(" WHERE 1=1 ");
  32. var queryParam = queryJson.ToJObject();
  33. // 虚拟参数
  34. var dp = new DynamicParameters(new { });
  35. if (!queryParam["StuName"].IsEmpty())
  36. {
  37. dp.Add("StuName", "%" + queryParam["StuName"].ToString() + "%", DbType.String);
  38. strSql.Append(" AND t.StuName Like @StuName ");
  39. }
  40. return this.BaseRepository("CollegeMIS").FindList<StuInfoBasicChangeEntity>(strSql.ToString(), dp, pagination);
  41. }
  42. catch (Exception ex)
  43. {
  44. if (ex is ExceptionEx)
  45. {
  46. throw;
  47. }
  48. else
  49. {
  50. throw ExceptionEx.ThrowServiceException(ex);
  51. }
  52. }
  53. }
  54. /// <summary>
  55. /// 获取StuInfoBasicChange表实体数据
  56. /// <param name="keyValue">主键</param>
  57. /// <summary>
  58. /// <returns></returns>
  59. public StuInfoBasicChangeEntity GetStuInfoBasicChangeEntity(string keyValue)
  60. {
  61. try
  62. {
  63. return this.BaseRepository("CollegeMIS").FindEntity<StuInfoBasicChangeEntity>(keyValue);
  64. }
  65. catch (Exception ex)
  66. {
  67. if (ex is ExceptionEx)
  68. {
  69. throw;
  70. }
  71. else
  72. {
  73. throw ExceptionEx.ThrowServiceException(ex);
  74. }
  75. }
  76. }
  77. #endregion
  78. #region 提交数据
  79. /// <summary>
  80. /// 删除实体数据
  81. /// <param name="keyValue">主键</param>
  82. /// <summary>
  83. /// <returns></returns>
  84. public void DeleteEntity(string keyValue)
  85. {
  86. try
  87. {
  88. this.BaseRepository("CollegeMIS").Delete<StuInfoBasicChangeEntity>(t => t.Id == keyValue);
  89. }
  90. catch (Exception ex)
  91. {
  92. if (ex is ExceptionEx)
  93. {
  94. throw;
  95. }
  96. else
  97. {
  98. throw ExceptionEx.ThrowServiceException(ex);
  99. }
  100. }
  101. }
  102. /// <summary>
  103. /// 保存实体数据(新增、修改)
  104. /// <param name="keyValue">主键</param>
  105. /// <summary>
  106. /// <returns></returns>
  107. public void SaveEntity(string keyValue, StuInfoBasicChangeEntity entity)
  108. {
  109. try
  110. {
  111. if (!string.IsNullOrEmpty(keyValue))
  112. {
  113. entity.Modify(keyValue);
  114. this.BaseRepository("CollegeMIS").Update(entity);
  115. }
  116. else
  117. {
  118. entity.Create();
  119. this.BaseRepository("CollegeMIS").Insert(entity);
  120. }
  121. }
  122. catch (Exception ex)
  123. {
  124. if (ex is ExceptionEx)
  125. {
  126. throw;
  127. }
  128. else
  129. {
  130. throw ExceptionEx.ThrowServiceException(ex);
  131. }
  132. }
  133. }
  134. /// <summary>
  135. /// 审核实体数据
  136. /// <param name="keyValue">主键</param>
  137. /// <summary>
  138. /// <returns></returns>
  139. public void DoCheck(string keyValue)
  140. {
  141. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  142. try
  143. {
  144. var loginUserInfo = LoginUserInfo.Get();
  145. var now = DateTime.Now;
  146. var logList = new List<StuInfoBasic_ChangeLogEntity>();
  147. var entity = db.FindEntity<StuInfoBasicChangeEntity>(x => x.Id == keyValue);
  148. if (entity != null)
  149. {
  150. var stuInfoBasicEntity = db.FindEntity<StuInfoBasicEntity>(x => x.StuNo == entity.StuNo);
  151. if (stuInfoBasicEntity != null)
  152. {
  153. //处理数据
  154. if (entity.StuChangeType == "01" || entity.StuChangeType == "07") //降级、转班、
  155. {
  156. if (stuInfoBasicEntity.ClassNo != entity.NewClassNo)
  157. {
  158. var classInfoEntity = db.FindEntity<ClassInfoEntity>(x => x.ClassNo == entity.NewClassNo);
  159. if (classInfoEntity != null)
  160. {
  161. if (stuInfoBasicEntity.Grade != classInfoEntity.Grade)
  162. {
  163. //增加异动日志表:年级
  164. var logentity2 = new StuInfoBasic_ChangeLogEntity()
  165. {
  166. FieldName = "年级",
  167. BeforeChange = stuInfoBasicEntity.Grade,
  168. AfterChange = classInfoEntity.Grade,
  169. UpdateBy = loginUserInfo.userId,
  170. UpdateTime = now,
  171. StuID = stuInfoBasicEntity.StuId,
  172. StuChangeType = entity.StuChangeType,
  173. StuChangeRemark = entity.StuChangeRemark,
  174. StuChangeId = entity.Id
  175. };
  176. logentity2.Create();
  177. logList.Add(logentity2);
  178. }
  179. //改学籍信息表;
  180. db.ExecuteBySql($"update StuInfoBasic set ClassNo='{entity.NewClassNo}',Grade='{classInfoEntity.Grade}' where StuNo='{entity.StuNo}' ");
  181. //增加异动日志表:班级
  182. var logentity = new StuInfoBasic_ChangeLogEntity()
  183. {
  184. FieldName = "班级",
  185. BeforeChange = entity.ClassNo,
  186. AfterChange = entity.NewClassNo,
  187. UpdateBy = loginUserInfo.userId,
  188. UpdateTime = now,
  189. StuID = stuInfoBasicEntity.StuId,
  190. StuChangeType = entity.StuChangeType,
  191. StuChangeRemark = entity.StuChangeRemark,
  192. StuChangeId = entity.Id
  193. };
  194. logentity.Create();
  195. logList.Add(logentity);
  196. }
  197. }
  198. }
  199. else if (entity.StuChangeType == "02" || entity.StuChangeType == "05" || entity.StuChangeType == "06") //转校、退学、休学、
  200. {
  201. //增加异动日志表:学籍异动状态
  202. var logentity = new StuInfoBasic_ChangeLogEntity()
  203. {
  204. FieldName = "学籍异动状态",
  205. BeforeChange = stuInfoBasicEntity.ChangeStatus?.ToString(),
  206. AfterChange = "1",
  207. UpdateBy = loginUserInfo.userId,
  208. UpdateTime = now,
  209. StuID = stuInfoBasicEntity.StuId,
  210. StuChangeType = entity.StuChangeType,
  211. StuChangeRemark = entity.StuChangeRemark,
  212. StuChangeId = entity.Id
  213. };
  214. logentity.Create();
  215. logList.Add(logentity);
  216. //改学籍信息(异动状态为1表示不显示成绩);
  217. db.ExecuteBySql($"update StuInfoBasic set ChangeStatus=1 where StuNo='{entity.StuNo}' ");
  218. }
  219. else if (entity.StuChangeType == "03") //复学
  220. {
  221. //增加异动日志表:学籍异动状态
  222. var logentity = new StuInfoBasic_ChangeLogEntity()
  223. {
  224. FieldName = "学籍异动状态",
  225. BeforeChange = stuInfoBasicEntity.ChangeStatus?.ToString(),
  226. AfterChange = "0",
  227. UpdateBy = loginUserInfo.userId,
  228. UpdateTime = now,
  229. StuID = stuInfoBasicEntity.StuId,
  230. StuChangeType = entity.StuChangeType,
  231. StuChangeRemark = entity.StuChangeRemark,
  232. StuChangeId = entity.Id
  233. };
  234. logentity.Create();
  235. logList.Add(logentity);
  236. //改学籍信息(异动状态为0表示显示成绩);
  237. db.ExecuteBySql($"update StuInfoBasic set ChangeStatus=null where StuNo='{entity.StuNo}' ");
  238. }
  239. else if (entity.StuChangeType == "08") //转专业、
  240. {
  241. if (stuInfoBasicEntity.MajorNo != entity.NewMajorNo)
  242. {
  243. var classInfoEntity2 = db.FindEntity<ClassInfoEntity>(x => x.ClassNo == entity.NewClassNo);
  244. if (classInfoEntity2 != null)
  245. {
  246. if (stuInfoBasicEntity.Grade != classInfoEntity2.Grade)
  247. {
  248. //增加异动日志表:年级
  249. var logentity3 = new StuInfoBasic_ChangeLogEntity()
  250. {
  251. FieldName = "年级",
  252. BeforeChange = stuInfoBasicEntity.Grade,
  253. AfterChange = classInfoEntity2.Grade,
  254. UpdateBy = loginUserInfo.userId,
  255. UpdateTime = now,
  256. StuID = stuInfoBasicEntity.StuId,
  257. StuChangeType = entity.StuChangeType,
  258. StuChangeRemark = entity.StuChangeRemark,
  259. StuChangeId = entity.Id
  260. };
  261. logentity3.Create();
  262. logList.Add(logentity3);
  263. }
  264. //改学籍信息;
  265. db.ExecuteBySql($"update StuInfoBasic set MajorNo='{entity.NewMajorNo}',ClassNo='{entity.NewClassNo}',Grade='{classInfoEntity2.Grade}' where StuNo='{entity.StuNo}' ");
  266. //增加异动日志表:专业
  267. var logentity = new StuInfoBasic_ChangeLogEntity()
  268. {
  269. FieldName = "专业",
  270. BeforeChange = entity.MajorNo,
  271. AfterChange = entity.NewMajorNo,
  272. UpdateBy = loginUserInfo.userId,
  273. UpdateTime = now,
  274. StuID = stuInfoBasicEntity.StuId,
  275. StuChangeType = entity.StuChangeType,
  276. StuChangeRemark = entity.StuChangeRemark,
  277. StuChangeId = entity.Id
  278. };
  279. logentity.Create();
  280. logList.Add(logentity);
  281. //增加异动日志表:班级
  282. var logentity2 = new StuInfoBasic_ChangeLogEntity()
  283. {
  284. FieldName = "班级",
  285. BeforeChange = entity.ClassNo,
  286. AfterChange = entity.NewClassNo,
  287. UpdateBy = loginUserInfo.userId,
  288. UpdateTime = now,
  289. StuID = stuInfoBasicEntity.StuId,
  290. StuChangeType = entity.StuChangeType,
  291. StuChangeRemark = entity.StuChangeRemark,
  292. StuChangeId = entity.Id
  293. };
  294. logentity2.Create();
  295. logList.Add(logentity2);
  296. }
  297. }
  298. else
  299. {
  300. if (stuInfoBasicEntity.ClassNo != entity.NewClassNo)
  301. {
  302. var classInfoEntity2 = db.FindEntity<ClassInfoEntity>(x => x.ClassNo == entity.NewClassNo);
  303. if (classInfoEntity2 != null)
  304. {
  305. if (stuInfoBasicEntity.Grade != classInfoEntity2.Grade)
  306. {
  307. //增加异动日志表:年级
  308. var logentity2 = new StuInfoBasic_ChangeLogEntity()
  309. {
  310. FieldName = "年级",
  311. BeforeChange = stuInfoBasicEntity.Grade,
  312. AfterChange = classInfoEntity2.Grade,
  313. UpdateBy = loginUserInfo.userId,
  314. UpdateTime = now,
  315. StuID = stuInfoBasicEntity.StuId,
  316. StuChangeType = entity.StuChangeType,
  317. StuChangeRemark = entity.StuChangeRemark,
  318. StuChangeId = entity.Id
  319. };
  320. logentity2.Create();
  321. logList.Add(logentity2);
  322. }
  323. //改学籍信息表;
  324. db.ExecuteBySql($"update StuInfoBasic set MajorNo='{entity.NewMajorNo}',ClassNo='{entity.NewClassNo}',Grade='{classInfoEntity2.Grade}' where StuNo='{entity.StuNo}' ");
  325. //增加异动日志表:班级
  326. var logentity = new StuInfoBasic_ChangeLogEntity()
  327. {
  328. FieldName = "班级",
  329. BeforeChange = entity.ClassNo,
  330. AfterChange = entity.NewClassNo,
  331. UpdateBy = loginUserInfo.userId,
  332. UpdateTime = now,
  333. StuID = stuInfoBasicEntity.StuId,
  334. StuChangeType = entity.StuChangeType,
  335. StuChangeRemark = entity.StuChangeRemark,
  336. StuChangeId = entity.Id
  337. };
  338. logentity.Create();
  339. logList.Add(logentity);
  340. }
  341. }
  342. }
  343. }
  344. db.Insert(logList);
  345. //修改异动表:审批状态、审批人、
  346. entity.CheckTime = now;
  347. entity.CheckUserId = loginUserInfo.userId;
  348. entity.CheckStatus = 1;
  349. db.Update(entity);
  350. }
  351. }
  352. db.Commit();
  353. }
  354. catch (Exception ex)
  355. {
  356. db.Rollback();
  357. if (ex is ExceptionEx)
  358. {
  359. throw;
  360. }
  361. else
  362. {
  363. throw ExceptionEx.ThrowServiceException(ex);
  364. }
  365. }
  366. }
  367. /// <summary>
  368. /// 去审核实体数据
  369. /// <param name="keyValue">主键</param>
  370. /// <summary>
  371. /// <returns></returns>
  372. public void DoUnCheck(string keyValue)
  373. {
  374. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  375. try
  376. {
  377. var entity = db.FindEntity<StuInfoBasicChangeEntity>(x => x.Id == keyValue);
  378. if (entity != null)
  379. {
  380. //处理数据
  381. if (entity.StuChangeType == "01" || entity.StuChangeType == "07" || entity.StuChangeType == "08") //降级、转班、转专业、
  382. {
  383. //改学籍信息;
  384. var classInfoEntity = db.FindEntity<ClassInfoEntity>(x => x.ClassNo == entity.ClassNo);
  385. if (classInfoEntity != null)
  386. {
  387. db.ExecuteBySql($"update StuInfoBasic set DeptNo='{entity.DeptNo}',MajorNo='{entity.MajorNo}',ClassNo='{entity.ClassNo}',Grade='{classInfoEntity.Grade}' where StuNo='{entity.StuNo}' ");
  388. }
  389. }
  390. else if (entity.StuChangeType == "02" || entity.StuChangeType == "05" || entity.StuChangeType == "06") //转校、退学、休学
  391. {
  392. //改学籍信息(异动状态为null表示显示成绩);
  393. db.ExecuteBySql($"update StuInfoBasic set ChangeStatus=null where StuNo='{entity.StuNo}' ");
  394. }
  395. else if (entity.StuChangeType == "03") //复学
  396. {
  397. //改学籍信息(异动状态为1表示不显示成绩);
  398. db.ExecuteBySql($"update StuInfoBasic set ChangeStatus=1 where StuNo='{entity.StuNo}' ");
  399. }
  400. //修改异动表:审批状态、审批人、
  401. db.ExecuteBySql("update StuInfoBasicChange set CheckTime=null,CheckUserId=null,CheckStatus=0 where Id='" + keyValue + "' ");
  402. //删除异动日志表:学籍异动主键id
  403. db.ExecuteBySql("delete from StuInfoBasic_ChangeLog where StuChangeId='" + keyValue + "' ");
  404. }
  405. db.Commit();
  406. }
  407. catch (Exception ex)
  408. {
  409. db.Rollback();
  410. if (ex is ExceptionEx)
  411. {
  412. throw;
  413. }
  414. else
  415. {
  416. throw ExceptionEx.ThrowServiceException(ex);
  417. }
  418. }
  419. }
  420. #endregion
  421. }
  422. }