123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392 |
- 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.WorkflowManage;
- using EMIS.ViewModel.CultureplanManage.PlanManagement;
- using EMIS.DataLogic.CultureplanManage.PlanManagement;
- using EMIS.CommonLogic.SystemServices;
- namespace EMIS.CommonLogic.CultureplanManage.PlanManagement
- {
- public class PlanApplicationApproveServices : BaseWorkflowServices<EM_PlanApplication>, IPlanApplicationApproveServices
- {
- public PlanApplicationDAL PlanApplicationDAL { get; set; }
- /// <summary>
- /// 查询对应的计划审核信息PlanApplicationView
- /// 注:普教版本(年级专业)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="schoolyearID"></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="grademajorID"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="handleModeID"></param>
- /// <param name="approvalStatus"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<PlanApplicationView> GetPlanApplicationApproveViewGrid(ConfiguretView configuretView, Guid? schoolyearID,
- Guid? campusID, Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
- Guid? grademajorID, Guid? coursematerialID, int? handleModeID, int? approvalStatus, int pageIndex, int pageSize)
- {
- var approveStatusList = this.GetApproveStatusViewList();
- var approveStatusIDList = approveStatusList.Select(x => x.ID).ToList();
- //计划申请
- Expression<Func<EM_PlanApplication, bool>> expPlanApplication = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expPlanApplication = expPlanApplication.And(x => approveStatusIDList.Contains(x.RecordStatus));
- if (schoolyearID.HasValue)
- {
- expPlanApplication = expPlanApplication.And(x => x.SchoolyearID == schoolyearID);
- }
- if (grademajorID.HasValue)
- {
- expPlanApplication = expPlanApplication.And(x => x.GrademajorID == grademajorID);
- }
- if (coursematerialID.HasValue)
- {
- expPlanApplication = expPlanApplication.And(x => x.CoursematerialID == coursematerialID);
- }
- if (handleModeID.HasValue)
- {
- expPlanApplication = expPlanApplication.And(x => x.HandleModeID == handleModeID);
- }
- if (approvalStatus.HasValue)
- {
- expPlanApplication = expPlanApplication.And(x => x.RecordStatus == approvalStatus);
- }
- var query = PlanApplicationDAL.GetPlanApplicationViewQueryable(expPlanApplication);
- 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.GradeID == 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 (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- var result = this.GetQueryByDataRangeByCollege(query)
- .OrderBy(x => x.GrademajorCode.Length).ThenBy(x => x.GrademajorCode)
- .ThenBy(x => x.Value).ThenBy(x => x.CourseTypeID)
- .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
- .ThenByDescending(x => x.CreateTime).ToGridResultSet<PlanApplicationView>(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="yearID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="grademajorID"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="handleModeID"></param>
- /// <param name="approvalStatus"></param>
- /// <returns></returns>
- public IList<PlanApplicationView> GetPlanApplicationApproveViewList(ConfiguretView configuretView, Guid? schoolyearID,
- Guid? campusID, Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
- Guid? grademajorID, Guid? coursematerialID, int? handleModeID, int? approvalStatus)
- {
- var approveStatusList = this.GetApproveStatusViewList();
- var approveStatusIDList = approveStatusList.Select(x => x.ID).ToList();
- //计划申请
- Expression<Func<EM_PlanApplication, bool>> expPlanApplication = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expPlanApplication = expPlanApplication.And(x => approveStatusIDList.Contains(x.RecordStatus));
- if (schoolyearID.HasValue)
- {
- expPlanApplication = expPlanApplication.And(x => x.SchoolyearID == schoolyearID);
- }
- if (grademajorID.HasValue)
- {
- expPlanApplication = expPlanApplication.And(x => x.GrademajorID == grademajorID);
- }
- if (coursematerialID.HasValue)
- {
- expPlanApplication = expPlanApplication.And(x => x.CoursematerialID == coursematerialID);
- }
- if (handleModeID.HasValue)
- {
- expPlanApplication = expPlanApplication.And(x => x.HandleModeID == handleModeID);
- }
- if (approvalStatus.HasValue)
- {
- expPlanApplication = expPlanApplication.And(x => x.RecordStatus == approvalStatus);
- }
- var query = PlanApplicationDAL.GetPlanApplicationViewQueryable(expPlanApplication);
- 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.GradeID == 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 (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- var result = this.GetQueryByDataRangeByCollege(query)
- .OrderBy(x => x.GrademajorCode.Length).ThenBy(x => x.GrademajorCode)
- .ThenBy(x => x.Value).ThenBy(x => x.CourseTypeID)
- .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
- .ThenByDescending(x => x.CreateTime).ToList();
- result.ForEach(x => x.ApprovalStatusName = approveStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
- return result;
- }
- /// <summary>
- /// 查询对应的计划审核信息PlanApplicationView(根据计划申请ID)
- /// </summary>
- /// <param name="planApplicationID"></param>
- /// <returns></returns>
- public PlanApplicationView GetPlanApplicationApproveView(Guid? planApplicationID)
- {
- try
- {
- var planApplicationView = PlanApplicationDAL.GetPlanApplicationViewQueryable(x => x.PlanApplicationID == planApplicationID).SingleOrDefault();
- return planApplicationView;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// </summary>
- /// <param name="planApplicationView"></param>
- public void PlanApplicationApproveEdit(PlanApplicationView planApplicationView)
- {
- throw new NotImplementedException();
- }
- /// <summary>
- /// 查询对应的流程环节动作List(ActionView)
- /// </summary>
- /// <param name="formID"></param>
- /// <param name="userID"></param>
- /// <returns></returns>
- public List<ActionView> GetApproveActionView(Guid formID, Guid userID)
- {
- try
- {
- List<ActionView> listAction = this.GetActionView(formID, userID);
- return listAction;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="planApplicationIDs"></param>
- /// <returns></returns>
- public bool PlanApplicationApproveDelete(List<Guid?> planApplicationIDs)
- {
- try
- {
- using (TransactionScope ts = new TransactionScope())
- {
- UnitOfWork.Delete<EM_PlanApplicationTeachingPlace>(x => planApplicationIDs.Contains(x.PlanApplicationID));
- UnitOfWork.Delete<EM_PlanApplicationTeachingModeType>(x => planApplicationIDs.Contains(x.PlanApplicationID));
- UnitOfWork.Delete<EM_PlanApplicationTeachingSetting>(x => planApplicationIDs.Contains(x.PlanApplicationID));
- UnitOfWork.Delete<EM_PlanApplication>(x => planApplicationIDs.Contains(x.PlanApplicationID));
- ts.Complete();
- return true;
- }
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 审核确定(批量)
- /// </summary>
- /// <param name="planApplicationIDs"></param>
- /// <param name="userID"></param>
- /// <param name="actionID"></param>
- /// <param name="comment"></param>
- /// <returns></returns>
- public string PlanApplicationApproveConfirm(List<Guid?> planApplicationIDs, Guid userID, Guid actionID, string comment)
- {
- try
- {
- //查询对应的工作流程环节状态信息View
- var approveStatusList = this.GetStatusViewList();
- if (approveStatusList == null || approveStatusList.Count() <= 0)
- {
- throw new Exception("工作流平台中,专业计划流程未配置,请核查。");
- }
- //查询工作流程结束环节状态
- var endStatusID = this.GetCorrectEndStatus();
- if (endStatusID == null)
- {
- throw new Exception("工作流平台中,专业计划流程结束环节未配置,请核查。");
- }
- //查询对应的计划申请信息List
- var planApplicationList = PlanApplicationDAL.PlanApplicationRepository
- .GetList(x => planApplicationIDs.Contains(x.PlanApplicationID), (x => x.EM_PlanApplicationTeachingSetting)).ToList();
- //计划申请信息对应的grademajorIDList
- var grademajorIDList = planApplicationList.Where(x => !string.IsNullOrEmpty(x.GrademajorID.ToString()))
- .Select(x => x.GrademajorID).ToList();
- //查询对应的专业计划信息
- var specialtyPlanList = PlanApplicationDAL.SpecialtyPlanRepository
- .GetList(x => grademajorIDList.Contains(x.GrademajorID), (x => x.EM_SpecialtyPlanTeachingSetting)).ToList();
- int success = 0; //成功
- int fail = 0; //失败
- string tipMessage = null; //提示消息
- var approveIDList = new List<Guid>();
- foreach (var planApplication in planApplicationList)
- {
- //查询对应的计划审核信息(业务主键:学年学期ID、年级专业ID、课程信息ID)
- var specialtyPlan = specialtyPlanList.Where(x => x.SchoolyearID == planApplication.SchoolyearID
- && x.GrademajorID == planApplication.GrademajorID
- && x.CoursematerialID == planApplication.CoursematerialID).SingleOrDefault();
- if (specialtyPlan == null)
- {
- approveIDList.Add(planApplication.PlanApplicationID);
- success++;
- }
- else
- {
- fail++;
- }
- }
- if (approveIDList.Count > 0)
- {
- //审核
- this.Approve(approveIDList, userID, actionID, comment);
- }
- if (success > 0 && fail <= 0)
- {
- tipMessage = success + "条";
- }
- else
- {
- tipMessage = success + "条," + fail + "条失败,原因:已存在相同的专业计划信息,请检查。";
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询计划审核对应的授课方式List
- /// </summary>
- /// <param name="planApplicationID"></param>
- /// <returns></returns>
- public List<string> GetTeachingModeTypeList(Guid? planApplicationID)
- {
- //计划申请
- Expression<Func<EM_PlanApplication, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.PlanApplicationID == planApplicationID);
- var query = PlanApplicationDAL.GetTeachingModeTypeQueryble(exp);
- return query.OrderBy(x => x.Value).Select(x => x.ToString()).ToList();
- }
- /// <summary>
- /// 查询计划审核对应的授课地点List
- /// </summary>
- /// <param name="planApplicationID"></param>
- /// <returns></returns>
- public List<string> GetTeachingPlaceList(Guid? planApplicationID)
- {
- //计划申请
- Expression<Func<EM_PlanApplication, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.PlanApplicationID == planApplicationID);
- var query = PlanApplicationDAL.GetTeachingPlaceQueryble(exp);
- return query.OrderBy(x => x.Value).Select(x => x.ToString()).ToList();
- }
- }
- }
|