jobs_base.py 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # -*- coding: utf-8 -*-
  2. from sqlalchemy import String, Column, Integer,DateTime,Text,Date,Time,ForeignKey
  3. from database import Base
  4. from sqlalchemy.orm import relationship
  5. from datetime import datetime
  6. class JobConfigEntity(Base):
  7. __tablename__ = "tp_job_config"
  8. id = Column(Integer, primary_key=True, autoincrement=True,comment="id")
  9. jobName = Column(String(255), nullable=False,comment="任务名称")
  10. groupName = Column (String(255),default='',comment="组名称")
  11. enable = Column(Integer,default=True,comment="启用状态")
  12. create_time = Column(DateTime, default=datetime.now,comment="任务创建时间")
  13. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now,comment="任务最后修改时间")
  14. triggerType = Column(String(2),comment="更新机制 1:手动触发;2:每时;3:每天;4:每周;5:每月;6:每年")
  15. readerPreSQL = Column(String(255),default='',comment="源库前置SQL")
  16. readerSQL = Column(Text, nullable=False,comment="源库取数SQL") # {sql} order by create_time limit ,writerBatchSize {sql}:select * from xxx where
  17. readerPostSQL = Column(String(255),default='',comment="源库后置SQL")
  18. writerPreSQL = Column(String(255),default='',comment="目标库前置SQL") #清表动作
  19. writerPostSQL = Column(String(255),default='',comment="目标库后置SQL")
  20. columns = Column(Text,comment="入库列")
  21. fromDbId = Column(String(100),nullable = False,comment = "源库ID")
  22. toDbId = Column(String(100),nullable = False,comment = "目标库ID")
  23. toTableName = Column(String(100),nullable=False,comment="目标表")
  24. toTablePKColumns = Column(String(50),comment="目标表主键字段") # 按,分隔开
  25. writerBatchSize = Column(Integer,default=0,comment="每次事务写记录数") # divmod(total, size)
  26. defaultParamsMapJson = Column(String(100),default='',comment="默认参数值json串") #{"create_time":"2024-07-26 00:00:00"}
  27. incrementColumns = Column(String(50),comment="增量字段") # create_time
  28. class Config:
  29. orm_mode = True
  30. class JobHistoryEntity(Base):
  31. __tablename__ = "tp_job_history"
  32. id = Column(Integer, primary_key=True, autoincrement=True,comment="id")
  33. configId = Column(Integer, comment="configid")
  34. jobName = Column(String(255), nullable=False,comment="任务名称")
  35. postStepId = Column(Integer, nullable=False, comment="postStepId")
  36. postStepState = Column(Integer,comment="任务状态 1:执行中;2:成功;3:失败")
  37. preStepSuccessRecord = Column(Integer, comment="读库数")
  38. postStepSuccessRecord = Column(Integer, comment="入库数")
  39. create_time = Column(DateTime, default=datetime.now,comment="任务开始执行时间")
  40. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now,comment="任务最后更新时间")
  41. toTableName = Column(String(100),nullable=False,comment="目标表")
  42. totalCostsMS = Column(Integer, comment="执行总耗时ms")
  43. class Config:
  44. orm_mode = True
  45. class JobStepEntity(Base):
  46. __tablename__ = "tp_job_step"
  47. id = Column(Integer, primary_key=True, autoincrement=True,comment="id")
  48. jobHisId = Column(Integer, comment="jobhisid")
  49. state = Column(Integer,comment="任务状态 1:执行中;2:成功;3:失败")
  50. create_time = Column(DateTime, default=datetime.now,comment="任务开始执行时间")
  51. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now,comment="任务最后更新时间")
  52. paramsMapJson = Column(String(100),default='',comment="已合并参数JSON") # {"create_time":"2024-07-26 00:00:00"}
  53. incrementColumnMaxValueJson = Column(String(100),default='',comment="执行结束增量字段最大值") # tmp
  54. totalReadRecords = Column(Integer, comment="总读取记录行数")# select count(*) from ({sql})A
  55. totalWriteSuccessRecords = Column(Integer, comment="总成功写入行数")
  56. totalErrorRecords = Column(Integer, comment="总失败记录行数")
  57. totalCostsMS = Column(Integer, comment="执行总耗时ms")
  58. class Config:
  59. orm_mode = True