diff --git a/jpahefengweather/pom.xml b/jpahefengweather/pom.xml
index 1824715..385a3e2 100644
--- a/jpahefengweather/pom.xml
+++ b/jpahefengweather/pom.xml
@@ -49,18 +49,6 @@
1.18.20
true
-
-
- org.apache.logging.log4j
- log4j-api
- 2.17.1
-
-
-
- org.apache.logging.log4j
- log4j-core
- 2.17.1
-
org.apache.poi
@@ -92,36 +80,6 @@
annotations
19.0.0
-
- com.liuhuiyu
- util
- 2022.1.0
-
-
- com.liuhuiyu
- spring-util
- 2021.1.0
-
-
- com.liuhuiyu
- web
- 2022.1.0
-
-
- com.liuhuiyu
- jpa
- 2021.1.0
-
-
- com.liuhuiyu
- okhttp3util
- 2021.2.2
-
-
- com.liuhuiyu
- test
- 2021.1.0
-
javax.validation
validation-api
@@ -155,21 +113,31 @@
eddsa
0.3.0
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ commons-beanutils
+ commons-beanutils
+ 1.9.4
+
+
+ commons-collections
+ commons-collections
+
+
+
-
+
+
+
+ repository
+ http://47.242.184.139:8081/repository/maven-public/
+
+ true
+
+
+ true
+
+
+
${project.artifactId}
@@ -179,5 +147,4 @@
-
\ No newline at end of file
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/JpahefengweatherApplication.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/JpahefengweatherApplication.java
index 3e368b3..7e68684 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/JpahefengweatherApplication.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/JpahefengweatherApplication.java
@@ -1,10 +1,13 @@
package com.rehome.jpahefengweather;
+import org.springframework.beans.BeansException;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
@@ -14,7 +17,9 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableJpaAuditing
@EnableScheduling
@SpringBootApplication
-public class JpahefengweatherApplication extends SpringBootServletInitializer {
+public class JpahefengweatherApplication extends SpringBootServletInitializer implements ApplicationContextAware {
+
+ public static ApplicationContext context;
public static void main(String[] args) {
SpringApplication.run(JpahefengweatherApplication.class, args);
@@ -30,4 +35,9 @@ public class JpahefengweatherApplication extends SpringBootServletInitializer {
SpringApplicationBuilder builder) {
return builder.sources(JpahefengweatherApplication.class);
}
+
+ @Override
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ context = applicationContext;
+ }
}
\ No newline at end of file
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/controller/WeatherController.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/controller/HefengWeatherController.java
similarity index 52%
rename from jpahefengweather/src/main/java/com/rehome/jpahefengweather/controller/WeatherController.java
rename to jpahefengweather/src/main/java/com/rehome/jpahefengweather/controller/HefengWeatherController.java
index 05bc63a..de2f281 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/controller/WeatherController.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/controller/HefengWeatherController.java
@@ -1,32 +1,30 @@
package com.rehome.jpahefengweather.controller;
-import com.liuhuiyu.util.model.Result;
-import com.rehome.jpahefengweather.dto.BaseFindDto;
-import com.rehome.jpahefengweather.dto.BaseWeatherFindDto;
-import com.rehome.jpahefengweather.dto.ForecastWeatherDto;
-import com.rehome.jpahefengweather.dto.NowWeatherDto;
+import com.rehome.jpahefengweather.dto.*;
import com.rehome.jpahefengweather.entity.HefengCity;
import com.rehome.jpahefengweather.entity.NowWeather;
import com.rehome.jpahefengweather.service.CityService;
-import com.rehome.jpahefengweather.service.WeatherService;
+import com.rehome.jpahefengweather.service.HefengWeatherService;
+import com.rehome.jpahefengweather.utils.Result;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
-
import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
+import java.util.Date;
import java.util.List;
@RestController
-@RequestMapping("/weather")
-public class WeatherController {
+@RequestMapping("/hefengWeather/service")
+public class HefengWeatherController {
@Resource
private CityService cityService;
@Resource
- private WeatherService weatherService;
+ private HefengWeatherService hefengWeatherService;
/**
* @date 2022-05-01 14:42
@@ -45,7 +43,7 @@ public class WeatherController {
@ApiImplicitParam(name = "dto", value = "获取历史天气处理", dataTypeClass = BaseWeatherFindDto.class, paramType = "body", required = true),
})
public Result> getNowWeatherEntity(@Validated @RequestBody BaseWeatherFindDto dto){
- List weathers = this.weatherService.findNowWeatherByLocationIdAndDate(dto.getLocationId(),dto.getWeatherDate());
+ List weathers = this.hefengWeatherService.findNowWeatherByLocationIdAndDate(dto.getLocationId(),dto.getWeatherDate());
return Result.of(weathers);
}
//endregion
@@ -56,7 +54,7 @@ public class WeatherController {
@ApiImplicitParam(name = "dto", value = "获取历史天气处理", dataTypeClass = BaseWeatherFindDto.class, paramType = "body", required = true),
})
public Result> getNowWeatherDto(@Validated @RequestBody BaseWeatherFindDto dto){
- List weathers = this.weatherService.findHistoryWeatherByLocationIdAndDateDto(dto.getLocationId(),dto.getWeatherDate());
+ List weathers = this.hefengWeatherService.findHistoryWeatherByLocationIdAndDateDto(dto.getLocationId(),dto.getWeatherDate());
return Result.of(weathers);
}
//endregion
@@ -67,7 +65,7 @@ public class WeatherController {
@ApiImplicitParam(name = "dto", value = "实时天气数据处理", dataTypeClass = BaseFindDto.class, paramType = "body", required = true),
})
public Result getNowWeatherDtoOne(@Validated @RequestBody BaseFindDto dto){
- NowWeatherDto nowWeatherDto=this.weatherService.findNowWeatherByLocationIdAndDateDto(dto.getLocationId());
+ NowWeatherDto nowWeatherDto=this.hefengWeatherService.findNowWeatherByLocationIdAndDateDto(dto.getLocationId());
return Result.of(nowWeatherDto);
}
//endregion
@@ -78,9 +76,31 @@ public class WeatherController {
@ApiImplicitParam(name = "dto", value = "天气预报处理", dataTypeClass = BaseWeatherFindDto.class, paramType = "body", required = true),
})
public Result> getForecastWeatherDto(@Validated @RequestBody BaseWeatherFindDto dto){
- List weathers = this.weatherService.findForecastWeatherByLocationIdAndDateDto(dto.getLocationId(),dto.getWeatherDate());
+ List weathers = this.hefengWeatherService.findForecastWeatherByLocationIdAndDateDto(dto.getLocationId(),dto.getWeatherDate());
return Result.of(weathers);
}
//endregion
-
-}
+ //region 获取本地保存的和风天气平台,实时天气和天气预报
+ @PostMapping("/getHefengWeatherResultDtoByLocationIdAndDateDto")
+ @ApiOperation(value = "获取本地保存的和风天气平台,实时天气和天气预报", notes = "获取本地保存的和风天气平台,实时天气和天气预报")
+ @ApiImplicitParams(value = {
+ @ApiImplicitParam(name = "dto", value = "天气预报处理", dataTypeClass = BaseWeatherFindDto.class, paramType = "body", required = true),
+ })
+ public HefengWeatherResultDto getHefengWeatherResultDtoByLocationIdAndDateDto(@Validated @RequestBody BaseWeatherFindDto dto){
+ HefengWeatherResultDto hefengWeatherResultDto = this.hefengWeatherService.getHefengWeatherResultDtoByLocationIdAndDateDto(dto.getLocationId(),dto.getWeatherDate());
+ return hefengWeatherResultDto;
+ }
+ //endregion
+ //region 获取本地保存的和风天气平台,实时天气和天气预报
+ @PostMapping("/getHefengWeatherResultDtoByLocationId")
+ @ApiOperation(value = "获取本地保存的和风天气平台,实时天气和天气预报", notes = "获取本地保存的和风天气平台,实时天气和天气预报")
+ @ApiImplicitParams(value = {
+ @ApiImplicitParam(name = "dto", value = "天气预报处理", dataTypeClass = BaseFindDto.class, paramType = "body", required = true),
+ })
+ public HefengWeatherResultDto getHefengWeatherResultDtoByLocationId(@Validated @RequestBody BaseFindDto dto){
+ String currentDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
+ HefengWeatherResultDto hefengWeatherResultDto = this.hefengWeatherService.getHefengWeatherResultDtoByLocationIdAndDateDto(dto.getLocationId(),currentDate);
+ return hefengWeatherResultDto;
+ }
+ //endregion
+}
\ No newline at end of file
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/controller/TyphoonController.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/controller/WztfwStormController.java
similarity index 55%
rename from jpahefengweather/src/main/java/com/rehome/jpahefengweather/controller/TyphoonController.java
rename to jpahefengweather/src/main/java/com/rehome/jpahefengweather/controller/WztfwStormController.java
index db7c689..13a35ba 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/controller/TyphoonController.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/controller/WztfwStormController.java
@@ -1,52 +1,26 @@
package com.rehome.jpahefengweather.controller;
-import com.liuhuiyu.util.model.Result;
-import com.rehome.jpahefengweather.dto.BaseWeatherFindDto;
import com.rehome.jpahefengweather.dto.TyphoonBaseDto;
-import com.rehome.jpahefengweather.dto.TyphoonTfidDto;
import com.rehome.jpahefengweather.dto.WztfStormInfoDto;
import com.rehome.jpahefengweather.entity.*;
-import com.rehome.jpahefengweather.service.WeatherService;
import com.rehome.jpahefengweather.service.WztfStormService;
-import com.rehome.jpahefengweather.service.ZjsltStormService;
+import com.rehome.jpahefengweather.utils.Result;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
-
import javax.annotation.Resource;
import java.util.List;
@RestController
@RequestMapping("/typhoon")
-public class TyphoonController {
- @Resource
- private ZjsltStormService zjsltStormService;
+public class WztfwStormController {
+
@Resource
private WztfStormService wztfStormService;
- //region 根据年份获取台风列表
- @PostMapping("/getStormListByYear")
- @ApiOperation(value = "获取台风列表", notes = "获取台风列表")
- @ApiImplicitParams(value = {
- @ApiImplicitParam(name = "dto", value = "获取台风列表", dataTypeClass = TyphoonBaseDto.class, paramType = "body", required = true),
- })
- public Result> getStormListByYear(@Validated @RequestBody TyphoonBaseDto dto){
- return Result.of(this.zjsltStormService.findByYear(dto.getYear()));
- }
- //endregion
-
- //region 根据台风id获取单条台风数据
- @PostMapping("/getTyphoonInfoByTfid")
- @ApiOperation(value = "根据台风id获取单条台风数据", notes = "根据台风id获取单条台风数据")
- @ApiImplicitParams(value = {
- @ApiImplicitParam(name = "dto", value = "根据台风id获取单条台风数据", dataTypeClass = TyphoonTfidDto.class, paramType = "body", required = true),
- })
- public Result getTyphoonInfoByTfid(@Validated @RequestBody TyphoonTfidDto dto){
- return Result.of(this.zjsltStormService.findTyphoonInfoByTfid(dto.getTfid()));
- }
//endregion
//region 根据年份获取台风列表
@PostMapping("/getWztfStormListByYear")
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/controller/ZjsltStormController.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/controller/ZjsltStormController.java
new file mode 100644
index 0000000..0c29ba0
--- /dev/null
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/controller/ZjsltStormController.java
@@ -0,0 +1,62 @@
+package com.rehome.jpahefengweather.controller;
+
+
+import com.rehome.jpahefengweather.entity.TyphoonInfo;
+import com.rehome.jpahefengweather.entity.ZjsltStorm;
+import com.rehome.jpahefengweather.service.ZjsltStormService;
+import org.springframework.web.bind.annotation.*;
+import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author huangwenfei
+ * @version v1.0.0.0
+ * Created DateTime 2025-06-17 13:48
+ * @description: 台风接口控制器
+ */
+
+@RestController
+@RequestMapping("/storm/service")
+public class ZjsltStormController {
+ //台风服务
+ @Resource
+ private ZjsltStormService zjsltStormService;
+
+ /**
+ * 功能描述 从本地数据库查台风列表,然后返回给前端
+ * @author huangwenfei
+ * Created DateTime 2021-05-08 14:03
+ */
+ @CrossOrigin
+ @RequestMapping(value = "/getStormListByYear",method = RequestMethod.GET)
+ public List getStormListByYear(@RequestParam(value = "year", required = false) String year){
+ String currentYear = new SimpleDateFormat("yyyy").format(new Date());
+ String paramYear = year==null?currentYear:year;
+ return this.zjsltStormService.findByYear(paramYear);
+ }
+
+ /**
+ * 功能描述 从本地数据库获取活跃台风列表
+ * @author huangwenfei
+ * Created DateTime 2025-06-17 14:48
+ */
+ @CrossOrigin
+ @RequestMapping(value = "/getTyhoonActivityList",method = RequestMethod.GET)
+ public List getTyhoonActivityList(){
+ return this.zjsltStormService.getTyhoonActivity();
+ }
+
+ /**
+ * 功能描述 从本地数据库查台风实况和路径,然后返回给前端
+ * @author huangwenfei
+ * Created DateTime 2021-05-10 14:17
+ */
+ @CrossOrigin
+ @ResponseBody
+ @RequestMapping(value = "/getTyhoonInfo",method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
+ public TyphoonInfo getTyhoonInfo(@RequestParam("tfid") String tfid) {
+ return this.zjsltStormService.findTyphoonInfoByTfid(tfid);
+ }
+}
\ No newline at end of file
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dao/BaseDataCenterView.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dao/BaseDataCenterView.java
deleted file mode 100644
index a07b445..0000000
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dao/BaseDataCenterView.java
+++ /dev/null
@@ -1,129 +0,0 @@
-package com.rehome.jpahefengweather.dao;
-
-import com.liuhuiyu.jpa.BaseView;
-import com.liuhuiyu.jpa.DaoOperator;
-import com.rehome.jpahefengweather.utils.DaoUtil;
-import com.rehome.jpahefengweather.utils.IPaging;
-import org.springframework.data.domain.PageImpl;
-import javax.sql.DataSource;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author LiuHuiYu
- * @version v1.0.0.0
- * Created DateTime 2022-02-21 16:16
- */
-public abstract class BaseDataCenterView extends BaseView {
- public BaseDataCenterView(DataSource dataSource) {
- super(dataSource);
- }
-
- /**
- * 数量查询
- *
- * @param t 条件
- * @param sql 原始语句
- * @param fullWhere 填充条件
- * @param 分页查询的条件
- * @return java.lang.Long
- * @author LiuHuiYu
- * Created DateTime 2022-02-21 16:24
- */
- protected Long count(T t, String sql, String baseWhere, FullWhere fullWhere) {
- StringBuilder sqlBuilder = new StringBuilder(sql);
- sqlBuilder.append(baseWhere);
- Map parameterMap = new HashMap<>(0);
- fullWhere.fullWhere(t, sqlBuilder, parameterMap);
- DaoUtil.countOracleSql(sqlBuilder);
- return super.selectCount(sqlBuilder.toString(), parameterMap);
- }
-
- /**
- * 获取分页列表数据
- * @author LiuHuiYu
- * Created DateTime 2022-04-25 10:29
- * @param b 获取数据后的转换
- * @param t 获取条件
- * @param sql 基础查询语句
- * @param baseWhere 基础查询条件
- * @param order 排序
- * @param fullWhere 填充查询条件
- * @param 返回分页的数据类型
- * @param 分页查询的条件
- * @return java.util.List
- */
- protected List pageList(DaoOperator b, T t, String sql, String baseWhere, String order, FullWhere fullWhere) {
- StringBuilder sqlBuilder = new StringBuilder(sql);
- sqlBuilder.append(baseWhere);
- Map parameterMap = new HashMap<>(0);
- fullWhere.fullWhere(t, sqlBuilder, parameterMap);
- sqlBuilder.append(" ").append(order);
- DaoUtil.paginationOracleSql(sqlBuilder, t.getPaging());
- return super.getResultList(b, sqlBuilder.toString(), parameterMap);
- }
-
- protected PageImpl page(DaoOperator b, T t, String sql, FullWhere fullWhere, String order) {
- return page(b, t, sql, " WHERE(1=1) ", order, fullWhere);
- }
-
- /**
- * 获取列表数据
- * @author LiuHuiYu
- * Created DateTime 2022-04-25 10:29
- * @param b 获取数据后的转换
- * @param t 获取条件
- * @param sql 基础查询语句
- * @param baseWhere 基础查询条件
- * @param order 排序
- * @param fullWhere 填充查询条件
- * @param 返回分页的数据类型
- * @param 分页查询的条件
- * @return java.util.List
- */
- protected List list(DaoOperator b, T t, String sql, String baseWhere, String order, FullWhere fullWhere) {
- StringBuilder sqlBuilder = new StringBuilder(sql);
- sqlBuilder.append(baseWhere);
- Map parameterMap = new HashMap<>(0);
- fullWhere.fullWhere(t, sqlBuilder, parameterMap);
- sqlBuilder.append(" ").append(order);
- return super.getResultList(b, sqlBuilder.toString(), parameterMap);
- }
-
- /**
- * 功能描述
- *
- * @param b 查询结果转换实例的实现
- * @param t 分页查询条件
- * @param sql 基础语句
- * @param baseWhere 基础查询(带where)
- * @param order 排序(带 order by)
- * @param fullWhere void fullWhere(T find, StringBuilder sqlBuilder, Map parameterMap) 实现
- * @param 返回分页的数据类型
- * @param 分页查询的条件
- * @return org.springframework.data.domain.PageImpl
- * @author LiuHuiYu
- * Created DateTime 2022-04-09 11:41
- */
- protected PageImpl page(DaoOperator b, T t, String sql, String baseWhere, String order, FullWhere fullWhere) {
- Long total = this.count(t, sql, baseWhere, fullWhere);
- final List gatekeeperCarLogDtoList;
- if (total == 0) {
- gatekeeperCarLogDtoList = Collections.emptyList();
- }
- else if (t.getPaging().isAllInOne()) {
- gatekeeperCarLogDtoList = this.list(b, t, sql, baseWhere, order, fullWhere);
- }
- else if (t.getPaging().getPageSize() == 0) {
- gatekeeperCarLogDtoList = Collections.emptyList();
- }
- else {
- //记录查询
- gatekeeperCarLogDtoList = pageList(b, t, sql, baseWhere, order, fullWhere);
- }
- return new PageImpl<>(gatekeeperCarLogDtoList, t.getPaging().getPageRequest(), total);
- }
-
-}
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dao/FullWhere.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dao/FullWhere.java
deleted file mode 100644
index f61ed4c..0000000
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dao/FullWhere.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.rehome.jpahefengweather.dao;
-
-import java.util.Map;
-
-/**
- * @author LiuHuiYu
- * @version v1.0.0.0
- * Created DateTime 2022-02-21 16:17
- */
-@FunctionalInterface
-public interface FullWhere {
- /**
- * 功能描述
- *
- * @param find 查询条件
- * @param sqlBuilder sql
- * @param parameterMap 参数列表
- * @author LiuHuiYu
- * Created DateTime 2022-02-21 16:19
- */
- void fullWhere(T find, StringBuilder sqlBuilder, Map parameterMap);
-}
\ No newline at end of file
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dao/NowWeatherRepository.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dao/NowWeatherRepository.java
index 061f3b4..e3dc972 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dao/NowWeatherRepository.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dao/NowWeatherRepository.java
@@ -16,11 +16,9 @@ import java.util.List;
public interface NowWeatherRepository extends JpaRepository {
//方法名称必须要遵循驼峰式命名规则,findBy(关键字)+属性名称(首字母大写)+查询条件(首字母大写)
//List findByLocationIdAndWeatherDate(String locationId, String weatherDate);
- @Query(value="select * from now_weather where location_id=?1 and weather_date=?2 order by id desc", nativeQuery = true)
- List findByLocationIdAndWeatherDate(String locationId, String weatherDate);
List findByLocationIdAndWeatherDateOrderByIdDesc(String locationId, String weatherDate);
- @Query(value="select * from (select * from now_weather where location_id=?1 and weather_date=?2 order by id desc) where rownum = 1", nativeQuery = true)
- NowWeather findByLocationIdOne(String locationId, String weatherDate);
+ List findByLocationIdAndWeatherDateOrderByIdAsc(String locationId, String weatherDate);
NowWeather findFirstByLocationIdAndWeatherDateOrderByIdDesc(String locationId, String weatherDate);
NowWeather findTopByLocationIdAndWeatherDateOrderByIdDesc(String locationId, String weatherDate);
+ //NowWeather findByLocationIdO(String locationId, String weatherDate);
}
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dao/ZjsltStormRepository.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dao/ZjsltStormRepository.java
index e10f215..e89e63d 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dao/ZjsltStormRepository.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dao/ZjsltStormRepository.java
@@ -20,4 +20,6 @@ public interface ZjsltStormRepository extends JpaRepository {
ZjsltStorm findByTfid(String tfid);
List findByYear(String year);
+
+ List findByYearAndIsactiveOrderByCreateDateDesc(String year,String isactive);
}
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/BaseDto.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/BaseDto.java
index aefaa4a..71f31e5 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/BaseDto.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/BaseDto.java
@@ -1,9 +1,9 @@
package com.rehome.jpahefengweather.dto;
-import com.liuhuiyu.util.map.MapUtil;
+
+import com.rehome.jpahefengweather.utils.MapUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
-
import java.util.Map;
/**
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/BaseFindDto.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/BaseFindDto.java
index 72762cb..bd0c459 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/BaseFindDto.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/BaseFindDto.java
@@ -1,6 +1,7 @@
package com.rehome.jpahefengweather.dto;
-import com.liuhuiyu.util.map.MapUtil;
+
+import com.rehome.jpahefengweather.utils.MapUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Map;
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/BaseWeatherFindDto.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/BaseWeatherFindDto.java
index cbdbe71..7515c57 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/BaseWeatherFindDto.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/BaseWeatherFindDto.java
@@ -1,9 +1,9 @@
package com.rehome.jpahefengweather.dto;
-import com.liuhuiyu.util.map.MapUtil;
+
+import com.rehome.jpahefengweather.utils.MapUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
-
import java.util.Map;
/**
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/ForecastDto.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/ForecastDto.java
index a860b3d..c41badc 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/ForecastDto.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/ForecastDto.java
@@ -1,10 +1,10 @@
package com.rehome.jpahefengweather.dto;
-import com.liuhuiyu.util.map.MapUtil;
+
+import com.rehome.jpahefengweather.utils.MapUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
-
import java.util.Map;
/**
@@ -12,7 +12,7 @@ import java.util.Map;
* @version v1.0.0.0
* Created DateTime 2022-05-01 16:22
*/
-@ApiModel(value = "ForecastDto", description = "实时天气数据")
+@ApiModel(value = "ForecastDto", description = "天气预报数据")
public class ForecastDto {
@ApiModelProperty("预报日期")
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/ForecastWeatherDto.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/ForecastWeatherDto.java
index cf904df..e78406e 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/ForecastWeatherDto.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/ForecastWeatherDto.java
@@ -1,10 +1,10 @@
package com.rehome.jpahefengweather.dto;
-import com.liuhuiyu.util.map.MapUtil;
+
+import com.rehome.jpahefengweather.utils.MapUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
-
import java.util.List;
import java.util.Map;
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/HefengWeatherResultDto.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/HefengWeatherResultDto.java
new file mode 100644
index 0000000..ead0147
--- /dev/null
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/HefengWeatherResultDto.java
@@ -0,0 +1,11 @@
+package com.rehome.jpahefengweather.dto;
+
+import com.rehome.jpahefengweather.entity.HefengFutureWeather;
+import lombok.Data;
+
+import java.util.List;
+@Data
+public class HefengWeatherResultDto extends HefengRealtimeWeatherDto{
+ //每日天气预报
+ private List daily;
+}
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/NmcBaseDto.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/NmcBaseDto.java
index bbfd4bd..42d82b2 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/NmcBaseDto.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/NmcBaseDto.java
@@ -1,9 +1,9 @@
package com.rehome.jpahefengweather.dto;
-import com.liuhuiyu.util.map.MapUtil;
+
+import com.rehome.jpahefengweather.utils.MapUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
-
import java.util.Map;
/**
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/NmcForecastWeatherDto.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/NmcForecastWeatherDto.java
index 9cc82af..9132363 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/NmcForecastWeatherDto.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/NmcForecastWeatherDto.java
@@ -1,6 +1,7 @@
package com.rehome.jpahefengweather.dto;
-import com.liuhuiyu.util.map.MapUtil;
+
+import com.rehome.jpahefengweather.utils.MapUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/NmcNowWeatherDto.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/NmcNowWeatherDto.java
index f4023b7..b3ae7de 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/NmcNowWeatherDto.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/NmcNowWeatherDto.java
@@ -1,10 +1,9 @@
package com.rehome.jpahefengweather.dto;
-import com.liuhuiyu.util.map.MapUtil;
import com.rehome.jpahefengweather.dto.bean.NmcNowData;
+import com.rehome.jpahefengweather.utils.MapUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
-
import java.util.Map;
/**
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/NowDto.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/NowDto.java
index 380cb01..904c162 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/NowDto.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/NowDto.java
@@ -1,9 +1,9 @@
package com.rehome.jpahefengweather.dto;
-import com.liuhuiyu.util.map.MapUtil;
+
+import com.rehome.jpahefengweather.utils.MapUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
-
import java.util.Map;
/**
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/NowWeatherDto.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/NowWeatherDto.java
index b2b7b63..9d3c9df 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/NowWeatherDto.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/NowWeatherDto.java
@@ -1,9 +1,9 @@
package com.rehome.jpahefengweather.dto;
-import com.liuhuiyu.util.map.MapUtil;
+
+import com.rehome.jpahefengweather.utils.MapUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
-
import java.util.Map;
/**
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/StormDataDto.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/StormDataDto.java
index 252ce65..a03eea1 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/StormDataDto.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/StormDataDto.java
@@ -1,10 +1,10 @@
package com.rehome.jpahefengweather.dto;
-import com.liuhuiyu.util.map.MapUtil;
+
+import com.rehome.jpahefengweather.utils.MapUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
-
import java.util.List;
import java.util.Map;
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/TyhoonActivityDto.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/TyhoonActivityDto.java
index 621caa9..0be475b 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/TyhoonActivityDto.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/TyhoonActivityDto.java
@@ -1,9 +1,9 @@
package com.rehome.jpahefengweather.dto;
-import com.liuhuiyu.util.map.MapUtil;
+
+import com.rehome.jpahefengweather.utils.MapUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
-
import java.util.Map;
/**
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/TyphoonBaseDto.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/TyphoonBaseDto.java
index 94e489d..2851f8c 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/TyphoonBaseDto.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/TyphoonBaseDto.java
@@ -1,10 +1,10 @@
package com.rehome.jpahefengweather.dto;
-import com.liuhuiyu.util.map.MapUtil;
+
+import com.rehome.jpahefengweather.utils.MapUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
-
import java.util.Map;
/**
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/TyphoonTfidDto.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/TyphoonTfidDto.java
index 6e7d1ac..80a6a46 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/TyphoonTfidDto.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/TyphoonTfidDto.java
@@ -1,10 +1,9 @@
package com.rehome.jpahefengweather.dto;
-import com.liuhuiyu.util.map.MapUtil;
+import com.rehome.jpahefengweather.utils.MapUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
-
import java.util.Map;
/**
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/WztfStormInfoDto.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/WztfStormInfoDto.java
index 7476170..a2834a6 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/WztfStormInfoDto.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/dto/WztfStormInfoDto.java
@@ -1,10 +1,9 @@
package com.rehome.jpahefengweather.dto;
-import com.liuhuiyu.util.map.MapUtil;
+import com.rehome.jpahefengweather.utils.MapUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
-
import java.util.Map;
/**
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/ForecastWeather.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/ForecastWeather.java
index 3a90b91..082dd8d 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/ForecastWeather.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/ForecastWeather.java
@@ -8,8 +8,7 @@ import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
-@EntityListeners(AuditingEntityListener.class)
-@Proxy(lazy = false)
+
@Data
@Entity
//@Table(name="t_users")
@@ -26,9 +25,8 @@ public class ForecastWeather implements Serializable {
private String locationNameZh;
-// 存放长文本
- @Lob
- @Basic(fetch=FetchType.LAZY)
+ //存放长文本
+ @Column(columnDefinition = "TEXT")
private String weather;
private String weatherDate;
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/HefengFutureWeather.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/HefengFutureWeather.java
index 93c8bf0..9c63aff 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/HefengFutureWeather.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/HefengFutureWeather.java
@@ -6,8 +6,7 @@ import lombok.Data;
import org.hibernate.annotations.Proxy;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
-@EntityListeners(AuditingEntityListener.class)
-@Proxy(lazy = false)
+
@Data
@Entity
@Table(indexes = {@Index(name = "idx_location_id_future", columnList = "locationId")})
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/HefengRealtimeWeather.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/HefengRealtimeWeather.java
index 99cb4b0..fb8df04 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/HefengRealtimeWeather.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/HefengRealtimeWeather.java
@@ -6,8 +6,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.util.Date;
-@EntityListeners(AuditingEntityListener.class)
-@Proxy(lazy = false)
+
@Data
@Entity
@Table(indexes = {@Index(name = "idx_location_id_realtime", columnList = "locationId"),@Index(name = "idx_year", columnList = "year"),@Index(name = "idx_year_month", columnList = "yearAndMonth"),@Index(name = "idx_date", columnList = "date")})
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/NmcCity.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/NmcCity.java
index 319a110..58cce05 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/NmcCity.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/NmcCity.java
@@ -7,8 +7,7 @@ import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
-@EntityListeners(AuditingEntityListener.class)
-@Proxy(lazy = false)
+
@Data
@Entity
public class NmcCity implements Serializable{
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/NmcNowWeather.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/NmcNowWeather.java
index 949538c..ed4beb8 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/NmcNowWeather.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/NmcNowWeather.java
@@ -7,8 +7,7 @@ import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
-@EntityListeners(AuditingEntityListener.class)
-@Proxy(lazy = false)
+
@Data
@Entity
public class NmcNowWeather implements Serializable{
@@ -17,8 +16,7 @@ public class NmcNowWeather implements Serializable{
private Long id;
//存放长文本
- @Lob
- @Basic(fetch=FetchType.LAZY)
+ @Column(columnDefinition = "TEXT")
private String weather;
private String weatherDate;
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/NmcProvince.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/NmcProvince.java
index 72dd131..5db4f73 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/NmcProvince.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/NmcProvince.java
@@ -7,8 +7,7 @@ import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
-@EntityListeners(AuditingEntityListener.class)
-@Proxy(lazy = false)
+
@Data
@Entity
public class NmcProvince implements Serializable{
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/NmcStorm.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/NmcStorm.java
index 3e2001e..6636c47 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/NmcStorm.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/NmcStorm.java
@@ -8,8 +8,7 @@ import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
-@EntityListeners(AuditingEntityListener.class)
-@Proxy(lazy = false)
+
@Data
@Entity
public class NmcStorm implements Serializable {
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/NowWeather.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/NowWeather.java
index f066c1b..808b5a0 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/NowWeather.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/NowWeather.java
@@ -11,8 +11,7 @@ import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
-@EntityListeners(AuditingEntityListener.class)
-@Proxy(lazy = false)
+
@Data
@Entity
//@Table(name="t_users")
@@ -30,8 +29,7 @@ public class NowWeather implements Serializable {
private String locationNameZh;
//存放长文本
- @Lob
- @Basic(fetch=FetchType.LAZY)
+ @Column(columnDefinition = "TEXT")
private String weather;
private String weatherDate;
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/TyphoonInfo.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/TyphoonInfo.java
index f5f0dfb..531af0c 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/TyphoonInfo.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/TyphoonInfo.java
@@ -9,8 +9,7 @@ import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
-@EntityListeners(AuditingEntityListener.class)
-@Proxy(lazy = false)
+
@Data
@Entity
public class TyphoonInfo implements Serializable {
@@ -18,8 +17,7 @@ public class TyphoonInfo implements Serializable {
private String tfid;
//存放长文本
- @Lob
- @Basic(fetch=FetchType.LAZY)
+ @Column(columnDefinition = "TEXT")
private String stormData;
@Temporal(TemporalType.TIMESTAMP)
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/WztfStorm.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/WztfStorm.java
index ae69008..22ea832 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/WztfStorm.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/WztfStorm.java
@@ -9,8 +9,7 @@ import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
-@EntityListeners(AuditingEntityListener.class)
-@Proxy(lazy = false)
+
@Data
@Entity
public class WztfStorm implements Serializable {
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/WztfStormInfo.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/WztfStormInfo.java
index d24c3b0..56a0651 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/WztfStormInfo.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/WztfStormInfo.java
@@ -9,8 +9,7 @@ import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
-@EntityListeners(AuditingEntityListener.class)
-@Proxy(lazy = false)
+
@Data
@Entity
public class WztfStormInfo implements Serializable {
@@ -18,8 +17,7 @@ public class WztfStormInfo implements Serializable {
private String tfbh;
//存放长文本
- @Lob
- @Basic(fetch=FetchType.LAZY)
+ @Column(columnDefinition = "TEXT")
private String stormData;
@Temporal(TemporalType.TIMESTAMP)
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/ZjsltStorm.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/ZjsltStorm.java
index f389b45..159ed23 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/ZjsltStorm.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/entity/ZjsltStorm.java
@@ -9,8 +9,7 @@ import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
-@EntityListeners(AuditingEntityListener.class)
-@Proxy(lazy = false)
+
@Data
@Entity
public class ZjsltStorm implements Serializable {
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/WeatherService.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/HefengWeatherService.java
similarity index 84%
rename from jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/WeatherService.java
rename to jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/HefengWeatherService.java
index 9cc0c01..6aa2965 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/WeatherService.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/HefengWeatherService.java
@@ -1,13 +1,14 @@
package com.rehome.jpahefengweather.service;
import com.rehome.jpahefengweather.dto.ForecastWeatherDto;
+import com.rehome.jpahefengweather.dto.HefengWeatherResultDto;
import com.rehome.jpahefengweather.dto.NowWeatherDto;
import com.rehome.jpahefengweather.entity.ForecastWeather;
import com.rehome.jpahefengweather.entity.NowWeather;
import java.util.List;
-public interface WeatherService {
+public interface HefengWeatherService {
/**
* 查询全国3000+个市县区
* @return NowWeather
@@ -59,4 +60,9 @@ public interface WeatherService {
* @return List
*/
List findForecastWeatherByLocationIdAndDateDto(String locationId, String date);
+ /**
+ * 和风天气,根据位置id和日期查询实时天气和天气预报后,整合数据到一个dto提供给api调用
+ * @return List
+ */
+ HefengWeatherResultDto getHefengWeatherResultDtoByLocationIdAndDateDto(String locationId, String date);
}
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/Impl/WeatherServiceImpl.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/Impl/HefengWeatherServiceImpl.java
similarity index 85%
rename from jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/Impl/WeatherServiceImpl.java
rename to jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/Impl/HefengWeatherServiceImpl.java
index 3650e23..09407e1 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/Impl/WeatherServiceImpl.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/Impl/HefengWeatherServiceImpl.java
@@ -1,30 +1,27 @@
package com.rehome.jpahefengweather.service.Impl;
+
import com.google.gson.Gson;
import com.rehome.jpahefengweather.dao.ForecastWeatherRepository;
import com.rehome.jpahefengweather.dao.HefengFutureWeatherRepository;
import com.rehome.jpahefengweather.dao.HefengRealtimeWeatherRepository;
import com.rehome.jpahefengweather.dao.NowWeatherRepository;
-import com.rehome.jpahefengweather.dto.ForecastWeatherDto;
-import com.rehome.jpahefengweather.dto.HefengFutureWeatherDto;
-import com.rehome.jpahefengweather.dto.HefengRealtimeWeatherDto;
-import com.rehome.jpahefengweather.dto.NowWeatherDto;
+import com.rehome.jpahefengweather.dto.*;
import com.rehome.jpahefengweather.entity.*;
import com.rehome.jpahefengweather.service.CityService;
-import com.rehome.jpahefengweather.service.WeatherService;
+import com.rehome.jpahefengweather.service.HefengWeatherService;
import com.rehome.jpahefengweather.utils.OkHttpUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
-
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.*;
@Service
-public class WeatherServiceImpl implements WeatherService {
+public class HefengWeatherServiceImpl implements HefengWeatherService {
private Logger log = LoggerFactory.getLogger(this.getClass());
@Resource
@@ -42,7 +39,7 @@ public class WeatherServiceImpl implements WeatherService {
@Override
public List findNowWeatherByLocationIdAndDate(String locationId, String date) {
- return this.nowWeatherRepository.findByLocationIdAndWeatherDate(locationId,date);
+ return this.nowWeatherRepository.findByLocationIdAndWeatherDateOrderByIdDesc(locationId,date);
}
@Override
@@ -181,6 +178,7 @@ public class WeatherServiceImpl implements WeatherService {
daily.setCity(city.getAdm2NameZh());
daily.setLocationNameZh(city.getLocationNameZh());
+ daily.setCreateTime(dailyDB.getCreateTime());
daily.setUpdateTime(now);
daily.setFxLink(hefengFutureWeatherDto.getFxLink());
hefengFutureWeatherRepository.save(daily);
@@ -216,8 +214,9 @@ public class WeatherServiceImpl implements WeatherService {
public NowWeatherDto findNowWeatherByLocationIdAndDateDto(String locationId) {
SimpleDateFormat sdFormat=new SimpleDateFormat("yyyy-MM-dd");
String now = sdFormat.format(new Date());
- NowWeather nowWeather = this.nowWeatherRepository.findByLocationIdOne(locationId,now);
- if(nowWeather!=null){
+ List nowWeatherList = this.nowWeatherRepository.findByLocationIdAndWeatherDateOrderByIdDesc(locationId,now);
+ if(nowWeatherList!=null&&nowWeatherList.size()>0){
+ NowWeather nowWeather=nowWeatherList.get(0);
Gson gson = new Gson();
NowWeatherDto nowWeatherDto = gson.fromJson(nowWeather.getWeather(),NowWeatherDto.class);
return nowWeatherDto;
@@ -242,7 +241,7 @@ public class WeatherServiceImpl implements WeatherService {
@Override
public List findForecastWeatherByLocationIdAndDateDto(String locationId, String date) {
- List weathers = this.findForecastWeatherByLocationIdAndDate(locationId,date);
+ List weathers = this.findForecastWeatherByLocationIdAndDateOrderByCreateDateDesc(locationId,date);
if(weathers!=null&&weathers.size()>0){
List dtos = new ArrayList<>();
for (ForecastWeather weather:weathers) {
@@ -254,4 +253,30 @@ public class WeatherServiceImpl implements WeatherService {
}
return new ArrayList<>();
}
-}
+
+ @Override
+ public HefengWeatherResultDto getHefengWeatherResultDtoByLocationIdAndDateDto(String locationId, String date) {
+ NowWeatherDto nowWeatherDto=this.findNowWeatherByLocationIdAndDateDto(locationId);
+ //System.out.println(new Gson().toJson(nowWeatherDto));
+ if(nowWeatherDto!=null){
+ Gson gson = new Gson();
+ String nowWeatherDtoStr = gson.toJson(nowWeatherDto);
+ HefengWeatherResultDto hefengWeatherResultDto=gson.fromJson(nowWeatherDtoStr,HefengWeatherResultDto.class);
+ //System.out.println("-----------hefengWeatherResultDto------------");
+ //System.out.println(new Gson().toJson(hefengWeatherResultDto));
+
+ List forecastWeatherDtoList=this.findForecastWeatherByLocationIdAndDateDto(locationId,date);
+ //System.out.println(new Gson().toJson(forecastWeatherDtoList));
+
+ if(forecastWeatherDtoList!=null&&forecastWeatherDtoList.size()>0){
+ String futureWeatherData = gson.toJson(forecastWeatherDtoList.get(0));
+ HefengFutureWeatherDto hefengFutureWeatherDto = gson.fromJson(futureWeatherData, HefengFutureWeatherDto.class);
+ if(hefengFutureWeatherDto!=null){
+ hefengWeatherResultDto.setDaily(hefengFutureWeatherDto.getDaily());
+ return hefengWeatherResultDto;
+ }
+ }
+ }
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/Impl/ZjsltStormServiceImpl.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/Impl/ZjsltStormServiceImpl.java
index 6574b70..999bd62 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/Impl/ZjsltStormServiceImpl.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/Impl/ZjsltStormServiceImpl.java
@@ -1,14 +1,16 @@
package com.rehome.jpahefengweather.service.Impl;
-import com.rehome.jpahefengweather.dao.NmcStormRepository;
+
import com.rehome.jpahefengweather.dao.TyphoonInfoRepository;
import com.rehome.jpahefengweather.dao.ZjsltStormRepository;
import com.rehome.jpahefengweather.entity.TyphoonInfo;
import com.rehome.jpahefengweather.entity.ZjsltStorm;
import com.rehome.jpahefengweather.service.ZjsltStormService;
import org.springframework.stereotype.Service;
-
import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
@Service
@@ -29,6 +31,16 @@ public class ZjsltStormServiceImpl implements ZjsltStormService {
return this.zjsltStormRepository.findByYear(year);
}
+ @Override
+ public List getTyhoonActivity() {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
+ List list = this.zjsltStormRepository.findByYearAndIsactiveOrderByCreateDateDesc(sdf.format(new Date()),"1");
+ if(list!=null&&list.size()>0){
+ return list;
+ }
+ return new ArrayList();
+ }
+
@Override
public void saveZjsltStorm(ZjsltStorm zjsltStorm) {
this.zjsltStormRepository.save(zjsltStorm);
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/ScheduledHefengWeatherService.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/ScheduledHefengWeatherService.java
index d9dacdb..71c43f8 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/ScheduledHefengWeatherService.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/ScheduledHefengWeatherService.java
@@ -3,8 +3,7 @@ package com.rehome.jpahefengweather.service;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
-import com.liuhuiyu.spring_util.SpringUtil;
-import com.rehome.jpahefengweather.dto.NmcBaseDto;
+import com.rehome.jpahefengweather.dto.*;
import com.rehome.jpahefengweather.entity.*;
import com.rehome.jpahefengweather.service.excel.*;
import com.rehome.jpahefengweather.utils.JwtUtils;
@@ -15,6 +14,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
+import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
@@ -41,8 +41,9 @@ public class ScheduledHefengWeatherService {
@Resource
private CityService cityService;
+
@Resource
- private WeatherService weatherService;
+ private HefengWeatherService hefengWeatherService;
/**
@@ -53,7 +54,7 @@ public class ScheduledHefengWeatherService {
* //天气图标用法: https://icons.qweather.com/usage/
* @Param: null
*/
- //@Scheduled(cron = "0 34 * * * *")//每个小时执行一次
+ //@Scheduled(cron = "0 30 * * * *")//每个小时执行一次
public void scheduled() {
log.info("scheduled");
log.info("=====>>>>>使用cron:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
@@ -116,12 +117,7 @@ public class ScheduledHefengWeatherService {
}
}
}
-
- //@Scheduled(cron = "0/5 * * * * *")//每个小时执行一次
- public void scheduledGetJwt() {
- String jwt = JwtUtils.getJwt();
- log.info(jwt);
- }
+
/**
* @date 2022-03-16 09:41
@@ -137,7 +133,7 @@ public class ScheduledHefengWeatherService {
//广东省惠州市惠阳
String locationNameEn_Huiyang = "Huiyang";
- this.weatherService.saveHefengWeatherByLocationNameEn(locationNameEn_Huiyang);
+ this.hefengWeatherService.saveHefengWeatherByLocationNameEn(locationNameEn_Huiyang);
}
/**
@@ -146,14 +142,14 @@ public class ScheduledHefengWeatherService {
* @Param: null
*/
//@Scheduled(cron = "0 0 9 * * *")//每天9点执行一次
- @Scheduled(cron = "0 16 * * * *")//每个小时执行一次
+ @Scheduled(cron = "0 15 * * * *")//每个小时执行一次
public void scheduledGetForecastWeather() {
log.info("scheduledGetForecastWeather");
log.info("=====>>>>>使用cron:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
//广东省惠州市惠阳
String locationNameEn_Huiyang = "Huiyang";
- this.weatherService.saveHefengFutureWeatherByLocationNameEn(locationNameEn_Huiyang);
+ this.hefengWeatherService.saveHefengFutureWeatherByLocationNameEn(locationNameEn_Huiyang);
}
/**
@@ -334,7 +330,7 @@ public class ScheduledHefengWeatherService {
* @description: 定时任务, 从本地获取天气预报
* @Param: null
*/
- //@Scheduled(cron = "*/10 * * * * *")//每天0,8,16点各执行一次,一天总共执行三次
+ //@Scheduled(cron = "0 15 * * * *")//每天0,8,16点各执行一次,一天总共执行三次
public void getForecastWeatherDto() {
log.info("scheduledGetWeather");
log.info("=====>>>>>使用cron:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
@@ -370,4 +366,39 @@ public class ScheduledHefengWeatherService {
}
});
}
+
+ /**
+ * @date 2022-03-16 09:41
+ * @description: 获取本地保存的和风天气平台,实时天气和天气预报
+ * @Param: null
+ */
+ @Scheduled(cron = "0 0/1 * * * *")
+ public void getLocalNowWeatherDto() {
+ log.info("getLocalNowWeatherDto");
+ String strNow = String.valueOf(System.currentTimeMillis());
+ log.info(strNow);
+ BaseFindDto dto = new BaseFindDto();
+ dto.setLocationId("101280303");
+ String currentDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
+ HefengWeatherResultDto hefengWeatherResultDto=this.hefengWeatherService.getHefengWeatherResultDtoByLocationIdAndDateDto(dto.getLocationId(),currentDate);
+ log.info("-----------和风天气获取实时天气和天气预报完成------------");
+ log.info(new Gson().toJson(hefengWeatherResultDto));
+ }
+
+ /**
+ * @date 2022-03-16 09:41
+ * @description: 获取本地保存的和风天气平台,天气预报
+ * @Param: null
+ */
+ @Scheduled(cron = "0 0/1 * * * *")
+ public void getLocalForecastWeatherDto() {
+ log.info("getLocalForecastWeatherDto");
+ String strNow = String.valueOf(System.currentTimeMillis());
+ log.info(strNow);
+ String currentDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
+ BaseFindDto dto = new BaseFindDto();
+ dto.setLocationId("101280303");
+ List forecastWeatherDtoList=this.hefengWeatherService.findForecastWeatherByLocationIdAndDateDto(dto.getLocationId(),currentDate);
+ log.info(new Gson().toJson(forecastWeatherDtoList));
+ }
}
\ No newline at end of file
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/ScheduledNmcWeatherService.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/ScheduledNmcWeatherService.java
index 2978536..582e26e 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/ScheduledNmcWeatherService.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/ScheduledNmcWeatherService.java
@@ -2,22 +2,15 @@ package com.rehome.jpahefengweather.service;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
-import com.liuhuiyu.spring_util.SpringUtil;
+import com.rehome.jpahefengweather.JpahefengweatherApplication;
import com.rehome.jpahefengweather.dto.NmcBaseDto;
import com.rehome.jpahefengweather.entity.*;
-import com.rehome.jpahefengweather.service.excel.*;
-import com.rehome.jpahefengweather.utils.JwtUtils;
-import com.rehome.jpahefengweather.utils.OkHttpUtil;
import okhttp3.*;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
-import java.io.File;
import java.io.IOException;
-import java.lang.reflect.Type;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
@@ -36,8 +29,6 @@ public class ScheduledNmcWeatherService {
@Resource
private CityService cityService;
@Resource
- private WeatherService weatherService;
- @Resource
private NmcCityService nmcCityService;
@Resource
private NmcWeatherService nmcWeatherService;
@@ -207,9 +198,8 @@ public class ScheduledNmcWeatherService {
nowWeather.setLastUpdateDate(now);
nowWeather.setCreateDate(now);
- NmcWeatherService nmcWeatherServiceTemp = SpringUtil.getBean(NmcWeatherService.class);
+ NmcWeatherService nmcWeatherServiceTemp = JpahefengweatherApplication.context.getBean(NmcWeatherService.class);
nmcWeatherServiceTemp.saveNowWeather(nowWeather);
-
}
} catch (Exception e) {
e.printStackTrace();
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/ScheduledWztfwStormService.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/ScheduledWztfwStormService.java
index 37790e8..c810b9c 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/ScheduledWztfwStormService.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/ScheduledWztfwStormService.java
@@ -2,7 +2,6 @@ package com.rehome.jpahefengweather.service;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
-import com.liuhuiyu.spring_util.SpringUtil;
import com.rehome.jpahefengweather.dto.NmcBaseDto;
import com.rehome.jpahefengweather.entity.*;
import com.rehome.jpahefengweather.service.excel.*;
@@ -28,7 +27,7 @@ import java.util.concurrent.TimeUnit;
* Created DateTime 2021-04-26 14:35
* @description: 温州气象台 获取台风列表和对应的台风详情,定时任务
*/
-//@Component
+@Component
public class ScheduledWztfwStormService {
@Resource
@@ -39,9 +38,9 @@ public class ScheduledWztfwStormService {
* @description: 从温州气象台获取台风列表
* @Param: null
*/
- //@Scheduled(cron = "0 30 * * * *")
+ @Scheduled(cron = "0 39 15 * * *")
public void getWztfHistoryStormList() {
- for(int i=1945;i<2025;i++){
+ for(int i=1945;i<2026;i++){
getWztfStormList(String.valueOf(i));
}
//getWztfStormList(String.valueOf(1944));
@@ -62,7 +61,7 @@ public class ScheduledWztfwStormService {
.build();
try {
- Thread.sleep(3000);
+ Thread.sleep(1000);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy");
String nowDate = sdf.format(new Date());
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/ScheduledZjsltStormService.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/ScheduledZjsltStormService.java
index ce9b2e2..d635999 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/ScheduledZjsltStormService.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/ScheduledZjsltStormService.java
@@ -2,13 +2,14 @@ package com.rehome.jpahefengweather.service;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
-import com.liuhuiyu.spring_util.SpringUtil;
import com.rehome.jpahefengweather.dto.NmcBaseDto;
import com.rehome.jpahefengweather.entity.*;
import com.rehome.jpahefengweather.service.excel.*;
import com.rehome.jpahefengweather.utils.JwtUtils;
import com.rehome.jpahefengweather.utils.OkHttpUtil;
import okhttp3.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -28,8 +29,9 @@ import java.util.concurrent.TimeUnit;
* Created DateTime 2021-04-26 14:35
* @description: 浙江省水利厅 台风列表数据和对应的台风详情,定时任务
*/
-//@Component
+@Component
public class ScheduledZjsltStormService {
+ private Logger log = LoggerFactory.getLogger(this.getClass());
@Resource
private ZjsltStormService zjsltStormService;
@@ -40,9 +42,9 @@ public class ScheduledZjsltStormService {
* @description: 从浙江省水利厅获取历史台风列表数据和对应的台风详情
* @Param: null
*/
-// @Scheduled(cron = "0 48 * * * *")
+// @Scheduled(cron = "0 24 * * * *")
// public void getZjsltHistoryStormList() {
-// for(int i=1940;i<2025;i++){
+// for(int i=1944;i<2026;i++){
// getZjsltStormList(String.valueOf(i));
// }
// }
@@ -51,9 +53,9 @@ public class ScheduledZjsltStormService {
* @description: 从浙江省水利厅获取台风列表
* @Param: null
*/
- //@Scheduled(cron = "0 30 * * * *")
+ //@Scheduled(cron = "0 23 * * * *")
public void getZjsltStormList() {
- System.out.println("getZjsltStormList");
+ log.info("getZjsltStormList");
String strNow = String.valueOf(System.currentTimeMillis());
// 初始化 OkHttpClient
@@ -63,7 +65,7 @@ public class ScheduledZjsltStormService {
.readTimeout(30, TimeUnit.SECONDS)
.build();
try {
- Thread.sleep(5000);
+ Thread.sleep(2000);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy");
String nowDate = sdf.format(new Date());
@@ -74,7 +76,7 @@ public class ScheduledZjsltStormService {
Long nowLong = 13728353350362976L;
Long nowLongTemp = nowLong + iRandom;
String url = "https://typhoon.slt.zj.gov.cn/Api/TyphoonList/" + nowYear + "?callback=jQuery" + "1830" + String.valueOf(nowLongTemp) + "_" + strNow + "&_=" + String.valueOf(System.currentTimeMillis());
- System.out.println(url);
+ log.info(url);
// 初始化请求体
Request request = new Request.Builder()
.get()
@@ -83,16 +85,16 @@ public class ScheduledZjsltStormService {
// 得到返回Response
Response response = client.newCall(request).execute();
String body = response.body().string();
- //System.out.println(body);
+ //log.info(body);
if (StringUtils.hasText(body)) {
if (body.length() > 0) {
Gson gson = new Gson();
int startIndex = body.indexOf("[");
int endIndex = body.lastIndexOf("]");
-// System.out.println(body.indexOf("["));
-// System.out.println(body.lastIndexOf("]"));
+// log.info(body.indexOf("["));
+// log.info(body.lastIndexOf("]"));
String stormStr = body.substring(startIndex, endIndex + 1);
- //System.out.println(stormStr);
+ //log.info(stormStr);
if (stormStr != null && stormStr.length() > 2) {
Type type = new TypeToken>() {
}.getType();
@@ -101,7 +103,7 @@ public class ScheduledZjsltStormService {
for (ZjsltStorm storm : stormList) {
storm.setYear(nowYear);
storm.setCreateDate(new Date());
- System.out.println(gson.toJson(storm));
+ log.info(gson.toJson(storm));
ZjsltStorm stormDB = this.zjsltStormService.findByTfid(storm.getTfid());
if (stormDB == null) {
//数据库无数据,第一次插入,同时从第三方平台拉取台风路径数据入库
@@ -147,7 +149,7 @@ public class ScheduledZjsltStormService {
* @Param: null
*/
public void saveOrUpdateTyphoonInfo(ZjsltStorm storm) {
- System.out.println("saveOrUpdateTyphoonInfo");
+ log.info("saveOrUpdateTyphoonInfo");
String strNow = String.valueOf(System.currentTimeMillis());
// 初始化 OkHttpClient
@@ -167,7 +169,7 @@ public class ScheduledZjsltStormService {
Long nowLong = 25528353350362976L;
Long nowLongTemp = nowLong + iRandom;
String url = "https://typhoon.slt.zj.gov.cn/Api/TyphoonInfo/" + storm.getTfid() + "?callback=jQuery" + "1830" + String.valueOf(nowLongTemp) + "_" + strNow + "&_=" + String.valueOf(System.currentTimeMillis());
- System.out.println(url);
+ log.info(url);
// 初始化请求体
Request request = new Request.Builder()
.get()
@@ -176,23 +178,23 @@ public class ScheduledZjsltStormService {
// 得到返回Response
Response response = client.newCall(request).execute();
String body = response.body().string();
- //System.out.println(body);
+ //log.info(body);
if (StringUtils.hasText(body)) {
if (body.length() > 0) {
Gson gson = new Gson();
int startIndex = body.indexOf("[");
int endIndex = body.lastIndexOf("]");
-// System.out.println(body.indexOf("["));
-// System.out.println(body.lastIndexOf("]"));
+// log.info(body.indexOf("["));
+// log.info(body.lastIndexOf("]"));
String typhoonInfoArryStr = body.substring(startIndex, endIndex + 1);
- //System.out.println(typhoonInfoArryStr);
+ //log.info(typhoonInfoArryStr);
if (typhoonInfoArryStr != null && typhoonInfoArryStr.length() > 2) {
int startIndex0 = typhoonInfoArryStr.indexOf("{");
int endIndex0 = typhoonInfoArryStr.lastIndexOf("}");
-// System.out.println(startIndex0);
-// System.out.println(endIndex0);
+// log.info(startIndex0);
+// log.info(endIndex0);
String typhoonInfoStr = typhoonInfoArryStr.substring(startIndex0, endIndex0 + 1);
- //System.out.println(typhoonInfoStr);
+ //log.info(typhoonInfoStr);
TyphoonInfo typhoonInfoDB = this.zjsltStormService.findTyphoonInfoByTfid(storm.getTfid());
TyphoonInfo typhoonInfo = new TyphoonInfo();
@@ -216,4 +218,35 @@ public class ScheduledZjsltStormService {
e.printStackTrace();
}
}
+
+ /**
+ * @date 2022-03-16 09:41
+ * @description: 从本地数据库获取活跃台风列表
+ * @Param: null
+ */
+ @Scheduled(cron = "0 0/1 * * * *")
+ public void getTyhoonActivity() {
+ log.info("getTyhoonActivity");
+ String strNow = String.valueOf(System.currentTimeMillis());
+ log.info(strNow);
+ List list = this.zjsltStormService.getTyhoonActivity();
+ log.info(String.valueOf(list.size()));
+ log.info(new Gson().toJson(list));
+ }
+
+ /**
+ * @date 2022-03-16 09:41
+ * @description: 根据年份查台风列表
+ * @Param: null
+ */
+ @Scheduled(cron = "0 0/1 * * * *")
+ public void getZjsltStormByYear() {
+ log.info("getZjsltStormByYear");
+ String strNow = String.valueOf(System.currentTimeMillis());
+ log.info(strNow);
+ String currentYear = new SimpleDateFormat("yyyy").format(new Date());
+ List list = this.zjsltStormService.findByYear(currentYear);
+ log.info(String.valueOf(list.size()));
+ log.info(new Gson().toJson(list));
+ }
}
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/ZjsltStormService.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/ZjsltStormService.java
index f795eae..a9301bc 100644
--- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/ZjsltStormService.java
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/ZjsltStormService.java
@@ -11,6 +11,8 @@ public interface ZjsltStormService {
ZjsltStorm findByTfid(String tfid);
//根据年份查询台风列表
List findByYear(String year);
+ //根据年份查询台风列表
+ List getTyhoonActivity();
/**
* 保存台风数据
*/
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/utils/LhyAssert.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/utils/LhyAssert.java
new file mode 100644
index 0000000..fa9e4e2
--- /dev/null
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/utils/LhyAssert.java
@@ -0,0 +1,142 @@
+package com.rehome.jpahefengweather.utils;
+
+
+import java.util.function.Function;
+
+/**
+ * @author LiuHuiYu
+ * @version v1.0.0.0
+ * Created DateTime 2020-09-10 8:41
+ */
+public class LhyAssert {
+ static Function exceptionProxy;
+
+ private static RuntimeException throwEx(String message) {
+ if (exceptionProxy == null) {
+ return new RuntimeException(message);
+ }
+ else {
+ return exceptionProxy.apply(message);
+ }
+ }
+
+ /**
+ * 接受到异常信息后的异常抛出处理
+ *
+ * @param proxy 接受到异常信息后的代理。
+ * @author LiuHuiYu
+ * Created DateTime 2021-12-10 14:43
+ */
+ public static void exceptionProxy(Function proxy) {
+ exceptionProxy = proxy;
+ }
+ //region assertTrue
+
+ public static void assertTrue(boolean value, RuntimeException exception) {
+ if (!value) {
+ throw exception;
+ }
+ }
+
+ public static void assertTrue(boolean value, String message) {
+ assertTrue(value, throwEx(message));
+ }
+ //endregion
+
+ //region assertFalse
+
+ public static void assertFalse(boolean value, String message) {
+ assertTrue(!value, message);
+ }
+
+ public static void assertFalse(boolean value, RuntimeException exception) {
+ assertTrue(!value, exception);
+ }
+ //endregion
+
+ //region assertNotNull
+ public static void assertNotNull(Object object, RuntimeException exception) {
+ assertTrue(object != null, exception);
+ }
+
+ /**
+ * 对象为空则抛出异常
+ *
+ * @param object 对象
+ */
+ public static void assertNotNull(Object object, String message) {
+ assertTrue(object != null, message);
+ }
+
+
+ //endregion
+
+ //region assertNull
+
+ /**
+ * 对象不为空则抛出异常
+ *
+ * @param object 对象
+ */
+ public static void assertNull(Object object, RuntimeException exception) {
+ assertTrue(object == null, exception);
+ }
+
+ /**
+ * 对象不为空则抛出异常
+ *
+ * @param object 对象
+ */
+ public static void assertNull(Object object, String message) {
+ assertTrue(object == null, message);
+ }
+ //endregion
+
+ //region 枚举模式拦截
+
+ /**
+ * 对象不为空则抛出异常
+ *
+ * @param value 对象
+ * @param resultEnum 错误枚举
+ */
+ public static void assertTrue(boolean value, ResultEnum resultEnum) {
+ if (!value) {
+ throw new LhyException(resultEnum);
+ }
+ }
+
+ /**
+ * 对象为空则抛出异常
+ *
+ * @param object 对象
+ * @param resultEnum 错误枚举
+ */
+ public static void assertNotNull(Object object, ResultEnum resultEnum) {
+ assertTrue(object != null, resultEnum);
+ }
+
+ /**
+ * 对象不为空则抛出异常
+ *
+ * @param object 对象
+ * @param resultEnum 错误枚举
+ */
+ public static void assertNull(Object object, ResultEnum resultEnum) {
+ assertTrue(object == null, resultEnum);
+ }
+ //endregion
+
+
+ public static void assertLen(String value, int min, int max, String message) {
+ assertNotNull(value, message + "未设定");
+ assertTrue(
+ (min <= 0 || value.length() >= min) &&
+ (max < 0 || value.length() <= max), message + "(长度范围[" + min + "-" + max + "])");
+ }
+
+ public static void assertLen(String value, int min, int max, RuntimeException exception) {
+ assertNotNull(value, exception);
+ assertTrue(value.length() >= min && value.length() <= max, exception);
+ }
+}
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/utils/LhyException.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/utils/LhyException.java
new file mode 100644
index 0000000..f29819e
--- /dev/null
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/utils/LhyException.java
@@ -0,0 +1,53 @@
+package com.rehome.jpahefengweather.utils;
+
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * 自定义报错类
+ *
+ * @author LiuHuiYu
+ * @version v1.0.0.0
+ * Created DateTime 2020-06-23 13:27
+ */
+public class LhyException extends RuntimeException {
+ private Integer errId;
+/*
+ public ArchivesManagementException(Integer code, String message) {
+ super(message);
+ this.code = code;
+ }
+*/
+
+ public LhyException(@NotNull ResultEnum resultEnum) {
+ super(resultEnum.getMessage());
+ this.errId = resultEnum.getCode();
+ }
+
+ public LhyException(@NotNull ResultEnum resultEnum, String message) {
+ super(resultEnum.getMessage() + ":" + message);
+ this.errId = resultEnum.getCode();
+ }
+
+ public LhyException(String message, @NotNull ResultEnum resultEnum) {
+ super(message + resultEnum.getMessage());
+ this.errId = resultEnum.getCode();
+ }
+
+ public LhyException(String message, @NotNull ResultEnum resultEnum, String message1) {
+ super(message + resultEnum.getMessage() + message1);
+ this.errId = resultEnum.getCode();
+ }
+
+ public LhyException(String message) {
+ super(message);
+ this.errId = 0;
+ }
+
+ public Integer getErrId() {
+ return errId;
+ }
+
+ public void setErrId(Integer errId) {
+ this.errId = errId;
+ }
+}
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/utils/MapToT.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/utils/MapToT.java
new file mode 100644
index 0000000..554e4ac
--- /dev/null
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/utils/MapToT.java
@@ -0,0 +1,18 @@
+package com.rehome.jpahefengweather.utils;
+
+import java.util.Map;
+
+/**
+ * @author LiuHuiYu
+ * @version v1.0.0.0
+ * Created DateTime 2021-03-23 16:49
+ */
+@FunctionalInterface
+public interface MapToT {
+ /**
+ * Object 转换成 类型 T
+ * @param map Map
+ * @return T
+ */
+ T mapToT(Map map);
+}
diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/utils/MapUtil.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/utils/MapUtil.java
new file mode 100644
index 0000000..2061048
--- /dev/null
+++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/utils/MapUtil.java
@@ -0,0 +1,637 @@
+package com.rehome.jpahefengweather.utils;
+
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonSyntaxException;
+import com.google.gson.reflect.TypeToken;
+import org.apache.commons.beanutils.BeanUtils;
+import org.jetbrains.annotations.NotNull;
+import org.springframework.data.domain.PageImpl;
+import org.springframework.data.domain.PageRequest;
+import java.lang.reflect.Type;
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.time.LocalDateTime;
+import java.util.*;
+import java.util.function.Function;
+import java.util.function.Supplier;
+
+/**
+ * @author LiuHuiYu
+ * @version v1.0.0.0
+ * Created DateTime 2021-01-20 14:53
+ */
+public class MapUtil {
+
+ boolean throwException = false;
+
+ public boolean isThrowException() {
+ return throwException;
+ }
+
+ public void setThrowException(boolean throwException) {
+ this.throwException = throwException;
+ }
+
+ //region 静态方法
+
+ /**
+ * Map对象转换成Map对象
+ *
+ * @param obj Map对象
+ * @return Map对象
+ */
+ public static Map mapObjectToStringKeyMap(Object obj) {
+ if (obj == null) {
+ return null;
+ }
+ else if (obj instanceof Map, ?>) {
+ Map, ?> map = (Map, ?>) obj;
+ Map resMap = new HashMap<>(map.size());
+ map.forEach((k, v) -> resMap.put(k.toString(), v));
+ return resMap;
+ }
+ else {
+ return new HashMap<>(0);
+ }
+ }
+
+ private Object getMapObjectValue(Map map, String key) {
+ return getMapObjectValue(map, key, null);
+ }
+
+ private Object getMapObjectValue(Map map, String key, Object defValue) {
+ return map.getOrDefault(key, defValue);
+ }
+
+ public static String getMapStringValue(Map map, String key) {
+ return getMapStringValue(map, key, "");
+ }
+
+ /**
+ * 获取字符串(如果key 不存在返回 “”)
+ *
+ * @param map map
+ * @param key key
+ * @return 字符串
+ */
+ public static String getMapStringValue(Map map, String key, String defValue) {
+ if (map.containsKey(key)) {
+ Object obj = map.get(key);
+ return obj == null ? defValue : obj.toString();
+ }
+ else {
+ return defValue;
+ }
+ }
+
+ public static Integer getMapIntegerValue(Map map, String key) {
+ return getMapIntegerValue(map, key, 0);
+ }
+
+ public static Integer getMapIntegerValue(Map map, String key, Integer defValue) {
+ Object obj = map.getOrDefault(key, defValue);
+ if (obj == null) {
+ return defValue;
+ }
+ else if (obj instanceof Number) {
+ return ((Number) obj).intValue();
+ }
+ else {
+ String value = obj.toString();
+ try {
+ return Integer.parseInt(value);
+ }
+ catch (NumberFormatException ex) {
+ return defValue;
+ }
+ }
+ }
+
+ public static Float getMapFloatValue(Map map, String key) {
+ return getMapFloatValue(map, key, 0F);
+ }
+
+ public static Float getMapFloatValue(Map map, String key, Float defValue) {
+ Object obj = map.getOrDefault(key, defValue);
+ if (obj == null) {
+ return defValue;
+ }
+ else if (obj instanceof Number) {
+ return ((Number) obj).floatValue();
+ }
+ else {
+ String value = obj.toString();
+ try {
+ return Float.parseFloat(value);
+ }
+ catch (NumberFormatException ex) {
+ return defValue;
+ }
+ }
+ }
+
+ public static Long getMapLongValue(Map map, String key) {
+ return getMapLongValue(map, key, 0L);
+ }
+
+ public static Long getMapLongValue(Map map, String key, Long defValue) {
+ Object obj = map.getOrDefault(key, defValue);
+ if (obj == null) {
+ return defValue;
+ }
+ else if (obj instanceof Number) {
+ return ((Number) obj).longValue();
+ }
+ else {
+ String value = obj.toString();
+ try {
+ return Long.parseLong(value);
+ }
+ catch (NumberFormatException ex) {
+ return defValue;
+ }
+ }
+ }
+
+ public static Boolean getMapBooleanValue(Map map, String key) {
+ return getMapBooleanValue(map, key, false);
+ }
+
+ public static Boolean getMapBooleanValue(Map map, String key, boolean defValue) {
+ Object obj = map.getOrDefault(key, defValue);
+ if (obj == null) {
+ return defValue;
+ }
+ else if (obj instanceof Boolean) {
+ return (Boolean) obj;
+ }
+ try {
+ return Boolean.parseBoolean(obj.toString());
+ }
+ catch (Exception ex) {
+ return defValue;
+ }
+ }
+
+ /**
+ * 将 map 中的 可转化为 int 的数字转化为 int
+ *
+ * @param resultMap map
+ * @return 修正后的map
+ */
+ public static Map mapNumberToInt(Map, ?> resultMap) {
+ Map res = new HashMap<>(resultMap.size());
+ for (Object keyObj : resultMap.keySet()) {
+ String key = keyObj.toString();
+ if (resultMap.get(key) instanceof Double) {
+ Double value = (Double) resultMap.get(key);
+ if (value.intValue() == value) {
+ res.put(key, ((Double) resultMap.get(key)).intValue());
+ }
+ else {
+ res.put(key, resultMap.get(key));
+ }
+ }
+ else if (resultMap.get(key) instanceof List>) {
+ res.put(key, listNumberToInt((List>) resultMap.get(key)));
+ }
+ else if (resultMap.get(key) instanceof Map, ?>) {
+ res.put(key, mapNumberToInt((Map, ?>) resultMap.get(key)));
+ }
+ else {
+ res.put(key, resultMap.get(key));
+ }
+ }
+ return res;
+ }
+
+ /**
+ * 将 list 中的 可转化为 int 的数字转化为 int
+ *
+ * @param list list
+ * @return 修正后的list
+ */
+ public static List