feat(forecast): 支持温湿度预测记录编辑与删除,修复组件调用并级联清理周期数据

这个提交包含在:
wikiboss
2026-11-02 14:55:36 +08:00
父节点 4a1e4f1d93
当前提交 f6e454a589
共有 8 个文件被更改,包括 284 次插入 和 61 次删除

查看文件

@@ -265,10 +265,10 @@ class Index extends Api
*/
public function env()
{
= ->request->get('site', 'center');
if (!GranarySite::valid()) ->error('无效库区');
$site = $this->request->get('site', 'center');
if (!GranarySite::valid($site)) $this->error('无效库区');
= [
$envData = [
'center' => [
'site' => 'center',
'name' => '遵义直属库中心库区',
@@ -291,29 +291,29 @@ class Index extends Api
]
];
= isset([]) ? [] : ['center'];
$data = isset($envData[$site]) ? $envData[$site] : $envData['center'];
// 优先读取该库区最新一条人工录入或设定的温湿度快照
try {
= Db::name('grain_forecast')
$latestRecord = Db::name('grain_forecast')
->alias('f')
->join('granary g', 'f.gid = g.id')
->where('g.site', )
->where('g.site', $site)
->order('f.id DESC')
->field('f.tm_i, f.hm_i, f.tm_o, f.hm_o, f.update_time')
->find();
if () {
['tm_i'] = (float)['tm_i'];
['hm_i'] = (float)['hm_i'];
['tm_o'] = (float)['tm_o'];
['hm_o'] = (float)['hm_o'];
['update_time'] = (int)['update_time'];
if ($latestRecord) {
$data['tm_i'] = (float)$latestRecord['tm_i'];
$data['hm_i'] = (float)$latestRecord['hm_i'];
$data['tm_o'] = (float)$latestRecord['tm_o'];
$data['hm_o'] = (float)$latestRecord['hm_o'];
$data['update_time'] = (int)$latestRecord['update_time'];
}
} catch (\Exception ) {
} catch (\Exception $e) {
// 异常时安全兜底基准工况
}
->success('获取成功', );
$this->success('获取成功', $data);
}
/**
@@ -355,6 +355,7 @@ class Index extends Api
$remoteData = $this->callRemoteForecast($remoteUrl, [
'type' => $grainType,
'commodity' => $grainType,
'month' => $targetMonth,
'day' => $targetDay,
'tm_i' => $tm_i,