from sqlalchemy import Column, Integer, String, DateTime from ..core.database import Base from datetime import datetime class SettlementData(Base): __tablename__ = "settlement_data" id = Column(Integer, primary_key=True, index=True, autoincrement=True) point_id = Column(String(100), nullable=False, comment="观测点id", index=True) CVALUE = Column(String(100), nullable=False, comment="修正量(m)") MAVALUE = Column(String(100), nullable=False, comment="成果值(m)") MTIME_W = Column(DateTime, nullable=False, comment="观测时间") NYID = Column(String(100), nullable=False, comment="期数id", index=True) PRELOADH = Column(String(100), nullable=False) PSTATE = Column(String(100), nullable=False) REMARK = Column(String(100), comment="备注") WORKINFO = Column(String(100)) createdate = Column(DateTime, nullable=False, comment="上传时间", index=True) day = Column(String(100), nullable=False, comment="累计天数") day_jg = Column(String(100), nullable=False, comment="两次观测时") isgzjdxz = Column(String(100)) mavalue_bc = Column(String(100), comment="本次沉降") mavalue_lj = Column(String(100), comment="累计沉降") sjName = Column(String(100), comment="司镜人员") useflag = Column(String(100)) workinfoname = Column(String(100), comment="观测阶段") upd_remark = Column(String(1000), comment="备注") def to_dict(self): data = {} for column in self.__table__.columns: field_value = getattr(self, column.name) # 时间字段格式化(不影响原生字段名) if isinstance(field_value, datetime): data[column.name] = field_value.strftime("%Y-%m-%d %H:%M:%S") else: data[column.name] = field_value # 【关键】删除之前添加的max_nyid,只保留原生NYID字段 return data