using SqlSugar;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using WIDESEA_Core;
|
using WIDESEA_Core.BaseRepository;
|
using WIDESEA_Core.BaseServices;
|
using WIDESEA_Core.Helper;
|
using WIDESEA_IAllocateService;
|
using WIDESEA_Model.Models;
|
|
namespace WIDESEA_AllocateService
|
{
|
public class AllocateDetailService : ServiceBase<Dt_AllocateOrderDetail, IRepository<Dt_AllocateOrderDetail>>, IAllocateDetailService
|
{
|
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_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);
|
}
|
|
|
int totalCount = 0;
|
List<SearchParameters> searchParametersList = new List<SearchParameters>();
|
if (!string.IsNullOrEmpty(options.Wheres))
|
{
|
try
|
{
|
searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>();
|
options.Filter = searchParametersList;
|
}
|
catch { }
|
}
|
//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("无明细");
|
}
|
}
|
}
|
}
|