|
@@ -6,6 +6,7 @@ import cn.hutool.core.date.DatePattern;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.text.StrBuilder;
|
|
|
import cn.hutool.core.util.BooleanUtil;
|
|
|
+import cn.hutool.core.util.NumberUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -18,10 +19,7 @@ import com.xy.collections.list.JList;
|
|
|
import com.xy.config.DeviceThreadPoolConfig;
|
|
|
import com.xy.consts.DictConsts;
|
|
|
import com.xy.dto.*;
|
|
|
-import com.xy.entity.DeviceErrorsRecord;
|
|
|
-import com.xy.entity.DeviceInfo;
|
|
|
-import com.xy.entity.DeviceStatus;
|
|
|
-import com.xy.entity.SysDictRedis;
|
|
|
+import com.xy.entity.*;
|
|
|
import com.xy.error.CommRuntimeException;
|
|
|
import com.xy.mapper.DeviceInfoMapper;
|
|
|
import com.xy.mapper.entity.DeviceInfoQueryPage;
|
|
@@ -43,6 +41,8 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.IOException;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -68,8 +68,13 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
private final DeviceRegisterServiceImpl deviceRegisterService;
|
|
|
|
|
|
private final DeviceErrorsRecordServiceImpl deviceErrorsRecordService;
|
|
|
+
|
|
|
private final DeviceDataServiceImpl deviceDataService;
|
|
|
|
|
|
+ private final DeviceTempRecordsServiceImpl deviceTempRecordsService;
|
|
|
+
|
|
|
+ private final DeviceNetRecordServiceImpl deviceNetRecordService;
|
|
|
+
|
|
|
private final GoodsDeviceService goodsDeviceService;
|
|
|
|
|
|
private final RedisService<String> redisService;
|
|
@@ -732,6 +737,43 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
*/
|
|
|
private DeviceInfoDto.DeviceDataCountVO dataCount3(DeviceInfoDto.DeviceDataCountDTO dto) {
|
|
|
DeviceInfoDto.DeviceDataCountVO vo = new DeviceInfoDto.DeviceDataCountVO();
|
|
|
+ Long deviceId = dto.getDeviceId();
|
|
|
+ String choosDate = dto.getChoosDate();
|
|
|
+ if (StrUtil.isEmpty(choosDate)) {
|
|
|
+ choosDate = DateUtil.formatDate(new Date());
|
|
|
+ }
|
|
|
+ String startTime = choosDate + " 00:00:00";
|
|
|
+ String endTime = choosDate + " 23:59:59";
|
|
|
+ //查询选定日期的温度数据
|
|
|
+ List<DeviceTempRecords> deviceTempRecords = deviceTempRecordsService.list(Wrappers.<DeviceTempRecords>lambdaQuery()
|
|
|
+ .eq(DeviceTempRecords::getDeviceId, deviceId).between(DeviceTempRecords::getCreateTime, startTime, endTime)
|
|
|
+ .orderBy(true, true, DeviceTempRecords::getCreateTime));
|
|
|
+ if (CollUtil.isEmpty(deviceTempRecords)) {
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ DeviceInfoDto.TemperatureChart temperatureChart = new DeviceInfoDto.TemperatureChart();
|
|
|
+ List<String> categories = new ArrayList<>();
|
|
|
+
|
|
|
+
|
|
|
+ String name = "温度";
|
|
|
+ List<DeviceInfoDto.MyChartSeries2> series = new ArrayList<>();
|
|
|
+ List<BigDecimal> data = new ArrayList<>();
|
|
|
+ deviceTempRecords.forEach(d -> {
|
|
|
+ String tempValue = d.getTempValue();
|
|
|
+ LocalDateTime createTime = d.getCreateTime();
|
|
|
+ String time = DateUtil.format(createTime, "HH:mm:ss");
|
|
|
+ categories.add(time);
|
|
|
+ data.add(NumberUtil.toBigDecimal(tempValue));
|
|
|
+
|
|
|
+ });
|
|
|
+ DeviceInfoDto.MyChartSeries2 myChartSeries = new DeviceInfoDto.MyChartSeries2();
|
|
|
+ myChartSeries.setName(name);
|
|
|
+ myChartSeries.setData(data);
|
|
|
+ series.add(myChartSeries);
|
|
|
+ temperatureChart.setSeries(series);
|
|
|
+ temperatureChart.setCategories(categories);
|
|
|
+ vo.setTemperatureChart(temperatureChart);
|
|
|
return vo;
|
|
|
}
|
|
|
|
|
@@ -743,6 +785,43 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
*/
|
|
|
private DeviceInfoDto.DeviceDataCountVO dataCount4(DeviceInfoDto.DeviceDataCountDTO dto) {
|
|
|
DeviceInfoDto.DeviceDataCountVO vo = new DeviceInfoDto.DeviceDataCountVO();
|
|
|
+ Long deviceId = dto.getDeviceId();
|
|
|
+ String choosDate = dto.getChoosDate();
|
|
|
+ if (StrUtil.isEmpty(choosDate)) {
|
|
|
+ choosDate = DateUtil.formatDate(new Date());
|
|
|
+ }
|
|
|
+ String startTime = choosDate + " 00:00:00";
|
|
|
+ String endTime = choosDate + " 23:59:59";
|
|
|
+ //查询选定日期的温度数据
|
|
|
+ List<DeviceNetRecord> deviceNetRecords = deviceNetRecordService.list(Wrappers.<DeviceNetRecord>lambdaQuery()
|
|
|
+ .eq(DeviceNetRecord::getDeviceId, deviceId).between(DeviceNetRecord::getCreateTime, startTime, endTime)
|
|
|
+ .orderBy(true, true, DeviceNetRecord::getCreateTime));
|
|
|
+ if (CollUtil.isEmpty(deviceNetRecords)) {
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ DeviceInfoDto.SignalChart signalChart = new DeviceInfoDto.SignalChart();
|
|
|
+ List<String> categories = new ArrayList<>();
|
|
|
+
|
|
|
+
|
|
|
+ String name = "信号";
|
|
|
+ List<DeviceInfoDto.MyChartSeries> series = new ArrayList<>();
|
|
|
+ List<Integer> data = new ArrayList<>();
|
|
|
+ deviceNetRecords.forEach(d -> {
|
|
|
+ Integer value = d.getSimDbm();
|
|
|
+ LocalDateTime createTime = d.getCreateTime();
|
|
|
+ String time = DateUtil.format(createTime, "HH:mm:ss");
|
|
|
+ categories.add(time);
|
|
|
+ data.add(value);
|
|
|
+
|
|
|
+ });
|
|
|
+ DeviceInfoDto.MyChartSeries myChartSeries = new DeviceInfoDto.MyChartSeries();
|
|
|
+ myChartSeries.setName(name);
|
|
|
+ myChartSeries.setData(data);
|
|
|
+ series.add(myChartSeries);
|
|
|
+ signalChart.setSeries(series);
|
|
|
+ signalChart.setCategories(categories);
|
|
|
+ vo.setSignalChart(signalChart);
|
|
|
return vo;
|
|
|
}
|
|
|
|