123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using System.Transactions;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using Bowin.Common.Utility;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.StudentManage.StudentProfile;
- using EMIS.DataLogic.StudentManage.StudentProfile;
- using EMIS.CommonLogic.StudentManage.StudentStatistics;
- using EMIS.CommonLogic.SystemServices;
- namespace EMIS.CommonLogic.StudentManage.StudentProfile
- {
- public class StudentPunishServices : BaseWorkflowServices<EM_StudentPunish>, IStudentPunishServices
- {
- public Lazy<StudentPunishDAL> StudentPunishDAL { get; set; }
- public Lazy<IInSchoolSettingServices> InSchoolSettingServices { get; set; }
- /// <summary>
- /// 数据范围
- /// </summary>
- public StudentPunishServices()
- {
- DataRangeUserFunc = ((x, y) => this.IsUserInDataRangeByCollege<EM_StudentPunish>(x, y, (w => w.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID)));
- }
- /// <summary>
- /// 查询对应的学生处分信息StudentPunishView
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="schoolyearID"></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="punishTypeID"></param>
- /// <param name="punishLevelID"></param>
- /// <param name="inSchoolStatus"></param>
- /// <param name="approvalStatus"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<StudentPunishView> GetStudentPunishViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID,
- int? educationID, int? learningformID, string learnSystem, int? punishTypeID, int? punishLevelID, int? inSchoolStatus, int? approvalStatus, int pageIndex, int pageSize)
- {
- var approveStatusList = this.GetStatusViewList();
- Expression<Func<EM_StudentPunish, bool>> expStudentPunish = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (schoolyearID.HasValue)
- {
- expStudentPunish = expStudentPunish.And(x => x.SchoolyearID == schoolyearID);
- }
- if (punishTypeID.HasValue)
- {
- expStudentPunish = expStudentPunish.And(x => x.PunishTypeID == punishTypeID);
- }
- if (punishLevelID.HasValue)
- {
- expStudentPunish = expStudentPunish.And(x => x.PunishLevelID == punishLevelID);
- }
- if (approvalStatus.HasValue)
- {
- expStudentPunish = expStudentPunish.And(x => x.ApprovalStatus == approvalStatus);
- }
- 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));
- }
- }
- var query = StudentPunishDAL.Value.GetStudentPunishViewQueryable(expStudentPunish, expStudent);
- 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.StudentNo.Length).ThenBy(x => x.StudentNo).ThenByDescending(x => x.SchoolyearValue).ToGridResultSet<StudentPunishView>(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="schoolyearID"></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="punishTypeID"></param>
- /// <param name="punishLevelID"></param>
- /// <param name="inSchoolStatus"></param>
- /// <param name="approvalStatus"></param>
- /// <returns></returns>
- public IList<StudentPunishView> GetStudentPunishViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID,
- int? educationID, int? learningformID, string learnSystem, int? punishTypeID, int? punishLevelID, int? inSchoolStatus, int? approvalStatus)
- {
- var approveStatusList = this.GetStatusViewList();
- Expression<Func<EM_StudentPunish, bool>> expStudentPunish = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (schoolyearID.HasValue)
- {
- expStudentPunish = expStudentPunish.And(x => x.SchoolyearID == schoolyearID);
- }
- if (punishTypeID.HasValue)
- {
- expStudentPunish = expStudentPunish.And(x => x.PunishTypeID == punishTypeID);
- }
- if (punishLevelID.HasValue)
- {
- expStudentPunish = expStudentPunish.And(x => x.PunishLevelID == punishLevelID);
- }
- if (approvalStatus.HasValue)
- {
- expStudentPunish = expStudentPunish.And(x => x.ApprovalStatus == approvalStatus);
- }
- 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));
- }
- }
- var query = StudentPunishDAL.Value.GetStudentPunishViewQueryable(expStudentPunish, expStudent);
- 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.StudentNo.Length).ThenBy(x => x.StudentNo).ThenByDescending(x => x.SchoolyearValue).ToList();
- result.ForEach(x => x.ApprovalStatusName = approveStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
- return result;
- }
- /// <summary>
- /// 查询对应的学生处分信息View
- /// </summary>
- /// <param name="studentPunishID"></param>
- /// <returns></returns>
- public StudentPunishView GetStudentPunishView(Guid? studentPunishID)
- {
- try
- {
- var query = StudentPunishDAL.Value.GetStudentPunishViewQueryable(x => x.StudentPunishID == studentPunishID).SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="studentPunishView"></param>
- public void StudentPunishEdit(StudentPunishView studentPunishView)
- {
- try
- {
- var approveStatusList = this.GetStatusViewList();
- if (approveStatusList == null || approveStatusList.Count() <= 0)
- {
- throw new Exception("工作流平台中,学生处分流程未配置,请核查。");
- }
- var startStatusID = this.GetStartStatus();
- if (startStatusID == null)
- {
- throw new Exception("工作流平台中,学生处分流程开始环节未配置,请核查。");
- }
- var studentPunishVerify = StudentPunishDAL.Value.StudentPunishRepository.GetList(x => x.StudentPunishID != studentPunishView.StudentPunishID
- && x.SchoolyearID == studentPunishView.SchoolyearID && x.UserID == studentPunishView.UserID && x.PunishTypeID == studentPunishView.PunishTypeID).SingleOrDefault();
- if (studentPunishVerify == null)
- {
- if (studentPunishView.StudentPunishID != Guid.Empty)
- {
- var studentPunish = StudentPunishDAL.Value.StudentPunishRepository.GetList(x => x.StudentPunishID == studentPunishView.StudentPunishID).SingleOrDefault();
- if (studentPunish == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- else
- {
- //表示修改
- studentPunish.PunishLevelID = studentPunishView.PunishLevelID;
- studentPunish.DocNo = studentPunishView.DocNo;
- studentPunish.PunishDate = studentPunishView.PunishDate;
- studentPunish.Reason = studentPunishView.Reason;
- studentPunish.CancelDocNo = studentPunishView.CancelDocNo;
- studentPunish.CancelDate = studentPunishView.CancelDate;
- SetModifyStatus(studentPunish);
- }
- }
- else
- {
- //表示新增
- var newStudentPunish = new EM_StudentPunish();
- newStudentPunish.StudentPunishID = Guid.NewGuid();
- newStudentPunish.SchoolyearID = studentPunishView.SchoolyearID;
- newStudentPunish.UserID = studentPunishView.UserID;
- newStudentPunish.PunishTypeID = studentPunishView.PunishTypeID;
- newStudentPunish.PunishLevelID = studentPunishView.PunishLevelID;
- newStudentPunish.DocNo = studentPunishView.DocNo;
- newStudentPunish.PunishDate = studentPunishView.PunishDate;
- newStudentPunish.Reason = studentPunishView.Reason;
- newStudentPunish.CancelDocNo = studentPunishView.CancelDocNo;
- newStudentPunish.CancelDate = studentPunishView.CancelDate;
- newStudentPunish.ApprovalStatus = startStatusID;
- SetNewStatus(newStudentPunish);
- UnitOfWork.Add(newStudentPunish);
- }
- }
- else
- {
- throw new Exception("已存在相同的学生处分信息,请核查。");
- }
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="studentPunishIDs"></param>
- /// <returns></returns>
- public bool StudentPunishDelete(List<Guid?> studentPunishIDs)
- {
- try
- {
- var startStatusID = this.GetStartStatus();
- if (startStatusID == null)
- {
- throw new Exception("工作流平台中,学生处分流程开始环节流程未配置,请核查");
- }
- var approvalStatusList = StudentPunishDAL.Value.StudentPunishRepository.GetList(x => studentPunishIDs.Contains(x.StudentPunishID)).Select(x => x.ApprovalStatus).ToList();
- foreach (var approvalStatus in approvalStatusList)
- {
- if (approvalStatus != startStatusID)
- {
- throw new Exception("只能对未提交状态的信息进行删除");
- }
- }
- UnitOfWork.Delete<EM_StudentPunish>(x => studentPunishIDs.Contains(x.StudentPunishID));
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 提交
- /// </summary>
- /// <param name="studentPunishIDs"></param>
- /// <param name="userID"></param>
- /// <param name="comment"></param>
- /// <returns></returns>
- public string StudentPunishSubmit(List<Guid> studentPunishIDs, Guid userID, string comment = "")
- {
- try
- {
- var startStatusID = this.GetStartStatus();
- if (startStatusID == null)
- {
- throw new Exception("工作流平台中,学生处分流程开始环节流程未配置,请核查。");
- }
- var studentPunishList = StudentPunishDAL.Value.StudentPunishRepository.GetList(x => studentPunishIDs.Contains(x.StudentPunishID)).ToList();
- int success = 0;
- string tipMessage = null;
- var submitIDList = new List<Guid>();
- var approveIDList = new List<Guid>();
- foreach (var studentPunish in studentPunishList)
- {
- if (studentPunish.ApprovalStatus == startStatusID)
- {
- submitIDList.Add(studentPunish.StudentPunishID);
- }
- else
- {
- approveIDList.Add(studentPunish.StudentPunishID);
- }
- success++;
- }
- if (submitIDList.Count > 0)
- {
- this.StartUp(submitIDList, userID, comment);
- }
- if (approveIDList.Count > 0)
- {
- this.Approve(approveIDList, userID, Guid.Empty, comment);
- }
- tipMessage = success + "条";
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 审核确定(批量)
- /// </summary>
- /// <param name="studentPunishIDs"></param>
- /// <param name="userID"></param>
- /// <param name="actionID"></param>
- /// <param name="comment"></param>
- public void StudentPunishApproveConfirm(List<Guid?> studentPunishIDs, Guid userID, Guid actionID, string comment)
- {
- try
- {
- var studentPunishList = StudentPunishDAL.Value.StudentPunishRepository.GetList(x => studentPunishIDs.Contains(x.StudentPunishID)).ToList();
- foreach (var studentPunishID in studentPunishIDs)
- {
- var studentPunish = studentPunishList.Where(x => x.StudentPunishID == studentPunishID).SingleOrDefault();
- if (studentPunish == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- }
- this.Approve(studentPunishIDs.Select(x => x.Value).ToList(), userID, actionID, comment);
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 撤销确定(批量)
- /// </summary>
- /// <param name="studentPunishIDs"></param>
- /// <param name="userID"></param>
- /// <param name="comment"></param>
- public void StudentPunishCancelConfirm(List<Guid?> studentPunishIDs, Guid userID, string comment)
- {
- try
- {
- var studentPunishList = StudentPunishDAL.Value.StudentPunishRepository.GetList(x => studentPunishIDs.Contains(x.StudentPunishID)).ToList();
- foreach (var studentPunishID in studentPunishIDs)
- {
- var studentPunish = studentPunishList.Where(x => x.StudentPunishID == studentPunishID).SingleOrDefault();
- if (studentPunish == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- }
- var actionID = this.GetActionView(studentPunishIDs[0].Value, userID).Where(x => (x.Description ?? "").Contains("[CANCEL]")).Select(x => x.ActionID).SingleOrDefault();
- this.Approve(studentPunishIDs.Select(x => x.Value).ToList(), userID, actionID, comment);
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 撤销确定(批量)
- /// </summary>
- /// <param name="studentPunishIDs"></param>
- /// <param name="userID"></param>
- /// <param name="cancelDocNo"></param>
- /// <param name="cancelDate"></param>
- /// <param name="comment"></param>
- public void StudentPunishCancelConfirm(List<Guid?> studentPunishIDs, Guid userID, string cancelDocNo, DateTime? cancelDate, string comment)
- {
- try
- {
- var newStudentPunishUpList = new List<EM_StudentPunish>();
- var studentPunishList = StudentPunishDAL.Value.StudentPunishRepository.GetList(x => studentPunishIDs.Contains(x.StudentPunishID)).ToList();
- foreach (var studentPunishID in studentPunishIDs)
- {
- var studentPunish = studentPunishList.Where(x => x.StudentPunishID == studentPunishID).SingleOrDefault();
- if (studentPunish == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- studentPunish.CancelDocNo = cancelDocNo;
- studentPunish.CancelDate = cancelDate;
- this.SetModifyStatus(studentPunish);
- newStudentPunishUpList.Add(studentPunish);
- }
- var actionID = this.GetActionView(studentPunishIDs[0].Value, userID).Where(x => (x.Description ?? "").Contains("[CANCEL]")).Select(x => x.ActionID).SingleOrDefault();
- using (TransactionScope ts = new TransactionScope())
- {
- this.Approve(studentPunishIDs.Select(x => x.Value).ToList(), userID, actionID, comment);
- this.UnitOfWork.BatchUpdate(newStudentPunishUpList);
- ts.Complete();
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 流程结束跳转函数(工作流平台中配置)
- /// </summary>
- /// <param name="studentPunishIDList"></param>
- /// <param name="userID"></param>
- public void OnApproveEnd(List<Guid> studentPunishIDList, Guid? userID)
- {
- throw new NotImplementedException();
- }
- }
- }
|