123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.Entities;
- using System.Configuration;
- using EMIS.ViewModel;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.SystemView;
- using EMIS.DataLogic.Common.TeachingMaterial;
- using EMIS.ViewModel.TeachingMaterial;
- using EMIS.CommonLogic;
- using EMIS.DataLogic.Repositories;
- using Bowin.Common.Linq;
- using System.Linq.Expressions;
- namespace EMIS.CommonLogic.TeachingMaterial
- {
- public class TeachersConfirmOrderServices : BaseServices, ITeachersConfirmOrderServices
- {
- #region 0.0 --定义--
- public TeachersOrderRepository TeachersOrderRepository { get; set; }
- public TeachersConfirmOrderRepository TeachersConfirmOrderRepository { get; set; }
- public TeachingMaterialPoolRepository TeachingMaterialPoolRepository { get; set; }
- public TeachersPreOrderRepository TeachersPreOrderRepository { get; set; }
- public UserRepository UserRepository { get; set; }
- public CoursematerialRepository CoursematerialRepository { get; set; }
- public PublishRepository PublishRepository { get; set; }
- public SchoolyearRepository SchoolyearRepository { get; set; }
- public CollegeRepository CollegeRepository { get; set; }
- public DictionaryItemRepository DictionaryItemRepository { get; set; }
- public TeachersConfirmOrderDAL TeachersConfirmOrderDAL { get; set; }
- public Lazy<ITeachersOrderServices> TeachersOrderServices { get; set; }
- #endregion
- #region 1.0 查询教师征订清单信息
- /// <summary>
- /// 查询教师征订清单记录绑定页面
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="approvalStatus"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<TeachersConfirmOrderView> GetTeachersOrderViewGrid(ViewModel.ConfiguretView configuretView, Guid? schoolyearID,
- Guid? teachingMaterialPoolID, Guid? coursematerialID, Guid? publishID, int? ApprovalStatus, int pageIndex, int pageSize)
- {
- ApprovalStatus = TeachersOrderServices.Value.GetCorrectEndStatus();//提取已通过
- Expression<Func<ET_TeachersOrder, bool>> exp = (x => x.ApprovalStatus == ApprovalStatus);
- if (schoolyearID.HasValue)
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- if (teachingMaterialPoolID.HasValue)
- exp = exp.And(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
- if (coursematerialID.HasValue)
- exp = exp.And(x => x.CF_TeachingMaterialPool.EM_Coursematerial.Any(w => w.CoursematerialID == coursematerialID));
- if (publishID.HasValue)
- exp = exp.And(x => x.CF_TeachingMaterialPool.PublishID == publishID);
- var query = TeachersConfirmOrderDAL.GetTeachersConfirmOrderGridView(exp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ThenBy(x => x.SchoolyearName).ToGridResultSet<TeachersConfirmOrderView>(pageIndex, pageSize);
- return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ThenBy(x => x.SchoolyearName).ToGridResultSet<TeachersConfirmOrderView>(pageIndex, pageSize);
- }
- #endregion
- #region 2.0 查询教师征订清单明细信息
- /// <summary>
- /// 查询教师征订清单征订明细页面
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="approvalStatus"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<TeachersConfirmOrderView> GetTeachersOrderDetailViewGrid(Guid? schoolyearID,
- Guid? collegeID, Guid? teachingMaterialPoolID, int pageIndex, int pageSize)
- {
- var endStatus = TeachersOrderServices.Value.GetCorrectEndStatus();
- var query = TeachersConfirmOrderDAL.GetTeachingOrderDetail(x => x.ApprovalStatus == endStatus);
- if (schoolyearID.HasValue)
- query = query.Where(x => x.SchoolyearID == schoolyearID);
- //if (collegeID.HasValue)
- // query = query.Where(x => x.CollegeID == collegeID);
- if (teachingMaterialPoolID.HasValue)
- query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
- return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.PublishTime).ToGridResultSet<TeachersConfirmOrderView>(pageIndex, pageSize);
- }
- #endregion
- #region 3.0 查询教师征订清单Excel导出
- /// <summary>
- /// 获取征订清单列表导出
- /// </summary>
- /// <param name="exp"></param>
- /// <returns></returns>
- public IList<TeachersConfirmOrderView> GetTeachersConfirmOrderViewExcel(ConfiguretView configuretView, Guid? schoolyearID,
- Guid? teachingMaterialPoolID, Guid? coursematerialID, Guid? publishID)
- {
- int? ApprovalStatus = TeachersOrderServices.Value.GetCorrectEndStatus();//提取已通过
- Expression<Func<ET_TeachersOrder, bool>> exp = (x => x.ApprovalStatus == ApprovalStatus);
- if (schoolyearID.HasValue)
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- if (teachingMaterialPoolID.HasValue)
- exp = exp.And(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
- if (coursematerialID.HasValue)
- exp = exp.And(x => x.CF_TeachingMaterialPool.EM_Coursematerial.Any(w => w.CoursematerialID == coursematerialID));
- if (publishID.HasValue)
- exp = exp.And(x => x.CF_TeachingMaterialPool.PublishID == publishID);
- var query = TeachersConfirmOrderDAL.GetTeachersConfirmOrderGridView(exp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ThenBy(x => x.SchoolyearName).ToList();
- return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ThenBy(x => x.SchoolyearName).ToList();
- }
- #endregion
- #region 4.0 批量更新预加值
- /// <summary>
- /// 批量更新预加值
- /// </summary>
- /// <param name="teachersOrderIDs"></param>
- /// <param name="preAddedValue"></param>
- public void BatchUpdatePreAddedValue(List<TeachersOrderView> teachersOrderList, int preAddedValue, Guid userId)
- {
- try
- {
- if (teachersOrderList.Count > 0)
- {
- //int? ApprovalStatus = (int)CF_TeachersOrderStatus.Completed;//提取已通过
- foreach (var teachersOrder in teachersOrderList)
- {
- var teachersPreOrderEnt = TeachersPreOrderRepository.Entities.Where(x => x.TeachingMaterialPoolID == teachersOrder.TeachingMaterialPoolID && x.SchoolyearID == teachersOrder.SchoolyearID).FirstOrDefault();//&& x.ApprovalStatus == ApprovalStatus 所有教材征订附加表的信息ApprovalStatus的值为空
- if (teachersPreOrderEnt == null)//如果该记录存在、就更新数据
- {
- ET_TeachersPreOrder teachersPreOrder = new ET_TeachersPreOrder();
- teachersPreOrder.TeachersPreOrderID = Guid.NewGuid();
- teachersPreOrder.TeachingMaterialPoolID = teachersOrder.TeachingMaterialPoolID;
- teachersPreOrder.SchoolyearID = (Guid)teachersOrder.SchoolyearID;
- teachersPreOrder.CreateTime = DateTime.Now;
- teachersPreOrder.CreateUserID = userId;
- teachersPreOrder.ModifyTime = DateTime.Now;
- teachersPreOrder.ModifyUserID = userId;
- teachersPreOrder.Desc = "预加值";
- teachersPreOrder.PreQty = preAddedValue;//设置预加值;
- TeachersPreOrderRepository.UnitOfWork.Add(teachersPreOrder);
- }
- else
- {
- ET_TeachersPreOrder teachersPreOrder = teachersPreOrderEnt;
- teachersPreOrder.ModifyTime = DateTime.Now;
- teachersPreOrder.ModifyUserID = userId;
- teachersPreOrder.Desc = "预加值";
- teachersPreOrder.PreQty = preAddedValue;//设置预加值;
- TeachersPreOrderRepository.UnitOfWork.Update(teachersPreOrder);
- }
- }
- UnitOfWork.Commit();
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- #region 5.0 导出Excel明细信息
- /// <summary>
- /// 导出清单明细数据
- /// </summary>
- /// <param name="schoolyearID"></param>
- /// <param name="teachingMaterialPoolID"></param>
- /// <returns></returns>
- public IList<TeachersConfirmOrderView> GetTeachersConfirmOrderViewDetailExcel(Guid? schoolyearID, Guid? teachingMaterialPoolID)
- {
- int? ApprovalStatus = TeachersOrderServices.Value.GetCorrectEndStatus();//提取已通过
- var query = TeachersConfirmOrderDAL.GetTeachingOrderDetail(x => x.ApprovalStatus == ApprovalStatus);
- if (schoolyearID.HasValue)
- query = query.Where(x => x.SchoolyearID == schoolyearID);
- if (teachingMaterialPoolID.HasValue)
- query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
- return query.OrderBy(x => x.PublishTime).ToList();
- }
- #endregion
- }
- }
|