| | |
| | | { |
| | | public class AllocateDetailService : ServiceBase<Dt_AllocateOrderDetail, IRepository<Dt_AllocateOrderDetail>>, IAllocateDetailService |
| | | { |
| | | public AllocateDetailService(IRepository<Dt_AllocateOrderDetail> BaseDal) : base(BaseDal) |
| | | public readonly IRepository<Dt_AllocateOrder> _allocateOrderRepository; |
| | | public AllocateDetailService(IRepository<Dt_AllocateOrderDetail> BaseDal, IRepository<Dt_AllocateOrder> allocateOrderRepository) : base(BaseDal) |
| | | { |
| | | _allocateOrderRepository = allocateOrderRepository; |
| | | } |
| | | |
| | | IRepository<Dt_AllocateOrderDetail> IAllocateDetailService.Repository => BaseDal; |
| | | |
| | | public override PageGridData<Dt_AllocateOrderDetail> GetPageData(PageDataOptions options) |
| | | public override PageGridData<Dt_OutboundOrderDetail> GetDetailPage(PageDataOptions options) |
| | | { |
| | | string wheres = ValidatePageOptions(options); |
| | | //è·åæåºå段 |
| | | Dictionary<string, SqlSugar.OrderByType> orderbyDic = GetPageDataSort(options, TProperties); |
| | | List<OrderByModel> orderByModels = new List<OrderByModel>(); |
| | | foreach (var item in orderbyDic) |
| | | { |
| | | OrderByModel orderByModel = new() |
| | | { |
| | | FieldName = item.Key, |
| | | OrderByType = item.Value |
| | | }; |
| | | orderByModels.Add(orderByModel); |
| | | } |
| | | |
| | | ISugarQueryable<Dt_AllocateOrderDetail> sugarQueryable1 = BaseDal.Db.Queryable<Dt_AllocateOrderDetail>(); |
| | | |
| | | int totalCount = 0; |
| | | List<SearchParameters> searchParametersList = new List<SearchParameters>(); |
| | | if (!string.IsNullOrEmpty(options.Wheres)) |
| | | { |
| | | |
| | | List<SearchParameters> searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>(); |
| | | int totalCount = 0; |
| | | if (searchParametersList.Count > 0) |
| | | try |
| | | { |
| | | { |
| | | SearchParameters? searchParameters = searchParametersList.FirstOrDefault(x => x.Name == nameof(Dt_AllocateOrderDetail.OrderId).FirstLetterToLower()); |
| | | if (searchParameters != null) |
| | | { |
| | | sugarQueryable1 = sugarQueryable1.Where(x => x.OrderId == searchParameters.Value.ObjToInt()); |
| | | var dataList = sugarQueryable1.ToPageList(options.Page, options.Rows, ref totalCount); |
| | | return new PageGridData<Dt_AllocateOrderDetail>(totalCount, dataList); |
| | | } |
| | | } |
| | | |
| | | |
| | | searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>(); |
| | | options.Filter = searchParametersList; |
| | | } |
| | | catch { } |
| | | } |
| | | return new PageGridData<Dt_AllocateOrderDetail>(); |
| | | //var data = BaseDal.Db.Queryable<Dt_AllocateOrderDetail>() |
| | | // .WhereIF(!wheres.IsNullOrEmpty(), wheres) |
| | | // .OrderBy(orderByModels) |
| | | // .ToPageList(options.Page, options.Rows, ref totalCount); |
| | | //Dt_AllocateOrder allocateOrder = _allocateOrderRepository.QueryFirst(x => x.Id == (int)options.Value); |
| | | //Dt_InboundOrder _InboundOrder = SqlSugarHelper.DbWMS.Queryable<Dt_InboundOrder>().Where(x => x.UpperOrderNo == allocateOrder.UpperOrderNo).First(); |
| | | //var details = _inboundOrderDetailRepository.QueryData(x => x.OrderId == _InboundOrder.Id ); |
| | | //foreach (var item in data) |
| | | //{ |
| | | // var detail = details.Where(x => x.MaterielCode == item.MaterielCode).FirstOrDefault(); |
| | | // if (detail != null) |
| | | // { |
| | | // item.OrderQuantity = detail.OrderQuantity; |
| | | // item.ReceiptQuantity = detail.ReceiptQuantity; |
| | | // item.OverInQuantity = detail.OverInQuantity; |
| | | // item.OrderDetailStatus = detail.OrderDetailStatus; |
| | | // } |
| | | //} |
| | | //return new PageGridData<Dt_AllocateOrderDetail>(totalCount, data); |
| | | |
| | | try |
| | | { |
| | | Dt_AllocateOrder allocateOrder = _allocateOrderRepository.QueryFirst(x => x.Id == options.Filter.FirstOrDefault().Value.ObjToInt()); |
| | | Dt_OutboundOrder _InboundOrder = SqlSugarHelper.DbWMS.Queryable<Dt_OutboundOrder>().Where(x => x.UpperOrderNo == allocateOrder.UpperOrderNo).First(); |
| | | var Id = _InboundOrder == null ? 0 : _InboundOrder.Id; |
| | | var data = BaseDal.Db.Queryable<Dt_OutboundOrderDetail>() |
| | | .Where(x => x.OrderId == Id) |
| | | .OrderBy(orderByModels) |
| | | .ToPageList(options.Page, options.Rows, ref totalCount); |
| | | |
| | | return new PageGridData<Dt_OutboundOrderDetail>(totalCount, data); |
| | | } |
| | | catch(Exception ex) |
| | | { |
| | | throw new Exception("æ æç»"); |
| | | } |
| | | } |
| | | } |
| | | } |