from sqlalchemy import Column, Integer, String, Float, DateTime, Text, func from app.database import Base class EnergyRecord(Base): """班次能耗记录""" __tablename__ = "energy_records" id = Column(Integer, primary_key=True, index=True) shift = Column(String(10), nullable=True, comment="班次 甲/乙/丙/丁") shift_date = Column(DateTime, nullable=True, comment="班期") # 产量 production_weight_kg = Column(Float, nullable=True, comment="本班产量 kg") # 电力 power_consumption_kwh = Column(Float, nullable=True, comment="电耗 kWh") power_unit = Column(Float, nullable=True, comment="电耗单耗 kWh/t") # 蒸汽 steam_consumption_kg = Column(Float, nullable=True, comment="蒸汽消耗 kg") steam_unit = Column(Float, nullable=True, comment="蒸汽单耗 kg/t") # 盐酸 acid_consumption_kg = Column(Float, nullable=True, comment="盐酸消耗 kg") acid_unit = Column(Float, nullable=True, comment="酸耗单耗 kg/t") # 冷却水 cooling_water_m3 = Column(Float, nullable=True, comment="冷却水 m³") water_unit = Column(Float, nullable=True, comment="冷却水单耗 m³/t") # 各槽HCl平均浓度 (JSON字符串, e.g. '[180,175,170,165,160,155]') acid_conc_avg = Column(Text, nullable=True, comment="各槽HCl平均浓度 JSON g/L") created_at = Column(DateTime, server_default=func.now()) updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())