瀏覽代碼

光资源分析提交

xieshengjie 1 年之前
父節點
當前提交
8a17b04eee

+ 2 - 4
web/runeconomy-jjyx/src/main/java/com/gyee/runeconomy/controller/Economic/EconomicController.java

@@ -6,7 +6,6 @@ import com.gyee.runeconomy.dto.PowercurveVo;
 import com.gyee.runeconomy.dto.R;
 import com.gyee.runeconomy.dto.ResultMsg;
 import com.gyee.runeconomy.service.Economic.EconomicService;
-import com.gyee.runeconomy.util.DateUtils;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.log4j.Log4j2;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -28,8 +27,7 @@ import java.util.Map;
 @RestController
 @RequestMapping("//economy")
 public class EconomicController {
-    String strdate = "2023-01-26";
-    Date date = DateUtils.parseDate(strdate);
+
     @Autowired
     private EconomicService economicService;
 
@@ -50,7 +48,7 @@ public class EconomicController {
 
     ) throws Exception {
 
-        Map<String, Object> map = economicService.getEconomyPointInfo(date, companyId, type, statype, datetype);
+        Map<String, Object> map = economicService.getEconomyPointInfo(companyId, type, statype, datetype);
         if (null != map) {
             return R.data(ResultMsg.ok(map));
         } else {

+ 43 - 0
web/runeconomy-jjyx/src/main/java/com/gyee/runeconomy/dto/AveVo.java

@@ -0,0 +1,43 @@
+package com.gyee.runeconomy.dto;/*
+@author   谢生杰
+@date   2023/6/28-18:06
+*/
+
+public class AveVo {
+    private String id;
+    private String name;
+    private Double aves;
+    private long time;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Double getAves() {
+        return aves;
+    }
+
+    public void setAves(Double aves) {
+        this.aves = aves;
+    }
+
+    public long getTime() {
+        return time;
+    }
+
+    public void setTime(long time) {
+        this.time = time;
+    }
+}

+ 43 - 0
web/runeconomy-jjyx/src/main/java/com/gyee/runeconomy/dto/MaxVo.java

@@ -0,0 +1,43 @@
+package com.gyee.runeconomy.dto;/*
+@author   谢生杰
+@date   2023/6/28-18:06
+*/
+
+public class MaxVo {
+    private String id;
+    private String name;
+    private Double maxs;
+    private long time;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Double getMaxs() {
+        return maxs;
+    }
+
+    public void setMaxs(Double maxs) {
+        this.maxs = maxs;
+    }
+
+    public long getTime() {
+        return time;
+    }
+
+    public void setTime(long time) {
+        this.time = time;
+    }
+}

+ 43 - 0
web/runeconomy-jjyx/src/main/java/com/gyee/runeconomy/dto/MinVo.java

@@ -0,0 +1,43 @@
+package com.gyee.runeconomy.dto;/*
+@author   谢生杰
+@date   2023/6/28-18:06
+*/
+
+public class MinVo {
+    private String id;
+    private String name;
+    private Double mins;
+    private long time;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Double getMins() {
+        return mins;
+    }
+
+    public void setMins(Double mins) {
+        this.mins = mins;
+    }
+
+    public long getTime() {
+        return time;
+    }
+
+    public void setTime(long time) {
+        this.time = time;
+    }
+}

+ 110 - 68
web/runeconomy-jjyx/src/main/java/com/gyee/runeconomy/service/Economic/EconomicService.java

@@ -2,10 +2,7 @@ package com.gyee.runeconomy.service.Economic;
 
 import com.gyee.common.contant.ContantXk;
 import com.gyee.common.model.PointData;
-import com.gyee.runeconomy.dto.EconomicVo;
-import com.gyee.runeconomy.dto.Glqx;
-import com.gyee.runeconomy.dto.PowercurveVo;
-import com.gyee.runeconomy.dto.WxssVo;
+import com.gyee.runeconomy.dto.*;
 import com.gyee.runeconomy.init.CacheContext;
 import com.gyee.runeconomy.model.auto.ProBasicEquipmentPoint;
 import com.gyee.runeconomy.model.auto.ProBasicOrganizeTree;
@@ -56,13 +53,13 @@ public class EconomicService {
      * @return
      * @throws ParseException
      */
-    public Map<String, Object> getEconomyPointInfo(Date date, String companyId, String type, String statype, String datetype) throws ParseException {
+    public Map<String, Object> getEconomyPointInfo(String companyId, String type, String statype, String datetype) throws ParseException {
 
 
         //获取当前时间
 //        String strdate = DateUtils.toDate1(new Date());
-//        String strdate = "2023-01-26";
-//        Date date = DateUtils.parseDate(strdate);
+        String strdate = "2023-01-26";
+        Date date = DateUtils.parseDate(strdate);
 
         Map<String, Object> map = new HashMap<>();
         Map<String, Object> fdtjmap = new HashMap<>();
@@ -83,31 +80,31 @@ public class EconomicService {
 
         BigDecimal num1 = new BigDecimal("100");
         if (companyId.startsWith("JS_RGN") && type.equals("-1")) {
-            qyls = station1ls.stream().filter(wp -> wp.getForeignKeyId().contains("JS_RGN-1") && wp.getRecordDate().equals(date)).collect(Collectors.toList());
+            qyls = station1ls.stream().filter(wp -> wp != null && "JS_RGN-1".contains(wp.getForeignKeyId()) && date.equals(wp.getRecordDate())).collect(Collectors.toList());
         } else if (companyId.startsWith("JS_RGN") && type.equals("-2")) {
-            qyls = station1ls.stream().filter(wp -> wp.getForeignKeyId().contains("JS_RGN-2") && wp.getRecordDate().equals(date)).collect(Collectors.toList());
+            qyls = station1ls.stream().filter(wp ->wp != null && "JS_RGN-2".contains(wp.getForeignKeyId()) && date.equals(wp.getRecordDate())).collect(Collectors.toList());
         } else {
-            qyls = station1ls.stream().filter(wp -> wp.getForeignKeyId().contains(companyId) && wp.getRecordDate().equals(date)).collect(Collectors.toList());
+            qyls = station1ls.stream().filter(wp -> wp.getForeignKeyId().contains(companyId) && date.equals(wp.getRecordDate())).collect(Collectors.toList());
         }
 
 
         //列表
         if (companyId.startsWith("JS_RGN") && type.equals("-1")) {
-            gsls = station1ls.stream().filter(wp -> wp.getRegionId().contains("JS_RGN-1") && wp.getRecordDate().equals(date)).collect(Collectors.toList());
+            gsls = station1ls.stream().filter(wp -> wp != null && "JS_RGN-1".contains(wp.getRegionId()) && date.equals(wp.getRecordDate())).collect(Collectors.toList());
             trls = treels.stream().filter(wp -> wp.getId().endsWith("ZGS")).collect(Collectors.toList());
         } else if (companyId.startsWith("JS_RGN") && type.equals("-2")) {
-            gsls = station1ls.stream().filter(wp -> wp.getRegionId().contains("JS_RGN-2") && wp.getRecordDate().equals(date)).collect(Collectors.toList());
-            trls = treels.stream().filter(wp -> wp.getId().endsWith("ZGS")).collect(Collectors.toList());
-
+            gsls = station1ls.stream().filter(wp -> "JS_RGN-2".contains(wp.getRegionId()) && wp.getRecordDate().equals(date)).collect(Collectors.toList());
+            trls = treels.stream().filter(wp -> wp != null && wp.getId().endsWith("ZGS")).collect(Collectors.toList());
 
+        //statype判断
         } else if (companyId.startsWith("JS_RGN") && statype.equals("-1")) {
-            gsls = station1ls.stream().filter(wp -> wp.getRegionId().contains("JS_RGN-1") && wp.getRecordDate().equals(date)).collect(Collectors.toList());
+            gsls = station1ls.stream().filter(wp -> wp != null && "JS_RGN-1".contains(wp.getRegionId()) && date.equals(wp.getRecordDate())).collect(Collectors.toList());
             trls = treels.stream().filter(wp -> wp.getId().endsWith("STA")).collect(Collectors.toList());
         } else if (companyId.startsWith("JS_RGN") && statype.equals("-2")) {
-            gsls = station1ls.stream().filter(wp -> wp.getRegionId().contains("JS_RGN-2") && wp.getRecordDate().equals(date)).collect(Collectors.toList());
+            gsls = station1ls.stream().filter(wp -> wp != null && "JS_RGN-2".contains(wp.getRegionId()) && date.equals(wp.getRecordDate())).collect(Collectors.toList());
             trls = treels.stream().filter(wp -> wp.getId().endsWith("STA")).collect(Collectors.toList());
         } else {
-            gsls = station1ls.stream().filter(wp -> wp.getForeignKeyId().contains("STA") && wp.getRecordDate().equals(date)).collect(Collectors.toList());
+            gsls = station1ls.stream().filter(wp -> "STA".contains(wp.getForeignKeyId()) && date.equals(wp.getRecordDate())).collect(Collectors.toList());
             trls = treels.stream().filter(wp -> wp.getParentCode().endsWith(companyId)).collect(Collectors.toList());
         }
 
@@ -391,73 +388,75 @@ public class EconomicService {
 
         for (EconomicVo wt2 : wt) {
 
-                ProBasicEquipmentPoint sjgl = null;
-                ProBasicEquipmentPoint llgl = null;
+            ProBasicEquipmentPoint sjgl = null;
+            ProBasicEquipmentPoint llgl = null;
 
-                if (type.equals("-2")) {
-                    sjgl = proBasicEquipmentPointService.getEquipmentPoint(wt2.getId(), ContantXk.AIG007);
-                    llgl = proBasicEquipmentPointService.getEquipmentPoint(wt2.getId(), ContantXk.AIG007);
-                }
-                if (type.equals("-1")) {
-                    sjgl = proBasicEquipmentPointService.getEquipmentPoint(wt2.getId(), ContantXk.AIG007);
-                    llgl = proBasicEquipmentPointService.getEquipmentPoint(wt2.getId(), ContantXk.AIG007);
-                }
-                if (sjgl.getId() == null) {
-                    continue;
-                }
+            if (type.equals("-2")) {
+                sjgl = proBasicEquipmentPointService.getEquipmentPoint(wt2.getId(), ContantXk.AIG007);
+                llgl = proBasicEquipmentPointService.getEquipmentPoint(wt2.getId(), ContantXk.AIG007);
+            }
+            if (type.equals("-1")) {
+                sjgl = proBasicEquipmentPointService.getEquipmentPoint(wt2.getId(), ContantXk.AIG007);
+                llgl = proBasicEquipmentPointService.getEquipmentPoint(wt2.getId(), ContantXk.AIG007);
+            }
+            if (sjgl.getId() == null) {
+                continue;
+            }
 
 
-                List<PointData> sjglls = edosUtil.getHistoryDatasSnap(sjgl, beginDate.getTime() / 1000, endDate.getTime() / 1000, null, 900L);
-                List<PointData> llglls = edosUtil.getHistoryDatasSnap(llgl, beginDate.getTime() / 1000, endDate.getTime() / 1000, null, 900L);
-                double temp1 = 0;
-                double temp2 = 0;
-                for (int i = 0; i < sjglls.size(); i++) {
+            List<PointData> sjglls = edosUtil.getHistoryDatasSnap(sjgl, beginDate.getTime() / 1000, endDate.getTime() / 1000, null, 900L);
+            List<PointData> llglls = edosUtil.getHistoryDatasSnap(llgl, beginDate.getTime() / 1000, endDate.getTime() / 1000, null, 900L);
+            double temp1 = 0;
+            double temp2 = 0;
+            for (int i = 0; i < sjglls.size(); i++) {
 
-                    Glqx vos = new Glqx();
-                    vos.setYcgl(0.0);
-                    vos.setSjgl(0.0);
-                    vos.setName("0");
-                    vos.setId("0");
-                    vos.setTime(2023);
+                Glqx vos = new Glqx();
+                vos.setYcgl(0.0);
+                vos.setSjgl(0.0);
+                vos.setName("0");
+                vos.setId("0");
+                vos.setTime(2023);
 
-                    temp1 = sjglls.get(i).getPointValueInDouble();
+                temp1 = sjglls.get(i).getPointValueInDouble();
 
-                    if (sjgl.getWindturbineId().contains(wt2.getId())) {
+                if (sjgl.getWindturbineId().contains(wt2.getId())) {
 //                            Date date = new Date(sjglls.get(i).getPointTime());
 //                            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 //                            String formattedDate = sdf.format(date);
-                        vos.setTime(sjglls.get(i).getPointTime());
+                    vos.setTime(sjglls.get(i).getPointTime());
 //                            vos.setTime(formattedDate);
-                        vos.setId(wt2.getId());
-                        vos.setName(wt2.getName());
-                        vos.setSjgl(StringUtils.round(temp1, 2));
-                    }
-
-                    temp2 = llglls.get(i).getPointValueInDouble();
-                    if (llgl.getWindturbineId().contains(wt2.getId())) {
-                        vos.setYcgl(StringUtils.round(temp2, 2));
-                    }
+                    vos.setId(wt2.getId());
+                    vos.setName(wt2.getName());
+                    vos.setSjgl(StringUtils.round(temp1, 2));
+                }
 
-                    vo.add(vos);
+                temp2 = llglls.get(i).getPointValueInDouble();
+                if (llgl.getWindturbineId().contains(wt2.getId())) {
+                    vos.setYcgl(StringUtils.round(temp2, 2));
                 }
 
+                vo.add(vos);
+            }
+
         }
 
         return vo;
     }
 
 
-    public Map<String, Object>irradiance(String companys,String wpids, String type, String starttime, String endtime, String dateType, String windturbineids) throws Exception {
+    public Map<String, Object> irradiance(String companys, String wpids, String type, String starttime, String endtime, String dateType, String windturbineids) throws Exception {
 
 //        List<ProBasicOrganizeEquipment> wtls = CacheContext.organizeEquipmentList;
-        String[] split = wpids.split(",");
+        List<MaxVo> maxvalue = new ArrayList<>();
+        List<MinVo> minvalue = new ArrayList<>();
+        List<AveVo> avevalue = new ArrayList<>();
         List<ProBasicOrganizeTree> eqs = CacheContext.proBasicOrganizeTrees;
 
-        List<ProBasicOrganizeTree> wtls =null;
+        List<ProBasicOrganizeTree> wtls = null;
 
-            wtls = eqs.stream()
-                    .filter(v -> "EMI".equals(v.getEqType()) && wpids.contains(v.getParentCode()))
-                    .collect(Collectors.toList());
+        wtls = eqs.stream()
+                .filter(v -> "EMI".equals(v.getEqType()) && wpids.contains(v.getParentCode()))
+                .collect(Collectors.toList());
 
         List<EconomicVo> wt = new ArrayList<>();
         List<Glqx> vo = new ArrayList<>();
@@ -501,6 +500,13 @@ public class EconomicService {
             }
 
             List<PointData> pjgzdls = edosUtil.getHistoryDatasSnap(pjgzd, beginDate.getTime() / 1000, endDate.getTime() / 1000, null, 900L);
+
+
+            List<PointData> maxs = edosUtil.getHistStat(pjgzd, beginDate.getTime() / 1000, endDate.getTime() / 1000, (long) 1, null, 0);
+            List<PointData> mins = edosUtil.getHistStat(pjgzd, beginDate.getTime() / 1000, endDate.getTime() / 1000, (long) 1, null, 1);
+            List<PointData> ave = edosUtil.getHistStat(pjgzd, beginDate.getTime() / 1000, endDate.getTime() / 1000, (long) 1, null, 2);
+
+
             double temp1 = 0;
             for (int i = 0; i < pjgzdls.size(); i++) {
                 Glqx vos = new Glqx();
@@ -517,22 +523,58 @@ public class EconomicService {
                 }
                 vo.add(vos);
             }
+
+
+            double temp2 = 0;
+            double temp3 = 0;
+            double temp4 = 0;
+
+            MaxVo maxVo = new MaxVo();
+            temp2 = maxs.get(0).getPointValueInDouble();
+            maxVo.setMaxs(StringUtils.round(temp2, 2));
+            maxVo.setName(wt2.getName());
+            maxVo.setId(wt2.getId());
+            maxVo.setTime(maxs.get(0).getPointTime());
+
+            MinVo minVo = new MinVo();
+            temp3 = mins.get(0).getPointValueInDouble();
+            minVo.setMins(StringUtils.round(temp3, 2));
+            minVo.setName(wt2.getName());
+            minVo.setId(wt2.getId());
+            minVo.setTime(mins.get(0).getPointTime());
+
+            AveVo aveVo = new AveVo();
+            temp4 = ave.get(0).getPointValueInDouble();
+            aveVo.setAves(StringUtils.round(temp4, 2));
+            aveVo.setName(wt2.getName());
+            aveVo.setId(wt2.getId());
+            aveVo.setTime(ave.get(0).getPointTime());
+
+            maxvalue.add(maxVo);
+            minvalue.add(minVo);
+            avevalue.add(aveVo);
+
         }
 
-        List<Double> pjgzdList = vo.stream()
-                .map(Glqx::getPjgzd)  // 获取pjgzd字段的值
-                .collect(Collectors.toList());
+//        List<Double> pjgzdList = vo.stream()
+//                .map(Glqx::getPjgzd)  // 获取pjgzd字段的值
+//                .collect(Collectors.toList());
 
 // 使用stream流筛选最大值、最小值、平均值,并放入新的列表中
-        List<Double> result = new ArrayList<>();
-        result.add(pjgzdList.stream().max(Double::compareTo).orElse(null));
-        result.add(pjgzdList.stream().min(Double::compareTo).orElse(null));
-        result.add(pjgzdList.stream().mapToDouble(Double::doubleValue).average().orElse(0));
+//        List<Double> result = new ArrayList<>();
+//        result.add(pjgzdList.stream().max(Double::compareTo).orElse(null));
+//        result.add(pjgzdList.stream().min(Double::compareTo).orElse(null));
+//        result.add(pjgzdList.stream().mapToDouble(Double::doubleValue).average().orElse(0));
 
-        Map<String, Object> map = new HashMap<>();
+
+        Map<String, Object> map = new LinkedHashMap<>();
 //        map.put("result", result);
+        map.put("maxs", maxvalue);
+        map.put("mins", minvalue);
+        map.put("aves", avevalue);
         map.put("list", vo);
 
+
         return map;
     }
 

+ 3 - 3
web/runeconomy-jjyx/src/main/java/com/gyee/runeconomy/util/realtimesource/EdosUtil.java

@@ -1224,11 +1224,11 @@ public class EdosUtil implements IEdosUtil {
 
             try {
                 String url = "";
-                if (point.getTypeId().equals("G")){
+//                if (point.getTypeId().equals("G")){
                     url = baseURL2 + "/history/stat?null=0";
-                }else {
+//                }else {
                     url = baseURL + "/history/stat?null=0";
-                }
+//                }
                 //tagName 或thingType,thingId,uniformCode可以确定一个标签点
                 if (tagName.isPresent())
                     url = url + "&tagName=" + tagName.get();