|
|
@@ -757,7 +757,7 @@ public class FhzgSvgBreakersServiceImpl implements FhzgSvgBreakersService {
|
|
|
} else {
|
|
|
try {
|
|
|
LocalDateTime floorNow =LocalDateTime.parse(dto.getTime(), TIME_FORMATTER);
|
|
|
- LocalDateTime sTime = floorNow.minusMinutes(30);
|
|
|
+ LocalDateTime sTime = floorNow.minusHours(1);
|
|
|
periodSwitchSeResult = iStateEstimationApiClient.queryByFeederSave(StateEstimationRequest.builder()
|
|
|
.psrIds(Collections.singletonList(dto.getLinePsrId()))
|
|
|
.containerCode(Collections.singletonList(CommonConstant.SWITCH))
|
|
|
@@ -776,13 +776,17 @@ public class FhzgSvgBreakersServiceImpl implements FhzgSvgBreakersService {
|
|
|
if (dto.getPsrId().equals(e.getPsrId())) {
|
|
|
String seiIs = "0.0";
|
|
|
String seoIs = "0.0";
|
|
|
+ //记录状估电流最新非空下标,状估其余字段(P/Q/U/状态)按该下标取同一时间点数据
|
|
|
+ int seoIsIdx = -1;
|
|
|
try {
|
|
|
- if (StringUtils.isNotEmpty(e.getSeiIs().get(0))) {
|
|
|
- BigDecimal bigDecimal = new BigDecimal(e.getSeiIs().get(0));
|
|
|
+ int seiIsIdx = getLatestValidIndex(e.getSeiIs());
|
|
|
+ if (seiIsIdx >= 0) {
|
|
|
+ BigDecimal bigDecimal = new BigDecimal(getValueByIndex(e.getSeiIs(), seiIsIdx));
|
|
|
seiIs = bigDecimal.multiply(new BigDecimal(1000)).toString();
|
|
|
}
|
|
|
- if (StringUtils.isNotEmpty(e.getSeoIs().get(0))) {
|
|
|
- BigDecimal bigDecimal = new BigDecimal(e.getSeoIs().get(0));
|
|
|
+ seoIsIdx = getLatestValidIndex(e.getSeoIs());
|
|
|
+ if (seoIsIdx >= 0) {
|
|
|
+ BigDecimal bigDecimal = new BigDecimal(getValueByIndex(e.getSeoIs(), seoIsIdx));
|
|
|
seoIs = bigDecimal.multiply(new BigDecimal(1000)).toString();
|
|
|
}
|
|
|
} catch (Exception exception) {
|
|
|
@@ -809,11 +813,11 @@ public class FhzgSvgBreakersServiceImpl implements FhzgSvgBreakersService {
|
|
|
.qunit(CommonUnitEnum.Q.getCode())
|
|
|
.iunit(CommonUnitEnum.I.getCode())
|
|
|
.uunit(CommonUnitEnum.U.getCode())
|
|
|
- .pvalue(convertToKW(e.getSeoPs().get(0)))
|
|
|
- .qvalue(e.getSeoQs().get(0))
|
|
|
+ .pvalue(convertToKW(getValueByIndex(e.getSeoPs(), seoIsIdx)))
|
|
|
+ .qvalue(getValueByIndex(e.getSeoQs(), seoIsIdx))
|
|
|
.ivalue(seoIs)
|
|
|
- .uvalue(e.getSeoUs().get(0))
|
|
|
- .status(e.getSeoStatuss().get(0))
|
|
|
+ .uvalue(getValueByIndex(e.getSeoUs(), seoIsIdx))
|
|
|
+ .status(getValueByIndex(e.getSeoStatuss(), seoIsIdx))
|
|
|
.build());
|
|
|
}
|
|
|
}
|
|
|
@@ -998,7 +1002,7 @@ public class FhzgSvgBreakersServiceImpl implements FhzgSvgBreakersService {
|
|
|
groupFeederIds = Collections.singletonList(feederId);
|
|
|
}
|
|
|
LocalDateTime floorNow =LocalDateTime.parse(dto.getTime(), TIME_FORMATTER);
|
|
|
- LocalDateTime sTime = floorNow.minusMinutes(30);
|
|
|
+ LocalDateTime sTime = floorNow.minusHours(1);
|
|
|
for (String feeder : groupFeederIds) {
|
|
|
s = JSON.parseObject(JSON.toJSONString(redisTemplate.opsForValue().get(feeder + dto.getTime() + "zg")), StateEstimation.class);
|
|
|
if (s != null) {
|
|
|
@@ -1032,9 +1036,12 @@ public class FhzgSvgBreakersServiceImpl implements FhzgSvgBreakersService {
|
|
|
periodSwitchSeResult.forEach(e -> {
|
|
|
BeakerSvgInfoVO beakerSvgInfoVO = BeakerSvgInfoVO.builder().breakerPsrId(e.getPsrId()).build();
|
|
|
String seiIs = "0.0";
|
|
|
+ //记录量测电流最新非空下标,量测/状估其余字段(P/Q/U/状态)按该下标取同一时间点数据
|
|
|
+ int seiIsIdx = -1;
|
|
|
try {
|
|
|
- if (StringUtils.isNotEmpty(e.getSeiIs().get(0))) {
|
|
|
- BigDecimal bigDecimal = new BigDecimal(e.getSeiIs().get(0));
|
|
|
+ seiIsIdx = getLatestValidIndex(e.getSeiIs());
|
|
|
+ if (seiIsIdx >= 0) {
|
|
|
+ BigDecimal bigDecimal = new BigDecimal(getValueByIndex(e.getSeiIs(), seiIsIdx));
|
|
|
seiIs = bigDecimal.multiply(new BigDecimal(1000)).toString();
|
|
|
}
|
|
|
} catch (Exception exception) {
|
|
|
@@ -1054,11 +1061,11 @@ public class FhzgSvgBreakersServiceImpl implements FhzgSvgBreakersService {
|
|
|
.qunit(CommonUnitEnum.Q.getCode())
|
|
|
.iunit(CommonUnitEnum.I.getCode())
|
|
|
.uunit(CommonUnitEnum.U.getCode())
|
|
|
- .pvalue(convertToKW(e.getSeiPs().get(0)))
|
|
|
- .qvalue(e.getSeiQs().get(0))
|
|
|
+ .pvalue(convertToKW(getValueByIndex(e.getSeiPs(), seiIsIdx)))
|
|
|
+ .qvalue(getValueByIndex(e.getSeiQs(), seiIsIdx))
|
|
|
.ivalue(seiIs)
|
|
|
- .uvalue(e.getSeiUs().get(0))
|
|
|
- .status(e.getSeiStatuss().get(0))
|
|
|
+ .uvalue(getValueByIndex(e.getSeiUs(), seiIsIdx))
|
|
|
+ .status(getValueByIndex(e.getSeiStatuss(), seiIsIdx))
|
|
|
.isAuto(e.getIsAuto())
|
|
|
.sourceSystem("lc")
|
|
|
.switchType(switchType)
|
|
|
@@ -1070,11 +1077,11 @@ public class FhzgSvgBreakersServiceImpl implements FhzgSvgBreakersService {
|
|
|
.qunit(CommonUnitEnum.Q.getCode())
|
|
|
.iunit(CommonUnitEnum.I.getCode())
|
|
|
.uunit(CommonUnitEnum.U.getCode())
|
|
|
- .pvalue(convertToKW(e.getSeoPs().get(0)))
|
|
|
- .qvalue(e.getSeoQs().get(0))
|
|
|
+ .pvalue(convertToKW(getValueByIndex(e.getSeoPs(), seiIsIdx)))
|
|
|
+ .qvalue(getValueByIndex(e.getSeoQs(), seiIsIdx))
|
|
|
.ivalue(seiIs)
|
|
|
- .uvalue(e.getSeoUs().get(0))
|
|
|
- .status(e.getSeoStatuss().get(0))
|
|
|
+ .uvalue(getValueByIndex(e.getSeoUs(), seiIsIdx))
|
|
|
+ .status(getValueByIndex(e.getSeoStatuss(), seiIsIdx))
|
|
|
.isAuto(e.getIsAuto())
|
|
|
.sourceSystem("zg")
|
|
|
.switchType(switchType)
|
|
|
@@ -1238,6 +1245,39 @@ public class FhzgSvgBreakersServiceImpl implements FhzgSvgBreakersService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取集合中最新的非空值所在下标(下标越大数据越新,从后往前找第一个非null且非空的元素)
|
|
|
+ * 同一开关结果中各字段集合时间对齐,记录该下标后,P/Q/U/状态等其它集合应取同一对应下标的数据
|
|
|
+ *
|
|
|
+ * @param list 数据集合
|
|
|
+ * @return 最后一个非空值的下标,集合为空或全部为空时返回 -1
|
|
|
+ */
|
|
|
+ private int getLatestValidIndex(List<String> list) {
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ for (int i = list.size() - 1; i >= 0; i--) {
|
|
|
+ if (StringUtils.isNotEmpty(list.get(i))) {
|
|
|
+ return i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按下标取值,下标越界或集合为空时返回 null
|
|
|
+ *
|
|
|
+ * @param list 数据集合
|
|
|
+ * @param index 下标
|
|
|
+ * @return 对应下标的值
|
|
|
+ */
|
|
|
+ private String getValueByIndex(List<String> list, int index) {
|
|
|
+ if (CollectionUtils.isEmpty(list) || index < 0 || index >= list.size()) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return list.get(index);
|
|
|
+ }
|
|
|
+
|
|
|
private String convertToKW(String p) {
|
|
|
if (StringUtils.isEmpty(p)) {
|
|
|
return null;
|