results.py 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. import datetime
  2. import numpy as np
  3. # def DictResultsNull(dict_chiller_outer, dict_chiller_inner, dict_code, results_depict):
  4. # if isinstance(dict_code['triggerTime'], str):
  5. # trigger_time = dict_code['triggerTime']
  6. # else:
  7. # trigger_time = dict_code['triggerTime'].strftime("%Y-%m-%d %H:%M:%S")
  8. # resultsOutput = {'userName': dict_chiller_outer['userName'],
  9. # 'coolingStationName': dict_chiller_outer['coolingStationName'],
  10. # 'chillerName': dict_chiller_outer['chillerName'],
  11. # 'chillerId': dict_chiller_outer['chillerId'],
  12. # 'isOrder': False,
  13. # 'waterTempSetNew': None,
  14. # 'controlMode': dict_code['controlMode'],
  15. # 'energyMode': dict_code['energyMode'],
  16. # # 'triggerTime': dict_code['triggerTime'].strftime("%Y-%m-%d %H:%M:%S"),
  17. # 'triggerTime': trigger_time,
  18. # 'isHardwareControl': dict_code['isHardwareControl'],
  19. # 'runStatus': dict_chiller_inner['runStatus'][-1],
  20. # 'chillerWaterTempOut': dict_chiller_inner['chillerWaterTempOut'][-1],
  21. # 'chillerWaterTempSet': dict_chiller_inner['chillerWaterTempSet'],
  22. # 'chillerWaterTempSetUpper': dict_chiller_inner['chillerWaterTempSetUpper'],
  23. # 'ahuName': [],
  24. # 'tempReal': [],
  25. # 'humiReal': [],
  26. # 'dewTempReal': [],
  27. # 'tempLimit': [],
  28. # 'humiLimit': [],
  29. # 'dewTempLimit': [],
  30. # 'worstTerminalInfo': {},
  31. # 'resultsDepict': results_depict
  32. # }
  33. # return resultsOutput
  34. def DictResultsNormal(is_suction_with_liquid, is_control, results_depict, water_temp_set_new, dict_chiller_inner,
  35. dict_chiller_outer, dict_code, data_temp_humi, excess_reslut, terminal_cal):
  36. if isinstance(dict_code['triggerTime'], str):
  37. trigger_time = dict_code['triggerTime']
  38. else:
  39. trigger_time = dict_code['triggerTime'].strftime("%Y-%m-%d %H:%M:%S")
  40. resultsOutput = {'userName': dict_chiller_outer['userName'],
  41. 'coolingStationName': dict_chiller_outer['coolingStationName'],
  42. 'chillerName': dict_chiller_outer['chillerName'],
  43. 'chillerId': dict_chiller_outer['chillerId'],
  44. 'isOrder': is_control,
  45. 'waterTempSetNew': water_temp_set_new,
  46. 'controlMode': dict_code['controlMode'],
  47. 'energyMode': dict_code['energyMode'],
  48. 'triggerTime': trigger_time,
  49. # 'triggerTime': dict_code['triggerTime'],
  50. 'isHardwareControl': dict_code['isHardwareControl'],
  51. 'runStatus': dict_chiller_inner['runStatus'][-1],
  52. 'chillerWaterTempOut': dict_chiller_inner['chillerWaterTempOut'][-1],
  53. 'chillerWaterTempSet': dict_chiller_inner['chillerWaterTempSet'],
  54. 'chillerWaterTempSetUpper': dict_chiller_inner['chillerWaterTempSetUpper'],
  55. 'resultsDepict': results_depict}
  56. if dict_chiller_inner['runMode'] == 0:
  57. if is_suction_with_liquid == 1 or data_temp_humi.shape[0] == 0 or not terminal_cal:
  58. resultsTempHumid = {'ahuName': [],
  59. 'tempReal': [],
  60. 'humiReal': [],
  61. 'dewTempReal': [],
  62. 'tempLimit': [],
  63. 'humiLimit': [],
  64. 'dewTempLimit': [],
  65. 'worstTerminalInfo': {}}
  66. else:
  67. resultsTempHumid = {'ahuName': list(data_temp_humi['ahuName']),
  68. 'tempReal': list(data_temp_humi['tempReal']),
  69. 'humiReal': list(data_temp_humi['humiReal']),
  70. 'dewTempReal': list(data_temp_humi['dewTempReal']),
  71. 'tempLimit': list(data_temp_humi['tempLimit']),
  72. 'humiLimit': list(data_temp_humi['humiLimit']),
  73. 'dewTempLimit': list(data_temp_humi['dewTempLimit']),
  74. 'worstTerminalInfo': excess_reslut,
  75. }
  76. if dict_chiller_inner['waterTempControlMode'] == 1: # python输出参数中冷冻水进/出水温度统一字段
  77. resultsOtherOutput = {'chillerWaterTempSet': dict_chiller_inner['chillerWaterTempInSet'],
  78. 'chillerWaterTempSetUpper': dict_chiller_inner['chillerWaterTempInSetUpper'],
  79. # 'resultsDepict': '冷冻水回水温度设定值,由%s℃调整为%s℃' % (
  80. # dict_chiller_inner['chillerWaterTempInSet'], water_temp_set_new)
  81. }
  82. else:
  83. resultsOtherOutput = {'chillerWaterTempSet': dict_chiller_inner['chillerWaterTempSet'],
  84. 'chillerWaterTempSetUpper': dict_chiller_inner['chillerWaterTempSetUpper'],
  85. # 'resultsDepict': '冷冻水出水温度设定值,由%s℃调整为%s℃' % (
  86. # dict_chiller_inner['chillerWaterTempSet'], water_temp_set_new)
  87. }
  88. else:
  89. if is_suction_with_liquid == 1 or data_temp_humi.shape[0] == 0:
  90. resultsTempHumid = {'tempHumiMeterId': '',
  91. 'tempReal': '',
  92. 'tempLimit': ''}
  93. else:
  94. resultsTempHumid = {'tempHumiMeterId': list(data_temp_humi['tempHumiMeterId']),
  95. 'tempReal': list(data_temp_humi['tempReal']),
  96. 'tempLimit': list(data_temp_humi['tempLimit'])}
  97. if dict_chiller_inner['waterTempControlMode'] == 1: # python输出参数中冷冻水进/出水温度统一字段
  98. resultsOtherOutput = {'heatingWaterTempSet': dict_chiller_inner['heatingWaterTempInSet'],
  99. 'heatingWaterTempSetInitial': dict_chiller_inner['heatingWaterTempInSetInitial'],
  100. 'heatingWaterTempSetUpper': dict_chiller_inner['heatingWaterTempInSetUpper'],
  101. 'resultsDepict': '热水回水温度设定值,由%s℃调整为%s℃' % (
  102. dict_chiller_inner['heatingWaterTempInSet'], water_temp_set_new)
  103. }
  104. else:
  105. resultsOtherOutput = {'heatingWaterTempSet': dict_chiller_inner['heatingWaterTempSet'],
  106. 'heatingWaterTempSetInitial': dict_chiller_inner['heatingWaterTempSetInitial'],
  107. 'heatingWaterTempSetUpper': dict_chiller_inner['heatingWaterTempSetUpper'],
  108. 'resultsDepict': '热水出水温度设定值,由%s℃调整为%s℃' % (
  109. dict_chiller_inner['heatingWaterTempSet'], water_temp_set_new)
  110. }
  111. resultsOutput.update(resultsTempHumid)
  112. resultsOutput.update(resultsOtherOutput)
  113. return resultsOutput
  114. def DictResultsAbnormal(dict_input, result_depict):
  115. resultsOutput = {'userName': dict_input['stationInfo']['userName'],
  116. 'coolingStationName': dict_input['stationInfo']['coolingStationName'],
  117. 'chillerName': dict_input['chillerInfo']['chillerName'],
  118. 'chillerId': dict_input['chillerInfo']['chillerId'],
  119. 'triggerTime': dict_input['stationInfo']['triggerTime'],
  120. 'isOrder': False,
  121. 'waterTempSetNew': None,
  122. 'resultsDepict': result_depict
  123. }
  124. return resultsOutput
  125. def default_dump(obj):
  126. """
  127. TypeError: Object of type int64 is not JSON serializable
  128. Covert numpy classes to JSON serializable objects
  129. """
  130. if isinstance(obj, (np.integer, np.floating, np.bool_)):
  131. return obj.item()
  132. elif isinstance(obj, np.ndarray):
  133. return obj.tolist()
  134. else:
  135. return obj