Forráskód Böngészése

峰平谷 大屏首页

guoqiang 7 hónapja
szülő
commit
91521135b2

+ 1 - 9
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/deviceLesm/entity/DeviceRegionInformation.java

@@ -1,15 +1,10 @@
 package org.jeecg.modules.deviceLesm.entity;
 
-import com.baomidou.mybatisplus.annotation.TableName;
-import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
-import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 import org.jeecgframework.poi.excel.annotation.Excel;
 
-import java.io.Serializable;
-
 /**
  * @Description: 区域管理信息表
  * @Author: jeecg-boot
@@ -17,11 +12,8 @@ import java.io.Serializable;
  * @Version: V1.0
  */
 @Data
-@TableName("device_region")
 @Accessors(chain = true)
-@EqualsAndHashCode(callSuper = false)
-@ApiModel(value="device_region对象", description="区域管理信息表")
-public class DeviceRegionInformation implements Serializable {
+public class DeviceRegionInformation{
 
 	/**区域ID*/
 	@Excel(name = "区域ID", width = 15)

+ 2 - 1
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/deviceLesm/mapper/DevicePointMapper.java

@@ -2,6 +2,7 @@ package org.jeecg.modules.deviceLesm.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.jeecg.modules.deviceLesm.entity.DevicePoint;
+import org.jeecg.modules.deviceLesm.entity.DeviceRegionInformation;
 
 import java.util.List;
 
@@ -14,5 +15,5 @@ import java.util.List;
  */
 public interface DevicePointMapper extends BaseMapper<DevicePoint> {
 
-    List getPointInformation(String deviceRegionId);
+    List<DeviceRegionInformation> getPointInformation(String deviceRegionId);
 }

+ 1 - 1
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/deviceLesm/mapper/xml/DevicePointMapper.xml

@@ -2,7 +2,7 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.modules.deviceLesm.mapper.DevicePointMapper">
 
-    <select id="getPointInformation" parameterType="java.lang.String" resultType="map">
+    <select id="getPointInformation" parameterType="java.lang.String" resultType="org.jeecg.modules.deviceLesm.entity.DeviceRegionInformation">
         SELECT *, COUNT(*) as sum FROM (SELECT
             di.device_region_id,dp.gather_status,dp.device_id
             FROM

+ 5 - 3
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/gatherData/entity/FpgGatherData.java

@@ -1,6 +1,8 @@
 package org.jeecg.modules.gatherData.entity;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
+
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -66,15 +68,15 @@ public class FpgGatherData implements Serializable {
 	/**运行电流*/
 	@Excel(name = "运行电流", width = 15)
     @ApiModelProperty(value = "运行电流")
-    private Double current;
+    private BigDecimal current;
 	/**有功功率*/
 	@Excel(name = "有功功率", width = 15)
     @ApiModelProperty(value = "有功功率")
-    private Double activePower;
+    private BigDecimal activePower;
 	/**电压*/
 	@Excel(name = "电压", width = 15)
     @ApiModelProperty(value = "电压")
-    private Double voltage;
+    private BigDecimal voltage;
 	/**峰平谷类型*/
 	@Excel(name = "峰平谷类型", width = 15, dicCode = "fpg_type")
 	@Dict(dicCode = "fpg_type")

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

@@ -1,8 +1,12 @@
 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 java.util.Map;
+
+
 /**
  * @Description: 峰平谷数据采集
  * @Author: jeecg-boot
@@ -10,5 +14,5 @@ import org.jeecg.modules.gatherData.entity.FpgGatherData;
  * @Version: V1.0
  */
 public interface FpgGatherDataMapper extends BaseMapper<FpgGatherData> {
-
+    Map getFpgTheLeftSideOneData(@Param("deviceRegionId")String deviceRegionId, @Param("startTime")String startTime, @Param("endTime")String endTime);
 }

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

@@ -1,5 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.modules.gatherData.mapper.FpgGatherDataMapper">
-
+    <select id="getFpgTheLeftSideOneData" parameterType="java.lang.String" resultType="map">
+        SELECT
+            SUM(current) as currents, SUM(active_power) as active_power
+        FROM
+            fpg_gather_data
+        WHERE
+            device_region_id =  #{deviceRegionId} AND
+            create_time BETWEEN #{startTime} AND #{endTime}
+    </select>
 </mapper>

+ 3 - 3
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/homePageData/controller/HomePageDataController.java

@@ -32,12 +32,12 @@ public class HomePageDataController {
 
 
     /**
-     * 各区域峰平谷时间段用电量
+     * 评价
      *
      * @return
      */
-    @AutoLog(value = "各区域峰平谷时间段用电量")
-    @ApiOperation(value="各区域峰平谷时间段用电量", notes="各区域峰平谷时间段用电量")
+    @AutoLog(value = "评价")
+    @ApiOperation(value="评价", notes="评价")
     @GetMapping(value = "/regionPfvElectricity")
     public Result<List<Map<String, String>>> regionPfvElectricity() {
         List<Map<String, String>> list = homePageDataService.regionPfvElectricity();

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

@@ -1,23 +1,19 @@
 package org.jeecg.modules.homePageData.service.impl;
 
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.alibaba.fastjson.JSON;
 import org.jeecg.common.util.oConvertUtils;
-import org.jeecg.modules.deviceLesm.entity.DeviceInformation;
-import org.jeecg.modules.deviceLesm.entity.DevicePoint;
-import org.jeecg.modules.deviceLesm.entity.DeviceRegion;
-import org.jeecg.modules.deviceLesm.entity.DeviceRegionInformation;
+import org.jeecg.modules.deviceLesm.entity.*;
 import org.jeecg.modules.deviceLesm.mapper.DevicePointMapper;
-import org.jeecg.modules.deviceLesm.mapper.DeviceRegionMapper;
 import org.jeecg.modules.deviceLesm.service.IDeviceInformationService;
 import org.jeecg.modules.deviceLesm.service.IDeviceRegionService;
-import org.jeecg.modules.deviceLesm.service.impl.DeviceRegionServiceImpl;
+import org.jeecg.modules.gatherData.mapper.FpgGatherDataMapper;
 import org.jeecg.modules.homePageData.service.IHomePageDataService;
 import org.jeecg.modules.systemConfig.peaksAndValleysTimeConfig.entity.PeaksAndValleysTimeConfig;
 import org.jeecg.modules.systemConfig.peaksAndValleysTimeConfig.service.IPeaksAndValleysTimeConfigService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.text.ParseException;
+import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicReference;
@@ -35,20 +31,58 @@ public class HomePageDataServiceImpl implements IHomePageDataService {
     @Autowired
     private DevicePointMapper devicePointMapper;
 
+    @Autowired
+    private FpgGatherDataMapper fpgGatherDataMapper;
+
+    @Autowired
+    private IPeaksAndValleysTimeConfigService peaksAndValleysTimeConfigService;
+
 
     @Override
     public List<Map<String, String>> regionPfvElectricity() {
+        Date today = new Date();
+        String dayDate = new SimpleDateFormat("yyyy-MM-dd").format(today);
         List<DeviceRegion> list = deviceRegionService.list();
+        List<PeaksAndValleysTimeConfig>  peaksAndValleysTimeConfiglist = peaksAndValleysTimeConfigService.list();
         List<Map<String, String>> res = new ArrayList<>();
         if(oConvertUtils.listIsNotEmpty(list)){
             list.forEach(deviceRegion -> {
                 Map<String, String> map = new HashMap<>();
-                Double electricity = Math.random()*100+200;
+                Map<String, Object> mapSum = new HashMap<>();
+                mapSum.put("topsSum", 0.00);
+                mapSum.put("peaksSum", 0.00);
+                mapSum.put("flatSum", 0.00);
+                mapSum.put("valleysSum", 0.00);
+                // 峰平谷时段处理
+                peaksAndValleysTimeConfiglist.forEach(peaksAndValleysTime -> {
+                    String startDate = dayDate + " " + peaksAndValleysTime.getStartTime();
+                    String endDate = dayDate + " " + peaksAndValleysTime.getEndTime();
+                    Map peaksAndValleysTimeMap= fpgGatherDataMapper.getFpgTheLeftSideOneData(deviceRegion.getId(), startDate, endDate);
+                    if(peaksAndValleysTimeMap != null){
+                        if("tops".equals(peaksAndValleysTime.getType())){ // 尖值处理
+                            BigDecimal topsAmount = new BigDecimal(String.valueOf(peaksAndValleysTimeMap.get("active_power")));
+                            BigDecimal topsSum = new BigDecimal(String.valueOf(mapSum.get("topsSum")));
+                            mapSum.put("topsSum", topsSum.add(topsAmount));
+                        }else if("peaks".equals(peaksAndValleysTime.getType())){ // 峰值处理
+                            BigDecimal peaksAmount = new BigDecimal(String.valueOf(peaksAndValleysTimeMap.get("active_power")));
+                            BigDecimal peaksSum = new BigDecimal(String.valueOf(mapSum.get("peaksSum")));
+                            mapSum.put("peaksSum", peaksSum.add(peaksAmount));
+                        }else if("flat".equals(peaksAndValleysTime.getType())){ // 平值处理
+                            BigDecimal flatAmount = new BigDecimal(String.valueOf(peaksAndValleysTimeMap.get("active_power")));
+                            BigDecimal flatSum = new BigDecimal(String.valueOf(mapSum.get("flatSum")));
+                            mapSum.put("flatSum", flatSum.add(flatAmount));
+                        }else if("valleys".equals(peaksAndValleysTime.getType())){ // 谷值处理
+                            BigDecimal valleysAmount = new BigDecimal(String.valueOf(peaksAndValleysTimeMap.get("active_power")));
+                            BigDecimal valleysSum = new BigDecimal(String.valueOf(mapSum.get("valleysSum")));
+                            mapSum.put("valleysSum", valleysSum.add(valleysAmount));
+                        }
+                    }
+                });
                 map.put("name",deviceRegion.getRegionTitle());
-                map.put("tops", String.format("%.2f",electricity*(Math.random()*0.2+1)));
-                map.put("peaks", String.format("%.2f",electricity));
-                map.put("flat", String.format("%.2f",electricity*(Math.random()*0.2+0.7)));
-                map.put("valleys", String.format("%.2f",electricity*(Math.random()*0.2+0.5)));
+                map.put("tops", String.format("%.2f", mapSum.get("topsSum")));
+                map.put("peaks", String.format("%.2f", mapSum.get("peaksSum")));
+                map.put("flat", String.format("%.2f", mapSum.get("flatSum")));
+                map.put("valleys", String.format("%.2f", mapSum.get("valleysSum")));
                 res.add(map);
             });
         }
@@ -66,10 +100,12 @@ public class HomePageDataServiceImpl implements IHomePageDataService {
             list.forEach(deviceRegion -> {
                 List<DeviceRegionInformation> devicePointList = devicePointMapper.getPointInformation(deviceRegion.getId());
                 Map<String, Object> map = new HashMap<>();
+                map.put("online",  0);
+                map.put("offline",  0);
                 devicePointList.forEach(devicePointInfo -> {
-                    if(devicePointInfo.getGatherStatus() == "1"){ // 在线
+                    if("1".equals(devicePointInfo.getGatherStatus())){ // 在线
                         map.put("online",  devicePointInfo.getSum());
-                    }else if(devicePointInfo.getGatherStatus() == "0"){ // 离线
+                    }else if("0".equals(devicePointInfo.getGatherStatus())){ // 离线
                         map.put("offline", devicePointInfo.getSum());
                     }
                 });

+ 2 - 2
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/systemConfig/peaksAndValleysTimeConfig/entity/PeaksAndValleysTimeConfig.java

@@ -57,13 +57,13 @@ public class PeaksAndValleysTimeConfig implements Serializable {
 	@JsonFormat(timezone = "GMT+8",pattern = "HH:mm:ss")
     @DateTimeFormat(pattern="HH:mm:ss")
     @ApiModelProperty(value = "开始时间")
-    private java.util.Date startTime;
+    private String startTime;
 	/**结束时间*/
 	@Excel(name = "结束时间", width = 20, format = "HH:mm:ss")
 	@JsonFormat(timezone = "GMT+8",pattern = "HH:mm:ss")
     @DateTimeFormat(pattern="HH:mm:ss")
     @ApiModelProperty(value = "结束时间")
-    private java.util.Date endTime;
+    private String endTime;
 	/**峰平谷类型*/
 	@Excel(name = "峰平谷类型", width = 15)
     @ApiModelProperty(value = "峰平谷类型(尖:tops 峰:peaks 平:flat 谷:valleys)")