修改设备监控电表类型设备曲线不展示问题
This commit is contained in:
@ -1,9 +1,10 @@
|
|||||||
package com.xzzn.ems.domain.vo;
|
package com.xzzn.ems.domain.vo;
|
||||||
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备列表-点位详情-入参
|
* 设备列表-点位详情-入参
|
||||||
*
|
*
|
||||||
@ -24,6 +25,8 @@ public class PointDataRequest {
|
|||||||
private String dataPointName;
|
private String dataPointName;
|
||||||
/** 点位-模糊查询 */
|
/** 点位-模糊查询 */
|
||||||
private String dataPoint;
|
private String dataPoint;
|
||||||
|
/** 点位匹配字段 */
|
||||||
|
private String matchField;
|
||||||
/** 点位数据-范围上下限 */
|
/** 点位数据-范围上下限 */
|
||||||
private BigDecimal lower;
|
private BigDecimal lower;
|
||||||
private BigDecimal upper;
|
private BigDecimal upper;
|
||||||
@ -126,6 +129,14 @@ public class PointDataRequest {
|
|||||||
this.dataPoint = dataPoint;
|
this.dataPoint = dataPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMatchField() {
|
||||||
|
return matchField;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMatchField(String matchField) {
|
||||||
|
this.matchField = matchField;
|
||||||
|
}
|
||||||
|
|
||||||
public BigDecimal getLower() {
|
public BigDecimal getLower() {
|
||||||
return lower;
|
return lower;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,10 @@ public class PointQueryResponse
|
|||||||
@Excel(name = "点位名称")
|
@Excel(name = "点位名称")
|
||||||
private String pointName;
|
private String pointName;
|
||||||
|
|
||||||
|
/** 点位匹配字段 */
|
||||||
|
@Excel(name = "点位匹配字段")
|
||||||
|
private String matchField;
|
||||||
|
|
||||||
/** 数据点位 */
|
/** 数据点位 */
|
||||||
@Excel(name = "数据点位")
|
@Excel(name = "数据点位")
|
||||||
private String dataPoint;
|
private String dataPoint;
|
||||||
@ -110,6 +114,14 @@ public class PointQueryResponse
|
|||||||
this.pointName = pointName;
|
this.pointName = pointName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMatchField() {
|
||||||
|
return matchField;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMatchField(String matchField) {
|
||||||
|
this.matchField = matchField;
|
||||||
|
}
|
||||||
|
|
||||||
public String getDataUnit() {
|
public String getDataUnit() {
|
||||||
return dataUnit;
|
return dataUnit;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,7 +75,8 @@ public interface EmsPointMatchMapper
|
|||||||
|
|
||||||
// 获取匹配信息
|
// 获取匹配信息
|
||||||
public List<EmsPointMatch> getMatchInfo(@Param("siteIds") List<String> siteIds,
|
public List<EmsPointMatch> getMatchInfo(@Param("siteIds") List<String> siteIds,
|
||||||
@Param("deviceCategory")String deviceCategory,
|
@Param("deviceId") String deviceId,
|
||||||
|
@Param("deviceCategory") String deviceCategory,
|
||||||
@Param("pointName") String pointName);
|
@Param("pointName") String pointName);
|
||||||
// 根据条件查询数据-按分钟-单体电池特殊处理
|
// 根据条件查询数据-按分钟-单体电池特殊处理
|
||||||
public List<GeneralQueryDataVo> getBatteryPointDataByMinutes(@Param("siteIds")List<String> siteIds,
|
public List<GeneralQueryDataVo> getBatteryPointDataByMinutes(@Param("siteIds")List<String> siteIds,
|
||||||
|
|||||||
@ -3,13 +3,15 @@ package com.xzzn.ems.service.impl;
|
|||||||
import com.xzzn.common.enums.DeviceCategory;
|
import com.xzzn.common.enums.DeviceCategory;
|
||||||
import com.xzzn.common.utils.DateUtils;
|
import com.xzzn.common.utils.DateUtils;
|
||||||
import com.xzzn.ems.domain.EmsPointMatch;
|
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.EmsBatteryDataMonthMapper;
|
||||||
import com.xzzn.ems.mapper.EmsDevicesSettingMapper;
|
import com.xzzn.ems.mapper.EmsDevicesSettingMapper;
|
||||||
import com.xzzn.ems.mapper.EmsPointMatchMapper;
|
import com.xzzn.ems.mapper.EmsPointMatchMapper;
|
||||||
import com.xzzn.ems.service.IGeneralQueryService;
|
import com.xzzn.ems.service.IGeneralQueryService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
@ -17,10 +19,23 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.time.temporal.TemporalAdjusters;
|
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 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> querySiteIds = new ArrayList<>();
|
||||||
|
|
||||||
List<String> siteIds = request.getSiteIds();
|
List<String> siteIds = request.getSiteIds();
|
||||||
|
String deviceId = request.getDeviceId();
|
||||||
String deviceCategory = request.getDeviceCategory();
|
String deviceCategory = request.getDeviceCategory();
|
||||||
|
// 处理点位名称
|
||||||
|
String pointName = request.getPointName();
|
||||||
// 根据入参获取点位对应的表和字段
|
// 根据入参获取点位对应的表和字段
|
||||||
List<EmsPointMatch> matchInfo = emsPointMatchMapper.getMatchInfo(siteIds,deviceCategory,request.getPointName());
|
List<EmsPointMatch> matchInfo = emsPointMatchMapper.getMatchInfo(siteIds,deviceId,deviceCategory,pointName);
|
||||||
if (matchInfo == null || matchInfo.size() == 0) {
|
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;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
for (EmsPointMatch emsPointMatch : matchInfo) {
|
for (EmsPointMatch emsPointMatch : matchInfo) {
|
||||||
@ -107,9 +129,17 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// 不同的site_id根据设备类型和字段,默认取第一个匹配到的表和表字段只会有一个,
|
// 不同的site_id根据设备类型和字段,默认取第一个匹配到的表和表字段只会有一个,
|
||||||
String tableName = matchInfo.get(0).getMatchTable();
|
EmsPointMatch pointMatch = matchInfo.get(0);
|
||||||
String tableField = matchInfo.get(0).getMatchField();
|
String finalPointName = pointName;
|
||||||
Long dataType = matchInfo.get(0).getDataType();
|
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)) {
|
if (DeviceCategory.BATTERY.getCode().equals(deviceCategory)) {
|
||||||
// 单体电池数据特殊处理
|
// 单体电池数据特殊处理
|
||||||
result = generalQueryBatteryData(querySiteIds,tableName,tableField,request,deviceCategory,dataType);
|
result = generalQueryBatteryData(querySiteIds,tableName,tableField,request,deviceCategory,dataType);
|
||||||
@ -123,6 +153,29 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService
|
|||||||
return result;
|
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,
|
private List<GeneralQueryResponse> generalQueryCommonData(List<String> querySiteIds, String tableName,
|
||||||
String tableField, PointNameRequest request,
|
String tableField, PointNameRequest request,
|
||||||
String deviceCategory, Long dataType) throws ParseException {
|
String deviceCategory, Long dataType) throws ParseException {
|
||||||
|
|||||||
@ -178,6 +178,7 @@
|
|||||||
t.match_field as matchField,
|
t.match_field as matchField,
|
||||||
t.device_category as deviceCategory,
|
t.device_category as deviceCategory,
|
||||||
t.point_name as pointName,
|
t.point_name as pointName,
|
||||||
|
t.data_point_name as dataPointName,
|
||||||
t.data_type as dataType
|
t.data_type as dataType
|
||||||
from ems_point_match t
|
from ems_point_match t
|
||||||
where 1=1
|
where 1=1
|
||||||
@ -190,8 +191,11 @@
|
|||||||
<if test="deviceCategory != null and deviceCategory != ''">
|
<if test="deviceCategory != null and deviceCategory != ''">
|
||||||
and t.device_category = #{deviceCategory}
|
and t.device_category = #{deviceCategory}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="deviceId != null and deviceId != ''">
|
||||||
|
and t.device_id = #{deviceId}
|
||||||
|
</if>
|
||||||
<if test="pointName != null and pointName != ''">
|
<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>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@ -423,6 +427,7 @@
|
|||||||
t.data_point as dataPoint,
|
t.data_point as dataPoint,
|
||||||
t.data_point_name as dataPointName,
|
t.data_point_name as dataPointName,
|
||||||
t.data_device as dataDevice,
|
t.data_device as dataDevice,
|
||||||
|
t.match_field as matchField,
|
||||||
t.need_diff_device_id as isNeedDeviceId,
|
t.need_diff_device_id as isNeedDeviceId,
|
||||||
t.data_unit as dataUnit,
|
t.data_unit as dataUnit,
|
||||||
t.ip_address as ipAddress,
|
t.ip_address as ipAddress,
|
||||||
@ -459,6 +464,7 @@
|
|||||||
SELECT tmp.pointName,
|
SELECT tmp.pointName,
|
||||||
tmp.dataPoint,
|
tmp.dataPoint,
|
||||||
tmp.dataDevice,
|
tmp.dataDevice,
|
||||||
|
tmp.matchField,
|
||||||
tmp.dataPointName,
|
tmp.dataPointName,
|
||||||
tmp.dataUnit,
|
tmp.dataUnit,
|
||||||
tmp.ipAddress,
|
tmp.ipAddress,
|
||||||
@ -469,6 +475,7 @@
|
|||||||
when t.need_diff_device_id = 1 and t.data_device = 'BMSD' then concat(#{parentDeviceId}, t.data_point)
|
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,
|
else t.data_point end as dataPoint,
|
||||||
t.data_point_name as dataPointName,
|
t.data_point_name as dataPointName,
|
||||||
|
t.match_field as matchField,
|
||||||
t.data_device as dataDevice,
|
t.data_device as dataDevice,
|
||||||
t.data_unit as dataUnit,
|
t.data_unit as dataUnit,
|
||||||
t.ip_address as ipAddress,
|
t.ip_address as ipAddress,
|
||||||
|
|||||||
Reference in New Issue
Block a user