| | |
| | | 锘縰sing Autofac.Core; |
| | | using MailKit.Search; |
| | | using Microsoft.Extensions.Logging; |
| | | 锘縰sing Microsoft.Extensions.Logging; |
| | | using SqlSugar; |
| | | 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_Common.OrderEnum; |
| | | using WIDESEA_Core; |
| | |
| | | using WIDESEA_Core.BaseServices; |
| | | 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_IBasicService; |
| | | using WIDESEA_IInboundService; |
| | | using WIDESEA_IOutboundService; |
| | | using WIDESEA_Model.Models; |
| | |
| | | public readonly IOutboundService _outboundService; |
| | | public readonly IRepository<Dt_AllocateOrder> _allocateOrderRepository; |
| | | public readonly IRepository<Dt_AllocateOrderDetail> _allocateOrderDetailRepository; |
| | | |
| | | private readonly IMaterielInfoService _materielInfoService; |
| | | public readonly IRepository<Dt_InboundOrderDetail> _inboundOrderDetailRepository; |
| | | |
| | | private readonly ILogger<AllocateService> _logger; |
| | |
| | | IRepository<Dt_AllocateOrder> allocateOrderRepository, |
| | | IRepository<Dt_AllocateOrderDetail> allocateOrderDetailRepository, |
| | | IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, |
| | | ILogger<AllocateService> logger) : base(BaseDal) |
| | | ILogger<AllocateService> logger, |
| | | IMaterielInfoService materielInfoService) : base(BaseDal) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _inboundService = inboundService; |
| | |
| | | _allocateOrderDetailRepository = allocateOrderDetailRepository; |
| | | _logger = logger; |
| | | _inboundOrderDetailRepository = inboundOrderDetailRepository; |
| | | _materielInfoService = materielInfoService; |
| | | } |
| | | |
| | | public IRepository<Dt_AllocateOrder> Repository => BaseDal; |
| | |
| | | { |
| | | if (BaseDal.QueryFirst(x => x.UpperOrderNo == allocateOrder.UpperOrderNo) != null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"璋冩嫧鍗曞彿閲嶅"); |
| | | return WebResponseContent.Instance.Error($"{allocateOrder.UpperOrderNo}璋冩嫧鍗曞彿閲嶅"); |
| | | } |
| | | allocateOrder.OrderNo = CreateCodeByRule(nameof(RuleCodeEnum.AllocateOrderCodeRule)); |
| | | var materielCodes = allocateOrder.Details.Select(x => x.MaterielCode).Distinct().ToList(); |
| | | var materielInfos = _materielInfoService.Db.Queryable<Dt_MaterielInfo>().Where(x => materielCodes.Contains(x.MaterielCode)).ToList(); |
| | | foreach (var item in allocateOrder.Details) |
| | | { |
| | | if (materielInfos.Any()) |
| | | { |
| | | item.MaterielName = materielInfos.FirstOrDefault(x => x.MaterielCode == item.MaterielCode)?.MaterielName ?? ""; |
| | | } |
| | | } |
| | | Db.InsertNav(allocateOrder).Include(x => x.Details).ExecuteCommand(); |
| | | await AddInOutData(allocateOrder); |
| | | return WebResponseContent.Instance.OK(); |
| | |
| | | List<Dt_AllocateOrderDetail> allocateOrderDetails = new List<Dt_AllocateOrderDetail>(); |
| | | List<Dt_AllocateOrderDetail> updateAllocateOrderDetails = new List<Dt_AllocateOrderDetail>(); |
| | | List<int> detailIds = new List<int>(); |
| | | |
| | | var materielCodes = allocateOrder.Details.Select(x => x.MaterielCode).Distinct().ToList(); |
| | | var materielInfos = _materielInfoService.Db.Queryable<Dt_MaterielInfo>().Where(x => materielCodes.Contains(x.MaterielCode)).ToList(); |
| | | |
| | | foreach (var item in model.Details) |
| | | { |
| | | if (string.IsNullOrEmpty(item.Barcode)) |
| | | { |
| | | |
| | | } |
| | | else |
| | | if (!string.IsNullOrEmpty(item.Barcode)) |
| | | { |
| | | Dt_AllocateOrderDetail? allocateOrderDetail = allocateOrder.Details.FirstOrDefault(x => x.Barcode == item.Barcode); |
| | | if (allocateOrderDetail == null) |
| | |
| | | BarcodeQty = (decimal)item.BarcodeQty, |
| | | OrderQuantity = item.OrderQuantity |
| | | }; |
| | | if (materielInfos.Any()) |
| | | { |
| | | allocateOrderDetail.MaterielName = materielInfos.FirstOrDefault(x => x.MaterielCode == item.MaterielCode)?.MaterielName ?? ""; |
| | | } |
| | | allocateOrderDetails.Add(allocateOrderDetail); |
| | | } |
| | | else |
| | |
| | | allocateOrderDetail.BarcodeUnit = item.BarcodeUnit; |
| | | allocateOrderDetail.BarcodeQty = item.BarcodeQty; |
| | | allocateOrderDetail.OrderQuantity = item.OrderQuantity; |
| | | |
| | | if (materielInfos.Any()) |
| | | { |
| | | allocateOrderDetail.MaterielName = materielInfos.FirstOrDefault(x => x.MaterielCode == item.MaterielCode)?.MaterielName ?? ""; |
| | | } |
| | | |
| | | updateAllocateOrderDetails.Add(allocateOrderDetail); |
| | | detailIds.Add(allocateOrderDetail.Id); |
| | |
| | | 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); |
| | |
| | | |
| | | 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 Id = _InboundOrder == null ? 0 : _InboundOrder.Id; |
| | | var data = BaseDal.Db.Queryable<Dt_InboundOrderDetail>() |
| | | .WhereIF(!wheres.IsNullOrEmpty(), wheres) |
| | | .WhereIF(!_InboundOrder.IsNullOrEmpty(), x => x.OrderId == _InboundOrder.Id) |
| | | .Where( x => x.OrderId == Id) |
| | | .OrderBy(orderByModels) |
| | | .ToPageList(options.Page, options.Rows, ref totalCount); |
| | | |