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>
This commit is contained in:
48
backend/app/models/prediction.py
Normal file
48
backend/app/models/prediction.py
Normal file
@@ -0,0 +1,48 @@
|
||||
from sqlalchemy import Column, Integer, String, Float, DateTime, ForeignKey, JSON, Text
|
||||
from sqlalchemy.sql import func
|
||||
from app.core.database import Base
|
||||
|
||||
|
||||
class PredictionTask(Base):
|
||||
"""AI预测任务元数据"""
|
||||
__tablename__ = "prediction_tasks"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
device_id = Column(Integer, ForeignKey("devices.id"))
|
||||
prediction_type = Column(String(50), nullable=False) # pv, load, heatpump, optimization
|
||||
horizon_hours = Column(Integer, default=24)
|
||||
status = Column(String(20), default="pending") # pending, running, completed, failed
|
||||
parameters = Column(JSON) # extra config for the prediction run
|
||||
error_message = Column(Text)
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
completed_at = Column(DateTime(timezone=True))
|
||||
|
||||
|
||||
class PredictionResult(Base):
|
||||
"""AI预测结果时序数据"""
|
||||
__tablename__ = "prediction_results"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
task_id = Column(Integer, ForeignKey("prediction_tasks.id"), nullable=False, index=True)
|
||||
timestamp = Column(DateTime(timezone=True), nullable=False, index=True)
|
||||
predicted_value = Column(Float, nullable=False)
|
||||
confidence_lower = Column(Float)
|
||||
confidence_upper = Column(Float)
|
||||
actual_value = Column(Float) # filled later for accuracy tracking
|
||||
unit = Column(String(20))
|
||||
|
||||
|
||||
class OptimizationSchedule(Base):
|
||||
"""AI优化调度建议"""
|
||||
__tablename__ = "optimization_schedules"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
device_id = Column(Integer, ForeignKey("devices.id"))
|
||||
date = Column(DateTime(timezone=True), nullable=False, index=True)
|
||||
schedule_data = Column(JSON) # hourly on/off + setpoints
|
||||
expected_savings_kwh = Column(Float, default=0)
|
||||
expected_savings_yuan = Column(Float, default=0)
|
||||
status = Column(String(20), default="pending") # pending, approved, executed, rejected
|
||||
approved_by = Column(Integer, ForeignKey("users.id"))
|
||||
approved_at = Column(DateTime(timezone=True))
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
Reference in New Issue
Block a user