fix(data-service): 修复相位判断逻辑并优化数据查询配置

- 统一将相位判断条件从"M"改为"T"
- 修正CT/PT变比计算逻辑,增加二次变比处理
- 移除废弃的闪变数据过滤逻辑
- 更新InfluxDB数据表名和字段名配置
- 修改服务接口参数传递方式
- 优化相位数据显示逻辑,统一相位标识处理
This commit is contained in:
xy
2026-05-20 09:26:05 +08:00
parent 16724d7d79
commit a82ea6b217
14 changed files with 65 additions and 81 deletions

View File

@@ -7,12 +7,8 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.param.DeviceMessageParam;
import com.njcn.csdevice.pojo.param.DataArrayParam;
import com.njcn.csdevice.pojo.po.CsDataArray;
import com.njcn.csdevice.pojo.vo.DataArrayTreeVO;
import com.njcn.csdevice.pojo.vo.DeviceManagerDetailVO;
import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.service.DeviceMessageService;
import com.njcn.csdevice.service.ICsDataArrayService;
import com.njcn.user.pojo.po.User;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
@@ -22,7 +18,6 @@ import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
@@ -47,8 +42,8 @@ public class DeviceMessageController extends BaseController {
@PostMapping("/getEventUserByDeviceId")
@ApiOperation("根据设备获取需要推送的用户id")
@ApiImplicitParams({
@ApiImplicitParam(name = "devId", value = "设备id", required = true, paramType = "query"),
@ApiImplicitParam(name = "isAdmin", value = "是否需要推送给普通用户", required = true, paramType = "query")
@ApiImplicitParam(name = "devId", value = "设备id", required = true, paramType = "query"),
@ApiImplicitParam(name = "isAdmin", value = "是否需要推送给普通用户", required = true, paramType = "query")
})
public HttpResult<List<String>> getEventUserByDeviceId(@RequestParam("devId") String devId, @RequestParam("isAdmin") Boolean isAdmin){
String methodDescribe = getMethodDescribe("getEventUserByDeviceId");
@@ -70,9 +65,13 @@ public class DeviceMessageController extends BaseController {
@PostMapping("/getLineInfo")
@ApiOperation("获取监测点信息")
@ApiImplicitParam(name = "id", value = "参数", required = true, paramType = "query")
public HttpResult<String> getLineInfo(@RequestParam("id") String id){
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "参数", paramType = "query"),
@ApiImplicitParam(name = "list", value = "监测点id集合", paramType = "query")
})
public HttpResult<String> getLineInfo(@RequestParam("id") String id, @RequestParam("list") List<CsLinePO> list){
String methodDescribe = getMethodDescribe("getLineInfo");
deviceMessageService.getLineInfo(id);
deviceMessageService.getLineInfo(id,list);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "success", methodDescribe);
}

View File

@@ -1,6 +1,7 @@
package com.njcn.csdevice.service;
import com.njcn.csdevice.param.DeviceMessageParam;
import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.user.pojo.po.User;
import java.util.List;
@@ -14,6 +15,6 @@ public interface DeviceMessageService {
List<User> getSendUserByType(DeviceMessageParam param);
void getLineInfo(String id);
void getLineInfo(String id,List<CsLinePO> list);
}

View File

@@ -57,7 +57,7 @@ public class CsDataArrayServiceImpl extends ServiceImpl<CsDataArrayMapper, CsDat
for (Map.Entry<String, List<EleEpdPqd>> entry : map.entrySet()) {
DeviceManagerDetailVO vo = new DeviceManagerDetailVO();
EleEpdPqd eleEpdPqd = entry.getValue().get(0);
if (Objects.equals(eleEpdPqd.getPhase(),"M")){
if (Objects.equals(eleEpdPqd.getPhase(),"T")){
vo.setPhasic("/");
} else {
vo.setPhasic(entry.getValue().stream().map(EleEpdPqd::getPhase).collect(Collectors.joining(",")));
@@ -109,7 +109,7 @@ public class CsDataArrayServiceImpl extends ServiceImpl<CsDataArrayMapper, CsDat
DataArrayTreeVO vo3 = new DataArrayTreeVO();
vo3.setId(item.getDataSetId() + item.getDataArrayName()+item2);
vo3.setName(item2);
if (Objects.equals(item2,"M")){
if (Objects.equals(item2,"T")){
vo3.setShowName("无相别");
} else {
vo3.setShowName(item2);

View File

@@ -316,8 +316,8 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
if(Objects.isNull(csDataSet) || StrUtil.isBlank(csDataSet.getDataLevel())){
throw new BusinessException("当前测点数据集主要信息缺失,请联系管理员排查(测点表里面数据集id缺失)");
}
Double ct = finalCsLinePOList.get(0).getCtRatio();
Double pt = finalCsLinePOList.get(0).getPtRatio();
Double ct = finalCsLinePOList.get(0).getCtRatio() / (Objects.isNull(finalCsLinePOList.get(0).getCt2Ratio())?1.0:finalCsLinePOList.get(0).getCt2Ratio());
Double pt = finalCsLinePOList.get(0).getPtRatio() / (Objects.isNull(finalCsLinePOList.get(0).getPt2Ratio())?1.0:finalCsLinePOList.get(0).getPt2Ratio());
if(CollectionUtil.isNotEmpty(commonStatisticalQueryParam.getList())){
for (CommonStatisticalQueryParam param : commonStatisticalQueryParam.getList()){
@@ -347,7 +347,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
String unit;
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
vo.setPhase(Objects.equals("T",temp.getPhaseType())?null:temp.getPhaseType());
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime());
@@ -455,21 +455,6 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
vo.setAnotherName(epdPqd.getShowName());
return vo;
}).collect(Collectors.toList());
//长时闪变
if (Objects.equals(epdPqd.getOtherName(), "plt")) {
List<Instant> timeInstants = getTimeInstants(commonStatisticalQueryParam.getStartTime(), commonStatisticalQueryParam.getEndTime(), 2, ChronoUnit.HOURS, DEFAULT_ZONE);
collect1 = collect1.stream()
.filter(vo -> timeInstants.contains(vo.getTime()))
.collect(Collectors.toList());
}
//短时闪变 || 电压波动
else if (Objects.equals(epdPqd.getOtherName(), "pst") || Objects.equals(epdPqd.getOtherName(), "fluc")) {
List<Instant> timeInstants = getTimeInstants(commonStatisticalQueryParam.getStartTime(), commonStatisticalQueryParam.getEndTime(), 10, ChronoUnit.MINUTES, DEFAULT_ZONE);
collect1 = collect1.stream()
.filter(vo -> timeInstants.contains(vo.getTime()))
.collect(Collectors.toList());
}
result.addAll(collect1);
});
}
@@ -512,7 +497,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
vo.setPhase(Objects.equals("T",temp.getPhaseType())?null:temp.getPhaseType());
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime());
@@ -667,7 +652,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
vo.setPhase(Objects.equals("T",temp.getPhaseType())?null:temp.getPhaseType());
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime());
@@ -767,7 +752,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
vo.setPhase(Objects.equals("T",temp.getPhaseType())?null:temp.getPhaseType());
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime());
@@ -846,8 +831,8 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
if(Objects.isNull(csDataSet) || StrUtil.isBlank(csDataSet.getDataLevel())) {
throw new BusinessException("当前测点数据集主要信息缺失,请联系管理员排查(测点表里面数据集id缺失)");
}
Double ct = finalCsLinePO.getCtRatio();
Double pt = finalCsLinePO.getPtRatio();
Double ct = finalCsLinePO.getCtRatio() / (Objects.isNull(finalCsLinePO.getCt2Ratio())?1.0:finalCsLinePO.getCt2Ratio());
Double pt = finalCsLinePO.getPtRatio() / (Objects.isNull(finalCsLinePO.getPt2Ratio())?1.0:finalCsLinePO.getPt2Ratio());
if(CollectionUtil.isNotEmpty(trendDataQueryParam.getList())) {
for (TrendDataQueryParam param : trendDataQueryParam.getList()) {
List<EleEpdPqd> eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(param.getStatisticalId()).getData();
@@ -872,7 +857,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
String unit;
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(Objects.equals("M", temp.getPhaseType()) ? null : temp.getPhaseType());
vo.setPhase(Objects.equals("T", temp.getPhaseType()) ? null : temp.getPhaseType());
String position = finalCsLinePO.getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime());
@@ -980,21 +965,6 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
vo.setAnotherName(epdPqd.getShowName());
return vo;
}).collect(Collectors.toList());
//长时闪变
if (Objects.equals(epdPqd.getOtherName(), "plt")) {
List<Instant> timeInstants = getTimeInstants(trendDataQueryParam.getSearchBeginTime(), trendDataQueryParam.getSearchEndTime(), 2, ChronoUnit.HOURS, DEFAULT_ZONE);
collect1 = collect1.stream()
.filter(vo -> timeInstants.contains(vo.getTime()))
.collect(Collectors.toList());
}
//短时闪变 || 电压波动
else if (Objects.equals(epdPqd.getOtherName(), "pst") || Objects.equals(epdPqd.getOtherName(), "fluc")) {
List<Instant> timeInstants = getTimeInstants(trendDataQueryParam.getSearchBeginTime(), trendDataQueryParam.getSearchEndTime(), 10, ChronoUnit.MINUTES, DEFAULT_ZONE);
collect1 = collect1.stream()
.filter(vo -> timeInstants.contains(vo.getTime()))
.collect(Collectors.toList());
}
result.addAll(collect1);
}
}
@@ -1010,9 +980,10 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
if(Objects.isNull(csDataSet) || StrUtil.isBlank(csDataSet.getDataLevel())){
throw new BusinessException("当前测点数据集主要信息缺失,请联系管理员排查(测点表里面数据集id缺失)");
}
Double ct = finalCsLinePO.getCtRatio();
Double pt = finalCsLinePO.getPtRatio();
// String position = finalCsLinePO.getPosition();
Double ct = finalCsLinePO.getCtRatio() / (Objects.isNull(finalCsLinePO.getCt2Ratio())?1.0:finalCsLinePO.getCt2Ratio());
Double pt = finalCsLinePO.getPtRatio() / (Objects.isNull(finalCsLinePO.getPt2Ratio())?1.0:finalCsLinePO.getPt2Ratio());
// String position = finalCsLinePO.getPosition();
Overlimit overlimit = overLimitWlMapper.selectById(finalCsLinePO.getLineId());
if (Objects.isNull(overlimit)) {
throw new BusinessException("当前测点限值信息缺失,请联系管理员排查");
@@ -1048,7 +1019,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
// vo.setLineName(finalCsLinePO.getName());
vo.setPhase(Objects.equals("M", temp.getPhaseType()) ? null : temp.getPhaseType());
vo.setPhase(Objects.equals("T", temp.getPhaseType()) ? null : temp.getPhaseType());
// vo.setPosition(position);
vo.setTime(temp.getTime());
vo.setStatMethod(commonQueryParam.getDataType());

View File

@@ -86,9 +86,14 @@ class DeviceMessageServiceImpl implements DeviceMessageService {
}
@Override
public void getLineInfo(String id) {
public void getLineInfo(String id, List<CsLinePO> list) {
Map<Integer,String> map = new HashMap<>();
List<CsLinePO> lineList = csLinePOService.findByNdid(id);
List<CsLinePO> lineList;
if (CollectionUtil.isNotEmpty(list) && list != null) {
lineList = list;
} else {
lineList = csLinePOService.findByNdid(id);
}
if (CollectionUtil.isEmpty(lineList)){
throw new BusinessException("监测点为空");
}

View File

@@ -79,16 +79,16 @@ public class RStatIntegrityDServiceImpl extends MppServiceImpl<RStatIntegrityDMa
RStatIntegrityD data = new RStatIntegrityD();
//治理监测点
if (item.getClDid() == 0) {
statisticalDataDTO = commonService.getDataCounts(item.getLineId(),"apf_data","Apf_Freq","value","M","avg",item.getClDid().toString(),process.toString(),time+" 00:00:00",time+" 23:59:59");
statisticalDataDTO = commonService.getDataCounts(item.getLineId(),"apf_data","Apf_Freq","value","T","AVG",item.getClDid().toString(),process.toString(),time+" 00:00:00",time+" 23:59:59");
}
else {
//云前置监测点
if (ObjectUtil.isNotNull(item.getLineNo())) {
statisticalDataDTO = commonService.getDataCounts(item.getLineId(),"data_v","Pq_Freq","value","M","avg",item.getClDid().toString(),process.toString(),time+" 00:00:00",time+" 23:59:59");
statisticalDataDTO = commonService.getDataCounts(item.getLineId(),"data_v","freq","value","T","AVG",item.getClDid().toString(),process.toString(),time+" 00:00:00",time+" 23:59:59");
}
//治理、无线监测点
else {
statisticalDataDTO = commonService.getDataCounts(item.getLineId(),"pqd_data","Pq_Freq","value","M","avg",item.getClDid().toString(),process.toString(),time+" 00:00:00",time+" 23:59:59");
statisticalDataDTO = commonService.getDataCounts(item.getLineId(),"data_v","freq","value","T","AVG",item.getClDid().toString(),process.toString(),time+" 00:00:00",time+" 23:59:59");
}
}
data.setTimeId(LocalDate.parse(time, DatePattern.NORM_DATE_FORMATTER));

View File

@@ -504,7 +504,7 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
String unit;
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
vo.setPhase(Objects.equals("T",temp.getPhaseType())?null:temp.getPhaseType());
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime());
@@ -681,13 +681,13 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
if(Objects.isNull(list.get(i).getEndTime())){
LocalDateTime now = LocalDateTime.now();
String sqlNow = now.format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN));
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper("pqd_data",StatisticalDataDTO.class);
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper("data_v",StatisticalDataDTO.class);
influxQueryWrapper.select(StatisticalDataDTO::getLineId)
.select(StatisticalDataDTO::getPhaseType)
.select(StatisticalDataDTO::getValueType)
.last("Pq_Freq")
.last("freq")
.eq(InfluxDBTableConstant.LINE_ID,lineId)
.eq(InfluxDBTableConstant.PHASIC_TYPE,"M")
.eq(InfluxDBTableConstant.PHASIC_TYPE,"T")
.between(InfluxDBTableConstant.TIME,startSql,sqlNow);
System.out.println(influxQueryWrapper.generateSql());
StatisticalDataDTO statisticalDataDTO = commonMapper.getLineRtData(influxQueryWrapper);
@@ -708,13 +708,13 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
//如果不存在结束时间,则取后面一条的起始时间作为结束判断标识
if(Objects.isNull(list.get(i).getEndTime())){
String end = list.get(i+1).getStartTime().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN));
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper("pqd_data",StatisticalDataDTO.class);
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper("data_v",StatisticalDataDTO.class);
influxQueryWrapper.select(StatisticalDataDTO::getLineId)
.select(StatisticalDataDTO::getPhaseType)
.select(StatisticalDataDTO::getValueType)
.last("Pq_Freq")
.last("freq")
.eq(InfluxDBTableConstant.LINE_ID,lineId)
.eq(InfluxDBTableConstant.PHASIC_TYPE,"M")
.eq(InfluxDBTableConstant.PHASIC_TYPE,"T")
.between(InfluxDBTableConstant.TIME,startSql,end);
System.out.println(influxQueryWrapper.generateSql());
StatisticalDataDTO statisticalDataDTO = commonMapper.getLineRtData(influxQueryWrapper);