接口修改
This commit is contained in:
parent
6771ee6345
commit
d63d79cda3
@ -0,0 +1,11 @@
|
|||||||
|
package com.das.modules.equipment.domain.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class BaseImptabmappingVo {
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
private String params;
|
||||||
|
}
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
import com.das.modules.auth.mapper.BaseMapperPlus;
|
import com.das.modules.auth.mapper.BaseMapperPlus;
|
||||||
import com.das.modules.equipment.domain.dto.SysEquipmentDto;
|
import com.das.modules.equipment.domain.dto.SysEquipmentDto;
|
||||||
import com.das.modules.equipment.domain.excel.SysEquipmentExcel;
|
import com.das.modules.equipment.domain.excel.SysEquipmentExcel;
|
||||||
|
import com.das.modules.equipment.domain.vo.BaseImptabmappingVo;
|
||||||
import com.das.modules.equipment.domain.vo.SysEquipmentVo;
|
import com.das.modules.equipment.domain.vo.SysEquipmentVo;
|
||||||
import com.das.modules.equipment.entity.SysEquipment;
|
import com.das.modules.equipment.entity.SysEquipment;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
@ -26,10 +27,10 @@ public interface SysEquipmentMapper extends BaseMapperPlus<SysEquipment, SysEqui
|
|||||||
void updateIotAddr(Long id, String iotAddr);
|
void updateIotAddr(Long id, String iotAddr);
|
||||||
|
|
||||||
// 获取设备的属性信息
|
// 获取设备的属性信息
|
||||||
List<String> getEquipmentAttributeInfo(Long equipmentId);
|
List<BaseImptabmappingVo> getEquipmentAttributeInfo(Long equipmentId);
|
||||||
|
|
||||||
// 获取设备的动作信息
|
// 获取设备的动作信息
|
||||||
List<String> getEquipmentServiceInfo(Long equipmentId);
|
List<BaseImptabmappingVo> getEquipmentServiceInfo(Long equipmentId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,14 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
@Service(value = NodeConstant.INIT_DEVICE_DATA)
|
@Service(value = NodeConstant.INIT_DEVICE_DATA)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class InitDeviceDataCommand implements BaseCommand{
|
public class InitDeviceDataCommand implements BaseCommand{
|
||||||
|
|
||||||
|
public static final String DEVICE_DATA = "deviceData:{0}";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
AdminRedisTemplate adminRedisTemplate;
|
AdminRedisTemplate adminRedisTemplate;
|
||||||
@Override
|
@Override
|
||||||
@ -22,8 +26,9 @@ public class InitDeviceDataCommand implements BaseCommand{
|
|||||||
if (!dataInfo.isEmpty()) {
|
if (!dataInfo.isEmpty()) {
|
||||||
String deviceId = dataInfo.get("deviceId").asText();
|
String deviceId = dataInfo.get("deviceId").asText();
|
||||||
JsonNode values = dataInfo.get("values");
|
JsonNode values = dataInfo.get("values");
|
||||||
|
String key = MessageFormat.format(DEVICE_DATA, deviceId);
|
||||||
// 存入redis
|
// 存入redis
|
||||||
adminRedisTemplate.set(deviceId, values);
|
adminRedisTemplate.set(key, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,8 @@ public class DataServiceImpl implements DataService {
|
|||||||
|
|
||||||
public ConcurrentHashMap<String, Map<String, Object>> iotFieldMap = new ConcurrentHashMap<>(10000);
|
public ConcurrentHashMap<String, Map<String, Object>> iotFieldMap = new ConcurrentHashMap<>(10000);
|
||||||
|
|
||||||
|
public static final String DEVICE_DATA = "deviceData:{0}";
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
//初始化高性能队列
|
//初始化高性能队列
|
||||||
@ -229,7 +231,8 @@ public class DataServiceImpl implements DataService {
|
|||||||
// 先从redis里面获取设备的初始化数据
|
// 先从redis里面获取设备的初始化数据
|
||||||
JsonNode jsonNode = data.getData();
|
JsonNode jsonNode = data.getData();
|
||||||
String deviceId = jsonNode.get("deviceId").asText();
|
String deviceId = jsonNode.get("deviceId").asText();
|
||||||
HashMap<String, Object> initValue = adminRedisTemplate.get(deviceId);
|
String key = String.format(DEVICE_DATA, deviceId);
|
||||||
|
HashMap<String, Object> initValue = adminRedisTemplate.get(key);
|
||||||
JsonNode values = jsonNode.get("values");
|
JsonNode values = jsonNode.get("values");
|
||||||
List<Map.Entry<String, Object>> entryList = new ArrayList<>(initValue.entrySet());
|
List<Map.Entry<String, Object>> entryList = new ArrayList<>(initValue.entrySet());
|
||||||
HashMap<String, Object> newHashMap = new HashMap<>();
|
HashMap<String, Object> newHashMap = new HashMap<>();
|
||||||
@ -241,12 +244,12 @@ public class DataServiceImpl implements DataService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
adminRedisTemplate.set(deviceId, newHashMap);
|
adminRedisTemplate.set(key, newHashMap);
|
||||||
Long dataTime = data.getTime();
|
Long dataTime = data.getTime();
|
||||||
// 存入td库
|
// 存入td库
|
||||||
// 根据设备ID获取对应的物模型属性
|
// 根据设备ID获取对应的物模型属性
|
||||||
String iotModelCode = sysIotModelMapper.getIotModel(jsonNode.get("deviceId").asLong());
|
String iotModelCode = sysIotModelMapper.getIotModel(jsonNode.get("deviceId").asLong());
|
||||||
HashMap<String, Object> tdValues = adminRedisTemplate.get(deviceId);
|
HashMap<String, Object> tdValues = adminRedisTemplate.get(key);
|
||||||
List<RTData> list = new ArrayList<>();
|
List<RTData> list = new ArrayList<>();
|
||||||
RTData rtData = RTData.builder()
|
RTData rtData = RTData.builder()
|
||||||
.dataTime(dataTime)
|
.dataTime(dataTime)
|
||||||
|
@ -11,6 +11,7 @@ import com.das.common.utils.SequenceUtils;
|
|||||||
import com.das.modules.auth.domain.vo.SysUserVo;
|
import com.das.modules.auth.domain.vo.SysUserVo;
|
||||||
import com.das.modules.auth.entity.SysOrg;
|
import com.das.modules.auth.entity.SysOrg;
|
||||||
import com.das.modules.auth.mapper.SysOrgMapper;
|
import com.das.modules.auth.mapper.SysOrgMapper;
|
||||||
|
import com.das.modules.equipment.domain.vo.BaseImptabmappingVo;
|
||||||
import com.das.modules.equipment.mapper.SysEquipmentMapper;
|
import com.das.modules.equipment.mapper.SysEquipmentMapper;
|
||||||
import com.das.modules.equipment.mapper.SysIotModelMapper;
|
import com.das.modules.equipment.mapper.SysIotModelMapper;
|
||||||
import com.das.modules.node.constant.NodeConstant;
|
import com.das.modules.node.constant.NodeConstant;
|
||||||
@ -213,9 +214,9 @@ public class SysNodeServiceImpl implements SysNodeService {
|
|||||||
if (CollectionUtils.isEmpty(bindDeviceList)) {
|
if (CollectionUtils.isEmpty(bindDeviceList)) {
|
||||||
addSysImptabmapping(equipmentId, linkId, sysUserVo, addList);
|
addSysImptabmapping(equipmentId, linkId, sysUserVo, addList);
|
||||||
} else {
|
} else {
|
||||||
|
addSysImptabmapping(equipmentId, linkId, sysUserVo, addList);
|
||||||
// 删除原来绑定的设备信息
|
// 删除原来绑定的设备信息
|
||||||
sysImptabmappingMapper.deleteBindDevice(linkId);
|
sysImptabmappingMapper.deleteBindDevice(linkId);
|
||||||
addSysImptabmapping(equipmentId, linkId, sysUserVo, addList);
|
|
||||||
}
|
}
|
||||||
if (!CollectionUtils.isEmpty(addList)) {
|
if (!CollectionUtils.isEmpty(addList)) {
|
||||||
sysImptabmappingMapper.insertBatch(addList);
|
sysImptabmappingMapper.insertBatch(addList);
|
||||||
@ -350,19 +351,21 @@ public class SysNodeServiceImpl implements SysNodeService {
|
|||||||
|
|
||||||
// 获取设备的测点信息
|
// 获取设备的测点信息
|
||||||
for (BindEquipmentInfoDto info : equipmentId) {
|
for (BindEquipmentInfoDto info : equipmentId) {
|
||||||
List<String> fieldList = sysEquipmentMapper.getEquipmentAttributeInfo(info.getEquipmentId());
|
List<BaseImptabmappingVo> fieldList = sysEquipmentMapper.getEquipmentAttributeInfo(info.getEquipmentId());
|
||||||
List<String> serviceList = sysEquipmentMapper.getEquipmentServiceInfo(info.getEquipmentId());
|
List<BaseImptabmappingVo> serviceList = sysEquipmentMapper.getEquipmentServiceInfo(info.getEquipmentId());
|
||||||
if (!CollectionUtils.isEmpty(fieldList)) {
|
if (!CollectionUtils.isEmpty(fieldList)) {
|
||||||
for (String field : fieldList) {
|
for (BaseImptabmappingVo field : fieldList) {
|
||||||
SysImptabmapping sysImptabmapping = getSysImptabmapping(linkId, sysUserVo, info);
|
SysImptabmapping sysImptabmapping = getSysImptabmapping(linkId, sysUserVo, info);
|
||||||
sysImptabmapping.setEquipmentAttribute(field);
|
sysImptabmapping.setEquipmentAttribute(field.getCode());
|
||||||
|
sysImptabmapping.setParams(field.getParams());
|
||||||
addList.add(sysImptabmapping);
|
addList.add(sysImptabmapping);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!CollectionUtils.isEmpty(serviceList)) {
|
if (!CollectionUtils.isEmpty(serviceList)) {
|
||||||
for (String service : serviceList) {
|
for (BaseImptabmappingVo service : serviceList) {
|
||||||
SysImptabmapping sysImptabmapping = getSysImptabmapping(linkId, sysUserVo, info);
|
SysImptabmapping sysImptabmapping = getSysImptabmapping(linkId, sysUserVo, info);
|
||||||
sysImptabmapping.setEquipmentService(service);
|
sysImptabmapping.setEquipmentService(service.getCode());
|
||||||
|
sysImptabmapping.setParams(service.getParams());
|
||||||
addList.add(sysImptabmapping);
|
addList.add(sysImptabmapping);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,15 +116,17 @@
|
|||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
|
||||||
<select id="getEquipmentAttributeInfo" resultType="java.lang.String">
|
<select id="getEquipmentAttributeInfo" resultType="com.das.modules.equipment.domain.vo.BaseImptabmappingVo">
|
||||||
select simf.attribute_code from sys_iot_model_field simf
|
select simf.attribute_code as code, si.params from sys_iot_model_field simf
|
||||||
left join sys_equipment se on simf.iot_model_id = se.iot_model_id
|
left join sys_equipment se on simf.iot_model_id = se.iot_model_id
|
||||||
|
left join sys_imptabmapping si on si.equipment_attribute = simf.attribute_code
|
||||||
where se.id = #{id}
|
where se.id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getEquipmentServiceInfo" resultType="java.lang.String">
|
<select id="getEquipmentServiceInfo" resultType="com.das.modules.equipment.domain.vo.BaseImptabmappingVo">
|
||||||
select sims.service_code from sys_iot_model_service sims
|
select sims.service_code as code, si.params from sys_iot_model_service sims
|
||||||
left join sys_equipment se on sims.iot_model_id = se.iot_model_id
|
left join sys_equipment se on sims.iot_model_id = se.iot_model_id
|
||||||
|
left join sys_imptabmapping si on si.equipment_attribute = sims.service_code
|
||||||
where se.id = #{id}
|
where se.id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user