|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496 |
- using Dapper;
- using Learun.Application.Organization;
- using Learun.DataBase.Repository;
- using Learun.Util;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Text;
-
- namespace Learun.Application.TwoDevelopment.EducationalAdministration
- {
- /// <summary>
- /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
- /// Copyright (c) 2013-2018 北京泉江科技有限公司
- /// 创 建:超级管理员
- /// 日 期:2019-10-28 11:48
- /// 描 述:学籍异动
- /// </summary>
- public class StuInfoBasicChangeService : RepositoryFactory
- {
- #region 获取数据
-
- /// <summary>
- /// 获取页面显示列表数据
- /// <summary>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- public IEnumerable<StuInfoBasicChangeEntity> GetPageList(Pagination pagination, string queryJson)
- {
- try
- {
- var strSql = new StringBuilder();
- strSql.Append("SELECT t.* FROM StuInfoBasicChange t ");
- strSql.Append(" WHERE 1=1 ");
- var queryParam = queryJson.ToJObject();
- // 虚拟参数
- var dp = new DynamicParameters(new { });
- if (!queryParam["StuName"].IsEmpty())
- {
- dp.Add("StuName", "%" + queryParam["StuName"].ToString() + "%", DbType.String);
- strSql.Append(" AND t.StuName Like @StuName ");
- }
- return this.BaseRepository("CollegeMIS").FindList<StuInfoBasicChangeEntity>(strSql.ToString(), dp, pagination);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取StuInfoBasicChange表实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public StuInfoBasicChangeEntity GetStuInfoBasicChangeEntity(string keyValue)
- {
- try
- {
- return this.BaseRepository("CollegeMIS").FindEntity<StuInfoBasicChangeEntity>(keyValue);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- #endregion
-
- #region 提交数据
-
- /// <summary>
- /// 删除实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public void DeleteEntity(string keyValue)
- {
- try
- {
- this.BaseRepository("CollegeMIS").Delete<StuInfoBasicChangeEntity>(t => t.Id == keyValue);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public void SaveEntity(string keyValue, StuInfoBasicChangeEntity entity)
- {
- try
- {
- if (!string.IsNullOrEmpty(keyValue))
- {
- entity.Modify(keyValue);
- this.BaseRepository("CollegeMIS").Update(entity);
- }
- else
- {
- entity.Create();
- this.BaseRepository("CollegeMIS").Insert(entity);
- }
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 审核实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public void DoCheck(string keyValue)
- {
- var db = this.BaseRepository("CollegeMIS").BeginTrans();
- var dbbase = this.BaseRepository().BeginTrans();
- try
- {
- var loginUserInfo = LoginUserInfo.Get();
- var now = DateTime.Now;
- var logList = new List<StuInfoBasic_ChangeLogEntity>();
- var entity = this.BaseRepository("CollegeMIS").FindEntity<StuInfoBasicChangeEntity>(x => x.Id == keyValue);
- if (entity != null)
- {
- var stuInfoBasicEntity = this.BaseRepository("CollegeMIS").FindEntity<StuInfoBasicEntity>(x => x.StuNo == entity.StuNo);
- if (stuInfoBasicEntity != null)
- {
- //处理数据
- if (entity.StuChangeType == "01" || entity.StuChangeType == "07") //降级、转班、
- {
- if (stuInfoBasicEntity.ClassNo != entity.NewClassNo)
- {
- var classInfoEntity = db.FindEntity<ClassInfoEntity>(x => x.ClassNo == entity.NewClassNo);
- if (classInfoEntity != null)
- {
- if (stuInfoBasicEntity.Grade != classInfoEntity.Grade)
- {
- //增加异动日志表:年级
- var logentity2 = new StuInfoBasic_ChangeLogEntity()
- {
- FieldName = "年级",
- BeforeChange = stuInfoBasicEntity.Grade,
- AfterChange = classInfoEntity.Grade,
- UpdateBy = loginUserInfo.userId,
- UpdateTime = now,
- StuID = stuInfoBasicEntity.StuId,
- StuChangeType = entity.StuChangeType,
- StuChangeRemark = entity.StuChangeRemark,
- StuChangeId = entity.Id
- };
- logentity2.Create();
- logList.Add(logentity2);
- }
- //改学籍信息表;
- db.ExecuteBySql($"update StuInfoBasic set ClassNo='{entity.NewClassNo}',Grade='{classInfoEntity.Grade}' where StuNo='{entity.StuNo}' ");
- //增加异动日志表:班级
- var logentity = new StuInfoBasic_ChangeLogEntity()
- {
- FieldName = "班级",
- BeforeChange = entity.ClassNo,
- AfterChange = entity.NewClassNo,
- UpdateBy = loginUserInfo.userId,
- UpdateTime = now,
- StuID = stuInfoBasicEntity.StuId,
- StuChangeType = entity.StuChangeType,
- StuChangeRemark = entity.StuChangeRemark,
- StuChangeId = entity.Id
- };
- logentity.Create();
- logList.Add(logentity);
- }
- }
-
- }
- else if (entity.StuChangeType == "02" || entity.StuChangeType == "05" || entity.StuChangeType == "06") //转校、退学、休学、
- {
- //增加异动日志表:学籍id被删除
- var logentity = new StuInfoBasic_ChangeLogEntity()
- {
- FieldName = "学籍表主键",
- BeforeChange = stuInfoBasicEntity.StuId,
- AfterChange = null,
- UpdateBy = loginUserInfo.userId,
- UpdateTime = now,
- StuID = stuInfoBasicEntity.StuId,
- StuChangeType = entity.StuChangeType,
- StuChangeRemark = entity.StuChangeRemark,
- StuChangeId = entity.Id
- };
- logentity.Create();
- logList.Add(logentity);
- //增加退学表
- db.ExecuteBySql($"insert into StuInfoDrop select * from StuInfoBasic where StuId='{stuInfoBasicEntity.StuId}' ");
- //修改异动表:退学表id
- entity.StuIdInDrop = stuInfoBasicEntity.StuId;
- //删除学籍表
- db.ExecuteBySql($"delete from StuInfoBasic where StuId='{stuInfoBasicEntity.StuId}' ");
- //删除账户表
- var userEntity = this.BaseRepository().FindEntity<UserEntity>(x => x.F_Account == stuInfoBasicEntity.StuNo);
- if (userEntity != null)
- {
- dbbase.Delete(userEntity);
- }
-
- }
- else if (entity.StuChangeType == "08") //转专业、
- {
- if (stuInfoBasicEntity.MajorNo != entity.NewMajorNo)
- {
- var classInfoEntity2 = db.FindEntity<ClassInfoEntity>(x => x.ClassNo == entity.NewClassNo);
- if (classInfoEntity2 != null)
- {
- if (stuInfoBasicEntity.Grade != classInfoEntity2.Grade)
- {
- //增加异动日志表:年级
- var logentity3 = new StuInfoBasic_ChangeLogEntity()
- {
- FieldName = "年级",
- BeforeChange = stuInfoBasicEntity.Grade,
- AfterChange = classInfoEntity2.Grade,
- UpdateBy = loginUserInfo.userId,
- UpdateTime = now,
- StuID = stuInfoBasicEntity.StuId,
- StuChangeType = entity.StuChangeType,
- StuChangeRemark = entity.StuChangeRemark,
- StuChangeId = entity.Id
- };
- logentity3.Create();
- logList.Add(logentity3);
- }
- //改学籍信息;
- db.ExecuteBySql($"update StuInfoBasic set MajorNo='{entity.NewMajorNo}',ClassNo='{entity.NewClassNo}',Grade='{classInfoEntity2.Grade}' where StuNo='{entity.StuNo}' ");
- //增加异动日志表:专业
- var logentity = new StuInfoBasic_ChangeLogEntity()
- {
- FieldName = "专业",
- BeforeChange = entity.MajorNo,
- AfterChange = entity.NewMajorNo,
- UpdateBy = loginUserInfo.userId,
- UpdateTime = now,
- StuID = stuInfoBasicEntity.StuId,
- StuChangeType = entity.StuChangeType,
- StuChangeRemark = entity.StuChangeRemark,
- StuChangeId = entity.Id
- };
- logentity.Create();
- logList.Add(logentity);
- //增加异动日志表:班级
- var logentity2 = new StuInfoBasic_ChangeLogEntity()
- {
- FieldName = "班级",
- BeforeChange = entity.ClassNo,
- AfterChange = entity.NewClassNo,
- UpdateBy = loginUserInfo.userId,
- UpdateTime = now,
- StuID = stuInfoBasicEntity.StuId,
- StuChangeType = entity.StuChangeType,
- StuChangeRemark = entity.StuChangeRemark,
- StuChangeId = entity.Id
- };
- logentity2.Create();
- logList.Add(logentity2);
- }
- }
- else
- {
- if (stuInfoBasicEntity.ClassNo != entity.NewClassNo)
- {
- var classInfoEntity2 = db.FindEntity<ClassInfoEntity>(x => x.ClassNo == entity.NewClassNo);
- if (classInfoEntity2 != null)
- {
- if (stuInfoBasicEntity.Grade != classInfoEntity2.Grade)
- {
- //增加异动日志表:年级
- var logentity2 = new StuInfoBasic_ChangeLogEntity()
- {
- FieldName = "年级",
- BeforeChange = stuInfoBasicEntity.Grade,
- AfterChange = classInfoEntity2.Grade,
- UpdateBy = loginUserInfo.userId,
- UpdateTime = now,
- StuID = stuInfoBasicEntity.StuId,
- StuChangeType = entity.StuChangeType,
- StuChangeRemark = entity.StuChangeRemark,
- StuChangeId = entity.Id
- };
- logentity2.Create();
- logList.Add(logentity2);
- }
- //改学籍信息表;
- db.ExecuteBySql($"update StuInfoBasic set MajorNo='{entity.NewMajorNo}',ClassNo='{entity.NewClassNo}',Grade='{classInfoEntity2.Grade}' where StuNo='{entity.StuNo}' ");
- //增加异动日志表:班级
- var logentity = new StuInfoBasic_ChangeLogEntity()
- {
- FieldName = "班级",
- BeforeChange = entity.ClassNo,
- AfterChange = entity.NewClassNo,
- UpdateBy = loginUserInfo.userId,
- UpdateTime = now,
- StuID = stuInfoBasicEntity.StuId,
- StuChangeType = entity.StuChangeType,
- StuChangeRemark = entity.StuChangeRemark,
- StuChangeId = entity.Id
- };
- logentity.Create();
- logList.Add(logentity);
- }
- }
- }
- }
-
- db.Insert(logList);
-
- //修改异动表:审批状态、审批人、
- entity.CheckTime = now;
- entity.CheckUserId = loginUserInfo.userId;
- entity.CheckStatus = 1;
- db.Update(entity);
- }
- }
- db.Commit();
- dbbase.Commit();
- }
- catch (Exception ex)
- {
- db.Rollback();
- dbbase.Rollback();
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 去审核实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public void DoUnCheck(string keyValue)
- {
- var db = this.BaseRepository("CollegeMIS").BeginTrans();
- try
- {
- var entity = db.FindEntity<StuInfoBasicChangeEntity>(x => x.Id == keyValue);
- if (entity != null)
- {
- //处理数据
- if (entity.StuChangeType == "01" || entity.StuChangeType == "07" || entity.StuChangeType == "08") //降级、转班、转专业、
- {
- //改学籍信息;
- var classInfoEntity = db.FindEntity<ClassInfoEntity>(x => x.ClassNo == entity.ClassNo);
- if (classInfoEntity != null)
- {
- db.ExecuteBySql($"update StuInfoBasic set DeptNo='{entity.DeptNo}',MajorNo='{entity.MajorNo}',ClassNo='{entity.ClassNo}',Grade='{classInfoEntity.Grade}' where StuNo='{entity.StuNo}' ");
- }
- }
- else if (entity.StuChangeType == "02" || entity.StuChangeType == "05" || entity.StuChangeType == "06") //转校、退学、休学
- {
- //增加学籍表
- db.ExecuteBySql($"insert into StuInfoBasic select * from StuInfoDrop where StuId='{entity.StuIdInDrop}' ");
- //删除退学表
- db.ExecuteBySql($"delete from StuInfoDrop where StuId='{entity.StuIdInDrop}' ");
- //修改异动表:退学表id 为空
-
- }
-
- //修改异动表:审批状态、审批人、
- db.ExecuteBySql($"update StuInfoBasicChange set CheckTime=null,CheckUserId=null,CheckStatus=0,StuIdInDrop=null where Id='" + keyValue + "' ");
- //删除异动日志表:学籍异动主键id
- db.ExecuteBySql("delete from StuInfoBasic_ChangeLog where StuChangeId='" + keyValue + "' ");
-
- }
- db.Commit();
- }
- catch (Exception ex)
- {
- db.Rollback();
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 复学
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public void DoGoBack(string keyValue)
- {
- var db = this.BaseRepository("CollegeMIS").BeginTrans();
- try
- {
- var loginUserInfo = LoginUserInfo.Get();
- var now = DateTime.Now;
- var logList = new List<StuInfoBasic_ChangeLogEntity>();
- var entity = this.BaseRepository("CollegeMIS").FindEntity<StuInfoBasicChangeEntity>(x => x.Id == keyValue);
- if (entity != null)
- {
- var stuInfoDropEntity = this.BaseRepository("CollegeMIS").FindEntity<StuInfoDropEntity>(x => x.StuId == entity.StuIdInDrop);
- if (stuInfoDropEntity != null)
- {
- //增加异动日志表:学籍id增加
- var logentity = new StuInfoBasic_ChangeLogEntity()
- {
- FieldName = "学籍表主键",
- BeforeChange = null,
- AfterChange = stuInfoDropEntity.StuId,
- UpdateBy = loginUserInfo.userId,
- UpdateTime = now,
- StuID = stuInfoDropEntity.StuId,
- StuChangeType = "03",
- StuChangeRemark = "复学",
- StuChangeId = entity.Id
- };
- logentity.Create();
- logList.Add(logentity);
- //增加学籍表
- db.ExecuteBySql($"insert into StuInfoBasic select * from StuInfoDrop where StuId='{entity.StuIdInDrop}' ");
- //删除退学表
- db.ExecuteBySql($"delete from StuInfoDrop where StuId='{entity.StuIdInDrop}' ");
-
- //修改异动表:复学状态、复学时间、
- entity.GoBackStatus = 1;
- entity.GoBackTime = now;
- db.Update(entity);
-
- db.Insert(logList);
-
- }
- }
- db.Commit();
- }
- catch (Exception ex)
- {
- db.Rollback();
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowBusinessException(ex);
- }
- }
- }
-
- #endregion
-
- }
- }
|