|
@@ -53,6 +53,10 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
private ITurbineInfoDayService turbineInfoDayService;
|
|
|
@Resource
|
|
|
private IProEconReportIndicatorPoolService reportIndicatorPoolService;
|
|
|
+ @Resource
|
|
|
+ private ITurbineInfoMinService turbineInfoMinService;
|
|
|
+ @Resource
|
|
|
+ private IStationInfoMinService stationInfoMinService;
|
|
|
|
|
|
@Override
|
|
|
public void execute() throws Exception {
|
|
@@ -79,15 +83,45 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
|
|
|
public List<StationInfoHour> getStationinfoByHour(Date hour) {
|
|
|
QueryWrapper<StationInfoHour> wrapper = new QueryWrapper<>();
|
|
|
- wrapper.eq("record_date", DateUtil.beginOfHour(hour));
|
|
|
+ wrapper.eq("record_date", hour);
|
|
|
return stationInfoHourService.list(wrapper);
|
|
|
}
|
|
|
|
|
|
+ public List<StationInfoHour> getStationinfoByHour(Date hour, List<PointInfo> entity) {
|
|
|
+ List<StationInfoHour> byDate = getStationinfoByHour(hour);
|
|
|
+ if (CollUtil.isEmpty(byDate)) {
|
|
|
+ entity.forEach(pi -> {
|
|
|
+ StationInfoHour day = new StationInfoHour();
|
|
|
+ day.setStationId(pi.getStationId());
|
|
|
+ day.setRecordDate(hour);
|
|
|
+ byDate.add(day);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return byDate;
|
|
|
+ }
|
|
|
+
|
|
|
public List<StationInfoDay> getStationinfoByDate(Date date) {
|
|
|
QueryWrapper<StationInfoDay> wrapper = new QueryWrapper<>();
|
|
|
wrapper.eq("record_date", date);
|
|
|
return stationInfoDayService.list(wrapper);
|
|
|
}
|
|
|
+ public List<StationInfoMin> getStationinfoMinByDate(Date date) {
|
|
|
+ QueryWrapper<StationInfoMin> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.eq("record_date", date);
|
|
|
+ return stationInfoMinService.list(wrapper);
|
|
|
+ }
|
|
|
+ public List<StationInfoMin> getStationinfoMinByDate(Date date, List<PointInfo> entity) {
|
|
|
+ List<StationInfoMin> byDate = getStationinfoMinByDate(date);
|
|
|
+ if (CollUtil.isEmpty(byDate)) {
|
|
|
+ entity.forEach(pi -> {
|
|
|
+ StationInfoMin day = new StationInfoMin();
|
|
|
+ day.setStationId(pi.getStationId());
|
|
|
+ day.setRecordDate(date);
|
|
|
+ byDate.add(day);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return byDate;
|
|
|
+ }
|
|
|
|
|
|
public StationInfoDay getStationinfoByDate(Date date, String stId) {
|
|
|
QueryWrapper<StationInfoDay> wrapper = new QueryWrapper<>();
|
|
@@ -803,31 +837,17 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
}
|
|
|
|
|
|
public void calcStationHourPJGL(Date hour) {
|
|
|
- PointInfo pointInfo = new PointInfo();
|
|
|
- pointInfo.setInstitutionType("station");
|
|
|
- pointInfo.setUniformCode("SSZGL");
|
|
|
- List<PointInfo> entity = pointService.getByEntity(pointInfo);
|
|
|
- List<StationInfoHour> byHours = getStationinfoByHour(hour);
|
|
|
- Map<String, StationInfoHour> collect = new HashMap<>();
|
|
|
- if (!byHours.isEmpty()) {
|
|
|
- collect = byHours.stream().collect(Collectors.toMap(StationInfoHour::getStationId, Function.identity()));
|
|
|
- }
|
|
|
- DoubleStatData stat;
|
|
|
- List<StationInfoHour> byHours2 = new ArrayList<>();
|
|
|
- for (PointInfo point : entity) {
|
|
|
- stat = adapter.getHistoryStat(taosGoldenUriTest(), point.getPointKey(), DateUtil.offsetHour(hour, -1).getTime(), hour.getTime());
|
|
|
- if (byHours.isEmpty()) {
|
|
|
- StationInfoHour info = new StationInfoHour();
|
|
|
- info.setStationId(point.getStationId());
|
|
|
- info.setRecordDate(DateUtil.beginOfHour(hour));
|
|
|
- if (stat == null || stat.getAvg() == null) info.setPjgl(0.0);
|
|
|
- info.setPjgl(stat.getAvg().getDoubleValue());
|
|
|
- byHours2.add(info);
|
|
|
- } else {
|
|
|
- collect.get(point.getStationId()).setPjgl(stat.getAvg().getDoubleValue());
|
|
|
- }
|
|
|
+ hour = DateUtil.beginOfHour(hour);
|
|
|
+ DateTime start = DateUtil.offsetHour(hour, -1);
|
|
|
+ //出线
|
|
|
+ List<PointInfo> entityCx = getEntity("AGC001", "booster");
|
|
|
+ Map<String, PointInfo> statMapCx = getStatDataByEntityMap(entityCx, goldenUri(), start, hour, PointInfo::getTurbineId);
|
|
|
+
|
|
|
+ List<StationInfoHour> byHours = getStationinfoByHour(hour,entityCx);
|
|
|
+ for (StationInfoHour byHour : byHours) {
|
|
|
+ byHour.setPjgl(statMapCx.get(byHour.getStationId()).getPointDatas().get(0).getValue());
|
|
|
}
|
|
|
- stationInfoHourService.saveOrUpdateBatch(byHours.isEmpty() ? byHours2 : byHours);
|
|
|
+ stationInfoHourService.saveOrUpdateBatch(byHours);
|
|
|
}
|
|
|
|
|
|
public void calcStationRfdlFj(Date date) {
|
|
@@ -1320,6 +1340,30 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
return data2;
|
|
|
}
|
|
|
|
|
|
+ public List<PointData> doublePointDatasFull(double v, List<PointData> data, long startTime, long endTime, int interval) {
|
|
|
+ int j = 0, m = 0;
|
|
|
+ List<PointData> data2 = new ArrayList<>();
|
|
|
+ for (long i = startTime; i < endTime; i += interval * 1000L) {
|
|
|
+ PointData dt = new PointData();
|
|
|
+ dt.setTs(i);
|
|
|
+ data2.add(dt);
|
|
|
+ //超出范围
|
|
|
+ if (j >= data.size() - 1) continue;
|
|
|
+ if (i < data.get(j).getTs()) {
|
|
|
+ if (m == 0) {
|
|
|
+ dt.setDoubleValue(v);
|
|
|
+ } else {
|
|
|
+ dt.setDoubleValue(data.get(j - 1).getValue());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ dt.setDoubleValue(data.get(j).getValue());
|
|
|
+ j++;
|
|
|
+ m++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return data2;
|
|
|
+ }
|
|
|
+
|
|
|
public void calcGlqxnh(Date start, Date end) {
|
|
|
//风速
|
|
|
List<PointInfo> entityFs = getEntity("AI066", "turbine");
|
|
@@ -2580,14 +2624,23 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
});
|
|
|
|
|
|
Map<String, String> entityMxzt = getEntityMap("MXZT", "turbine");
|
|
|
- Map<String, String> entityQfzt = getEntityMap("SSQFZT", "turbine");
|
|
|
+ Map<String, String> entityQfzt = getEntityMap("SSQFZT", "turbine");
|
|
|
+ //Map<String, String> entityKygl = getEntityMap("KYGL", "turbine");
|
|
|
|
|
|
- List<PointData> qfztDataList = entityFs.stream().map(qfzt->{
|
|
|
- String wtId = qfzt.getTurbineId();
|
|
|
- PointData data = qfzt.getPointDatas().get(qfzt.getPointDatas().size()-1);
|
|
|
+ List<PointInfo> fsEntity = entityFs.stream().peek(fs -> {
|
|
|
+ PointData data = fs.getPointDatas().get(fs.getPointDatas().size() - 1);
|
|
|
+ if (data != null) {
|
|
|
+ fs.setPointDatas(Collections.singletonList(data));
|
|
|
+ } else {
|
|
|
+ fs.setPointDatas(Collections.singletonList(new PointData()));
|
|
|
+ }
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ List<PointData> qfztDataList = fsEntity.stream().map(fs -> {
|
|
|
+ String wtId = fs.getTurbineId();
|
|
|
+ PointData data = fs.getPointDatas().get(0);
|
|
|
data.setTs(date.getTime());
|
|
|
data.setTagName(entityQfzt.get(wtId));
|
|
|
- data.setDoubleValue(calcQfzt(glMap.get(wtId).get(0).getValue(),CalcCache.fitcoef.get(wtId).get(data.getValue())));
|
|
|
+ data.setDoubleValue(calcQfzt(glMap.get(wtId).get(0).getValue(), CalcCache.fitcoef.get(wtId).get(data.getValue())));
|
|
|
return data;
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
@@ -2610,7 +2663,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
return true;
|
|
|
}
|
|
|
}).collect(Collectors.toList());
|
|
|
- List<PointData> collect2 = qfztDataList.stream().filter(d -> {
|
|
|
+ List<PointData> qfztDatas = qfztDataList.stream().filter(d -> {
|
|
|
if (Objects.equals(CalcCache.qfztCache.get(d.getTagName()), d.getValue())) {
|
|
|
return false;
|
|
|
} else {
|
|
@@ -2619,7 +2672,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
}
|
|
|
}).collect(Collectors.toList());
|
|
|
adapter.writeHistoryBatch(taosUri(), collect);
|
|
|
- adapter.writeHistoryBatch(taosUri(), collect2);
|
|
|
+ adapter.writeHistoryBatch(taosUri(), qfztDatas);
|
|
|
}
|
|
|
}
|
|
|
//此处加公式
|
|
@@ -2685,6 +2738,21 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void getStatDataByEntity(List<PointInfo> entity, URI uri, Date start, Date end) {
|
|
|
+ for (PointInfo info : entity) {
|
|
|
+ DoubleStatData stat = adapter.getHistoryStat(uri, info.getPointKey(), start.getTime(), end.getTime());
|
|
|
+ ThreadUtil.sleep(5);
|
|
|
+ info.getPointDatas().add(stat.getAvg());
|
|
|
+ info.getPointDatas().add(stat.getMax());
|
|
|
+ info.getPointDatas().add(stat.getMin());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<String, PointInfo> getStatDataByEntityMap(List<PointInfo> entity, URI uri, Date start, Date end,Function<PointInfo,String> function) {
|
|
|
+ getStatDataByEntity(entity, uri, start, end);
|
|
|
+ return entity.stream().collect(Collectors.toMap(function, Function.identity()));
|
|
|
+ }
|
|
|
+
|
|
|
// 主函数或测试方法(如果需要)
|
|
|
public static void main(String[] args) {
|
|
|
Double b = 2.0;
|
|
@@ -2702,10 +2770,10 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
points.add(new PointData(2000, 1));
|
|
|
points.add(new PointData(2500, 3));
|
|
|
|
|
|
-// Map<Integer, Long> durations = calculateStateDurations(points);
|
|
|
-// for (Map.Entry<Integer, Long> entry : durations.entrySet()) {
|
|
|
-// System.out.println("State " + entry.getKey() + ": " + entry.getValue() + "ms");
|
|
|
-// }
|
|
|
+ // Map<Integer, Long> durations = calculateStateDurations(points);
|
|
|
+ // for (Map.Entry<Integer, Long> entry : durations.entrySet()) {
|
|
|
+ // System.out.println("State " + entry.getKey() + ": " + entry.getValue() + "ms");
|
|
|
+ // }
|
|
|
}
|
|
|
|
|
|
public List<PointInfo> getLatest(String uniformCode, String institutionType) {
|
|
@@ -2937,24 +3005,24 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
DateTime time0 = DateUtil.offsetDay(time, -1);
|
|
|
DateTime beginOfMonth = DateUtil.beginOfMonth(time0);
|
|
|
DateTime beginOfYear = DateUtil.beginOfYear(time0);
|
|
|
-
|
|
|
+
|
|
|
QueryWrapper<TurbineInfoDay> wrapper = new QueryWrapper<>();
|
|
|
wrapper.select("sum(llfdl) llfdl,sum(jhjxss) jhjxss,sum(fjhjxss) fjhjxss,sum(xdss) xdss,sum(slss) slss,sum(xnss) xnss," +
|
|
|
- "sum(gzss) gzss,sum(djss) djss,avg(pjfs) pjfs,sum(dj_min) dj_min,sum(tj_min) tj_min,sum(yx_min) yx_min,sum(gz_min) gz_min," +
|
|
|
+ "sum(gzss) gzss,sum(djss) djss,avg(pjfs) pjfs,sum(dj_min) dj_min,sum(tj_min) tj_min,sum(yx_min) yx_min,sum(gz_min) gz_min," +
|
|
|
"sum(jx_min) jx_min,sum(xd_min) xd_min,sum(lx_min) lx_min,project_id,station_id")
|
|
|
.eq("record_date", time0).groupBy("project_id,station_id");
|
|
|
List<TurbineInfoDay> days = turbineInfoDayService.list(wrapper);
|
|
|
Map<String, TurbineInfoDay> dayMap = days.stream().collect(Collectors.toMap(TurbineInfoDay::getProjectId, Function.identity()));
|
|
|
wrapper = new QueryWrapper<>();
|
|
|
wrapper.select("sum(llfdl) llfdl,sum(jhjxss) jhjxss,sum(fjhjxss) fjhjxss,sum(xdss) xdss,sum(slss) slss,sum(xnss) xnss," +
|
|
|
- "sum(gzss) gzss,sum(djss) djss,avg(pjfs) pjfs,sum(dj_min) dj_min,sum(tj_min) tj_min,sum(yx_min) yx_min,sum(gz_min) gz_min," +
|
|
|
+ "sum(gzss) gzss,sum(djss) djss,avg(pjfs) pjfs,sum(dj_min) dj_min,sum(tj_min) tj_min,sum(yx_min) yx_min,sum(gz_min) gz_min," +
|
|
|
"sum(jx_min) jx_min,sum(xd_min) xd_min,sum(lx_min) lx_min,project_id,station_id")
|
|
|
.between("record_date", beginOfMonth, time0).groupBy("project_id,station_id");
|
|
|
List<TurbineInfoDay> monthDays = turbineInfoDayService.list(wrapper);
|
|
|
Map<String, TurbineInfoDay> monthMap = monthDays.stream().collect(Collectors.toMap(TurbineInfoDay::getProjectId, Function.identity()));
|
|
|
wrapper = new QueryWrapper<>();
|
|
|
wrapper.select("sum(llfdl) llfdl,sum(jhjxss) jhjxss,sum(fjhjxss) fjhjxss,sum(xdss) xdss,sum(slss) slss,sum(xnss) xnss," +
|
|
|
- "sum(gzss) gzss,sum(djss) djss,avg(pjfs) pjfs,sum(dj_min) dj_min,sum(tj_min) tj_min,sum(yx_min) yx_min,sum(gz_min) gz_min," +
|
|
|
+ "sum(gzss) gzss,sum(djss) djss,avg(pjfs) pjfs,sum(dj_min) dj_min,sum(tj_min) tj_min,sum(yx_min) yx_min,sum(gz_min) gz_min," +
|
|
|
"sum(jx_min) jx_min,sum(xd_min) xd_min,sum(lx_min) lx_min,project_id,station_id")
|
|
|
.between("record_date", beginOfYear, time0).groupBy("project_id,station_id");
|
|
|
List<TurbineInfoDay> yearDays = turbineInfoDayService.list(wrapper);
|
|
@@ -3032,12 +3100,12 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
pool.setRxnssdl(day.getXnss());
|
|
|
pool.setRxdjclssdl(day.getXdss());
|
|
|
pool.setRllfdl(day.getLlfdl());
|
|
|
- pool.setRhjdjxs(day.getDjMin()/60);
|
|
|
- pool.setRhjgztjxs(day.getGzMin()/60);
|
|
|
- pool.setRhjtxzdxs(day.getLxMin()/60);
|
|
|
- pool.setRhjjxtjxs(day.getJxMin()/60);
|
|
|
- pool.setRhjxdxs(day.getXdMin()/60);
|
|
|
- pool.setRhjyxxs(day.getYxMin()/60);
|
|
|
+ pool.setRhjdjxs(day.getDjMin() / 60);
|
|
|
+ pool.setRhjgztjxs(day.getGzMin() / 60);
|
|
|
+ pool.setRhjtxzdxs(day.getLxMin() / 60);
|
|
|
+ pool.setRhjjxtjxs(day.getJxMin() / 60);
|
|
|
+ pool.setRhjxdxs(day.getXdMin() / 60);
|
|
|
+ pool.setRhjyxxs(day.getYxMin() / 60);
|
|
|
pool.setRhjslxs(0.0);
|
|
|
|
|
|
pool.setYpjfs(month.getPjfs());
|
|
@@ -3047,12 +3115,12 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
pool.setYxnssdl(month.getXnss());
|
|
|
pool.setYxdjclssdl(month.getXdss());
|
|
|
pool.setYllfdl(month.getLlfdl());
|
|
|
- pool.setYhjdjxs(month.getDjMin()/60);
|
|
|
- pool.setYhjgztjxs(month.getGzMin()/60);
|
|
|
- pool.setYhjtxzdxs(month.getLxMin()/60);
|
|
|
- pool.setYhjjxtjxs(month.getJxMin()/60);
|
|
|
- pool.setYhjxdxs(month.getXdMin()/60);
|
|
|
- pool.setYhjyxxs(month.getYxMin()/60);
|
|
|
+ pool.setYhjdjxs(month.getDjMin() / 60);
|
|
|
+ pool.setYhjgztjxs(month.getGzMin() / 60);
|
|
|
+ pool.setYhjtxzdxs(month.getLxMin() / 60);
|
|
|
+ pool.setYhjjxtjxs(month.getJxMin() / 60);
|
|
|
+ pool.setYhjxdxs(month.getXdMin() / 60);
|
|
|
+ pool.setYhjyxxs(month.getYxMin() / 60);
|
|
|
pool.setYhjslxs(0.0);
|
|
|
|
|
|
pool.setNpjfs(year.getPjfs());
|
|
@@ -3062,12 +3130,12 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
pool.setNxnssdl(year.getXnss());
|
|
|
pool.setNxdjclssdl(year.getXdss());
|
|
|
pool.setNllfdl(year.getLlfdl());
|
|
|
- pool.setNhjdjxs(year.getDjMin()/60);
|
|
|
- pool.setNhjgztjxs(year.getGzMin()/60);
|
|
|
- pool.setNhjtxzdxs(year.getLxMin()/60);
|
|
|
- pool.setNhjjxtjxs(year.getJxMin()/60);
|
|
|
- pool.setNhjxdxs(year.getXdMin()/60);
|
|
|
- pool.setNhjyxxs(year.getYxMin()/60);
|
|
|
+ pool.setNhjdjxs(year.getDjMin() / 60);
|
|
|
+ pool.setNhjgztjxs(year.getGzMin() / 60);
|
|
|
+ pool.setNhjtxzdxs(year.getLxMin() / 60);
|
|
|
+ pool.setNhjjxtjxs(year.getJxMin() / 60);
|
|
|
+ pool.setNhjxdxs(year.getXdMin() / 60);
|
|
|
+ pool.setNhjyxxs(year.getYxMin() / 60);
|
|
|
pool.setNhjslxs(0.0);
|
|
|
}
|
|
|
|
|
@@ -3087,7 +3155,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
pool.setRhjxdxs(p.getRhjxdxs());
|
|
|
pool.setRhjyxxs(p.getRhjyxxs());
|
|
|
pool.setRhjslxs(0.0);
|
|
|
-
|
|
|
+
|
|
|
pool.setYpjfs(p.getYpjfs() / pools.size());
|
|
|
pool.setYgzssdl(p.getYgzssdl());
|
|
|
pool.setYjxssdl(p.getYjxssdl());
|
|
@@ -3199,6 +3267,111 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
}
|
|
|
return qfzt;
|
|
|
}
|
|
|
+
|
|
|
+ public List<TurbineInfoMin> getTurbineinfoMin(Date date) {
|
|
|
+ QueryWrapper<TurbineInfoMin> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.eq("record_date", date);
|
|
|
+ return turbineInfoMinService.list(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<TurbineInfoMin> getTurbineinfoMinByEntity(Date date, List<PointInfo> entity) {
|
|
|
+ List<TurbineInfoMin> list = getTurbineinfoMin(date);
|
|
|
+ if (list.isEmpty()) {
|
|
|
+ entity.forEach(pi -> {
|
|
|
+ TurbineInfoMin day = new TurbineInfoMin();
|
|
|
+ day.setStationId(pi.getStationId());
|
|
|
+ day.setProjectId(pi.getProjectId());
|
|
|
+ day.setLineId(pi.getLineId());
|
|
|
+ day.setTurbineId(pi.getTurbineId());
|
|
|
+ day.setRecordDate(date);
|
|
|
+ list.add(day);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<String, TurbineInfoMin> getTurbineinfoMinMap(Date date) {
|
|
|
+ List<TurbineInfoMin> tims = getTurbineinfoMin(date);
|
|
|
+ return tims.stream().collect(Collectors.toMap(TurbineInfoMin::getTurbineId, Function.identity()));
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<String, TurbineInfoMin> getTurbineinfoMinMapByEntity(Date date, List<PointInfo> entity) {
|
|
|
+ List<TurbineInfoMin> tims = getTurbineinfoMinByEntity(date, entity);
|
|
|
+ return tims.stream().collect(Collectors.toMap(TurbineInfoMin::getTurbineId, Function.identity()));
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<String, PointInfo> getRawDataMapByEntity(List<PointInfo> entity, URI uri, Date start, Date end, Function<PointInfo, String> function) {
|
|
|
+ getRawDataByEntity(entity, uri, start, end);
|
|
|
+ return entity.stream().collect(Collectors.toMap(function, Function.identity()));
|
|
|
+ }
|
|
|
+
|
|
|
+ public void calcTurbinePjfsPjglKyglLlglMin(Date date, int granularity) {
|
|
|
+ date = DateUtil.beginOfMinute(date);
|
|
|
+ DateTime start = DateUtil.offsetMinute(date, -granularity);
|
|
|
+ //风速
|
|
|
+ List<PointInfo> entityFs = getEntity("AI066", "turbine");
|
|
|
+ Map<String, PointInfo> rawMapFs = getRawDataMapByEntity(entityFs, goldenUri(), start, date, PointInfo::getTurbineId);
|
|
|
+ //功率
|
|
|
+ List<PointInfo> entityGl = getEntity("AI114", "turbine");
|
|
|
+ Map<String, PointInfo> rawMapGl = getRawDataMapByEntity(entityGl, goldenUri(), start, date, PointInfo::getTurbineId);
|
|
|
+ List<PointInfo> entityZt = getEntity("MXZT", "turbine");
|
|
|
+ Map<String, PointInfo> rawMapZt = getRawDataMapByEntity(entityZt, goldenUri(), start, date, PointInfo::getTurbineId);
|
|
|
+
|
|
|
+ List<TurbineInfoMin> mins = getTurbineinfoMinByEntity(date, entityFs);
|
|
|
+ for (TurbineInfoMin min : mins) {
|
|
|
+ String tbId = min.getTurbineId();
|
|
|
+ List<PointData> fsDatas = rawMapFs.get(tbId).getPointDatas();
|
|
|
+ List<PointData> ztDatas = rawMapZt.get(tbId).getPointDatas();
|
|
|
+ ztDatas = doublePointDatasFull(2, ztDatas, start.getTime(), date.getTime(), 1);
|
|
|
+ Map<Long, Double> ztMap = ztDatas.stream().collect(Collectors.toMap(PointData::getTs, PointData::getValue));
|
|
|
+ double pjfs = fsDatas.stream().mapToDouble(PointData::getValue).average().orElse(0);
|
|
|
+ fsDatas = fsDatas.stream().peek(pd -> pd.setDoubleValue(NumberUtil.round(pd.getValue(), 2).doubleValue())).collect(Collectors.toList());
|
|
|
+ double llgl = fsDatas.stream().peek(pd -> pd.setDoubleValue(CalcCache.llgl.get(tbId).get(pd.getValue())))
|
|
|
+ .mapToDouble(PointData::getValue).average().orElse(0);
|
|
|
+ double kygl = fsDatas.stream().filter(pd -> ztMap.get(pd.getTs()) != 4 || ztMap.get(pd.getTs()) != 6)
|
|
|
+ .peek(pd -> pd.setDoubleValue(CalcCache.fitcoef.get(tbId).get(pd.getValue())))
|
|
|
+ .mapToDouble(PointData::getValue).average().orElse(0);
|
|
|
+ double sjgl = rawMapGl.get(tbId).getPointDatas().stream().mapToDouble(PointData::getValue).average().orElse(0);
|
|
|
+
|
|
|
+ double v = llgl * 0.9;
|
|
|
+ if (kygl > v) kygl = v;
|
|
|
+ if (kygl < sjgl) kygl = sjgl;
|
|
|
+ min.setPjfs(pjfs);
|
|
|
+ min.setPjgl(sjgl);
|
|
|
+ min.setLlgl(llgl);
|
|
|
+ min.setKygl(kygl);
|
|
|
+ }
|
|
|
+ turbineInfoMinService.saveOrUpdateBatch(mins);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void calcStationLlglKyglSjglAgcMin(Date date, int granularity) {
|
|
|
+ date = DateUtil.beginOfMinute(date);
|
|
|
+ DateTime start = DateUtil.offsetMinute(date, -granularity);
|
|
|
+
|
|
|
+ //AGC
|
|
|
+ List<PointInfo> entityAgc = getEntity("AGC002", "booster");
|
|
|
+ Map<String, PointInfo> statMapAgc = getStatDataByEntityMap(entityAgc, goldenUri(), start, date, PointInfo::getTurbineId);
|
|
|
+ //出线
|
|
|
+ List<PointInfo> entityCx = getEntity("AGC001", "booster");
|
|
|
+ Map<String, PointInfo> statMapCx = getStatDataByEntityMap(entityCx, goldenUri(), start, date, PointInfo::getTurbineId);
|
|
|
+
|
|
|
+ QueryWrapper<TurbineInfoMin> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.select("sum(llgl) llgl,sum(kygl) kygl,sum(pjfs) pjfs,station_id").eq("record_date", date).groupBy("station_id");
|
|
|
+ List<TurbineInfoMin> list = turbineInfoMinService.list(wrapper);
|
|
|
+ Map<String, TurbineInfoMin> minMap = list.stream().collect(Collectors.toMap(TurbineInfoMin::getStationId, Function.identity()));
|
|
|
+ List<StationInfoMin> byDate = getStationinfoMinByDate(date,entityAgc);
|
|
|
+
|
|
|
+ for (StationInfoMin day : byDate) {
|
|
|
+ String stId = day.getStationId();
|
|
|
+ TurbineInfoMin min = minMap.get(stId);
|
|
|
+ day.setLlgl(min.getLlgl());
|
|
|
+ day.setKygl(min.getKygl());
|
|
|
+ day.setAgc(statMapAgc.get(stId).getPointDatas().get(0).getValue());
|
|
|
+ day.setPjgl(statMapCx.get(stId).getPointDatas().get(0).getValue());
|
|
|
+ day.setPjfs(min.getPjfs());
|
|
|
+ }
|
|
|
+ stationInfoMinService.saveOrUpdateBatch(byDate);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|