|
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.hdkj.lt.bf.application.FeederGroupApplication;
|
|
import com.hdkj.lt.bf.application.FeederGroupApplication;
|
|
|
import com.hdkj.lt.bf.entity.FhzgSeCurrentEvent;
|
|
import com.hdkj.lt.bf.entity.FhzgSeCurrentEvent;
|
|
|
import com.hdkj.lt.bf.entity.FhzgSeLineLossRate;
|
|
import com.hdkj.lt.bf.entity.FhzgSeLineLossRate;
|
|
|
|
|
+import com.hdkj.lt.bf.entity.FhzgSeLineLossDaily;
|
|
|
import com.hdkj.lt.bf.entity.FhzgDwmVoltageOverLimitDaily;
|
|
import com.hdkj.lt.bf.entity.FhzgDwmVoltageOverLimitDaily;
|
|
|
import com.hdkj.lt.bf.entity.FhzgSeCapacityDaily;
|
|
import com.hdkj.lt.bf.entity.FhzgSeCapacityDaily;
|
|
|
import com.hdkj.lt.bf.entity.FhzgSeVoltageEvent;
|
|
import com.hdkj.lt.bf.entity.FhzgSeVoltageEvent;
|
|
@@ -19,6 +20,7 @@ import com.hdkj.lt.bf.entity.vo.SeVoltageDashboardVO;
|
|
|
import com.hdkj.lt.bf.entity.vo.SeVoltageIndexVO;
|
|
import com.hdkj.lt.bf.entity.vo.SeVoltageIndexVO;
|
|
|
import com.hdkj.lt.bf.mapper.FhzgSeCurrentEventMapper;
|
|
import com.hdkj.lt.bf.mapper.FhzgSeCurrentEventMapper;
|
|
|
import com.hdkj.lt.bf.mapper.FhzgSeLineLossRateMapper;
|
|
import com.hdkj.lt.bf.mapper.FhzgSeLineLossRateMapper;
|
|
|
|
|
+import com.hdkj.lt.bf.mapper.FhzgSeLineLossDailyMapper;
|
|
|
import com.hdkj.lt.bf.mapper.FhzgDwmVoltageOverLimitDailyMapper;
|
|
import com.hdkj.lt.bf.mapper.FhzgDwmVoltageOverLimitDailyMapper;
|
|
|
import com.hdkj.lt.bf.mapper.FhzgSeCapacityDailyMapper;
|
|
import com.hdkj.lt.bf.mapper.FhzgSeCapacityDailyMapper;
|
|
|
import com.hdkj.lt.bf.mapper.FhzgSeVoltageEventMapper;
|
|
import com.hdkj.lt.bf.mapper.FhzgSeVoltageEventMapper;
|
|
@@ -62,6 +64,7 @@ public class SeIndicatorServiceImpl implements SeIndicatorService {
|
|
|
private final FhzgSeConsumerCountDailyMapper consumerCountDailyMapper;
|
|
private final FhzgSeConsumerCountDailyMapper consumerCountDailyMapper;
|
|
|
private final FhzgSeConsumerRelationMapper consumerRelationMapper;
|
|
private final FhzgSeConsumerRelationMapper consumerRelationMapper;
|
|
|
private final FhzgSeLineLossRateMapper lineLossRateMapper;
|
|
private final FhzgSeLineLossRateMapper lineLossRateMapper;
|
|
|
|
|
+ private final FhzgSeLineLossDailyMapper lineLossDailyMapper;
|
|
|
private final FeederGroupApplication feederGroupApplication;
|
|
private final FeederGroupApplication feederGroupApplication;
|
|
|
|
|
|
|
|
private static final DateTimeFormatter DATE_FMT = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
private static final DateTimeFormatter DATE_FMT = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
@@ -560,8 +563,9 @@ public class SeIndicatorServiceImpl implements SeIndicatorService {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 线损率(独立接口,从供电能力拆出):
|
|
* 线损率(独立接口,从供电能力拆出):
|
|
|
- * 按区间从 fhzg_se_line_loss_rate 加权平均(Σ线损功率 / Σ总功率 × 100)。
|
|
|
|
|
- * today → 今日 0 点至今;month → 月初至今;year → 年初至今。
|
|
|
|
|
|
|
+ * today → 断面表 fhzg_se_line_loss_rate 加权平均(Σ线损功率/Σ总功率×100,今日 0 点至今);
|
|
|
|
|
+ * month/year → 中台日汇总表 ads_grid_tqxs_line_tq_loss_daily_result(T-2,DI 同步本地表 fhzg_se_line_loss_daily_result),
|
|
|
|
|
+ * 按 dim_level+维度id+stat_date 区间聚合,线损率 = Σsum_power_loss/Σsum_power_sup×100(电量加权)。
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public SeLineLossRateVO queryLineLoss(String id, Integer type, String timeScope) {
|
|
public SeLineLossRateVO queryLineLoss(String id, Integer type, String timeScope) {
|
|
@@ -569,9 +573,9 @@ public class SeIndicatorServiceImpl implements SeIndicatorService {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // TODO 历史线损(month/year):取中台线损日汇总表(建设中,未接入),暂不返回
|
|
|
|
|
|
|
+ // 历史(month/year):查中台日汇总表(电量加权)
|
|
|
if (!"today".equalsIgnoreCase(timeScope)) {
|
|
if (!"today".equalsIgnoreCase(timeScope)) {
|
|
|
- return null;
|
|
|
|
|
|
|
+ return queryLineLossHistory(id, type, timeScope);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
LocalDateTime startTime = LocalDate.now().atStartOfDay();
|
|
LocalDateTime startTime = LocalDate.now().atStartOfDay();
|
|
@@ -602,6 +606,47 @@ public class SeIndicatorServiceImpl implements SeIndicatorService {
|
|
|
return SeLineLossRateVO.builder().lineLossRate(rate).build();
|
|
return SeLineLossRateVO.builder().lineLossRate(rate).build();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 历史线损率(month/year):中台日汇总表(DI 同步本地表 fhzg_se_line_loss_daily_result)
|
|
|
|
|
+ * <p>
|
|
|
|
|
+ * 分层分级过滤:dim_level 三档 —— type=2 county → org_id;type=3 substation → substation_id;type=4 feeder → feeder_id。
|
|
|
|
|
+ * 时间窗:month → stat_date >= 月初(yyyymmdd);year → stat_date >= 年初(yyyymmdd);至昨日(中台 T-2 数据)。
|
|
|
|
|
+ * 计算:线损率 = SUM(sum_power_loss)/SUM(sum_power_sup)×100(电量加权,不能 AVG 日线损率)。
|
|
|
|
|
+ */
|
|
|
|
|
+ private SeLineLossRateVO queryLineLossHistory(String id, Integer type, String timeScope) {
|
|
|
|
|
+ String startDate;
|
|
|
|
|
+ if ("month".equalsIgnoreCase(timeScope)) {
|
|
|
|
|
+ startDate = LocalDate.now().withDayOfMonth(1).format(DATE_FMT);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ startDate = LocalDate.now().withDayOfMonth(1).withMonth(1).format(DATE_FMT);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ QueryWrapper<FhzgSeLineLossDaily> qw = new QueryWrapper<>();
|
|
|
|
|
+ qw.select("COALESCE(SUM(sum_power_loss), 0) AS total_loss",
|
|
|
|
|
+ "COALESCE(SUM(sum_power_sup), 0) AS total_power")
|
|
|
|
|
+ .eq("dim_level", resolveDimLevel(type))
|
|
|
|
|
+ .ge("stat_date", startDate)
|
|
|
|
|
+ .le("stat_date", LocalDate.now().minusDays(1).format(DATE_FMT));
|
|
|
|
|
+ if (type == 2) {
|
|
|
|
|
+ qw.eq("org_id", id);
|
|
|
|
|
+ } else if (type == 3) {
|
|
|
|
|
+ qw.eq("substation_id", id);
|
|
|
|
|
+ } else if (type == 4) {
|
|
|
|
|
+ qw.eq("feeder_id", id);
|
|
|
|
|
+ }
|
|
|
|
|
+ List<Map<String, Object>> rows = lineLossDailyMapper.selectMaps(qw);
|
|
|
|
|
+ if (rows == null || rows.isEmpty() || rows.get(0).get("total_power") == null
|
|
|
|
|
+ || new BigDecimal(rows.get(0).get("total_power").toString()).compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
|
|
+ return SeLineLossRateVO.builder().lineLossRate(BigDecimal.ZERO).build();
|
|
|
|
|
+ }
|
|
|
|
|
+ BigDecimal totalLoss = new BigDecimal(rows.get(0).get("total_loss").toString());
|
|
|
|
|
+ BigDecimal totalPower = new BigDecimal(rows.get(0).get("total_power").toString());
|
|
|
|
|
+ BigDecimal rate = totalLoss.multiply(BigDecimal.valueOf(100))
|
|
|
|
|
+ .divide(totalPower, 2, RoundingMode.HALF_UP);
|
|
|
|
|
+
|
|
|
|
|
+ return SeLineLossRateVO.builder().lineLossRate(rate).build();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 构建馈线今日96点时序(负载率+电流+电压+有功+无功)
|
|
* 构建馈线今日96点时序(负载率+电流+电压+有功+无功)
|
|
|
*/
|
|
*/
|