mirror of
https://gitee.com/pan648540858/wvp-GB28181-pro.git
synced 2026-05-27 07:27:49 +08:00
Compare commits
1 Commits
972237b722
...
cc90c72eaf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc90c72eaf |
@ -426,36 +426,4 @@ public interface DeviceMapper {
|
|||||||
"<foreach collection='offlineDevices' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
|
"<foreach collection='offlineDevices' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
|
||||||
" </script>"})
|
" </script>"})
|
||||||
void offlineByList(List<Device> offlineDevices);
|
void offlineByList(List<Device> offlineDevices);
|
||||||
|
|
||||||
|
|
||||||
@Update({"<script>" +
|
|
||||||
"<foreach collection='devices' item='item' separator=';'>" +
|
|
||||||
" UPDATE" +
|
|
||||||
" wvp_device" +
|
|
||||||
" SET update_time=#{item.updateTime}" +
|
|
||||||
", name=#{item.name}" +
|
|
||||||
", manufacturer=#{item.manufacturer}" +
|
|
||||||
", model=#{item.model}" +
|
|
||||||
", firmware=#{item.firmware}" +
|
|
||||||
", transport=#{item.transport}" +
|
|
||||||
", ip=#{item.ip}" +
|
|
||||||
", local_ip=#{item.localIp}" +
|
|
||||||
", port=#{item.port}" +
|
|
||||||
", host_address=#{item.hostAddress}" +
|
|
||||||
", on_line=#{item.onLine}" +
|
|
||||||
", register_time=#{item.registerTime}" +
|
|
||||||
", keepalive_time=#{item.keepaliveTime}" +
|
|
||||||
", heart_beat_interval=#{item.heartBeatInterval}" +
|
|
||||||
", position_capability=#{item.positionCapability}" +
|
|
||||||
", heart_beat_count=#{item.heartBeatCount}" +
|
|
||||||
", subscribe_cycle_for_catalog=#{item.subscribeCycleForCatalog}" +
|
|
||||||
", subscribe_cycle_for_mobile_position=#{item.subscribeCycleForMobilePosition}" +
|
|
||||||
", mobile_position_submission_interval=#{item.mobilePositionSubmissionInterval}" +
|
|
||||||
", subscribe_cycle_for_alarm=#{item.subscribeCycleForAlarm}" +
|
|
||||||
", expires=#{item.expires}" +
|
|
||||||
", server_id=#{item.serverId}" +
|
|
||||||
" WHERE device_id=#{item.deviceId}"+
|
|
||||||
"</foreach>" +
|
|
||||||
"</script>"})
|
|
||||||
void batchUpdate(List<Device> devices);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import com.genersoft.iot.vmp.service.bean.ErrorCallback;
|
|||||||
import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
|
import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -118,9 +117,6 @@ public interface IDeviceService {
|
|||||||
*/
|
*/
|
||||||
void updateDevice(Device device);
|
void updateDevice(Device device);
|
||||||
|
|
||||||
@Transactional
|
|
||||||
void updateDeviceList(List<Device> deviceList);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查设备编号是否已经存在
|
* 检查设备编号是否已经存在
|
||||||
* @param deviceId 设备编号
|
* @param deviceId 设备编号
|
||||||
|
|||||||
@ -729,6 +729,8 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner {
|
|||||||
@Override
|
@Override
|
||||||
public void updateDevice(Device device) {
|
public void updateDevice(Device device) {
|
||||||
|
|
||||||
|
String now = DateUtil.getNow();
|
||||||
|
device.setUpdateTime(now);
|
||||||
device.setCharset(device.getCharset() == null ? "" : device.getCharset().toUpperCase());
|
device.setCharset(device.getCharset() == null ? "" : device.getCharset().toUpperCase());
|
||||||
device.setUpdateTime(DateUtil.getNow());
|
device.setUpdateTime(DateUtil.getNow());
|
||||||
if (deviceMapper.update(device) > 0) {
|
if (deviceMapper.update(device) > 0) {
|
||||||
@ -736,40 +738,6 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@Override
|
|
||||||
public void updateDeviceList(List<Device> deviceList) {
|
|
||||||
if (deviceList.isEmpty()){
|
|
||||||
log.info("[批量更新设备] 列表为空,更细失败");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (deviceList.size() == 1) {
|
|
||||||
updateDevice(deviceList.get(0));
|
|
||||||
}else {
|
|
||||||
for (Device device : deviceList) {
|
|
||||||
device.setCharset(device.getCharset() == null ? "" : device.getCharset().toUpperCase());
|
|
||||||
device.setUpdateTime(DateUtil.getNow());
|
|
||||||
}
|
|
||||||
int limitCount = 300;
|
|
||||||
if (!deviceList.isEmpty()) {
|
|
||||||
if (deviceList.size() > limitCount) {
|
|
||||||
for (int i = 0; i < deviceList.size(); i += limitCount) {
|
|
||||||
int toIndex = i + limitCount;
|
|
||||||
if (i + limitCount > deviceList.size()) {
|
|
||||||
toIndex = deviceList.size();
|
|
||||||
}
|
|
||||||
deviceMapper.batchUpdate(deviceList.subList(i, toIndex));
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
deviceMapper.batchUpdate(deviceList);
|
|
||||||
}
|
|
||||||
for (Device device : deviceList) {
|
|
||||||
redisCatchStorage.updateDevice(device);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isExist(String deviceId) {
|
public boolean isExist(String deviceId) {
|
||||||
return getDeviceByDeviceIdFromDb(deviceId) != null;
|
return getDeviceByDeviceIdFromDb(deviceId) != null;
|
||||||
|
|||||||
@ -87,7 +87,6 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
|
|||||||
if (handlerCatchDataList.isEmpty()) {
|
if (handlerCatchDataList.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<Device> deviceListForUpdate = new ArrayList<>();
|
|
||||||
for (SipMsgInfo sipMsgInfo : handlerCatchDataList) {
|
for (SipMsgInfo sipMsgInfo : handlerCatchDataList) {
|
||||||
if (sipMsgInfo == null) {
|
if (sipMsgInfo == null) {
|
||||||
continue;
|
continue;
|
||||||
@ -114,7 +113,7 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
|
|||||||
device.setKeepaliveTime(DateUtil.getNow());
|
device.setKeepaliveTime(DateUtil.getNow());
|
||||||
|
|
||||||
if (device.isOnLine()) {
|
if (device.isOnLine()) {
|
||||||
deviceListForUpdate.add(device);
|
deviceService.updateDevice(device);
|
||||||
long expiresTime = Math.min(device.getExpires(), device.getHeartBeatInterval() * device.getHeartBeatCount()) * 1000L;
|
long expiresTime = Math.min(device.getExpires(), device.getHeartBeatInterval() * device.getHeartBeatCount()) * 1000L;
|
||||||
if (statusTaskRunner.containsKey(device.getDeviceId())) {
|
if (statusTaskRunner.containsKey(device.getDeviceId())) {
|
||||||
statusTaskRunner.updateDelay(device.getDeviceId(), expiresTime + System.currentTimeMillis());
|
statusTaskRunner.updateDelay(device.getDeviceId(), expiresTime + System.currentTimeMillis());
|
||||||
@ -126,9 +125,6 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!deviceListForUpdate.isEmpty()) {
|
|
||||||
deviceService.updateDeviceList(deviceListForUpdate);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user