- 新增 UpdateDbVariableProcessor 处理器,通过队列和定时器实现数据库的批量更新,以降低负载。 - 重构 ValueConvertProcessor 处理器,使其能够解析 ConversionFormula 公式,计算出最终的 DisplayValue。 - 扩展 IVariableRepository 仓储接口,添加 UpdateBatchAsync 方法,并使用SqlSugar实现高效的批量更新。 - 优化 VariableContext 模型,将 NewValue 类型统一为 string,简化了数据流并提升了类型安全。
30 lines
952 B
C#
30 lines
952 B
C#
using DMS.Core.Models;
|
|
using DMS.Application.Interfaces;
|
|
using DMS.Application.Models;
|
|
|
|
namespace DMS.Application.Services.Processors;
|
|
|
|
public class CheckValueChangedProcessor : IVariableProcessor
|
|
{
|
|
|
|
|
|
public Task ProcessAsync(VariableContext context)
|
|
{
|
|
// Variable newVariable = context.Data;
|
|
// if (!_dataServices.AllVariables.TryGetValue(newVariable.Id, out Variable oldVariable))
|
|
// {
|
|
// NlogHelper.Warn($"检查变量值是否改变时在_dataServices.AllVariables中找不到Id:{newVariable.Id},Name:{newVariable.Name}的变量。");
|
|
// context.IsHandled = true;
|
|
// return Task.CompletedTask;
|
|
// }
|
|
|
|
// if (newVariable.DataValue == oldVariable.DataValue)
|
|
// {
|
|
// // 值没有变化,直接完成
|
|
// context.IsHandled = true;
|
|
// }
|
|
//
|
|
// 在这里处理 context.Data
|
|
return Task.CompletedTask;
|
|
}
|
|
} |