|
|
@@ -1,6 +1,7 @@
|
|
|
package com.hdkj.lt.si.service.recon.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
@@ -74,7 +75,7 @@ public class ReconResultServiceImpl implements ReconResultService {
|
|
|
private RestTemplate restTemplate;
|
|
|
|
|
|
@Override
|
|
|
-// @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public ReconSaveResultVO saveReconResult(String eventId, Map<String, Object> params) {
|
|
|
// 1. 构造请求参数
|
|
|
Map<String, Object> req = buildReconRequestParams(params);
|
|
|
@@ -117,7 +118,7 @@ public class ReconResultServiceImpl implements ReconResultService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
-// @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public ReconSaveResultVO parseAndSaveReconResult(String rawResultJson, String eventId) {
|
|
|
// 1. 反序列化 raw_result JSON -> RawResultDTO
|
|
|
RawResultDTO dto;
|
|
|
@@ -135,7 +136,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);
|
|
|
@@ -222,17 +223,38 @@ public class ReconResultServiceImpl implements ReconResultService {
|
|
|
// ==================== 求解器 格式解析 ====================
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public ReconSaveResultVO saveDnrResultV24(DnrResultV24DTO resultV24DTO, String eventId) {
|
|
|
log.info("解析 求解器 结果, eventId: {}", eventId);
|
|
|
|
|
|
+
|
|
|
if (resultV24DTO.getData() == null || resultV24DTO.getData().isEmpty()) {
|
|
|
- log.warn("v2.4 结果无 data 数据, eventId: {}", eventId);
|
|
|
+ log.error("v2.4 结果无 data 数据, eventId: {}", eventId);
|
|
|
ReconSaveResultVO vo = new ReconSaveResultVO();
|
|
|
vo.setSuccess(true);
|
|
|
vo.setEventId(eventId);
|
|
|
return vo;
|
|
|
}
|
|
|
|
|
|
+ // 1. 插入前根据 eventId 删除可能已有的主表+子表历史数据(幂等覆盖式写入)
|
|
|
+ List<Long> existResultIds = resultMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<FhzgReconResult>()
|
|
|
+ .eq(FhzgReconResult::getEventId, eventId)
|
|
|
+ .select(FhzgReconResult::getId))
|
|
|
+ .stream().map(FhzgReconResult::getId).collect(Collectors.toList());
|
|
|
+ if (!CollectionUtils.isEmpty(existResultIds)) {
|
|
|
+ log.info("清理 eventId={} 的旧重构数据, resultIds={}", eventId, existResultIds);
|
|
|
+ // 先删子表(按 resultId),再删主表(按 eventId)
|
|
|
+ switchOpMapper.delete(new LambdaQueryWrapper<FhzgReconSwitchOp>().in(FhzgReconSwitchOp::getResultId, existResultIds));
|
|
|
+ switchSeqMapper.delete(new LambdaQueryWrapper<FhzgReconSwitchSeq>().in(FhzgReconSwitchSeq::getResultId, existResultIds));
|
|
|
+ feederResultMapper.delete(new LambdaQueryWrapper<FhzgReconFeederResult>().in(FhzgReconFeederResult::getResultId, existResultIds));
|
|
|
+ volResultMapper.delete(new LambdaQueryWrapper<FhzgReconVolResult>().in(FhzgReconVolResult::getResultId, existResultIds));
|
|
|
+ volDetailMapper.delete(new LambdaQueryWrapper<FhzgReconVolDetail>().in(FhzgReconVolDetail::getResultId, existResultIds));
|
|
|
+ switchResultDetailMapper.delete(new LambdaQueryWrapper<FhzgReconSwitchResultDetail>().in(FhzgReconSwitchResultDetail::getResultId, existResultIds));
|
|
|
+ metricsMapper.delete(new LambdaQueryWrapper<FhzgReconMetrics>().in(FhzgReconMetrics::getResultId, existResultIds));
|
|
|
+ resultMapper.delete(new LambdaQueryWrapper<FhzgReconResult>().in(FhzgReconResult::getId, existResultIds));
|
|
|
+ }
|
|
|
+
|
|
|
// 2. 遍历每个 group → soln,独立处理主表,复用分表方法
|
|
|
Map<String, Integer> counts = new LinkedHashMap<>();
|
|
|
for (DnrResultV24GroupDTO group : resultV24DTO.getData()) {
|