| | |
| | | namespace WIDESEA_StockService |
| | | { |
| | | /// <summary> |
| | | /// 库存服务 |
| | | /// 库存服务聚合实现类 |
| | | /// </summary> |
| | | public class StockSerivce : IStockService |
| | | public class StockService : IStockService |
| | | { |
| | | /// <summary> |
| | | /// 库存明细服务 |
| | | /// </summary> |
| | | public IStockInfoDetailService StockInfoDetailService { get; } |
| | | |
| | | /// <summary> |
| | | /// 库存信息服务 |
| | | /// </summary> |
| | | public IStockInfoService StockInfoService { get; } |
| | | |
| | | /// <summary> |
| | | /// 库存明细历史服务 |
| | | /// </summary> |
| | | public IStockInfoDetail_HtyService StockInfoDetail_HtyService { get; } |
| | | |
| | | /// <summary> |
| | | /// 库存历史服务 |
| | | /// </summary> |
| | | public IStockInfo_HtyService StockInfo_HtyService { get; } |
| | | |
| | | public StockSerivce( |
| | | /// <summary> |
| | | /// 构造函数 |
| | | /// </summary> |
| | | /// <param name="stockInfoDetailService">库存明细服务</param> |
| | | /// <param name="stockInfoService">库存信息服务</param> |
| | | /// <param name="stockInfoDetail_HtyService">库存明细历史服务</param> |
| | | /// <param name="stockInfo_HtyService">库存历史服务</param> |
| | | public StockService( |
| | | IStockInfoDetailService stockInfoDetailService, |
| | | IStockInfoService stockInfoService, |
| | | IStockInfoDetail_HtyService stockInfoDetail_HtyService, |
| | |
| | | /// </summary> |
| | | public async Task<WebResponseContent> ChangePalletAsync(StockDTO stock) |
| | | { |
| | | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | if (stock == null || |
| | | string.IsNullOrWhiteSpace(stock.TargetPalletNo) || |
| | |
| | | return content.Error("源托盘号与目标托盘号相同"); |
| | | } |
| | | |
| | | var sourceStock = StockInfoService.Repository.QueryFirst(s => s.PalletCode == stock.SourcePalletNo); |
| | | var sourceStock = await StockInfoService.Repository.QueryDataNavFirstAsync(s => s.PalletCode == stock.SourcePalletNo); |
| | | if (sourceStock == null) return content.Error("源托盘不存在"); |
| | | |
| | | var targetStock = StockInfoService.Repository.QueryFirst(s => s.PalletCode == stock.TargetPalletNo); |
| | |
| | | targetStock.Id = newId; |
| | | } |
| | | |
| | | var serialNumbers = stock.Details.Select(d => d.CellBarcode).Distinct().ToList(); |
| | | var serialNumbers = stock.Details.Select(d => d.Channel).Distinct().ToList(); |
| | | if (!serialNumbers.Any()) return content.Error("未找到有效的序列号"); |
| | | |
| | | var detailEntities = StockInfoDetailService.Repository.QueryData( |
| | | d => d.StockId == sourceStock.Id && serialNumbers.Contains(d.SerialNumber)); |
| | | d => d.StockId == sourceStock.Id && serialNumbers.Contains(d.InboundOrderRowNo)); |
| | | if (!detailEntities.Any()) return content.Error("未找到有效的库存明细"); |
| | | |
| | | if (await StockInfoDetail_HtyService.Repository.AddDataAsync(CreateDetailHistory(detailEntities, "换盘")) <= 0) |
| | |
| | | Creater = s.Creater, |
| | | CreateDate = s.CreateDate, |
| | | Modifier = s.Modifier, |
| | | ModifyDate = s.ModifyDate |
| | | ModifyDate = s.ModifyDate, |
| | | LocationId = s.LocationId, |
| | | OutboundDate = s.OutboundDate |
| | | }).ToList(); |
| | | } |
| | | } |