Browse Source

预测功率页面提交

wangb@gyee-china.com 1 year ago
parent
commit
4237d4de97

+ 2 - 1
common/src/main/java/com/gyee/common/contant/ContantXk.java

@@ -358,7 +358,8 @@ public class ContantXk {
     public static final String MX011 = "MX011";//环境受累
     public static final String MX012 = "MX012";//通讯中断
     public static final String MX013 = "MX013";//设备离线
-
+    public static final String FSYC="FSYC";
+    public static final String GZYC="GZYC";
 
 
 

+ 81 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/controller/Forecast/ForecastController.java

@@ -0,0 +1,81 @@
+package com.gyee.runeconomy.controller.Forecast;
+
+import com.gyee.runeconomy.dto.AjaxResult;
+import com.gyee.runeconomy.dto.ForecastVo;
+import com.gyee.runeconomy.service.Forecast.ForecastService;
+import com.gyee.runeconomy.util.StringUtils;
+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.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+@Controller
+@RequestMapping("/Forecast")
+@Api(value = "短期预测", tags = "短期预测")
+public class ForecastController {
+
+    @Autowired
+    private ForecastService forecastService;
+
+
+    @GetMapping("/short")
+    @ResponseBody
+    @ApiOperation(value = "首页", notes = "首页")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "wpId", value = "场站编号", required = true, dataType = "string", paramType = "query"),
+            @ApiImplicitParam(name = "beginDate", value = "开始时间", required = true, dataType = "string", paramType = "query"),
+            @ApiImplicitParam(name = "endDate", value = "结束时间", required = true, dataType = "string", paramType = "query")
+    })
+
+    public AjaxResult forecast(String wpId, String beginDate,String endDate) throws Exception {
+
+
+        List<ForecastVo> resultList = new ArrayList<>();
+        if (StringUtils.notEmp(wpId)) {
+            resultList = forecastService.getcockpit(wpId,beginDate,endDate);
+        }
+
+        if (null != resultList) {
+            return AjaxResult.successData(200, resultList);
+        } else {
+            return AjaxResult.error(500, "操作失败");
+        }
+
+    }
+
+    @GetMapping("/shorttype")
+    @ResponseBody
+    @ApiOperation(value = "首页", notes = "首页")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "beginDate", value = "开始时间", required = true, dataType = "string", paramType = "query"),
+            @ApiImplicitParam(name = "endDate", value = "结束时间", required = true, dataType = "string", paramType = "query"),
+            @ApiImplicitParam(name = "type", value = "结束时间", required = true, dataType = "string", paramType = "query")
+    })
+
+    public AjaxResult forecasttype(String beginDate,String endDate,String type) throws Exception {
+
+
+        Map<String, Object> resultList = new LinkedHashMap<>();
+
+            resultList = forecastService.getcockpittype(beginDate,endDate,type);
+
+        if (null != resultList) {
+            return AjaxResult.successData(200, resultList);
+        } else {
+            return AjaxResult.error(500, "操作失败");
+        }
+
+    }
+
+
+}

+ 83 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/dto/ForecastVo.java

@@ -0,0 +1,83 @@
+package com.gyee.runeconomy.dto;
+
+public class ForecastVo {
+
+    private Long hours;
+
+    private String name;
+    private String id;
+
+    private Double pjfs;
+
+    private Double ycfs;
+
+    private Double sjgl;
+
+    private Double ycgl;
+
+    private Double llgl;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public Long getHours() {
+        return hours;
+    }
+
+    public void setHours(Long hours) {
+        this.hours = hours;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Double getPjfs() {
+        return pjfs;
+    }
+
+    public void setPjfs(Double pjfs) {
+        this.pjfs = pjfs;
+    }
+
+    public Double getYcfs() {
+        return ycfs;
+    }
+
+    public void setYcfs(Double ycfs) {
+        this.ycfs = ycfs;
+    }
+
+    public Double getSjgl() {
+        return sjgl;
+    }
+
+    public void setSjgl(Double sjgl) {
+        this.sjgl = sjgl;
+    }
+
+    public Double getYcgl() {
+        return ycgl;
+    }
+
+    public void setYcgl(Double ycgl) {
+        this.ycgl = ycgl;
+    }
+
+    public Double getLlgl() {
+        return llgl;
+    }
+
+    public void setLlgl(Double llgl) {
+        this.llgl = llgl;
+    }
+}

+ 208 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/Forecast/ForecastService.java

@@ -0,0 +1,208 @@
+package com.gyee.runeconomy.service.Forecast;
+
+import com.gyee.common.contant.ContantXk;
+import com.gyee.common.model.PointData;
+import com.gyee.common.util.DateUtils;
+import com.gyee.runeconomy.dto.ForecastVo;
+import com.gyee.runeconomy.init.CacheContext;
+import com.gyee.runeconomy.model.auto.ProBasicPowerstation;
+import com.gyee.runeconomy.model.auto.ProBasicPowerstationPoint;
+import com.gyee.runeconomy.service.auto.IProBasicPowerstationPointService;
+import com.gyee.runeconomy.util.StringUtils;
+import com.gyee.runeconomy.util.realtimesource.IEdosUtil;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.*;
+
+@Service
+public class ForecastService {
+
+    @Resource
+    private IEdosUtil edosUtil;
+    @Resource
+    private IProBasicPowerstationPointService proBasicPowerstationPointService;
+
+    public List<ForecastVo> getcockpit(String wpId, String beginDate, String endDate) throws Exception {
+
+        Date starttime = DateUtils.parseDate(beginDate);
+        Date endtime = DateUtils.parseDate(endDate);
+
+        List<ProBasicPowerstation> wpls = CacheContext.wpls;
+
+        List<ForecastVo> vos = new ArrayList<ForecastVo>();
+
+
+//            ForecastVo vo = new ForecastVo();
+//            vo.setPjfs(0.0); //平均风速
+//            vo.setSjgl(0.0); //实际功率
+//            vo.setDqglyc(0.0); //短期功率预测
+//            vo.setCdqglyc(0.0); //超短期功率预测
+//            vo.setRnycgl(0.0); //日内预测功率
+//            vo.setHours(i);  //时间戳
+//            vo.setName(wpId);
+//            vos.add(vo);
+
+        ProBasicPowerstationPoint pjfs = null;
+        ProBasicPowerstationPoint fsyc = null;
+        ProBasicPowerstationPoint ycgl = null;
+        ProBasicPowerstationPoint sjgl = null;
+        ProBasicPowerstationPoint llgl = null;
+
+        for (ProBasicPowerstation wp : wpls) {
+            if (wpId.equals(wp.getId())) {
+
+
+                if (wpId.endsWith("FDC_STA")) {
+                    pjfs = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.PJFS15);
+                    fsyc = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.FSYC);
+                    ycgl = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.ZYCGL);
+                    sjgl = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.PJGL15);
+                    llgl = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.SSZLLGL);
+                }
+                if (wpId.endsWith("GDC_STA")) {
+                    pjfs = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.PJGZD15);
+                    fsyc = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.GZYC);
+                    ycgl = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.ZYCGL);
+                    sjgl = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.PJGL15);
+                    llgl = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.SSZLLGL);
+                }
+                List<PointData> pjfsls = edosUtil.getHistoryDatasSnap(pjfs, starttime.getTime() / 1000, endtime.getTime() / 1000, null, 900L);
+                List<PointData> fsycls = edosUtil.getHistoryDatasSnap(fsyc, starttime.getTime() / 1000, endtime.getTime() / 1000, null, 900L);
+                List<PointData> ycglls = edosUtil.getHistoryDatasSnap(ycgl, starttime.getTime() / 1000, endtime.getTime() / 1000, null, 900L);
+                List<PointData> sjglls = edosUtil.getHistoryDatasSnap(sjgl, starttime.getTime() / 1000, endtime.getTime() / 1000, null, 900L);
+                List<PointData> llglls = edosUtil.getHistoryDatasSnap(llgl, starttime.getTime() / 1000, endtime.getTime() / 1000, null, 900L);
+                double temp1 = 0;
+                double temp2 = 0;
+                double temp3 = 0;
+                double temp4 = 0;
+                double temp5 = 0;
+                for (int i = 0; i < pjfsls.size(); i++) {
+
+                    ForecastVo vo = new ForecastVo();
+                    vo.setPjfs(0.0); //平均风速
+                    vo.setYcfs(0.0); //平均风速
+                    vo.setSjgl(0.0); //实际功率
+                    vo.setYcgl(0.0); //功率预测
+                    vo.setLlgl(0.0); //超短期功率预测
+                    vo.setHours(2023L);  //时间戳
+                    vo.setName(wpId);
+
+                    temp1 = pjfsls.get(i).getPointValueInDouble();
+                    vo.setPjfs(StringUtils.round(temp1, 2));
+
+                    temp2 = fsycls.get(i).getPointValueInDouble();
+                    vo.setYcfs(StringUtils.round(temp2, 2));
+
+                    temp3 = ycglls.get(i).getPointValueInDouble();
+                    vo.setYcgl(StringUtils.round(temp3, 2));
+
+                    temp4 = sjglls.get(i).getPointValueInDouble();
+                    vo.setSjgl(StringUtils.round(temp4, 2));
+
+                    temp5 = llglls.get(i).getPointValueInDouble();
+                    vo.setLlgl(StringUtils.round(temp5, 2));
+
+                    vo.setHours(pjfsls.get(i).getPointTime());
+
+                    vo.setName(wp.getAname());
+                    vo.setId(wpId);
+
+                    vos.add(vo);
+                }
+            }
+        }
+        return vos;
+
+    }
+
+
+    public Map<String, Object> getcockpittype(String beginDate, String endDate, String type) throws Exception {
+
+        Date starttime = DateUtils.parseDate(beginDate);
+        Date endtime = DateUtils.parseDate(endDate);
+        Map<String, Object> map = new LinkedHashMap<>();
+
+        Map<String, Object> map1 = new LinkedHashMap<>();
+
+
+        ProBasicPowerstationPoint pjfs = null;
+        ProBasicPowerstationPoint fsyc = null;
+        ProBasicPowerstationPoint ycgl = null;
+        ProBasicPowerstationPoint sjgl = null;
+        ProBasicPowerstationPoint llgl = null;
+
+
+        List<ProBasicPowerstation> wpls = CacheContext.wpls;
+
+        String wpId = null;
+
+        for (ProBasicPowerstation wp : wpls) {
+            if (wp.getId().contains("MLJ")) continue;
+            wpId = wp.getId();
+            List<ForecastVo> vos = new ArrayList<ForecastVo>();
+
+            if (wpId.endsWith("FDC_STA") && type.equals("F")) {
+                pjfs = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.PJFS15);
+//            fsyc = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.FSYC);
+                ycgl = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.ZYCGL);
+                sjgl = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.PJGL15);
+                llgl = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.SSZLLGL);
+            }
+            if (wpId.endsWith("GDC_STA") && type.equals("G")) {
+                pjfs = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.PJGZD15);
+                fsyc = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.GZYC);
+                ycgl = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.ZYCGL);
+                sjgl = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.PJGL15);
+                llgl = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.SSZLLGL);
+            }
+            List<PointData> pjfsls = edosUtil.getHistoryDatasSnap(pjfs, starttime.getTime() / 1000, endtime.getTime() / 1000, null, 900L);
+//        List<PointData> fsycls = edosUtil.getHistoryDatasSnap(fsyc, starttime.getTime() / 1000, endtime.getTime() / 1000, null, 900L);
+            List<PointData> ycglls = edosUtil.getHistoryDatasSnap(ycgl, starttime.getTime() / 1000, endtime.getTime() / 1000, null, 900L);
+            List<PointData> sjglls = edosUtil.getHistoryDatasSnap(sjgl, starttime.getTime() / 1000, endtime.getTime() / 1000, null, 900L);
+            List<PointData> llglls = edosUtil.getHistoryDatasSnap(llgl, starttime.getTime() / 1000, endtime.getTime() / 1000, null, 900L);
+            double temp1 = 0;
+            double temp2 = 0;
+            double temp3 = 0;
+            double temp4 = 0;
+            double temp5 = 0;
+            for (int i = 0; i < pjfsls.size(); i++) {
+
+                ForecastVo vo = new ForecastVo();
+                vo.setPjfs(0.0); //平均风速
+                vo.setYcfs(0.0); //平均风速
+                vo.setSjgl(0.0); //实际功率
+                vo.setYcgl(0.0); //功率预测
+                vo.setLlgl(0.0); //超短期功率预测
+                vo.setHours(2023L);  //时间戳
+                vo.setName("wpId");
+                vo.setId(wpId);
+
+                temp1 = pjfsls.get(i).getPointValueInDouble();
+                vo.setPjfs(StringUtils.round(temp1, 2));
+
+//            temp2 = fsycls.get(i).getPointValueInDouble();
+//            vo.setYcfs(StringUtils.round(temp2, 2));
+
+                temp3 = ycglls.get(i).getPointValueInDouble();
+                vo.setYcgl(StringUtils.round(temp3, 2));
+
+                temp4 = sjglls.get(i).getPointValueInDouble();
+                vo.setSjgl(StringUtils.round(temp4, 2));
+
+                temp5 = llglls.get(i).getPointValueInDouble();
+                vo.setLlgl(StringUtils.round(temp5, 2));
+
+                vo.setHours(pjfsls.get(i).getPointTime());
+
+                vo.setName(wp.getAname());
+
+                vo.setId(wp.getNemCode());
+                vos.add(vo);
+            }
+            map.put(wp.getId(), vos);
+        }
+        return map;
+    }
+
+}

+ 49 - 49
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/util/realtimesource/EdosUtil.java

@@ -234,58 +234,58 @@ public class EdosUtil implements IEdosUtil {
 
                     if (snapList.isEmpty()) {
 
-                        getHistsnapSameTiem(point.getNemCode(), beginDate, pried, resultList);
-                    } else {
-                        for (PointData snapItem : snapList) {
-
-                            long subTime = snapItem.getPointTime() - pried;
-                            //查询时间区间的截面值(截面值为传入时间节点的上一个最近值,返回时间为值的真实时间),
-                            // 再进行比较,若截面值的时间戳在以快照时间节点前推一个单位的时间区间中,
-                            // 则代表该时间节点快照有效,否则为0
-                            String rawUrl = baseURL + "/history/section?null=0&tagNames=" + point.getNemCode() + "&ts=" + snapItem.getPointTime();
-                            if (point.getNemCode().startsWith("GF-")) {
-                                rawUrl = baseURL2 + "/history/section?null=0&tagNames=" + point.getNemCode() + "&ts=" + snapItem.getPointTime();
-                            }
-                            ResponseEntity<JSONObject> sectionResp = restTemplate.getForEntity(rawUrl, JSONObject.class);
-                            JSONObject jsonObjectSection = sectionResp.getBody();
-
-                            if (jsonObjectSection != null) {
-                                List<PointData> sectionlist = JsonObjectHelper.phrasePointData(jsonObjectSection);
-                                if (sectionlist.size() > 0) {
-                                    if (sectionlist.get(0).getPointTime() <= snapItem.getPointTime()) {
-                                        resultList.add(snapItem);
-                                    } else {
-                                        PointData data = new PointData();
-                                        data.setEdnaId(point.getNemCode());
-                                        data.setPointTime(snapItem.getPointTime());
-                                        data.setPointValue("0");
-                                        data.setPointName("1");
-                                        data.setPointValueInDouble(0.0);
-                                        resultList.add(data);
-                                    }
-                                } else {
-                                    PointData data = new PointData();
-                                    data.setEdnaId(point.getNemCode());
-                                    data.setPointTime(0l);
-                                    data.setPointValue("0");
-                                    data.setPointName("1");
-                                    data.setPointValueInDouble(0.0);
-                                    resultList.add(data);
-                                }
-                            } else {
-                                PointData data = new PointData();
-                                data.setEdnaId(point.getNemCode());
-                                data.setPointTime(0l);
-                                data.setPointValue("0");
-                                data.setPointName("1");
-                                data.setPointValueInDouble(0.0);
-                                resultList.add(data);
-                            }
-                        }
+                        getHistsnapSameTiem(point.getNemCode(), beginDate, pried, snapList);
+//                    } else {
+//                        for (PointData snapItem : snapList) {
+//
+//                            long subTime = snapItem.getPointTime() - pried;
+//                            //查询时间区间的截面值(截面值为传入时间节点的上一个最近值,返回时间为值的真实时间),
+//                            // 再进行比较,若截面值的时间戳在以快照时间节点前推一个单位的时间区间中,
+//                            // 则代表该时间节点快照有效,否则为0
+//                            String rawUrl = baseURL + "/history/section?null=0&tagNames=" + point.getNemCode() + "&ts=" + snapItem.getPointTime();
+//                            if (point.getNemCode().startsWith("GF-")) {
+//                                rawUrl = baseURL2 + "/history/section?null=0&tagNames=" + point.getNemCode() + "&ts=" + snapItem.getPointTime();
+//                            }
+//                            ResponseEntity<JSONObject> sectionResp = restTemplate.getForEntity(rawUrl, JSONObject.class);
+//                            JSONObject jsonObjectSection = sectionResp.getBody();
+//
+//                            if (jsonObjectSection != null) {
+//                                List<PointData> sectionlist = JsonObjectHelper.phrasePointData(jsonObjectSection);
+//                                if (sectionlist.size() > 0) {
+//                                    if (sectionlist.get(0).getPointTime() <= snapItem.getPointTime()) {
+//                                        resultList.add(snapItem);
+//                                    } else {
+//                                        PointData data = new PointData();
+//                                        data.setEdnaId(point.getNemCode());
+//                                        data.setPointTime(snapItem.getPointTime());
+//                                        data.setPointValue("0");
+//                                        data.setPointName("1");
+//                                        data.setPointValueInDouble(0.0);
+//                                        resultList.add(data);
+//                                    }
+//                                } else {
+//                                    PointData data = new PointData();
+//                                    data.setEdnaId(point.getNemCode());
+//                                    data.setPointTime(0l);
+//                                    data.setPointValue("0");
+//                                    data.setPointName("1");
+//                                    data.setPointValueInDouble(0.0);
+//                                    resultList.add(data);
+//                                }
+//                            } else {
+//                                PointData data = new PointData();
+//                                data.setEdnaId(point.getNemCode());
+//                                data.setPointTime(0l);
+//                                data.setPointValue("0");
+//                                data.setPointName("1");
+//                                data.setPointValueInDouble(0.0);
+//                                resultList.add(data);
+//                            }
+//                        }
                     }
 
 
-                    return resultList;
+                    return snapList;
 
 
                 } else {