|
@@ -30,9 +30,6 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
|
|
|
-/* @Resource
|
|
|
- private PointInfo pointInfo;*/
|
|
|
-
|
|
|
@Resource
|
|
|
private AdapterApi adapter;
|
|
|
@Resource
|
|
@@ -105,13 +102,15 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
wrapper.eq("record_date", date);
|
|
|
return stationInfoDayService.list(wrapper);
|
|
|
}
|
|
|
- public List<StationInfoMin> getStationinfoMinByDate(Date date) {
|
|
|
+
|
|
|
+ public List<StationInfoMin> getStationinfoByMin(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);
|
|
|
+
|
|
|
+ public List<StationInfoMin> getStationinfoByMin(Date date, List<PointInfo> entity) {
|
|
|
+ List<StationInfoMin> byDate = getStationinfoByMin(date);
|
|
|
if (CollUtil.isEmpty(byDate)) {
|
|
|
entity.forEach(pi -> {
|
|
|
StationInfoMin day = new StationInfoMin();
|
|
@@ -123,11 +122,20 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
return byDate;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
public StationInfoDay getStationinfoByDate(Date date, String stId) {
|
|
|
QueryWrapper<StationInfoDay> wrapper = new QueryWrapper<>();
|
|
|
wrapper.eq("record_date", date).eq("station_id", stId);
|
|
|
List<StationInfoDay> list = stationInfoDayService.list(wrapper);
|
|
|
- return CollUtil.isNotEmpty(list) ? list.get(0) : new StationInfoDay();
|
|
|
+ StationInfoDay day;
|
|
|
+ if (CollUtil.isEmpty(list)) {
|
|
|
+ day = new StationInfoDay();
|
|
|
+ day.setStationId(stId);
|
|
|
+ day.setRecordDate(date);
|
|
|
+ } else {
|
|
|
+ day = list.get(0);
|
|
|
+ }
|
|
|
+ return day;
|
|
|
}
|
|
|
|
|
|
public List<StationInfoDay> getStationinfoByDate(Date date, List<PointInfo> entity) {
|
|
@@ -264,14 +272,15 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
return pointService.getByEntity(pi);
|
|
|
}
|
|
|
|
|
|
- public Map<String, Double> getTurbinePowerLoss(double rfdl, PointInfo piZt, List<PointData> fsList, List<PointData> glList) {
|
|
|
+ public Map<String, Double> getTurbinePowerLoss(Double rfdl, PointInfo piZt, List<PointData> fsList, List<PointData> glList) {
|
|
|
+ if (rfdl == null) rfdl = 0.0;
|
|
|
String tbId = piZt.getTurbineId();
|
|
|
// Map<Double, Long> collect = piZt.getPointDatas().stream().collect(Collectors.groupingBy(PointData::getValue, Collectors.counting()));
|
|
|
- double sum1 = glList.stream().mapToDouble(PointData::getValue).sum();
|
|
|
- double xs = 1;
|
|
|
- if (rfdl > 0 && sum1 > 0) {
|
|
|
- xs = rfdl / (sum1 / 240);
|
|
|
- }
|
|
|
+ double sumfs = fsList.stream().mapToDouble(PointData::getValue).sum();
|
|
|
+// double xs = 1;
|
|
|
+// if (rfdl > 0 && sum1 > 0) {
|
|
|
+// xs = rfdl / (sum1 / 240);
|
|
|
+// }
|
|
|
// double sum2 = fsList.stream().mapToDouble(pd -> {
|
|
|
// Double v = CalcCache.fitcoef.get(tbId).get(pd.getValue());
|
|
|
// if (v == null) v = 0.0;
|
|
@@ -282,8 +291,9 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
List<PointData> collectZt = piZt.getPointDatas();
|
|
|
double jxss = 0, sdtj = 0, gzss = 0, djss = 0, xnss = 0, fdjcl = 0, xdjcl = 0, xdtj = 0;
|
|
|
Map<String, Double> map = new HashMap<>();
|
|
|
- if (collectZt.size() == fsList.size() && fsList.size() == glList.size()) {
|
|
|
- for (int i = 0; i < collectZt.size(); i++) {
|
|
|
+ if (Math.abs(collectZt.size() - fsList.size()) < 9 && Math.abs(fsList.size() - glList.size()) < 9) {
|
|
|
+ int min = Math.min(collectZt.size(), Math.min(fsList.size(), glList.size()));
|
|
|
+ for (int i = 0; i < min; i++) {
|
|
|
Double v = CalcCache.fitcoef.get(tbId).get(fsList.get(i).getValue());
|
|
|
if (v == null) v = 0.0;
|
|
|
v = v - glList.get(i).getValue();
|
|
@@ -336,14 +346,17 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
if (xdjcl > 30000) xdjcl = 0;
|
|
|
if (xdtj > 30000) xdtj = 0;
|
|
|
//15秒*60分钟
|
|
|
- map.put("jxss", jxss > 0 ? jxss / 240 * xs : 0);
|
|
|
- map.put("sdtj", sdtj > 0 ? sdtj / 240 * xs : 0);
|
|
|
- map.put("gzss", gzss > 0 ? gzss / 240 * xs : 0);
|
|
|
- map.put("djss", djss > 0 ? djss / 240 * xs : 0);
|
|
|
- map.put("xnss", xnss > 0 ? xnss / 240 * xs : 0);
|
|
|
- map.put("fdjcl", fdjcl > 0 ? fdjcl / 240 * xs : 0);
|
|
|
- map.put("xdjcl", xdjcl > 0 ? xdjcl / 240 * xs : 0);
|
|
|
- map.put("xdtj", xdtj > 0 ? xdtj / 240 * xs : 0);
|
|
|
+ map.put("jxss", jxss > 0 ? jxss / 240 : 0);
|
|
|
+ map.put("sdtj", sdtj > 0 ? sdtj / 240 : 0);
|
|
|
+ map.put("gzss", gzss > 0 ? gzss / 240 : 0);
|
|
|
+ map.put("djss", djss > 0 ? djss / 240 : 0);
|
|
|
+ map.put("xnss", xnss > 0 ? xnss / 240 : 0);
|
|
|
+ map.put("fdjcl", fdjcl > 0 ? fdjcl / 240 : 0);
|
|
|
+ map.put("xdjcl", xdjcl > 0 ? xdjcl / 240 : 0);
|
|
|
+ map.put("xdtj", xdtj > 0 ? xdtj / 240 : 0);
|
|
|
+
|
|
|
+ double v = map.get("jxss") + map.get("sdtj") + map.get("gzss") + map.get("djss") + map.get("xnss") + map.get("fdjcl") + map.get("xdjcl") + map.get("xdtj");
|
|
|
+ System.out.println(piZt.getTurbineId() + ",日发" + rfdl + ",损失" + v + ",风速和" + sumfs / 240);
|
|
|
return map;
|
|
|
}
|
|
|
|
|
@@ -597,17 +610,102 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
stationInfoDayService.saveOrUpdateBatch(byDate);
|
|
|
}
|
|
|
|
|
|
+ public void SwdlRepair(Date date) {
|
|
|
+ //date当天零点
|
|
|
+ DateTime time = DateUtil.beginOfDay(date);
|
|
|
+ //date昨天零点
|
|
|
+ DateTime time0 = DateUtil.offsetDay(time, -1);
|
|
|
+ List<PointInfo> swdlEt = getEntity("Z-ZXYG-CX", "meter");
|
|
|
+ Map<String, PointInfo> map = swdlEt.stream().collect(Collectors.toMap(PointInfo::getStationId, Function.identity()));
|
|
|
+ List<StationInfoDay> list = getStationinfoByDate(time0);
|
|
|
+ Map<String, StationInfoDay> dayMap = list.stream().collect(Collectors.toMap(StationInfoDay::getStationId, Function.identity()));
|
|
|
+ CalcCache.swdlTime.forEach((key, ts) -> {
|
|
|
+ int swdl = 0;
|
|
|
+ PointData data1, data0;
|
|
|
+ double ll = (double) (time.getTime() - ts) / 23 * 60 * 60 * 1000;
|
|
|
+ if (ts > 0 && (ll > 23 && ll < 25)) {
|
|
|
+ StationInfoDay day = dayMap.get(key);
|
|
|
+ PointInfo info = map.get(key);
|
|
|
+ List<PointData> raw1 = adapter.getHistoryRaw(goldenUri(), key, time.getTime(), DateUtil.offsetMinute(time, 6).getTime());
|
|
|
+ if (CollUtil.isEmpty(raw1)) {
|
|
|
+ Map<String, PointData> section = adapter.getHistorySection(goldenUri(), key, time.getTime() + 1000);
|
|
|
+ data1 = section.get(key);
|
|
|
+ } else {
|
|
|
+ data1 = raw1.get(0);
|
|
|
+ }
|
|
|
+ Map<String, PointData> section = adapter.getHistorySection(goldenUri(), key, ts + 1000);
|
|
|
+ data0 = section.get(key);
|
|
|
+ swdl = (int) ((data1.getValue() - data0.getValue()) * info.getCoef());
|
|
|
+ if (swdl > day.getRfdl()) {
|
|
|
+ List<PointData> rawl1 = adapter.getHistoryRaw(goldenUri(), key, DateUtil.offsetMinute(time, -60).getTime(), time.getTime());
|
|
|
+ for (int i = rawl1.size() - 1; i >= 0; i--) {
|
|
|
+ swdl = (int) ((rawl1.get(i).getValue() - data0.getValue()) * info.getCoef());
|
|
|
+ if (swdl <= day.getRfdl()) {
|
|
|
+ day.setSwdl(swdl);
|
|
|
+ day.setZhcydl(day.getRfdl() + day.getGwdl() - day.getSwdl());
|
|
|
+ day.setCydl(day.getZhcydl() - day.getZyb());
|
|
|
+ CalcCache.swdlTime.put(info.getPointKey(), rawl1.get(i).getTs());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ day.setSwdl(swdl);
|
|
|
+ day.setZhcydl(day.getRfdl() + day.getGwdl() - day.getSwdl());
|
|
|
+ day.setCydl(day.getZhcydl() - day.getZyb());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ for (StationInfoDay day : list) {
|
|
|
+ int swdl = 0;
|
|
|
+ if (day.getSwdl() > day.getRfdl()) {
|
|
|
+ PointInfo info = map.get(day.getStationId());
|
|
|
+ Long l = CalcCache.swdlTime.get(info.getPointKey());
|
|
|
+ PointData data0;
|
|
|
+ if (l == null || l == 0) {
|
|
|
+ List<PointData> raw0 = adapter.getHistoryRaw(goldenUri(), info.getPointKey(), time0.getTime(), DateUtil.offsetMinute(time0, 6).getTime());
|
|
|
+ if (CollUtil.isEmpty(raw0)) {
|
|
|
+ Map<String, PointData> section = adapter.getHistorySection(goldenUri(), info.getPointKey(), time0.getTime() + 1000);
|
|
|
+ data0 = section.get(info.getPointKey());
|
|
|
+ } else {
|
|
|
+ data0 = raw0.get(0);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ double ll = (double) (time.getTime() - l) / 23 * 60 * 60 * 1000;
|
|
|
+ if (ll > 23 && ll < 25) {
|
|
|
+ Map<String, PointData> section = adapter.getHistorySection(goldenUri(), info.getPointKey(), l + 1000);
|
|
|
+ data0 = section.get(info.getPointKey());
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<PointData> raw1 = adapter.getHistoryRaw(goldenUri(), info.getPointKey(), DateUtil.offsetMinute(time, -60).getTime(), time.getTime());
|
|
|
+ for (int i = raw1.size() - 1; i >= 0; i--) {
|
|
|
+ swdl = (int) ((raw1.get(i).getValue() - data0.getValue()) * info.getCoef());
|
|
|
+ if (swdl <= day.getRfdl()) {
|
|
|
+ day.setSwdl(swdl);
|
|
|
+ day.setZhcydl(day.getRfdl() + day.getGwdl() - day.getSwdl());
|
|
|
+ day.setCydl(day.getZhcydl() - day.getZyb());
|
|
|
+ CalcCache.swdlTime.put(info.getPointKey(), raw1.get(i).getTs());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ stationInfoDayService.saveOrUpdateBatch(list);
|
|
|
+ stringRedisTemplate.opsForValue().set("swdlTime", JSON.toJSONString(CalcCache.swdlTime));
|
|
|
+ }
|
|
|
+
|
|
|
public void getZeroNextData(List<PointInfo> entity, Date start0, Date start) {
|
|
|
List<PointData> snap0, snap;
|
|
|
for (PointInfo info : entity) {
|
|
|
PointData data0, data;
|
|
|
List<PointData> datas = new ArrayList<>();
|
|
|
- snap0 = adapter.getHistoryRaw(goldenUri(), info.getPointKey(), start0.getTime(), DateUtil.offsetMinute(start0, 90).getTime());
|
|
|
+ snap0 = adapter.getHistoryRaw(goldenUri(), info.getPointKey(), start0.getTime(), DateUtil.offsetMinute(start0, 6).getTime());
|
|
|
if (CollUtil.isEmpty(snap0)) {
|
|
|
Map<String, PointData> section = adapter.getHistorySection(goldenUri(), info.getPointKey(), start0.getTime());
|
|
|
snap0 = new ArrayList<>(section.values());
|
|
|
}
|
|
|
- snap = adapter.getHistoryRaw(goldenUri(), info.getPointKey(), start.getTime(), DateUtil.offsetMinute(start, 90).getTime());
|
|
|
+ snap = adapter.getHistoryRaw(goldenUri(), info.getPointKey(), start.getTime(), DateUtil.offsetMinute(start, 6).getTime());
|
|
|
if (CollUtil.isEmpty(snap)) {
|
|
|
Map<String, PointData> section = adapter.getHistorySection(goldenUri(), info.getPointKey(), start.getTime());
|
|
|
snap = new ArrayList<>(section.values());
|
|
@@ -698,6 +796,91 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
lineInfoDayService.saveOrUpdateBatch(byDate);
|
|
|
}
|
|
|
|
|
|
+ public void calcTurbineRFDLSameDay() {
|
|
|
+ DateTime time = DateUtil.date();
|
|
|
+ //date当天零点
|
|
|
+ DateTime time0 = DateUtil.beginOfDay(time);
|
|
|
+
|
|
|
+ List<PointInfo> entity = getEntity("AI121", "turbine");
|
|
|
+ getZeroNextData(entity, time0, time);
|
|
|
+ Map<String, PointInfo> turMap = entity.stream().collect(Collectors.toMap(PointInfo::getTurbineId, Function.identity()));
|
|
|
+ Map<String, String> fsMap = getEntityMap("AI066", "turbine");
|
|
|
+
|
|
|
+ Map<String, TurbineInfoDay> byDate = getTurbineinfoMap(time0, entity);
|
|
|
+
|
|
|
+ TurbineInfoDay infoDay;
|
|
|
+ PointInfo rfdlPi;
|
|
|
+ String turbineId;
|
|
|
+ List<TurbineInfoDay> infoDays = new ArrayList<>();
|
|
|
+ DoubleStatData stat;
|
|
|
+ for (PointInfo info : entity) {
|
|
|
+ turbineId = info.getTurbineId();
|
|
|
+ infoDay = byDate.get(turbineId);
|
|
|
+
|
|
|
+ rfdlPi = turMap.get(turbineId);
|
|
|
+ double v = (rfdlPi.getPointDatas().get(1).getValue() - rfdlPi.getPointDatas().get(0).getValue()) * rfdlPi.getCoef();
|
|
|
+ if (v < 0 || v > 1000000) {
|
|
|
+ v = 0;
|
|
|
+ } else if (v > 30000) {
|
|
|
+ v = v / (v % 30000 + 3);
|
|
|
+ }
|
|
|
+ infoDay.setRfdl(v);
|
|
|
+ stat = adapter.getHistoryStat(goldenUri(), fsMap.get(turbineId), time0.getTime(), time.getTime());
|
|
|
+ if (stat == null) {
|
|
|
+ infoDay.setPjfs(0.0);
|
|
|
+ } else {
|
|
|
+ infoDay.setPjfs(stat.getAvg().getValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ infoDays.add(infoDay);
|
|
|
+ }
|
|
|
+ turbineInfoDayService.saveOrUpdateBatch(infoDays);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void calcTurbine5s2SameDay() {
|
|
|
+ DateTime time = DateUtil.date();
|
|
|
+ //date当天零点
|
|
|
+ DateTime time0 = DateUtil.beginOfDay(time);
|
|
|
+ //风速
|
|
|
+ List<PointInfo> entityFs = getEntity("AI066", "turbine");
|
|
|
+ //功率
|
|
|
+ List<PointInfo> entityGl = getEntity("AI114", "turbine");
|
|
|
+ //状态
|
|
|
+ List<PointInfo> entityZT = getEntity("MXZT", "turbine");
|
|
|
+ Map<String, Map<String, PointInfo>> ztMapMapInfos = entityZT.stream().collect(Collectors.groupingBy(PointInfo::getStationId, Collectors.toMap(PointInfo::getTurbineId, Function.identity())));
|
|
|
+ Map<String, TurbineInfoDay> dayMap = getTurbineinfoMap(time0, entityFs);
|
|
|
+ List<TurbineInfoDay> infoDays = new ArrayList<>();
|
|
|
+ Map<String, Map<String, PointInfo>> fsMapMap = entityFs.stream().collect(Collectors.groupingBy(PointInfo::getStationId, Collectors.toMap(PointInfo::getTurbineId, Function.identity())));
|
|
|
+ Map<String, Map<String, PointInfo>> glMapMap = entityGl.stream().collect(Collectors.groupingBy(PointInfo::getStationId, Collectors.toMap(PointInfo::getTurbineId, Function.identity())));
|
|
|
+
|
|
|
+ ztMapMapInfos.forEach((stId, ztMapInfo) -> ztMapInfo.forEach((wtId, ztInfo) -> {
|
|
|
+ //0 待机,1 手动停机,2 正常发电,3 发电降出力,4 故障,5 故障受累,6 检修,7 检修受累,8 限电降出力,
|
|
|
+ // 9 限电停机,10 电网受累,11 环境受累,12 通讯中断,13 设备离线
|
|
|
+ TurbineInfoDay infoDay = dayMap.get(wtId);
|
|
|
+ PointInfo fspi = fsMapMap.get(stId).get(wtId);
|
|
|
+ PointInfo glpi = glMapMap.get(stId).get(wtId);
|
|
|
+ getSnapDataByEntity(fspi, time0, time, 15);
|
|
|
+ getSnapDataByEntity(glpi, time0, time, 15);
|
|
|
+ getSnapDataByEntity(ztInfo, taosUri(), time0, time, 15);
|
|
|
+ List<PointData> fsData = fspi.getPointDatas();
|
|
|
+ fsData = fsData.stream().peek(pd -> pd.setDoubleValue(NumberUtil.round(pd.getValue() > 25 ? 25.0 : pd.getValue(), 2).doubleValue())).collect(Collectors.toList());
|
|
|
+ Map<String, Double> loss = getTurbinePowerLoss(infoDay.getRfdl(), ztInfo, fsData, glpi.getPointDatas());
|
|
|
+ infoDay.setJhjxss(loss.get("jxss") + loss.get("sdtj"));
|
|
|
+ infoDay.setFjhjxss(loss.get("gzss") + loss.get("djss") + loss.get("fdjcl"));
|
|
|
+ infoDay.setXdss(loss.get("xdjcl") + loss.get("xdtj"));
|
|
|
+ infoDay.setSlss(0.0);
|
|
|
+ infoDay.setDjss(loss.get("djss"));
|
|
|
+ infoDay.setGzss(loss.get("gzss"));
|
|
|
+ if (infoDay.getRfdl() == 0) {
|
|
|
+ infoDay.setXnss(0.0);
|
|
|
+ } else {
|
|
|
+ infoDay.setXnss(loss.get("xnss"));
|
|
|
+ }
|
|
|
+ infoDay.setLlfdl(infoDay.getRfdl() + infoDay.getJhjxss() + infoDay.getFjhjxss() + infoDay.getXdss() + infoDay.getSlss() + infoDay.getXnss());
|
|
|
+ infoDays.add(infoDay);
|
|
|
+ }));
|
|
|
+ turbineInfoDayService.saveOrUpdateBatch(infoDays);
|
|
|
+ }
|
|
|
|
|
|
public void calcLineRfdlSameDay() {
|
|
|
//date当天零点
|
|
@@ -836,16 +1019,87 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
stationInfoDayService.saveOrUpdateBatch(infoDays);
|
|
|
}
|
|
|
|
|
|
+ public void calcStationHourPjglRfdl(Date hour) {
|
|
|
+ //hour整点
|
|
|
+ DateTime time = DateUtil.beginOfHour(hour);
|
|
|
+ //1小时前
|
|
|
+ DateTime time0 = DateUtil.offsetHour(time, -1);
|
|
|
+ //当天零点
|
|
|
+ DateTime rft = DateUtil.beginOfDay(time);
|
|
|
+
|
|
|
+ List<PointInfo> entity = getEntity("Z-ZXYG-JX", "meter");
|
|
|
+ //出线
|
|
|
+ List<PointInfo> entityCx = getEntity("AGC001", "booster");
|
|
|
+ Map<String, PointInfo> statMapCx = getStatDataByEntity(entityCx, goldenUri(), time0, time, PointInfo::getStationId);
|
|
|
+ List<StationInfoHour> byHours = getStationinfoByHour(time, entityCx);
|
|
|
+
|
|
|
+ entity = entity.stream().filter(e -> !"".equals(e.getProjectId())).collect(Collectors.toList());
|
|
|
+ if (time.getHours() == 0) {
|
|
|
+ getSectionDataByEntity(entity, goldenUri(), DateUtil.offsetDay(rft, -1), time);
|
|
|
+ } else {
|
|
|
+ getSectionDataByEntity(entity, goldenUri(), rft, time);
|
|
|
+ }
|
|
|
+ Map<String, List<PointInfo>> stMap = entity.stream().collect(Collectors.groupingBy(PointInfo::getStationId));
|
|
|
+ for (StationInfoHour byHour : byHours) {
|
|
|
+ List<PointInfo> pis = stMap.get(byHour.getStationId());
|
|
|
+ double dl = 0, v = 0;
|
|
|
+ List<PointData> pds;
|
|
|
+ for (PointInfo pi : pis) {
|
|
|
+ pds = pi.getPointDatas();
|
|
|
+ if (pds.size() > 1) v = (pds.get(1).getValue() - pds.get(0).getValue()) * pi.getCoef();
|
|
|
+ dl += (v < 0 || v > 30000000) ? 0 : v;
|
|
|
+ }
|
|
|
+ byHour.setRfdl(dl);
|
|
|
+
|
|
|
+ PointInfo info = statMapCx.get(byHour.getStationId());
|
|
|
+ double v1 = info.getPointDatas().get(0).getValue();
|
|
|
+ byHour.setPjgl(v1 <= 0 ? 0 : v1 * info.getCoef());
|
|
|
+ }
|
|
|
+
|
|
|
+ stationInfoHourService.saveOrUpdateBatch(byHours);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void calcStationMinRfdl(Date hour) {
|
|
|
+ //hour整分钟
|
|
|
+ DateTime time = DateUtil.beginOfMinute(hour);
|
|
|
+ //当天零点
|
|
|
+ DateTime rft = DateUtil.beginOfDay(time);
|
|
|
+ List<PointInfo> entity = getEntity("Z-ZXYG-JX", "meter");
|
|
|
+ entity = entity.stream().filter(e -> !"".equals(e.getProjectId())).collect(Collectors.toList());
|
|
|
+ List<StationInfoMin> byHours = getStationinfoByMin(time, entity);
|
|
|
+ getSectionDataByEntity(entity, goldenUri(), rft, time);
|
|
|
+ Map<String, List<PointInfo>> stMap = entity.stream().collect(Collectors.groupingBy(PointInfo::getStationId));
|
|
|
+ for (StationInfoMin byHour : byHours) {
|
|
|
+ List<PointInfo> pis = stMap.get(byHour.getStationId());
|
|
|
+ double dl = 0, v = 0;
|
|
|
+ List<PointData> pds;
|
|
|
+ for (PointInfo pi : pis) {
|
|
|
+ pds = pi.getPointDatas();
|
|
|
+ if (pds.size() > 1) v = (pds.get(1).getValue() - pds.get(0).getValue()) * pi.getCoef();
|
|
|
+ dl += (v < 0 || v > 30000000) ? 0 : v;
|
|
|
+ }
|
|
|
+ byHour.setRfdl(dl);
|
|
|
+ }
|
|
|
+ stationInfoMinService.saveOrUpdateBatch(byHours);
|
|
|
+ }
|
|
|
+
|
|
|
public void calcStationHourPJGL(Date hour) {
|
|
|
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);
|
|
|
+ Map<String, PointInfo> statMapCx = getStatDataByEntity(entityCx, goldenUri(), start, hour, PointInfo::getStationId);
|
|
|
|
|
|
- List<StationInfoHour> byHours = getStationinfoByHour(hour,entityCx);
|
|
|
+ List<StationInfoHour> byHours = getStationinfoByHour(hour, entityCx);
|
|
|
for (StationInfoHour byHour : byHours) {
|
|
|
- byHour.setPjgl(statMapCx.get(byHour.getStationId()).getPointDatas().get(0).getValue());
|
|
|
+ PointInfo info = statMapCx.get(byHour.getStationId());
|
|
|
+ double v = info.getPointDatas().get(0).getValue();
|
|
|
+ if (v < 0) {
|
|
|
+ v = 0;
|
|
|
+ } else {
|
|
|
+ v = v * info.getCoef();
|
|
|
+ }
|
|
|
+ byHour.setPjgl(v);
|
|
|
}
|
|
|
stationInfoHourService.saveOrUpdateBatch(byHours);
|
|
|
}
|
|
@@ -1085,7 +1339,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
// List<PointData> firstGl = new ArrayList<>();
|
|
|
List<PointData> firstZsgl = new ArrayList<>();
|
|
|
double v1, v2, v3;
|
|
|
- for (int i = 0; i < 5760; i++) {
|
|
|
+ for (int i = 0; i < agcInfo.getPointDatas().size(); i++) {
|
|
|
int finalI = i;
|
|
|
long ts = start.getTime() + i * 15000;
|
|
|
// v1 = fsMap.values().stream().mapToDouble(pds -> pds.getPointDatas().get(finalI).getValue()).average().orElse(0.0);
|
|
@@ -1097,7 +1351,9 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
}
|
|
|
|
|
|
List<PointData> czxd = calcStationXd2(agcInfo, cxInfo.getPointDatas(), firstZsgl);
|
|
|
+ String ybj = "GJNY_SXGS_FSG_F_WT_0013_EQ,GJNY_SXGS_FSG_F_WT_0042_EQ,GJNY_SXGS_FSG_F_WT_0062_EQ,GJNY_SXGS_FSG_F_WT_0064_EQ";
|
|
|
ztMap.forEach((wtId, ztInfo) -> {
|
|
|
+ if (ybj.contains(wtId)) return;
|
|
|
List<PointData> fss = fsMap.get(wtId).getPointDatas();
|
|
|
List<PointData> gls = glMapMap.get(stId).get(wtId);
|
|
|
//叶轮转速给定
|
|
@@ -1319,7 +1575,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
public List<PointData> boolPointDatasFull(boolean 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) {
|
|
|
+ for (long i = startTime; i <= endTime; i += interval * 1000L) {
|
|
|
PointData dt = new PointData();
|
|
|
dt.setTs(i);
|
|
|
data2.add(dt);
|
|
@@ -1343,7 +1599,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
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) {
|
|
|
+ for (long i = startTime; i <= endTime; i += interval * 1000L) {
|
|
|
PointData dt = new PointData();
|
|
|
dt.setTs(i);
|
|
|
data2.add(dt);
|
|
@@ -1394,6 +1650,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
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<>();
|
|
|
+// entityFs = entityFs.stream().filter(ef -> !CalcCache.keys.contains(ef.getTurbineId())).collect(Collectors.toList());
|
|
|
for (PointInfo ef : entityFs) {
|
|
|
String wtId = ef.getTurbineId();
|
|
|
PointInfo glInfo = glMap.get(wtId);
|
|
@@ -1419,12 +1676,77 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
}
|
|
|
ef.setPointDatas(null);
|
|
|
glInfo.setPointDatas(null);
|
|
|
- stringRedisTemplate.opsForValue().set("edfs:" + end.getMonth() + ":" + wtId, JSON.toJSONString(fit));
|
|
|
+ String key = "glqxnh:" + (end.getMonth() + 1) + ":" + wtId;
|
|
|
+ stringRedisTemplate.opsForValue().set(key, JSON.toJSONString(fit));
|
|
|
+ CalcCache.fitcoef.put(key, new ConcurrentHashMap<>(fit));
|
|
|
}
|
|
|
System.out.println("苹果天涯");
|
|
|
// stringRedisTemplate.opsForValue().set("glqxnh", JSON.toJSONString(fitMap));
|
|
|
}
|
|
|
|
|
|
+ public void calcGlqxnhSurplus(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<>();
|
|
|
+ entityFs = entityFs.stream().filter(ef -> !CalcCache.already.contains(ef.getTurbineId())).collect(Collectors.toList());
|
|
|
+ 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);
|
|
|
+ String key = "glqxnh:" + (end.getMonth() + 1) + ":" + wtId;
|
|
|
+ stringRedisTemplate.opsForValue().set(key, JSON.toJSONString(fit));
|
|
|
+ CalcCache.fitcoef.put(key, new ConcurrentHashMap<>(fit));
|
|
|
+ }
|
|
|
+ System.out.println("苹果天涯");
|
|
|
+ // stringRedisTemplate.opsForValue().set("glqxnh", JSON.toJSONString(fitMap));
|
|
|
+ }
|
|
|
|
|
|
public Map<Double, Double> dataProcessAndFit(PointInfo fsPI, PointInfo glPI, PointInfo ztPI, Map<Double, Double> modelPowerMap, double capacity) {
|
|
|
System.out.println("开始拟合");
|
|
@@ -1432,6 +1754,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
List<PointData> glPds = glPI.getPointDatas();
|
|
|
List<PointData> ztPds = ztPI.getPointDatas();
|
|
|
WeightedObservedPoints points = new WeightedObservedPoints();
|
|
|
+ if (ztPds.size() - glPds.size() == 1) ztPds.remove(glPds.size());
|
|
|
//数据过滤 0正常,1过滤掉
|
|
|
if (fsPds.size() != glPds.size() || glPds.size() != ztPds.size()) return new HashMap<>();
|
|
|
|
|
@@ -1528,16 +1851,27 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void getSectionDataByEntity(List<PointInfo> entitys, URI uri, Date start, Date end) {
|
|
|
+ String collect = entitys.stream().map(PointInfo::getPointKey).collect(Collectors.joining(","));
|
|
|
+ Map<String, PointData> section0 = adapter.getHistorySection(uri, collect, start.getTime());
|
|
|
+ Map<String, PointData> section1 = adapter.getHistorySection(uri, collect, end.getTime());
|
|
|
+ for (PointInfo entity : entitys) {
|
|
|
+ entity.setPointDatas(new ArrayList<>());
|
|
|
+ entity.getPointDatas().add(section0.get(entity.getPointKey()));
|
|
|
+ entity.getPointDatas().add(section1.get(entity.getPointKey()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public void getSnapDataByEntity(List<PointInfo> entity, URI uri, Date start, Date end, int interval) {
|
|
|
for (PointInfo info : entity) {
|
|
|
- List<PointData> snap = adapter.getHistorySnap(uri, info.getPointKey(), start.getTime(), end.getTime(), interval);
|
|
|
+ getSnapDataByEntity(info, uri, start, end, interval);
|
|
|
ThreadUtil.sleep(5);
|
|
|
- info.setPointDatas(snap);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void getSnapDataByEntity(PointInfo entity, URI uri, Date start, Date end, int interval) {
|
|
|
- getSnapDataByEntity(Collections.singletonList(entity), uri, start, end, interval);
|
|
|
+ List<PointData> snap = adapter.getHistorySnap(uri, entity.getPointKey(), start.getTime(), end.getTime(), interval);
|
|
|
+ entity.setPointDatas(snap);
|
|
|
}
|
|
|
|
|
|
public void getSnapDataByEntity(List<PointInfo> entity, Date start, Date end, int interval) {
|
|
@@ -2742,19 +3076,27 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
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());
|
|
|
+ info.setPointDatas(new ArrayList<>(3));
|
|
|
+ if (stat != null) {
|
|
|
+ info.getPointDatas().add(stat.getAvg());
|
|
|
+ info.getPointDatas().add(stat.getMax());
|
|
|
+ info.getPointDatas().add(stat.getMin());
|
|
|
+ } else {
|
|
|
+ info.getPointDatas().add(new PointData());
|
|
|
+ info.getPointDatas().add(new PointData());
|
|
|
+ info.getPointDatas().add(new PointData());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public Map<String, PointInfo> getStatDataByEntityMap(List<PointInfo> entity, URI uri, Date start, Date end,Function<PointInfo,String> function) {
|
|
|
+ public Map<String, PointInfo> getStatDataByEntity(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;
|
|
|
double c = 2.0;
|
|
|
System.out.println(b == c);
|
|
@@ -3092,6 +3434,117 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
reportIndicatorPoolService.saveOrUpdate(poolsCompany);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public void writeReportPoolPjfs2(Date date) {
|
|
|
+ //date当天零点
|
|
|
+ DateTime time = DateUtil.beginOfDay(date);
|
|
|
+ //date昨天零点
|
|
|
+ DateTime time0 = DateUtil.offsetDay(time, -1);
|
|
|
+ DateTime beginOfMonth = DateUtil.beginOfMonth(time0);
|
|
|
+ DateTime beginOfYear = DateUtil.beginOfYear(time0);
|
|
|
+
|
|
|
+ QueryWrapper<TurbineInfoDay> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.select("avg(pjfs) pjfs,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("avg(pjfs) pjfs,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("avg(pjfs) pjfs,project_id,station_id")
|
|
|
+ .between("record_date", beginOfYear, time0).groupBy("project_id,station_id");
|
|
|
+ List<TurbineInfoDay> yearDays = turbineInfoDayService.list(wrapper);
|
|
|
+ Map<String, TurbineInfoDay> yearMap = yearDays.stream().collect(Collectors.toMap(TurbineInfoDay::getProjectId, Function.identity()));
|
|
|
+
|
|
|
+ QueryWrapper<ProEconReportIndicatorPool> wrapperRp = new QueryWrapper<>();
|
|
|
+ wrapperRp.eq("record_date", time0).last("and foreign_key_id = project_id");
|
|
|
+ List<ProEconReportIndicatorPool> poolsProject = reportIndicatorPoolService.list(wrapperRp);
|
|
|
+ wrapperRp = new QueryWrapper<>();
|
|
|
+ wrapperRp.eq("record_date", time0).last("and foreign_key_id = windpowerstation_id");
|
|
|
+ List<ProEconReportIndicatorPool> poolsStation = reportIndicatorPoolService.list(wrapperRp);
|
|
|
+ wrapperRp = new QueryWrapper<>();
|
|
|
+ wrapperRp.eq("record_date", time0).eq("foreign_key_id", "GJNY_SXGS_DBXNY_ZGS0");
|
|
|
+ ProEconReportIndicatorPool poolsCompany = reportIndicatorPoolService.getOne(wrapperRp);
|
|
|
+
|
|
|
+ TurbineInfoDay day, month, year;
|
|
|
+ String projectId;
|
|
|
+ if (poolsProject.isEmpty()) {
|
|
|
+ for (TurbineInfoDay infoDay : days) {
|
|
|
+ projectId = infoDay.getProjectId();
|
|
|
+ ProEconReportIndicatorPool pool = new ProEconReportIndicatorPool();
|
|
|
+ pool.setRecordDate(time0);
|
|
|
+ pool.setForeignKeyId(projectId);
|
|
|
+ pool.setWindpowerstationId(infoDay.getStationId());
|
|
|
+ pool.setProjectId(projectId);
|
|
|
+ month = monthMap.get(projectId);
|
|
|
+ year = yearMap.get(projectId);
|
|
|
+
|
|
|
+ pool.setRpjfs(infoDay.getPjfs());
|
|
|
+ pool.setYpjfs(month.getPjfs());
|
|
|
+ pool.setNpjfs(year.getPjfs());
|
|
|
+
|
|
|
+ poolsProject.add(pool);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (ProEconReportIndicatorPool pool : poolsProject) {
|
|
|
+ projectId = pool.getProjectId();
|
|
|
+ day = dayMap.get(projectId);
|
|
|
+ month = monthMap.get(projectId);
|
|
|
+ year = yearMap.get(projectId);
|
|
|
+
|
|
|
+ pool.setRpjfs(day.getPjfs());
|
|
|
+ pool.setYpjfs(month.getPjfs());
|
|
|
+ pool.setNpjfs(year.getPjfs());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ reportIndicatorPoolService.saveOrUpdateBatch(poolsProject);
|
|
|
+ Map<String, List<ProEconReportIndicatorPool>> projectMap = poolsProject.stream().collect(Collectors.groupingBy(ProEconReportIndicatorPool::getWindpowerstationId));
|
|
|
+ if (poolsStation.isEmpty()) {
|
|
|
+ projectMap.forEach((StId, pis) -> {
|
|
|
+ ProEconReportIndicatorPool pool = new ProEconReportIndicatorPool();
|
|
|
+ pool.setRecordDate(time0);
|
|
|
+ pool.setForeignKeyId(StId);
|
|
|
+ pool.setWindpowerstationId(StId);
|
|
|
+
|
|
|
+ ProEconReportIndicatorPool p = sumProperties(pis, ProEconReportIndicatorPool.class);
|
|
|
+ pool.setRpjfs(p.getRpjfs() / pis.size());
|
|
|
+ pool.setYpjfs(p.getYpjfs() / pis.size());
|
|
|
+ pool.setNpjfs(p.getNpjfs() / pis.size());
|
|
|
+ poolsStation.add(pool);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ for (ProEconReportIndicatorPool pool : poolsStation) {
|
|
|
+ List<ProEconReportIndicatorPool> pools = projectMap.get(pool.getWindpowerstationId());
|
|
|
+
|
|
|
+ ProEconReportIndicatorPool p = sumProperties(pools, ProEconReportIndicatorPool.class);
|
|
|
+ pool.setRpjfs(p.getRpjfs() / pools.size());
|
|
|
+ pool.setYpjfs(p.getYpjfs() / pools.size());
|
|
|
+ pool.setNpjfs(p.getNpjfs() / pools.size());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ reportIndicatorPoolService.saveOrUpdateBatch(poolsStation);
|
|
|
+ if (poolsCompany == null) {
|
|
|
+ poolsCompany = new ProEconReportIndicatorPool();
|
|
|
+ poolsCompany.setRecordDate(time0);
|
|
|
+ poolsCompany.setForeignKeyId("GJNY_SXGS_DBXNY_ZGS0");
|
|
|
+ poolsCompany.setCompanyId("GJNY_SXGS_DBXNY_ZGS");
|
|
|
+
|
|
|
+ ProEconReportIndicatorPool p = sumProperties(poolsStation, ProEconReportIndicatorPool.class);
|
|
|
+ poolsCompany.setRpjfs(p.getRpjfs() / poolsStation.size());
|
|
|
+ poolsCompany.setYpjfs(p.getYpjfs() / poolsStation.size());
|
|
|
+ poolsCompany.setNpjfs(p.getNpjfs() / poolsStation.size());
|
|
|
+ } else {
|
|
|
+ ProEconReportIndicatorPool p = sumProperties(poolsStation, ProEconReportIndicatorPool.class);
|
|
|
+ poolsCompany.setRpjfs(p.getRpjfs() / poolsStation.size());
|
|
|
+ poolsCompany.setYpjfs(p.getYpjfs() / poolsStation.size());
|
|
|
+ poolsCompany.setNpjfs(p.getNpjfs() / poolsStation.size());
|
|
|
+ }
|
|
|
+ reportIndicatorPoolService.saveOrUpdate(poolsCompany);
|
|
|
+ }
|
|
|
+
|
|
|
public void poolSetValue1(ProEconReportIndicatorPool pool, TurbineInfoDay day, TurbineInfoDay month, TurbineInfoDay year) {
|
|
|
pool.setRpjfs(day.getPjfs());
|
|
|
pool.setRgzssdl(day.getGzss() == null ? day.getFjhjxss() * 0.11 : day.getGzss());
|
|
@@ -3251,9 +3704,10 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
return a + b;
|
|
|
}
|
|
|
|
|
|
- public double calcQfzt(double ssgl, double zsgl) {
|
|
|
+ public double calcQfzt(Double ssgl, Double zsgl) {
|
|
|
+ if (ssgl == null || ssgl < 0) ssgl = 0.0;
|
|
|
double qfzt, ratioll;
|
|
|
- ratioll = zsgl != 0 ? (zsgl - ssgl) / zsgl : 0;
|
|
|
+ ratioll = (zsgl == null || zsgl <= 0) ? 0 : (zsgl - ssgl) / zsgl;
|
|
|
if (ratioll < 0.05) {
|
|
|
qfzt = 0;
|
|
|
} else if (ratioll < 0.1) {
|
|
@@ -3268,14 +3722,14 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
return qfzt;
|
|
|
}
|
|
|
|
|
|
- public List<TurbineInfoMin> getTurbineinfoMin(Date date) {
|
|
|
+ public List<TurbineInfoMin> getTurbineinfoByMin(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);
|
|
|
+ public List<TurbineInfoMin> getTurbineinfoByMin(Date date, List<PointInfo> entity) {
|
|
|
+ List<TurbineInfoMin> list = getTurbineinfoByMin(date);
|
|
|
if (list.isEmpty()) {
|
|
|
entity.forEach(pi -> {
|
|
|
TurbineInfoMin day = new TurbineInfoMin();
|
|
@@ -3290,17 +3744,17 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
- public Map<String, TurbineInfoMin> getTurbineinfoMinMap(Date date) {
|
|
|
- List<TurbineInfoMin> tims = getTurbineinfoMin(date);
|
|
|
+ public Map<String, TurbineInfoMin> getTurbineinfoByMinMap(Date date) {
|
|
|
+ List<TurbineInfoMin> tims = getTurbineinfoByMin(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);
|
|
|
+ public Map<String, TurbineInfoMin> getTurbineinfoByMinMap(Date date, List<PointInfo> entity) {
|
|
|
+ List<TurbineInfoMin> tims = getTurbineinfoByMin(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) {
|
|
|
+ public Map<String, PointInfo> getRawDataByEntity(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()));
|
|
|
}
|
|
@@ -3310,28 +3764,26 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
DateTime start = DateUtil.offsetMinute(date, -granularity);
|
|
|
//风速
|
|
|
List<PointInfo> entityFs = getEntity("AI066", "turbine");
|
|
|
- Map<String, PointInfo> rawMapFs = getRawDataMapByEntity(entityFs, goldenUri(), start, date, PointInfo::getTurbineId);
|
|
|
+ Map<String, PointInfo> rawMapFs = getRawDataByEntity(entityFs, goldenUri(), start, date, PointInfo::getTurbineId);
|
|
|
//功率
|
|
|
List<PointInfo> entityGl = getEntity("AI114", "turbine");
|
|
|
- Map<String, PointInfo> rawMapGl = getRawDataMapByEntity(entityGl, goldenUri(), start, date, PointInfo::getTurbineId);
|
|
|
+ Map<String, PointInfo> rawMapGl = getRawDataByEntity(entityGl, goldenUri(), start, date, PointInfo::getTurbineId);
|
|
|
List<PointInfo> entityZt = getEntity("MXZT", "turbine");
|
|
|
- Map<String, PointInfo> rawMapZt = getRawDataMapByEntity(entityZt, goldenUri(), start, date, PointInfo::getTurbineId);
|
|
|
+ Map<String, PointInfo> rawMapZt = getRawDataByEntity(entityZt, goldenUri(), start, date, PointInfo::getTurbineId);
|
|
|
|
|
|
- List<TurbineInfoMin> mins = getTurbineinfoMinByEntity(date, entityFs);
|
|
|
+ List<TurbineInfoMin> mins = getTurbineinfoByMin(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 pjfs = fsDatas.stream().mapToDouble(PointData::getValue).average().orElse(0.0);
|
|
|
+ fsDatas.stream().peek(pd -> pd.setDoubleValue(pd.getValue() > 25 ? 25 : pd.getValue() < 0 ? 0 : NumberUtil.round(pd.getValue(), 2).doubleValue())).collect(Collectors.toList());
|
|
|
+ double llgl = fsDatas.stream().mapToDouble(pd -> pd.getValue() < 3 ? 0d : CalcCache.llgl.get(tbId).get(pd.getValue())).average().orElse(0.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);
|
|
|
+ .mapToDouble(pd -> CalcCache.fitcoef.get(tbId).get(pd.getValue())).average().orElse(0.0);
|
|
|
+ double sjgl = rawMapGl.get(tbId).getPointDatas().stream().mapToDouble(PointData::getValue).average().orElse(0.0);
|
|
|
|
|
|
double v = llgl * 0.9;
|
|
|
if (kygl > v) kygl = v;
|
|
@@ -3350,24 +3802,26 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
|
|
|
//AGC
|
|
|
List<PointInfo> entityAgc = getEntity("AGC002", "booster");
|
|
|
- Map<String, PointInfo> statMapAgc = getStatDataByEntityMap(entityAgc, goldenUri(), start, date, PointInfo::getTurbineId);
|
|
|
+ Map<String, PointInfo> statMapAgc = getStatDataByEntity(entityAgc, goldenUri(), start, date, PointInfo::getStationId);
|
|
|
//出线
|
|
|
List<PointInfo> entityCx = getEntity("AGC001", "booster");
|
|
|
- Map<String, PointInfo> statMapCx = getStatDataByEntityMap(entityCx, goldenUri(), start, date, PointInfo::getTurbineId);
|
|
|
+ Map<String, PointInfo> statMapCx = getStatDataByEntity(entityCx, goldenUri(), start, date, PointInfo::getStationId);
|
|
|
|
|
|
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");
|
|
|
+ wrapper.select("sum(llgl) llgl,sum(kygl) kygl,avg(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);
|
|
|
+ List<StationInfoMin> byDate = getStationinfoByMin(date, entityAgc);
|
|
|
|
|
|
for (StationInfoMin day : byDate) {
|
|
|
String stId = day.getStationId();
|
|
|
TurbineInfoMin min = minMap.get(stId);
|
|
|
+ PointInfo agcInfo = statMapAgc.get(stId);
|
|
|
+ PointInfo cxInfo = statMapCx.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.setAgc(agcInfo.getPointDatas().get(0).getValue() * agcInfo.getCoef());
|
|
|
+ day.setPjgl(cxInfo.getPointDatas().get(0).getValue() * cxInfo.getCoef());
|
|
|
day.setPjfs(min.getPjfs());
|
|
|
}
|
|
|
stationInfoMinService.saveOrUpdateBatch(byDate);
|