diff --git a/Framework/YLErp.Core/Configuration/Abstract/IErpConfig.cs b/Framework/YLErp.Core/Configuration/Abstract/IErpConfig.cs index 007e2eeb..8e00b1b4 100644 --- a/Framework/YLErp.Core/Configuration/Abstract/IErpConfig.cs +++ b/Framework/YLErp.Core/Configuration/Abstract/IErpConfig.cs @@ -719,5 +719,10 @@ namespace YLErp.Configuration /// 密码错误锁定时间(分钟) /// int PasswordErrorLockMinutes { get; } + + /// + /// 收盘回调地址 + /// + string EodExecCallbackUrl { get; } } } \ No newline at end of file diff --git a/Framework/YLErp.Core/Configuration/ProjectSettings.cs b/Framework/YLErp.Core/Configuration/ProjectSettings.cs index 2aeaaffa..f88f6d9c 100644 --- a/Framework/YLErp.Core/Configuration/ProjectSettings.cs +++ b/Framework/YLErp.Core/Configuration/ProjectSettings.cs @@ -835,6 +835,11 @@ namespace YLErp /// 注意:此默认值应与appconfig.xml中的配置保持一致 /// public int PasswordErrorLockMinutes { get; set; } = 120; // 默认120分钟 + + /// + /// 收盘回调地址 + /// + public string EodExecCallbackUrl { get; set; } = string.Empty; } } } \ No newline at end of file diff --git a/YLErpDAL/Modules/ApiModule/HttpClientWrap.cs b/YLErpDAL/Modules/ApiModule/HttpClientWrap.cs index 6a4ebcf6..1ee05227 100644 --- a/YLErpDAL/Modules/ApiModule/HttpClientWrap.cs +++ b/YLErpDAL/Modules/ApiModule/HttpClientWrap.cs @@ -77,6 +77,24 @@ namespace YLErp.Modules.ApiModule } } } + + + /// + /// 发送Post请求 + /// + /// + /// + /// + public static async Task PostAsync(string url, string data, int timeoutSeconds = 15) + { + using (var client = new HttpClient()) + { + client.Timeout = TimeSpan.FromSeconds(timeoutSeconds); + var content = new StringContent(data, Encoding.UTF8, "application/json"); + var response = await client.PostAsync(url, content); + return await response.Content.ReadAsStringAsync(); + } + } /// /// POST提交JSON请求到WebAPI并将返回字符串结果 diff --git a/YLErpDAL/Modules/EodModule/SettlementModule/EodTaskRunner.cs b/YLErpDAL/Modules/EodModule/SettlementModule/EodTaskRunner.cs index b57c27b7..eb3da751 100644 --- a/YLErpDAL/Modules/EodModule/SettlementModule/EodTaskRunner.cs +++ b/YLErpDAL/Modules/EodModule/SettlementModule/EodTaskRunner.cs @@ -1,6 +1,7 @@ using System.Text; using YLErp.BLL.EodSettlement; using YLErp.Configuration; +using YLErp.Modules.ApiModule; using YLErp.Modules.EodFileModule; using YLErp.Modules.EodModule.CompanySpecial; using YLErp.Modules.ExchangeOptionTradeModule; @@ -421,6 +422,24 @@ where {nameof(t.TaskStartTime)}>'{startDateStr}' and {nameof(t.TaskState)}={(int var runner = new InnerTaskRunner(request.Clone(true), settlementConfig, _cancellationTokenSource); runner.Execute(out var elapsedMilliseconds); detail.ElapsedMilliseconds += (int)elapsedMilliseconds; + #region 收盘动作 回调 用于收盘后 部分接口功能开发 + try + { + //回调地址不为空就启用回调 + if (!String.IsNullOrWhiteSpace(PS.Config.ErpElement.EodExecCallbackUrl)) + { + var url = PS.Config.ErpElement.EodExecCallbackUrl; + var callbackjson = request.ToJson(); + LogFactory.GetLogger("收盘回调收盘参数:").Info(callbackjson); + var asyncTask = HttpClientWrap.PostAsync(url, callbackjson); + LogFactory.GetLogger("收盘回调结果:").Info(asyncTask?.Result); + } + } + catch (Exception e) + { + LogFactory.GetLogger("收盘动作回调").Error("收盘回调:失败:", e); + } + #endregion } } }