using Dapper; using Learun.DataBase.Repository; using Learun.Util; using System; using System.Collections.Generic; using System.Data; using System.Text; namespace Learun.Application.TwoDevelopment.EducationalAdministration { /// /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架 /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司 /// 创 建:超级管理员 /// 日 期:2023-03-13 10:37 /// 描 述:定制功能助学金 /// public class StuFellowshipService : RepositoryFactory { #region 获取数据 /// /// 获取列表数据 /// /// 条件参数 /// public IEnumerable GetList(string queryJson) { try { //参考写法 //var queryParam = queryJson.ToJObject(); // 虚拟参数 //var dp = new DynamicParameters(new { }); //dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime); var strSql = new StringBuilder(); strSql.Append("SELECT t.*"); strSql.Append(" FROM StuFellowship t "); var queryParam = queryJson.ToJObject(); // 虚拟参数 var dp = new DynamicParameters(new { }); return this.BaseRepository("CollegeMIS").FindList(strSql.ToString(), dp); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } /// /// 获取列表分页数据 /// /// 分页参数 /// 条件参数 /// public IEnumerable GetPageList(Pagination pagination, string queryJson) { try { var strSql = new StringBuilder(); strSql.Append("SELECT t.*,s.StuName,s.DeptNo,s.ClassNo,s.IdentityCardNo,s.IdCardType,s.DepositBank as OpenBank,s.BankCard as OpenAccount "); strSql.Append(" FROM StuFellowship t "); strSql.Append(" left join StuInfoBasic s on t.StuNo=s.StuNo "); strSql.Append(" left join ClassInfo c on t.CreateUserNo=c.ClassTutorNo and s.ClassNo=c.ClassNo "); strSql.Append(" left join CdDept d on c.DeptNo=d.DeptNo "); strSql.Append(" where 1=1 "); var queryParam = queryJson.ToJObject(); // 虚拟参数 var dp = new DynamicParameters(new { }); if (!queryParam["Types"].IsEmpty())//助学金类型:1国家助学金,2校级助学金 { dp.Add("Types", queryParam["Types"].ToString(), DbType.String); strSql.Append(" AND t.Types=@Types "); } if (!queryParam["StuNo"].IsEmpty()) { dp.Add("StuNo", "%" + queryParam["StuNo"].ToString() + "%", DbType.String); strSql.Append(" AND t.StuNo Like @StuNo "); } if (!queryParam["StuName"].IsEmpty()) { dp.Add("StuName", "%" + queryParam["StuName"].ToString() + "%", DbType.String); strSql.Append(" AND s.StuName Like @StuName "); } if (!queryParam["DeptNo"].IsEmpty()) { dp.Add("DeptNo", queryParam["DeptNo"].ToString(), DbType.String); strSql.Append(" AND s.DeptNo=@DeptNo "); } if (!queryParam["ClassNo"].IsEmpty()) { dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String); strSql.Append(" AND s.ClassNo=@ClassNo "); } if (!queryParam["IdentityCardNo"].IsEmpty()) { dp.Add("IdentityCardNo", "%" + queryParam["IdentityCardNo"].ToString() + "%", DbType.String); strSql.Append(" AND s.IdentityCardNo like @IdentityCardNo "); } if (!queryParam["SubsidizeType"].IsEmpty()) { dp.Add("SubsidizeType", queryParam["SubsidizeType"].ToString(), DbType.String); strSql.Append(" AND t.SubsidizeType=@SubsidizeType "); } if (!queryParam["OpenBankNo"].IsEmpty()) { dp.Add("OpenBankNo", "%" + queryParam["OpenBankNo"].ToString() + "%", DbType.String); strSql.Append(" AND t.OpenBankNo Like @OpenBankNo "); } if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty()) { dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime); dp.Add("endTime", queryParam["EndTime"].ToDate(), DbType.DateTime); strSql.Append(" AND ( t.ApplyDate >= @startTime AND t.ApplyDate <= @endTime ) "); } if (!queryParam["StartTimeRelease"].IsEmpty() && !queryParam["EndTimeRelease"].IsEmpty()) { dp.Add("StartTimeRelease", queryParam["StartTimeRelease"].ToDate(), DbType.DateTime); dp.Add("EndTimeRelease", queryParam["EndTimeRelease"].ToDate(), DbType.DateTime); strSql.Append(" AND ( t.ReleaseDate >= @StartTimeRelease AND t.ReleaseDate <= @EndTimeRelease ) "); } if (!queryParam["Step"].IsEmpty() && queryParam["Step"].ToString() == "2")//第二步:二级学院审核 { //不查看状态为草稿的记录 strSql.Append(" AND t.Status > 0 "); //二级学院审核专员==系部的资助审核人==登录用户,系统管理员除外 if (LoginUserInfo.Get().account.ToLower() != "system") { strSql.Append($" and d.DeptSubsidizer='{LoginUserInfo.Get().account}' "); } } if (!queryParam["Step"].IsEmpty() && queryParam["Step"].ToString() == "3")//第三步:学工部审核 { //不查看状态为草稿的记录 strSql.Append(" AND t.Status > 1 "); } if (!queryParam["Status"].IsEmpty()) { dp.Add("Status", queryParam["Status"].ToString(), DbType.String); strSql.Append(" AND t.Status = @Status "); } if (!queryParam["CreateUserNo"].IsEmpty()) { dp.Add("CreateUserNo", queryParam["CreateUserNo"].ToString(), DbType.String); strSql.Append(" AND t.CreateUserNo = @CreateUserNo "); } return this.BaseRepository("CollegeMIS").FindList(strSql.ToString(), dp, pagination); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } /// /// 获取实体数据 /// /// 主键 /// public StuFellowshipEntity GetEntity(string keyValue) { try { var strsql = $"select t.*,s.StuName,s.DeptNo,s.ClassNo,s.IdentityCardNo,s.IdCardType,s.DepositBank as OpenBank,s.BankCard as OpenAccount from StuFellowship t left join StuInfoBasic s on t.StuNo=s.StuNo where 1=1 and t.ID='{keyValue}' "; return this.BaseRepository("CollegeMIS").FindEntity(strsql, null); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } #endregion #region 提交数据 /// /// 删除实体数据 /// /// 主键 public void DeleteEntity(string keyValue) { try { this.BaseRepository("CollegeMIS").Delete(t => t.ID == keyValue); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } /// /// 保存实体数据(新增、修改) /// 主键 /// 实体 /// public void SaveEntity(string keyValue, StuFellowshipEntity 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); } } } /// /// 提交 /// /// 主键 public void DoSubmit(string keyValue, string status, string step) { try { if (step == "1")//第一步:提交二级学院审核 { this.BaseRepository("CollegeMIS").ExecuteBySql($"update StuFellowship set SubmitTime='{DateTime.Now}',SubmitUserId='{LoginUserInfo.Get().userId}',Status='{status}' where Id='{keyValue}' "); } else if (step == "2")//第二步:提交学工部审核 { this.BaseRepository("CollegeMIS").ExecuteBySql($"update StuFellowship set FirstCheckTime='{DateTime.Now}',FirstCheckUserId='{LoginUserInfo.Get().userId}',Status='{status}' where Id='{keyValue}' "); } else if (step == "3")//第三步:归档 { this.BaseRepository("CollegeMIS").ExecuteBySql($"update StuFellowship set SecondCheckTime='{DateTime.Now}',SecondCheckUserId='{LoginUserInfo.Get().userId}',Status='{status}' where Id='{keyValue}' "); } } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } /// /// 退回 /// /// 主键 public void DoBack(string keyValue, string status, string step) { try { if (step == "2")//第二步:退回辅导员 { this.BaseRepository("CollegeMIS").ExecuteBySql($"update StuFellowship set FirstCheckTime='{DateTime.Now}',FirstCheckUserId='{LoginUserInfo.Get().userId}',Status='{status}' where Id='{keyValue}' "); } else if (step == "3")//第三步:退回辅导员、退回二级学院、取消归档 { this.BaseRepository("CollegeMIS").ExecuteBySql($"update StuFellowship set SecondCheckTime='{DateTime.Now}',SecondCheckUserId='{LoginUserInfo.Get().userId}',Status='{status}' where Id='{keyValue}' "); } } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } #endregion } }