liuaini 2 дней назад
Родитель
Сommit
50f297ac84
14 измененных файлов с 414 добавлено и 23 удалено
  1. 5 0
      api/load-transfer-si-api/src/main/java/com/hdkj/lt/feign/IStateEstimationApiClient.java
  2. 6 0
      api/load-transfer-si-api/src/main/java/com/hdkj/lt/feign/fallback/StateEstimationApiClientFallBack.java
  3. 1 0
      common/common-se/src/main/java/com/hdkj/lt/bf/entity/FhzgSeCurrentEvent.java
  4. 7 0
      services/load-transfer-bf/src/main/java/com/hdkj/lt/bf/controller/FhzgSvgBreakerController.java
  5. 51 0
      services/load-transfer-bf/src/main/java/com/hdkj/lt/bf/entity/FhzgSeEventStateEstimation.java
  6. 87 2
      services/load-transfer-bf/src/main/java/com/hdkj/lt/bf/listener/ReconTriggerListener.java
  7. 18 0
      services/load-transfer-bf/src/main/java/com/hdkj/lt/bf/mapper/FhzgSeEventStateEstimationMapper.java
  8. 13 0
      services/load-transfer-bf/src/main/java/com/hdkj/lt/bf/service/FhzgSeEventStateEstimationService.java
  9. 2 0
      services/load-transfer-bf/src/main/java/com/hdkj/lt/bf/service/FhzgSvgBreakersService.java
  10. 22 0
      services/load-transfer-bf/src/main/java/com/hdkj/lt/bf/service/impl/FhzgSeEventStateEstimationServiceImpl.java
  11. 177 20
      services/load-transfer-bf/src/main/java/com/hdkj/lt/bf/service/impl/FhzgSvgBreakersServiceImpl.java
  12. 19 0
      services/load-transfer-bf/src/main/resources/mapper/FhzgSeEventStateEstimationMapper.xml
  13. 5 0
      services/load-transfer-si/src/main/java/com/hdkj/lt/si/feign/StateEstimationApiClient.java
  14. 1 1
      services/load-transfer-si/src/main/java/com/hdkj/lt/si/service/recon/impl/ReconResultServiceImpl.java

+ 5 - 0
api/load-transfer-si-api/src/main/java/com/hdkj/lt/feign/IStateEstimationApiClient.java

@@ -31,4 +31,9 @@ public interface IStateEstimationApiClient {
 
     @PostMapping(value = "feign/stateEstimation/saveAutoSwitch")
     ApiResponse<List<FhzgFeederAutoSwitchMapping>> saveAutoSwitch(@Valid @RequestBody StateEstimationRequest request);
+
+    @PostMapping("feign/stateEstimation/queryByFeeder")
+    ApiResponse<StateEstimation> queryByFeeder(StateEstimationRequest request);
+
+
 }

+ 6 - 0
api/load-transfer-si-api/src/main/java/com/hdkj/lt/feign/fallback/StateEstimationApiClientFallBack.java

@@ -43,6 +43,12 @@ public class StateEstimationApiClientFallBack implements FallbackFactory<IStateE
                 return ApiResponse.fail(String.format("查询线路自动化开关失败-getPlanTransferScheme 远程调用服务异常:%s", cause.getMessage()));
 
             }
+
+            @Override
+            public ApiResponse<StateEstimation> queryByFeeder(StateEstimationRequest request) {
+                log.error("分时段查询线路状估数据-queryByFeeder 远程调用服务异常, 参数:{}", request);
+                return ApiResponse.fail(String.format("分时段查询线路状估数据-queryByFeeder 远程调用服务异常:%s", cause.getMessage()));
+            }
         };
     }
 }

+ 1 - 0
common/common-se/src/main/java/com/hdkj/lt/bf/entity/FhzgSeCurrentEvent.java

@@ -37,4 +37,5 @@ public class FhzgSeCurrentEvent implements Serializable {
     private Integer reconStatus;
     private LocalDateTime createTime;
     private LocalDateTime updateTime;
+    private String stateEstimationJson;
 }

+ 7 - 0
services/load-transfer-bf/src/main/java/com/hdkj/lt/bf/controller/FhzgSvgBreakerController.java

@@ -106,5 +106,12 @@ public class FhzgSvgBreakerController extends BaseController {
     public ApiResponse<SwitchOrTransformerVO> getSwitchOrTransformerInfo(@RequestBody SwitchOrTransformerDTO dto) {
         return ApiResponse.success(fhzgSvgBreakersService.getSwitchOrTransformerInfo(dto));
     }
+    @PostMapping("/getBreakerStateEstimationInfo")
+    @ApiOperation(value = "通过通过线路id查询开关状态状估信息")
+    @RequiresCountryPermissions(lineFields = "linePsrId")
+    public ApiResponse<List<BeakerStatusInfoVO>> getBreakerStateEstimationInfo(@RequestBody BeakerStatusDTO dto) {
+        List<BeakerStatusInfoVO> breakerList = fhzgSvgBreakersService.getBreakerStateEstimationInfo(dto);
+        return ApiResponse.success(breakerList);
+    }
 
 }

+ 51 - 0
services/load-transfer-bf/src/main/java/com/hdkj/lt/bf/entity/FhzgSeEventStateEstimation.java

@@ -0,0 +1,51 @@
+package com.hdkj.lt.bf.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Builder;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 重过载事件接线组状估数据
+ * @TableName fhzg_se_event_state_estimation
+ */
+@TableName(value ="fhzg_se_event_state_estimation")
+@Data
+@Builder
+@Accessors(chain = true)
+public class FhzgSeEventStateEstimation implements Serializable {
+    /**
+     * id
+     */
+    @TableId
+    private Long id;
+
+    /**
+     * fhzg_se_current_event.id
+     */
+    private Long eventId;
+
+    /**
+     * 线路id
+     */
+    private String feederId;
+
+    /**
+     * 状估数据
+     */
+    private String stateEstimationJson;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+
+}

+ 87 - 2
services/load-transfer-bf/src/main/java/com/hdkj/lt/bf/listener/ReconTriggerListener.java

@@ -1,21 +1,32 @@
 package com.hdkj.lt.bf.listener;
 
+import cn.hutool.core.lang.Snowflake;
+import cn.hutool.core.util.IdUtil;
 import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.hdkj.hussar.ApiResponse;
+import com.hdkj.lt.base.exception.ExceptionCast;
 import com.hdkj.lt.bf.entity.FhzgSeCurrentEvent;
+import com.hdkj.lt.bf.entity.FhzgSeEventStateEstimation;
 import com.hdkj.lt.bf.entity.FhzgSeVoltageEvent;
 import com.hdkj.lt.bf.entity.dto.XlRelDTO;
 import com.hdkj.lt.bf.entity.vo.XlRelVO;
 import com.hdkj.lt.bf.event.ReconTriggerEvent;
 import com.hdkj.lt.bf.mapper.FhzgSeCurrentEventMapper;
+import com.hdkj.lt.bf.mapper.FhzgSeEventStateEstimationMapper;
 import com.hdkj.lt.bf.mapper.FhzgSeVoltageEventMapper;
 import com.hdkj.lt.bf.mapper.XlRelMapper;
+import com.hdkj.lt.core.bizms.modle.dto.StateEstimation;
 import com.hdkj.lt.core.bizms.modle.po.DwdShbDsFeederBase;
 import com.hdkj.lt.core.bizms.modle.po.Jxz;
+import com.hdkj.lt.core.bizms.modle.request.StateEstimationRequest;
 import com.hdkj.lt.core.sys.dao.DwdShbDsFeederBaseMapper;
 import com.hdkj.lt.core.sys.dao.JxzMapper;
 import com.hdkj.lt.feign.IReconApiClient;
 import com.hdkj.lt.feign.ISimulationPlatformApiClient;
+import com.hdkj.lt.feign.IStateEstimationApiClient;
 import com.hdkj.lt.modle.dto.simulation.EacFeederDTO;
 import com.hdkj.lt.modle.dto.simulation.OperationModeDTO;
 import com.hdkj.lt.modle.dto.simulation.OperationModeStartDTO;
@@ -27,9 +38,11 @@ import org.springframework.context.event.EventListener;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Component;
 
+import java.time.LocalDateTime;
+import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
-import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.*;
 import java.util.stream.Collectors;
 
 /**
@@ -61,9 +74,11 @@ public class ReconTriggerListener {
     private final DwdShbDsFeederBaseMapper feederBaseMapper;
     private final FhzgSeCurrentEventMapper currentEventMapper;
     private final FhzgSeVoltageEventMapper voltageEventMapper;
+    private final FhzgSeEventStateEstimationMapper stateEstimationMapper;
+    private final IStateEstimationApiClient stateEstimationApiClient;
 
     private static final DateTimeFormatter DT_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
-
+    private final ObjectMapper writeMapper = new ObjectMapper();
     private static final int RECON_RUNNING   = 1;
     private static final int RECON_COMPLETED = 2;
     private static final int RECON_NO_PLAN   = 3;
@@ -86,6 +101,8 @@ public class ReconTriggerListener {
         log.info("重构触发: eventId={}, feederId={}, alarmType={}, pointTime={}",
                 event.getEventId(), event.getFeederId(), event.getAlarmType(), event.getPointTime());
 
+        // 保存状估数据
+        CompletableFuture.runAsync(() -> saveStateEstimation(event));
         // 异步调用求解器,不阻塞后续重构请求
         CompletableFuture.runAsync(() -> callSolver(event));
 
@@ -220,4 +237,72 @@ public class ReconTriggerListener {
                     eventId, alarmType, reconStatus, e.getMessage());
         }
     }
+
+    /**
+     * 状估数据保存
+     * @param event
+     */
+    private void saveStateEstimation(ReconTriggerEvent event){
+        // 1. 查询接线组线路
+        Long eventId = event.getEventId();
+        List<Jxz> jxzList = jxzMapper.queryJxzXl(event.getFeederId());
+        List<String> groupFeederIds = jxzList.stream()
+                .map(Jxz::getFeederId)
+                .filter(Objects::nonNull)
+                .distinct()
+                .collect(Collectors.toList());
+        //没有接线组只存当前线路数据
+        if (groupFeederIds.isEmpty()) {
+            groupFeederIds = Collections.singletonList(event.getFeederId());
+        }
+        Snowflake snowflake = IdUtil.getSnowflake(1,1);
+        for (String feeder : groupFeederIds) {
+            StateEstimationRequest req = buildStateEstimationReq(event.getTriggerTime().format(DT_FMT));
+            req.setPsrIds(Collections.singletonList(feeder));
+            StateEstimation stateEstimation = callWithRetry(feeder, req);
+            if(Objects.nonNull(stateEstimation)){
+                FhzgSeEventStateEstimation estimation = FhzgSeEventStateEstimation.builder()
+                        .id(snowflake.nextId()).eventId(eventId).feederId(feeder)
+                        .createTime(new Date()).build();
+                try {
+                    String jsonStr = writeMapper.writeValueAsString(stateEstimation);
+                    estimation.setStateEstimationJson(jsonStr);
+                } catch (JsonProcessingException e) {
+                    log.warn("馈线={} 状估数据  序列化失败: {}", feeder, e.getMessage());
+                    continue;
+                }
+                try {
+                    stateEstimationMapper.insert(estimation);
+                    log.info("馈线={} ,事件={} ,状估数据 保存成功!", feeder, eventId);
+                } catch (Exception e) {
+                    log.error("馈线={} ,事件={} ,落库失败: {}", feeder, eventId, e.getMessage(), e);
+                }
+            }
+        }
+    }
+    private StateEstimationRequest buildStateEstimationReq(String pointTime){
+        StateEstimationRequest req = new StateEstimationRequest();
+        req.setContainerCode(Collections.singletonList("switch"));
+        req.setStartTime(pointTime);
+        req.setEndTime(pointTime);
+        return req;
+    }
+    private static final int RETRY_COUNT = 2;
+    private StateEstimation callWithRetry(String feeder, StateEstimationRequest req) {
+        int maxAttempts = RETRY_COUNT + 1;
+        Exception last = null;
+        for (int attempt = 1; attempt <= maxAttempts; attempt++) {
+            try {
+                ApiResponse<StateEstimation> resp = stateEstimationApiClient.queryByFeeder(req);
+                if (resp != null) {
+                    return resp.getData();
+                }
+            } catch (Exception e) {
+                last = e;
+                log.warn(" 第{}/{}次: {}, psrIds ={}", attempt, maxAttempts, e.getMessage(), feeder);
+            }
+        }
+        throw new RuntimeException("状估调用失败 (已重试 " + RETRY_COUNT+ " 次), psrIds ="
+                + feeder + ", 最后错误: " + (last == null ? "unknown" : last.getMessage()), last);
+    }
 }

+ 18 - 0
services/load-transfer-bf/src/main/java/com/hdkj/lt/bf/mapper/FhzgSeEventStateEstimationMapper.java

@@ -0,0 +1,18 @@
+package com.hdkj.lt.bf.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.hdkj.lt.bf.entity.FhzgSeEventStateEstimation;
+
+/**
+* @author Annie
+* @description 针对表【fhzg_se_event_state_estimation(重过载事件接线组状估数据)】的数据库操作Mapper
+* @createDate 2026-08-12 11:46:35
+* @Entity stateEstimation.FhzgSeEventStateEstimation
+*/
+public interface FhzgSeEventStateEstimationMapper extends BaseMapper<FhzgSeEventStateEstimation> {
+
+}
+
+
+
+

+ 13 - 0
services/load-transfer-bf/src/main/java/com/hdkj/lt/bf/service/FhzgSeEventStateEstimationService.java

@@ -0,0 +1,13 @@
+package com.hdkj.lt.bf.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.hdkj.lt.bf.entity.FhzgSeEventStateEstimation;
+
+/**
+* @author Annie
+* @description 针对表【fhzg_se_event_state_estimation(重过载事件接线组状估数据)】的数据库操作Service
+* @createDate 2026-08-12 11:46:35
+*/
+public interface FhzgSeEventStateEstimationService extends IService<FhzgSeEventStateEstimation> {
+
+}

+ 2 - 0
services/load-transfer-bf/src/main/java/com/hdkj/lt/bf/service/FhzgSvgBreakersService.java

@@ -30,4 +30,6 @@ public interface FhzgSvgBreakersService {
     List<SwitchOrTransformerVO> getSwitchAndTransformerList(SwitchOrTransformerDTO dto);
 
     SwitchOrTransformerVO getSwitchOrTransformerInfo(SwitchOrTransformerDTO dto);
+
+    List<BeakerStatusInfoVO> getBreakerStateEstimationInfo(BeakerStatusDTO dto);
 }

+ 22 - 0
services/load-transfer-bf/src/main/java/com/hdkj/lt/bf/service/impl/FhzgSeEventStateEstimationServiceImpl.java

@@ -0,0 +1,22 @@
+package com.hdkj.lt.bf.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.hdkj.lt.bf.entity.FhzgSeEventStateEstimation;
+import com.hdkj.lt.bf.mapper.FhzgSeEventStateEstimationMapper;
+import org.springframework.stereotype.Service;
+
+/**
+* @author Annie
+* @description 针对表【fhzg_se_event_state_estimation(重过载事件接线组状估数据)】的数据库操作Service实现
+* @createDate 2026-08-12 11:46:35
+*/
+@Service
+public class FhzgSeEventStateEstimationServiceImpl extends ServiceImpl<FhzgSeEventStateEstimationMapper, FhzgSeEventStateEstimation>
+    implements IService<FhzgSeEventStateEstimation> {
+
+}
+
+
+
+

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

@@ -2,7 +2,7 @@ package com.hdkj.lt.bf.service.impl;
 
 import cn.hutool.core.date.DatePattern;
 import cn.hutool.core.util.ObjectUtil;
-import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson2.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.hdkj.hussar.ApiResponse;
 import com.hdkj.lt.base.constants.CommonConstant;
@@ -11,6 +11,8 @@ import com.hdkj.lt.base.enums.CommonUnitEnum;
 import com.hdkj.lt.base.exception.ExceptionCast;
 import com.hdkj.lt.bf.adapter.SiStateEstimationClient;
 import com.hdkj.lt.bf.entity.FhzgPlanPowerCut;
+import com.hdkj.lt.bf.entity.FhzgSeCurrentEvent;
+import com.hdkj.lt.bf.entity.FhzgSeEventStateEstimation;
 import com.hdkj.lt.bf.entity.dto.BeakerStatusDTO;
 import com.hdkj.lt.bf.entity.dto.FhzgPlanTransferSchemeDTO;
 import com.hdkj.lt.bf.entity.dto.SwitchOrTransformerDTO;
@@ -22,6 +24,7 @@ import com.hdkj.lt.core.bizms.modle.dto.StateEstimation;
 import com.hdkj.lt.core.bizms.modle.po.DwdShbDsFeederBase;
 import com.hdkj.lt.core.bizms.modle.po.FeederTopo;
 import com.hdkj.lt.core.bizms.modle.po.FhzgSwitchProtectionSettings;
+import com.hdkj.lt.core.bizms.modle.po.Jxz;
 import com.hdkj.lt.core.bizms.modle.po.fault.FaultPowerCut;
 import com.hdkj.lt.core.bizms.modle.po.plan.FhzgInfoBreakerSvgAfter;
 import com.hdkj.lt.core.bizms.modle.po.plan.FhzgPlanTransferScheme;
@@ -30,6 +33,7 @@ import com.hdkj.lt.core.bizms.modle.request.StateEstimationRequest;
 import com.hdkj.lt.core.plugins.thread.MultiThreadExecuteService;
 import com.hdkj.lt.core.sys.dao.DwdShbDsFeederBaseMapper;
 import com.hdkj.lt.core.sys.dao.FhzgOrganSuffixMapper;
+import com.hdkj.lt.core.sys.dao.JxzMapper;
 import com.hdkj.lt.core.sys.service.DwdShbDsFeederBaseService;
 import com.hdkj.lt.core.sys.service.SwitchProtectionSettingsService;
 import com.hdkj.lt.feign.IStateEstimationApiClient;
@@ -38,6 +42,7 @@ import com.hdkj.lt.modle.dto.jsty.AllSwitchInfoListDTO;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.compress.utils.Lists;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.Cursor;
@@ -94,7 +99,8 @@ public class FhzgSvgBreakersServiceImpl implements FhzgSvgBreakersService {
     private RedisTemplate<String, Object> redisTemplate;
     @Autowired
     MultiThreadExecuteService multiThreadExecuteService;
-
+    private final FhzgSeEventStateEstimationMapper stateEstimationMapper;
+    private final JxzMapper jxzMapper;
 
     private static final DateTimeFormatter TIME_FORMATTER =
             DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN);
@@ -720,28 +726,46 @@ public class FhzgSvgBreakersServiceImpl implements FhzgSvgBreakersService {
     @Override
     public BeakerSvgInfoVO getBeakerSvgInfoVOByPsrId(BeakerStatusDTO dto) {
         List<StateEstimation.StateEstimationSwitchResult> periodSwitchSeResult = new ArrayList<>();
-        DwdShbDsFeederBase dwdShbDsFeederBase = dwdShbDsFeederBaseService.getByPsrId(dto.getLinePsrId());
+        String feederId = dto.getLinePsrId();
+        DwdShbDsFeederBase dwdShbDsFeederBase = dwdShbDsFeederBaseService.getByPsrId(feederId);
         if (ObjectUtil.isNull(dwdShbDsFeederBase)) {
             ExceptionCast.cast("线路不存在");
         }
         // 调用状态估算
         StateEstimation s = null;
         //判断是否需要获取计划或故障数据
-        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
-        s = JSON.parseObject(JSON.toJSONString(redisTemplate.opsForValue().get(dto.getLinePsrId() + dto.getTime() + "zg")), StateEstimation.class);
-        if (s != null) {
-            periodSwitchSeResult = s.getPeriodSwitchSeResult();
-        } else {
-            try {
-                periodSwitchSeResult = iStateEstimationApiClient.queryByFeederSave(StateEstimationRequest.builder()
-                        .psrIds(Collections.singletonList(dto.getLinePsrId()))
-                        .containerCode(Collections.singletonList(CommonConstant.SWITCH))
-                        .startTime(dto.getTime())
-                        .endTime(dto.getTime())
-                        .isAuto(Boolean.FALSE)
-                        .build()).getData().getPeriodSwitchSeResult();
-            } catch (Exception e) {
-                e.printStackTrace();
+        String eventId = dto.getEventId();
+        if(StringUtils.isNotEmpty(eventId)){
+            List<FhzgSeEventStateEstimation> estimationList = stateEstimationMapper.selectList(
+                    new LambdaQueryWrapper<FhzgSeEventStateEstimation>()
+                            .eq(FhzgSeEventStateEstimation::getEventId, eventId)
+                            .eq(FhzgSeEventStateEstimation::getFeederId, feederId));
+            if(CollectionUtils.size(estimationList) > 0){
+                FhzgSeEventStateEstimation estimation = estimationList.get(0);
+                String stateEstimationJson = estimation.getStateEstimationJson();
+                if(StringUtils.isNotEmpty(stateEstimationJson)){
+                    s = JSON.parseObject(stateEstimationJson, StateEstimation.class);
+                    if(s != null){
+                        periodSwitchSeResult = s.getPeriodSwitchSeResult();
+                    }
+                }
+            }
+        }else {
+            s = JSON.parseObject(JSON.toJSONString(redisTemplate.opsForValue().get(feederId + dto.getTime() + "zg")), StateEstimation.class);
+            if (s != null) {
+                periodSwitchSeResult = s.getPeriodSwitchSeResult();
+            } else {
+                try {
+                    periodSwitchSeResult = iStateEstimationApiClient.queryByFeederSave(StateEstimationRequest.builder()
+                            .psrIds(Collections.singletonList(dto.getLinePsrId()))
+                            .containerCode(Collections.singletonList(CommonConstant.SWITCH))
+                            .startTime(dto.getTime())
+                            .endTime(dto.getTime())
+                            .isAuto(Boolean.FALSE)
+                            .build()).getData().getPeriodSwitchSeResult();
+                } catch (Exception e) {
+                    log.error("远程调用异常!",e);
+                }
             }
         }
         BeakerSvgInfoVO beakerSvgInfoVO = BeakerSvgInfoVO.builder().breakerPsrId(dto.getPsrId()).build();
@@ -763,7 +787,7 @@ public class FhzgSvgBreakersServiceImpl implements FhzgSvgBreakersService {
                         exception.printStackTrace();
                     }
                     if (Objects.equals(e.getIsAuto(), "true")) {
-                        beakerSvgInfoVO.setLcs(BeakerStatusInfoVO.builder()
+                        beakerSvgInfoVO.setLcs(BeakerStatusInfoVO.builder().breakerPsrId(e.getPsrId())
                                 .breakerPsrId(dto.getPsrId())
                                 .punit(CommonUnitEnum.P.getCode())
                                 .qunit(CommonUnitEnum.Q.getCode())
@@ -776,7 +800,7 @@ public class FhzgSvgBreakersServiceImpl implements FhzgSvgBreakersService {
                                 .status(e.getSeiStatuss().get(0))
                                 .build());
                     }
-                    beakerSvgInfoVO.setZgs(BeakerStatusInfoVO.builder()
+                    beakerSvgInfoVO.setZgs(BeakerStatusInfoVO.builder().breakerPsrId(e.getPsrId())
                             .breakerPsrId(dto.getPsrId())
                             .punit(CommonUnitEnum.P.getCode())
                             .qunit(CommonUnitEnum.Q.getCode())
@@ -928,6 +952,139 @@ public class FhzgSvgBreakersServiceImpl implements FhzgSvgBreakersService {
         return null;
     }
 
+    @Override
+    public List<BeakerStatusInfoVO> getBreakerStateEstimationInfo(BeakerStatusDTO dto) {
+        List<BeakerStatusInfoVO> beakerStatusInfoVOS = new ArrayList<>();
+        String eventId = dto.getEventId();
+        List<StateEstimation.StateEstimationSwitchResult> ss = new ArrayList<>();
+        List<StateEstimation.StateEstimationSwitchResult> periodSwitchSeResult = new ArrayList<>();
+        StateEstimation s = null;
+        if(StringUtils.isNotEmpty(eventId)){
+            //获取表中历史状估数据
+            List<FhzgSeEventStateEstimation> estimationList = stateEstimationMapper.selectList(
+                    new LambdaQueryWrapper<FhzgSeEventStateEstimation>().eq(FhzgSeEventStateEstimation::getEventId, eventId));
+            if(CollectionUtils.size(estimationList) > 0){
+                estimationList.forEach(estimation -> {
+                    StateEstimation se = null;
+                    String stateEstimationJson = estimation.getStateEstimationJson();
+                    if(StringUtils.isNotEmpty(stateEstimationJson)){
+                        se = JSON.parseObject(stateEstimationJson, StateEstimation.class);
+                        if(se != null){
+                            List<StateEstimation.StateEstimationSwitchResult> switchSeResult = se.getPeriodSwitchSeResult();
+                            if (CollectionUtils.isNotEmpty(switchSeResult)) {
+                                periodSwitchSeResult.addAll(switchSeResult);
+                            }
+                        }
+                    }
+                });
+            }
+
+        }else {
+            //实时查询
+            // 1. 查询接线组线路
+            String feederId = dto.getLinePsrId();
+            List<Jxz> jxzList = jxzMapper.queryJxzXl(feederId);
+            List<String> groupFeederIds = jxzList.stream()
+                    .map(Jxz::getFeederId)
+                    .filter(Objects::nonNull)
+                    .distinct()
+                    .collect(Collectors.toList());
+            //没有接线组只存当前线路数据
+            if (groupFeederIds.isEmpty()) {
+                groupFeederIds = Collections.singletonList(feederId);
+            }
+            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(dto.getTime())
+                            .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 -> {
+                BeakerSvgInfoVO beakerSvgInfoVO = BeakerSvgInfoVO.builder().breakerPsrId(e.getPsrId()).build();
+                String seiIs = "0.0";
+                try {
+                    if (StringUtils.isNotEmpty(e.getSeiIs().get(0))) {
+                        BigDecimal bigDecimal = new BigDecimal(e.getSeiIs().get(0));
+                        seiIs = bigDecimal.multiply(new BigDecimal(1000)).toString();
+                    }
+                } 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(e.getSeiPs().get(0)))
+                            .qvalue(e.getSeiQs().get(0))
+                            .ivalue(seiIs)
+                            .uvalue(e.getSeiUs().get(0))
+                            .status(e.getSeiStatuss().get(0))
+                            .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(e.getSeoPs().get(0)))
+                            .qvalue(e.getSeoQs().get(0))
+                            .ivalue(seiIs)
+                            .uvalue(e.getSeoUs().get(0))
+                            .status(e.getSeoStatuss().get(0))
+                            .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());
+                }
+                beakerStatusInfoVOS.add(beakerSvgInfoVO.getZgs());
+            });
+        }
+        return beakerStatusInfoVOS;
+    }
+
     //查找上级开关id
     public String getFirstSwitchOfPb(SwitchOrTransformerDTO dto) {
         List<String> psrTypeKg = Arrays.asList(DictConstants.KG_PSR_TYPE.split(","));

+ 19 - 0
services/load-transfer-bf/src/main/resources/mapper/FhzgSeEventStateEstimationMapper.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.hdkj.lt.bf.mapper.FhzgSeEventStateEstimationMapper">
+
+    <resultMap id="BaseResultMap" type="com.hdkj.lt.bf.entity.FhzgSeEventStateEstimation">
+            <id property="id" column="id" jdbcType="BIGINT"/>
+            <result property="eventId" column="event_id" jdbcType="BIGINT"/>
+            <result property="feederId" column="line_id" jdbcType="VARCHAR"/>
+            <result property="stateEstimationJson" column="state_estimation_json" jdbcType="VARCHAR"/>
+            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id,event_id,feeder_id,
+        state_estimation_json,create_time
+    </sql>
+</mapper>

+ 5 - 0
services/load-transfer-si/src/main/java/com/hdkj/lt/si/feign/StateEstimationApiClient.java

@@ -44,4 +44,9 @@ public class StateEstimationApiClient implements IStateEstimationApiClient {
     public ApiResponse<List<FhzgFeederAutoSwitchMapping>> saveAutoSwitch(StateEstimationRequest request) {
         return ApiResponse.success(stateEstimationService.saveAutoSwitch(request));
     }
+
+    @Override
+    public ApiResponse<StateEstimation> queryByFeeder(StateEstimationRequest request) {
+        return ApiResponse.success(stateEstimationService.queryByFeeder(request));
+    }
 }

+ 1 - 1
services/load-transfer-si/src/main/java/com/hdkj/lt/si/service/recon/impl/ReconResultServiceImpl.java

@@ -135,7 +135,7 @@ public class ReconResultServiceImpl implements ReconResultService {
             // 1. 主表
             FhzgReconResult main = buildMain(dto, scheme, i++);
             main.setEventId(eventId);
-            main.setRawResult(rawResultJson);
+//            main.setRawResult(rawResultJson);
             resultMapper.insert(main);
             Long resultId = main.getId();
             counts.merge("result", 1, Integer::sum);