From 0b99644eea91bf40583bbd42279535466777e728 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 11 Jul 2023 11:35:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E9=99=A4warning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.WarehouseMgr/WmsInStockService.cs | 44 ++++++++++--------- .../Options/ConfigureSwaggerUIOptions.cs | 37 ++++++++++++++++ 2 files changed, 60 insertions(+), 21 deletions(-) create mode 100644 common/Tnb.Common/Options/ConfigureSwaggerUIOptions.cs diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs index 729a1728..84064d4e 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs @@ -85,7 +85,7 @@ namespace Tnb.WarehouseMgr [HttpPost] public async Task BarCodePrint(BarCodePrintInput input) { - if (input == null) throw new ArgumentNullException("input"); + if (input == null) throw new ArgumentNullException(nameof(input)); if (input.BillIds == null || input.BillIds.Count == 0) throw new ArgumentException($"parameter {nameof(input.BillIds)} not be null or zero"); try { @@ -161,28 +161,30 @@ namespace Tnb.WarehouseMgr private Task CreateInstock(WmsInstockD detail, int no) { - WmsTempCode barCode = new(); - barCode.org_id = detail.org_id; - barCode.material_id = detail.material_id; - barCode.material_code = detail.material_code; var code = $"{detail.material_code}{detail.code_batch}{no.ToString().PadLeft(4, '0')}"; - barCode.barcode = code; - barCode.code_batch = detail.code_batch; - barCode.codeqty = detail.pr_qty!.Value; - barCode.unit_id = detail.unit_id; - barCode.is_lock = 0; - barCode.is_end = 0; - barCode.require_id = detail.bill_id; - barCode.require_code = _dicBillCodes.ContainsKey(detail.bill_id) ? _dicBillCodes[detail.bill_id]?.ToString() : ""; - barCode.create_id = _userManager.UserId; - barCode.create_time = DateTime.Now; + WmsTempCode barCode = new() + { + org_id = detail.org_id, + material_id = detail.material_id, + material_code = detail.material_code, + barcode = code, + code_batch = detail.code_batch, + codeqty = detail.pr_qty!.Value, + unit_id = detail.unit_id, + is_lock = 0, + is_end = 0, + require_id = detail.bill_id, + require_code = _dicBillCodes.ContainsKey(detail.bill_id) ? _dicBillCodes[detail.bill_id]?.ToString() : "", + create_id = _userManager.UserId, + create_time = DateTime.Now + }; return Task.FromResult(barCode); } public override async Task ModifyAsync(WareHouseUpInput input) { - if (input == null) throw new ArgumentNullException("input"); + if (input == null) throw new ArgumentNullException(nameof(input)); //更具distaskCode的barcode 更新 instockcode 的 is_end 为 1 try { @@ -351,7 +353,7 @@ namespace Tnb.WarehouseMgr List pretaskCodes = new(); foreach (var pt in preTasks) { - if (instockCOdes.Count() > 0) + if (instockCOdes.Count > 0) { foreach (var jo in instockCOdes) { @@ -377,9 +379,9 @@ namespace Tnb.WarehouseMgr var preTaskUpInput = new GenPreTaskUpInput(); preTaskUpInput.RquireId = instock.id; preTaskUpInput.CarryId = instock.carry_id!; - preTaskUpInput.CarryStartLocationId = points.FirstOrDefault()!.location_id!; - preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault()!.location_code!; - preTaskUpInput.LocationIds = points.Select(x => x.location_id).ToList()!; + preTaskUpInput.CarryStartLocationId = points.FirstOrDefault()?.location_id; + preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault()?.location_code; + preTaskUpInput.LocationIds = (points?.Select(x => x.location_id)?.ToList() ?? Enumerable.Empty().ToList()) as List; //创建预任务操作记录 var operBillId = string.Empty; @@ -393,7 +395,7 @@ namespace Tnb.WarehouseMgr preTaskUpInput.PreTaskRecord = handleH; } //创建预任务条码操作记录 - if (instockcodes != null && instockcodes.Count() > 0) + if (instockcodes?.Count > 0) { foreach (var jo in instockcodes) { diff --git a/common/Tnb.Common/Options/ConfigureSwaggerUIOptions.cs b/common/Tnb.Common/Options/ConfigureSwaggerUIOptions.cs new file mode 100644 index 00000000..2b17b266 --- /dev/null +++ b/common/Tnb.Common/Options/ConfigureSwaggerUIOptions.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Options; +using Swashbuckle.AspNetCore.SwaggerUI; + +namespace Tnb.Common.Options +{ + public class ConfigureSwaggerUIOptions : IConfigureOptions + { + private readonly IWebHostEnvironment _hostingEnvironment; + + public ConfigureSwaggerUIOptions(IWebHostEnvironment hostingEnvironment) + { + _hostingEnvironment = hostingEnvironment; + } + + public void Configure(SwaggerUIOptions options) + { + // Configure SwaggerUI options + + options.DefaultModelExpandDepth(2); + options.DefaultModelRendering(ModelRendering.Example); + options.DocExpansion(DocExpansion.List); + options.EnableDeepLinking(); + options.DisplayOperationId(); + options.EnableFilter(); + options.MaxDisplayedTags(5); + options.ShowExtensions(); + } + } + +}