|
@@ -1,9 +1,11 @@
|
|
|
package com.ruoyi;
|
|
|
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.ruoyi.ucp.entity.*;
|
|
|
+import com.ruoyi.ucp.service.ITurbineInfoDayService;
|
|
|
import com.ruoyi.ucp.util.CalcCache;
|
|
|
import org.junit.runner.RunWith;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
@@ -11,6 +13,8 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -23,12 +27,79 @@ import java.util.stream.Collectors;
|
|
|
public class Test {
|
|
|
@Resource
|
|
|
private JavaFunctionJobHandler javaFunctionJobHandler;
|
|
|
+ @Resource
|
|
|
+ private ITurbineInfoDayService turbineInfoDayService;
|
|
|
+
|
|
|
|
|
|
@org.junit.Test
|
|
|
- public void test(){
|
|
|
+ public void test() {
|
|
|
javaFunctionJobHandler.cutInWindSpeed();
|
|
|
javaFunctionJobHandler.calcGlqxnh_edfs();
|
|
|
+ }
|
|
|
+
|
|
|
+ //平均温度
|
|
|
+ @org.junit.Test
|
|
|
+ public void cutInWindSpeed() {
|
|
|
+ //date当天零点
|
|
|
+ DateTime timeNow = DateUtil.beginOfDay(new Date());
|
|
|
+ //date昨天零点
|
|
|
+ DateTime timeBegin = DateUtil.offsetDay(timeNow, -1);
|
|
|
+
|
|
|
+
|
|
|
+ //所有风机的温度
|
|
|
+ QueryWrapper<PointInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("uniform_code", "AI072");
|
|
|
+
|
|
|
+ List<PointInfo> pointInfos = javaFunctionJobHandler.getEntity("AI072", "turbine");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //遍历pointInfos
|
|
|
+ for (PointInfo turbine : pointInfos) {
|
|
|
+ //取出pointData
|
|
|
+ List<PointData> pointDatas = turbine.getPointDatas();
|
|
|
+ //遍历pointDatas,取出数据算平均值
|
|
|
+ double avgCutInWindSpeed = 0;
|
|
|
+ for (PointData pointData : pointDatas) {
|
|
|
+ avgCutInWindSpeed += pointData.getValue();
|
|
|
+ }
|
|
|
+ avgCutInWindSpeed /= pointDatas.size();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //存入数据库
|
|
|
+ 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);
|
|
|
+ System.out.println(one);
|
|
|
+ if (one == null) {
|
|
|
+ TurbineInfoDay turbineInfoDay = new TurbineInfoDay();
|
|
|
+ turbineInfoDay.setTurbineId(turbine.getTurbineId());
|
|
|
+ turbineInfoDay.setRecordDate(timeBegin.toJdkDate());
|
|
|
+ turbineInfoDay.setHjwd(avgCutInWindSpeed);
|
|
|
+ System.out.println(turbineInfoDay);
|
|
|
+// turbineInfoDayService.save(turbineInfoDay);
|
|
|
+ } else {
|
|
|
+ one.setHjwd(avgCutInWindSpeed);
|
|
|
+ System.out.println(one);
|
|
|
+// turbineInfoDayService.updateById(one);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
}
|