private async Task <string> GetNextTaskCode() { DateTime today = DateTime.Now.Date; string seqName = string.Format("TaskCode-{0:yyMMdd}", today); int nextSn = await _appSeqService.GetNextAsync(seqName).ConfigureAwait(false); return($"T{today:yyMMdd}{nextSn:000000}"); }
public async Task <ApiData> CreateOutboundOrder(CreateOutboundOrderArgs args) { OutboundOrder outboundOrder = new OutboundOrder(); string prefix = $"OBO{DateTime.Now:yyMMdd}"; int next = await _appSeqService.GetNextAsync(prefix); outboundOrder.OutboundOrderCode = $"{prefix}{next:00000}"; outboundOrder.BizType = args.BizType; outboundOrder.BizOrder = args.BizOrder; outboundOrder.Comment = args.Comment; if (args.Lines == null || args.Lines.Count == 0) { throw new InvalidOperationException("出库单应至少有一个出库行。"); } foreach (var lineInfo in args.Lines) { OutboundLine line = new OutboundLine(); var material = await _session.Query <Material>() .Where(x => x.MaterialCode == lineInfo.MaterialCode) .SingleOrDefaultAsync(); if (material == null) { throw new InvalidOperationException($"未找到编码为 {lineInfo.MaterialCode} 的物料。"); } line.Material = material; line.QuantityRequired = lineInfo.QuantityRequired; line.QuantityDelivered = 0; line.Batch = lineInfo.Batch; line.StockStatus = lineInfo.StockStatus; line.Uom = lineInfo.Uom; outboundOrder.AddLine(line); _logger.Information("已添加出库单明细,物料 {materialCode},批号 {batch},需求数量 {quantity}", line.Material.MaterialCode, line.Batch, line.QuantityRequired); } await _session.SaveAsync(outboundOrder); _logger.Information("已创建出库单 {outboundOrder}", outboundOrder); _ = await _opHelper.SaveOpAsync(outboundOrder.OutboundOrderCode); return(this.Success()); }
public async Task <int> GetNextValAsync(string seqName) { int i = await _seqService.GetNextAsync(seqName); return(i); }