Compare commits

...

3 Commits

Author SHA1 Message Date
阿斌
7c410f644e
Pre Merge pull request !36 from 阿斌/N/A 2025-06-10 01:45:14 +00:00
lin
98ea5846fe 心跳入库 支持批量入库 2025-06-10 09:45:02 +08:00
阿斌
da98101aac
update src/main/resources/civilCode.csv.
行政规划错误。江苏南通海门市,修改为海门区,浙江杭州删除下城区、江干区,新增钱塘区,临平区

Signed-off-by: 阿斌 <38912748@qq.com>
2024-12-15 08:58:42 +00:00
5 changed files with 78 additions and 6 deletions

View File

@ -426,4 +426,36 @@ 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);
} }

View File

@ -6,6 +6,7 @@ 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;
@ -117,6 +118,9 @@ public interface IDeviceService {
*/ */
void updateDevice(Device device); void updateDevice(Device device);
@Transactional
void updateDeviceList(List<Device> deviceList);
/** /**
* 检查设备编号是否已经存在 * 检查设备编号是否已经存在
* @param deviceId 设备编号 * @param deviceId 设备编号

View File

@ -729,8 +729,6 @@ 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) {
@ -738,6 +736,40 @@ 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;

View File

@ -87,6 +87,7 @@ 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;
@ -113,7 +114,7 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
device.setKeepaliveTime(DateUtil.getNow()); device.setKeepaliveTime(DateUtil.getNow());
if (device.isOnLine()) { if (device.isOnLine()) {
deviceService.updateDevice(device); deviceListForUpdate.add(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());
@ -125,6 +126,9 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
} }
} }
} }
if (!deviceListForUpdate.isEmpty()) {
deviceService.updateDeviceList(deviceListForUpdate);
}
} }
@Override @Override

View File

@ -861,7 +861,7 @@
320623,如东县,3206 320623,如东县,3206
320681,启东市,3206 320681,启东市,3206
320682,如皋市,3206 320682,如皋市,3206
320684,海门,3206 320684,海门,3206
320685,海安市,3206 320685,海安市,3206
3207,连云港市,32 3207,连云港市,32
320703,连云区,3207 320703,连云区,3207
@ -918,8 +918,6 @@
33,浙江省, 33,浙江省,
3301,杭州市,33 3301,杭州市,33
330102,上城区,3301 330102,上城区,3301
330103,下城区,3301
330104,江干区,3301
330105,拱墅区,3301 330105,拱墅区,3301
330106,西湖区,3301 330106,西湖区,3301
330108,滨江区,3301 330108,滨江区,3301
@ -927,6 +925,8 @@
330110,余杭区,3301 330110,余杭区,3301
330111,富阳区,3301 330111,富阳区,3301
330112,临安区,3301 330112,临安区,3301
330113,临平区,3301
330114,钱塘区,3301
330122,桐庐县,3301 330122,桐庐县,3301
330127,淳安县,3301 330127,淳安县,3301
330182,建德市,3301 330182,建德市,3301

1 编号 名称 上级
861 320623 如东县 3206
862 320681 启东市 3206
863 320682 如皋市 3206
864 320684 海门市 海门区 3206
865 320685 海安市 3206
866 3207 连云港市 32
867 320703 连云区 3207
918 33 浙江省
919 3301 杭州市 33
920 330102 上城区 3301
330103 下城区 3301
330104 江干区 3301
921 330105 拱墅区 3301
922 330106 西湖区 3301
923 330108 滨江区 3301
925 330110 余杭区 3301
926 330111 富阳区 3301
927 330112 临安区 3301
928 330113 临平区 3301
929 330114 钱塘区 3301
930 330122 桐庐县 3301
931 330127 淳安县 3301
932 330182 建德市 3301