models.py 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. from pydantic import BaseModel
  2. from typing import Optional
  3. import datetime
  4. from pymysql import NULL
  5. SECRET_KEY = "df2f77bd544240801a048bd4293afd8eeb7fff3cb7050e42c791db4b83ebadcd"
  6. ALGORITHM = "HS256"
  7. class Token(BaseModel):
  8. access_token: str
  9. token_type: str
  10. class del_user(BaseModel):
  11. access_token: str
  12. del_name: str
  13. class User(BaseModel):
  14. id: int
  15. username: str
  16. password: str
  17. changPwdTime: Optional[datetime.datetime] = None
  18. isAdmin: Optional[bool] = None
  19. isEnable: Optional[bool] = True
  20. updateTime: Optional[datetime.datetime] = None
  21. token: Optional[str] = None
  22. class user_authority(BaseModel):
  23. ai_prediction_isView : int
  24. ai_prediction_isAdd : int
  25. ai_prediction_isEdit : int
  26. ai_prediction_isDel : int
  27. channel_isView : int
  28. channel_isAdd : int
  29. channel_isEdit : int
  30. channel_isDel : int
  31. device_isView : int
  32. device_isAdd : int
  33. device_isEdit : int
  34. device_isDel : int
  35. event_isView : int
  36. event_isAdd : int
  37. event_isEdit : int
  38. event_isDel : int
  39. index_isView : int
  40. index_isAdd : int
  41. index_isEdit : int
  42. index_isDel : int
  43. performance_isView : int
  44. performance_isAdd : int
  45. performance_isEdit : int
  46. performance_isDel : int
  47. record_isView : int
  48. record_isAdd : int
  49. record_isEdit : int
  50. record_isDel : int
  51. setting_device_isView : int
  52. setting_device_isAdd : int
  53. setting_device_isEdit : int
  54. setting_device_isDel : int
  55. setting_system_isView : int
  56. setting_system_isAdd : int
  57. setting_system_isEdit : int
  58. setting_system_isDel : int
  59. tower_isView : int
  60. tower_isAdd : int
  61. tower_isEdit : int
  62. tower_isDel : int
  63. ai_prediction_id:int
  64. channel_id:int
  65. device_id:int
  66. event_id:int
  67. index_id:int
  68. performance_id:int
  69. record_id:int
  70. setting_device_id:int
  71. setting_system_id:int
  72. tower_id:int
  73. role_id:str
  74. access_token: str
  75. def get_acl_from_module_name(self,module_name:str):
  76. result = {}
  77. exec("result['id'] = self.{}".format(module_name+'_id'))
  78. exec("result['isView'] = self.{}".format(module_name+'_isView'))
  79. exec("result['isAdd'] = self.{}".format(module_name+'_isAdd'))
  80. exec("result['isEdit'] = self.{}".format(module_name+'_isEdit'))
  81. exec("result['isDel'] = self.{}".format(module_name+'_isDel'))
  82. result["role_id"]= self.role_id
  83. result["module_id"]= module_name
  84. print(result)
  85. return result
  86. # AuthJWT setting
  87. class Settings(BaseModel):
  88. authjwt_secret_key: str = SECRET_KEY
  89. authjwt_token_location: set = {"cookies"}
  90. authjwt_cookie_secure: bool = False
  91. authjwt_cookie_csrf_protect: bool = True
  92. class record_tower_data(BaseModel):
  93. hotTemp: float
  94. coldTempData1:float
  95. coldTempData2:float
  96. reducer:float
  97. total:float
  98. towernum:float
  99. fannum:float
  100. flowchange:float
  101. savewater:float
  102. fanchange:float
  103. saveelec:float
  104. count:float
  105. wetTemp:float
  106. count1:float
  107. staticPressure:float
  108. waterFlow:float
  109. class record_dcs_data(BaseModel):
  110. hotTemp: float
  111. coldTemp:float
  112. fanMotorCur:float
  113. fanMotorSpeedFreq:float
  114. waterFlow:float
  115. class record_diagnosis_data(BaseModel):
  116. DW_Unbalance: float
  117. DW_Bending:float
  118. DW_Misalignment:float
  119. DW_Loose:float
  120. DW_Whirl:float
  121. DW_Whip:float
  122. DW_InnerDamage:float
  123. DW_OuterDamage:float
  124. DW_BallDamage:float
  125. DW_AirGap:float
  126. DW_BrokenBars:float
  127. DW_PhaseProblem:float
  128. DW_GMisalignment:float
  129. DW_GBrokenTeeth:float
  130. DW_Gwear:float
  131. DW_GBending:float
  132. DW_GEccentricity:float
  133. vibration_id:float
  134. class record_health_data(BaseModel):
  135. time_stamp:str
  136. CV_index:float
  137. Vrms:float
  138. Grms:float
  139. RPM:float
  140. PeakToPeak:float
  141. MeanAbsolute:float
  142. Skewness:float
  143. Kurtosis:float
  144. WaveformFactor:float
  145. CrestFactor:float
  146. ImpulseFactor:float
  147. StandardDeviation:float
  148. MeanValue:float
  149. Maximum:float
  150. Minimum:float
  151. IQR:float
  152. vibration_id:str
  153. class record_performance_data(BaseModel):
  154. creatTime:str
  155. deviceCode:str
  156. designWFR:float
  157. designHP:float
  158. designCurrent:float
  159. designHWT:float
  160. designCWT:float
  161. designWBT:float
  162. testWFR:float
  163. testBHP:float
  164. testCurrent:float
  165. testHWT:float
  166. testCWT:float
  167. testWBT:float
  168. testWindSpeed:float
  169. testMakeupWFR:float
  170. testMakeupCWT:float
  171. testCorrectCWT:float
  172. testCoolingRange:float
  173. resPredictRate:float
  174. resPredictWFR:float
  175. resCorrectedWFR:float
  176. resPerformance:float
  177. coolingRangeData:str
  178. coolingRangeChart:str
  179. waterFlowRateChart:str
  180. class record_prediction_data(BaseModel):
  181. time_stamp:str
  182. valueType:str
  183. predictType:str
  184. timeInternal:int
  185. alarmValue:float
  186. calCount:int
  187. remainCount:int
  188. remark:str
  189. vibration_id:str
  190. class record_prediction_upd_data(BaseModel):
  191. time_stamp:str
  192. valueType:str
  193. predictData:str
  194. vibration_id:str