初始化设备id物模型code映射缓存

This commit is contained in:
huguanghan 2024-10-31 17:53:49 +08:00
parent 6d53615f8c
commit 292f018bde
3 changed files with 18 additions and 6 deletions

View File

@ -9,11 +9,12 @@ import com.das.modules.data.domain.TSValueQueryParam;
import com.das.modules.data.service.DataService;
import com.das.modules.data.service.TDEngineService;
import com.das.modules.equipment.domain.vo.IotModelFieldVo;
import com.das.modules.equipment.domain.vo.SysEquipmentVo;
import com.das.modules.equipment.entity.SysIotModelField;
import com.das.modules.equipment.mapper.SysEquipmentMapper;
import com.das.modules.equipment.mapper.SysIotModelFieldMapper;
import com.das.modules.equipment.mapper.SysIotModelMapper;
import com.das.modules.node.domain.bo.CalculateRTData;
import com.das.modules.node.service.impl.NodeMessageServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -36,10 +37,10 @@ public class DataServiceImpl implements DataService {
private SysIotModelFieldMapper sysIotModelFieldMapper;
@Autowired
private TDEngineService tdEngineService;
private SysEquipmentMapper sysEquipmentMapper;
@Autowired
private NodeMessageServiceImpl dataService;
private TDEngineService tdEngineService;
@Autowired
SysIotModelMapper sysIotModelMapper;
@ -50,13 +51,13 @@ public class DataServiceImpl implements DataService {
//key:modelId value:modelCode
public ConcurrentHashMap<String, String> iotModelMap = new ConcurrentHashMap<>(10000);
//key:modelCode value:Filed:Code,dataType
//key:modelCode value:FiledCode,dataType
public ConcurrentHashMap<String, Map<String, Object>> highIotFieldMap = new ConcurrentHashMap<>(10000);
//key:modelCode value:Filed:Code,dataType
//key:modelCode value:FiledCode,dataType
public ConcurrentHashMap<String, Map<String, Object>> lowIotFieldMap = new ConcurrentHashMap<>(10000);
//key:modelCode value:Filed:Code,dataType
//key:modelCode value:FiledCode,dataType
public ConcurrentHashMap<String, Map<String, String>> calculateIotFieldMap = new ConcurrentHashMap<>(10000);
/**
@ -182,6 +183,10 @@ public class DataServiceImpl implements DataService {
@Override
public void createTdStable() {
List<SysEquipmentVo> sysEquipmentVos = sysEquipmentMapper.queryAllIdModelCodeMapping();
for (SysEquipmentVo item : sysEquipmentVos){
deviceModelMap.put(item.getId().toString(), item.getModel());
}
List<IotModelFieldVo> allIotModel = sysIotModelMapper.getAllIotModel();
for (IotModelFieldVo item : allIotModel) {
String key = String.valueOf(item.getId());

View File

@ -54,5 +54,7 @@ public interface SysEquipmentMapper extends BaseMapperPlus<SysEquipment, SysEqui
*/
List<SysEquipmentVo> queryEquipmentList(@Param("info") SysEquipmentDto sysEquipmentDto);
List<SysEquipmentVo> queryAllIdModelCodeMapping();
}

View File

@ -168,5 +168,10 @@
</where>
order by t.name
</select>
<select id="queryAllIdModelCodeMapping" resultType="com.das.modules.equipment.domain.vo.SysEquipmentVo">
select se.id as id,sim.iot_model_code as model from sys_equipment se
left join sys_iot_model sim on se.iot_model_id = sim.id
where se.iot_model_id is not null
</select>
</mapper>