37 lines
1.6 KiB
Python
37 lines
1.6 KiB
Python
|
|
from sqlalchemy import Column, Integer, String, Float, DateTime, Text
|
||
|
|
from sqlalchemy.sql import func
|
||
|
|
from app.core.database import Base
|
||
|
|
|
||
|
|
|
||
|
|
class EmissionFactor(Base):
|
||
|
|
"""碳排放因子"""
|
||
|
|
__tablename__ = "emission_factors"
|
||
|
|
|
||
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
||
|
|
name = Column(String(100), nullable=False)
|
||
|
|
energy_type = Column(String(50), nullable=False) # electricity, natural_gas, diesel, etc.
|
||
|
|
factor = Column(Float, nullable=False) # kgCO2/单位
|
||
|
|
unit = Column(String(20), nullable=False) # kWh, m³, L, etc.
|
||
|
|
region = Column(String(50), default="north_china") # 区域电网
|
||
|
|
scope = Column(Integer, nullable=False) # 1, 2, 3
|
||
|
|
source = Column(String(200)) # 数据来源
|
||
|
|
year = Column(Integer)
|
||
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||
|
|
|
||
|
|
|
||
|
|
class CarbonEmission(Base):
|
||
|
|
"""碳排放记录"""
|
||
|
|
__tablename__ = "carbon_emissions"
|
||
|
|
|
||
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
||
|
|
date = Column(DateTime(timezone=True), nullable=False, index=True)
|
||
|
|
scope = Column(Integer, nullable=False) # 1, 2, 3
|
||
|
|
category = Column(String(50), nullable=False) # electricity, gas, heat, etc.
|
||
|
|
emission = Column(Float, nullable=False) # kgCO2e
|
||
|
|
reduction = Column(Float, default=0) # 减排量 kgCO2e (光伏、热泵节能等)
|
||
|
|
energy_consumption = Column(Float) # 对应能耗量
|
||
|
|
energy_unit = Column(String(20))
|
||
|
|
emission_factor_id = Column(Integer)
|
||
|
|
note = Column(Text)
|
||
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|