liuaini 1 hete
szülő
commit
e2fd8e959e

+ 2 - 1
api/load-transfer-si-api/src/main/java/com/hdkj/lt/feign/ISimulationPlatformApiClient.java

@@ -2,6 +2,7 @@ package com.hdkj.lt.feign;
 
 import com.hdkj.lt.base.constants.SystemGlobalConstant;
 import com.hdkj.lt.feign.fallback.SimulationPlatformApiClientFallBack;
+import com.hdkj.lt.modle.dto.recon.DnrResultV24DTO;
 import com.hdkj.lt.modle.dto.simulation.*;
 import com.hdkj.hussar.ApiResponse;
 import io.swagger.annotations.ApiOperation;
@@ -37,5 +38,5 @@ public interface ISimulationPlatformApiClient {
 
     @ApiOperation(value = "查询调优计算结果")
     @GetMapping("/operationMode/queryOperationResult")
-    ApiResponse<QueryOperationModeDTO> queryOperationResult(@RequestParam("id") String taskId);
+    ApiResponse<DnrResultV24DTO> queryOperationResult(@RequestParam("id") String taskId);
 }

+ 2 - 1
api/load-transfer-si-api/src/main/java/com/hdkj/lt/feign/fallback/SimulationPlatformApiClientFallBack.java

@@ -1,6 +1,7 @@
 package com.hdkj.lt.feign.fallback;
 
 import com.hdkj.lt.feign.ISimulationPlatformApiClient;
+import com.hdkj.lt.modle.dto.recon.DnrResultV24DTO;
 import com.hdkj.lt.modle.dto.simulation.*;
 import com.hdkj.hussar.ApiResponse;
 import lombok.extern.slf4j.Slf4j;
@@ -47,7 +48,7 @@ public class SimulationPlatformApiClientFallBack implements FallbackFactory<ISim
             }
 
             @Override
-            public ApiResponse<QueryOperationModeDTO> queryOperationResult(String taskId) {
+            public ApiResponse<DnrResultV24DTO> queryOperationResult(String taskId) {
                 log.error("查询调优计算结果-远程调用服务异常, taskId:{},异常:{}", taskId, cause.getMessage());
                 return ApiResponse.fail("查询调优计算结果服务异常");
             }

+ 2 - 2
services/load-transfer-mq/src/main/java/com/hdkj/lt/mq/listener/RocketConsumerSimulationTaskListener.java

@@ -8,7 +8,7 @@ import com.aliyun.openservices.ons.api.Message;
 import com.aliyun.openservices.ons.api.MessageListener;
 import com.hdkj.hussar.ApiResponse;
 import com.hdkj.lt.feign.ISimulationPlatformApiClient;
-import com.hdkj.lt.modle.dto.simulation.QueryOperationModeDTO;
+import com.hdkj.lt.modle.dto.recon.DnrResultV24DTO;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
@@ -44,7 +44,7 @@ public class RocketConsumerSimulationTaskListener implements MessageListener {
      * 查询处理调优计算结果
      */
     private void executeFunc(String value) {
-        ApiResponse<QueryOperationModeDTO> result = simulationPlatformApiClient.queryOperationResult(value);
+        ApiResponse<DnrResultV24DTO> result = simulationPlatformApiClient.queryOperationResult(value);
         log.info("查询处理调优计算结果: taskId={}, response={}", value, JSONObject.toJSONString(result));
     }
 }

+ 2 - 1
services/load-transfer-si/src/main/java/com/hdkj/lt/si/controller/simulation/SimulationController.java

@@ -2,6 +2,7 @@ package com.hdkj.lt.si.controller.simulation;
 
 import com.alibaba.fastjson.JSONObject;
 import com.hdkj.lt.feign.ISimulationPlatformApiClient;
+import com.hdkj.lt.modle.dto.recon.DnrResultV24DTO;
 import com.hdkj.lt.modle.dto.simulation.*;
 import com.hdkj.lt.si.service.simulation.ISimulationService;
 import com.hdkj.hussar.ApiResponse;
@@ -58,7 +59,7 @@ public class SimulationController implements ISimulationPlatformApiClient {
      */
     @Override
     @GetMapping("/operationMode/queryOperationResult")
-    public ApiResponse<QueryOperationModeDTO> queryOperationResult(@RequestParam("id") String taskId) {
+    public ApiResponse<DnrResultV24DTO> queryOperationResult(@RequestParam("id") String taskId) {
         return simulationService.queryOperationResult(taskId);
     }
 }

+ 2 - 3
services/load-transfer-si/src/main/java/com/hdkj/lt/si/service/recon/ReconResultService.java

@@ -1,6 +1,7 @@
 package com.hdkj.lt.si.service.recon;
 
 
+import com.hdkj.lt.modle.dto.recon.DnrResultV24DTO;
 import com.hdkj.lt.modle.vo.recon.ReconSaveResultVO;
 
 import java.util.List;
@@ -29,12 +30,10 @@ public interface ReconResultService {
     /**
      * 解析 v2.4 格式的 DNR 结果 JSON 并入库.
      * <p>
-     * 独立反序列化 dnr_result_v2.4.json 格式({ summary, data: [...] }),
      * 转换为内部 RawResultDTO 格式后复用 {@link #parseAndSaveReconResult} 的入库逻辑。
      *
-     * @param jsonStr v2.4 格式的完整 JSON 字符串
      * @param eventId 事件ID
      * @return 入库结果概要
      */
-    ReconSaveResultVO parseAndSaveDnrResultV24(String jsonStr, String eventId);
+    ReconSaveResultVO saveDnrResultV24(DnrResultV24DTO resultV24DTO, String eventId);
 }

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

@@ -1,12 +1,10 @@
 package com.hdkj.lt.si.service.recon.impl;
 
 import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.fasterxml.jackson.databind.DeserializationFeature;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
-
 import com.hdkj.lt.base.exception.ExceptionCast;
 import com.hdkj.lt.core.bizms.modle.po.Jxz;
 import com.hdkj.lt.core.rest.config.HttpClientConfig;
@@ -23,17 +21,17 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.codec.Charsets;
 import org.apache.commons.collections.MapUtils;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.http.*;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
-import org.springframework.util.StreamUtils;
 import org.springframework.web.client.RestTemplate;
 
 import javax.annotation.Resource;
 import java.io.IOException;
-import java.nio.charset.StandardCharsets;
 import java.time.LocalDateTime;
 import java.time.OffsetDateTime;
 import java.time.format.DateTimeFormatter;
@@ -135,7 +133,7 @@ public class ReconResultServiceImpl implements ReconResultService {
         int i = 1;
         for (ReconfigurationSchemeDTO scheme : schemes) {
             // 1. 主表
-            FhzgReconResult main = buildMain(dto,scheme,i++);
+            FhzgReconResult main = buildMain(dto, scheme, i++);
             main.setEventId(eventId);
             main.setRawResult(rawResultJson);
             resultMapper.insert(main);
@@ -161,9 +159,9 @@ public class ReconResultServiceImpl implements ReconResultService {
     /**
      * 构建请求参数
      */
-    private Map<String, Object> buildReconRequestParams(Map<String, Object> params){
+    private Map<String, Object> buildReconRequestParams(Map<String, Object> params) {
         Map<String, Object> root = new HashMap<>();
-        if(Objects.nonNull(params)) {
+        if (Objects.nonNull(params)) {
             String feederId = MapUtils.getString(params, "feeder_id");
             String pointTime = MapUtils.getString(params, "point_time");
             List<Jxz> jxzList = getFeederGroup(feederId);
@@ -205,12 +203,15 @@ public class ReconResultServiceImpl implements ReconResultService {
         }
         return root;
     }
-    private List<Jxz> getFeederGroup(String feederId){
-         return jxzMapper.queryJxzXl(feederId);
+
+    private List<Jxz> getFeederGroup(String feederId) {
+        return jxzMapper.queryJxzXl(feederId);
     }
     // ==================== 构建主表 ====================
 
-    /** [FHZG-RECON-MULTI] 取方案列表; 容器或 list 为空时返回空表(不报错, 入 0 条)。 */
+    /**
+     * [FHZG-RECON-MULTI] 取方案列表; 容器或 list 为空时返回空表(不报错, 入 0 条)。
+     */
     private List<ReconfigurationSchemeDTO> extractSchemes(RawResultDTO dto) {
         if (dto.getReconfigurationSchemes() == null || dto.getReconfigurationSchemes().getList() == null) {
             return Collections.emptyList();
@@ -218,21 +219,13 @@ public class ReconResultServiceImpl implements ReconResultService {
         return dto.getReconfigurationSchemes().getList();
     }
 
-    // ==================== v2.4 格式解析 ====================
+    // ==================== 求解器 格式解析 ====================
 
     @Override
-    public ReconSaveResultVO parseAndSaveDnrResultV24(String jsonStr, String eventId) {
-        log.info("解析 v2.4 DNR 结果, eventId: {}", eventId);
-
-        // 1. 反序列化新结构
-        DnrResultV24DTO root;
-        try {
-            root = OM.readValue(jsonStr, DnrResultV24DTO.class);
-        } catch (IOException e) {
-            throw new RuntimeException("反序列化 v2.4 DNR 结果 JSON 失败", e);
-        }
+    public ReconSaveResultVO saveDnrResultV24(DnrResultV24DTO resultV24DTO, String eventId) {
+        log.info("解析 求解器 结果, eventId: {}", eventId);
 
-        if (root.getData() == null || root.getData().isEmpty()) {
+        if (resultV24DTO.getData() == null || resultV24DTO.getData().isEmpty()) {
             log.warn("v2.4 结果无 data 数据, eventId: {}", eventId);
             ReconSaveResultVO vo = new ReconSaveResultVO();
             vo.setSuccess(true);
@@ -242,13 +235,13 @@ public class ReconResultServiceImpl implements ReconResultService {
 
         // 2. 遍历每个 group → soln,独立处理主表,复用分表方法
         Map<String, Integer> counts = new LinkedHashMap<>();
-        for (DnrResultV24GroupDTO group : root.getData()) {
+        for (DnrResultV24GroupDTO group : resultV24DTO.getData()) {
             if (group.getSolnList() == null || group.getSolnList().isEmpty()) {
                 continue;
             }
             for (DnrResultV24SolnDTO soln : group.getSolnList()) {
                 // 主表
-                FhzgReconResult main = buildMainV24(group, soln, eventId, jsonStr);
+                FhzgReconResult main = buildMainV24(group, soln, eventId);
                 resultMapper.insert(main);
                 Long resultId = main.getId();
                 counts.merge("result", 1, Integer::sum);
@@ -276,11 +269,11 @@ public class ReconResultServiceImpl implements ReconResultService {
      * computeResult, detalDesc, soln_id, soln_name 等来自 soln 层.
      */
     private FhzgReconResult buildMainV24(DnrResultV24GroupDTO group, DnrResultV24SolnDTO soln,
-                                         String eventId, String rawResultJson) {
+                                         String eventId) {
         FhzgReconResult m = new FhzgReconResult();
         m.setId(IdWorker.getId());
         m.setEventId(eventId);
-        m.setRawResult(rawResultJson);
+        m.setRawResult(null);
         m.setGroupId(String.valueOf(group.getGroupId()));
         m.setGroupSid(group.getGroupSid());
         m.setGroupName(group.getGroupName());
@@ -310,12 +303,11 @@ public class ReconResultServiceImpl implements ReconResultService {
 
     /**
      * 插入所有子表记录(switchOp, switchSeq, feederResult, volResult, switchResultDetail, metrics).
-     * 在 {@link #parseAndSaveReconResult} 和 {@link #parseAndSaveDnrResultV24} 中复用.
      */
     private void insertSubTables(SwitchOpDTO switchOp, SwitchSeqDTO switchSeq,
-                                  FeederResultDTO feederResult, VolResultDTO volResult,
-                                  SwitchResultDTO switchResult, MetricsDTO metrics,
-                                  Long resultId, Map<String, Integer> counts) {
+                                 FeederResultDTO feederResult, VolResultDTO volResult,
+                                 SwitchResultDTO switchResult, MetricsDTO metrics,
+                                 Long resultId, Map<String, Integer> counts) {
         // 开关操作(简化版)
         if (switchOp != null) {
             counts.merge("switch_op", insertSwitchOp(switchOp, resultId), Integer::sum);
@@ -349,7 +341,7 @@ public class ReconResultServiceImpl implements ReconResultService {
         }
     }
 
-    private FhzgReconResult buildMain(RawResultDTO dto, ReconfigurationSchemeDTO scheme,int i) {
+    private FhzgReconResult buildMain(RawResultDTO dto, ReconfigurationSchemeDTO scheme, int i) {
         FhzgReconResult m = new FhzgReconResult();
         // 共享标量(每个方案主记录重复)
         m.setId(IdWorker.getId());
@@ -591,7 +583,9 @@ public class ReconResultServiceImpl implements ReconResultService {
         return e;
     }
 
-    /** 按 before/after 将指标子对象扁平写入实体对应字段; val 为 null 时跳过. */
+    /**
+     * 按 before/after 将指标子对象扁平写入实体对应字段; val 为 null 时跳过.
+     */
     private void fillMetricsSide(FhzgReconMetrics e, MetricsDTO.MetricsBeforeAfterDTO m, boolean before) {
         if (m == null) return;
 
@@ -662,7 +656,9 @@ public class ReconResultServiceImpl implements ReconResultService {
         }
     }
 
-    /** before 时调 beforeSetter, 否则调 afterSetter; val 为 null 跳过. */
+    /**
+     * before 时调 beforeSetter, 否则调 afterSetter; val 为 null 跳过.
+     */
     private <T> void side(FhzgReconMetrics e, boolean before,
                           BiConsumer<FhzgReconMetrics, T> beforeSetter,
                           BiConsumer<FhzgReconMetrics, T> afterSetter, T val) {
@@ -672,7 +668,9 @@ public class ReconResultServiceImpl implements ReconResultService {
 
     // ==================== 类型转换工具 ====================
 
-    /** ISO8601 字符串(含时区) -> LocalDateTime(取本地壁钟时间); 无法解析返回 null. */
+    /**
+     * ISO8601 字符串(含时区) -> LocalDateTime(取本地壁钟时间); 无法解析返回 null.
+     */
     private LocalDateTime parseTime(String s) {
         if (s == null || s.trim().isEmpty()) return null;
         try {
@@ -686,7 +684,9 @@ public class ReconResultServiceImpl implements ReconResultService {
         }
     }
 
-    /** JsonNode -> JSON 字符串; null 或 null 节点返回 null. */
+    /**
+     * JsonNode -> JSON 字符串; null 或 null 节点返回 null.
+     */
     private String toJson(JsonNode node) {
         if (node == null || node.isNull()) return null;
         try {

+ 2 - 1
services/load-transfer-si/src/main/java/com/hdkj/lt/si/service/simulation/ISimulationService.java

@@ -1,5 +1,6 @@
 package com.hdkj.lt.si.service.simulation;
 
+import com.hdkj.lt.modle.dto.recon.DnrResultV24DTO;
 import com.hdkj.lt.modle.dto.simulation.*;
 import com.hdkj.hussar.ApiResponse;
 
@@ -34,5 +35,5 @@ public interface ISimulationService {
      * @param taskId 任务ID
      * @return 调优计算结果
      */
-    ApiResponse<QueryOperationModeDTO> queryOperationResult(String taskId);
+    ApiResponse<DnrResultV24DTO> queryOperationResult(String taskId);
 }

+ 7 - 8
services/load-transfer-si/src/main/java/com/hdkj/lt/si/service/simulation/impl/SimulationServiceImpl.java

@@ -12,6 +12,7 @@ import com.hdkj.lt.base.constants.ErrorLogConstant;
 import com.hdkj.lt.base.enums.EventTypeEnum;
 import com.hdkj.lt.base.enums.OperationStepEnum;
 import com.hdkj.lt.base.exception.ExceptionCast;
+import com.hdkj.lt.modle.dto.recon.DnrResultV24DTO;
 import com.hdkj.lt.si.modle.FhzgReconSimulationTask;
 import com.hdkj.lt.si.service.simulation.FhzgReconSimulationTaskService;
 import com.hdkj.lt.core.bizms.modle.po.fault.FaultAwaitTransferAreaResult;
@@ -318,7 +319,7 @@ public class SimulationServiceImpl implements ISimulationService {
     }
 
     @Override
-    public ApiResponse<QueryOperationModeDTO> queryOperationResult(String taskId) {
+    public ApiResponse<DnrResultV24DTO> queryOperationResult(String taskId) {
         log.info("查询重构结果, taskId: {}", taskId);
 
         // 1. 调用远程接口查询重构结果
@@ -348,17 +349,15 @@ public class SimulationServiceImpl implements ISimulationService {
                 log.error("重构结果查询失败, taskId: {}, code: {}, msg: {}", taskId, code, msg);
                 return ApiResponse.fail("重构结果查询失败: " + msg);
             }
-            JsonNode dataNode = root.get("data");
+            JsonNode dataNode = root.get("data").get("result");
             if (dataNode == null || dataNode.isNull()) {
                 return ApiResponse.fail("重构结果查询响应数据为空");
             }
-            QueryOperationModeDTO resultDTO = OM.treeToValue(dataNode, QueryOperationModeDTO.class);
 
             // 3. 保存结果到数据库
-            if (resultDTO.getResult() != null) {
-                // 将 result 序列化为 rawResult JSON 并入库
-                String rawResultJson = OM.writeValueAsString(resultDTO.getResult());
-                reconResultService.parseAndSaveDnrResultV24(rawResultJson, one.getEventId());
+            if (dataNode.get("data") != null) {
+                DnrResultV24DTO resultDTO = OM.treeToValue(dataNode, DnrResultV24DTO.class);
+                reconResultService.saveDnrResultV24(resultDTO, one.getEventId());
             }
 
             if (one != null) {
@@ -366,7 +365,7 @@ public class SimulationServiceImpl implements ISimulationService {
                 reconSimulationTaskService.saveOrUpdate(one);
             }
 
-            return ApiResponse.success(resultDTO);
+            return ApiResponse.success(responseStr);
         } catch (IOException e) {
             log.error("解析重构结果查询响应失败, taskId: {}", taskId, e);
             return ApiResponse.fail("解析重构结果查询响应失败: " + e.getMessage());