提交代码
This commit is contained in:
@@ -48,6 +48,12 @@
|
|||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.njcn</groupId>
|
||||||
|
<artifactId>cs-device-api</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.njcn.influx.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.lang.Dict;
|
import cn.hutool.core.lang.Dict;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||||
|
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||||
import com.njcn.influx.imapper.CommonMapper;
|
import com.njcn.influx.imapper.CommonMapper;
|
||||||
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
||||||
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
||||||
@@ -9,10 +11,12 @@ import com.njcn.influx.query.InfluxQueryWrapper;
|
|||||||
import com.njcn.influx.service.CommonService;
|
import com.njcn.influx.service.CommonService;
|
||||||
import com.njcn.influx.utils.ReflectUitl;
|
import com.njcn.influx.utils.ReflectUitl;
|
||||||
import com.njcn.system.api.DicDataFeignClient;
|
import com.njcn.system.api.DicDataFeignClient;
|
||||||
|
import com.njcn.system.enums.DicDataEnum;
|
||||||
import com.njcn.system.pojo.po.DictData;
|
import com.njcn.system.pojo.po.DictData;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -31,6 +35,8 @@ public class CommonServiceImpl implements CommonService {
|
|||||||
private final CommonMapper commonMapper;
|
private final CommonMapper commonMapper;
|
||||||
private final
|
private final
|
||||||
DicDataFeignClient dicDataFeignClient;
|
DicDataFeignClient dicDataFeignClient;
|
||||||
|
|
||||||
|
private final CsLineFeignClient csLineFeignClient;
|
||||||
@Override
|
@Override
|
||||||
public StatisticalDataDTO getLineRtData(String lineId, String tableName, String columnName, String phasic, String dataType, String clDid) {
|
public StatisticalDataDTO getLineRtData(String lineId, String tableName, String columnName, String phasic, String dataType, String clDid) {
|
||||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(getTableNameByClassId(tableName),StatisticalDataDTO.class);
|
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(getTableNameByClassId(tableName),StatisticalDataDTO.class);
|
||||||
@@ -47,29 +53,43 @@ public class CommonServiceImpl implements CommonService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<StatisticalDataDTO> getDeviceRtData(List<String> lineIds, String tableName, String columnName, String phasic, String dataType) {
|
public List<StatisticalDataDTO> getDeviceRtData(List<String> lineIds, String tableName, String columnName, String phasic, String dataType) {
|
||||||
|
List<StatisticalDataDTO> resultList = new ArrayList<>();
|
||||||
|
for (String lineId: lineIds) {
|
||||||
|
String clDidByLineId = getClDidByLineId(lineId);
|
||||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(getTableNameByClassId(tableName),StatisticalDataDTO.class);
|
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(getTableNameByClassId(tableName),StatisticalDataDTO.class);
|
||||||
influxQueryWrapper.select(StatisticalDataDTO::getLineId)
|
influxQueryWrapper.select(StatisticalDataDTO::getLineId)
|
||||||
.select(StatisticalDataDTO::getPhaseType)
|
.select(StatisticalDataDTO::getPhaseType)
|
||||||
.select(StatisticalDataDTO::getValueType)
|
.select(StatisticalDataDTO::getValueType)
|
||||||
.last(columnName,InfluxDBTableConstant.VALUE)
|
.last(columnName,InfluxDBTableConstant.VALUE)
|
||||||
.or(InfluxDBTableConstant.LINE_ID,lineIds)
|
.eq(InfluxDBTableConstant.LINE_ID,lineId)
|
||||||
.eq(InfluxDBTableConstant.PHASIC_TYPE,phasic)
|
.eq(InfluxDBTableConstant.PHASIC_TYPE,phasic)
|
||||||
.eq(InfluxDBTableConstant.VALUE_TYPE,dataType).groupBy(InfluxDBTableConstant.LINE_ID);
|
.eq(InfluxDBTableConstant.VALUE_TYPE,dataType).eq(InfluxDBTableConstant.CL_DID,clDidByLineId);
|
||||||
return commonMapper.getDeviceRtData(influxQueryWrapper);
|
List<StatisticalDataDTO> deviceRtData = commonMapper.getDeviceRtData(influxQueryWrapper);
|
||||||
|
resultList.addAll(deviceRtData);
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<StatisticalDataDTO> getDeviceRtDataByTime(List<String> lineIds, String tableName, String columnName, String phasic, String dataType, String startTime, String endTime) {
|
public List<StatisticalDataDTO> getDeviceRtDataByTime(List<String> lineIds, String tableName, String columnName, String phasic, String dataType, String startTime, String endTime) {
|
||||||
|
List<StatisticalDataDTO> resultList = new ArrayList<>();
|
||||||
|
for (String lineId: lineIds) {
|
||||||
|
String clDidByLineId = getClDidByLineId(lineId);
|
||||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(getTableNameByClassId(tableName),StatisticalDataDTO.class);
|
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(getTableNameByClassId(tableName),StatisticalDataDTO.class);
|
||||||
influxQueryWrapper.select(StatisticalDataDTO::getLineId)
|
influxQueryWrapper.select(StatisticalDataDTO::getLineId)
|
||||||
.select(StatisticalDataDTO::getPhaseType)
|
.select(StatisticalDataDTO::getPhaseType)
|
||||||
.select(StatisticalDataDTO::getValueType)
|
.select(StatisticalDataDTO::getValueType)
|
||||||
.select(columnName,InfluxDBTableConstant.VALUE)
|
.select(columnName,InfluxDBTableConstant.VALUE)
|
||||||
.or(InfluxDBTableConstant.LINE_ID,lineIds)
|
.eq(InfluxDBTableConstant.LINE_ID,lineId)
|
||||||
.eq(InfluxDBTableConstant.PHASIC_TYPE,phasic)
|
.eq(InfluxDBTableConstant.PHASIC_TYPE,phasic)
|
||||||
.between(InfluxDBTableConstant.TIME, startTime, endTime)
|
.between(InfluxDBTableConstant.TIME, startTime, endTime)
|
||||||
.eq(InfluxDBTableConstant.VALUE_TYPE,dataType).groupBy(InfluxDBTableConstant.LINE_ID);
|
.eq(InfluxDBTableConstant.VALUE_TYPE,dataType).eq(InfluxDBTableConstant.CL_DID,clDidByLineId);
|
||||||
return commonMapper.getDeviceRtDataByTime(influxQueryWrapper);
|
List<StatisticalDataDTO> deviceRtData = commonMapper.getDeviceRtDataByTime(influxQueryWrapper);
|
||||||
|
resultList.addAll(deviceRtData);
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -96,4 +116,20 @@ public class CommonServiceImpl implements CommonService {
|
|||||||
}
|
}
|
||||||
return data.getCode();
|
return data.getCode();
|
||||||
}
|
}
|
||||||
|
private String getClDidByLineId(String lineId){
|
||||||
|
String position = csLineFeignClient.getPositionById(lineId).getData();
|
||||||
|
if (Objects.isNull(position)){
|
||||||
|
throw new BusinessException(AlgorithmResponseEnum.POSITION_ERROR);
|
||||||
|
}
|
||||||
|
String clDid = null;
|
||||||
|
String areaCode = dicDataFeignClient.getDicDataById(position).getData().getCode();
|
||||||
|
if (Objects.equals(areaCode, DicDataEnum.OUTPUT_SIDE.getCode())){
|
||||||
|
clDid = "0";
|
||||||
|
} else if (Objects.equals(areaCode, DicDataEnum.LOAD_SIDE.getCode())){
|
||||||
|
clDid = "1";
|
||||||
|
} else if (Objects.equals(areaCode, DicDataEnum.GRID_SIDE.getCode())){
|
||||||
|
clDid = "2";
|
||||||
|
}
|
||||||
|
return clDid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user