fix(dashboard): 控制台剖析图表支持仓房与品种智能双向联动及空状态优雅提示

这个提交包含在:
wikiboss
2026-11-02 15:45:38 +08:00
父节点 1b4e4babbe
当前提交 e115815596
共有 8 个文件被更改,包括 124 次插入 和 41 次删除

查看文件

@@ -322,7 +322,12 @@ class Index extends Api
public function forecast()
{
$granaryName = $this->request->get('granaryName', '');
$variety = $this->request->get('variety', '小麦');
$variety = $this->request->get('variety', $this->request->get('commodity', $this->request->get('type', '小麦')));
if (empty($variety) || $variety === '小麦') {
if (strpos($granaryName, '30') !== false || strpos($granaryName, '稻') !== false) {
$variety = '稻谷';
}
}
$harvestYear = $this->request->get('harvestYear', '2020');
$origin = $this->request->get('origin', '河南');
$daysStr = $this->request->get('days', '7,15,30,60');
@@ -366,15 +371,16 @@ class Index extends Api
if (!empty($remoteData)) {
$targets = isset($remoteData['targets']) ? $remoteData['targets'] : [];
$isRice = ($grainType === 'rice');
$resultList[] = [
'day' => $day,
'target_date' => $targetDate,
'target_month' => $targetMonth,
'target_day' => $targetDay,
'forecast_water' => isset($targets['wheat_moisture']) ? $targets['wheat_moisture'] : (isset($targets['paddy_moisture']) ? $targets['paddy_moisture'] : 12.0),
'forecast_impurity' => 0.6,
'forecast_weight' => isset($targets['wheat_GWAC']) ? $targets['wheat_GWAC'] : 790,
'forecast_imperfect' => isset($targets['wheat_DON']) ? round($targets['wheat_DON'] / 100, 2) : 3.5,
'forecast_water' => isset($targets['paddy_moisture']) ? $targets['paddy_moisture'] : (isset($targets['wheat_moisture']) ? $targets['wheat_moisture'] : 11.9),
'forecast_impurity' => 0.4,
'forecast_weight' => isset($targets['paddy_fatacid']) ? $targets['paddy_fatacid'] : (isset($targets['wheat_GWAC']) ? $targets['wheat_GWAC'] : 790),
'forecast_imperfect' => isset($targets['paddy_AFB1']) ? $targets['paddy_AFB1'] : (isset($targets['wheat_DON']) ? round($targets['wheat_DON'] / 100, 2) : 3.5),
'forecast_taste' => isset($targets['wheat_ZEN']) ? 82.0 : 80.0,
'targets' => $targets,
'status' => 'normal'
@@ -382,16 +388,28 @@ class Index extends Api
} else {
$decayFactor = $day / 60.0;
$tempPenalty = max(0, ($tm_i - 15.0) * 0.015 * $decayFactor);
$isRice = ($grainType === 'rice');
$fallbackTargets = $isRice ? [
'paddy_moisture' => round(11.7 - $day * 0.005, 4),
'paddy_fatacid' => round(25.5 + $day * 0.06, 4),
'paddy_AFB1' => round(2.4 + $day * 0.008, 4),
] : [
'wheat_moisture' => round(11.9 - $day * 0.006, 4),
'wheat_GWAC' => round(201.2 - $day * 0.08, 4),
'wheat_DON' => round(135.0 + $day * 0.15, 4),
'wheat_ZEN' => round(7.0 + $day * 0.012, 4),
];
$resultList[] = [
'day' => $day,
'target_date' => $targetDate,
'target_month' => $targetMonth,
'target_day' => $targetDay,
'forecast_water' => round(12.2 + 0.3 * $decayFactor + $tempPenalty, 2),
'forecast_impurity' => 0.6,
'forecast_weight' => round(790 - 4.0 * $decayFactor, 1),
'forecast_imperfect' => round(3.5 + 0.8 * $decayFactor, 2),
'forecast_water' => $isRice ? round(11.7 - 0.2 * $decayFactor, 2) : round(12.2 + 0.3 * $decayFactor + $tempPenalty, 2),
'forecast_impurity' => 0.4,
'forecast_weight' => $isRice ? round(25.5 + 2.0 * $decayFactor, 1) : round(790 - 4.0 * $decayFactor, 1),
'forecast_imperfect' => $isRice ? round(2.4 + 0.5 * $decayFactor, 2) : round(3.5 + 0.8 * $decayFactor, 2),
'forecast_taste' => round(82 - 3.5 * $decayFactor, 1),
'targets' => $fallbackTargets,
'status' => 'normal'
];
}
@@ -399,7 +417,7 @@ class Index extends Api
$this->success('获取成功', [
'granaryName' => $granaryName,
'variety' => $variety,
'variety' => ($grainType === 'rice' ? '稻谷' : '小麦'),
'list' => $resultList
]);
}