Browse Source

天气数据开放

learshaw 2 months ago
parent
commit
ac4596f9bb
46 changed files with 1276 additions and 804 deletions
  1. 0 211
      common-cloud/tool-modules/collect-weather/src/main/java/com/huashe/common/weather/config/AmapWeatherConfig.java
  2. 0 40
      common-cloud/tool-modules/collect-weather/src/main/java/com/huashe/common/weather/config/RegionConfig.java
  3. 0 74
      common-cloud/tool-modules/collect-weather/src/main/java/com/huashe/common/weather/controller/TestController.java
  4. 0 321
      common-cloud/tool-modules/collect-weather/src/main/java/com/huashe/common/weather/model/DwdWeatherHourRt.java
  5. 0 85
      common-cloud/tool-modules/collect-weather/src/main/resources/application-locale.yml
  6. 0 0
      common-cloud/tool-modules/general-data/Dockerfile
  7. 2 2
      common-cloud/tool-modules/general-data/pom.xml
  8. 0 0
      common-cloud/tool-modules/general-data/sql/dim_ga_weather.sql
  9. 0 0
      common-cloud/tool-modules/general-data/sql/dim_gb_region.sql
  10. 18 1
      common-cloud/tool-modules/general-data/sql/table.sql
  11. 4 4
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/GeneralDataApplication.java
  12. 116 0
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/config/AmapWeatherConfig.java
  13. 41 0
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/config/ApiAuth.java
  14. 24 0
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/config/AuthKeyType.java
  15. 12 5
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/config/CollectConfig.java
  16. 40 0
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/config/WebConfig.java
  17. 75 0
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/controller/ApiAuthController.java
  18. 96 0
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/controller/GbRegionController.java
  19. 172 0
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/controller/WeatherController.java
  20. 69 0
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/controller/interceptor/AuthInterceptor.java
  21. 40 0
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/controller/interceptor/GlobalExceptionHandler.java
  22. 56 0
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/mapper/AdmApiAuthMapper.java
  23. 11 3
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/mapper/AdmWeatherForecastMapper.java
  24. 19 2
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/mapper/AdmWeatherRtMapper.java
  25. 19 4
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/mapper/DimGbRegionMapper.java
  26. 105 0
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/model/AdmApiAuth.java
  27. 1 1
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/model/BaseWeather.java
  28. 60 0
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/model/CallResponse.java
  29. 41 0
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/service/AuthService.java
  30. 1 1
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/service/RegionService.java
  31. 3 9
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/service/TaskService.java
  32. 1 7
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/service/WeatherColService.java
  33. 53 0
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/service/WeatherService.java
  34. 8 11
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/service/impl/RegionConfServiceImpl.java
  35. 5 5
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/service/impl/RegionDbServiceImpl.java
  36. 6 6
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/service/impl/WeatherColAmapServiceImpl.java
  37. 56 0
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/service/impl/WeatherServiceimpl.java
  38. 1 1
      common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/util/HttpUtils.java
  39. 32 0
      common-cloud/tool-modules/general-data/src/main/resources/application-locale.yml
  40. 1 1
      common-cloud/tool-modules/general-data/src/main/resources/application.yml
  41. 1 1
      common-cloud/tool-modules/general-data/src/main/resources/logback-spring.xml
  42. 38 0
      common-cloud/tool-modules/general-data/src/main/resources/mapper/AdmApiAuthMapper.xml
  43. 11 4
      common-cloud/tool-modules/general-data/src/main/resources/mapper/AdmWeatherForecastMapper.xml
  44. 15 1
      common-cloud/tool-modules/general-data/src/main/resources/mapper/AdmWeatherRtMapper.xml
  45. 21 2
      common-cloud/tool-modules/general-data/src/main/resources/mapper/DimGbRegionMapper.xml
  46. 2 2
      common-cloud/tool-modules/pom.xml

+ 0 - 211
common-cloud/tool-modules/collect-weather/src/main/java/com/huashe/common/weather/config/AmapWeatherConfig.java

@@ -1,211 +0,0 @@
-/*
- * 文 件 名:  AmapWeatherConfig
- * 版    权:
- * 描    述:  <描述>
- * 修 改 人:  learshaw
- * 修改时间:  2021/9/22
- * 跟踪单号:  <跟踪单号>
- * 修改单号:  <修改单号>
- * 修改内容:  <修改内容>
- */
-package com.huashe.common.weather.config;
-
-import com.huashe.common.weather.model.BaseWeather;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.Configuration;
-
-import javax.annotation.PostConstruct;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 高德天气配置
- * <功能详细描述>
- *
- * @author learshaw
- * @version [版本号, 2021/9/22]
- * @see [相关类/方法]
- * @since [产品/模块版本]
- */
-@Configuration
-@ConfigurationProperties(prefix = "collect.amap")
-public class AmapWeatherConfig extends BaseWeather {
-    /**
-     * 访问地址
-     * <br/>https://lbs.amap.com/api/webservice/guide/api/weatherinfo
-     */
-    private String url;
-
-    /**
-     * 高德访问
-     */
-    private String key;
-
-    /**
-     * 结果类型
-     */
-    private String extensions;
-
-    /**
-     * 天气映射
-     */
-    private Map<String, String> weatherMapper;
-
-    /**
-     * 降雨映射
-     */
-    private Map<String, String> rainMapper;
-
-    /**
-     * 降雪映射
-     */
-    private Map<String, String> snowMapper;
-
-    /**
-     * 雾(天)映射
-     */
-    private Map<String, String> fogMapper;
-
-    /**
-     * 沙尘映射
-     */
-    private Map<String, String> sandMapper;
-
-    /**
-     * 雷电映射
-     */
-    private Map<String, String> thunderMapper;
-
-    /**
-     * 风映射
-     */
-    private Map<String, String> windMapper;
-
-    @PostConstruct
-    public void init() {
-        this.weatherMapper = resetCacheMap(weatherList);
-        this.rainMapper = resetCacheMap(rainList);
-        this.snowMapper = resetCacheMap(snowList);
-        this.fogMapper = resetCacheMap(fogList);
-        this.sandMapper = resetCacheMap(sandList);
-        this.thunderMapper = resetCacheMap(thunderList);
-        this.windMapper = resetCacheMap(windList);
-    }
-
-    public String getUrl() {
-        return url;
-    }
-
-    public void setUrl(String url) {
-        this.url = url;
-    }
-
-    public String getKey() {
-        return key;
-    }
-
-    public void setKey(String key) {
-        this.key = key;
-    }
-
-    public String getExtensions() {
-        return extensions;
-    }
-
-    public void setExtensions(String extensions) {
-        this.extensions = extensions;
-    }
-
-    public String getWeatherTypeByName(String name) {
-        String ret = null;
-
-        for (Map.Entry<String, String> entry : weatherMapper.entrySet()) {
-            String key = entry.getKey();
-
-            if (StringUtils.equals(name, key) || StringUtils.contains(name, key)) {
-                ret = entry.getValue();
-                break;
-            }
-        }
-
-        return ret;
-    }
-
-    public String getRainCodeByName(String name) {
-        return rainMapper.get(name);
-    }
-
-    public String getSnowCodeByName(String name) {
-        return snowMapper.get(name);
-    }
-
-    public String getHailCodeByName(String name) {
-        String[] array = StringUtils.split(hailKey, ":");
-        return StringUtils.equals(name, array[1]) ? array[0] : null;
-    }
-
-    public String getDewCodeByName(String name) {
-        String[] array = StringUtils.split(dewKey, ":");
-        return StringUtils.equals(name, array[1]) ? array[0] : null;
-    }
-
-    public String getFrostCodeByName(String name) {
-        String[] array = StringUtils.split(frostKey, ":");
-        return StringUtils.equals(name, array[1]) ? array[0] : null;
-    }
-
-    public String getFogCodeByName(String name) {
-        return fogMapper.get(name);
-    }
-
-    public String getHazeCodeByName(String name) {
-        String[] array = StringUtils.split(hazeKey, ":");
-        return StringUtils.contains(name, array[1]) ? array[0] : null;
-    }
-
-    public String getSandCodeByName(String name) {
-        return sandMapper.get(name);
-    }
-
-    public String getThunderCodeByName(String name) {
-        return thunderMapper.get(name);
-    }
-
-    public String getWindCodeByName(String name) {
-        String key = StringUtils.remove(name, "≤");
-        return windMapper.get(key);
-    }
-
-    public String getTornadoCodeByName(String name) {
-        String[] array = StringUtils.split(tornadoKey, ":");
-        return StringUtils.equals(name, array[1]) ? array[0] : null;
-    }
-
-    public String getSnowCoverCodeByName(String name) {
-        String[] array = StringUtils.split(snowCoverKey, ":");
-        return StringUtils.equals(name, array[1]) ? array[0] : null;
-    }
-
-    public String getFrozenCodeByName(String name) {
-        String[] array = StringUtils.split(frozenKey, ":");
-        return StringUtils.equals(name, array[1]) ? array[0] : null;
-    }
-
-    public Map<String, String> resetCacheMap(List<String> list) {
-        Map<String, String> cacheMap = new HashMap<>();
-
-        for (String str : list) {
-            String[] array = StringUtils.split(str, ":");
-
-            String[] subKeys = StringUtils.split(array[1], ",");
-
-            for (String subKey : subKeys) {
-                cacheMap.put(subKey, array[0]);
-            }
-        }
-
-        return cacheMap;
-    }
-}

+ 0 - 40
common-cloud/tool-modules/collect-weather/src/main/java/com/huashe/common/weather/config/RegionConfig.java

@@ -1,40 +0,0 @@
-/*
- * 文 件 名:  RegionConfig
- * 版    权:
- * 描    述:  <描述>
- * 修 改 人:  learshaw
- * 修改时间:  2022/2/18
- * 跟踪单号:  <跟踪单号>
- * 修改单号:  <修改单号>
- * 修改内容:  <修改内容>
- */
-package com.huashe.common.weather.config;
-
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * 区域属性配置
- * <功能详细描述>
- *
- * @author learshaw
- * @version [版本号, 2022/2/18]
- * @see [相关类/方法]
- * @since [产品/模块版本]
- */
-@Configuration
-@ConfigurationProperties(prefix = "collect.region")
-public class RegionConfig {
-    /**
-     * 区域代码配置
-     */
-    private String confAdcodes;
-
-    public String getConfAdcodes() {
-        return confAdcodes;
-    }
-
-    public void setConfAdcodes(String confAdcodes) {
-        this.confAdcodes = confAdcodes;
-    }
-}

+ 0 - 74
common-cloud/tool-modules/collect-weather/src/main/java/com/huashe/common/weather/controller/TestController.java

@@ -1,74 +0,0 @@
-/*
- * 文 件 名:  GeekOpenCbController
- * 版    权:  华设设计集团股份有限公司
- * 描    述:  <描述>
- * 修 改 人:  lvwenbin
- * 修改时间:  2025/2/27
- * 跟踪单号:  <跟踪单号>
- * 修改单号:  <修改单号>
- * 修改内容:  <修改内容>
- */
-package com.huashe.common.weather.controller;
-
-import com.huashe.common.weather.service.WeatherColService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.web.bind.annotation.CrossOrigin;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-
-/**
- * 天气数据采集
- * <功能详细描述>
- *
- * @author lvwenbin
- * @version [版本号, 2025/2/27]
- * @see [相关类/方法]
- * @since [产品/模块版本]
- */
-@RestController
-@CrossOrigin(allowedHeaders = "*", allowCredentials = "false")
-@RequestMapping("/test")
-@Api(value = "TestController", description = "测试Api")
-public class TestController {
-    /**
-     * 日志
-     */
-    private static final Logger log = LoggerFactory.getLogger(TestController.class);
-
-    @Qualifier("weatherColAmapService")
-    @Resource
-    private WeatherColService weatherColService;
-
-    /**
-     * 实时天气采集
-     */
-    @RequestMapping(value = "/colRt", method = RequestMethod.GET)
-    @ApiOperation(value = "/colRt", notes = "实时天气采集")
-    @ApiResponses({ @ApiResponse(code = 200, message = "success"),
-        @ApiResponse(code = 400, message = "{code:****,message:'fail'}")
-    })
-    public void colRt() {
-        weatherColService.collectRt("320100");
-    }
-
-    /**
-     * 实时天气采集
-     */
-    @RequestMapping(value = "/colForecast", method = RequestMethod.GET)
-    @ApiOperation(value = "/colForecast", notes = "预报天气采集")
-    @ApiResponses({ @ApiResponse(code = 200, message = "success"),
-        @ApiResponse(code = 400, message = "{code:****,message:'fail'}")
-    })
-    public void colForecast() {
-        weatherColService.collectForecast("320100");
-    }
-}

+ 0 - 321
common-cloud/tool-modules/collect-weather/src/main/java/com/huashe/common/weather/model/DwdWeatherHourRt.java

@@ -1,321 +0,0 @@
-/*
- * 文 件 名:  DwdWeaterHourRt
- * 版    权:
- * 描    述:  <描述>
- * 修 改 人:  learshaw
- * 修改时间:  2021/9/22
- * 跟踪单号:  <跟踪单号>
- * 修改单号:  <修改单号>
- * 修改内容:  <修改内容>
- */
-package com.huashe.common.weather.model;
-
-/**
- * 天气小时实时数据
- * <功能详细描述>
- *
- * @author learshaw
- * @version [版本号, 2021/9/22]
- * @see [相关类/方法]
- * @since [产品/模块版本]
- */
-public class DwdWeatherHourRt {
-    /**
-     * 行政编码
-     */
-    private String adcode;
-
-    /**
-     * 地区名称
-     */
-    private String areaName;
-
-    /**
-     * 日期
-     */
-    private String date;
-
-    /**
-     * 小时
-     */
-    private String hour;
-
-    /**
-     * 天气类型
-     */
-    private String weatherType;
-
-    /**
-     * 天气-中文描述
-     */
-    private String weatherCn;
-
-    /**
-     * 温度
-     */
-    private Double temperature;
-
-    /**
-     * 湿度
-     */
-    private Integer humidity;
-
-    /**
-     * 降雨
-     */
-    private String rainPhenomena;
-
-    /**
-     * 降水现象
-     */
-    private String snowPhenomena;
-
-    /**
-     * 冰雹
-     */
-    private String hailPhenomena;
-
-    /**
-     * 露水
-     */
-    private String dewPhenomena;
-
-    /**
-     * 霜冻
-     */
-    private String frostPhenomena;
-
-    /**
-     * 雾天
-     */
-    private String fogPhenomena;
-
-    /**
-     * 霾
-     */
-    private String hazePhenomena;
-
-    /**
-     * 沙尘
-     */
-    private String sandPhenomena;
-
-    /**
-     * 打雷
-     */
-    private String thunderPhenomena;
-
-    /**
-     * 刮风
-     */
-    private String windPhenomena;
-
-    /**
-     * 龙卷风
-     */
-    private String tornadoPhenomena;
-
-    /**
-     * 积雪
-     */
-    private String snowCoverPhenomena;
-
-    /**
-     * 冰冻
-     */
-    private String frozenPhenomena;
-
-    /**
-     * 数据更新时间
-     */
-    private String updateTime;
-
-    /**
-     * 时间戳
-     */
-    private long timestamp;
-
-    public String getAdcode() {
-        return adcode;
-    }
-
-    public void setAdcode(String adcode) {
-        this.adcode = adcode;
-    }
-
-    public String getAreaName() {
-        return areaName;
-    }
-
-    public void setAreaName(String areaName) {
-        this.areaName = areaName;
-    }
-
-    public String getDate() {
-        return date;
-    }
-
-    public void setDate(String date) {
-        this.date = date;
-    }
-
-    public String getHour() {
-        return hour;
-    }
-
-    public void setHour(String hour) {
-        this.hour = hour;
-    }
-
-    public String getWeatherType() {
-        return weatherType;
-    }
-
-    public void setWeatherType(String weatherType) {
-        this.weatherType = weatherType;
-    }
-
-    public String getWeatherCn() {
-        return weatherCn;
-    }
-
-    public void setWeatherCn(String weatherCn) {
-        this.weatherCn = weatherCn;
-    }
-
-    public Double getTemperature() {
-        return temperature;
-    }
-
-    public void setTemperature(Double temperature) {
-        this.temperature = temperature;
-    }
-
-    public Integer getHumidity() {
-        return humidity;
-    }
-
-    public void setHumidity(Integer humidity) {
-        this.humidity = humidity;
-    }
-
-    public String getRainPhenomena() {
-        return rainPhenomena;
-    }
-
-    public void setRainPhenomena(String rainPhenomena) {
-        this.rainPhenomena = rainPhenomena;
-    }
-
-    public String getSnowPhenomena() {
-        return snowPhenomena;
-    }
-
-    public void setSnowPhenomena(String snowPhenomena) {
-        this.snowPhenomena = snowPhenomena;
-    }
-
-    public String getHailPhenomena() {
-        return hailPhenomena;
-    }
-
-    public void setHailPhenomena(String hailPhenomena) {
-        this.hailPhenomena = hailPhenomena;
-    }
-
-    public String getDewPhenomena() {
-        return dewPhenomena;
-    }
-
-    public void setDewPhenomena(String dewPhenomena) {
-        this.dewPhenomena = dewPhenomena;
-    }
-
-    public String getFrostPhenomena() {
-        return frostPhenomena;
-    }
-
-    public void setFrostPhenomena(String frostPhenomena) {
-        this.frostPhenomena = frostPhenomena;
-    }
-
-    public String getFogPhenomena() {
-        return fogPhenomena;
-    }
-
-    public void setFogPhenomena(String fogPhenomena) {
-        this.fogPhenomena = fogPhenomena;
-    }
-
-    public String getHazePhenomena() {
-        return hazePhenomena;
-    }
-
-    public void setHazePhenomena(String hazePhenomena) {
-        this.hazePhenomena = hazePhenomena;
-    }
-
-    public String getSandPhenomena() {
-        return sandPhenomena;
-    }
-
-    public void setSandPhenomena(String sandPhenomena) {
-        this.sandPhenomena = sandPhenomena;
-    }
-
-    public String getThunderPhenomena() {
-        return thunderPhenomena;
-    }
-
-    public void setThunderPhenomena(String thunderPhenomena) {
-        this.thunderPhenomena = thunderPhenomena;
-    }
-
-    public String getWindPhenomena() {
-        return windPhenomena;
-    }
-
-    public void setWindPhenomena(String windPhenomena) {
-        this.windPhenomena = windPhenomena;
-    }
-
-    public String getTornadoPhenomena() {
-        return tornadoPhenomena;
-    }
-
-    public void setTornadoPhenomena(String tornadoPhenomena) {
-        this.tornadoPhenomena = tornadoPhenomena;
-    }
-
-    public String getSnowCoverPhenomena() {
-        return snowCoverPhenomena;
-    }
-
-    public void setSnowCoverPhenomena(String snowCoverPhenomena) {
-        this.snowCoverPhenomena = snowCoverPhenomena;
-    }
-
-    public String getFrozenPhenomena() {
-        return frozenPhenomena;
-    }
-
-    public void setFrozenPhenomena(String frozenPhenomena) {
-        this.frozenPhenomena = frozenPhenomena;
-    }
-
-    public String getUpdateTime() {
-        return updateTime;
-    }
-
-    public void setUpdateTime(String updateTime) {
-        this.updateTime = updateTime;
-    }
-
-    public long getTimestamp() {
-        return timestamp;
-    }
-
-    public void setTimestamp(long timestamp) {
-        this.timestamp = timestamp;
-    }
-}

+ 0 - 85
common-cloud/tool-modules/collect-weather/src/main/resources/application-locale.yml

@@ -1,85 +0,0 @@
-spring:
-  datasource:
-    username: root
-    password: 'abc123'
-    url: jdbc:mariadb://172.192.13.95:3310/common_data?characterEncoding=utf8&useSSL=false&allowMultiQueries=true
-    driver-class-name: org.mariadb.jdbc.Driver
-
-mybatis:
-  mapper-locations: classpath:mapper/*.xml
-  type-aliases-package: com.huashe.common.domain.model,com.huashe.common.weather.model
-
-collect:
-  rt-cron: 0 15 0,6,12,18 * * ?
-  forecast-cron: 0 15 0 * * ?
-  # 服务提供商
-  service-provider: amap
-  region:
-    # 数据来源 db、conf
-    source: db
-    conf-adcodes:
-  amap:
-    url: https://restapi.amap.com/v3/weather/weatherInfo?key=${collect.amap.key}&city=#{adcode}&extensions=#{extensions}&output=JSON
-    key: 9a5a4852c8698e783989e7f376d77816
-    weatherList:
-      - '1101:晴'
-      - '1103:多云'
-      - '1106:阴'
-      - '2200:雪'
-      - '2100:雨'
-      - '4100:雾'
-      - '4200:霾'
-      - '4300:沙'
-    rainList:
-      - '2101:雨,小雨'
-      - '2102:中雨'
-      - '2103:大雨'
-      - '2104:暴雨,大暴雨'
-      - '2111:阵雨'
-      - '2121:雷阵雨'
-      - '2131:冻雨'
-    snowList:
-      - '2201:小雪'
-      - '2202:中雪'
-      - '2203:大雪'
-      - '2204:暴雪'
-      - '2211:雨夹雪'
-    hailKey: '2300:冰雹'
-    dewKey: '3100:露水'
-    frostKey: '3200:霜冻'
-    fogList:
-      - '4101:轻雾'
-      - '4102:大雾'
-      - '4103:浓雾'
-    hazeKey: '4200:霾'
-    sandList:
-      - '4301:浮尘'
-      - '4302:扬沙'
-      - '4303:沙尘暴'
-      - '4304:强沙尘暴'
-      - '4305:特强沙尘暴'
-    thunderList:
-      - '5101:雷暴'
-      - '5105:闪电'
-    windList:
-      - '9101:1'
-      - '9102:2'
-      - '9103:3'
-      - '9104:4'
-      - '9105:5'
-      - '9106:6'
-      - '9107:7'
-      - '9108:8'
-      - '9109:9'
-      - '9110:10'
-      - '9111:11'
-      - '9112:12'
-      - '9113:13'
-      - '9114:14'
-      - '9115:15'
-      - '9116:16'
-      - '9117:17'
-      - '9191:0'
-    tornadoKey: '9301:龙卷风'
-    snowCoverKey: '9401:积雪'
-    frozenKey: '9501:冰冻'

+ 0 - 0
common-cloud/tool-modules/collect-weather/Dockerfile → common-cloud/tool-modules/general-data/Dockerfile


+ 2 - 2
common-cloud/tool-modules/collect-weather/pom.xml → common-cloud/tool-modules/general-data/pom.xml

@@ -11,10 +11,10 @@
         <relativePath/>
     </parent>
 
-    <artifactId>collect-weather</artifactId>
+    <artifactId>general-data</artifactId>
     <groupId>com.huashe.common</groupId>
     <version>1.0.0-SNAPSHOT</version>
-    <description>实时天气属性采集</description>
+    <description>通用数据服务</description>
 
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

+ 0 - 0
common-cloud/tool-modules/collect-weather/sql/dim_ga_weather.sql → common-cloud/tool-modules/general-data/sql/dim_ga_weather.sql


+ 0 - 0
common-cloud/tool-modules/collect-weather/sql/dim_gb_region.sql → common-cloud/tool-modules/general-data/sql/dim_gb_region.sql


+ 18 - 1
common-cloud/tool-modules/collect-weather/sql/table.sql → common-cloud/tool-modules/general-data/sql/table.sql

@@ -39,4 +39,21 @@ CREATE TABLE `adm_area_weather_forecast` (
     `report_time`         datetime       DEFAULT NULL COMMENT '数据时间',
     `create_time`         datetime       DEFAULT CURRENT_TIMESTAMP    comment '创建时间',
     PRIMARY KEY (`adcode`,`date`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='区域天气预报';
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='区域天气预报';
+
+
+-- ----------------------------
+-- 接口认证
+-- ----------------------------
+DROP TABLE IF EXISTS `adm_api_auth`;
+CREATE TABLE `adm_api_auth` (
+    `id` INT(11) NOT NULL AUTO_INCREMENT,
+    `client_id` VARCHAR(64) NOT NULL COMMENT '客户端ID',
+    `client_name` VARCHAR(128) NOT NULL COMMENT '客户端名称',
+    `api_key` VARCHAR(64) NOT NULL COMMENT 'API密钥',
+    `status` TINYINT(1) NOT NULL DEFAULT '1' COMMENT '状态 1-有效 0-禁用',
+    `expire_time` DATETIME DEFAULT NULL COMMENT '过期时间',
+    PRIMARY KEY (`id`),
+    UNIQUE KEY `uniq_client` (`client_id`),
+    KEY `idx_apikey` (`api_key`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Api认证信息表';

+ 4 - 4
common-cloud/tool-modules/collect-weather/src/main/java/com/huashe/common/weather/WeatherColApplication.java → common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/GeneralDataApplication.java

@@ -5,14 +5,14 @@
  * 修 改 人:  learshaw
  * 修改时间:  2018/12/18
  */
-package com.huashe.common.weather;
+package com.huashe.common.data;
 
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.scheduling.annotation.EnableAsync;
 
 /**
- * 天气采集启动入口
+ * 通用数据服务启动
  * <功能详细描述>
  *
  * @author learshaw
@@ -22,9 +22,9 @@ import org.springframework.scheduling.annotation.EnableAsync;
  */
 @EnableAsync
 @SpringBootApplication
-public class WeatherColApplication {
+public class GeneralDataApplication {
     public static void main(String[] args) {
-        SpringApplication application = new SpringApplication(WeatherColApplication.class);
+        SpringApplication application = new SpringApplication(GeneralDataApplication.class);
         application.run(args);
     }
 }

+ 116 - 0
common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/config/AmapWeatherConfig.java

@@ -0,0 +1,116 @@
+/*
+ * 文 件 名:  AmapWeatherConfig
+ * 版    权:
+ * 描    述:  <描述>
+ * 修 改 人:  learshaw
+ * 修改时间:  2021/9/22
+ * 跟踪单号:  <跟踪单号>
+ * 修改单号:  <修改单号>
+ * 修改内容:  <修改内容>
+ */
+package com.huashe.common.data.config;
+
+import com.huashe.common.data.model.BaseWeather;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+import javax.annotation.PostConstruct;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 高德天气配置
+ * <功能详细描述>
+ *
+ * @author learshaw
+ * @version [版本号, 2021/9/22]
+ * @see [相关类/方法]
+ * @since [产品/模块版本]
+ */
+@Configuration
+@ConfigurationProperties(prefix = "weather.amap")
+public class AmapWeatherConfig extends BaseWeather {
+    /**
+     * 访问地址
+     * <br/>https://lbs.amap.com/api/webservice/guide/api/weatherinfo
+     */
+    private String url;
+
+    /**
+     * 高德访问
+     */
+    private String key;
+
+    /**
+     * 结果类型
+     */
+    private String extensions;
+
+    /**
+     * 天气映射
+     */
+    private Map<String, String> weatherMapper;
+
+
+    @PostConstruct
+    public void init() {
+        this.weatherMapper = resetCacheMap(weatherList);
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getKey() {
+        return key;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    public String getExtensions() {
+        return extensions;
+    }
+
+    public void setExtensions(String extensions) {
+        this.extensions = extensions;
+    }
+
+    public String getWeatherTypeByName(String name) {
+        String ret = null;
+
+        for (Map.Entry<String, String> entry : weatherMapper.entrySet()) {
+            String key = entry.getKey();
+
+            if (StringUtils.equals(name, key) || StringUtils.contains(name, key)) {
+                ret = entry.getValue();
+                break;
+            }
+        }
+
+        return ret;
+    }
+
+    public Map<String, String> resetCacheMap(List<String> list) {
+        Map<String, String> cacheMap = new HashMap<>();
+
+        for (String str : list) {
+            String[] array = StringUtils.split(str, ":");
+
+            String[] subKeys = StringUtils.split(array[1], ",");
+
+            for (String subKey : subKeys) {
+                cacheMap.put(subKey, array[0]);
+            }
+        }
+
+        return cacheMap;
+    }
+}

+ 41 - 0
common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/config/ApiAuth.java

@@ -0,0 +1,41 @@
+/*
+ * 文 件 名:  ApiAuth
+ * 版    权:  华设设计集团股份有限公司
+ * 描    述:  <描述>
+ * 修 改 人:  lvwenbin
+ * 修改时间:  2025/5/8
+ * 跟踪单号:  <跟踪单号>
+ * 修改单号:  <修改单号>
+ * 修改内容:  <修改内容>
+ */
+package com.huashe.common.data.config;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * 鉴权注解
+ * <功能详细描述>
+ *
+ * @author lvwenbin
+ * @version [版本号, 2025/5/8]
+ * @see [相关类/方法]
+ * @since [产品/模块版本]
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface ApiAuth {
+    /**
+     * 是否必须验证 默认true
+     */
+    boolean required() default true;
+
+    /**
+     * 密钥位置类型(HEADER/PARAM)
+     */
+    AuthKeyType type() default AuthKeyType.PARAM;
+}

+ 24 - 0
common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/config/AuthKeyType.java

@@ -0,0 +1,24 @@
+/*
+ * 文 件 名:  AuthKeyType
+ * 版    权:  华设设计集团股份有限公司
+ * 描    述:  <描述>
+ * 修 改 人:  lvwenbin
+ * 修改时间:  2025/5/8
+ * 跟踪单号:  <跟踪单号>
+ * 修改单号:  <修改单号>
+ * 修改内容:  <修改内容>
+ */
+package com.huashe.common.data.config;
+
+/**
+ * 认证key类型
+ * <功能详细描述>
+ *
+ * @author lvwenbin
+ * @version [版本号, 2025/5/8]
+ * @see [相关类/方法]
+ * @since [产品/模块版本]
+ */
+public enum AuthKeyType {
+    HEADER, PARAM
+}

+ 12 - 5
common-cloud/tool-modules/collect-weather/src/main/java/com/huashe/common/weather/config/CollectConfig.java → common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/config/CollectConfig.java

@@ -8,10 +8,10 @@
  * 修改单号:  <修改单号>
  * 修改内容:  <修改内容>
  */
-package com.huashe.common.weather.config;
+package com.huashe.common.data.config;
 
 import com.huashe.common.exception.BusinessException;
-import com.huashe.common.weather.service.WeatherColService;
+import com.huashe.common.data.service.WeatherColService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.beans.factory.annotation.Value;
@@ -29,17 +29,24 @@ import org.springframework.context.annotation.Configuration;
  */
 @Configuration
 public class CollectConfig {
-    @Value("${collect.service-provider}")
-    private String serviceProvider;
+    @Value("${weather.service-provider}")
+    private String weatherServiceProvider;
+
+    @Value("${weather.region.conf-adcodes}")
+    private String weatherAdcodes;
 
     @Bean(value = "weatherColService")
     public WeatherColService weatherColService(
         @Qualifier(value = "weatherColAmapService") WeatherColService amapColService) {
-        if (StringUtils.equals("amap", serviceProvider)) {
+        if (StringUtils.equals("amap", weatherServiceProvider)) {
             return amapColService;
         }
         else {
             throw new BusinessException(-1, "serviceProvider 未匹配!");
         }
     }
+
+    public String getWeatherAdcodes() {
+        return weatherAdcodes;
+    }
 }

+ 40 - 0
common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/config/WebConfig.java

@@ -0,0 +1,40 @@
+/*
+ * 文 件 名:  WebConfig
+ * 版    权:  华设设计集团股份有限公司
+ * 描    述:  <描述>
+ * 修 改 人:  lvwenbin
+ * 修改时间:  2025/5/8
+ * 跟踪单号:  <跟踪单号>
+ * 修改单号:  <修改单号>
+ * 修改内容:  <修改内容>
+ */
+package com.huashe.common.data.config;
+
+import com.huashe.common.data.controller.interceptor.AuthInterceptor;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+/**
+ * Web配置
+ * <功能详细描述>
+ *
+ * @author lvwenbin
+ * @version [版本号, 2025/5/8]
+ * @see [相关类/方法]
+ * @since [产品/模块版本]
+ */
+@Configuration
+public class WebConfig implements WebMvcConfigurer {
+    @Override
+    public void addInterceptors(InterceptorRegistry registry) {
+        registry.addInterceptor(authInterceptor())
+            .addPathPatterns("/**");
+    }
+
+    @Bean
+    public AuthInterceptor authInterceptor() {
+        return new AuthInterceptor();
+    }
+}

+ 75 - 0
common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/controller/ApiAuthController.java

@@ -0,0 +1,75 @@
+/*
+ * 文 件 名:  WeatherController
+ * 版    权:  华设设计集团股份有限公司
+ * 描    述:  <描述>
+ * 修 改 人:  lvwenbin
+ * 修改时间:  2025/5/8
+ * 跟踪单号:  <跟踪单号>
+ * 修改单号:  <修改单号>
+ * 修改内容:  <修改内容>
+ */
+package com.huashe.common.data.controller;
+
+import com.huashe.common.data.mapper.AdmApiAuthMapper;
+import com.huashe.common.data.model.AdmApiAuth;
+import com.huashe.common.data.model.CallResponse;
+import com.huashe.common.exception.BusinessException;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import org.apache.commons.lang3.RandomStringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.UUID;
+
+/**
+ * Api鉴权Api
+ * <功能详细描述>
+ *
+ * @author lvwenbin
+ * @version [版本号, 2025/5/8]
+ * @see [相关类/方法]
+ * @since [产品/模块版本]
+ */
+@RestController
+@CrossOrigin(allowedHeaders = "*", allowCredentials = "false")
+@RequestMapping("/auth")
+@Api(value = "ApiAuthController", description = "鉴权接口")
+public class ApiAuthController {
+    @Autowired
+    private AdmApiAuthMapper apiAuthMapper;
+
+    /**
+     * 生成鉴权记录
+     */
+    @RequestMapping(value = "/generateCfg", method = RequestMethod.POST)
+    @ApiOperation(value = "/generateCfg", notes = "生成鉴权配置")
+    @ApiResponses({ @ApiResponse(code = 200, message = "success"),
+        @ApiResponse(code = 400, message = "{code:****,message:'fail'}")
+    })
+    public CallResponse<Void> generateCfg(@RequestBody AdmApiAuth admApiAuth) {
+        CallResponse<Void> callResponse = new CallResponse<>();
+
+        try {
+            admApiAuth.setApiKey(generateApiKey());
+            apiAuthMapper.insert(admApiAuth);
+            callResponse.setCode(0);
+            callResponse.setMessage("success");
+        }
+        catch (Exception e) {
+            throw new BusinessException(-1, e.getMessage());
+        }
+
+        return callResponse;
+    }
+
+    public static String generateApiKey() {
+        return UUID.randomUUID().toString().replace("-", "") + RandomStringUtils.randomAlphanumeric(16);
+    }
+}

+ 96 - 0
common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/controller/GbRegionController.java

@@ -0,0 +1,96 @@
+/*
+ * 文 件 名:  GbRegionController
+ * 版    权:  华设设计集团股份有限公司
+ * 描    述:  <描述>
+ * 修 改 人:  lvwenbin
+ * 修改时间:  2025/5/8
+ * 跟踪单号:  <跟踪单号>
+ * 修改单号:  <修改单号>
+ * 修改内容:  <修改内容>
+ */
+package com.huashe.common.data.controller;
+
+import com.huashe.common.data.config.ApiAuth;
+import com.huashe.common.data.mapper.DimGbRegionMapper;
+import com.huashe.common.data.model.CallResponse;
+import com.huashe.common.domain.model.GbRegion;
+import com.huashe.common.exception.BusinessException;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 行政区划数据接口
+ * <功能详细描述>
+ *
+ * @author lvwenbin
+ * @version [版本号, 2025/5/8]
+ * @see [相关类/方法]
+ * @since [产品/模块版本]
+ */
+@RestController
+@CrossOrigin(allowedHeaders = "*", allowCredentials = "false")
+@RequestMapping("/region")
+@Api(value = "GbRegionController", description = "行政区划数据接口")
+public class GbRegionController {
+    @Autowired
+    private DimGbRegionMapper regionMapper;
+
+    /**
+     * 获取行政区划列表-全部
+     */
+    @ApiAuth
+    @RequestMapping(value = "/getAll", method = RequestMethod.GET)
+    @ApiOperation(value = "/getAll", notes = "获取行政区划列表-全部")
+    @ApiResponses({ @ApiResponse(code = 200, message = "success"),
+        @ApiResponse(code = 400, message = "{code:****,message:'fail'}")
+    })
+    public CallResponse<List<GbRegion>> getAll() {
+        CallResponse<List<GbRegion>> callResponse = new CallResponse<>();
+
+        try {
+            List<GbRegion> list = regionMapper.getAll();
+            callResponse.setData(list);
+            callResponse.setCode(0);
+            callResponse.setMessage("success");
+        }
+        catch (Exception e) {
+            throw new BusinessException(-1, e.getMessage());
+        }
+
+        return callResponse;
+    }
+
+    /**
+     * 条件查询
+     */
+    @ApiAuth
+    @RequestMapping(value = "/getByCondition", method = RequestMethod.GET)
+    @ApiOperation(value = "/getByCondition", notes = "查询行政区划-条件查询")
+    @ApiResponses({ @ApiResponse(code = 200, message = "success"),
+        @ApiResponse(code = 400, message = "{code:****,message:'fail'}")
+    })
+    public CallResponse<List<GbRegion>> getSubArea(GbRegion param) {
+        CallResponse<List<GbRegion>> callResponse = new CallResponse<>();
+
+        try {
+            List<GbRegion> list = regionMapper.getGbRegion(param);
+            callResponse.setData(list);
+            callResponse.setCode(0);
+            callResponse.setMessage("success");
+        }
+        catch (Exception e) {
+            throw new BusinessException(-1, e.getMessage());
+        }
+
+        return callResponse;
+    }
+}

+ 172 - 0
common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/controller/WeatherController.java

@@ -0,0 +1,172 @@
+/*
+ * 文 件 名:  WeatherController
+ * 版    权:  华设设计集团股份有限公司
+ * 描    述:  <描述>
+ * 修 改 人:  lvwenbin
+ * 修改时间:  2025/5/8
+ * 跟踪单号:  <跟踪单号>
+ * 修改单号:  <修改单号>
+ * 修改内容:  <修改内容>
+ */
+package com.huashe.common.data.controller;
+
+import com.huashe.common.data.config.ApiAuth;
+import com.huashe.common.data.model.CallResponse;
+import com.huashe.common.data.service.TaskService;
+import com.huashe.common.data.service.WeatherService;
+import com.huashe.common.domain.model.WeatherForecast;
+import com.huashe.common.domain.model.WeatherRt;
+import com.huashe.common.exception.BusinessException;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 天气相关API
+ * <功能详细描述>
+ *
+ * @author lvwenbin
+ * @version [版本号, 2025/5/8]
+ * @see [相关类/方法]
+ * @since [产品/模块版本]
+ */
+@RestController
+@CrossOrigin(allowedHeaders = "*", allowCredentials = "false")
+@RequestMapping("/weather")
+@Api(value = "WeatherController", description = "天气数据接口")
+public class WeatherController {
+    @Autowired
+    private WeatherService weatherService;
+
+    @Autowired
+    private TaskService taskService;
+
+    /**
+     * 实时天气采集
+     */
+    @ApiAuth
+    @RequestMapping(value = "/getWeather", method = RequestMethod.GET)
+    @ApiOperation(value = "/getWeather", notes = "获取实时天气")
+    @ApiResponses({ @ApiResponse(code = 200, message = "success"),
+        @ApiResponse(code = 400, message = "{code:****,message:'fail'}")
+    })
+    public CallResponse<WeatherRt> getWeather(@RequestParam(value = "adcode") String adcode) {
+        CallResponse<WeatherRt> callResponse = new CallResponse<>();
+
+        try {
+            WeatherRt weatherRt = weatherService.getWeatherRt(adcode);
+            callResponse.setData(weatherRt);
+            callResponse.setCode(0);
+            callResponse.setMessage("success");
+        }
+        catch (Exception e) {
+            throw new BusinessException(-1, e.getMessage());
+        }
+
+        return callResponse;
+    }
+
+    /**
+     * 获取历史天气数据
+     */
+    @ApiAuth
+    @RequestMapping(value = "/getWeatherHis", method = RequestMethod.GET)
+    @ApiOperation(value = "/getWeatherHis", notes = "获取天气历史")
+    @ApiResponses({ @ApiResponse(code = 200, message = "success"),
+        @ApiResponse(code = 400, message = "{code:****,message:'fail'}")
+    })
+    public CallResponse<List<WeatherRt>> getWeather(@RequestParam(value = "adcode") String adcode,
+        @RequestParam(value = "startTime") String startTime, @RequestParam(value = "endTime") String endTime) {
+        CallResponse<List<WeatherRt>> callResponse = new CallResponse<>();
+
+        try {
+            List<WeatherRt> list = weatherService.getWeatherHis(adcode, startTime, endTime);
+            callResponse.setData(list);
+            callResponse.setCode(0);
+            callResponse.setMessage("success");
+        }
+        catch (Exception e) {
+            throw new BusinessException(-1, e.getMessage());
+        }
+
+        return callResponse;
+    }
+
+    /**
+     * 获取历史天气数据
+     */
+    @ApiAuth
+    @RequestMapping(value = "/getWeatherForecast", method = RequestMethod.GET)
+    @ApiOperation(value = "/getWeatherForecast", notes = "获取天气预报")
+    @ApiResponses({ @ApiResponse(code = 200, message = "success"),
+        @ApiResponse(code = 400, message = "{code:****,message:'fail'}")
+    })
+    public CallResponse<List<WeatherForecast>> getWeatherForecast(@RequestParam(value = "adcode") String adcode) {
+        CallResponse<List<WeatherForecast>> callResponse = new CallResponse<>();
+
+        try {
+            List<WeatherForecast> list = weatherService.getWeatherForecast(adcode);
+            callResponse.setData(list);
+            callResponse.setCode(0);
+            callResponse.setMessage("success");
+        }
+        catch (Exception e) {
+            throw new BusinessException(-1, e.getMessage());
+        }
+
+        return callResponse;
+    }
+
+    /**
+     * 实时天气采集
+     */
+    @RequestMapping(value = "/triggerColRt", method = RequestMethod.GET)
+    @ApiOperation(value = "/triggerColRt", notes = "触发-天气实况采集")
+    @ApiResponses({ @ApiResponse(code = 200, message = "success"),
+        @ApiResponse(code = 400, message = "{code:****,message:'fail'}")
+    })
+    public CallResponse<Void> colRt() {
+        CallResponse<Void> callResponse = new CallResponse<>();
+        try {
+            taskService.collectWeatherRt();
+            callResponse.setCode(0);
+            callResponse.setMessage("success");
+        }
+        catch (Exception e) {
+            throw new BusinessException(-1, e.getMessage());
+        }
+
+        return callResponse;
+    }
+
+    /**
+     * 实时天气采集
+     */
+    @RequestMapping(value = "/triggercolForecast", method = RequestMethod.GET)
+    @ApiOperation(value = "/triggercolForecast", notes = "触发-预报天气采集")
+    @ApiResponses({ @ApiResponse(code = 200, message = "success"),
+        @ApiResponse(code = 400, message = "{code:****,message:'fail'}")
+    })
+    public CallResponse<Void> colForecast() {
+        CallResponse<Void> callResponse = new CallResponse<>();
+        try {
+            taskService.collectWeatherForecast();
+            callResponse.setCode(0);
+            callResponse.setMessage("success");
+        }
+        catch (Exception e) {
+            throw new BusinessException(-1, e.getMessage());
+        }
+
+        return callResponse;
+    }
+}

+ 69 - 0
common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/controller/interceptor/AuthInterceptor.java

@@ -0,0 +1,69 @@
+/*
+ * 文 件 名:  AuthInterceptor
+ * 版    权:  华设设计集团股份有限公司
+ * 描    述:  <描述>
+ * 修 改 人:  lvwenbin
+ * 修改时间:  2025/5/8
+ * 跟踪单号:  <跟踪单号>
+ * 修改单号:  <修改单号>
+ * 修改内容:  <修改内容>
+ */
+package com.huashe.common.data.controller.interceptor;
+
+import com.huashe.common.data.config.ApiAuth;
+import com.huashe.common.data.config.AuthKeyType;
+import com.huashe.common.data.service.AuthService;
+import com.huashe.common.exception.BusinessException;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.method.HandlerMethod;
+import org.springframework.web.servlet.HandlerInterceptor;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * 认证拦截器
+ * <功能详细描述>
+ *
+ * @author lvwenbin
+ * @version [版本号, 2025/5/8]
+ * @see [相关类/方法]
+ * @since [产品/模块版本]
+ */
+public class AuthInterceptor implements HandlerInterceptor {
+    @Autowired
+    private AuthService authService;
+
+    @Override
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
+        if (!(handler instanceof HandlerMethod)) {
+            return true;
+        }
+
+        HandlerMethod handlerMethod = (HandlerMethod) handler;
+        ApiAuth apiAuth = handlerMethod.getMethodAnnotation(ApiAuth.class);
+
+        // 不需要认证的方法直接放行
+        if (apiAuth == null || !apiAuth.required()) {
+            return true;
+        }
+
+        // 获取客户端密钥
+        String clientKey = getClientKey(request, apiAuth.type());
+        if (StringUtils.isEmpty(clientKey)) {
+            throw new BusinessException(-1, "Api秘钥缺失,拒绝访问!");
+        }
+
+        // 验证密钥有效性
+        if (!authService.validateKey(clientKey)) {
+            throw new BusinessException(-1, "非法客户端调用,拒绝访问!");
+        }
+
+        return true;
+    }
+
+    private String getClientKey(HttpServletRequest request, AuthKeyType type) {
+        return type == AuthKeyType.HEADER ? request.getHeader("X-API-Key") : request.getParameter("apiKey");
+    }
+}

+ 40 - 0
common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/controller/interceptor/GlobalExceptionHandler.java

@@ -0,0 +1,40 @@
+/*
+ * 文 件 名:  GlobalExceptionHandler
+ * 版    权:  华设设计集团股份有限公司
+ * 描    述:  <描述>
+ * 修 改 人:  lvwenbin
+ * 修改时间:  2025/5/8
+ * 跟踪单号:  <跟踪单号>
+ * 修改单号:  <修改单号>
+ * 修改内容:  <修改内容>
+ */
+package com.huashe.common.data.controller.interceptor;
+
+import com.huashe.common.exception.BusinessException;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * 全局异常
+ * <功能详细描述>
+ *
+ * @author lvwenbin
+ * @version [版本号, 2025/5/8]
+ * @see [相关类/方法]
+ * @since [产品/模块版本]
+ */
+@ControllerAdvice
+public class GlobalExceptionHandler {
+    @ExceptionHandler(BusinessException.class)
+    public ResponseEntity<Map<String, Object>> handleBusinessException(BusinessException ex) {
+        Map<String, Object> body = new LinkedHashMap<>();
+        body.put("code", ex.getCode());
+        body.put("message", ex.getMessage());
+        return new ResponseEntity<>(body, HttpStatus.FORBIDDEN);
+    }
+}

+ 56 - 0
common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/mapper/AdmApiAuthMapper.java

@@ -0,0 +1,56 @@
+/*
+ * 文 件 名:  DwdWeatherHourRtMapper
+ * 版    权:
+ * 描    述:  <描述>
+ * 修 改 人:  learshaw
+ * 修改时间:  2021/9/22
+ * 跟踪单号:  <跟踪单号>
+ * 修改单号:  <修改单号>
+ * 修改内容:  <修改内容>
+ */
+package com.huashe.common.data.mapper;
+
+import com.huashe.common.data.model.AdmApiAuth;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 小时天气时空保存
+ * <功能详细描述>
+ *
+ * @author learshaw
+ * @version [版本号, 2021/9/22]
+ * @see [相关类/方法]
+ * @since [产品/模块版本]
+ */
+@Mapper
+public interface AdmApiAuthMapper {
+    /**
+     * 新增认证配置
+     *
+     * @param admApiAuth 配置对象
+     */
+    void insert(AdmApiAuth admApiAuth);
+
+    /**
+     * 新增认证配置
+     *
+     * @param admApiAuth 配置对象
+     */
+    void update(AdmApiAuth admApiAuth);
+
+    /**
+     * 删除认证配置
+     *
+     * @param clientId 客户端编号
+     */
+    void delete(@Param("clientId") String clientId);
+
+    /**
+     * 查询Api认证记录
+     *
+     * @param apiKey 认证记录
+     * @return 认证配置对象
+     */
+    AdmApiAuth getByKey(@Param("apiKey") String apiKey);
+}

+ 11 - 3
common-cloud/tool-modules/collect-weather/src/main/java/com/huashe/common/weather/mapper/AdmWeatherForecastMapper.java → common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/mapper/AdmWeatherForecastMapper.java

@@ -8,7 +8,7 @@
  * 修改单号:  <修改单号>
  * 修改内容:  <修改内容>
  */
-package com.huashe.common.weather.mapper;
+package com.huashe.common.data.mapper;
 
 import com.huashe.common.domain.model.WeatherForecast;
 import com.huashe.common.domain.model.WeatherRt;
@@ -29,9 +29,12 @@ import java.util.List;
 @Mapper
 public interface AdmWeatherForecastMapper {
     /**
-     * 根据区划代码删除
+     * 根据adcode和date查询
+     * @param adcode 行政区划代码
+
+     * @return List<WeatherRt>
      */
-    void deleteByAdcode(@Param("adcode") String adcode);
+    List<WeatherForecast> getByAdcode(@Param("adcode") String adcode);
 
     /**
      * 天气预报入库
@@ -39,4 +42,9 @@ public interface AdmWeatherForecastMapper {
      * @param list 对象
      */
     void insertBatch(List<WeatherForecast> list);
+
+    /**
+     * 根据区划代码删除
+     */
+    void deleteByAdcode(@Param("adcode") String adcode);
 }

+ 19 - 2
common-cloud/tool-modules/collect-weather/src/main/java/com/huashe/common/weather/mapper/AdmWeatherRtMapper.java → common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/mapper/AdmWeatherRtMapper.java

@@ -8,11 +8,11 @@
  * 修改单号:  <修改单号>
  * 修改内容:  <修改内容>
  */
-package com.huashe.common.weather.mapper;
+package com.huashe.common.data.mapper;
 
 import com.huashe.common.domain.model.WeatherRt;
-import com.huashe.common.weather.model.DwdWeatherHourRt;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -33,4 +33,21 @@ public interface AdmWeatherRtMapper {
      * @param poItem 对象
      */
     void merge(WeatherRt poItem);
+
+    /**
+     * 获取最新数据
+     * @param adcode 行政区划代码
+     * @return WeatherRt
+     */
+    WeatherRt getNewByAdcode(@Param("adcode") String adcode);
+
+    /**
+     * 根据adcode和date查询
+     * @param adcode 行政区划代码
+     * @param startTime 开始时间
+     * @param endTime 结束时间
+     * @return List<WeatherRt>
+     */
+    List<WeatherRt> getByTime(@Param("adcode") String adcode, @Param("startTime") String startTime,
+        @Param("endTime") String endTime);
 }

+ 19 - 4
common-cloud/tool-modules/collect-weather/src/main/java/com/huashe/common/weather/mapper/DimGbRegionMapper.java → common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/mapper/DimGbRegionMapper.java

@@ -8,10 +8,10 @@
  * 修改单号:  <修改单号>
  * 修改内容:  <修改内容>
  */
-package com.huashe.common.weather.mapper;
+package com.huashe.common.data.mapper;
 
+import com.huashe.common.domain.model.GbRegion;
 import org.apache.ibatis.annotations.Mapper;
-import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -27,8 +27,23 @@ import java.util.List;
 @Mapper
 public interface DimGbRegionMapper {
     /**
-     * 查询区域
+     * 查询全部行政区划
+     *
+     * @return 行政区划
+     */
+    List<GbRegion> getAll();
+
+    /**
+     * 查询子区域
+     *
+     * @return 行政区划
+     */
+    List<GbRegion> getGbRegion(GbRegion param);
+
+    /**
+     * 查询地级市
+     *
      * @return 区域列表
      */
-    List<String> fetchArea();
+    List<String> getPrefectureLevelCity();
 }

+ 105 - 0
common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/model/AdmApiAuth.java

@@ -0,0 +1,105 @@
+/*
+ * 文 件 名:  AdmApiAuth
+ * 版    权:  华设设计集团股份有限公司
+ * 描    述:  <描述>
+ * 修 改 人:  lvwenbin
+ * 修改时间:  2025/5/8
+ * 跟踪单号:  <跟踪单号>
+ * 修改单号:  <修改单号>
+ * 修改内容:  <修改内容>
+ */
+package com.huashe.common.data.model;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import java.util.Date;
+
+/**
+ * 接口认证配置对象
+ * <功能详细描述>
+ *
+ * @author lvwenbin
+ * @version [版本号, 2025/5/8]
+ * @see [相关类/方法]
+ * @since [产品/模块版本]
+ */
+public class AdmApiAuth {
+    /**
+     * 认证配置ID
+     */
+    private Integer id;
+
+    /**
+     * 客户端ID
+     */
+    private String clientId;
+
+    /**
+     * 客户端名称
+     */
+    private String clientName;
+
+    /**
+     * API密钥
+     */
+    private String apiKey;
+
+    /**
+     * 状态
+     */
+    private Integer status;
+
+    /**
+     * 过期时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date expireTime;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getClientId() {
+        return clientId;
+    }
+
+    public void setClientId(String clientId) {
+        this.clientId = clientId;
+    }
+
+    public String getClientName() {
+        return clientName;
+    }
+
+    public void setClientName(String clientName) {
+        this.clientName = clientName;
+    }
+
+    public String getApiKey() {
+        return apiKey;
+    }
+
+    public void setApiKey(String apiKey) {
+        this.apiKey = apiKey;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public Date getExpireTime() {
+        return expireTime;
+    }
+
+    public void setExpireTime(Date expireTime) {
+        this.expireTime = expireTime;
+    }
+}

+ 1 - 1
common-cloud/tool-modules/collect-weather/src/main/java/com/huashe/common/weather/model/BaseWeather.java → common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/model/BaseWeather.java

@@ -8,7 +8,7 @@
  * 修改单号:  <修改单号>
  * 修改内容:  <修改内容>
  */
-package com.huashe.common.weather.model;
+package com.huashe.common.data.model;
 
 import java.util.List;
 

+ 60 - 0
common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/model/CallResponse.java

@@ -0,0 +1,60 @@
+/*
+ * 文 件 名:  CallResponse
+ * 版    权:  华设设计集团股份有限公司
+ * 描    述:  <描述>
+ * 修 改 人:  lvwenbin
+ * 修改时间:  2025/2/27
+ * 跟踪单号:  <跟踪单号>
+ * 修改单号:  <修改单号>
+ * 修改内容:  <修改内容>
+ */
+package com.huashe.common.data.model;
+
+/**
+ * 调用响应
+ * <功能详细描述>
+ *
+ * @author lvwenbin
+ * @version [版本号, 2025/2/27]
+ * @see [相关类/方法]
+ * @since [产品/模块版本]
+ */
+public class CallResponse<T> {
+    private int code;
+
+    private String message;
+
+    private T data;
+
+    public CallResponse() {
+    }
+
+    public CallResponse(int code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+    public int getCode() {
+        return code;
+    }
+
+    public void setCode(int code) {
+        this.code = code;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
+    public T getData() {
+        return data;
+    }
+
+    public void setData(T data) {
+        this.data = data;
+    }
+}

+ 41 - 0
common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/service/AuthService.java

@@ -0,0 +1,41 @@
+/*
+ * 文 件 名:  AuthService
+ * 版    权:  华设设计集团股份有限公司
+ * 描    述:  <描述>
+ * 修 改 人:  lvwenbin
+ * 修改时间:  2025/5/8
+ * 跟踪单号:  <跟踪单号>
+ * 修改单号:  <修改单号>
+ * 修改内容:  <修改内容>
+ */
+package com.huashe.common.data.service;
+
+import com.huashe.common.data.mapper.AdmApiAuthMapper;
+import com.huashe.common.data.model.AdmApiAuth;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+
+/**
+ * 认证服务
+ * <功能详细描述>
+ *
+ * @author lvwenbin
+ * @version [版本号, 2025/5/8]
+ * @see [相关类/方法]
+ * @since [产品/模块版本]
+ */
+@Service
+public class AuthService {
+    @Autowired
+    private AdmApiAuthMapper apiAuthMapper;
+
+    @Cacheable(value = "apiKeys", key = "#clientKey")
+    public boolean validateKey(String clientKey) {
+        AdmApiAuth apiAuthCfg = apiAuthMapper.getByKey(clientKey);
+        return apiAuthCfg != null && apiAuthCfg.getStatus() == 1 && (apiAuthCfg.getExpireTime() == null
+            || apiAuthCfg.getExpireTime().after(new Date()));
+    }
+}

+ 1 - 1
common-cloud/tool-modules/collect-weather/src/main/java/com/huashe/common/weather/service/RegionService.java → common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/service/RegionService.java

@@ -8,7 +8,7 @@
  * 修改单号:  <修改单号>
  * 修改内容:  <修改内容>
  */
-package com.huashe.common.weather.service;
+package com.huashe.common.data.service;
 
 import java.util.List;
 

+ 3 - 9
common-cloud/tool-modules/collect-weather/src/main/java/com/huashe/common/weather/service/TaskService.java → common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/service/TaskService.java

@@ -8,13 +8,11 @@
  * 修改单号:  <修改单号>
  * 修改内容:  <修改内容>
  */
-package com.huashe.common.weather.service;
+package com.huashe.common.data.service;
 
 import com.huashe.common.exception.Assert;
 import com.huashe.common.exception.BusinessException;
 import com.huashe.common.utils.ThreadUtils;
-import com.huashe.common.weather.model.DwdWeatherHourRt;
-import org.apache.commons.collections4.CollectionUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Qualifier;
@@ -24,11 +22,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Date;
 import java.util.List;
-import java.util.concurrent.Future;
 
 /**
  * 任务驱动
@@ -57,7 +51,7 @@ public class TaskService {
      * @see [类、类#方法、类#成员]
      */
     @Async
-    @Scheduled(cron = "${collect.rt-cron}")
+    @Scheduled(cron = "${weather.rt-cron}")
     public void collectWeatherRt() {
         log.info("开始天气采集任务...");
 
@@ -83,7 +77,7 @@ public class TaskService {
      * @see [类、类#方法、类#成员]
      */
     @Async
-    @Scheduled(cron = "${collect.forecast-cron}")
+    @Scheduled(cron = "${weather.forecast-cron}")
     public void collectWeatherForecast() {
         log.info("开始天气采集任务...");
 

+ 1 - 7
common-cloud/tool-modules/collect-weather/src/main/java/com/huashe/common/weather/service/WeatherColService.java → common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/service/WeatherColService.java

@@ -8,13 +8,7 @@
  * 修改单号:  <修改单号>
  * 修改内容:  <修改内容>
  */
-package com.huashe.common.weather.service;
-
-import com.huashe.common.domain.model.WeatherForecast;
-import com.huashe.common.domain.model.WeatherRt;
-import com.huashe.common.weather.model.DwdWeatherHourRt;
-
-import java.util.Date;
+package com.huashe.common.data.service;
 
 /**
  * 天气采集

+ 53 - 0
common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/service/WeatherService.java

@@ -0,0 +1,53 @@
+/*
+ * 文 件 名:  WeatherService
+ * 版    权:  华设设计集团股份有限公司
+ * 描    述:  <描述>
+ * 修 改 人:  lvwenbin
+ * 修改时间:  2025/5/8
+ * 跟踪单号:  <跟踪单号>
+ * 修改单号:  <修改单号>
+ * 修改内容:  <修改内容>
+ */
+package com.huashe.common.data.service;
+
+import com.huashe.common.domain.model.WeatherForecast;
+import com.huashe.common.domain.model.WeatherRt;
+
+import java.util.List;
+
+/**
+ * 天气数据服务
+ * <功能详细描述>
+ *
+ * @author lvwenbin
+ * @version [版本号, 2025/5/8]
+ * @see [相关类/方法]
+ * @since [产品/模块版本]
+ */
+public interface WeatherService {
+    /**
+     * 获取实时天气
+     *
+     * @param adcode 行政区划代码
+     * @return 实时天气数据
+     */
+    WeatherRt getWeatherRt(String adcode);
+
+    /**
+     * 获取历史天气数据
+     *
+     * @param adcode    行政区划代码
+     * @param startTime 开始时间
+     * @param endTime   结束时间
+     * @return 历史天气数据列表
+     */
+    List<WeatherRt> getWeatherHis(String adcode, String startTime, String endTime);
+
+    /**
+     * 获取未来天气预报
+     *
+     * @param adcode 行政区划代码
+     * @return 未来天气预报数据
+     */
+    List<WeatherForecast> getWeatherForecast(String adcode);
+}

+ 8 - 11
common-cloud/tool-modules/collect-weather/src/main/java/com/huashe/common/weather/service/impl/RegionConfServiceImpl.java → common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/service/impl/RegionConfServiceImpl.java

@@ -8,16 +8,16 @@
  * 修改单号:  <修改单号>
  * 修改内容:  <修改内容>
  */
-package com.huashe.common.weather.service.impl;
+package com.huashe.common.data.service.impl;
 
-import com.huashe.common.weather.config.RegionConfig;
-import com.huashe.common.weather.service.RegionService;
+import com.huashe.common.data.config.CollectConfig;
+import com.huashe.common.data.service.RegionService;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.stereotype.Service;
 
-import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -31,18 +31,15 @@ import java.util.List;
  * @see [相关类/方法]
  * @since [产品/模块版本]
  */
-@ConditionalOnProperty(prefix = "collect.region", name = "source", havingValue = "conf", matchIfMissing = false)
+@ConditionalOnProperty(prefix = "weather.region", name = "source", havingValue = "conf", matchIfMissing = false)
 @Service
 public class RegionConfServiceImpl implements RegionService {
-    /**
-     * 系统配置
-     */
-    @Resource
-    private RegionConfig config;
+    @Autowired
+    private CollectConfig collectConfig;
 
     @Override
     public List<String> fetch() {
-        String cfgStr = config.getConfAdcodes();
+        String cfgStr = collectConfig.getWeatherAdcodes();
 
         String[] areaArray = null;
 

+ 5 - 5
common-cloud/tool-modules/collect-weather/src/main/java/com/huashe/common/weather/service/impl/RegionDbServiceImpl.java → common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/service/impl/RegionDbServiceImpl.java

@@ -8,10 +8,10 @@
  * 修改单号:  <修改单号>
  * 修改内容:  <修改内容>
  */
-package com.huashe.common.weather.service.impl;
+package com.huashe.common.data.service.impl;
 
-import com.huashe.common.weather.mapper.DimGbRegionMapper;
-import com.huashe.common.weather.service.RegionService;
+import com.huashe.common.data.mapper.DimGbRegionMapper;
+import com.huashe.common.data.service.RegionService;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.stereotype.Service;
 
@@ -27,7 +27,7 @@ import java.util.List;
  * @see [相关类/方法]
  * @since [产品/模块版本]
  */
-@ConditionalOnProperty(prefix = "collect.region", name = "source", havingValue = "db", matchIfMissing = false)
+@ConditionalOnProperty(prefix = "weather.region", name = "source", havingValue = "db", matchIfMissing = false)
 @Service
 public class RegionDbServiceImpl implements RegionService {
     /**
@@ -38,6 +38,6 @@ public class RegionDbServiceImpl implements RegionService {
 
     @Override
     public List<String> fetch() {
-        return mapper.fetchArea();
+        return mapper.getPrefectureLevelCity();
     }
 }

+ 6 - 6
common-cloud/tool-modules/collect-weather/src/main/java/com/huashe/common/weather/service/impl/WeatherColAmapServiceImpl.java → common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/service/impl/WeatherColAmapServiceImpl.java

@@ -8,7 +8,7 @@
  * 修改单号:  <修改单号>
  * 修改内容:  <修改内容>
  */
-package com.huashe.common.weather.service.impl;
+package com.huashe.common.data.service.impl;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
@@ -16,11 +16,11 @@ import com.alibaba.fastjson.JSONObject;
 import com.huashe.common.domain.model.WeatherForecast;
 import com.huashe.common.domain.model.WeatherRt;
 import com.huashe.common.exception.Assert;
-import com.huashe.common.weather.config.AmapWeatherConfig;
-import com.huashe.common.weather.mapper.AdmWeatherForecastMapper;
-import com.huashe.common.weather.mapper.AdmWeatherRtMapper;
-import com.huashe.common.weather.service.WeatherColService;
-import com.huashe.common.weather.util.HttpUtils;
+import com.huashe.common.data.config.AmapWeatherConfig;
+import com.huashe.common.data.mapper.AdmWeatherForecastMapper;
+import com.huashe.common.data.mapper.AdmWeatherRtMapper;
+import com.huashe.common.data.service.WeatherColService;
+import com.huashe.common.data.util.HttpUtils;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;

+ 56 - 0
common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/service/impl/WeatherServiceimpl.java

@@ -0,0 +1,56 @@
+/*
+ * 文 件 名:  WeatherServiceimpl
+ * 版    权:  华设设计集团股份有限公司
+ * 描    述:  <描述>
+ * 修 改 人:  lvwenbin
+ * 修改时间:  2025/5/8
+ * 跟踪单号:  <跟踪单号>
+ * 修改单号:  <修改单号>
+ * 修改内容:  <修改内容>
+ */
+package com.huashe.common.data.service.impl;
+
+import com.huashe.common.data.mapper.AdmWeatherForecastMapper;
+import com.huashe.common.data.mapper.AdmWeatherRtMapper;
+import com.huashe.common.data.service.WeatherService;
+import com.huashe.common.domain.model.WeatherForecast;
+import com.huashe.common.domain.model.WeatherRt;
+import com.huashe.common.utils.DateUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 天气数据服务实现
+ * <功能详细描述>
+ *
+ * @author lvwenbin
+ * @version [版本号, 2025/5/8]
+ * @see [相关类/方法]
+ * @since [产品/模块版本]
+ */
+@Service
+public class WeatherServiceimpl implements WeatherService {
+    @Resource
+    private AdmWeatherRtMapper weatherRtMapper;
+
+    @Resource
+    private AdmWeatherForecastMapper weatherForecastMapper;
+
+    @Override
+    public WeatherRt getWeatherRt(String adcode) {
+        return weatherRtMapper.getNewByAdcode(adcode);
+    }
+
+    @Override
+    public List<WeatherRt> getWeatherHis(String adcode, String startTime, String endTime) {
+        return weatherRtMapper.getByTime(adcode, startTime, endTime);
+    }
+
+    @Override
+    public List<WeatherForecast> getWeatherForecast(String adcode) {
+        return weatherForecastMapper.getByAdcode(adcode);
+    }
+}

+ 1 - 1
common-cloud/tool-modules/collect-weather/src/main/java/com/huashe/common/weather/util/HttpUtils.java → common-cloud/tool-modules/general-data/src/main/java/com/huashe/common/data/util/HttpUtils.java

@@ -8,7 +8,7 @@
  * 修改单号:  <修改单号>
  * 修改内容:  <修改内容>
  */
-package com.huashe.common.weather.util;
+package com.huashe.common.data.util;
 
 import com.huashe.common.exception.Assert;
 import com.huashe.common.exception.BusinessException;

+ 32 - 0
common-cloud/tool-modules/general-data/src/main/resources/application-locale.yml

@@ -0,0 +1,32 @@
+spring:
+  datasource:
+    username: root
+    password: 'abc123'
+    url: jdbc:mariadb://172.192.13.95:3310/common_data?characterEncoding=utf8&useSSL=false&allowMultiQueries=true
+    driver-class-name: org.mariadb.jdbc.Driver
+
+mybatis:
+  mapper-locations: classpath:mapper/*.xml
+  type-aliases-package: com.huashe.common.domain.model,com.huashe.common.weather.model
+
+weather:
+  rt-cron: 0 15 0,6,12,18 * * ?
+  forecast-cron: 0 15 6 * * ?
+  # 服务提供商
+  service-provider: amap
+  region:
+    # 数据来源 db、conf
+    source: db
+    conf-adcodes:
+  amap:
+    url: https://restapi.amap.com/v3/weather/weatherInfo?key=${weather.amap.key}&city=#{adcode}&extensions=#{extensions}&output=JSON
+    key: 9a5a4852c8698e783989e7f376d77816
+    weatherList:
+      - '1101:晴'
+      - '1103:多云'
+      - '1106:阴'
+      - '2200:雪'
+      - '2100:雨'
+      - '4100:雾'
+      - '4200:霾'
+      - '4300:沙'

+ 1 - 1
common-cloud/tool-modules/collect-weather/src/main/resources/application.yml → common-cloud/tool-modules/general-data/src/main/resources/application.yml

@@ -7,4 +7,4 @@ spring:
 server:
   port: 9300
   servlet:
-    context-path: /common/weather
+    context-path: /general-data

+ 1 - 1
common-cloud/tool-modules/collect-weather/src/main/resources/logback-spring.xml → common-cloud/tool-modules/general-data/src/main/resources/logback-spring.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <configuration scan="true" scanPeriod="60 seconds" debug="false">
 	<!-- 日志存放路径 -->
-	<property name="log.path" value="logs/weather-collect" />
+	<property name="log.path" value="logs/general-data" />
 	<!-- 日志输出格式 -->
 	<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
 

+ 38 - 0
common-cloud/tool-modules/general-data/src/main/resources/mapper/AdmApiAuthMapper.xml

@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.huashe.common.data.mapper.AdmApiAuthMapper">
+    <resultMap id="BaseResultMap" type="com.huashe.common.data.model.AdmApiAuth">
+        <result column="id" property="id" jdbcType="BIGINT"/>
+        <result column="client_id" property="clientId" jdbcType="VARCHAR"/>
+        <result column="client_name" property="clientName" jdbcType="VARCHAR"/>
+        <result column="api_key" property="apiKey" jdbcType="VARCHAR"/>
+        <result column="status" property="status" jdbcType="VARCHAR"/>
+        <result column="expire_time" property="expireTime" jdbcType="DATE"/>
+    </resultMap>
+
+    <insert id="insert" parameterType="com.huashe.common.data.model.AdmApiAuth">
+        INSERT INTO `adm_api_auth` (`client_id`, `client_name`, `api_key`, `status`, `expire_time`) VALUES (#{clientId}, #{clientName}, #{apiKey}, #{status}, #{expireTime});
+    </insert>
+
+    <update id="update" parameterType="com.huashe.common.data.model.AdmApiAuth">
+        UPDATE `adm_api_auth`
+        SET `client_name` = #{clientName},
+            `api_key` = #{apiKey},
+            `status` = #{status},
+            `expire_time` = #{expireTime}
+        WHERE `client_id` = #{clientId};
+    </update>
+
+    <delete id="delete" parameterType="java.lang.String">
+        DELETE FROM `adm_api_auth` WHERE `client_id` = #{clientId};
+    </delete>
+
+    <select id="getByKey" resultType="java.lang.String" resultMap="BaseResultMap">
+        SELECT
+            `id`, `client_id`, `client_name`, `api_key`, `status`, `expire_time`
+        FROM
+            adm_api_auth
+        WHERE
+            `api_key` = #{apiKey}
+    </select>
+</mapper>

+ 11 - 4
common-cloud/tool-modules/collect-weather/src/main/resources/mapper/AdmWeatherForecastMapper.xml → common-cloud/tool-modules/general-data/src/main/resources/mapper/AdmWeatherForecastMapper.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
-<mapper namespace="com.huashe.common.weather.mapper.AdmWeatherForecastMapper">
+<mapper namespace="com.huashe.common.data.mapper.AdmWeatherForecastMapper">
     <resultMap id="BaseResultMap" type="com.huashe.common.domain.model.WeatherForecast">
         <result column="adcode" property="adcode" jdbcType="VARCHAR"/>
         <result column="area_name" property="areaName" jdbcType="VARCHAR"/>
@@ -18,9 +18,12 @@
         <result column="report_time" property="reportTime" jdbcType="TIMESTAMP"/>
     </resultMap>
 
-    <delete id="deleteByAdcode" parameterType="java.lang.String">
-        delete from `adm_area_weather_forecast` where adcode = #{adcode}
-    </delete>
+    <select id="getByAdcode" parameterType="java.lang.String" resultMap="BaseResultMap" >
+        SELECT
+            `adcode`, `area_name`, `date`, `day_weather_type`, `day_weather_cn`, `night_weather_type`, `night_weather_cn`, `day_temp`, `night_temp`, `day_wind_power`, `night_wind_power`, `day_wind_dir`, `night_wind_dir`, `report_time`
+        FROM `adm_area_weather_forecast`
+        WHERE `adcode` = #{adcode}
+    </select>
 
     <update id="insertBatch" parameterType="java.util.List">
         INSERT INTO `adm_area_weather_forecast`
@@ -31,4 +34,8 @@
              #{item.dayTemp}, #{item.nightTemp}, #{item.dayWindPower}, #{item.nightWindPower}, #{item.dayWindDir}, #{item.nightWindDir}, #{item.reportTime})
         </foreach>
     </update>
+
+    <delete id="deleteByAdcode" parameterType="java.lang.String">
+        delete from `adm_area_weather_forecast` where adcode = #{adcode}
+    </delete>
 </mapper>

+ 15 - 1
common-cloud/tool-modules/collect-weather/src/main/resources/mapper/AdmWeatherRtMapper.xml → common-cloud/tool-modules/general-data/src/main/resources/mapper/AdmWeatherRtMapper.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
-<mapper namespace="com.huashe.common.weather.mapper.AdmWeatherRtMapper">
+<mapper namespace="com.huashe.common.data.mapper.AdmWeatherRtMapper">
     <resultMap id="BaseResultMap" type="com.huashe.common.domain.model.WeatherRt">
         <result column="adcode" property="adcode" jdbcType="VARCHAR"/>
         <result column="area_name" property="areaName" jdbcType="VARCHAR"/>
@@ -30,4 +30,18 @@
         )
         VALUES (#{adcode}, #{areaName}, #{date}, #{weatherType}, #{weatherCn}, #{temperature}, #{humidity}, #{windPower}, #{windDirection}, #{reportTime})
     </update>
+
+    <select id="getNewByAdcode" resultMap="BaseResultMap">
+        select
+            `adcode`,`area_name`,`date`,`weather_type`,`weather_cn`,`temperature`,`humidity`,`wind_power`,`wind_direction`,`report_time`
+        from `adm_area_weather_rt`
+        where `adcode` = #{adcode} order by `date` desc limit 1
+    </select>
+
+    <select id="getByTime" resultMap="BaseResultMap">
+        select
+            `adcode`,`area_name`,`date`,`weather_type`,`weather_cn`,`temperature`,`humidity`,`wind_power`,`wind_direction`,`report_time`
+        from `adm_area_weather_rt`
+        where `adcode` = #{adcode} and `date` &gt;= STR_TO_DATE(#{startTime},'%Y-%m-%d') and date &lt;= STR_TO_DATE(#{endTime},'%Y-%m-%d')
+    </select>
 </mapper>

+ 21 - 2
common-cloud/tool-modules/collect-weather/src/main/resources/mapper/DimGbRegionMapper.xml → common-cloud/tool-modules/general-data/src/main/resources/mapper/DimGbRegionMapper.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
-<mapper namespace="com.huashe.common.weather.mapper.DimGbRegionMapper">
+<mapper namespace="com.huashe.common.data.mapper.DimGbRegionMapper">
     <resultMap id="BaseResultMap" type="com.huashe.common.domain.model.GbRegion">
         <result column="adcode" property="adcode" jdbcType="VARCHAR"/>
         <result column="name" property="name" jdbcType="VARCHAR"/>
@@ -9,7 +9,26 @@
         <result column="parent_area_name" property="parentAreaName" jdbcType="VARCHAR"/>
     </resultMap>
 
-    <select id="fetchArea" resultType="java.lang.String">
+    <sql id="selectGbRegion">
+        SELECT
+            `adcode`, `name`, `area_type`, `parent_area`, `parent_area_name`
+        FROM
+            dim_gb_region
+    </sql>
+
+    <select id="getAll" resultMap="BaseResultMap">
+        <include refid="selectGbRegion"/>
+    </select>
+
+    <select id="getGbRegion" parameterType="com.huashe.common.domain.model.GbRegion" resultMap="BaseResultMap">
+        <include refid="selectGbRegion"/>
+        <where>
+            <if test="parentArea != null and parentArea != ''">and parent_area = #{parentArea}</if>
+            <if test="areaType != null">and area_type = #{areaType}</if>
+        </where>
+    </select>
+
+    <select id="getPrefectureLevelCity" resultType="java.lang.String">
         SELECT
             `adcode`
         FROM

+ 2 - 2
common-cloud/tool-modules/pom.xml

@@ -12,7 +12,7 @@
     <name>tool-modules</name>
 
     <modules>
-        <!-- 天气采集 -->
-        <module>collect-weather</module>
+        <!-- 通用数据服务 -->
+        <module>general-data</module>
     </modules>
 </project>