Browse Source

风速功率曲线图数据获取

lizaixun 4 years ago
parent
commit
c225916503

+ 44 - 0
src/main/java/com/gyee/frame/common/quartz/task/Windpowerstationdetail_twentyfourhourlinechart_target.java

@@ -0,0 +1,44 @@
+package com.gyee.frame.common.quartz.task;
+
+import com.gyee.frame.service.app.targetdetail.TargetdetailService;
+import com.gyee.frame.service.app.windpowerstationdetail.Windspeedpowercurvedetail;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+
+/**
+ *测试类
+ * @CLASSNAME   WeatherfdPushTask
+ * @Description 向页面预测今天24小时气象推送数据
+ * @Auther Li ZaiXun
+ * @DATE 2020/1/2 15:33
+ */
+@Component("windpowerstationdetail_twentyfourhourlinechart_target")
+public class Windpowerstationdetail_twentyfourhourlinechart_target {
+    @Autowired
+    private Windspeedpowercurvedetail windspeedpowercurvedetail;
+    /**
+     * 无参的任务
+     */
+    public void windpowerstationdetail_twentyfourhourlinechart_target() throws Exception {
+        windspeedpowercurvedetail.windpowerstationdetail_twentyfourhourlinechart_target();//调用list方法完成对 key :"weatherProphet_1" ,路径"weather/weatherProphet_1"的推送
+        //System.out.println("我已执行");
+    }
+
+
+    /**
+     * 有参任务
+     * 目前仅执行常见的数据类型  Integer Long  带L  string  带 ''  bool Double 带 d
+     * @param a
+     * @param b
+     *
+     */
+    public void runTask2(Integer a,Long b,String c,Boolean d,Double e)
+    {
+        //List<TsysUser> list=  tsysUserMapper.selectByExample(new TsysUserExample());
+        //System.err.println("用户查询num:"+list.size());
+        System.out.println("正在执行定时任务,带多个参数的方法"+a+"   "+b+" "+c+"  "+d+" "+e+"执行时间:"+new Date().toLocaleString());
+    }
+
+}

+ 163 - 0
src/main/java/com/gyee/frame/service/app/windpowerstationdetail/Windspeedpowercurvedetail.java

@@ -0,0 +1,163 @@
+package com.gyee.frame.service.app.windpowerstationdetail;
+
+import com.gyee.frame.common.spring.Constant;
+import com.gyee.frame.common.spring.InitialRunner;
+import com.gyee.frame.model.auto.WindPowerStationTestingPoint2;
+import com.gyee.frame.model.auto.Windpowerstation;
+import com.gyee.frame.model.custom.PointData;
+import com.gyee.frame.model.enumeration.Messagetype;
+import com.gyee.frame.netty.websocket.util.SocketToolController;
+import com.gyee.frame.netty.websocket.util.SocketToolService;
+import com.gyee.frame.util.DateUtils;
+import com.gyee.frame.util.golden.EdosUtil;
+import com.gyee.frame.util.golden.IEdosUtil;
+import com.gyee.frame.util.mongodb.IMongodbUtil;
+import com.gyee.frame.util.mongodb.MongodbUtilImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.swing.text.html.parser.Entity;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * @author Li ZaiXun
+ * @purpose
+ * @date 2020-05-16 15:48
+ */
+@Service
+public class Windspeedpowercurvedetail extends SocketToolService {
+    @Autowired
+    private InitialRunner initialRunner;
+    private static int decimal_digit = 0;
+    IEdosUtil mongodb = new EdosUtil();
+    public static Map<String,String> windpowerstationdetail_twentyfourhourlinechart_target_pointMap = new HashMap<>();
+    private double decimal(int num,double value){
+        return new BigDecimal(value).setScale(num, RoundingMode.HALF_EVEN).doubleValue();
+    }
+    public <T> void windpowerstationdetail_twentyfourhourlinechart_target() throws Exception {
+        Map<String, Map<String, WindPowerStationTestingPoint2>> stationPointmap = InitialRunner.stationPointmap;
+        String fs = Constant.TPOINT_WP_SSFS;
+        String gl = Constant.TPOINT_WT_FJGL;
+        String llgl = Constant.TPOINT_WT_LLGL;
+        String ycgl = Constant.TPOINT_WP_YCGL;
+        List<Windpowerstation> wpls = new ArrayList<>();
+        for (Windpowerstation wp : InitialRunner.wpls) {
+            wpls.add(wp);
+        }
+        Windpowerstation windpowerstationAll = new Windpowerstation();
+        windpowerstationAll.setId("0");
+        wpls.add(windpowerstationAll);
+        Map<String, Map<String,List<PointData>>> windpowerstationpointDataMap = new HashMap();
+
+        
+        for (Windpowerstation windpowerstation : wpls) {
+            Map<String,List<PointData>> map = new HashMap<>();
+            windpowerstationpointDataMap.put(windpowerstation.getId(),map);
+            List<PointData> listPointData = new ArrayList<>();
+            double pjfs = 0;
+
+            try {
+                //风速功率曲线图,风速
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH");
+                Date nowTime = DateUtils.getNowDate();
+                Date endTime = sdf.parse(sdf.format(nowTime));
+                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
+                Date beginTime = sdf1.parse(sdf1.format(nowTime));
+                Long count = (endTime.getTime() - beginTime.getTime()) / 1000L / 3600L;
+                WindPowerStationTestingPoint2 point = stationPointmap.get(windpowerstation.getId()).get(fs);
+                listPointData = mongodb.getHistoryDatasSnap(point,
+                        beginTime.getTime() / 1000, endTime.getTime() / 1000 + 3600L,
+                        (long) count+1, 3600L);
+                for (int i = 0; i < listPointData.size(); i++) {
+                    listPointData.get(i).setPointTime(listPointData.get(i).getPointTime() - 3600);
+                    listPointData.get(i).setPointValueInDouble(this.decimal(2,listPointData.get(i).getPointValueInDouble()));
+                }
+                if(listPointData.size()>0) {
+                    listPointData.remove(0);
+                }
+                map.put("fs",listPointData);
+            } catch (Exception e) {
+                System.out.println(e.getMessage());
+            }
+
+
+            try {
+                //风速功率曲线图,功率
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH");
+                Date nowTime = DateUtils.getNowDate();
+                Date endTime = sdf.parse(sdf.format(nowTime));
+                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
+                Date beginTime = sdf1.parse(sdf1.format(nowTime));
+                Long count = (endTime.getTime() - beginTime.getTime()) / 1000L / 3600L;
+                WindPowerStationTestingPoint2 point = stationPointmap.get(windpowerstation.getId()).get(gl);
+                listPointData = mongodb.getHistoryDatasSnap(point,
+                        beginTime.getTime() / 1000, endTime.getTime() / 1000 + 3600L,
+                        (long) count+1, 3600L);
+                for (int i = 0; i < listPointData.size(); i++) {
+                    listPointData.get(i).setPointTime(listPointData.get(i).getPointTime() - 3600);
+                    listPointData.get(i).setPointValueInDouble(this.decimal(2,listPointData.get(i).getPointValueInDouble()));
+                }
+                if(listPointData.size()>0) {
+                    listPointData.remove(0);
+                }
+                map.put("gl",listPointData);
+            } catch (Exception e) {
+                System.out.println(e.getMessage());
+            }
+
+
+            try {
+                //风速功率曲线图,理论功率
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH");
+                Date nowTime = DateUtils.getNowDate();
+                Date endTime = sdf.parse(sdf.format(nowTime));
+                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
+                Date beginTime = sdf1.parse(sdf1.format(nowTime));
+                Long count = (endTime.getTime() - beginTime.getTime()) / 1000L / 3600L;
+                WindPowerStationTestingPoint2 point = stationPointmap.get(windpowerstation.getId()).get(llgl);
+                listPointData = mongodb.getHistoryDatasSnap(point,
+                        beginTime.getTime() / 1000, endTime.getTime() / 1000 + 3600L,
+                        (long) count+1, 3600L);
+                for (int i = 0; i < listPointData.size(); i++) {
+                    listPointData.get(i).setPointTime(listPointData.get(i).getPointTime() - 3600);
+                    listPointData.get(i).setPointValueInDouble(this.decimal(2,listPointData.get(i).getPointValueInDouble()));
+                }
+                if(listPointData.size()>0) {
+                    listPointData.remove(0);
+                }
+                map.put("llgl",listPointData);
+            } catch (Exception e) {
+                System.out.println(e.getMessage());
+            }
+
+
+            try {
+                //风速功率曲线图,预测功率
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH");
+                Date nowTime = DateUtils.getNowDate();
+                Date endTime = sdf.parse(sdf.format(nowTime));
+                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
+                Date beginTime = sdf1.parse(sdf1.format(nowTime));
+                Long count = (endTime.getTime() - beginTime.getTime()) / 1000L / 3600L;
+                WindPowerStationTestingPoint2 point = stationPointmap.get(windpowerstation.getId()).get(ycgl);
+                listPointData = mongodb.getHistoryDatasSnap(point,
+                        beginTime.getTime() / 1000, endTime.getTime() / 1000 + 3600L,
+                        (long) count+1, 3600L);
+                for (int i = 0; i < listPointData.size(); i++) {
+                    listPointData.get(i).setPointTime(listPointData.get(i).getPointTime() - 3600);
+                    listPointData.get(i).setPointValueInDouble(this.decimal(2,listPointData.get(i).getPointValueInDouble()));
+                }
+                if(listPointData.size()>0) {
+                    listPointData.remove(0);
+                }
+                map.put("ycgl",listPointData);
+            } catch (Exception e) {
+                System.out.println(e.getMessage());
+            }
+        }
+        this.pushToWeb("pageNumber_7","functionNumber_4",windpowerstationpointDataMap, Messagetype.MESSAGE);
+    }
+}

+ 4 - 2
src/main/java/com/gyee/frame/service/app/windpowerstationdetail/Windspeedpowermodule.java

@@ -7,6 +7,8 @@ import com.gyee.frame.model.auto.Windpowerstation;
 import com.gyee.frame.model.custom.PointData;
 import com.gyee.frame.model.enumeration.Messagetype;
 import com.gyee.frame.netty.websocket.util.SocketToolService;
+import com.gyee.frame.util.golden.EdosUtil;
+import com.gyee.frame.util.golden.IEdosUtil;
 import com.gyee.frame.util.mongodb.IMongodbUtil;
 import com.gyee.frame.util.mongodb.MongodbUtilImpl;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -24,7 +26,7 @@ public class Windspeedpowermodule extends SocketToolService {
     @Autowired
     private InitialRunner initialRunner;
     private static int decimal_digit = 0;
-
+    IEdosUtil mongodb = new EdosUtil();
     public void index_windSpeed_power_target_detail() throws Exception{
         Map<String, Map<String, WindPowerStationTestingPoint2>> stationPointmap = InitialRunner.stationPointmap;
         List<Windpowerstation> wpls = new ArrayList<>();
@@ -35,7 +37,7 @@ public class Windspeedpowermodule extends SocketToolService {
         windpowerstationAll.setId("0");
         wpls.add(windpowerstationAll);
         Map<String,Map<String,Double>> windpowerstationpointDataMap = new HashMap();
-        IMongodbUtil mongodb = new MongodbUtilImpl();
+
 
         for(Windpowerstation windpowerstation:wpls){
             Map<String,Double> pointDataMap = new HashMap();