feat: 完善仓库建筑绑定、质检预警规则与大屏展示

这个提交包含在:
wikiboss
2026-10-28 17:30:49 +08:00
父节点 d4ff221fa3
当前提交 ffff286274
共有 18 个文件被更改,包括 614 次插入 和 318 次删除

查看文件

@@ -0,0 +1,45 @@
<?php
namespace app\common\library;
/** Numeric warning rules shared by the editor and persistence layer. */
class QualityRule
{
public static function direction($item)
{
if (isset($item['direction']) && in_array($item['direction'], ['upper', 'lower'], true)) {
return $item['direction'];
}
$warning = isset($item['warning']) ? $item['warning'] : null;
$alert = isset($item['alert']) ? $item['alert'] : null;
return is_numeric($warning) && is_numeric($alert) && $warning > $alert ? 'lower' : 'upper';
}
public static function validate($content)
{
if (!is_array($content) || empty($content)) {
return '请填写检测参数';
}
foreach ($content as $item) {
if (!is_array($item)) {
return '检测参数格式无效';
}
if (isset($item['direction']) && !in_array($item['direction'], ['upper', 'lower'], true)) {
return '预警方向无效';
}
if (!isset($item['warning'], $item['alert'])) {
return '请填写预警值和警告值';
}
if (is_numeric($item['warning']) && is_numeric($item['alert'])) {
$upper = self::direction($item) === 'upper';
if (($upper && $item['warning'] > $item['alert'])
|| (!$upper && $item['warning'] < $item['alert'])) {
return $item['name'] . ($upper
? ':越小越好指标要求预警值 ≤ 警告值(高值预警)'
: ':越大越好指标要求预警值 ≥ 警告值(低值预警)');
}
}
}
return '';
}
}