feat: 完善仓库建筑绑定、质检预警规则与大屏展示
这个提交包含在:
@@ -52,8 +52,23 @@ class Index extends Api
|
||||
if (!empty($list) && count($list) > 0) {
|
||||
$list = collection($list)->toArray();
|
||||
|
||||
// Load saved rules in two queries rather than one query per granary.
|
||||
$tests = TestingModel::with(['testingParams'])
|
||||
->where('gid', 'in', array_column($list, 'id'))
|
||||
->order('test_date DESC, id DESC')->select();
|
||||
$latestTests = [];
|
||||
foreach ($tests as $test) {
|
||||
$test = $test->toArray();
|
||||
$testKey = $test['gid'] . ':' . $test['type'];
|
||||
if (!isset($latestTests[$testKey])) {
|
||||
$latestTests[$testKey] = $test;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($list as &$v) {
|
||||
$v['varieties'] = getVarietiesInfo($v['varieties']);
|
||||
$testKey = $v['id'] . ':' . $v['varieties']['type'];
|
||||
$v['quality_test'] = isset($latestTests[$testKey]) ? $latestTests[$testKey] : null;
|
||||
$v['harvest_year'] = is_numeric($v['harvest_year']) ? date('Y-m-d', $v['harvest_year']) : $v['harvest_year'];
|
||||
$v['enter_time'] = is_numeric($v['enter_time']) ? date('Y-m-d', $v['enter_time']) : $v['enter_time'];
|
||||
$v['create_time'] = is_numeric($v['create_time']) ? date('Y-m-d', $v['create_time']) : $v['create_time'];
|
||||
@@ -72,6 +87,12 @@ class Index extends Api
|
||||
}
|
||||
|
||||
$coords = $this->getSiteCoords($site);
|
||||
if ($site !== 'xishui' && is_array($list)) {
|
||||
foreach ($list as &$granary) {
|
||||
$granary['screen_coord'] = \app\common\library\GranaryScreen::resolve($granary, $coords);
|
||||
}
|
||||
unset($granary);
|
||||
}
|
||||
|
||||
$this->success('获取成功', [
|
||||
'list' => $list,
|
||||
|
||||
在新工单中引用
屏蔽一个用户