feat:收盘回调功能接口添加

This commit is contained in:
xuyulong
2026-04-21 15:49:44 +08:00
parent 0bd3b6bb0e
commit 7d02edf6ff
4 changed files with 47 additions and 0 deletions
@@ -719,5 +719,10 @@ namespace YLErp.Configuration
/// 密码错误锁定时间(分钟)
/// </summary>
int PasswordErrorLockMinutes { get; }
/// <summary>
/// 收盘回调地址
/// </summary>
string EodExecCallbackUrl { get; }
}
}
@@ -835,6 +835,11 @@ namespace YLErp
/// 注意:此默认值应与appconfig.xml中的配置保持一致
/// </summary>
public int PasswordErrorLockMinutes { get; set; } = 120; // 默认120分钟
/// <summary>
/// 收盘回调地址
/// </summary>
public string EodExecCallbackUrl { get; set; } = string.Empty;
}
}
}
@@ -77,6 +77,24 @@ namespace YLErp.Modules.ApiModule
}
}
}
/// <summary>
/// 发送Post请求
/// </summary>
/// <param name="url"></param>
/// <param name="data"></param>
/// <returns></returns>
public static async Task<string> 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();
}
}
/// <summary>
/// POST提交JSON请求到WebAPI并将返回字符串结果
@@ -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
}
}
}