Browse Source

大屏统计

guoqiang 7 months ago
parent
commit
a4dc106a84

+ 1 - 1
zgztBus/.gitignore

@@ -5,7 +5,7 @@ rebel.xml
 
 ## backend
 **/target
-**/logs
+../**/logs
 
 ## front
 **/*.lock

+ 4 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/gatherData/mapper/FpgGatherDataMapper.java

@@ -3,7 +3,9 @@ package org.jeecg.modules.gatherData.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import io.lettuce.core.dynamic.annotation.Param;
 import org.jeecg.modules.gatherData.entity.FpgGatherData;
+import org.jeecg.modules.gatherData.entity.FpgMiddleTwoData;
 
+import java.util.List;
 import java.util.Map;
 
 
@@ -15,4 +17,6 @@ import java.util.Map;
  */
 public interface FpgGatherDataMapper extends BaseMapper<FpgGatherData> {
     Map getFpgTheLeftSideOneData(@Param("deviceRegionId")String deviceRegionId, @Param("startTime")String startTime, @Param("endTime")String endTime);
+
+    List<FpgMiddleTwoData> getFpgTheLeftSideOneData(@Param("startTime")String startTime);
 }

+ 10 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/gatherData/mapper/xml/FpgGatherDataMapper.xml

@@ -10,4 +10,14 @@
             device_region_id =  #{deviceRegionId} AND
             create_time BETWEEN #{startTime} AND #{endTime}
     </select>
+    <select id="getFpgMiddleTwoData" parameterType="java.lang.String" resultType="rg.jeecg.modules.gatherData.entity.FpgMiddleTwoData">
+        SELECT SUM(active_power) as active_power, SUM(current) as currents,formatted_date FROM (SELECT
+                current, active_power, DATE_FORMAT(create_time, '%H:00') AS formatted_date
+            FROM
+                fpg_gather_data
+            WHERE
+                create_time > #{startTime}) gfd
+        GROUP BY gfd.formatted_date
+
+    </select>
 </mapper>

+ 19 - 4
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/homePageData/service/impl/HomePageDataServiceImpl.java

@@ -6,6 +6,7 @@ import org.jeecg.modules.deviceLesm.entity.*;
 import org.jeecg.modules.deviceLesm.mapper.DevicePointMapper;
 import org.jeecg.modules.deviceLesm.service.IDeviceInformationService;
 import org.jeecg.modules.deviceLesm.service.IDeviceRegionService;
+import org.jeecg.modules.gatherData.entity.FpgMiddleTwoData;
 import org.jeecg.modules.gatherData.mapper.FpgGatherDataMapper;
 import org.jeecg.modules.homePageData.service.IHomePageDataService;
 import org.jeecg.modules.systemConfig.peaksAndValleysTimeConfig.entity.PeaksAndValleysTimeConfig;
@@ -158,16 +159,30 @@ public class HomePageDataServiceImpl implements IHomePageDataService {
 
     @Override
     public Map<String, List> fpvTimeElectricity() {
+        Date today = new Date();
+        String dayDate = new SimpleDateFormat("yyyy-MM-dd 00:00:00").format(today);
+        List<Map<String,String>> tops = new ArrayList<>();
+        List<Map<String,String>> peaks = new ArrayList<>();
+        List<Map<String,String>> flat = new ArrayList<>();
+        List<Map<String,String>> valleys = new ArrayList<>();
+        List<PeaksAndValleysTimeConfig>  peaksAndValleysTimeConfiglist = peaksAndValleysTimeConfigService.list();
+        // 查询时段数据
+        List<FpgMiddleTwoData>  fpgGatherDatalist = fpgGatherDataMapper.getFpgTheLeftSideOneData(dayDate);
+        // 归类尖峰平谷数据
+        // fpgGatherDatalist.forEach(fpgGatherData -> {
+            // 峰平谷时段处理
+           // peaksAndValleysTimeConfiglist.forEach(peaksAndValleysTime -> {
+             //   String startDate = dayDate + " " + peaksAndValleysTime.getStartTime();
+             //   String endDate = dayDate + " " + peaksAndValleysTime.getEndTime();
+           // });
+        // });
         Calendar calendar = Calendar.getInstance();
         calendar.set(Calendar.SECOND, 0);
         calendar.set(Calendar.MINUTE, 0);
         calendar.set(Calendar.HOUR_OF_DAY, 0);
         calendar.set(Calendar.MILLISECOND, 0);
         Map<String, List> res = new HashMap<>();
-        List<Map<String,String>> tops = new ArrayList<>();
-        List<Map<String,String>> peaks = new ArrayList<>();
-        List<Map<String,String>> flat = new ArrayList<>();
-        List<Map<String,String>> valleys = new ArrayList<>();
+
         for (int i = 0; i < 24; i++) {
             calendar.set(Calendar.HOUR_OF_DAY, i);
             Double electricity = Math.random()*100+200;