1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Data;
- using System.IO;
- 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.NewStudentManage;
- using EMIS.DataLogic.EnrollManage.NewStudentManage;
- namespace EMIS.CommonLogic.EnrollManage.NewStudentManage
- {
- public class NewStudentCollegeServices : BaseServices, INewStudentCollegeServices
- {
- public NewStudentDAL NewStudentDAL { get; set; }
- /// <summary>
- /// 查询新生分配信息View
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="gradeID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="isPhoto"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<NewStudentView> GetNewStudentCollegeViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID,
- int? standardID, int? educationID, int? learningformID, string learnSystem, int? isPhoto, int pageIndex, int pageSize)
- {
- Expression<Func<CF_NewStudent, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.PreAssigned);
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CollegeID == collegeID);
- }
- if (gradeID.HasValue)
- {
- exp = exp.And(x => x.GradeID == gradeID);
- }
- if (isPhoto.HasValue)
- {
- if (isPhoto.Value == (int)CF_GeneralExist.Have)
- {
- exp = exp.And(x => x.RecruitPictureUrl != null && x.RecruitPictureUrl != "");
- }
- if (isPhoto.Value == (int)CF_GeneralExist.No)
- {
- exp = exp.And(x => x.RecruitPictureUrl == null || x.RecruitPictureUrl == "");
- }
- }
- var query = NewStudentDAL.GetNewStudentCollegeViewQueryable(exp);
- if (campusID.HasValue)
- {
- query = query.Where(x => x.CampusID == campusID);
- }
- if (standardID.HasValue)
- {
- query = query.Where(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- query = query.Where(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- query = query.Where(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(learnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeID)
- .ThenBy(x => x.StandardName).ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem).OrderBy(x => x.OrderNo).ToGridResultSet<NewStudentView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询新生分配信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="gradeID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="isPhoto"></param>
- /// <returns></returns>
- public IList<NewStudentView> GetNewStudentCollegeViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID,
- int? standardID, int? educationID, int? learningformID, string learnSystem, int? isPhoto)
- {
- Expression<Func<CF_NewStudent, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.PreAssigned);
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CollegeID == collegeID);
- }
- if (gradeID.HasValue)
- {
- exp = exp.And(x => x.GradeID == gradeID);
- }
- if (isPhoto.HasValue)
- {
- if (isPhoto.Value == (int)CF_GeneralExist.Have)
- {
- exp = exp.And(x => x.RecruitPictureUrl != null && x.RecruitPictureUrl != "");
- }
- if (isPhoto.Value == (int)CF_GeneralExist.No)
- {
- exp = exp.And(x => x.RecruitPictureUrl == null || x.RecruitPictureUrl == "");
- }
- }
- var query = NewStudentDAL.GetNewStudentCollegeViewQueryable(exp);
- if (campusID.HasValue)
- {
- query = query.Where(x => x.CampusID == campusID);
- }
- if (standardID.HasValue)
- {
- query = query.Where(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- query = query.Where(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- query = query.Where(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(learnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeID)
- .ThenBy(x => x.StandardName).ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem).OrderBy(x => x.OrderNo).ToList();
- }
- /// <summary>
- /// 查询未分配新生名单信息View
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="gradeID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<NewStudentView> GetUnAssignNewStudentViewGrid(ConfiguretView configuretView, int? gradeID, int? standardID, int? educationID, int? learningformID, string learnSystem, int pageIndex, int pageSize)
- {
- Expression<Func<CF_NewStudent, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.NotAssigned);
- if (gradeID.HasValue)
- {
- exp = exp.And(x => x.GradeID == gradeID);
- }
- var query = NewStudentDAL.GetNewStudentViewQueryable(exp);
- 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 query.OrderByDescending(x => x.GradeID).ThenBy(x => x.StandardName).ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID)
- .ThenBy(x => x.LearnSystem).ToGridResultSet<NewStudentView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询未分配新生名单信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="gradeID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <returns></returns>
- public IList<NewStudentView> GetUnAssignNewStudentViewList(ConfiguretView configuretView, int? gradeID, int? standardID, int? educationID, int? learningformID, string learnSystem)
- {
- Expression<Func<CF_NewStudent, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.NotAssigned);
- if (gradeID.HasValue)
- {
- exp = exp.And(x => x.GradeID == gradeID);
- }
- var query = NewStudentDAL.GetNewStudentViewQueryable(exp);
- 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 query.OrderByDescending(x => x.GradeID).ThenBy(x => x.StandardName).ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID)
- .ThenBy(x => x.LearnSystem).ToList();
- }
- /// <summary>
- /// 查询对应的新生分配信息NewStudentView
- /// </summary>
- /// <param name="newStudentID"></param>
- /// <returns></returns>
- public NewStudentView GetNewStudentCollegeView(Guid? newStudentID)
- {
- try
- {
- Expression<Func<CF_NewStudent, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.PreAssigned);
- exp = exp.And(x => x.NewStudentID == newStudentID);
- var query = NewStudentDAL.GetNewStudentCollegeViewQueryable(exp).SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 导入分配
- /// </summary>
- /// <param name="cellheader"></param>
- /// <param name="inCount"></param>
- /// <param name="upCount"></param>
- /// <param name="errdataList"></param>
- /// <param name="errCount"></param>
- /// <param name="sourcePhysicalPath"></param>
- public void NewStudentAssignCollegeImport(Dictionary<string, string> cellheader, out int? inCount, out int? upCount, out List<NewStudentView> errdataList, out int? errCount, string sourcePhysicalPath)
- {
- try
- {
- StringBuilder errorMsg = new StringBuilder(); // 错误信息
- List<NewStudentView> errList = new List<NewStudentView>();
- // 1.1解析文件,存放到一个List集合里
- cellheader.Remove("ErrorMessage");//移除“未导入原因”列(ErrorMessage)
- List<NewStudentView> enlist = NpoiExcelHelper.ExcelToEntityList<NewStudentView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
- cellheader.Add("ErrorMessage", "未导入原因");
- //对List集合进行有效性校验
- if (enlist.Count() <= 0)
- {
- throw new Exception("Excel文件数据为空,请检查。");
- }
- Regex reg = null; //正则表达式
- inCount = 0; //导入个数
- upCount = 0; //更新个数
- errCount = 0; //失败个数
- string errorMsgStr = ""; //错误信息
- List<CF_NewStudent> newStudentInList = new List<CF_NewStudent>();
- List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
- //将循环中相关数据库查询统一查询出来进行匹配(尽量避免在循环中进行数据库查询)
- //年级
- var gradeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Grade).ToList();
- //院系所代码
- var collegeNoList = enlist.Where(x => !string.IsNullOrEmpty(x.CollegeNo)).Select(x => x.CollegeNo).ToList();
- //院系所
- var collegeList = NewStudentDAL.CollegeRepository.GetList(x => true, x => x.CF_CollegeProfile).ToList();
- //姓名
- var nameList = enlist.Where(x => !string.IsNullOrEmpty(x.Name)).Select(x => x.Name).ToList();
- //身份证号
- var iDNumberList = enlist.Where(x => !string.IsNullOrEmpty(x.IDNumber)).Select(x => x.IDNumber).ToList();
- //年级
- var gradeIDList = enlist.Where(x => !string.IsNullOrEmpty(x.GradeStr)).Select(x => x.GradeStr).ToList();
- //新生名单(由于需要和Excel中数据进行比对,数据太多就会报异常,所以需要先查询出来)
- var newStudentAllList = NewStudentDAL.NewStudentRepository.GetList(x => true).ToList();
- //对比后的newStudentList
- var newStudentList = newStudentAllList.Where(x => nameList.Contains(x.Name) && iDNumberList.Contains(x.IDNumber) && gradeIDList.Contains(x.GradeID.ToString())).ToList();
- //招生专业(用于检测是否开设相对应的专业:专业信息、年级、院系所)
- var recruitSpecialtyList = NewStudentDAL.RecruitSpecialtyRepository.GetList(x => gradeIDList.Contains(x.GradeID.ToString())).ToList();
- //循环检测数据列,对各数据列进行验证(必填、字典项验证、数据格式等)
- for (int i = 0; i < enlist.Count; i++)
- {
- NewStudentView en = enlist[i]; //Excel表数据视图
- CF_NewStudent newStudent = new CF_NewStudent(); //新生信息实体
- //序号
- if (string.IsNullOrEmpty(en.OrderNoStr))
- {
- errCount++;
- errorMsgStr = "序号不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- reg = new Regex(@"^[1-9]\d*|0$"); //序号字段正则表达式()
- if (!reg.IsMatch(en.OrderNoStr))
- {
- errCount++;
- errorMsgStr = "序号格式不正确,请检查(自然数)";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //序号
- newStudent.OrderNo = Convert.ToInt32(en.OrderNoStr);
- }
- }
- //身份证号
- if (string.IsNullOrEmpty(en.IDNumber))
- {
- errCount++;
- errorMsgStr = "身份证号不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //身份证号正则表达式
- //if (!reg.IsMatch(en.IDNumber))
- //{
- // errCount++;
- // errorMsgStr = "身份证号格式不正确,请检查";
- // en.ErrorMessage = errorMsgStr;
- // errList.Add(en);
- // errorMsg.AppendLine(errorMsgStr);
- // continue;
- //}
- //else
- //{
- // //身份证号
- // newStudent.IDNumber = en.IDNumber.Trim();
- //}
- newStudent.IDNumber = en.IDNumber.Trim();
- }
- //姓名
- if (string.IsNullOrEmpty(en.Name))
- {
- errCount++;
- errorMsgStr = "姓名不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //姓名
- newStudent.Name = en.Name.Trim();
- }
- //年级
- if (string.IsNullOrEmpty(en.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
- {
- //年级ID
- newStudent.GradeID = grade.Value;
- }
- }
- //院系所代码
- 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
- newStudent.CollegeID = college.CollegeID;
- }
- }
- ////Excel表重复性验证(注:当数据表中没有此记录,但是Excel中有重复数据时的去掉)
- //for (int j = i + 1; j < enlist.Count; j++)
- //{
- // NewStudentView enA = enlist[j];
- // //根据Excel表中的业务主键进行去重(身份证号、姓名、年级唯一)
- // if (en.IDNumber == enA.IDNumber && en.Name == enA.Name && en.YearID == enA.YearID)
- // {
- // //用于标识Excel表中的重复记录(由于是批量进行插入数据表)
- // }
- //}
- //由于新生管理模块中存在新生分配的业务,在进行新生信息新增时,
- //需要对新生分配、录取名单中的信息进行提示性验证(业务主键:身份证号、姓名、年级唯一)
- //处理方法:进行Excel导入时,对新生分配、录取名单中的信息提示性验证(当错误信息抛出)
- //注:(未分配-1,预分配-2,已分配-3)
- //数据表重复性验证,此为名单归站功能(身份证号、姓名、年级唯一)
- CF_NewStudent newStudentEnetey = newStudentList.Where(x => x.IDNumber == newStudent.IDNumber
- && x.Name == newStudent.Name && x.GradeID == newStudent.GradeID).FirstOrDefault();
- if (newStudentEnetey == null)
- {
- errCount++;
- errorMsgStr = "此归站名单不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var recruitSpecialty = recruitSpecialtyList.Where(x => x.GradeID == newStudent.GradeID
- && x.SpecialtyID == newStudentEnetey.SpecialtyID && x.CollegeID == newStudent.CollegeID).FirstOrDefault();
- //名单归站时,需对招生专业进行验证
- if (recruitSpecialty == null)
- {
- errCount++;
- errorMsgStr = "归站失败,此归站名单未开设相关的招生专业,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //由于新生管理模块中存在新生分配的业务,只更新分配状态为:未分配-1、预分配-2
- //分配状态为:未分配-1,预分配-2,已分配-3
- if (newStudentEnetey.AssignStatus == (int)CF_AssignStatus.Assigned)
- {
- errCount++;
- errorMsgStr = "归站失败,录取名单信息中已存在此归站名单";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //(Excel有重复时,以最后一条记录的更新为准)
- if (newStudentEnetey.CollegeID.HasValue)
- {
- //更新
- newStudentEnetey.OrderNo = newStudent.OrderNo;
- newStudentEnetey.CollegeID = newStudent.CollegeID;
- newStudentEnetey.AssignStatus = (int)CF_AssignStatus.PreAssigned; //预分配
- SetModifyStatus(newStudentEnetey);
- newStudentUpList.Add(newStudentEnetey);
- upCount++;
- }
- else
- {
- //归站
- newStudentEnetey.OrderNo = newStudent.OrderNo;
- newStudentEnetey.CollegeID = newStudent.CollegeID;
- newStudentEnetey.AssignStatus = (int)CF_AssignStatus.PreAssigned; //预分配
- SetModifyStatus(newStudentEnetey);
- newStudentUpList.Add(newStudentEnetey);
- inCount++;
- }
- }
- }
- }
- }
- //批量统一提交更新
- if (newStudentUpList != null && newStudentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStudentUpList); //批量更新
- }
- errdataList = errList.Distinct().ToList(); //错误列表List
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 名单分配确定
- /// 注:需对招生专业进行验证
- /// </summary>
- /// <param name="collegeID"></param>
- /// <param name="newStudentIDList"></param>
- /// <returns></returns>
- public string NewStudentAssignCollegeConfirm(Guid? collegeID, List<Guid?> newStudentIDList)
- {
- try
- {
- //查询新生信息
- var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => newStudentIDList.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.NotAssigned).ToList();
- //查询招生专业信息
- var recruitSpecialtyList = NewStudentDAL.RecruitSpecialtyRepository.GetList(x => x.CollegeID == collegeID).ToList();
- int success = 0; //成功
- int fail = 0; //失败
- string tipMessage = null; //提示消息
- List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
- foreach (var newStudentID in newStudentIDList)
- {
- var newStudent = newStudentList.Where(x => x.NewStudentID == newStudentID).SingleOrDefault();
- if (newStudent == null)
- {
- throw new Exception("数据有误,请检查。");
- }
- else
- {
- var recruitSpecialty = recruitSpecialtyList.Where(x => x.SpecialtyID == newStudent.SpecialtyID
- && x.GradeID == newStudent.GradeID && x.CollegeID == collegeID).SingleOrDefault();
- if (recruitSpecialty == null)
- {
- fail++;
- }
- else
- {
- newStudent.CollegeID = collegeID;
- newStudent.AssignStatus = (int)CF_AssignStatus.PreAssigned;
- SetModifyStatus(newStudent);
- newStudentUpList.Add(newStudent);
- success++;
- }
- }
- }
- //批量统一提交更新
- if (newStudentUpList != null && newStudentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStudentUpList);
- }
- if (success > 0 && fail <= 0)
- {
- tipMessage = success + "条";
- }
- else
- {
- tipMessage = success + "条," + fail + "条失败,原因:选择分配的" + RSL.Get("College") + ",未开设相应的招生专业,请检查";
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除照片(批量删除)
- /// </summary>
- /// <param name="newStudentIDs"></param>
- /// <returns></returns>
- public bool PicDelete(List<Guid?> newStudentIDs)
- {
- try
- {
- List<string> photoUrlList = new List<string>();
- List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
- var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => newStudentIDs.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.PreAssigned).ToList();
- foreach (var newStudent in newStudentList)
- {
- if (newStudent != null)
- {
- if (!string.IsNullOrEmpty(newStudent.RecruitPictureUrl))
- {
- photoUrlList.Add(newStudent.RecruitPictureUrl);
- newStudent.RecruitPictureUrl = null;
- newStudentUpList.Add(newStudent);
- }
- }
- }
- using (TransactionScope ts = new TransactionScope())
- {
- foreach (var photoUrl in photoUrlList)
- {
- FileUploadHelper.DeleteFile(photoUrl);
- }
- if (newStudentUpList != null && newStudentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStudentUpList);
- }
- ts.Complete();
- }
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 取消分配
- /// </summary>
- /// <param name="NewStudentIDList"></param>
- /// <returns></returns>
- public string NewStudentCollegeCancleAssign(List<Guid?> NewStudentIDList)
- {
- try
- {
- var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => NewStudentIDList.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.PreAssigned).ToList();
- int success = 0; //成功
- string tipMessage = null; //提示消息
- List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
- foreach (var newStudent in newStudentList)
- {
- //newStudent.RecruitPictureUrl = null;
- newStudent.CollegeID = null;
- newStudent.AssignStatus = (int)CF_AssignStatus.NotAssigned;
- SetModifyStatus(newStudent);
- newStudentUpList.Add(newStudent);
- success++;
- }
- //批量统一提交更新
- if (newStudentUpList != null && newStudentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStudentUpList);
- }
- tipMessage = success + "条";
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 提交(需对招生专业进行验证,再提交,同时生成录取通知书编号(默认:年级+院系所代码+5位流水号))
- /// 注:个性化生成录取通知书编号(暂不考虑)
- /// </summary>
- /// <param name="NewStudentIDList"></param>
- /// <returns></returns>
- public string NewStudentCollegeSubmitAssign(List<Guid?> NewStudentIDList)
- {
- try
- {
- //查询新生信息(注意排序)
- var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => NewStudentIDList.Contains(x.NewStudentID)
- && x.AssignStatus == (int)CF_AssignStatus.PreAssigned).OrderByDescending(x => x.GradeID).ThenBy(x => x.CollegeID)
- .ThenBy(x => x.ExamineeNum.Length).ThenBy(x => x.ExamineeNum);
- //查询对应的院系所IDList
- var collegeIDList = newStudentList.Where(x => !string.IsNullOrEmpty(x.CollegeID.ToString())).Select(x => x.CollegeID).Distinct().ToList();
- //查询院系所信息
- var collegeList = NewStudentDAL.CollegeRepository.GetList(x => true).ToList();
- //查询招生专业信息
- var recruitSpecialtyList = NewStudentDAL.RecruitSpecialtyRepository.GetList(x => collegeIDList.Contains(x.CollegeID)).ToList();
- //查询各院系所最大的录取通知编号(只查询已分配状态的信息--录取名单)
- var maxCollegeEnrollmentList = NewStudentDAL.GetEnrollmentNo(x => collegeIDList.Contains(x.CollegeID) && x.AssignStatus == (int)CF_AssignStatus.Assigned).ToList();
- long startEnrollmentNo = 0; //初始录取通知书编号
- long newEnrollmentNo = 0; //新生成的录取通知书编号
- int total = 0; //年级+院系所长度
- int success = 0; //成功
- int fail = 0; //失败
- string tipMessage = null; //提示消息
- //新生信息提交List
- var newStudentUpList = new List<CF_NewStudent>();
- foreach (var newStudent in newStudentList)
- {
- var recruitSpecialty = recruitSpecialtyList.Where(x => x.SpecialtyID == newStudent.SpecialtyID && x.GradeID == newStudent.GradeID && x.CollegeID == newStudent.CollegeID).SingleOrDefault();
- if (recruitSpecialty == null)
- {
- fail++;
- }
- else
- {
- //查询对应院系的最大的录取通知编号(根据年级、院系所查询)
- var maxCollegeEnrollment = maxCollegeEnrollmentList.Where(x => x.GradeID == newStudent.GradeID && x.CollegeID == newStudent.CollegeID).SingleOrDefault();
- //查询新生信息提交List中是否有重复的信息(业务主键:年级、院系所)
- var newStudentRepeatList = newStudentUpList.Where(x => x.GradeID == newStudent.GradeID && x.CollegeID == newStudent.CollegeID).ToList();
- //表示当前院系所无对应的录取通知书编号,此时应为初始编号(年级+院系所代码+5位流水号)
- if (maxCollegeEnrollment == null)
- {
- //查询院系所代码
- var college = collegeList.Where(x => x.CollegeID == newStudent.CollegeID).SingleOrDefault();
- //生成初始录取通知书编号
- total = (newStudent.GradeID.ToString() + college.No).Length;
- startEnrollmentNo = Convert.ToInt64((newStudent.GradeID.ToString() + college.No).PadRight(total + 4, '0') + "1");
- //表示提交的信息中无重复信息(业务主键:年级、院系所)
- if (newStudentRepeatList.Count() <= 0)
- {
- //初始录取通知书编号
- newEnrollmentNo = startEnrollmentNo;
- }
- else
- {
- //提交信息中重复数据的最大录取通知书编号+1,作为下一个录取通知书编号
- newEnrollmentNo = Convert.ToInt64(newStudentRepeatList.OrderByDescending(x => Convert.ToInt64(x.EnrollmentNo)).FirstOrDefault().EnrollmentNo) + 1;
- }
- }
- else
- {
- //表示提交的信息中无重复信息(业务主键:年级、院系所)
- if (newStudentRepeatList.Count() <= 0)
- {
- //数据表中的最大录取通知书编号+1,作为下一个录取通知书编号
- newEnrollmentNo = Convert.ToInt64(maxCollegeEnrollment.EnrollmentNo) + 1;
- }
- else
- {
- //提交信息中重复数据的最大录取通知书编号+1,作为下一个录取通知书编号
- newEnrollmentNo = Convert.ToInt64(newStudentRepeatList.OrderByDescending(x => Convert.ToInt64(x.EnrollmentNo)).FirstOrDefault().EnrollmentNo) + 1;
- }
- }
- //录取通知书编号
- newStudent.EnrollmentNo = newEnrollmentNo.ToString();
- newStudent.AssignStatus = (int)CF_AssignStatus.Assigned; //已分配
- SetModifyStatus(newStudent);
- newStudentUpList.Add(newStudent);
- success++;
- }
- }
- //批量统一提交更新
- if (newStudentUpList != null && newStudentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStudentUpList);
- }
- if (success > 0 && fail <= 0)
- {
- tipMessage = success + "条";
- }
- else
- {
- tipMessage = success + "条," + fail + "条失败,原因:提交的信息中存在," + RSL.Get("College") + "未开设相应的招生专业信息,请检查";
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 导入照片
- /// </summary>
- /// <param name="photoPaths"></param>
- /// <param name="importPicType"></param>
- /// <param name="inCount"></param>
- /// <param name="errCount"></param>
- /// <param name="errDataTable"></param>
- public void NewStudentCollegePicImport(IList<string> photoPaths, string importPicType, out int? inCount, out int? errCount, out DataTable errDataTable)
- {
- try
- {
- var mapList = photoPaths.Select(s => new
- {
- PhotoInfo = Path.GetFileName(s).Trim(),
- PhotoName = Path.GetFileNameWithoutExtension(s).Trim(),
- PhotoPath = s,
- }).ToArray();
- var photoNameList = mapList.Select(s => s.PhotoName).Distinct().ToList();
- inCount = 0;
- errCount = 0;
- errDataTable = new DataTable();
- List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
- if (importPicType.Equals("ExamineeNum"))
- {
- var newPhotoNameList = new List<string>();
- foreach (var photoName in photoNameList)
- {
- var photoNameStart = photoName.Substring(0, 1);
- if (photoNameStart.Equals("F") || photoNameStart.Equals("Z"))
- {
- newPhotoNameList.Add(photoName.Substring(1));
- }
- }
- errDataTable.Columns.Add("PhotoInfo", typeof(string));
- errDataTable.Columns.Add("ExamineeNum", typeof(string));
- errDataTable.Columns.Add("ErrorMessage", typeof(string));
- var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => x.AssignStatus == (int)CF_AssignStatus.PreAssigned && (photoNameList.Contains(x.ExamineeNum) || newPhotoNameList.Contains(x.ExamineeNum))).ToList();
- foreach (var map in mapList)
- {
- var photoNameStart = map.PhotoName.Substring(0, 1);
- if (photoNameStart.Equals("F") || photoNameStart.Equals("Z"))
- {
- var newStudent = newStudentList.Where(x => x.ExamineeNum == map.PhotoName || x.ExamineeNum == map.PhotoName.Substring(1)).SingleOrDefault();
- if (newStudent == null)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["ExamineeNum"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的考生号(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- newStudent.RecruitPictureUrl = map.PhotoPath;
- this.SetModifyStatus(newStudent);
- newStudentUpList.Add(newStudent);
- inCount++;
- }
- }
- else
- {
- var newStudent = newStudentList.Where(x => x.ExamineeNum == map.PhotoName).SingleOrDefault();
- if (newStudent == null)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["ExamineeNum"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的考生号(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- newStudent.RecruitPictureUrl = map.PhotoPath;
- this.SetModifyStatus(newStudent);
- newStudentUpList.Add(newStudent);
- inCount++;
- }
- }
- }
- }
- else if (importPicType.Equals("IDNumber"))
- {
- errDataTable.Columns.Add("PhotoInfo", typeof(string));
- errDataTable.Columns.Add("IDNumber", typeof(string));
- errDataTable.Columns.Add("ErrorMessage", typeof(string));
- var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => x.AssignStatus == (int)CF_AssignStatus.PreAssigned && photoNameList.Contains(x.IDNumber)).ToList();
- foreach (var map in mapList)
- {
- var newStudentVerifyList = newStudentList.Where(x => x.IDNumber == map.PhotoName).ToList();
- if (newStudentVerifyList != null && newStudentVerifyList.Count() > 1)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["IDNumber"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "存在多个对应的证件号码(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- if (newStudentVerifyList != null && newStudentVerifyList.Count() == 1)
- {
- var newStudent = newStudentVerifyList.Where(x => x.IDNumber == map.PhotoName).SingleOrDefault();
- if (newStudent == null)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["IDNumber"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的证件号码(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- newStudent.RecruitPictureUrl = map.PhotoPath;
- this.SetModifyStatus(newStudent);
- newStudentUpList.Add(newStudent);
- inCount++;
- }
- }
- else
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["IDNumber"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的证件号码(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- }
- }
- }
- if (newStudentUpList != null && newStudentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate<CF_NewStudent>(newStudentUpList);
- }
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 招生信息Excel导入(预分配,需根据省招专业相关信息进行匹配--个性化)
- /// </summary>
- /// <param name="cellheader"></param>
- /// <param name="inCount"></param>
- /// <param name="upCount"></param>
- /// <param name="errdataList"></param>
- /// <param name="errCount"></param>
- /// <param name="sourcePhysicalPath"></param>
- public virtual void NewStudentCollegeImport(Dictionary<string, string> cellheader, out int? inCount, out int? upCount, out List<NewStudentView> errdataList, out int? errCount, string sourcePhysicalPath)
- {
- //根据各高校个性化要求进行配置
- throw new Exception("招生信息导入配置有误(根据个性化要求进行配置),请检查");
- }
- }
- }
|