123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.Common.TeachingMaterial;
- using EMIS.ViewModel.TeachingMaterial;
- using Bowin.Common.Linq.Entity;
- using Bowin.Common.Linq;
- using EMIS.ViewModel;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using EMIS.ViewModel.Cultureplan;
- namespace EMIS.CommonLogic.TeachingMaterial
- {
- public class InventoryServices : BaseServices, IInventoryServices
- {
- public InventoryDAL InventoryDAL { get; set; }
- public IGridResultSet<InventoryView> GetTeachingMateriaInventoryViewGrid(ConfiguretView configuretView, Guid? teachingMateriaCodeID, Guid? teachingMateriaNameID, Guid? publishID, bool? isLate, int? teachingMaterialTypeID, int pageIndex, int pageSize)
- {
- Expression<Func<ET_TeachingMateriaInventory, bool>> exp = x => true;
- Expression<Func<CF_TeachingMaterialPool, bool>> poolexp = x => true;
- if (isLate != null)
- {
- //exp = exp.And(x => x.CF_TeachingMaterialPool.IsLate == isLate);
- poolexp = poolexp.And(x => x.IsLate == isLate);
- }
- if (teachingMateriaNameID.HasValue)
- {
- //exp = exp.And(x => x.TeachingMaterialPoolID == teachingMateriaNameID);
- poolexp = poolexp.And(x => x.TeachingMaterialPoolID == teachingMateriaNameID);
- }
- if (publishID.HasValue)
- {
- //exp = exp.And(x => x.CF_TeachingMaterialPool.CF_Publish.PublishID == publishID);
- poolexp = poolexp.And(x => x.CF_Publish.PublishID == publishID);
- }
- if (teachingMaterialTypeID.HasValue)
- {
- //exp = exp.And(x => x.CF_TeachingMaterialPool.TeachingMaterialTypeID == teachingMaterialTypeID);
- poolexp = poolexp.And(x => x.TeachingMaterialTypeID == teachingMaterialTypeID);
- }
- var query = InventoryDAL.GetTeachingMaterialInventoryGridView(exp, poolexp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<InventoryView>(pageIndex, pageSize);
- return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<InventoryView>(pageIndex, pageSize);
- }
- public IList<InventoryView> GetTeachingMateriaInventoryViewList(ConfiguretView configuretView, Guid? teachingMateriaCodeID, Guid? teachingMateriaNameID, Guid? publishID, bool? isLate, int? teachingMaterialTypeID)
- {
- Expression<Func<ET_TeachingMateriaInventory, bool>> exp = x => true;
- Expression<Func<CF_TeachingMaterialPool, bool>> poolexp = x => true;
- if (isLate != null)
- {
- //exp = exp.And(x => x.CF_TeachingMaterialPool.IsLate == isLate);
- poolexp = poolexp.And(x => x.IsLate == isLate);
- }
- if (teachingMateriaNameID.HasValue)
- {
- //exp = exp.And(x => x.TeachingMaterialPoolID == teachingMateriaNameID);
- poolexp = poolexp.And(x => x.TeachingMaterialPoolID == teachingMateriaNameID);
- }
- if (publishID.HasValue)
- {
- //exp = exp.And(x => x.CF_TeachingMaterialPool.CF_Publish.PublishID == publishID);
- poolexp = poolexp.And(x => x.CF_Publish.PublishID == publishID);
- }
- if (teachingMaterialTypeID.HasValue)
- {
- //exp = exp.And(x => x.CF_TeachingMaterialPool.TeachingMaterialTypeID == teachingMaterialTypeID);
- poolexp = poolexp.And(x => x.TeachingMaterialTypeID == teachingMaterialTypeID);
- }
- var query = InventoryDAL.GetTeachingMaterialInventoryGridView(exp, poolexp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList();
- return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList();
- }
- //获取库存统计信息
- public IGridResultSet<InventoryView> GetInventoryManagementViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? teachingMateriaID, int? teachingMateriaType, Guid? publishID, int pageIndex, int pageSize)
- {
- var query = InventoryDAL.GetInventoryManagementGridOnlyNumView(schoolyearID);
- //if (schoolyearID.HasValue)
- // query = query.Where(x => x.SchoolYearID == schoolyearID);
- if (teachingMateriaID.HasValue)
- query = query.Where(x => x.TeachingMaterialPoolID == teachingMateriaID);
- if (teachingMateriaType.HasValue)
- query = query.Where(x => x.TeachingMaterialTypeID == teachingMateriaType);
- if (publishID.HasValue)
- query = query.Where(x => x.PublishID == publishID);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<InventoryView>(pageIndex, pageSize);
- return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<InventoryView>(pageIndex, pageSize);
- }
- public IList<InventoryView> GetInventoryManagementViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? teachingMateriaID, int? teachingMateriaType, Guid? publishID)
- {
- var query = InventoryDAL.GetInventoryManagementGridOnlyNumView(schoolyearID);
- if (teachingMateriaID.HasValue)
- query = query.Where(x => x.TeachingMaterialPoolID == teachingMateriaID);
- if (teachingMateriaType > 1)
- query = query.Where(x => x.TeachingMaterialTypeID == teachingMateriaType);
- if (publishID.HasValue)
- query = query.Where(x => x.PublishID == publishID);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList();
- return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList();
- }
- /*----------------------------加载入库、库存、出库明细各项数据------------------------------*/
- public IGridResultSet<StockOutView> GetStockOutDetailViewGrid(Guid? teachingMaterialPoolID, Guid? schoolyearID)
- {
- //var query = InventoryDAL.GetStockOutDetailGridView(x => true);
- var query = InventoryDAL.GetStockOutDetailGridView(schoolyearID, teachingMaterialPoolID);
- 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.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<StockOutView>(0, 20);
- }
- public IGridResultSet<StockInView> GetStockInDetailViewGrid(Guid? teachingMaterialPoolID, Guid? schoolyearID)
- {
- Expression<Func<ET_StockIn, bool>> exp = x => true;
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- }
- var query = InventoryDAL.GetStockInDetailGridView(exp);
- if (teachingMaterialPoolID.HasValue)
- query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
- return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<StockInView>(0, 20);
- }
- #region 2.0 库存出入库教材信息数据加载
- public IGridResultSet<StockOutView> GetStockOutDetailByValueViewGrid(Guid? teachingMaterialPoolID, int? Value, Guid? schoolyearID, decimal? discountPrice, int pageIndex, int pageSize)
- {
- var schoolyearIDList = InventoryDAL.SchoolyearRepository.Entities.Where(x => x.Value >= Value).Select(x => x.SchoolyearID);
- var query = InventoryDAL.GetStockOutDetailGridView(schoolyearID, teachingMaterialPoolID);
- if (teachingMaterialPoolID.HasValue)
- query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
- if (discountPrice.HasValue)
- query = query.Where(x => x.DiscountPrice == discountPrice);
- return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<StockOutView>(pageIndex, pageSize);
- }
- public IGridResultSet<StockInView> GetStockInDetailByValueViewGrid(Guid? teachingMaterialPoolID, Guid? schoolyearID, decimal? discountPrice, int pageIndex, int pageSize)
- {
- var query = InventoryDAL.GetStockInDetailGridView(x => x.SchoolyearID == schoolyearID && x.RecordStatus == (int)CF_YesOrNoStatus.Yes);
- if (teachingMaterialPoolID.HasValue)
- query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
- if (discountPrice.HasValue)
- query = query.Where(x => x.DiscountPrice == discountPrice);
- return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<StockInView>(pageIndex, pageSize);
- }
- #endregion
- public IGridResultSet<InventoryView> GetTeachingMateriaInventoryViewGrid(Guid? teachingMaterialPoolID)
- {
- var query = InventoryDAL.GetTeachingMaterialInventoryGridView(x => x.TeachingMaterialPoolID == teachingMaterialPoolID, x => true);
- return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<InventoryView>(0, 20);
- }
- /*----------------------------Excel导出入库、库存、出库明细各项数据------------------------------*/
- public IList<StockOutView> GetStockOutDetailViewList(Guid? teachingMaterialPoolID, Guid? schoolyearID)
- {
- var SchoolYearEntity = InventoryDAL.SchoolyearRepository.Entities.Where(x => x.SchoolyearID == schoolyearID);
- var schoolyearIDList = InventoryDAL.SchoolyearRepository.Entities.Where(x => x.Value >= SchoolYearEntity.FirstOrDefault().Value).Select(x => x.SchoolyearID);
- var query = InventoryDAL.GetStockOutDetailGridView(schoolyearID, teachingMaterialPoolID);
- if (query.Count() <= 0)
- {
- query = InventoryDAL.GetStudentDistributeDetailGridView(x => schoolyearIDList.Contains(x.EM_SpecialtyPlan.CF_Schoolyear.SchoolyearID) && x.RecordStatus == (int)CF_YesOrNoStatus.Yes);
- }
- 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.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList();
- }
- public IList<StockInView> GetStockInDetailViewList(Guid? teachingMaterialPoolID, Guid? schoolyearID)
- {
- Expression<Func<ET_StockIn, bool>> exp = x => true;
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- }
- var query = InventoryDAL.GetStockInDetailGridView(exp);
- if (teachingMaterialPoolID.HasValue)
- query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
- return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList();
- }
- #region 2.0 库存汇总出入库明细查看
- public IList<StockOutView> GetStockOutDetailByValueViewList(Guid? teachingMaterialPoolID, int? Value, Guid? schoolyearID)
- {
- var schoolyearIDList = InventoryDAL.SchoolyearRepository.Entities.Where(x => x.Value >= Value).Select(x => x.SchoolyearID);
- var query = InventoryDAL.GetStockOutDetailGridView(schoolyearID, teachingMaterialPoolID);
- if (teachingMaterialPoolID.HasValue)
- query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
- return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList();
- }
- public IList<StockInView> GetStockInDetailByValueViewList(Guid? teachingMaterialPoolID, Guid? schoolyearID)
- {
- Expression<Func<ET_StockIn, bool>> exp = x => x.SchoolyearID == schoolyearID && x.RecordStatus == (int)CF_YesOrNoStatus.Yes;
- var query = InventoryDAL.GetStockInDetailGridView(exp);
- if (teachingMaterialPoolID.HasValue)
- query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
- return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList();
- }
- #endregion
- public IList<InventoryView> GetTeachingMateriaInventoryViewList(Guid? teachingMaterialPoolID)
- {
- var query = InventoryDAL.GetTeachingMaterialInventoryGridView(x => x.TeachingMaterialPoolID == teachingMaterialPoolID, x => true);
- return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList();
- }
- }
- }
|