From 9a874ee47e02230420880be31536606939aced8a Mon Sep 17 00:00:00 2001 From: mahao Date: Wed, 12 Apr 2023 09:47:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B6=E4=BB=96=E9=A2=86=E7=89=A9=E6=96=99?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=89=8D=E7=BD=AE=E8=BF=87=E6=BB=A4=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- host/WmsWebApi.HttpApi.Host/appsettings.json | 53 ++++++++++--------- .../OtherZll/OtherZllService.cs | 19 ++++++- .../ZlldcjLogs/ZlldcjLogAppService.cs | 2 +- .../Options/CustomConfigOptions.cs | 13 +++++ .../Options/OtherZllConfigOptions.cs | 15 ++++++ src/WmsWebApi.Domain/WmsWebApiDomainModule.cs | 17 +++++- 6 files changed, 92 insertions(+), 27 deletions(-) create mode 100644 src/WmsWebApi.Domain/Options/CustomConfigOptions.cs create mode 100644 src/WmsWebApi.Domain/Options/OtherZllConfigOptions.cs diff --git a/host/WmsWebApi.HttpApi.Host/appsettings.json b/host/WmsWebApi.HttpApi.Host/appsettings.json index 9d60b54..665c6ec 100644 --- a/host/WmsWebApi.HttpApi.Host/appsettings.json +++ b/host/WmsWebApi.HttpApi.Host/appsettings.json @@ -1,29 +1,34 @@ { - "App": { - "Urls": "http://localhost:5000", - "CorsOrigins": "http://localhost:5000" - }, - "ConnectionStrings": { - //"Default": "Server=192.168.0.63;Database=ABP;User ID=sa;Password=Microsoft2008", - //"WmsWebApi": "Server=192.168.0.63;Database=CPAT_WMS;User ID=sa;Password=Microsoft2008", - //"WmsWebApiJson": "Server=192.168.0.63;Database=CPAT_WMS_Json;User ID=sa;Password=Microsoft2008", - //"AbpBackgroundJobs": "Server=192.168.0.63;Database=CPAT_WMS_Json;User ID=sa;Password=Microsoft2008", + "App": { + "Urls": "http://localhost:5000", + "CorsOrigins": "http://localhost:5000" + }, + "ConnectionStrings": { + //"Default": "Server=192.168.0.63;Database=ABP;User ID=sa;Password=Microsoft2008", + //"WmsWebApi": "Server=192.168.0.63;Database=CPAT_WMS;User ID=sa;Password=Microsoft2008", + //"WmsWebApiJson": "Server=192.168.0.63;Database=CPAT_WMS_Json;User ID=sa;Password=Microsoft2008", + //"AbpBackgroundJobs": "Server=192.168.0.63;Database=CPAT_WMS_Json;User ID=sa;Password=Microsoft2008", - "Default": "Server=192.168.0.140;Database=ABP;User ID=sa;Password=Microsoft2008", - "WmsWebApi": "Server=192.168.0.140;Database=CPAT_WMS_TEST;User ID=sa;Password=Microsoft2008", - "WmsWebApiJson": "Server=192.168.0.140;Database=CPAT_WMS_Json_TEST;User ID=sa;Password=Microsoft2008", - "AbpBackgroundJobs": "Server=192.168.0.140;Database=CPAT_WMS_Json_TEST;User ID=sa;Password=Microsoft2008", + "Default": "Server=192.168.0.140;Database=ABP;User ID=sa;Password=Microsoft2008", + "WmsWebApi": "Server=192.168.0.140;Database=CPAT_WMS_TEST;User ID=sa;Password=Microsoft2008", + "WmsWebApiJson": "Server=192.168.0.140;Database=CPAT_WMS_Json_TEST;User ID=sa;Password=Microsoft2008", + "AbpBackgroundJobs": "Server=192.168.0.140;Database=CPAT_WMS_Json_TEST;User ID=sa;Password=Microsoft2008", - "AgvInLoc": "A01", - "AgvOutLoc": "B01" - }, - "Redis": { - "Configuration": "127.0.0.1" - }, - "AuthServer": { - "Authority": "http://192.168.0.140:8066", - "RequireHttpsMetadata": "false", - "SwaggerClientId": "WmsWebApi_Swagger", - "SwaggerClientSecret": "1q2w3e*" + "AgvInLoc": "A01", + "AgvOutLoc": "B01" + }, + "Redis": { + "Configuration": "127.0.0.1" + }, + "AuthServer": { + "Authority": "http://192.168.0.140:8066", + "RequireHttpsMetadata": "false", + "SwaggerClientId": "WmsWebApi_Swagger", + "SwaggerClientSecret": "1q2w3e*" + }, + "CustomConfig": { + "OtherZllConfig": { + "ErnamFilters": [ "1023", "1024" ] } + } } diff --git a/src/WmsWebApi.Application/OtherZll/OtherZllService.cs b/src/WmsWebApi.Application/OtherZll/OtherZllService.cs index 6ce84b8..5c90cd7 100644 --- a/src/WmsWebApi.Application/OtherZll/OtherZllService.cs +++ b/src/WmsWebApi.Application/OtherZll/OtherZllService.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Newtonsoft.Json; using Polly; using Polly.Retry; @@ -14,6 +15,7 @@ using WmsWebApi.BackgroundJobs; using WmsWebApi.EntityFrameworkCore; using WmsWebApi.Enums; using WmsWebApi.Jsons; +using WmsWebApi.Options; using WmsWebApi.Wms; namespace WmsWebApi.OtherZll; @@ -36,6 +38,7 @@ public class OtherZllService : ApplicationService, IOtherZllService private readonly IBackgroundJobRequestRetry _backgroundJobRequestRetry; private readonly IOtherZllJsonRepository _otherZllJsonRepository; private readonly AsyncRetryPolicy _asyncRetryPolicy; + private readonly OtherZllConfigOptions _otherZllConfigOptions; /// /// 是否是请求重试 @@ -52,7 +55,9 @@ public class OtherZllService : ApplicationService, IOtherZllService TmPgWmsUpdate tmPgWmsUpdate, Volo.Abp.Uow.IUnitOfWorkManager unitOfWorkManager, IBackgroundJobRequestRetry backgroundJobRequestRetry, - IOtherZllJsonRepository otherZllJsonRepository) + IOtherZllJsonRepository otherZllJsonRepository, + IOptionsMonitor customConfigOptions, + IOptionsMonitor otherZllConfigOptions) { _tsStockDetailRepository = tsStockDetailRepository; _tbProductReceiveRepository = tbProductReceiveRepository; @@ -75,6 +80,7 @@ public class OtherZllService : ApplicationService, IOtherZllService { Logger.LogInformation($"执行失败,第 {retryCount} 次重试"); }); + _otherZllConfigOptions = otherZllConfigOptions.CurrentValue; } [HttpPost("add")] @@ -93,6 +99,17 @@ public class OtherZllService : ApplicationService, IOtherZllService result.MESSAGE = "Json格式不正确,详细信息:" + ex.Message; return result; } + + if (_dtoList != null && _dtoList.Count() > 0) + { + //根据配置文件过滤ERNAM + var ernamFilters = _otherZllConfigOptions.ErnamFilters; + if (ernamFilters != null && ernamFilters.Count > 0) + { + _dtoList = _dtoList.FindAll(e => !ernamFilters.Contains(e.ERNAM)); + } + } + if (_dtoList == null || _dtoList.Count() <= 0) { bErr = true; diff --git a/src/WmsWebApi.Application/ZlldcjLogs/ZlldcjLogAppService.cs b/src/WmsWebApi.Application/ZlldcjLogs/ZlldcjLogAppService.cs index 910e0d5..df4cda5 100644 --- a/src/WmsWebApi.Application/ZlldcjLogs/ZlldcjLogAppService.cs +++ b/src/WmsWebApi.Application/ZlldcjLogs/ZlldcjLogAppService.cs @@ -114,7 +114,7 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService result.MESSAGE = "Json格式不正确,详细信息:" + ex.GetBaseException().Message; return result; } - if (dtos == null || dtos.Count == 0) + if (dtos == null || dtos.Count <= 0) { bErr = true; result.MESSAGE = "err:没有1000工厂数据"; diff --git a/src/WmsWebApi.Domain/Options/CustomConfigOptions.cs b/src/WmsWebApi.Domain/Options/CustomConfigOptions.cs new file mode 100644 index 0000000..f4d8396 --- /dev/null +++ b/src/WmsWebApi.Domain/Options/CustomConfigOptions.cs @@ -0,0 +1,13 @@ +namespace WmsWebApi.Options +{ + /// + /// 自定义配置选项 + /// + public class CustomConfigOptions + { + /// + /// 其他领物料配置 + /// + public OtherZllConfigOptions OtherZllConfig { get; set; } + } +} diff --git a/src/WmsWebApi.Domain/Options/OtherZllConfigOptions.cs b/src/WmsWebApi.Domain/Options/OtherZllConfigOptions.cs new file mode 100644 index 0000000..faddcf2 --- /dev/null +++ b/src/WmsWebApi.Domain/Options/OtherZllConfigOptions.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; + +namespace WmsWebApi.Options +{ + /// + /// 其他领物料配置选项 + /// + public class OtherZllConfigOptions + { + /// + /// 创建对象的人员名称过滤 + /// + public List ErnamFilters { get; set; } + } +} diff --git a/src/WmsWebApi.Domain/WmsWebApiDomainModule.cs b/src/WmsWebApi.Domain/WmsWebApiDomainModule.cs index e85615a..9fb1fa7 100644 --- a/src/WmsWebApi.Domain/WmsWebApiDomainModule.cs +++ b/src/WmsWebApi.Domain/WmsWebApiDomainModule.cs @@ -1,5 +1,8 @@ -using Volo.Abp.Domain; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Domain; using Volo.Abp.Modularity; +using WmsWebApi.Options; namespace WmsWebApi { @@ -9,6 +12,18 @@ namespace WmsWebApi )] public class WmsWebApiDomainModule : AbpModule { + public override void ConfigureServices(ServiceConfigurationContext context) + { + base.ConfigureServices(context); + + IConfiguration configuration = context.Services.GetConfiguration(); + + #region Options + context.Services.AddOptions(); + Configure(configuration.GetSection("CustomConfig")); + Configure(configuration.GetSection("CustomConfig:OtherZllConfig")); + #endregion + } } }