| | |
| | | private readonly IRepository<Dt_InboundOrderDetail> _inboundOrderDetailRepository; |
| | | private readonly IRepository<Dt_Task> _taskRepository; |
| | | private IStockService _stockService; |
| | | private readonly IRepository<Dt_AllocateMaterialInfo> _allocateMaterialInfo; |
| | | |
| | | public InboundService(IUnitOfWorkManage unitOfWorkManage, IInboundOrderDetailService inboundOrderDetailService, IInboundOrderService inbounOrderService, IRepository<Dt_InboundOrder> inboundOrderRepository, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IRepository<Dt_LocationType> locationTypeRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IStockService stockService, IRepository<Dt_Task> taskRepository) |
| | | public InboundService(IUnitOfWorkManage unitOfWorkManage, IInboundOrderDetailService inboundOrderDetailService, IInboundOrderService inbounOrderService, IRepository<Dt_InboundOrder> inboundOrderRepository, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IRepository<Dt_LocationType> locationTypeRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IStockService stockService, IRepository<Dt_Task> taskRepository,IRepository<Dt_AllocateMaterialInfo> allocateMaterialInfo) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | InboundOrderDetailService = inboundOrderDetailService; |
| | |
| | | _inboundOrderDetailRepository = inboundOrderDetailRepository; |
| | | _stockService = stockService; |
| | | _taskRepository = taskRepository; |
| | | _allocateMaterialInfo = allocateMaterialInfo; |
| | | } |
| | | |
| | | public async Task<WebResponseContent> GroupPallet(GroupPalletDto palletDto) |
| | |
| | | return content; |
| | | } |
| | | |
| | | public async Task<WebResponseContent> AllcatedGroupPallet(GroupPalletDto palletDto) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | (bool, string, object?) result2 = ModelValidate.ValidateModelData(palletDto); |
| | | if (!result2.Item1) return content.Error(result2.Item2); |
| | | |
| | | var code = _warehouseAreaRepository.Db.Queryable<Dt_WarehouseArea>().Where(x => x.Code == palletDto.WarehouseType).Select(x => x.Code).First(); |
| | | if (string.IsNullOrEmpty(code)) |
| | | { |
| | | return content.Error($"ä»åºä¸æ²¡æè¯¥{palletDto.WarehouseType}ç¼å·ã"); |
| | | } |
| | | |
| | | Dt_StockInfo? stockInfo = await _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == palletDto.PalletCode).FirstAsync(); |
| | | |
| | | if (_taskRepository.QueryFirst(x => x.PalletCode == palletDto.PalletCode) != null) |
| | | { |
| | | return content.Error($"该æçå·²çæä»»å¡"); |
| | | } |
| | | if (stockInfo != null && !string.IsNullOrEmpty(stockInfo.LocationCode) && stockInfo.StockStatus != (int)StockStatusEmun.ç»çæå) |
| | | { |
| | | return content.Error("已䏿¶çæçä¸è½å次ç»ç"); |
| | | } |
| | | |
| | | if (_stockService.StockInfoDetailService.ExistBarcodes(palletDto.Barcode)) |
| | | { |
| | | return content.Error($"{palletDto.Barcode} æ¡ç å¨åºåä¸å·²åå¨"); |
| | | } |
| | | |
| | | if (stockInfo == null) |
| | | { |
| | | stockInfo = new Dt_StockInfo() { PalletType = (int)PalletTypeEnum.None, LocationType = Convert.ToInt32(palletDto.locationType) }; |
| | | stockInfo.Details = new List<Dt_StockInfoDetail>(); |
| | | } |
| | | |
| | | if (stockInfo != null && stockInfo.Details.Count > 0 && stockInfo.Details.FirstOrDefault()?.WarehouseCode != palletDto.WarehouseType) |
| | | { |
| | | return content.Error($"该æçç»çä»åºä¸º{stockInfo.Details.FirstOrDefault()?.WarehouseCode}ä¸å½åä»åº{palletDto.WarehouseType}ä¸ä¸è´ï¼ä¸å
许ç»ç"); |
| | | } |
| | | Dt_AllocateMaterialInfo allocateMaterialInfo = _allocateMaterialInfo.QueryFirst(x => x.Barcode == palletDto.Barcode); |
| | | if(allocateMaterialInfo == null) |
| | | { |
| | | return content.Error($"æªæ¾å°è¯¥æ¡ç {palletDto.Barcode}éè°å
¥æºä»çä¿¡æ¯"); |
| | | } |
| | | |
| | | stockInfo.Details.Add(new Dt_StockInfoDetail |
| | | { |
| | | StockId = stockInfo == null ? 0 : stockInfo.Id, |
| | | Barcode = allocateMaterialInfo.Barcode, |
| | | MaterielCode = allocateMaterialInfo.MaterialCode, |
| | | BatchNo = allocateMaterialInfo.BatchNo, |
| | | Unit = allocateMaterialInfo.Unit, |
| | | SupplyCode = allocateMaterialInfo.SupplyCode, |
| | | WarehouseCode = palletDto.WarehouseType, |
| | | StockQuantity = allocateMaterialInfo.Quantity, |
| | | BarcodeQty = allocateMaterialInfo.Quantity, |
| | | BarcodeUnit = allocateMaterialInfo.Unit, |
| | | FactoryArea = allocateMaterialInfo.FactoryArea, |
| | | Status = 0, |
| | | OrderNo = allocateMaterialInfo.OrderNo, |
| | | BusinessType = "1", |
| | | |
| | | }); |
| | | |
| | | if (stockInfo.Id == 0) |
| | | { |
| | | stockInfo.PalletCode = palletDto.PalletCode; |
| | | stockInfo.StockStatus = (int)StockStatusEmun.ç»çæå; |
| | | } |
| | | stockInfo.PalletType = (int)PalletTypeEnum.None; |
| | | _unitOfWorkManage.BeginTran(); |
| | | _stockService.StockInfoService.AddMaterielGroup(stockInfo); |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | Dt_StockInfo? NewstockInfo = await _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == palletDto.PalletCode).FirstAsync(); |
| | | |
| | | return WebResponseContent.Instance.OK(data: NewstockInfo.Details.OrderByDescending(x => x.Id)); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | LogFactory.GetLog($"ç»çä¿¡æ¯").Info(true, $"ãå¼å¸¸ãï¼ã{ex.Message}ã{Environment.NewLine}ã{ex.StackTrace}ã{Environment.NewLine}{Environment.NewLine}"); |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// éªè¯ç»çæ°æ® |
| | | /// </summary> |