浏览代码

修改单机月度分析

shilin 1 年之前
父节点
当前提交
39ced058e7

+ 17 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/model/vo/ExcelVo.java

@@ -0,0 +1,17 @@
+package com.gyee.generation.model.vo;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class ExcelVo {
+
+    private String id;
+    private Double value;
+    private Date date;
+}

+ 22 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/model/vo/PowerVo.java

@@ -0,0 +1,22 @@
+package com.gyee.generation.model.vo;
+
+import lombok.Data;
+
+@Data
+public class PowerVo {
+
+    Double llfdl;
+    Double rfdl;
+    Double rgzssdl;
+    Double rcnslgzssdl;
+    Double rjxssdl;
+    Double rcnsljxssdl;
+    Double rdjssdl;
+    Double rqxjclssdl;
+    Double rsdtjssdl;
+    Double rxnssdl;
+    Double rxdtjssdl;
+    Double rxdjclssdl;
+    Double rcwsldwssdl;
+    Double rcwsltqssdl;
+}

+ 357 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/util/math/LightToTheoreticalPower.java

@@ -0,0 +1,357 @@
+package com.gyee.generation.util.math;
+
+import com.gyee.common.model.PointData;
+import com.gyee.common.model.StringUtils;
+import com.gyee.generation.model.vo.PowerVo;
+import com.gyee.generation.util.DateUtils;
+import com.gyee.generation.util.realtimesource.IEdosUtil;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.*;
+
+@Service
+public class LightToTheoreticalPower {
+    @Resource
+    private IEdosUtil edosUtil;
+
+    // 计算光伏理论发电量
+    public double calculateEnergy(List<PointData> lightData, double power) {
+        double energy = 0.0;
+        double theoreticalPower = 0.0;
+        try {
+
+            if (!lightData.isEmpty()) {
+                List<PointData> filterls = new ArrayList<>();
+                for (PointData po : lightData) {
+                    if (po.getPointValueInDouble() > 10) {
+                        filterls.add(po);
+                    }
+                }
+
+
+                if (!filterls.isEmpty()) {
+                    Date beginTime = new Date(filterls.get(0).getPointTime());
+                    Date endTime = new Date(filterls.get(filterls.size() - 1).getPointTime());
+                    double hours = DateUtils.hoursDiff(beginTime, endTime);
+
+                    DoubleSummaryStatistics summaryStatistics = filterls.stream().mapToDouble(PointData::getPointValueInDouble).summaryStatistics();
+
+
+                    double avg = StringUtils.round(summaryStatistics.getAverage(), 2);
+
+                    double lightresult = new BigDecimal(avg * hours).divide(new BigDecimal(1000), 2, RoundingMode.HALF_EVEN).doubleValue();
+
+                    theoreticalPower = lightresult * power;
+                }
+
+
+            }
+
+        } catch (Exception e) {
+            System.out.println("");
+        }
+
+        return theoreticalPower;
+    }
+
+
+    // 计算光伏理论发电量
+    public PowerVo calculateEnergy(List<PointData> powerData, List<PointData> lightData, List<PointData> status, String pointid, double power) throws Exception{
+
+        double lastState = -1;//上一分钟状态
+        Date stateBegin;
+        Date stateEnd;
+        Map<Long, PointData> pmap = new HashMap<>();
+
+        double llfdl = 0.0;
+        double rfdl = 0.0;
+        double rgzssdl = 0.0;
+        double rcnslgzssdl = 0.0;
+        double rjxssdl = 0.0;
+        double rcnsljxssdl = 0.0;
+        double rdjssdl = 0.0;
+        double rqxjclssdl = 0.0;
+        double rsdtjssdl = 0.0;
+        double rxnssdl = 0.0;
+        double rxdtjssdl = 0.0;
+        double rxdjclssdl = 0.0;
+        double rcwsldwssdl = 0.0;
+        double rcwsltqssdl = 0.0;
+
+
+        PowerVo vo = new PowerVo();
+        vo.setLlfdl(llfdl);
+        vo.setRfdl(rfdl);
+        vo.setRgzssdl(rgzssdl);
+        vo.setRcnslgzssdl(rcnslgzssdl);
+        vo.setRjxssdl(rjxssdl);
+        vo.setRcnsljxssdl(rcnsljxssdl);
+        vo.setRdjssdl(rdjssdl);
+        vo.setRqxjclssdl(rqxjclssdl);
+        vo.setRsdtjssdl(rsdtjssdl);
+        vo.setRxnssdl(rxnssdl);
+        vo.setRxdtjssdl(rxdtjssdl);
+        vo.setRxdjclssdl(rxdjclssdl);
+        vo.setRcwsldwssdl(rcwsldwssdl);
+        vo.setRcwsltqssdl(rcwsltqssdl);
+
+
+//        try {
+
+        if (!status.isEmpty() && !powerData.isEmpty() && status.size() == powerData.size()) {
+            llfdl = calculateEnergy(lightData, power);
+            rfdl = powerData.get(powerData.size() - 1).getPointValueInDouble();
+            stateBegin = new Date(status.get(0).getPointTime());
+            for (PointData po : powerData) {
+                pmap.put(po.getPointTime(), po);
+            }
+            for (PointData po : status) {
+
+
+                if (po.getPointValueInDouble() == 0) {
+
+                    if (lastState != po.getPointValueInDouble()) {
+                        //将当前状态保存到上一分钟状态
+                        lastState = po.getPointValueInDouble();
+                        stateEnd = new Date(po.getPointTime());
+
+                        rdjssdl = getSsdl(pointid, stateBegin, stateEnd, pmap, rdjssdl);
+
+                        Date temp = new Date(po.getPointTime());
+                        Calendar c = Calendar.getInstance();
+                        c.setTime(temp);
+                        c.add(Calendar.MINUTE, 1);
+                        stateBegin = c.getTime();
+                    }
+                } else if (po.getPointValueInDouble() == 1) {
+                    if (lastState != po.getPointValueInDouble()) {
+                        //将当前状态保存到上一分钟状态
+                        lastState = po.getPointValueInDouble();
+                        stateEnd = new Date(po.getPointTime());
+
+                        rsdtjssdl = getSsdl(pointid, stateBegin, stateEnd, pmap, rsdtjssdl);
+
+                        Date temp = new Date(po.getPointTime());
+                        Calendar c = Calendar.getInstance();
+                        c.setTime(temp);
+                        c.add(Calendar.MINUTE, 1);
+                        stateBegin = c.getTime();
+                    }
+
+                } else if (po.getPointValueInDouble() == 3) {
+                    if (lastState != po.getPointValueInDouble()) {
+                        lastState = po.getPointValueInDouble();
+                        stateEnd = new Date(po.getPointTime());
+
+                        rqxjclssdl = getSsdl(pointid, stateBegin, stateEnd, pmap, rqxjclssdl);
+
+                        Date temp = new Date(po.getPointTime());
+                        Calendar c = Calendar.getInstance();
+                        c.setTime(temp);
+                        c.add(Calendar.MINUTE, 1);
+                        stateBegin = c.getTime();
+                    }
+
+                } else if (po.getPointValueInDouble() == 4) {
+                    if (lastState != po.getPointValueInDouble()) {
+                        //将当前状态保存到上一分钟状态
+                        lastState = po.getPointValueInDouble();
+                        stateEnd = new Date(po.getPointTime());
+
+                        double lldl = getLldl(pointid, stateBegin, stateEnd);
+                        rgzssdl = rgzssdl + lldl;
+
+                        Date temp = new Date(po.getPointTime());
+                        Calendar c = Calendar.getInstance();
+                        c.setTime(temp);
+                        c.add(Calendar.MINUTE, 1);
+                        stateBegin = c.getTime();
+                    }
+
+                } else if (po.getPointValueInDouble() == 5) {
+                    lastState = po.getPointValueInDouble();
+                    stateEnd = new Date(po.getPointTime());
+
+                    rcnslgzssdl = getSsdl(pointid, stateBegin, stateEnd, pmap, rcnslgzssdl);
+
+                    Date temp = new Date(po.getPointTime());
+                    Calendar c = Calendar.getInstance();
+                    c.setTime(temp);
+                    c.add(Calendar.MINUTE, 1);
+                    stateBegin = c.getTime();
+
+                } else if (po.getPointValueInDouble() == 6) {
+                    if (lastState != po.getPointValueInDouble()) {
+                        //将当前状态保存到上一分钟状态
+                        lastState = po.getPointValueInDouble();
+                        stateEnd = new Date(po.getPointTime());
+
+                        double lldl = getLldl(pointid, stateBegin, stateEnd);
+                        rjxssdl = rjxssdl + lldl;
+
+                        Date temp = new Date(po.getPointTime());
+                        Calendar c = Calendar.getInstance();
+                        c.setTime(temp);
+                        c.add(Calendar.MINUTE, 1);
+                        stateBegin = c.getTime();
+                    }
+
+                } else if (po.getPointValueInDouble() == 7) {
+                    lastState = po.getPointValueInDouble();
+                    stateEnd = new Date(po.getPointTime());
+
+                    rcnsljxssdl = getSsdl(pointid, stateBegin, stateEnd, pmap, rcnsljxssdl);
+
+                    Date temp = new Date(po.getPointTime());
+                    Calendar c = Calendar.getInstance();
+                    c.setTime(temp);
+                    c.add(Calendar.MINUTE, 1);
+                    stateBegin = c.getTime();
+
+                } else if (po.getPointValueInDouble() == 8) {
+                    if (lastState != po.getPointValueInDouble()) {
+                        lastState = po.getPointValueInDouble();
+                        stateEnd = new Date(po.getPointTime());
+
+                        rxdjclssdl = getSsdl(pointid, stateBegin, stateEnd, pmap, rxdjclssdl);
+
+                        Date temp = new Date(po.getPointTime());
+                        Calendar c = Calendar.getInstance();
+                        c.setTime(temp);
+                        c.add(Calendar.MINUTE, 1);
+                        stateBegin = c.getTime();
+                    }
+
+                } else if (po.getPointValueInDouble() == 9) {
+                    if (lastState != po.getPointValueInDouble()) {
+
+                        //将当前状态保存到上一分钟状态
+                        lastState = po.getPointValueInDouble();
+                        stateEnd = new Date(po.getPointTime());
+
+                        double lldl = getLldl(pointid, stateBegin, stateEnd);
+                        rxdtjssdl = rxdtjssdl + lldl;
+
+                        Date temp = new Date(po.getPointTime());
+                        Calendar c = Calendar.getInstance();
+                        c.setTime(temp);
+                        c.add(Calendar.MINUTE, 1);
+                        stateBegin = c.getTime();
+                    }
+
+                } else if (po.getPointValueInDouble() == 10) {
+                    if (lastState != po.getPointValueInDouble()) {
+
+                        //将当前状态保存到上一分钟状态
+                        lastState = po.getPointValueInDouble();
+                        stateEnd = new Date(po.getPointTime());
+
+                        double lldl = getLldl(pointid, stateBegin, stateEnd);
+                        rcwsldwssdl = rcwsldwssdl + lldl;
+
+                        Date temp = new Date(po.getPointTime());
+                        Calendar c = Calendar.getInstance();
+                        c.setTime(temp);
+                        c.add(Calendar.MINUTE, 1);
+                        stateBegin = c.getTime();
+                    }
+
+                } else if (po.getPointValueInDouble() == 11) {
+                    if (lastState != po.getPointValueInDouble()) {
+                        //将当前状态保存到上一分钟状态
+                        lastState = po.getPointValueInDouble();
+                        stateEnd = new Date(po.getPointTime());
+
+                        double lldl = getLldl(pointid, stateBegin, stateEnd);
+                        rcwsltqssdl = rcwsltqssdl + lldl;
+
+                        Date temp = new Date(po.getPointTime());
+                        Calendar c = Calendar.getInstance();
+                        c.setTime(temp);
+                        c.add(Calendar.MINUTE, 1);
+                        stateBegin = c.getTime();
+                    }
+
+                }
+
+            }
+
+        }
+
+        vo.setLlfdl(llfdl);
+        vo.setRfdl(rfdl);
+        vo.setRgzssdl(rgzssdl);
+        vo.setRcnslgzssdl(rcnslgzssdl);
+        vo.setRjxssdl(rjxssdl);
+        vo.setRcnsljxssdl(rcnsljxssdl);
+        vo.setRdjssdl(rdjssdl);
+        vo.setRqxjclssdl(rqxjclssdl);
+        vo.setRsdtjssdl(rsdtjssdl);
+        vo.setRxnssdl(rxnssdl);
+        vo.setRxdtjssdl(rxdtjssdl);
+        vo.setRxdjclssdl(rxdjclssdl);
+        vo.setRcwsldwssdl(rcwsldwssdl);
+        vo.setRcwsltqssdl(rcwsltqssdl);
+
+//        }catch (Exception e)
+//        {
+//            System.out.println("");
+//        }
+
+        return vo;
+    }
+
+    private double getSsdl(String pointid, Date stateBegin, Date stateEnd, Map<Long, PointData> pmap, double ssdl) throws Exception {
+        double begin = 0.0;
+        double end = 0.0;
+        if (pmap.containsKey(stateBegin.getTime())) {
+            begin = pmap.get(stateBegin.getTime()).getPointValueInDouble();
+        }
+        if (pmap.containsKey(stateEnd.getTime())) {
+            end = pmap.get(stateEnd.getTime()).getPointValueInDouble();
+        }
+
+        double lldl = getLldl(pointid, stateBegin, stateEnd);
+
+        ssdl = ssdl + lldl - (end - begin);
+
+        if (ssdl < 0) {
+            ssdl = 0;
+        }
+        return ssdl;
+    }
+
+    private double getLldl(String pointid, Date stateBegin, Date stateEnd) throws Exception {
+
+        double result = 0.0;
+        List<PointData> pointls = edosUtil.getHistoryDatasSnap(pointid, stateBegin.getTime() / 1000, stateEnd.getTime() / 1000);
+        if (!pointls.isEmpty()) {
+            List<PointData> filterls = new ArrayList<>();
+            for (PointData p : pointls) {
+                if (p.getPointValueInDouble() > 10) {
+                    filterls.add(p);
+                }
+            }
+
+
+            if (!filterls.isEmpty()) {
+                Date beginTime = new Date(filterls.get(0).getPointTime());
+                Date endTime = new Date(filterls.get(filterls.size() - 1).getPointTime());
+                double hours = DateUtils.hoursDiff(beginTime, endTime);
+
+                DoubleSummaryStatistics summaryStatistics = filterls.stream().mapToDouble(PointData::getPointValueInDouble).summaryStatistics();
+                double avg = StringUtils.round(summaryStatistics.getAverage(), 2);
+
+                result = new BigDecimal(avg * hours).divide(new BigDecimal(1000), 2, RoundingMode.HALF_EVEN).doubleValue();
+
+
+            }
+
+
+        }
+        return result;
+    }
+}

+ 9 - 7
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/controller/SingleAnalysisController.java

@@ -1,7 +1,9 @@
 package com.gyee.runeconomy.controller;
 
 
+import com.gyee.runeconomy.dto.AjaxResult;
 import com.gyee.runeconomy.dto.R;
+import com.gyee.runeconomy.dto.ResultCode;
 import com.gyee.runeconomy.dto.ResultMsg;
 import com.gyee.runeconomy.init.CacheContext;
 import com.gyee.runeconomy.model.auto.ProBasicEquipment;
@@ -174,7 +176,7 @@ public class SingleAnalysisController {
             @ApiImplicitParam(name = "year", value = "年份", required = true, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "month", value = "月份", required = true, dataType = "string", paramType = "query")})
 
-    public R singleanalysisChart(String wtId, String year, String month) throws Exception {
+    public AjaxResult singleanalysisChart(String wtId, String year, String month) throws Exception {
 
         Map<String, List<SingleAnalysisVo>> map = new HashMap<>();
 
@@ -201,12 +203,12 @@ public class SingleAnalysisController {
 //        map.put("ws",wsls);//五项损失,绑定五个
 //        map.put("jd",jfpldjsjls);//静风频率和待机时间
 
-//        if (null!=map) {
-//            return AjaxResult.successData(ResultCode.SUCCESS, map);
-//        } else {
-//            return AjaxResult.successData(ResultCode.SUCCESS, map);
-//        }
-        return R.data(ResultMsg.ok(map));
+        if (null!=map) {
+            return AjaxResult.successData(ResultCode.SUCCESS, map);
+        } else {
+            return AjaxResult.successData(ResultCode.SUCCESS, map);
+        }
+
     }
 
 

+ 2 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/model/vo/SingleAnalysisVo.java

@@ -1,5 +1,6 @@
 package com.gyee.runeconomy.model.vo;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
 import java.util.Date;
@@ -74,6 +75,7 @@ public class SingleAnalysisVo implements java.io.Serializable {
     //静风频率
     private Double jfpl;
     //日期
+    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
     private Date recorddate;
 
     private String companyId;