| | |
| | | using SqlSugar.Extensions; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Dynamic; |
| | | using System.Linq; |
| | | using System.Reflection; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.AllocateEnum; |
| | |
| | | using WIDESEA_Core.CodeConfigEnum; |
| | | using WIDESEA_Core.DB; |
| | | using WIDESEA_Core.Enums; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_Core.Seed; |
| | | using WIDESEA_IAllocateService; |
| | | using WIDESEA_IInboundService; |
| | |
| | | public readonly IRepository<Dt_AllocateOrder> _allocateOrderRepository; |
| | | public readonly IRepository<Dt_AllocateOrderDetail> _allocateOrderDetailRepository; |
| | | |
| | | public readonly IRepository<Dt_InboundOrderDetail> _inboundOrderDetailRepository; |
| | | |
| | | private readonly ILogger<AllocateService> _logger; |
| | | public AllocateService(IRepository<Dt_AllocateOrder> BaseDal, |
| | | IUnitOfWorkManage unitOfWorkManage, |
| | |
| | | IOutboundService outboundService, |
| | | IRepository<Dt_AllocateOrder> allocateOrderRepository, |
| | | IRepository<Dt_AllocateOrderDetail> allocateOrderDetailRepository, |
| | | IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, |
| | | ILogger<AllocateService> logger) : base(BaseDal) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | |
| | | _allocateOrderRepository = allocateOrderRepository; |
| | | _allocateOrderDetailRepository = allocateOrderDetailRepository; |
| | | _logger = logger; |
| | | _inboundOrderDetailRepository = inboundOrderDetailRepository; |
| | | } |
| | | |
| | | public IRepository<Dt_AllocateOrder> Repository => BaseDal; |
| | |
| | | { |
| | | if (businessType == BusinessTypeEnum.å¤é¨ä»åºè°æºä») |
| | | { |
| | | allocateOrder.OrderType = InOrderTypeEnum.AllocatInbound.ObjToInt(); |
| | | allocateOrder.OrderType = (int)InOrderTypeEnum.AllocatInbound; |
| | | var inboundOrders = ConvertToInboundOrders(allocateOrder); |
| | | await _inboundService.InbounOrderService.ReceiveInboundOrder(inboundOrders, 1); |
| | | } |
| | |
| | | { |
| | | if (businessType == BusinessTypeEnum.æºä»è°å¤é¨ä»åº) |
| | | { |
| | | allocateOrder.OrderType = InOrderTypeEnum.AllocatOutbound.ObjToInt(); |
| | | allocateOrder.OrderType = (int)InOrderTypeEnum.AllocatOutbound; |
| | | } |
| | | else if (businessType == BusinessTypeEnum.æºä»è°æºä») |
| | | { |
| | | allocateOrder.OrderType = InOrderTypeEnum.InternalAllocat.ObjToInt(); |
| | | allocateOrder.OrderType = (int)InOrderTypeEnum.InternalAllocat; |
| | | } |
| | | |
| | | var outboundOrders = ConvertToOutboundOrders(allocateOrder); |
| | |
| | | { |
| | | |
| | | var distinctDetails = allocateOrder.Details |
| | | .GroupBy(d => string.IsNullOrEmpty(d.Barcode) |
| | | ? $"{d.MaterielCode}_{d.BatchNo}_{d.SupplyCode}_{d.WarehouseCode}" |
| | | : d.Barcode) |
| | | .Select(g => new |
| | | { |
| | | Detail = g.First(), |
| | | //æ±æ»åç»å
çæ°é |
| | | Qty = g.Sum(x => x.BarcodeQty ?? x.OrderQuantity) |
| | | }).ToList(); |
| | | .GroupBy(d => string.IsNullOrEmpty(d.Barcode) |
| | | ? $"{d.MaterielCode}_{d.BatchNo}_{d.SupplyCode}_{d.WarehouseCode}" |
| | | : d.Barcode) |
| | | .Select(g => new |
| | | { |
| | | Detail = g.First(), |
| | | //æ±æ»åç»å
çæ°é |
| | | Qty = g.Sum(x => x.BarcodeQty ?? x.OrderQuantity) |
| | | }).ToList(); |
| | | |
| | | return new Dt_OutboundOrder() |
| | | { |
| | |
| | | MaterielName = "", |
| | | BatchNo = item.Detail.BatchNo, |
| | | OrderQuantity = item.Detail.OrderQuantity, |
| | | BarcodeQty = (decimal)item.Detail.BarcodeQty, |
| | | BarcodeUnit = item.Detail.BarcodeUnit, |
| | | BarcodeQty = item.Detail.BarcodeQty??0, |
| | | BarcodeUnit = item.Detail.BarcodeUnit??"", |
| | | LockQuantity = 0, |
| | | lineNo = item.Detail.LineNo, |
| | | OverOutQuantity = 0, |
| | |
| | | return code; |
| | | } |
| | | } |
| | | |
| | | public override PageGridData<Dt_AllocateOrder> GetPageData(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_AllocateOrder>() |
| | | .WhereIF(!wheres.IsNullOrEmpty(), wheres) |
| | | .OrderBy(orderByModels) |
| | | .ToPageList(options.Page, options.Rows, ref totalCount); |
| | | |
| | | foreach (var item in data) |
| | | { |
| | | Dt_InboundOrder _InboundOrder = SqlSugarHelper.DbWMS.Queryable<Dt_InboundOrder>().Where(x => x.UpperOrderNo == item.UpperOrderNo).First(); |
| | | Dt_OutboundOrder OutboundOrder = SqlSugarHelper.DbWMS.Queryable<Dt_OutboundOrder>().Where(x => x.UpperOrderNo == item.UpperOrderNo).First(); |
| | | if (_InboundOrder != null) |
| | | { |
| | | item.OrderStatus = _InboundOrder.OrderStatus; |
| | | item.OrderType = _InboundOrder.OrderType; |
| | | }else if (OutboundOrder!=null) |
| | | { |
| | | item.OrderStatus = OutboundOrder.OrderStatus; |
| | | item.OrderType = OutboundOrder.OrderType; |
| | | } |
| | | } |
| | | return new PageGridData<Dt_AllocateOrder>(totalCount, data); |
| | | } |
| | | |
| | | public override PageGridData<Dt_InboundOrderDetail> 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); |
| | | |
| | | 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 data = BaseDal.Db.Queryable<Dt_InboundOrderDetail>() |
| | | .WhereIF(!wheres.IsNullOrEmpty(), wheres) |
| | | .WhereIF(!_InboundOrder.IsNullOrEmpty(), x => x.OrderId == _InboundOrder.Id) |
| | | .OrderBy(orderByModels) |
| | | .ToPageList(options.Page, options.Rows, ref totalCount); |
| | | |
| | | |
| | | return new PageGridData<Dt_InboundOrderDetail>(totalCount, data); |
| | | } |
| | | } |
| | | } |