1.修复删除点位缓存未清除
2.修复saas端下发时间配置未更新问题 3.修复重连失败问题
This commit is contained in:
parent
fd65318629
commit
493420bb76
@ -91,7 +91,7 @@
|
||||
<dependency>
|
||||
<groupId>org.eclipse.paho</groupId>
|
||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||
<version>1.1.0</version>
|
||||
<version>1.2.0</version>
|
||||
</dependency>
|
||||
<!--quartz依赖-->
|
||||
<dependency>
|
||||
|
||||
@ -83,9 +83,12 @@ public class CenterServiceImpl implements CenterService {
|
||||
public void reconnected() {
|
||||
if (!this.isConnected()) {
|
||||
try {
|
||||
mqttClientService.getClient().reconnect();
|
||||
} catch (MqttException e) {
|
||||
if (!mqttClientService.reconnect()) {
|
||||
log.error("Mqtt重连失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Mqtt重连失败:{}", e.getMessage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -362,7 +362,7 @@ public class ConnectionServiceImpl extends ServiceImpl<ConnectionMapper, Connect
|
||||
itemEntityMap.clear();
|
||||
}
|
||||
connectionItemService.remove(new QueryWrapper<ConnectionItemEntity>().eq("connection_id", connectionEntity.getId()));
|
||||
|
||||
BuffContext.itemBuff.get(connectionEntity.getDeviceId()).clear();
|
||||
List<ConnectionItemEntity> itemEntities = new ArrayList<>();
|
||||
items.forEach(
|
||||
i -> {
|
||||
@ -504,20 +504,21 @@ public class ConnectionServiceImpl extends ServiceImpl<ConnectionMapper, Connect
|
||||
jobDataMap.put("deviceId", deviceId);
|
||||
jobDetail = JobBuilder.newJob(ClientUploadJob.class).setJobData(jobDataMap).build();
|
||||
} else {
|
||||
scheduler.pauseJob(jobDetail.getKey());
|
||||
scheduler.deleteJob(jobDetail.getKey());
|
||||
}
|
||||
if (trigger == null) {
|
||||
String corn = null;
|
||||
if (uploadType == 0) {
|
||||
trigger = TriggerBuilder.newTrigger().withSchedule(SimpleScheduleBuilder.repeatSecondlyForever(uploadcycle)).build();
|
||||
} else if (uploadType == 1 && uploadcycle < 60) {
|
||||
corn = "0 " + "0/" + uploadcycle + " * * * ?";
|
||||
trigger = TriggerBuilder.newTrigger().withSchedule(CronScheduleBuilder.cronSchedule(corn)).build();
|
||||
} else if (uploadType == 1 && uploadcycle >= 60) {
|
||||
corn = "0 0" + "0/" + uploadcycle / 60 + " * * ?";
|
||||
trigger = TriggerBuilder.newTrigger().withSchedule(CronScheduleBuilder.cronSchedule(corn)).build();
|
||||
}
|
||||
|
||||
String corn = null;
|
||||
if (uploadType == 0) {
|
||||
trigger = TriggerBuilder.newTrigger().withSchedule(SimpleScheduleBuilder.repeatSecondlyForever(uploadcycle)).build();
|
||||
} else if (uploadType == 1 && uploadcycle < 60) {
|
||||
corn = "0 " + "0/" + uploadcycle + " * * * ?";
|
||||
trigger = TriggerBuilder.newTrigger().withSchedule(CronScheduleBuilder.cronSchedule(corn)).build();
|
||||
} else if (uploadType == 1 && uploadcycle >= 60) {
|
||||
corn = "0 0" + "0/" + uploadcycle / 60 + " * * ?";
|
||||
trigger = TriggerBuilder.newTrigger().withSchedule(CronScheduleBuilder.cronSchedule(corn)).build();
|
||||
}
|
||||
|
||||
QuartzContext.jobs.put(deviceId, jobDetail);
|
||||
QuartzContext.triggers.put(deviceId, trigger);
|
||||
if (status == 1) {
|
||||
|
||||
@ -48,13 +48,13 @@ public class MqttClientServiceImpl implements MqttClientService {
|
||||
@Autowired
|
||||
ClientService clientService;
|
||||
|
||||
MqttConnectOptions options = new MqttConnectOptions();
|
||||
|
||||
@Override
|
||||
public Boolean init(String host, Integer port, String username, String password, String clientId, MqttCallback publishCallBack, List<String> sTopic, int qos) {
|
||||
try {
|
||||
host = "tcp://" + host + ":" + port;
|
||||
client = new MqttClient(host, clientId);
|
||||
MqttConnectOptions options;
|
||||
options = new MqttConnectOptions();
|
||||
options.setCleanSession(true);
|
||||
options.setKeepAliveInterval(10);
|
||||
options.setConnectionTimeout(50);
|
||||
@ -109,11 +109,11 @@ public class MqttClientServiceImpl implements MqttClientService {
|
||||
if (!client.isConnected()) {
|
||||
client.reconnect();
|
||||
}
|
||||
return client.isConnected();
|
||||
} catch (Exception e) {
|
||||
log.error("Mqtt客户端重连失败:{}", e.getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -206,8 +206,18 @@ public class MqttInfoServiceImpl implements MqttInfoService {
|
||||
ConfigContext.items.get(connectionEntity.getDeviceId()).put(connectionItemEntity.getItemCode(), connectionItemEntity);
|
||||
}
|
||||
}
|
||||
|
||||
//点位同步
|
||||
if (CollectionUtils.isNotEmpty(i.getItems())) {
|
||||
connectionItemService.remove(new QueryWrapper<ConnectionItemEntity>().eq("connection_id", connectionEntity.getId()).notIn("item_code", i.getItems()));
|
||||
Map<String, ItemUploadDTO.Value> buffMap = BuffContext.itemBuff.get(connectionEntity.getDeviceId());
|
||||
if (CollectionUtils.isNotEmpty(buffMap)) {
|
||||
for (String itemCode : buffMap.keySet()) {
|
||||
if (!i.getItems().contains(itemCode)) {
|
||||
buffMap.remove(itemCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user