| | |
| | | using System.Text.RegularExpressions; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.CommonEnum; |
| | | using WIDESEA_Common.LocationEnum; |
| | | using WIDESEA_Common.OrderEnum; |
| | | using WIDESEA_Common.StockEnum; |
| | | using WIDESEA_Core; |
| | |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_Core.Seed; |
| | | using WIDESEA_Core.Utilities; |
| | | using WIDESEA_DTO.Base; |
| | | using WIDESEA_DTO.Inbound; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_IInboundService; |
| | |
| | | private readonly IRepository<Dt_WarehouseArea> _warehouseAreaRepository; |
| | | private readonly IRepository<Dt_LocationType> _locationTypeRepository; |
| | | private readonly IRepository<Dt_StockInfo> _stockRepository; |
| | | private readonly IRepository<Dt_LocationInfo> _locationInfoRepository; |
| | | private readonly IBasicService _basicService; |
| | | public IRepository<Dt_InboundOrder> Repository => BaseDal; |
| | | |
| | | public InboundOrderService(IRepository<Dt_InboundOrder> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IRepository<Dt_Task> taskRepository, IStockService stockService, IInboundOrderDetailService inboundOrderDetailService, IMaterialUnitService materialUnitService, IRepository<Dt_StockInfoDetail> stockDetailRepository, IRepository<Dt_InboundOrder> inboundOrderRepository, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IRepository<Dt_StockInfo> stockRepository, IRepository<Dt_LocationType> locationTypeRepository, IMaterielInfoService materielInfoService) : base(BaseDal) |
| | | public InboundOrderService(IRepository<Dt_InboundOrder> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IRepository<Dt_Task> taskRepository, IStockService stockService, IInboundOrderDetailService inboundOrderDetailService, IMaterialUnitService materialUnitService, IRepository<Dt_StockInfoDetail> stockDetailRepository, IRepository<Dt_InboundOrder> inboundOrderRepository, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IRepository<Dt_StockInfo> stockRepository, IRepository<Dt_LocationType> locationTypeRepository, IMaterielInfoService materielInfoService, IBasicService basicService, IRepository<Dt_LocationInfo> locationInfoRepository) : base(BaseDal) |
| | | { |
| | | _mapper = mapper; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | |
| | | _stockRepository = stockRepository; |
| | | _locationTypeRepository = locationTypeRepository; |
| | | _materielInfoService = materielInfoService; |
| | | _basicService = basicService; |
| | | _locationInfoRepository = locationInfoRepository; |
| | | } |
| | | |
| | | public async Task<WebResponseContent> ReceiveInboundOrder(List<Dt_InboundOrder> models, int operateType) |
| | |
| | | |
| | | foreach (var item in model.Details) |
| | | { |
| | | var purchaseToStockResult = await _materialUnitService.ConvertPurchaseToStockAsync(item.MaterielCode, item.BarcodeQty); |
| | | item.Unit = purchaseToStockResult.Unit; |
| | | item.OrderQuantity = purchaseToStockResult.Quantity; |
| | | //var purchaseToStockResult = await _materialUnitService.ConvertPurchaseToStockAsync(item.MaterielCode, item.BarcodeQty); |
| | | |
| | | UnitConvertResultDTO totalResult = _basicService.UnitQuantityConvert(item.MaterielCode, item.Unit, item.BarcodeUnit, item.OrderQuantity); |
| | | item.Unit = totalResult.ToUnit; |
| | | item.OrderQuantity = totalResult.ToQuantity; |
| | | if (materielInfos.Any()) |
| | | { |
| | | item.MaterielName = materielInfos.FirstOrDefault(x => x.MaterielCode == item.MaterielCode)?.MaterielName ?? ""; |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | |
| | | (bool, string, object?) result2 = ModelValidate.ValidateModelData(materielGroupDTO); |
| | | if (!result2.Item1) return content = WebResponseContent.Instance.Error(result2.Item2); |
| | | |
| | | bool code = _locationTypeRepository.Db.Queryable<Dt_LocationType>().Where(x => x.LocationType == materielGroupDTO.WarehouseCode).Any(); |
| | | bool statu = _locationInfoRepository.Db.Queryable<Dt_LocationInfo>().Where(x => x.LocationType == materielGroupDTO.WarehouseCode && x.LocationStatus == (int)LocationStatusEnum.Free).Any(); |
| | | if (!statu) |
| | | { |
| | | return content = WebResponseContent.Instance.Error($"该åºåæ è´§ä½å¯åé
"); |
| | | } |
| | | if (!code) |
| | | { |
| | | return content = WebResponseContent.Instance.Error($"åºå䏿²¡æè¯¥{materielGroupDTO.WarehouseCode}ç¼å·ã"); |
| | |
| | | { |
| | | resultDTO.UniqueUnit = ""; |
| | | } |
| | | var validDetails = _stockDetailRepository.Db.Queryable<Dt_StockInfoDetail>().Where(s => s.OrderNo == orderNo).ToList(); |
| | | resultDTO.StockSumQuantity = orderDetail.Details.Sum(d => d.OrderQuantity); |
| | | resultDTO.StockCount = orderDetail.Details.Count; |
| | | if (validDetails.Any()) |
| | | { |
| | | resultDTO.StockSumQuantity -= validDetails.Sum(d => d.StockQuantity); |
| | | // æç»è®°å½æ°ï¼ç¬¦åæ¡ä»¶çææè®°å½æ¡æ° |
| | | resultDTO.StockCount -= validDetails.Count; |
| | | } |
| | | var inbound =_inboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Where(x => x.InboundOrderNo == orderNo); |
| | | var inboundDetails = _inboundOrderDetailRepository.Db.Queryable<Dt_InboundOrderDetail>().Where(x => x.OrderId == inbound.First().Id).ToList(); |
| | | resultDTO.StockSumQuantity = inboundDetails.Where(x=>x.ReceiptQuantity==0).Sum(x=>x.OrderQuantity); |
| | | resultDTO.StockCount = inboundDetails.Where(x => x.ReceiptQuantity == 0).Count(); |
| | | //var validDetails = _stockDetailRepository.Db.Queryable<Dt_StockInfoDetail>().Where(s => s.OrderNo == orderNo).ToList(); |
| | | //resultDTO.StockSumQuantity = orderDetail.Details.Sum(d => d.OrderQuantity); |
| | | //resultDTO.StockCount = orderDetail.Details.Count; |
| | | //if (validDetails.Any()) |
| | | //{ |
| | | // resultDTO.StockSumQuantity -= validDetails.Sum(d => d.StockQuantity); |
| | | // // æç»è®°å½æ°ï¼ç¬¦åæ¡ä»¶çææè®°å½æ¡æ° |
| | | // resultDTO.StockCount -= validDetails.Count; |
| | | //} |
| | | return content.OK("", resultDTO); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | // return new PageGridData<Dt_InboundOrder>(); |
| | | //} |
| | | |
| | | public WebResponseContent UnPalletGroupBarcode(string orderNo) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | var inbound = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Where(x => x.InboundOrderNo == orderNo).First(); |
| | | if(inbound == null) |
| | | { |
| | | return content.Error(); |
| | | } |
| | | |
| | | var details = _inboundOrderDetailRepository.Db.Queryable<Dt_InboundOrderDetail>().Where(x => x.OrderId == inbound.Id && x.ReceiptQuantity == 0).ToList(); |
| | | |
| | | return content.OK(data:details); |
| | | } |
| | | } |
| | | } |