Sfoglia il codice sorgente

修改计划电量取值方式,增加首页实时功率弹窗功能

wangb@gyee-china.com 1 anno fa
parent
commit
39b0121dc1

+ 26 - 4
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/controller/monitor/MonitorController.java

@@ -1,21 +1,21 @@
 package com.gyee.runeconomy.controller.monitor;
 
 import com.gyee.runeconomy.dto.AjaxResult;
+import com.gyee.runeconomy.dto.DataVo;
 import com.gyee.runeconomy.dto.PowercurveVo;
 import com.gyee.runeconomy.dto.ProjectplanVo;
-import com.gyee.runeconomy.model.auto.ProBasicProjectPlan;
 import com.gyee.runeconomy.service.monitor.MonitorService;
 import com.gyee.runeconomy.util.StringUtils;
-import com.gyee.runeconomy.util.realtimesource.IEdosUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
 
-import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -159,5 +159,27 @@ public class MonitorController {
 
     }
 
+    @GetMapping("GroupRealtime")
+    @ResponseBody
+    @ApiOperation(value = "首页实时数据", notes = "首页实时数据")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "wpId", value = "场站编号", required = true, dataType = "string", paramType = "query"),
+            @ApiImplicitParam(name = "uniformCode", value = "统一编码", required = true, dataType = "string", paramType = "query")
+    })
+    public AjaxResult GroupRealtime(String wpId,String uniformCode) throws Exception {
+
+        List<DataVo> resultList = new ArrayList<>();
+        if (StringUtils.notEmp(wpId)) {
+            resultList = monitorService.GroupRealtimevalue(wpId,uniformCode);
+        }
+
+        if (null != resultList) {
+            return AjaxResult.successData(200, resultList);
+        } else {
+            return AjaxResult.error(500, "操作失败");
+        }
+
+    }
+
 
 }

+ 57 - 207
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/monitor/MonitorService.java

@@ -6,6 +6,7 @@ import com.gyee.common.model.PointData;
 import com.gyee.common.util.DateUtils;
 import com.gyee.common.util.DoubleUtils;
 import com.gyee.common.util.SortUtils;
+import com.gyee.runeconomy.dto.DataVo;
 import com.gyee.runeconomy.dto.PowercurveVo;
 import com.gyee.runeconomy.dto.ProjectplanVo;
 import com.gyee.runeconomy.init.CacheContext;
@@ -838,120 +839,7 @@ public class MonitorService {
 
 
             /**********************************************首页电量统计**********************************************************/
-//            Calendar cal = Calendar.getInstance();
-//            cal.setTime(new Date());
-//            int year = cal.get(Calendar.YEAR);
-//
-//            double fd_r_jhdl = 0;
-//            double fd_y_jhdl = 0;
-//            double fd_n_jhdl = 0;
-//            double gf_r_jhdl = 0;
-//            double gf_y_jhdl = 0;
-//            double gf_n_jhdl = 0;
-//
-//            double fd_r_sjdl = 0;
-//            double fd_y_sjdl = 0;
-//            double fd_n_sjdl = 0;
-//            double gf_r_sjdl = 0;
-//            double gf_y_sjdl = 0;
-//            double gf_n_sjdl = 0;
-//
-//
-//            List<ProBasicProjectPlan> pjls = proBasicProjectPlanService.getList(String.valueOf(year));
-//
-//            // 获取计划发电量信息
-//            Map<String, Map<String, Double>> planmap = new HashMap<>();
-//
-//            setPlanInfoByType(planmap, pjls, wpId);
-//
-//            for (ProBasicPowerstation wp : wplist) {
-//                if (planmap.containsKey(wp.getId())) {
-//                    Map<String, Double> valuemap = planmap.get(wp.getId());
-//
-//                    double yfdljh = 0.0;
-//                    double rfdlsj = 0.0;
-//                    double yfdlsj = 0.0;
-//                    double nfdljh = 0.0;
-//                    double nfdlsj = 0.0;
-//                    if (valuemap.containsKey("yfdljh")) {
-//                        yfdljh = valuemap.get("yfdljh");
-//                    }
-////                    if (valuemap.containsKey("yfdlsj")) {
-////                        yfdlsj = valuemap.get("yfdlsj");
-////                    }
-//                    if (valuemap.containsKey("nfdljh")) {
-//                        nfdljh = valuemap.get("nfdljh");
-//                    }
-////                    if (valuemap.containsKey("nfdlsj")) {
-////                        nfdlsj = valuemap.get("nfdlsj");
-////                    }
-//                    if (wp.getId().indexOf("FDC_STA") >= 0) {
-//                        //日发电量
-//                        ProBasicPowerstationPoint rfdlvalue = proBasicPowerstationPointService.getPowerstationPoint(wp.getId(), ContantXk.RFDL);
-//                        rfdlsj = edosUtil.getRealData(rfdlvalue).getPointValueInDouble();
-//                        //月发电量
-//                        ProBasicPowerstationPoint yfdlvalue = proBasicPowerstationPointService.getPowerstationPoint(wp.getId(), ContantXk.YFDL);
-//                        yfdlsj = edosUtil.getRealData(yfdlvalue).getPointValueInDouble();
-//                        //年发电量
-//                        ProBasicPowerstationPoint nfdlvalue = proBasicPowerstationPointService.getPowerstationPoint(wp.getId(), ContantXk.NFDL);
-//                        nfdlsj = edosUtil.getRealData(nfdlvalue).getPointValueInDouble();
-//
-//                        fd_r_jhdl = fd_r_jhdl + yfdljh / 30;
-//                        fd_y_jhdl = fd_y_jhdl + yfdljh;
-//                        fd_n_jhdl = fd_n_jhdl + nfdljh;
-//
-//                        fd_r_sjdl = fd_r_sjdl + rfdlsj;
-//                        fd_y_sjdl = fd_y_sjdl + yfdlsj;
-//                        fd_n_sjdl = fd_n_sjdl + nfdlsj;
-//                    } else {
-//                        //日发电量
-//                        ProBasicPowerstationPoint rfdlvalue = proBasicPowerstationPointService.getPowerstationPoint(wp.getId(), ContantXk.RFDL);
-//                        rfdlsj = edosUtil.getRealData(rfdlvalue).getPointValueInDouble();
-//                        //月发电量
-//                        ProBasicPowerstationPoint yfdlvalue = proBasicPowerstationPointService.getPowerstationPoint(wp.getId(), ContantXk.YFDL);
-//                        yfdlsj = edosUtil.getRealData(yfdlvalue).getPointValueInDouble();
-//
-//                        //年发电量
-//                        ProBasicPowerstationPoint nfdlvalue = proBasicPowerstationPointService.getPowerstationPoint(wp.getId(), ContantXk.NFDL);
-//                        nfdlsj = edosUtil.getRealData(nfdlvalue).getPointValueInDouble();
-//
-//                        gf_r_jhdl = gf_r_jhdl + yfdljh / 30;
-//                        gf_y_jhdl = gf_y_jhdl + yfdljh;
-//                        gf_n_jhdl = gf_n_jhdl + nfdljh;
-//
-//                        gf_r_sjdl = gf_r_sjdl + rfdlsj;
-//                        gf_y_sjdl = gf_y_sjdl + yfdlsj;
-//                        gf_n_sjdl = gf_n_sjdl + rfdlsj;
-//                    }
-//                }
-//
-//            }
-//
-//
-//            Map<String, Double> proplanmap = new HashMap<>();
-//
-//            proplanmap.put("fd_r_jhdl", StringUtils.round(fd_r_jhdl, 0));
-//            proplanmap.put("fd_y_jhdl", StringUtils.round(fd_y_jhdl, 0));
-//            proplanmap.put("fd_n_jhdl", StringUtils.round(fd_n_jhdl, 0));
-//            proplanmap.put("fd_r_sjdl", StringUtils.round(fd_r_sjdl, 2));
-//            proplanmap.put("fd_y_sjdl", StringUtils.round(fd_y_sjdl, 2));
-//            proplanmap.put("fd_n_sjdl", StringUtils.round(fd_n_sjdl, 2));
-//
-//            proplanmap.put("gf_r_jhdl", StringUtils.round(gf_r_jhdl, 0));
-//            proplanmap.put("gf_y_jhdl", StringUtils.round(gf_y_jhdl, 0));
-//            proplanmap.put("gf_n_jhdl", StringUtils.round(gf_n_jhdl, 0));
-//            proplanmap.put("gf_r_sjdl", StringUtils.round(gf_r_sjdl, 2));
-//            proplanmap.put("gf_y_sjdl", StringUtils.round(gf_y_sjdl, 2));
-//            proplanmap.put("gf_n_sjdl", StringUtils.round(gf_n_sjdl, 2));
-//
-//            proplanmap.put("qy_r_jhdl", StringUtils.round(fd_r_jhdl + gf_r_jhdl, 0));
-//            proplanmap.put("qy_y_jhdl", StringUtils.round(fd_y_jhdl + gf_y_jhdl, 0));
-//            proplanmap.put("qy_n_jhdl", StringUtils.round(fd_n_jhdl + gf_n_jhdl, 0));
-//            proplanmap.put("qy_r_sjdl", StringUtils.round(fd_r_sjdl + gf_r_sjdl, 2));
-//            proplanmap.put("qy_y_sjdl", StringUtils.round(fd_y_sjdl + gf_y_sjdl, 2));
-//            proplanmap.put("qy_n_sjdl", StringUtils.round(fd_n_sjdl + gf_n_sjdl, 2));
-//
-//            map.put("proplanmap", proplanmap);
+
             /**********************************************首页电量统计**********************************************************/
 
 
@@ -1588,22 +1476,6 @@ public class MonitorService {
         currentyear.add(Calendar.YEAR, 0);
         Date currentDate = currentyear.getTime();
 
-//        Calendar threemonth = Calendar.getInstance();
-//        threemonth.add(Calendar.MONTH, -3);
-//        Date threeDatemonth = threemonth.getTime();
-//
-//
-//        Calendar twomonth = Calendar.getInstance();
-//        twomonth.add(Calendar.MONTH, -2);
-//        Date twoDatemonth = twomonth.getTime();
-//
-//        Calendar onemonth = Calendar.getInstance();
-//        onemonth.add(Calendar.MONTH, -1);
-//        Date oneDatemonth = onemonth.getTime();
-//
-//        Calendar currentmonth = Calendar.getInstance();
-//        currentmonth.add(Calendar.MONTH, 1);
-//        Date currentDatemonth = currentmonth.getTime();
 
 
         double zjrl = 0.0;
@@ -1985,6 +1857,8 @@ public class MonitorService {
             cal.setTime(new Date());
             int year = cal.get(Calendar.YEAR);
 
+            int month2 = DateUtils.getMonth(new Date());
+
             double fd_r_jhdl = 0;
             double fd_y_jhdl = 0;
             double fd_n_jhdl = 0;
@@ -2000,13 +1874,6 @@ public class MonitorService {
             double gf_n_sjdl = 0;
 
 
-            List<ProBasicProjectPlan> pjls = proBasicProjectPlanService.getList(String.valueOf(year));
-
-            // 获取计划发电量信息
-            Map<String, Map<String, Double>> planmap = new HashMap<>();
-
-            setPlanInfoByType(planmap, pjls, wpId);
-
             if (wpId.endsWith(QS) || wpId.endsWith(FD) || wpId.endsWith(GF)) {
 
                 double rfdlsj = 0.0;
@@ -2071,22 +1938,23 @@ public class MonitorService {
 
             }
 
+            List<ProBasicProjectPlan> currentls = proBasicProjectPlanService.getList(String.valueOf(year));
+            List<ProBasicProjectPlan> monthls = proBasicProjectPlanService.getmonthList(String.valueOf(month2));
+
             for (ProBasicPowerstation wp : wplist) {
 
-                if (planmap.containsKey(wp.getId())) {
-                    Map<String, Double> valuemap = planmap.get(wp.getId());
+                List<ProBasicProjectPlan> currentjh = currentls.stream().filter(wp1 -> wp1.getWindpowerstationId().equals(wp.getId())).collect(Collectors.toList());
+                List<ProBasicProjectPlan> monthjh = monthls.stream().filter(wp1 -> wp1.getWindpowerstationId().equals(wp.getId())).collect(Collectors.toList());
+
 
                     double yfdljh = 0.0;
                     double rfdlsj = 0.0;
                     double yfdlsj = 0.0;
                     double nfdljh = 0.0;
                     double nfdlsj = 0.0;
-                    if (valuemap.containsKey("yfdljh")) {
-                        yfdljh = valuemap.get("yfdljh");
-                    }
-                    if (valuemap.containsKey("nfdljh")) {
-                        nfdljh = valuemap.get("nfdljh");
-                    }
+                        yfdljh = monthjh.stream().mapToDouble(ProBasicProjectPlan::getGeneratingCapacity).sum();;
+                        nfdljh = currentjh.stream().mapToDouble(ProBasicProjectPlan::getGeneratingCapacity).sum(); ;
+
                     if (wp.getId().indexOf("FDC_STA") >= 0) {
 
                         if (wpId.endsWith("STA")) {
@@ -2133,9 +2001,6 @@ public class MonitorService {
 
                     }
 
-
-                }
-
             }
 
 
@@ -2185,75 +2050,60 @@ public class MonitorService {
     }
 
     /**********************************************计划电量统计**********************************************************/
-    private void setPlanInfoByType
-    (Map<String, Map<String, Double>> gxkmap, List<ProBasicProjectPlan> planls, String wpId) {
-
-        double yfdljh = 0.0;
-        double yfdlsj = 0.0;
-        double nfdljh = 0.0;
-        double nfdlsj = 0.0;
-
-        Calendar cal = Calendar.getInstance();
-        cal.setTime(new Date());
-        int month = cal.get(Calendar.MONTH) + 1;
-
-
-        for (ProBasicProjectPlan plan : planls) {
-
-            double fdl = null != plan.getGeneratingCapacity() ? Double.valueOf(plan.getGeneratingCapacity()) : 0.0;
-
-            double sjfdl = null != plan.getOutageHours() ? Double.valueOf(plan.getOutageHours()) : 0.0;
-
 
-            if (gxkmap.containsKey(plan.getWindpowerstationId())) {
+    /**********************************************计划电量统计**********************************************************/
 
-                Map<String, Double> map = gxkmap.get(plan.getWindpowerstationId());
-                if (StringUtils.notEmp(plan.getMonth())) {
-                    int planmonth = Integer.valueOf(plan.getMonth());
-                    if (planmonth == month) {
+    //首页实时数据
+    public List<DataVo> GroupRealtimevalue(String wpId, String uniformCode) throws Exception {
 
-                        yfdljh = map.get("yfdljh");
-                        yfdlsj = map.get("yfdlsj");
+        Date beginDate = com.gyee.common.util.DateUtils.getSamedayZero();   //当日零点
+        Date endDate = com.gyee.common.util.DateUtils.getCurrentDate();   //当前时间
+        List<DataVo> vos = new ArrayList<DataVo>();
 
-                        yfdljh = yfdljh + fdl;
-                        yfdlsj = yfdlsj + sjfdl;
+        int day = DateUtils.getCurrentHour();//4
 
-                        map.put("yfdljh", yfdljh);
-                        map.put("yfdlsj", yfdlsj);
-                    }
+        for (int i = 0; i < day; i++) {
+            DataVo vo = new DataVo();
+            vo.setValue1(0.0); //实际功率
+            vo.setValue2(0.0); //风电实际功率
+            vo.setValue3(0.0); //光伏实际功率
+            vo.setHours(i);  //时间戳
+            vo.setName(wpId);
+            vos.add(vo);
+        }
 
-                    nfdljh = map.get("nfdljh");
-                    nfdlsj = map.get("nfdlsj");
-                    nfdlsj = nfdlsj + sjfdl;
-                    nfdljh = nfdljh + plan.getGeneratingCapacity();
-                    map.put("nfdljh", nfdljh);
-                    map.put("nfdlsj", nfdlsj);
+        ProBasicPowerstationPoint sjgl = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.SSZGL);
 
+        if (uniformCode.contains("SSZGL")) {
+            List<PointData> sjglls = edosUtil.getHistoryDatasSnap(sjgl, beginDate.getTime() / 1000, endDate.getTime() / 1000, null, 3600L);
+            double temp1 = 0;
+            for (int i = 0; i < sjglls.size(); i++) {
+                temp1 = sjglls.get(i).getPointValueInDouble();
+                vos.get(i).setValue1(StringUtils.round(temp1 / 1000, 2));
+            }
+        }
+        if (wpId.contains(QS)) {
+            ProBasicPowerstationPoint fdsjgl = proBasicPowerstationPointService.getPowerstationPoint(wpId.substring(0,wpId.indexOf("0"))+"-1", ContantXk.SSZGL);
+            if (uniformCode.contains("SSZGL")) {
+                List<PointData> fdsjglls = edosUtil.getHistoryDatasSnap(fdsjgl, beginDate.getTime() / 1000, endDate.getTime() / 1000, null, 3600L);
+                double temp2 = 0;
+                for (int i = 0; i < fdsjglls.size(); i++) {
+                    temp2 = fdsjglls.get(i).getPointValueInDouble();
+                    vos.get(i).setValue2(StringUtils.round(temp2 / 1000, 2));
                 }
-            } else {
-                Map<String, Double> map = new HashMap<>();
-
-                if (StringUtils.notEmp(plan.getMonth())) {
-                    int planmonth = Integer.valueOf(plan.getMonth());
-                    if (planmonth == month) {
-
-                        map.put("yfdljh", fdl);
-                        map.put("yfdlsj", sjfdl);
-                        map.put("nfdljh", 0.00);
-                        map.put("nfdlsj", 0.00);
-                    } else {
-                        map.put("nfdljh", fdl);
-                        map.put("nfdlsj", sjfdl);
-                        map.put("yfdljh", 0.00);
-                        map.put("yfdlsj", 0.00);
-                    }
-
-
+            }
+        }
+        if (wpId.contains(QS)) {
+            ProBasicPowerstationPoint gfsjgl = proBasicPowerstationPointService.getPowerstationPoint(wpId.substring(0,wpId.indexOf("0"))+"-2", ContantXk.SSZGL);
+            if (uniformCode.contains("SSZGL")) {
+                List<PointData> gfsjglls = edosUtil.getHistoryDatasSnap(gfsjgl, beginDate.getTime() / 1000, endDate.getTime() / 1000, null, 3600L);
+                double temp3 = 0;
+                for (int i = 0; i < gfsjglls.size(); i++) {
+                    temp3 = gfsjglls.get(i).getPointValueInDouble();
+                    vos.get(i).setValue3(StringUtils.round(temp3 / 1000, 2));
                 }
-                gxkmap.put(plan.getWindpowerstationId(), map);
             }
-
         }
+        return vos;
     }
-    /**********************************************计划电量统计**********************************************************/
 }