| | |
| | | import com.influxdb.query.FluxTable; |
| | | import com.influxdb.query.InfluxQLQueryResult; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | } |
| | | if (!CollectionUtils.isEmpty(tagValues)) { |
| | | tagValues.forEach(item -> { |
| | | log.info("bucket==="+ influxDBInstance.getBucket() + ",org===" + influxDBInstance.org); |
| | | log.info("bucket===" + influxDBInstance.getBucket() + ",org===" + influxDBInstance.org); |
| | | writeApi.writeMeasurement(influxDBInstance.getBucket(), influxDBInstance.org, WritePrecision.MS, item); |
| | | }); |
| | | } |
| | |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | // String start = startTime.getTime() - calendar.getTime().getTime() + "ms"; |
| | | String start = startTime.getTime() - calendar.getTime().getTime() - pas_ms + "ms"; |
| | | if (endTime==null){ |
| | | endTime= new Date(); |
| | | if (endTime == null) { |
| | | endTime = new Date(); |
| | | } |
| | | String stop = endTime.getTime() - calendar.getTime().getTime() + "ms"; |
| | | |
| | |
| | | List<Map<String, Object>> list = data.get(queryDto.getTagIds().get(0)); |
| | | |
| | | //导出 |
| | | try{ |
| | | try { |
| | | String sheetTitle = "采集数据"; |
| | | String[] title = new String[]{"值", "时间"}; |
| | | ExcelUtil.exportPointValue(sheetTitle, title, new ArrayList<>(list), response); |
| | |
| | | |
| | | //提取list |
| | | List<Map<String, Object>> list = data.get(queryDto.getPointNos().get(0)); |
| | | for(Map<String, Object> map : list){ |
| | | for (Map<String, Object> map : list) { |
| | | PointValueExportVO dto = new PointValueExportVO(); |
| | | dto.setDatatime(map.get("time").toString()); |
| | | dto.setDatavalue(map.get("value").toString()); |
| | |
| | | sql.append("'"); |
| | | InfluxQLQueryResult data = influxQLQueryApi.query(new InfluxQLQuery(sql.toString(), influxDBInstance.getBucket())); |
| | | Object value = data.getResults().get(0).getSeries().get(0).getValues().get(0).getValueByKey("last"); |
| | | result.put(point.getPoint(), value); |
| | | if (value != null) { |
| | | result.put(point.getPoint(), value); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | |
| | | if (influxQLQueryApi == null) { |
| | | influxQLQueryApi = influxDBInstance.getClient().getInfluxQLQueryApi(); |
| | | } |
| | | long utcMillis = startTime.getTime() -rawOffset; |
| | | long utcMillis = startTime.getTime() - rawOffset; |
| | | String utsStart = DateUtils.format(new Date(utcMillis), DateUtils.FORMAT_YEAR_MONTH_DAY); |
| | | log.info("utsStart=" + utsStart); |
| | | String measurement = PointValueUtils.getMeasurement(point.getType()); |
| | |
| | | sql.append(measurement); |
| | | sql.append(" WHERE point = '"); |
| | | sql.append(point.getPoint()); |
| | | sql.append("' AND time >= '" + utsStart +"'"); |
| | | sql.append("' AND time >= '" + utsStart + "'"); |
| | | InfluxQLQueryResult data = influxQLQueryApi.query(new InfluxQLQuery(sql.toString(), influxDBInstance.getBucket())); |
| | | if (data == null) { |
| | | return null; |
| | |
| | | Map<String, List<Map<String, Object>>> result = new HashMap<>(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | String start = startTime.getTime() - calendar.getTime().getTime() + "ms"; |
| | | if (endTime==null){ |
| | | endTime= new Date(); |
| | | String start = (startTime.getTime() - calendar.getTime().getTime() - pas_ms) + "ms"; |
| | | if (endTime == null) { |
| | | endTime = new Date(); |
| | | } |
| | | String stop = endTime.getTime() - calendar.getTime().getTime() + "ms"; |
| | | |