Procházet zdrojové kódy

单机信息总览线路明细功率曲线接口

shilin před 4 roky
rodič
revize
0dc56daefb

+ 23 - 0
src/main/java/com/gyee/frame/controller/goodness/WindturbineDetailLineChartController.java

@@ -53,6 +53,29 @@ public class WindturbineDetailLineChartController {
 
 
     /**
+     * 获得功率曲线数据查询
+     *
+     * @param wtId
+     * @param recorddate
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/findWtRealPowerChar")
+    @ResponseBody
+    public AjaxResult findWtRealPowerChar(String wtId, String recorddate) throws Exception {
+        Date date = DateUtils.parseStrtoDate(recorddate);
+        List<DataVo> result = windturbinegoodnessService.findWtRealPowerChar(wtId, date);
+
+//
+//        System.out.println( JSONArray.toJSON(result));
+
+        if (result != null) {
+            return AjaxResult.successData(AjaxStatus.success.code, result);
+        } else {
+            return AjaxResult.successData(AjaxStatus.emptyresultset.code, result);
+        }
+    }
+    /**
      * 获得曲线区间区分功能数据查询
      *
      * @param wtId

+ 11 - 0
src/main/java/com/gyee/frame/model/custom/EchartDataVo.java

@@ -9,7 +9,18 @@ public class EchartDataVo {
 
     private String name;
     private String xAxis;
+
+    public String getColor() {
+        return color;
+    }
+
+    public void setColor(String color) {
+        this.color = color;
+    }
+
     private String time;
+    private String color;
+
     public String getName() {
         return name;
     }

+ 168 - 0
src/main/java/com/gyee/frame/service/goodness/WindturbinegoodnessService.java

@@ -76,7 +76,142 @@ public class WindturbinegoodnessService {
         return pageInfo;
     }
 
+    /**
+     * 初始化折线图数据
+     *
+     * @return
+     */
 
+    public List<DataVo> findWtRealPowerChar(String wtId, Date recorddate) throws Exception {
+        List<DataVo> vos = new ArrayList<DataVo>();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        SimpleDateFormat sdfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+        Date endDate = sdfs.parse(sdf.format(DateUtils.addDays(recorddate, 1)) + " 00:0:00");
+        Date beginDate = sdfs.parse(sdf.format(recorddate) + " 00:00:00");
+
+        int length = 24;
+        for (int i = 0; i < length; i++) {
+            DataVo vo = new DataVo();
+
+            vo.setValue1(0.0);// 实发功率
+            vo.setValue2(0.0);// 保证功率
+            vo.setValue3(0.0);// 风速
+            vo.setValue4(0.0);// 状态
+            vos.add(vo);
+        }
+
+
+
+        WindTurbineTestingPointAi2 sjgl = windTurbineTestingPointAiService.getWindTurbineTestingPointAi2(wtId,Constant.TPOINT_WT_FJGL);
+        WindTurbineTestingPointAi2 bzgl = windTurbineTestingPointAiService.getWindTurbineTestingPointAi2(wtId,Constant.TPOINT_WT_YFGL);
+        WindTurbineTestingPointAi2 pjfs = windTurbineTestingPointAiService.getWindTurbineTestingPointAi2(wtId,Constant.TPOINT_WT_FJSSFS);
+
+
+       // WindTurbineTestingPointAi2 fs = map.get(Constant.TPOINT_WT_PJFS);
+
+        if (null != sjgl) {
+            List<PointData> sjglls = realApiUtil.getHistoryDatasSnap(sjgl, beginDate.getTime() / 1000, endDate.getTime() / 1000, (long) length, 3600L);
+            int count = 0;
+            double temp = 0;
+            for (int i = 0; i < vos.size(); i++) {
+                vos.get(i).setTime(sjglls.get(i ).getPointTime() * 1000);
+
+                if (i < sjglls.size() && StringUtils.notEmp(sjglls.get(i ).getPointTime())) {
+
+                    if (vos.get(i).getTime() <= DateUtils.now().getTime()) {
+                        temp = sjglls.get(i ).getPointValueInDouble();
+                        if (Math.abs(temp) < 10000) {
+                            vos.get(i).setValue1(StringUtils.round(temp, 2));// 实际功率
+                        }
+
+                        count++;
+                    } else {
+                        vos.get(i).setValue1(0d);// 实际功率
+                    }
+
+                }
+            }
+
+        }
+
+        if (null != bzgl) {
+            List<PointData> bzglls = realApiUtil.getHistoryDatasSnap(bzgl, beginDate.getTime() / 1000, endDate.getTime() / 1000, (long) length, 3600L);
+            int count = 0;
+            double temp = 0;
+            for (int i = 0; i < vos.size(); i++) {
+                // vos.get(i).setTime(bzglls.get(i).getPointTime() * 1000);
+                if (i < bzglls.size() && StringUtils.notEmp(bzglls.get(i ).getPointTime())) {
+
+                    if (vos.get(i).getTime() <= DateUtils.now().getTime()) {
+                        temp = bzglls.get(i ).getPointValueInDouble();
+                        if (Math.abs(temp) < 10000) {
+                            vos.get(i).setValue2(StringUtils.round(temp, 2));// 保证功率
+                        }
+
+                        count++;
+                    } else {
+                        vos.get(i).setValue2(0d);// 保证功率
+                    }
+
+                }
+            }
+
+        }
+
+        if (null != pjfs) {
+            List<PointData> pjfsls = realApiUtil.getHistoryDatasSnap(pjfs, beginDate.getTime() / 1000, endDate.getTime() / 1000, (long) length, 3600L);
+
+            int count = 0;
+            double temp = 0;
+            for (int i = 0; i < vos.size(); i++) {
+                vos.get(i).setTime(pjfsls.get(i ).getPointTime() * 1000);
+                if (i < pjfsls.size() && StringUtils.notEmp(pjfsls.get(i ).getPointTime())) {
+
+                    if (vos.get(i).getTime() <= DateUtils.now().getTime()) {
+                        temp = pjfsls.get(i ).getPointValueInDouble();
+                        vos.get(i).setValue3(StringUtils.round(temp, 2));// 风速
+                        count++;
+                    } else {
+                        vos.get(i).setValue3(0d);// 实际功率
+                    }
+
+                }
+            }
+
+        }
+
+        // if (null != fjzt) {
+        // List<PointData> fjztls = ednaApiUtil.getHistoryDatasSnap(fjzt,
+        // beginDate.getTime() / 1000, endDate.getTime() / 1000, (long) length,
+        // 3600L);
+        // int count = 0;
+        // double temp = 0;
+        // for (int i = 0; i < vos.size(); i++) {
+        // vos.get(i).setTime(fjztls.get(i).getPointTime() * 1000);
+        // if (i < fjztls.size() &&
+        // StringUtils.notEmp(fjztls.get(i).getPointTime())) {
+        //
+        // if (vos.get(i).getTime() <= DateUtils.now().getTime()) {
+        // temp = fjztls.get(i).getPointValueInDouble();
+        // if (Math.abs(temp) < 10000) {
+        // vos.get(i).setValue4(StringUtils.round(temp, 2));// 风机状态
+        // }
+        //
+        // count++;
+        // } else {
+        // vos.get(i).setValue4(0d);// 风机状态
+        // }
+        //
+        // }
+        // }
+        //
+        // }
+
+        // ////////////////////////////////////////////////
+
+        return vos;
+    }
     public List<List<EchartDataVo>> getplotBands(String wtId, Date recorddate) throws Exception {
 
         SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
@@ -129,6 +264,7 @@ public class WindturbinegoodnessService {
                             vo.setxAxis(beginTime);
                             vo.setTime(time);
                             vo.setName(judgeSatte(zttemp));
+                            vo.setColor(judgeColor(zttemp));
                             vos.add(vo);
                         } else {
                             if (zt != zttemp) {
@@ -149,6 +285,7 @@ public class WindturbinegoodnessService {
                                     vo.setxAxis(beginTime);
                                     vo.setTime(sdf2.format(resultDate));
                                     vo.setName(judgeSatte(zttemp));
+                                    vo.setColor(judgeColor(zttemp));
                                     vos.add(vo);
                                 }
                             }
@@ -192,6 +329,37 @@ public class WindturbinegoodnessService {
         }
         return ztname;
     }
+//    运行 #08FCF0 待机 #34A90A  维护 #FD7D1C 故障 #FD0100 限电 #D201D8 离线 #A6A6A6
+    private  String judgeColor(int zt)
+    {
+        String ztname=null;
+        switch ( zt ) {
+            case 0:
+                ztname= "#34A90A";
+                break;
+            case 1:
+                ztname= "#08FCF0";
+                break;
+            case 2:
+                ztname= "#FD0100";
+                break;
+            case 3:
+                ztname= "#A6A6A6";
+                break;
+            case 4:
+                ztname= "#FD7D1C";
+                break;
+            case 5:
+                ztname= "#D201D8";
+                break;
+            case 6:
+                ztname= "#D201D8";
+                break;
+            default:
+
+        }
+        return ztname;
+    }
 
     public Map<String, String> getPlotBand(String wtId , String begin, String end) throws Exception {
         WindTurbineTestingPointAi2 fdlAi =windTurbineTestingPointAiService.getWindTurbineTestingPointAi2(wtId,Constant.TPOINT_WT_RFDL);

+ 32 - 24
src/test/java/test/GoodnessTest.java

@@ -4,8 +4,7 @@ import com.gyee.SpringbootStart;
 import com.gyee.frame.common.domain.AjaxResult;
 import com.gyee.frame.common.spring.SpringUtils;
 import com.gyee.frame.controller.goodness.WindturbineDetailLineChartController;
-import com.gyee.frame.controller.goodness.WindturbineGoodnessDetailController;
-import com.gyee.frame.model.custom.EchartDataVo;
+import com.gyee.frame.model.custom.DataVo;
 import com.gyee.frame.model.custom.Tablepar;
 import lombok.SneakyThrows;
 import org.springframework.boot.SpringApplication;
@@ -13,7 +12,6 @@ import org.springframework.boot.SpringApplication;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
-import java.util.Map;
 
 public class GoodnessTest {
 
@@ -39,7 +37,8 @@ public class GoodnessTest {
         String wtid="MG01_02";
 
 //        WindturbinegoodnessController windturbinegoodnessController= SpringUtils.getBean("windturbinegoodnessController");
-        WindturbineGoodnessDetailController windturbineGoodnessDetailController= SpringUtils.getBean("windturbineGoodnessDetailController");
+        WindturbineDetailLineChartController windturbineDetailLineChartController= SpringUtils.getBean("windturbineDetailLineChartController");
+
 ////
 //
 //        AjaxResult ajaxResult = dayBenchmarkingController.gadaylist(wpid,"2021-01-01");
@@ -161,33 +160,42 @@ public class GoodnessTest {
 //            System.out.println(wtd.getValue1()+"----------------"+wtd.getSpeed());
 //        }
 //        System.out.println("***************************************************************************************");
+//
+//
+//        WindturbineDetailLineChartController windturbineDetailLineChartController= SpringUtils.getBean("windturbineDetailLineChartController");
+//
+//        AjaxResult ajaxResult =windturbineDetailLineChartController.getplotBands(wtid,"2021-01-02");
+//
+//        List<List<EchartDataVo>> test3=(List<List<EchartDataVo>>)ajaxResult.get("data");
+//
+//        for(List<EchartDataVo> ls:test3)
+//        {
+//            for(EchartDataVo wtd:ls)
+//            {
+//                System.out.println(wtd.getName()+"----------------"+wtd.getxAxis());
+//            }
+//
+//        }
+//        System.out.println("***************************************************************************************");
+//
+//        AjaxResult ajaxResult2 =windturbineDetailLineChartController.plotBandAjax(wtid,"2021-01-02 00:01" ,"2021-01-02 03:22");
+//
+//        Map<String, Double> test2=(Map<String, Double>)ajaxResult2.get("data");
+//
+//
+//                System.out.println(test2.get("fdl")+"----------------"+test2.get("llfdl")+"----------------"+test2.get("fjzt")+"----------------"
+//                        +test2.get("fs")+"----------------"+test2.get("gl")+"----------------"+test2.get("sc"));
 
 
-        WindturbineDetailLineChartController windturbineDetailLineChartController= SpringUtils.getBean("windturbineDetailLineChartController");
-
-        AjaxResult ajaxResult =windturbineDetailLineChartController.getplotBands(wtid,"2021-01-02");
+       AjaxResult ajaxResult4 =windturbineDetailLineChartController.findWtRealPowerChar(wtid,"2021-01-01");
 
-        List<List<EchartDataVo>> test3=(List<List<EchartDataVo>>)ajaxResult.get("data");
+        List<DataVo> test4=(List<DataVo> )ajaxResult4.get("data");
 
-        for(List<EchartDataVo> ls:test3)
+        for(DataVo wtd:test4)
         {
-            for(EchartDataVo wtd:ls)
-            {
-                System.out.println(wtd.getName()+"----------------"+wtd.getxAxis());
-            }
-
+            System.out.println(wtd.getValue1()+"----------------"+wtd.getValue2()+"----------------"+wtd.getValue3());
         }
         System.out.println("***************************************************************************************");
-
-        AjaxResult ajaxResult2 =windturbineDetailLineChartController.plotBandAjax(wtid,"2021-01-02 00:01" ,"2021-01-02 03:22");
-
-        Map<String, Double> test2=(Map<String, Double>)ajaxResult2.get("data");
-
-
-                System.out.println(test2.get("fdl")+"----------------"+test2.get("llfdl")+"----------------"+test2.get("fjzt")+"----------------"
-                        +test2.get("fs")+"----------------"+test2.get("gl")+"----------------"+test2.get("sc"));
-
-        System.out.println("***************************************************************************************");
     }