Browse Source

数据获取实现类

JCM 4 years ago
parent
commit
d4ed470a02

+ 7 - 2
src/main/java/com/ebei/screen/common/task/EbaTask.java

@@ -1,6 +1,8 @@
 package com.ebei.screen.common.task;
 
+import com.ebei.screen.service.EbaSystemService;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
@@ -14,8 +16,11 @@ import org.springframework.stereotype.Component;
 @Component
 public class EbaTask {
 
-    @Scheduled(cron = "*/15 * * * * ?")
-    public void execute() {
+    @Autowired
+    private EbaSystemService ebaSystemService;
 
+    @Scheduled(cron = "*/5 * * * * ?")
+    public void execute() {
+        ebaSystemService.getProjectList();
     }
 }

+ 12 - 0
src/main/java/com/ebei/screen/service/EnergyPlatformService.java

@@ -0,0 +1,12 @@
+package com.ebei.screen.service;
+
+/**
+ * @author JCM
+ * @description
+ * @date 2021/1/15 15:36
+ */
+public interface EnergyPlatformService {
+
+
+    void apiClientBoxGrouped();
+}

+ 15 - 1
src/main/java/com/ebei/screen/service/impl/EbaSystemServiceImpl.java

@@ -40,91 +40,105 @@ public class EbaSystemServiceImpl implements EbaSystemService {
     @Override
     public void getProjectList() {
         List<Map> projectList = EbaUtils.getProjectList();
-        //mongoTemplate.dropCollection("test");
+        mongoTemplate.dropCollection("projectList");
         mongoTemplate.insert(projectList, "projectList");
     }
 
     @Override
     public void getMobjectList(Long projectId) {
         List<Map> mobjectList = EbaUtils.getMobjectList(projectId);
+        mongoTemplate.dropCollection("mobjectList");
         mongoTemplate.insert(mobjectList,"mobjectList");
     }
 
     @Override
     public void getIotList(Long projectId) {
         List<Map> iotList = EbaUtils.getIotList(projectId);
+        mongoTemplate.dropCollection("iotList");
         mongoTemplate.insert(iotList,"iotList");
     }
 
     @Override
     public void getDeviceSystemList() {
         List<Map> deviceSystemList = EbaUtils.getDeviceSystemList();
+        mongoTemplate.dropCollection("deviceSystemList");
         mongoTemplate.insert(deviceSystemList,"deviceSystemList");
     }
 
     @Override
     public void getDeviceTypeList() {
         List<Map> deviceTypeList = EbaUtils.getDeviceTypeList();
+        mongoTemplate.dropCollection("deviceTypeList");
         mongoTemplate.insert(deviceTypeList,"deviceTypeList");
     }
 
     @Override
     public void getDeviceParamList() {
         List<Map> deviceParamList = EbaUtils.getDeviceParamList();
+        mongoTemplate.dropCollection("deviceParamList");
         mongoTemplate.insert(deviceParamList,"deviceParamList");
     }
 
     @Override
     public void getDeviceAlarmTypeList() {
         List<Map> deviceAlarmTypeList = EbaUtils.getDeviceAlarmTypeList();
+        mongoTemplate.dropCollection("deviceAlarmTypeList");
         mongoTemplate.insert(deviceAlarmTypeList,"deviceAlarmTypeList");
     }
 
     @Override
     public void getFireDeviceTypeList() {
         List<Map> fireDeviceTypeList = EbaUtils.getFireDeviceTypeList();
+        mongoTemplate.dropCollection("fireDeviceTypeList");
         mongoTemplate.insert(fireDeviceTypeList,"fireDeviceTypeList");
     }
 
     @Override
     public void getMobjectRealDataList(List<Map<String, Integer>> deviceParams) {
         List<Map> mobjectRealDataList = EbaUtils.getMobjectRealDataList(deviceParams);
+        mongoTemplate.dropCollection("mobjectRealDataList");
         mongoTemplate.insert(mobjectRealDataList,"mobjectRealDataList");
     }
 
     @Override
     public void getMobjectRealDataByProjectIdList(Long projectId) {
         List<Map> dataByProjectIdList = EbaUtils.getMobjectRealDataByProjectIdList(projectId);
+        mongoTemplate.dropCollection("dataByProjectIdList");
         mongoTemplate.insert(dataByProjectIdList,"dataByProjectIdList");
     }
 
     @Override
     public void getMobjectEnergyList(Long deviceId, Long deviceParameterId, Long beginTime, Long endTime) {
         List<Map> mobjectEnergyList = EbaUtils.getMobjectEnergyList(deviceId, deviceParameterId, beginTime, endTime);
+        mongoTemplate.dropCollection("mobjectEnergyList");
         mongoTemplate.insert(mobjectEnergyList,"mobjectEnergyList");
     }
 
     @Override
     public void getMobjectRealTimeAlarmList(Long projectId) {
         List<Map> mobjectRealTimeAlarmList = EbaUtils.getMobjectRealTimeAlarmList(projectId);
+        mongoTemplate.dropCollection("mobjectRealTimeAlarmList");
         mongoTemplate.insert(mobjectRealTimeAlarmList,"mobjectRealTimeAlarmList");
     }
 
     @Override
     public void getMobjectHisAlarmPageList(Long projectId, Long beginTime, Long endTime, Integer pageIndex, Integer pageSize) {
         List<Map> mobjectHisAlarmPageList = EbaUtils.getMobjectHisAlarmPageList(projectId, beginTime, endTime, pageIndex, pageSize);
+        mongoTemplate.dropCollection("mobjectHisAlarmPageList");
         mongoTemplate.insert(mobjectHisAlarmPageList,"mobjectHisAlarmPageList");
     }
 
     @Override
     public void getIotVideoUrl(Long IotId) {
         List<Map> iotVideoUrl = EbaUtils.getIotVideoUrl(IotId);
+        mongoTemplate.dropCollection("iotVideoUrl");
         mongoTemplate.insert(iotVideoUrl,"iotVideoUrl");
     }
 
     @Override
     public void getIotAlarmRealTimeList(Long projectId) {
         List<Map> iotAlarmRealTimeList = EbaUtils.getIotAlarmRealTimeList(projectId);
+        mongoTemplate.dropCollection("iotAlarmRealTimeList");
         mongoTemplate.insert(iotAlarmRealTimeList,"iotAlarmRealTimeList");
     }
 

+ 29 - 0
src/main/java/com/ebei/screen/service/impl/EnergyPlatformServiceImpl.java

@@ -0,0 +1,29 @@
+package com.ebei.screen.service.impl;
+
+import com.ebei.screen.service.EnergyPlatformService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * 能耗平台大屏
+ *
+ * @author JCM
+ * @description
+ * @date 2021/1/15 15:36
+ */
+@Slf4j
+@Service("energyPlatformService")
+@Transactional(rollbackFor = {Exception.class})
+public class EnergyPlatformServiceImpl implements EnergyPlatformService {
+
+    @Autowired
+    private MongoTemplate mongoTemplate;
+
+    @Override
+    public void apiClientBoxGrouped() {
+
+    }
+}