using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using System.Text.RegularExpressions; using System.Transactions; using Bowin.Common.Utility; using Bowin.Common.Linq; using Bowin.Common.Linq.Entity; using EMIS.Utility; using EMIS.Entities; using EMIS.ViewModel; using EMIS.ViewModel.CacheManage; using EMIS.ViewModel.EnrollManage.SpecialtyManage; using EMIS.DataLogic.EnrollManage.SpecialtyManage; namespace EMIS.CommonLogic.EnrollManage.SpecialtyManage { public class RecruitSpecialtyServices : BaseServices, IRecruitSpecialtyServices { public RecruitSpecialtyDAL recruitSpecialtyDAL { get; set; } public Lazy SpecialtyApplyServices { get; set; } /// /// 查询对应的招生专业信息View /// /// /// /// /// /// /// /// /// /// /// /// /// public IGridResultSet GetRecruitSpecialtyViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID, int? educationID, int? learningformID, string learnSystem, int? isGenerated, int pageIndex, int pageSize) { //招生专业 Expression> expRecruitSpecialty = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (collegeID.HasValue) { expRecruitSpecialty = expRecruitSpecialty.And(x => x.CollegeID == collegeID); } if (gradeID.HasValue) { expRecruitSpecialty = expRecruitSpecialty.And(x => x.GradeID == gradeID); } if (isGenerated.HasValue) { //生成状态 if (isGenerated.Value == (int)CF_GeneralPurpose.IsYes) { expRecruitSpecialty = expRecruitSpecialty.And(x => x.isGenerated == true); } if (isGenerated.Value == (int)CF_GeneralPurpose.IsNo) { expRecruitSpecialty = expRecruitSpecialty.And(x => x.isGenerated != true); } } var query = recruitSpecialtyDAL.GetRecruitSpecialtyViewQueryable(expRecruitSpecialty); if (campusID.HasValue) { query = query.Where(x => x.CampusID == campusID); } if (standardID.HasValue) { query = query.Where(x => x.StandardID == standardID); } if (educationID.HasValue) { query = query.Where(x => x.EducationID == educationID); } if (learningformID.HasValue) { query = query.Where(x => x.LearningformID == learningformID); } if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1") { var LearnSystems = Convert.ToDecimal(learnSystem); query = query.Where(x => x.LearnSystem == LearnSystems); } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeID) .ThenBy(x => x.StandardName).ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem).ToGridResultSet(pageIndex, pageSize); } /// /// 查询对应的招生专业信息List /// /// /// /// /// /// /// /// /// /// /// public IList GetRecruitSpecialtyViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID, int? educationID, int? learningformID, string learnSystem, int? isGenerated) { //招生专业 Expression> expRecruitSpecialty = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (collegeID.HasValue) { expRecruitSpecialty = expRecruitSpecialty.And(x => x.CollegeID == collegeID); } if (gradeID.HasValue) { expRecruitSpecialty = expRecruitSpecialty.And(x => x.GradeID == gradeID); } if (isGenerated.HasValue) { //生成状态 if (isGenerated.Value == (int)CF_GeneralPurpose.IsYes) { expRecruitSpecialty = expRecruitSpecialty.And(x => x.isGenerated == true); } if (isGenerated.Value == (int)CF_GeneralPurpose.IsNo) { expRecruitSpecialty = expRecruitSpecialty.And(x => x.isGenerated != true); } } var query = recruitSpecialtyDAL.GetRecruitSpecialtyViewQueryable(expRecruitSpecialty); if (campusID.HasValue) { query = query.Where(x => x.CampusID == campusID); } if (standardID.HasValue) { query = query.Where(x => x.StandardID == standardID); } if (educationID.HasValue) { query = query.Where(x => x.EducationID == educationID); } if (learningformID.HasValue) { query = query.Where(x => x.LearningformID == learningformID); } if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1") { var LearnSystems = Convert.ToDecimal(learnSystem); query = query.Where(x => x.LearnSystem == LearnSystems); } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeID) .ThenBy(x => x.StandardName).ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem).ToList(); } /// /// 查询对应的招生专业信息CF_RecruitSpecialty /// /// /// public CF_RecruitSpecialty GetRecruitSpecialtyInfo(Guid? recruitSpecialtyID) { try { var query = recruitSpecialtyDAL.recruitSpecialtyRepository.GetList(x => x.RecruitSpecialtyID == recruitSpecialtyID).SingleOrDefault(); return query; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 查询对应的招生专业信息RecruitSpecialtyView /// /// /// public RecruitSpecialtyView GetRecruitSpecialtyView(Guid? recruitSpecialtyID) { try { var query = recruitSpecialtyDAL.GetRecruitSpecialtyViewQueryable(x => x.RecruitSpecialtyID == recruitSpecialtyID).SingleOrDefault(); return query; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 招生专业批量新增(业务主键:专业信息ID、年级、学期、院系所) /// /// /// /// public string RecruitSpecialtyBatchAdd(List specialtyIDList, RecruitSpecialtyView recruitSpecialtyView) { try { var endStatusID = SpecialtyApplyServices.Value.GetCorrectEndStatus(); if (endStatusID == null) { throw new Exception("工作流平台中,招生专业流程结束环节未配置,请核查"); } //招生专业 Expression> expRecruitSpecialty = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expRecruitSpecialty = expRecruitSpecialty.And(x => specialtyIDList.Contains(x.SpecialtyID)); //查询对应的招生专业信息List var recruitSpecialtyList = recruitSpecialtyDAL.recruitSpecialtyRepository.GetList(expRecruitSpecialty).ToList(); int success = 0; int fail = 0; string tipMessage = null; List recruitSpecialtyInList = new List(); foreach (var specialtyID in specialtyIDList) { var recruitSpecialtyVerify = recruitSpecialtyList.Where(x => x.SpecialtyID == specialtyID && x.CollegeID == recruitSpecialtyView.CollegeID && x.GradeID == recruitSpecialtyView.GradeID && x.SemesterID == recruitSpecialtyView.SemesterID).SingleOrDefault(); if (recruitSpecialtyVerify == null) { //新增 var recruitSpecialty = new CF_RecruitSpecialty(); recruitSpecialty.RecruitSpecialtyID = Guid.NewGuid(); recruitSpecialty.SpecialtyApplyID = null; recruitSpecialty.SpecialtyID = specialtyID; recruitSpecialty.CollegeID = recruitSpecialtyView.CollegeID; recruitSpecialty.GradeID = recruitSpecialtyView.GradeID; recruitSpecialty.SemesterID = recruitSpecialtyView.SemesterID; recruitSpecialty.ApprovalStatus = endStatusID; recruitSpecialty.isGenerated = false; recruitSpecialty.Remark = recruitSpecialtyView.Remark; SetNewStatus(recruitSpecialty); recruitSpecialtyInList.Add(recruitSpecialty); success++; } else { //表示已存在相同的招生专业信息 fail++; } } //批量插入 UnitOfWork.BulkInsert(recruitSpecialtyInList); if (success > 0 && fail <= 0) { tipMessage = success + "条"; } else { tipMessage = success + "条," + fail + "条失败,原因:已存在相同的招生专业信息,请检查"; } return tipMessage; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 查询招生专业中未新增的专业信息SpecialtyView /// /// /// /// /// /// /// /// /// /// /// /// /// public IGridResultSet GetSpecialtyViewNoAdd(ConfiguretView configuretView, Guid? collegeID, int? gradeID, int? semesterID, int? standardID, int? educationID, int? learningformID, string learnSystem, int? scienceclassID, int pageIndex, int pageSize) { //专业信息(只查询启用状态的专业信息) Expression> expSpecialty = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (standardID.HasValue) { expSpecialty = expSpecialty.And(x => x.StandardID == standardID); } if (educationID.HasValue) { expSpecialty = expSpecialty.And(x => x.EducationID == educationID); } if (learningformID.HasValue) { expSpecialty = expSpecialty.And(x => x.LearningformID == learningformID); } if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1") { var LearnSystems = Convert.ToDecimal(learnSystem); expSpecialty = expSpecialty.And(x => x.LearnSystem == LearnSystems); } if (scienceclassID.HasValue) { expSpecialty = expSpecialty.And(x => x.ScienceclassID == scienceclassID); } //招生专业 Expression> expRecruitSpecialty = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (collegeID.HasValue) { expRecruitSpecialty = expRecruitSpecialty.And(x => x.CollegeID == collegeID); } if (gradeID.HasValue) { expRecruitSpecialty = expRecruitSpecialty.And(x => x.GradeID == gradeID); } if (semesterID.HasValue) { expRecruitSpecialty = expRecruitSpecialty.And(x => x.SemesterID == semesterID); } var query = recruitSpecialtyDAL.GetSpecialtyViewNoAddQueryable(expSpecialty, expRecruitSpecialty); //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return query.OrderBy(x => x.StandardName).ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem).ToGridResultSet(pageIndex, pageSize); } /// /// 编辑(新增、修改,业务主键:专业信息ID、院系所、年级、学期) /// /// public void RecruitSpecialtyEdit(RecruitSpecialtyView recruitSpecialtyView) { try { var endStatusID = SpecialtyApplyServices.Value.GetCorrectEndStatus(); if (endStatusID == null) { throw new Exception("工作流平台中,招生专业流程结束环节未配置,请核查"); } //查询数据库进行验证 var recruitSpecialtyVerification = recruitSpecialtyDAL.recruitSpecialtyRepository.GetList(x => x.RecruitSpecialtyID != recruitSpecialtyView.RecruitSpecialtyID && x.SpecialtyID == recruitSpecialtyView.SpecialtyID && x.CollegeID == recruitSpecialtyView.CollegeID && x.GradeID == recruitSpecialtyView.GradeID && x.SemesterID == recruitSpecialtyView.SemesterID).SingleOrDefault(); if (recruitSpecialtyVerification == null) { //数据有误验证 if (recruitSpecialtyView.RecruitSpecialtyID != Guid.Empty) { var recruitSpecialty = recruitSpecialtyDAL.recruitSpecialtyRepository.GetList(x => x.RecruitSpecialtyID == recruitSpecialtyView.RecruitSpecialtyID).SingleOrDefault(); if (recruitSpecialty == null) { throw new Exception("数据有误,请核查"); } else { //表示修改 recruitSpecialty.Remark = recruitSpecialtyView.Remark; SetModifyStatus(recruitSpecialty); } } else { //表示新增 var recruitSpecialty = new CF_RecruitSpecialty(); recruitSpecialty.RecruitSpecialtyID = Guid.NewGuid(); recruitSpecialty.SpecialtyApplyID = null; recruitSpecialty.SpecialtyID = recruitSpecialtyView.SpecialtyID; recruitSpecialty.CollegeID = recruitSpecialtyView.CollegeID; recruitSpecialty.GradeID = recruitSpecialtyView.GradeID; recruitSpecialty.SemesterID = recruitSpecialtyView.SemesterID; recruitSpecialty.ApprovalStatus = endStatusID; recruitSpecialty.isGenerated = false; recruitSpecialty.Remark = recruitSpecialtyView.Remark; SetNewStatus(recruitSpecialty); UnitOfWork.Add(recruitSpecialty); } } else { throw new Exception("已存在相同的招生专业信息(专业信息、" + RSL.Get("College") + "、年级、学期唯一),请核查"); } //事务提交 UnitOfWork.Commit(); } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 专业班级生成(由于各高校生成规则不同,需分版本—个性化配置) /// /// /// public virtual string GenerateClass(List recruitSpecialtyIDs) { //根据各高校个性化要求进行配置 throw new Exception("生成规则配置有误(根据个性化要求进行配置),请检查"); } /// /// 删除(需根据业务主键删除对应的流程结束专业申请信息) /// /// /// public bool RecruitSpecialtyDelete(List recruitSpecialtyIDList) { try { //查询招生专业工作流程线束环节状态 var endStatusID = SpecialtyApplyServices.Value.GetCorrectEndStatus(); if (endStatusID == null) { throw new Exception("工作流平台中,招生专业流程结束环节未配置,请核查"); } //查询对应的招生专业信息List var recruitSpecialtyList = this.recruitSpecialtyDAL.recruitSpecialtyRepository.GetList(x => recruitSpecialtyIDList.Contains(x.RecruitSpecialtyID)).ToList(); //招生专业中对应的专业信息IDList var specialtyIDList = recruitSpecialtyList.Select(x => x.SpecialtyID).ToList(); //查询对应的专业申请信息List var specialtyApplyList = recruitSpecialtyDAL.specialtyApplyRepository.GetList(x => specialtyIDList.Contains(x.SpecialtyID)).ToList(); //查询专业申请信息List(流程结束) List specialtyApplyIDList = new List(); foreach (var recruitSpecialty in recruitSpecialtyList) { //查询专业申请信息 var specialtyApply = specialtyApplyList.Where(x => x.SpecialtyID == recruitSpecialty.SpecialtyID && x.CollegeID == recruitSpecialty.CollegeID && x.GradeID == recruitSpecialty.GradeID && x.SemesterID == recruitSpecialty.SemesterID && x.ApprovalStatus == endStatusID).SingleOrDefault(); if (specialtyApply != null) { specialtyApplyIDList.Add(specialtyApply.SpecialtyApplyID); } } using (TransactionScope ts = new TransactionScope()) { if (recruitSpecialtyIDList != null && recruitSpecialtyIDList.Count() > 0) { UnitOfWork.Delete(x => recruitSpecialtyIDList.Contains(x.RecruitSpecialtyID)); } if (specialtyApplyIDList != null && specialtyApplyIDList.Count() > 0) { UnitOfWork.Delete(x => specialtyApplyIDList.Contains(x.SpecialtyApplyID)); } ts.Complete(); } return true; } catch (Exception) { throw; } } /// /// Excel导入 /// /// /// /// /// /// /// public void RecruitSpecialtyImport(Dictionary cellheader, out int? inCount, out int? upCount, out List errdataList, out int? errCount, string sourcePhysicalPath) { try { //查询招生专业工作流程结束环节状态 var endStatusID = SpecialtyApplyServices.Value.GetCorrectEndStatus(); if (endStatusID == null) { throw new Exception("工作流平台中,招生专业流程结束环节未配置,请核查"); } StringBuilder errorMsg = new StringBuilder(); // 错误信息 List errList = new List(); // 1.1解析文件,存放到一个List集合里 cellheader.Remove("ErrorMessage");//移除“未导入原因”列(ErrorMessage) List enlist = NpoiExcelHelper.ExcelToEntityList(cellheader, sourcePhysicalPath, out errorMsg, out errList); cellheader.Add("ErrorMessage", "未导入原因"); //对List集合进行有效性校验 if (enlist.Count() <= 0) { throw new Exception("Excel文件数据为空,请检查。"); } Regex reg = new Regex(@"^[0-9]+([.]{1}[0-9]+){0,1}$"); //学制字段正则表达式() inCount = 0; //导入个数 upCount = 0; //更新个数 errCount = 0; //失败个数 string errorMsgStr = ""; //错误信息 List recruitSpecialtyInList = new List(); List recruitSpecialtyUpList = new List(); //将循环中相关数据库查询统一查询出来进行匹配(尽量避免在循环中进行数据库查询) //专业代码、专业名称、专业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 collegeNoList = enlist.Where(x => !string.IsNullOrEmpty(x.CollegeNo)).Select(x => x.CollegeNo).ToList(); //对应的院系所信息 var collegeList = recruitSpecialtyDAL.collegeRepository.GetList(x => collegeNoList.Contains(x.No), x => x.CF_CollegeProfile).ToList(); //GradeStr var gradeStrList = enlist.Where(x => !string.IsNullOrEmpty(x.GradeStr)).Select(x => x.GradeStr).ToList(); //年级 var gradeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Grade).ToList(); //学期 var semesterList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Semester).ToList(); //专业信息 var specialtyList = recruitSpecialtyDAL.specialtyRepository.GetList(x => true).ToList(); //招生专业 var recruitSpecialtyList = recruitSpecialtyDAL.recruitSpecialtyRepository.GetList(x => gradeStrList.Contains(x.GradeID.ToString())).ToList(); //循环检测数据列,对各数据列进行验证(必填、字典项验证、数据格式等) for (int i = 0; i < enlist.Count; i++) { RecruitSpecialtyView en = enlist[i]; //Excel表数据视图 var recruitSpecialty = new CF_RecruitSpecialty(); //招生专业实体 //专业代码 if (string.IsNullOrEmpty(en.StandardCode)) { errCount++; errorMsgStr = "专业代码不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { var standardCode = standardList.Where(x => x.Code == en.StandardCode.Trim()).FirstOrDefault(); if (standardCode == null) { errCount++; errorMsgStr = "专业代码不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //专业代码 } } //专业名称 if (string.IsNullOrEmpty(en.StandardName)) { errCount++; errorMsgStr = "专业名称不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { var standardName = standardList.Where(x => x.Name == en.StandardName.Trim()).FirstOrDefault(); if (standardName == null) { errCount++; errorMsgStr = "专业名称不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //专业名称 } } //专业代码与专业名称查询专业ID(Value) if (string.IsNullOrEmpty(en.StandardCode) || string.IsNullOrEmpty(en.StandardName)) { errCount++; errorMsgStr = "专业代码或专业名称不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { var standardID = standardList.Where(x => x.Code == en.StandardCode.Trim() && x.Name == en.StandardName.Trim()).SingleOrDefault(); if (standardID == null) { errCount++; errorMsgStr = "专业代码与专业名称对应的元素值不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //专业ID(Value) en.StandardID = standardID.Value; } } //培养层次(所修学历) if (string.IsNullOrEmpty(en.EducationStr)) { errCount++; errorMsgStr = RSL.Get("EducationID") + "不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { var education = educationList.Where(x => x.Name == en.EducationStr.Trim()).SingleOrDefault(); if (education == null) { errCount++; errorMsgStr = RSL.Get("EducationID") + "不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //培养层次 en.EducationID = education.Value; } } //学习形式 if (string.IsNullOrEmpty(en.LearningformStr)) { errCount++; errorMsgStr = "学习形式不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { var learningForm = learningFormList.Where(x => x.Name == en.LearningformStr.Trim()).SingleOrDefault(); if (learningForm == null) { errCount++; errorMsgStr = "学习形式不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //学习形式 en.LearningformID = learningForm.Value; } } //学制 if (string.IsNullOrEmpty(en.LearnSystemStr)) { errCount++; errorMsgStr = "学制不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { if (!reg.IsMatch(en.LearnSystemStr)) { errCount++; errorMsgStr = "学制格式不正确,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //学制 en.LearnSystem = Convert.ToDecimal(en.LearnSystemStr); } } //专业信息查询 var specialty = specialtyList.Where(x => x.StandardID == en.StandardID && x.EducationID == en.EducationID && x.LearningformID == en.LearningformID && x.LearnSystem == en.LearnSystem).SingleOrDefault(); //专业信息ID if (specialty == null) { errCount++; errorMsgStr = "专业信息不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //查询专业信息(启用、禁用状态) if (specialty.RecordStatus > (int)SYS_STATUS.UNUSABLE) { recruitSpecialty.SpecialtyID = specialty.SpecialtyID; } else { recruitSpecialty.SpecialtyID = specialty.SpecialtyID; errCount++; errorMsgStr = "专业信息为禁用状态,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } } //院系所代码 if (string.IsNullOrEmpty(en.CollegeNo)) { errCount++; errorMsgStr = RSL.Get("CollegeCode") + "不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { var college = collegeList.Where(x => x.No == en.CollegeNo.Trim()).SingleOrDefault(); if (college == null) { errCount++; errorMsgStr = RSL.Get("CollegeCode") + "不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { if (college.CF_CollegeProfile == null) { errCount++; errorMsgStr = RSL.Get("CollegeCode") + "所属的单位类别有误,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else if (college.CF_CollegeProfile.UnitCategoryID != (int)CF_UnitCategory.College) { errCount++; errorMsgStr = RSL.Get("CollegeCode") + "所属的单位类别有误,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } //院系所ID recruitSpecialty.CollegeID = college.CollegeID; } } //年级 if (string.IsNullOrEmpty(en.GradeStr)) { errCount++; errorMsgStr = "年级不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { var grade = gradeList.Where(x => x.Name == en.GradeStr.Trim()).SingleOrDefault(); if (grade == null) { errCount++; errorMsgStr = "年级不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //年级 recruitSpecialty.GradeID = grade.Value; } } //学期 if (string.IsNullOrEmpty(en.SemesterStr)) { errCount++; errorMsgStr = "学期不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { var semester = semesterList.Where(x => x.Name == en.SemesterStr.Trim()).SingleOrDefault(); if (semester == null) { errCount++; errorMsgStr = "学期不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //学期 recruitSpecialty.SemesterID = semester.Value; } } //备注 recruitSpecialty.Remark = en.Remark; ////Excel表重复性验证(注:当数据表中没有此记录,但是Excel中有重复数据时的去掉) //for (int j = i + 1; j < enlist.Count; j++) //{ // RecruitSpecialtyView enA = enlist[j]; // //根据Excel表中的业务主键进行去重(专业代码、专业名称、学制、培养层次(所修学历)、学习形式、年级、学期、院系所代码唯一) // if (en.StandardCode == enA.StandardCode && en.StandardName == enA.StandardName // && en.LearnSystemStr == enA.LearnSystemStr // && en.EducationStr == enA.EducationStr // && en.LearningformStr == enA.LearningformStr // && en.GradeStr == enA.GradeStr // && en.SemesterStr == enA.SemesterStr // && en.CollegeNo == enA.CollegeNo) // { // //用于标识Excel表中的重复记录(由于是批量进行插入数据表) // } //} //由于招生专业表与专业申请表不同,招生专业新增时,需进行处理(目前采用方法一进行处理) //处理方法一:目前已在工作流审核处理通过时,进行了相关处理(采用更新的方式) //处理方法二:可在此处进行判断处理,以Excel错误数据方式进行抛出,提示信息:数据重复,工作流程中已存在此数据 //数据表重复性验证(专业信息ID、年级、学期、院系所ID唯一) var recruitSpecialtyVerify = recruitSpecialtyList.Where(x => x.GradeID == recruitSpecialty.GradeID && x.SemesterID == recruitSpecialty.SemesterID && x.SpecialtyID == recruitSpecialty.SpecialtyID && x.CollegeID == recruitSpecialty.CollegeID).SingleOrDefault(); if (recruitSpecialtyVerify == null) { //新增 if (!recruitSpecialtyInList.Any(x => x.GradeID == recruitSpecialty.GradeID && x.SemesterID == recruitSpecialty.SemesterID && x.SpecialtyID == recruitSpecialty.SpecialtyID && x.CollegeID == recruitSpecialty.CollegeID)) { recruitSpecialty.RecruitSpecialtyID = Guid.NewGuid(); recruitSpecialty.SpecialtyApplyID = null; recruitSpecialty.ApprovalStatus = endStatusID; recruitSpecialty.isGenerated = false; SetNewStatus(recruitSpecialty); recruitSpecialtyInList.Add(recruitSpecialty); inCount++; } else { //Excel表重复性验证 //(注:当数据表中没有此记录,但是Excel中有重复数据,可在此处进行抛出到失败数据文件中,目前暂不考虑) inCount++; } } else { //更新(Excel有重复时,以最后一条记录的更新为准) recruitSpecialtyVerify.Remark = recruitSpecialty.Remark; SetModifyStatus(recruitSpecialtyVerify); recruitSpecialtyUpList.Add(recruitSpecialtyVerify); upCount++; } } using (TransactionScope ts = new TransactionScope()) { if (recruitSpecialtyInList != null && recruitSpecialtyInList.Count() > 0) { UnitOfWork.BulkInsert(recruitSpecialtyInList); } if (recruitSpecialtyUpList != null && recruitSpecialtyUpList.Count() > 0) { UnitOfWork.BatchUpdate(recruitSpecialtyUpList); } ts.Complete(); } errdataList = errList.Distinct().ToList(); } catch (Exception) { throw; } } } }