|
@@ -1,5 +1,6 @@
|
|
|
package com.ruoyi;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -8,6 +9,7 @@ import com.ruoyi.quartz.task.ChangedSave;
|
|
|
import com.ruoyi.ucp.entity.*;
|
|
|
import com.ruoyi.ucp.feign.AdapterApi;
|
|
|
import com.ruoyi.ucp.service.*;
|
|
|
+import com.ruoyi.ucp.util.CalcCache;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -421,34 +423,52 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
piFs.setInstitutionType("turbine");
|
|
|
List<PointInfo> entityFs = pointService.getByEntity(piFs);
|
|
|
Map<String, PointInfo> collectFs = entityFs.stream().collect(Collectors.toMap(PointInfo::getTurbineId, Function.identity()));
|
|
|
+ Map<String, List<PointInfo>> collect = entityFs.stream().collect(Collectors.groupingBy(PointInfo::getStationId));
|
|
|
String keysFs = pointInfos2Keys(entityFs);
|
|
|
//设备拟合功率(自算)
|
|
|
PointInfo piFjzsgl = new PointInfo();
|
|
|
piFjzsgl.setUniformCode("ZSGL");
|
|
|
piFjzsgl.setInstitutionType("turbine");
|
|
|
List<PointInfo> entityFjzsgl = pointService.getByEntity(piFjzsgl);
|
|
|
- Map<String, PointInfo> collectFjzsgl = entityFjzsgl.stream().collect(Collectors.toMap(PointInfo::getTurbineId, Function.identity()));
|
|
|
+ Map<String, String> collectFjzsgl = entityFjzsgl.stream().collect(Collectors.toMap(PointInfo::getTurbineId, PointInfo::getPointKey));
|
|
|
String keysFjzsgl = pointInfos2Keys(entityFjzsgl);
|
|
|
//场站自算功率
|
|
|
PointInfo piCzzsgl = new PointInfo();
|
|
|
piCzzsgl.setUniformCode("AGC010");
|
|
|
piCzzsgl.setInstitutionType("booster");
|
|
|
List<PointInfo> entityCzzsgl = pointService.getByEntity(piCzzsgl);
|
|
|
- Map<String, PointInfo> collectCzzsgl = entityCzzsgl.stream().collect(Collectors.toMap(PointInfo::getTurbineId, Function.identity()));
|
|
|
+ Map<String, String> collectCzzsgl = entityCzzsgl.stream().collect(Collectors.toMap(PointInfo::getStationId, PointInfo::getPointKey));
|
|
|
String keysCzzsgl = pointInfos2Keys(entityCzzsgl);
|
|
|
|
|
|
DateTime time = DateUtil.beginOfMinute(DateUtil.date());
|
|
|
DateTime time5 = DateUtil.offsetMinute(time, -5);
|
|
|
List<DoubleStatData> statFs5;
|
|
|
PointData avg;
|
|
|
- for (PointInfo info : entityFs) {
|
|
|
- statFs5 = adapter.getHistoryStat(goldenUri(), keysFs, time5.getTime(), time.getTime());
|
|
|
- if(!statFs5.isEmpty()){
|
|
|
- avg = statFs5.get(0).getAvg();
|
|
|
- avg.setTs(time.getTime());
|
|
|
- avg.setTagName(info.getPointKey());
|
|
|
- adapter.writeHistory(taosUri(), avg);
|
|
|
+ List<PointData> avgs = new ArrayList<>();
|
|
|
+ double value,v;
|
|
|
+ for (Map.Entry<String, List<PointInfo>> entry : collect.entrySet()) {
|
|
|
+ double stV=0;
|
|
|
+ for (PointInfo info : entry.getValue()) {
|
|
|
+ //todo
|
|
|
+ statFs5 = adapter.getHistoryStat(goldenUri(), info.getPointKey(), time5.getTime(), time.getTime());
|
|
|
+ if(CollUtil.isNotEmpty(statFs5)){
|
|
|
+ //todo
|
|
|
+ value = statFs5.get(0).getAvg().getValue();
|
|
|
+ avg = new PointData();
|
|
|
+ v = CalcCache.wtMcfMap.get(info.getTurbineId()).get(value);
|
|
|
+ stV += v;
|
|
|
+ avg.setTs(time.getTime());
|
|
|
+ avg.setDoubleValue(v);
|
|
|
+ avg.setTagName(collectFjzsgl.get(info.getTurbineId()));
|
|
|
+ avgs.add(avg);
|
|
|
+ }
|
|
|
}
|
|
|
+ adapter.writeHistoryBatch(taosUri(), avgs);
|
|
|
+ PointData data = new PointData();
|
|
|
+ data.setTs(time.getTime());
|
|
|
+ data.setDoubleValue(stV);
|
|
|
+ data.setTagName(collectCzzsgl.get(entry.getKey()));
|
|
|
+ adapter.writeHistory(taosUri(), data);
|
|
|
}
|
|
|
}
|
|
|
|