|
|
@@ -0,0 +1,508 @@
|
|
|
+package com.ufo.project.data.service.impl;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.time.Instant;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneId;
|
|
|
+import java.time.ZoneOffset;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import com.ufo.module.system.domain.SysDictData;
|
|
|
+import com.ufo.module.system.service.ISysDictTypeService;
|
|
|
+import com.ufo.project.config.domain.ConfigStation;
|
|
|
+import com.ufo.project.config.service.IConfigStationService;
|
|
|
+import com.ufo.project.data.domain.vo.PvPlantCumulativeReportQuery;
|
|
|
+import com.ufo.project.data.domain.vo.PvPlantCumulativeReportVO;
|
|
|
+import com.ufo.project.data.service.IPvPlantCumulativeReportService;
|
|
|
+import com.ufo.project.model.domain.DataElectricityLocal;
|
|
|
+import com.ufo.project.model.service.IDataElectricityLocalService;
|
|
|
+import com.ufo.project.weather.domain.DataWeatherLocal;
|
|
|
+import com.ufo.project.weather.service.IDataWeatherLocalService;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 光伏电场累计报表Service业务层处理
|
|
|
+ *
|
|
|
+ * @author ufo
|
|
|
+ * @date 2026-09-08
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class PvPlantCumulativeReportServiceImpl implements IPvPlantCumulativeReportService
|
|
|
+{
|
|
|
+ /** 数据采集频率字典类型 */
|
|
|
+ private static final String DICT_TYPE_DATA_LOCAL_FREQUENCY = "data_local_frequency";
|
|
|
+
|
|
|
+ /** 北京时间偏移 */
|
|
|
+ private static final ZoneOffset ZONE_OFFSET = ZoneOffset.ofHours(8);
|
|
|
+
|
|
|
+ /** 组件有效辐照时段(北京时间) */
|
|
|
+ private static final int BOARD_TEMP_START_HOUR = 7;
|
|
|
+ private static final int BOARD_TEMP_START_MINUTE = 30;
|
|
|
+ private static final int BOARD_TEMP_END_HOUR = 18;
|
|
|
+ private static final int BOARD_TEMP_END_MINUTE = 30;
|
|
|
+
|
|
|
+ /** 辐照度阈值(W/m²),用于累计日照小时数计算 */
|
|
|
+ private static final double IRRADIANCE_THRESHOLD = 120.0;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IDataWeatherLocalService weatherLocalService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IDataElectricityLocalService electricityLocalService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IConfigStationService configStationService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ISysDictTypeService dictTypeService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询光伏电场累计报表数据
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<PvPlantCumulativeReportVO> selectReportList(PvPlantCumulativeReportQuery query)
|
|
|
+ {
|
|
|
+ // 1. 获取站点配置
|
|
|
+ Long stationId = parseLong(query.getEntityId());
|
|
|
+ ConfigStation station = configStationService.selectConfigStationById(stationId);
|
|
|
+ if (station == null || station.getInstalledCapacity() == null || station.getInstalledCapacity() == 0)
|
|
|
+ {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ BigDecimal installedCapacity = new BigDecimal(station.getInstalledCapacity());
|
|
|
+
|
|
|
+ // 2. 获取数据采集频率(单位:秒)
|
|
|
+ Long frequency = getCollectionFrequency();
|
|
|
+
|
|
|
+ // 3. 构建时间参数(ISO 8601 格式)
|
|
|
+ String startStr = formatOffsetDateTime(query.getStartTime());
|
|
|
+ String endStr = formatOffsetDateTime(query.getEndTime());
|
|
|
+
|
|
|
+ // 4. 获取气象数据和电力数据
|
|
|
+ List<DataWeatherLocal> weatherList = weatherLocalService.selectWeatherFieldsByTimeRange(
|
|
|
+ stationId, startStr, endStr);
|
|
|
+ List<DataElectricityLocal> electricityList = electricityLocalService.selectActualPowerList(
|
|
|
+ stationId, startStr, endStr);
|
|
|
+
|
|
|
+ // 5. 按时间戳合并
|
|
|
+ Map<Long, PointData> mergeMap = mergeData(weatherList, electricityList);
|
|
|
+
|
|
|
+ // 6. 按时间分组
|
|
|
+ Map<String, List<PointData>> groupedMap = groupByTime(mergeMap.values(), query.getType());
|
|
|
+
|
|
|
+ // 7. 逐组计算
|
|
|
+ List<PvPlantCumulativeReportVO> result = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, List<PointData>> entry : groupedMap.entrySet())
|
|
|
+ {
|
|
|
+ String timeKey = entry.getKey();
|
|
|
+ List<PointData> points = entry.getValue();
|
|
|
+ PvPlantCumulativeReportVO vo = computeGroup(timeKey, points, query.getType(), frequency, installedCapacity);
|
|
|
+ result.add(vo);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取数据采集频率(秒)
|
|
|
+ */
|
|
|
+ private Long getCollectionFrequency()
|
|
|
+ {
|
|
|
+ List<SysDictData> dictList = dictTypeService.selectDictDataByType(DICT_TYPE_DATA_LOCAL_FREQUENCY);
|
|
|
+ if (dictList != null && !dictList.isEmpty())
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ return Long.parseLong(dictList.get(0).getDictValue());
|
|
|
+ }
|
|
|
+ catch (NumberFormatException e)
|
|
|
+ {
|
|
|
+ return 900L; // 默认15分钟
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 900L; // 默认15分钟
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将 yyyy-MM-dd 转换为 ISO 8601 格式(北京时间)
|
|
|
+ */
|
|
|
+ private String formatOffsetDateTime(String dateStr)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ // 解析为北京时间的当天 00:00:00
|
|
|
+ DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ LocalDateTime ldt = LocalDateTime.parse(dateStr, fmt);
|
|
|
+ LocalDateTime beijing = ldt.atZone(ZoneId.of("Asia/Shanghai")).withZoneSameInstant(ZONE_OFFSET).toLocalDateTime();
|
|
|
+ return beijing.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME);
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ return dateStr;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 合并气象数据和电力数据,按时间戳去重
|
|
|
+ */
|
|
|
+ private Map<Long, PointData> mergeData(List<DataWeatherLocal> weatherList, List<DataElectricityLocal> electricityList)
|
|
|
+ {
|
|
|
+ Map<Long, PointData> map = new LinkedHashMap<>();
|
|
|
+
|
|
|
+ for (DataWeatherLocal w : weatherList)
|
|
|
+ {
|
|
|
+ if (w.getTm() == null) continue;
|
|
|
+ Long ts = w.getTm().getTime();
|
|
|
+ map.computeIfAbsent(ts, k -> new PointData()).setWeather(w);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (DataElectricityLocal e : electricityList)
|
|
|
+ {
|
|
|
+ if (e.getTm() == null) continue;
|
|
|
+ Long ts = e.getTm().getTime();
|
|
|
+ PointData pd = map.computeIfAbsent(ts, k -> new PointData());
|
|
|
+ pd.setElectricity(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按时间类型分组
|
|
|
+ */
|
|
|
+ private Map<String, List<PointData>> groupByTime(Iterable<PointData> points, String type)
|
|
|
+ {
|
|
|
+ Map<String, List<PointData>> map = new LinkedHashMap<>();
|
|
|
+ for (PointData pd : points)
|
|
|
+ {
|
|
|
+ if (pd.getTm() == null) continue;
|
|
|
+ String key = toTimeKey(pd.getTm(), type);
|
|
|
+ map.computeIfAbsent(key, k -> new ArrayList<>()).add(pd);
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将时间戳转换为时间分组键
|
|
|
+ */
|
|
|
+ private String toTimeKey(java.util.Date tm, String type)
|
|
|
+ {
|
|
|
+ long ts = tm.getTime();
|
|
|
+ LocalDateTime ldt = LocalDateTime.ofInstant(Instant.ofEpochMilli(ts), ZONE_OFFSET);
|
|
|
+
|
|
|
+ switch (type)
|
|
|
+ {
|
|
|
+ case "daily":
|
|
|
+ return ldt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ case "monthly":
|
|
|
+ return ldt.format(DateTimeFormatter.ofPattern("yyyy-MM"));
|
|
|
+ case "yearly":
|
|
|
+ return ldt.format(DateTimeFormatter.ofPattern("yyyy"));
|
|
|
+ default:
|
|
|
+ return ldt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算一组数据的报表行
|
|
|
+ */
|
|
|
+ private PvPlantCumulativeReportVO computeGroup(String timeKey, List<PointData> points, String type,
|
|
|
+ Long frequency, BigDecimal installedCapacity)
|
|
|
+ {
|
|
|
+ PvPlantCumulativeReportVO vo = new PvPlantCumulativeReportVO();
|
|
|
+ vo.setTime(timeKey);
|
|
|
+
|
|
|
+ // 过滤空数据点
|
|
|
+ List<PointData> validPoints = new ArrayList<>();
|
|
|
+ for (PointData pd : points)
|
|
|
+ {
|
|
|
+ if (pd.getTm() != null)
|
|
|
+ {
|
|
|
+ validPoints.add(pd);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (validPoints.isEmpty()) return vo;
|
|
|
+
|
|
|
+ // --- 气象字段聚合 ---
|
|
|
+ double sumIrradiance = 0.0;
|
|
|
+ double maxIrradiance = 0.0;
|
|
|
+ double sumWindSpeed = 0.0;
|
|
|
+ double sumTemperature = 0.0;
|
|
|
+ double sumBoardTemperature = 0.0;
|
|
|
+ int weatherCount = 0;
|
|
|
+ int boardTempCount = 0;
|
|
|
+ double totalIrradiation = 0.0;
|
|
|
+
|
|
|
+ for (PointData pd : validPoints)
|
|
|
+ {
|
|
|
+ if (pd.weather != null)
|
|
|
+ {
|
|
|
+ Double irradiance = pd.weather.getIrradiance();
|
|
|
+ if (irradiance != null)
|
|
|
+ {
|
|
|
+ sumIrradiance += irradiance;
|
|
|
+ maxIrradiance = Math.max(maxIrradiance, irradiance);
|
|
|
+ }
|
|
|
+ Double windSpeed = pd.weather.getWindSpeed();
|
|
|
+ if (windSpeed != null) sumWindSpeed += windSpeed;
|
|
|
+ Double temperature = pd.weather.getTemperature();
|
|
|
+ if (temperature != null) sumTemperature += temperature;
|
|
|
+ Double boardTemperature = pd.weather.getBoardTemperature();
|
|
|
+ if (boardTemperature != null && isWithinBoardTempWindow(pd.getTm()))
|
|
|
+ {
|
|
|
+ sumBoardTemperature += boardTemperature;
|
|
|
+ boardTempCount++;
|
|
|
+ }
|
|
|
+ weatherCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // avgIrradiance
|
|
|
+ if (weatherCount > 0)
|
|
|
+ {
|
|
|
+ vo.setAvgIrradiance(round2(new BigDecimal(sumIrradiance).divide(new BigDecimal(weatherCount), 4, RoundingMode.HALF_UP)));
|
|
|
+ }
|
|
|
+
|
|
|
+ // maxIrradiance
|
|
|
+ if (maxIrradiance > 0)
|
|
|
+ {
|
|
|
+ vo.setMaxIrradiance(round2(BigDecimal.valueOf(maxIrradiance)));
|
|
|
+ }
|
|
|
+
|
|
|
+ // totalIrradiation = SUM(irradiance) * frequency / 1000000 (MJ/m²)
|
|
|
+ if (sumIrradiance > 0)
|
|
|
+ {
|
|
|
+ totalIrradiation = sumIrradiance * frequency.doubleValue() / 1000000.0;
|
|
|
+ vo.setTotalIrradiation(round2(BigDecimal.valueOf(totalIrradiation)));
|
|
|
+ }
|
|
|
+
|
|
|
+ // avgWindSpeed
|
|
|
+ if (weatherCount > 0)
|
|
|
+ {
|
|
|
+ vo.setAvgWindSpeed(round2(new BigDecimal(sumWindSpeed).divide(new BigDecimal(weatherCount), 4, RoundingMode.HALF_UP)));
|
|
|
+ }
|
|
|
+
|
|
|
+ // avgTemperature
|
|
|
+ if (weatherCount > 0)
|
|
|
+ {
|
|
|
+ vo.setAvgTemperature(round2(new BigDecimal(sumTemperature).divide(new BigDecimal(weatherCount), 4, RoundingMode.HALF_UP)));
|
|
|
+ }
|
|
|
+
|
|
|
+ // avgBoardTemperature
|
|
|
+ if (boardTempCount > 0)
|
|
|
+ {
|
|
|
+ vo.setAvgBoardTemperature(round2(new BigDecimal(sumBoardTemperature).divide(new BigDecimal(boardTempCount), 4, RoundingMode.HALF_UP)));
|
|
|
+ }
|
|
|
+
|
|
|
+ // --- 电力字段聚合 ---
|
|
|
+ double sumActualPower = 0.0;
|
|
|
+ double sumTheoreticalPower = 0.0;
|
|
|
+ double maxActualPower = 0.0;
|
|
|
+ Long maxPowerTimestamp = null;
|
|
|
+ int electricityCount = 0;
|
|
|
+
|
|
|
+ for (PointData pd : validPoints)
|
|
|
+ {
|
|
|
+ if (pd.electricity != null && pd.electricity.getGridStatus() != null && pd.electricity.getGridStatus() == 1)
|
|
|
+ {
|
|
|
+ Double actualPower = pd.electricity.getActualPower();
|
|
|
+ if (actualPower != null)
|
|
|
+ {
|
|
|
+ sumActualPower += actualPower;
|
|
|
+ if (actualPower > maxActualPower)
|
|
|
+ {
|
|
|
+ maxActualPower = actualPower;
|
|
|
+ maxPowerTimestamp = pd.getTm().getTime();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Double theoreticalPower = pd.electricity.getTheoreticalPower();
|
|
|
+ if (theoreticalPower != null)
|
|
|
+ {
|
|
|
+ sumTheoreticalPower += theoreticalPower;
|
|
|
+ }
|
|
|
+ electricityCount++;
|
|
|
+ }
|
|
|
+ else if (pd.electricity != null)
|
|
|
+ {
|
|
|
+ Double actualPower = pd.electricity.getActualPower();
|
|
|
+ if (actualPower != null)
|
|
|
+ {
|
|
|
+ sumActualPower += actualPower;
|
|
|
+ }
|
|
|
+ Double theoreticalPower = pd.electricity.getTheoreticalPower();
|
|
|
+ if (theoreticalPower != null)
|
|
|
+ {
|
|
|
+ sumTheoreticalPower += theoreticalPower;
|
|
|
+ }
|
|
|
+ electricityCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // gridMaxPowerTime
|
|
|
+ if (maxPowerTimestamp != null)
|
|
|
+ {
|
|
|
+ vo.setGridMaxPowerTime(formatTimeByType(maxPowerTimestamp, type));
|
|
|
+ }
|
|
|
+
|
|
|
+ // gridMaxPowder = MAX(actual_power) / 1000 (MW)
|
|
|
+ if (maxActualPower > 0)
|
|
|
+ {
|
|
|
+ vo.setGridMaxPowder(round2(BigDecimal.valueOf(maxActualPower).divide(BigDecimal.valueOf(1000), 4, RoundingMode.HALF_UP)));
|
|
|
+ }
|
|
|
+
|
|
|
+ // actualPower = SUM(actual_power) * frequency / 3600 / 10000 (万千瓦时)
|
|
|
+ if (sumActualPower > 0)
|
|
|
+ {
|
|
|
+ BigDecimal energy = BigDecimal.valueOf(sumActualPower)
|
|
|
+ .multiply(BigDecimal.valueOf(frequency))
|
|
|
+ .divide(BigDecimal.valueOf(3600))
|
|
|
+ .divide(BigDecimal.valueOf(10000), 4, RoundingMode.HALF_UP);
|
|
|
+ vo.setActualPower(energy);
|
|
|
+ }
|
|
|
+
|
|
|
+ // theoreticalPower = SUM(theoretical_power) * frequency / 3600 / 10000 (万千瓦时)
|
|
|
+ if (sumTheoreticalPower > 0)
|
|
|
+ {
|
|
|
+ BigDecimal energy = BigDecimal.valueOf(sumTheoreticalPower)
|
|
|
+ .multiply(BigDecimal.valueOf(frequency))
|
|
|
+ .divide(BigDecimal.valueOf(3600))
|
|
|
+ .divide(BigDecimal.valueOf(10000), 4, RoundingMode.HALF_UP);
|
|
|
+ vo.setTheoreticalPower(energy);
|
|
|
+ }
|
|
|
+
|
|
|
+ // validHours = SUM(actual_power) * frequency / 3600 / installedCapacity (h)
|
|
|
+ if (sumActualPower > 0 && installedCapacity.compareTo(BigDecimal.ZERO) > 0)
|
|
|
+ {
|
|
|
+ BigDecimal hours = BigDecimal.valueOf(sumActualPower)
|
|
|
+ .multiply(BigDecimal.valueOf(frequency))
|
|
|
+ .divide(BigDecimal.valueOf(3600))
|
|
|
+ .divide(installedCapacity, 4, RoundingMode.HALF_UP);
|
|
|
+ vo.setValidHours(hours);
|
|
|
+ }
|
|
|
+
|
|
|
+ // totalHours = 累计日照小时数(辐照度 > 120 W/m² 的小时数)
|
|
|
+ int totalHours = countValidHours(validPoints);
|
|
|
+ vo.setTotalHours(BigDecimal.valueOf(totalHours));
|
|
|
+
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断时间点是否处于组件有效辐照时段(北京时间 07:30 ~ 18:30)
|
|
|
+ */
|
|
|
+ private boolean isWithinBoardTempWindow(java.util.Date tm)
|
|
|
+ {
|
|
|
+ LocalDateTime ldt = LocalDateTime.ofInstant(Instant.ofEpochMilli(tm.getTime()), ZONE_OFFSET);
|
|
|
+ return (ldt.getHour() > BOARD_TEMP_START_HOUR
|
|
|
+ || (ldt.getHour() == BOARD_TEMP_START_HOUR && ldt.getMinute() >= BOARD_TEMP_START_MINUTE))
|
|
|
+ && (ldt.getHour() < BOARD_TEMP_END_HOUR
|
|
|
+ || (ldt.getHour() == BOARD_TEMP_END_HOUR && ldt.getMinute() <= BOARD_TEMP_END_MINUTE));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按小时聚合辐照度,统计 avg(irradiance) > 120 W/m² 的小时数
|
|
|
+ */
|
|
|
+ private int countValidHours(List<PointData> points)
|
|
|
+ {
|
|
|
+ // 按小时分组:key = 小时时间戳(去掉分钟和秒)
|
|
|
+ Map<Long, List<Double>> hourlyIrradiance = new LinkedHashMap<>();
|
|
|
+ for (PointData pd : points)
|
|
|
+ {
|
|
|
+ if (pd.weather == null || pd.weather.getIrradiance() == null) continue;
|
|
|
+ long ts = pd.getTm().getTime();
|
|
|
+ LocalDateTime ldt = LocalDateTime.ofInstant(Instant.ofEpochMilli(ts), ZONE_OFFSET);
|
|
|
+ LocalDateTime hourStart = ldt.withMinute(0).withSecond(0).withNano(0);
|
|
|
+ long hourTs = hourStart.atZone(ZONE_OFFSET).toInstant().toEpochMilli();
|
|
|
+ hourlyIrradiance.computeIfAbsent(hourTs, k -> new ArrayList<>()).add(pd.weather.getIrradiance());
|
|
|
+ }
|
|
|
+
|
|
|
+ int count = 0;
|
|
|
+ for (List<Double> values : hourlyIrradiance.values())
|
|
|
+ {
|
|
|
+ if (values.isEmpty()) continue;
|
|
|
+ double sum = 0.0;
|
|
|
+ for (Double v : values) sum += v;
|
|
|
+ double avg = sum / values.size();
|
|
|
+ if (avg > IRRADIANCE_THRESHOLD) count++;
|
|
|
+ }
|
|
|
+ return count;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将时间戳格式化为时间字符串,按报表类型
|
|
|
+ */
|
|
|
+ private String formatTimeByType(long timestamp, String type)
|
|
|
+ {
|
|
|
+ LocalDateTime ldt = LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZONE_OFFSET);
|
|
|
+ switch (type)
|
|
|
+ {
|
|
|
+ case "daily":
|
|
|
+ return ldt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ case "monthly":
|
|
|
+ return ldt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ case "yearly":
|
|
|
+ return ldt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ default:
|
|
|
+ return ldt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保留两位小数(四舍五入)
|
|
|
+ */
|
|
|
+ private BigDecimal round2(BigDecimal value)
|
|
|
+ {
|
|
|
+ if (value == null) return null;
|
|
|
+ return value.setScale(2, RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 安全解析String为Long
|
|
|
+ */
|
|
|
+ private Long parseLong(String value)
|
|
|
+ {
|
|
|
+ if (value == null || value.isEmpty()) return null;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ return Long.parseLong(value.trim());
|
|
|
+ }
|
|
|
+ catch (NumberFormatException e)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 合并数据点
|
|
|
+ */
|
|
|
+ private static class PointData
|
|
|
+ {
|
|
|
+ DataWeatherLocal weather;
|
|
|
+ DataElectricityLocal electricity;
|
|
|
+
|
|
|
+ java.util.Date getTm()
|
|
|
+ {
|
|
|
+ if (weather != null && weather.getTm() != null) return weather.getTm();
|
|
|
+ if (electricity != null && electricity.getTm() != null) return electricity.getTm();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ void setWeather(DataWeatherLocal weather)
|
|
|
+ {
|
|
|
+ this.weather = weather;
|
|
|
+ }
|
|
|
+
|
|
|
+ void setElectricity(DataElectricityLocal electricity)
|
|
|
+ {
|
|
|
+ this.electricity = electricity;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|