Procházet zdrojové kódy

增加风速预测发电量接口

zghww před 3 roky
rodič
revize
52c1118354

+ 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;
+}

+ 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;
+	}
+
 }

+ 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