Compare commits

..

1 Commits

Author SHA1 Message Date
WangXuewen
cc90c72eaf
Pre Merge pull request !34 from WangXuewen/master 2025-06-06 07:25:11 +00:00
4 changed files with 3 additions and 75 deletions

View File

@ -426,36 +426,4 @@ public interface DeviceMapper {
"<foreach collection='offlineDevices' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
" </script>"})
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);
}

View File

@ -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.WVPResult;
import com.github.pagehelper.PageInfo;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@ -118,9 +117,6 @@ public interface IDeviceService {
*/
void updateDevice(Device device);
@Transactional
void updateDeviceList(List<Device> deviceList);
/**
* 检查设备编号是否已经存在
* @param deviceId 设备编号

View File

@ -729,6 +729,8 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner {
@Override
public void updateDevice(Device device) {
String now = DateUtil.getNow();
device.setUpdateTime(now);
device.setCharset(device.getCharset() == null ? "" : device.getCharset().toUpperCase());
device.setUpdateTime(DateUtil.getNow());
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
public boolean isExist(String deviceId) {
return getDeviceByDeviceIdFromDb(deviceId) != null;

View File

@ -87,7 +87,6 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
if (handlerCatchDataList.isEmpty()) {
return;
}
List<Device> deviceListForUpdate = new ArrayList<>();
for (SipMsgInfo sipMsgInfo : handlerCatchDataList) {
if (sipMsgInfo == null) {
continue;
@ -114,7 +113,7 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
device.setKeepaliveTime(DateUtil.getNow());
if (device.isOnLine()) {
deviceListForUpdate.add(device);
deviceService.updateDevice(device);
long expiresTime = Math.min(device.getExpires(), device.getHeartBeatInterval() * device.getHeartBeatCount()) * 1000L;
if (statusTaskRunner.containsKey(device.getDeviceId())) {
statusTaskRunner.updateDelay(device.getDeviceId(), expiresTime + System.currentTimeMillis());
@ -126,9 +125,6 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
}
}
}
if (!deviceListForUpdate.isEmpty()) {
deviceService.updateDeviceList(deviceListForUpdate);
}
}
@Override