123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.GraduationManage.GraduationSetting;
- using EMIS.ViewModel.GraduationManage.GraduationSetting;
- using Bowin.Common.Linq.Entity;
- using Bowin.Common.Linq;
- using EMIS.ViewModel;
- using EMIS.Entities;
- using EMIS.ViewModel.CacheManage;
- using System.Linq.Expressions;
- namespace EMIS.CommonLogic.GraduationManage.GraduationSetting
- {
- public class GraduationConditionPackageServices : BaseServices, IGraduationConditionPackageServices
- {
- public GraduationConditionPackageDAL GraduationConditionPackageDAL { get; set; }
- /// <summary>
- /// 查询对应的毕业公式信息View(只查询毕业公式信息,不查询毕业公式对应的毕业条件)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="isDefault"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<GraduationConditionPackageView> GetGradConditionPackageViewGrid(ConfiguretView configuretView, int? isDefault, int pageIndex, int pageSize)
- {
- //毕业公式
- Expression<Func<ER_GraduationConditionPackage, bool>> exp = (x => true);
- if (isDefault.HasValue)
- {
- if (isDefault == 1)
- {
- exp = exp.And(x => x.IsDefault.Value == true);
- }
- if (isDefault == 0)
- {
- exp = exp.And(x => x.IsDefault.Value != true);
- }
- }
- var query = GraduationConditionPackageDAL.GetGraduationConditionPackageQueryable(exp);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderByDescending(x => x.Title).ThenBy(x => x.IsDefault)
- .ToGridResultSet<GraduationConditionPackageView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的毕业公式信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="isDefault"></param>
- /// <returns></returns>
- public List<GraduationConditionPackageView> GetGradConditionPackageViewList(ConfiguretView configuretView, int? isDefault)
- {
- //毕业公式
- Expression<Func<ER_GraduationConditionPackage, bool>> exp = (x => true);
- if (isDefault.HasValue)
- {
- if (isDefault == 1)
- {
- exp = exp.And(x => x.IsDefault.Value == true);
- }
- if (isDefault == 0)
- {
- exp = exp.And(x => x.IsDefault.Value != true);
- }
- }
- var query = GraduationConditionPackageDAL.GetGraduationConditionPackageQueryable(exp);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderByDescending(x => x.Title).ThenBy(x => x.IsDefault).ToList();
- }
- /// <summary>
- /// 根据毕业公式ID查询对应的毕业公式信息GraduationConditionPackageView
- /// </summary>
- /// <param name="GraduationConditionPackageID"></param>
- /// <returns></returns>
- public GraduationConditionPackageView GetGraduationConditionPackageView(Guid? GraduationConditionPackageID)
- {
- try
- {
- var query = GraduationConditionPackageDAL.GetGraduationConditionPackageQueryable(x => x.GraduationConditionPackageID == GraduationConditionPackageID).SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 根据毕业公式ID查询对应的毕业条件信息List
- /// </summary>
- /// <param name="GraduationConditionPackageID"></param>
- /// <returns></returns>
- public List<GraduationConditionView> GetGraduationConditionList(Guid? GraduationConditionPackageID)
- {
- var query = GraduationConditionPackageDAL.GraduationConditionQueryable(x => x.GraduationConditionPackageID == GraduationConditionPackageID);
- return query.OrderBy(x => x.OrderNo).ToList();
- }
- /// <summary>
- /// 查询毕业公式中未存在的毕业条件信息View
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="graduationConditionPackageID"></param>
- /// <param name="isCurrent"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<GraduationConditionView> GetGraduationConditionNoViewGrid(ConfiguretView configuretView, Guid? graduationConditionPackageID, int? isCurrent, int pageIndex, int pageSize)
- {
- //毕业条件
- Expression<Func<ER_GraduationCondition, bool>> expGraduationCondition = (x => true);
- if (isCurrent.HasValue)
- {
- if (isCurrent == 1)
- {
- expGraduationCondition = expGraduationCondition.And(x => x.RecordStatus >= (int)SYS_STATUS.USABLE);
- }
- if (isCurrent == 0)
- {
- expGraduationCondition = expGraduationCondition.And(x => x.RecordStatus <= (int)SYS_STATUS.UNUSABLE);
- }
- }
- var query = GraduationConditionPackageDAL.GetGraduationConditionNoQueryable(expGraduationCondition, graduationConditionPackageID);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.OrderNo).ToGridResultSet<GraduationConditionView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询毕业公式中未存在的毕业条件信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="graduationConditionPackageID"></param>
- /// <param name="isCurrent"></param>
- /// <returns></returns>
- public IList<GraduationConditionView> GetGraduationConditionNoViewList(ConfiguretView configuretView, Guid? graduationConditionPackageID, int? isCurrent)
- {
- //毕业条件
- Expression<Func<ER_GraduationCondition, bool>> expGraduationCondition = (x => true);
- if (isCurrent.HasValue)
- {
- if (isCurrent == 1)
- {
- expGraduationCondition = expGraduationCondition.And(x => x.RecordStatus >= (int)SYS_STATUS.USABLE);
- }
- if (isCurrent == 0)
- {
- expGraduationCondition = expGraduationCondition.And(x => x.RecordStatus <= (int)SYS_STATUS.UNUSABLE);
- }
- }
- var query = GraduationConditionPackageDAL.GetGraduationConditionNoQueryable(expGraduationCondition, graduationConditionPackageID);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.OrderNo).ToList();
- }
- /// <summary>
- /// 编辑(新增、修改,业务主键:公式名称)
- /// 注:判断是否默认状态(同一种学生类别,只有一种默认公式)
- /// 暂时不考虑当公式被引用时,不可修改公式中条件的情况
- /// </summary>
- /// <param name="graduationConditionPackageView"></param>
- /// <param name="graduationConditionViewList"></param>
- public void GraduationConditionPackageEdit(GraduationConditionPackageView graduationConditionPackageView, IList<GraduationConditionView> graduationConditionViewList)
- {
- try
- {
- var graduationConditionPackageVerification = GraduationConditionPackageDAL.GraduationConditionPackageRepository.GetList(x => x.GraduationConditionPackageID != graduationConditionPackageView.GraduationConditionPackageID && x.Title == graduationConditionPackageView.Title).SingleOrDefault();
- var graduationConditionIDList = graduationConditionViewList.Select(x => x.GraduationConditionID).ToList();
- var graduationConditionList = GraduationConditionPackageDAL.GraduationConditionRepository.GetList(x => graduationConditionIDList.Contains(x.GraduationConditionID)).ToList();
- if (graduationConditionPackageVerification == null)
- {
- //数据有误验证
- if (graduationConditionPackageView.GraduationConditionPackageID != Guid.Empty)
- {
- var graduationConditionPackage = GraduationConditionPackageDAL.GraduationConditionPackageRepository.GetList(x => x.GraduationConditionPackageID == graduationConditionPackageView.GraduationConditionPackageID).SingleOrDefault();
- if (graduationConditionPackage == null)
- {
- throw new Exception("数据有误,请核查");
- }
- else
- {
- //表示修改
- ////注:当毕业申请、毕业审核、毕业名单中有引用相关的毕业公式时,不可对相应的毕业公式进行修改--是否默认列除外
- ////根据毕业公式查询对应的毕业申请、毕业审核、毕业名单信息(外键引用)
- //var graduationApplyList = GraduationConditionPackageDAL.GraduationApplyRepository
- // .GetList(x => x.GraduationConditionPackageID == graduationConditionPackageView.GraduationConditionPackageID).ToList();
- //判断是否默认状态(同一种学生类别,只能启用一种默认公式)
- if (graduationConditionPackageView.IsDefault)
- {
- var graduationConditionPackageList = GraduationConditionPackageDAL.GraduationConditionPackageRepository.GetList(x => x.StudentType == graduationConditionPackageView.StudentTypeID
- && x.IsDefault.Value && x.GraduationConditionPackageID != graduationConditionPackageView.GraduationConditionPackageID).ToList();
- graduationConditionPackageList.ForEach(x => x.IsDefault = false);
- }
- graduationConditionPackage.Title = graduationConditionPackageView.Title;
- graduationConditionPackage.StudentType = graduationConditionPackageView.StudentTypeID;
- graduationConditionPackage.IsDefault = graduationConditionPackageView.IsDefault;
- SetModifyStatus(graduationConditionPackage);
- ////查询毕业公式对应的毕业条件信息
- //var gradPackageConditionList = GraduationConditionPackageDAL
- // .GraduationConditionQueryable(x => x.GraduationConditionPackageID == graduationConditionPackageView.GraduationConditionPackageID)
- // .ToList();
- ////查询毕业公式对应的毕业条件IDList
- //var gradPackageConditionIDList = gradPackageConditionList.Select(x => x.GraduationConditionID).ToList();
-
- ////先删除毕业公式对应的全部毕业条件信息,再对选择的毕业条件进行新增
- //graduationConditionPackage.ER_GraduationCondition
- // .RemoveWhere(x => gradPackageConditionIDList.Contains(x.GraduationConditionID));
- //物理删除(暂时将上述逻辑删除代码注释)
- UnitOfWork.Delete(graduationConditionPackage, (x => x.ER_GraduationCondition));
- //对应的毕业条件
- if (graduationConditionViewList != null && graduationConditionViewList.Count() > 0)
- {
- foreach (var graduationCondition in graduationConditionList)
- {
- graduationConditionPackage.ER_GraduationCondition.Add(graduationCondition);
- }
- }
- }
- }
- else
- {
- //表示新增
- //判断是否默认状态(同一种学生类别,只能启用一种默认公式)
- if (graduationConditionPackageView.IsDefault)
- {
- var graduationConditionPackageList = GraduationConditionPackageDAL
- .GraduationConditionPackageRepository
- .GetList(x => x.StudentType == graduationConditionPackageView.StudentTypeID && x.IsDefault.Value)
- .ToList();
- graduationConditionPackageList.ForEach(x => x.IsDefault = false);
- }
- ER_GraduationConditionPackage graduationConditionPackage = new ER_GraduationConditionPackage();
- graduationConditionPackage.GraduationConditionPackageID = Guid.NewGuid();
- graduationConditionPackage.Title = graduationConditionPackageView.Title;
- graduationConditionPackage.StudentType = graduationConditionPackageView.StudentTypeID;
- graduationConditionPackage.IsDefault = graduationConditionPackageView.IsDefault;
- SetNewStatus(graduationConditionPackage);
- UnitOfWork.Add(graduationConditionPackage);
- //对应的毕业条件
- if (graduationConditionViewList != null && graduationConditionViewList.Count() > 0)
- {
- foreach (var graduationCondition in graduationConditionList)
- {
- graduationConditionPackage.ER_GraduationCondition.Add(graduationCondition);
- }
- }
- }
- //事务提交
- UnitOfWork.Commit();
- }
- else
- {
- throw new Exception("已存在相同的毕业公式,请核查");
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除(当对应的毕业公式被引用时,不可删除--毕业公式、对应的毕业条件)
- /// </summary>
- /// <param name="graduationConditionPackageIDs"></param>
- /// <returns></returns>
- public bool GraduationConditionPackageDelete(List<Guid?> graduationConditionPackageIDs)
- {
- try
- {
- //根据毕业公式查询对应的毕业申请、毕业审核、毕业名单信息(外键引用)
- var graduationApplyList = GraduationConditionPackageDAL.GraduationApplyRepository
- .GetList(x => graduationConditionPackageIDs.Contains(x.GraduationConditionPackageID)).ToList();
- if (graduationApplyList != null && graduationApplyList.Count() > 0)
- {
- throw new Exception("存在与其有关联的数据,如:毕业申请、毕业审核、毕业名单等");
- }
- //查询相应的毕业公式及对应的毕业条件信息List
- var graduationConditionPackageList = GraduationConditionPackageDAL.GraduationConditionPackageRepository
- .GetList(x => graduationConditionPackageIDs.Contains(x.GraduationConditionPackageID), x => x.ER_GraduationCondition)
- .ToList();
- foreach (var graduationConditionPackage in graduationConditionPackageList)
- {
- //物理删除
- UnitOfWork.Delete(graduationConditionPackage, (x => x.ER_GraduationCondition));
- UnitOfWork.Delete<ER_GraduationConditionPackage>(x => x.GraduationConditionPackageID == graduationConditionPackage.GraduationConditionPackageID);
- }
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 根据学生类别查询对应的默认毕业公式信息View(GraduationConditionPackageView)
- /// </summary>
- /// <param name="studentType"></param>
- /// <returns></returns>
- public GraduationConditionPackageView GetGradConditionPackageIsDefaultView(int? studentType)
- {
- try
- {
- //毕业公式
- Expression<Func<ER_GraduationConditionPackage, bool>> exp = (x => true);
- exp = exp.And(x => x.IsDefault.Value == true);
- exp = exp.And(x => x.StudentType == studentType);
- var graduationConditionPackageView = GraduationConditionPackageDAL
- .GetGraduationConditionPackageQueryable(exp).SingleOrDefault();
- return graduationConditionPackageView;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- }
- }
|