| | |
| | | { |
| | | public class OutboundOrderDetailService : ServiceBase<Dt_OutboundOrderDetail, IOutboundOrderDetailRepository>, IOutboundOrderDetailService |
| | | { |
| | | private readonly IStockInfoService _stockInfoService; |
| | | private readonly IStockInfoDetailService _stockInfoDetailService; |
| | | private readonly IOutStockLockInfoService _outStockLockInfoService; |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | private readonly ILocationStatusChangeRecordSetvice _locationStatusChangeRecordSetvice; |
| | | private readonly IOutboundOrderService _outboundOrderService; |
| | | private readonly ILocationInfoService _locationInfoService; |
| | | |
| | | private readonly IStockService _stockService; |
| | | private readonly IBasicService _basicService; |
| | | private readonly IRecordService _recordService; |
| | | private readonly IOutboundRepository _outboundRepository; |
| | | private readonly IOutStockLockInfoService _outStockLockInfoService; |
| | | |
| | | public IOutboundOrderDetailRepository Repository => BaseDal; |
| | | |
| | | public OutboundOrderDetailService(IOutboundOrderDetailRepository BaseDal, IStockInfoService stockInfoService, IOutStockLockInfoService outStockLockInfoService, IUnitOfWorkManage unitOfWorkManage, ILocationStatusChangeRecordSetvice locationStatusChangeRecordSetvice, IOutboundOrderService outboundOrderService, ILocationInfoService locationInfoService, IStockInfoDetailService stockInfoDetailService) : base(BaseDal) |
| | | public OutboundOrderDetailService(IOutboundOrderDetailRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockService stockService, IBasicService basicService, IRecordService recordService, IOutboundRepository outboundRepository, IOutStockLockInfoService outStockLockInfoService) : base(BaseDal) |
| | | { |
| | | _stockInfoService = stockInfoService; |
| | | _outStockLockInfoService = outStockLockInfoService; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _locationStatusChangeRecordSetvice = locationStatusChangeRecordSetvice; |
| | | _outboundOrderService = outboundOrderService; |
| | | _locationInfoService = locationInfoService; |
| | | _stockInfoDetailService = stockInfoDetailService; |
| | | _stockService = stockService; |
| | | _basicService = basicService; |
| | | _recordService = recordService; |
| | | _outboundRepository = outboundRepository; |
| | | _outStockLockInfoService = outStockLockInfoService; |
| | | } |
| | | // |
| | | public WebResponseContent LockOutboundStock(int orderDetailId) |
| | |
| | | |
| | | List<Dt_StockInfo> outStock = new List<Dt_StockInfo>(); |
| | | |
| | | List<Dt_StockInfo> stockInfos = _stockInfoService.GetUseableStocks(outboundOrderDetail.MaterielCode); |
| | | List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(outboundOrderDetail.MaterielCode); |
| | | decimal stockTotalQuantity = stockInfos.Select(x => x.Details.Sum(v => v.StockQuantity - v.OutboundQuantity)).Sum(x => x); |
| | | if (stockTotalQuantity >= needQuantity)//åºåå¤ |
| | | { |
| | |
| | | (bool, string) checkResult = CheckSelectStockDeital(outboundOrderDetail, stockSelectViews); |
| | | if (!checkResult.Item1) throw new Exception(checkResult.Item2); |
| | | |
| | | Dt_OutboundOrder outboundOrder = _outboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetail.OrderId); |
| | | Dt_OutboundOrder outboundOrder = _outboundRepository.OutboundOrderRepository.QueryFirst(x => x.Id == outboundOrderDetail.OrderId); |
| | | decimal originalNeedQuantity = outboundOrderDetail.OrderQuantity - outboundOrderDetail.LockQuantity; |
| | | |
| | | decimal needQuantity = originalNeedQuantity; |
| | | |
| | | List<Dt_StockInfo> outStocks = _stockInfoService.Repository.GetStockInfosByPalletCodes(stockSelectViews.Select(x => x.PalletCode).ToList()); |
| | | List<Dt_StockInfo> outStocks = _stockService.StockInfoService.Repository.GetStockInfosByPalletCodes(stockSelectViews.Select(x => x.PalletCode).ToList()); |
| | | decimal assignQuantity = 0; |
| | | outStocks.ForEach(x => |
| | | { |
| | |
| | | needQuantity -= assignQuantity; |
| | | if (outboundOrderDetail.OrderQuantity > outboundOrderDetail.LockQuantity) |
| | | { |
| | | List<Dt_StockInfo> stockInfos = _stockInfoService.GetUseableStocks(outboundOrderDetail.MaterielCode); |
| | | List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(outboundOrderDetail.MaterielCode); |
| | | stockInfos = stockInfos.Where(x => !stockSelectViews.Select(v => v.PalletCode).Contains(x.PalletCode)).ToList(); |
| | | List<Dt_StockInfo> autoAssignStocks = _stockInfoService.GetOutboundStocks(stockInfos, outboundOrderDetail.MaterielCode, needQuantity, out decimal residueQuantity); |
| | | List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, outboundOrderDetail.MaterielCode, needQuantity, out decimal residueQuantity); |
| | | outboundOrderDetail.LockQuantity += needQuantity - residueQuantity; |
| | | outStocks.AddRange(autoAssignStocks); |
| | | outboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.AssignOver.ObjToInt(); |
| | |
| | | |
| | | List<Dt_OutStockLockInfo> outStockLockInfos = _outStockLockInfoService.GetOutStockLockInfos(outboundOrder, outboundOrderDetail, outStocks); |
| | | |
| | | List<Dt_LocationInfo> locationInfos = _locationInfoService.Repository.GetLocationInfos(outStocks.Select(x => x.LocationCode).ToList()); |
| | | List<Dt_LocationInfo> locationInfos = _basicService.LocationInfoService.Repository.GetLocationInfos(outStocks.Select(x => x.LocationCode).ToList()); |
| | | |
| | | return (outStocks, outboundOrderDetail, outStockLockInfos, locationInfos); |
| | | } |
| | |
| | | { |
| | | try |
| | | { |
| | | _stockInfoService.Repository.UpdateData(stockInfos); |
| | | _stockService.StockInfoService.Repository.UpdateData(stockInfos); |
| | | List<Dt_StockInfoDetail> stockInfoDetails = new List<Dt_StockInfoDetail>(); |
| | | foreach (var item in stockInfos) |
| | | { |
| | | stockInfoDetails.AddRange(item.Details); |
| | | } |
| | | _stockInfoDetailService.Repository.UpdateData(stockInfoDetails); |
| | | _stockService.StockInfoDetailService.Repository.UpdateData(stockInfoDetails); |
| | | BaseDal.UpdateData(outboundOrderDetails); |
| | | |
| | | List<Dt_OutStockLockInfo> addOutStockLockInfos = outStockLockInfos.Where(x => x.Id == 0).ToList(); |
| | |
| | | _outStockLockInfoService.Repository.UpdateData(updateOutStockLockInfos); |
| | | } |
| | | |
| | | _locationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfos, locationStatus.ObjToInt(), StockChangeType.Outbound.ObjToInt(), "", tasks?.Select(x => x.TaskNum).ToList()); |
| | | _locationInfoService.Repository.UpdateLocationStatus(locationInfos, locationStatus); |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfos, locationStatus.ObjToInt(), StockChangeType.Outbound.ObjToInt(), "", tasks?.Select(x => x.TaskNum).ToList()); |
| | | _basicService.LocationInfoService.Repository.UpdateLocationStatus(locationInfos, locationStatus); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | List<Dt_OutStockLockInfo> outStockLockInfos = _outStockLockInfoService.GetByOrderDetailId(orderDetailId, OutStockStatus.å·²åé
); |
| | | if (outStockLockInfos.Count > 0) |
| | | { |
| | | List<Dt_StockInfo> stocks = _stockInfoService.Repository.GetStockInfosByPalletCodes(outStockLockInfos.Select(x => x.PalletCode).ToList()); |
| | | List<Dt_StockInfo> stocks = _stockService.StockInfoService.Repository.GetStockInfosByPalletCodes(outStockLockInfos.Select(x => x.PalletCode).ToList()); |
| | | if (stocks.Count > 0) |
| | | { |
| | | stocks.ForEach(x => |
| | |
| | | x.Status = OutStockStatus.æ¤é.ObjToInt(); |
| | | }); |
| | | |
| | | List<Dt_LocationInfo> locationInfos = _locationInfoService.Repository.GetLocationInfos(stocks.Select(x => x.LocationCode).ToList()); |
| | | List<Dt_LocationInfo> locationInfos = _basicService.LocationInfoService.Repository.GetLocationInfos(stocks.Select(x => x.LocationCode).ToList()); |
| | | |
| | | return LockOutboundStockDataUpdate(stocks, new List<Dt_OutboundOrderDetail> { outboundOrderDetail }, outStockLockInfos, locationInfos, LocationStatusEnum.InStock); |
| | | } |