岩仔88 1 month ago
parent a2ff92145a
commit 5d3c06c12c

@ -0,0 +1,133 @@
{
"$schema": "https://opencode.ai/config.json",
"provider":{
"bailian-coding-plan": {
"npm": "@ai-sdk/anthropic",
"name": "Model Studio Coding Plan",
"options": {
"baseURL": "https://coding.dashscope.aliyuncs.com/apps/anthropic/v1",
"apiKey": "sk-sp-08990303176d4bfeb36f8eef6a46484f"
},
"models": {
"qwen3.5-plus": {
"name": "Qwen3.5 Plus",
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
},
"limit": {
"context": 1000000,
"output": 65536
}
},
"qwen3-max-2026-01-23": {
"name": "Qwen3 Max 2026-01-23",
"modalities": {
"input": ["text"],
"output": ["text"]
},
"limit": {
"context": 262144,
"output": 32768
}
},
"qwen3-coder-next": {
"name": "Qwen3 Coder Next",
"modalities": {
"input": ["text"],
"output": ["text"]
},
"limit": {
"context": 262144,
"output": 65536
}
},
"qwen3-coder-plus": {
"name": "Qwen3 Coder Plus",
"modalities": {
"input": ["text"],
"output": ["text"]
},
"limit": {
"context": 1000000,
"output": 65536
}
},
"MiniMax-M2.5": {
"name": "MiniMax M2.5",
"modalities": {
"input": ["text"],
"output": ["text"]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
},
"limit": {
"context": 204800,
"output": 131072
}
},
"glm-5": {
"name": "GLM-5",
"modalities": {
"input": ["text"],
"output": ["text"]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
},
"limit": {
"context": 202752,
"output": 16384
}
},
"glm-4.7": {
"name": "GLM-4.7",
"modalities": {
"input": ["text"],
"output": ["text"]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
},
"limit": {
"context": 202752,
"output": 16384
}
},
"kimi-k2.5": {
"name": "Kimi K2.5",
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
},
"limit": {
"context": 262144,
"output": 32768
}
}
}
}
}
}

@ -1,187 +1,142 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using Newtonsoft.Json; // 用于生成 JSON 数据
using Newtonsoft.Json;
namespace MyHosListener.common
{
public class Tools
{
private static Timer _timerNoPay;
private static Timer _timerNightly;
// 保持 HttpClient 单例,复用连接
static readonly HttpClient client = new HttpClient();
private static System.Timers.Timer _timerNoPay;
private static readonly HttpClient client = new HttpClient();
/// <summary>
/// 原有的委托变更通知 (GET) - 未修改
/// 通知医技取消
/// </summary>
public static async Task NoticeEntrustChange(string orderNo)
{
try
{
string url = $"http://192.168.80.76/api/PacsCancelApplyInfo?orderNo={orderNo}";
HttpResponseMessage response = await client.GetAsync(url);
var response = await client.GetAsync(url);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
MyLog.Info(responseBody);
}
catch (HttpRequestException e)
catch (Exception e)
{
MyLog.Info($"请求错误 (NoticeEntrustChange): {e.Message}");
Console.WriteLine($"请求错误: {e.Message}");
}
}
/// <summary>
/// 原有的未支付取消任务 (GET) - 未修改
/// 未支付自动取消每5分钟
/// </summary>
public static async void NoPayCancel(object sender, ElapsedEventArgs e)
private static async void NoPayCancel(object sender, System.Timers.ElapsedEventArgs e)
{
try
{
string url = $"http://192.168.80.76/api/admin/NoPayCancel";
HttpResponseMessage response = await client.GetAsync(url);
string url = "http://192.168.80.76/api/admin/NoPayCancel";
var response = await client.GetAsync(url);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
MyLog.Info(responseBody);
MyLog.Info("[NoPayCancel] " + responseBody);
}
catch (HttpRequestException es)
catch (Exception ex)
{
MyLog.Info($"请求错误 (NoPayCancel): {es.Message}");
MyLog.Info($"请求错误 (NoPayCancel): {ex.Message}");
}
}
/// <summary>
/// 新增每天晚上10点执行的任务 (POST)
/// 逻辑:计算当前日期+15天构建JSON发送POST请求
/// 夜间任务核心逻辑每天22点执行
/// </summary>
public static async void NightlyTaskHandler(object sender, ElapsedEventArgs e)
private static async Task NightlyTaskCore()
{
try
{
MyLog.Info(">>> 开始执行每日夜间定时任务 (POST)...");
MyLog.Info(">>> 夜间任务执行:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
// 1. 计算日期:当前日期 + 15天
DateTime targetDate = DateTime.Now.AddDays(15);
string dateStr = targetDate.ToString("yyyy-MM-dd");
// 2. 构建符合要求的对象
var postData = new
{
dateRange = new[] { dateStr, dateStr }, // ["2026-XX-XX", "2026-XX-XX"]
dateRange = new[] { dateStr, dateStr },
HolidayEnable = 1
};
// 3. 序列化为 JSON 字符串
string jsonContent = JsonConvert.SerializeObject(postData);
// 4. 准备 HTTP 内容 (UTF8 编码application/json 类型)
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
// TODO: 【重要】请在此处替换为你真实的夜间任务接口地址
string url = "http://192.168.80.76/api/YourNightlyApi";
MyLog.Info($"准备发送 POST 请求到: {url}");
MyLog.Info($"请求体数据: {jsonContent}");
// 5. 发送 POST 请求
HttpResponseMessage response = await client.PostAsync(url, content);
// 检查状态码,如果不是 2xx 会抛出异常
var response = await client.PostAsync(url, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
MyLog.Info($"<<< 夜间任务执行成功,响应内容: {responseBody}");
}
catch (Exception ex)
{
MyLog.Info($"!!! 夜间任务执行失败: {ex.Message}");
if (ex.InnerException != null)
{
MyLog.Info($"内部错误详情: {ex.InnerException.Message}");
}
}
finally
{
// 关键步骤:无论成功或失败,都要重新计算下一次运行时间并重启定时器
// 这样能保证即使某次报错,明天的任务依然会准时运行
ScheduleNextNightlyRun();
}
MyLog.Info("<<< 夜间任务成功:" + responseBody);
}
/// <summary>
/// 计算距离下一个晚上 22:00 的时间间隔,并配置定时器
/// 启动所有定时任务
/// </summary>
private static void ScheduleNextNightlyRun()
public static void StartRound()
{
DateTime now = DateTime.Now;
DateTime nextRun = now.Date.AddHours(22); // 设定为今天的 22:00
MyLog.Info("正在初始化定时任务模块...");
// 如果现在已超过今天 22:00则设为明天 22:00
if (nextRun <= now)
// ===== 5分钟任务 =====
if (_timerNoPay == null)
{
nextRun = nextRun.AddDays(1);
}
_timerNoPay = new System.Timers.Timer(300000); // 5分钟
_timerNoPay.Elapsed += NoPayCancel;
_timerNoPay.AutoReset = true;
_timerNoPay.Start();
// 计算毫秒差
double intervalMs = (nextRun - now).TotalMilliseconds;
MyLog.Info("[OK] 定时任务 [NoPayCancel] 已启动 (每5分钟)");
}
// 安全保护:防止负数
if (intervalMs < 0) intervalMs = 60000;
// ===== 每天22点任务 =====
Task.Run(async () =>
{
MyLog.Info("[Nightly] 每日22点任务已启动");
if (_timerNightly == null)
while (true)
{
_timerNightly = new Timer(intervalMs);
_timerNightly.Elapsed += NightlyTaskHandler;
_timerNightly.AutoReset = false; // 设置为只触发一次,由我们在回调中手动重置
}
else
try
{
_timerNightly.Interval = intervalMs;
_timerNightly.Stop();
_timerNightly.Start();
}
DateTime now = DateTime.Now;
// 确保启用
if (!_timerNightly.Enabled)
{
_timerNightly.Enabled = true;
}
// 今天22点
DateTime today22 = new DateTime(
now.Year, now.Month, now.Day, 22, 0, 0
);
double minutesToWait = intervalMs / 1000 / 60;
MyLog.Info($"[调度器] 夜间任务已设定,将于 {nextRun:yyyy-MM-dd HH:mm:ss} 执行 (约 {minutesToWait:F1} 分钟后)");
}
// 如果已经过了22点就安排到明天
DateTime nextRun = now > today22 ? today22.AddDays(1) : today22;
/// <summary>
/// 启动所有定时任务
/// </summary>
public static void StartRound()
{
MyLog.Info("正在初始化定时任务模块...");
TimeSpan delay = nextRun - now;
// 1. 启动原有的每 5 分钟任务 (GET)
if (_timerNoPay == null)
{
_timerNoPay = new Timer(300000); // 300000ms = 5分钟
_timerNoPay.Elapsed += NoPayCancel;
_timerNoPay.AutoReset = true; // 自动重复
_timerNoPay.Enabled = true;
MyLog.Info("[OK] 定时任务 [NoPayCancel] 已启动 (每 5 分钟/GET)");
MyLog.Info($"[Nightly] 下次执行时间: {nextRun:yyyy-MM-dd HH:mm:ss}");
// 等待到指定时间
await Task.Delay(delay);
// 执行任务
await NightlyTaskCore();
}
else
catch (Exception ex)
{
MyLog.Info("[提示] 任务 [NoPayCancel] 已在运行中");
}
MyLog.Info("夜间任务异常:" + ex.Message);
// 2. 启动新的每天 22:00 任务 (POST)
ScheduleNextNightlyRun();
// 出错后延迟1分钟再重试
await Task.Delay(TimeSpan.FromMinutes(1));
}
}
});
MyLog.Info("所有定时任务初始化完成。");
}

Loading…
Cancel
Save