models.py 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. # coding: utf-8
  2. from sqlalchemy import Column, Date, DateTime, Float, Index, Integer, String, Text
  3. from sqlalchemy.schema import FetchedValue
  4. from flask_sqlalchemy import SQLAlchemy
  5. # db = SQLAlchemy()
  6. #與當前項目相關的模型文件,即所有的實體類在此編寫
  7. from manage import db
  8. class User(db.Model):
  9. __tablename__ = 'user'
  10. userID = db.Column(db.Integer, primary_key=True)
  11. firstname = db.Column(db.String(30), nullable=False)
  12. lastname = db.Column(db.String(30), nullable=False)
  13. mail = db.Column(db.String(50), nullable=False)
  14. phone = db.Column(db.String(20), nullable=False)
  15. username = db.Column(db.String(30), nullable=False, unique=True)
  16. password = db.Column(db.String(40), nullable=False)
  17. status = db.Column(db.Integer, nullable=False, info='0:admin;1:new;9:disable')
  18. class LiquidTank(db.Model):
  19. __tablename__ = 'liquid_tank'
  20. sn = db.Column(db.Integer, primary_key=True)
  21. datetime = db.Column(db.DateTime, nullable=False)
  22. fitolab = db.Column(db.Integer, nullable=False, default=1)
  23. tk1_duration1 = db.Column(db.Text, nullable=True)
  24. tk1_start1 = db.Column(db.Text, nullable=True)
  25. tk1_end1 = db.Column(db.Text, nullable=True)
  26. tk1_duration2 = db.Column(db.Text, nullable=True)
  27. tk1_start2 = db.Column(db.Text, nullable=True)
  28. tk1_end2 = db.Column(db.Text, nullable=True)
  29. tk1_duration3 = db.Column(db.Text, nullable=True)
  30. tk1_start3 = db.Column(db.Text, nullable=True)
  31. tk1_end3 = db.Column(db.Text, nullable=True)
  32. tk2_duration1 = db.Column(db.Text, nullable=True)
  33. tk2_start1 = db.Column(db.Text, nullable=True)
  34. tk2_end1 = db.Column(db.Text, nullable=True)
  35. tk2_duration2 = db.Column(db.Text, nullable=True)
  36. tk2_start2 = db.Column(db.Text, nullable=True)
  37. tk2_end2 = db.Column(db.Text, nullable=True)
  38. tk2_duration3 = db.Column(db.Text, nullable=True)
  39. tk2_start3 = db.Column(db.Text, nullable=True)
  40. tk2_end3 = db.Column(db.Text, nullable=True)
  41. class LightControl(db.Model):
  42. __tablename__ = 'light_control'
  43. sn = db.Column(db.Integer, primary_key=True)
  44. datetime = db.Column(db.DateTime, nullable=True)
  45. fitolab = db.Column(db.Integer, nullable=False, default=1)
  46. l_kind = db.Column(db.Text, nullable=False)
  47. l_start = db.Column(db.Text, nullable=True)
  48. l_end = db.Column(db.Text, nullable=True)
  49. l_r = db.Column(db.Integer, nullable=True)
  50. l_g = db.Column(db.Integer, nullable=True)
  51. l_b = db.Column(db.Integer, nullable=True)
  52. l_bright_auto = db.Column(db.Integer, nullable=False, info='0:off;1:on')
  53. l_bright_vol = db.Column(db.Integer, nullable=False)
  54. class MusicControl(db.Model):
  55. __tablename__ = 'music_control'
  56. sn = db.Column(db.Integer, primary_key=True)
  57. datetime = db.Column(db.DateTime, nullable=True)
  58. fitolab = db.Column(db.Integer, nullable=False, default=1)
  59. m_vol = db.Column(db.Text, nullable=False, default='40')
  60. m_playlist = db.Column(db.Integer, nullable=True)
  61. m_start = db.Column(db.Text, nullable=True)
  62. m_end = db.Column(db.Text, nullable=True)
  63. class VibrationControl(db.Model):
  64. __tablename__ = 'vibration_control'
  65. sn = db.Column(db.Integer, primary_key=True)
  66. datetime = db.Column(db.DateTime, nullable=False)
  67. fitolab = db.Column(db.Integer, nullable=False, default=1)
  68. v_power = db.Column(db.Text, nullable=False, default='40')
  69. v_vol = db.Column(db.Text, nullable=False)
  70. v_start = db.Column(db.Text, nullable=False)
  71. v_end = db.Column(db.Text, nullable=False)
  72. class CameraControl(db.Model):
  73. __tablename__ = 'camera_control'
  74. sn = db.Column(db.Integer, primary_key=True)
  75. datetime = db.Column(db.DateTime, nullable=False)
  76. fitolab = db.Column(db.Integer, nullable=False, default=1)
  77. c_status = db.Column(db.Integer, nullable=False, info='0:off;1:on')
  78. c_piriodicity = db.Column(db.Text, nullable=False)
  79. c_live_stream = db.Column(db.Text, nullable=False)
  80. class Gallery(db.Model):
  81. __tablename__ = 'gallery'
  82. sn = db.Column(db.Integer, primary_key=True)
  83. datetime = db.Column(db.DateTime, nullable=False)
  84. fitolab = db.Column(db.Integer, nullable=False, default=1)
  85. img = db.Column(db.Text, nullable=False)
  86. class RootSystem(db.Model):
  87. __tablename__ = 'root_system'
  88. sn = db.Column(db.Integer, primary_key=True)
  89. datetime = db.Column(db.DateTime, nullable=False)
  90. fitolab = db.Column(db.Integer, nullable=False, default=1)
  91. tem_tem1 = db.Column(db.Text, nullable=True)
  92. tem_start1 = db.Column(db.Text, nullable=True)
  93. tem_end1 = db.Column(db.Text, nullable=True)
  94. tem_tem2 = db.Column(db.Text, nullable=True)
  95. tem_start2 = db.Column(db.Text, nullable=True)
  96. tem_end2 = db.Column(db.Text, nullable=True)
  97. tem_tem3 = db.Column(db.Text, nullable=True)
  98. tem_start3 = db.Column(db.Text, nullable=True)
  99. tem_end3 = db.Column(db.Text, nullable=True)
  100. l_start1 = db.Column(db.Text, nullable=True)
  101. l_end1 = db.Column(db.Text, nullable=True)
  102. l_start2 = db.Column(db.Text, nullable=True)
  103. l_end2 = db.Column(db.Text, nullable=True)
  104. l_start3 = db.Column(db.Text, nullable=True)
  105. l_end3 = db.Column(db.Text, nullable=True)
  106. l_r = db.Column(db.Integer, nullable=True)
  107. l_g = db.Column(db.Integer, nullable=True)
  108. l_b = db.Column(db.Integer, nullable=True)
  109. l_bright_auto = db.Column(db.Integer, nullable=True, info='0:off;1:on')
  110. l_bright_vol = db.Column(db.Integer, nullable=True)
  111. fan_status = db.Column(db.Integer, nullable=True, info='0:off;1:on')
  112. fan_periodicity = db.Column(db.Text, nullable=True)
  113. fan_duration = db.Column(db.Text, nullable=True)
  114. fan_speed = db.Column(db.Text, nullable=True)
  115. humidity = db.Column(db.Text, nullable=True)
  116. class StemSystem(db.Model):
  117. __tablename__ = 'stem_system'
  118. sn = db.Column(db.Integer, primary_key=True)
  119. datetime = db.Column(db.DateTime, nullable=False)
  120. fitolab = db.Column(db.Integer, nullable=False, default=1)
  121. tem_tem1 = db.Column(db.Text, nullable=True)
  122. tem_start1 = db.Column(db.Text, nullable=True)
  123. tem_end1 = db.Column(db.Text, nullable=True)
  124. tem_tem2 = db.Column(db.Text, nullable=True)
  125. tem_start2 = db.Column(db.Text, nullable=True)
  126. tem_end2 = db.Column(db.Text, nullable=True)
  127. tem_tem3 = db.Column(db.Text, nullable=True)
  128. tem_start3 = db.Column(db.Text, nullable=True)
  129. tem_end3 = db.Column(db.Text, nullable=True)
  130. l_start1 = db.Column(db.Text, nullable=True)
  131. l_end1 = db.Column(db.Text, nullable=True)
  132. l_start2 = db.Column(db.Text, nullable=True)
  133. l_end2 = db.Column(db.Text, nullable=True)
  134. l_start3 = db.Column(db.Text, nullable=True)
  135. l_end3= db.Column(db.Text, nullable=True)
  136. l_r = db.Column(db.Integer, nullable=True)
  137. l_g = db.Column(db.Integer, nullable=True)
  138. l_b = db.Column(db.Integer, nullable=True)
  139. l_bright_auto = db.Column(db.Integer, nullable=True, info='0:off;1:on')
  140. l_bright_vol = db.Column(db.Integer, nullable=True)
  141. c_status = db.Column(db.Integer, nullable=True, info='0:off;1:on')
  142. c_duration = db.Column(db.Text, nullable=True)
  143. t_n_s_tem1 = db.Column(db.Text, nullable=True)
  144. t_n_s_start1 = db.Column(db.Text, nullable=True)
  145. t_n_s_end1 = db.Column(db.Text, nullable=True)
  146. t_n_s_tem2 = db.Column(db.Text, nullable=True)
  147. t_n_s_start2 = db.Column(db.Text, nullable=True)
  148. t_n_s_end2 = db.Column(db.Text, nullable=True)
  149. t_n_s_tem3 = db.Column(db.Text, nullable=True)
  150. t_n_s_start3 = db.Column(db.Text, nullable=True)
  151. t_n_s_end3 = db.Column(db.Text, nullable=True)
  152. m_vol = db.Column(db.Text, nullable=True, default='40')
  153. m_playlist1 = db.Column(db.Text, nullable=True)
  154. m_start1 = db.Column(db.Text, nullable=True)
  155. m_end1 = db.Column(db.Text, nullable=True)
  156. m_playlist2 = db.Column(db.Text, nullable=True)
  157. m_start2 = db.Column(db.Text, nullable=True)
  158. m_end2 = db.Column(db.Text, nullable=True)
  159. m_playlist3 = db.Column(db.Text, nullable=True)
  160. m_start3 = db.Column(db.Text, nullable=True)
  161. m_end3 = db.Column(db.Text, nullable=True)
  162. u_s_status = db.Column(db.Integer, nullable=True, info='0:off;1:on')
  163. u_s_vol = db.Column(db.Text, nullable=True)
  164. u_s_start1 = db.Column(db.Text, nullable=True)
  165. u_s_end1 = db.Column(db.Text, nullable=True)
  166. u_s_start2 = db.Column(db.Text, nullable=True)
  167. u_s_end2 = db.Column(db.Text, nullable=True)
  168. u_s_start3 = db.Column(db.Text, nullable=True)
  169. u_s_end3 = db.Column(db.Text, nullable=True)
  170. v_power = db.Column(db.Text, nullable=True, default='40')
  171. v_vol1 = db.Column(db.Text, nullable=True)
  172. v_start1 = db.Column(db.Text, nullable=True)
  173. v_end1 = db.Column(db.Text, nullable=True)
  174. v_vol2 = db.Column(db.Text, nullable=True)
  175. v_start2 = db.Column(db.Text, nullable=True)
  176. v_end2 = db.Column(db.Text, nullable=True)
  177. v_vol3 = db.Column(db.Text, nullable=True)
  178. v_start3 = db.Column(db.Text, nullable=True)
  179. v_end3 = db.Column(db.Text, nullable=True)
  180. w_vol1 = db.Column(db.Text, nullable=True)
  181. w_start1 = db.Column(db.Text, nullable=True)
  182. w_end1 = db.Column(db.Text, nullable=True)
  183. w_vol2 = db.Column(db.Text, nullable=True)
  184. w_start2 = db.Column(db.Text, nullable=True)
  185. w_end2 = db.Column(db.Text, nullable=True)
  186. w_vol3 = db.Column(db.Text, nullable=True)
  187. w_start3 = db.Column(db.Text, nullable=True)
  188. w_end3 = db.Column(db.Text, nullable=True)
  189. rh = db.Column(db.Text, nullable=True)
  190. class Fitolab1Sensor(db.Model):
  191. __tablename__ = 'fitolab1_sensor'
  192. sn = db.Column(db.Integer, primary_key=True)
  193. datetime = db.Column(db.DateTime, nullable=False)
  194. s_humidity = db.Column(db.Float, nullable=True)
  195. s_wind_flow = db.Column(db.Float, nullable=True)
  196. s_temp = db.Column(db.Float, nullable=True)
  197. s_near_stem1 = db.Column(db.Float, nullable=True)
  198. s_near_stem2 = db.Column(db.Float, nullable=True)
  199. s_air_tem1 = db.Column(db.Float, nullable=True)
  200. s_air_tem2 = db.Column(db.Float, nullable=True)
  201. s_orp = db.Column(db.Float, nullable=True)
  202. s_wgt = db.Column(db.Float, nullable=True)
  203. s_wgt_sensor1 = db.Column(db.Float, nullable=True)
  204. s_wgt_sensor2 = db.Column(db.Float, nullable=True)
  205. s_water_frequency = db.Column(db.Float, nullable=True)
  206. s_h2 = db.Column(db.Float, nullable=True)
  207. s_n2 = db.Column(db.Float, nullable=True)
  208. s_c2h4 = db.Column(db.Float, nullable=True)
  209. s_o3 = db.Column(db.Float, nullable=True)
  210. s_o2 = db.Column(db.Float, nullable=True)
  211. s_co2 = db.Column(db.Float, nullable=True)
  212. s_chlorophyll = db.Column(db.Float, nullable=True)
  213. s_leaf = db.Column(db.Text, nullable=True)
  214. r_humidity = db.Column(db.Float, nullable=True)
  215. r_air_temp = db.Column(db.Float, nullable=True)
  216. r_water_temp = db.Column(db.Float, nullable=True)
  217. r_orp = db.Column(db.Float, nullable=True)
  218. r_ec = db.Column(db.Float, nullable=True)
  219. r_do = db.Column(db.Float, nullable=True)
  220. r_ed = db.Column(db.Float, nullable=True)
  221. r_wind_flow = db.Column(db.Float, nullable=True)
  222. r_water_level = db.Column(db.Text, nullable=True)
  223. r_fluorine = db.Column(db.Float, nullable=True)
  224. r_ph = db.Column(db.Float, nullable=True)
  225. r_turbidity = db.Column(db.Float, nullable=True)
  226. r_nh4 = db.Column(db.Float, nullable=True)
  227. r_co2 = db.Column(db.Float, nullable=True)
  228. r_no3 = db.Column(db.Float, nullable=True)
  229. r_no2 = db.Column(db.Float, nullable=True)
  230. db.create_all()