Просмотр исходного кода

feat(backend): 生产接收接种量改为 VARCHAR(255) 自由文本

同步模型、API、CRUD 与 SQL 迁移/基线,支持数字与说明文案组合录入。

Co-authored-by: Cursor <cursoragent@cursor.com>
zlwu 2 месяцев назад
Родитель
Сommit
2d6b367a67

+ 1 - 1
backend/app/api/sample_production_reception.py

@@ -61,7 +61,7 @@ class ProductionReceptionBody(BaseModel):
     infectious_four_test_result: Optional[str] = Field(None, alias="infectiousFourTestResult")
     enriched_blood_weight_g: Optional[float] = Field(None, alias="enrichedBloodWeightG")
     cryopreservation_volume_ml: Optional[float] = Field(None, alias="cryopreservationVolumeMl")
-    inoculation_amount: Optional[float] = Field(None, alias="inoculationAmount")
+    inoculation_amount: Optional[str] = Field(None, alias="inoculationAmount")
     cryopreservation_time: Optional[str] = Field(None, alias="cryopreservationTime")
     storage_total_tubes: Optional[int] = Field(None, alias="storageTotalTubes")
     available_cell_count_1e7: Optional[float] = Field(None, alias="availableCellCount1e7")

+ 6 - 2
backend/app/crud/sample_production_reception.py

@@ -99,7 +99,7 @@ def _row_to_dict(row: BizSampleProductionReception) -> Dict[str, Any]:
         "infectiousFourTestResultLabel": INFECTIOUS_FOUR_LABELS.get(result, result),
         "enrichedBloodWeightG": _dec(row.enriched_blood_weight_g),
         "cryopreservationVolumeMl": _dec(row.cryopreservation_volume_ml),
-        "inoculationAmount": _dec(row.inoculation_amount),
+        "inoculationAmount": row.inoculation_amount or "",
         "cryopreservationTime": _fmt_dt(row.cryopreservation_time),
         "storageTotalTubes": row.storage_total_tubes,
         "availableCellCount1e7": _dec(row.available_cell_count_1e7),
@@ -200,7 +200,11 @@ def _apply_payload_to_row(
     row.cryopreservation_volume_ml = (
         data.get("cryopreservationVolumeMl") if "cryopreservationVolumeMl" in allowed else None
     )
-    row.inoculation_amount = data.get("inoculationAmount") if "inoculationAmount" in allowed else None
+    row.inoculation_amount = (
+        (str(data.get("inoculationAmount") or "").strip() or None)
+        if "inoculationAmount" in allowed
+        else None
+    )
     ct = data.get("cryopreservationTime")
     row.cryopreservation_time = ct if "cryopreservationTime" in allowed and ct else None
     row.storage_total_tubes = (

+ 1 - 1
backend/app/models/models.py

@@ -1470,7 +1470,7 @@ class BizSampleProductionReception(Base):
     infectious_four_test_result = Column(String(16), nullable=True, comment="传染四项 zc正常 bzc不正常")
     enriched_blood_weight_g = Column(Numeric(18, 4), nullable=True, comment="富集后血量/g")
     cryopreservation_volume_ml = Column(Numeric(18, 4), nullable=True, comment="冻存液用量/ml")
-    inoculation_amount = Column(Numeric(18, 4), nullable=True, comment="接种量")
+    inoculation_amount = Column(String(255), nullable=True, comment="接种量")
     cryopreservation_time = Column(DateTime, nullable=True, comment="冻存时间")
     storage_total_tubes = Column(Integer, nullable=True, comment="储存总量(管)")
     available_cell_count_1e7 = Column(Numeric(18, 4), nullable=True, comment="可提供细胞数量/*10E7")

+ 5 - 0
docs/sql/2026-08-31-production-reception-inoculation-amount-varchar.sql

@@ -0,0 +1,5 @@
+-- 生产接收接种量:数值 → 自由文本(最长 255)
+-- 执行前请备份;MySQL 会将既有 decimal 值转为对应数字字符串。
+
+ALTER TABLE biz_sample_production_reception
+  MODIFY COLUMN inoculation_amount VARCHAR(255) NULL COMMENT '接种量';

+ 1 - 1
docs/sql/zkxw.sql

@@ -20617,7 +20617,7 @@ CREATE TABLE `biz_sample_production_reception` (
   `infectious_four_test_result` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '传染四项 zc正常 bzc不正常',
   `enriched_blood_weight_g` decimal(18,4) DEFAULT NULL COMMENT '富集后血量/g',
   `cryopreservation_volume_ml` decimal(18,4) DEFAULT NULL COMMENT '冻存液用量/ml',
-  `inoculation_amount` decimal(18,4) DEFAULT NULL COMMENT '接种量',
+  `inoculation_amount` varchar(255) DEFAULT NULL COMMENT '接种量',
   `cryopreservation_time` datetime DEFAULT NULL COMMENT '冻存时间',
   `storage_total_tubes` int(11) DEFAULT NULL COMMENT '储存总量(管)',
   `available_cell_count_1e7` decimal(18,4) DEFAULT NULL COMMENT '可提供细胞数量/*10E7',