|
@@ -2,6 +2,7 @@ package com.hdkj.lt.si.service.recon.impl;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
@@ -128,105 +129,108 @@ public class ReconResultServiceImpl implements ReconResultService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Map<String, Integer> counts = new LinkedHashMap<>();
|
|
Map<String, Integer> counts = new LinkedHashMap<>();
|
|
|
|
|
+ //获取方案列表
|
|
|
|
|
+ List<ReconfigurationSchemeDTO> schemes = extractSchemes(dto);
|
|
|
|
|
+ for (ReconfigurationSchemeDTO scheme : schemes) {
|
|
|
|
|
+ // 1. 主表
|
|
|
|
|
+ FhzgReconResult main = buildMain(dto,scheme);
|
|
|
|
|
+ main.setEventId(eventId);
|
|
|
|
|
+ main.setRawResult(rawResultJson);
|
|
|
|
|
+ resultMapper.insert(main);
|
|
|
|
|
+ Long resultId = main.getId();
|
|
|
|
|
+ counts.merge("result", 1, Integer::sum);
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 开关操作(简化版)
|
|
|
|
|
+ if (scheme.getSwitchOp() != null) {
|
|
|
|
|
+ counts.merge("switch_op", insertSwitchOp(scheme.getSwitchOp(), resultId), Integer::sum);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // 2. 主表
|
|
|
|
|
- FhzgReconResult main = buildMain(dto);
|
|
|
|
|
- main.setEventId(eventId);
|
|
|
|
|
- main.setRawResult(rawResultJson);
|
|
|
|
|
- resultMapper.insert(main);
|
|
|
|
|
- Long resultId = main.getId();
|
|
|
|
|
- counts.put("result", 1);
|
|
|
|
|
-
|
|
|
|
|
- // 3. 开关操作(简化版)
|
|
|
|
|
- if (dto.getSwitchOp() != null) {
|
|
|
|
|
- int n = insertSwitchOp(dto.getSwitchOp(), resultId);
|
|
|
|
|
- counts.put("switch_op", n);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 4. 开关操作序列(详细)
|
|
|
|
|
- if (dto.getSwitchSeq() != null) {
|
|
|
|
|
- int n = insertSwitchSeq(dto.getSwitchSeq(), resultId);
|
|
|
|
|
- counts.put("switch_seq", n);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 5. 馈线结果
|
|
|
|
|
- if (dto.getFeederResult() != null) {
|
|
|
|
|
- int n = insertFeederResult(dto.getFeederResult(), resultId);
|
|
|
|
|
- counts.put("feeder_result", n);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 3. 开关操作序列(详细)
|
|
|
|
|
+ if (scheme.getSwitchSeq() != null) {
|
|
|
|
|
+ counts.merge("switch_seq", insertSwitchSeq(scheme.getSwitchSeq(), resultId), Integer::sum);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // 6. 电压结果(汇总+详情)
|
|
|
|
|
- if (dto.getVolResult() != null) {
|
|
|
|
|
- if (dto.getVolResult().getSummary() != null) {
|
|
|
|
|
- volResultMapper.insert(buildVolResult(dto.getVolResult().getSummary(), resultId));
|
|
|
|
|
- counts.put("vol_result", 1);
|
|
|
|
|
|
|
+ // 4. 馈线结果
|
|
|
|
|
+ if (scheme.getFeederResult() != null) {
|
|
|
|
|
+ counts.merge("feeder_result", insertFeederResult(scheme.getFeederResult(), resultId), Integer::sum);
|
|
|
}
|
|
}
|
|
|
- if (dto.getVolResult().getDetails() != null) {
|
|
|
|
|
- int n = insertVolDetail(dto.getVolResult().getDetails(), resultId);
|
|
|
|
|
- counts.put("vol_detail", n);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 5. 电压结果(汇总+详情)
|
|
|
|
|
+ if (scheme.getVolResult() != null) {
|
|
|
|
|
+ if (scheme.getVolResult().getSummary() != null) {
|
|
|
|
|
+ volResultMapper.insert(buildVolResult(scheme.getVolResult().getSummary(), resultId));
|
|
|
|
|
+ counts.merge("vol_result", 1, Integer::sum);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (scheme.getVolResult().getDetails() != null) {
|
|
|
|
|
+ counts.merge("vol_detail", insertVolDetail(scheme.getVolResult().getDetails(), resultId), Integer::sum);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- // 7. 开关状态详情(summary 折叠进主表)
|
|
|
|
|
- if (dto.getSwitchResult() != null && dto.getSwitchResult().getDetails() != null) {
|
|
|
|
|
- int n = insertSwitchResultDetail(dto.getSwitchResult().getDetails(), resultId);
|
|
|
|
|
- counts.put("switch_result_detail", n);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 6. 开关状态详情(summary 折叠进主表)
|
|
|
|
|
+ if (scheme.getSwitchResult() != null && scheme.getSwitchResult().getDetails() != null) {
|
|
|
|
|
+ counts.merge("switch_result_detail", insertSwitchResultDetail(scheme.getSwitchResult().getDetails(), resultId), Integer::sum);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // 8. 运行指标
|
|
|
|
|
- if (dto.getMetrics() != null) {
|
|
|
|
|
- metricsMapper.insert(buildMetrics(dto.getMetrics(), resultId));
|
|
|
|
|
- counts.put("metrics", 1);
|
|
|
|
|
|
|
+ // 7. 运行指标
|
|
|
|
|
+ if (scheme.getMetrics() != null) {
|
|
|
|
|
+ metricsMapper.insert(buildMetrics(scheme.getMetrics(), resultId));
|
|
|
|
|
+ counts.merge("metrics", 1, Integer::sum);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
log.info("重构方案counts:{}", JSON.toJSONString(counts));
|
|
log.info("重构方案counts:{}", JSON.toJSONString(counts));
|
|
|
ReconSaveResultVO vo = new ReconSaveResultVO();
|
|
ReconSaveResultVO vo = new ReconSaveResultVO();
|
|
|
vo.setSuccess(true);
|
|
vo.setSuccess(true);
|
|
|
- vo.setMainId(resultId);
|
|
|
|
|
- vo.setEventId(main.getEventId());
|
|
|
|
|
|
|
+// vo.setMainId(resultId);
|
|
|
|
|
+ vo.setEventId(eventId);
|
|
|
vo.setCounts(counts);
|
|
vo.setCounts(counts);
|
|
|
return vo;
|
|
return vo;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 构建请求参数
|
|
|
|
|
+ */
|
|
|
private Map<String, Object> buildReconRequestParams(Map<String, Object> params){
|
|
private Map<String, Object> buildReconRequestParams(Map<String, Object> params){
|
|
|
Map<String, Object> root = new HashMap<>();
|
|
Map<String, Object> root = new HashMap<>();
|
|
|
- if(Objects.nonNull(params)){
|
|
|
|
|
|
|
+ if(Objects.nonNull(params)) {
|
|
|
String feederId = MapUtils.getString(params, "feeder_id");
|
|
String feederId = MapUtils.getString(params, "feeder_id");
|
|
|
String pointTime = MapUtils.getString(params, "point_time");
|
|
String pointTime = MapUtils.getString(params, "point_time");
|
|
|
List<Jxz> jxzList = getFeederGroup(feederId);
|
|
List<Jxz> jxzList = getFeederGroup(feederId);
|
|
|
List<String> feederIds = jxzList.stream().map(Jxz::getFeederId).distinct().collect(Collectors.toList());
|
|
List<String> feederIds = jxzList.stream().map(Jxz::getFeederId).distinct().collect(Collectors.toList());
|
|
|
- Jxz jxz = jxzList.get(0);
|
|
|
|
|
- // county
|
|
|
|
|
- Map<String, Object> county = new HashMap<>();
|
|
|
|
|
- county.put("county_id", jxz.getMaintOrg());
|
|
|
|
|
- county.put("county_sid", jxz.getMaintOrgName());
|
|
|
|
|
- county.put("county_name", jxz.getMaintOrgName());
|
|
|
|
|
- root.put("county", county);
|
|
|
|
|
-
|
|
|
|
|
- // snapshot
|
|
|
|
|
- Map<String, Object> snapshot = new HashMap<>();
|
|
|
|
|
- snapshot.put("snapshot_id", pointTime);
|
|
|
|
|
- snapshot.put("alarm_state_estimation_time", pointTime);
|
|
|
|
|
- snapshot.put("point_time", pointTime);
|
|
|
|
|
- root.put("snapshot", snapshot);
|
|
|
|
|
-
|
|
|
|
|
- // problem
|
|
|
|
|
- Map<String, Object> problem = new HashMap<>();
|
|
|
|
|
- problem.put("problem_feeder_ids", Collections.singletonList(feederId));
|
|
|
|
|
- problem.put("trigger_type", "load_rate");
|
|
|
|
|
- problem.put("trigger_reason", "feeder_load_rate_over_limit");
|
|
|
|
|
- problem.put("trigger_source", "customer_backend_alarm");
|
|
|
|
|
- root.put("problem", problem);
|
|
|
|
|
-
|
|
|
|
|
- // feeder_group
|
|
|
|
|
- Map<String, Object> feederGroup = new HashMap<>();
|
|
|
|
|
- feederGroup.put("group_id", jxz.getJxzId());
|
|
|
|
|
- feederGroup.put("group_sid", jxz.getJxzId());
|
|
|
|
|
- feederGroup.put("group_name", jxz.getJxzName());
|
|
|
|
|
- feederGroup.put("feeder_ids", feederIds);
|
|
|
|
|
- root.put("feeder_group", feederGroup);
|
|
|
|
|
- // algorithm_config【外部可传入覆盖】
|
|
|
|
|
- root.put("algorithm_config", algorithmProp.toAlgorithmConfigMap());
|
|
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(jxzList)) {
|
|
|
|
|
+ Jxz jxz = jxzList.get(0);
|
|
|
|
|
+ // county
|
|
|
|
|
+ Map<String, Object> county = new HashMap<>();
|
|
|
|
|
+ county.put("county_id", jxz.getMaintOrg());
|
|
|
|
|
+ county.put("county_sid", jxz.getMaintOrgName());
|
|
|
|
|
+ county.put("county_name", jxz.getMaintOrgName());
|
|
|
|
|
+ root.put("county", county);
|
|
|
|
|
+
|
|
|
|
|
+ // snapshot
|
|
|
|
|
+ Map<String, Object> snapshot = new HashMap<>();
|
|
|
|
|
+ snapshot.put("snapshot_id", pointTime);
|
|
|
|
|
+ snapshot.put("alarm_state_estimation_time", pointTime);
|
|
|
|
|
+ snapshot.put("point_time", pointTime);
|
|
|
|
|
+ root.put("snapshot", snapshot);
|
|
|
|
|
+
|
|
|
|
|
+ // problem
|
|
|
|
|
+ Map<String, Object> problem = new HashMap<>();
|
|
|
|
|
+ problem.put("problem_feeder_ids", Collections.singletonList(feederId));
|
|
|
|
|
+ problem.put("trigger_type", "load_rate");
|
|
|
|
|
+ problem.put("trigger_reason", "feeder_load_rate_over_limit");
|
|
|
|
|
+ problem.put("trigger_source", "customer_backend_alarm");
|
|
|
|
|
+ root.put("problem", problem);
|
|
|
|
|
+
|
|
|
|
|
+ // feeder_group
|
|
|
|
|
+ Map<String, Object> feederGroup = new HashMap<>();
|
|
|
|
|
+ feederGroup.put("group_id", jxz.getJxzId());
|
|
|
|
|
+ feederGroup.put("group_sid", jxz.getJxzId());
|
|
|
|
|
+ feederGroup.put("group_name", jxz.getJxzName());
|
|
|
|
|
+ feederGroup.put("feeder_ids", feederIds);
|
|
|
|
|
+ root.put("feeder_group", feederGroup);
|
|
|
|
|
+ // algorithm_config【外部可传入覆盖】
|
|
|
|
|
+ root.put("algorithm_config", algorithmProp.toAlgorithmConfigMap());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
return root;
|
|
return root;
|
|
|
}
|
|
}
|
|
@@ -235,11 +239,19 @@ public class ReconResultServiceImpl implements ReconResultService {
|
|
|
}
|
|
}
|
|
|
// ==================== 构建主表 ====================
|
|
// ==================== 构建主表 ====================
|
|
|
|
|
|
|
|
- private FhzgReconResult buildMain(RawResultDTO dto) {
|
|
|
|
|
|
|
+ /** [FHZG-RECON-MULTI] 取方案列表; 容器或 list 为空时返回空表(不报错, 入 0 条)。 */
|
|
|
|
|
+ private List<ReconfigurationSchemeDTO> extractSchemes(RawResultDTO dto) {
|
|
|
|
|
+ if (dto.getReconfigurationSchemes() == null || dto.getReconfigurationSchemes().getList() == null) {
|
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
|
+ }
|
|
|
|
|
+ return dto.getReconfigurationSchemes().getList();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private FhzgReconResult buildMain(RawResultDTO dto, ReconfigurationSchemeDTO scheme) {
|
|
|
FhzgReconResult m = new FhzgReconResult();
|
|
FhzgReconResult m = new FhzgReconResult();
|
|
|
|
|
+ // 共享标量(每个方案主记录重复)
|
|
|
|
|
+ m.setId(IdWorker.getId());
|
|
|
m.setGroupId(dto.getGroupId());
|
|
m.setGroupId(dto.getGroupId());
|
|
|
- //目前就一个方案
|
|
|
|
|
- m.setSchemeName("方案一");
|
|
|
|
|
m.setGroupSid(dto.getGroupSid());
|
|
m.setGroupSid(dto.getGroupSid());
|
|
|
m.setGroupName(dto.getGroupName());
|
|
m.setGroupName(dto.getGroupName());
|
|
|
m.setStAreaId(dto.getStAreaId());
|
|
m.setStAreaId(dto.getStAreaId());
|
|
@@ -248,14 +260,20 @@ public class ReconResultServiceImpl implements ReconResultService {
|
|
|
m.setComputeResult(dto.getComputeResult());
|
|
m.setComputeResult(dto.getComputeResult());
|
|
|
m.setDetalDesc(dto.getDetalDesc());
|
|
m.setDetalDesc(dto.getDetalDesc());
|
|
|
|
|
|
|
|
- // finalCheck 折叠
|
|
|
|
|
- if (dto.getFinalCheck() != null) {
|
|
|
|
|
- m.setFinalCheckIsSafe(dto.getFinalCheck().getSafe());
|
|
|
|
|
- m.setFinalCheckDetails(dto.getFinalCheck().getDetails());
|
|
|
|
|
|
|
+ // [FHZG-RECON-MULTI] 方案标识 + objective
|
|
|
|
|
+ m.setRank(scheme.getRank());
|
|
|
|
|
+ m.setSchemeId(scheme.getSchemeId());
|
|
|
|
|
+ m.setSchemeName(scheme.getSchemeName());
|
|
|
|
|
+ m.setObjective(toJson(scheme.getObjective()));
|
|
|
|
|
+
|
|
|
|
|
+ // finalCheck 折叠(per-scheme)
|
|
|
|
|
+ if (scheme.getFinalCheck() != null) {
|
|
|
|
|
+ m.setFinalCheckIsSafe(scheme.getFinalCheck().getSafe());
|
|
|
|
|
+ m.setFinalCheckDetails(scheme.getFinalCheck().getDetails());
|
|
|
}
|
|
}
|
|
|
- // switchResult.summary 折叠
|
|
|
|
|
- if (dto.getSwitchResult() != null) {
|
|
|
|
|
- m.setSwitchResultSummary(dto.getSwitchResult().getSummary());
|
|
|
|
|
|
|
+ // switchResult.summary 折叠(per-scheme)
|
|
|
|
|
+ if (scheme.getSwitchResult() != null) {
|
|
|
|
|
+ m.setSwitchResultSummary(scheme.getSwitchResult().getSummary());
|
|
|
}
|
|
}
|
|
|
m.setSnapshotTime(LocalDateTime.now());
|
|
m.setSnapshotTime(LocalDateTime.now());
|
|
|
return m;
|
|
return m;
|