Files
dpb/backend/sql/bre_disease_chilling_traits.sql
34047007@qq.com b95053c52c init: 初始化 dpb 桃育种系统代码库
前后端 + 后端 FastAPI 全量源码、部署脚本与文档。
2026-08-06 00:17:49 +08:00

42 lines
3.6 KiB
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- ============================================================
-- 现代桃育种领域覆盖·抗病性状 + 需冷量/需热量 trait 字典种子(2026-08-04
-- 背景:bre_trait 字典原 66 行(6 标签页:基本鉴定/果实外观/果皮/果实大小/果肉/果核)
-- 「其它」标签页由用户自定义追加。缺口:
-- ③ 细菌性穿孔病 / 褐腐病 / 白粉病——减药育种核心目标,原字典一条都没有;
-- ② 需冷量/需热量——原字典无,只存在于 germplasm 属性(bre_germplasm.chilling_requirement)
-- 与环境侧(bre_environment_condition.chilling_hours/GDD);选种性状侧缺失。
-- 设计:统计引擎(EBV/选择指数)仅消费 data_type='numeric' 的性状(_trait_meta_map 过滤),
-- 故抗病/需冷量全部建 numeric 病情指数/小时数,direction=asc(低值优),into_ebv='1' 进选种目标。
-- · 抗病用 0-5 级病情指数(0=免疫 1=高抗 2=抗 3=中抗 4=感 5=高感),direction=asc
-- · 需冷量 = 品种打破自然休眠所需 0~7.2℃ 低温累计小时数(h)direction=asc(低需冷适应暖区)
-- · 需热量 = 发芽前 >7.2℃ 有效积温(GDD)direction=asc(低需热早熟/暖区)
-- 幂等:以 trait_code 冲突则更新(不动 uuid/created_time),同 bre_trait_seed.sql 惯例。
-- ============================================================
INSERT INTO bre_trait
(trait_code, trait_name, category, data_type, unit, is_core, scale_json, uuid, is_deleted, created_time,
direction, into_ebv, default_h2, valid_min, valid_max, stage, method)
VALUES
-- ③ 抗病性(numeric 0-5 级病情指数,越低越抗)--------------------
('disease_shot_hole', '细菌性穿孔病', '抗病性', 'numeric', '级', '1', NULL, md5(random()::text||'disease_shot_hole'), false, now(), 'asc', '1', 0.3, 0, 5, 'evaluation', '田间自然发病病情指数 0-5 级(0免疫/1高抗/2抗/3中抗/4感/5高感)'),
('disease_brown_rot', '褐腐病', '抗病性', 'numeric', '级', '1', NULL, md5(random()::text||'disease_brown_rot'), false, now(), 'asc', '1', 0.3, 0, 5, 'evaluation', '果实/花器褐腐病病情指数 0-5 级(低=抗)'),
('disease_powdery_mildew','白粉病', '抗病性', 'numeric', '级', '1', NULL, md5(random()::text||'disease_powdery_mildew'), false, now(), 'asc', '1', 0.3, 0, 5, 'evaluation', '叶/果白粉病病情指数 0-5 级(低=抗)'),
-- ② 生态适应性(需冷量/需热量,低值=暖区适应/早熟)---------------
('chilling_requirement', '需冷量', '生态适应性', 'numeric', 'h', '1', NULL, md5(random()::text||'chilling_requirement'), false, now(), 'asc', '1', 0.5, 0, 3000, 'evaluation', '打破自然休眠所需 0~7.2℃ 低温累计小时数(品种需冷量)'),
('heat_requirement', '需热量', '生态适应性', 'numeric', 'GDD', '1', NULL, md5(random()::text||'heat_requirement'), false, now(), 'asc', '1', 0.4, 0, 10000, 'evaluation', '发芽前 >7.2℃ 有效积温生长度日(品种需热量)')
ON CONFLICT (trait_code) DO UPDATE SET
trait_name = EXCLUDED.trait_name,
category = EXCLUDED.category,
data_type = EXCLUDED.data_type,
unit = EXCLUDED.unit,
is_core = EXCLUDED.is_core,
scale_json = EXCLUDED.scale_json,
direction = EXCLUDED.direction,
into_ebv = EXCLUDED.into_ebv,
default_h2 = EXCLUDED.default_h2,
valid_min = EXCLUDED.valid_min,
valid_max = EXCLUDED.valid_max,
stage = EXCLUDED.stage,
method = EXCLUDED.method,
updated_time = now();