|
|
@@ -1,6 +1,10 @@
|
|
|
package com.hdkj.lt.bf.controller.optimization;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.hdkj.fhzg.optimization.request.MaintOrgRequest;
|
|
|
import com.hdkj.hussar.ApiResponse;
|
|
|
+import com.hdkj.lt.bf.adapter.SiStateEstimationClient;
|
|
|
+import com.hdkj.lt.bf.common.SeSnapshotConstants;
|
|
|
import com.hdkj.lt.bf.entity.vo.IndicatorDashboardVO;
|
|
|
import com.hdkj.lt.bf.entity.vo.PageResult;
|
|
|
import com.hdkj.lt.bf.entity.vo.SeCapacityDashboardVO;
|
|
|
@@ -12,14 +16,19 @@ import com.hdkj.lt.bf.entity.vo.SeVoltageDashboardVO;
|
|
|
import com.hdkj.lt.bf.service.IndicatorDashboardService;
|
|
|
import com.hdkj.lt.bf.service.SeAlarmService;
|
|
|
import com.hdkj.lt.bf.service.SeIndicatorService;
|
|
|
+import com.hdkj.lt.bf.service.SeSnapshotService;
|
|
|
+import com.hdkj.lt.core.bizms.modle.dto.StateEstimation;
|
|
|
import com.hdkj.lt.core.mvc.BaseController;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
@@ -39,6 +48,8 @@ public class IndicatorController extends BaseController {
|
|
|
private final IndicatorDashboardService indicatorDashboardService;
|
|
|
private final SeIndicatorService seIndicatorService;
|
|
|
private final SeAlarmService seAlarmService;
|
|
|
+ private final SiStateEstimationClient siStateEstimationClient;
|
|
|
+ private final SeSnapshotService seSnapshotService;
|
|
|
|
|
|
/**
|
|
|
* 查询运行态仪表盘
|
|
|
@@ -106,14 +117,15 @@ public class IndicatorController extends BaseController {
|
|
|
/**
|
|
|
* 异常告警-线路重过载列表
|
|
|
*
|
|
|
- * @param params {id, type(2/3/4), feederName(可选), date(可选), orderBy(asc/desc,可选)}
|
|
|
+ * @param params {id, type(2/3/4), feederName(可选), startDate(可选), endDate(可选), orderBy(asc/desc,可选)}
|
|
|
*/
|
|
|
@PostMapping("/alarm/overload")
|
|
|
public ApiResponse<PageResult<SeAlarmListVO>> alarmOverload(@RequestBody Map<String, String> params) {
|
|
|
String id = params.get("id");
|
|
|
String type = params.get("type");
|
|
|
String feederName = params.get("feederName");
|
|
|
- String date = params.get("date");
|
|
|
+ String startDate = params.get("startDate");
|
|
|
+ String endDate = params.get("endDate");
|
|
|
String orderBy = params.get("orderBy");
|
|
|
String pageStr = params.get("page");
|
|
|
String pageSizeStr = params.get("pageSize");
|
|
|
@@ -122,20 +134,21 @@ public class IndicatorController extends BaseController {
|
|
|
}
|
|
|
Integer page = pageStr != null ? Integer.parseInt(pageStr) : 1;
|
|
|
Integer pageSize = pageSizeStr != null ? Integer.parseInt(pageSizeStr) : 20;
|
|
|
- return ApiResponse.success(seAlarmService.queryOverloadAlarmList(id, Integer.parseInt(type), feederName, date, orderBy, page, pageSize));
|
|
|
+ return ApiResponse.success(seAlarmService.queryOverloadAlarmList(id, Integer.parseInt(type), feederName, startDate, endDate, orderBy, page, pageSize));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 异常告警-电压越限列表
|
|
|
*
|
|
|
- * @param params {id, type(2/3/4), feederName(可选), date(可选), orderBy(asc/desc,可选)}
|
|
|
+ * @param params {id, type(2/3/4), feederName(可选), startDate(可选), endDate(可选), orderBy(asc/desc,可选)}
|
|
|
*/
|
|
|
@PostMapping("/alarm/voltage")
|
|
|
public ApiResponse<PageResult<SeAlarmListVO>> alarmVoltage(@RequestBody Map<String, String> params) {
|
|
|
String id = params.get("id");
|
|
|
String type = params.get("type");
|
|
|
String feederName = params.get("feederName");
|
|
|
- String date = params.get("date");
|
|
|
+ String startDate = params.get("startDate");
|
|
|
+ String endDate = params.get("endDate");
|
|
|
String orderBy = params.get("orderBy");
|
|
|
String pageStr = params.get("page");
|
|
|
String pageSizeStr = params.get("pageSize");
|
|
|
@@ -144,7 +157,7 @@ public class IndicatorController extends BaseController {
|
|
|
}
|
|
|
Integer page = pageStr != null ? Integer.parseInt(pageStr) : 1;
|
|
|
Integer pageSize = pageSizeStr != null ? Integer.parseInt(pageSizeStr) : 20;
|
|
|
- return ApiResponse.success(seAlarmService.queryVoltageAlarmList(id, Integer.parseInt(type), feederName, date, orderBy, page, pageSize));
|
|
|
+ return ApiResponse.success(seAlarmService.queryVoltageAlarmList(id, Integer.parseInt(type), feederName, startDate, endDate, orderBy, page, pageSize));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -175,4 +188,98 @@ public class IndicatorController extends BaseController {
|
|
|
}
|
|
|
return ApiResponse.success(seAlarmService.queryFeederList(id, Integer.parseInt(type)));
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 手动触发状估断面拉取
|
|
|
+ * <p>
|
|
|
+ * 按县域调 SI queryEquipByCounty 拉取最新状估数据,聚合后送入 processSnapshot 解析。
|
|
|
+ * 传 snapTime 时启用覆盖更新:先删该断面时刻存量明细再重新写入。
|
|
|
+ *
|
|
|
+ * @param params {snapTime(可选, yyyy-MM-dd HH:mm:ss),传值时覆盖更新}
|
|
|
+ */
|
|
|
+ @PostMapping("/snapshot/manual")
|
|
|
+ public ApiResponse<String> manualSnapshot(@RequestBody Map<String, String> params) {
|
|
|
+ String snapTimeStr = params.get("snapTime");
|
|
|
+ boolean overwrite = StringUtils.isNotBlank(snapTimeStr);
|
|
|
+
|
|
|
+ log.info("手动状估拉取开始 overwrite={}", overwrite);
|
|
|
+ int successCount = 0;
|
|
|
+ List<String> errors = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Map.Entry<String, String[]> county : SeSnapshotConstants.COUNTIES) {
|
|
|
+ String maintOrg = county.getKey();
|
|
|
+ String countyName = county.getValue()[1];
|
|
|
+ try {
|
|
|
+ MaintOrgRequest request = new MaintOrgRequest();
|
|
|
+ request.setMaintOrg(maintOrg);
|
|
|
+
|
|
|
+ ApiResponse<List<StateEstimation>> resp = siStateEstimationClient.queryEquipByCounty(request);
|
|
|
+ if (resp == null || !resp.isSuccess() || resp.getData() == null || resp.getData().isEmpty()) {
|
|
|
+ errors.add(countyName + "无数据");
|
|
|
+ log.warn("手动状估拉取 县域{} 无数据, resp={}", countyName, resp != null ? resp.isSuccess() : "null");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ StateEstimation merged = mergeCountyResults(resp.getData());
|
|
|
+ if (merged == null) {
|
|
|
+ errors.add(countyName + "聚合后无数据");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ String json = JSON.toJSONString(merged);
|
|
|
+ if (overwrite) {
|
|
|
+ seSnapshotService.processSnapshotOverwrite(json);
|
|
|
+ } else {
|
|
|
+ seSnapshotService.processSnapshot(json);
|
|
|
+ }
|
|
|
+ successCount++;
|
|
|
+ log.info("手动状估拉取完成 county={}, pointTime={}", countyName, merged.getPointTime());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("手动状估拉取异常 county={}", countyName, e);
|
|
|
+ errors.add(countyName + "异常:" + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ StringBuilder msg = new StringBuilder();
|
|
|
+ msg.append("成功处理").append(successCount).append("个县域");
|
|
|
+ if (!errors.isEmpty()) {
|
|
|
+ msg.append(",").append(errors.size()).append("个异常:").append(String.join("; ", errors));
|
|
|
+ }
|
|
|
+ return ApiResponse.success(msg.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ private StateEstimation mergeCountyResults(List<StateEstimation> list) {
|
|
|
+ if (list == null || list.isEmpty()) return null;
|
|
|
+
|
|
|
+ StateEstimation merged = new StateEstimation();
|
|
|
+ List<StateEstimation.StateEstimationCommonResult> allFeeders = new ArrayList<>();
|
|
|
+ List<StateEstimation.StateEstimationTransResult> allMvtrans = new ArrayList<>();
|
|
|
+ List<StateEstimation.StateEstimationSwitchResult> allSwitches = new ArrayList<>();
|
|
|
+ List<StateEstimation.StateEstimationCommonResult> allEquips = new ArrayList<>();
|
|
|
+ List<StateEstimation.StateEstimationSegmentResult> allSegments = new ArrayList<>();
|
|
|
+ List<String> pointTime = null;
|
|
|
+
|
|
|
+ for (StateEstimation se : list) {
|
|
|
+ if (se == null) continue;
|
|
|
+ if (pointTime == null && se.getPointTime() != null) pointTime = se.getPointTime();
|
|
|
+ if (se.getPeriodFeederSeResult() != null) allFeeders.addAll(se.getPeriodFeederSeResult());
|
|
|
+ if (se.getPeriodMVTransSeResult() != null) allMvtrans.addAll(se.getPeriodMVTransSeResult());
|
|
|
+ if (se.getPeriodSwitchSeResult() != null) allSwitches.addAll(se.getPeriodSwitchSeResult());
|
|
|
+ if (se.getPeriodEquipResult() != null) allEquips.addAll(se.getPeriodEquipResult());
|
|
|
+ if (se.getPeriodSegmentSeResult() != null) allSegments.addAll(se.getPeriodSegmentSeResult());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (allFeeders.isEmpty() && allMvtrans.isEmpty()) {
|
|
|
+ log.warn("手动状估拉取 聚合后无任何数据");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ merged.setPeriodFeederSeResult(allFeeders);
|
|
|
+ merged.setPeriodMVTransSeResult(allMvtrans);
|
|
|
+ merged.setPeriodSwitchSeResult(allSwitches);
|
|
|
+ merged.setPeriodEquipResult(allEquips);
|
|
|
+ merged.setPeriodSegmentSeResult(allSegments);
|
|
|
+ merged.setPointTime(pointTime);
|
|
|
+ return merged;
|
|
|
+ }
|
|
|
}
|