Переглянути джерело

增加气象历史数据接口

chenminghua 3 роки тому
батько
коміт
37e1942cc1

+ 20 - 7
src/main/java/com/gyee/frame/controller/weather/WeatherAnalysisController.java

@@ -1,26 +1,25 @@
 package com.gyee.frame.controller.weather;
 
+import com.github.pagehelper.PageInfo;
 import com.gyee.frame.common.conf.AjaxStatus;
 import com.gyee.frame.common.domain.AjaxResult;
+import com.gyee.frame.model.auto.Weatherfd;
 import com.gyee.frame.model.custom.DataVo;
+import com.gyee.frame.model.custom.Tablepar;
 import com.gyee.frame.service.weather.WeatherService;
 import com.gyee.frame.service.websocket.GenreSetPushService;
 import com.gyee.frame.service.websocket.RealPowerPushService;
+import com.gyee.frame.util.DateUtils;
 import com.gyee.frame.util.StringUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 @Controller
 @RequestMapping("/weather")
@@ -109,4 +108,18 @@ public class WeatherAnalysisController {
 
     }
 
+
+    @GetMapping("/history/list")
+    @ResponseBody
+    @ApiOperation(value = "气象历史数据查询", notes = "气象历史数据查询")
+    public AjaxResult getWeatherHistory(Tablepar tablepar,
+                                        @RequestParam("wpId") String wpId,
+                                        @RequestParam("startTs") String startTs,
+                                        @RequestParam("endTs") String endTs){
+        Date begin = DateUtils.parseDate(startTs);
+        Date end = DateUtils.parseDate(endTs);
+        PageInfo<Weatherfd> list = weatherService.getWeatherHistory(tablepar, wpId, begin, end);
+        return AjaxResult.successData(AjaxStatus.success.code, list);
+    }
+
 }

+ 30 - 7
src/main/java/com/gyee/frame/service/weather/WeatherService.java

@@ -2,21 +2,23 @@ package com.gyee.frame.service.weather;
 
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.TypeReference;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import com.gyee.frame.common.cache.RedisUtils;
 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.mapper.auto.WeatherfdMapper;
+import com.gyee.frame.model.auto.*;
+import com.gyee.frame.model.custom.Tablepar;
 import com.gyee.frame.model.custom.weather.*;
+import com.gyee.frame.service.WeatherfdService;
 import com.gyee.frame.util.MathUtil;
 import com.gyee.frame.util.StringUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
+import java.util.List;
 
 
 @Service
@@ -25,6 +27,8 @@ public class WeatherService  {
 	private final Integer DATABASE=2;
 	@Resource
 	private RedisUtils redisUtils;
+	@Resource
+	private WeatherfdService weatherfdService;
 
 	public Map<String,Object> getWeatherRealInfo(String id)
 	{
@@ -271,5 +275,24 @@ public class WeatherService  {
 		return  map;
 	}
 
-
+	/**
+	 * 分页查询气象历史数据
+	 * @param wpId
+	 * @param startTs
+	 * @param endTs
+	 * @return
+	 */
+	public PageInfo<Weatherfd> getWeatherHistory(Tablepar tablepar, String wpId, Date startTs, Date endTs){
+
+		WeatherfdExample example = new WeatherfdExample();
+		example.createCriteria().andWindpowerstationidEqualTo(wpId)
+								.andRecodedataBetween(startTs, endTs);
+		example.setOrderByClause("recodedata DESC");
+
+		PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
+		List<Weatherfd> list = weatherfdService.selectByExample(example);
+		PageInfo<Weatherfd> pageInfo = new PageInfo<>(list);
+
+		return pageInfo;
+	}
 }