소스 검색

move get_season to Duoduo service

chenhaiyang 4 년 전
부모
커밋
22078c57ab
3개의 변경된 파일12개의 추가작업 그리고 12개의 파일을 삭제
  1. 1 1
      app/controllers/equipment/fcu/basic.py
  2. 1 1
      app/controllers/equipment/fcu/q_learning.py
  3. 10 10
      app/services/transfer.py

+ 1 - 1
app/controllers/equipment/fcu/basic.py

@@ -98,7 +98,7 @@ async def get_fcu_control_result(project_id: str, equipment_id: str) -> Dict:
             transfer = SpaceInfoService(client, project_id, sp.get('id'))
             current_target = await transfer.get_current_temperature_target()
             realtime_temperature = await platform.get_realtime_temperature(sp.get('id'))
-            season = await transfer.get_season()
+            season = await duo_duo.get_season()
             temp_space_params = {
                 'id': sp.get('id'),
                 'temperature_target': current_target,

+ 1 - 1
app/controllers/equipment/fcu/q_learning.py

@@ -106,7 +106,7 @@ async def get_fcu_q_learning_control_result(project_id: str, equipment_id: str)
             if len(spaces) > 1:
                 logger.error(f'FCU {equipment_id} control more than one spaces!')
             transfer = SpaceInfoService(client, project_id, spaces[0].get('id'))
-            season = await transfer.get_season()
+            season = await duo_duo.get_season()
             current_target = await transfer.get_current_temperature_target()
             realtime_temperature = await platform.get_realtime_temperature(spaces[0].get('id'))
             past_temperature = await platform.get_past_temperature(spaces[0].get('id'), 15 * 60)

+ 10 - 10
app/services/transfer.py

@@ -39,16 +39,6 @@ class SpaceInfoService(Service):
     def _common_parameters(self) -> Dict:
         return {'projectId': self._project_id, 'spaceId': self._space_id}
 
-    async def get_season(self) -> Season:
-        url = self._base_url.join('duoduo-service/transfer/environment/getSeasonType')
-        params = {
-            'projectId': self._project_id,
-            'date': self._now_time,
-        }
-        raw_info = await self._get(url, params)
-
-        return Season(raw_info.get('data'))
-
     async def is_customized(self) -> bool:
         url = self._base_url.join('duoduo-service/custom-service/custom/timetarget')
         time_str = arrow.get(arrow.get(self._now_time, TIME_FMT).shift(minutes=15).timestamp
@@ -196,6 +186,16 @@ class Duoduo(Service):
         self._base_url = URL(server_settings.TRANSFER_HOST)
         self._now_time = get_time_str()
 
+    async def get_season(self) -> Season:
+        url = self._base_url.join('duoduo-service/transfer/environment/getSeasonType')
+        params = {
+            'projectId': self._project_id,
+            'date': self._now_time,
+        }
+        raw_info = await self._get(url, params)
+
+        return Season(raw_info.get('data'))
+
     async def get_fill_rate(self):
         url = self._base_url.join('duoduo-service/review-service/space/report/quarter/query')
         payload = {