From 5cd3e0e919d427c68d2e21be20f27af9b24622b0 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期四, 16 三月 2023 09:32:21 +0800
Subject: [PATCH] 更新前后端分离部署文档
---
src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java | 34 +++++++++++++++++++++++++++++++++-
1 files changed, 33 insertions(+), 1 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java
index 9db2d68..336082f 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java
@@ -19,6 +19,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
/**
* @author lin
@@ -99,7 +100,7 @@
HashMap<String, DeviceChannel> channelsInStore = new HashMap<>();
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
if (channels != null && channels.size() > 0) {
- List<DeviceChannel> channelList = channelMapper.queryChannels(deviceId, null, null, null, null);
+ List<DeviceChannel> channelList = channelMapper.queryChannels(deviceId, null, null, null, null,null);
if (channelList.size() == 0) {
for (DeviceChannel channel : channels) {
channel.setDeviceId(deviceId);
@@ -176,5 +177,36 @@
return channelMapper.queryChannelListInAll(null, null, null, platformId, null);
}
+ @Override
+ public boolean updateAllGps(Device device) {
+ List<DeviceChannel> deviceChannels = channelMapper.getChannelsWithoutTransform(device.getDeviceId());
+ List<DeviceChannel> result = new CopyOnWriteArrayList<>();
+ if (deviceChannels.size() == 0) {
+ return true;
+ }
+ String now = DateUtil.getNow();
+ deviceChannels.parallelStream().forEach(deviceChannel -> {
+ deviceChannel.setUpdateTime(now);
+ result.add(updateGps(deviceChannel, device));
+ });
+ int limitCount = 300;
+ if (result.size() > limitCount) {
+ for (int i = 0; i < result.size(); i += limitCount) {
+ int toIndex = i + limitCount;
+ if (i + limitCount > result.size()) {
+ toIndex = result.size();
+ }
+ channelMapper.batchUpdate(result.subList(i, toIndex));
+ }
+ }else {
+ channelMapper.batchUpdate(result);
+ }
+ return true;
+ }
+
+ @Override
+ public List<Device> getDeviceByChannelId(String channelId) {
+ return channelMapper.getDeviceByChannelId(channelId);
+ }
}
--
Gitblit v1.8.0