123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Linq.Expressions;
- using System.Transactions;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.StudentManage.OnlineChecking;
- using EMIS.DataLogic.StudentManage.OnlineChecking;
- using EMIS.CommonLogic.SystemServices;
- namespace EMIS.CommonLogic.StudentManage.OnlineChecking
- {
- public class CheckingApproveServices : BaseWorkflowServices<CF_StudentContrast>, ICheckingApproveServices
- {
- public Lazy<CheckingApproveDAL> CheckingApproveDAL { get; set; }
- /// <summary>
- /// 数据范围
- /// </summary>
- public CheckingApproveServices()
- {
- DataRangeUserFunc = ((x, y) => this.IsUserInDataRangeByCollege<CF_StudentContrast>(x, y, (w => w.Sys_User.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID)));
- }
- /// <summary>
- /// 查询对应的校对审核信息CheckingApproveView
- /// </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="approvalStatus"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<CheckingContrastView> GetCheckingApproveViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID,
- int? educationID, int? learningformID, string learnSystem, int? approvalStatus, int pageIndex, int pageSize)
- {
- var approveStatusList = this.GetApproveStatusViewList();
- var approveStatusIDList = approveStatusList.Select(x => x.ID).ToList();
- Expression<Func<CF_StudentContrast, bool>> expStudentContrast = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expStudentContrast = expStudentContrast.And(x => approveStatusIDList.Contains(x.ApprovalStatus));
- if (approvalStatus.HasValue)
- {
- expStudentContrast = expStudentContrast.And(x => x.ApprovalStatus == approvalStatus);
- }
- Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- Expression<Func<CF_StudentRecordChangeHistory, bool>> expStudentRecordChangeHistory = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- //expStudentRecordChangeHistory = expStudentRecordChangeHistory.And(x => x.CheckingTypeID == (int)CF_CheckingType.OpenApprove);
-
- var query = CheckingApproveDAL.Value.GetCheckingApproveViewQueryable(expStudentContrast, expStudent, expStudentRecordChangeHistory);
- if (campusID.HasValue)
- {
- query = query.Where(x => x.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (gradeID.HasValue)
- {
- query = query.Where(x => x.GradeID == gradeID);
- }
- 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());
- }
- var result = this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query))
- .OrderBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo).ThenBy(x => x.GradeID)
- .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).OrderByDescending(x => x.ModifyTime)
- .ToGridResultSet<CheckingContrastView>(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="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="approvalStatus"></param>
- /// <returns></returns>
- public IList<CheckingContrastView> GetCheckingApproveViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID,
- int? educationID, int? learningformID, string learnSystem, int? approvalStatus)
- {
- var approveStatusList = this.GetApproveStatusViewList();
- var approveStatusIDList = approveStatusList.Select(x => x.ID).ToList();
- Expression<Func<CF_StudentContrast, bool>> expStudentContrast = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expStudentContrast = expStudentContrast.And(x => approveStatusIDList.Contains(x.ApprovalStatus));
- if (approvalStatus.HasValue)
- {
- expStudentContrast = expStudentContrast.And(x => x.ApprovalStatus == approvalStatus);
- }
- Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- Expression<Func<CF_StudentRecordChangeHistory, bool>> expStudentRecordChangeHistory = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- //expStudentRecordChangeHistory = expStudentRecordChangeHistory.And(x => x.CheckingTypeID == (int)CF_CheckingType.OpenApprove);
- var query = CheckingApproveDAL.Value.GetCheckingApproveViewQueryable(expStudentContrast, expStudent, expStudentRecordChangeHistory);
- if (campusID.HasValue)
- {
- query = query.Where(x => x.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (gradeID.HasValue)
- {
- query = query.Where(x => x.GradeID == gradeID);
- }
- 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());
- }
- var result = this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query))
- .OrderBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo).ThenBy(x => x.GradeID)
- .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).OrderByDescending(x => x.ModifyTime).ToList();
- result.ForEach(x => x.ApprovalStatusName = approveStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
- return result;
- }
- /// <summary>
- /// 查询对应的校对审核信息CheckingContrastView
- /// </summary>
- /// <param name="studentContrastID"></param>
- /// <returns></returns>
- public CheckingContrastView GetStudentContrastView(Guid? studentContrastID)
- {
- try
- {
- Expression<Func<CF_StudentContrast, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.StudentContrastID == studentContrastID);
- var query = CheckingApproveDAL.Value.GetCheckingApproveViewQueryable(exp).SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="studentContrastIDs"></param>
- /// <returns></returns>
- public bool StudentContrastDelete(List<Guid?> studentContrastIDs)
- {
- try
- {
- using (TransactionScope ts = new TransactionScope())
- {
- UnitOfWork.Delete<CF_RecruitstudentsSource>(x => studentContrastIDs.Contains(x.StudentContrastID));
- UnitOfWork.Delete<CF_RecruitstudentsContrast>(x => studentContrastIDs.Contains(x.StudentContrastID));
- UnitOfWork.Delete<CF_StudentAccountSource>(x => studentContrastIDs.Contains(x.StudentContrastID));
- UnitOfWork.Delete<CF_StudentAccountContrast>(x => studentContrastIDs.Contains(x.StudentContrastID));
- UnitOfWork.Delete<CF_StudentContactSource>(x => studentContrastIDs.Contains(x.StudentContrastID));
- UnitOfWork.Delete<CF_StudentContactContrast>(x => studentContrastIDs.Contains(x.StudentContrastID));
- UnitOfWork.Delete<CF_StudentProfileSource>(x => studentContrastIDs.Contains(x.StudentContrastID));
- UnitOfWork.Delete<CF_StudentProfileContrast>(x => studentContrastIDs.Contains(x.StudentContrastID));
- UnitOfWork.Delete<Sys_UserSource>(x => studentContrastIDs.Contains(x.StudentContrastID));
- UnitOfWork.Delete<Sys_UserContrast>(x => studentContrastIDs.Contains(x.StudentContrastID));
- UnitOfWork.Delete<CF_StudentRecordChangeHistory>(x => studentContrastIDs.Contains(x.StudentContrastID));
- UnitOfWork.Delete<CF_StudentSource>(x => studentContrastIDs.Contains(x.StudentContrastID));
- UnitOfWork.Delete<CF_StudentContrast>(x => studentContrastIDs.Contains(x.StudentContrastID));
- ts.Complete();
- return true;
- }
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 查询对应的校对数明细CheckingHistoryView
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="studentContrastID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<CheckingHistoryView> GetCheckingDetailViewGrid(ConfiguretView configuretView, Guid? studentContrastID, int pageIndex, int pageSize)
- {
- Expression<Func<CF_StudentContrast, bool>> expStudentContrast = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expStudentContrast = expStudentContrast.And(x => x.StudentContrastID == studentContrastID);
- var query = CheckingApproveDAL.Value.GetCheckingHistoryViewQueryable(expStudentContrast);
-
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ThenBy(x => x.ColumnName.Length)
- .ThenBy(x => x.ColumnName).ToGridResultSet<CheckingHistoryView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的校对数明细List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="studentContrastID"></param>
- /// <returns></returns>
- public IList<CheckingHistoryView> GetCheckingDetailViewList(ConfiguretView configuretView, Guid? studentContrastID)
- {
- Expression<Func<CF_StudentContrast, bool>> expStudentContrast = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expStudentContrast = expStudentContrast.And(x => x.StudentContrastID == studentContrastID);
- var query = CheckingApproveDAL.Value.GetCheckingHistoryViewQueryable(expStudentContrast);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ThenBy(x => x.ColumnName.Length)
- .ThenBy(x => x.ColumnName).ToList();
- }
- /// <summary>
- /// 审核确定(批量)
- /// </summary>
- /// <param name="studentContrastIDs"></param>
- /// <param name="userID"></param>
- /// <param name="actionID"></param>
- /// <param name="comment"></param>
- public void CheckingApproveConfirm(List<Guid?> studentContrastIDs, Guid userID, Guid actionID, string comment)
- {
- try
- {
- var studentContrastList = CheckingApproveDAL.Value.StudentContrastRepository.GetList(x => studentContrastIDs.Contains(x.StudentContrastID)).ToList();
- foreach (var studentContrastID in studentContrastIDs)
- {
- var studentContrast = studentContrastList.Where(x => x.StudentContrastID == studentContrastID).SingleOrDefault();
- if (studentContrast == null)
- {
- throw new Exception("数据有误,请核查");
- }
- }
- this.Approve(studentContrastIDs.Select(x => x.Value).ToList(), userID, actionID, comment);
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询对应列名称及值ColumnNameValue
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="t"></param>
- /// <returns></returns>
- public Dictionary<string, object> GetColumnNameValue<T>(T t)
- {
- try
- {
- var columnNameValueList = new Dictionary<string, object>();
- System.Reflection.PropertyInfo[] properties = t.GetType().GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
- foreach (System.Reflection.PropertyInfo item in properties)
- {
- if (item.PropertyType.IsValueType || item.PropertyType.Name.StartsWith("String"))
- {
- columnNameValueList.Add(item.Name, item.GetValue(t, null));
- }
- }
- return columnNameValueList;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 流程结束跳转函数(工作流平台中配置)
- /// 注:需对网上校对信息进行处理
- /// </summary>
- /// <param name="studentContrastIDList"></param>
- /// <param name="userID"></param>
- public void OnApproveEnd(List<Guid> studentContrastIDList, Guid? userID)
- {
- try
- {
- var studentContrastList = CheckingApproveDAL.Value.StudentContrastRepository.GetList(x => studentContrastIDList.Contains(x.StudentContrastID)).ToList();
- var userIDList = studentContrastList.Select(x => x.UserID).ToList();
- var studentList = CheckingApproveDAL.Value.StudentRepository.GetList(x => userIDList.Contains(x.UserID), (x => x.CF_StudentProfile), (x => x.CF_StudentContact), (x => x.CF_StudentAccount), (x => x.CF_Recruitstudents), (x => x.Sys_User)).ToList();
- var checkingHistoryViewList = CheckingApproveDAL.Value.GetCheckingHistoryViewQueryable(x => studentContrastIDList.Contains(x.StudentContrastID)).ToList();
- bool isUserCheck = false;
- bool isStudentCheck = false;
- bool isStuProfileCheck = false;
- bool isStuContactCheck = false;
- bool isStuAccountCheck = false;
- bool isStuRecruitCheck = false;
- List<Sys_User> userUpList = new List<Sys_User>();
- List<CF_Student> studentUpList = new List<CF_Student>();
- List<CF_StudentProfile> studentProfileUpList = new List<CF_StudentProfile>();
- List<CF_StudentContact> studentContactUpList = new List<CF_StudentContact>();
- List<CF_StudentAccount> studentAccountUpList = new List<CF_StudentAccount>();
- List<CF_Recruitstudents> recruitstudentsUpList = new List<CF_Recruitstudents>();
- foreach (var studentContrast in studentContrastList)
- {
- isUserCheck = false;
- isStudentCheck = false;
- isStuProfileCheck = false;
- isStuContactCheck = false;
- isStuAccountCheck = false;
- isStuRecruitCheck = false;
- var keyValuePairList = checkingHistoryViewList.Where(x => x.StudentContrastID == studentContrast.StudentContrastID).ToDictionary(x => x.ColumnName, x => x.CheckingAfterValue);
- var student = studentList.Where(x => x.UserID == studentContrast.UserID).SingleOrDefault();
- foreach (var keyValuePair in keyValuePairList)
- {
- var userProperty = typeof(Sys_User).GetProperties().Where(x => x.Name.ToLower() == keyValuePair.Key.ToLower()).SingleOrDefault();
- if (userProperty != null)
- {
- if (!(userProperty.GetValue(student.Sys_User, null) ?? "").Equals((keyValuePairList[keyValuePair.Key] ?? "")))
- {
- userProperty.SetValue(student.Sys_User, keyValuePairList[keyValuePair.Key], null);
- isUserCheck = true;
- }
- }
- var studentProperty = typeof(CF_Student).GetProperties().Where(x => x.Name.ToLower() == keyValuePair.Key.ToLower()).SingleOrDefault();
- if (studentProperty != null)
- {
- if (!(studentProperty.GetValue(student, null) ?? "").Equals((keyValuePairList[keyValuePair.Key] ?? "")))
- {
- studentProperty.SetValue(student, keyValuePairList[keyValuePair.Key], null);
- isStudentCheck = true;
- }
- }
- var studentProfileProperty = typeof(CF_StudentProfile).GetProperties().Where(x => x.Name.ToLower() == keyValuePair.Key.ToLower()).SingleOrDefault();
- if (studentProfileProperty != null)
- {
- if (!(studentProfileProperty.GetValue(student.CF_StudentProfile, null) ?? "").Equals((keyValuePairList[keyValuePair.Key] ?? "")))
- {
- studentProfileProperty.SetValue(student.CF_StudentProfile, keyValuePairList[keyValuePair.Key], null);
- isStuProfileCheck = true;
- }
- }
- var studentContactProperty = typeof(CF_StudentContact).GetProperties().Where(x => x.Name.ToLower() == keyValuePair.Key.ToLower()).SingleOrDefault();
- if (studentContactProperty != null)
- {
- if (!(studentContactProperty.GetValue(student.CF_StudentContact, null) ?? "").Equals((keyValuePairList[keyValuePair.Key] ?? "")))
- {
- studentContactProperty.SetValue(student.CF_StudentContact, keyValuePairList[keyValuePair.Key], null);
- isStuContactCheck = true;
- }
- }
- var studentAccountProperty = typeof(CF_StudentAccount).GetProperties().Where(x => x.Name.ToLower() == keyValuePair.Key.ToLower()).SingleOrDefault();
- if (studentAccountProperty != null)
- {
- if (!(studentAccountProperty.GetValue(student.CF_StudentAccount, null) ?? "").Equals((keyValuePairList[keyValuePair.Key] ?? "")))
- {
- studentAccountProperty.SetValue(student.CF_StudentAccount, keyValuePairList[keyValuePair.Key], null);
- isStuAccountCheck = true;
- }
- }
- var recruitstudentsProperty = typeof(CF_Recruitstudents).GetProperties().Where(x => x.Name.ToLower() == keyValuePair.Key.ToLower()).SingleOrDefault();
- if (recruitstudentsProperty != null)
- {
- if (!(recruitstudentsProperty.GetValue(student.CF_Recruitstudents, null) ?? "").Equals((keyValuePairList[keyValuePair.Key] ?? "")))
- {
- recruitstudentsProperty.SetValue(student.CF_Recruitstudents, keyValuePairList[keyValuePair.Key], null);
- isStuRecruitCheck = true;
- }
- }
- }
- if (isUserCheck)
- {
- student.Sys_User.ModifyUserID = userID;
- student.Sys_User.ModifyTime = DateTime.Now;
- userUpList.Add(student.Sys_User);
- }
- if (isStudentCheck)
- {
- student.ModifyUserID = userID;
- student.ModifyTime = DateTime.Now;
- studentUpList.Add(student);
- }
- if (isStuProfileCheck)
- {
- student.CF_StudentProfile.ModifyUserID = userID;
- student.CF_StudentProfile.ModifyTime = DateTime.Now;
- studentProfileUpList.Add(student.CF_StudentProfile);
- }
- if (isStuContactCheck)
- {
- student.CF_StudentContact.ModifyUserID = userID;
- student.CF_StudentContact.ModifyTime = DateTime.Now;
- studentContactUpList.Add(student.CF_StudentContact);
- }
- if (isStuAccountCheck)
- {
- student.CF_StudentAccount.ModifyUserID = userID;
- student.CF_StudentAccount.ModifyTime = DateTime.Now;
- studentAccountUpList.Add(student.CF_StudentAccount);
- }
- if (isStuRecruitCheck)
- {
- student.CF_Recruitstudents.ModifyUserID = userID;
- student.CF_Recruitstudents.ModifyTime = DateTime.Now;
- recruitstudentsUpList.Add(student.CF_Recruitstudents);
- }
- }
- TransactionOptions transactionOption = new TransactionOptions();
- transactionOption.IsolationLevel = System.Transactions.IsolationLevel.Serializable;
- transactionOption.Timeout = new TimeSpan(0, 3, 0);
- using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, transactionOption))
- {
- if (userUpList != null && userUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(userUpList);
- }
- if (studentUpList != null && studentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(studentUpList);
- }
- if (studentProfileUpList != null && studentProfileUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(studentProfileUpList);
- }
- if (studentContactUpList != null && studentContactUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(studentContactUpList);
- }
- if (studentAccountUpList != null && studentAccountUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(studentAccountUpList);
- }
- if (recruitstudentsUpList != null && recruitstudentsUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(recruitstudentsUpList);
- }
- ts.Complete();
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- }
- }
|