123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Linq.Expressions;
- using System.Text.RegularExpressions;
- using Bowin.Common.Utility;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.GraduationManage.GraduationManage;
- using EMIS.DataLogic.GraduationManage.GraduationManage;
- using EMIS.CommonLogic.CalendarManage;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.CommonLogic.StudentManage.StudentStatistics;
- namespace EMIS.CommonLogic.GraduationManage.CompletionManage
- {
- public class CompletionListServices : BaseWorkflowServices<ER_GraduationApply>, ICompletionListServices
- {
- public GraduationApplyDAL GraduationApplyDAL { get; set; }
- public Lazy<IInSchoolSettingServices> InSchoolSettingServices { get; set; }
- public Lazy<ISchoolYearServices> SchoolYearServices { get; set; }
- /// <summary>
- /// 查询结业名单信息View
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="gradSchoolyearID"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="yearID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="graduationTypeID"></param>
- /// <param name="educationTypeID"></param>
- /// <param name="inSchoolStatus"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<GraduationApplyView> GetCompletionListViewGrid(ConfiguretView configuretView, Guid? gradSchoolyearID,
- Guid? campusID, Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
- int? graduationTypeID, int? educationTypeID, int? inSchoolStatus, int pageIndex, int pageSize)
- {
- var approveStatusList = this.GetStatusViewList();
- var endApproveStatusID = this.GetCorrectEndStatus();
- //毕业申请
- Expression<Func<ER_GraduationApply, bool>> expGraduationApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expGraduationApply = expGraduationApply.And(x => x.ApprovalStatus == endApproveStatusID);
- //毕业结论
- expGraduationApply = expGraduationApply.And(x => x.GraduationResult == (int)ER_GraduationResult.Completion);
- if (gradSchoolyearID.HasValue)
- {
- //毕业学期(实际的毕业学期)
- expGraduationApply = expGraduationApply.And(x => x.GraduatingSemesterID == gradSchoolyearID);
- }
- if (graduationTypeID.HasValue)
- {
- //毕业类型
- expGraduationApply = expGraduationApply.And(x => x.GraduationTypeID == graduationTypeID);
- }
- //学生信息
- Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (inSchoolStatus != null && inSchoolStatus > -1)
- {
- var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
- if (inSchoolStatus == 1)
- {
- //表示在校
- expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- if (inSchoolStatus == 0)
- {
- //不在校
- expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- }
- ////在校状态(结业)
- //expStudent = expStudent.And(x => x.InSchoolStatusID == (int)CF_InschoolStatus.Complete);
- var query = GraduationApplyDAL.GetGraduationApplyViewQueryable(expGraduationApply, expStudent);
- if (campusID.HasValue)
- {
- query = query.Where(x => x.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- query = query.Where(x => x.SchoolyearID == yearID);
- }
- 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 (educationTypeID.HasValue)
- {
- //培养类型
- query = query.Where(x => x.EducationTypeID == educationTypeID);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- var result = this.GetQueryByDataRangeByCollege(query)
- .OrderBy(x => x.ClassNo.Length)
- .ThenBy(x => x.ClassNo).ThenBy(x => x.StudentNo.Length)
- .ThenBy(x => x.StudentNo).ThenBy(x => x.GraduatingSemesterValue)
- .ToGridResultSet<GraduationApplyView>(pageIndex, pageSize);
- result.rows.ForEach(x => x.ApprovalStatusName = approveStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
- return result;
- }
- /// <summary>
- /// 查询结业名单信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="gradSchoolyearID"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="yearID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="graduationTypeID"></param>
- /// <param name="educationTypeID"></param>
- /// <param name="inSchoolStatus"></param>
- /// <returns></returns>
- public List<GraduationApplyView> GetCompletionListViewList(ConfiguretView configuretView, Guid? gradSchoolyearID,
- Guid? campusID, Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
- int? graduationTypeID, int? educationTypeID, int? inSchoolStatus)
- {
- var approveStatusList = this.GetStatusViewList();
- var endApproveStatusID = this.GetCorrectEndStatus();
- //毕业申请
- Expression<Func<ER_GraduationApply, bool>> expGraduationApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expGraduationApply = expGraduationApply.And(x => x.ApprovalStatus == endApproveStatusID);
- //毕业结论
- expGraduationApply = expGraduationApply.And(x => x.GraduationResult == (int)ER_GraduationResult.Completion);
- if (gradSchoolyearID.HasValue)
- {
- //毕业学期(实际的毕业学期)
- expGraduationApply = expGraduationApply.And(x => x.GraduatingSemesterID == gradSchoolyearID);
- }
- if (graduationTypeID.HasValue)
- {
- //毕业类型
- expGraduationApply = expGraduationApply.And(x => x.GraduationTypeID == graduationTypeID);
- }
- //学生信息
- Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (inSchoolStatus != null && inSchoolStatus > -1)
- {
- var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
- if (inSchoolStatus == 1)
- {
- //表示在校
- expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- if (inSchoolStatus == 0)
- {
- //不在校
- expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- }
- ////在校状态(结业)
- //expStudent = expStudent.And(x => x.InSchoolStatusID == (int)CF_InschoolStatus.Complete);
- var query = GraduationApplyDAL.GetGraduationApplyViewQueryable(expGraduationApply, expStudent);
- if (campusID.HasValue)
- {
- query = query.Where(x => x.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- query = query.Where(x => x.SchoolyearID == yearID);
- }
- 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 (educationTypeID.HasValue)
- {
- //培养类型
- query = query.Where(x => x.EducationTypeID == educationTypeID);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- var result = this.GetQueryByDataRangeByCollege(query)
- .OrderBy(x => x.ClassNo.Length)
- .ThenBy(x => x.ClassNo).ThenBy(x => x.StudentNo.Length)
- .ThenBy(x => x.StudentNo).ThenBy(x => x.GraduatingSemesterValue)
- .ToList();
- result.ForEach(x => x.ApprovalStatusName = approveStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
- return result;
- }
- /// <summary>
- /// 查询对应的结业名单信息GraduationApplyView
- /// </summary>
- /// <param name="graduationApplyID"></param>
- /// <returns></returns>
- public GraduationApplyView GetCompletionListView(Guid? graduationApplyID)
- {
- try
- {
- var graduationListView = GraduationApplyDAL.GetGraduationApplyViewQueryable(x => x.GraduationApplyID == graduationApplyID)
- .SingleOrDefault();
- return graduationListView;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 编辑(新增、修改,业务主键:学生信息ID、流程结束状态(已通过))
- /// </summary>
- /// <param name="graduationApplyView"></param>
- public void CompletionListEdit(GraduationApplyView graduationApplyView)
- {
- try
- {
- //查询对应的工作流程环节状态信息View
- var approveStatusList = this.GetStatusViewList();
- if (approveStatusList == null || approveStatusList.Count() <= 0)
- {
- throw new Exception("工作流平台中,毕业处理流程未配置,请核查。");
- }
- //查询工作流程开始环节状态
- var approveStartStatusID = this.GetStartStatus();
- if (approveStartStatusID == null)
- {
- throw new Exception("工作流平台中,毕业处理流程开始环节未配置,请核查。");
- }
- //查询工作流程结束环节状态
- var approveEndStatusID = this.GetCorrectEndStatus();
- if (approveEndStatusID == null)
- {
- throw new Exception("工作流平台中,毕业处理流程结束环节未配置,请核查。");
- }
- //查询当前启用的学年学期View
- var currentSchoolYearView = SchoolYearServices.Value.GetCurrentSchoolYear();
- if (currentSchoolYearView == null)
- {
- throw new Exception("未设置启用的学年学期,请设置。");
- }
- //查询数据库进行验证
- var graduationApplyVerify = GraduationApplyDAL.GraduationApplyRepository
- .GetList(x => x.GraduationApplyID != graduationApplyView.GraduationApplyID
- && x.UserID == graduationApplyView.UserID
- && x.ApprovalStatus == approveEndStatusID)
- .SingleOrDefault();
- if (graduationApplyVerify == null)
- {
- if (!string.IsNullOrEmpty(graduationApplyView.GraduateCardNo))
- {
- //查询数据库进行验证(结业证书编号唯一)
- var graduateCardNoVerify = GraduationApplyDAL.StudentRepository
- .GetList(x => x.UserID != graduationApplyView.UserID
- && x.GraduateCardNo == graduationApplyView.GraduateCardNo).SingleOrDefault();
- if (graduateCardNoVerify != null)
- {
- throw new Exception("已存在此结业证书编号(重复),请检查。");
- }
- }
- //查询毕业学期对应的毕业学期信息
- var graduateSchoolyear = GraduationApplyDAL.GraduateSchoolyearRepository
- .GetList(x => x.SchoolyearID == graduationApplyView.GraduatingSemesterID).SingleOrDefault();
- //数据有误验证
- if (graduationApplyView.GraduationApplyID != Guid.Empty)
- {
- var graduationApply = GraduationApplyDAL.GraduationApplyRepository
- .GetList(x => x.GraduationApplyID == graduationApplyView.GraduationApplyID, (x => x.CF_Student))
- .SingleOrDefault();
- if (graduationApply == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- else
- {
- //表示修改
- if (graduationApply.ApprovalStatus == approveEndStatusID)
- {
- //毕业名单信息
- graduationApply.Remark = graduationApplyView.Remark;
- SetModifyStatus(graduationApply);
- //更新对应的学生信息
- graduationApply.CF_Student.GraduateCardNo = graduationApplyView.GraduateCardNo;
- //毕业日期
- if (graduateSchoolyear != null)
- {
- if (graduationApply.CF_Student.GraduateDate == null)
- {
- graduationApply.CF_Student.GraduateDate = graduateSchoolyear.GraduateDate;
- }
- }
- this.SetModifyStatus(graduationApply.CF_Student);
- }
- else
- {
- throw new Exception("数据有误,请核查(只能修改已通过状态的信息)。");
- }
- }
- }
- else
- {
- //查询对应的学生信息
- var student = GraduationApplyDAL.StudentRepository
- .GetList(x => x.UserID == graduationApplyView.UserID).SingleOrDefault();
- //表示新增
- ER_GraduationApply graduationApply = new ER_GraduationApply();
- graduationApply.GraduationApplyID = Guid.NewGuid();
- graduationApply.UserID = graduationApplyView.UserID;
- graduationApply.GraduationTypeID = graduationApplyView.GraduationTypeID;
- graduationApply.GraduatingSemesterID = graduationApplyView.GraduatingSemesterID;
- graduationApply.ApplySchoolyearID = currentSchoolYearView.SchoolYearID;
- graduationApply.GraduationConditionPackageID = graduationApplyView.GraduationConditionPackageID;
- graduationApply.BeforeInSchoolStatusID = student.InSchoolStatusID;
- graduationApply.BeforeStudentStatusID = student.StudentStatus;
- graduationApply.ApprovalStatus = approveEndStatusID;
- graduationApply.GraduationResult = (int)ER_GraduationResult.Completion;
- graduationApply.ApprovalResult = graduationApplyView.ApprovalResult;
- graduationApply.Remark = graduationApplyView.Remark;
- SetNewStatus(graduationApply);
- UnitOfWork.Add(graduationApply);
- //更新对应的学生信息
- student.InSchoolStatusID = (int)CF_InschoolStatus.Complete;
- student.StudentStatus = (int)CF_StudentStatus.Complete;
- student.GraduateCardNo = graduationApplyView.GraduateCardNo;
- //毕业日期
- if (graduateSchoolyear != null)
- {
- if (student.GraduateDate == null)
- {
- student.GraduateDate = graduateSchoolyear.GraduateDate;
- }
- }
- this.SetModifyStatus(student);
- }
- }
- else
- {
- if (graduationApplyVerify.GraduationResult == (int)ER_GraduationResult.Completion)
- {
- throw new Exception("此名单在结业名单中已存在,请核查。");
- }
- else if (graduationApplyVerify.GraduationResult == (int)ER_GraduationResult.Graduation)
- {
- throw new Exception("此名单在毕业名单中已存在,请核查。");
- }
- else
- {
- throw new Exception("数据异常(毕业结论为空),请核查。");
- }
- }
- //事务提交
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除(事务处理)
- /// 注:需考虑对应的在校状态、毕结业证书编号等信息的处理
- /// </summary>
- /// <param name="graduationApplyIDs"></param>
- /// <returns></returns>
- public bool CompletionListDelete(List<Guid?> graduationApplyIDs)
- {
- try
- {
- //查询对应的学位申请信息List
- var degreeApplyList = GraduationApplyDAL.DegreeApplyRepository
- .GetList(x => graduationApplyIDs.Contains(x.GraduationApplyID)).ToList();
- if (degreeApplyList != null && degreeApplyList.Count() > 0)
- {
- throw new Exception("请先删除与其关联的数据,如:学位申请、学位审核、学位名单等");
- }
- //查询对应的毕业申请信息List
- var graduationApplyList = GraduationApplyDAL.GraduationApplyRepository
- .GetList(x => graduationApplyIDs.Contains(x.GraduationApplyID), (x => x.CF_Student))
- .ToList();
- //更新对应的学生信息(如:在校状态、学籍状态、毕结业证书编号、毕业日期),同时删除对应的结业名单信息
- graduationApplyList.ForEach(x =>
- {
- x.CF_Student.InSchoolStatusID = x.BeforeInSchoolStatusID;
- x.CF_Student.StudentStatus = x.BeforeStudentStatusID;
- x.CF_Student.GraduateCardNo = null;
- x.CF_Student.GraduateDate = null;
- this.SetModifyStatus(x.CF_Student);
- UnitOfWork.Remove(x);
- });
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <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 void CompletionNoImport(Dictionary<string, string> cellheader, out int? inCount, out int? upCount,
- out List<GraduationApplyView> errdataList, out int? errCount, string sourcePhysicalPath)
- {
- try
- {
- //查询工作流程结束环节状态
- var approveEndStatusID = this.GetCorrectEndStatus();
- if (approveEndStatusID == null)
- {
- throw new Exception("工作流平台中,毕业处理流程结束环节未配置,请核查。");
- }
- //查询培养类型设置信息List
- var educationTypeSettingList = GraduationApplyDAL.EducationTypeSettingRepository
- .GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
- if (educationTypeSettingList == null || educationTypeSettingList.Count() <= 0)
- {
- throw new Exception("培养类型设置未设置,请设置。");
- }
- StringBuilder errorMsg = new StringBuilder(); // 错误信息
- List<GraduationApplyView> errList = new List<GraduationApplyView>();
- // 1.1解析文件,存放到一个List集合里
- cellheader.Remove("ErrorMessage");//移除“未导入原因”列(ErrorMessage)
- List<GraduationApplyView> enlist = NpoiExcelHelper
- .ExcelToEntityList<GraduationApplyView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
- cellheader.Add("ErrorMessage", "未导入原因");
- //对List集合进行有效性校验
- if (enlist.Count() <= 0)
- {
- throw new Exception("Excel文件数据为空,请检查。");
- }
- Regex reg = null; //正则表达式
- //DateTime result; //用于返回判断日期字段格式
- inCount = 0; //导入个数
- upCount = 0; //更新个数
- errCount = 0; //失败个数
- string errorMsgStr = ""; //错误信息
- List<ER_GraduationApply> newGraduationApplyInList = new List<ER_GraduationApply>();
- List<CF_Student> newStudentUpList = new List<CF_Student>();
- //移除StuUpList
- List<CF_Student> removeStuUpList = new List<CF_Student>();
- //将循环中相关数据库查询统一查询出来进行匹配(尽量避免在循环中进行数据库查询)
- //毕业申请
- Expression<Func<ER_GraduationApply, bool>> expGraduationApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expGraduationApply = expGraduationApply.And(x => x.ApprovalStatus == approveEndStatusID);
- //毕业结论(结业)
- expGraduationApply = expGraduationApply.And(x => x.GraduationResult == (int)ER_GraduationResult.Completion);
- //查询对应的结业名单信息ViewList
- var completionListViewList = GraduationApplyDAL.GetGraduationApplyViewQueryable(expGraduationApply).ToList();
- //查询对应的学生信息IDList
- var userIDList = completionListViewList.Select(x => x.UserID).ToList();
- //学号List
- var studentNoList = enlist.Where(x => !string.IsNullOrEmpty(x.StudentNo)).Select(x => x.StudentNo).ToList();
- //对比后的studentNoCompletionListViewList
- var studentNoCompletionListViewList = completionListViewList.Where(x => studentNoList.Contains(x.StudentNo)).ToList();
- //查询对应的学生信息List
- var studentList = GraduationApplyDAL.StudentRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
- //结业名单中的学生信息List
- var completionStudentList = studentList.Where(x => userIDList.Contains(x.UserID)).ToList();
- //结业证书编号List
- var completionNoList = enlist.Where(x => !string.IsNullOrEmpty(x.GraduateCardNo)).Select(x => x.GraduateCardNo).ToList();
- //对比后的completionNoStudentList
- var completionNoStudentList = studentList.Where(x => completionNoList.Contains(x.GraduateCardNo)).ToList();
- //查询对应的毕业学期信息List
- var graduateSchoolyearList = GraduationApplyDAL.GraduateSchoolyearRepository
- .GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
- //循环检测数据列,对各数据列进行验证(必填、字典项验证、数据格式等)
- for (int i = 0; i < enlist.Count; i++)
- {
- GraduationApplyView en = enlist[i]; //Excel表数据视图
- ER_GraduationApply newGraduationApply = new ER_GraduationApply();
- CF_Student newStudent = new CF_Student();
- //学号
- if (string.IsNullOrEmpty(en.StudentNo))
- {
- errCount++;
- errorMsgStr = "学号不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var studentNoGraduationApplyViewList = studentNoCompletionListViewList
- .Where(x => x.StudentNo == en.StudentNo).ToList();
- if (studentNoGraduationApplyViewList.Count() > 1)
- {
- errCount++;
- errorMsgStr = "对应的学号存在多个结业名单信息,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var studentNoGraduationApplyView = studentNoGraduationApplyViewList
- .Where(x => x.StudentNo == en.StudentNo).SingleOrDefault();
- if (studentNoGraduationApplyView == null)
- {
- errCount++;
- errorMsgStr = "对应的学号中不存在相应的结业名单信息,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //学生信息ID
- newStudent.UserID = studentNoGraduationApplyView.UserID.Value;
- newGraduationApply.UserID = studentNoGraduationApplyView.UserID;
- newGraduationApply.GraduatingSemesterID = studentNoGraduationApplyView.GraduatingSemesterID;
- }
- }
- }
- //结业证书编号
- if (string.IsNullOrEmpty(en.GraduateCardNo))
- {
- 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.GraduateCardNo))
- {
- errCount++;
- errorMsgStr = "结业证书编号格式不正确,请检查(数字或英文字母)";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var completionNoStudentViewList = completionNoStudentList
- .Where(x => x.UserID != newStudent.UserID && x.GraduateCardNo == en.GraduateCardNo.Trim()).ToList();
- if (completionNoStudentViewList.Count() > 1)
- {
- errCount++;
- errorMsgStr = "对应的结业证书编号存在多个学生信息中(重复),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var completionNoStudentView = completionNoStudentViewList
- .Where(x => x.GraduateCardNo == en.GraduateCardNo.Trim()).SingleOrDefault();
- if (completionNoStudentView == null)
- {
- newStudent.GraduateCardNo = en.GraduateCardNo.Trim();
- }
- else
- {
- errCount++;
- errorMsgStr = "对应的结业证书编号已存在学生信息中(重复),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- }
- }
- ////Excel表重复性验证(注:当数据表中没有此记录,但是Excel中有重复数据时的去掉)
- //for (int j = i + 1; j < enlist.Count; j++)
- //{
- // GraduationApplyView enA = enlist[j];
- // //根据Excel表中的业务主键进行去重(学号或学生信息ID唯一)
- // if (en.StudentNo == enA.StudentNo || en.UserID == enA.UserID)
- // {
- // //用于标识Excel表中的重复记录(由于是批量进行插入数据表)
- // }
- //}
- //数据表重复性验证(学号或学生信息ID唯一)
- var completionStudentVerification = completionStudentList
- .Where(x => x.UserID == newStudent.UserID).SingleOrDefault();
- //查询毕业学期对应的毕业学期信息
- var graduateSchoolyear = graduateSchoolyearList
- .Where(x => x.SchoolyearID == newGraduationApply.GraduatingSemesterID).SingleOrDefault();
- if (completionStudentVerification == null)
- {
- //由于前面已做相应判断,此处代码暂时无效
- //新增
- if (!newGraduationApplyInList.Any(x => x.UserID == newStudent.UserID))
- {
- //ER_GraduationApply表
- inCount++;
- }
- else
- {
- //Excel表重复性验证
- //(注:当数据表中没有此记录,但是Excel中有重复数据,可在此处进行抛出到失败数据文件中,目前暂不考虑)
- inCount++;
- }
- }
- else
- {
- //注:结业证书编号唯一
- //更新(Excel中有重复时,以数据重复抛出到失败数据文件中进行处理,不进行更新)
- if (!removeStuUpList.Any(x => x.GraduateCardNo == en.GraduateCardNo.Trim()))
- {
- if (!newStudentUpList.Any(x => x.GraduateCardNo == en.GraduateCardNo.Trim()))
- {
- completionStudentVerification.GraduateCardNo = newStudent.GraduateCardNo;
- //毕业日期
- if (graduateSchoolyear != null)
- {
- if (completionStudentVerification.GraduateDate == null)
- {
- completionStudentVerification.GraduateDate = graduateSchoolyear.GraduateDate;
- }
- }
- SetModifyStatus(completionStudentVerification);
- newStudentUpList.Add(completionStudentVerification);
- upCount++;
- }
- else
- {
- var stuUpList = newStudentUpList.Where(x => x.GraduateCardNo == en.GraduateCardNo.Trim()).ToList();
- foreach (var stuUp in stuUpList)
- {
- errCount++;
- errorMsgStr = "结业证书编号重复,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(new GraduationApplyView()
- {
- StudentNo = en.StudentNo,
- GraduateCardNo = en.GraduateCardNo,
- ErrorMessage = en.ErrorMessage
- });
- errorMsg.AppendLine(errorMsgStr);
- newStudentUpList.Remove(stuUp);
- removeStuUpList.Add(stuUp);
- upCount--;
- }
- errCount++;
- errorMsgStr = "结业证书编号重复,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- else
- {
- errCount++;
- errorMsgStr = "结业证书编号重复,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- }
- //移除Up
- if (removeStuUpList != null && removeStuUpList.Count() > 0)
- {
- foreach (var removeStuUp in removeStuUpList)
- {
- newStudentUpList.Remove(removeStuUp);
- }
- }
- //批量统一提交更新
- if (newStudentUpList != null && newStudentUpList.Count() > 0)
- {
- ////事务提交
- //UnitOfWork.Commit();
- UnitOfWork.BatchUpdate(newStudentUpList);
- }
- errdataList = errList.Distinct().ToList(); //错误列表List
- }
- catch (Exception ex)
- {
- //目前会出现,由于错误信息字符太长,无法抛出弹出框的问题
- throw new Exception(ex.Message);
- }
- }
- }
- }
|