123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- import datetime
- import numpy as np
- def DictResultsNull(dict_chiller_outer, dict_chiller_inner, dict_code, results_depict):
- if isinstance(dict_code['triggerTime'], str):
- trigger_time = dict_code['triggerTime']
- else:
- trigger_time = dict_code['triggerTime'].strftime("%Y-%m-%d %H:%M:%S")
- resultsOutput = {'userName': dict_chiller_outer['userName'],
- 'coolingStationName': dict_chiller_outer['coolingStationName'],
- 'chillerName': dict_chiller_outer['chillerName'],
- 'chillerId': dict_chiller_outer['chillerId'],
- 'isOrder': False,
- 'waterTempSetNew': None,
- 'controlMode': dict_code['controlMode'],
- 'energyMode': dict_code['energyMode'],
- # 'triggerTime': dict_code['triggerTime'].strftime("%Y-%m-%d %H:%M:%S"),
- 'triggerTime': trigger_time,
- 'isHardwareControl': dict_code['isHardwareControl'],
- 'runStatus': dict_chiller_inner['runStatus'][-1],
- 'chillerWaterTempOut': dict_chiller_inner['chillerWaterTempOut'][-1],
- 'chillerWaterTempSet': dict_chiller_inner['chillerWaterTempSet'],
- 'chillerWaterTempSetUpper': dict_chiller_inner['chillerWaterTempSetUpper'],
- 'ahuName': [],
- 'tempReal': [],
- 'humiReal': [],
- 'dewTempReal': [],
- 'tempLimit': [],
- 'humiLimit': [],
- 'dewTempLimit': [],
- 'worstTerminalInfo': {},
- 'resultsDepict': results_depict
- }
- return resultsOutput
- def DictResultsNormal(is_suction_with_liquid, is_control, results_depict, water_temp_set_new, dict_chiller_inner,
- dict_chiller_outer, dict_code, data_temp_humi, excess_reslut, terminal_cal):
- if isinstance(dict_code['triggerTime'], str):
- trigger_time = dict_code['triggerTime']
- else:
- trigger_time = dict_code['triggerTime'].strftime("%Y-%m-%d %H:%M:%S")
- resultsOutput = {'userName': dict_chiller_outer['userName'],
- 'coolingStationName': dict_chiller_outer['coolingStationName'],
- 'chillerName': dict_chiller_outer['chillerName'],
- 'chillerId': dict_chiller_outer['chillerId'],
- 'isOrder': is_control,
- 'waterTempSetNew': water_temp_set_new,
- 'controlMode': dict_code['controlMode'],
- 'energyMode': dict_code['energyMode'],
- 'triggerTime': trigger_time,
- # 'triggerTime': dict_code['triggerTime'],
- 'isHardwareControl': dict_code['isHardwareControl'],
- 'runStatus': dict_chiller_inner['runStatus'][-1],
- 'chillerWaterTempOut': dict_chiller_inner['chillerWaterTempOut'][-1],
- 'chillerWaterTempSet': dict_chiller_inner['chillerWaterTempSet'],
- 'chillerWaterTempSetUpper': dict_chiller_inner['chillerWaterTempSetUpper'],
- 'resultsDepict': results_depict}
- if dict_chiller_inner['runMode'] == 0:
- if is_suction_with_liquid == 1 or data_temp_humi.shape[0] == 0 or not terminal_cal:
- resultsTempHumid = {'ahuName': [],
- 'tempReal': [],
- 'humiReal': [],
- 'dewTempReal': [],
- 'tempLimit': [],
- 'humiLimit': [],
- 'dewTempLimit': [],
- 'worstTerminalInfo': {}}
- else:
- resultsTempHumid = {'ahuName': list(data_temp_humi['ahuName']),
- 'tempReal': list(data_temp_humi['tempReal']),
- 'humiReal': list(data_temp_humi['humiReal']),
- 'dewTempReal': list(data_temp_humi['dewTempReal']),
- 'tempLimit': list(data_temp_humi['tempLimit']),
- 'humiLimit': list(data_temp_humi['humiLimit']),
- 'dewTempLimit': list(data_temp_humi['dewTempLimit']),
- 'worstTerminalInfo': excess_reslut,
- }
- if dict_chiller_inner['waterTempControlMode'] == 1: # python输出参数中冷冻水进/出水温度统一字段
- resultsOtherOutput = {'chillerWaterTempSet': dict_chiller_inner['chillerWaterTempInSet'],
- 'chillerWaterTempSetUpper': dict_chiller_inner['chillerWaterTempInSetUpper'],
- # 'resultsDepict': '冷冻水回水温度设定值,由%s℃调整为%s℃' % (
- # dict_chiller_inner['chillerWaterTempInSet'], water_temp_set_new)
- }
- else:
- resultsOtherOutput = {'chillerWaterTempSet': dict_chiller_inner['chillerWaterTempSet'],
- 'chillerWaterTempSetUpper': dict_chiller_inner['chillerWaterTempSetUpper'],
- # 'resultsDepict': '冷冻水出水温度设定值,由%s℃调整为%s℃' % (
- # dict_chiller_inner['chillerWaterTempSet'], water_temp_set_new)
- }
- else:
- if is_suction_with_liquid == 1 or data_temp_humi.shape[0] == 0:
- resultsTempHumid = {'tempHumiMeterId': '',
- 'tempReal': '',
- 'tempLimit': ''}
- else:
- resultsTempHumid = {'tempHumiMeterId': list(data_temp_humi['tempHumiMeterId']),
- 'tempReal': list(data_temp_humi['tempReal']),
- 'tempLimit': list(data_temp_humi['tempLimit'])}
- if dict_chiller_inner['waterTempControlMode'] == 1: # python输出参数中冷冻水进/出水温度统一字段
- resultsOtherOutput = {'heatingWaterTempSet': dict_chiller_inner['heatingWaterTempInSet'],
- 'heatingWaterTempSetInitial': dict_chiller_inner['heatingWaterTempInSetInitial'],
- 'heatingWaterTempSetUpper': dict_chiller_inner['heatingWaterTempInSetUpper'],
- 'resultsDepict': '热水回水温度设定值,由%s℃调整为%s℃' % (
- dict_chiller_inner['heatingWaterTempInSet'], water_temp_set_new)
- }
- else:
- resultsOtherOutput = {'heatingWaterTempSet': dict_chiller_inner['heatingWaterTempSet'],
- 'heatingWaterTempSetInitial': dict_chiller_inner['heatingWaterTempSetInitial'],
- 'heatingWaterTempSetUpper': dict_chiller_inner['heatingWaterTempSetUpper'],
- 'resultsDepict': '热水出水温度设定值,由%s℃调整为%s℃' % (
- dict_chiller_inner['heatingWaterTempSet'], water_temp_set_new)
- }
- resultsOutput.update(resultsTempHumid)
- resultsOutput.update(resultsOtherOutput)
- return resultsOutput
- def DictResultsAbnormal(dict_input, result_depict):
- resultsOutput = {'userName': dict_input['stationInfo']['userName'],
- 'coolingStationName': dict_input['stationInfo']['coolingStationName'],
- 'chillerName': dict_input['chillerInfo']['chillerName'],
- 'chillerId': dict_input['chillerInfo']['chillerId'],
- 'triggerTime': dict_input['stationInfo']['triggerTime'],
- 'isOrder': False,
- 'waterTempSetNew': None,
- 'resultsDepict': result_depict
- }
- return resultsOutput
- def default_dump(obj):
- """
- TypeError: Object of type int64 is not JSON serializable
- Covert numpy classes to JSON serializable objects
- """
- if isinstance(obj, (np.integer, np.floating, np.bool_)):
- return obj.item()
- elif isinstance(obj, np.ndarray):
- return obj.tolist()
- else:
- return obj
|