| | |
| | | private readonly IMaterialUnitService _materialUnitService; |
| | | private readonly IInboundOrderDetailService _inboundOrderDetailService; |
| | | private readonly IRepository<Dt_InboundOrderDetail> _inboundOrderDetailRepository; |
| | | private readonly IRepository<Dt_StockInfoDetail> _stockDetailRepository; |
| | | private readonly IRepository<Dt_InboundOrder> _inboundOrderRepository; |
| | | 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) : 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) : base(BaseDal) |
| | | { |
| | | _mapper = mapper; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | |
| | | _stockService = stockService; |
| | | _inboundOrderDetailService = inboundOrderDetailService; |
| | | _materialUnitService = materialUnitService; |
| | | _stockDetailRepository = stockDetailRepository; |
| | | _inboundOrderRepository = inboundOrderRepository; |
| | | } |
| | | |
| | | public async Task<WebResponseContent> ReceiveInboundOrder(List<Dt_InboundOrder> models, int operateType) |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | public WebResponseContent UnPalletQuantity(string orderNo) |
| | | { |
| | | // åå§åè¿åDTOï¼é»è®¤å¼é½ä¸º0ï¼é¿å
nullï¼ |
| | | var resultDTO = new PalletSumQuantityDTO |
| | | { |
| | | StockSumQuantity = 0, |
| | | StockCount = 0, |
| | | UniqueUnit="" |
| | | }; |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | if (string.IsNullOrWhiteSpace(orderNo)) |
| | | { |
| | | return content.Error("ä¼ å
¥ç订åå·orderNo为空æç©ºç½"); |
| | | } |
| | | var orderDetail = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Includes(x => x.Details).Where(s => s.InboundOrderNo == orderNo).First(); |
| | | if (orderDetail == null) |
| | | { |
| | | return content.Error("æªæ¾å°åæ®"); |
| | | } |
| | | var unitGroups = orderDetail.Details.GroupBy(d => d.Unit).ToList(); |
| | | if (unitGroups.Count == 1) |
| | | { |
| | | resultDTO.UniqueUnit = unitGroups.First().Key; |
| | | } |
| | | else |
| | | { |
| | | 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; |
| | | } |
| | | return content.OK("",resultDTO); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error("SumQuantity ç»è®¡åºåæ°é失败ï¼è®¢åå·ï¼{OrderNo}"); |
| | | } |
| | | } |
| | | } |
| | | } |