123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using Bowin.Common.Utility;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.EnrollManage.SpecialtyManage;
- using EMIS.DataLogic.EnrollManage.SpecialtyManage;
- namespace EMIS.CommonLogic.EnrollManage.SpecialtyManage
- {
- public class SpecialtyClassSettingServices : BaseServices, ISpecialtyClassSettingServices
- {
- public SpecialtyClassSettingDAL SpecialtyClassSettingDAL { get; set; }
- /// <summary>
- /// 查询对应的专业分班信息View
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<SpecialtyClassSettingView> GetSpecialtyClassSettingViewGrid(ConfiguretView configuretView, int? standardID, int? educationID, int? learningformID, string learnSystem, int pageIndex, int pageSize)
- {
- //专业分班
- Expression<Func<CF_SpecialtyClassSetting, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = SpecialtyClassSettingDAL.GetSpecialtyClassSettingViewQueryable(exp);
- if (standardID.HasValue)
- {
- //专业ID(Value)
- 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());
- }
- return query.OrderBy(x => x.StandardName).ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem).ToGridResultSet<SpecialtyClassSettingView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的专业分班信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <returns></returns>
- public IList<SpecialtyClassSettingView> GetSpecialtyClassSettingViewList(ConfiguretView configuretView, int? standardID, int? educationID, int? learningformID, string learnSystem)
- {
- //专业分班
- Expression<Func<CF_SpecialtyClassSetting, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = SpecialtyClassSettingDAL.GetSpecialtyClassSettingViewQueryable(exp);
- if (standardID.HasValue)
- {
- //专业ID(Value)
- 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());
- }
- return query.OrderBy(x => x.StandardName).ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem).ToList();
- }
- /// <summary>
- /// 根据专业分班ID查询对应的专业分班信息SpecialtyClassSettingView
- /// </summary>
- /// <param name="specialtyClassSettingID"></param>
- /// <returns></returns>
- public SpecialtyClassSettingView GetSpecialtyClassSettingView(Guid? specialtyClassSettingID)
- {
- try
- {
- var query = SpecialtyClassSettingDAL.GetSpecialtyClassSettingViewQueryable(x => x.SpecialtyClassSettingID == specialtyClassSettingID).SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 专业分班批量新增(业务主键:专业信息ID)
- /// </summary>
- /// <param name="specialtyIDList"></param>
- /// <param name="specialtyClassSettingView"></param>
- /// <returns></returns>
- public string SpecialtyClassSettingBatchAdd(List<Guid?> specialtyIDList, SpecialtyClassSettingView specialtyClassSettingView)
- {
- try
- {
- //专业分班
- Expression<Func<CF_SpecialtyClassSetting, bool>> expSpecialtyClassSetting = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expSpecialtyClassSetting = expSpecialtyClassSetting.And(x => specialtyIDList.Contains(x.SpecialtyID));
- //查询对应的专业分班信息List
- var specialtyClassSettingList = SpecialtyClassSettingDAL.SpecialtyClassSettingRepository.GetList(expSpecialtyClassSetting).ToList();
- int success = 0; //成功
- int fail = 0; //失败
- string tipMessage = null; //提示消息
- List<CF_SpecialtyClassSetting> specialtyClassSettingInList = new List<CF_SpecialtyClassSetting>();
- foreach (var specialtyID in specialtyIDList)
- {
- var specialtyClassSettingVerify = specialtyClassSettingList.Where(x => x.SpecialtyID == specialtyID).SingleOrDefault();
- if (specialtyClassSettingVerify == null)
- {
- //新增
- var specialtyClassSetting = new CF_SpecialtyClassSetting();
- specialtyClassSetting.SpecialtyClassSettingID = Guid.NewGuid();
- specialtyClassSetting.SpecialtyID = specialtyID;
- specialtyClassSetting.PlanRecruitStudentCount = 0;
- specialtyClassSetting.ClassArrangeStudentCount = 0;
- specialtyClassSetting.ClassMaxStudentCount = 0;
- specialtyClassSetting.ClassNumber = 1;
- SetNewStatus(specialtyClassSetting);
- specialtyClassSettingInList.Add(specialtyClassSetting);
- success++;
- }
- else
- {
- //表示已存在相同的专业分班信息
- fail++;
- }
- }
- //批量插入
- UnitOfWork.BulkInsert<CF_SpecialtyClassSetting>(specialtyClassSettingInList);
- if (success > 0 && fail <= 0)
- {
- tipMessage = success + "条";
- }
- else
- {
- tipMessage = success + "条," + fail + "条失败,原因:已存在相同的专业分班信息,请检查";
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询专业分班中未新增的专业信息SpecialtyView
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="scienceclassID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<SpecialtyView> GetSpecialtyViewNoAdd(ConfiguretView configuretView, int? standardID, int? educationID, int? learningformID, string learnSystem, int? scienceclassID, int pageIndex, int pageSize)
- {
- //专业信息(只查询启用状态的专业信息)
- Expression<Func<CF_Specialty, bool>> expSpecialty = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (standardID.HasValue)
- {
- expSpecialty = expSpecialty.And(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- expSpecialty = expSpecialty.And(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- expSpecialty = expSpecialty.And(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(learnSystem);
- expSpecialty = expSpecialty.And(x => x.LearnSystem == LearnSystems);
- }
- if (scienceclassID.HasValue)
- {
- expSpecialty = expSpecialty.And(x => x.ScienceclassID == scienceclassID);
- }
- //专业分班
- Expression<Func<CF_SpecialtyClassSetting, bool>> expSpecialtyClassSetting = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = SpecialtyClassSettingDAL.GetSpecialtyViewNoAddQueryable(expSpecialty, expSpecialtyClassSetting);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.StandardName).ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem).ToGridResultSet<SpecialtyView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 编辑(新增、修改,业务主键:专业信息ID)
- /// </summary>
- /// <param name="specialtyClassSettingView"></param>
- public void SpecialtyClassSettingEdit(SpecialtyClassSettingView specialtyClassSettingView)
- {
- try
- {
- //查询数据库进行验证
- var specialtyClassSettingVerification = SpecialtyClassSettingDAL.SpecialtyClassSettingRepository.GetList(x => x.SpecialtyClassSettingID != specialtyClassSettingView.SpecialtyClassSettingID
- && x.SpecialtyID == specialtyClassSettingView.SpecialtyID).SingleOrDefault();
- if (specialtyClassSettingVerification == null)
- {
- //数据有误验证
- if (specialtyClassSettingView.SpecialtyClassSettingID != Guid.Empty)
- {
- var specialtyClassSetting = SpecialtyClassSettingDAL.SpecialtyClassSettingRepository
- .GetList(x => x.SpecialtyClassSettingID == specialtyClassSettingView.SpecialtyClassSettingID).SingleOrDefault();
- if (specialtyClassSetting == null)
- {
- throw new Exception("数据有误,请核查");
- }
- else
- {
- //表示修改
- specialtyClassSetting.SpecialtyID = specialtyClassSettingView.SpecialtyID;
- specialtyClassSetting.PlanRecruitStudentCount = specialtyClassSettingView.PlanRecruitStudentCount;
- specialtyClassSetting.ClassArrangeStudentCount = specialtyClassSettingView.ClassArrangeStudentCount;
- specialtyClassSetting.ClassMaxStudentCount = specialtyClassSettingView.ClassMaxStudentCount;
- specialtyClassSetting.ClassNumber = specialtyClassSettingView.ClassNumber;
- SetModifyStatus(specialtyClassSetting);
- }
- }
- else
- {
- //表示新增
- CF_SpecialtyClassSetting specialtyClassSetting = new CF_SpecialtyClassSetting();
- specialtyClassSetting.SpecialtyClassSettingID = Guid.NewGuid();
- specialtyClassSetting.SpecialtyID = specialtyClassSettingView.SpecialtyID;
- specialtyClassSetting.PlanRecruitStudentCount = specialtyClassSettingView.PlanRecruitStudentCount;
- specialtyClassSetting.ClassArrangeStudentCount = specialtyClassSettingView.ClassArrangeStudentCount;
- specialtyClassSetting.ClassMaxStudentCount = specialtyClassSettingView.ClassMaxStudentCount;
- specialtyClassSetting.ClassNumber = specialtyClassSettingView.ClassNumber;
- SetNewStatus(specialtyClassSetting);
- UnitOfWork.Add(specialtyClassSetting);
- }
- }
- else
- {
- throw new Exception("已存在相同的专业分班信息,请核查");
- }
- //事务提交
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 批量修改(计划招生人数、每班预招人数、每班最大人数)
- /// </summary>
- /// <param name="specialtyClassSettingIDList"></param>
- /// <param name="planRecruitStudentCount"></param>
- /// <param name="classArrangeStudentCount"></param>
- /// <param name="classMaxStudentCount"></param>
- /// <returns></returns>
- public string BatchModify(List<Guid?> specialtyClassSettingIDList, int? planRecruitStudentCount, int? classArrangeStudentCount, int? classMaxStudentCount)
- {
- try
- {
- //查询对应的专业分班信息
- var specialtyClassSettingList = SpecialtyClassSettingDAL.SpecialtyClassSettingRepository.GetList(x => specialtyClassSettingIDList.Contains(x.SpecialtyClassSettingID)).ToList();
- int fail = 0;
- int success = 0;
- string tipMessage = null; //提示消息
- List<CF_SpecialtyClassSetting> specialtyClassSettingUpList = new List<CF_SpecialtyClassSetting>();
- foreach (var specialtyClassSetting in specialtyClassSettingList)
- {
- if (planRecruitStudentCount != null)
- {
- if (specialtyClassSetting.ClassArrangeStudentCount > specialtyClassSetting.ClassMaxStudentCount)
- {
- fail++;
- continue;
- }
- else if (planRecruitStudentCount <= 0)
- {
- specialtyClassSetting.PlanRecruitStudentCount = planRecruitStudentCount;
- specialtyClassSetting.ClassNumber = 1;
- }
- else if (specialtyClassSetting.ClassArrangeStudentCount <= 0)
- {
- specialtyClassSetting.PlanRecruitStudentCount = planRecruitStudentCount;
- specialtyClassSetting.ClassNumber = 1;
- }
- else if (specialtyClassSetting.ClassMaxStudentCount <= 0)
- {
- specialtyClassSetting.PlanRecruitStudentCount = planRecruitStudentCount;
- specialtyClassSetting.ClassNumber = 1;
- }
- else
- {
- specialtyClassSetting.PlanRecruitStudentCount = planRecruitStudentCount;
- var classNumber = planRecruitStudentCount.Value / specialtyClassSetting.ClassArrangeStudentCount.Value;
- var total = classNumber * specialtyClassSetting.ClassMaxStudentCount;
- if (total >= planRecruitStudentCount)
- {
- specialtyClassSetting.ClassNumber = classNumber;
- }
- else
- {
- specialtyClassSetting.ClassNumber = classNumber + 1;
- }
- }
- SetModifyStatus(specialtyClassSetting);
- }
- if (classArrangeStudentCount != null)
- {
- if (classArrangeStudentCount > specialtyClassSetting.ClassMaxStudentCount)
- {
- fail++;
- continue;
- }
- else if (classArrangeStudentCount <= 0)
- {
- specialtyClassSetting.ClassArrangeStudentCount = classArrangeStudentCount;
- specialtyClassSetting.ClassNumber = 1;
- }
- else if (specialtyClassSetting.PlanRecruitStudentCount <= 0)
- {
- specialtyClassSetting.ClassArrangeStudentCount = classArrangeStudentCount;
- specialtyClassSetting.ClassNumber = 1;
- }
- else if (specialtyClassSetting.ClassMaxStudentCount <= 0)
- {
- specialtyClassSetting.ClassArrangeStudentCount = classArrangeStudentCount;
- specialtyClassSetting.ClassNumber = 1;
- }
- else
- {
- specialtyClassSetting.ClassArrangeStudentCount = classArrangeStudentCount;
- var classNumber = specialtyClassSetting.PlanRecruitStudentCount.Value / classArrangeStudentCount.Value;
- var total = classNumber * specialtyClassSetting.ClassMaxStudentCount;
- if (total >= specialtyClassSetting.PlanRecruitStudentCount)
- {
- specialtyClassSetting.ClassNumber = classNumber;
- }
- else
- {
- specialtyClassSetting.ClassNumber = classNumber + 1;
- }
- }
- SetModifyStatus(specialtyClassSetting);
- }
- if (classMaxStudentCount != null)
- {
- if (specialtyClassSetting.ClassArrangeStudentCount > classMaxStudentCount)
- {
- fail++;
- continue;
- }
- else if (classMaxStudentCount <= 0)
- {
- specialtyClassSetting.ClassMaxStudentCount = classMaxStudentCount;
- specialtyClassSetting.ClassNumber = 1;
- }
- else if (specialtyClassSetting.PlanRecruitStudentCount <= 0)
- {
- specialtyClassSetting.ClassMaxStudentCount = classMaxStudentCount;
- specialtyClassSetting.ClassNumber = 1;
- }
- else if (specialtyClassSetting.ClassArrangeStudentCount <= 0)
- {
- specialtyClassSetting.ClassMaxStudentCount = classMaxStudentCount;
- specialtyClassSetting.ClassNumber = 1;
- }
- else
- {
- specialtyClassSetting.ClassMaxStudentCount = classMaxStudentCount;
- var classNumber = specialtyClassSetting.PlanRecruitStudentCount.Value / specialtyClassSetting.ClassArrangeStudentCount.Value;
- var total = classNumber * classMaxStudentCount;
- if (total >= specialtyClassSetting.PlanRecruitStudentCount)
- {
- specialtyClassSetting.ClassNumber = classNumber;
- }
- else
- {
- specialtyClassSetting.ClassNumber = classNumber + 1;
- }
- }
- SetModifyStatus(specialtyClassSetting);
- }
- specialtyClassSettingUpList.Add(specialtyClassSetting);
- success++;
- }
- //批量统一提交更新
- if (specialtyClassSettingUpList != null && specialtyClassSettingUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(specialtyClassSettingUpList);
- }
- if (success > 0 && fail <= 0)
- {
- tipMessage = success + "条";
- }
- else
- {
- tipMessage = success + "条," + fail + "条失败,原因:每班预招人数不能大于每班最大人数";
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="specialtyClassSettingIDList"></param>
- /// <returns></returns>
- public bool SpecialtyClassSettingDelete(List<Guid?> specialtyClassSettingIDList)
- {
- try
- {
- UnitOfWork.Delete<CF_SpecialtyClassSetting>(x => specialtyClassSettingIDList.Contains(x.SpecialtyClassSettingID));
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|