|
|
|
@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.google.common.collect.Maps; |
|
|
|
import com.mybatisflex.core.keygen.impl.SnowFlakeIDKeyGenerator; |
|
|
|
@ -40,6 +41,7 @@ import com.thing.thing.dictRelation.dto.IotThingDictRelationDTO; |
|
|
|
import com.thing.thing.dictRelation.param.IotThingDictRelationParamDTO; |
|
|
|
import com.thing.thing.entity.dto.IotThingEntityDictDTO; |
|
|
|
import com.thing.thing.entity.dto.IotThingViewDTO; |
|
|
|
import com.thing.transport.api.adaptor.JsonConverter; |
|
|
|
import com.thing.util.BeanUtil; |
|
|
|
import jakarta.annotation.Resource; |
|
|
|
import jakarta.servlet.http.HttpServletRequest; |
|
|
|
@ -420,21 +422,18 @@ public class IotThingApiServiceImpl extends BaseServiceImpl<IotThingApiMapper, I |
|
|
|
@Override |
|
|
|
public Map<String, Object> websocketApi(Long id) { |
|
|
|
IotThingApiDTO dto = getByIdAs(id, IotThingApiDTO.class); |
|
|
|
if (ObjectUtil.isNull(dto)) { |
|
|
|
dto = mapper.selectOneByQueryAs(QueryWrapper.create().eq(IotThingApiEntity::getRouteId, id), IotThingApiDTO.class); |
|
|
|
if(ObjectUtil.isNull(dto)){ |
|
|
|
return Maps.newHashMap(); |
|
|
|
} |
|
|
|
} |
|
|
|
//todo 这里主要是组态设计的websocket请求,可能需要修改 |
|
|
|
String remark = dto.getRemark(); |
|
|
|
Long tenantCode = dto.getTenantCode(); |
|
|
|
if (StringUtils.equals(remark, "0")) { |
|
|
|
tenantCode = UserContext.getRealTenantCode(); |
|
|
|
} |
|
|
|
// Map<String, Object> params = new HashMap<>(); |
|
|
|
// params.put("id", id); |
|
|
|
// params.put("reqParams", dto.getReqParams()); |
|
|
|
// Map<String, Object> stringObjectMap1 = telemetryById(params); |
|
|
|
// Map<String, Object> stringObjectMap = encapsulationQuery(dto.getThingCondition(), dto.getAttrCondition(), dto.getTimeCondition(), dto.getReqParams(), null, null, dto.getSort(), tenantCode); |
|
|
|
|
|
|
|
return encapsulationQuery(dto.getThingCondition(), dto.getAttrCondition(), dto.getTimeCondition(), dto.getReqParams(), null, null, dto.getSort(), tenantCode); |
|
|
|
} |
|
|
|
|
|
|
|
@ -503,7 +502,7 @@ public class IotThingApiServiceImpl extends BaseServiceImpl<IotThingApiMapper, I |
|
|
|
|
|
|
|
//属性查询类型 |
|
|
|
Map<String, Object> entityResultMap = new HashMap<>(); |
|
|
|
Map<String, IotThingViewDTO> entityInfoMap = new HashMap<>(); |
|
|
|
Map<String, ObjectNode> entityInfoMap = new HashMap<>(); |
|
|
|
ApiEntityAttrDTO attrsEntity = ApiEntityAttrDTO.createFromJson(attrCondition); |
|
|
|
String type = attrsEntity.getType(); |
|
|
|
//过滤条件的封装 |
|
|
|
@ -534,7 +533,8 @@ public class IotThingApiServiceImpl extends BaseServiceImpl<IotThingApiMapper, I |
|
|
|
Map<String, IotThingDictRelationDTO> collect = dictRelationDTOList.orElseGet(Collections::emptyList).stream() |
|
|
|
.collect(Collectors.toMap(IotThingDictRelationDTO::getCode, Function.identity(),(existing, replacement) -> existing)); |
|
|
|
optional.get().setAttrs(collect); |
|
|
|
entityInfoMap.put(code, optional.get()); |
|
|
|
ObjectNode nodes = JsonConverter.convertToJsonObjectObjectNode(optional.get()); |
|
|
|
entityInfoMap.put(code, nodes); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
@ -582,7 +582,8 @@ public class IotThingApiServiceImpl extends BaseServiceImpl<IotThingApiMapper, I |
|
|
|
s-> ConvertUtils.sourceToTarget(s,IotThingDictRelationDTO.class) |
|
|
|
,(existing, replacement) -> existing)); |
|
|
|
optional.get().setAttrs(collect); |
|
|
|
entityInfoMap.put(entityCode, optional.get()); |
|
|
|
ObjectNode nodes = JsonConverter.convertToJsonObjectObjectNode(optional.get()); |
|
|
|
entityInfoMap.put(entityCode, nodes); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|