from sqlalchemy import Column, String, Numeric, DateTime, Integer,Float,Boolean,BigInteger # from sqlalchemy.orm import declarative_base from sqlalchemy.ext.declarative import declarative_base from datetime import datetime import uuid Base = declarative_base() class WaterResourceProject(Base): __tablename__ = 'water_resource_projects' id = Column(Integer, primary_key=True, autoincrement=True, comment='数据自增键') jsdwzjlx = Column(String(50), comment='建设单位证件类型') lxfs = Column(String(50), comment='联系方式') sjtgbmtyshxydm = Column(String(18), comment='数据提供部门统一社会信用代码') jdgljgbm = Column(String(50), comment='监督管理机关编码') cd_time = Column(DateTime, comment='插入时间') sjtgbmmc = Column(String(400), comment='数据提供部门名称') ggmj = Column(String(50), comment='灌溉面积') sjtgbmxzqhdm = Column(String(12), comment='数据提供部门行政区划代码') jsdwzjhm = Column(String(50), comment='建设单位证件号码') xzqhdm = Column(String(50), comment='水利设施和水利工程所在地行政区划代码') cd_operation = Column(String(10), comment='新增数据类型 I-INSERT, U_UPDATE, D-DELETE') zdmj = Column(String(50), comment='占地面积') d_bmmc = Column(String(500), comment='前置机归属数源部门名称源') etl_time = Column(DateTime, comment='ETL时间') jssj = Column(String(50), comment='建设时间') jsdwmc = Column(String(400), comment='建设单位名称') slsshslgcmc = Column(String(400), comment='水利设施和水利工程名称') cd_batch = Column(String(200), comment='数据批次号') slsshslgcdd = Column(String(400), comment='水利设施和水利工程地点') jdgljg = Column(String(400), comment='监督管理机关') jingdu = Column(String(50), comment='经度') weidu = Column(String(50), comment='维度') is_delete = Column(Integer, comment='删除标识') class Config: allow_population_by_field_name = True orm_mode = True def to_dict(self): return { "id": self.id, "jsdwzjlx": self.jsdwzjlx, "lxfs": self.lxfs, "sjtgbmtyshxydm": self.sjtgbmtyshxydm, "jdgljgbm": self.jdgljgbm, "cd_time": self.cd_time, "sjtgbmmc": self.sjtgbmmc, "ggmj": self.ggmj, "sjtgbmxzqhdm": self.sjtgbmxzqhdm, "jsdwzjhm": self.jsdwzjhm, "xzqhdm": self.xzqhdm, "cd_operation": self.cd_operation, "zdmj": self.zdmj, "d_bmmc": self.d_bmmc, "etl_time": self.etl_time, "jssj": self.jssj, "jsdwmc": self.jsdwmc, "slsshslgcmc": self.slsshslgcmc, "cd_batch": self.cd_batch, "slsshslgcdd": self.slsshslgcdd, "jdgljg": self.jdgljg, "jingdu": self.jingdu, "weidu": self.weidu, # "is_delete": self.is_delete } class Unit(Base): __tablename__ = 'rescue_units' id = Column(Integer, autoincrement=True, primary_key=True) name = Column(String(255), nullable=False, comment='单位名称') category = Column(String(100), nullable=False, comment='类别') address = Column(String(255), nullable=False, comment='地址') equipment = Column(String(255), comment='装备') training = Column(String(255), comment='训练') responsible_person = Column(String(100), comment='负责人') contact_number = Column(String(20), comment='联系电话') longitude = Column(Float, comment='经度') latitude = Column(Float, comment='纬度') is_delete = Column(Integer, comment='删除标识') def to_dict(self): return { "id": self.id, "name": self.name, "category": self.category, "address": self.address, "equipment": self.equipment, "training": self.training, "responsible_person": self.responsible_person, "contact_number": self.contact_number, "longitude": self.longitude, "latitude": self.latitude, # "is_delete": self.is_delete } class Config: allow_population_by_field_name = True orm_mode = True class RescuePersonnel(Base): __tablename__ = 'rescue_personnel' id = Column(Integer, primary_key=True, autoincrement=True) name = Column(String(255), nullable=False, comment='姓名') contact_number = Column(String(20), nullable=False, comment='联系电话') gender = Column(String(10), nullable=False, comment='性别') current_address = Column(String(255), nullable=False, comment='现在地址') position = Column(String(100), comment='职务') unit_id = Column(Integer, comment='所属救援人员单位ID') unit_name = Column(Integer, comment='所属救援人员单位') is_delete = Column(Integer, default=0, comment='删除标识') modified_time = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, comment='修改时间') created_time = Column(DateTime, default=datetime.utcnow, comment='创建时间') def to_dict(self): return { "id": self.id, "name": self.name, "contact_number": self.contact_number, "gender": self.gender, "current_address": self.current_address, "position": self.position, "unit_id": self.unit_id, # "is_delete": self.is_delete, "unit_name": self.unit_name, "modified_time": self.modified_time.isoformat() if self.modified_time else None, "created_time": self.created_time.isoformat() if self.created_time else None } class RescueStation(Base): __tablename__ = 'rescue_stations' id = Column(Integer, primary_key=True, autoincrement=True, comment='数字自增ID') data_id = Column(String(255), primary_key=True, default=uuid.uuid4, comment='uuid主键') fwdx = Column(String(100), comment='服务对象姓名') zj = Column(String(20), comment='所属镇街') lng = Column(String(30), comment='救助站经度') cd_time = Column(DateTime, comment='更新时间') fwdmc = Column(String(50), comment='救助站名称') fwnr = Column(String(500), comment='服务内容') add_time = Column(DateTime, comment='新增时间') cd_operation = Column(String(1), comment='操作方式') fwdlx = Column(String(2), comment='救助站类型') lxdh = Column(String(30), comment='联系电话') kfsj = Column(String(100), comment='开放时间') lat = Column(String(30), comment='救助站纬度') fwdjj = Column(String(1000), comment='救助站简介') lxr = Column(String(30), comment='联系人') fid = Column(String(36), comment='主键') fwdzt = Column(String(1), comment='服务点状态') fwdaddr = Column(String(80), comment='服务点地址') is_delete = Column(Boolean, default=False, comment='删除标识') def to_dict(self): return { "id": self.id, "data_id": self.data_id, "fwdx": self.fwdx, "zj": self.zj, "lng": self.lng, "cd_time": self.cd_time.isoformat() if self.cd_time else None, "fwdmc": self.fwdmc, "fwnr": self.fwnr, "add_time": self.add_time.isoformat() if self.add_time else None, "cd_operation": self.cd_operation, "fwdlx": self.fwdlx, "lxdh": self.lxdh, "kfsj": self.kfsj, "lat": self.lat, "fwdjj": self.fwdjj, "lxr": self.lxr, "fid": self.fid, "fwdzt": self.fwdzt, "fwdaddr": self.fwdaddr, # "is_delete": self.is_delete } class DefenseProject(Base): __tablename__ = 'defense_projects' data_id = Column(String(255), primary_key=True, default=uuid.uuid4, comment='uuid主键') id = Column(BigInteger, primary_key=True, autoincrement=True, comment='数字自增ID') gcmc = Column(String(200), comment='工程名称') jsdw = Column(String(100), comment='建设单位') whdw = Column(String(100), comment='维护单位') rfzyjlgcs = Column(String(100), comment='人防专业监理工程师') jsdd = Column(String(100), comment='建设地点') cd_operation = Column(String(1), comment='操作方式') yjdxsmj = Column(Numeric(12), comment='应建人防地下室面积(㎡)') sjdxsmj = Column(Numeric(12), comment='实建人防地下室面积(㎡)') cd_time = Column(DateTime, default=datetime.utcnow, comment='更新时间') add_time = Column(DateTime, default=datetime.utcnow, comment='新增时间') jldw = Column(String(100), comment='监理单位') jsdwdm = Column(String(100), comment='建设单位统一社会信用代码') kgsj = Column(DateTime, comment='开工时间') stdw = Column(String(100), comment='审图单位') rfsjdwdm = Column(String(100), comment='人防设计单位单位统一社会信用代码') rfsjdw = Column(String(100), comment='人防设计单位单位') ybrs = Column(Numeric, comment='掩蔽人数') stdwdm = Column(String(100), comment='审图单位统一社会信用代码') whdwdm = Column(String(100), comment='维护单位统一社会信用代码') jldwdm = Column(String(100), comment='监理单位统一社会信用代码') rfzjlgcs = Column(String(100), comment='人防总监理工程师') gcid = Column(String(50), comment='主键') extend2 = Column(String(200), comment='扩展2') data_area = Column(String(12), comment='数据区域') extend1 = Column(String(200), comment='扩展1') jgsj = Column(DateTime, comment='竣工时间') is_delete = Column(Boolean, default=False, comment='删除标识') def to_dict(self): return { "id": self.id, "data_id": str(self.data_id), # 确保UUID转换为字符串 "gcmc": self.gcmc, "jsdw": self.jsdw, "whdw": self.whdw, "rfzyjlgcs": self.rfzyjlgcs, "jsdd": self.jsdd, "cd_operation": self.cd_operation, "yjdxsmj": self.yjdxsmj, "sjdxsmj": self.sjdxsmj, "cd_time": self.cd_time.isoformat() if self.cd_time else None, "add_time": self.add_time.isoformat() if self.add_time else None, "jldw": self.jldw, "jsdwdm": self.jsdwdm, "kgsj": self.kgsj.isoformat() if self.kgsj else None, "stdw": self.stdw, "rfsjdwdm": self.rfsjdwdm, "rfsjdw": self.rfsjdw, "ybrs": self.ybrs, "stdwdm": self.stdwdm, "whdwdm": self.whdwdm, "jldwdm": self.jldwdm, "rfzjlgcs": self.rfzjlgcs, "gcid": self.gcid, "extend2": self.extend2, "data_area": self.data_area, "extend1": self.extend1, "jgsj": self.jgsj.isoformat() if self.jgsj else None, # "is_delete": self.is_delete, } class Shelter(Base): __tablename__ = 'shelters' data_id = Column(String(255), primary_key=True, default=uuid.uuid4, comment='uuid主键') id = Column(Integer, primary_key=True, autoincrement=True, comment='数字自增ID') admin_area = Column(String(100), comment='行政区域') full_name = Column(String(200), comment='应急避难场所全称') address = Column(String(255), comment='应急避难场所地址') incident_type = Column(String(100), comment='按突发事件类型分类') shelter_type = Column(String(100), comment='避难种类') total_area = Column(Numeric, comment='应急避难场所占地总面积(平方米)') indoor_area = Column(Numeric, comment='应急避难场所室内面积(平方米)') capacity = Column(Numeric, comment='避难场所容纳人数(人)') supplies = Column(String(500), comment='物资储备') facilities = Column(String(500), comment='应急设施') is_delete = Column(Boolean, default=False, comment='删除标识') modified_time = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, comment='修改时间') created_time = Column(DateTime, default=datetime.utcnow, comment='创建时间') def to_dict(self): return { "id": self.id, "data_id": str(self.data_id), "admin_area": self.admin_area, "full_name": self.full_name, "address": self.address, "incident_type": self.incident_type, "shelter_type": self.shelter_type, "total_area": self.total_area, "indoor_area": self.indoor_area, "capacity": self.capacity, "supplies": self.supplies, "facilities": self.facilities, # "is_delete": self.is_delete, "modified_time": self.modified_time.isoformat() if self.modified_time else None, "created_time": self.created_time.isoformat() if self.created_time else None, }