Commit 27b684b6 authored by 刘林's avatar 刘林

fix(equip):装备代码集成influxDB,版本1.0

parent 05a123c4
......@@ -56,6 +56,12 @@
<artifactId>amos-component-security</artifactId>
<version>1.7.13-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-component-influxdb</artifactId>
<version>1.8.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
......@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.component.influxdb.InfluxDbConnection;
import com.yeejoin.amos.feign.systemctl.model.MessageModel;
import com.yeejoin.equipmanage.common.datasync.entity.FireEquipmentDefectAlarm;
import com.yeejoin.equipmanage.common.datasync.entity.FireEquipmentFaultAlarm;
......@@ -111,6 +112,10 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
//消防炮
@Value("${equipment.plan.monitor}")
String monitorCodes;
@Autowired
private InfluxDbConnection influxDbConnection;
/**
* 泡沫罐KEY
*/
......@@ -601,6 +606,11 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
@Override
@Transactional(rollbackFor = Exception.class)
public void handlerMqttIotMessage(String topic, String message) {
//influxdb
Map<String, String> tagsMap = new HashMap<>();
Map<String, Object> fieldsMap = new HashMap<>();
Map<String, Object> fieldsStrMap = new HashMap<>();
log.info("接收到iot消息: {}", message);
TopicEntityVo topicEntity = new TopicEntityVo();
topicEntity.setTopic(topic);
......@@ -613,9 +623,11 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
String dataType = jsonObject.getString("dataType");
String indexAddress = jsonObject.getString("address");
String traceId = jsonObject.getString("traceId");
String deviceCode = jsonObject.getString("deviceCode");
String gatewayId = jsonObject.getString("gatewayId");
String value=jsonObject.getString("value");
EquipmentSpecificIndex equipmentSpeIndex = equipmentSpecificIndexService.getEquipmentSpeIndexByIndexAddress(indexAddress,gatewayId);
if (equipmentSpeIndex == null){
return;
......@@ -630,8 +642,24 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
equipmentSpeIndex.setTraceId(traceId);
equipmentSpeIndex.setUUID(UUIDUtils.getUUID());
//更新装备性能指标
equipmentSpecificIndexService.updateById(equipmentSpeIndex);
//equipmentSpecificIndexService.updateById(equipmentSpeIndex);
tagsMap.put("key", indexAddress+"_"+gatewayId);
fieldsMap.put("traceId", traceId);
fieldsMap.put("address", indexAddress);
fieldsMap.put("value", value);
fieldsMap.put("gatewayId", gatewayId);
fieldsMap.put("dataType", dataType);
fieldsMap.put("equipmentId", equipmentSpeIndex.getEquipmentId());
fieldsMap.put("equipmentIndexName", equipmentSpeIndex.getEquipmentIndexName());
fieldsMap.put("equipmentIndexKey", equipmentSpeIndex.getEquipmentIndexKey());
fieldsMap.put("isAlarm", equipmentSpeIndex.getIsAlarm().toString());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
fieldsMap.put("createdTime", simpleDateFormat.format(new Date()));
fieldsMap.put("equipment", JSON.toJSONString(equipmentSpeIndex));
influxDbConnection.insert("iot_data", tagsMap, fieldsMap);
QueryWrapper<EquipmentSpecific> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id", equipmentSpeIndex.getEquipmentSpecificId());
......
......@@ -135,3 +135,13 @@ water.level.indexKey=FHS_FirePoolDevice_WaterLevel,FHS_LevelDetector_WaterLevel,
mileage.parameter=0.5
# 江西电建-车辆里程跨天记录切分(每日0点执行)
mileage.segmentation.cron=0 0 0 * * ?
# influxDB
spring.influx.url=http://172.16.11.201:8086
spring.influx.password=Yeejoin@2020
spring.influx.user=root
spring.influx.database=iot_platform
spring.influx.retention_policy=default
spring.influx.retention_policy_time=30d
spring.influx.actions=10000
spring.influx.bufferLimit=20000
\ No newline at end of file
......@@ -9,7 +9,7 @@ spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#mybatis mapper file
mybatis.mapper-locations=classpath:mapper/*.xml
#mybatis-plus
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.slf4j.Slf4jImpl
# mybatis entity package
mybatis.type-aliases-package=com.yeejoin.equipmanage.common.entity
spring.jackson.time-zone=GMT+8
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment