修改设备监控电表类型设备曲线不展示问题

This commit is contained in:
zq
2026-01-28 19:21:30 +08:00
parent 2b22b70baa
commit 8a44009c42
5 changed files with 97 additions and 13 deletions

View File

@ -1,9 +1,10 @@
package com.xzzn.ems.domain.vo;
import javax.validation.constraints.NotBlank;
import java.math.BigDecimal;
import javax.validation.constraints.NotBlank;
/**
* 设备列表-点位详情-入参
*
@ -24,6 +25,8 @@ public class PointDataRequest {
private String dataPointName;
/** 点位-模糊查询 */
private String dataPoint;
/** 点位匹配字段 */
private String matchField;
/** 点位数据-范围上下限 */
private BigDecimal lower;
private BigDecimal upper;
@ -126,6 +129,14 @@ public class PointDataRequest {
this.dataPoint = dataPoint;
}
public String getMatchField() {
return matchField;
}
public void setMatchField(String matchField) {
this.matchField = matchField;
}
public BigDecimal getLower() {
return lower;
}

View File

@ -14,6 +14,10 @@ public class PointQueryResponse
@Excel(name = "点位名称")
private String pointName;
/** 点位匹配字段 */
@Excel(name = "点位匹配字段")
private String matchField;
/** 数据点位 */
@Excel(name = "数据点位")
private String dataPoint;
@ -110,6 +114,14 @@ public class PointQueryResponse
this.pointName = pointName;
}
public String getMatchField() {
return matchField;
}
public void setMatchField(String matchField) {
this.matchField = matchField;
}
public String getDataUnit() {
return dataUnit;
}

View File

@ -75,6 +75,7 @@ public interface EmsPointMatchMapper
// 获取匹配信息
public List<EmsPointMatch> getMatchInfo(@Param("siteIds") List<String> siteIds,
@Param("deviceId") String deviceId,
@Param("deviceCategory") String deviceCategory,
@Param("pointName") String pointName);
// 根据条件查询数据-按分钟-单体电池特殊处理

View File

@ -3,13 +3,15 @@ package com.xzzn.ems.service.impl;
import com.xzzn.common.enums.DeviceCategory;
import com.xzzn.common.utils.DateUtils;
import com.xzzn.ems.domain.EmsPointMatch;
import com.xzzn.ems.domain.vo.*;
import com.xzzn.ems.domain.vo.DevicePointDataList;
import com.xzzn.ems.domain.vo.GeneralQueryDataVo;
import com.xzzn.ems.domain.vo.GeneralQueryResponse;
import com.xzzn.ems.domain.vo.PointNameRequest;
import com.xzzn.ems.domain.vo.SiteBatteryListVo;
import com.xzzn.ems.mapper.EmsBatteryDataMonthMapper;
import com.xzzn.ems.mapper.EmsDevicesSettingMapper;
import com.xzzn.ems.mapper.EmsPointMatchMapper;
import com.xzzn.ems.service.IGeneralQueryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.ParseException;
@ -17,10 +19,23 @@ import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.stream.Collectors;
import javax.lang.model.util.ElementScanner6;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
/**
* 综合查询 服务层实现
@ -85,10 +100,17 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService
List<String> querySiteIds = new ArrayList<>();
List<String> siteIds = request.getSiteIds();
String deviceId = request.getDeviceId();
String deviceCategory = request.getDeviceCategory();
// 处理点位名称
String pointName = request.getPointName();
// 根据入参获取点位对应的表和字段
List<EmsPointMatch> matchInfo = emsPointMatchMapper.getMatchInfo(siteIds,deviceCategory,request.getPointName());
if (matchInfo == null || matchInfo.size() == 0) {
List<EmsPointMatch> matchInfo = emsPointMatchMapper.getMatchInfo(siteIds,deviceId,deviceCategory,pointName);
if (CollectionUtils.isEmpty(matchInfo) && DeviceCategory.AMMETER.getCode().equals(deviceCategory)) {
pointName = processPointName(pointName);
matchInfo = emsPointMatchMapper.getMatchInfo(siteIds,deviceId,deviceCategory,pointName);
}
if (CollectionUtils.isEmpty(matchInfo)) {
return result;
} else {
for (EmsPointMatch emsPointMatch : matchInfo) {
@ -107,9 +129,17 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService
try {
// 不同的site_id根据设备类型和字段默认取第一个匹配到的表和表字段只会有一个
String tableName = matchInfo.get(0).getMatchTable();
String tableField = matchInfo.get(0).getMatchField();
Long dataType = matchInfo.get(0).getDataType();
EmsPointMatch pointMatch = matchInfo.get(0);
String finalPointName = pointName;
Optional<EmsPointMatch> emsPointMatch = matchInfo.stream()
.filter(item -> finalPointName.equals(item.getPointName()) || finalPointName.equals(item.getDataPointName()))
.findFirst();
if (emsPointMatch.isPresent()) {
pointMatch = emsPointMatch.get();
}
String tableName = pointMatch.getMatchTable();
String tableField = pointMatch.getMatchField();
Long dataType = pointMatch.getDataType();
if (DeviceCategory.BATTERY.getCode().equals(deviceCategory)) {
// 单体电池数据特殊处理
result = generalQueryBatteryData(querySiteIds,tableName,tableField,request,deviceCategory,dataType);
@ -123,6 +153,29 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService
return result;
}
private String processPointName(String pointName) {
// 特殊处理
if ("正向有功电能".equals(pointName)) {
pointName = "当前正向总有功电能";
}
if ("反向有功电能".equals(pointName)) {
pointName = "当前反向总有功电能";
}
if ("正向无功电能".equals(pointName)) {
pointName = "当前正向总无功电能";
}
if ("反向无功电能".equals(pointName)) {
pointName = "当前反向总无功电能";
}
if ("有功功率".equals(pointName)) {
pointName = "功率";
}
if ("无功功率".equals(pointName)) {
pointName = "总无功功率";
}
return pointName;
}
private List<GeneralQueryResponse> generalQueryCommonData(List<String> querySiteIds, String tableName,
String tableField, PointNameRequest request,
String deviceCategory, Long dataType) throws ParseException {

View File

@ -178,6 +178,7 @@
t.match_field as matchField,
t.device_category as deviceCategory,
t.point_name as pointName,
t.data_point_name as dataPointName,
t.data_type as dataType
from ems_point_match t
where 1=1
@ -190,8 +191,11 @@
<if test="deviceCategory != null and deviceCategory != ''">
and t.device_category = #{deviceCategory}
</if>
<if test="deviceId != null and deviceId != ''">
and t.device_id = #{deviceId}
</if>
<if test="pointName != null and pointName != ''">
and t.point_name like concat('%', #{pointName}, '%')
and (t.point_name like concat('%', #{pointName}, '%') or t.data_point_name like concat('%', #{pointName}, '%'))
</if>
</select>
@ -423,6 +427,7 @@
t.data_point as dataPoint,
t.data_point_name as dataPointName,
t.data_device as dataDevice,
t.match_field as matchField,
t.need_diff_device_id as isNeedDeviceId,
t.data_unit as dataUnit,
t.ip_address as ipAddress,
@ -459,6 +464,7 @@
SELECT tmp.pointName,
tmp.dataPoint,
tmp.dataDevice,
tmp.matchField,
tmp.dataPointName,
tmp.dataUnit,
tmp.ipAddress,
@ -469,6 +475,7 @@
when t.need_diff_device_id = 1 and t.data_device = 'BMSD' then concat(#{parentDeviceId}, t.data_point)
else t.data_point end as dataPoint,
t.data_point_name as dataPointName,
t.match_field as matchField,
t.data_device as dataDevice,
t.data_unit as dataUnit,
t.ip_address as ipAddress,