文件

42 行
1.9 KiB
PHP

<?php
namespace app\common\library;
/** 建筑位置独立于仓号,修改仓号不会移动大屏标记。 */
class GranaryScreen
{
public static function extraPositions()
{
return [
'center_upper_left' => ['x' => 46.8, 'y' => 28.4],
'center_lower_right' => ['x' => 58.8, 'y' => 34.1],
'center_middle' => ['x' => 44.0, 'y' => 33.5],
'center_rear' => ['x' => 45.1, 'y' => 18.7],
'center_silo_1' => ['x' => 52.4, 'y' => 13.5, 'stemY' => 17.2],
'center_silo_2' => ['x' => 56.6, 'y' => 17.5, 'stemY' => 19.6],
'center_silo_3' => ['x' => 61.3, 'y' => 13.5, 'stemY' => 22.0],
'center_silo_4' => ['x' => 66.2, 'y' => 21.0, 'stemY' => 24.1],
'center_silo_5' => ['x' => 73.2, 'y' => 22.5, 'stemY' => 26.3],
'center_silo_6' => ['x' => 78.5, 'y' => 26.0, 'stemY' => 28.8],
'center_silo_7' => ['x' => 84.9, 'y' => 28.0, 'stemY' => 30.7],
];
}
public static function resolve($item, $coords)
{
$content = is_array($item['content']) ? $item['content'] : json_decode($item['content'], true);
$position = isset($content['screenPosition']) ? $content['screenPosition'] : '';
$extra = self::extraPositions();
if (isset($extra[$position])) {
return $extra[$position];
}
// 历史记录按数据库 id 锚定原建筑,避免改号后套用另一栋仓库的位置。
$originalNumbers = [27 => 30, 29 => 31, 30 => 32, 31 => 10, 33 => 42,
34 => 33, 36 => 35, 37 => 36, 38 => 12, 39 => 39, 40 => 40,
42 => 41, 43 => 14, 44 => 37, 45 => 15, 46 => 44, 47 => 16,
48 => 17, 49 => 18, 50 => 38, 51 => 43];
$num = isset($originalNumbers[$item['id']]) ? $originalNumbers[$item['id']] : null;
return $num !== null && isset($coords[$num]) ? $coords[$num] : null;
}
}