123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Transactions;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.CacheManage;
- using EMIS.ViewModel.UniversityManage.SpecialtyClassManage;
- using EMIS.CommonLogic.SystemServices;
- namespace EMIS.ExtensionLogic.ServiceLogic.EnrollManage
- {
- public class RecruitSpecialtyServices : EMIS.CommonLogic.EnrollManage.SpecialtyManage.RecruitSpecialtyServices
- {
- /// <summary>
- /// 流水号生成Services
- /// </summary>
- public Lazy<ISerialNumberServices> SerialNumberServices { get; set; }
- /// <summary>
- /// 广东松山专业班级生成规则
- /// </summary>
- /// <param name="recruitSpecialtyIDs"></param>
- /// <returns></returns>
- public override string GenerateClass(List<Guid?> recruitSpecialtyIDs)
- {
- //生成规则如下:
- //院系编码(5位):院系所代码后2位+学制1位(直接取值)+2位流水号,拼出来,如:01201、01303
- //院系名称:专业名称(默认),如:电气自动化技术(分方向的情况下的命名需手动设置)
- //2位流水号:按院系所代码、学制、培养层次、学习形式、专业名称进行排序取2位流水号
- //年级专业编码(8位):年级+院系所代码后2位+2位流水号,拼出来,如:20170101、20170103
- //年级专业名称:年级+"级"+院系名称或专业名称(院系名称优先),如:2017级电气自动化技术(分方向的情况下的命名需手动设置)
- //2位流水号:按院系所代码、学制、培养层次、学习形式、专业名称进行排序取2位流水号
- //注:此处2位流水号可与对应的院系编码2位流水号不一致,不然会出现年级专业编码重复的问题
- //班级编码(9位):年级专业编码+1位流水号,拼出来,如:201701121、201701131
- //班级名称:年级+"级"+专业名称或年级专业名称(年级专业名称优先)+流水号(可为空)+"班",如:2017级应用电子技术班、2017级物联网应用技术1班
- //注:班级名称的命名有无流水号的问题
- try
- {
- //查询招生专业信息
- var recruitSpecialtyList = recruitSpecialtyDAL.recruitSpecialtyRepository.GetList(x => recruitSpecialtyIDs.Contains(x.RecruitSpecialtyID), x => x.CF_College, x => x.CF_Specialty)
- .OrderBy(x => x.CF_College.No).ThenByDescending(x => x.GradeID).ThenBy(x => x.CF_Specialty.LearnSystem).ThenBy(x => x.CF_Specialty.EducationID)
- .ThenBy(x => x.CF_Specialty.LearningformID).ThenBy(x => x.CF_Specialty.StandardID).ToList();
- //年级ID
- var gradeIDList = recruitSpecialtyList.Where(x => !string.IsNullOrEmpty(x.GradeID.ToString())).Select(x => x.GradeID).ToList();
- //专业信息ID
- var specialtyIDList = recruitSpecialtyList.Where(x => !string.IsNullOrEmpty(x.SpecialtyID.ToString())).Select(x => x.SpecialtyID).ToList();
- //院系所ID
- var collegeIDList = recruitSpecialtyList.Where(x => !string.IsNullOrEmpty(x.CollegeID.ToString())).Select(x => x.CollegeID).ToList();
- //查询专业信息
- var specialtyList = recruitSpecialtyDAL.specialtyRepository.GetList(x => specialtyIDList.Contains(x.SpecialtyID)).ToList();
- //查询专业分班信息
- var specialtyClassSettingList = recruitSpecialtyDAL.SpecialtyClassSettingRepository.GetList(x => specialtyIDList.Contains(x.SpecialtyID)).ToList();
- //查询院系所信息
- var collegeList = recruitSpecialtyDAL.collegeRepository.Entities.Where(x => collegeIDList.Contains(x.CollegeID)).ToList();
- //年级
- var gradeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Grade).ToList();
- //专业代码、专业名称、专业ID(Value)
- var standardList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Standard).ToList();
- //培养层次(所修学历)
- var educationList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Education).ToList();
- //学习形式
- var learningFormList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Learningform).ToList();
- //查询对应的院系专业信息
- var facultymajorList = recruitSpecialtyDAL.GetFacultymajorByRecruitSpecialty(x => recruitSpecialtyIDs.Contains(x.RecruitSpecialtyID)).ToList();
- //院系专业ID
- var facultymajorIDList = facultymajorList.Where(x => !string.IsNullOrEmpty(x.FacultymajorID.ToString())).Select(x => x.FacultymajorID).ToList();
- //查询对应的院系所中院系专业信息当前Max流水序号(院系所、学制分组查询)
- var faMaxCodeList = recruitSpecialtyDAL.GetFacultymajorMaxCodeByCollegeLearnSystem(x => collegeIDList.Contains(x.CollegeID)).ToList();
- //查询对应的年级专业信息
- var grademajorList = recruitSpecialtyDAL.GetGrademajorByRecruitSpecialty(x => recruitSpecialtyIDs.Contains(x.RecruitSpecialtyID), x => facultymajorIDList.Contains(x.FacultymajorID)).ToList();
- //年级专业ID
- var grademajorIDList = grademajorList.Where(x => !string.IsNullOrEmpty(x.GrademajorID.ToString())).Select(x => x.GrademajorID).ToList();
- //查询对应的年级中年级专业信息当前Max流水序号(院系所、年级分组查询)
- var grMaxCodeList = recruitSpecialtyDAL.GetGrademajorMaxCodeByCollegeSchoolyear(x => gradeIDList.Contains(x.GradeID)).ToList();
- //查询对应的班级信息
- var classmajorList = recruitSpecialtyDAL.GetClassmajorByRecruitSpecialty(x => recruitSpecialtyIDs.Contains(x.RecruitSpecialtyID), x => facultymajorIDList.Contains(x.FacultymajorID), x => grademajorIDList.Contains(x.GrademajorID)).ToList();
- //班级信息ID
- var classmajorIDList = classmajorList.Where(x => !string.IsNullOrEmpty(x.ClassmajorID.ToString())).Select(x => x.ClassmajorID).ToList();
- //根据年级专业信息查询对应的班级信息MaxCode(年级专业分组查询)
- var clMaxCodeList = recruitSpecialtyDAL.GetClassmajorMaxCodeByGrademajor(x => grademajorIDList.Contains(x.GrademajorID)).ToList();
- //查询学年学期信息
- var schoolyearList = recruitSpecialtyDAL.schoolyearRepository.GetList(x => true).ToList();
- var facultymajorCode = "";
- var facultymajorName = "";
- var grademajorCode = "";
- var grademajorName = "";
- var classmajorCode = "";
- var classmajorName = "";
- int fail = 0;
- int success = 0;
- string tipMessage = null;
- List<CF_RecruitSpecialty> recruitSpecialtyUpList = new List<CF_RecruitSpecialty>();
- List<CF_Facultymajor> facultymajorInList = new List<CF_Facultymajor>();
- List<GrademajorView> tempGrademajorViewInList = new List<GrademajorView>(); //用于年级专业编码流水生成(标识)
- List<CF_Grademajor> grademajorInList = new List<CF_Grademajor>();
- List<CF_Classmajor> classmajorInList = new List<CF_Classmajor>();
- foreach (var recruitSpecialty in recruitSpecialtyList)
- {
- //目前只处理招生专业与专业班级对应关系的情况(已存在的情况下,暂时不做处理)
- //专业分方向的情况处理有以下3种,按以下方式进行处理:
- //院系专业分方向(手动新增来处理)
- //年级专业分方向(手动新增来处理)
- //班级信息分方向(以专业分班设置来处理)
- //查询对应的院系所信息
- var college = collegeList.Where(x => x.CollegeID == recruitSpecialty.CollegeID).SingleOrDefault();
- //查询对应的专业信息
- var specialty = specialtyList.Where(x => x.SpecialtyID == recruitSpecialty.SpecialtyID).SingleOrDefault();
- //查询对应的专业分班信息
- var specialtyClassSetting = specialtyClassSettingList.Where(x => x.SpecialtyID == recruitSpecialty.SpecialtyID).SingleOrDefault();
- //对应的班级个数
- int classNum = 1;
- if (specialtyClassSetting != null)
- {
- if (specialtyClassSetting.ClassNumber != null)
- {
- if (specialtyClassSetting.ClassNumber.Value > 1)
- {
- classNum = specialtyClassSetting.ClassNumber.Value;
- }
- }
- }
- //专业名称数据字典
- var standard = standardList.Where(x => x.Value == specialty.StandardID).SingleOrDefault();
- //培养层次(所修学历)
- var education = educationList.Where(x => x.Value == specialty.EducationID).SingleOrDefault();
- //学习形式
- var learningForm = learningFormList.Where(x => x.Value == specialty.LearningformID).SingleOrDefault();
- //计算毕业学年学期Value
- var graduateSchoolyearValue = (recruitSpecialty.GradeID * 2) - 1 + (recruitSpecialty.SemesterID - 1)
- + Convert.ToInt32(Math.Ceiling(specialty.LearnSystem.Value * 2 - 1));
- //查询对应的学年学期信息
- var graduateSchoolyear = schoolyearList.Where(x => x.Value == graduateSchoolyearValue).SingleOrDefault();
- if (graduateSchoolyear == null)
- {
- //表示年级专业对应的毕业学期,在学年学期信息中不存在(此时不生成)
- fail++;
- continue;
- }
- //院系专业Max当前初始编号(院系所、学制分组查询)
- var faMaxCode = faMaxCodeList.Where(x => x.CollegeID == recruitSpecialty.CollegeID && x.LearnSystem == recruitSpecialty.CF_Specialty.LearnSystem).SingleOrDefault();
- if (faMaxCode == null)
- {
- //表示不存在(取初始值01)
- //院系编码(5位):院系所代码后2位+学制1位(直接取值)+2位流水号,拼出来
- facultymajorCode = college.No.Trim().Substring(college.No.Trim().Length - 2).PadLeft(2, '0')
- + Convert.ToInt32(specialty.LearnSystem).ToString() + "01";
- }
- else
- {
- //表示已存在(当前初始值+1)
- //院系编码(5位):院系所代码后2位+学制1位(直接取值)+2位流水号,拼出来
- var nextFaNum = (Convert.ToInt32(faMaxCode.Code.Trim().Substring(faMaxCode.Code.Trim().Length - 2)) + 1).ToString().PadLeft(2, '0');
- facultymajorCode = college.No.Trim().Substring(college.No.Trim().Length - 2).PadLeft(2, '0')
- + Convert.ToInt32(specialty.LearnSystem).ToString() + nextFaNum;
- }
- //由于可批量生成,需判断缓存中的院系专业编号中流水序号的问题
- if (facultymajorInList != null && facultymajorInList.Count() > 0)
- {
- //查询缓存中已生成的院系专业编号List
- var newFaMaxCodeList = facultymajorInList.Where(x => x.CollegeID == recruitSpecialty.CollegeID
- && x.LearnSystem == recruitSpecialty.CF_Specialty.LearnSystem).ToList();
- if (newFaMaxCodeList != null && newFaMaxCodeList.Count() > 0)
- {
- //表示缓存中已存在对应的院系编号(取当前MaxCode为初始值+1)
- var newFaMaxCode = newFaMaxCodeList.GroupBy(x => x.Code).Max(x => x.Key);
- //院系编码(5位):院系所代码后2位+学制1位(直接取值)+2位流水号,拼出来
- var newNextFaNum = (Convert.ToInt32(newFaMaxCode.Trim().Substring(newFaMaxCode.Trim().Length - 2)) + 1).ToString().PadLeft(2, '0');
- facultymajorCode = college.No.Trim().Substring(college.No.Trim().Length - 2).PadLeft(2, '0')
- + Convert.ToInt32(specialty.LearnSystem).ToString() + newNextFaNum;
- }
- }
- //院系名称:专业名称(默认),如:电气自动化技术(分方向的情况下的命名需手动修改)
- facultymajorName = standard.Name.Trim();
- //年级专业Max当前初始编号(院系所、年级分组查询)
- var grMaxCode = grMaxCodeList.Where(x => x.CollegeID == recruitSpecialty.CollegeID && x.GradeID == recruitSpecialty.GradeID).SingleOrDefault();
- if (grMaxCode == null)
- {
- //表示不存在(取初始值01)
- //年级专业编码(8位):年级+院系所代码后2位+2位流水号,拼出来
- grademajorCode = recruitSpecialty.GradeID.ToString() + college.No.Trim().Substring(college.No.Trim().Length - 2).PadLeft(2, '0') + "01";
- }
- else
- {
- //表示已存在(当前初始值+1)
- //年级专业编码(8位):年级+院系所代码后2位+2位流水号,拼出来
- var nextGrNum = (Convert.ToInt32(grMaxCode.Code.Trim().Substring(grMaxCode.Code.Trim().Length - 2)) + 1).ToString().PadLeft(2, '0');
- grademajorCode = recruitSpecialty.GradeID.ToString() + college.No.Trim().Substring(college.No.Trim().Length - 2).PadLeft(2, '0') + nextGrNum;
- }
- //由于可批量生成,需判断缓存中的年级专业编号中流水序号的问题
- if (grademajorInList != null && grademajorInList.Count() > 0)
- {
- //查询缓存中已生成的年级专业编号List(通过标识List来查询)
- var newGrMaxCodeList = tempGrademajorViewInList.Where(x => x.CollegeID == recruitSpecialty.CollegeID
- && x.GradeID == recruitSpecialty.GradeID).ToList();
- if (newGrMaxCodeList != null && newGrMaxCodeList.Count() > 0)
- {
- //表示缓存中已存在对应的年级专业编号(取当前MaxCode为初始值+1)
- var newGrMaxCode = newGrMaxCodeList.GroupBy(x => x.Code).Max(x => x.Key);
- //年级专业编码(8位):年级+院系所代码后2位+2位流水号,拼出来
- var newNextGrNum = (Convert.ToInt32(newGrMaxCode.Trim().Substring(newGrMaxCode.Trim().Length - 2)) + 1).ToString().PadLeft(2, '0');
- grademajorCode = recruitSpecialty.GradeID.ToString() + college.No.Trim().Substring(college.No.Trim().Length - 2).PadLeft(2, '0') + newNextGrNum;
- }
- }
- //年级专业名称:年级+"级"+院系名称或专业名称(院系名称优先)
- grademajorName = recruitSpecialty.GradeID.ToString() + "级" + facultymajorName;
- //注:暂时只取部分命名规则
- //班级编码(9位):年级+院系所代码后2位+2位流水号+1位流水号(年级专业编码+1位流水号),拼出来
- classmajorCode = grademajorCode;
- //班级名称:年级+"级"+专业名称或年级专业名称(年级专业名称优先)+流水号(可为空)+"班"
- classmajorName = grademajorName;
- //查询对应的院系专业信息
- var facultymajorVerifyList = facultymajorList.Where(x => x.RecruitSpecialtyID == recruitSpecialty.RecruitSpecialtyID).ToList();
- //判断院系专业
- if (facultymajorVerifyList != null && facultymajorVerifyList.Count() > 0)
- {
- //表示存在对应的院系专业信息
- foreach (var facultymajorVerify in facultymajorVerifyList)
- {
- //查询对应的年级专业信息
- var grademajorVerifyList = grademajorList.Where(x => x.FacultymajorID == facultymajorVerify.FacultymajorID).ToList();
- //判断年级专业
- if (grademajorVerifyList != null && grademajorVerifyList.Count() > 0)
- {
- //表示存在对应的年级专业信息
- foreach (var grademajorVerify in grademajorVerifyList)
- {
- //查询对应的班级信息
- var classmajorVerifyList = classmajorList.Where(x => x.GrademajorID == grademajorVerify.GrademajorID).ToList();
- //判断班级信息
- if (classmajorVerifyList != null && classmajorVerifyList.Count() > 0)
- {
- //表示存在对应的班级信息(需处理专业分班信息中班级个数的问题)
- //表示存在的班级个数大于专业分班的班级个数
- if (classmajorVerifyList.Count() >= classNum)
- {
- if (classmajorVerifyList.Count() == 1)
- {
- //查询对应的班级信息(只有一条班级信息可在此处做更新处理)
- var classmajorEntity = classmajorVerifyList.Where(x => x.GrademajorID == grademajorVerify.GrademajorID).SingleOrDefault();
- //(暂时不做更新处理)
- }
- else
- {
- //表示存在多个班级个数(可在此做其它处理)
- }
- }
- else
- {
- //表示存在的班级个数不足
- //查询对应的班级信息Max编号(年级专业分组查询)
- var clMaxCode = clMaxCodeList.Where(x => x.GrademajorID == grademajorVerify.GrademajorID).SingleOrDefault();
- var clNum = Convert.ToInt32(clMaxCode.No.Trim().Substring(clMaxCode.No.Trim().Length - 1));
- //生成剩余的班级个数(暂时以MaxCode+1形式生成)
- for (int i = 1; i <= classNum - classmajorVerifyList.Count(); i++)
- {
- CF_Classmajor newClassmajor = new CF_Classmajor();
- newClassmajor.ClassmajorID = Guid.NewGuid();
- newClassmajor.GrademajorID = grademajorVerify.GrademajorID;
- newClassmajor.No = grademajorVerify.GrademajorCode.Trim() + (clNum + i).ToString();
- newClassmajor.Name = grademajorVerify.GrademajorName.Trim() + (clNum + i).ToString() + "班";
- newClassmajor.Abbreviation = newClassmajor.Name;
- newClassmajor.EnglishName = null;
- newClassmajor.ClassNum = (clNum + i);
- newClassmajor.UserID = null;
- newClassmajor.AssistantUserID = null;
- newClassmajor.Fixedclassroom = null;
- newClassmajor.Remark = null;
- SetNewStatus(newClassmajor);
- classmajorInList.Add(newClassmajor);
- }
- }
- }
- else
- {
- //表示对应的班级信息不存在(需根据专业分班信息生成对应的班级个数)
- if (classNum > 1)
- {
- for (int i = 1; i <= classNum; i++)
- {
- CF_Classmajor newClassmajor = new CF_Classmajor();
- newClassmajor.ClassmajorID = Guid.NewGuid();
- newClassmajor.GrademajorID = grademajorVerify.GrademajorID;
- newClassmajor.No = grademajorVerify.GrademajorCode.Trim() + i.ToString();
- newClassmajor.Name = grademajorVerify.GrademajorName.Trim() + i.ToString() + "班";
- newClassmajor.Abbreviation = newClassmajor.Name;
- newClassmajor.EnglishName = null;
- newClassmajor.ClassNum = i;
- newClassmajor.UserID = null;
- newClassmajor.AssistantUserID = null;
- newClassmajor.Fixedclassroom = null;
- newClassmajor.Remark = null;
- SetNewStatus(newClassmajor);
- classmajorInList.Add(newClassmajor);
- }
- }
- else
- {
- //表示只生成一个对应的班级信息(默认)
- CF_Classmajor newClassmajor = new CF_Classmajor();
- newClassmajor.ClassmajorID = Guid.NewGuid();
- newClassmajor.GrademajorID = grademajorVerify.GrademajorID;
- newClassmajor.No = grademajorVerify.GrademajorCode.Trim() + "1";
- newClassmajor.Name = grademajorVerify.GrademajorName.Trim() + "班";
- newClassmajor.Abbreviation = newClassmajor.Name;
- newClassmajor.EnglishName = null;
- newClassmajor.ClassNum = 1;
- newClassmajor.UserID = null;
- newClassmajor.AssistantUserID = null;
- newClassmajor.Fixedclassroom = null;
- newClassmajor.Remark = null;
- SetNewStatus(newClassmajor);
- classmajorInList.Add(newClassmajor);
- }
- }
- }
- }
- else
- {
- //表示对应的年级专业信息不存在
- //注:根据院系专业信息生成年级专业信息、专业分班信息生成对应的班级个数
- CF_Grademajor newGrademajor = new CF_Grademajor();
- newGrademajor.GrademajorID = Guid.NewGuid();
- newGrademajor.FacultymajorID = facultymajorVerify.FacultymajorID;
- newGrademajor.Code = grademajorCode;
- newGrademajor.Name = recruitSpecialty.GradeID.ToString() + "级" + facultymajorVerify.FacultymajorName.Trim();
- newGrademajor.Abbreviation = newGrademajor.Name;
- newGrademajor.GradeID = recruitSpecialty.GradeID;
- newGrademajor.SemesterID = recruitSpecialty.SemesterID;
- newGrademajor.GraduateSchoolyearID = graduateSchoolyear.SchoolyearID;
- newGrademajor.Professional = null;
- newGrademajor.Remark = null;
- SetNewStatus(newGrademajor);
- grademajorInList.Add(newGrademajor);
- //用于年级专业编码流水生成(标识)
- GrademajorView newGrademajorView = new GrademajorView();
- newGrademajorView.Code = newGrademajor.Code;
- newGrademajorView.CollegeID = facultymajorVerify.CollegeID;
- newGrademajorView.GradeID = newGrademajor.GradeID;
- tempGrademajorViewInList.Add(newGrademajorView);
- //表示对应的班级信息不存在(需根据专业分班信息生成对应的班级信息)
- if (classNum > 1)
- {
- for (int i = 1; i <= classNum; i++)
- {
- CF_Classmajor newClassmajor = new CF_Classmajor();
- newClassmajor.ClassmajorID = Guid.NewGuid();
- newClassmajor.GrademajorID = newGrademajor.GrademajorID;
- newClassmajor.No = newGrademajor.Code.Trim() + i.ToString();
- newClassmajor.Name = newGrademajor.Name.Trim() + i.ToString() + "班";
- newClassmajor.Abbreviation = newClassmajor.Name;
- newClassmajor.EnglishName = null;
- newClassmajor.ClassNum = i;
- newClassmajor.UserID = null;
- newClassmajor.AssistantUserID = null;
- newClassmajor.Fixedclassroom = null;
- newClassmajor.Remark = null;
- SetNewStatus(newClassmajor);
- classmajorInList.Add(newClassmajor);
- }
- }
- else
- {
- //表示只生成一个对应的班级信息(默认)
- CF_Classmajor newClassmajor = new CF_Classmajor();
- newClassmajor.ClassmajorID = Guid.NewGuid();
- newClassmajor.GrademajorID = newGrademajor.GrademajorID;
- newClassmajor.No = newGrademajor.Code.Trim() + "1";
- newClassmajor.Name = newGrademajor.Name.Trim() + "班";
- newClassmajor.Abbreviation = newClassmajor.Name;
- newClassmajor.EnglishName = null;
- newClassmajor.ClassNum = 1;
- newClassmajor.UserID = null;
- newClassmajor.AssistantUserID = null;
- newClassmajor.Fixedclassroom = null;
- newClassmajor.Remark = null;
- SetNewStatus(newClassmajor);
- classmajorInList.Add(newClassmajor);
- }
- //此处为当存在多个对应的院系专业时,年级专业编码流水+1,作为下一个年级专业编码(院系所、年级分班)
- grademajorCode = (Convert.ToInt32(grademajorCode) + 1).ToString().PadLeft(8, '0');
- }
- }
- }
- else
- {
- //表示对应的院系专业信息不存在
- //注:默认生成一条院系专业信息、一条年级专业信息、专业分班信息生成对应的班级个数
- CF_Facultymajor newFacultymajor = new CF_Facultymajor();
- newFacultymajor.FacultymajorID = Guid.NewGuid();
- newFacultymajor.CollegeID = recruitSpecialty.CollegeID;
- newFacultymajor.Code = facultymajorCode;
- newFacultymajor.Name = facultymajorName;
- newFacultymajor.Abbreviation = newFacultymajor.Name;
- newFacultymajor.EnglishName = null;
- newFacultymajor.StandardID = specialty.StandardID;
- newFacultymajor.EducationID = specialty.EducationID;
- newFacultymajor.LearningformID = specialty.LearningformID;
- newFacultymajor.LearnSystem = specialty.LearnSystem;
- newFacultymajor.ScienceclassID = specialty.ScienceclassID;
- newFacultymajor.SetTime = DateTime.Now;
- newFacultymajor.Remark = null;
- SetNewStatus(newFacultymajor);
- facultymajorInList.Add(newFacultymajor);
- //表示对应的年级专业信息不存在
- CF_Grademajor newGrademajor = new CF_Grademajor();
- newGrademajor.GrademajorID = Guid.NewGuid();
- newGrademajor.FacultymajorID = newFacultymajor.FacultymajorID;
- newGrademajor.Code = grademajorCode;
- newGrademajor.Name = grademajorName;
- newGrademajor.Abbreviation = newGrademajor.Name;
- newGrademajor.GradeID = recruitSpecialty.GradeID;
- newGrademajor.SemesterID = recruitSpecialty.SemesterID;
- newGrademajor.GraduateSchoolyearID = graduateSchoolyear.SchoolyearID;
- newGrademajor.Professional = null;
- newGrademajor.Remark = null;
- SetNewStatus(newGrademajor);
- grademajorInList.Add(newGrademajor);
- //用于年级专业编码流水生成(标识)
- GrademajorView newGrademajorView = new GrademajorView();
- newGrademajorView.Code = newGrademajor.Code;
- newGrademajorView.CollegeID = newFacultymajor.CollegeID;
- newGrademajorView.GradeID = newGrademajor.GradeID;
- tempGrademajorViewInList.Add(newGrademajorView);
- //表示对应的班级信息不存在(需根据专业分班信息生成对应的班级信息)
- if (classNum > 1)
- {
- for (int i = 1; i <= classNum; i++)
- {
- CF_Classmajor newClassmajor = new CF_Classmajor();
- newClassmajor.ClassmajorID = Guid.NewGuid();
- newClassmajor.GrademajorID = newGrademajor.GrademajorID;
- newClassmajor.No = classmajorCode + i.ToString();
- newClassmajor.Name = classmajorName + i.ToString() + "班";
- newClassmajor.Abbreviation = newClassmajor.Name;
- newClassmajor.EnglishName = null;
- newClassmajor.ClassNum = i;
- newClassmajor.UserID = null;
- newClassmajor.AssistantUserID = null;
- newClassmajor.Fixedclassroom = null;
- newClassmajor.Remark = null;
- SetNewStatus(newClassmajor);
- classmajorInList.Add(newClassmajor);
- }
- }
- else
- {
- //表示只生成一个对应的班级信息(默认)
- CF_Classmajor newClassmajor = new CF_Classmajor();
- newClassmajor.ClassmajorID = Guid.NewGuid();
- newClassmajor.GrademajorID = newGrademajor.GrademajorID;
- newClassmajor.No = classmajorCode + "1";
- newClassmajor.Name = classmajorName + "班";
- newClassmajor.Abbreviation = newClassmajor.Name;
- newClassmajor.EnglishName = null;
- newClassmajor.ClassNum = 1;
- newClassmajor.UserID = null;
- newClassmajor.AssistantUserID = null;
- newClassmajor.Fixedclassroom = null;
- newClassmajor.Remark = null;
- SetNewStatus(newClassmajor);
- classmajorInList.Add(newClassmajor);
- }
- }
- //更新招生专业信息生成状态
- recruitSpecialty.isGenerated = true;
- recruitSpecialtyUpList.Add(recruitSpecialty);
- success++;
- }
- using (TransactionScope ts = new TransactionScope())
- {
- if (facultymajorInList != null && facultymajorInList.Count() > 0)
- {
- UnitOfWork.BulkInsert(facultymajorInList);
- }
- if (grademajorInList != null && grademajorInList.Count() > 0)
- {
- UnitOfWork.BulkInsert(grademajorInList);
- }
- if (classmajorInList != null && classmajorInList.Count() > 0)
- {
- UnitOfWork.BulkInsert(classmajorInList);
- }
- if (recruitSpecialtyUpList != null && recruitSpecialtyUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(recruitSpecialtyUpList);
- }
- ts.Complete();
- }
- if (success > 0 && fail <= 0)
- {
- tipMessage = success + "条";
- }
- else
- {
- tipMessage = success + "条," + fail + "条失败,原因:年级专业对应的毕业学期不存在,请核查";
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- }
- }
|