123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Transactions;
- using Bowin.Common.Utility;
- using EMIS.Entities;
- using EMIS.Utility;
- using EMIS.ViewModel;
- namespace EMIS.ExtensionLogic.ServiceLogic.EnrollManage
- {
- public class NewStudentEnterServices : EMIS.CommonLogic.EnrollManage.NewStudentManage.NewStudentEnterServices
- {
- /// <summary>
- /// 提交(河北工大)
- /// 注:需判断对应的录取照片是否存在、是否已分班且生成学号,并对学生信息进行验证,如:考生号或准考证号唯一、学号唯一
- /// </summary>
- /// <param name="newStudentIDList"></param>
- /// <returns></returns>
- public override string NewStudentEnterSubmit(List<Guid?> newStudentIDList)
- {
- try
- {
- //查询相关Web.config配置
- if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringMonth == null)
- {
- throw new Exception("预计毕业月(春季、上学期入学月)未配置,请检查。");
- }
- if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringDay == null)
- {
- throw new Exception("预计毕业日(春季、上学期入学日)未配置,请检查。");
- }
- if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnMonth == null)
- {
- throw new Exception("预计毕业月(秋季、下学期入学月)未配置,请检查。");
- }
- if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnDay == null)
- {
- throw new Exception("预计毕业日(秋季、下学期入学日)未配置,请检查。");
- }
- //查询录取名单信息(已分配状态)
- var newStudentEnterList = NewStudentDAL.NewStudentRepository.GetList(x => newStudentIDList.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.Assigned).ToList();
- //查询班级信息ID为空的录取名单(注:如果有班级信息,对应的专业班级一定存在(无需验证是否有专业班级))
- var classIDVerifyList = newStudentEnterList.Where(x => string.IsNullOrEmpty(x.ClassmajorID.ToString())).ToList();
- if (classIDVerifyList != null && classIDVerifyList.Count() > 0)
- {
- throw new Exception("选择提交的名单中存在未分班的数据,请检查。");
- }
- //查询学号为空的录取名单
- var studentNoVerifyList = newStudentEnterList.Where(x => string.IsNullOrEmpty(x.StudentNo)).ToList();
- if (studentNoVerifyList != null && studentNoVerifyList.Count() > 0)
- {
- throw new Exception("选择提交的名单中存在未生成学号的数据,请检查。");
- }
- //有疑义名单判断
- if (newStudentEnterList.Any(x => x.IsDoubt == true))
- {
- throw new Exception("选择提交的名单中存在有疑议的数据,请检查。");
- }
- //已提交状态判断
- if (newStudentEnterList.Any(x => x.RecordStatus == (int)EMIS.ViewModel.CF_NewStudentEnterStatus.Submitted))
- {
- throw new Exception("选择提交的名单中存在已提交的数据,请检查。");
- }
- //查询录取照片为空的录取名单
- var pictureUrlVerifyList = newStudentEnterList.Where(x => string.IsNullOrEmpty(x.RecruitPictureUrl)).ToList();
- if (pictureUrlVerifyList != null && pictureUrlVerifyList.Count() > 0)
- {
- throw new Exception("选择提交的名单中存在录取照片不存在的数据,请检查。");
- }
- //年级
- var gradeIDList = newStudentEnterList.Where(x => !string.IsNullOrEmpty(x.GradeID.ToString())).Select(x => x.GradeID).ToList();
- //考生号
- var examineeNumList = newStudentEnterList.Where(x => !string.IsNullOrEmpty(x.ExamineeNum)).Select(x => x.ExamineeNum).ToList();
- ////准考证号
- //var admissionTicketNoList = newStudentEnterList.Where(x => !string.IsNullOrEmpty(x.AdmissionTicketNo)).Select(x => x.AdmissionTicketNo).ToList();
- //身份证号
- var iDNumberList = newStudentEnterList.Where(x => !string.IsNullOrEmpty(x.IDNumber)).Select(x => x.IDNumber).ToList();
- //学号
- var studentNoList = newStudentEnterList.Where(x => !string.IsNullOrEmpty(x.StudentNo)).Select(x => x.StudentNo).ToList();
- //查询学年学期信息(验证对应的年级专业的入学学期与Web.config配置是否一致,有班级信息相应的学年学期信息一定存在)
- //如不致,以年级专业对应的入学学期为准
- var schoolyearVerifyList = NewStudentDAL.SchoolyearRepository.GetList(x => gradeIDList.Contains(x.Years)).ToList();
- //班级信息ID
- var classIDList = newStudentEnterList.Where(x => !string.IsNullOrEmpty(x.ClassmajorID.ToString())).Select(x => x.ClassmajorID).ToList();
- ////查询学生信息(用于验证考生号、准考证号)
- //var studentVerifyList = NewStudentDAL.RecruitstudentsRepository.GetList(x => examineeNumList.Contains(x.ExamineeNum) || admissionTicketNoList.Contains(x.AdmissionTicketNo)).ToList();
- //查询学生信息(用于验证考生号)
- var studentVerifyList = NewStudentDAL.RecruitstudentsRepository.GetList(x => examineeNumList.Contains(x.ExamineeNum)).ToList();
- //查询用户信息(用于验证学号)
- var userVerifyList = NewStudentDAL.UserRepository.GetList(x => studentNoList.Contains(x.LoginID)).ToList();
- //查询班级信息(用于验证班级)
- var classMajorVerifyList = NewStudentDAL.ClassmajorRepository.GetList(x => classIDList.Contains(x.ClassmajorID)).ToList();
- //年级专业ID(根据班级信息ID)
- var classMajorIDList = classMajorVerifyList.Where(x => !string.IsNullOrEmpty(x.GrademajorID.ToString())).Select(x => x.GrademajorID).ToList();
- //查询年级专业(根据年级专业ID)
- var gradeMajorVerifyList = NewStudentDAL.GrademajorRepository.GetList(x => classMajorIDList.Contains(x.GrademajorID)).ToList();
- //查询年级专业的毕业学期ID(根据年级专业ID)
- var gradschoolyearIDList = NewStudentDAL.GrademajorRepository.GetList(x => classMajorIDList.Contains(x.GrademajorID)).Select(x => x.GraduateSchoolyearID).ToList();
- //查询毕业学期(用于验证毕业学期)
- var gradschoolyearVerifyList = NewStudentDAL.SchoolyearRepository.GetList(x => gradschoolyearIDList.Contains(x.SchoolyearID)).ToList();
- //查询毕业学期对应的毕业日期List
- var graduateDateList = NewStudentDAL.GraduateSchoolyearRepository.GetList(x => true).ToList();
- //查询学生用户密码规则定义
- var passwordParameter = NewStudentDAL.ParameterRepository.GetSingle(x => x.ParameterTypeID == (int)ViewModel.CF_ParameterType.StudentInitPassword);
- //查询学生角色信息
- var roleList = NewStudentDAL.RoleRepository.GetList(x => x.TypeID == (int)SYS_RoleType.Student, (x => x.CF_StudentRole)).ToList();
- int studentfail = 0;
- int studentNofail = 0;
- int success = 0;
- string tipMessage = null;
- List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
- List<Sys_User> userInList = new List<Sys_User>();
- List<CF_Student> studentInList = new List<CF_Student>();
- List<CF_StudentProfile> studentProfileInList = new List<CF_StudentProfile>();
- List<CF_StudentContact> studentContactInList = new List<CF_StudentContact>();
- List<CF_StudentAccount> studentAccountInList = new List<CF_StudentAccount>();
- List<CF_Recruitstudents> studentRecruitInList = new List<CF_Recruitstudents>();
- //List<CF_StudentFamily> studentFamilyInList = new List<CF_StudentFamily>();
- //List<CF_StudentExperience> studentExperienceInList = new List<CF_StudentExperience>();
- foreach (var newStudentEnter in newStudentEnterList)
- {
- Sys_User user = new Sys_User();
- CF_Student student = new CF_Student();
- CF_StudentProfile studentProfile = new CF_StudentProfile();
- CF_StudentContact studentContact = new CF_StudentContact();
- CF_StudentAccount studentAccount = new CF_StudentAccount();
- CF_Recruitstudents studentRecruit = new CF_Recruitstudents();
- //CF_StudentFamily studentFamily = new CF_StudentFamily();
- //CF_StudentExperience studentExperience = new CF_StudentExperience();
-
- //验证考生号
- var examineeNumVerify = studentVerifyList.Where(x => x.ExamineeNum == newStudentEnter.ExamineeNum).SingleOrDefault();
- if (examineeNumVerify == null)
- {
- ////验证准考证号
- //if (!string.IsNullOrEmpty(newStudentEnter.AdmissionTicketNo))
- //{
- // var admissionTicketNoVerify = studentVerifyList.Where(x => x.AdmissionTicketNo == newStudentEnter.AdmissionTicketNo).SingleOrDefault();
- // if (admissionTicketNoVerify != null)
- // {
- // //准考证号验证不通过
- // studentfail++;
- // continue;
- // }
- //}
- //考生号验证通过,验证学号
- var userVerify = userVerifyList.Where(x => x.LoginID == newStudentEnter.StudentNo).SingleOrDefault();
- if (userVerify == null)
- {
- //学号验证通过
- user.UserID = Guid.NewGuid();
- user.LoginID = newStudentEnter.StudentNo;
- user.Name = newStudentEnter.Name;
- if (passwordParameter == null)
- {
- user.Password = ("A" + newStudentEnter.StudentNo).MD5();
- }
- else
- {
- if (passwordParameter.Value != null)
- {
- user.Password = passwordParameter.Value;
- }
- else
- {
- user.Password = ("A" + newStudentEnter.StudentNo).MD5();
- }
- }
- SetNewStatus(user, (int)SYS_STATUS.USABLE);
- userInList.Add(user);
- user.Sys_Role = new HashSet<Sys_Role>();
- roleList = roleList.Where(x => x.CF_StudentRole.StudentType == (int)CF_STUDENTTYPE.DefaultType).ToList();
- if (roleList != null && roleList.Count > 0)
- {
- roleList.ForEach(x => user.Sys_Role.Add(x));
- }
- student.UserID = user.UserID;
- student.ClassmajorID = newStudentEnter.ClassmajorID;
- student.SexID = newStudentEnter.SexID;
- student.BirthDate = newStudentEnter.BirthDate;
- student.NationID = newStudentEnter.NationID;
- student.PoliticsID = newStudentEnter.PoliticsID;
- student.CertificatesType = newStudentEnter.CertificatesType;
- student.IDNumber = newStudentEnter.IDNumber;
- student.StudentType = (int)CF_STUDENTTYPE.DefaultType;
- student.InSchoolStatusID = (int)CF_InschoolStatus.InSchool;
- student.StudentStatus = (int)CF_StudentStatus.Registration;
- student.StudentCardNo = user.LoginID;
- student.PhotoUrl = null;
- //对应的班级信息
- var classMajor = classMajorVerifyList.Where(x => x.ClassmajorID == newStudentEnter.ClassmajorID).SingleOrDefault();
- //对应的年级专业的毕业学期
- var gradeMajor = gradeMajorVerifyList.Where(x => x.GrademajorID == classMajor.GrademajorID).SingleOrDefault();
- if (gradeMajor != null)
- {
- //查询对应毕业学期信息
- var gradschoolyear = gradschoolyearVerifyList.Where(x => x.SchoolyearID == gradeMajor.GraduateSchoolyearID).SingleOrDefault();
- if (gradschoolyear != null)
- {
- //预计毕业日期
- student.PlanningGraduateDate = PlanningGraduateDateHelper.GetPlanningGraduateDate(gradschoolyear.FirstWeek);
- }
- else
- {
- //预计毕业日期
- student.PlanningGraduateDate = null;
- }
- //查询对应的毕业日期
- var graduateDate = graduateDateList.Where(x => x.SchoolyearID == gradeMajor.GraduateSchoolyearID).SingleOrDefault();
- if (graduateDate != null)
- {
- //毕业日期
- student.GraduateDate = graduateDate.GraduateDate;
- }
- else
- {
- //毕业日期
- student.GraduateDate = null;
- }
- }
- else
- {
- //预计毕业日期
- student.PlanningGraduateDate = null;
- //毕业日期
- student.GraduateDate = null;
- }
- student.GraduateCardNo = null;
- student.ReplaceGraduateNo = null;
- student.DegreeStatus = false;
- student.GraduationPictureUrl = null;
- student.Career = null;
- student.IsPhotoComparison = false;
- student.IsProofread = false;
- student.Remark = newStudentEnter.Remark;
- SetNewStatus(student, (int)SYS_STATUS.USABLE);
- studentInList.Add(student);
- studentProfile.UserID = user.UserID;
- studentProfile.UsedName = null;
- studentProfile.LiteracyLevelID = null;
- studentProfile.CultureModelID = null;
- studentProfile.IsDreamProject = false;
- studentProfile.Country = "中国";
- studentProfile.Place = null;
- studentProfile.BornPlace = null;
- studentProfile.HealthStateID = null;
- studentProfile.BloodGroup = null;
- studentProfile.Specialty = null;
- studentProfile.Height = null;
- studentProfile.Weight = null;
- studentProfile.DirectorName = null;
- SetNewStatus(studentProfile, (int)SYS_STATUS.USABLE);
- studentProfileInList.Add(studentProfile);
- studentContact.UserID = user.UserID;
- studentContact.Email = null;
- studentContact.Telephone = newStudentEnter.Telephone;
- studentContact.Mobile = newStudentEnter.Telephone;
- studentContact.ZIPCode = newStudentEnter.ZIPCode;
- studentContact.WeChatNum = null;
- studentContact.QQ = null;
- studentContact.HomeAddress = null;
- studentContact.WorkUnit = null;
- studentContact.Address = newStudentEnter.Address;
- studentContact.Recipient = newStudentEnter.Name;
- studentContact.Dormitory = null;
- SetNewStatus(studentContact, (int)SYS_STATUS.USABLE);
- studentContactInList.Add(studentContact);
- studentAccount.UserID = user.UserID;
- studentAccount.CardNo = null;
- studentAccount.BankName = null;
- SetNewStatus(studentAccount, (int)SYS_STATUS.USABLE);
- studentAccountInList.Add(studentAccount);
- studentRecruit.UserID = user.UserID;
- studentRecruit.ExamineeNum = newStudentEnter.ExamineeNum;
- studentRecruit.AdmissionTicketNo = newStudentEnter.AdmissionTicketNo;
- studentRecruit.ExamineeType = null;
- //查询对应入学学年学期
- var enterSchoolYear = schoolyearVerifyList.Where(x => x.Years == newStudentEnter.GradeID && x.SchoolcodeID == classMajor.CF_Grademajor.SemesterID).SingleOrDefault();
- if (enterSchoolYear != null)
- {
- studentRecruit.EnteringSchoolYearID = enterSchoolYear.SchoolyearID;
- }
- else
- {
- studentRecruit.EnteringSchoolYearID = null;
- }
- studentRecruit.EntranceDate = newStudentEnter.EntranceDate;
- studentRecruit.Score = newStudentEnter.Score;
- studentRecruit.EntranceWayID = newStudentEnter.EntranceWayID;
- studentRecruit.FeaturesID = newStudentEnter.FeaturesID;
- studentRecruit.TerritorialID = newStudentEnter.TerritorialID;
- studentRecruit.Area = null;
- studentRecruit.RecruitPictureUrl = newStudentEnter.RecruitPictureUrl;
- SetNewStatus(studentRecruit, (int)SYS_STATUS.USABLE);
- studentRecruitInList.Add(studentRecruit);
- //studentFamily.StudentFamilyID = Guid.NewGuid();
- //studentFamily.UserID = user.UserID;
- //SetNewStatus(studentFamily, (int)SYS_STATUS.USABLE);
- //studentFamilyInList.Add(studentFamily);
- //studentExperience.StudentExperienceID = Guid.NewGuid();
- //studentExperience.UserID = user.UserID;
- //SetNewStatus(studentExperience, (int)SYS_STATUS.USABLE);
- //studentExperienceInList.Add(studentExperience);
- //获取提交成功的录取名单信息(用于做其它的处理,如:删除、更新等)
- newStudentEnter.RecordStatus = (int)CF_NewStudentEnterStatus.Submitted;
- SetModifyStatus(newStudentEnter);
- newStudentUpList.Add(newStudentEnter);
- success++;
- }
- else
- {
- //学号验证不通过
- studentNofail++;
- continue;
- }
- }
- else
- {
- //考生号验证不通过
- studentfail++;
- continue;
- }
- }
- using (TransactionScope ts = new TransactionScope())
- {
- //批量插入
- UnitOfWork.BulkInsert<Sys_User>(userInList);
- UnitOfWork.BulkInsert(userInList, (x => x.Sys_Role)); //插入相应的关系表
- UnitOfWork.BulkInsert<CF_Student>(studentInList);
- UnitOfWork.BulkInsert<CF_StudentProfile>(studentProfileInList);
- UnitOfWork.BulkInsert<CF_StudentContact>(studentContactInList);
- UnitOfWork.BulkInsert<CF_StudentAccount>(studentAccountInList);
- UnitOfWork.BulkInsert<CF_Recruitstudents>(studentRecruitInList);
- //UnitOfWork.BulkInsert<CF_StudentFamily>(studentFamilyInList);
- //UnitOfWork.BulkInsert<CF_StudentExperience>(studentExperienceInList);
- //刷新对应的学生相关信息
- StudentServices.Value.AddStudentEnd(studentInList.Select(x => x.UserID).ToList());
- //提交成功后,更新相应的录取名单状态
- if (newStudentUpList != null && newStudentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStudentUpList); //批量更新
- }
- ts.Complete();
- }
- if (studentfail <= 0 && studentNofail <= 0)
- {
- tipMessage = success + "条录取名单进入学生信息库";
- }
- else
- {
- if (studentNofail > 0 && studentfail <= 0)
- {
- tipMessage = success + "条录取名单进入学生信息库," + studentNofail + "条录取名单提交失败,原因:学号已存在,请检查";
- }
- else if (studentNofail <= 0 && studentfail > 0)
- {
- tipMessage = success + "条录取名单进入学生信息库," + studentfail + "条录取名单提交失败,原因:考生号或准考证号已存在,请检查";
- }
- else
- {
- tipMessage = success + "条录取名单进入学生信息库," + studentNofail + "条录取名单由于学号已存在提交失败," + studentfail + "条录取名单由于考生号或准考证号已存在提交失败,请检查";
- }
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
-
- }
- }
|