浏览代码

Merge remote-tracking branch 'origin/master'

wangchangsheng 3 年之前
父节点
当前提交
53b0735077

+ 2 - 1
src/main/java/com/gyee/frame/common/exception/GlobalExceptionResolver.java

@@ -2,6 +2,7 @@ package com.gyee.frame.common.exception;
 
 import javax.servlet.http.HttpServletRequest;
 
+import com.gyee.frame.model.custom.weather.Sys;
 import org.apache.shiro.authz.AuthorizationException;
 import org.apache.shiro.authz.UnauthenticatedException;
 import org.apache.shiro.authz.UnauthorizedException;
@@ -127,7 +128,7 @@ public class GlobalExceptionResolver{
     public AjaxResult qiniuException(QiNiuException e)
     {
         logger.error(e.getMessage());
-        return AjaxResult.error(e.getCode(), e.getMessage());
+        return AjaxResult.error(e.getCode(), e.getMsg());
     }
 
 

+ 77 - 0
src/main/java/com/gyee/frame/controller/monitor/PredictionController.java

@@ -0,0 +1,77 @@
+package com.gyee.frame.controller.monitor;
+
+import com.gyee.frame.common.conf.AjaxStatus;
+import com.gyee.frame.common.domain.AjaxResult;
+import com.gyee.frame.model.auto.Forecastwindspeed;
+import com.gyee.frame.model.auto.ForecastwindspeedLongid;
+import com.gyee.frame.model.auto.Weatherfd;
+import com.gyee.frame.service.ForecastwindspeedService;
+import com.gyee.frame.service.WeatherfdService;
+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.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.net.CacheRequest;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+@RestController
+@RequestMapping("/decision")
+public class PredictionController {
+    @Autowired
+    private WeatherfdService weatherfdService;
+    @Autowired
+    private ForecastwindspeedService forecastwindspeedService;
+    @GetMapping("/ycfsdl/{nianyue}")
+    public AjaxResult ycfsdc(@PathVariable long nianyue) {
+        Map<String, Date> map = timeInMillisToDate(nianyue);
+        if(map==null) return AjaxResult.error("时间错误!");
+        List<Weatherfd> wrd = weatherfdService.findWeatherfdRemoveDuplicates(map.get("StartDate"), map.get("EndDate"));
+        List<ForecastwindspeedLongid> byTime = forecastwindspeedService.findByTime("forecastwindspeed",map.get("StartDate"), map.get("EndDate"));
+        Map<String, Object> mapObj = new HashMap<>();
+        mapObj.put("Weatherfd", wrd);
+        mapObj.put("Forecastwindspeed", byTime);
+        return AjaxResult.successData(AjaxStatus.success.code, mapObj);
+    }
+    @GetMapping("/ycfsdlxz/{nianyue}")
+    public AjaxResult ycfsdcxz(@PathVariable long nianyue) {
+        Map<String, Date> map = timeInMillisToDate(nianyue);
+        if(map==null) return AjaxResult.error("时间错误!");
+        List<Weatherfd> wrd = weatherfdService.findWeatherfdRemoveDuplicates(map.get("StartDate"), map.get("EndDate"));
+        List<ForecastwindspeedLongid> byTime = forecastwindspeedService.findByTime("forecastwindspeedamended",map.get("StartDate"), map.get("EndDate"));
+        Map<String, Object> mapObj = new HashMap<>();
+        mapObj.put("Weatherfd", wrd);
+        mapObj.put("Forecastwindspeed", byTime);
+        return AjaxResult.successData(AjaxStatus.success.code, mapObj);
+    }
+    @GetMapping("/ycfsdlnh/{nianyue}")
+    public AjaxResult ycfsdcnh(@PathVariable long nianyue) {
+        Map<String, Date> map = timeInMillisToDate(nianyue);
+        if(map==null) return AjaxResult.error("时间错误!");
+        List<Weatherfd> wrd = weatherfdService.findWeatherfdRemoveDuplicates(map.get("StartDate"), map.get("EndDate"));
+        List<ForecastwindspeedLongid> byTime = forecastwindspeedService.findByTime("forecastwindspeedfitting",map.get("StartDate"), map.get("EndDate"));
+        Map<String, Object> mapObj = new HashMap<>();
+        mapObj.put("Weatherfd", wrd);
+        mapObj.put("Forecastwindspeed", byTime);
+        return AjaxResult.successData(AjaxStatus.success.code, mapObj);
+    }
+    private Map<String,Date> timeInMillisToDate(long tim){
+        if (tim == 0.0) return null;
+        Map<String, Date> map = new HashMap<>();
+        Calendar c= Calendar.getInstance();
+        c.setTimeInMillis(tim);
+        c.set(c.get(Calendar.YEAR),c.get(Calendar.MONTH)+1,1,0,0,0);
+        Date startTime=c.getTime();
+
+        c.add(Calendar.MONTH,1);
+        c.add(Calendar.DATE,-1);
+        Date endTime=c.getTime();
+
+        map.put("StartDate", startTime);
+        map.put("EndDate", endTime);
+        return map;
+    }
+}

+ 4 - 1
src/main/java/com/gyee/frame/mapper/auto/ForecastwindspeedMapper.java

@@ -2,8 +2,10 @@ package com.gyee.frame.mapper.auto;
 
 import com.gyee.frame.model.auto.Forecastwindspeed;
 import com.gyee.frame.model.auto.ForecastwindspeedExample;
+import com.gyee.frame.model.auto.ForecastwindspeedLongid;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.Date;
 import java.util.List;
 
 public interface ForecastwindspeedMapper {
@@ -53,8 +55,9 @@ public interface ForecastwindspeedMapper {
      *
      * @mbg.generated
      */
-    List<Forecastwindspeed> selectByExample(ForecastwindspeedExample example);
+    List<ForecastwindspeedLongid> selectByExample(ForecastwindspeedExample example);
 
+    List<ForecastwindspeedLongid> selectByMonth(@Param("tablename") String tn, @Param("starttime") Date st,@Param("endtime") Date et);
     /**
      * This method was generated by MyBatis Generator.
      * This method corresponds to the database table FORECASTWINDSPEED

+ 5 - 0
src/main/java/com/gyee/frame/mapper/auto/WeatherfdMapper.java

@@ -2,6 +2,8 @@ package com.gyee.frame.mapper.auto;
 
 import com.gyee.frame.model.auto.Weatherfd;
 import com.gyee.frame.model.auto.WeatherfdExample;
+
+import java.util.Date;
 import java.util.List;
 import org.apache.ibatis.annotations.Param;
 
@@ -62,6 +64,9 @@ public interface WeatherfdMapper {
      */
     Weatherfd selectByPrimaryKey(String id);
 
+
+    List<Weatherfd> selectByMonth(@Param("starttime") Date startTime,@Param("endtime") Date endTime);
+
     /**
      * This method was generated by MyBatis Generator.
      * This method corresponds to the database table WEATHERFD

+ 21 - 0
src/main/java/com/gyee/frame/model/auto/ForecastwindspeedLongid.java

@@ -0,0 +1,21 @@
+package com.gyee.frame.model.auto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+@Data
+public class ForecastwindspeedLongid implements Serializable {
+    private Long id;
+    private String wpid;
+    private String wpname;
+    private Date recodedate;
+    private Double dayspeed;
+    private Double daypower;
+    private Double nightspeed;
+    private Double nightpower;
+    private String pjid;
+    private String pjname;
+    private Date createdate;
+    private static final long serialVersionUID = 1L;
+}

+ 2 - 1
src/main/java/com/gyee/frame/schdule/weather/TaskWeatherGather.java

@@ -42,7 +42,8 @@ public class TaskWeatherGather {
     /**
      * 延时1分钟  每天凌晨1点执行一次
      */
-    @Scheduled(initialDelay = 60 * 1000, cron = "0 0 1 * * ")
+//    @Scheduled(initialDelay = 60 * 1000, cron = "0 0 1 * * ")
+    @Scheduled(initialDelay = 30 * 1000, fixedRate = 2 * 86400 * 1000)
     public void gatherTask() {
         for (int key : wp_map.keySet()) {
             String[] value = wp_map.get(key).split("#");

+ 15 - 4
src/main/java/com/gyee/frame/service/ForecastwindspeedService.java

@@ -1,10 +1,8 @@
 package com.gyee.frame.service;
 
 import com.gyee.frame.common.spring.InitialRunner;
-import com.gyee.frame.model.auto.Line;
-import com.gyee.frame.model.auto.Project;
-import com.gyee.frame.model.auto.Windpowerstation;
-import com.gyee.frame.model.auto.Windturbine;
+import com.gyee.frame.mapper.auto.ForecastwindspeedMapper;
+import com.gyee.frame.model.auto.*;
 import com.gyee.frame.model.custom.DataVo;
 import com.gyee.frame.service.weather.WeatherDay5Service;
 import com.gyee.frame.util.DateUtils;
@@ -19,6 +17,8 @@ import java.util.*;
 @Service
 public class ForecastwindspeedService  {
 	@Resource
+	private ForecastwindspeedMapper forecastwindspeedMapper;
+	@Resource
 	private WeatherDay5Service weatherDay5Service;
 	@Resource
 	private PowerToPowerService powerToPowerService;
@@ -295,4 +295,15 @@ public class ForecastwindspeedService  {
 		return vos;
 	}
 
+	/**
+	 * @param s 拟合fitting,修正amended,无null
+	 */
+	public List<ForecastwindspeedLongid> findByTime(String s,Date beginDate,Date endDate){
+		List<ForecastwindspeedLongid> list = new ArrayList<>();
+		if(StringUtils.notEmp(beginDate)&&StringUtils.notEmp(endDate)){
+			list = forecastwindspeedMapper.selectByMonth(s,beginDate,endDate);
+		}
+		return list;
+	}
+
 }

+ 13 - 0
src/main/java/com/gyee/frame/service/WeatherfdService.java

@@ -116,4 +116,17 @@ public class WeatherfdService implements BaseService<Weatherfd, WeatherfdExample
 		return list;
 
 	}
+
+	public List<Weatherfd> findWeatherfdRemoveDuplicates(Date beginDate, Date endDate) {
+
+		List<Weatherfd> list=new ArrayList<>();
+
+		if (StringUtils.notEmp(beginDate) && StringUtils.notEmp(endDate)) {
+
+			list= weatherfdMapper.selectByMonth(beginDate,endDate);
+
+		}
+		return list;
+	}
+
 }

+ 250 - 244
src/main/java/com/gyee/frame/service/singleanalysis/SingleAnalysisService.java

@@ -1,5 +1,7 @@
 package com.gyee.frame.service.singleanalysis;
 
+import com.gyee.frame.common.exception.QiNiuException;
+import com.gyee.frame.common.exception.enums.QiNiuErrorEnum;
 import com.gyee.frame.common.spring.InitialRunner;
 import com.gyee.frame.model.auto.*;
 import com.gyee.frame.model.custom.SingleAnalysisVo;
@@ -36,285 +38,289 @@ public class SingleAnalysisService {
 
         List<SingleAnalysisVo> vos = new ArrayList<>();
 
-        if (StringUtils.notEmp(wpId) && StringUtils.notEmp(beginDate) && StringUtils.notEmp(endDate)) {
+        try{
+            if (StringUtils.notEmp(wpId) && StringUtils.notEmp(beginDate) && StringUtils.notEmp(endDate)) {
 
-            Map<String, SingleAnalysisVo> iomap = getInputoroutputspeedtotalMap(wpId, beginDate, endDate);
-            Map<String, SingleAnalysisVo> wtdaymap = getWindturbineinfodayMap(wpId, beginDate, endDate);
-            Map<String, SingleAnalysisVo> wtday2map = getWindturbineinfoday2Map(wpId, beginDate, endDate);
-            Map<String, SingleAnalysisVo> wtday3map = getWindturbineinfoday3Map(wpId, beginDate, endDate);
+                Map<String, SingleAnalysisVo> iomap = getInputoroutputspeedtotalMap(wpId, beginDate, endDate);
+                Map<String, SingleAnalysisVo> wtdaymap = getWindturbineinfodayMap(wpId, beginDate, endDate);
+                Map<String, SingleAnalysisVo> wtday2map = getWindturbineinfoday2Map(wpId, beginDate, endDate);
+                Map<String, SingleAnalysisVo> wtday3map = getWindturbineinfoday3Map(wpId, beginDate, endDate);
 
 
-            if (InitialRunner.wp_wtmap.containsKey(wpId)) {
-                List<Windturbine> wtls = InitialRunner.wp_wtmap.get(wpId);
+                if (InitialRunner.wp_wtmap.containsKey(wpId)) {
+                    List<Windturbine> wtls = InitialRunner.wp_wtmap.get(wpId);
 
-                for (Windturbine wt : wtls) {
-                    SingleAnalysisVo vo = new SingleAnalysisVo();
-                    vo.setWindPowerStationId(wt.getWindpowerstationid());
-                    vo.setWindturbineName(wt.getName());
-                    if (InitialRunner.wpmap.containsKey(wt.getWindpowerstationid())) {
-                        Windpowerstation wp = InitialRunner.wpmap.get(wt.getWindpowerstationid());
-                        vo.setWindPowerStationName(wp.getName());
-                    }
+                    for (Windturbine wt : wtls) {
+                        SingleAnalysisVo vo = new SingleAnalysisVo();
+                        vo.setWindPowerStationId(wt.getWindpowerstationid());
+                        vo.setWindturbineName(wt.getName());
+                        if (InitialRunner.wpmap.containsKey(wt.getWindpowerstationid())) {
+                            Windpowerstation wp = InitialRunner.wpmap.get(wt.getWindpowerstationid());
+                            vo.setWindPowerStationName(wp.getName());
+                        }
 
-                    if (InitialRunner.mlmap.containsKey(wt.getModelid())) {
-                        Equipmentmodel model = InitialRunner.mlmap.get(wt.getModelid());
-                        vo.setFjrl(model.getPowerproduction());
-                    }
+                        if (InitialRunner.mlmap.containsKey(wt.getModelid())) {
+                            Equipmentmodel model = InitialRunner.mlmap.get(wt.getModelid());
+                            vo.setFjrl(model.getPowerproduction());
+                        }
 
 
-                    vo.setWindturbineid(wt.getId());
+                        vo.setWindturbineid(wt.getId());
 
 //                        double swdl=wpls.stream().mapToDouble(Windpowerinfoday::getGridelectricity).sum();//风场上网电量合计
 //                        double gwdl=wpls.stream().mapToDouble(Windpowerinfoday::getBuyelectricity).sum();//风场购网电量合计
 //
 //                        vo.setSwdl(swdl);
 //                        vo.setGwdl(gwdl);
-                    double fdl = 0;
-                    if (wtdaymap.containsKey(wt.getId())) {
-                        SingleAnalysisVo wtd = wtdaymap.get(wt.getId());
-
-                        fdl = null != wtd.getFdl() ? wtd.getFdl() : 0.0;//风机发电量合计
-                        fdl = new BigDecimal(fdl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_UP).doubleValue();
-
-                        double yxxs = null != wtd.getYxxs() ? wtd.getYxxs() : 0.0;//风机运行小时合计
-                        double gzxs = null != wtd.getGzxs() ? wtd.getGzxs() : 0.0;//风机故障小时合计
-                        double jxxs = null != wtd.getJxxs() ? wtd.getJxxs() : 0.0;//风机检修小时合计
-                        double tjxs = null != wtd.getTjxs() ? wtd.getTjxs() : 0.0;//风机停机小时合计
-                        double zdxs = null != wtd.getZdxs() ? wtd.getZdxs() : 0.0;//风机中断小时合计
-                        double rlxs = null != wtd.getRlxs() ? wtd.getRlxs() : 0.0;//风机日历小时合计
-                        double fs = null != wtd.getFs() ? wtd.getFs() : 0.0;//风机平均风速
-                        double sbklyl = null != wtd.getSbklyl() ? wtd.getSbklyl() : 0.0;//风机平均设备可利用率
-                        double dxklyxs = null != wtd.getDxklyxs() ? wtd.getDxklyxs() : 0.0;//风机平均等效可利用系数
-                        double lyxs = null != wtd.getLyxs() ? wtd.getLyxs() : 0.0;//风机平均利用小时
-                        double yxfss = null != wtd.getYxfss() ? wtd.getYxfss() : 0.0;//风机平均有效风时速
-
-
-                        vo.setFdl(StringUtils.round(fdl, 2));
-                        vo.setYxxs(StringUtils.round(yxxs, 2));
-                        vo.setGzxs(StringUtils.round(gzxs, 2));
-                        vo.setJxxs(StringUtils.round(jxxs, 2));
-                        vo.setTjxs(StringUtils.round(tjxs, 2));
-                        vo.setZdxs(StringUtils.round(zdxs, 2));
-                        vo.setRlxs(StringUtils.round(rlxs, 2));
-                        vo.setFs(StringUtils.round(fs, 2));
-                        vo.setSbklyl(StringUtils.round(sbklyl, 2));
-                        vo.setDxklyxs(StringUtils.round(dxklyxs, 2));
-                        vo.setLyxs(StringUtils.round(lyxs, 2));
-                        vo.setYxxs(StringUtils.round(yxfss, 2));
-
+                        double fdl = 0;
+                        if (wtdaymap.containsKey(wt.getId())) {
+                            SingleAnalysisVo wtd = wtdaymap.get(wt.getId());
+
+                            fdl = null != wtd.getFdl() ? wtd.getFdl() : 0.0;//风机发电量合计
+                            fdl = new BigDecimal(fdl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_UP).doubleValue();
+
+                            double yxxs = null != wtd.getYxxs() ? wtd.getYxxs() : 0.0;//风机运行小时合计
+                            double gzxs = null != wtd.getGzxs() ? wtd.getGzxs() : 0.0;//风机故障小时合计
+                            double jxxs = null != wtd.getJxxs() ? wtd.getJxxs() : 0.0;//风机检修小时合计
+                            double tjxs = null != wtd.getTjxs() ? wtd.getTjxs() : 0.0;//风机停机小时合计
+                            double zdxs = null != wtd.getZdxs() ? wtd.getZdxs() : 0.0;//风机中断小时合计
+                            double rlxs = null != wtd.getRlxs() ? wtd.getRlxs() : 0.0;//风机日历小时合计
+                            double fs = null != wtd.getFs() ? wtd.getFs() : 0.0;//风机平均风速
+                            double sbklyl = null != wtd.getSbklyl() ? wtd.getSbklyl() : 0.0;//风机平均设备可利用率
+                            double dxklyxs = null != wtd.getDxklyxs() ? wtd.getDxklyxs() : 0.0;//风机平均等效可利用系数
+                            double lyxs = null != wtd.getLyxs() ? wtd.getLyxs() : 0.0;//风机平均利用小时
+                            double yxfss = null != wtd.getYxfss() ? wtd.getYxfss() : 0.0;//风机平均有效风时速
+
+
+                            vo.setFdl(StringUtils.round(fdl, 2));
+                            vo.setYxxs(StringUtils.round(yxxs, 2));
+                            vo.setGzxs(StringUtils.round(gzxs, 2));
+                            vo.setJxxs(StringUtils.round(jxxs, 2));
+                            vo.setTjxs(StringUtils.round(tjxs, 2));
+                            vo.setZdxs(StringUtils.round(zdxs, 2));
+                            vo.setRlxs(StringUtils.round(rlxs, 2));
+                            vo.setFs(StringUtils.round(fs, 2));
+                            vo.setSbklyl(StringUtils.round(sbklyl, 2));
+                            vo.setDxklyxs(StringUtils.round(dxklyxs, 2));
+                            vo.setLyxs(StringUtils.round(lyxs, 2));
+                            vo.setYxxs(StringUtils.round(yxfss, 2));
+
+                        }
+
+                        if (wtday2map.containsKey(wt.getId())) {
+                            SingleAnalysisVo wtd = wtday2map.get(wt.getId());
+
+                            double glyzxxs = null != wtd.getGlyzxxs() ? wtd.getGlyzxxs() : 0.0;//风机平均功率一致性系数
+                            vo.setGlyzxxs(StringUtils.round(glyzxxs, 2));
+                        }
+
+                        if (wtday3map.containsKey(wt.getId())) {
+                            SingleAnalysisVo wtd = wtday3map.get(wt.getId());
+
+                            double gzss = null != wtd.getGzss() ? wtd.getGzss() : 0.0;//风机故障损失合计
+                            double jxss = null != wtd.getJxss() ? wtd.getJxss() : 0.0;//风机检修损失合计
+                            double xdss = null != wtd.getXdss() ? wtd.getXdss() : 0.0;//风机限电损失合计
+                            double xnss = null != wtd.getXnss() ? wtd.getXnss() : 0.0;//风机性能损失时合计
+                            double slss = null != wtd.getSlss() ? wtd.getSlss() : 0.0;//风机受累损失合计
+
+
+                            double llfdl = fdl + gzss + jxss + xdss + xnss + slss;
+
+                            vo.setGzss(StringUtils.round(gzss,2));
+                            vo.setJxss(StringUtils.round(jxss,2));
+                            vo.setXdss(StringUtils.round(xdss,2));
+                            vo.setXnss(StringUtils.round(xnss,2));
+                            vo.setSlss(StringUtils.round(xnss,2));
+
+                            vo.setLlfdl(StringUtils.round(llfdl, 2));
+                        }
+
+                        if (iomap.containsKey(wt.getId())) {
+                            SingleAnalysisVo wtd = iomap.get(wt.getId());
+
+                            double xfqr = null != wtd.getXfqr() ? wtd.getXfqr() : 0.0;//风机小风切入
+                            double xfqrhgl = null != wtd.getXfqrhgl() ? wtd.getXfqrhgl() : 0.0;//风机小风切入合格率
+                            vo.setXfqr(StringUtils.round(xfqr, 2));
+                            vo.setXfqrhgl(StringUtils.round(xfqrhgl, 2));
+                        }
+                        vos.add(vo);
                     }
 
-                    if (wtday2map.containsKey(wt.getId())) {
-                        SingleAnalysisVo wtd = wtday2map.get(wt.getId());
+                }
+            }
 
-                        double glyzxxs = null != wtd.getGlyzxxs() ? wtd.getGlyzxxs() : 0.0;//风机平均功率一致性系数
-                        vo.setGlyzxxs(StringUtils.round(glyzxxs, 2));
+            if (null != vos && !vos.isEmpty()) {
+
+                //统计所有风机指标数据
+                SingleAnalysisVo vo = new SingleAnalysisVo();
+                vo.setWindturbineName("合计");
+                List<Windpowerinfoday> wpls = windpowerinfodayService.getWindpowerinfodayList(wpId, beginDate, endDate);
+                double swdl = wpls.stream().mapToDouble(Windpowerinfoday::getGridelectricity).sum();//风场上网电量合计
+                double gwdl = wpls.stream().mapToDouble(Windpowerinfoday::getBuyelectricity).sum();//风场购网电量合计
+                vo.setSwdl(StringUtils.round(swdl, 2));
+                vo.setGwdl(StringUtils.round(gwdl, 2));
+
+                double fdl = 0.0;//风机发电量合计
+                double yxxs = 0.0;//风机运行小时合计
+                double gzxs = 0.0;//风机故障小时合计
+                double jxxs = 0.0;//风机检修小时合计
+                double tjxs = 0.0;//风机停机小时合计
+                double zdxs = 0.0;//风机中断小时合计
+                double rlxs = 0.0;//风机日历小时合计
+
+                double fs = 0.0;//风机平均风速
+                double sbklyl = 0.0;//风机平均设备可利用率
+                double dxklyxs = 0.0;//风机平均等效可利用系数
+                double lyxs = 0.0;//风机平均利用小时
+                double yxfss = 0.0;//风机平均有效风时速
+                double glyzxxs = 0.0;//风机平均功率一致性系数
+
+                double xfqr = 0.0;//风机小风切入
+                double xfqrhgl = 0.0;//风机小风切入合格率
+
+                int xfqrnum = 0;
+                int xfqrhglnum = 0;
+
+                int fsnum = 0;
+                int sbklylnum = 0;
+                int dxklyxsnum = 0;
+                int lyxsnum = 0;
+                int yxfssnum = 0;
+                int glyzxxsnum = 0;
+
+                for (SingleAnalysisVo wtd : vos) {
+                    double temp = null != wtd.getFdl() ? wtd.getFdl() : 0.0;//风机发电量合计
+                    fdl = fdl + temp;
+                    temp = null != wtd.getYxxs() ? wtd.getYxxs() : 0.0;//风机运行小时合计
+                    yxxs = yxxs + temp;
+                    temp = null != wtd.getGzxs() ? wtd.getGzxs() : 0.0;//风机故障小时合计
+                    gzxs = gzxs + temp;
+                    temp = null != wtd.getJxxs() ? wtd.getJxxs() : 0.0;//风机检修小时合计
+                    jxxs = jxxs + temp;
+                    temp = null != wtd.getTjxs() ? wtd.getTjxs() : 0.0;//风机停机小时合计
+                    tjxs = tjxs + temp;
+                    temp = null != wtd.getZdxs() ? wtd.getZdxs() : 0.0;//风机中断小时合计
+                    zdxs = zdxs + temp;
+                    temp = null != wtd.getRlxs() ? wtd.getRlxs() : 0.0;//风机日历小时合计
+                    rlxs = rlxs + temp;
+
+                    temp = null != wtd.getFs() ? wtd.getFs() : 0.0;//风机平均风速
+                    fs = fs + temp;
+                    if (StringUtils.notEmp(wtd.getFs())) {
+                        fsnum++;
                     }
-
-                    if (wtday3map.containsKey(wt.getId())) {
-                        SingleAnalysisVo wtd = wtday3map.get(wt.getId());
-
-                        double gzss = null != wtd.getGzss() ? wtd.getGzss() : 0.0;//风机故障损失合计
-                        double jxss = null != wtd.getJxss() ? wtd.getJxss() : 0.0;//风机检修损失合计
-                        double xdss = null != wtd.getXdss() ? wtd.getXdss() : 0.0;//风机限电损失合计
-                        double xnss = null != wtd.getXnss() ? wtd.getXnss() : 0.0;//风机性能损失时合计
-                        double slss = null != wtd.getSlss() ? wtd.getSlss() : 0.0;//风机受累损失合计
-
-
-                        double llfdl = fdl + gzss + jxss + xdss + xnss + slss;
-
-                        vo.setGzss(StringUtils.round(gzss,2));
-                        vo.setJxss(StringUtils.round(jxss,2));
-                        vo.setXdss(StringUtils.round(xdss,2));
-                        vo.setXnss(StringUtils.round(xnss,2));
-                        vo.setSlss(StringUtils.round(xnss,2));
-
-                        vo.setLlfdl(StringUtils.round(llfdl, 2));
+                    temp = null != wtd.getSbklyl() ? wtd.getSbklyl() : 0.0;//风机平均设备可利用率
+                    sbklyl = sbklyl + temp;
+                    if (StringUtils.notEmp(wtd.getSbklyl())) {
+                        sbklylnum++;
+                    }
+                    temp = null != wtd.getDxklyxs() ? wtd.getDxklyxs() : 0.0;//风机平均等效可利用系数
+                    dxklyxs = dxklyxs + temp;
+                    if (StringUtils.notEmp(wtd.getDxklyxs())) {
+                        dxklyxsnum++;
+                    }
+                    temp = null != wtd.getLyxs() ? wtd.getLyxs() : 0.0;//风机平均利用小时
+                    lyxs = lyxs + temp;
+                    if (StringUtils.notEmp(wtd.getLyxs())) {
+                        lyxsnum++;
+                    }
+                    temp = null != wtd.getYxfss() ? wtd.getYxfss() : 0.0;//风机平均有效风时速
+                    yxfss = yxfss + temp;
+                    if (StringUtils.notEmp(wtd.getYxfss())) {
+                        yxfssnum++;
+                    }
+                    temp = null != wtd.getGlyzxxs() ? wtd.getGlyzxxs() : 0.0;//风机平均功率一致性系数
+                    glyzxxs = glyzxxs + temp;
+                    if (StringUtils.notEmp(wtd.getGlyzxxs())) {
+                        glyzxxsnum++;
                     }
 
-                    if (iomap.containsKey(wt.getId())) {
-                        SingleAnalysisVo wtd = iomap.get(wt.getId());
-
-                        double xfqr = null != wtd.getXfqr() ? wtd.getXfqr() : 0.0;//风机小风切入
-                        double xfqrhgl = null != wtd.getXfqrhgl() ? wtd.getXfqrhgl() : 0.0;//风机小风切入合格率
-                        vo.setXfqr(StringUtils.round(xfqr, 2));
-                        vo.setXfqrhgl(StringUtils.round(xfqrhgl, 2));
+                    temp = null != wtd.getXfqr() ? wtd.getXfqr() : 0.0;//风机小风切入
+                    xfqr = xfqr + temp;
+                    if (StringUtils.notEmp(wtd.getXfqr())) {
+                        xfqrnum++;
+                    }
+                    temp = null != wtd.getXfqrhgl() ? wtd.getXfqrhgl() : 0.0;//风机小风切入合格率
+                    xfqrhgl = xfqrhgl + temp;
+                    if (StringUtils.notEmp(wtd.getXfqrhgl())) {
+                        xfqrhglnum++;
                     }
-                    vos.add(vo);
                 }
 
-            }
-        }
-
-        if (null != vos && !vos.isEmpty()) {
-
-            //统计所有风机指标数据
-            SingleAnalysisVo vo = new SingleAnalysisVo();
-            vo.setWindturbineName("合计");
-            List<Windpowerinfoday> wpls = windpowerinfodayService.getWindpowerinfodayList(wpId, beginDate, endDate);
-            double swdl = wpls.stream().mapToDouble(Windpowerinfoday::getGridelectricity).sum();//风场上网电量合计
-            double gwdl = wpls.stream().mapToDouble(Windpowerinfoday::getBuyelectricity).sum();//风场购网电量合计
-            vo.setSwdl(StringUtils.round(swdl, 2));
-            vo.setGwdl(StringUtils.round(gwdl, 2));
-
-            double fdl = 0.0;//风机发电量合计
-            double yxxs = 0.0;//风机运行小时合计
-            double gzxs = 0.0;//风机故障小时合计
-            double jxxs = 0.0;//风机检修小时合计
-            double tjxs = 0.0;//风机停机小时合计
-            double zdxs = 0.0;//风机中断小时合计
-            double rlxs = 0.0;//风机日历小时合计
-
-            double fs = 0.0;//风机平均风速
-            double sbklyl = 0.0;//风机平均设备可利用率
-            double dxklyxs = 0.0;//风机平均等效可利用系数
-            double lyxs = 0.0;//风机平均利用小时
-            double yxfss = 0.0;//风机平均有效风时速
-            double glyzxxs = 0.0;//风机平均功率一致性系数
-
-            double xfqr = 0.0;//风机小风切入
-            double xfqrhgl = 0.0;//风机小风切入合格率
-
-            int xfqrnum = 0;
-            int xfqrhglnum = 0;
-
-            int fsnum = 0;
-            int sbklylnum = 0;
-            int dxklyxsnum = 0;
-            int lyxsnum = 0;
-            int yxfssnum = 0;
-            int glyzxxsnum = 0;
-
-            for (SingleAnalysisVo wtd : vos) {
-                double temp = null != wtd.getFdl() ? wtd.getFdl() : 0.0;//风机发电量合计
-                fdl = fdl + temp;
-                temp = null != wtd.getYxxs() ? wtd.getYxxs() : 0.0;//风机运行小时合计
-                yxxs = yxxs + temp;
-                temp = null != wtd.getGzxs() ? wtd.getGzxs() : 0.0;//风机故障小时合计
-                gzxs = gzxs + temp;
-                temp = null != wtd.getJxxs() ? wtd.getJxxs() : 0.0;//风机检修小时合计
-                jxxs = jxxs + temp;
-                temp = null != wtd.getTjxs() ? wtd.getTjxs() : 0.0;//风机停机小时合计
-                tjxs = tjxs + temp;
-                temp = null != wtd.getZdxs() ? wtd.getZdxs() : 0.0;//风机中断小时合计
-                zdxs = zdxs + temp;
-                temp = null != wtd.getRlxs() ? wtd.getRlxs() : 0.0;//风机日历小时合计
-                rlxs = rlxs + temp;
-
-                temp = null != wtd.getFs() ? wtd.getFs() : 0.0;//风机平均风速
-                fs = fs + temp;
-                if (StringUtils.notEmp(wtd.getFs())) {
-                    fsnum++;
-                }
-                temp = null != wtd.getSbklyl() ? wtd.getSbklyl() : 0.0;//风机平均设备可利用率
-                sbklyl = sbklyl + temp;
-                if (StringUtils.notEmp(wtd.getSbklyl())) {
-                    sbklylnum++;
-                }
-                temp = null != wtd.getDxklyxs() ? wtd.getDxklyxs() : 0.0;//风机平均等效可利用系数
-                dxklyxs = dxklyxs + temp;
-                if (StringUtils.notEmp(wtd.getDxklyxs())) {
-                    dxklyxsnum++;
-                }
-                temp = null != wtd.getLyxs() ? wtd.getLyxs() : 0.0;//风机平均利用小时
-                lyxs = lyxs + temp;
-                if (StringUtils.notEmp(wtd.getLyxs())) {
-                    lyxsnum++;
+                if (fsnum != 0) {
+                    double temp = new BigDecimal(fs).divide(new BigDecimal(fsnum), 2, RoundingMode.HALF_UP).doubleValue();
+                    vo.setFs(temp);
                 }
-                temp = null != wtd.getYxfss() ? wtd.getYxfss() : 0.0;//风机平均有效风时速
-                yxfss = yxfss + temp;
-                if (StringUtils.notEmp(wtd.getYxfss())) {
-                    yxfssnum++;
-                }
-                temp = null != wtd.getGlyzxxs() ? wtd.getGlyzxxs() : 0.0;//风机平均功率一致性系数
-                glyzxxs = glyzxxs + temp;
-                if (StringUtils.notEmp(wtd.getGlyzxxs())) {
-                    glyzxxsnum++;
+                if (sbklylnum != 0) {
+                    double temp = new BigDecimal(sbklyl).divide(new BigDecimal(sbklylnum), 2, RoundingMode.HALF_UP).doubleValue();
+                    vo.setSbklyl(temp);
                 }
 
-                temp = null != wtd.getXfqr() ? wtd.getXfqr() : 0.0;//风机小风切入
-                xfqr = xfqr + temp;
-                if (StringUtils.notEmp(wtd.getXfqr())) {
-                    xfqrnum++;
-                }
-                temp = null != wtd.getXfqrhgl() ? wtd.getXfqrhgl() : 0.0;//风机小风切入合格率
-                xfqrhgl = xfqrhgl + temp;
-                if (StringUtils.notEmp(wtd.getXfqrhgl())) {
-                    xfqrhglnum++;
+                if (dxklyxsnum != 0) {
+                    double temp = new BigDecimal(dxklyxs).divide(new BigDecimal(dxklyxsnum), 2, RoundingMode.HALF_UP).doubleValue();
+                    vo.setDxklyxs(temp);
                 }
-            }
 
-            if (fsnum != 0) {
-                double temp = new BigDecimal(fs).divide(new BigDecimal(fsnum), 2, RoundingMode.HALF_UP).doubleValue();
-                vo.setFs(temp);
-            }
-            if (sbklylnum != 0) {
-                double temp = new BigDecimal(sbklyl).divide(new BigDecimal(sbklylnum), 2, RoundingMode.HALF_UP).doubleValue();
-                vo.setSbklyl(temp);
-            }
-
-            if (dxklyxsnum != 0) {
-                double temp = new BigDecimal(dxklyxs).divide(new BigDecimal(dxklyxsnum), 2, RoundingMode.HALF_UP).doubleValue();
-                vo.setDxklyxs(temp);
-            }
-
-            if (lyxsnum != 0) {
-                double temp = new BigDecimal(lyxs).divide(new BigDecimal(lyxsnum), 2, RoundingMode.HALF_UP).doubleValue();
-                vo.setLyxs(temp);
-            }
-
-            if (yxfssnum != 0) {
-                double temp = new BigDecimal(yxfss).divide(new BigDecimal(yxfssnum), 2, RoundingMode.HALF_UP).doubleValue();
-                vo.setYxfss(temp);
-            }
-
-            if (glyzxxsnum != 0) {
-                double temp = new BigDecimal(glyzxxs).divide(new BigDecimal(glyzxxsnum), 2, RoundingMode.HALF_UP).doubleValue();
-                vo.setGlyzxxs(temp);
-            }
+                if (lyxsnum != 0) {
+                    double temp = new BigDecimal(lyxs).divide(new BigDecimal(lyxsnum), 2, RoundingMode.HALF_UP).doubleValue();
+                    vo.setLyxs(temp);
+                }
 
+                if (yxfssnum != 0) {
+                    double temp = new BigDecimal(yxfss).divide(new BigDecimal(yxfssnum), 2, RoundingMode.HALF_UP).doubleValue();
+                    vo.setYxfss(temp);
+                }
 
-            vo.setFdl(StringUtils.round(fdl, 2));
-            vo.setYxxs(StringUtils.round(yxxs, 2));
-            vo.setGzxs(StringUtils.round(gzxs, 2));
-            vo.setJxxs(StringUtils.round(jxxs, 2));
-            vo.setTjxs(StringUtils.round(tjxs, 2));
-            vo.setZdxs(StringUtils.round(zdxs, 2));
-            vo.setRlxs(StringUtils.round(rlxs, 2));
-            vo.setFs(StringUtils.round(fs, 2));
-            vo.setSbklyl(StringUtils.round(sbklyl, 2));
-            vo.setDxklyxs(StringUtils.round(dxklyxs, 2));
-            vo.setLyxs(StringUtils.round(lyxs, 2));
-            vo.setYxxs(StringUtils.round(yxfss, 2));
-            vo.setGlyzxxs(StringUtils.round(glyzxxs, 2));
+                if (glyzxxsnum != 0) {
+                    double temp = new BigDecimal(glyzxxs).divide(new BigDecimal(glyzxxsnum), 2, RoundingMode.HALF_UP).doubleValue();
+                    vo.setGlyzxxs(temp);
+                }
 
-            double gzss = vos.stream().mapToDouble(SingleAnalysisVo::getGzss).sum();//风机故障损失合计
-            double jxss = vos.stream().mapToDouble(SingleAnalysisVo::getJxss).sum();//风机检修损失合计
-            double xdss = vos.stream().mapToDouble(SingleAnalysisVo::getXdss).sum();//风机限电损失合计
-            double xnss = vos.stream().mapToDouble(SingleAnalysisVo::getXnss).sum();//风机性能损失时合计
-            double slss = vos.stream().mapToDouble(SingleAnalysisVo::getSlss).sum();//风机受累损失合计
-            double llfdl = fdl + gzss + jxss + xdss + xnss + slss;
 
-            vo.setGzss(StringUtils.round(gzss, 2));
-            vo.setJxss(StringUtils.round(jxss, 2));
-            vo.setXdss(StringUtils.round(xdss, 2));
-            vo.setXnss(StringUtils.round(xnss, 2));
-            vo.setSlss(StringUtils.round(slss, 2));
-            vo.setLlfdl(StringUtils.round(llfdl, 2));
+                vo.setFdl(StringUtils.round(fdl, 2));
+                vo.setYxxs(StringUtils.round(yxxs, 2));
+                vo.setGzxs(StringUtils.round(gzxs, 2));
+                vo.setJxxs(StringUtils.round(jxxs, 2));
+                vo.setTjxs(StringUtils.round(tjxs, 2));
+                vo.setZdxs(StringUtils.round(zdxs, 2));
+                vo.setRlxs(StringUtils.round(rlxs, 2));
+                vo.setFs(StringUtils.round(fs, 2));
+                vo.setSbklyl(StringUtils.round(sbklyl, 2));
+                vo.setDxklyxs(StringUtils.round(dxklyxs, 2));
+                vo.setLyxs(StringUtils.round(lyxs, 2));
+                vo.setYxxs(StringUtils.round(yxfss, 2));
+                vo.setGlyzxxs(StringUtils.round(glyzxxs, 2));
+
+                double gzss = vos.stream().mapToDouble(SingleAnalysisVo::getGzss).sum();//风机故障损失合计
+                double jxss = vos.stream().mapToDouble(SingleAnalysisVo::getJxss).sum();//风机检修损失合计
+                double xdss = vos.stream().mapToDouble(SingleAnalysisVo::getXdss).sum();//风机限电损失合计
+                double xnss = vos.stream().mapToDouble(SingleAnalysisVo::getXnss).sum();//风机性能损失时合计
+                double slss = vos.stream().mapToDouble(SingleAnalysisVo::getSlss).sum();//风机受累损失合计
+                double llfdl = fdl + gzss + jxss + xdss + xnss + slss;
+
+                vo.setGzss(StringUtils.round(gzss, 2));
+                vo.setJxss(StringUtils.round(jxss, 2));
+                vo.setXdss(StringUtils.round(xdss, 2));
+                vo.setXnss(StringUtils.round(xnss, 2));
+                vo.setSlss(StringUtils.round(slss, 2));
+                vo.setLlfdl(StringUtils.round(llfdl, 2));
+
+
+                if (xfqrnum != 0) {
+                    double temp = new BigDecimal(xfqr).divide(new BigDecimal(xfqrnum), 2, RoundingMode.HALF_UP).doubleValue();
+                    vo.setXfqr(temp);
+                }
 
+                if (xfqrhglnum != 0) {
+                    double temp = new BigDecimal(xfqrhgl).divide(new BigDecimal(xfqrhglnum), 2, RoundingMode.HALF_UP).doubleValue();
+                    vo.setXfqrhgl(temp);
+                }
 
-            if (xfqrnum != 0) {
-                double temp = new BigDecimal(xfqr).divide(new BigDecimal(xfqrnum), 2, RoundingMode.HALF_UP).doubleValue();
-                vo.setXfqr(temp);
-            }
 
-            if (xfqrhglnum != 0) {
-                double temp = new BigDecimal(xfqrhgl).divide(new BigDecimal(xfqrhglnum), 2, RoundingMode.HALF_UP).doubleValue();
-                vo.setXfqrhgl(temp);
+                vos.add(vo);
             }
-
-
-            vos.add(vo);
+        } catch (Exception e){
+            throw new QiNiuException(QiNiuErrorEnum.ERROR_DATA);
         }
 
         vos = sortSingleAnalysisVoList(tablepar, vos);

+ 9 - 0
src/main/resources/mybatis/auto/ForecastwindspeedMapper.xml

@@ -110,6 +110,15 @@
       order by ${orderByClause}
     </if>
   </select>
+  <select id="selectByMonth" resultType="com.gyee.frame.model.auto.ForecastwindspeedLongid">
+    select * from ${tablename}
+    <where>
+      <if test="starttime !=null and endtime !=null">
+        and recodedate &gt;= #{starttime,jdbcType=DATE} and recodedate &lt;= #{endtime,jdbcType=DATE}
+      </if>
+    </where>
+    order by recodedate
+  </select>
   <select id="selectByPrimaryKey" parameterType="java.lang.Short" resultMap="BaseResultMap">
     <!--
       WARNING - @mbg.generated

+ 12 - 0
src/main/resources/mybatis/auto/WeatherfdMapper.xml

@@ -107,6 +107,18 @@
     SPEED1, GUST1, WEATHER2, TEMPERATURE2, REALFEEL2, PRECIPITATION2, WINDDIRECTION2, 
     SPEED2, GUST2
   </sql>
+  
+  <select id="selectByMonth" resultType="com.gyee.frame.model.auto.Weatherfd">
+    select * from weatherfd
+    <where>
+      id in (SELECT MAX(ID) FROM weatherfd GROUP BY recodedata,windpowerstationid)
+      <if test="starttime !=null and endtime !=null">
+        and recodedata &gt;= #{starttime,jdbcType=DATE} and recodedata &lt;= #{endtime,jdbcType=DATE}
+      </if>
+        order by recodedata
+    </where>
+  </select>
+  
   <select id="selectByExample" parameterType="com.gyee.frame.model.auto.WeatherfdExample" resultMap="BaseResultMap">
     <!--
       WARNING - @mbg.generated