namespace Admin.NET.Plugin.AiDOP.Infrastructure; /// /// L1/L2 合并:期量差与绿黄红(指标模型总方案 03)。 /// 阈值含义(以达标比例%表示): /// higher_is_better: 绿 actual/target >= 100%;黄 >= yellowPct;红 < redPct /// lower_is_better: 绿 actual/target <= 100%;黄 <= yellowPct;红 > redPct /// 默认值:higher (95/80) lower (110/120) /// public static class AidopS4KpiMerge { public const string Green = "green"; public const string Yellow = "yellow"; public const string Red = "red"; public static string AchievementLevel( decimal? current, decimal? target, string direction, decimal? yellowThreshold = null, decimal? redThreshold = null) { if (current == null || target == null) return Yellow; var c = current.Value; var t = target.Value; if (t == 0) return Yellow; if (direction == "lower_is_better") { var yPct = yellowThreshold ?? 110m; var rPct = redThreshold ?? 120m; if (c <= t) return Green; if (c <= t * yPct / 100m) return Yellow; return Red; } // higher_is_better { var yPct = yellowThreshold ?? 95m; var rPct = redThreshold ?? 80m; if (c >= t) return Green; if (c >= t * yPct / 100m) return Yellow; return Red; } } /// 期量差数值(当前−目标);展示用箭头与符号在调用方处理。 public static decimal? GapValue(decimal? current, decimal? target) { if (current == null || target == null) return null; return current.Value - target.Value; } public static string GapArrow(decimal? gap) { if (gap == null) return "flat"; return gap.Value >= 0 ? "up" : "down"; } }