Files
ems-core/backend/app/models/pricing.py
Du Wenbo 92ec910a13 ems-core v1.0.0: Standard EMS platform core
Shared backend + frontend for multi-customer EMS deployments.
- 12 enterprise modules: quota, cost, charging, maintenance, analysis, etc.
- 120+ API endpoints, 37 database tables
- Customer config mechanism (CUSTOMER env var + YAML config)
- Collectors: Modbus TCP, MQTT, HTTP API, Sungrow iSolarCloud
- Frontend: React 19 + Ant Design + ECharts + Three.js
- Infrastructure: Redis cache, rate limiting, aggregation engine

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 18:14:11 +08:00

34 lines
1.6 KiB
Python

from sqlalchemy import Column, Integer, String, Float, Boolean, DateTime, ForeignKey, JSON
from sqlalchemy.sql import func
from app.core.database import Base
class ElectricityPricing(Base):
"""电价配置"""
__tablename__ = "electricity_pricing"
id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(String(200), nullable=False)
energy_type = Column(String(50), default="electricity") # electricity, heat, water, gas
pricing_type = Column(String(20), nullable=False) # flat, tou, tiered
effective_from = Column(DateTime(timezone=True))
effective_to = Column(DateTime(timezone=True))
is_active = Column(Boolean, default=True)
created_by = Column(Integer, ForeignKey("users.id"))
created_at = Column(DateTime(timezone=True), server_default=func.now())
updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
class PricingPeriod(Base):
"""分时电价时段"""
__tablename__ = "pricing_periods"
id = Column(Integer, primary_key=True, autoincrement=True)
pricing_id = Column(Integer, ForeignKey("electricity_pricing.id"), nullable=False)
period_name = Column(String(50), nullable=False) # peak, valley, flat, shoulder, sharp
start_time = Column(String(10), nullable=False) # HH:MM format
end_time = Column(String(10), nullable=False) # HH:MM format
price_per_unit = Column(Float, nullable=False) # yuan per kWh
applicable_months = Column(JSON) # [1,2,3,...12] or null for all months
created_at = Column(DateTime(timezone=True), server_default=func.now())