|
|
@@ -4,12 +4,19 @@ import com.rabbitmq.client.Channel;
|
|
|
import com.yunfeiyun.agmp.common.framework.mq.rabbitmq.enums.TosActionEnums;
|
|
|
import com.yunfeiyun.agmp.common.framework.mq.rabbitmq.model.SynGlobalTenantInfoDto;
|
|
|
import com.yunfeiyun.agmp.common.utils.JSONUtils;
|
|
|
+import com.yunfeiyun.agmp.iot.common.domain.TosDeviceclass;
|
|
|
+import com.yunfeiyun.agmp.iot.common.domain.TosDevicetype;
|
|
|
+import com.yunfeiyun.agmp.iot.common.domain.TosFirm;
|
|
|
+import com.yunfeiyun.agmp.iotm.device.service.ITosDeviceclassService;
|
|
|
+import com.yunfeiyun.agmp.iotm.device.service.ITosDevicetypeService;
|
|
|
+import com.yunfeiyun.agmp.iotm.device.service.ITosFirmService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.amqp.core.Message;
|
|
|
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.io.IOException;
|
|
|
|
|
|
/**
|
|
|
@@ -24,6 +31,12 @@ import java.io.IOException;
|
|
|
@ConditionalOnBean(name = "tosMqConfig")
|
|
|
public class TosChannelGlobalAwareMessageListener implements ChannelAwareMessageListener {
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ITosDevicetypeService tosDevicetypeService;
|
|
|
+ @Resource
|
|
|
+ private ITosDeviceclassService tosDeviceclassService;
|
|
|
+ @Resource
|
|
|
+ private ITosFirmService tosFirmService;
|
|
|
@Override
|
|
|
public void onMessage(Message message, Channel channel) throws Exception {
|
|
|
try {
|
|
|
@@ -37,7 +50,33 @@ public class TosChannelGlobalAwareMessageListener implements ChannelAwareMessage
|
|
|
TosActionEnums tosActionEnums = TosActionEnums.getAction(action);
|
|
|
if (tosActionEnums != null) {
|
|
|
switch (tosActionEnums) {
|
|
|
-
|
|
|
+ case TOS_DEVICE_TYPE_CREATE:
|
|
|
+ tosDevicetypeService.insertTosDevicetype(synGlobalTenantInfoDto.getData().to(TosDevicetype.class));
|
|
|
+ break;
|
|
|
+ case TOS_DEVICE_TYPE_UPDATE:
|
|
|
+ tosDevicetypeService.updateTosDevicetype(synGlobalTenantInfoDto.getData().to(TosDevicetype.class));
|
|
|
+ break;
|
|
|
+ case TOS_DEVICE_TYPE_DELETE:
|
|
|
+ tosDevicetypeService.deleteTosDevicetypeByDevtypeBid(synGlobalTenantInfoDto.getData().to(TosDevicetype.class));
|
|
|
+ break;
|
|
|
+ case TOS_DEVICE_CLASS_CREATE:
|
|
|
+ tosDeviceclassService.insertTosDeviceclass(synGlobalTenantInfoDto.getData().to(TosDeviceclass.class));
|
|
|
+ break;
|
|
|
+ case TOS_DEVICE_CLASS_UPDATE:
|
|
|
+ tosDeviceclassService.updateTosDeviceclass(synGlobalTenantInfoDto.getData().to(TosDeviceclass.class));
|
|
|
+ break;
|
|
|
+ case TOS_DEVICE_CLASS_DELETE:
|
|
|
+ tosDeviceclassService.deleteTosDeviceclassByDevclassBid(synGlobalTenantInfoDto.getData().to(TosDeviceclass.class));
|
|
|
+ break;
|
|
|
+ case TOS_FIRM_CREATE:
|
|
|
+ tosFirmService.insertTosFirm(synGlobalTenantInfoDto.getData().to(TosFirm.class));
|
|
|
+ break;
|
|
|
+ case TOS_FIRM_UPDATE:
|
|
|
+ tosFirmService.updateTosFirm(synGlobalTenantInfoDto.getData().to(TosFirm.class));
|
|
|
+ break;
|
|
|
+ case TOS_FIRM_DELETE:
|
|
|
+ tosFirmService.deleteTosFirmByFirmBid(synGlobalTenantInfoDto.getData().to(TosFirm.class));
|
|
|
+ break;
|
|
|
}
|
|
|
} else {
|
|
|
log.error("【SAAS:】收到Tos:所有租户处理的消息:action 为空,忽略消息");
|