From 8a44009c42ac00be4adddd8c75cad4fb4fe3392d Mon Sep 17 00:00:00 2001 From: zq Date: Wed, 28 Jan 2026 19:21:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=BE=E5=A4=87=E7=9B=91?= =?UTF-8?q?=E6=8E=A7=E7=94=B5=E8=A1=A8=E7=B1=BB=E5=9E=8B=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E6=9B=B2=E7=BA=BF=E4=B8=8D=E5=B1=95=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/ems/domain/vo/PointDataRequest.java | 13 +++- .../ems/domain/vo/PointQueryResponse.java | 12 +++ .../xzzn/ems/mapper/EmsPointMatchMapper.java | 3 +- .../service/impl/GeneralQueryServiceImpl.java | 73 ++++++++++++++++--- .../mapper/ems/EmsPointMatchMapper.xml | 9 ++- 5 files changed, 97 insertions(+), 13 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataRequest.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataRequest.java index dcfffc4..0ec198f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataRequest.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataRequest.java @@ -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; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointQueryResponse.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointQueryResponse.java index ec8b249..7ab0445 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointQueryResponse.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointQueryResponse.java @@ -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; } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java index 0a9e0cf..ee94d2d 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java @@ -75,7 +75,8 @@ public interface EmsPointMatchMapper // 获取匹配信息 public List getMatchInfo(@Param("siteIds") List siteIds, - @Param("deviceCategory")String deviceCategory, + @Param("deviceId") String deviceId, + @Param("deviceCategory") String deviceCategory, @Param("pointName") String pointName); // 根据条件查询数据-按分钟-单体电池特殊处理 public List getBatteryPointDataByMinutes(@Param("siteIds")List siteIds, diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java index 70b2170..5df0d62 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java @@ -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 querySiteIds = new ArrayList<>(); List siteIds = request.getSiteIds(); + String deviceId = request.getDeviceId(); String deviceCategory = request.getDeviceCategory(); + // 处理点位名称 + String pointName = request.getPointName(); // 根据入参获取点位对应的表和字段 - List matchInfo = emsPointMatchMapper.getMatchInfo(siteIds,deviceCategory,request.getPointName()); - if (matchInfo == null || matchInfo.size() == 0) { + List 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 = 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 generalQueryCommonData(List querySiteIds, String tableName, String tableField, PointNameRequest request, String deviceCategory, Long dataType) throws ParseException { diff --git a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml index 6abab7a..e0b49ee 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml @@ -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 @@ and t.device_category = #{deviceCategory} + + and t.device_id = #{deviceId} + - and t.point_name like concat('%', #{pointName}, '%') + and (t.point_name like concat('%', #{pointName}, '%') or t.data_point_name like concat('%', #{pointName}, '%')) @@ -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,