RecruitSpecialtyServices.cs 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Transactions;
  6. using EMIS.Entities;
  7. using EMIS.ViewModel;
  8. using EMIS.ViewModel.CacheManage;
  9. using EMIS.ViewModel.UniversityManage.SpecialtyClassManage;
  10. using EMIS.CommonLogic.SystemServices;
  11. namespace EMIS.ExtensionLogic.ServiceLogic.EnrollManage
  12. {
  13. public class RecruitSpecialtyServices : EMIS.CommonLogic.EnrollManage.SpecialtyManage.RecruitSpecialtyServices
  14. {
  15. /// <summary>
  16. /// 流水号生成Services
  17. /// </summary>
  18. public Lazy<ISerialNumberServices> SerialNumberServices { get; set; }
  19. /// <summary>
  20. /// 广东松山专业班级生成规则
  21. /// </summary>
  22. /// <param name="recruitSpecialtyIDs"></param>
  23. /// <returns></returns>
  24. public override string GenerateClass(List<Guid?> recruitSpecialtyIDs)
  25. {
  26. //生成规则如下:
  27. //院系编码(5位):院系所代码后2位+学制1位(直接取值)+2位流水号,拼出来,如:01201、01303
  28. //院系名称:专业名称(默认),如:电气自动化技术(分方向的情况下的命名需手动设置)
  29. //2位流水号:按院系所代码、学制、培养层次、学习形式、专业名称进行排序取2位流水号
  30. //年级专业编码(8位):年级+院系所代码后2位+2位流水号,拼出来,如:20170101、20170103
  31. //年级专业名称:年级+"级"+院系名称或专业名称(院系名称优先),如:2017级电气自动化技术(分方向的情况下的命名需手动设置)
  32. //2位流水号:按院系所代码、学制、培养层次、学习形式、专业名称进行排序取2位流水号
  33. //注:此处2位流水号可与对应的院系编码2位流水号不一致,不然会出现年级专业编码重复的问题
  34. //班级编码(9位):年级专业编码+1位流水号,拼出来,如:201701121、201701131
  35. //班级名称:年级+"级"+专业名称或年级专业名称(年级专业名称优先)+流水号(可为空)+"班",如:2017级应用电子技术班、2017级物联网应用技术1班
  36. //注:班级名称的命名有无流水号的问题
  37. try
  38. {
  39. //查询招生专业信息
  40. var recruitSpecialtyList = recruitSpecialtyDAL.recruitSpecialtyRepository.GetList(x => recruitSpecialtyIDs.Contains(x.RecruitSpecialtyID), x => x.CF_College, x => x.CF_Specialty)
  41. .OrderBy(x => x.CF_College.No).ThenByDescending(x => x.GradeID).ThenBy(x => x.CF_Specialty.LearnSystem).ThenBy(x => x.CF_Specialty.EducationID)
  42. .ThenBy(x => x.CF_Specialty.LearningformID).ThenBy(x => x.CF_Specialty.StandardID).ToList();
  43. //年级ID
  44. var gradeIDList = recruitSpecialtyList.Where(x => !string.IsNullOrEmpty(x.GradeID.ToString())).Select(x => x.GradeID).ToList();
  45. //专业信息ID
  46. var specialtyIDList = recruitSpecialtyList.Where(x => !string.IsNullOrEmpty(x.SpecialtyID.ToString())).Select(x => x.SpecialtyID).ToList();
  47. //院系所ID
  48. var collegeIDList = recruitSpecialtyList.Where(x => !string.IsNullOrEmpty(x.CollegeID.ToString())).Select(x => x.CollegeID).ToList();
  49. //查询专业信息
  50. var specialtyList = recruitSpecialtyDAL.specialtyRepository.GetList(x => specialtyIDList.Contains(x.SpecialtyID)).ToList();
  51. //查询专业分班信息
  52. var specialtyClassSettingList = recruitSpecialtyDAL.SpecialtyClassSettingRepository.GetList(x => specialtyIDList.Contains(x.SpecialtyID)).ToList();
  53. //查询院系所信息
  54. var collegeList = recruitSpecialtyDAL.collegeRepository.Entities.Where(x => collegeIDList.Contains(x.CollegeID)).ToList();
  55. //年级
  56. var gradeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Grade).ToList();
  57. //专业代码、专业名称、专业ID(Value)
  58. var standardList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Standard).ToList();
  59. //培养层次(所修学历)
  60. var educationList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Education).ToList();
  61. //学习形式
  62. var learningFormList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Learningform).ToList();
  63. //查询对应的院系专业信息
  64. var facultymajorList = recruitSpecialtyDAL.GetFacultymajorByRecruitSpecialty(x => recruitSpecialtyIDs.Contains(x.RecruitSpecialtyID)).ToList();
  65. //院系专业ID
  66. var facultymajorIDList = facultymajorList.Where(x => !string.IsNullOrEmpty(x.FacultymajorID.ToString())).Select(x => x.FacultymajorID).ToList();
  67. //查询对应的院系所中院系专业信息当前Max流水序号(院系所、学制分组查询)
  68. var faMaxCodeList = recruitSpecialtyDAL.GetFacultymajorMaxCodeByCollegeLearnSystem(x => collegeIDList.Contains(x.CollegeID)).ToList();
  69. //查询对应的年级专业信息
  70. var grademajorList = recruitSpecialtyDAL.GetGrademajorByRecruitSpecialty(x => recruitSpecialtyIDs.Contains(x.RecruitSpecialtyID), x => facultymajorIDList.Contains(x.FacultymajorID)).ToList();
  71. //年级专业ID
  72. var grademajorIDList = grademajorList.Where(x => !string.IsNullOrEmpty(x.GrademajorID.ToString())).Select(x => x.GrademajorID).ToList();
  73. //查询对应的年级中年级专业信息当前Max流水序号(院系所、年级分组查询)
  74. var grMaxCodeList = recruitSpecialtyDAL.GetGrademajorMaxCodeByCollegeSchoolyear(x => gradeIDList.Contains(x.GradeID)).ToList();
  75. //查询对应的班级信息
  76. var classmajorList = recruitSpecialtyDAL.GetClassmajorByRecruitSpecialty(x => recruitSpecialtyIDs.Contains(x.RecruitSpecialtyID), x => facultymajorIDList.Contains(x.FacultymajorID), x => grademajorIDList.Contains(x.GrademajorID)).ToList();
  77. //班级信息ID
  78. var classmajorIDList = classmajorList.Where(x => !string.IsNullOrEmpty(x.ClassmajorID.ToString())).Select(x => x.ClassmajorID).ToList();
  79. //根据年级专业信息查询对应的班级信息MaxCode(年级专业分组查询)
  80. var clMaxCodeList = recruitSpecialtyDAL.GetClassmajorMaxCodeByGrademajor(x => grademajorIDList.Contains(x.GrademajorID)).ToList();
  81. //查询学年学期信息
  82. var schoolyearList = recruitSpecialtyDAL.schoolyearRepository.GetList(x => true).ToList();
  83. var facultymajorCode = "";
  84. var facultymajorName = "";
  85. var grademajorCode = "";
  86. var grademajorName = "";
  87. var classmajorCode = "";
  88. var classmajorName = "";
  89. int fail = 0;
  90. int success = 0;
  91. string tipMessage = null;
  92. List<CF_RecruitSpecialty> recruitSpecialtyUpList = new List<CF_RecruitSpecialty>();
  93. List<CF_Facultymajor> facultymajorInList = new List<CF_Facultymajor>();
  94. List<GrademajorView> tempGrademajorViewInList = new List<GrademajorView>(); //用于年级专业编码流水生成(标识)
  95. List<CF_Grademajor> grademajorInList = new List<CF_Grademajor>();
  96. List<CF_Classmajor> classmajorInList = new List<CF_Classmajor>();
  97. foreach (var recruitSpecialty in recruitSpecialtyList)
  98. {
  99. //目前只处理招生专业与专业班级对应关系的情况(已存在的情况下,暂时不做处理)
  100. //专业分方向的情况处理有以下3种,按以下方式进行处理:
  101. //院系专业分方向(手动新增来处理)
  102. //年级专业分方向(手动新增来处理)
  103. //班级信息分方向(以专业分班设置来处理)
  104. //查询对应的院系所信息
  105. var college = collegeList.Where(x => x.CollegeID == recruitSpecialty.CollegeID).SingleOrDefault();
  106. //查询对应的专业信息
  107. var specialty = specialtyList.Where(x => x.SpecialtyID == recruitSpecialty.SpecialtyID).SingleOrDefault();
  108. //查询对应的专业分班信息
  109. var specialtyClassSetting = specialtyClassSettingList.Where(x => x.SpecialtyID == recruitSpecialty.SpecialtyID).SingleOrDefault();
  110. //对应的班级个数
  111. int classNum = 1;
  112. if (specialtyClassSetting != null)
  113. {
  114. if (specialtyClassSetting.ClassNumber != null)
  115. {
  116. if (specialtyClassSetting.ClassNumber.Value > 1)
  117. {
  118. classNum = specialtyClassSetting.ClassNumber.Value;
  119. }
  120. }
  121. }
  122. //专业名称数据字典
  123. var standard = standardList.Where(x => x.Value == specialty.StandardID).SingleOrDefault();
  124. //培养层次(所修学历)
  125. var education = educationList.Where(x => x.Value == specialty.EducationID).SingleOrDefault();
  126. //学习形式
  127. var learningForm = learningFormList.Where(x => x.Value == specialty.LearningformID).SingleOrDefault();
  128. //计算毕业学年学期Value
  129. var graduateSchoolyearValue = (recruitSpecialty.GradeID * 2) - 1 + (recruitSpecialty.SemesterID - 1)
  130. + Convert.ToInt32(Math.Ceiling(specialty.LearnSystem.Value * 2 - 1));
  131. //查询对应的学年学期信息
  132. var graduateSchoolyear = schoolyearList.Where(x => x.Value == graduateSchoolyearValue).SingleOrDefault();
  133. if (graduateSchoolyear == null)
  134. {
  135. //表示年级专业对应的毕业学期,在学年学期信息中不存在(此时不生成)
  136. fail++;
  137. continue;
  138. }
  139. //院系专业Max当前初始编号(院系所、学制分组查询)
  140. var faMaxCode = faMaxCodeList.Where(x => x.CollegeID == recruitSpecialty.CollegeID && x.LearnSystem == recruitSpecialty.CF_Specialty.LearnSystem).SingleOrDefault();
  141. if (faMaxCode == null)
  142. {
  143. //表示不存在(取初始值01)
  144. //院系编码(5位):院系所代码后2位+学制1位(直接取值)+2位流水号,拼出来
  145. facultymajorCode = college.No.Trim().Substring(college.No.Trim().Length - 2).PadLeft(2, '0')
  146. + Convert.ToInt32(specialty.LearnSystem).ToString() + "01";
  147. }
  148. else
  149. {
  150. //表示已存在(当前初始值+1)
  151. //院系编码(5位):院系所代码后2位+学制1位(直接取值)+2位流水号,拼出来
  152. var nextFaNum = (Convert.ToInt32(faMaxCode.Code.Trim().Substring(faMaxCode.Code.Trim().Length - 2)) + 1).ToString().PadLeft(2, '0');
  153. facultymajorCode = college.No.Trim().Substring(college.No.Trim().Length - 2).PadLeft(2, '0')
  154. + Convert.ToInt32(specialty.LearnSystem).ToString() + nextFaNum;
  155. }
  156. //由于可批量生成,需判断缓存中的院系专业编号中流水序号的问题
  157. if (facultymajorInList != null && facultymajorInList.Count() > 0)
  158. {
  159. //查询缓存中已生成的院系专业编号List
  160. var newFaMaxCodeList = facultymajorInList.Where(x => x.CollegeID == recruitSpecialty.CollegeID
  161. && x.LearnSystem == recruitSpecialty.CF_Specialty.LearnSystem).ToList();
  162. if (newFaMaxCodeList != null && newFaMaxCodeList.Count() > 0)
  163. {
  164. //表示缓存中已存在对应的院系编号(取当前MaxCode为初始值+1)
  165. var newFaMaxCode = newFaMaxCodeList.GroupBy(x => x.Code).Max(x => x.Key);
  166. //院系编码(5位):院系所代码后2位+学制1位(直接取值)+2位流水号,拼出来
  167. var newNextFaNum = (Convert.ToInt32(newFaMaxCode.Trim().Substring(newFaMaxCode.Trim().Length - 2)) + 1).ToString().PadLeft(2, '0');
  168. facultymajorCode = college.No.Trim().Substring(college.No.Trim().Length - 2).PadLeft(2, '0')
  169. + Convert.ToInt32(specialty.LearnSystem).ToString() + newNextFaNum;
  170. }
  171. }
  172. //院系名称:专业名称(默认),如:电气自动化技术(分方向的情况下的命名需手动修改)
  173. facultymajorName = standard.Name.Trim();
  174. //年级专业Max当前初始编号(院系所、年级分组查询)
  175. var grMaxCode = grMaxCodeList.Where(x => x.CollegeID == recruitSpecialty.CollegeID && x.GradeID == recruitSpecialty.GradeID).SingleOrDefault();
  176. if (grMaxCode == null)
  177. {
  178. //表示不存在(取初始值01)
  179. //年级专业编码(8位):年级+院系所代码后2位+2位流水号,拼出来
  180. grademajorCode = recruitSpecialty.GradeID.ToString() + college.No.Trim().Substring(college.No.Trim().Length - 2).PadLeft(2, '0') + "01";
  181. }
  182. else
  183. {
  184. //表示已存在(当前初始值+1)
  185. //年级专业编码(8位):年级+院系所代码后2位+2位流水号,拼出来
  186. var nextGrNum = (Convert.ToInt32(grMaxCode.Code.Trim().Substring(grMaxCode.Code.Trim().Length - 2)) + 1).ToString().PadLeft(2, '0');
  187. grademajorCode = recruitSpecialty.GradeID.ToString() + college.No.Trim().Substring(college.No.Trim().Length - 2).PadLeft(2, '0') + nextGrNum;
  188. }
  189. //由于可批量生成,需判断缓存中的年级专业编号中流水序号的问题
  190. if (grademajorInList != null && grademajorInList.Count() > 0)
  191. {
  192. //查询缓存中已生成的年级专业编号List(通过标识List来查询)
  193. var newGrMaxCodeList = tempGrademajorViewInList.Where(x => x.CollegeID == recruitSpecialty.CollegeID
  194. && x.GradeID == recruitSpecialty.GradeID).ToList();
  195. if (newGrMaxCodeList != null && newGrMaxCodeList.Count() > 0)
  196. {
  197. //表示缓存中已存在对应的年级专业编号(取当前MaxCode为初始值+1)
  198. var newGrMaxCode = newGrMaxCodeList.GroupBy(x => x.Code).Max(x => x.Key);
  199. //年级专业编码(8位):年级+院系所代码后2位+2位流水号,拼出来
  200. var newNextGrNum = (Convert.ToInt32(newGrMaxCode.Trim().Substring(newGrMaxCode.Trim().Length - 2)) + 1).ToString().PadLeft(2, '0');
  201. grademajorCode = recruitSpecialty.GradeID.ToString() + college.No.Trim().Substring(college.No.Trim().Length - 2).PadLeft(2, '0') + newNextGrNum;
  202. }
  203. }
  204. //年级专业名称:年级+"级"+院系名称或专业名称(院系名称优先)
  205. grademajorName = recruitSpecialty.GradeID.ToString() + "级" + facultymajorName;
  206. //注:暂时只取部分命名规则
  207. //班级编码(9位):年级+院系所代码后2位+2位流水号+1位流水号(年级专业编码+1位流水号),拼出来
  208. classmajorCode = grademajorCode;
  209. //班级名称:年级+"级"+专业名称或年级专业名称(年级专业名称优先)+流水号(可为空)+"班"
  210. classmajorName = grademajorName;
  211. //查询对应的院系专业信息
  212. var facultymajorVerifyList = facultymajorList.Where(x => x.RecruitSpecialtyID == recruitSpecialty.RecruitSpecialtyID).ToList();
  213. //判断院系专业
  214. if (facultymajorVerifyList != null && facultymajorVerifyList.Count() > 0)
  215. {
  216. //表示存在对应的院系专业信息
  217. foreach (var facultymajorVerify in facultymajorVerifyList)
  218. {
  219. //查询对应的年级专业信息
  220. var grademajorVerifyList = grademajorList.Where(x => x.FacultymajorID == facultymajorVerify.FacultymajorID).ToList();
  221. //判断年级专业
  222. if (grademajorVerifyList != null && grademajorVerifyList.Count() > 0)
  223. {
  224. //表示存在对应的年级专业信息
  225. foreach (var grademajorVerify in grademajorVerifyList)
  226. {
  227. //查询对应的班级信息
  228. var classmajorVerifyList = classmajorList.Where(x => x.GrademajorID == grademajorVerify.GrademajorID).ToList();
  229. //判断班级信息
  230. if (classmajorVerifyList != null && classmajorVerifyList.Count() > 0)
  231. {
  232. //表示存在对应的班级信息(需处理专业分班信息中班级个数的问题)
  233. //表示存在的班级个数大于专业分班的班级个数
  234. if (classmajorVerifyList.Count() >= classNum)
  235. {
  236. if (classmajorVerifyList.Count() == 1)
  237. {
  238. //查询对应的班级信息(只有一条班级信息可在此处做更新处理)
  239. var classmajorEntity = classmajorVerifyList.Where(x => x.GrademajorID == grademajorVerify.GrademajorID).SingleOrDefault();
  240. //(暂时不做更新处理)
  241. }
  242. else
  243. {
  244. //表示存在多个班级个数(可在此做其它处理)
  245. }
  246. }
  247. else
  248. {
  249. //表示存在的班级个数不足
  250. //查询对应的班级信息Max编号(年级专业分组查询)
  251. var clMaxCode = clMaxCodeList.Where(x => x.GrademajorID == grademajorVerify.GrademajorID).SingleOrDefault();
  252. var clNum = Convert.ToInt32(clMaxCode.No.Trim().Substring(clMaxCode.No.Trim().Length - 1));
  253. //生成剩余的班级个数(暂时以MaxCode+1形式生成)
  254. for (int i = 1; i <= classNum - classmajorVerifyList.Count(); i++)
  255. {
  256. CF_Classmajor newClassmajor = new CF_Classmajor();
  257. newClassmajor.ClassmajorID = Guid.NewGuid();
  258. newClassmajor.GrademajorID = grademajorVerify.GrademajorID;
  259. newClassmajor.No = grademajorVerify.GrademajorCode.Trim() + (clNum + i).ToString();
  260. newClassmajor.Name = grademajorVerify.GrademajorName.Trim() + (clNum + i).ToString() + "班";
  261. newClassmajor.Abbreviation = newClassmajor.Name;
  262. newClassmajor.EnglishName = null;
  263. newClassmajor.ClassNum = (clNum + i);
  264. newClassmajor.UserID = null;
  265. newClassmajor.AssistantUserID = null;
  266. newClassmajor.Fixedclassroom = null;
  267. newClassmajor.Remark = null;
  268. SetNewStatus(newClassmajor);
  269. classmajorInList.Add(newClassmajor);
  270. }
  271. }
  272. }
  273. else
  274. {
  275. //表示对应的班级信息不存在(需根据专业分班信息生成对应的班级个数)
  276. if (classNum > 1)
  277. {
  278. for (int i = 1; i <= classNum; i++)
  279. {
  280. CF_Classmajor newClassmajor = new CF_Classmajor();
  281. newClassmajor.ClassmajorID = Guid.NewGuid();
  282. newClassmajor.GrademajorID = grademajorVerify.GrademajorID;
  283. newClassmajor.No = grademajorVerify.GrademajorCode.Trim() + i.ToString();
  284. newClassmajor.Name = grademajorVerify.GrademajorName.Trim() + i.ToString() + "班";
  285. newClassmajor.Abbreviation = newClassmajor.Name;
  286. newClassmajor.EnglishName = null;
  287. newClassmajor.ClassNum = i;
  288. newClassmajor.UserID = null;
  289. newClassmajor.AssistantUserID = null;
  290. newClassmajor.Fixedclassroom = null;
  291. newClassmajor.Remark = null;
  292. SetNewStatus(newClassmajor);
  293. classmajorInList.Add(newClassmajor);
  294. }
  295. }
  296. else
  297. {
  298. //表示只生成一个对应的班级信息(默认)
  299. CF_Classmajor newClassmajor = new CF_Classmajor();
  300. newClassmajor.ClassmajorID = Guid.NewGuid();
  301. newClassmajor.GrademajorID = grademajorVerify.GrademajorID;
  302. newClassmajor.No = grademajorVerify.GrademajorCode.Trim() + "1";
  303. newClassmajor.Name = grademajorVerify.GrademajorName.Trim() + "班";
  304. newClassmajor.Abbreviation = newClassmajor.Name;
  305. newClassmajor.EnglishName = null;
  306. newClassmajor.ClassNum = 1;
  307. newClassmajor.UserID = null;
  308. newClassmajor.AssistantUserID = null;
  309. newClassmajor.Fixedclassroom = null;
  310. newClassmajor.Remark = null;
  311. SetNewStatus(newClassmajor);
  312. classmajorInList.Add(newClassmajor);
  313. }
  314. }
  315. }
  316. }
  317. else
  318. {
  319. //表示对应的年级专业信息不存在
  320. //注:根据院系专业信息生成年级专业信息、专业分班信息生成对应的班级个数
  321. CF_Grademajor newGrademajor = new CF_Grademajor();
  322. newGrademajor.GrademajorID = Guid.NewGuid();
  323. newGrademajor.FacultymajorID = facultymajorVerify.FacultymajorID;
  324. newGrademajor.Code = grademajorCode;
  325. newGrademajor.Name = recruitSpecialty.GradeID.ToString() + "级" + facultymajorVerify.FacultymajorName.Trim();
  326. newGrademajor.Abbreviation = newGrademajor.Name;
  327. newGrademajor.GradeID = recruitSpecialty.GradeID;
  328. newGrademajor.SemesterID = recruitSpecialty.SemesterID;
  329. newGrademajor.GraduateSchoolyearID = graduateSchoolyear.SchoolyearID;
  330. newGrademajor.Professional = null;
  331. newGrademajor.Remark = null;
  332. SetNewStatus(newGrademajor);
  333. grademajorInList.Add(newGrademajor);
  334. //用于年级专业编码流水生成(标识)
  335. GrademajorView newGrademajorView = new GrademajorView();
  336. newGrademajorView.Code = newGrademajor.Code;
  337. newGrademajorView.CollegeID = facultymajorVerify.CollegeID;
  338. newGrademajorView.GradeID = newGrademajor.GradeID;
  339. tempGrademajorViewInList.Add(newGrademajorView);
  340. //表示对应的班级信息不存在(需根据专业分班信息生成对应的班级信息)
  341. if (classNum > 1)
  342. {
  343. for (int i = 1; i <= classNum; i++)
  344. {
  345. CF_Classmajor newClassmajor = new CF_Classmajor();
  346. newClassmajor.ClassmajorID = Guid.NewGuid();
  347. newClassmajor.GrademajorID = newGrademajor.GrademajorID;
  348. newClassmajor.No = newGrademajor.Code.Trim() + i.ToString();
  349. newClassmajor.Name = newGrademajor.Name.Trim() + i.ToString() + "班";
  350. newClassmajor.Abbreviation = newClassmajor.Name;
  351. newClassmajor.EnglishName = null;
  352. newClassmajor.ClassNum = i;
  353. newClassmajor.UserID = null;
  354. newClassmajor.AssistantUserID = null;
  355. newClassmajor.Fixedclassroom = null;
  356. newClassmajor.Remark = null;
  357. SetNewStatus(newClassmajor);
  358. classmajorInList.Add(newClassmajor);
  359. }
  360. }
  361. else
  362. {
  363. //表示只生成一个对应的班级信息(默认)
  364. CF_Classmajor newClassmajor = new CF_Classmajor();
  365. newClassmajor.ClassmajorID = Guid.NewGuid();
  366. newClassmajor.GrademajorID = newGrademajor.GrademajorID;
  367. newClassmajor.No = newGrademajor.Code.Trim() + "1";
  368. newClassmajor.Name = newGrademajor.Name.Trim() + "班";
  369. newClassmajor.Abbreviation = newClassmajor.Name;
  370. newClassmajor.EnglishName = null;
  371. newClassmajor.ClassNum = 1;
  372. newClassmajor.UserID = null;
  373. newClassmajor.AssistantUserID = null;
  374. newClassmajor.Fixedclassroom = null;
  375. newClassmajor.Remark = null;
  376. SetNewStatus(newClassmajor);
  377. classmajorInList.Add(newClassmajor);
  378. }
  379. //此处为当存在多个对应的院系专业时,年级专业编码流水+1,作为下一个年级专业编码(院系所、年级分班)
  380. grademajorCode = (Convert.ToInt32(grademajorCode) + 1).ToString().PadLeft(8, '0');
  381. }
  382. }
  383. }
  384. else
  385. {
  386. //表示对应的院系专业信息不存在
  387. //注:默认生成一条院系专业信息、一条年级专业信息、专业分班信息生成对应的班级个数
  388. CF_Facultymajor newFacultymajor = new CF_Facultymajor();
  389. newFacultymajor.FacultymajorID = Guid.NewGuid();
  390. newFacultymajor.CollegeID = recruitSpecialty.CollegeID;
  391. newFacultymajor.Code = facultymajorCode;
  392. newFacultymajor.Name = facultymajorName;
  393. newFacultymajor.Abbreviation = newFacultymajor.Name;
  394. newFacultymajor.EnglishName = null;
  395. newFacultymajor.StandardID = specialty.StandardID;
  396. newFacultymajor.EducationID = specialty.EducationID;
  397. newFacultymajor.LearningformID = specialty.LearningformID;
  398. newFacultymajor.LearnSystem = specialty.LearnSystem;
  399. newFacultymajor.ScienceclassID = specialty.ScienceclassID;
  400. newFacultymajor.SetTime = DateTime.Now;
  401. newFacultymajor.Remark = null;
  402. SetNewStatus(newFacultymajor);
  403. facultymajorInList.Add(newFacultymajor);
  404. //表示对应的年级专业信息不存在
  405. CF_Grademajor newGrademajor = new CF_Grademajor();
  406. newGrademajor.GrademajorID = Guid.NewGuid();
  407. newGrademajor.FacultymajorID = newFacultymajor.FacultymajorID;
  408. newGrademajor.Code = grademajorCode;
  409. newGrademajor.Name = grademajorName;
  410. newGrademajor.Abbreviation = newGrademajor.Name;
  411. newGrademajor.GradeID = recruitSpecialty.GradeID;
  412. newGrademajor.SemesterID = recruitSpecialty.SemesterID;
  413. newGrademajor.GraduateSchoolyearID = graduateSchoolyear.SchoolyearID;
  414. newGrademajor.Professional = null;
  415. newGrademajor.Remark = null;
  416. SetNewStatus(newGrademajor);
  417. grademajorInList.Add(newGrademajor);
  418. //用于年级专业编码流水生成(标识)
  419. GrademajorView newGrademajorView = new GrademajorView();
  420. newGrademajorView.Code = newGrademajor.Code;
  421. newGrademajorView.CollegeID = newFacultymajor.CollegeID;
  422. newGrademajorView.GradeID = newGrademajor.GradeID;
  423. tempGrademajorViewInList.Add(newGrademajorView);
  424. //表示对应的班级信息不存在(需根据专业分班信息生成对应的班级信息)
  425. if (classNum > 1)
  426. {
  427. for (int i = 1; i <= classNum; i++)
  428. {
  429. CF_Classmajor newClassmajor = new CF_Classmajor();
  430. newClassmajor.ClassmajorID = Guid.NewGuid();
  431. newClassmajor.GrademajorID = newGrademajor.GrademajorID;
  432. newClassmajor.No = classmajorCode + i.ToString();
  433. newClassmajor.Name = classmajorName + i.ToString() + "班";
  434. newClassmajor.Abbreviation = newClassmajor.Name;
  435. newClassmajor.EnglishName = null;
  436. newClassmajor.ClassNum = i;
  437. newClassmajor.UserID = null;
  438. newClassmajor.AssistantUserID = null;
  439. newClassmajor.Fixedclassroom = null;
  440. newClassmajor.Remark = null;
  441. SetNewStatus(newClassmajor);
  442. classmajorInList.Add(newClassmajor);
  443. }
  444. }
  445. else
  446. {
  447. //表示只生成一个对应的班级信息(默认)
  448. CF_Classmajor newClassmajor = new CF_Classmajor();
  449. newClassmajor.ClassmajorID = Guid.NewGuid();
  450. newClassmajor.GrademajorID = newGrademajor.GrademajorID;
  451. newClassmajor.No = classmajorCode + "1";
  452. newClassmajor.Name = classmajorName + "班";
  453. newClassmajor.Abbreviation = newClassmajor.Name;
  454. newClassmajor.EnglishName = null;
  455. newClassmajor.ClassNum = 1;
  456. newClassmajor.UserID = null;
  457. newClassmajor.AssistantUserID = null;
  458. newClassmajor.Fixedclassroom = null;
  459. newClassmajor.Remark = null;
  460. SetNewStatus(newClassmajor);
  461. classmajorInList.Add(newClassmajor);
  462. }
  463. }
  464. //更新招生专业信息生成状态
  465. recruitSpecialty.isGenerated = true;
  466. recruitSpecialtyUpList.Add(recruitSpecialty);
  467. success++;
  468. }
  469. using (TransactionScope ts = new TransactionScope())
  470. {
  471. if (facultymajorInList != null && facultymajorInList.Count() > 0)
  472. {
  473. UnitOfWork.BulkInsert(facultymajorInList);
  474. }
  475. if (grademajorInList != null && grademajorInList.Count() > 0)
  476. {
  477. UnitOfWork.BulkInsert(grademajorInList);
  478. }
  479. if (classmajorInList != null && classmajorInList.Count() > 0)
  480. {
  481. UnitOfWork.BulkInsert(classmajorInList);
  482. }
  483. if (recruitSpecialtyUpList != null && recruitSpecialtyUpList.Count() > 0)
  484. {
  485. UnitOfWork.BatchUpdate(recruitSpecialtyUpList);
  486. }
  487. ts.Complete();
  488. }
  489. if (success > 0 && fail <= 0)
  490. {
  491. tipMessage = success + "条";
  492. }
  493. else
  494. {
  495. tipMessage = success + "条," + fail + "条失败,原因:年级专业对应的毕业学期不存在,请核查";
  496. }
  497. return tipMessage;
  498. }
  499. catch (Exception ex)
  500. {
  501. throw new Exception(ex.Message);
  502. }
  503. }
  504. }
  505. }