123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.Repositories;
- using EMIS.ViewModel.TeachingMaterial;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using EMIS.ViewModel;
- namespace EMIS.DataLogic.Common.TeachingMaterial
- {
- public class TeachersOrderDAL
- {
- public TeachersOrderRepository TeachersOrderRepository { get; set; }
- public TeachersPreOrderRepository TeachersPreOrderRepository { get; set; }
- public TeachingMaterialPoolRepository TeachingMaterialPoolRepository { get; set; }
- public TeachersConfirmOrderRepository TeachersConfirmOrderRepository { 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; }
- /// <summary>
- /// 获取征订信息列表
- /// </summary>
- /// <param name="exp"></param>
- /// <returns></returns>
- public IQueryable<TeachersOrderView> GetTeachingOrderGridView(Expression<Func<ET_TeachersOrder, bool>> exporder)
- {
- var view = (from to in TeachersOrderRepository.Entities.Where(exporder)
- join tm in TeachingMaterialPoolRepository.Entities on to.TeachingMaterialPoolID equals tm.TeachingMaterialPoolID
- join u in UserRepository.Entities on to.OrderUserID equals u.UserID
- join p in PublishRepository.Entities on tm.PublishID equals (Guid)p.PublishID
- join sl in SchoolyearRepository.Entities on to.SchoolyearID equals sl.SchoolyearID
- join cr in CollegeRepository.Entities on to.CollegeID equals cr.CollegeID
- select new TeachersOrderView
- {
- SchoolyearID = sl.SchoolyearID,
- SchoolyearName = sl.Code,
- TeachingMaterialCode = tm.TeachingMaterialCode,
- Author = tm.Author,
- CollegeID = cr.CollegeID,
- CollegeName = cr.Name,
- TeachingMaterialName = tm.TeachingMaterialName,
- TeachingMaterialTypeID = tm.TeachingMaterialTypeID,
- PublishTime = tm.PublishTime,
- TeachersOrderID = to.TeachersOrderID,
- TeachingMaterialPoolID = tm.TeachingMaterialPoolID,
- PublishName = p.UnitName,
- OrderLoginID = u.LoginID,
- OrderUserName = u.Name,
- OrderDate = to.OrderDate,
- OrderQty = to.OrderQty,
- OrderDesc = to.OrderDesc,
- ApproveStatus = (int)to.ApprovalStatus,
- CoursematerialEntityList = tm.EM_Coursematerial,
- PublishID = p.PublishID,
- CreateTime = to.CreateTime,
- CreateUserID = to.CreateUserID,
- ISBN = tm.ISBN,
- Price = tm.Price
- });
- return view;
- }
- /// <summary>
- /// 获取教材及征订信息列表
- /// </summary>
- /// <param name="exp"></param>
- /// <returns></returns>
- public IQueryable<TeachingMaterialPoolView> GetTeachingOrderByTeachingMaterialPoolGridView(Guid? teachersOrderID, Expression<Func<CF_TeachingMaterialPool, bool>> teachingMaterialPoolExp)
- {
- var view = (from to in TeachersOrderRepository.Entities.Where(x => x.TeachersOrderID == teachersOrderID)
- join tm in TeachingMaterialPoolRepository.GetList(teachingMaterialPoolExp) on to.TeachingMaterialPoolID equals tm.TeachingMaterialPoolID
- join u in UserRepository.Entities on to.OrderUserID equals u.UserID
- join p in PublishRepository.Entities on tm.PublishID equals (Guid)p.PublishID
- join sl in SchoolyearRepository.Entities on to.SchoolyearID equals sl.SchoolyearID
- join cr in CollegeRepository.Entities on to.CollegeID equals cr.CollegeID
- //join ct in DictionaryItemRepository.Entities on c.CourseScienceID equals ct.Value
- //join cl in DictionaryItemRepository.Entities on c.CourseLevelID equals cl.Value
- //join s in DictionaryItemRepository.Entities on to.ApprovalStatus equals s.Value
- select new TeachingMaterialPoolView
- {
- TeachingMaterialPoolID = tm.TeachingMaterialPoolID,
- TeachingMaterialCode = tm.TeachingMaterialCode,
- TeachingMaterialName = tm.TeachingMaterialName,
- TeachingMaterialShorName = tm.TeachingMaterialShorName,
- CoursematerialEntityList = tm.EM_Coursematerial,
- ISBN = tm.ISBN,
- PublishTime = tm.PublishTime,
- PublishName = p.UnitName,
- Author = tm.Author,
- Price = tm.Price,
- OrderQty = to.OrderQty,
- });
- return view;
- }
- /// <summary>
- /// 获取教师征订视图
- /// </summary>
- /// <returns></returns>
- public TeachersOrderView GetSingleTeachersOrderView(Guid teachersOrderID)
- {
- var teachersOrder = TeachersOrderRepository.GetSingle(x => x.TeachersOrderID == teachersOrderID,
- (x => x.CF_College), (x => x.CF_Schoolyear), (x => x.CF_TeachingMaterialPool),(x=>x.CF_TeachingMaterialPool.EM_Coursematerial));
- var teachersOrderView = new TeachersOrderView()
- {
- TeachingMaterialCode = teachersOrder.CF_TeachingMaterialPool.TeachingMaterialCode,
- CoursematerialEntityList = teachersOrder.CF_TeachingMaterialPool.EM_Coursematerial,
- TeachingMaterialName = teachersOrder.CF_TeachingMaterialPool.TeachingMaterialName,
- PublishTime = teachersOrder.CF_TeachingMaterialPool.PublishTime,
- PublishID = teachersOrder.CF_TeachingMaterialPool.PublishID,
- Author = teachersOrder.CF_TeachingMaterialPool.Author,
- ISBN = teachersOrder.CF_TeachingMaterialPool.ISBN,
- Price = teachersOrder.CF_TeachingMaterialPool.Price,
- OrderQty = teachersOrder.OrderQty,
- OrderDesc = teachersOrder.OrderDesc,
- SchoolyearID = teachersOrder.SchoolyearID,
- CollegeID = teachersOrder.CollegeID,
- CollegeName = teachersOrder.CF_College.Name,
- SchoolyearName=teachersOrder.CF_Schoolyear.Code,
- ApproveStatus=(int)teachersOrder.ApprovalStatus
- };
- return teachersOrderView;
- }
- /// <summary>
- /// 获取单个基本信息
- /// </summary>
- /// <returns></returns>
- public TeachersOrderView GetSingleTeachersOrderOneView(Guid teachersOrderID)
- {
- var teachersOrder = TeachersOrderRepository.GetSingle(x => x.TeachersOrderID == teachersOrderID,
- (x => x.CF_College), (x => x.CF_Schoolyear), (x => x.CF_TeachingMaterialPool));
- var teachersOrderView = new TeachersOrderView()
- {
- TeachingMaterialCode = teachersOrder.CF_TeachingMaterialPool.TeachingMaterialCode,
- CoursematerialEntityList = teachersOrder.CF_TeachingMaterialPool.EM_Coursematerial,
- TeachingMaterialName = teachersOrder.CF_TeachingMaterialPool.TeachingMaterialName,
- PublishTime = teachersOrder.CF_TeachingMaterialPool.PublishTime,
- PublishID = teachersOrder.CF_TeachingMaterialPool.PublishID,
- Author = teachersOrder.CF_TeachingMaterialPool.Author,
- ISBN = teachersOrder.CF_TeachingMaterialPool.ISBN,
- Price = teachersOrder.CF_TeachingMaterialPool.Price,
- OrderQty = teachersOrder.OrderQty
- };
- return teachersOrderView;
- }
- /// <summary>
- /// 获取单个教师征订记录
- /// </summary>
- /// <param name="teachersOrderID"></param>
- /// <returns></returns>
- public ET_TeachersOrder GetSingleTeachersOrder(Guid teachersOrderID)
- {
- return TeachersOrderRepository.GetSingle(x => x.TeachersOrderID == teachersOrderID);
- }
- /// <summary>
- /// 获取单个教师征订View
- /// </summary>
- /// <param name="teachersOrderID"></param>
- /// <returns></returns>
- public TeachersOrderView GetSingleTeachersOrderById(Guid teachersOrderID)
- {
- var teachersOrder = TeachersOrderRepository.GetSingle(x => x.TeachersOrderID == teachersOrderID);
- var teachersOrderView = new TeachersOrderView()
- {
- OrderQty = teachersOrder.OrderQty,
- TeachersOrderID = teachersOrder.TeachersOrderID,
- CollegeID = teachersOrder.CollegeID,
- CreateTime = teachersOrder.CreateTime,
- CreateUserID = teachersOrder.CreateUserID,
- OrderDate = teachersOrder.OrderDate,
- OrderDesc = teachersOrder.OrderDesc,
- OrderUserID = teachersOrder.OrderUserID,
- TeachingMaterialPoolID = teachersOrder.TeachingMaterialPoolID,
- SchoolyearID = teachersOrder.SchoolyearID
- };
- return teachersOrderView;
- }
- #region 复制征订数据到征订清单表(废弃)
- ///// <summary>
- ///// 复制征订数据到征订清单表
- ///// </summary>
- ///// <param name="teachersOrderIDs"></param>
- //public void CopyTeachersOrderInTeachersConfirmOrder(Guid teachersOrderID)
- //{
- // try
- // {
- // if (teachersOrderID != null && teachersOrderID != Guid.Empty)
- // {
- // ET_TeachersOrder teachersOrder = TeachersOrderRepository.GetSingle(x => x.TeachersOrderID == teachersOrderID && x.ApprovalStatus == (int)CF_TeachersOrderStatus.Completed);
- // if (teachersOrder != null)
- // {
- // ET_TeachersConfirmOrder teachersConfirmOrder = new ET_TeachersConfirmOrder
- // {
- // PreAddedValue = 5,//设置预加值、
- // TeachersOrderID = teachersOrder.TeachersOrderID,
- // CollegeID = teachersOrder.CollegeID,
- // CreateTime = DateTime.Now,
- // CreateUserID = teachersOrder.CreateUserID,
- // Desc = teachersOrder.Desc,
- // ModifyTime = DateTime.Now,
- // ModifyUserID = teachersOrder.ModifyUserID,
- // OrderDate = teachersOrder.OrderDate,
- // OrderDesc = teachersOrder.OrderDesc,
- // OrderQty = teachersOrder.OrderQty,
- // OrderUserID = teachersOrder.OrderUserID,
- // SchoolyearID = teachersOrder.SchoolyearID,
- // TeachingMaterialPoolID = teachersOrder.TeachingMaterialPoolID
- // };
- // TeachersConfirmOrderRepository.UnitOfWork.Add(teachersConfirmOrder);
- // TeachersConfirmOrderRepository.UnitOfWork.Commit();
- // }
- // }
- // }
- // catch (Exception ex)
- // {
- // throw ex;
- // }
- //}
- #endregion
- /// <summary>
- /// 获取教材总库信息列表、排除在教师征订表已存在的教材
- /// </summary>
- /// <param name="exp"></param>
- /// <returns></returns>
- public IQueryable<TeachingMaterialPoolView> GetTeachersOrderByTeachingMaterial(Expression<Func<CF_TeachingMaterialPool, bool>> exp)
- {
- //教材所有信息以教材总库表为准 其他都左联 --- 兵良提出
- var view = (from l in TeachingMaterialPoolRepository.Entities.Where(exp)
- //关联字典导致数据重复
- //join d in DictionaryItemRepository.Entities on l.TeachingMaterialTypeID equals d.Value
- // into td
- //from ctd in td.DefaultIfEmpty()
- join u in UserRepository.Entities on l.CreateUserID equals u.UserID
- into user
- from uu in user.DefaultIfEmpty()
- join p in PublishRepository.Entities on l.PublishID equals p.PublishID
- into pp
- from ppp in pp.DefaultIfEmpty()
- // join g in TeachersOrderRepository.Entities on l.TeachingMaterialPoolID equals g.TeachingMaterialPoolID
- // into teachingMaterialPool
- // from gteachingMaterialPool in teachingMaterialPool.DefaultIfEmpty()
- // where gteachingMaterialPool.TeachingMaterialPoolID ==null //在征订表不存在记录
- select new TeachingMaterialPoolView
- {
- Author = l.Author,
- ISBN = l.ISBN,
- CoursematerialEntityList = l.EM_Coursematerial,
- Price = l.Price,
- TeachingMaterialCode = l.TeachingMaterialCode,
- TeachingMaterialName = l.TeachingMaterialName,
- TeachingMaterialShorName = l.TeachingMaterialShorName,
- TeachingMaterialPoolID = l.TeachingMaterialPoolID,
- TeachingMaterialTypeID = l.TeachingMaterialTypeID,
- //TeachingMaterialTypeName = ctd.Name,
- PublishID = l.PublishID,
- PublishName = ppp.UnitName,
- PublishTime = l.PublishTime,
- CreateTime = l.CreateTime,
- CreateUserName = uu.Name,
- Desc = l.Desc,
- IsLate = l.IsLate.Value,
- ModifyTime = l.ModifyTime,
- IsLateName = l.IsLate == true ? "是" : "否",
- OrderQty = 1
- });
- return view;
- }
- public IQueryable<ET_TeachersPreOrder> GetPreOrderByTeachersOrderIDList(List<Guid> teacherOrderIDList)
- {
- var query = (from tpo in TeachersPreOrderRepository.Entities
- join to in TeachersOrderRepository.GetList(x => teacherOrderIDList.Contains(x.TeachersOrderID))
- on new { tpo.SchoolyearID, tpo.TeachingMaterialPoolID }
- equals new { to.SchoolyearID, to.TeachingMaterialPoolID }
- select tpo);
- return query;
- }
- }
- }
|