|
@@ -8,6 +8,8 @@ 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.common.SeMonitorThreshold;
|
|
import com.hdkj.lt.bf.common.SeMonitorThreshold;
|
|
|
import com.hdkj.lt.bf.common.SeSnapshotConstants;
|
|
import com.hdkj.lt.bf.common.SeSnapshotConstants;
|
|
|
|
|
+import com.hdkj.lt.bf.entity.DwdShbDsCableSegmentBase;
|
|
|
|
|
+import com.hdkj.lt.bf.entity.DwdShbDsSpanSegmentBase;
|
|
|
import com.hdkj.lt.bf.entity.DwdShbDsTransformerBase;
|
|
import com.hdkj.lt.bf.entity.DwdShbDsTransformerBase;
|
|
|
import com.hdkj.lt.bf.entity.FhzgSeCurrentEvent;
|
|
import com.hdkj.lt.bf.entity.FhzgSeCurrentEvent;
|
|
|
import com.hdkj.lt.bf.entity.FhzgSeLineLossDetail;
|
|
import com.hdkj.lt.bf.entity.FhzgSeLineLossDetail;
|
|
@@ -24,6 +26,8 @@ import com.hdkj.lt.bf.mapper.FhzgSeMonitorCurrentMapper;
|
|
|
import com.hdkj.lt.bf.mapper.FhzgSeMonitorVoltageMapper;
|
|
import com.hdkj.lt.bf.mapper.FhzgSeMonitorVoltageMapper;
|
|
|
import com.hdkj.lt.bf.mapper.FhzgSeSnapshotDetailMapper;
|
|
import com.hdkj.lt.bf.mapper.FhzgSeSnapshotDetailMapper;
|
|
|
import com.hdkj.lt.bf.mapper.FhzgSeVoltageEventMapper;
|
|
import com.hdkj.lt.bf.mapper.FhzgSeVoltageEventMapper;
|
|
|
|
|
+import com.hdkj.lt.bf.mapper.DwdShbDsCableSegmentBaseMapper;
|
|
|
|
|
+import com.hdkj.lt.bf.mapper.DwdShbDsSpanSegmentBaseMapper;
|
|
|
import com.hdkj.lt.bf.mapper.DwdShbDsTransformerBaseMapper;
|
|
import com.hdkj.lt.bf.mapper.DwdShbDsTransformerBaseMapper;
|
|
|
import com.hdkj.lt.bf.service.SeSnapshotService;
|
|
import com.hdkj.lt.bf.service.SeSnapshotService;
|
|
|
import com.hdkj.lt.core.bizms.modle.po.FeederTopo;
|
|
import com.hdkj.lt.core.bizms.modle.po.FeederTopo;
|
|
@@ -56,6 +60,8 @@ public class SeSnapshotServiceImpl implements SeSnapshotService {
|
|
|
private final ApplicationEventPublisher eventPublisher;
|
|
private final ApplicationEventPublisher eventPublisher;
|
|
|
private final FeederTopoMapper feederTopoMapper;
|
|
private final FeederTopoMapper feederTopoMapper;
|
|
|
private final FhzgSeLineLossDetailMapper lineLossDetailMapper;
|
|
private final FhzgSeLineLossDetailMapper lineLossDetailMapper;
|
|
|
|
|
+ private final DwdShbDsSpanSegmentBaseMapper spanSegmentMapper;
|
|
|
|
|
+ private final DwdShbDsCableSegmentBaseMapper cableSegmentMapper;
|
|
|
|
|
|
|
|
private static final DateTimeFormatter DT_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
private static final DateTimeFormatter DT_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
@@ -461,32 +467,41 @@ public class SeSnapshotServiceImpl implements SeSnapshotService {
|
|
|
* <p>
|
|
* <p>
|
|
|
* line_loss_kW = 3000 × I_kA² × r_Ω_per_km × (L_m / 1000)
|
|
* line_loss_kW = 3000 × I_kA² × r_Ω_per_km × (L_m / 1000)
|
|
|
* 电阻率: dxd(导线段)=0.4132Ω/km, 0201(电缆段)=0.313Ω/km
|
|
* 电阻率: dxd(导线段)=0.4132Ω/km, 0201(电缆段)=0.313Ω/km
|
|
|
- * 段长度从 t_feeder_topo.sb_length 取(单位:米)
|
|
|
|
|
|
|
+ * 段长度从 dwd_shb_ds_span_segment_base(导线段)/ dwd_shb_ds_cable_segment_base(电缆段)的 length 取(单位:米)
|
|
|
* SE 返回的 seoIs 为安培,先 /1000 换算成 kA
|
|
* SE 返回的 seoIs 为安培,先 /1000 换算成 kA
|
|
|
*/
|
|
*/
|
|
|
private void processSegmentsForLineLoss(JSONArray segments, LocalDateTime snapTime, Map<String, String[]> feederMap) {
|
|
private void processSegmentsForLineLoss(JSONArray segments, LocalDateTime snapTime, Map<String, String[]> feederMap) {
|
|
|
- // 1. 收集所有 psrId
|
|
|
|
|
- List<String> psrIds = new ArrayList<>();
|
|
|
|
|
- for (int i = 0; i < segments.size(); i++) {
|
|
|
|
|
- String psrId = segments.getJSONObject(i).getString("psrId");
|
|
|
|
|
- if (psrId != null) psrIds.add(psrId);
|
|
|
|
|
- }
|
|
|
|
|
- if (psrIds.isEmpty()) return;
|
|
|
|
|
-
|
|
|
|
|
- // 2. 批量查 topo 表取 sbLength
|
|
|
|
|
- Map<String, Double> lengthMap = new HashMap<>();
|
|
|
|
|
|
|
+ // 1. 按类型分组查段长度(档距段→span表,电缆段→cable表),过滤在运设备
|
|
|
|
|
+ Map<String, BigDecimal> lengthMap = new HashMap<>();
|
|
|
try {
|
|
try {
|
|
|
- List<FeederTopo> topoList = feederTopoMapper.selectList(
|
|
|
|
|
- new QueryWrapper<FeederTopo>()
|
|
|
|
|
- .in("psr_id", psrIds)
|
|
|
|
|
- .select("psr_id", "sb_length"));
|
|
|
|
|
- for (FeederTopo t : topoList) {
|
|
|
|
|
- if (t.getSbLength() != null) {
|
|
|
|
|
- lengthMap.put(t.getPsrId(), t.getSbLength());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ List<String> spanIds = new ArrayList<>();
|
|
|
|
|
+ List<String> cableIds = new ArrayList<>();
|
|
|
|
|
+ for (int i = 0; i < segments.size(); i++) {
|
|
|
|
|
+ JSONObject seg = segments.getJSONObject(i);
|
|
|
|
|
+ String pid = seg.getString("psrId");
|
|
|
|
|
+ String pt = seg.getString("psrType");
|
|
|
|
|
+ if (pid == null) continue;
|
|
|
|
|
+ if ("dxd".equals(pt)) spanIds.add(pid);
|
|
|
|
|
+ else if ("0201".equals(pt)) cableIds.add(pid);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!spanIds.isEmpty()) {
|
|
|
|
|
+ spanSegmentMapper.selectList(
|
|
|
|
|
+ new LambdaQueryWrapper<DwdShbDsSpanSegmentBase>()
|
|
|
|
|
+ .select(DwdShbDsSpanSegmentBase::getPsrId, DwdShbDsSpanSegmentBase::getLength)
|
|
|
|
|
+ .in(DwdShbDsSpanSegmentBase::getPsrId, spanIds)
|
|
|
|
|
+ .eq(DwdShbDsSpanSegmentBase::getPsrState, "20"))
|
|
|
|
|
+ .forEach(r -> { if (r.getLength() != null) lengthMap.put(r.getPsrId(), r.getLength()); });
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!cableIds.isEmpty()) {
|
|
|
|
|
+ cableSegmentMapper.selectList(
|
|
|
|
|
+ new LambdaQueryWrapper<DwdShbDsCableSegmentBase>()
|
|
|
|
|
+ .select(DwdShbDsCableSegmentBase::getPsrId, DwdShbDsCableSegmentBase::getLength)
|
|
|
|
|
+ .in(DwdShbDsCableSegmentBase::getPsrId, cableIds)
|
|
|
|
|
+ .eq(DwdShbDsCableSegmentBase::getPsrState, "20"))
|
|
|
|
|
+ .forEach(r -> { if (r.getLength() != null) lengthMap.put(r.getPsrId(), r.getLength()); });
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- log.warn("查询线路线损段长度失败", e);
|
|
|
|
|
|
|
+ log.warn("查询段长度失败", e);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 3. 逐段计算线损
|
|
// 3. 逐段计算线损
|
|
@@ -502,8 +517,8 @@ public class SeSnapshotServiceImpl implements SeSnapshotService {
|
|
|
BigDecimal current = firstValue(seg.getJSONArray("seoIs"));
|
|
BigDecimal current = firstValue(seg.getJSONArray("seoIs"));
|
|
|
if (current == null || current.compareTo(BigDecimal.ZERO) <= 0) continue;
|
|
if (current == null || current.compareTo(BigDecimal.ZERO) <= 0) continue;
|
|
|
|
|
|
|
|
- Double sbLength = lengthMap.get(psrId);
|
|
|
|
|
- if (sbLength == null || sbLength <= 0) continue;
|
|
|
|
|
|
|
+ BigDecimal sbLength = lengthMap.get(psrId);
|
|
|
|
|
+ if (sbLength == null || sbLength.compareTo(BigDecimal.ZERO) <= 0) continue;
|
|
|
|
|
|
|
|
// 电阻率
|
|
// 电阻率
|
|
|
BigDecimal resistivity;
|
|
BigDecimal resistivity;
|
|
@@ -520,7 +535,7 @@ public class SeSnapshotServiceImpl implements SeSnapshotService {
|
|
|
BigDecimal currentKa = current.divide(BigDecimal.valueOf(1000), 8, RoundingMode.HALF_UP);
|
|
BigDecimal currentKa = current.divide(BigDecimal.valueOf(1000), 8, RoundingMode.HALF_UP);
|
|
|
|
|
|
|
|
// 3000 × I_kA² × r × (L_m / 1000) = 3 × I_kA² × r × L_m
|
|
// 3000 × I_kA² × r × (L_m / 1000) = 3 × I_kA² × r × L_m
|
|
|
- BigDecimal lengthKm = BigDecimal.valueOf(sbLength / 1000.0);
|
|
|
|
|
|
|
+ BigDecimal lengthKm = sbLength.divide(BigDecimal.valueOf(1000), 8, RoundingMode.HALF_UP);
|
|
|
BigDecimal loss = BigDecimal.valueOf(3000)
|
|
BigDecimal loss = BigDecimal.valueOf(3000)
|
|
|
.multiply(currentKa.pow(2))
|
|
.multiply(currentKa.pow(2))
|
|
|
.multiply(resistivity)
|
|
.multiply(resistivity)
|
|
@@ -535,7 +550,7 @@ public class SeSnapshotServiceImpl implements SeSnapshotService {
|
|
|
.countyId(loc.length > 1 ? loc[1] : "")
|
|
.countyId(loc.length > 1 ? loc[1] : "")
|
|
|
.subsId(loc.length > 0 ? loc[0] : "")
|
|
.subsId(loc.length > 0 ? loc[0] : "")
|
|
|
.currentKa(currentKa)
|
|
.currentKa(currentKa)
|
|
|
- .sbLengthM(BigDecimal.valueOf(sbLength))
|
|
|
|
|
|
|
+ .sbLengthM(sbLength)
|
|
|
.resistivity(resistivity)
|
|
.resistivity(resistivity)
|
|
|
.lineLossKw(loss)
|
|
.lineLossKw(loss)
|
|
|
.createTime(now)
|
|
.createTime(now)
|
|
@@ -739,9 +754,10 @@ public class SeSnapshotServiceImpl implements SeSnapshotService {
|
|
|
Map<String, String> map = new HashMap<>();
|
|
Map<String, String> map = new HashMap<>();
|
|
|
try {
|
|
try {
|
|
|
List<DwdShbDsTransformerBase> rows = transformerBaseMapper.selectList(
|
|
List<DwdShbDsTransformerBase> rows = transformerBaseMapper.selectList(
|
|
|
- new LambdaQueryWrapper<DwdShbDsTransformerBase>()
|
|
|
|
|
- .in(DwdShbDsTransformerBase::getPsrId, ids)
|
|
|
|
|
- .isNotNull(DwdShbDsTransformerBase::getName));
|
|
|
|
|
|
|
+ new LambdaQueryWrapper<DwdShbDsTransformerBase>()
|
|
|
|
|
+ .in(DwdShbDsTransformerBase::getPsrId, ids)
|
|
|
|
|
+ .eq(DwdShbDsTransformerBase::getPsrState, "20")
|
|
|
|
|
+ .isNotNull(DwdShbDsTransformerBase::getName));
|
|
|
for (DwdShbDsTransformerBase row : rows) {
|
|
for (DwdShbDsTransformerBase row : rows) {
|
|
|
map.put(row.getPsrId(), row.getName());
|
|
map.put(row.getPsrId(), row.getName());
|
|
|
}
|
|
}
|