|
|
@@ -2,6 +2,7 @@ package com.zswl.dataservice.service.mqtt;
|
|
|
|
|
|
import com.zswl.dataservice.dao.mqtt.*;
|
|
|
import com.zswl.dataservice.domain.mqtt.*;
|
|
|
+import com.zswl.dataservice.event.GateWaySyncEvent;
|
|
|
import com.zswl.dataservice.model.mqtt.*;
|
|
|
import com.zswl.dataservice.utils.DateUtils;
|
|
|
import com.zswl.dataservice.utils.bean.BeanUtils;
|
|
|
@@ -16,6 +17,7 @@ import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.context.ApplicationContext;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -61,6 +63,12 @@ public class GateWayInfoService {
|
|
|
@Autowired
|
|
|
OperationLogsService operationLogsService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ApplicationContext applicationContext;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ DeviceSyncFullCardService deviceSyncFullCardService;
|
|
|
+
|
|
|
/**
|
|
|
* 添加网关
|
|
|
*
|
|
|
@@ -69,15 +77,25 @@ public class GateWayInfoService {
|
|
|
*/
|
|
|
public ResultContent addGateWayInfo(GateWayInfoAddParam param) {
|
|
|
GateWayInfo gateWayInfo = gateWayInfoDao.findTopByGateWayId(param.getGateWayId());
|
|
|
- if (ObjectUtils.isNotEmpty(gateWayInfo)) {
|
|
|
- return ResultContent.buildFail(String.format("网关ID已存在:%s", param.getGateWayId()));
|
|
|
+ if(ObjectUtils.isEmpty(gateWayInfo)){
|
|
|
+ gateWayInfo = new GateWayInfo();
|
|
|
}
|
|
|
- gateWayInfo = new GateWayInfo();
|
|
|
BeanUtils.copyProperties(param, gateWayInfo);
|
|
|
if (param.getState() == null) {
|
|
|
gateWayInfo.setState(OnLineState.OffLine);
|
|
|
}
|
|
|
gateWayInfoDao.save(gateWayInfo);
|
|
|
+ deviceSyncFullCardService.noticeSyncGateWay(gateWayInfo);
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 注册网关
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent registerGateWay(GateWayInfoAddParam param){
|
|
|
+ addGateWayInfo(param);
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|