|
@@ -9,6 +9,7 @@ import com.jiayue.biz.domain.*;
|
|
|
import com.jiayue.biz.mapper.ProphaseAnemometryDataMapper;
|
|
|
import com.jiayue.biz.service.*;
|
|
|
import com.jiayue.biz.service.impl.*;
|
|
|
+import com.jiayue.biz.util.CalculationUtil;
|
|
|
import com.jiayue.biz.util.DateTimeUtil;
|
|
|
import com.jiayue.common.utils.DateUtil;
|
|
|
import io.undertow.util.DateUtils;
|
|
@@ -22,6 +23,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
+import java.sql.Time;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -66,28 +68,33 @@ public class AirDensityJob {
|
|
|
//前一天23点59分
|
|
|
Date endDate = DateTimeUtil.getDayLastTime(DateUtil.yesterday().getTime());
|
|
|
//传入时间的月初
|
|
|
- Date startMonthDate = DateTimeUtil.beginOfMonth(new Date());
|
|
|
+ Date startMonthDate = DateTimeUtil.beginOfMonth(startDate);
|
|
|
//传入时间的月末
|
|
|
- Date endMonthDate = DateTimeUtil.endOfMonth(new Date());
|
|
|
+ Date endMonthDate = DateTimeUtil.endOfMonth(endDate);
|
|
|
for (WindTowerInfo windTowerInfo : windTowerInfoList) {
|
|
|
Date sevenDate = startDate;
|
|
|
- //获取统计数据最后一条数据
|
|
|
+ Date startTime = startMonthDate;
|
|
|
WindTowerCalculationData lastData = windTowerCalculationDataService.getLastDataCalculation(windTowerInfo.getEquipmentNo());
|
|
|
- List<Entity> firstData = prophaseWeatherDataService.getFirstData(windTowerInfo.getEquipmentNo());
|
|
|
- //获取统计数据最后一条的当月开始时间 作为查询时间使用
|
|
|
- Date startTime = (Timestamp) firstData.get(0).get("first (ts)");
|
|
|
- //获取统计数据最后一天的数据时间第二天的 00 点
|
|
|
- if (lastData != null && lastData.getTime() != null) {
|
|
|
- startTime = DateUtil.beginOfMonth(lastData.getTime());
|
|
|
- //如果最后一条统计数据的时间小于7天之前的时间 就拿 统计数据的最后一条作为数据计算的开始时间
|
|
|
- if (lastData.getTime().getTime() < startDate.getTime()) {
|
|
|
- sevenDate = DateUtil.beginOfDay(lastData.getTime());
|
|
|
+ List<Entity> lastRealData = prophaseWeatherDataService.getLastData(windTowerInfo.getEquipmentNo());
|
|
|
+ if (lastData != null && lastRealData != null){
|
|
|
+ Timestamp timestamp = (Timestamp) lastRealData.get(0).get("last (ts)");
|
|
|
+ long lastTime = DateUtil.endOfDay(lastData.getTime()).getTime();
|
|
|
+ long realTime = DateUtil.endOfDay(new Date(timestamp.getTime())).getTime();
|
|
|
+ if(lastTime == realTime){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (realTime - lastTime >= 60 * 60 * 24 * 1000 * 8) {
|
|
|
+ sevenDate = new Date(lastTime);
|
|
|
}
|
|
|
- }else{
|
|
|
- sevenDate = startTime;
|
|
|
+
|
|
|
}
|
|
|
+ if(sevenDate.getTime() < startMonthDate.getTime()){
|
|
|
+ startTime = sevenDate;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//风数据查询
|
|
|
- List<ProphaseAnemometryData> prophaseAnemometryDataList = prophaseAnemometryDataService.selectAll(windTowerInfo.getEquipmentNo(), new Timestamp(startTime.getTime()) ,new Timestamp(endDate.getTime()));
|
|
|
+ List<ProphaseAnemometryData> prophaseAnemometryDataList = prophaseAnemometryDataService.selectAll(windTowerInfo.getEquipmentNo(), new Timestamp(startTime.getTime()), new Timestamp(endDate.getTime()));
|
|
|
//环境数据查询
|
|
|
List<ProphaseWeatherData> prophaseWeatherDataList = prophaseWeatherDataService.selectPublicData(windTowerInfo.getEquipmentNo(), new Timestamp(startTime.getTime()), new Timestamp(endDate.getTime()));
|
|
|
//统计数据
|
|
@@ -200,7 +207,7 @@ public class AirDensityJob {
|
|
|
// 统计概述
|
|
|
statisticsSituationService.statisticsSituation(windTowerInfo, statisticsSituations, equipmentAttributeList);
|
|
|
//保存
|
|
|
- windTowerCalculationDataService.saveBatchByEquipmentId(dataList,windTowerInfo.getEquipmentNo());
|
|
|
+ windTowerCalculationDataService.saveBatchByEquipmentId(dataList, windTowerInfo.getEquipmentNo());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -219,7 +226,7 @@ public class AirDensityJob {
|
|
|
if (!s1.contains("MW")) {
|
|
|
continue;
|
|
|
}
|
|
|
- String s2 = getNumberFromString(s1);
|
|
|
+ String s2 = CalculationUtil.getNumberFromStringForDian(s1);
|
|
|
BigDecimal realTimeTotal = new BigDecimal(fdn).divide(new BigDecimal(s2), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
//一期
|
|
@@ -238,20 +245,5 @@ public class AirDensityJob {
|
|
|
|
|
|
}
|
|
|
|
|
|
- //获取字符串中数字 附带小数点
|
|
|
- public String getNumberFromString(String string) {
|
|
|
- String str = string;
|
|
|
- str = str.trim();
|
|
|
- StringBuffer str2 = new StringBuffer();
|
|
|
- if (str != null && !"".equals(str)) {
|
|
|
- for (int i = 0; i < str.length(); i++) {
|
|
|
- if ((str.charAt(i) >= 48 && str.charAt(i) <= 57) || str.charAt(i) == 46) {
|
|
|
- String s = String.valueOf(str.charAt(i));
|
|
|
- str2.append(s);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return str2.toString();
|
|
|
- }
|
|
|
|
|
|
}
|