|
@@ -12,6 +12,7 @@ import com.influxdb.query.FluxTable;
|
|
import com.platform.common.exception.BusinessException;
|
|
import com.platform.common.exception.BusinessException;
|
|
import com.platform.common.util.BeanConverterUtil;
|
|
import com.platform.common.util.BeanConverterUtil;
|
|
import com.platform.common.util.DateUtils;
|
|
import com.platform.common.util.DateUtils;
|
|
|
|
+import com.platform.dao.dto.remote.RemoteOpcDTO;
|
|
import com.platform.dao.entity.remote.RemoteOpc;
|
|
import com.platform.dao.entity.remote.RemoteOpc;
|
|
import com.platform.dao.influxdb.InfluxDBService;
|
|
import com.platform.dao.influxdb.InfluxDBService;
|
|
import com.platform.dao.influxdb.builder.InfluxDbBuilder;
|
|
import com.platform.dao.influxdb.builder.InfluxDbBuilder;
|
|
@@ -102,39 +103,48 @@ public class InfluxDBServiceImpl implements InfluxDBService {
|
|
/**
|
|
/**
|
|
* 查询数据: 查询某个点位,某个时间段的数据*,表格数据,图表数据
|
|
* 查询数据: 查询某个点位,某个时间段的数据*,表格数据,图表数据
|
|
*
|
|
*
|
|
- * @param id positionNum值
|
|
|
|
- * @param type 1: 5分钟
|
|
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public RemoteOpcVO select(String id, Integer type) {
|
|
|
|
- RemoteOpc remoteOpc = remoteOpcMapper.selectByPrimaryKey(id);
|
|
|
|
|
|
+ public RemoteOpcVO select(RemoteOpcDTO remoteOpcDTO) {
|
|
|
|
+ RemoteOpc remoteOpc = remoteOpcMapper.selectByPrimaryKey(remoteOpcDTO.getId());
|
|
RemoteOpcVO vo = BeanConverterUtil.copyObjectProperties(remoteOpc, RemoteOpcVO.class);
|
|
RemoteOpcVO vo = BeanConverterUtil.copyObjectProperties(remoteOpc, RemoteOpcVO.class);
|
|
StringBuffer stringBuilder = new StringBuffer();
|
|
StringBuffer stringBuilder = new StringBuffer();
|
|
|
|
+ if(remoteOpcDTO.getStartTime() == null){
|
|
|
|
+ throw new BusinessException("请选择查询开始时间");
|
|
|
|
+ }
|
|
|
|
+ if(remoteOpcDTO.getEndTime() == null){
|
|
|
|
+ throw new BusinessException("请选择查询截止时间");
|
|
|
|
+ }
|
|
|
|
+ if(remoteOpcDTO.getEndTime().isAfter(LocalDateTime.now())){
|
|
|
|
+ throw new BusinessException("截止时间不能晚于当前系统时间");
|
|
|
|
+ }
|
|
try {
|
|
try {
|
|
-
|
|
|
|
- LocalDateTime start = LocalDateTime.now().minusHours(8);
|
|
|
|
- LocalDateTime stop = LocalDateTime.now().minusHours(8);
|
|
|
|
|
|
+ LocalDateTime start = remoteOpcDTO.getStartTime().minusHours(8);
|
|
|
|
+ LocalDateTime stop = remoteOpcDTO.getEndTime().minusHours(8);
|
|
|
|
+ /*Integer type = remoteOpcDTO.getSearchDay();
|
|
if (type == 1) {// 5分钟
|
|
if (type == 1) {// 5分钟
|
|
start = start.minusMinutes(5);
|
|
start = start.minusMinutes(5);
|
|
- } else if (type == 2) {// 5分钟
|
|
|
|
|
|
+ } else if (type == 2) {// 15分钟
|
|
start = start.minusMinutes(15);
|
|
start = start.minusMinutes(15);
|
|
- }else if (type == 3) {// 5分钟
|
|
|
|
|
|
+ }else if (type == 3) {// 1小时
|
|
start = start.minusHours(1);
|
|
start = start.minusHours(1);
|
|
- }else if (type == 4) {// 5分钟
|
|
|
|
|
|
+ }else if (type == 4) {// 3小时
|
|
start = start.minusHours(3);
|
|
start = start.minusHours(3);
|
|
- }else if (type == 5) {// 5分钟
|
|
|
|
|
|
+ }else if (type == 5) {// 6小时
|
|
start = start.minusHours(6);
|
|
start = start.minusHours(6);
|
|
- }else if (type == 6) {// 5分钟
|
|
|
|
|
|
+ }else if (type == 6) {// 12小时
|
|
start = start.minusHours(12);
|
|
start = start.minusHours(12);
|
|
- }else if (type == 7) {// 5分钟
|
|
|
|
|
|
+ }else if (type == 7) {// 24小时
|
|
start = start.minusHours(24);
|
|
start = start.minusHours(24);
|
|
- }else if (type == 8) {// 5分钟
|
|
|
|
|
|
+ }else if (type == 8) {// 2天
|
|
start = start.minusDays(2);
|
|
start = start.minusDays(2);
|
|
- }else if (type == 9) {// 5分钟
|
|
|
|
|
|
+ }else if (type == 9) {// 7天
|
|
start = start.minusDays(7);
|
|
start = start.minusDays(7);
|
|
- }else{
|
|
|
|
|
|
+ }else if (type == 10) {// 30天
|
|
start = start.minusDays(30);
|
|
start = start.minusDays(30);
|
|
- }
|
|
|
|
|
|
+ }else{// 1年
|
|
|
|
+ start = start.minusYears(1);
|
|
|
|
+ }*/
|
|
InfluxDBFluxExpression.appendCommonFlux(stringBuilder, InfluxDBFluxExpression.bucket, InfluxDBFluxExpression.measurement, DateUtils.localDateTimeToUTC(start), DateUtils.localDateTimeToUTC(stop));
|
|
InfluxDBFluxExpression.appendCommonFlux(stringBuilder, InfluxDBFluxExpression.bucket, InfluxDBFluxExpression.measurement, DateUtils.localDateTimeToUTC(start), DateUtils.localDateTimeToUTC(stop));
|
|
} catch (ParseException e) {
|
|
} catch (ParseException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|