|
@@ -5,7 +5,9 @@ import cn.hutool.core.date.DateUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.ruoyi.ucp.entity.PointData;
|
|
|
import com.ruoyi.ucp.entity.PointInfo;
|
|
|
+import com.ruoyi.ucp.entity.TurbineInfoDay;
|
|
|
import com.ruoyi.ucp.feign.AdapterApi;
|
|
|
+import com.ruoyi.ucp.service.impl.TurbineInfoDayServiceImpl;
|
|
|
import org.junit.Test;
|
|
|
import org.junit.runner.RunWith;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -35,6 +37,9 @@ public class ZhiBiaoCalculation {
|
|
|
@Resource
|
|
|
private AdapterApi adapter;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private TurbineInfoDayServiceImpl turbineInfoDayService;
|
|
|
+
|
|
|
|
|
|
//切入切出风速
|
|
|
@Test
|
|
@@ -66,6 +71,10 @@ public class ZhiBiaoCalculation {
|
|
|
//风速测点key
|
|
|
String windSpeedKey = null;
|
|
|
|
|
|
+ //平均切入风速
|
|
|
+ double avgCutInWindSpeedOne = 0;
|
|
|
+
|
|
|
+
|
|
|
//遍历pointInfos,找出pointData1的id和pointInfos中相等的,取出pointInfo的pointKey
|
|
|
for (PointInfo info : pointInfos) {
|
|
|
if (Objects.equals(turbine.getTurbineId(), info.getTurbineId())) {
|
|
@@ -102,8 +111,6 @@ public class ZhiBiaoCalculation {
|
|
|
mapIn.put(turbine.getTurbineId(), new HashMap<String, Double>() {{
|
|
|
put(String.valueOf(ts1), avgCutInWindSpeed);
|
|
|
}});
|
|
|
-
|
|
|
- //TODO: 存数据库
|
|
|
}
|
|
|
|
|
|
//切出
|
|
@@ -121,19 +128,17 @@ public class ZhiBiaoCalculation {
|
|
|
mapOut.put(turbine.getTurbineId(), new HashMap<String, Double>() {{
|
|
|
put(String.valueOf(ts2), avgCutOutWindSpeed);
|
|
|
}});
|
|
|
-
|
|
|
- //TODO: 存数据库
|
|
|
}
|
|
|
}
|
|
|
//遍历map集合,取出每个风机的所有切入风速,算一个平均值
|
|
|
HashMap<String, Double> mapTurbineValues = mapIn.get(turbine.getTurbineId());
|
|
|
if (mapTurbineValues != null) {
|
|
|
AtomicReference<Double> sum = new AtomicReference<>(0.0);
|
|
|
- //遍历mapTurbineValues,V大于10的舍弃,剩余算平均值
|
|
|
+ //遍历mapTurbineValues,V大于5的舍弃,剩余算平均值
|
|
|
for (Map.Entry<String, Double> entry : mapTurbineValues.entrySet()) {
|
|
|
String key = entry.getKey();
|
|
|
Double value = entry.getValue();
|
|
|
- if (value > 10) {
|
|
|
+ if (value > 5) {
|
|
|
mapTurbineValues.remove(key);
|
|
|
}
|
|
|
}
|
|
@@ -141,16 +146,17 @@ public class ZhiBiaoCalculation {
|
|
|
sum.updateAndGet(v1 -> v1 + v);
|
|
|
});
|
|
|
|
|
|
- double avgCutInWindSpeed;
|
|
|
+
|
|
|
//如果值为空则置0
|
|
|
if (sum.get() == 0) {
|
|
|
- avgCutInWindSpeed = 0;
|
|
|
+ avgCutInWindSpeedOne = 0;
|
|
|
} else {
|
|
|
- avgCutInWindSpeed = sum.get() / mapTurbineValues.size();
|
|
|
+ avgCutInWindSpeedOne = sum.get() / mapTurbineValues.size();
|
|
|
}
|
|
|
|
|
|
- System.out.println(turbine.getTurbineId() + "切入平均风速" + avgCutInWindSpeed + "时间" + timeBegin);
|
|
|
+ System.out.println(turbine.getTurbineId() + "切入平均风速" + avgCutInWindSpeedOne + "时间" + timeBegin);
|
|
|
}
|
|
|
+
|
|
|
//遍历map集合,取出每个风机的所有切出风速,算一个平均值
|
|
|
HashMap<String, Double> mapTurbineValues2 = mapOut.get(turbine.getTurbineId());
|
|
|
|
|
@@ -160,7 +166,7 @@ public class ZhiBiaoCalculation {
|
|
|
for (Map.Entry<String, Double> entry : mapTurbineValues2.entrySet()) {
|
|
|
String key = entry.getKey();
|
|
|
Double value = entry.getValue();
|
|
|
- if (value > 10) {
|
|
|
+ if (value > 5) {
|
|
|
mapTurbineValues2.remove(key);
|
|
|
}
|
|
|
}
|
|
@@ -175,6 +181,26 @@ public class ZhiBiaoCalculation {
|
|
|
}
|
|
|
System.out.println(turbine.getTurbineId() + "切出平均风速" + avgCutOutWindSpeed + "时间" + timeBegin);
|
|
|
}
|
|
|
+
|
|
|
+ //存入数据库
|
|
|
+ String turbineId = turbine.getTurbineId();
|
|
|
+ Date jdkDate = timeBegin.toJdkDate();
|
|
|
+ System.out.println(turbineId + " " + jdkDate);
|
|
|
+ QueryWrapper<TurbineInfoDay> turbineInfoDayQueryWrapper = new QueryWrapper<>();
|
|
|
+ turbineInfoDayQueryWrapper.eq("turbine_id", turbine.getTurbineId());
|
|
|
+ turbineInfoDayQueryWrapper.eq("record_date", timeBegin.toJdkDate());
|
|
|
+ TurbineInfoDay one = turbineInfoDayService.getOne(turbineInfoDayQueryWrapper);
|
|
|
+ if (one == null) {
|
|
|
+ TurbineInfoDay turbineInfoDay = new TurbineInfoDay();
|
|
|
+ turbineInfoDay.setTurbineId(turbine.getTurbineId());
|
|
|
+ turbineInfoDay.setRecordDate(timeBegin.toJdkDate());
|
|
|
+ turbineInfoDay.setXfqrfs(avgCutInWindSpeedOne);
|
|
|
+ }else {
|
|
|
+ one.setXfqrfs(avgCutInWindSpeedOne);
|
|
|
+ }
|
|
|
+ System.out.println(one);
|
|
|
+// turbineInfoDayService.saveOrUpdate(one);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|