Преглед изворни кода

状态区间展示功能接口开发

shilin пре 4 година
родитељ
комит
b5714b7d0a

+ 1 - 1
src/main/java/com/gyee/frame/common/dao/IRealTimeDataBaseUtil.java

@@ -206,5 +206,5 @@ public interface IRealTimeDataBaseUtil {
      * @return
      * @throws Exception
      */
-    public DNAVal[] getHistMatrix(String[] nameList, int tTime) throws Exception;
+    public DNAVal[] getHistMatrix(String[] nameList, long tTime) throws Exception;
 }

+ 1 - 1
src/main/java/com/gyee/frame/common/dao/golden/EdosUtil.java

@@ -1223,7 +1223,7 @@ public class EdosUtil implements IRealTimeDataBaseUtil {
 
     //多点切面数据
     @Override
-    public DNAVal[] getHistMatrix(String[] nameList, int tTime) throws Exception {
+    public DNAVal[] getHistMatrix(String[] nameList, long tTime) throws Exception {
         String tagNameString = StringUtil.join(nameList, ",");
         Long time = Long.valueOf(tTime);
         Optional<String> tagName = Optional.ofNullable(tagNameString);

+ 2 - 2
src/main/java/com/gyee/frame/common/spring/InitialRunner.java

@@ -78,8 +78,8 @@ public class InitialRunner implements CommandLineRunner {
     public static Map<String, List<Project>> pjsmap = new HashMap<String, List<Project>>(); // 通过风场编号获得所属项目
     public static Map<String, List<Line>> lnsmap = new HashMap<String, List<Line>>(); // 通过项目编号获得所属线路
     public static Map<String, Map<Double, ModelpowerRd>> mprdMap = new HashMap<String, Map<Double, ModelpowerRd>>();
-    public static Map<String, Map<String, WindTurbineTestingPointAi2>> wtpAimap = new HashMap<String, Map<String, WindTurbineTestingPointAi2>>();// 风电机测点AI表
-    public static Map<String, Map<String, WindPowerStationTestingPoint2>> stationPointmap = new HashMap<String, Map<String, WindPowerStationTestingPoint2>>();//场站测点
+//    public static Map<String, Map<String, WindTurbineTestingPointAi2>> wtpAimap = new HashMap<String, Map<String, WindTurbineTestingPointAi2>>();// 风电机测点AI表
+//    public static Map<String, Map<String, WindPowerStationTestingPoint2>> stationPointmap = new HashMap<String, Map<String, WindPowerStationTestingPoint2>>();//场站测点
     public static Map<String, SysQuartzJob>  jobsmap = new HashMap<String, SysQuartzJob>();
     public static Map<String, Map<Double, Windturbinepowercurvefitting>> wpcmap = new HashMap<String, Map<Double, Windturbinepowercurvefitting>>();
     public static Map<String, Equipmentmodel> mlmap = new HashMap<String, Equipmentmodel>();// 风电机模型

+ 15 - 16
src/main/java/com/gyee/frame/controller/goodness/WindturbineDetailLineChartController.java

@@ -7,6 +7,7 @@ import com.gyee.frame.model.auto.Brownoutsevent2;
 import com.gyee.frame.model.auto.Inputoroutputspeedtotal;
 import com.gyee.frame.model.auto.WarningRecords;
 import com.gyee.frame.model.custom.DataVo;
+import com.gyee.frame.model.custom.EchartDataVo;
 import com.gyee.frame.model.custom.ShutdowneventVo;
 import com.gyee.frame.model.custom.Tablepar;
 import com.gyee.frame.service.*;
@@ -19,7 +20,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 
 import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
 import java.util.*;
 
 /**
@@ -57,15 +57,18 @@ public class WindturbineDetailLineChartController {
      *
      * @param wtId
      * @param recorddate
-     * @param request
      * @return
      * @throws Exception
      */
     @PostMapping("/getplotBands")
     @ResponseBody
-    public AjaxResult list(String wtId, String recorddate, HttpServletRequest request) throws Exception {
+    public AjaxResult getplotBands(String wtId, String recorddate) throws Exception {
         Date date = DateUtils.parseStrtoDate(recorddate);
-        String result = windturbinegoodnessService.getplotBands(wtId, date, request);
+        List<List<EchartDataVo>> result = windturbinegoodnessService.getplotBands(wtId, date);
+
+//
+//        System.out.println( JSONArray.toJSON(result));
+
         if (result != null) {
             return AjaxResult.successData(AjaxStatus.success.code, result);
         } else {
@@ -212,30 +215,26 @@ public class WindturbineDetailLineChartController {
     /**
      * 获取区域弹出列表信息
      *
-     * @param plotBand
-     * @return
-     * @throws Exception
+
      */
     @PostMapping("/plotBandAjax")
     @ResponseBody
-    public AjaxResult plotBandAjax(HttpServletRequest request, String plotBand) throws Exception {
+    public AjaxResult plotBandAjax(String wtId,String beginDate,String endDate) throws Exception {
 
-        Map<String, Double> map = new HashMap<>();
-        if (StringUtils.notEmp(request.getSession().getAttribute("plotBandMap"))) {
-            Map<String, Map<String, Double>> plotBandMap = (Map<String, Map<String, Double>>) request.getSession().getAttribute("plotBandMap");
+        Map<String, String> map = new HashMap<>();
 
-            if (StringUtils.notEmp(plotBand)) {
-                if (plotBandMap.containsKey(plotBand)) {
-                    map = plotBandMap.get(plotBand);
 
+            if (StringUtils.notEmp(wtId) && StringUtils.notEmp(beginDate) && StringUtils.notEmp(endDate) ) {
+
+                    map=windturbinegoodnessService.getPlotBand(wtId,beginDate,endDate);
                     if (map != null) {
                         return AjaxResult.successData(AjaxStatus.success.code, map);
                     } else {
                         return AjaxResult.successData(AjaxStatus.emptyresultset.code, map);
                     }
-                }
+
             }
-        }
+
         return AjaxResult.successData(AjaxStatus.success.code, map);
     }
 

+ 1 - 1
src/main/java/com/gyee/frame/controller/powercompare/PowerCompareController.java

@@ -231,7 +231,7 @@ public class PowerCompareController {
     }
 
     /**
-     * 通过风电场ID获取风机下拉接口
+     * 获得所有风电场风机下拉接口
      * @return
      */
     @GetMapping("/windturbineAllAjax")

+ 26 - 14
src/main/java/com/gyee/frame/controller/scatter/ScatterController.java

@@ -5,11 +5,12 @@ import com.gyee.frame.common.dao.IRealTimeDataBaseUtil;
 import com.gyee.frame.common.dao.golden.EdosUtil;
 import com.gyee.frame.common.domain.AjaxResult;
 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.WindTurbineTestingPointAi2;
 import com.gyee.frame.model.auto.Windturbinecurvefittingmonth;
 import com.gyee.frame.model.custom.PointData;
+import com.gyee.frame.service.WindPowerstationTestingPointService;
+import com.gyee.frame.service.WindTurbineTestingPointAiService;
 import com.gyee.frame.service.WindturbinecurvefittingmonthService;
 import com.gyee.frame.util.DateUtils;
 import com.gyee.frame.util.StringUtils;
@@ -28,6 +29,12 @@ public class ScatterController {
 
     @Autowired
     private WindturbinecurvefittingmonthService windturbinecurvefittingmonthService;
+
+    @Autowired
+    private WindPowerstationTestingPointService windPowerstationTestingPointService;
+
+    @Autowired
+    private WindTurbineTestingPointAiService  windTurbineTestingPointAiService;
     IRealTimeDataBaseUtil realApiUtil = new EdosUtil();
     /**
      *
@@ -54,15 +61,22 @@ public class ScatterController {
             cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
             Date endDate = cal.getTime();
 
-            Map<String, WindPowerStationTestingPoint2> map = null;
-            if (StringUtils.notEmp(wpId) && InitialRunner.stationPointmap.containsKey(wpId)) {
-                map = InitialRunner.stationPointmap.get(wpId);
-            } else if (StringUtils.notEmp(pjId) && InitialRunner.stationPointmap.containsKey(pjId)) {
-                map = InitialRunner.stationPointmap.get(pjId);
-            } else if (StringUtils.notEmp(lnId) && InitialRunner.stationPointmap.containsKey(lnId)) {
-                map = InitialRunner.stationPointmap.get(lnId);
+
+            WindPowerStationTestingPoint2 gl=null;
+            WindPowerStationTestingPoint2 fs=null;
+
+            if (StringUtils.notEmp(wpId)) {
+                gl=windPowerstationTestingPointService.getWindPowerStationTestingPoint2(wpId,Constant.TPOINT_WP_SJGL);
+                fs=windPowerstationTestingPointService.getWindPowerStationTestingPoint2(wpId,Constant.TPOINT_WP_SSFS);
+            } else if (StringUtils.notEmp(pjId)) {
+                gl=windPowerstationTestingPointService.getWindPowerStationTestingPoint2(pjId,Constant.TPOINT_WP_SJGL);
+                fs=windPowerstationTestingPointService.getWindPowerStationTestingPoint2(wpId,Constant.TPOINT_WP_SSFS);
+
+            } else if (StringUtils.notEmp(lnId)) {
+                gl=windPowerstationTestingPointService.getWindPowerStationTestingPoint2(lnId,Constant.TPOINT_WP_SJGL);
+                fs=windPowerstationTestingPointService.getWindPowerStationTestingPoint2(wpId,Constant.TPOINT_WP_SSFS);
             }
-            WindPowerStationTestingPoint2 gl = map.get(Constant.TPOINT_WP_SJGL);
+
 
             int daynum= DateUtils.daysDiff(beginDate, endDate);
             long pried=60*10;
@@ -70,7 +84,7 @@ public class ScatterController {
 
             DecimalFormat dcmFmt = new DecimalFormat("0.00");
             List<PointData> gls = realApiUtil.getHistoryDatasSnap(gl, beginDate.getTime() / 1000, endDate.getTime() / 1000, count, pried);
-            WindPowerStationTestingPoint2 fs = map.get(Constant.TPOINT_WP_SSFS);
+
             List<PointData> fss = realApiUtil.getHistoryDatasSnap(fs, beginDate.getTime() / 1000, endDate.getTime() / 1000, count, pried);
 
 
@@ -123,10 +137,8 @@ public class ScatterController {
             Date endDate = cal.getTime();
 
             Map<String, WindTurbineTestingPointAi2> map = null;
-            if (StringUtils.notEmp(wtId) && InitialRunner.wtpAimap.containsKey(wtId)) {
-                map = InitialRunner.wtpAimap.get(wtId);
-            }
-            WindTurbineTestingPointAi2 gl = map.get(Constant.TPOINT_WT_FJGL);
+
+            WindTurbineTestingPointAi2 gl =windTurbineTestingPointAiService.getWindTurbineTestingPointAi2(wtId,Constant.TPOINT_WT_FJGL);
             int daynum=DateUtils.daysDiff(beginDate, endDate);
             long pried=60*10;
             long count=6*24*daynum;

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

@@ -0,0 +1,36 @@
+
+package com.gyee.frame.model.custom;
+
+/**
+ *
+ */
+
+public class EchartDataVo {
+
+    private String name;
+    private String xAxis;
+    private String time;
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getxAxis() {
+        return xAxis;
+    }
+
+    public void setxAxis(String xAxis) {
+        this.xAxis = xAxis;
+    }
+
+    public String getTime() {
+        return time;
+    }
+
+    public void setTime(String time) {
+        this.time = time;
+    }
+}

+ 20 - 0
src/main/java/com/gyee/frame/service/WindPowerstationTestingPointService.java

@@ -9,6 +9,7 @@ import com.gyee.frame.model.auto.WindPowerStationTestingPoint2;
 import com.gyee.frame.model.auto.WindPowerStationTestingPoint2Example;
 import com.gyee.frame.model.custom.Tablepar;
 import com.gyee.frame.util.SnowflakeIdWorker;
+import com.gyee.frame.util.StringUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -132,5 +133,24 @@ public class WindPowerstationTestingPointService implements BaseService<WindPowe
 		return list.size();
 	}
 
+	public WindPowerStationTestingPoint2 getWindPowerStationTestingPoint2(String wpId, String unicode)  {
+		WindPowerStationTestingPoint2 point=new WindPowerStationTestingPoint2();
+
+		WindPowerStationTestingPoint2Example example=new WindPowerStationTestingPoint2Example();
+
+		if(StringUtils.isNotEmpty(wpId) &&  StringUtils.isNotEmpty(unicode)){
+
+
+			example.createCriteria().andWindpowerstationidEqualTo(wpId).andUniformcodeEqualTo(unicode);
+			List<WindPowerStationTestingPoint2> list= windPowerStationTestingPoint2Mapper.selectByExample(example);
+			if(!list.isEmpty())
+			{
+				point=list.get(0);
+			}
+		}
+
+		return point;
+	}
+
 
 }

+ 19 - 0
src/main/java/com/gyee/frame/service/WindTurbineTestingPointAiService.java

@@ -9,6 +9,7 @@ import com.gyee.frame.model.auto.WindTurbineTestingPointAi2;
 import com.gyee.frame.model.auto.WindTurbineTestingPointAi2Example;
 import com.gyee.frame.model.custom.Tablepar;
 import com.gyee.frame.util.SnowflakeIdWorker;
+import com.gyee.frame.util.StringUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -132,5 +133,23 @@ public class WindTurbineTestingPointAiService implements BaseService<WindTurbine
 		return list.size();
 	}
 
+	public WindTurbineTestingPointAi2 getWindTurbineTestingPointAi2(String wtId, String unicode)  {
 
+		WindTurbineTestingPointAi2 point=new WindTurbineTestingPointAi2();
+		WindTurbineTestingPointAi2Example example=new WindTurbineTestingPointAi2Example();
+
+		if(StringUtils.isNotEmpty(wtId) &&  StringUtils.isNotEmpty(unicode)){
+
+
+			example.createCriteria().andWindturbineidEqualTo(wtId).andUniformcodeEqualTo(unicode);
+			List<WindTurbineTestingPointAi2> list= windTurbineTestingPointAi2Mapper.selectByExample(example);
+
+			if(!list.isEmpty())
+			{
+				point=list.get(0);
+			}
+		}
+
+		return point;
+	}
 }

+ 137 - 117
src/main/java/com/gyee/frame/service/goodness/WindturbinegoodnessService.java

@@ -5,20 +5,17 @@ import com.github.pagehelper.PageInfo;
 import com.gyee.frame.common.dao.IRealTimeDataBaseUtil;
 import com.gyee.frame.common.dao.golden.EdosUtil;
 import com.gyee.frame.common.spring.Constant;
-import com.gyee.frame.common.spring.InitialRunner;
 import com.gyee.frame.mapper.auto.WindturbinegoodnessMapper;
 import com.gyee.frame.model.auto.WindTurbineTestingPointAi2;
 import com.gyee.frame.model.auto.Windturbinegoodness;
 import com.gyee.frame.model.auto.WindturbinegoodnessExample;
-import com.gyee.frame.model.custom.DataVo;
-import com.gyee.frame.model.custom.PointData;
-import com.gyee.frame.model.custom.Tablepar;
+import com.gyee.frame.model.custom.*;
+import com.gyee.frame.service.WindTurbineTestingPointAiService;
 import com.gyee.frame.util.DateUtils;
 import com.gyee.frame.util.StringUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.text.SimpleDateFormat;
@@ -35,8 +32,11 @@ public class WindturbinegoodnessService {
     @Resource
     private WindturbinegoodnessMapper windturbinegoodnessMapper;
 
+    @Resource
+    private WindTurbineTestingPointAiService windTurbineTestingPointAiService;
+
     IRealTimeDataBaseUtil realApiUtil = new EdosUtil();
-    
+
     public PageInfo<Windturbinegoodness> windturbinegoodnessList(Tablepar tablepar, String wpId, String recorddate) {
 
         WindturbinegoodnessExample example = new WindturbinegoodnessExample();
@@ -77,124 +77,143 @@ public class WindturbinegoodnessService {
     }
 
 
-    public String getplotBands(String wtId, Date recorddate, HttpServletRequest request) throws Exception {
+    public List<List<EchartDataVo>> getplotBands(String wtId, Date recorddate) throws Exception {
 
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-        SimpleDateFormat sdfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
+        SimpleDateFormat sdf2 = new SimpleDateFormat("YYYY-MM-DD HH:mm");
+        Calendar c = Calendar.getInstance();
+        c.setTime(recorddate);
+        c.set(Calendar.HOUR_OF_DAY, 0);
+        c.set(Calendar.MINUTE, 0);
+        c.set(Calendar.SECOND, 0);
+        c.set(Calendar.MILLISECOND,0);
 
-        List<Long> from = new ArrayList<Long>();
-        List<Long> to = new ArrayList<Long>();
-        List<Integer> ztls = new ArrayList<Integer>();
-        Date endDate = sdfs.parse(sdf.format(DateUtils.addDays(recorddate, 1)) + " 00:06:00");
-        Date beginDate = sdfs.parse(sdf.format(recorddate) + " 01:00:00");
 
-        int length = 230;
+        Date beginDate = c.getTime();
+        c.add(Calendar.DAY_OF_MONTH, 1);
+        Date endDate = c.getTime();
+
+
+
+        List<String> xtime=new ArrayList<>();
+        List<EchartDataVo> vos=new ArrayList<>();
+        List<List<EchartDataVo>> resultvos=new ArrayList<>();
+        Map<String,String> map=new HashMap<>();
+        int length = 240;
         String plotBands = null;
         StringBuilder sb = new StringBuilder("");
-        Map<String, WindTurbineTestingPointAi2> map = InitialRunner.wtpAimap.get(wtId);
 
-        WindTurbineTestingPointAi2 fjzt = map.get(Constant.FJZT);
-        Map<String, Map<String, Double>> plotBandMap = new HashMap<String, Map<String, Double>>();
-        try {
+        WindTurbineTestingPointAi2 fjzt = windTurbineTestingPointAiService.getWindTurbineTestingPointAi2(wtId,Constant.FJZT);
+
+        String beginTime=null;
+        String endTime=null;
+        String time=null;
 
             if (null != fjzt) {
                 List<PointData> fjztls = realApiUtil.getHistoryDatasSnap(fjzt, beginDate.getTime() / 1000, endDate.getTime() / 1000, (long) length, 360L);
 
 
+                int zt = 0;
                 for (int i = 0; i < fjztls.size(); i++) {
-                    if (i < fjztls.size() ) {
-                        from.add(fjztls.get(i).getPointTime() * 1000);
-                        ztls.add(Double.valueOf(fjztls.get(i).getPointValueInDouble()).intValue());
-                    }
-
-                    to.add(fjztls.get(i).getPointTime() * 1000);
-
-                }
-
-            }
-
-            Integer state = ztls.get(0);
-            double begin = -1;
-            double end = 0.1;
-            int beginnum = 0;
-            int endnum = 1;
-            StringBuilder temp = new StringBuilder();
-
-            for (int i = 0; i < length; i++) {
-
-                Integer zt = ztls.get(i);
-                if (i < length - 1) {
-                    zt = ztls.get(i + 1);
-                }
-
-                if (StringUtils.notEmp(zt)) {
-                    if (zt != state) {
-                        sb.append("{");
-                        sb.append("id: '").append(i).append("',");
-                        sb.append(getColor(temp, state));
-                        state = zt;
-                        sb.append("from: ").append(begin).append(",");
-                        Date begindate = new Date(from.get(beginnum));
-                        if (i != 0) {
-                            begin = end;
-                            beginnum = endnum;
-                            end = end + 0.1;
-                            endnum++;
+                    if (i < fjztls.size()) {
+
+                        PointData pd=fjztls.get(i);
+                        int zttemp = Double.valueOf(pd.getPointValueInDouble()).intValue();
+                        Date resultDate = new Date(pd.getPointTime() * 1000);
+                        beginTime = sdf.format(resultDate);
+                        time=sdf2.format(resultDate);
+                        xtime.add(beginTime);
+                        if (i == 0) {
+                            zt = zttemp;
+                            EchartDataVo vo = new EchartDataVo();
+                            vo.setxAxis(beginTime);
+                            vo.setTime(time);
+                            vo.setName(judgeSatte(zttemp));
+                            vos.add(vo);
                         } else {
-                            begin = 0.0;
-                        }
-                        sb.append("to: ").append(end);
-                        sb.append(", events: { click: function (e) {plotBandAjax(" + i + ");}}},");
-
-                        Date enddate = new Date(to.get(endnum));
+                            if (zt != zttemp) {
+                                zt = zttemp;
+                                c = Calendar.getInstance();
+                                c.setTime(resultDate);
+                                c.add(Calendar.MINUTE, -6);
+                                endTime = sdf.format(c.getTime());
+                                time=sdf2.format(c.getTime());
+                                EchartDataVo vo = new EchartDataVo();
+                                vo.setxAxis(endTime);
+                                vo.setTime(time);
+                                vos.add(vo);
+                                if (vos.size() == 2) {
+                                    resultvos.add(vos);
+                                    vos = new ArrayList<>();
+                                    vo = new EchartDataVo();
+                                    vo.setxAxis(beginTime);
+                                    vo.setTime(sdf2.format(resultDate));
+                                    vo.setName(judgeSatte(zttemp));
+                                    vos.add(vo);
+                                }
+                            }
 
-                        plotBandMap.put(String.valueOf(i), getPlotBand(map, begindate, enddate));
+                        }
 
-                    } else {
-                        end = end + 0.1;
-                        endnum++;
                     }
 
                 }
-
-            }
-            sb.append("{");
-            sb.append("id: '230' ,");
-            sb.append(getColor(temp, state));
-            sb.append("from: ").append(begin).append(",");
-            sb.append("to: ").append(end);
-            sb.append(", events: { click: function (e) {plotBandAjax(230); }}},");
-            Date begindate = new Date(from.get(beginnum));
-            Date enddate = new Date(to.get(229));
-            plotBandMap.put(String.valueOf(230), getPlotBand(map, begindate, enddate));
-            // ////////////////////////////////////////////////
-
-            if (sb.length() >= 1) {
-                plotBands = sb.substring(0, sb.length() - 1);
             }
-        } catch (Exception ex) {
-            ex.printStackTrace();
-        }
-        request.getSession().setAttribute("plotBandMap", plotBandMap);
-
-        // sb.append("]");
-        // plotBands = String.valueOf(sb);
-        return plotBands;
+        return resultvos;
     }
 
-    public Map<String, Double> getPlotBand(Map<String, WindTurbineTestingPointAi2> map, Date begindate, Date enddate) throws Exception {
-        WindTurbineTestingPointAi2 fdlAi = map.get(Constant.TPOINT_WT_RFDL);
-        WindTurbineTestingPointAi2 fsAi = map.get(Constant.TPOINT_WT_FJSSFS);
-        WindTurbineTestingPointAi2 llfdlAi = map.get(Constant.TPOINT_WT_RFDLBZ);
-        WindTurbineTestingPointAi2 glAi = map.get(Constant.TPOINT_WT_FJGL);
-        WindTurbineTestingPointAi2 fjztAi = map.get(Constant.FJZT);
+    private  String judgeSatte(int zt)
+    {
+        String ztname=null;
+        switch ( zt ) {
+            case 0:
+                ztname= "待机";
+                break;
+            case 1:
+                ztname= "运行";
+                break;
+            case 2:
+                ztname= "故障";
+                break;
+            case 3:
+                ztname= "中断";
+                break;
+            case 4:
+                ztname= "维护";
+                break;
+            case 5:
+                ztname= "限电停机";
+                break;
+            case 6:
+                ztname= "限电出力";
+                break;
+            default:
+
+        }
+        return ztname;
+    }
 
-        Map<String, Double> tempmap = new HashMap<String, Double>();
+    public Map<String, String> getPlotBand(String wtId , String begin, String end) throws Exception {
+        WindTurbineTestingPointAi2 fdlAi =windTurbineTestingPointAiService.getWindTurbineTestingPointAi2(wtId,Constant.TPOINT_WT_RFDL);
+        WindTurbineTestingPointAi2 fsAi = windTurbineTestingPointAiService.getWindTurbineTestingPointAi2(wtId,Constant.TPOINT_WT_FJSSFS);
+        WindTurbineTestingPointAi2 llfdlAi =windTurbineTestingPointAiService.getWindTurbineTestingPointAi2(wtId,Constant.TPOINT_WT_RFDLBZ);
+        WindTurbineTestingPointAi2 glAi = windTurbineTestingPointAiService.getWindTurbineTestingPointAi2(wtId,Constant.TPOINT_WT_FJGL);
+        WindTurbineTestingPointAi2 fjztAi =windTurbineTestingPointAiService.getWindTurbineTestingPointAi2(wtId,Constant.FJZT);
+         String sdf = "yyyy-MM-dd HH:mm";
+        Date begindate=DateUtils.parseStrtoDate(begin,sdf);
+        Date enddate=DateUtils.parseStrtoDate(end,sdf);
+        Map<String, String> tempmap = new HashMap<String, String>();
 
         // 发电量
         double beginfdl = 0.0;
         double endfdl = 0.0;
         double fdl = 0.0;
+
+//        String[] id=new String[1];
+//        DNAVal[] val= realApiUtil.getHistMatrix(id,begindate.getTime() / 1000);
+//        beginfdl=val[0].DValue;
+//        val= realApiUtil.getHistMatrix(id,enddate.getTime() / 1000);
+//        endfdl=val[0].DValue;
         List<PointData> beginfdlls = realApiUtil.getHistoryDatasSnap(fdlAi,
                 begindate.getTime() / 1000, begindate.getTime() / 1000,
                 (long) 1, 3600L);
@@ -209,7 +228,7 @@ public class WindturbinegoodnessService {
         }
         fdl = endfdl - beginfdl;
 
-        tempmap.put("fdl", StringUtils.round(fdl, 2));
+        tempmap.put("fdl", String.valueOf(StringUtils.round(fdl, 2)));
         // 理论电量
         double beginllfdl = 0.0;
         double endllfdl = 0.0;
@@ -230,16 +249,17 @@ public class WindturbinegoodnessService {
         // llfdl=new BigDecimal(llfdl).multiply(new
         // BigDecimal(10000)).doubleValue();
 
-        tempmap.put("llfdl", StringUtils.round(llfdl, 2));
+        tempmap.put("llfdl", String.valueOf(StringUtils.round(llfdl, 2)));
 
         // 风机状态
-        double fjzt = 0.0;
+        int fjzt = 0;
         List<PointData> fjztls = realApiUtil.getHistoryDatasSnap(fjztAi,
                 begindate.getTime() / 1000, enddate.getTime() / 1000, (long) 1,
                 3600L);
         if (!fjztls.isEmpty()) {
-            fjzt = fjztls.get(0).getPointValueInDouble();
-            tempmap.put("fjzt", fjzt);
+            fjzt =  Double.valueOf(fjztls.get(0).getPointValueInDouble()).intValue();
+
+            tempmap.put("fjzt", judgeSatte(fjzt));
 
         }
 
@@ -262,7 +282,7 @@ public class WindturbinegoodnessService {
             double fstemp = new BigDecimal(fs).divide(
                     new BigDecimal(time1.doubleValue()), 2,
                     RoundingMode.HALF_EVEN).doubleValue();
-            tempmap.put("fs", StringUtils.round(fstemp, 2));
+            tempmap.put("fs", String.valueOf(StringUtils.round(fstemp, 2)));
         }
         // 功率
         double gl = 0.0;
@@ -282,21 +302,21 @@ public class WindturbinegoodnessService {
             double gltemp = new BigDecimal(gl).divide(
                     new BigDecimal(time2.doubleValue()), 2,
                     RoundingMode.HALF_EVEN).doubleValue();
-            tempmap.put("gl", StringUtils.round(gltemp, 2));
+            tempmap.put("gl", String.valueOf(StringUtils.round(gltemp, 2)));
         }
         // 时长
-        tempmap.put("sc", StringUtils.round(DateUtils.hoursDiff2(begindate, enddate), 2));
+        tempmap.put("sc", String.valueOf(StringUtils.round(DateUtils.hoursDiff2(begindate, enddate), 2)));
 
         // 损失电量
 
         if (fjzt != 1) {
             fdl = 0.0;
-            tempmap.put("fdl", 0.0);
-            tempmap.put("gl", 0.0);
+            tempmap.put("fdl", "0.0");
+            tempmap.put("gl", "0.0");
         }
-        tempmap.put("ssdl", StringUtils.round(llfdl - fdl, 2));
-        tempmap.put("ks", Double.valueOf(begindate.getTime()));
-        tempmap.put("js", Double.valueOf(enddate.getTime()));
+        tempmap.put("ssdl", String.valueOf(StringUtils.round(llfdl - fdl, 2)));
+        tempmap.put("ks", begin);
+        tempmap.put("js", end);
         return tempmap;
     }
 
@@ -360,14 +380,14 @@ public class WindturbinegoodnessService {
             vos.add(vo);
         }
 
-        Map<String, WindTurbineTestingPointAi2> map = InitialRunner.wtpAimap.get(wtId);
 
-        WindTurbineTestingPointAi2 fdl = map.get(Constant.TPOINT_WT_RFDL);
-        WindTurbineTestingPointAi2 whss = map.get(Constant.RJXSSDL);
-        WindTurbineTestingPointAi2 gzss = map.get(Constant.RGZSSDL);
-        WindTurbineTestingPointAi2 xdss = map.get(Constant.RXDSSDL);
-        WindTurbineTestingPointAi2 qfss = map.get(Constant.RQFSSDL);
-        WindTurbineTestingPointAi2 fs = map.get(Constant.TPOINT_WT_FJSSFS);
+
+        WindTurbineTestingPointAi2 fdl =windTurbineTestingPointAiService.getWindTurbineTestingPointAi2(wtId,Constant.TPOINT_WT_RFDL);
+        WindTurbineTestingPointAi2 whss =windTurbineTestingPointAiService.getWindTurbineTestingPointAi2(wtId,Constant.RJXSSDL);
+        WindTurbineTestingPointAi2 gzss =windTurbineTestingPointAiService.getWindTurbineTestingPointAi2(wtId,Constant.RGZSSDL);
+        WindTurbineTestingPointAi2 xdss =windTurbineTestingPointAiService.getWindTurbineTestingPointAi2(wtId,Constant.RXDSSDL);
+        WindTurbineTestingPointAi2 qfss =windTurbineTestingPointAiService.getWindTurbineTestingPointAi2(wtId,Constant.RQFSSDL);
+        WindTurbineTestingPointAi2 fs =windTurbineTestingPointAiService.getWindTurbineTestingPointAi2(wtId,Constant.TPOINT_WT_FJSSFS);
 
         try {
             if (null != fdl) {

+ 13 - 0
src/main/java/com/gyee/frame/util/DateUtils.java

@@ -211,6 +211,19 @@ public class DateUtils  extends org.apache.commons.lang3.time.DateUtils {
         return dateTime;
     }
 
+    public static Date parseStrtoDate(String time,String pattern) {
+
+        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
+        Date dateTime = null;
+        try {
+            dateTime = sdf.parse(time);
+        } catch (ParseException e) {
+            e.printStackTrace();
+
+        }
+        return dateTime;
+    }
+
     public static double hoursDiff1(Date d1, Date d2) {
         return Math.floor(Math.abs((d1.getTime() - d2.getTime())) / (double) (60 * 60 * 1000));
     }

+ 20 - 25
src/test/java/test/GoldenTest.java

@@ -3,16 +3,11 @@ package test;
 import com.gyee.SpringbootStart;
 import com.gyee.frame.common.dao.IRealTimeDataBaseUtil;
 import com.gyee.frame.common.dao.golden.EdosUtil;
-import com.gyee.frame.common.spring.InitialRunner;
-import com.gyee.frame.model.auto.WindPowerStationTestingPoint2;
-import com.gyee.frame.model.custom.PointData;
 import lombok.SneakyThrows;
 import org.springframework.boot.SpringApplication;
 
 import java.util.Calendar;
 import java.util.Date;
-import java.util.List;
-import java.util.Map;
 
 public class GoldenTest {
 
@@ -34,26 +29,26 @@ public class GoldenTest {
         c.add(Calendar.DAY_OF_MONTH, 1);
         Date endDate = c.getTime();
 
-        if(InitialRunner.stationPointmap.containsKey("0"))
-        {
-            Map<String, WindPowerStationTestingPoint2> map=InitialRunner.stationPointmap.get("0");
-
-            if(map.containsKey("RFDLB"))
-            {
-                WindPowerStationTestingPoint2 p=map.get("RFDLB");
-
-//查看历史快照数据
-                List<PointData> ls = mongodb.getHistoryDatasSnap(p.getCode(),
-                        beginDate.getTime() / 1000, endDate.getTime() / 1000,
-                        (long) 24, 3600L);
-                if (!ls.isEmpty()) {
-                    ls.forEach(obj ->System.out.println(obj.getEdnaId() + "___" +obj.getPointTime() + "___" + obj.getPointValueInDouble()));
-                }
-//查看实时数据
-                PointData real=mongodb.getRealData(p.getCode());
-                //System.out.println(real.getPointValueInDouble());
-            }
-        }
+//        if(InitialRunner.stationPointmap.containsKey("0"))
+//        {
+//            Map<String, WindPowerStationTestingPoint2> map=InitialRunner.stationPointmap.get("0");
+//
+//            if(map.containsKey("RFDLB"))
+//            {
+//                WindPowerStationTestingPoint2 p=map.get("RFDLB");
+//
+////查看历史快照数据
+//                List<PointData> ls = mongodb.getHistoryDatasSnap(p.getCode(),
+//                        beginDate.getTime() / 1000, endDate.getTime() / 1000,
+//                        (long) 24, 3600L);
+//                if (!ls.isEmpty()) {
+//                    ls.forEach(obj ->System.out.println(obj.getEdnaId() + "___" +obj.getPointTime() + "___" + obj.getPointValueInDouble()));
+//                }
+////查看实时数据
+//                PointData real=mongodb.getRealData(p.getCode());
+//                //System.out.println(real.getPointValueInDouble());
+//            }
+//        }
 
     }
 

+ 44 - 1
src/test/java/test/GoodnessTest.java

@@ -1,14 +1,19 @@
 package test;
 
 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.Tablepar;
 import lombok.SneakyThrows;
 import org.springframework.boot.SpringApplication;
 
 import java.util.Calendar;
 import java.util.Date;
+import java.util.List;
+import java.util.Map;
 
 public class GoodnessTest {
 
@@ -144,8 +149,46 @@ public class GoodnessTest {
 //        System.out.println("***************************************************************************************");
 //
 
-    }
 
+//        WindturbineDetailPieChartAController windturbineDetailPieChartAController= SpringUtils.getBean("windturbineDetailPieChartAController");
+//
+//        AjaxResult ajaxResult =windturbineDetailPieChartAController.pieChart(wtid,"2021-01-02","1");
+//
+//        List<DataVo> test3=(List<DataVo>)ajaxResult.get("data");
+//
+//        for(DataVo wtd:test3)
+//        {
+//            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"));
+
+        System.out.println("***************************************************************************************");
+    }