DmprwdUtil.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. from MyUtils.HttpRequestsUtil import *
  2. url = "https://doimp.persagy.com/"
  3. energyId_path = "energy-research/common/api/energy/model/project/list"
  4. rwdId_path = "energy-research/common/api/multi/energy/model/item/list"
  5. query_data = "dmp-rwd/rwd/ipcal/data/queryIPDataInPeriod?groupCode=YS&projectId=Pj1101080259"
  6. #1.获取项目属于哪个集团,这里博锐属于散楼,groupCode=YS
  7. #2.获取项目能耗模型id,根据以上energyId_path获取id,id=1000001
  8. #3.获取分项树形结构,根据rwdId_path路径和能耗分项item获取rwdId,
  9. # {itemName:博锐尚格总电耗,itemCode:EI1001,rwdId:Vo1101080259f2481ca3604644399f1dacb84e20adae},
  10. # {itemName:照明与插座,itemCode:EI1010202001,rwdId:Vo110108025953894df8d4ae4dbeb7c81ced7df3f83e},
  11. # {itemName:空调末端,itemCode:EI10102010102001,rwdId:Vo11010802590eaef68d3289452d86d89fbee721e6df},
  12. # {itemName:冷热源,itemCode:EI10102010101001,rwdId:Vo1101080259e6dcf338d9be4bbf826f659b0b5a9ab2},
  13. #4.获取数据,根据以上query_data路径和rwdId获取数据
  14. data_url = url + query_data
  15. def get_query_data(startTime,endTime):
  16. payload = {
  17. "objects": [
  18. {
  19. "objectId": "Vo1101080259f2481ca3604644399f1dacb84e20adae",
  20. "infoCodes": [
  21. "subentryAccConsum"
  22. ]
  23. },
  24. {
  25. "objectId": "Vo110108025953894df8d4ae4dbeb7c81ced7df3f83e",
  26. "infoCodes": [
  27. "subentryAccConsum"
  28. ]
  29. },
  30. {
  31. "objectId": "Vo11010802590eaef68d3289452d86d89fbee721e6df",
  32. "infoCodes": [
  33. "subentryAccConsum"
  34. ]
  35. },
  36. {
  37. "objectId": "Vo1101080259e6dcf338d9be4bbf826f659b0b5a9ab2",
  38. "infoCodes": [
  39. "subentryAccConsum"
  40. ]
  41. }
  42. ],
  43. "ipType": "1d",
  44. "startTime": startTime,
  45. "endTime": endTime,
  46. "dataStatus": 1
  47. }
  48. headers = {
  49. 'Content-Type': 'application/json'
  50. }
  51. res = HttpRequestsUtil.post(data_url,payload,headers)
  52. data = res["data"]
  53. return data
  54. if __name__ == '__main__':
  55. data = get_query_data("20230701000000","20230702000000")
  56. print(data)