16 changed files with 450 additions and 56 deletions
@ -0,0 +1,63 @@
|
||||
package com.mh.common.core.domain.dto; |
||||
|
||||
import lombok.Data; |
||||
import org.apache.commons.lang3.builder.ToStringBuilder; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description 天气温度历史记录查询 |
||||
* @date 2025-06-16 11:21:48 |
||||
*/ |
||||
@Data |
||||
public class WeatherDataDTO { |
||||
|
||||
/** |
||||
* 时间 |
||||
*/ |
||||
private String weatherDate; |
||||
|
||||
/** |
||||
* 日期和星期 |
||||
*/ |
||||
private String dateAndWeek; |
||||
|
||||
/** |
||||
* 最高温度 |
||||
*/ |
||||
private String maxTemp; |
||||
|
||||
/** |
||||
* 最低温度 |
||||
*/ |
||||
private String minTemp; |
||||
|
||||
/** |
||||
* 天气 |
||||
*/ |
||||
private String weatherConditions; |
||||
|
||||
/** |
||||
* 风向 |
||||
*/ |
||||
private String windDirection; |
||||
|
||||
/** |
||||
* 风速 |
||||
*/ |
||||
private String windPower; |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return new ToStringBuilder(this) |
||||
.append("weatherDate", weatherDate) |
||||
.append("dateAndWeek", dateAndWeek) |
||||
.append("maxTemp", maxTemp) |
||||
.append("minTemp", minTemp) |
||||
.append("weatherConditions", weatherConditions) |
||||
.append("windDirection", windDirection) |
||||
.append("windPower", windPower) |
||||
.toString(); |
||||
} |
||||
} |
||||
@ -0,0 +1,72 @@
|
||||
package com.mh.quartz.task; |
||||
|
||||
import com.mh.common.core.domain.entity.WeatherData; |
||||
import com.mh.common.utils.WeatherUtil; |
||||
import com.mh.system.service.IWeatherDataService; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.math.RoundingMode; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description 广工需要的数据计算 |
||||
* @date 2026-04-21 19:05:21 |
||||
*/ |
||||
@Slf4j |
||||
@Component("ahuTask") |
||||
public class GGDataTask { |
||||
|
||||
@Autowired |
||||
private IWeatherDataService weatherDataService; |
||||
|
||||
public void calcWeatherData() { |
||||
// 从天气预报保存的表中获取没有焓值的数据
|
||||
WeatherUtil weatherUtil = new WeatherUtil(); |
||||
List<WeatherData> weatherDataList = weatherDataService.selectByEnthalpyEtc(); |
||||
if (weatherDataList != null && !weatherDataList.isEmpty()) { |
||||
// 室外压力,采用标准大气压 101325 Pa
|
||||
String pressure = "101.325"; |
||||
for (WeatherData weatherData : weatherDataList) { |
||||
|
||||
// 室外温度
|
||||
int temperature = weatherData.getTemperature(); |
||||
|
||||
// 室外湿度
|
||||
int humidity = weatherData.getHumidity(); |
||||
|
||||
// 室外含湿
|
||||
String wet = String.valueOf(new BigDecimal(humidity).divide(new BigDecimal("100")).setScale(1, RoundingMode.HALF_UP)); |
||||
BigDecimal humidityRatio = weatherUtil.returnMoistureContent(String.valueOf(temperature), |
||||
wet, |
||||
pressure); |
||||
weatherData.setHumidityContent(humidityRatio.setScale(1, RoundingMode.HALF_UP).doubleValue()); |
||||
|
||||
// 室外焓值
|
||||
BigDecimal enthalpy = weatherUtil.returnEnthalpy(String.valueOf(temperature), |
||||
wet, |
||||
pressure); |
||||
weatherData.setEnthalpy(enthalpy.setScale(1, RoundingMode.HALF_UP).doubleValue()); |
||||
|
||||
// 室外露点温度
|
||||
BigDecimal dewPointTemp = weatherUtil.calculateDewPoint(temperature, humidity); |
||||
weatherData.setDewPointTemp(dewPointTemp.setScale(1, RoundingMode.HALF_UP).doubleValue()); |
||||
|
||||
// 室外湿球温度
|
||||
BigDecimal wetBulbTemp = weatherUtil.returnComputePsi(temperature, (double) humidity / 100, Double.parseDouble(pressure) * 1000); |
||||
weatherData.setWetBulbTemp(wetBulbTemp.setScale(1, RoundingMode.HALF_UP).doubleValue()); |
||||
|
||||
try { |
||||
weatherDataService.updateDataById(weatherData); |
||||
} catch (Exception e) { |
||||
log.error("更新天气数据失败:{}", e.getMessage()); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue