|
|
|
@ -3,6 +3,7 @@ package com.thing.listener; |
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode; |
|
|
|
import com.thing.common.cache.constants.CacheNameEnum; |
|
|
|
import com.thing.common.core.constants.Constant; |
|
|
|
import com.thing.common.core.enumeration.GateWayStatus; |
|
|
|
import com.thing.common.core.enumeration.QueueOriginType; |
|
|
|
import com.thing.common.core.enumeration.TemplateMark; |
|
|
|
@ -18,6 +19,7 @@ import com.thing.thing.entity.dto.IotThingViewDTO; |
|
|
|
import com.thing.thing.entity.entity.IotThingEntity; |
|
|
|
import com.thing.thing.entity.service.IotThingEntityService; |
|
|
|
import com.thing.thing.model.dto.IotThingModelDTO; |
|
|
|
import com.thing.thing.model.dto.ModelDetailDTO; |
|
|
|
import com.thing.thing.model.entity.IotThingModelEntity; |
|
|
|
import com.thing.thing.model.service.IotThingModelService; |
|
|
|
import com.thing.transport.api.adaptor.JsonConverter; |
|
|
|
@ -72,10 +74,11 @@ public class QueueDeviceEventListener { |
|
|
|
Long tenantCode = thingEntry.getKey(); |
|
|
|
QueueMsgDTO queueMsgDTO = thingEntry.getValue().get(0); |
|
|
|
//物模型缓存查询 |
|
|
|
ObjectNode jsonObject = thingCache.findAccurateObjectNode(CacheNameEnum.THING_MODEL, thingCode); |
|
|
|
List<ObjectNode> list = thingModelService.findList(CacheNameEnum.ModelField.THING_MODEL_CREATE_DATE.getField(), |
|
|
|
Constant.DESC, thingCode, null, null, null, null, null, null, null); |
|
|
|
//缓存存在,更新,否则插入 |
|
|
|
if (null != jsonObject && !jsonObject.isEmpty()) { |
|
|
|
IotThingModelEntity modelEntity = JacksonUtil.convertValue(jsonObject, IotThingModelEntity.class); |
|
|
|
if (CollectionUtils.isNotEmpty(list)) { |
|
|
|
IotThingModelEntity modelEntity = JacksonUtil.convertValue(list.get(0), IotThingModelEntity.class); |
|
|
|
updateModelList.add(modelEntity); |
|
|
|
} else { |
|
|
|
String origin = QueueOriginType.AUTO_DATA_SYNC.name().equals(queueMsgDTO.getOrigin()) |
|
|
|
@ -96,8 +99,9 @@ public class QueueDeviceEventListener { |
|
|
|
} |
|
|
|
//物实体的构建 |
|
|
|
if (!Objects.equals(queueMsgDTO.getTenantCode(), 1001L)) { |
|
|
|
ObjectNode entityNode = thingCache.findObjectNode(CacheNameEnum.THING_ENTITY, tenantCode + ":" + thingCode); |
|
|
|
if (null == entityNode || entityNode.isEmpty()) { |
|
|
|
List<ObjectNode> entityServiceList = entityService.findList(CacheNameEnum.EntityField.THING_ENTITY_CREATE_DATE.getField(), Constant.DESC, thingCode, null, tenantCode, |
|
|
|
null, null, null, null, null, null); |
|
|
|
if (CollectionUtils.isNotEmpty(entityServiceList)) { |
|
|
|
IotThingEntity newThingEntity = createThingEntity(thingCode, queueMsgDTO.getTenantCode(), queueMsgDTO.getCompanyId(), queueMsgDTO.getDeptId()); |
|
|
|
insertEntityList.add(newThingEntity); |
|
|
|
} |
|
|
|
|