12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072 |
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Transactions;
- using System.IO;
- using Bowin.Common.Utility;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.Utility;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.EnrollManage.NewStudentManage;
- using EMIS.DataLogic.EnrollManage.NewStudentManage;
- using EMIS.CommonLogic.Students;
- namespace EMIS.CommonLogic.EnrollManage.NewStudentManage
- {
- public class NewStudentEnterServices : BaseServices, INewStudentEnterServices
- {
- public NewStudentDAL NewStudentDAL { get; set; }
- public Lazy<IStudentsServices> StudentServices { get; set; }
- /// <summary>
- /// 查询录取名单信息View
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="gradeID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="grademajorID"></param>
- /// <param name="classmajorID"></param>
- /// <param name="generalPurpose"></param>
- /// <param name="generalExist"></param>
- /// <param name="dictionaryNewStudentEnterStatus"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<NewStudentView> GetNewStudentEnterViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID,
- int? educationID, int? learningformID, string learnSystem, Guid? grademajorID, Guid? classmajorID, int? generalPurpose, int? generalExist, int? dictionaryNewStudentEnterStatus, int pageIndex, int pageSize)
- {
- Expression<Func<CF_NewStudent, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.Assigned);
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CollegeID == collegeID);
- }
- if (gradeID.HasValue)
- {
- exp = exp.And(x => x.GradeID == gradeID);
- }
- if (classmajorID.HasValue)
- {
- exp = exp.And(x => x.ClassmajorID == classmajorID);
- }
- if (generalPurpose.HasValue)
- {
- if (generalPurpose == 1)
- {
- exp = exp.And(x => x.IsDoubt == true);
- }
- if (generalPurpose == 0)
- {
- exp = exp.And(x => x.IsDoubt != true);
- }
- }
- if (dictionaryNewStudentEnterStatus.HasValue)
- {
- exp = exp.And(x => x.RecordStatus == dictionaryNewStudentEnterStatus);
- }
- var query = NewStudentDAL.GetNewStudentEnterViewQueryable(exp);
- if (campusID.HasValue)
- {
- query = query.Where(x => x.CampusID == campusID);
- }
- if (standardID.HasValue)
- {
- query = query.Where(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- query = query.Where(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- query = query.Where(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(learnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- if (grademajorID.HasValue)
- {
- query = query.Where(x => x.GrademajorID == grademajorID);
- }
- if (generalExist.HasValue)
- {
- if (generalExist.Value == (int)CF_GeneralExist.Have)
- {
- query = query.Where(x => !string.IsNullOrEmpty(x.StudentNo));
- }
- if (generalExist.Value == (int)CF_GeneralExist.No)
- {
- query = query.Where(x => string.IsNullOrEmpty(x.StudentNo));
- }
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.GradeID).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
- .ThenBy(x => x.StandardName).ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem)
- .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ToGridResultSet<NewStudentView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询录取名单信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="gradeID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="grademajorID"></param>
- /// <param name="classmajorID"></param>
- /// <param name="generalPurpose"></param>
- /// <param name="generalExist"></param>
- /// <param name="dictionaryNewStudentEnterStatus"></param>
- /// <returns></returns>
- public IList<NewStudentView> GetNewStudentEnterViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID,
- int? educationID, int? learningformID, string learnSystem, Guid? grademajorID, Guid? classmajorID, int? generalPurpose, int? generalExist, int? dictionaryNewStudentEnterStatus)
- {
- Expression<Func<CF_NewStudent, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.Assigned);
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CollegeID == collegeID);
- }
- if (gradeID.HasValue)
- {
- exp = exp.And(x => x.GradeID == gradeID);
- }
- if (classmajorID.HasValue)
- {
- exp = exp.And(x => x.ClassmajorID == classmajorID);
- }
- if (generalPurpose.HasValue)
- {
- if (generalPurpose == 1)
- {
- exp = exp.And(x => x.IsDoubt == true);
- }
- if (generalPurpose == 0)
- {
- exp = exp.And(x => x.IsDoubt != true);
- }
- }
- if (dictionaryNewStudentEnterStatus.HasValue)
- {
- exp = exp.And(x => x.RecordStatus == dictionaryNewStudentEnterStatus);
- }
- var query = NewStudentDAL.GetNewStudentEnterViewQueryable(exp);
- if (campusID.HasValue)
- {
- query = query.Where(x => x.CampusID == campusID);
- }
- if (standardID.HasValue)
- {
- query = query.Where(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- query = query.Where(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- query = query.Where(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(learnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- if (grademajorID.HasValue)
- {
- query = query.Where(x => x.GrademajorID == grademajorID);
- }
- if (generalExist.HasValue)
- {
- if (generalExist.Value == (int)CF_GeneralExist.Have)
- {
- query = query.Where(x => !string.IsNullOrEmpty(x.StudentNo));
- }
- if (generalExist.Value == (int)CF_GeneralExist.No)
- {
- query = query.Where(x => string.IsNullOrEmpty(x.StudentNo));
- }
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.GradeID).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
- .ThenBy(x => x.StandardName).ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem)
- .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ToList();
- }
- /// <summary>
- /// 查询对应的录取名单信息NewStudentView
- /// </summary>
- /// <param name="newStudentID"></param>
- /// <returns></returns>
- public NewStudentView GetNewStudentEnterView(Guid? newStudentID)
- {
- try
- {
- Expression<Func<CF_NewStudent, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.Assigned);
- exp = exp.And(x => x.NewStudentID == newStudentID);
- var query = NewStudentDAL.GetNewStudentEnterViewQueryable(exp).SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 录取查询
- /// </summary>
- /// <param name="examineeNum"></param>
- /// <param name="userName"></param>
- /// <returns></returns>
- public NewStudentView GetNewStudentEnterView(string examineeNum, string userName)
- {
- try
- {
- Expression<Func<CF_NewStudent, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.Assigned);
- exp = exp.And(x => x.ExamineeNum == examineeNum);
- exp = exp.And(x => x.Name == userName);
- var query = NewStudentDAL.GetNewStudentEnterViewQueryable(exp).SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 编辑(新增、修改,业务主键:考生号唯一)
- /// 注:需对相应的业务进行处理,如:学号等
- /// </summary>
- /// <param name="newStudentView"></param>
- /// <param name="photoUrl"></param>
- public void NewStudentEnterEdit(NewStudentView newStudentView, string photoUrl)
- {
- try
- {
- //查询对应的招生专业信息
- var recruitSpecialty = NewStudentDAL.RecruitSpecialtyRepository.GetList(x => x.GradeID == newStudentView.GradeID
- && x.CollegeID == newStudentView.CollegeID && x.SpecialtyID == newStudentView.SpecialtyID).SingleOrDefault();
- if (recruitSpecialty == null)
- {
- throw new Exception("对应的招生专业不存在(未开设相对应的招生专业)。");
- }
- //查询对应的专业信息
- var specialty = NewStudentDAL.SpecialtyRepository.GetList(x => x.SpecialtyID == newStudentView.SpecialtyID).SingleOrDefault();
- //根据专业信息和选择的院系所查询院系专业信息
- var facultymajorList = NewStudentDAL.FacultymajorRepository.GetList(x => x.CollegeID == newStudentView.CollegeID
- && x.StandardID == specialty.StandardID && x.EducationID == specialty.EducationID
- && x.LearningformID == specialty.LearningformID && x.LearnSystem == specialty.LearnSystem).Select(x => x.FacultymajorID).ToList();
- //if (facultymajorList.Count == 0)
- //{
- // throw new Exception(RSL.Get("College") + "对应的专业不存在(院系专业信息)。");
- //}
- //根据院系专业和新生的年级查询年级专业信息
- var grademajorList = NewStudentDAL.GrademajorRepository.GetList(x => facultymajorList.Contains(x.FacultymajorID.Value)
- && x.GradeID == newStudentView.GradeID, x => x.CF_Classmajor).Select(x => x.GrademajorID).ToList();
- //if (grademajorList.Count == 0)
- //{
- // throw new Exception("年级对应的专业不存在(年级专业信息)。");
- //}
- //根据年级专业查询班级信息
- var classajorList = NewStudentDAL.ClassmajorRepository.GetList(x => grademajorList.Contains(x.GrademajorID.Value)).ToList();
- //if (classajorList.Count == 0)
- //{
- // throw new Exception("对应的班级信息不存在。");
- //}
- if (newStudentView.ClassmajorID != null)
- {
- var classajor = classajorList.Where(x => x.ClassmajorID == newStudentView.ClassmajorID).FirstOrDefault();
- if (classajor == null)
- {
- throw new Exception("选择的班级信息与对应的专业信息不相符。");
- }
- }
- //查询数据库进行验证
- var examineeNumVerify = NewStudentDAL.NewStudentRepository.GetList(x => x.NewStudentID != newStudentView.NewStudentID
- && x.ExamineeNum == newStudentView.ExamineeNum.Trim()).SingleOrDefault();
- if (examineeNumVerify == null)
- {
- //if (!string.IsNullOrEmpty(newStudentView.AdmissionTicketNo))
- //{
- // var admissionTicketNoVerify = NewStudentDAL.NewStudentRepository.GetList(x => x.NewStudentID != newStudentView.NewStudentID
- // && x.AdmissionTicketNo == newStudentView.AdmissionTicketNo.Trim()).SingleOrDefault();
- // if (admissionTicketNoVerify != null)
- // {
- // if (admissionTicketNoVerify.AssignStatus == (int)CF_AssignStatus.NotAssigned)
- // {
- // throw new Exception("新生名单信息中已存在此准考证号(准考证号重复),请核查。");
- // }
- // else if (admissionTicketNoVerify.AssignStatus == (int)CF_AssignStatus.PreAssigned)
- // {
- // throw new Exception("新生分配信息中已存在此准考证号(准考证号重复),请核查。");
- // }
- // else
- // {
- // throw new Exception("已存在相同的准考证号(准考证号重复),请核查。");
- // }
- // }
- //}
- //查询Web.config学号位数配置
- var studentNoTotal = EMIS.Utility.Const.LOCAL_SETTING_LOGINIDTOTAL;
- if (!string.IsNullOrEmpty(newStudentView.StudentNo))
- {
- if (studentNoTotal == null)
- {
- throw new Exception("学号总位数未配置,请检查。");
- }
- else
- {
- //有学号一定要有班级信息
- if (!newStudentView.ClassmajorID.HasValue)
- {
- throw new Exception("请选择对应的班级名称(学号不为空时,班级名称不能为空)。");
- }
- else
- {
- //新生名单信息数据重复性验证(学号唯一)
- var newStudentNoVerify = NewStudentDAL.NewStudentRepository.GetList(x => x.NewStudentID != newStudentView.NewStudentID
- && x.AssignStatus == (int)CF_AssignStatus.Assigned && x.StudentNo == newStudentView.StudentNo.Trim()).SingleOrDefault();
- if (newStudentNoVerify != null)
- {
- throw new Exception("录取名单中已存在此学号(学号重复),请检查。");
- }
- //用户信息数据重复性验证(用户名唯一)
- var userVerify = NewStudentDAL.UserRepository.GetList(x => x.LoginID == newStudentView.StudentNo.Trim()).SingleOrDefault();
- if (userVerify != null)
- {
- //学生信息数据重复性验证(学号唯一,根据业务主键排除)
- var studentNoVerify = NewStudentDAL.StudentRepository.GetList(x => true, (x => x.CF_Recruitstudents), (x => x.Sys_User))
- .Where(x => (x.IDNumber != newStudentView.IDNumber && x.CF_Recruitstudents.ExamineeNum != newStudentView.ExamineeNum)
- && x.Sys_User.LoginID == newStudentView.StudentNo.Trim()).SingleOrDefault();
- if (studentNoVerify != null)
- {
- throw new Exception("学生信息中已存在此学号,请检查。");
- }
- else
- {
- studentNoVerify = NewStudentDAL.StudentRepository.GetList(x => true, (x => x.Sys_User))
- .Where(x => x.Sys_User.LoginID == newStudentView.StudentNo.Trim()).SingleOrDefault();
- if (studentNoVerify == null)
- {
- throw new Exception("用户信息中已存在相同的用户(用户名重复),请核查。");
- }
- }
- }
- //判断学号位数与Web.config配置位数是否一致
- if (newStudentView.StudentNo.Length != Convert.ToInt32(studentNoTotal))
- {
- throw new Exception("输入的学号总位数有误,学号总位数应为" + studentNoTotal + "位。");
- }
- }
- }
- }
- //查询最大的录取通知编号(只查询已分配状态的信息--录取名单,业务主键:年级、院系所)
- var maxCollegeEnrollment = NewStudentDAL.GetEnrollmentNo(x => x.GradeID == newStudentView.GradeID && x.CollegeID == newStudentView.CollegeID && x.AssignStatus == (int)CF_AssignStatus.Assigned).SingleOrDefault();
- //查询院系所信息
- var college = NewStudentDAL.CollegeRepository.GetList(x => x.CollegeID == newStudentView.CollegeID).SingleOrDefault();
- //通知书编号
- long newEnrollmentNo = 0;
- if (maxCollegeEnrollment == null)
- {
- //表示初始录取通书编号
- int total = (newStudentView.GradeID.ToString() + college.No).Length;
- newEnrollmentNo = Convert.ToInt64((newStudentView.GradeID.ToString() + college.No).PadRight(total + 4, '0') + "1");
- }
- else
- {
- newEnrollmentNo = Convert.ToInt64(maxCollegeEnrollment.EnrollmentNo) + 1;
- }
- //数据有误验证
- if (newStudentView.NewStudentID != Guid.Empty)
- {
- var newStudent = NewStudentDAL.NewStudentRepository.GetList(x => x.NewStudentID == newStudentView.NewStudentID
- && x.AssignStatus == (int)CF_AssignStatus.Assigned).SingleOrDefault();
- if (newStudent == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- else
- {
- //表示修改
- newStudent.ExamineeNum = newStudentView.ExamineeNum;
- newStudent.AdmissionTicketNo = newStudentView.AdmissionTicketNo;
- newStudent.Name = newStudentView.Name;
- newStudent.SexID = newStudentView.SexID;
- newStudent.NationID = newStudentView.NationID;
- newStudent.PoliticsID = newStudentView.PoliticsID;
- newStudent.BirthDate = newStudentView.BirthDate;
- newStudent.CertificatesType = newStudentView.CertificatesType;
- newStudent.IDNumber = newStudentView.IDNumber;
- newStudent.GradeID = newStudentView.GradeID;
- newStudent.SemesterID = newStudentView.SemesterID;
- newStudent.SpecialtyID = newStudentView.SpecialtyID;
- newStudent.EntranceDate = newStudentView.EntranceDate;
- newStudent.Score = newStudentView.Score;
- newStudent.Telephone = newStudentView.Telephone;
- newStudent.ZIPCode = newStudentView.ZIPCode;
- newStudent.EntranceWayID = newStudentView.EntranceWayID;
- newStudent.FeaturesID = newStudentView.FeaturesID;
- newStudent.TerritorialID = newStudentView.TerritorialID;
- newStudent.Address = newStudentView.Address;
- newStudent.Dormitory = newStudentView.Dormitory;
- //如果相关的年级或院系所有变动,此处要生成相应的录取通知书编号
- if (newStudent.GradeID != newStudentView.GradeID || newStudent.CollegeID != newStudentView.CollegeID)
- {
- newStudent.EnrollmentNo = newEnrollmentNo.ToString();
- }
- if (!string.IsNullOrEmpty(photoUrl))
- {
- newStudent.RecruitPictureUrl = photoUrl;
- }
- newStudent.CollegeID = newStudentView.CollegeID;
- newStudent.ClassmajorID = newStudentView.ClassmajorID;
- newStudent.StudentNo = newStudentView.StudentNo;
- newStudent.Remark = newStudentView.Remark;
- SetModifyStatus(newStudent);
- }
- }
- else
- {
- //表示新增
- var newStudent = new CF_NewStudent();
- newStudent.NewStudentID = Guid.NewGuid();
- newStudent.ExamineeNum = newStudentView.ExamineeNum;
- newStudent.AdmissionTicketNo = newStudentView.AdmissionTicketNo;
- newStudent.Name = newStudentView.Name;
- newStudent.SexID = newStudentView.SexID;
- newStudent.NationID = newStudentView.NationID;
- newStudent.PoliticsID = newStudentView.PoliticsID;
- newStudent.BirthDate = newStudentView.BirthDate;
- newStudent.CertificatesType = newStudentView.CertificatesType;
- newStudent.IDNumber = newStudentView.IDNumber;
- newStudent.GradeID = newStudentView.GradeID;
- newStudent.SemesterID = newStudentView.SemesterID;
- newStudent.SpecialtyID = newStudentView.SpecialtyID;
- newStudent.EntranceDate = newStudentView.EntranceDate;
- newStudent.Score = newStudentView.Score;
- newStudent.Telephone = newStudentView.Telephone;
- newStudent.ZIPCode = newStudentView.ZIPCode;
- newStudent.EntranceWayID = newStudentView.EntranceWayID;
- newStudent.FeaturesID = newStudentView.FeaturesID;
- newStudent.TerritorialID = newStudentView.TerritorialID;
- newStudent.Address = newStudentView.Address;
- newStudent.Dormitory = newStudentView.Dormitory;
- newStudent.EnrollmentNo = newEnrollmentNo.ToString();
- if (!string.IsNullOrEmpty(photoUrl))
- {
- newStudent.RecruitPictureUrl = photoUrl;
- }
- newStudent.IsDoubt = false;
- newStudent.AssignStatus = (int)CF_AssignStatus.Assigned;
- newStudent.CollegeID = newStudentView.CollegeID;
- newStudent.ClassmajorID = newStudentView.ClassmajorID;
- newStudent.StudentNo = newStudentView.StudentNo;
- newStudent.Remark = newStudentView.Remark;
- SetNewStatus(newStudent, (int)CF_NewStudentEnterStatus.NotSubmitted);
- UnitOfWork.Add(newStudent);
- }
- }
- else
- {
- if (examineeNumVerify.AssignStatus == (int)CF_AssignStatus.NotAssigned)
- {
- throw new Exception("新生名单信息中已存在此考生号(考生号重复),请核查。");
- }
- else if (examineeNumVerify.AssignStatus == (int)CF_AssignStatus.PreAssigned)
- {
- throw new Exception("新生分配信息中已存在此考生号(考生号重复),请核查。");
- }
- else
- {
- throw new Exception("已存在相同的考生号(考生号重复),请核查。");
- }
- }
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="newStudentIDList"></param>
- /// <returns></returns>
- public bool NewStudentEnterDelete(List<Guid?> newStudentIDList)
- {
- try
- {
- UnitOfWork.Delete<CF_NewStudent>(x => newStudentIDList.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.Assigned);
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 删除照片(单个删除)
- /// </summary>
- /// <param name="newStudentID"></param>
- public void DeletePhoto(Guid? newStudentID)
- {
- try
- {
- var newStudent = NewStudentDAL.NewStudentRepository.GetList(x => x.NewStudentID == newStudentID && x.AssignStatus == (int)CF_AssignStatus.Assigned).SingleOrDefault();
- if (newStudent != null)
- {
- if (!string.IsNullOrEmpty(newStudent.RecruitPictureUrl))
- {
- FileUploadHelper.DeleteFile(newStudent.RecruitPictureUrl);
- newStudent.RecruitPictureUrl = null;
- this.UnitOfWork.Commit();
- }
- else
- {
- throw new Exception("对应的照片不存在。");
- }
- }
- else
- {
- throw new Exception("对应的信息未保存,数据有误。");
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除照片(批量删除)
- /// </summary>
- /// <param name="newStudentIDs"></param>
- /// <returns></returns>
- public bool PicDelete(List<Guid?> newStudentIDs)
- {
- try
- {
- List<string> photoUrlList = new List<string>();
- List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
- var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => newStudentIDs.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.Assigned).ToList();
- foreach (var newStudent in newStudentList)
- {
- if (newStudent != null)
- {
- if (!string.IsNullOrEmpty(newStudent.RecruitPictureUrl))
- {
- photoUrlList.Add(newStudent.RecruitPictureUrl);
- newStudent.RecruitPictureUrl = null;
- newStudentUpList.Add(newStudent);
- }
- }
- }
- using (TransactionScope ts = new TransactionScope())
- {
- foreach (var photoUrl in photoUrlList)
- {
- FileUploadHelper.DeleteFile(photoUrl);
- }
- if (newStudentUpList != null && newStudentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStudentUpList);
- }
- //this.UnitOfWork.Commit();
- ts.Complete();
- }
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 取消分配
- /// </summary>
- /// <param name="newStudentIDList"></param>
- /// <returns></returns>
- public string NewStudentEnterCancelAssignCollege(List<Guid?> newStudentIDList)
- {
- try
- {
- //查询新生信息
- var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => newStudentIDList.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.Assigned).ToList();
- int success = 0; //成功
- int fail = 0; //失败
- string tipMessage = null; //提示消息
- List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
- foreach (var newStudentID in newStudentIDList)
- {
- var newStudent = newStudentList.Where(x => x.NewStudentID == newStudentID).SingleOrDefault();
- if (newStudent == null)
- {
- throw new Exception("数据有误,请检查。");
- }
- else
- {
- if (newStudent.RecordStatus == (int)CF_NewStudentEnterStatus.NotSubmitted)
- {
- newStudent.EnrollmentNo = null;
- newStudent.IsDoubt = false;
- newStudent.AssignStatus = (int)CF_AssignStatus.NotAssigned;
- newStudent.CollegeID = null;
- newStudent.ClassmajorID = null;
- newStudent.StudentNo = null;
- SetModifyStatus(newStudent);
- newStudentUpList.Add(newStudent);
- success++;
- }
- else
- {
- fail++;
- }
- }
- }
- //批量统一提交更新
- if (newStudentUpList != null && newStudentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStudentUpList);
- }
- if (success > 0 && fail <= 0)
- {
- tipMessage = success + "条";
- }
- else
- {
- tipMessage = success + "条," + fail + "条失败,原因:无法对已提交状态的信息取消分配,请检查";
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 导入照片
- /// </summary>
- /// <param name="photoPaths"></param>
- /// <param name="importPicType"></param>
- /// <param name="inCount"></param>
- /// <param name="errCount"></param>
- /// <param name="errDataTable"></param>
- public void NewStudentEnterPicImport(IList<string> photoPaths, string importPicType, out int? inCount, out int? errCount, out DataTable errDataTable)
- {
- try
- {
- var mapList = photoPaths.Select(s => new
- {
- PhotoInfo = Path.GetFileName(s).Trim(),
- PhotoName = Path.GetFileNameWithoutExtension(s).Trim(),
- PhotoPath = s,
- }).ToArray();
- var photoNameList = mapList.Select(s => s.PhotoName).Distinct().ToList();
- inCount = 0;
- errCount = 0;
- errDataTable = new DataTable();
- List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
- List<CF_Recruitstudents> newRecruitStudentUpList = new List<CF_Recruitstudents>();
- if (importPicType.Equals("ExamineeNum"))
- {
- var newPhotoNameList = new List<string>();
- foreach (var photoName in photoNameList)
- {
- var photoNameStart = photoName.Substring(0, 1);
- if (photoNameStart.Equals("F") || photoNameStart.Equals("Z"))
- {
- newPhotoNameList.Add(photoName.Substring(1));
- }
- }
- errDataTable.Columns.Add("PhotoInfo", typeof(string));
- errDataTable.Columns.Add("ExamineeNum", typeof(string));
- errDataTable.Columns.Add("ErrorMessage", typeof(string));
- var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => x.AssignStatus == (int)CF_AssignStatus.Assigned && (photoNameList.Contains(x.ExamineeNum) || newPhotoNameList.Contains(x.ExamineeNum))).ToList();
- var recruitStudentList = NewStudentDAL.RecruitstudentsRepository.GetList(x => photoNameList.Contains(x.ExamineeNum) || newPhotoNameList.Contains(x.ExamineeNum)).ToList();
- foreach (var map in mapList)
- {
- var photoNameStart = map.PhotoName.Substring(0, 1);
- if (photoNameStart.Equals("F") || photoNameStart.Equals("Z"))
- {
- var newStudent = newStudentList.Where(x => x.ExamineeNum == map.PhotoName || x.ExamineeNum == map.PhotoName.Substring(1)).SingleOrDefault();
- if (newStudent == null)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["ExamineeNum"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的考生号(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- var recruitStudent = recruitStudentList.Where(x => x.ExamineeNum == map.PhotoName || x.ExamineeNum == map.PhotoName.Substring(1)).SingleOrDefault();
- if (recruitStudent != null)
- {
- recruitStudent.RecruitPictureUrl = map.PhotoPath;
- this.SetModifyStatus(recruitStudent);
- newRecruitStudentUpList.Add(recruitStudent);
- }
- newStudent.RecruitPictureUrl = map.PhotoPath;
- this.SetModifyStatus(newStudent);
- newStudentUpList.Add(newStudent);
- inCount++;
- }
- }
- else
- {
- var newStudent = newStudentList.Where(x => x.ExamineeNum == map.PhotoName).SingleOrDefault();
- if (newStudent == null)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["ExamineeNum"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的考生号(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- var recruitStudent = recruitStudentList.Where(x => x.ExamineeNum == map.PhotoName).SingleOrDefault();
- if (recruitStudent != null)
- {
- recruitStudent.RecruitPictureUrl = map.PhotoPath;
- this.SetModifyStatus(recruitStudent);
- newRecruitStudentUpList.Add(recruitStudent);
- }
- newStudent.RecruitPictureUrl = map.PhotoPath;
- this.SetModifyStatus(newStudent);
- newStudentUpList.Add(newStudent);
- inCount++;
- }
- }
- }
- }
- else if (importPicType.Equals("IDNumber"))
- {
- errDataTable.Columns.Add("PhotoInfo", typeof(string));
- errDataTable.Columns.Add("IDNumber", typeof(string));
- errDataTable.Columns.Add("ErrorMessage", typeof(string));
- var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => x.AssignStatus == (int)CF_AssignStatus.Assigned && photoNameList.Contains(x.IDNumber)).ToList();
- var studentList = NewStudentDAL.StudentRepository.GetList(x => photoNameList.Contains(x.IDNumber), x => x.CF_Recruitstudents).ToList();
- foreach (var map in mapList)
- {
- var newStudentVerifyList = newStudentList.Where(x => x.IDNumber == map.PhotoName).ToList();
- if (newStudentVerifyList != null && newStudentVerifyList.Count() > 1)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["IDNumber"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "录取名单中存在多个对应的证件号码(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- if (newStudentVerifyList != null && newStudentVerifyList.Count() == 1)
- {
- var newStudent = newStudentVerifyList.Where(x => x.IDNumber == map.PhotoName).SingleOrDefault();
- if (newStudent == null)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["IDNumber"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "录取名单中不存在对应的证件号码(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- var studentVerifyList = studentList.Where(x => x.IDNumber == map.PhotoName).ToList();
- if (studentVerifyList != null && studentVerifyList.Count() > 1)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["IDNumber"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "学生信息中存在多个对应的证件号码(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- if (studentVerifyList != null && studentVerifyList.Count() == 1)
- {
- var student = studentVerifyList.Where(x => x.IDNumber == map.PhotoName).SingleOrDefault();
- if (student != null)
- {
- if (student.CF_Recruitstudents != null)
- {
- student.CF_Recruitstudents.RecruitPictureUrl = map.PhotoPath;
- this.SetModifyStatus(student.CF_Recruitstudents);
- newRecruitStudentUpList.Add(student.CF_Recruitstudents);
- }
- }
- }
- newStudent.RecruitPictureUrl = map.PhotoPath;
- this.SetModifyStatus(newStudent);
- newStudentUpList.Add(newStudent);
- inCount++;
- }
- }
- }
- else
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["IDNumber"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "录取名单中不存在对应的证件号码(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- }
- }
- }
- else
- {
- errDataTable.Columns.Add("PhotoInfo", typeof(string));
- errDataTable.Columns.Add("StudentNo", typeof(string));
- errDataTable.Columns.Add("ErrorMessage", typeof(string));
- var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => x.AssignStatus == (int)CF_AssignStatus.Assigned && photoNameList.Contains(x.StudentNo)).ToList();
- var userList = NewStudentDAL.UserRepository.GetList(x => photoNameList.Contains(x.LoginID), x => x.CF_Student.CF_Recruitstudents).ToList();
- foreach (var map in mapList)
- {
- var newStudent = newStudentList.Where(x => x.StudentNo == map.PhotoName).SingleOrDefault();
- if (newStudent == null)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["StudentNo"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的学号(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- var user = userList.Where(x => x.LoginID == map.PhotoName).SingleOrDefault();
- if (user != null)
- {
- if (user.CF_Student != null)
- {
- if (user.CF_Student.CF_Recruitstudents != null)
- {
- user.CF_Student.CF_Recruitstudents.RecruitPictureUrl = map.PhotoPath;
- this.SetModifyStatus(user.CF_Student.CF_Recruitstudents);
- newRecruitStudentUpList.Add(user.CF_Student.CF_Recruitstudents);
- }
- }
- }
- newStudent.RecruitPictureUrl = map.PhotoPath;
- this.SetModifyStatus(newStudent);
- newStudentUpList.Add(newStudent);
- inCount++;
- }
- }
- }
- using (TransactionScope ts = new TransactionScope())
- {
- if (newRecruitStudentUpList != null && newRecruitStudentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newRecruitStudentUpList);
- }
- if (newStudentUpList != null && newStudentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStudentUpList);
- }
- ts.Complete();
- }
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 导入标识
- /// </summary>
- /// <param name="cellheader"></param>
- /// <param name="inCount"></param>
- /// <param name="upCount"></param>
- /// <param name="errdataList"></param>
- /// <param name="errCount"></param>
- /// <param name="sourcePhysicalPath"></param>
- public void NewStudentEnterDoubtImport(Dictionary<string, string> cellheader, out int? inCount, out int? upCount, out List<NewStudentView> errdataList, out int? errCount, string sourcePhysicalPath)
- {
- try
- {
- StringBuilder errorMsg = new StringBuilder();
- List<NewStudentView> errList = new List<NewStudentView>();
- cellheader.Remove("ErrorMessage");
- List<NewStudentView> enlist = NpoiExcelHelper.ExcelToEntityList<NewStudentView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
- cellheader.Add("ErrorMessage", "未导入原因");
- if (enlist.Count() <= 0)
- {
- throw new Exception("Excel文件数据为空,请检查。");
- }
- inCount = 0;
- upCount = 0;
- errCount = 0;
- string errorMsgStr = "";
- List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
- //将循环中相关数据库查询统一查询出来进行匹配(尽量避免在循环中进行数据库查询)
- //姓名
- var nameList = enlist.Where(x => !string.IsNullOrEmpty(x.Name)).Select(x => x.Name).ToList();
- //身份证号
- var iDNumberList = enlist.Where(x => !string.IsNullOrEmpty(x.IDNumber)).Select(x => x.IDNumber).ToList();
- //录取名单(由于需要和Excel中数据进行比对,数据太多就会报异常,所以需要先查询出来)
- var newStudentAllList = NewStudentDAL.NewStudentRepository.GetList(x => true).ToList();
- //对比后的newStudentList
- var newStudentList = newStudentAllList.Where(x => nameList.Contains(x.Name) && iDNumberList.Contains(x.IDNumber)).ToList();
- //循环检测数据列,对各数据列进行验证(必填、字典项验证、数据格式等)
- for (int i = 0; i < enlist.Count; i++)
- {
- NewStudentView en = enlist[i]; //Excel表数据视图
- CF_NewStudent newStudent = new CF_NewStudent(); //新生信息实体
- //姓名
- if (string.IsNullOrEmpty(en.Name))
- {
- errCount++;
- errorMsgStr = "姓名不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //姓名
- newStudent.Name = en.Name.Trim();
- }
- //身份证号
- if (string.IsNullOrEmpty(en.IDNumber))
- {
- errCount++;
- errorMsgStr = "身份证号不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStudent.IDNumber = en.IDNumber.Trim();
- }
- ////Excel表重复性验证(注:当数据表中没有此记录,但是Excel中有重复数据时的去掉)
- //for (int j = i + 1; j < enlist.Count; j++)
- //{
- // NewStudentView enA = enlist[j];
- // //根据Excel表中的业务主键进行去重(考生号唯一)
- // if (en.ExamineeNum == enA.ExamineeNum)
- // {
- // //用于标识Excel表中的重复记录(由于是批量进行插入数据表)
- // }
- //}
- //由于新生管理模块中存在新生分配的业务,在进行新生信息新增时,
- //需要对新生分配、录取名单中的信息进行提示性验证(业务主键:考生号唯一)
- //处理方法:进行Excel导入时,对新生分配、录取名单中的信息提示性验证(当错误信息抛出)
- //注:(未分配-1,预分配-2,已分配-3)
- //数据表重复性验证,此为名单标识功能(考生号唯一)
- //由于标识模块问题,目前暂时不考虑业务主键问题,有重复抛异常
- var newStudentEnetey = newStudentList.Where(x => x.IDNumber == newStudent.IDNumber && x.Name == newStudent.Name).SingleOrDefault();
- if (newStudentEnetey == null)
- {
- errCount++;
- errorMsgStr = "此标识名单不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //由于新生管理模块中存在新生分配的业务,只更新分配状态为:已分配-3、提交状态为:未提交-2的信息
- //分配状态为:未分配-1,预分配-2,已分配-3,提交状态:未提交-1,已提交-2
- if (newStudentEnetey.AssignStatus == (int)CF_AssignStatus.Assigned)
- {
- if (newStudentEnetey.RecordStatus == (int)CF_NewStudentEnterStatus.NotSubmitted)
- {
- //(Excel有重复时,以最后一条记录的更新为准)
- if (newStudentEnetey.IsDoubt == true)
- {
- //更新
- newStudentEnetey.IsDoubt = true;
- SetModifyStatus(newStudentEnetey);
- newStudentUpList.Add(newStudentEnetey);
- upCount++;
- }
- else
- {
- //标识
- newStudentEnetey.IsDoubt = true;
- SetModifyStatus(newStudentEnetey);
- newStudentUpList.Add(newStudentEnetey);
- inCount++;
- }
- }
- else
- {
- errCount++;
- errorMsgStr = "标识失败,无法对状态为已提交的信息进行标识";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- else
- {
- errCount++;
- errorMsgStr = "标识失败,录取名单信息中不存在此标识名单(新生名单或新生分配信息中存在)";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- }
- if (newStudentUpList != null && newStudentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStudentUpList);
- }
- errdataList = errList.Distinct().ToList();
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 查询标识名单信息View
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="gradeID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="isPhotoUrl"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<NewStudentView> GetNewStudentEnterDoubtViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID, int? educationID, int? learningformID, string learnSystem, int? isPhotoUrl, int pageIndex, int pageSize)
- {
- Expression<Func<CF_NewStudent, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.Assigned);
- exp = exp.And(x => x.IsDoubt == true);
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CollegeID == collegeID);
- }
- if (gradeID.HasValue)
- {
- exp = exp.And(x => x.GradeID == gradeID);
- }
- if (isPhotoUrl.HasValue)
- {
- if (isPhotoUrl.Value == (int)CF_GeneralExist.Have)
- {
- exp = exp.And(x => x.RecruitPictureUrl != null && x.RecruitPictureUrl != "");
- }
- if (isPhotoUrl.Value == (int)CF_GeneralExist.No)
- {
- exp = exp.And(x => x.RecruitPictureUrl == null || x.RecruitPictureUrl == "");
- }
- }
- var query = NewStudentDAL.GetNewStudentEnterViewQueryable(exp);
- if (campusID.HasValue)
- {
- query = query.Where(x => x.CampusID == campusID);
- }
- if (standardID.HasValue)
- {
- query = query.Where(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- query = query.Where(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- query = query.Where(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(learnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeID)
- .ThenBy(x => x.StandardName).ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem)
- .ThenBy(x => x.ExamineeNum.Length).ThenBy(x => x.ExamineeNum).OrderBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ToGridResultSet<NewStudentView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询标识名单信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="gradeID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="isPhotoUrl"></param>
- /// <returns></returns>
- public IList<NewStudentView> GetNewStudentEnterDoubtViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID, int? educationID, int? learningformID, string learnSystem, int? isPhotoUrl)
- {
- Expression<Func<CF_NewStudent, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.Assigned);
- exp = exp.And(x => x.IsDoubt == true);
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CollegeID == collegeID);
- }
- if (gradeID.HasValue)
- {
- exp = exp.And(x => x.GradeID == gradeID);
- }
- if (isPhotoUrl.HasValue)
- {
- if (isPhotoUrl.Value == (int)CF_GeneralExist.Have)
- {
- exp = exp.And(x => x.RecruitPictureUrl != null && x.RecruitPictureUrl != "");
- }
- if (isPhotoUrl.Value == (int)CF_GeneralExist.No)
- {
- exp = exp.And(x => x.RecruitPictureUrl == null || x.RecruitPictureUrl == "");
- }
- }
- var query = NewStudentDAL.GetNewStudentEnterViewQueryable(exp);
- if (campusID.HasValue)
- {
- query = query.Where(x => x.CampusID == campusID);
- }
- if (standardID.HasValue)
- {
- query = query.Where(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- query = query.Where(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- query = query.Where(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(learnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeID)
- .ThenBy(x => x.StandardName).ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem)
- .ThenBy(x => x.ExamineeNum.Length).ThenBy(x => x.ExamineeNum).OrderBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ToList();
- }
- /// <summary>
- /// 审核(确定)
- /// </summary>
- /// <param name="newStudentIDList"></param>
- /// <returns></returns>
- public string NewStudentEnterDoubtApprove(List<Guid?> newStudentIDList)
- {
- try
- {
- //查询新生信息
- var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => newStudentIDList.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.Assigned).ToList();
- int success = 0; //成功
- int fail = 0; //失败
- string tipMessage = null; //提示消息
- List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
- foreach (var newStudentID in newStudentIDList)
- {
- var newStudent = newStudentList.Where(x => x.NewStudentID == newStudentID).SingleOrDefault();
- if (newStudent == null)
- {
- throw new Exception("数据有误,请检查。");
- }
- else
- {
- if (newStudent.AssignStatus == (int)CF_AssignStatus.Assigned)
- {
- newStudent.IsDoubt = false;
- SetModifyStatus(newStudent);
- newStudentUpList.Add(newStudent);
- success++;
- }
- else
- {
- fail++;
- }
- }
- }
- //批量统一提交更新
- if (newStudentUpList != null && newStudentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStudentUpList);
- }
- if (success > 0 && fail <= 0)
- {
- tipMessage = success + "条";
- }
- else
- {
- tipMessage = success + "条," + fail + "条失败,原因:数据有误,请检查";
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 初始化(班级信息、学号)
- /// </summary>
- /// <param name="newStudentIDList"></param>
- /// <returns></returns>
- public string NewStudentEnterInit(List<Guid?> newStudentIDList)
- {
- try
- {
- //查询新生信息
- var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => newStudentIDList.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.Assigned).ToList();
- int success = 0; //成功
- int fail = 0; //失败
- string tipMessage = null; //提示消息
- List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
- foreach (var newStudentID in newStudentIDList)
- {
- var newStudent = newStudentList.Where(x => x.NewStudentID == newStudentID).SingleOrDefault();
- if (newStudent == null)
- {
- throw new Exception("数据有误,请检查。");
- }
- else
- {
- if (newStudent.RecordStatus == (int)CF_NewStudentEnterStatus.NotSubmitted)
- {
- newStudent.ClassmajorID = null;
- newStudent.StudentNo = null;
- SetModifyStatus(newStudent);
- newStudentUpList.Add(newStudent);
- success++;
- }
- else
- {
- fail++;
- }
- }
- }
- //批量统一提交更新
- if (newStudentUpList != null && newStudentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStudentUpList);
- }
- if (success > 0 && fail <= 0)
- {
- tipMessage = success + "条";
- }
- else
- {
- tipMessage = success + "条," + fail + "条失败,原因:无法对已提交状态的信息进行初始化,请检查";
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 手动分配班级和生成学号(此为默认规则,一对一的情况,初始学号为:班级编号+流水号,下一位学号为:对应的最大学号+1)
- /// 注:个性化配置
- /// </summary>
- /// <param name="newStudentIDList"></param>
- /// <param name="classmajorID"></param>
- /// <returns></returns>
- public virtual string NewStudentEnterAssignClass(List<Guid?> newStudentIDList, Guid? classmajorID)
- {
- try
- {
- var studentNoTotal = EMIS.Utility.Const.LOCAL_SETTING_LOGINIDTOTAL;
- if (studentNoTotal == null)
- {
- throw new Exception("学号总位数未配置,请检查。");
- }
- //查询录取名单信息(已分配状态)
- var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => newStudentIDList.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.Assigned).ToList();
- //年级ID
- var gradeIDList = newStudentList.Where(x => !string.IsNullOrEmpty(x.GradeID.ToString())).Select(x => x.GradeID).ToList();
- //专业信息ID
- var specialtyIDList = newStudentList.Where(x => !string.IsNullOrEmpty(x.SpecialtyID.ToString())).Select(x => x.SpecialtyID).ToList();
- //院系所ID
- var collegeIDList = newStudentList.Where(x => !string.IsNullOrEmpty(x.CollegeID.ToString())).Select(x => x.CollegeID).ToList();
- //查询专业信息
- var specialtyList = NewStudentDAL.SpecialtyRepository.GetList(x => specialtyIDList.Contains(x.SpecialtyID)).ToList();
- //查询招生专业信息(暂时不需对招生专业进行验证)
- var recruitSpecialtyAllList = NewStudentDAL.RecruitSpecialtyRepository.GetList(x => true).ToList();
- //查询招生专业
- var recruitSpecialtyList = recruitSpecialtyAllList.Where(x => gradeIDList.Contains(x.GradeID) && specialtyIDList.Contains(x.SpecialtyID) && collegeIDList.Contains(x.CollegeID)).ToList();
- //查询对应的院系专业信息
- var facultymajorList = NewStudentDAL.GetFacultymajorByNewStudent(x => newStudentIDList.Contains(x.NewStudentID)).ToList();
- //院系专业ID
- var facultymajorIDList = facultymajorList.Where(x => !string.IsNullOrEmpty(x.FacultymajorID.ToString())).Select(x => x.FacultymajorID).ToList();
- //查询对应的年级专业信息
- var grademajorList = NewStudentDAL.GetGrademajorByNewStudent(x => newStudentIDList.Contains(x.NewStudentID), x => facultymajorIDList.Contains(x.FacultymajorID)).ToList();
- //年级专业ID
- var grademajorIDList = grademajorList.Where(x => !string.IsNullOrEmpty(x.GrademajorID.ToString())).Select(x => x.GrademajorID).ToList();
- //查询对应的班级信息
- var classmajorList = NewStudentDAL.GetClassmajorByNewStudent(x => newStudentIDList.Contains(x.NewStudentID), x => facultymajorIDList.Contains(x.FacultymajorID), x => grademajorIDList.Contains(x.GrademajorID)).ToList();
- //班级信息ID
- var classmajorIDList = classmajorList.Where(x => !string.IsNullOrEmpty(x.ClassmajorID.ToString())).Select(x => x.ClassmajorID).ToList();
- //查询各班级信息中最大的学号(新生信息表、学生信息表)
- var maxStudentNoList = NewStudentDAL.GetMaxStudentNoClass(x => classmajorIDList.Contains(x.ClassmajorID)).ToList();
- int classmajorfail = 0;
- int fail = 0;
- int success = 0;
- string tipMessage = null;
- long startStudentNo = 0;
- long newStudentNo = 0;
- List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
- foreach (var newStudent in newStudentList)
- {
- //需要对选择的班级信息分别进行验证(一一对应的情况下,才可分配班级及生成学号)
- //查询班级信息(根据新生ID、选择的班级信息ID查询)
- var classmajorVerify = classmajorList.Where(x => x.NewStudentID == newStudent.NewStudentID && x.ClassmajorID == classmajorID).SingleOrDefault();
- //判断对应的班级信息
- if (classmajorVerify != null)
- {
- //判断当选择的信息中存在班级信息或学号等情况(只要两者之中有一个存在,将不考虑生成)
- if (newStudent.ClassmajorID.HasValue || !string.IsNullOrEmpty(newStudent.StudentNo))
- {
- //表示不生成
- fail++;
- continue;
- }
- else
- {
- //查询对应班级信息中最大的学号(新生信息表、学生信息表)
- var maxStudentNo = maxStudentNoList.Where(x => x.ClassmajorID == classmajorID).SingleOrDefault();
- //查询选择生成的录取名单List中是否有分配到同一班级的信息
- var newStudentRepeatList = newStudentUpList.Where(x => x.ClassmajorID == classmajorID).ToList();
- //表示当前班级无对应的学号,此时应为初始学号(班级编号+2位流水号,需匹配Web.config配置)
- if (maxStudentNo == null)
- {
- //初始学号(班级编号+流水号,不够学号总位数的用0填充,可在此处通过个性化配置来定义学号生成规则)
- startStudentNo = Convert.ToInt64(classmajorVerify.ClassmajorNo.PadRight(Convert.ToInt32(studentNoTotal) - 1, '0') + "1");
- //表示无相同班级的信息
- if (newStudentRepeatList.Count <= 0)
- {
- //初始学号
- newStudentNo = startStudentNo;
- }
- else
- {
- //相同班级的信息中最大学号+1,作为下一个学号
- newStudentNo = Convert.ToInt64(newStudentRepeatList.OrderByDescending(x => Convert.ToInt64(x.StudentNo)).FirstOrDefault().StudentNo) + 1;
- }
- }
- else
- {
- //表示无相同班级的信息
- if (newStudentRepeatList.Count <= 0)
- {
- //数据表中的最大学号+1,作为下一个学号
- newStudentNo = Convert.ToInt64(maxStudentNo.StudentNo) + 1;
- }
- else
- {
- //相同班级的信息中最大学号+1,作为下一个学号
- newStudentNo = Convert.ToInt64(newStudentRepeatList.OrderByDescending(x => Convert.ToInt64(x.StudentNo)).FirstOrDefault().StudentNo) + 1;
- }
- }
- newStudent.ClassmajorID = classmajorID;
- newStudent.StudentNo = newStudentNo.ToString();
- SetModifyStatus(newStudent);
- newStudentUpList.Add(newStudent);
- success++;
- }
- }
- else
- {
- //表示选择的班级信息不相符,无法分班及生成学号
- classmajorfail++;
- continue;
- }
- }
- //批量更新
- if (newStudentUpList != null && newStudentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStudentUpList);
- }
- if (classmajorfail <= 0 && fail <= 0)
- {
- tipMessage = success + "条录取名单的学号";
- }
- else
- {
- if (classmajorfail <= 0 && fail > 0)
- {
- tipMessage = success + "个学号,失败" + fail + "条,原因:班级信息或学号已存在,如需生成请初始化后重新生成";
- }
- else if (classmajorfail > 0 && fail <= 0)
- {
- tipMessage = success + "个学号," + classmajorfail + "条由于与选择的班级信息不相符,无法生成,请核查";
- }
- else
- {
- tipMessage = success + "个学号," + fail + "条由于班级信息或学号已存在无法生成," + classmajorfail + "条由于与选择的班级信息不相符,无法生成,请核查";
- }
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 自动分配班级和生成学号
- /// 注:个性化配置
- /// 此为默认规则,一对一的情况,初始学号为:班级编号+流水号,下一位学号为:对应的最大学号+1)
- /// 目前只支持,学号=班级编号+流水号的情况,针对学号生成规则不同、专业分方向、有两个班以上等等情况,需要进行扩展-普教版本
- /// </summary>
- /// <param name="newStudentIDList"></param>
- /// <returns></returns>
- public virtual string NewStudentEnterAutoAssignClass(List<Guid?> newStudentIDList)
- {
- try
- {
- var studentNoTotal = EMIS.Utility.Const.LOCAL_SETTING_LOGINIDTOTAL;
- if (studentNoTotal == null)
- {
- throw new Exception("学号总位数未配置,请检查。");
- }
- //查询录取名单信息(已分配状态)
- var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => newStudentIDList.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.Assigned).ToList();
- //年级ID
- var gradeIDList = newStudentList.Where(x => !string.IsNullOrEmpty(x.GradeID.ToString())).Select(x => x.GradeID).ToList();
- //专业信息ID
- var specialtyIDList = newStudentList.Where(x => !string.IsNullOrEmpty(x.SpecialtyID.ToString())).Select(x => x.SpecialtyID).ToList();
- //院系所ID
- var collegeIDList = newStudentList.Where(x => !string.IsNullOrEmpty(x.CollegeID.ToString())).Select(x => x.CollegeID).ToList();
- //查询专业信息
- var specialtyList = NewStudentDAL.SpecialtyRepository.GetList(x => specialtyIDList.Contains(x.SpecialtyID)).ToList();
- //查询招生专业信息(暂时不需对招生专业进行验证)
- var recruitSpecialtyAllList = NewStudentDAL.RecruitSpecialtyRepository.GetList(x => true).ToList();
- //查询招生专业
- var recruitSpecialtyList = recruitSpecialtyAllList.Where(x => gradeIDList.Contains(x.GradeID) && specialtyIDList.Contains(x.SpecialtyID) && collegeIDList.Contains(x.CollegeID)).ToList();
- //查询对应的院系专业信息
- var facultymajorList = NewStudentDAL.GetFacultymajorByNewStudent(x => newStudentIDList.Contains(x.NewStudentID)).ToList();
- //院系专业ID
- var facultymajorIDList = facultymajorList.Where(x => !string.IsNullOrEmpty(x.FacultymajorID.ToString())).Select(x => x.FacultymajorID).ToList();
- //查询对应的年级专业信息
- var grademajorList = NewStudentDAL.GetGrademajorByNewStudent(x => newStudentIDList.Contains(x.NewStudentID), x => facultymajorIDList.Contains(x.FacultymajorID)).ToList();
- //年级专业ID
- var grademajorIDList = grademajorList.Where(x => !string.IsNullOrEmpty(x.GrademajorID.ToString())).Select(x => x.GrademajorID).ToList();
- //查询对应的班级信息
- var classmajorList = NewStudentDAL.GetClassmajorByNewStudent(x => newStudentIDList.Contains(x.NewStudentID), x => facultymajorIDList.Contains(x.FacultymajorID), x => grademajorIDList.Contains(x.GrademajorID)).ToList();
- //班级信息ID
- var classmajorIDList = classmajorList.Where(x => !string.IsNullOrEmpty(x.ClassmajorID.ToString())).Select(x => x.ClassmajorID).ToList();
- //查询各班级信息中最大的学号(新生信息表、学生信息表)
- var maxStudentNoList = NewStudentDAL.GetMaxStudentNoClass(x => classmajorIDList.Contains(x.ClassmajorID)).ToList();
- int facultymajorfail = 0;
- int grademajorfail = 0;
- int classmajorfail = 0;
- int fail = 0;
- int success = 0;
- string tipMessage = null;
- long startStudentNo = 0;
- long newStudentNo = 0;
- List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
- foreach (var newStudent in newStudentList)
- {
- //需要对院系专业、年级专业、班级信息分别进行验证(一一对应的情况下,才可自动分配班级及生成学号)
- //查询院系专业
- var facultymajorVerify = facultymajorList.Where(x => x.NewStudentID == newStudent.NewStudentID).ToList();
- //判断对应的院系专业
- if (facultymajorVerify != null && facultymajorVerify.Count() > 0)
- {
- if (facultymajorVerify.Count() == 1)
- {
- //查询年级专业
- var grademajorVerify = grademajorList.Where(x => x.NewStudentID == newStudent.NewStudentID).ToList();
- //判断对应的年级专业
- if (grademajorVerify != null && grademajorVerify.Count() > 0)
- {
- if (grademajorVerify.Count() == 1)
- {
- //查询班级信息
- var classmajorVerify = classmajorList.Where(x => x.NewStudentID == newStudent.NewStudentID).ToList();
- //判断对应的班级信息
- if (classmajorVerify != null && classmajorVerify.Count() > 0)
- {
- if (classmajorVerify.Count() == 1)
- {
- //判断当选择的信息中存在班级信息或学号等情况(只要两者之中有一个存在,将不考虑生成)
- if (newStudent.ClassmajorID.HasValue || !string.IsNullOrEmpty(newStudent.StudentNo))
- {
- //表示不生成
- fail++;
- continue;
- }
- else
- {
- //对可分配的班级信息及学号进行查询
- //查询对应班级信息中最大的学号(新生信息表、学生信息表)
- var specialtyClass = classmajorVerify.Where(x => x.NewStudentID == newStudent.NewStudentID).SingleOrDefault();
- var maxStudentNo = maxStudentNoList.Where(x => x.ClassmajorID == specialtyClass.ClassmajorID).SingleOrDefault();
- //查询选择生成的录取名单List中是否有分配到同一班级的信息
- var newStudentRepeatList = newStudentUpList.Where(x => x.ClassmajorID == specialtyClass.ClassmajorID).ToList();
- //表示当前班级无对应的学号,此时应为初始学号(班级编号+2位流水号,需匹配Web.config配置)
- if (maxStudentNo == null)
- {
- //初始学号(班级编号+流水号,不够学号总位数的用0填充,可在此处通过个性化配置来定义学号生成规则)
- startStudentNo = Convert.ToInt64(specialtyClass.ClassmajorNo.PadRight(Convert.ToInt32(studentNoTotal) - 1, '0') + "1");
- //表示无相同班级的信息
- if (newStudentRepeatList.Count <= 0)
- {
- //初始学号
- newStudentNo = startStudentNo;
- }
- else
- {
- //相同班级的信息中最大学号+1,作为下一个学号
- newStudentNo = Convert.ToInt64(newStudentRepeatList.OrderByDescending(x => Convert.ToInt64(x.StudentNo)).FirstOrDefault().StudentNo) + 1;
- }
- }
- else
- {
- //表示无相同班级的信息
- if (newStudentRepeatList.Count <= 0)
- {
- //数据表中的最大学号+1,作为下一个学号
- newStudentNo = Convert.ToInt64(maxStudentNo.StudentNo) + 1;
- }
- else
- {
- //相同班级的信息中最大学号+1,作为下一个学号
- newStudentNo = Convert.ToInt64(newStudentRepeatList.OrderByDescending(x => Convert.ToInt64(x.StudentNo)).FirstOrDefault().StudentNo) + 1;
- }
- }
- newStudent.ClassmajorID = specialtyClass.ClassmajorID;
- newStudent.StudentNo = newStudentNo.ToString();
- SetModifyStatus(newStudent);
- newStudentUpList.Add(newStudent);
- success++;
- }
- }
- else
- {
- //表示对应的班级信息存在多个,无法确定对应的班级信息(可在此处进行扩展,针对专业分方向的情况)
- classmajorfail++;
- continue;
- }
- }
- else
- {
- //表示对应的班级信息不存在,无法分班及生成学号
- classmajorfail++;
- continue;
- }
- }
- else
- {
- //表示对应的年级专业信息存在多个,无法确定对应的年级专业(可在此处进行扩展,针对专业分方向的情况)
- grademajorfail++;
- continue;
- }
- }
- else
- {
- //表示对应的年级专业信息不存在,无法分班及生成学号
- grademajorfail++;
- continue;
- }
- }
- else
- {
- //表示对应的院系专业信息存在多个,无法确定对应的院系专业(可在此处进行扩展,针对专业分方向的情况)
- facultymajorfail++;
- continue;
- }
- }
- else
- {
- //表示对应的院系专业信息不存在,无法分班及生成学号
- facultymajorfail++;
- continue;
- }
- }
- //批量更新
- if (newStudentUpList != null && newStudentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStudentUpList);
- }
- if (facultymajorfail <= 0 && grademajorfail <= 0 && classmajorfail <= 0 && fail <= 0)
- {
- tipMessage = success + "个学号";
- }
- else
- {
- if (facultymajorfail <= 0 && grademajorfail <= 0 && classmajorfail <= 0 && fail > 0)
- {
- tipMessage = success + "个学号,失败" + fail + "条,原因:班级信息或学号已存在,如需生成请初始化后重新生成";
- }
- else if (facultymajorfail > 0 && grademajorfail <= 0 && classmajorfail <= 0 && fail <= 0)
- {
- tipMessage = success + "个学号," + facultymajorfail + "条由于院系专业信息的原因无法生成,请核查";
- }
- else if (facultymajorfail <= 0 && grademajorfail > 0 && classmajorfail <= 0 && fail <= 0)
- {
- tipMessage = success + "个学号," + grademajorfail + "条由于年级专业信息的原因无法生成,请核查";
- }
- else if (facultymajorfail <= 0 && grademajorfail <= 0 && classmajorfail > 0 && fail <= 0)
- {
- tipMessage = success + "个学号," + classmajorfail + "条由于班级信息的原因无法生成,请核查";
- }
- else
- {
- tipMessage = success + "个学号," + fail + "条由于班级信息或学号已存在无法生成," + facultymajorfail + "条由于院系专业信息的原因无法生成," +
- grademajorfail + "条由于年级专业信息的原因无法生成," + classmajorfail + "条由于班级信息的原因无法生成,请核查";
- }
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 提交(需判断是否已分班且生成学号,并对学生信息进行验证,如:考生号或准考证号唯一、学号唯一)
- /// 注:个性化配置
- /// 此为默认规则
- /// </summary>
- /// <param name="newStudentIDList"></param>
- /// <returns></returns>
- public virtual 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 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);
- }
- }
- }
- }
|