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