123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel;
- using EMIS.ViewModel.MinorGraduation.MinorGraduationSetting;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using Bowin.Common.Linq;
- using EMIS.DataLogic.MinorGraduation.MinorGraduationSetting;
- using EMIS.DataLogic.MinorManage.MinorPlanManage;
- namespace EMIS.CommonLogic.MinorGraduation.MinorGraduationSetting
- {
- public class MinorGraduationStandardServices : BaseServices, IMinorGraduationStandardServices
- {
- public MinorGraduationStandardDAL minorGraduationStandardDAL { get; set; }
- public MinorSpecialtyDAL minorSpecialtyDAL { get; set; }
- /// <summary>
- /// 辅修毕业要求列表信息
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="collegeID"></param>
- /// <param name="yearID"></param>
- /// <param name="standardID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<MinorGraduationStandardView> GetMinorGraduationStandardViewGrid(ConfiguretView configuretView, Guid? collegeID, int? yearID, int? standardID, int pageIndex, int pageSize)
- {
- Expression<Func<ER_MinorGraduationStandard, bool>> exp = x => true;
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- exp = exp.And(x => x.YearID == yearID);
- }
- if (standardID.HasValue)
- {
- exp = exp.And(x => x.StandardID == standardID);
- }
- var query = minorGraduationStandardDAL.GetMinorGraduationStandardView(exp);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query)
- .OrderByDescending(x => x.YearID).OrderBy(x => x.StandardID)
- .ToGridResultSet<MinorGraduationStandardView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 辅修毕业要求列表信息(Excel)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="collegeID"></param>
- /// <param name="yearID"></param>
- /// <param name="standardID"></param>
- /// <param name="idList"></param>
- /// <returns></returns>
- public List<MinorGraduationStandardView> GetMinorGraduationStandardViewList(ConfiguretView configuretView, Guid? collegeID, int? yearID, int? standardID, List<Guid?> idList)
- {
- Expression<Func<ER_MinorGraduationStandard, bool>> exp = x => true;
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- exp = exp.And(x => x.YearID == yearID);
- }
- if (standardID.HasValue)
- {
- exp = exp.And(x => x.StandardID == standardID);
- }
- if (idList != null && idList.Count > 0)
- {
- exp = exp.And(x => idList.Contains(x.MinorGraduationStandardID));
- }
- var query = minorGraduationStandardDAL.GetMinorGraduationStandardView(exp);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.YearID).OrderBy(x => x.StandardID).ToList();
- }
- /// <summary>
- /// 查询单个辅修毕业要求
- /// </summary>
- /// <param name="GraduationStandardID"></param>
- /// <returns></returns>
- public MinorGraduationStandardView GetMinorGraduationStandardView(Guid? minorGraduationStandardID)
- {
- try
- {
- var query = minorGraduationStandardDAL.GetMinorGraduationStandardView(x => x.MinorGraduationStandardID == minorGraduationStandardID)
- .SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 生成
- /// </summary>
- /// <param name="yearID"></param>
- public void MinorGraduationStandardGenerate(int? yearID, Guid? collegeID)
- {
- try
- {
- Expression<Func<CF_Grademinor, bool>> exp = x => true;
- exp = exp.And(x => x.RecordStatus == (int)CF_GrademinorStatus.Opened || x.RecordStatus == (int)CF_GrademinorStatus.Confirmed);
- if (yearID.HasValue)
- {
- exp = exp.And(x => x.YearID == yearID);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CollegeID == collegeID);
- }
- var grademinorList = minorSpecialtyDAL.GetMinorSpecialtyViewQueryable(exp).ToList();
- List<ER_MinorGraduationStandard> minorGraduationStandardList = new List<ER_MinorGraduationStandard>();
- var dbminorGraduationStandardList = minorGraduationStandardDAL.GetMinorGraduationStandardView(x => true).ToList();
- foreach (var grademinor in grademinorList)
- {
- if (dbminorGraduationStandardList.Any(x => x.CollegeID == grademinor.CollegeID && x.YearID == grademinor.YearID && x.StandardID == grademinor.StandardID))
- {
- continue;
- }
- ER_MinorGraduationStandard minorGraduationStandard = new ER_MinorGraduationStandard();
- minorGraduationStandard.MinorGraduationStandardID = Guid.NewGuid();
- minorGraduationStandard.CollegeID = grademinor.CollegeID;
- minorGraduationStandard.YearID = grademinor.YearID;
- minorGraduationStandard.StandardID = grademinor.StandardID;
- minorGraduationStandard.GraduationCredit = 0;
- SetNewStatus(minorGraduationStandard);
- minorGraduationStandardList.Add(minorGraduationStandard);
- }
- UnitOfWork.BulkInsert(minorGraduationStandardList);
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 编辑(新增、修改,业务主键:年级专业ID)
- /// </summary>
- /// <param name="graduationStandardView"></param>
- public void MinorGraduationStandardEdit(MinorGraduationStandardView minorGraduationStandardView)
- {
- try
- {
- //查询数据库进行验证
- var minorGraduationStandardVerification = minorGraduationStandardDAL.minorGraduationStandardRepository
- .GetList(x => x.MinorGraduationStandardID != minorGraduationStandardView.MinorGraduationStandardID
- && x.StandardID == minorGraduationStandardView.StandardID && x.YearID == minorGraduationStandardView.YearID)
- .SingleOrDefault();
- if (minorGraduationStandardVerification == null)
- {
- //数据有误验证
- if (minorGraduationStandardView.MinorGraduationStandardID != Guid.Empty)
- {
- var minorGraduationStandard = minorGraduationStandardDAL.minorGraduationStandardRepository
- .GetList(x => x.MinorGraduationStandardID == minorGraduationStandardView.MinorGraduationStandardID)
- .SingleOrDefault();
- if (minorGraduationStandard == null)
- {
- throw new Exception("数据有误,请核查");
- }
- else
- {
- //表示修改
- minorGraduationStandard.GraduationCredit = minorGraduationStandardView.GraduationCredit;
- SetModifyStatus(minorGraduationStandard);
- }
- }
- else
- {
- //表示新增
- ER_MinorGraduationStandard minorGraduationStandard = new ER_MinorGraduationStandard();
- minorGraduationStandard.MinorGraduationStandardID = Guid.NewGuid();
- minorGraduationStandard.CollegeID = minorGraduationStandardView.CollegeID;
- minorGraduationStandard.YearID = minorGraduationStandardView.YearID;
- minorGraduationStandard.StandardID = minorGraduationStandardView.StandardID;
- minorGraduationStandard.GraduationCredit = minorGraduationStandardView.GraduationCredit;
- SetNewStatus(minorGraduationStandard);
- UnitOfWork.Add(minorGraduationStandard);
- }
- }
- else
- {
- throw new Exception("已存在相同的辅修毕业标准,请核查");
- }
- //事务提交
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="graduationStandardIDs"></param>
- /// <returns></returns>
- public void MinorGraduationStandardDelete(List<Guid?> minorGraduationStandardIDs)
- {
- try
- {
- UnitOfWork.Delete<ER_MinorGraduationStandard>(x => minorGraduationStandardIDs.Contains(x.MinorGraduationStandardID));
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- }
- }
|