NewStudentEnterServices.cs 114 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Linq.Expressions;
  6. using System.Text;
  7. using System.Text.RegularExpressions;
  8. using System.Transactions;
  9. using System.IO;
  10. using Bowin.Common.Utility;
  11. using Bowin.Common.Linq;
  12. using Bowin.Common.Linq.Entity;
  13. using EMIS.Utility;
  14. using EMIS.Entities;
  15. using EMIS.ViewModel;
  16. using EMIS.ViewModel.EnrollManage.NewStudentManage;
  17. using EMIS.DataLogic.EnrollManage.NewStudentManage;
  18. using EMIS.CommonLogic.Students;
  19. namespace EMIS.CommonLogic.EnrollManage.NewStudentManage
  20. {
  21. public class NewStudentEnterServices : BaseServices, INewStudentEnterServices
  22. {
  23. public NewStudentDAL NewStudentDAL { get; set; }
  24. public Lazy<IStudentsServices> StudentServices { get; set; }
  25. /// <summary>
  26. /// 查询录取名单信息View
  27. /// </summary>
  28. /// <param name="configuretView"></param>
  29. /// <param name="campusID"></param>
  30. /// <param name="collegeID"></param>
  31. /// <param name="gradeID"></param>
  32. /// <param name="standardID"></param>
  33. /// <param name="educationID"></param>
  34. /// <param name="learningformID"></param>
  35. /// <param name="learnSystem"></param>
  36. /// <param name="grademajorID"></param>
  37. /// <param name="classmajorID"></param>
  38. /// <param name="generalPurpose"></param>
  39. /// <param name="generalExist"></param>
  40. /// <param name="dictionaryNewStudentEnterStatus"></param>
  41. /// <param name="pageIndex"></param>
  42. /// <param name="pageSize"></param>
  43. /// <returns></returns>
  44. public IGridResultSet<NewStudentView> GetNewStudentEnterViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID,
  45. int? educationID, int? learningformID, string learnSystem, Guid? grademajorID, Guid? classmajorID, int? generalPurpose, int? generalExist, int? dictionaryNewStudentEnterStatus, int pageIndex, int pageSize)
  46. {
  47. Expression<Func<CF_NewStudent, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  48. exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.Assigned);
  49. if (collegeID.HasValue)
  50. {
  51. exp = exp.And(x => x.CollegeID == collegeID);
  52. }
  53. if (gradeID.HasValue)
  54. {
  55. exp = exp.And(x => x.GradeID == gradeID);
  56. }
  57. if (classmajorID.HasValue)
  58. {
  59. exp = exp.And(x => x.ClassmajorID == classmajorID);
  60. }
  61. if (generalPurpose.HasValue)
  62. {
  63. if (generalPurpose == 1)
  64. {
  65. exp = exp.And(x => x.IsDoubt == true);
  66. }
  67. if (generalPurpose == 0)
  68. {
  69. exp = exp.And(x => x.IsDoubt != true);
  70. }
  71. }
  72. if (dictionaryNewStudentEnterStatus.HasValue)
  73. {
  74. exp = exp.And(x => x.RecordStatus == dictionaryNewStudentEnterStatus);
  75. }
  76. var query = NewStudentDAL.GetNewStudentEnterViewQueryable(exp);
  77. if (campusID.HasValue)
  78. {
  79. query = query.Where(x => x.CampusID == campusID);
  80. }
  81. if (standardID.HasValue)
  82. {
  83. query = query.Where(x => x.StandardID == standardID);
  84. }
  85. if (educationID.HasValue)
  86. {
  87. query = query.Where(x => x.EducationID == educationID);
  88. }
  89. if (learningformID.HasValue)
  90. {
  91. query = query.Where(x => x.LearningformID == learningformID);
  92. }
  93. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  94. {
  95. var LearnSystems = Convert.ToDecimal(learnSystem);
  96. query = query.Where(x => x.LearnSystem == LearnSystems);
  97. }
  98. if (grademajorID.HasValue)
  99. {
  100. query = query.Where(x => x.GrademajorID == grademajorID);
  101. }
  102. if (generalExist.HasValue)
  103. {
  104. if (generalExist.Value == (int)CF_GeneralExist.Have)
  105. {
  106. query = query.Where(x => !string.IsNullOrEmpty(x.StudentNo));
  107. }
  108. if (generalExist.Value == (int)CF_GeneralExist.No)
  109. {
  110. query = query.Where(x => string.IsNullOrEmpty(x.StudentNo));
  111. }
  112. }
  113. //查询条件
  114. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  115. {
  116. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  117. }
  118. return this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.GradeID).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  119. .ThenBy(x => x.StandardName).ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem)
  120. .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ToGridResultSet<NewStudentView>(pageIndex, pageSize);
  121. }
  122. /// <summary>
  123. /// 查询录取名单信息List
  124. /// </summary>
  125. /// <param name="configuretView"></param>
  126. /// <param name="campusID"></param>
  127. /// <param name="collegeID"></param>
  128. /// <param name="gradeID"></param>
  129. /// <param name="standardID"></param>
  130. /// <param name="educationID"></param>
  131. /// <param name="learningformID"></param>
  132. /// <param name="learnSystem"></param>
  133. /// <param name="grademajorID"></param>
  134. /// <param name="classmajorID"></param>
  135. /// <param name="generalPurpose"></param>
  136. /// <param name="generalExist"></param>
  137. /// <param name="dictionaryNewStudentEnterStatus"></param>
  138. /// <returns></returns>
  139. public IList<NewStudentView> GetNewStudentEnterViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID,
  140. int? educationID, int? learningformID, string learnSystem, Guid? grademajorID, Guid? classmajorID, int? generalPurpose, int? generalExist, int? dictionaryNewStudentEnterStatus)
  141. {
  142. Expression<Func<CF_NewStudent, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  143. exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.Assigned);
  144. if (collegeID.HasValue)
  145. {
  146. exp = exp.And(x => x.CollegeID == collegeID);
  147. }
  148. if (gradeID.HasValue)
  149. {
  150. exp = exp.And(x => x.GradeID == gradeID);
  151. }
  152. if (classmajorID.HasValue)
  153. {
  154. exp = exp.And(x => x.ClassmajorID == classmajorID);
  155. }
  156. if (generalPurpose.HasValue)
  157. {
  158. if (generalPurpose == 1)
  159. {
  160. exp = exp.And(x => x.IsDoubt == true);
  161. }
  162. if (generalPurpose == 0)
  163. {
  164. exp = exp.And(x => x.IsDoubt != true);
  165. }
  166. }
  167. if (dictionaryNewStudentEnterStatus.HasValue)
  168. {
  169. exp = exp.And(x => x.RecordStatus == dictionaryNewStudentEnterStatus);
  170. }
  171. var query = NewStudentDAL.GetNewStudentEnterViewQueryable(exp);
  172. if (campusID.HasValue)
  173. {
  174. query = query.Where(x => x.CampusID == campusID);
  175. }
  176. if (standardID.HasValue)
  177. {
  178. query = query.Where(x => x.StandardID == standardID);
  179. }
  180. if (educationID.HasValue)
  181. {
  182. query = query.Where(x => x.EducationID == educationID);
  183. }
  184. if (learningformID.HasValue)
  185. {
  186. query = query.Where(x => x.LearningformID == learningformID);
  187. }
  188. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  189. {
  190. var LearnSystems = Convert.ToDecimal(learnSystem);
  191. query = query.Where(x => x.LearnSystem == LearnSystems);
  192. }
  193. if (grademajorID.HasValue)
  194. {
  195. query = query.Where(x => x.GrademajorID == grademajorID);
  196. }
  197. if (generalExist.HasValue)
  198. {
  199. if (generalExist.Value == (int)CF_GeneralExist.Have)
  200. {
  201. query = query.Where(x => !string.IsNullOrEmpty(x.StudentNo));
  202. }
  203. if (generalExist.Value == (int)CF_GeneralExist.No)
  204. {
  205. query = query.Where(x => string.IsNullOrEmpty(x.StudentNo));
  206. }
  207. }
  208. //查询条件
  209. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  210. {
  211. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  212. }
  213. return this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.GradeID).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  214. .ThenBy(x => x.StandardName).ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem)
  215. .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ToList();
  216. }
  217. /// <summary>
  218. /// 查询对应的录取名单信息NewStudentView
  219. /// </summary>
  220. /// <param name="newStudentID"></param>
  221. /// <returns></returns>
  222. public NewStudentView GetNewStudentEnterView(Guid? newStudentID)
  223. {
  224. try
  225. {
  226. Expression<Func<CF_NewStudent, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  227. exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.Assigned);
  228. exp = exp.And(x => x.NewStudentID == newStudentID);
  229. var query = NewStudentDAL.GetNewStudentEnterViewQueryable(exp).SingleOrDefault();
  230. return query;
  231. }
  232. catch (Exception ex)
  233. {
  234. throw new Exception(ex.Message);
  235. }
  236. }
  237. /// <summary>
  238. /// 录取查询
  239. /// </summary>
  240. /// <param name="examineeNum"></param>
  241. /// <param name="userName"></param>
  242. /// <returns></returns>
  243. public NewStudentView GetNewStudentEnterView(string examineeNum, string userName)
  244. {
  245. try
  246. {
  247. Expression<Func<CF_NewStudent, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  248. exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.Assigned);
  249. exp = exp.And(x => x.ExamineeNum == examineeNum);
  250. exp = exp.And(x => x.Name == userName);
  251. var query = NewStudentDAL.GetNewStudentEnterViewQueryable(exp).SingleOrDefault();
  252. return query;
  253. }
  254. catch (Exception ex)
  255. {
  256. throw new Exception(ex.Message);
  257. }
  258. }
  259. /// <summary>
  260. /// 编辑(新增、修改,业务主键:考生号唯一)
  261. /// 注:需对相应的业务进行处理,如:学号等
  262. /// </summary>
  263. /// <param name="newStudentView"></param>
  264. /// <param name="photoUrl"></param>
  265. public void NewStudentEnterEdit(NewStudentView newStudentView, string photoUrl)
  266. {
  267. try
  268. {
  269. //查询对应的招生专业信息
  270. var recruitSpecialty = NewStudentDAL.RecruitSpecialtyRepository.GetList(x => x.GradeID == newStudentView.GradeID
  271. && x.CollegeID == newStudentView.CollegeID && x.SpecialtyID == newStudentView.SpecialtyID).SingleOrDefault();
  272. if (recruitSpecialty == null)
  273. {
  274. throw new Exception("对应的招生专业不存在(未开设相对应的招生专业)。");
  275. }
  276. //查询对应的专业信息
  277. var specialty = NewStudentDAL.SpecialtyRepository.GetList(x => x.SpecialtyID == newStudentView.SpecialtyID).SingleOrDefault();
  278. //根据专业信息和选择的院系所查询院系专业信息
  279. var facultymajorList = NewStudentDAL.FacultymajorRepository.GetList(x => x.CollegeID == newStudentView.CollegeID
  280. && x.StandardID == specialty.StandardID && x.EducationID == specialty.EducationID
  281. && x.LearningformID == specialty.LearningformID && x.LearnSystem == specialty.LearnSystem).Select(x => x.FacultymajorID).ToList();
  282. //if (facultymajorList.Count == 0)
  283. //{
  284. // throw new Exception(RSL.Get("College") + "对应的专业不存在(院系专业信息)。");
  285. //}
  286. //根据院系专业和新生的年级查询年级专业信息
  287. var grademajorList = NewStudentDAL.GrademajorRepository.GetList(x => facultymajorList.Contains(x.FacultymajorID.Value)
  288. && x.GradeID == newStudentView.GradeID, x => x.CF_Classmajor).Select(x => x.GrademajorID).ToList();
  289. //if (grademajorList.Count == 0)
  290. //{
  291. // throw new Exception("年级对应的专业不存在(年级专业信息)。");
  292. //}
  293. //根据年级专业查询班级信息
  294. var classajorList = NewStudentDAL.ClassmajorRepository.GetList(x => grademajorList.Contains(x.GrademajorID.Value)).ToList();
  295. //if (classajorList.Count == 0)
  296. //{
  297. // throw new Exception("对应的班级信息不存在。");
  298. //}
  299. if (newStudentView.ClassmajorID != null)
  300. {
  301. var classajor = classajorList.Where(x => x.ClassmajorID == newStudentView.ClassmajorID).FirstOrDefault();
  302. if (classajor == null)
  303. {
  304. throw new Exception("选择的班级信息与对应的专业信息不相符。");
  305. }
  306. }
  307. //查询数据库进行验证
  308. var examineeNumVerify = NewStudentDAL.NewStudentRepository.GetList(x => x.NewStudentID != newStudentView.NewStudentID
  309. && x.ExamineeNum == newStudentView.ExamineeNum.Trim()).SingleOrDefault();
  310. if (examineeNumVerify == null)
  311. {
  312. //if (!string.IsNullOrEmpty(newStudentView.AdmissionTicketNo))
  313. //{
  314. // var admissionTicketNoVerify = NewStudentDAL.NewStudentRepository.GetList(x => x.NewStudentID != newStudentView.NewStudentID
  315. // && x.AdmissionTicketNo == newStudentView.AdmissionTicketNo.Trim()).SingleOrDefault();
  316. // if (admissionTicketNoVerify != null)
  317. // {
  318. // if (admissionTicketNoVerify.AssignStatus == (int)CF_AssignStatus.NotAssigned)
  319. // {
  320. // throw new Exception("新生名单信息中已存在此准考证号(准考证号重复),请核查。");
  321. // }
  322. // else if (admissionTicketNoVerify.AssignStatus == (int)CF_AssignStatus.PreAssigned)
  323. // {
  324. // throw new Exception("新生分配信息中已存在此准考证号(准考证号重复),请核查。");
  325. // }
  326. // else
  327. // {
  328. // throw new Exception("已存在相同的准考证号(准考证号重复),请核查。");
  329. // }
  330. // }
  331. //}
  332. //查询Web.config学号位数配置
  333. var studentNoTotal = EMIS.Utility.Const.LOCAL_SETTING_LOGINIDTOTAL;
  334. if (!string.IsNullOrEmpty(newStudentView.StudentNo))
  335. {
  336. if (studentNoTotal == null)
  337. {
  338. throw new Exception("学号总位数未配置,请检查。");
  339. }
  340. else
  341. {
  342. //有学号一定要有班级信息
  343. if (!newStudentView.ClassmajorID.HasValue)
  344. {
  345. throw new Exception("请选择对应的班级名称(学号不为空时,班级名称不能为空)。");
  346. }
  347. else
  348. {
  349. //新生名单信息数据重复性验证(学号唯一)
  350. var newStudentNoVerify = NewStudentDAL.NewStudentRepository.GetList(x => x.NewStudentID != newStudentView.NewStudentID
  351. && x.AssignStatus == (int)CF_AssignStatus.Assigned && x.StudentNo == newStudentView.StudentNo.Trim()).SingleOrDefault();
  352. if (newStudentNoVerify != null)
  353. {
  354. throw new Exception("录取名单中已存在此学号(学号重复),请检查。");
  355. }
  356. //用户信息数据重复性验证(用户名唯一)
  357. var userVerify = NewStudentDAL.UserRepository.GetList(x => x.LoginID == newStudentView.StudentNo.Trim()).SingleOrDefault();
  358. if (userVerify != null)
  359. {
  360. //学生信息数据重复性验证(学号唯一,根据业务主键排除)
  361. var studentNoVerify = NewStudentDAL.StudentRepository.GetList(x => true, (x => x.CF_Recruitstudents), (x => x.Sys_User))
  362. .Where(x => (x.IDNumber != newStudentView.IDNumber && x.CF_Recruitstudents.ExamineeNum != newStudentView.ExamineeNum)
  363. && x.Sys_User.LoginID == newStudentView.StudentNo.Trim()).SingleOrDefault();
  364. if (studentNoVerify != null)
  365. {
  366. throw new Exception("学生信息中已存在此学号,请检查。");
  367. }
  368. else
  369. {
  370. studentNoVerify = NewStudentDAL.StudentRepository.GetList(x => true, (x => x.Sys_User))
  371. .Where(x => x.Sys_User.LoginID == newStudentView.StudentNo.Trim()).SingleOrDefault();
  372. if (studentNoVerify == null)
  373. {
  374. throw new Exception("用户信息中已存在相同的用户(用户名重复),请核查。");
  375. }
  376. }
  377. }
  378. //判断学号位数与Web.config配置位数是否一致
  379. if (newStudentView.StudentNo.Length != Convert.ToInt32(studentNoTotal))
  380. {
  381. throw new Exception("输入的学号总位数有误,学号总位数应为" + studentNoTotal + "位。");
  382. }
  383. }
  384. }
  385. }
  386. //查询最大的录取通知编号(只查询已分配状态的信息--录取名单,业务主键:年级、院系所)
  387. var maxCollegeEnrollment = NewStudentDAL.GetEnrollmentNo(x => x.GradeID == newStudentView.GradeID && x.CollegeID == newStudentView.CollegeID && x.AssignStatus == (int)CF_AssignStatus.Assigned).SingleOrDefault();
  388. //查询院系所信息
  389. var college = NewStudentDAL.CollegeRepository.GetList(x => x.CollegeID == newStudentView.CollegeID).SingleOrDefault();
  390. //通知书编号
  391. long newEnrollmentNo = 0;
  392. if (maxCollegeEnrollment == null)
  393. {
  394. //表示初始录取通书编号
  395. int total = (newStudentView.GradeID.ToString() + college.No).Length;
  396. newEnrollmentNo = Convert.ToInt64((newStudentView.GradeID.ToString() + college.No).PadRight(total + 4, '0') + "1");
  397. }
  398. else
  399. {
  400. newEnrollmentNo = Convert.ToInt64(maxCollegeEnrollment.EnrollmentNo) + 1;
  401. }
  402. //数据有误验证
  403. if (newStudentView.NewStudentID != Guid.Empty)
  404. {
  405. var newStudent = NewStudentDAL.NewStudentRepository.GetList(x => x.NewStudentID == newStudentView.NewStudentID
  406. && x.AssignStatus == (int)CF_AssignStatus.Assigned).SingleOrDefault();
  407. if (newStudent == null)
  408. {
  409. throw new Exception("数据有误,请核查。");
  410. }
  411. else
  412. {
  413. //表示修改
  414. newStudent.ExamineeNum = newStudentView.ExamineeNum;
  415. newStudent.AdmissionTicketNo = newStudentView.AdmissionTicketNo;
  416. newStudent.Name = newStudentView.Name;
  417. newStudent.SexID = newStudentView.SexID;
  418. newStudent.NationID = newStudentView.NationID;
  419. newStudent.PoliticsID = newStudentView.PoliticsID;
  420. newStudent.BirthDate = newStudentView.BirthDate;
  421. newStudent.CertificatesType = newStudentView.CertificatesType;
  422. newStudent.IDNumber = newStudentView.IDNumber;
  423. newStudent.GradeID = newStudentView.GradeID;
  424. newStudent.SemesterID = newStudentView.SemesterID;
  425. newStudent.SpecialtyID = newStudentView.SpecialtyID;
  426. newStudent.EntranceDate = newStudentView.EntranceDate;
  427. newStudent.Score = newStudentView.Score;
  428. newStudent.Telephone = newStudentView.Telephone;
  429. newStudent.ZIPCode = newStudentView.ZIPCode;
  430. newStudent.EntranceWayID = newStudentView.EntranceWayID;
  431. newStudent.FeaturesID = newStudentView.FeaturesID;
  432. newStudent.TerritorialID = newStudentView.TerritorialID;
  433. newStudent.Address = newStudentView.Address;
  434. newStudent.Dormitory = newStudentView.Dormitory;
  435. //如果相关的年级或院系所有变动,此处要生成相应的录取通知书编号
  436. if (newStudent.GradeID != newStudentView.GradeID || newStudent.CollegeID != newStudentView.CollegeID)
  437. {
  438. newStudent.EnrollmentNo = newEnrollmentNo.ToString();
  439. }
  440. if (!string.IsNullOrEmpty(photoUrl))
  441. {
  442. newStudent.RecruitPictureUrl = photoUrl;
  443. }
  444. newStudent.CollegeID = newStudentView.CollegeID;
  445. newStudent.ClassmajorID = newStudentView.ClassmajorID;
  446. newStudent.StudentNo = newStudentView.StudentNo;
  447. newStudent.Remark = newStudentView.Remark;
  448. SetModifyStatus(newStudent);
  449. }
  450. }
  451. else
  452. {
  453. //表示新增
  454. var newStudent = new CF_NewStudent();
  455. newStudent.NewStudentID = Guid.NewGuid();
  456. newStudent.ExamineeNum = newStudentView.ExamineeNum;
  457. newStudent.AdmissionTicketNo = newStudentView.AdmissionTicketNo;
  458. newStudent.Name = newStudentView.Name;
  459. newStudent.SexID = newStudentView.SexID;
  460. newStudent.NationID = newStudentView.NationID;
  461. newStudent.PoliticsID = newStudentView.PoliticsID;
  462. newStudent.BirthDate = newStudentView.BirthDate;
  463. newStudent.CertificatesType = newStudentView.CertificatesType;
  464. newStudent.IDNumber = newStudentView.IDNumber;
  465. newStudent.GradeID = newStudentView.GradeID;
  466. newStudent.SemesterID = newStudentView.SemesterID;
  467. newStudent.SpecialtyID = newStudentView.SpecialtyID;
  468. newStudent.EntranceDate = newStudentView.EntranceDate;
  469. newStudent.Score = newStudentView.Score;
  470. newStudent.Telephone = newStudentView.Telephone;
  471. newStudent.ZIPCode = newStudentView.ZIPCode;
  472. newStudent.EntranceWayID = newStudentView.EntranceWayID;
  473. newStudent.FeaturesID = newStudentView.FeaturesID;
  474. newStudent.TerritorialID = newStudentView.TerritorialID;
  475. newStudent.Address = newStudentView.Address;
  476. newStudent.Dormitory = newStudentView.Dormitory;
  477. newStudent.EnrollmentNo = newEnrollmentNo.ToString();
  478. if (!string.IsNullOrEmpty(photoUrl))
  479. {
  480. newStudent.RecruitPictureUrl = photoUrl;
  481. }
  482. newStudent.IsDoubt = false;
  483. newStudent.AssignStatus = (int)CF_AssignStatus.Assigned;
  484. newStudent.CollegeID = newStudentView.CollegeID;
  485. newStudent.ClassmajorID = newStudentView.ClassmajorID;
  486. newStudent.StudentNo = newStudentView.StudentNo;
  487. newStudent.Remark = newStudentView.Remark;
  488. SetNewStatus(newStudent, (int)CF_NewStudentEnterStatus.NotSubmitted);
  489. UnitOfWork.Add(newStudent);
  490. }
  491. }
  492. else
  493. {
  494. if (examineeNumVerify.AssignStatus == (int)CF_AssignStatus.NotAssigned)
  495. {
  496. throw new Exception("新生名单信息中已存在此考生号(考生号重复),请核查。");
  497. }
  498. else if (examineeNumVerify.AssignStatus == (int)CF_AssignStatus.PreAssigned)
  499. {
  500. throw new Exception("新生分配信息中已存在此考生号(考生号重复),请核查。");
  501. }
  502. else
  503. {
  504. throw new Exception("已存在相同的考生号(考生号重复),请核查。");
  505. }
  506. }
  507. UnitOfWork.Commit();
  508. }
  509. catch (Exception ex)
  510. {
  511. throw new Exception(ex.Message);
  512. }
  513. }
  514. /// <summary>
  515. /// 删除
  516. /// </summary>
  517. /// <param name="newStudentIDList"></param>
  518. /// <returns></returns>
  519. public bool NewStudentEnterDelete(List<Guid?> newStudentIDList)
  520. {
  521. try
  522. {
  523. UnitOfWork.Delete<CF_NewStudent>(x => newStudentIDList.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.Assigned);
  524. return true;
  525. }
  526. catch (Exception)
  527. {
  528. throw;
  529. }
  530. }
  531. /// <summary>
  532. /// 删除照片(单个删除)
  533. /// </summary>
  534. /// <param name="newStudentID"></param>
  535. public void DeletePhoto(Guid? newStudentID)
  536. {
  537. try
  538. {
  539. var newStudent = NewStudentDAL.NewStudentRepository.GetList(x => x.NewStudentID == newStudentID && x.AssignStatus == (int)CF_AssignStatus.Assigned).SingleOrDefault();
  540. if (newStudent != null)
  541. {
  542. if (!string.IsNullOrEmpty(newStudent.RecruitPictureUrl))
  543. {
  544. FileUploadHelper.DeleteFile(newStudent.RecruitPictureUrl);
  545. newStudent.RecruitPictureUrl = null;
  546. this.UnitOfWork.Commit();
  547. }
  548. else
  549. {
  550. throw new Exception("对应的照片不存在。");
  551. }
  552. }
  553. else
  554. {
  555. throw new Exception("对应的信息未保存,数据有误。");
  556. }
  557. }
  558. catch (Exception ex)
  559. {
  560. throw new Exception(ex.Message);
  561. }
  562. }
  563. /// <summary>
  564. /// 删除照片(批量删除)
  565. /// </summary>
  566. /// <param name="newStudentIDs"></param>
  567. /// <returns></returns>
  568. public bool PicDelete(List<Guid?> newStudentIDs)
  569. {
  570. try
  571. {
  572. List<string> photoUrlList = new List<string>();
  573. List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
  574. var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => newStudentIDs.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.Assigned).ToList();
  575. foreach (var newStudent in newStudentList)
  576. {
  577. if (newStudent != null)
  578. {
  579. if (!string.IsNullOrEmpty(newStudent.RecruitPictureUrl))
  580. {
  581. photoUrlList.Add(newStudent.RecruitPictureUrl);
  582. newStudent.RecruitPictureUrl = null;
  583. newStudentUpList.Add(newStudent);
  584. }
  585. }
  586. }
  587. using (TransactionScope ts = new TransactionScope())
  588. {
  589. foreach (var photoUrl in photoUrlList)
  590. {
  591. FileUploadHelper.DeleteFile(photoUrl);
  592. }
  593. if (newStudentUpList != null && newStudentUpList.Count() > 0)
  594. {
  595. UnitOfWork.BatchUpdate(newStudentUpList);
  596. }
  597. //this.UnitOfWork.Commit();
  598. ts.Complete();
  599. }
  600. return true;
  601. }
  602. catch (Exception)
  603. {
  604. throw;
  605. }
  606. }
  607. /// <summary>
  608. /// 取消分配
  609. /// </summary>
  610. /// <param name="newStudentIDList"></param>
  611. /// <returns></returns>
  612. public string NewStudentEnterCancelAssignCollege(List<Guid?> newStudentIDList)
  613. {
  614. try
  615. {
  616. //查询新生信息
  617. var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => newStudentIDList.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.Assigned).ToList();
  618. int success = 0; //成功
  619. int fail = 0; //失败
  620. string tipMessage = null; //提示消息
  621. List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
  622. foreach (var newStudentID in newStudentIDList)
  623. {
  624. var newStudent = newStudentList.Where(x => x.NewStudentID == newStudentID).SingleOrDefault();
  625. if (newStudent == null)
  626. {
  627. throw new Exception("数据有误,请检查。");
  628. }
  629. else
  630. {
  631. if (newStudent.RecordStatus == (int)CF_NewStudentEnterStatus.NotSubmitted)
  632. {
  633. newStudent.EnrollmentNo = null;
  634. newStudent.IsDoubt = false;
  635. newStudent.AssignStatus = (int)CF_AssignStatus.NotAssigned;
  636. newStudent.CollegeID = null;
  637. newStudent.ClassmajorID = null;
  638. newStudent.StudentNo = null;
  639. SetModifyStatus(newStudent);
  640. newStudentUpList.Add(newStudent);
  641. success++;
  642. }
  643. else
  644. {
  645. fail++;
  646. }
  647. }
  648. }
  649. //批量统一提交更新
  650. if (newStudentUpList != null && newStudentUpList.Count() > 0)
  651. {
  652. UnitOfWork.BatchUpdate(newStudentUpList);
  653. }
  654. if (success > 0 && fail <= 0)
  655. {
  656. tipMessage = success + "条";
  657. }
  658. else
  659. {
  660. tipMessage = success + "条," + fail + "条失败,原因:无法对已提交状态的信息取消分配,请检查";
  661. }
  662. return tipMessage;
  663. }
  664. catch (Exception ex)
  665. {
  666. throw new Exception(ex.Message);
  667. }
  668. }
  669. /// <summary>
  670. /// 导入照片
  671. /// </summary>
  672. /// <param name="photoPaths"></param>
  673. /// <param name="importPicType"></param>
  674. /// <param name="inCount"></param>
  675. /// <param name="errCount"></param>
  676. /// <param name="errDataTable"></param>
  677. public void NewStudentEnterPicImport(IList<string> photoPaths, string importPicType, out int? inCount, out int? errCount, out DataTable errDataTable)
  678. {
  679. try
  680. {
  681. var mapList = photoPaths.Select(s => new
  682. {
  683. PhotoInfo = Path.GetFileName(s).Trim(),
  684. PhotoName = Path.GetFileNameWithoutExtension(s).Trim(),
  685. PhotoPath = s,
  686. }).ToArray();
  687. var photoNameList = mapList.Select(s => s.PhotoName).Distinct().ToList();
  688. inCount = 0;
  689. errCount = 0;
  690. errDataTable = new DataTable();
  691. List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
  692. List<CF_Recruitstudents> newRecruitStudentUpList = new List<CF_Recruitstudents>();
  693. if (importPicType.Equals("ExamineeNum"))
  694. {
  695. var newPhotoNameList = new List<string>();
  696. foreach (var photoName in photoNameList)
  697. {
  698. var photoNameStart = photoName.Substring(0, 1);
  699. if (photoNameStart.Equals("F") || photoNameStart.Equals("Z"))
  700. {
  701. newPhotoNameList.Add(photoName.Substring(1));
  702. }
  703. }
  704. errDataTable.Columns.Add("PhotoInfo", typeof(string));
  705. errDataTable.Columns.Add("ExamineeNum", typeof(string));
  706. errDataTable.Columns.Add("ErrorMessage", typeof(string));
  707. var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => x.AssignStatus == (int)CF_AssignStatus.Assigned && (photoNameList.Contains(x.ExamineeNum) || newPhotoNameList.Contains(x.ExamineeNum))).ToList();
  708. var recruitStudentList = NewStudentDAL.RecruitstudentsRepository.GetList(x => photoNameList.Contains(x.ExamineeNum) || newPhotoNameList.Contains(x.ExamineeNum)).ToList();
  709. foreach (var map in mapList)
  710. {
  711. var photoNameStart = map.PhotoName.Substring(0, 1);
  712. if (photoNameStart.Equals("F") || photoNameStart.Equals("Z"))
  713. {
  714. var newStudent = newStudentList.Where(x => x.ExamineeNum == map.PhotoName || x.ExamineeNum == map.PhotoName.Substring(1)).SingleOrDefault();
  715. if (newStudent == null)
  716. {
  717. DataRow errDataRow = errDataTable.NewRow();
  718. errDataRow["PhotoInfo"] = map.PhotoInfo;
  719. errDataRow["ExamineeNum"] = map.PhotoName;
  720. errDataRow["ErrorMessage"] = "不存在对应的考生号(" + map.PhotoName + ")";
  721. errDataTable.Rows.Add(errDataRow);
  722. errCount++;
  723. }
  724. else
  725. {
  726. var recruitStudent = recruitStudentList.Where(x => x.ExamineeNum == map.PhotoName || x.ExamineeNum == map.PhotoName.Substring(1)).SingleOrDefault();
  727. if (recruitStudent != null)
  728. {
  729. recruitStudent.RecruitPictureUrl = map.PhotoPath;
  730. this.SetModifyStatus(recruitStudent);
  731. newRecruitStudentUpList.Add(recruitStudent);
  732. }
  733. newStudent.RecruitPictureUrl = map.PhotoPath;
  734. this.SetModifyStatus(newStudent);
  735. newStudentUpList.Add(newStudent);
  736. inCount++;
  737. }
  738. }
  739. else
  740. {
  741. var newStudent = newStudentList.Where(x => x.ExamineeNum == map.PhotoName).SingleOrDefault();
  742. if (newStudent == null)
  743. {
  744. DataRow errDataRow = errDataTable.NewRow();
  745. errDataRow["PhotoInfo"] = map.PhotoInfo;
  746. errDataRow["ExamineeNum"] = map.PhotoName;
  747. errDataRow["ErrorMessage"] = "不存在对应的考生号(" + map.PhotoName + ")";
  748. errDataTable.Rows.Add(errDataRow);
  749. errCount++;
  750. }
  751. else
  752. {
  753. var recruitStudent = recruitStudentList.Where(x => x.ExamineeNum == map.PhotoName).SingleOrDefault();
  754. if (recruitStudent != null)
  755. {
  756. recruitStudent.RecruitPictureUrl = map.PhotoPath;
  757. this.SetModifyStatus(recruitStudent);
  758. newRecruitStudentUpList.Add(recruitStudent);
  759. }
  760. newStudent.RecruitPictureUrl = map.PhotoPath;
  761. this.SetModifyStatus(newStudent);
  762. newStudentUpList.Add(newStudent);
  763. inCount++;
  764. }
  765. }
  766. }
  767. }
  768. else if (importPicType.Equals("IDNumber"))
  769. {
  770. errDataTable.Columns.Add("PhotoInfo", typeof(string));
  771. errDataTable.Columns.Add("IDNumber", typeof(string));
  772. errDataTable.Columns.Add("ErrorMessage", typeof(string));
  773. var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => x.AssignStatus == (int)CF_AssignStatus.Assigned && photoNameList.Contains(x.IDNumber)).ToList();
  774. var studentList = NewStudentDAL.StudentRepository.GetList(x => photoNameList.Contains(x.IDNumber), x => x.CF_Recruitstudents).ToList();
  775. foreach (var map in mapList)
  776. {
  777. var newStudentVerifyList = newStudentList.Where(x => x.IDNumber == map.PhotoName).ToList();
  778. if (newStudentVerifyList != null && newStudentVerifyList.Count() > 1)
  779. {
  780. DataRow errDataRow = errDataTable.NewRow();
  781. errDataRow["PhotoInfo"] = map.PhotoInfo;
  782. errDataRow["IDNumber"] = map.PhotoName;
  783. errDataRow["ErrorMessage"] = "录取名单中存在多个对应的证件号码(" + map.PhotoName + ")";
  784. errDataTable.Rows.Add(errDataRow);
  785. errCount++;
  786. }
  787. else
  788. {
  789. if (newStudentVerifyList != null && newStudentVerifyList.Count() == 1)
  790. {
  791. var newStudent = newStudentVerifyList.Where(x => x.IDNumber == map.PhotoName).SingleOrDefault();
  792. if (newStudent == null)
  793. {
  794. DataRow errDataRow = errDataTable.NewRow();
  795. errDataRow["PhotoInfo"] = map.PhotoInfo;
  796. errDataRow["IDNumber"] = map.PhotoName;
  797. errDataRow["ErrorMessage"] = "录取名单中不存在对应的证件号码(" + map.PhotoName + ")";
  798. errDataTable.Rows.Add(errDataRow);
  799. errCount++;
  800. }
  801. else
  802. {
  803. var studentVerifyList = studentList.Where(x => x.IDNumber == map.PhotoName).ToList();
  804. if (studentVerifyList != null && studentVerifyList.Count() > 1)
  805. {
  806. DataRow errDataRow = errDataTable.NewRow();
  807. errDataRow["PhotoInfo"] = map.PhotoInfo;
  808. errDataRow["IDNumber"] = map.PhotoName;
  809. errDataRow["ErrorMessage"] = "学生信息中存在多个对应的证件号码(" + map.PhotoName + ")";
  810. errDataTable.Rows.Add(errDataRow);
  811. errCount++;
  812. }
  813. else
  814. {
  815. if (studentVerifyList != null && studentVerifyList.Count() == 1)
  816. {
  817. var student = studentVerifyList.Where(x => x.IDNumber == map.PhotoName).SingleOrDefault();
  818. if (student != null)
  819. {
  820. if (student.CF_Recruitstudents != null)
  821. {
  822. student.CF_Recruitstudents.RecruitPictureUrl = map.PhotoPath;
  823. this.SetModifyStatus(student.CF_Recruitstudents);
  824. newRecruitStudentUpList.Add(student.CF_Recruitstudents);
  825. }
  826. }
  827. }
  828. newStudent.RecruitPictureUrl = map.PhotoPath;
  829. this.SetModifyStatus(newStudent);
  830. newStudentUpList.Add(newStudent);
  831. inCount++;
  832. }
  833. }
  834. }
  835. else
  836. {
  837. DataRow errDataRow = errDataTable.NewRow();
  838. errDataRow["PhotoInfo"] = map.PhotoInfo;
  839. errDataRow["IDNumber"] = map.PhotoName;
  840. errDataRow["ErrorMessage"] = "录取名单中不存在对应的证件号码(" + map.PhotoName + ")";
  841. errDataTable.Rows.Add(errDataRow);
  842. errCount++;
  843. }
  844. }
  845. }
  846. }
  847. else
  848. {
  849. errDataTable.Columns.Add("PhotoInfo", typeof(string));
  850. errDataTable.Columns.Add("StudentNo", typeof(string));
  851. errDataTable.Columns.Add("ErrorMessage", typeof(string));
  852. var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => x.AssignStatus == (int)CF_AssignStatus.Assigned && photoNameList.Contains(x.StudentNo)).ToList();
  853. var userList = NewStudentDAL.UserRepository.GetList(x => photoNameList.Contains(x.LoginID), x => x.CF_Student.CF_Recruitstudents).ToList();
  854. foreach (var map in mapList)
  855. {
  856. var newStudent = newStudentList.Where(x => x.StudentNo == map.PhotoName).SingleOrDefault();
  857. if (newStudent == null)
  858. {
  859. DataRow errDataRow = errDataTable.NewRow();
  860. errDataRow["PhotoInfo"] = map.PhotoInfo;
  861. errDataRow["StudentNo"] = map.PhotoName;
  862. errDataRow["ErrorMessage"] = "不存在对应的学号(" + map.PhotoName + ")";
  863. errDataTable.Rows.Add(errDataRow);
  864. errCount++;
  865. }
  866. else
  867. {
  868. var user = userList.Where(x => x.LoginID == map.PhotoName).SingleOrDefault();
  869. if (user != null)
  870. {
  871. if (user.CF_Student != null)
  872. {
  873. if (user.CF_Student.CF_Recruitstudents != null)
  874. {
  875. user.CF_Student.CF_Recruitstudents.RecruitPictureUrl = map.PhotoPath;
  876. this.SetModifyStatus(user.CF_Student.CF_Recruitstudents);
  877. newRecruitStudentUpList.Add(user.CF_Student.CF_Recruitstudents);
  878. }
  879. }
  880. }
  881. newStudent.RecruitPictureUrl = map.PhotoPath;
  882. this.SetModifyStatus(newStudent);
  883. newStudentUpList.Add(newStudent);
  884. inCount++;
  885. }
  886. }
  887. }
  888. using (TransactionScope ts = new TransactionScope())
  889. {
  890. if (newRecruitStudentUpList != null && newRecruitStudentUpList.Count() > 0)
  891. {
  892. UnitOfWork.BatchUpdate(newRecruitStudentUpList);
  893. }
  894. if (newStudentUpList != null && newStudentUpList.Count() > 0)
  895. {
  896. UnitOfWork.BatchUpdate(newStudentUpList);
  897. }
  898. ts.Complete();
  899. }
  900. }
  901. catch (Exception)
  902. {
  903. throw;
  904. }
  905. }
  906. /// <summary>
  907. /// 导入标识
  908. /// </summary>
  909. /// <param name="cellheader"></param>
  910. /// <param name="inCount"></param>
  911. /// <param name="upCount"></param>
  912. /// <param name="errdataList"></param>
  913. /// <param name="errCount"></param>
  914. /// <param name="sourcePhysicalPath"></param>
  915. public void NewStudentEnterDoubtImport(Dictionary<string, string> cellheader, out int? inCount, out int? upCount, out List<NewStudentView> errdataList, out int? errCount, string sourcePhysicalPath)
  916. {
  917. try
  918. {
  919. StringBuilder errorMsg = new StringBuilder();
  920. List<NewStudentView> errList = new List<NewStudentView>();
  921. cellheader.Remove("ErrorMessage");
  922. List<NewStudentView> enlist = NpoiExcelHelper.ExcelToEntityList<NewStudentView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
  923. cellheader.Add("ErrorMessage", "未导入原因");
  924. if (enlist.Count() <= 0)
  925. {
  926. throw new Exception("Excel文件数据为空,请检查。");
  927. }
  928. inCount = 0;
  929. upCount = 0;
  930. errCount = 0;
  931. string errorMsgStr = "";
  932. List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
  933. //将循环中相关数据库查询统一查询出来进行匹配(尽量避免在循环中进行数据库查询)
  934. //姓名
  935. var nameList = enlist.Where(x => !string.IsNullOrEmpty(x.Name)).Select(x => x.Name).ToList();
  936. //身份证号
  937. var iDNumberList = enlist.Where(x => !string.IsNullOrEmpty(x.IDNumber)).Select(x => x.IDNumber).ToList();
  938. //录取名单(由于需要和Excel中数据进行比对,数据太多就会报异常,所以需要先查询出来)
  939. var newStudentAllList = NewStudentDAL.NewStudentRepository.GetList(x => true).ToList();
  940. //对比后的newStudentList
  941. var newStudentList = newStudentAllList.Where(x => nameList.Contains(x.Name) && iDNumberList.Contains(x.IDNumber)).ToList();
  942. //循环检测数据列,对各数据列进行验证(必填、字典项验证、数据格式等)
  943. for (int i = 0; i < enlist.Count; i++)
  944. {
  945. NewStudentView en = enlist[i]; //Excel表数据视图
  946. CF_NewStudent newStudent = new CF_NewStudent(); //新生信息实体
  947. //姓名
  948. if (string.IsNullOrEmpty(en.Name))
  949. {
  950. errCount++;
  951. errorMsgStr = "姓名不能为空";
  952. en.ErrorMessage = errorMsgStr;
  953. errList.Add(en);
  954. errorMsg.AppendLine(errorMsgStr);
  955. continue;
  956. }
  957. else
  958. {
  959. //姓名
  960. newStudent.Name = en.Name.Trim();
  961. }
  962. //身份证号
  963. if (string.IsNullOrEmpty(en.IDNumber))
  964. {
  965. errCount++;
  966. errorMsgStr = "身份证号不能为空";
  967. en.ErrorMessage = errorMsgStr;
  968. errList.Add(en);
  969. errorMsg.AppendLine(errorMsgStr);
  970. continue;
  971. }
  972. else
  973. {
  974. newStudent.IDNumber = en.IDNumber.Trim();
  975. }
  976. ////Excel表重复性验证(注:当数据表中没有此记录,但是Excel中有重复数据时的去掉)
  977. //for (int j = i + 1; j < enlist.Count; j++)
  978. //{
  979. // NewStudentView enA = enlist[j];
  980. // //根据Excel表中的业务主键进行去重(考生号唯一)
  981. // if (en.ExamineeNum == enA.ExamineeNum)
  982. // {
  983. // //用于标识Excel表中的重复记录(由于是批量进行插入数据表)
  984. // }
  985. //}
  986. //由于新生管理模块中存在新生分配的业务,在进行新生信息新增时,
  987. //需要对新生分配、录取名单中的信息进行提示性验证(业务主键:考生号唯一)
  988. //处理方法:进行Excel导入时,对新生分配、录取名单中的信息提示性验证(当错误信息抛出)
  989. //注:(未分配-1,预分配-2,已分配-3)
  990. //数据表重复性验证,此为名单标识功能(考生号唯一)
  991. //由于标识模块问题,目前暂时不考虑业务主键问题,有重复抛异常
  992. var newStudentEnetey = newStudentList.Where(x => x.IDNumber == newStudent.IDNumber && x.Name == newStudent.Name).SingleOrDefault();
  993. if (newStudentEnetey == null)
  994. {
  995. errCount++;
  996. errorMsgStr = "此标识名单不存在,请检查";
  997. en.ErrorMessage = errorMsgStr;
  998. errList.Add(en);
  999. errorMsg.AppendLine(errorMsgStr);
  1000. continue;
  1001. }
  1002. else
  1003. {
  1004. //由于新生管理模块中存在新生分配的业务,只更新分配状态为:已分配-3、提交状态为:未提交-2的信息
  1005. //分配状态为:未分配-1,预分配-2,已分配-3,提交状态:未提交-1,已提交-2
  1006. if (newStudentEnetey.AssignStatus == (int)CF_AssignStatus.Assigned)
  1007. {
  1008. if (newStudentEnetey.RecordStatus == (int)CF_NewStudentEnterStatus.NotSubmitted)
  1009. {
  1010. //(Excel有重复时,以最后一条记录的更新为准)
  1011. if (newStudentEnetey.IsDoubt == true)
  1012. {
  1013. //更新
  1014. newStudentEnetey.IsDoubt = true;
  1015. SetModifyStatus(newStudentEnetey);
  1016. newStudentUpList.Add(newStudentEnetey);
  1017. upCount++;
  1018. }
  1019. else
  1020. {
  1021. //标识
  1022. newStudentEnetey.IsDoubt = true;
  1023. SetModifyStatus(newStudentEnetey);
  1024. newStudentUpList.Add(newStudentEnetey);
  1025. inCount++;
  1026. }
  1027. }
  1028. else
  1029. {
  1030. errCount++;
  1031. errorMsgStr = "标识失败,无法对状态为已提交的信息进行标识";
  1032. en.ErrorMessage = errorMsgStr;
  1033. errList.Add(en);
  1034. errorMsg.AppendLine(errorMsgStr);
  1035. continue;
  1036. }
  1037. }
  1038. else
  1039. {
  1040. errCount++;
  1041. errorMsgStr = "标识失败,录取名单信息中不存在此标识名单(新生名单或新生分配信息中存在)";
  1042. en.ErrorMessage = errorMsgStr;
  1043. errList.Add(en);
  1044. errorMsg.AppendLine(errorMsgStr);
  1045. continue;
  1046. }
  1047. }
  1048. }
  1049. if (newStudentUpList != null && newStudentUpList.Count() > 0)
  1050. {
  1051. UnitOfWork.BatchUpdate(newStudentUpList);
  1052. }
  1053. errdataList = errList.Distinct().ToList();
  1054. }
  1055. catch (Exception)
  1056. {
  1057. throw;
  1058. }
  1059. }
  1060. /// <summary>
  1061. /// 查询标识名单信息View
  1062. /// </summary>
  1063. /// <param name="configuretView"></param>
  1064. /// <param name="campusID"></param>
  1065. /// <param name="collegeID"></param>
  1066. /// <param name="gradeID"></param>
  1067. /// <param name="standardID"></param>
  1068. /// <param name="educationID"></param>
  1069. /// <param name="learningformID"></param>
  1070. /// <param name="learnSystem"></param>
  1071. /// <param name="isPhotoUrl"></param>
  1072. /// <param name="pageIndex"></param>
  1073. /// <param name="pageSize"></param>
  1074. /// <returns></returns>
  1075. 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)
  1076. {
  1077. Expression<Func<CF_NewStudent, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1078. exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.Assigned);
  1079. exp = exp.And(x => x.IsDoubt == true);
  1080. if (collegeID.HasValue)
  1081. {
  1082. exp = exp.And(x => x.CollegeID == collegeID);
  1083. }
  1084. if (gradeID.HasValue)
  1085. {
  1086. exp = exp.And(x => x.GradeID == gradeID);
  1087. }
  1088. if (isPhotoUrl.HasValue)
  1089. {
  1090. if (isPhotoUrl.Value == (int)CF_GeneralExist.Have)
  1091. {
  1092. exp = exp.And(x => x.RecruitPictureUrl != null && x.RecruitPictureUrl != "");
  1093. }
  1094. if (isPhotoUrl.Value == (int)CF_GeneralExist.No)
  1095. {
  1096. exp = exp.And(x => x.RecruitPictureUrl == null || x.RecruitPictureUrl == "");
  1097. }
  1098. }
  1099. var query = NewStudentDAL.GetNewStudentEnterViewQueryable(exp);
  1100. if (campusID.HasValue)
  1101. {
  1102. query = query.Where(x => x.CampusID == campusID);
  1103. }
  1104. if (standardID.HasValue)
  1105. {
  1106. query = query.Where(x => x.StandardID == standardID);
  1107. }
  1108. if (educationID.HasValue)
  1109. {
  1110. query = query.Where(x => x.EducationID == educationID);
  1111. }
  1112. if (learningformID.HasValue)
  1113. {
  1114. query = query.Where(x => x.LearningformID == learningformID);
  1115. }
  1116. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  1117. {
  1118. var LearnSystems = Convert.ToDecimal(learnSystem);
  1119. query = query.Where(x => x.LearnSystem == LearnSystems);
  1120. }
  1121. //查询条件
  1122. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  1123. {
  1124. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  1125. }
  1126. return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeID)
  1127. .ThenBy(x => x.StandardName).ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem)
  1128. .ThenBy(x => x.ExamineeNum.Length).ThenBy(x => x.ExamineeNum).OrderBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ToGridResultSet<NewStudentView>(pageIndex, pageSize);
  1129. }
  1130. /// <summary>
  1131. /// 查询标识名单信息List
  1132. /// </summary>
  1133. /// <param name="configuretView"></param>
  1134. /// <param name="campusID"></param>
  1135. /// <param name="collegeID"></param>
  1136. /// <param name="gradeID"></param>
  1137. /// <param name="standardID"></param>
  1138. /// <param name="educationID"></param>
  1139. /// <param name="learningformID"></param>
  1140. /// <param name="learnSystem"></param>
  1141. /// <param name="isPhotoUrl"></param>
  1142. /// <returns></returns>
  1143. public IList<NewStudentView> GetNewStudentEnterDoubtViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID, int? educationID, int? learningformID, string learnSystem, int? isPhotoUrl)
  1144. {
  1145. Expression<Func<CF_NewStudent, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1146. exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.Assigned);
  1147. exp = exp.And(x => x.IsDoubt == true);
  1148. if (collegeID.HasValue)
  1149. {
  1150. exp = exp.And(x => x.CollegeID == collegeID);
  1151. }
  1152. if (gradeID.HasValue)
  1153. {
  1154. exp = exp.And(x => x.GradeID == gradeID);
  1155. }
  1156. if (isPhotoUrl.HasValue)
  1157. {
  1158. if (isPhotoUrl.Value == (int)CF_GeneralExist.Have)
  1159. {
  1160. exp = exp.And(x => x.RecruitPictureUrl != null && x.RecruitPictureUrl != "");
  1161. }
  1162. if (isPhotoUrl.Value == (int)CF_GeneralExist.No)
  1163. {
  1164. exp = exp.And(x => x.RecruitPictureUrl == null || x.RecruitPictureUrl == "");
  1165. }
  1166. }
  1167. var query = NewStudentDAL.GetNewStudentEnterViewQueryable(exp);
  1168. if (campusID.HasValue)
  1169. {
  1170. query = query.Where(x => x.CampusID == campusID);
  1171. }
  1172. if (standardID.HasValue)
  1173. {
  1174. query = query.Where(x => x.StandardID == standardID);
  1175. }
  1176. if (educationID.HasValue)
  1177. {
  1178. query = query.Where(x => x.EducationID == educationID);
  1179. }
  1180. if (learningformID.HasValue)
  1181. {
  1182. query = query.Where(x => x.LearningformID == learningformID);
  1183. }
  1184. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  1185. {
  1186. var LearnSystems = Convert.ToDecimal(learnSystem);
  1187. query = query.Where(x => x.LearnSystem == LearnSystems);
  1188. }
  1189. //查询条件
  1190. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  1191. {
  1192. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  1193. }
  1194. return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeID)
  1195. .ThenBy(x => x.StandardName).ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem)
  1196. .ThenBy(x => x.ExamineeNum.Length).ThenBy(x => x.ExamineeNum).OrderBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ToList();
  1197. }
  1198. /// <summary>
  1199. /// 审核(确定)
  1200. /// </summary>
  1201. /// <param name="newStudentIDList"></param>
  1202. /// <returns></returns>
  1203. public string NewStudentEnterDoubtApprove(List<Guid?> newStudentIDList)
  1204. {
  1205. try
  1206. {
  1207. //查询新生信息
  1208. var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => newStudentIDList.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.Assigned).ToList();
  1209. int success = 0; //成功
  1210. int fail = 0; //失败
  1211. string tipMessage = null; //提示消息
  1212. List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
  1213. foreach (var newStudentID in newStudentIDList)
  1214. {
  1215. var newStudent = newStudentList.Where(x => x.NewStudentID == newStudentID).SingleOrDefault();
  1216. if (newStudent == null)
  1217. {
  1218. throw new Exception("数据有误,请检查。");
  1219. }
  1220. else
  1221. {
  1222. if (newStudent.AssignStatus == (int)CF_AssignStatus.Assigned)
  1223. {
  1224. newStudent.IsDoubt = false;
  1225. SetModifyStatus(newStudent);
  1226. newStudentUpList.Add(newStudent);
  1227. success++;
  1228. }
  1229. else
  1230. {
  1231. fail++;
  1232. }
  1233. }
  1234. }
  1235. //批量统一提交更新
  1236. if (newStudentUpList != null && newStudentUpList.Count() > 0)
  1237. {
  1238. UnitOfWork.BatchUpdate(newStudentUpList);
  1239. }
  1240. if (success > 0 && fail <= 0)
  1241. {
  1242. tipMessage = success + "条";
  1243. }
  1244. else
  1245. {
  1246. tipMessage = success + "条," + fail + "条失败,原因:数据有误,请检查";
  1247. }
  1248. return tipMessage;
  1249. }
  1250. catch (Exception ex)
  1251. {
  1252. throw new Exception(ex.Message);
  1253. }
  1254. }
  1255. /// <summary>
  1256. /// 初始化(班级信息、学号)
  1257. /// </summary>
  1258. /// <param name="newStudentIDList"></param>
  1259. /// <returns></returns>
  1260. public string NewStudentEnterInit(List<Guid?> newStudentIDList)
  1261. {
  1262. try
  1263. {
  1264. //查询新生信息
  1265. var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => newStudentIDList.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.Assigned).ToList();
  1266. int success = 0; //成功
  1267. int fail = 0; //失败
  1268. string tipMessage = null; //提示消息
  1269. List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
  1270. foreach (var newStudentID in newStudentIDList)
  1271. {
  1272. var newStudent = newStudentList.Where(x => x.NewStudentID == newStudentID).SingleOrDefault();
  1273. if (newStudent == null)
  1274. {
  1275. throw new Exception("数据有误,请检查。");
  1276. }
  1277. else
  1278. {
  1279. if (newStudent.RecordStatus == (int)CF_NewStudentEnterStatus.NotSubmitted)
  1280. {
  1281. newStudent.ClassmajorID = null;
  1282. newStudent.StudentNo = null;
  1283. SetModifyStatus(newStudent);
  1284. newStudentUpList.Add(newStudent);
  1285. success++;
  1286. }
  1287. else
  1288. {
  1289. fail++;
  1290. }
  1291. }
  1292. }
  1293. //批量统一提交更新
  1294. if (newStudentUpList != null && newStudentUpList.Count() > 0)
  1295. {
  1296. UnitOfWork.BatchUpdate(newStudentUpList);
  1297. }
  1298. if (success > 0 && fail <= 0)
  1299. {
  1300. tipMessage = success + "条";
  1301. }
  1302. else
  1303. {
  1304. tipMessage = success + "条," + fail + "条失败,原因:无法对已提交状态的信息进行初始化,请检查";
  1305. }
  1306. return tipMessage;
  1307. }
  1308. catch (Exception ex)
  1309. {
  1310. throw new Exception(ex.Message);
  1311. }
  1312. }
  1313. /// <summary>
  1314. /// 手动分配班级和生成学号(此为默认规则,一对一的情况,初始学号为:班级编号+流水号,下一位学号为:对应的最大学号+1)
  1315. /// 注:个性化配置
  1316. /// </summary>
  1317. /// <param name="newStudentIDList"></param>
  1318. /// <param name="classmajorID"></param>
  1319. /// <returns></returns>
  1320. public virtual string NewStudentEnterAssignClass(List<Guid?> newStudentIDList, Guid? classmajorID)
  1321. {
  1322. try
  1323. {
  1324. var studentNoTotal = EMIS.Utility.Const.LOCAL_SETTING_LOGINIDTOTAL;
  1325. if (studentNoTotal == null)
  1326. {
  1327. throw new Exception("学号总位数未配置,请检查。");
  1328. }
  1329. //查询录取名单信息(已分配状态)
  1330. var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => newStudentIDList.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.Assigned).ToList();
  1331. //年级ID
  1332. var gradeIDList = newStudentList.Where(x => !string.IsNullOrEmpty(x.GradeID.ToString())).Select(x => x.GradeID).ToList();
  1333. //专业信息ID
  1334. var specialtyIDList = newStudentList.Where(x => !string.IsNullOrEmpty(x.SpecialtyID.ToString())).Select(x => x.SpecialtyID).ToList();
  1335. //院系所ID
  1336. var collegeIDList = newStudentList.Where(x => !string.IsNullOrEmpty(x.CollegeID.ToString())).Select(x => x.CollegeID).ToList();
  1337. //查询专业信息
  1338. var specialtyList = NewStudentDAL.SpecialtyRepository.GetList(x => specialtyIDList.Contains(x.SpecialtyID)).ToList();
  1339. //查询招生专业信息(暂时不需对招生专业进行验证)
  1340. var recruitSpecialtyAllList = NewStudentDAL.RecruitSpecialtyRepository.GetList(x => true).ToList();
  1341. //查询招生专业
  1342. var recruitSpecialtyList = recruitSpecialtyAllList.Where(x => gradeIDList.Contains(x.GradeID) && specialtyIDList.Contains(x.SpecialtyID) && collegeIDList.Contains(x.CollegeID)).ToList();
  1343. //查询对应的院系专业信息
  1344. var facultymajorList = NewStudentDAL.GetFacultymajorByNewStudent(x => newStudentIDList.Contains(x.NewStudentID)).ToList();
  1345. //院系专业ID
  1346. var facultymajorIDList = facultymajorList.Where(x => !string.IsNullOrEmpty(x.FacultymajorID.ToString())).Select(x => x.FacultymajorID).ToList();
  1347. //查询对应的年级专业信息
  1348. var grademajorList = NewStudentDAL.GetGrademajorByNewStudent(x => newStudentIDList.Contains(x.NewStudentID), x => facultymajorIDList.Contains(x.FacultymajorID)).ToList();
  1349. //年级专业ID
  1350. var grademajorIDList = grademajorList.Where(x => !string.IsNullOrEmpty(x.GrademajorID.ToString())).Select(x => x.GrademajorID).ToList();
  1351. //查询对应的班级信息
  1352. var classmajorList = NewStudentDAL.GetClassmajorByNewStudent(x => newStudentIDList.Contains(x.NewStudentID), x => facultymajorIDList.Contains(x.FacultymajorID), x => grademajorIDList.Contains(x.GrademajorID)).ToList();
  1353. //班级信息ID
  1354. var classmajorIDList = classmajorList.Where(x => !string.IsNullOrEmpty(x.ClassmajorID.ToString())).Select(x => x.ClassmajorID).ToList();
  1355. //查询各班级信息中最大的学号(新生信息表、学生信息表)
  1356. var maxStudentNoList = NewStudentDAL.GetMaxStudentNoClass(x => classmajorIDList.Contains(x.ClassmajorID)).ToList();
  1357. int classmajorfail = 0;
  1358. int fail = 0;
  1359. int success = 0;
  1360. string tipMessage = null;
  1361. long startStudentNo = 0;
  1362. long newStudentNo = 0;
  1363. List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
  1364. foreach (var newStudent in newStudentList)
  1365. {
  1366. //需要对选择的班级信息分别进行验证(一一对应的情况下,才可分配班级及生成学号)
  1367. //查询班级信息(根据新生ID、选择的班级信息ID查询)
  1368. var classmajorVerify = classmajorList.Where(x => x.NewStudentID == newStudent.NewStudentID && x.ClassmajorID == classmajorID).SingleOrDefault();
  1369. //判断对应的班级信息
  1370. if (classmajorVerify != null)
  1371. {
  1372. //判断当选择的信息中存在班级信息或学号等情况(只要两者之中有一个存在,将不考虑生成)
  1373. if (newStudent.ClassmajorID.HasValue || !string.IsNullOrEmpty(newStudent.StudentNo))
  1374. {
  1375. //表示不生成
  1376. fail++;
  1377. continue;
  1378. }
  1379. else
  1380. {
  1381. //查询对应班级信息中最大的学号(新生信息表、学生信息表)
  1382. var maxStudentNo = maxStudentNoList.Where(x => x.ClassmajorID == classmajorID).SingleOrDefault();
  1383. //查询选择生成的录取名单List中是否有分配到同一班级的信息
  1384. var newStudentRepeatList = newStudentUpList.Where(x => x.ClassmajorID == classmajorID).ToList();
  1385. //表示当前班级无对应的学号,此时应为初始学号(班级编号+2位流水号,需匹配Web.config配置)
  1386. if (maxStudentNo == null)
  1387. {
  1388. //初始学号(班级编号+流水号,不够学号总位数的用0填充,可在此处通过个性化配置来定义学号生成规则)
  1389. startStudentNo = Convert.ToInt64(classmajorVerify.ClassmajorNo.PadRight(Convert.ToInt32(studentNoTotal) - 1, '0') + "1");
  1390. //表示无相同班级的信息
  1391. if (newStudentRepeatList.Count <= 0)
  1392. {
  1393. //初始学号
  1394. newStudentNo = startStudentNo;
  1395. }
  1396. else
  1397. {
  1398. //相同班级的信息中最大学号+1,作为下一个学号
  1399. newStudentNo = Convert.ToInt64(newStudentRepeatList.OrderByDescending(x => Convert.ToInt64(x.StudentNo)).FirstOrDefault().StudentNo) + 1;
  1400. }
  1401. }
  1402. else
  1403. {
  1404. //表示无相同班级的信息
  1405. if (newStudentRepeatList.Count <= 0)
  1406. {
  1407. //数据表中的最大学号+1,作为下一个学号
  1408. newStudentNo = Convert.ToInt64(maxStudentNo.StudentNo) + 1;
  1409. }
  1410. else
  1411. {
  1412. //相同班级的信息中最大学号+1,作为下一个学号
  1413. newStudentNo = Convert.ToInt64(newStudentRepeatList.OrderByDescending(x => Convert.ToInt64(x.StudentNo)).FirstOrDefault().StudentNo) + 1;
  1414. }
  1415. }
  1416. newStudent.ClassmajorID = classmajorID;
  1417. newStudent.StudentNo = newStudentNo.ToString();
  1418. SetModifyStatus(newStudent);
  1419. newStudentUpList.Add(newStudent);
  1420. success++;
  1421. }
  1422. }
  1423. else
  1424. {
  1425. //表示选择的班级信息不相符,无法分班及生成学号
  1426. classmajorfail++;
  1427. continue;
  1428. }
  1429. }
  1430. //批量更新
  1431. if (newStudentUpList != null && newStudentUpList.Count() > 0)
  1432. {
  1433. UnitOfWork.BatchUpdate(newStudentUpList);
  1434. }
  1435. if (classmajorfail <= 0 && fail <= 0)
  1436. {
  1437. tipMessage = success + "条录取名单的学号";
  1438. }
  1439. else
  1440. {
  1441. if (classmajorfail <= 0 && fail > 0)
  1442. {
  1443. tipMessage = success + "个学号,失败" + fail + "条,原因:班级信息或学号已存在,如需生成请初始化后重新生成";
  1444. }
  1445. else if (classmajorfail > 0 && fail <= 0)
  1446. {
  1447. tipMessage = success + "个学号," + classmajorfail + "条由于与选择的班级信息不相符,无法生成,请核查";
  1448. }
  1449. else
  1450. {
  1451. tipMessage = success + "个学号," + fail + "条由于班级信息或学号已存在无法生成," + classmajorfail + "条由于与选择的班级信息不相符,无法生成,请核查";
  1452. }
  1453. }
  1454. return tipMessage;
  1455. }
  1456. catch (Exception ex)
  1457. {
  1458. throw new Exception(ex.Message);
  1459. }
  1460. }
  1461. /// <summary>
  1462. /// 自动分配班级和生成学号
  1463. /// 注:个性化配置
  1464. /// 此为默认规则,一对一的情况,初始学号为:班级编号+流水号,下一位学号为:对应的最大学号+1)
  1465. /// 目前只支持,学号=班级编号+流水号的情况,针对学号生成规则不同、专业分方向、有两个班以上等等情况,需要进行扩展-普教版本
  1466. /// </summary>
  1467. /// <param name="newStudentIDList"></param>
  1468. /// <returns></returns>
  1469. public virtual string NewStudentEnterAutoAssignClass(List<Guid?> newStudentIDList)
  1470. {
  1471. try
  1472. {
  1473. var studentNoTotal = EMIS.Utility.Const.LOCAL_SETTING_LOGINIDTOTAL;
  1474. if (studentNoTotal == null)
  1475. {
  1476. throw new Exception("学号总位数未配置,请检查。");
  1477. }
  1478. //查询录取名单信息(已分配状态)
  1479. var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => newStudentIDList.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.Assigned).ToList();
  1480. //年级ID
  1481. var gradeIDList = newStudentList.Where(x => !string.IsNullOrEmpty(x.GradeID.ToString())).Select(x => x.GradeID).ToList();
  1482. //专业信息ID
  1483. var specialtyIDList = newStudentList.Where(x => !string.IsNullOrEmpty(x.SpecialtyID.ToString())).Select(x => x.SpecialtyID).ToList();
  1484. //院系所ID
  1485. var collegeIDList = newStudentList.Where(x => !string.IsNullOrEmpty(x.CollegeID.ToString())).Select(x => x.CollegeID).ToList();
  1486. //查询专业信息
  1487. var specialtyList = NewStudentDAL.SpecialtyRepository.GetList(x => specialtyIDList.Contains(x.SpecialtyID)).ToList();
  1488. //查询招生专业信息(暂时不需对招生专业进行验证)
  1489. var recruitSpecialtyAllList = NewStudentDAL.RecruitSpecialtyRepository.GetList(x => true).ToList();
  1490. //查询招生专业
  1491. var recruitSpecialtyList = recruitSpecialtyAllList.Where(x => gradeIDList.Contains(x.GradeID) && specialtyIDList.Contains(x.SpecialtyID) && collegeIDList.Contains(x.CollegeID)).ToList();
  1492. //查询对应的院系专业信息
  1493. var facultymajorList = NewStudentDAL.GetFacultymajorByNewStudent(x => newStudentIDList.Contains(x.NewStudentID)).ToList();
  1494. //院系专业ID
  1495. var facultymajorIDList = facultymajorList.Where(x => !string.IsNullOrEmpty(x.FacultymajorID.ToString())).Select(x => x.FacultymajorID).ToList();
  1496. //查询对应的年级专业信息
  1497. var grademajorList = NewStudentDAL.GetGrademajorByNewStudent(x => newStudentIDList.Contains(x.NewStudentID), x => facultymajorIDList.Contains(x.FacultymajorID)).ToList();
  1498. //年级专业ID
  1499. var grademajorIDList = grademajorList.Where(x => !string.IsNullOrEmpty(x.GrademajorID.ToString())).Select(x => x.GrademajorID).ToList();
  1500. //查询对应的班级信息
  1501. var classmajorList = NewStudentDAL.GetClassmajorByNewStudent(x => newStudentIDList.Contains(x.NewStudentID), x => facultymajorIDList.Contains(x.FacultymajorID), x => grademajorIDList.Contains(x.GrademajorID)).ToList();
  1502. //班级信息ID
  1503. var classmajorIDList = classmajorList.Where(x => !string.IsNullOrEmpty(x.ClassmajorID.ToString())).Select(x => x.ClassmajorID).ToList();
  1504. //查询各班级信息中最大的学号(新生信息表、学生信息表)
  1505. var maxStudentNoList = NewStudentDAL.GetMaxStudentNoClass(x => classmajorIDList.Contains(x.ClassmajorID)).ToList();
  1506. int facultymajorfail = 0;
  1507. int grademajorfail = 0;
  1508. int classmajorfail = 0;
  1509. int fail = 0;
  1510. int success = 0;
  1511. string tipMessage = null;
  1512. long startStudentNo = 0;
  1513. long newStudentNo = 0;
  1514. List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
  1515. foreach (var newStudent in newStudentList)
  1516. {
  1517. //需要对院系专业、年级专业、班级信息分别进行验证(一一对应的情况下,才可自动分配班级及生成学号)
  1518. //查询院系专业
  1519. var facultymajorVerify = facultymajorList.Where(x => x.NewStudentID == newStudent.NewStudentID).ToList();
  1520. //判断对应的院系专业
  1521. if (facultymajorVerify != null && facultymajorVerify.Count() > 0)
  1522. {
  1523. if (facultymajorVerify.Count() == 1)
  1524. {
  1525. //查询年级专业
  1526. var grademajorVerify = grademajorList.Where(x => x.NewStudentID == newStudent.NewStudentID).ToList();
  1527. //判断对应的年级专业
  1528. if (grademajorVerify != null && grademajorVerify.Count() > 0)
  1529. {
  1530. if (grademajorVerify.Count() == 1)
  1531. {
  1532. //查询班级信息
  1533. var classmajorVerify = classmajorList.Where(x => x.NewStudentID == newStudent.NewStudentID).ToList();
  1534. //判断对应的班级信息
  1535. if (classmajorVerify != null && classmajorVerify.Count() > 0)
  1536. {
  1537. if (classmajorVerify.Count() == 1)
  1538. {
  1539. //判断当选择的信息中存在班级信息或学号等情况(只要两者之中有一个存在,将不考虑生成)
  1540. if (newStudent.ClassmajorID.HasValue || !string.IsNullOrEmpty(newStudent.StudentNo))
  1541. {
  1542. //表示不生成
  1543. fail++;
  1544. continue;
  1545. }
  1546. else
  1547. {
  1548. //对可分配的班级信息及学号进行查询
  1549. //查询对应班级信息中最大的学号(新生信息表、学生信息表)
  1550. var specialtyClass = classmajorVerify.Where(x => x.NewStudentID == newStudent.NewStudentID).SingleOrDefault();
  1551. var maxStudentNo = maxStudentNoList.Where(x => x.ClassmajorID == specialtyClass.ClassmajorID).SingleOrDefault();
  1552. //查询选择生成的录取名单List中是否有分配到同一班级的信息
  1553. var newStudentRepeatList = newStudentUpList.Where(x => x.ClassmajorID == specialtyClass.ClassmajorID).ToList();
  1554. //表示当前班级无对应的学号,此时应为初始学号(班级编号+2位流水号,需匹配Web.config配置)
  1555. if (maxStudentNo == null)
  1556. {
  1557. //初始学号(班级编号+流水号,不够学号总位数的用0填充,可在此处通过个性化配置来定义学号生成规则)
  1558. startStudentNo = Convert.ToInt64(specialtyClass.ClassmajorNo.PadRight(Convert.ToInt32(studentNoTotal) - 1, '0') + "1");
  1559. //表示无相同班级的信息
  1560. if (newStudentRepeatList.Count <= 0)
  1561. {
  1562. //初始学号
  1563. newStudentNo = startStudentNo;
  1564. }
  1565. else
  1566. {
  1567. //相同班级的信息中最大学号+1,作为下一个学号
  1568. newStudentNo = Convert.ToInt64(newStudentRepeatList.OrderByDescending(x => Convert.ToInt64(x.StudentNo)).FirstOrDefault().StudentNo) + 1;
  1569. }
  1570. }
  1571. else
  1572. {
  1573. //表示无相同班级的信息
  1574. if (newStudentRepeatList.Count <= 0)
  1575. {
  1576. //数据表中的最大学号+1,作为下一个学号
  1577. newStudentNo = Convert.ToInt64(maxStudentNo.StudentNo) + 1;
  1578. }
  1579. else
  1580. {
  1581. //相同班级的信息中最大学号+1,作为下一个学号
  1582. newStudentNo = Convert.ToInt64(newStudentRepeatList.OrderByDescending(x => Convert.ToInt64(x.StudentNo)).FirstOrDefault().StudentNo) + 1;
  1583. }
  1584. }
  1585. newStudent.ClassmajorID = specialtyClass.ClassmajorID;
  1586. newStudent.StudentNo = newStudentNo.ToString();
  1587. SetModifyStatus(newStudent);
  1588. newStudentUpList.Add(newStudent);
  1589. success++;
  1590. }
  1591. }
  1592. else
  1593. {
  1594. //表示对应的班级信息存在多个,无法确定对应的班级信息(可在此处进行扩展,针对专业分方向的情况)
  1595. classmajorfail++;
  1596. continue;
  1597. }
  1598. }
  1599. else
  1600. {
  1601. //表示对应的班级信息不存在,无法分班及生成学号
  1602. classmajorfail++;
  1603. continue;
  1604. }
  1605. }
  1606. else
  1607. {
  1608. //表示对应的年级专业信息存在多个,无法确定对应的年级专业(可在此处进行扩展,针对专业分方向的情况)
  1609. grademajorfail++;
  1610. continue;
  1611. }
  1612. }
  1613. else
  1614. {
  1615. //表示对应的年级专业信息不存在,无法分班及生成学号
  1616. grademajorfail++;
  1617. continue;
  1618. }
  1619. }
  1620. else
  1621. {
  1622. //表示对应的院系专业信息存在多个,无法确定对应的院系专业(可在此处进行扩展,针对专业分方向的情况)
  1623. facultymajorfail++;
  1624. continue;
  1625. }
  1626. }
  1627. else
  1628. {
  1629. //表示对应的院系专业信息不存在,无法分班及生成学号
  1630. facultymajorfail++;
  1631. continue;
  1632. }
  1633. }
  1634. //批量更新
  1635. if (newStudentUpList != null && newStudentUpList.Count() > 0)
  1636. {
  1637. UnitOfWork.BatchUpdate(newStudentUpList);
  1638. }
  1639. if (facultymajorfail <= 0 && grademajorfail <= 0 && classmajorfail <= 0 && fail <= 0)
  1640. {
  1641. tipMessage = success + "个学号";
  1642. }
  1643. else
  1644. {
  1645. if (facultymajorfail <= 0 && grademajorfail <= 0 && classmajorfail <= 0 && fail > 0)
  1646. {
  1647. tipMessage = success + "个学号,失败" + fail + "条,原因:班级信息或学号已存在,如需生成请初始化后重新生成";
  1648. }
  1649. else if (facultymajorfail > 0 && grademajorfail <= 0 && classmajorfail <= 0 && fail <= 0)
  1650. {
  1651. tipMessage = success + "个学号," + facultymajorfail + "条由于院系专业信息的原因无法生成,请核查";
  1652. }
  1653. else if (facultymajorfail <= 0 && grademajorfail > 0 && classmajorfail <= 0 && fail <= 0)
  1654. {
  1655. tipMessage = success + "个学号," + grademajorfail + "条由于年级专业信息的原因无法生成,请核查";
  1656. }
  1657. else if (facultymajorfail <= 0 && grademajorfail <= 0 && classmajorfail > 0 && fail <= 0)
  1658. {
  1659. tipMessage = success + "个学号," + classmajorfail + "条由于班级信息的原因无法生成,请核查";
  1660. }
  1661. else
  1662. {
  1663. tipMessage = success + "个学号," + fail + "条由于班级信息或学号已存在无法生成," + facultymajorfail + "条由于院系专业信息的原因无法生成," +
  1664. grademajorfail + "条由于年级专业信息的原因无法生成," + classmajorfail + "条由于班级信息的原因无法生成,请核查";
  1665. }
  1666. }
  1667. return tipMessage;
  1668. }
  1669. catch (Exception ex)
  1670. {
  1671. throw new Exception(ex.Message);
  1672. }
  1673. }
  1674. /// <summary>
  1675. /// 提交(需判断是否已分班且生成学号,并对学生信息进行验证,如:考生号或准考证号唯一、学号唯一)
  1676. /// 注:个性化配置
  1677. /// 此为默认规则
  1678. /// </summary>
  1679. /// <param name="newStudentIDList"></param>
  1680. /// <returns></returns>
  1681. public virtual string NewStudentEnterSubmit(List<Guid?> newStudentIDList)
  1682. {
  1683. try
  1684. {
  1685. //查询相关Web.config配置
  1686. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringMonth == null)
  1687. {
  1688. throw new Exception("预计毕业月(春季、上学期入学月)未配置,请检查。");
  1689. }
  1690. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringDay == null)
  1691. {
  1692. throw new Exception("预计毕业日(春季、上学期入学日)未配置,请检查。");
  1693. }
  1694. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnMonth == null)
  1695. {
  1696. throw new Exception("预计毕业月(秋季、下学期入学月)未配置,请检查。");
  1697. }
  1698. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnDay == null)
  1699. {
  1700. throw new Exception("预计毕业日(秋季、下学期入学日)未配置,请检查。");
  1701. }
  1702. //查询录取名单信息(已分配状态)
  1703. var newStudentEnterList = NewStudentDAL.NewStudentRepository.GetList(x => newStudentIDList.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.Assigned).ToList();
  1704. //查询班级信息ID为空的录取名单(注:如果有班级信息,对应的专业班级一定存在(无需验证是否有专业班级))
  1705. var classIDVerifyList = newStudentEnterList.Where(x => string.IsNullOrEmpty(x.ClassmajorID.ToString())).ToList();
  1706. if (classIDVerifyList != null && classIDVerifyList.Count() > 0)
  1707. {
  1708. throw new Exception("选择提交的名单中存在未分班的数据,请检查。");
  1709. }
  1710. //查询学号为空的录取名单
  1711. var studentNoVerifyList = newStudentEnterList.Where(x => string.IsNullOrEmpty(x.StudentNo)).ToList();
  1712. if (studentNoVerifyList != null && studentNoVerifyList.Count() > 0)
  1713. {
  1714. throw new Exception("选择提交的名单中存在未生成学号的数据,请检查。");
  1715. }
  1716. //有疑义名单判断
  1717. if (newStudentEnterList.Any(x => x.IsDoubt == true))
  1718. {
  1719. throw new Exception("选择提交的名单中存在有疑议的数据,请检查。");
  1720. }
  1721. //已提交状态判断
  1722. if (newStudentEnterList.Any(x => x.RecordStatus == (int)EMIS.ViewModel.CF_NewStudentEnterStatus.Submitted))
  1723. {
  1724. throw new Exception("选择提交的名单中存在已提交的数据,请检查。");
  1725. }
  1726. //年级
  1727. var gradeIDList = newStudentEnterList.Where(x => !string.IsNullOrEmpty(x.GradeID.ToString())).Select(x => x.GradeID).ToList();
  1728. //考生号
  1729. var examineeNumList = newStudentEnterList.Where(x => !string.IsNullOrEmpty(x.ExamineeNum)).Select(x => x.ExamineeNum).ToList();
  1730. ////准考证号
  1731. //var admissionTicketNoList = newStudentEnterList.Where(x => !string.IsNullOrEmpty(x.AdmissionTicketNo)).Select(x => x.AdmissionTicketNo).ToList();
  1732. //身份证号
  1733. var iDNumberList = newStudentEnterList.Where(x => !string.IsNullOrEmpty(x.IDNumber)).Select(x => x.IDNumber).ToList();
  1734. //学号
  1735. var studentNoList = newStudentEnterList.Where(x => !string.IsNullOrEmpty(x.StudentNo)).Select(x => x.StudentNo).ToList();
  1736. //查询学年学期信息(验证对应的年级专业的入学学期与Web.config配置是否一致,有班级信息相应的学年学期信息一定存在)
  1737. //如不致,以年级专业对应的入学学期为准
  1738. var schoolyearVerifyList = NewStudentDAL.SchoolyearRepository.GetList(x => gradeIDList.Contains(x.Years)).ToList();
  1739. //班级信息ID
  1740. var classIDList = newStudentEnterList.Where(x => !string.IsNullOrEmpty(x.ClassmajorID.ToString())).Select(x => x.ClassmajorID).ToList();
  1741. ////查询学生信息(用于验证考生号、准考证号)
  1742. //var studentVerifyList = NewStudentDAL.RecruitstudentsRepository.GetList(x => examineeNumList.Contains(x.ExamineeNum) || admissionTicketNoList.Contains(x.AdmissionTicketNo)).ToList();
  1743. //查询学生信息(用于验证考生号)
  1744. var studentVerifyList = NewStudentDAL.RecruitstudentsRepository.GetList(x => examineeNumList.Contains(x.ExamineeNum)).ToList();
  1745. //查询用户信息(用于验证学号)
  1746. var userVerifyList = NewStudentDAL.UserRepository.GetList(x => studentNoList.Contains(x.LoginID)).ToList();
  1747. //查询班级信息(用于验证班级)
  1748. var classMajorVerifyList = NewStudentDAL.ClassmajorRepository.GetList(x => classIDList.Contains(x.ClassmajorID)).ToList();
  1749. //年级专业ID(根据班级信息ID)
  1750. var classMajorIDList = classMajorVerifyList.Where(x => !string.IsNullOrEmpty(x.GrademajorID.ToString())).Select(x => x.GrademajorID).ToList();
  1751. //查询年级专业(根据年级专业ID)
  1752. var gradeMajorVerifyList = NewStudentDAL.GrademajorRepository.GetList(x => classMajorIDList.Contains(x.GrademajorID)).ToList();
  1753. //查询年级专业的毕业学期ID(根据年级专业ID)
  1754. var gradschoolyearIDList = NewStudentDAL.GrademajorRepository.GetList(x => classMajorIDList.Contains(x.GrademajorID)).Select(x => x.GraduateSchoolyearID).ToList();
  1755. //查询毕业学期(用于验证毕业学期)
  1756. var gradschoolyearVerifyList = NewStudentDAL.SchoolyearRepository.GetList(x => gradschoolyearIDList.Contains(x.SchoolyearID)).ToList();
  1757. //查询毕业学期对应的毕业日期List
  1758. var graduateDateList = NewStudentDAL.GraduateSchoolyearRepository.GetList(x => true).ToList();
  1759. //查询学生用户密码规则定义
  1760. var passwordParameter = NewStudentDAL.ParameterRepository.GetSingle(x => x.ParameterTypeID == (int)ViewModel.CF_ParameterType.StudentInitPassword);
  1761. //查询学生角色信息
  1762. var roleList = NewStudentDAL.RoleRepository.GetList(x => x.TypeID == (int)SYS_RoleType.Student, (x => x.CF_StudentRole)).ToList();
  1763. int studentfail = 0;
  1764. int studentNofail = 0;
  1765. int success = 0;
  1766. string tipMessage = null;
  1767. List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
  1768. List<Sys_User> userInList = new List<Sys_User>();
  1769. List<CF_Student> studentInList = new List<CF_Student>();
  1770. List<CF_StudentProfile> studentProfileInList = new List<CF_StudentProfile>();
  1771. List<CF_StudentContact> studentContactInList = new List<CF_StudentContact>();
  1772. List<CF_StudentAccount> studentAccountInList = new List<CF_StudentAccount>();
  1773. List<CF_Recruitstudents> studentRecruitInList = new List<CF_Recruitstudents>();
  1774. //List<CF_StudentFamily> studentFamilyInList = new List<CF_StudentFamily>();
  1775. //List<CF_StudentExperience> studentExperienceInList = new List<CF_StudentExperience>();
  1776. foreach (var newStudentEnter in newStudentEnterList)
  1777. {
  1778. Sys_User user = new Sys_User();
  1779. CF_Student student = new CF_Student();
  1780. CF_StudentProfile studentProfile = new CF_StudentProfile();
  1781. CF_StudentContact studentContact = new CF_StudentContact();
  1782. CF_StudentAccount studentAccount = new CF_StudentAccount();
  1783. CF_Recruitstudents studentRecruit = new CF_Recruitstudents();
  1784. //CF_StudentFamily studentFamily = new CF_StudentFamily();
  1785. //CF_StudentExperience studentExperience = new CF_StudentExperience();
  1786. //验证考生号
  1787. var examineeNumVerify = studentVerifyList.Where(x => x.ExamineeNum == newStudentEnter.ExamineeNum).SingleOrDefault();
  1788. if (examineeNumVerify == null)
  1789. {
  1790. ////验证准考证号
  1791. //if (!string.IsNullOrEmpty(newStudentEnter.AdmissionTicketNo))
  1792. //{
  1793. // var admissionTicketNoVerify = studentVerifyList.Where(x => x.AdmissionTicketNo == newStudentEnter.AdmissionTicketNo).SingleOrDefault();
  1794. // if (admissionTicketNoVerify != null)
  1795. // {
  1796. // //准考证号验证不通过
  1797. // studentfail++;
  1798. // continue;
  1799. // }
  1800. //}
  1801. //考生号验证通过,验证学号
  1802. var userVerify = userVerifyList.Where(x => x.LoginID == newStudentEnter.StudentNo).SingleOrDefault();
  1803. if (userVerify == null)
  1804. {
  1805. //学号验证通过
  1806. user.UserID = Guid.NewGuid();
  1807. user.LoginID = newStudentEnter.StudentNo;
  1808. user.Name = newStudentEnter.Name;
  1809. if (passwordParameter == null)
  1810. {
  1811. user.Password = ("A" + newStudentEnter.StudentNo).MD5();
  1812. }
  1813. else
  1814. {
  1815. if (passwordParameter.Value != null)
  1816. {
  1817. user.Password = passwordParameter.Value;
  1818. }
  1819. else
  1820. {
  1821. user.Password = ("A" + newStudentEnter.StudentNo).MD5();
  1822. }
  1823. }
  1824. SetNewStatus(user, (int)SYS_STATUS.USABLE);
  1825. userInList.Add(user);
  1826. user.Sys_Role = new HashSet<Sys_Role>();
  1827. roleList = roleList.Where(x => x.CF_StudentRole.StudentType == (int)CF_STUDENTTYPE.DefaultType).ToList();
  1828. if (roleList != null && roleList.Count > 0)
  1829. {
  1830. roleList.ForEach(x => user.Sys_Role.Add(x));
  1831. }
  1832. student.UserID = user.UserID;
  1833. student.ClassmajorID = newStudentEnter.ClassmajorID;
  1834. student.SexID = newStudentEnter.SexID;
  1835. student.BirthDate = newStudentEnter.BirthDate;
  1836. student.NationID = newStudentEnter.NationID;
  1837. student.PoliticsID = newStudentEnter.PoliticsID;
  1838. student.CertificatesType = newStudentEnter.CertificatesType;
  1839. student.IDNumber = newStudentEnter.IDNumber;
  1840. student.StudentType = (int)CF_STUDENTTYPE.DefaultType;
  1841. student.InSchoolStatusID = (int)CF_InschoolStatus.InSchool;
  1842. student.StudentStatus = (int)CF_StudentStatus.Registration;
  1843. student.StudentCardNo = user.LoginID;
  1844. student.PhotoUrl = null;
  1845. //对应的班级信息
  1846. var classMajor = classMajorVerifyList.Where(x => x.ClassmajorID == newStudentEnter.ClassmajorID).SingleOrDefault();
  1847. //对应的年级专业的毕业学期
  1848. var gradeMajor = gradeMajorVerifyList.Where(x => x.GrademajorID == classMajor.GrademajorID).SingleOrDefault();
  1849. if (gradeMajor != null)
  1850. {
  1851. //查询对应毕业学期信息
  1852. var gradschoolyear = gradschoolyearVerifyList.Where(x => x.SchoolyearID == gradeMajor.GraduateSchoolyearID).SingleOrDefault();
  1853. if (gradschoolyear != null)
  1854. {
  1855. //预计毕业日期
  1856. student.PlanningGraduateDate = PlanningGraduateDateHelper.GetPlanningGraduateDate(gradschoolyear.FirstWeek);
  1857. }
  1858. else
  1859. {
  1860. //预计毕业日期
  1861. student.PlanningGraduateDate = null;
  1862. }
  1863. //查询对应的毕业日期
  1864. var graduateDate = graduateDateList.Where(x => x.SchoolyearID == gradeMajor.GraduateSchoolyearID).SingleOrDefault();
  1865. if (graduateDate != null)
  1866. {
  1867. //毕业日期
  1868. student.GraduateDate = graduateDate.GraduateDate;
  1869. }
  1870. else
  1871. {
  1872. //毕业日期
  1873. student.GraduateDate = null;
  1874. }
  1875. }
  1876. else
  1877. {
  1878. //预计毕业日期
  1879. student.PlanningGraduateDate = null;
  1880. //毕业日期
  1881. student.GraduateDate = null;
  1882. }
  1883. student.GraduateCardNo = null;
  1884. student.ReplaceGraduateNo = null;
  1885. student.DegreeStatus = false;
  1886. student.GraduationPictureUrl = null;
  1887. student.Career = null;
  1888. student.IsPhotoComparison = false;
  1889. student.IsProofread = false;
  1890. student.Remark = newStudentEnter.Remark;
  1891. SetNewStatus(student, (int)SYS_STATUS.USABLE);
  1892. studentInList.Add(student);
  1893. studentProfile.UserID = user.UserID;
  1894. studentProfile.UsedName = null;
  1895. studentProfile.LiteracyLevelID = null;
  1896. studentProfile.CultureModelID = null;
  1897. studentProfile.IsDreamProject = false;
  1898. studentProfile.Country = "中国";
  1899. studentProfile.Place = null;
  1900. studentProfile.BornPlace = null;
  1901. studentProfile.HealthStateID = null;
  1902. studentProfile.BloodGroup = null;
  1903. studentProfile.Specialty = null;
  1904. studentProfile.Height = null;
  1905. studentProfile.Weight = null;
  1906. studentProfile.DirectorName = null;
  1907. SetNewStatus(studentProfile, (int)SYS_STATUS.USABLE);
  1908. studentProfileInList.Add(studentProfile);
  1909. studentContact.UserID = user.UserID;
  1910. studentContact.Email = null;
  1911. studentContact.Telephone = newStudentEnter.Telephone;
  1912. studentContact.Mobile = newStudentEnter.Telephone;
  1913. studentContact.ZIPCode = newStudentEnter.ZIPCode;
  1914. studentContact.WeChatNum = null;
  1915. studentContact.QQ = null;
  1916. studentContact.HomeAddress = null;
  1917. studentContact.WorkUnit = null;
  1918. studentContact.Address = newStudentEnter.Address;
  1919. studentContact.Recipient = newStudentEnter.Name;
  1920. studentContact.Dormitory = null;
  1921. SetNewStatus(studentContact, (int)SYS_STATUS.USABLE);
  1922. studentContactInList.Add(studentContact);
  1923. studentAccount.UserID = user.UserID;
  1924. studentAccount.CardNo = null;
  1925. studentAccount.BankName = null;
  1926. SetNewStatus(studentAccount, (int)SYS_STATUS.USABLE);
  1927. studentAccountInList.Add(studentAccount);
  1928. studentRecruit.UserID = user.UserID;
  1929. studentRecruit.ExamineeNum = newStudentEnter.ExamineeNum;
  1930. studentRecruit.AdmissionTicketNo = newStudentEnter.AdmissionTicketNo;
  1931. studentRecruit.ExamineeType = null;
  1932. //查询对应入学学年学期
  1933. var enterSchoolYear = schoolyearVerifyList.Where(x => x.Years == newStudentEnter.GradeID && x.SchoolcodeID == classMajor.CF_Grademajor.SemesterID).SingleOrDefault();
  1934. if (enterSchoolYear != null)
  1935. {
  1936. studentRecruit.EnteringSchoolYearID = enterSchoolYear.SchoolyearID;
  1937. }
  1938. else
  1939. {
  1940. studentRecruit.EnteringSchoolYearID = null;
  1941. }
  1942. studentRecruit.EntranceDate = newStudentEnter.EntranceDate;
  1943. studentRecruit.Score = newStudentEnter.Score;
  1944. studentRecruit.EntranceWayID = newStudentEnter.EntranceWayID;
  1945. studentRecruit.FeaturesID = newStudentEnter.FeaturesID;
  1946. studentRecruit.TerritorialID = newStudentEnter.TerritorialID;
  1947. studentRecruit.Area = null;
  1948. studentRecruit.RecruitPictureUrl = newStudentEnter.RecruitPictureUrl;
  1949. SetNewStatus(studentRecruit, (int)SYS_STATUS.USABLE);
  1950. studentRecruitInList.Add(studentRecruit);
  1951. //studentFamily.StudentFamilyID = Guid.NewGuid();
  1952. //studentFamily.UserID = user.UserID;
  1953. //SetNewStatus(studentFamily, (int)SYS_STATUS.USABLE);
  1954. //studentFamilyInList.Add(studentFamily);
  1955. //studentExperience.StudentExperienceID = Guid.NewGuid();
  1956. //studentExperience.UserID = user.UserID;
  1957. //SetNewStatus(studentExperience, (int)SYS_STATUS.USABLE);
  1958. //studentExperienceInList.Add(studentExperience);
  1959. //获取提交成功的录取名单信息(用于做其它的处理,如:删除、更新等)
  1960. newStudentEnter.RecordStatus = (int)CF_NewStudentEnterStatus.Submitted;
  1961. SetModifyStatus(newStudentEnter);
  1962. newStudentUpList.Add(newStudentEnter);
  1963. success++;
  1964. }
  1965. else
  1966. {
  1967. //学号验证不通过
  1968. studentNofail++;
  1969. continue;
  1970. }
  1971. }
  1972. else
  1973. {
  1974. //考生号验证不通过
  1975. studentfail++;
  1976. continue;
  1977. }
  1978. }
  1979. using (TransactionScope ts = new TransactionScope())
  1980. {
  1981. //批量插入
  1982. UnitOfWork.BulkInsert<Sys_User>(userInList);
  1983. UnitOfWork.BulkInsert(userInList, (x => x.Sys_Role)); //插入相应的关系表
  1984. UnitOfWork.BulkInsert<CF_Student>(studentInList);
  1985. UnitOfWork.BulkInsert<CF_StudentProfile>(studentProfileInList);
  1986. UnitOfWork.BulkInsert<CF_StudentContact>(studentContactInList);
  1987. UnitOfWork.BulkInsert<CF_StudentAccount>(studentAccountInList);
  1988. UnitOfWork.BulkInsert<CF_Recruitstudents>(studentRecruitInList);
  1989. //UnitOfWork.BulkInsert<CF_StudentFamily>(studentFamilyInList);
  1990. //UnitOfWork.BulkInsert<CF_StudentExperience>(studentExperienceInList);
  1991. //刷新对应的学生相关信息
  1992. StudentServices.Value.AddStudentEnd(studentInList.Select(x => x.UserID).ToList());
  1993. //提交成功后,更新相应的录取名单状态
  1994. if (newStudentUpList != null && newStudentUpList.Count() > 0)
  1995. {
  1996. UnitOfWork.BatchUpdate(newStudentUpList); //批量更新
  1997. }
  1998. ts.Complete();
  1999. }
  2000. if (studentfail <= 0 && studentNofail <= 0)
  2001. {
  2002. tipMessage = success + "条录取名单进入学生信息库";
  2003. }
  2004. else
  2005. {
  2006. if (studentNofail > 0 && studentfail <= 0)
  2007. {
  2008. tipMessage = success + "条录取名单进入学生信息库," + studentNofail + "条录取名单提交失败,原因:学号已存在,请检查";
  2009. }
  2010. else if (studentNofail <= 0 && studentfail > 0)
  2011. {
  2012. tipMessage = success + "条录取名单进入学生信息库," + studentfail + "条录取名单提交失败,原因:考生号或准考证号已存在,请检查";
  2013. }
  2014. else
  2015. {
  2016. tipMessage = success + "条录取名单进入学生信息库," + studentNofail + "条录取名单由于学号已存在提交失败," + studentfail + "条录取名单由于考生号或准考证号已存在提交失败,请检查";
  2017. }
  2018. }
  2019. return tipMessage;
  2020. }
  2021. catch (Exception ex)
  2022. {
  2023. throw new Exception(ex.Message);
  2024. }
  2025. }
  2026. }
  2027. }