refactor: 优化AI评分与二维码ID生成逻辑,调整RabbitMQ配置
1. 调整RabbitMQ预取计数配置,支持从配置读取 2. 新增随机ID帮助类,生成唯一长整型ID 3. 重构二维码ID生成逻辑,新增重试机制避免重复 4. 优化AI评分配置,调整温度系数与并发限制 5. 重构跨页题评分逻辑,支持分组评分与结果去重 6. 新增AI评分异常分类与结果校验逻辑 7. 优化评分提示词与结果归一化处理
This commit is contained in:
37
QYZH.InteractiveMagazine.Common/Helpers/RandomIdHelper.cs
Normal file
37
QYZH.InteractiveMagazine.Common/Helpers/RandomIdHelper.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace QYZH.InteractiveMagazine.Common.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// 随机ID帮助类
|
||||
/// </summary>
|
||||
public static class RandomIdHelper
|
||||
{
|
||||
private const long DefaultMinValue = 1_000_000_000_000_000_000L;
|
||||
private const long DefaultMaxValue = 9_000_000_000_000_000_000L;
|
||||
|
||||
/// <summary>
|
||||
/// 生成不可预测的正数长整型ID
|
||||
/// </summary>
|
||||
public static long GenerateLongId(long minValue = DefaultMinValue, long maxValue = DefaultMaxValue)
|
||||
{
|
||||
if (minValue <= 0 || minValue >= maxValue)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(minValue), "随机ID范围配置错误");
|
||||
}
|
||||
|
||||
var range = (ulong)(maxValue - minValue);
|
||||
var limit = ulong.MaxValue - (ulong.MaxValue % range);
|
||||
|
||||
Span<byte> bytes = stackalloc byte[sizeof(ulong)];
|
||||
while (true)
|
||||
{
|
||||
RandomNumberGenerator.Fill(bytes);
|
||||
var value = BitConverter.ToUInt64(bytes);
|
||||
if (value < limit)
|
||||
{
|
||||
return minValue + (long)(value % range);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user