648540858
2021-12-28 7241e0d2d21e408877cf2e1c62a19f17a82a9ac9
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
@@ -110,6 +110,7 @@
    */
   @Override
   public synchronized boolean create(Device device) {
      redisCatchStorage.updateDevice(device);
      return deviceMapper.add(device) > 0;
   }
@@ -128,10 +129,13 @@
      Device deviceByDeviceId = deviceMapper.getDeviceByDeviceId(device.getDeviceId());
      if (deviceByDeviceId == null) {
         device.setCreateTime(now);
         redisCatchStorage.updateDevice(device);
         return deviceMapper.add(device) > 0;
      }else {
         redisCatchStorage.updateDevice(device);
         return deviceMapper.update(device) > 0;
      }
   }
@@ -185,11 +189,32 @@
               }
            }
         }
         int limitCount = 300;
         if (addChannels.size() > 0) {
            deviceChannelMapper.batchAdd(addChannels);
            if (addChannels.size() > limitCount) {
               for (int i = 0; i < addChannels.size(); i += limitCount) {
                  int toIndex = i + limitCount;
                  if (i + limitCount > addChannels.size()) {
                     toIndex = addChannels.size();
                  }
                  deviceChannelMapper.batchAdd(addChannels.subList(i, toIndex));
               }
            }else {
               deviceChannelMapper.batchAdd(addChannels);
            }
         }
         if (updateChannels.size() > 0) {
            deviceChannelMapper.batchUpdate(updateChannels);
            if (updateChannels.size() > limitCount) {
               for (int i = 0; i < updateChannels.size(); i += limitCount) {
                  int toIndex = i + limitCount;
                  if (i + limitCount > updateChannels.size()) {
                     toIndex = updateChannels.size();
                  }
                  deviceChannelMapper.batchAdd(updateChannels.subList(i, toIndex));
               }
            }else {
               deviceChannelMapper.batchUpdate(updateChannels);
            }
         }
      }
   }
@@ -231,6 +256,11 @@
      PageHelper.startPage(page, count);
      List<DeviceChannel> all = deviceChannelMapper.queryChannels(deviceId, null, query, hasSubChannel, online);
      return new PageInfo<>(all);
   }
   @Override
   public List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit) {
      return deviceChannelMapper.queryChannelsByDeviceIdWithStartAndLimit(deviceId, null, query, hasSubChannel, online, start, limit);
   }
   @Override
@@ -322,6 +352,7 @@
      }
      device.setOnline(1);
      logger.info("更新设备在线: " + deviceId);
      redisCatchStorage.updateDevice(device);
      return deviceMapper.update(device) > 0;
   }
@@ -337,6 +368,7 @@
      Device device = deviceMapper.getDeviceByDeviceId(deviceId);
      if (device == null) return false;
      device.setOnline(0);
      redisCatchStorage.updateDevice(device);
      return deviceMapper.update(device) > 0;
   }