Procházet zdrojové kódy

实时状估逻辑修改

liu-aini před 5 hodinami
rodič
revize
174f37e5d0

+ 48 - 96
services/load-transfer-bf/src/main/java/com/hdkj/lt/bf/service/impl/FhzgSvgBreakersServiceImpl.java

@@ -751,23 +751,18 @@ public class FhzgSvgBreakersServiceImpl implements FhzgSvgBreakersService {
                 }
             }
         }else {
-            s = JSON.parseObject(JSON.toJSONString(redisTemplate.opsForValue().get(feederId + dto.getTime() + "zg")), StateEstimation.class);
-            if (s != null) {
-                periodSwitchSeResult = s.getPeriodSwitchSeResult();
-            } else {
-                try {
-                    LocalDateTime floorNow =LocalDateTime.parse(dto.getTime(), TIME_FORMATTER);
-                    LocalDateTime sTime = floorNow.minusHours(1);
-                    periodSwitchSeResult = iStateEstimationApiClient.queryByFeederSave(StateEstimationRequest.builder()
-                            .psrIds(Collections.singletonList(dto.getLinePsrId()))
-                            .containerCode(Collections.singletonList(CommonConstant.SWITCH))
-                            .startTime(sTime.format(TIME_FORMATTER))
-                            .endTime(dto.getTime())
-                            .isAuto(Boolean.FALSE)
-                            .build()).getData().getPeriodSwitchSeResult();
-                } catch (Exception e) {
-                    log.error("远程调用异常!",e);
-                }
+            try {
+                LocalDateTime floorNow =LocalDateTime.parse(dto.getTime(), TIME_FORMATTER);
+                LocalDateTime sTime = floorNow.minusHours(1);
+                periodSwitchSeResult = iStateEstimationApiClient.queryByFeederSave(StateEstimationRequest.builder()
+                        .psrIds(Collections.singletonList(feederId))
+                        .containerCode(Collections.singletonList(CommonConstant.SWITCH))
+                        .startTime(sTime.format(TIME_FORMATTER))
+                        .endTime(dto.getTime())
+                        .isAuto(Boolean.FALSE)
+                        .build()).getData().getPeriodSwitchSeResult();
+            } catch (Exception e) {
+                log.error("远程调用异常!",e);
             }
         }
         BeakerSvgInfoVO beakerSvgInfoVO = BeakerSvgInfoVO.builder().breakerPsrId(dto.getPsrId()).build();
@@ -806,20 +801,18 @@ public class FhzgSvgBreakersServiceImpl implements FhzgSvgBreakersService {
 //                                .status(e.getSeiStatuss().get(0))
 //                                .build());
 //                    }
-                    if(Objects.equals(e.getIsAuto(), "false")){
-                        beakerSvgInfoVO.setZgs(BeakerStatusInfoVO.builder().breakerPsrId(e.getPsrId())
-                                .breakerPsrId(dto.getPsrId())
-                                .punit(CommonUnitEnum.P.getCode())
-                                .qunit(CommonUnitEnum.Q.getCode())
-                                .iunit(CommonUnitEnum.I.getCode())
-                                .uunit(CommonUnitEnum.U.getCode())
-                                .pvalue(convertToKW(getValueByIndex(e.getSeoPs(), seoIsIdx)))
-                                .qvalue(getValueByIndex(e.getSeoQs(), seoIsIdx))
-                                .ivalue(seoIs)
-                                .uvalue(getValueByIndex(e.getSeoUs(), seoIsIdx))
-                                .status(getValueByIndex(e.getSeoStatuss(), seoIsIdx))
-                                .build());
-                    }
+                    beakerSvgInfoVO.setZgs(BeakerStatusInfoVO.builder().breakerPsrId(e.getPsrId())
+                            .breakerPsrId(dto.getPsrId())
+                            .punit(CommonUnitEnum.P.getCode())
+                            .qunit(CommonUnitEnum.Q.getCode())
+                            .iunit(CommonUnitEnum.I.getCode())
+                            .uunit(CommonUnitEnum.U.getCode())
+                            .pvalue(convertToKW(getValueByIndex(e.getSeoPs(), seoIsIdx)))
+                            .qvalue(getValueByIndex(e.getSeoQs(), seoIsIdx))
+                            .ivalue(seoIs)
+                            .uvalue(getValueByIndex(e.getSeoUs(), seoIsIdx))
+                            .status(getValueByIndex(e.getSeoStatuss(), seoIsIdx))
+                            .build());
                 }
             });
         }
@@ -1003,34 +996,17 @@ public class FhzgSvgBreakersServiceImpl implements FhzgSvgBreakersService {
             }
             LocalDateTime floorNow =LocalDateTime.parse(dto.getTime(), TIME_FORMATTER);
             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) {
-                    log.info(JSON.toJSONString(ss));
-                    ss = s.getPeriodSwitchSeResult();
-                } else {
-                    ss = iStateEstimationApiClient.queryByFeederSave(StateEstimationRequest.builder()
-                            .psrIds(Collections.singletonList(dto.getLinePsrId()))
-                            .containerCode(Collections.singletonList(CommonConstant.SWITCH))
-                            .startTime(sTime.format(TIME_FORMATTER))
-                            .endTime(dto.getTime())
-                            .isAuto(Boolean.FALSE)
-                            .build()).getData().getPeriodSwitchSeResult();
-                }
-                if (CollectionUtils.isNotEmpty(ss)) {
-                    periodSwitchSeResult.addAll(ss);
-                }
+            ss = iStateEstimationApiClient.queryByFeederSave(StateEstimationRequest.builder()
+                    .psrIds(groupFeederIds)
+                    .containerCode(Collections.singletonList(CommonConstant.SWITCH))
+                    .startTime(sTime.format(TIME_FORMATTER))
+                    .endTime(dto.getTime())
+                    .isAuto(Boolean.FALSE)
+                    .build()).getData().getPeriodSwitchSeResult();
+            if (CollectionUtils.isNotEmpty(ss)) {
+                periodSwitchSeResult.addAll(ss);
             }
         }
-        List<String> psrIdAuto = new ArrayList<>();
-        if (!periodSwitchSeResult.isEmpty()) {
-            //获取所有自动化开关psrId
-            psrIdAuto = periodSwitchSeResult
-                    .stream().filter(a -> "true".equals(a.getIsAuto()))
-                    .map(StateEstimation.StateEstimationSwitchResult::getPsrId)
-                    .collect(Collectors.toList());
-        }
-        HashSet<String> psrSet = new HashSet<>(psrIdAuto);
 
         if (CollectionUtils.isNotEmpty(periodSwitchSeResult)) {
             periodSwitchSeResult.forEach(e -> {
@@ -1047,51 +1023,27 @@ public class FhzgSvgBreakersServiceImpl implements FhzgSvgBreakersService {
                 } catch (Exception exception) {
                     exception.printStackTrace();
                 }
-                String sourceName;
                 //设置来源系统
                 String switchType = "0";
                 if ("0111".equals(e.getPsrType())) {
                     //柱上断路器
                     switchType = "1";
                 }
-                if (psrSet.contains(e.getPsrId())) {
-                    //量测
-                    beakerSvgInfoVO.setLcs(BeakerStatusInfoVO.builder()
-                            .punit(CommonUnitEnum.P.getCode())
-                            .qunit(CommonUnitEnum.Q.getCode())
-                            .iunit(CommonUnitEnum.I.getCode())
-                            .uunit(CommonUnitEnum.U.getCode())
-                            .pvalue(convertToKW(getValueByIndex(e.getSeiPs(), seiIsIdx)))
-                            .qvalue(getValueByIndex(e.getSeiQs(), seiIsIdx))
-                            .ivalue(seiIs)
-                            .uvalue(getValueByIndex(e.getSeiUs(), seiIsIdx))
-                            .status(getValueByIndex(e.getSeiStatuss(), seiIsIdx))
-                            .isAuto(e.getIsAuto())
-                            .sourceSystem("lc")
-                            .switchType(switchType)
-                            .build());
-                } else {
-                    //状估
-                    beakerSvgInfoVO.setZgs(BeakerStatusInfoVO.builder().breakerPsrId(e.getPsrId())
-                            .punit(CommonUnitEnum.P.getCode())
-                            .qunit(CommonUnitEnum.Q.getCode())
-                            .iunit(CommonUnitEnum.I.getCode())
-                            .uunit(CommonUnitEnum.U.getCode())
-                            .pvalue(convertToKW(getValueByIndex(e.getSeoPs(), seiIsIdx)))
-                            .qvalue(getValueByIndex(e.getSeoQs(), seiIsIdx))
-                            .ivalue(seiIs)
-                            .uvalue(getValueByIndex(e.getSeoUs(), seiIsIdx))
-                            .status(getValueByIndex(e.getSeoStatuss(), seiIsIdx))
-                            .isAuto(e.getIsAuto())
-                            .sourceSystem("zg")
-                            .switchType(switchType)
-                            .build());
-                }
-                if (beakerSvgInfoVO.getLcs() != null) {
-                    beakerSvgInfoVO.getLcs().setBreakerPsrId(e.getPsrId());
-                } else {
-                    beakerSvgInfoVO.setLcs(BeakerStatusInfoVO.builder().breakerPsrId(e.getPsrId()).build());
-                }
+                //状估
+                beakerSvgInfoVO.setZgs(BeakerStatusInfoVO.builder().breakerPsrId(e.getPsrId())
+                        .punit(CommonUnitEnum.P.getCode())
+                        .qunit(CommonUnitEnum.Q.getCode())
+                        .iunit(CommonUnitEnum.I.getCode())
+                        .uunit(CommonUnitEnum.U.getCode())
+                        .pvalue(convertToKW(getValueByIndex(e.getSeoPs(), seiIsIdx)))
+                        .qvalue(getValueByIndex(e.getSeoQs(), seiIsIdx))
+                        .ivalue(seiIs)
+                        .uvalue(getValueByIndex(e.getSeoUs(), seiIsIdx))
+                        .status(getValueByIndex(e.getSeoStatuss(), seiIsIdx))
+                        .isAuto(e.getIsAuto())
+                        .sourceSystem("zg")
+                        .switchType(switchType)
+                        .build());
                 beakerStatusInfoVOS.add(beakerSvgInfoVO.getZgs());
             });
         }