|
- using Dapper;
- using Learun.Application.Base.AuthorizeModule;
- using Learun.Application.Base.SystemModule;
- using Learun.Application.Organization;
- using Learun.Application.TwoDevelopment.LogisticsManagement;
- using Learun.DataBase.Repository;
- using Learun.Util;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.IO;
- using System.Linq;
- using System.Text;
-
- namespace Learun.Application.TwoDevelopment.EducationalAdministration
- {
- /// <summary>
- /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
- /// Copyright (c) 2013-2018 北京泉江科技有限公司
- /// 创 建:超级管理员
- /// 日 期:2019-08-08 17:21
- /// 描 述:新生信息管理
- /// </summary>
- public class StuInfoFreshService : RepositoryFactory
- {
- #region 构造函数和属性
-
- private string fieldSql;
- public StuInfoFreshService()
- {
- fieldSql = @"
- t.ID,
- t.NoticeNo,
- t.ksh,
- t.zkzh,
- t.StuNo,
- t.StuName,
- t.DeptNo,
- t.GenderNo,
- t.MajorNo,
- t.MajorDetailNok,
- t.MajorDetailName,
- t.Birthday,
- t.PartyFaceNo,
- t.FamilyOriginNo,
- t.NationalityNo,
- t.ResidenceNo,
- t.TestStuSortNo,
- t.HealthStatusNo,
- t.WillNo,
- t.TestStuSubjectNo,
- t.GraduateNo,
- t.PlanFormNo,
- t.HighTestSortNo,
- t.HighAmountScore,
- t.PoliticsScore,
- t.ChineseScore,
- t.MathScore,
- t.PhysicsScore,
- t.ChemScore,
- t.BiologyScore,
- t.ForeignLangScore,
- t.ForeignLangOralScore,
- t.ComprehensiveScore,
- t.ForeignLangSpecies,
- t.IsThreeGood,
- t.IsExcellent,
- t.IsNormalCadre,
- t.IsProvinceFirstThree,
- t.OverseasChineseNo,
- t.MatriculateSort,
- t.ProvinceNo,
- t.HighSchoolNo,
- t.RegionNo,
- t.Remark,
- t.RecruitYearDate,
- t.ClassNo,
- t.IdentityCardNo,
- t.HighSchoolName,
- t.GoodAt,
- t.ArriveDate,
- t.ArchivesNo,
- t.telephone,
- t.FamilyAddress,
- t.RegisterStatus,
- t.MailAddress,
- t.PostalCode,
- t.TransMark,
- t.LogIp,
- t.LogNum,
- t.Logtime,
- t.RecruitDeptNo,
- t.RecruitMajorNo,
- t.RegisterEmpNo,
- t.RegisterEmpName,
- t.ApprovedLeader,
- t.ChangeReason,
- t.ChangeDate,
- t.TextNo,
- t.SignUpTime,
- t.OriginAddress,
- t.IsAccommodate,
- t.HeightWeight,
- t.CreateUserId,
- t.UpdateUserId,
- t.IsPayUniform,
- t.IsGetUniform,
- t.Grade
- ";
- }
- #endregion
-
- #region 获取数据
-
- /// <summary>
- /// 获取列表数据
- /// <summary>
- /// <returns></returns>
- public IEnumerable<StuInfoFreshEntity> GetList(string queryJson)
- {
- try
- {
- //参考写法
- var queryParam = queryJson.ToJObject();
- //虚拟参数
- var dp = new DynamicParameters(new { });
-
- var strSql = new StringBuilder();
- strSql.Append("SELECT t.*,d.DeptName,m.MajorName,c.ClassName,b.Name as Bed,r.Name as Room,f.Name as floor,u.Name as Unit,build.Name as Build ");
- strSql.Append(" FROM StuInfoFresh t ");
- strSql.Append(" left join CdDept d on t.DeptNo=d.DeptNo ");
- strSql.Append(" left join CdMajor m on t.MajorNo=m.MajorNo ");
- strSql.Append(" left join ClassInfo c on t.ClassNo=c.ClassNo ");
- strSql.Append(" left join Acc_DormitoryBuild b on t.DormitoryNo=b.ID ");
- strSql.Append(" left join Acc_DormitoryBuild r on b.ParentID=r.ID ");
- strSql.Append(" left join Acc_DormitoryBuild f on r.ParentID=f.ID ");
- strSql.Append(" left join Acc_DormitoryBuild u on f.ParentID=u.ID ");
- strSql.Append(" left join Acc_DormitoryBuild build on u.ParentID=build.ID ");
- strSql.Append(" where 1=1 ");
-
- if (!queryParam["DeptNo"].IsEmpty())
- {
- strSql.Append(" and t.DeptNo = @DeptNo ");
- dp.Add("DeptNo", queryParam["DeptNo"].ToString(), DbType.String);
- }
- if (!queryParam["MajorNo"].IsEmpty())
- {
- strSql.Append(" and t.MajorNo = @MajorNo ");
- dp.Add("MajorNo", queryParam["MajorNo"].ToString(), DbType.String);
- }
- if (!queryParam["ClassNo"].IsEmpty())
- {
- strSql.Append(" and t.ClassNo = @ClassNo ");
- dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String);
- }
- if (!queryParam["Grade"].IsEmpty())
- {
- strSql.Append(" and t.Grade = @Grade ");
- dp.Add("Grade", queryParam["Grade"].ToString(), DbType.String);
- }
-
- var data = this.BaseRepository("CollegeMIS").FindList<StuInfoFreshEntity>(strSql.ToString(), dp);
-
- return data;
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取列表数据
- /// <summary>
- /// <returns></returns>
- public IEnumerable<StuInfoFreshEntity> GetList2(string queryJson)
- {
- try
- {
- //参考写法
- var queryParam = queryJson.ToJObject();
- //虚拟参数
- var dp = new DynamicParameters(new { });
-
- var strSql = new StringBuilder();
- strSql.Append("SELECT t.*,d.DeptName,m.MajorName,c.ClassName ");
- strSql.Append(" FROM StuInfoFresh t ");
- strSql.Append(" left join CdDept d on t.DeptNo=d.DeptNo ");
- strSql.Append(" left join CdMajor m on t.MajorNo=m.MajorNo ");
- strSql.Append(" left join ClassInfo c on t.ClassNo=c.ClassNo ");
- strSql.Append(" where 1=1 ");
-
- if (!queryParam["DeptNo"].IsEmpty())
- {
- strSql.Append(" and t.DeptNo = @DeptNo ");
- dp.Add("DeptNo", queryParam["DeptNo"].ToString(), DbType.String);
- }
- if (!queryParam["MajorNo"].IsEmpty())
- {
- strSql.Append(" and t.MajorNo = @MajorNo ");
- dp.Add("MajorNo", queryParam["MajorNo"].ToString(), DbType.String);
- }
- if (!queryParam["ClassNo"].IsEmpty())
- {
- strSql.Append(" and t.ClassNo = @ClassNo ");
- dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String);
- }
- if (!queryParam["Grade"].IsEmpty())
- {
- strSql.Append(" and t.Grade = @Grade ");
- dp.Add("Grade", queryParam["Grade"].ToString(), DbType.String);
- }
-
- var data = this.BaseRepository("CollegeMIS").FindList<StuInfoFreshEntity>(strSql.ToString(), dp);
-
- foreach (var item in data)
- {
- var familyList = this.BaseRepository("CollegeMIS").FindList<StuInfoFreshFamilyEntity>(x => x.StuInfoFreshId == item.ID);
- if (familyList.Any())
- {
- item.IsStudentEdit = true;
- }
- else
- {
- item.IsStudentEdit = false;
- }
- }
-
- return data;
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取列表分页数据
- /// <param name="pagination">分页参数</param>
- /// <summary>
- /// <returns></returns>
- public IEnumerable<StuInfoFreshEntity> GetPageList(Pagination pagination, string queryJson)
- {
- try
- {
- var strSql = new StringBuilder();
- strSql.Append("SELECT t.*,c.ClassName,c.ClassDiredctorNo,c.ClassTutorNo,b.Name as Bed,r.Name as Room,f.Name as floor,u.Name as Unit,build.Name as Build FROM StuInfoFresh t left join ClassInfo c on t.ClassNo=c.ClassNo ");
- strSql.Append(" left join Acc_DormitoryBuild b on t.DormitoryNo=b.ID ");
- strSql.Append(" left join Acc_DormitoryBuild r on b.ParentID=r.ID ");
- strSql.Append(" left join Acc_DormitoryBuild f on r.ParentID=f.ID ");
- strSql.Append(" left join Acc_DormitoryBuild u on f.ParentID=u.ID ");
- strSql.Append(" left join Acc_DormitoryBuild build on u.ParentID=build.ID ");
- strSql.Append(" where 1=1 ");
-
- var queryParam = queryJson.ToJObject();
- var dp = new DynamicParameters(new { });
- if (!queryParam["keyword"].IsEmpty())
- {
- strSql.Append(" and (t.ksh like @keyword or t.zkzh like @keyword or t.StuName like @keyword or t.IdentityCardNo like @keyword )");
- dp.Add("keyword", "%" + queryParam["keyword"].ToString() + "%", DbType.String);
- }
- if (!queryParam["StuNo"].IsEmpty())
- {
- strSql.Append(" and t.StuNo = @StuNo ");
- dp.Add("StuNo", queryParam["StuNo"].ToString(), DbType.String);
- }
- if (!queryParam["StuName"].IsEmpty())
- {
- strSql.Append(" and t.StuName like @StuName ");
- dp.Add("StuName", '%' + queryParam["StuName"].ToString() + '%', DbType.String);
- }
- if (!queryParam["Grade"].IsEmpty())
- {
- strSql.Append(" and t.Grade like @Grade ");
- dp.Add("Grade", '%' + queryParam["Grade"].ToString() + '%', DbType.String);
- }
- //分配班级
- if (!queryParam["MajorNo"].IsEmpty())
- {
- strSql.Append(" and t.MajorNo = @MajorNo ");
- dp.Add("MajorNo", queryParam["MajorNo"].ToString(), DbType.String);
- }
- if (!queryParam["EducationalSystem"].IsEmpty())
- {
- strSql.Append(" and t.EducationalSystem = @EducationalSystem ");
- dp.Add("EducationalSystem", queryParam["EducationalSystem"].ToString(), DbType.String);
- }
- if (!queryParam["IDCard"].IsEmpty())
- {
- strSql.Append(" and t.IdentityCardNo like @IDCard ");
- dp.Add("IDCard", '%' + queryParam["IDCard"].ToString() + '%', DbType.String);
- }
- if (!queryParam["IsAllocation"].IsEmpty())
- {
- var IsAllocation = Convert.ToBoolean(queryParam["IsAllocation"].ToString());
- if (IsAllocation)//未分配
- {
- strSql.Append(" AND (t.ClassNo IS NULL OR t.ClassNo='') ");
- }
- else
- {
- strSql.Append(" AND (t.ClassNo IS NOT NULL AND t.ClassNo<>'') ");
- }
- }
- //分配床位
- if (!queryParam["ClassNo"].IsEmpty())
- {
- strSql.Append(" and t.ClassNo = @ClassNo ");
- dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String);
- }
- //完善信息
- if (!queryParam["PerfectStatus"].IsEmpty())
- {
- if (queryParam["PerfectStatus"].ToString() == "1")
- {
- strSql.Append(" AND t.ID in (select StuInfoFreshId from StuInfoFreshFamily) ");
- }
- else
- {
- strSql.Append(" AND t.ID not in (select StuInfoFreshId from StuInfoFreshFamily) ");
- }
- }
- //报到状态
- if (!queryParam["RegisterStatus"].IsEmpty())
- {
- if (queryParam["RegisterStatus"].ToString() == "1")
- {
- strSql.Append(" AND t.RegisterStatus = @RegisterStatus ");
- }
- else
- {
- strSql.Append(" AND (t.RegisterStatus <> 1 or t.RegisterStatus is null)");
- }
- dp.Add("RegisterStatus", queryParam["RegisterStatus"].ToString(), DbType.String);
- }
- //缴费状态
- if (!queryParam["PayStatus"].IsEmpty())
- {
- if (queryParam["PayStatus"].ToString() == "1")
- {
- strSql.Append(" AND t.PayFeeStatus = @PayFeeStatus ");
- }
- else
- {
- strSql.Append(" AND (t.PayFeeStatus <> 1 or t.PayFeeStatus is null)");
- }
- dp.Add("PayFeeStatus", queryParam["PayStatus"].ToString(), DbType.String);
- }
- //领取状态
- if (!queryParam["GetKeyStatus"].IsEmpty())
- {
- if (queryParam["GetKeyStatus"].ToString() == "1")
- {
- strSql.Append(" AND t.GetKeyStatus = @GetKeyStatus ");
- }
- else
- {
- strSql.Append(" AND (t.GetKeyStatus <> 1 or t.GetKeyStatus is null)");
- }
- dp.Add("GetKeyStatus", queryParam["GetKeyStatus"].ToString(), DbType.String);
- }
- if (!queryParam["Gender"].IsEmpty())
- {
- if (queryParam["Gender"].ToString() == "1")
- {
- strSql.Append(" AND t.GenderNo = @Gender ");
- }
- else
- {
- strSql.Append(" AND t.GenderNo <> 1 ");
- }
- dp.Add("Gender", queryParam["Gender"].ToString(), DbType.String);
- }
- if (!queryParam["IsAllocationDormitory"].IsEmpty())
- {
- var IsAllocation = Convert.ToBoolean(queryParam["IsAllocationDormitory"].ToString());
- if (IsAllocation)
- {
- strSql.Append(" AND (t.DormitoryNo IS NULL OR t.DormitoryNo='')");
- }
- else
- {
- strSql.Append(" AND (t.DormitoryNo IS NOT NULL AND t.DormitoryNo<>'')");
- }
- }
- //班主任/辅导员
- if (!queryParam["EmpNo"].IsEmpty())
- {
- strSql.Append(" and (c.ClassDiredctorNo = @EmpNo or c.ClassTutorNo = @EmpNo) ");
- dp.Add("EmpNo", queryParam["EmpNo"].ToString(), DbType.String);
- }
-
- return this.BaseRepository("CollegeMIS").FindList<StuInfoFreshEntity>(strSql.ToString(), dp, pagination);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
-
- /// <summary>
- /// 获取StuInfoFreshFamily表数据
- /// <summary>
- /// <returns></returns>
- public IEnumerable<StuInfoFreshFamilyEntity> GetStuInfoFreshFamilyList(string keyValue)
- {
- try
- {
- return this.BaseRepository("CollegeMIS").FindList<StuInfoFreshFamilyEntity>(t => t.StuInfoFreshId == keyValue);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取StuInfoFreshEmergePeople表数据
- /// <summary>
- /// <returns></returns>
- public IEnumerable<StuInfoFreshEmergePeopleEntity> GetStuInfoFreshEmergePeopleList(string keyValue)
- {
- try
- {
- return this.BaseRepository("CollegeMIS").FindList<StuInfoFreshEmergePeopleEntity>(t => t.StuInfoFreshId == keyValue);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
- /// <summary>
- /// 获取StuInfoFresh表实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public StuInfoFreshEntity GetStuInfoFreshEntity(string keyValue)
- {
- try
- {
- return this.BaseRepository("CollegeMIS").FindEntity<StuInfoFreshEntity>(keyValue);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取StuInfoFresh表实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public StuInfoFreshEntity GetStuInfoFreshEntityByStuNo(string stuNo)
- {
- try
- {
- return this.BaseRepository("CollegeMIS").FindEntity<StuInfoFreshEntity>(x => x.StuNo == stuNo);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取StuInfoFreshEmergePeople表实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public StuInfoFreshEmergePeopleEntity GetStuInfoFreshEmergePeopleEntity(string keyValue)
- {
- try
- {
- return this.BaseRepository("CollegeMIS").FindEntity<StuInfoFreshEmergePeopleEntity>(t => t.StuInfoFreshId == keyValue);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取StuInfoFreshFamily表实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public StuInfoFreshFamilyEntity GetStuInfoFreshFamilyEntity(string keyValue)
- {
- try
- {
- return this.BaseRepository("CollegeMIS").FindEntity<StuInfoFreshFamilyEntity>(t => t.StuInfoFreshId == keyValue);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取列表分页数据
- /// <param name="pagination">分页参数</param>
- /// <summary>
- /// <returns></returns>
- public IEnumerable<StuInfoFreshEntity> GetStuInfoFreshListByClassNo(string classNo)
- {
- try
- {
- var strSql = new StringBuilder();
- strSql.Append("SELECT t.* FROM StuInfoFresh t where 1=1 and t.ClassNo='" + classNo + "' ");
- return this.BaseRepository("CollegeMIS").FindList<StuInfoFreshEntity>(strSql.ToString());
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取分配宿舍列表
- /// </summary>
- /// <param name="pagination"></param>
- /// <param name="queryJson"></param>
- /// <returns></returns>
- public IEnumerable<Acc_DormitoryBuildEntity> GetDormitorys(Pagination pagination, string queryJson)
- {
- try
- {
- var strSql = new StringBuilder();
- strSql.Append("SELECT t.* FROM Acc_DormitoryBuild t ");
- strSql.Append(" WHERE 1=1 ");
- var queryParam = queryJson.ToJObject();
- // 虚拟参数
- var dp = new DynamicParameters(new { });
- if (!queryParam["BuildType"].IsEmpty())
- {
- dp.Add("BuildType", queryParam["BuildType"].ToString(), DbType.String);
- strSql.Append(" AND t.BuildType =@BuildType ");
- }
- if (!queryParam["ParentID"].IsEmpty())
- {
- dp.Add("ParentID", queryParam["ParentID"].ToString(), DbType.String);
- strSql.Append(" AND t.ParentID =@ParentID ");
- }
- if (!queryParam["Sex"].IsEmpty())
- {
- dp.Add("Sex", queryParam["Sex"].ToString(), DbType.String);
- strSql.Append(" AND t.Sex = @Sex ");
- }
- //if (!queryParam["IsAllocationDormitory"].IsEmpty())
- //{
- // if (queryParam["IsAllocationDormitory"].ToString() == "false")
- // {
- // strSql.Append(" AND t.PlanClassNo is not null ");
- // }
- // else
- // {
- // strSql.Append(" AND t.PlanClassNo is null ");
- // }
- //}
- if (!queryParam["PlanClassNo"].IsEmpty())
- {
- //dp.Add("PlanClassNo", queryParam["PlanClassNo"].ToString(), DbType.String);
- //strSql.Append(" AND t.PlanClassNo =@PlanClassNo ");
- dp.Add("PlanClassNo", "%" + queryParam["PlanClassNo"].ToString() + "%", DbType.String);
- strSql.Append(" AND t.PlanClassNo like @PlanClassNo ");
- }
-
- var data = this.BaseRepository("CollegeMIS").FindList<Acc_DormitoryBuildEntity>(strSql.ToString(), dp, pagination).OrderBy(a => a.Name).ToList();
- foreach (var item in data)
- {
- //总床位
- item.ChildCount = this.BaseRepository("CollegeMIS").FindList<Acc_DormitoryBuildEntity>(a => a.ParentID == item.ID).Count();
-
- //可分配床位=总床位-预分床位
- int remainBedNum = item.ChildCount - (item.PlanBedNum.HasValue ? item.PlanBedNum.Value : 0);
- item.PlanBedNum = remainBedNum;
- item.RemainBedNum = remainBedNum;
-
- }
-
- if (!queryParam["IsAllocationDormitory"].IsEmpty())
- {
- if (queryParam["IsAllocationDormitory"].ToString() == "false")//不可分配
- {
- data = data.Where(x => x.RemainBedNum == 0).ToList();
- }
- else//可分配
- {
- data = data.Where(x => x.RemainBedNum > 0).ToList();
- }
- }
-
- return data;
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取分配宿舍列表
- /// </summary>
- /// <param name="pagination"></param>
- /// <param name="queryJson"></param>
- /// <returns></returns>
- public IEnumerable<Acc_DormitoryBuildEntity> GetDormitorys2(Pagination pagination, string queryJson)
- {
- try
- {
- var strSql = new StringBuilder();
- strSql.Append("SELECT t.* FROM Acc_DormitoryBuild t ");
- strSql.Append(" WHERE 1=1 ");
- var queryParam = queryJson.ToJObject();
- // 虚拟参数
- var dp = new DynamicParameters(new { });
- if (!queryParam["BuildType"].IsEmpty())
- {
- dp.Add("BuildType", queryParam["BuildType"].ToString(), DbType.String);
- strSql.Append(" AND t.BuildType =@BuildType ");
- }
- if (!queryParam["PlanClassNo"].IsEmpty())
- {
- dp.Add("PlanClassNo", "%" + queryParam["PlanClassNo"].ToString() + "%", DbType.String);
- strSql.Append(" AND t.PlanClassNo like @PlanClassNo ");
- }
-
- var data = this.BaseRepository("CollegeMIS").FindList<Acc_DormitoryBuildEntity>(strSql.ToString(), dp, pagination).OrderBy(a => a.Name).ToList();
- foreach (var item in data)
- {
- var bedList = this.BaseRepository("CollegeMIS").FindList<Acc_DormitoryBuildEntity>(a => a.ParentID == item.ID);
- //总床位
- item.ChildCount = bedList.Count();
- //已分配床位
- item.UseBedNum = bedList.Where(x => x.PlanClassNo == queryParam["PlanClassNo"].ToString()).Count();
- item.CancelUseBedNum = item.UseBedNum;
- }
-
- return data;
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取分配宿舍树
- /// </summary>
- /// <returns></returns>
- internal List<Tuple<int, int, string, string>> GetTree()
- {
- try
- {
- var data = this.BaseRepository("CollegeMIS").FindList<StuInfoFreshEntity>(a => !string.IsNullOrEmpty(a.ClassNo)).ToList();
- var classInfos = this.BaseRepository("CollegeMIS").FindList<ClassInfoEntity>().ToList();
- var classes = data.GroupBy(a => a.ClassNo).Select(a => a.Key).ToList();
- List<Tuple<int, int, string, string>> list = new List<Tuple<int, int, string, string>>();
- foreach (var classNo in classes)
- {
- var boy = data.Count(a => a.ClassNo == classNo && a.GenderNo == "1");
- var girl = data.Count(a => a.ClassNo == classNo && a.GenderNo != "1");
- var className = classInfos.FirstOrDefault(a => a.ClassNo == classNo)?.ClassName;
-
- Tuple<int, int, string, string> tuple = new Tuple<int, int, string, string>(boy, girl, classNo, className);
- list.Add(tuple);
- }
- return list;
-
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取分配床位树
- /// </summary>
- /// <param name="classNo"></param>
- /// <param name="gender"></param>
- /// <returns></returns>
- internal List<Acc_DormitoryBuildEntity> GetBedTree(string classNo, string gender)
- {
- try
- {
- List<Acc_DormitoryBuildEntity> list = new List<Acc_DormitoryBuildEntity>();
- var data = this.BaseRepository("CollegeMIS").FindList<Acc_DormitoryBuildEntity>(a => a.PlanClassNo.Contains(classNo) && a.Sex == gender && a.BuildType == "4").ToList();
- var bb = this.BaseRepository("CollegeMIS").FindList<StuInfoFreshEntity>().ToList();
- foreach (var item in data)
- {
- list.Add(item);
- var beds = this.BaseRepository("CollegeMIS").FindList<Acc_DormitoryBuildEntity>(a => a.ParentID == item.ID && a.PlanClassNo == classNo).ToList();
- foreach (var bed in beds)
- {
- var stuName = bb.FirstOrDefault(a => a.DormitoryNo == bed.ID)?.StuName;
- if (!string.IsNullOrEmpty(stuName))
- {
- bed.Name = $"{bed.Name}({stuName})";
- }
- list.Add(bed);
-
- }
-
- }
-
- return list;
-
- }
- 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)
- {
- var db = this.BaseRepository("CollegeMIS").BeginTrans();
- try
- {
- var stuInfoFreshEntity = GetStuInfoFreshEntity(keyValue);
- db.Delete<StuInfoFreshEntity>(t => t.ID == keyValue);
- db.Delete<StuInfoFreshEmergePeopleEntity>(t => t.StuInfoFreshId == stuInfoFreshEntity.ID);
- db.Delete<StuInfoFreshFamilyEntity>(t => t.StuInfoFreshId == stuInfoFreshEntity.ID);
- 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 SaveEntity(string keyValue, StuInfoFreshEntity entity, List<StuInfoFreshEmergePeopleEntity> stuInfoFreshEmergePeopleList, List<StuInfoFreshFamilyEntity> stuInfoFreshFamilyList)
- {
- var db = this.BaseRepository("CollegeMIS").BeginTrans();
- try
- {
- if (!string.IsNullOrEmpty(keyValue))
- {
- var stuInfoFreshEntityTmp = GetStuInfoFreshEntity(keyValue);
- entity.Modify(keyValue);
- db.Update(entity);
- db.Delete<StuInfoFreshEmergePeopleEntity>(t => t.StuInfoFreshId == stuInfoFreshEntityTmp.ID);
- if (null != stuInfoFreshEmergePeopleList && null != stuInfoFreshFamilyList)
- {
- foreach (StuInfoFreshEmergePeopleEntity item in stuInfoFreshEmergePeopleList)
- {
- item.Create();
- item.StuInfoFreshId = stuInfoFreshEntityTmp.ID;
- db.Insert(item);
- }
- db.Delete<StuInfoFreshFamilyEntity>(t => t.StuInfoFreshId == stuInfoFreshEntityTmp.ID);
- foreach (StuInfoFreshFamilyEntity item in stuInfoFreshFamilyList)
- {
- item.Create();
- item.StuInfoFreshId = stuInfoFreshEntityTmp.ID;
- db.Insert(item);
- }
- }
- }
- else
- {
- entity.Create();
- db.Insert(entity);
- if (null != stuInfoFreshEmergePeopleList && null != stuInfoFreshFamilyList)
- {
- foreach (StuInfoFreshEmergePeopleEntity item in stuInfoFreshEmergePeopleList)
- {
- item.Create();
- item.StuInfoFreshId = entity.ID;
- db.Insert(item);
- }
-
- foreach (StuInfoFreshFamilyEntity item in stuInfoFreshFamilyList)
- {
- item.Create();
- item.StuInfoFreshId = entity.ID;
- db.Insert(item);
- }
- }
- }
- 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 SaveEntity(string keyValue, StuInfoFreshEntity 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);
- }
- }
- }
-
- #endregion
-
- #region 扩展数据
-
- /// <summary>
- /// 确认报到、取消报到
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public void IsRegister(string keyValue, string status)
- {
- try
- {
- if (status == "1")//报到
- {
- this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set RegisterStatus='1',ArriveDate='" + DateTime.Now + "' where ID='" + keyValue + "' ");
- }
- else
- {
- this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set RegisterStatus='0',ArriveDate=null where 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 IsCollectFile(string keyValue, string status)
- {
- try
- {
- if (status == "1")//收取
- {
- this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set CollectFileStatus='1',CollectFileDate='" + DateTime.Now + "' where ID='" + keyValue + "' ");
- }
- else
- {
- this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set CollectFileStatus='0',CollectFileDate=null where 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 IsGetKey(string keyValue, string status)
- {
- try
- {
- if (status == "1")//领取
- {
- this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set GetKeyStatus='1',GetKeyDate='" + DateTime.Now + "' where ID='" + keyValue + "' ");
- }
- else
- {
- this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set GetKeyStatus='0',GetKeyDate=null where 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 IsGetCard(string keyValue, string status)
- {
- try
- {
- if (status == "1")//领取
- {
- this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set GetCardStatus='1',GetCardDate='" + DateTime.Now + "' where ID='" + keyValue + "' ");
- }
- else
- {
- this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set GetCardStatus='0',GetCardDate=null where 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 IsPayFee(string keyValue, string status)
- {
- try
- {
- if (status == "1")//缴费
- {
- this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set PayFeeStatus='1',PayFeeDate='" + DateTime.Now + "' where ID='" + keyValue + "' ");
- }
- else
- {
- this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set PayFeeStatus='0',PayFeeDate=null where 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 IsOtherPayFee(string keyValue, string status)
- {
- try
- {
- if (status == "1")//缴费
- {
- this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set OtherPayFeeStatus='1',OtherPayFeeDate='" + DateTime.Now + "' where ID='" + keyValue + "' ");
- }
- else
- {
- this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set OtherPayFeeStatus='0',OtherPayFeeDate=null where 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 DoCheckLoan(string keyValue, string status)
- {
- try
- {
- if (status == "1")//通过
- {
- this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set StudentLoanStatus='1' where ID='" + keyValue + "' ");
- }
- else
- {
- this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set StudentLoanStatus='0' where 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 DoAllocationClass(List<StuInfoFreshEntity> stuInfoFreshEntities)
- {
- UserRelationIBLL userRelationIBLL = new UserRelationBLL();
- UserIBLL userIBLL = new UserBLL();
- var defaultpwd = Config.GetValue("defaultpwd");
- //读取默认密码配置中已启用的密码
- var Sys_DefaultPwdConfigEntity = this.BaseRepository().FindEntity<Sys_DefaultPwdConfigEntity>(x => x.IsEnabled == true);
- if (Sys_DefaultPwdConfigEntity != null)
- {
- defaultpwd = Sys_DefaultPwdConfigEntity.Pwd;
- }
-
- var db = this.BaseRepository("CollegeMIS").BeginTrans();
- try
- {
- foreach (var entity in stuInfoFreshEntities)
- {
- //新生信息
- entity.Modify(entity.ID);
- db.Update(entity);
-
- //自动生成学生账号默认为学生角色,方便登录移动端
- //判断User是否存在
- var userModel = userIBLL.GetEntityByAccount(entity.StuNo);
- if (userModel == null)
- {
- //User
- var annexesFileEntity = this.BaseRepository().FindEntity<AnnexesFileEntity>(a => a.F_Id == entity.Photo);
- var url = "";
- if (annexesFileEntity != null)
- {
- url = annexesFileEntity.F_FilePath;
- url = "/" + url.Substring(url.IndexOf("Resource"));
-
- }
- var userEntity = new UserEntity()
- {
- F_Account = entity.StuNo,
- F_RealName = entity.StuName,
- F_EnCode = entity.StuNo,
- F_Password = Md5Helper.Encrypt(defaultpwd, 32).ToLower(),
- F_HeadIcon = string.IsNullOrEmpty(url) ? Config.GetValue("defaultheadimg") : url,
- F_Gender = entity.GenderNo == "1" ? 1 : 0,
- F_DeleteMark = 0,
- F_EnabledMark = 1,
- F_Mobile = entity.telephone,
- F_Description = "学生",
- F_CompanyId = this.BaseRepository("CollegeMIS").FindEntity<CdMajorEntity>(x => x.MajorNo == entity.MajorNo)?.F_SchoolId,
- F_DepartmentId = entity.DeptNo
- };
- userIBLL.SaveEntity(null, userEntity);
-
- //UserRelation
- var roleId = Config.GetValue("GenerateStudentsRoleId");
- //判断User是否添加成功
- var user = userIBLL.GetEntityByAccount(entity.StuNo);
- if (user != null)
- {
- var userRelationEntity = new UserRelationEntity();
- userRelationEntity.Create();
- userRelationEntity.F_UserId = user.F_UserId;
- userRelationEntity.F_Category = 1;
- userRelationEntity.F_ObjectId = roleId;
- this.BaseRepository().Insert(userRelationEntity);
- }
-
- }
-
- }
-
- 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 DoAllocationDormitory(List<Acc_DormitoryBuildEntity> acc_DormitoryBuildEntities)
- {
- var db = this.BaseRepository("CollegeMIS").BeginTrans();
- try
- {
- foreach (var entity in acc_DormitoryBuildEntities)
- {
- //修改房间:预分床位数量增加;预分班级判断是否需要增加;
- var model = db.FindEntity<Acc_DormitoryBuildEntity>(entity.ID);
- model.PlanBedNum = (model.PlanBedNum.HasValue ? model.PlanBedNum.Value : 0) + entity.PlanBedNum;
- if (!string.IsNullOrEmpty(model.PlanClassNo) && model.PlanClassNo.Contains(entity.PlanClassNo))
- {
- }
- else
- {
- model.PlanClassNo = model.PlanClassNo + entity.PlanClassNo + ',';
- }
- db.Update(model);
-
- //修改房间下的床位:预分班级增加;
- var redList = db.FindList<Acc_DormitoryBuildEntity>(x => x.ParentID == entity.ID && string.IsNullOrEmpty(x.PlanClassNo)).OrderBy(x => x.Name).ToList();
- foreach (var redItem in redList)
- {
- var index = redList.IndexOf(redItem);
- if (index == entity.PlanBedNum)
- {
- break;
- }
- redItem.PlanClassNo = entity.PlanClassNo;
- db.Update(redItem);
- }
-
- }
-
- 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 ImportDormitory(List<Acc_DormitoryBuildEntity> acc_DormitoryBuildEntities)
- {
- var db = this.BaseRepository("CollegeMIS").BeginTrans();
- try
- {
- foreach (var entity in acc_DormitoryBuildEntities)
- {
- //修改房间:预分床位数量增加;预分班级判断是否需要增加;
- var model = db.FindEntity<Acc_DormitoryBuildEntity>(entity.ID);
- model.PlanBedNum = (model.PlanBedNum.HasValue ? model.PlanBedNum.Value : 0) + entity.PlanBedNum;
- if (!string.IsNullOrEmpty(model.PlanClassNo) && model.PlanClassNo.Contains(entity.PlanClassNo))
- {
- }
- else
- {
- model.PlanClassNo = model.PlanClassNo + entity.PlanClassNo + ',';
- }
- db.Update(model);
-
- //修改房间下的床位:预分班级增加;
- var redList = db.FindList<Acc_DormitoryBuildEntity>(x => x.ID == entity.bedId).ToList();
- foreach (var redItem in redList)
- {
- var index = redList.IndexOf(redItem);
- if (index == entity.PlanBedNum)
- {
- break;
- }
- redItem.PlanClassNo = entity.PlanClassNo;
- db.Update(redItem);
- }
-
- }
-
- 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 CancelAllocationDormitory(List<Acc_DormitoryBuildEntity> acc_DormitoryBuildEntities)
- {
- var db = this.BaseRepository("CollegeMIS").BeginTrans();
- try
- {
- foreach (var entity in acc_DormitoryBuildEntities)
- {
- //修改房间:预分床位数量减少;预分班级判断是否需要清除;
- var model = db.FindEntity<Acc_DormitoryBuildEntity>(entity.ID);
- model.PlanBedNum = model.PlanBedNum - entity.CancelUseBedNum;
-
- if (!string.IsNullOrEmpty(model.PlanClassNo))
- {
- var planclassnotemp = entity.PlanClassNo + ',';
- if (model.PlanClassNo == planclassnotemp) //一个班
- {
- if (model.PlanBedNum <= 0)
- {
- model.PlanClassNo = "";
- }
- }
- else //多个班
- {
- var bedNumSelf = db.FindList<Acc_DormitoryBuildEntity>(x => x.ParentID == entity.ID && x.PlanClassNo == entity.PlanClassNo).Count();
- if (bedNumSelf == entity.CancelUseBedNum)
- {
- model.PlanClassNo = model.PlanClassNo.Replace(planclassnotemp, "");
- }
- }
-
- }
-
- db.Update(model);
-
- //修改房间下的床位:预分班级清除;
- var redList = db.FindList<Acc_DormitoryBuildEntity>(x => x.ParentID == entity.ID && x.PlanClassNo == entity.PlanClassNo).OrderBy(x => x.PlanStudentID).ThenBy(x => x.Name).ToList();
- foreach (var redItem in redList)
- {
- var index = redList.IndexOf(redItem);
- if (index == entity.CancelUseBedNum)
- {
- break;
- }
- redItem.PlanClassNo = "";
- //判断床位是否被占用;
- if (!string.IsNullOrEmpty(redItem.PlanStudentID))
- {
- redItem.PlanStudentID = "";
-
- var stuInfoFreshEntity = db.FindEntity<StuInfoFreshEntity>(x => x.DormitoryNo == redItem.ID);
- if (stuInfoFreshEntity != null)
- {
- stuInfoFreshEntity.DormitoryNo = "";
- stuInfoFreshEntity.DormitoryName = "";
- }
- db.Update(stuInfoFreshEntity);
-
- }
-
- db.Update(redItem);
- }
-
- }
-
- db.Commit();
- }
- catch (Exception ex)
- {
- db.Rollback();
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 分配床位
- /// </summary>
- /// <param name="dormitoryNo"></param>
- /// <param name="stuId"></param>
- /// <param name="dormitoryName"></param>
- public void DoAllocationBed(string dormitoryNo, string keyValue)
- {
- var db = this.BaseRepository("CollegeMIS").BeginTrans();
- try
- {
- //清除StuInfoFresh
- db.ExecuteBySql("update StuInfoFresh set DormitoryNo=null,DormitoryName=null where DormitoryNo='" + dormitoryNo + "' ");
- //清除Acc_DormitoryBuild
- db.ExecuteBySql("update Acc_DormitoryBuild set PlanStudentID=null where PlanStudentID='" + keyValue + "' ");
- //更新Acc_DormitoryBuild
- var newAcc_DormitoryBuildEntity = db.FindEntity<Acc_DormitoryBuildEntity>(x => x.ID == dormitoryNo);
- if (newAcc_DormitoryBuildEntity != null)
- {
- newAcc_DormitoryBuildEntity.PlanStudentID = keyValue;
- db.Update(newAcc_DormitoryBuildEntity);
-
- //更新StuInfoFresh
- var newStuInfoFreshEntity = db.FindEntity<StuInfoFreshEntity>(x => x.ID == keyValue);
- if (newStuInfoFreshEntity != null)
- {
- newStuInfoFreshEntity.DormitoryNo = dormitoryNo;
- newStuInfoFreshEntity.DormitoryName = db.FindEntity<Acc_DormitoryBuildEntity>(x => x.ID == newAcc_DormitoryBuildEntity.ParentID)?.Name + newAcc_DormitoryBuildEntity.Name;
- db.Update(newStuInfoFreshEntity);
- }
- }
-
- db.Commit();
- }
- catch (Exception ex)
- {
- db.Rollback();
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 自动分配床位
- /// </summary>
- /// <param name="classNo">班级编号</param>
- /// <param name="stuId"></param>
- /// <param name="dormitoryName"></param>
- public void DoAllocationBedOfAuto(string classNo)
- {
- var db = this.BaseRepository("CollegeMIS").BeginTrans();
- try
- {
- //区分性别:男1,女0;
- //班级里未分配床位的学生;班级里的空床位;
- //修改StuInfoFresh;修改Acc_DormitoryBuild;
-
- #region 随机分配
-
- for (int i = 0; i <= 1; i++)
- {
- var studentList = new List<StuInfoFreshEntity>();
- var bedList = new List<Acc_DormitoryBuildEntity>();
- string sexTemp = "1";
- if (i == 0)
- {
- studentList = db.FindList<StuInfoFreshEntity>(x => x.ClassNo == classNo && x.GenderNo != sexTemp && string.IsNullOrEmpty(x.DormitoryNo)).ToList();
- bedList = db.FindList<Acc_DormitoryBuildEntity>(x => x.PlanClassNo == classNo && x.Sex != sexTemp && string.IsNullOrEmpty(x.PlanStudentID)).ToList();
- }
- else
- {
- studentList = db.FindList<StuInfoFreshEntity>(x => x.ClassNo == classNo && x.GenderNo == sexTemp && string.IsNullOrEmpty(x.DormitoryNo)).ToList();
- bedList = db.FindList<Acc_DormitoryBuildEntity>(x => x.PlanClassNo == classNo && x.Sex == sexTemp && string.IsNullOrEmpty(x.PlanStudentID)).ToList();
- }
-
- var studentTempList = new List<StuInfoFreshEntity>();
- var bedTempList = new List<Acc_DormitoryBuildEntity>();
-
- foreach (var bedItem in bedList)
- {
- if (studentList.Count() == studentTempList.Count())
- {
- break;
- }
- var index = bedList.IndexOf(bedItem);
- var studentItem = studentList[index];
-
- bedItem.PlanStudentID = studentItem.ID;
- bedTempList.Add(bedItem);
-
- studentItem.DormitoryNo = bedItem.ID;
- studentItem.DormitoryName = db.FindEntity<Acc_DormitoryBuildEntity>(x => x.ID == bedItem.ParentID)?.Name + bedItem.Name;
- studentTempList.Add(studentItem);
-
- }
-
- db.Update(bedTempList);
- db.Update(studentTempList);
-
- }
-
- #endregion
-
- db.Commit();
- }
- catch (Exception ex)
- {
- db.Rollback();
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
- public void ConfirmDormitory()
- {
- try
- {
- var nostuBed = this.BaseRepository("CollegeMIS")
- .FindList<Acc_DormitoryBuildEntity>(a => a.StudentID == null || a.StudentID == "").Where(a => a.PlanStudentID != null);
- foreach (var bed in nostuBed)
- {
- var stuFreshInfo = this.BaseRepository("CollegeMIS")
- .FindEntity<StuInfoFreshEntity>(a => a.ID == bed.PlanStudentID);
- if (stuFreshInfo != null)
- {
- var stuInfo = this.BaseRepository("CollegeMIS")
- .FindEntity<StuInfoBasicEntity>(a => a.StuNo == stuFreshInfo.StuNo);
- if (stuInfo != null)
- {
- bed.Dept = stuInfo.DeptNo;
- bed.Major = stuInfo.MajorNo;
- bed.Class = stuInfo.ClassNo;
- bed.StudentID = stuInfo.StuId;
- this.BaseRepository("CollegeMIS").Update(bed);
- }
- }
- }
-
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
- public void ConfirmDormitoryTwo()
- {
- try
- {
- var nostuBed = this.BaseRepository("CollegeMIS")
- .FindList<Acc_DormitoryBuildEntity>(a => a.StudentID == null || a.StudentID == "").Where(a => a.PlanStudentID != null);
- foreach (var bed in nostuBed)
- {
- var stuFreshInfo = this.BaseRepository("CollegeMIS")
- .FindEntity<StuEnrollEntity>(a => a.StuId == bed.PlanStudentID);
- if (stuFreshInfo != null)
- {
- var stuInfo = this.BaseRepository("CollegeMIS")
- .FindEntity<StuInfoBasicEntity>(a => a.StuNo == stuFreshInfo.StuNo);
- if (stuInfo != null)
- {
- bed.Dept = stuInfo.DeptNo;
- bed.Major = stuInfo.MajorNo;
- bed.Class = stuInfo.ClassNo;
- bed.StudentID = stuInfo.StuId;
- this.BaseRepository("CollegeMIS").Update(bed);
- }
- }
- }
-
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
- public void GetUniform(string keyValue, bool Status)
- {
- try
- {
- var sql = "";
- if (Status)
- {
- sql = $"UPDATE dbo.StuInfoFresh SET IsGetUniform =1 WHERE ID='{keyValue}'";
- }
- else
- {
- sql = $"UPDATE dbo.StuInfoFresh SET IsGetUniform =0 WHERE ID='{keyValue}'";
- }
-
- this.BaseRepository("CollegeMIS").ExecuteBySql(sql);
-
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
- public void PayUniform(string keyValue, bool Status)
- {
- try
- {
- var sql = "";
- if (Status)
- {
- sql = $"UPDATE dbo.StuInfoFresh SET IsPayUniform =1 WHERE ID='{keyValue}'";
- }
- else
- {
- sql = $"UPDATE dbo.StuInfoFresh SET IsPayUniform =0 WHERE ID='{keyValue}'";
- }
-
- this.BaseRepository("CollegeMIS").ExecuteBySql(sql);
-
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 导入学籍信息
- /// </summary>
- public void ImportStuInfoBasic()
- {
- try
- {
- //学籍表增加数据
- var strSql = new StringBuilder();
- strSql.Append(@"insert into StuInfoBasic
- (StuId, StuNo, StuCode, NoticeNo, GraduateYear, ksh, DeptNo, MajorNo, MajorDetailNo, MajorDetailName,
- Grade, ClassNo, StuName, SpellFull, SpellBrief, GenderNo, Birthday, PartyFaceNo, FamilyOriginNo, NationalityNo,
- ProvinceNo, RegionNo, ResidenceNo, TestStuSortNo, HealthStatusNo, WillNo, TestStuSubjectNo, GraduateNo,
- PlanFormNo, IsThreeGood, IsExcellent, IsNormalCadre, IsProvinceFirstThree, OverseasChineseNo, MatriculateSort,
- ComeProvinceNo, HighSchoolNo, HighSchoolName, EntranceDate, Religion, GoodAt, IdentityCardNo, JoinPartyDate,
- JoinLeagueDate, InSchoolAddress, InSchoolTelephone, AbmormityMoveMark, AwardMark, PunishMark, LinkmanMark,
- StuNoChangeMark, FinishSchoolMark, CurrentRegisterMark, FinishSchoolDate, DiplomaNo, DiplomaRemark, Remark,
- RegisterDate, Photo, TeachPlanNo, CheckMark, mobile, EMail, QQ, FatherUnit, FatherName, FatherPhone, MatherName,
- MatherUnit, MatherPhone, username, password, MailAddress, PostalCode, InSchoolStatus, TransMark, ClassTutorNo,
- ResumeCheck, PracStatus, RegisterStatus, PunishmentDate, F_CityId, F_CountyId, F_ProvinceId, F_SchoolId,
- EduSystem, StudyModality, SyncFlag)
- select NEWID(),StuNo,null,NoticeNo,null,ksh,DeptNo,MajorNo,MajorDetailNok as MajorDetailNo,MajorDetailName,Grade,ClassNo,StuName,null,null,case when GenderNo ='1' then 1 else 0 end,Birthday,PartyFaceNo,FamilyOriginNo,NationalityNo,ProvinceNo,RegionNo,ResidenceNo,TestStuSortNo,HealthStatusNo,WillNo,TestStuSubjectNo,GraduateNo,PlanFormNo,IsThreeGood,IsExcellent,IsNormalCadre,IsProvinceFirstThree,OverseasChineseNo,MatriculateSort,null,HighSchoolNo,HighSchoolName,null,null,GoodAt,IdentityCardNo,null,null,null,null,null,null,null,null,null,null,null,null,null,null,Remark,ArriveDate as RegisterDate,Photo,null,null,telephone as mobile,null,null,null,null,null,null,null,null,StuNo as username,null,MailAddress,PostalCode,null,TransMark,null,null,null,RegisterStatus,null,null,null,null,F_SchoolId,null,null,0 from
- (select f.*,m.F_SchoolId from StuInfoFresh f left join CdMajor m on f.MajorNo=m.MajorNo where f.StuNo is not null ) as bb
- where bb.StuNo not in (select b.StuNo from StuInfoBasic b where b.StuNo=bb.StuNo) ");
-
- this.BaseRepository("CollegeMIS").ExecuteBySql(strSql.ToString());
-
- //新生表修改“是否生成学籍”的状态
- var strSql2 = new StringBuilder();
- strSql2.Append("update StuInfoFresh set IsInBasic=1 where StuNo is not null and (IsInBasic is null or IsInBasic=0) and StuNo in (select t.StuNo from StuInfoBasic t where t.StuNo=StuNo)");
- this.BaseRepository("CollegeMIS").ExecuteBySql(strSql2.ToString());
-
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 删除宿舍信息
- /// </summary>
- public void DeleteBed(string keyValue)
- {
- var db = this.BaseRepository("CollegeMIS").BeginTrans();
- try
- {
-
- var stuInfoFreshEntity = db.FindEntity<StuInfoFreshEntity>(x => x.ID == keyValue);
- if (stuInfoFreshEntity != null && !string.IsNullOrEmpty(stuInfoFreshEntity.DormitoryNo))
- {
- var dormitoryBuildEntity = db.FindEntity<Acc_DormitoryBuildEntity>(x => x.ID == stuInfoFreshEntity.DormitoryNo);
- if (dormitoryBuildEntity != null)
- {
- //判断是否清除宿舍中预分班级
- var roomEntity = db.FindEntity<Acc_DormitoryBuildEntity>(x => x.ID == dormitoryBuildEntity.ParentID);
- if (roomEntity != null)
- {
- roomEntity.PlanBedNum = roomEntity.PlanBedNum - 1;
- var aa = db.FindList<Acc_DormitoryBuildEntity>(x => x.ParentID == roomEntity.ID && x.PlanClassNo == dormitoryBuildEntity.PlanClassNo && x.ID != dormitoryBuildEntity.ID);
- if (!aa.Any()) //宿舍不存在同班学生
- {
- var tempClass = dormitoryBuildEntity.PlanClassNo + ",";
- roomEntity.PlanClassNo = roomEntity.PlanClassNo.Replace(tempClass, "");
- }
- db.Update(roomEntity);
- }
- //清除Acc_DormitoryBuild
- db.ExecuteBySql("update Acc_DormitoryBuild set PlanStudentID=null,PlanClassNo=null where ID='" + dormitoryBuildEntity.ID + "' ");
- }
- //清除StuInfoFresh
- db.ExecuteBySql("update StuInfoFresh set DormitoryNo=null,DormitoryName=null where ID='" + stuInfoFreshEntity.ID + "' ");
- }
-
- db.Commit();
- }
- catch (Exception ex)
- {
- db.Rollback();
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
-
- #endregion
-
- #region 上传图片
-
- internal (bool, string) IsPhoto(string stuId, bool status, string fileGuid)
- {
- try
- {
- string result = "";
- bool resultBool = false;
- var model = this.BaseRepository("CollegeMIS").FindEntity<StuInfoFreshEntity>(a => a.ID == stuId);
- if (model != null)
- {
- model.Photo = fileGuid;
- resultBool = true;
- result = "操作成功!";
- this.BaseRepository("CollegeMIS").Update(model);
- }
- else
- {
- result = "错误";
- }
- return (resultBool, result);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- #endregion
- }
- }
|