Browse Source

额定风速1

malijun 8 months ago
parent
commit
11e01df324

+ 68 - 0
ruoyi-admin/src/test/java/com/ruoyi/JavaFunctionJobHandler.java

@@ -1081,6 +1081,74 @@ public class JavaFunctionJobHandler extends IJobHandler {
 //        stringRedisTemplate.opsForValue().set("glqxnh", JSON.toJSONString(fitMap));
     }
 
+    //算额定风速
+    public void calcGlqxnh_edfs(Date start, Date end) {
+        //风速
+        List<PointInfo> entityFs = getEntity("AI066", "turbine");
+        //功率
+        List<PointInfo> entityGl = getEntity("AI114", "turbine");
+        Map<String, PointInfo> glMap = entityGl.stream().collect(Collectors.toMap(PointInfo::getTurbineId, Function.identity()));
+
+        Map<String, EquipmentModel> map = equipmentModelService.map();
+
+        List<PointInfo> entity = new ArrayList<>();
+        List<PointInfo> entity0 = getEntity("MX000", "state");
+        List<PointInfo> entity1 = getEntity("MX001", "state");
+        List<PointInfo> entity2 = getEntity("MX002", "state");
+        List<PointInfo> entity4 = getEntity("MX004", "state");
+        List<PointInfo> entity6 = getEntity("MX006", "state");
+        entity.addAll(entity0);
+        entity.addAll(entity1);
+        entity.addAll(entity2);
+        entity.addAll(entity4);
+        entity.addAll(entity6);
+        List<String> keys = entity.stream().map(PointInfo::getPointKey).collect(Collectors.toList());
+        Map<String, PointData> latest = adapter.getHistorySection(goldenUri(), String.join(",", keys), start.getTime());
+        Map<String, Map<String, PointInfo>> wtUcPis = entity.stream().collect(Collectors.groupingBy(PointInfo::getTurbineId, Collectors.toMap(PointInfo::getUniformCode, Function.identity())));
+
+        List<PointInfo> entityAiZt = getEntity("AI422", "state");
+        Map<String, PointInfo> aiztMap = entityAiZt.stream().collect(Collectors.toMap(PointInfo::getTurbineId, Function.identity()));
+        List<StateAi> list = stateAiService.list();
+        Map<String, Map<Integer, Integer>> collectAi = list.stream().collect(Collectors.groupingBy(
+                StateAi::getModel, Collectors.toMap(StateAi::getOriginalState, StateAi::getMappingState)));
+
+//        Map<String, Map<Double,Double>> fitMap = new HashMap<>();
+        int i = 0;
+        for (PointInfo ef : entityFs) {
+            String wtId = ef.getTurbineId();
+            PointInfo glInfo = glMap.get(wtId);
+            getSnapDataByEntity(ef, start, end, 60);
+            getSnapDataByEntity(glInfo, start, end, 60);
+            List<PointData> peek = ef.getPointDatas().stream().peek(pd -> pd.setDoubleValue(
+                    NumberUtil.round(pd.getValue(), 2).doubleValue())).collect(Collectors.toList());
+            ef.setPointDatas(peek);
+
+            PointInfo turbineZt = calcTurbineDizt2(wtUcPis.get(wtId), latest, start, end, 60);
+            PointInfo turbineAizt = calcTurbineAizt2(aiztMap.get(wtId), collectAi, start, end, 60);
+            Map<Double, Double> fit = new TreeMap<>();
+            if (turbineZt != null) {
+                double capacity = map.get(turbineZt.getSpare()).getPowerProduction();
+                fit = dataProcessAndFit(ef, glInfo, turbineZt, CalcCache.bzgl.get(turbineZt.getSpare()), capacity);
+//                fitMap.put(wtId, fit);
+                turbineZt.setPointDatas(null);
+            }
+            if (turbineAizt != null) {
+                double capacity = map.get(turbineAizt.getSpare()).getPowerProduction();
+                fit = dataProcessAndFit(ef, glInfo, turbineAizt, CalcCache.bzgl.get(turbineAizt.getSpare()), capacity);
+//                fitMap.put(wtId, fit);
+                turbineAizt.setPointDatas(null);
+            }
+            ef.setPointDatas(null);
+            glInfo.setPointDatas(null);
+
+            //存redis
+//            stringRedisTemplate.opsForValue().set("glqxnh:" + end.getMonth() + ":" + wtId, JSON.toJSONString(fit));
+
+        }
+
+//        stringRedisTemplate.opsForValue().set("glqxnh", JSON.toJSONString(fitMap));
+    }
+
     public Map<Double, Double> dataProcessAndFit(PointInfo fsPI, PointInfo glPI, PointInfo ztPI, Map<Double, Double> modelPowerMap, double capacity) {
         List<PointData> fsPds = fsPI.getPointDatas();
         List<PointData> glPds = glPI.getPointDatas();

+ 1 - 1
ruoyi-admin/src/test/java/com/ruoyi/NewTests.java

@@ -58,7 +58,7 @@ public class NewTests {
 //            task.calcTurbine5s2(date);
 
         }
-//        task.calcGlqxnh(start,end);
+        task.calcGlqxnh(start,end);
 //        calcTurbineRFDL(date);
         task.calcTurbine5s2(date);
 //        writeReportPool(date);

+ 29 - 0
ruoyi-admin/src/test/java/com/ruoyi/ZhiBiaoCalculation.java

@@ -2,16 +2,20 @@ package com.ruoyi;
 
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.TypeReference;
 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 com.ruoyi.ucp.util.CalcCache;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import javax.annotation.Resource;
@@ -41,6 +45,9 @@ public class ZhiBiaoCalculation {
     @Resource
     private TurbineInfoDayServiceImpl turbineInfoDayService;
 
+    @Resource
+    private StringRedisTemplate stringRedisTemplate;
+
 
     //切入切出风速
     @Test
@@ -208,8 +215,30 @@ public class ZhiBiaoCalculation {
 
 
     //满发下风速
+    @Test
     public void fullSpeedWindSpeed() {
+        //date当天零点
+        DateTime timeNow = DateUtil.beginOfDay(new Date());
+        //date昨天零点
+        DateTime timeBegin = DateUtil.offsetDay(timeNow, -1);
+
+
+        //功率曲线拟合,
+        javaFunctionJobHandler.calcGlqxnh_edfs(timeBegin.toJdkDate(), timeNow.toJdkDate());
+
+
+/*        //从redis取
+        Set<String> keys = stringRedisTemplate.keys("glqxnh:5:*");
+        for (String key : keys) {
+            String yc = stringRedisTemplate.opsForValue().get(key);
+            ConcurrentHashMap<Double, Double> wtyc = JSON.parseObject(yc, new TypeReference<ConcurrentHashMap<Double, Double>>() {}.getType());
+            CalcCache.fitcoef.put(key.replaceFirst("glqxnh:5:",""),wtyc);
+        }*/
+
+
     }
 
 
+
+
 }