保存设备上报数据

This commit is contained in:
mi9688
2024-12-19 19:50:28 +08:00
parent 6aa1d542da
commit 5d8e9db6c1
4 changed files with 29 additions and 8 deletions

View File

@ -53,8 +53,14 @@
<groupId>com.fastbee</groupId>
<artifactId>fastbee-notify-core</artifactId>
</dependency>
<dependency>
<groupId>com.fastbee</groupId>
<artifactId>fastbee-rechargecard-service</artifactId>
<version>3.8.5</version>
<scope>compile</scope>
</dependency>
</dependencies>
</dependencies>
</project>

View File

@ -7,6 +7,8 @@ import com.fastbee.common.core.mq.DeviceReportBo;
import com.fastbee.mq.redischannel.producer.IssueInstructionsProducer;
import com.fastbee.mq.service.impl.DeviceOtherMsgHandler;
import com.fastbee.mqttclient.PubMqttClient;
import com.fastbee.rechargecard.domain.NgWaterPumpUsageRecords;
import com.fastbee.rechargecard.mapper.NgWaterPumpUsageRecordsMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
@ -29,6 +31,9 @@ public class DeviceOtherMsgConsumer {
@Autowired
private IssueInstructionsProducer issueInstructionsProducer;
@Autowired
private NgWaterPumpUsageRecordsMapper ngWaterPumpUsageRecordsMapper;
@Autowired
private PubMqttClient pubMqttClient;
@ -53,6 +58,14 @@ public class DeviceOtherMsgConsumer {
//设备上报数据消息
if(topic.endsWith("hzlink/info/up")){
deviceDataReportHandler(new String(data));
//保存使用记录
NgWaterPumpUsageRecords pumpUsageRecords=new NgWaterPumpUsageRecords();
pumpUsageRecords.setDeviceNumber(serialNumber);
pumpUsageRecords.setMessageContent(new String(data));
int i = ngWaterPumpUsageRecordsMapper.insertNgWaterPumpUsageRecords(pumpUsageRecords);
if(i<1){
System.err.println("--------------------------保存使用记录失败!---------------------------");
}
//构建回复消息
Map<String,Object> reportMsg=new HashMap<>();
reportMsg.put("code",0);