|
|
@@ -2,6 +2,7 @@ package com.zswl.dataservice.service.sync;
|
|
|
|
|
|
import com.github.microservice.models.device.DeviceInfoSyncParam;
|
|
|
import com.github.microservice.models.device.DeviceSyncListParam;
|
|
|
+import com.github.microservice.models.device.GateWaySyncParam;
|
|
|
import com.zswl.dataservice.dao.mqtt.DeviceInfoDao;
|
|
|
import com.zswl.dataservice.dao.mqtt.GateWay2DeviceDao;
|
|
|
import com.zswl.dataservice.dao.mqtt.GateWayInfoDao;
|
|
|
@@ -133,8 +134,8 @@ public class DeviceSyncFullCardService extends SuperService {
|
|
|
}).collect(Collectors.toList());
|
|
|
}
|
|
|
param.setList(deviceInfos);
|
|
|
-// APIResponseModel api = apiRequestService.sendFullCardAPI(FullCardAPIConfig.deviceSync, param);
|
|
|
-// log.info("同步设备情况:{} {}", api.isSuccess(), api.getMsg());
|
|
|
+ APIResponseModel api = apiRequestService.sendFullCardAPI(FullCardAPIConfig.deviceSync, param);
|
|
|
+ log.info("同步设备情况:{} {}", api.isSuccess(), api.getMsg());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -145,7 +146,15 @@ public class DeviceSyncFullCardService extends SuperService {
|
|
|
*/
|
|
|
public ResultContent noticeSyncGateWay(GateWayInfo gateWayInfo) {
|
|
|
if (ObjectUtils.isNotEmpty(gateWayInfo)) {
|
|
|
- GateWaySyncEvent event = new GateWaySyncEvent(this, gateWayInfo.getGateWayId());
|
|
|
+ GateWaySyncEvent event = new GateWaySyncEvent(this, List.of(gateWayInfo.getGateWayId()));
|
|
|
+ applicationContext.publishEvent(event);
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultContent noticeSyncGateWay(List<GateWayInfo> gateWayInfos) {
|
|
|
+ if (ObjectUtils.isNotEmpty(gateWayInfos)) {
|
|
|
+ GateWaySyncEvent event = new GateWaySyncEvent(this, gateWayInfos.stream().map(it -> it.getGateWayId()).collect(Collectors.toList()));
|
|
|
applicationContext.publishEvent(event);
|
|
|
}
|
|
|
return ResultContent.buildSuccess();
|
|
|
@@ -160,8 +169,19 @@ public class DeviceSyncFullCardService extends SuperService {
|
|
|
@Async
|
|
|
@SneakyThrows
|
|
|
public void syncGateWayInfo(GateWaySyncEvent event) {
|
|
|
- String gatewayId = event.getGateWayId();
|
|
|
- log.info("event syncGateWayInfo: {}", gatewayId);
|
|
|
-
|
|
|
+ List<String> gatewayIds = event.getGateWayIds();
|
|
|
+ log.info("event syncGateWayInfo: {}", gatewayIds);
|
|
|
+ List<GateWayInfo> gateWayInfos = gateWayInfoDao.findByGateWayIdIn(gatewayIds);
|
|
|
+ if (ObjectUtils.isNotEmpty(gateWayInfos)) {
|
|
|
+ GateWaySyncParam syncParam = new GateWaySyncParam();
|
|
|
+ List<GateWaySyncParam.GateWaySyncInfo> list = gateWayInfos.stream().map(it -> {
|
|
|
+ GateWaySyncParam.GateWaySyncInfo syncInfo = new GateWaySyncParam.GateWaySyncInfo();
|
|
|
+ BeanUtils.copyProperties(it, syncInfo);
|
|
|
+ return syncInfo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ syncParam.setList(list);
|
|
|
+ APIResponseModel api = apiRequestService.sendFullCardAPI(FullCardAPIConfig.syncGateWays, syncParam);
|
|
|
+ log.info("同步网关情况:{} {}", api.isSuccess(), api.getMsg());
|
|
|
+ }
|
|
|
}
|
|
|
}
|