From 87a2fe3e6f1472a7e87e02d3fd956eee17b85352 Mon Sep 17 00:00:00 2001
From: aijinhui <aijinhui>
Date: 星期四, 12 十月 2023 15:28:33 +0800
Subject: [PATCH] 抽油机状态入库
---
ard-work/src/main/java/com/ruoyi/statistical/service/StatisticalService.java | 2 +
ard-work/src/main/java/com/ruoyi/statistical/controller/StatisticalController.java | 9 ++++
ard-work/src/main/java/com/ruoyi/statistical/domain/PumpStatus.java | 3 +
ard-work/src/main/java/com/ruoyi/statistical/service/impl/StatisticalServiceImpl.java | 45 ++++++++++++++++++++++
ard-work/src/main/java/com/ruoyi/utils/mqtt/MqttConsumerCallback.java | 6 ++-
5 files changed, 62 insertions(+), 3 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/statistical/controller/StatisticalController.java b/ard-work/src/main/java/com/ruoyi/statistical/controller/StatisticalController.java
index 4708e92..796bfae 100644
--- a/ard-work/src/main/java/com/ruoyi/statistical/controller/StatisticalController.java
+++ b/ard-work/src/main/java/com/ruoyi/statistical/controller/StatisticalController.java
@@ -243,4 +243,13 @@
return Results.succeed(statisticalService.pump());
}
+ /**
+ * 鏁版嵁澶勭悊
+ */
+ @ApiOperation("鏁版嵁澶勭悊")
+ @GetMapping("data")
+ public void data(String msg){
+ statisticalService.data(msg);
+ }
+
}
diff --git a/ard-work/src/main/java/com/ruoyi/statistical/domain/PumpStatus.java b/ard-work/src/main/java/com/ruoyi/statistical/domain/PumpStatus.java
index 30bbacd..6c5e76f 100644
--- a/ard-work/src/main/java/com/ruoyi/statistical/domain/PumpStatus.java
+++ b/ard-work/src/main/java/com/ruoyi/statistical/domain/PumpStatus.java
@@ -1,5 +1,6 @@
package com.ruoyi.statistical.domain;
+import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
/**
@@ -7,7 +8,7 @@
*/
@Data
public class PumpStatus {
- private String id;
+ private Integer targetId;
private String name;
private String alarmType;
private String alarmTime;
diff --git a/ard-work/src/main/java/com/ruoyi/statistical/service/StatisticalService.java b/ard-work/src/main/java/com/ruoyi/statistical/service/StatisticalService.java
index 6c1945f..3de5178 100644
--- a/ard-work/src/main/java/com/ruoyi/statistical/service/StatisticalService.java
+++ b/ard-work/src/main/java/com/ruoyi/statistical/service/StatisticalService.java
@@ -61,4 +61,6 @@
List<TenVo> ten();
List<TenVo> pump();
+
+ void data(String msg);
}
diff --git a/ard-work/src/main/java/com/ruoyi/statistical/service/impl/StatisticalServiceImpl.java b/ard-work/src/main/java/com/ruoyi/statistical/service/impl/StatisticalServiceImpl.java
index 2275bda..f5b13e3 100644
--- a/ard-work/src/main/java/com/ruoyi/statistical/service/impl/StatisticalServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/statistical/service/impl/StatisticalServiceImpl.java
@@ -1,6 +1,7 @@
package com.ruoyi.statistical.service.impl;
import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.alarm.access.mapper.ArdAlarmAccessMapper;
import com.ruoyi.alarm.apponekey.mapper.ArdAlarmApponekeyMapper;
@@ -397,6 +398,50 @@
return list;
}
+ @Override
+ public void data(String msg) {
+ JSONObject jsonObject = JSONObject.parseObject(msg);
+ String alarmTime = jsonObject.getString("alarmTime");
+ List<JSONObject> list = (List<JSONObject>) jsonObject.get("ardAlarmRadars");
+ if(list.size()>0){
+ for (int i = 0; i < list.size(); i++) {
+ JSONObject j = list.get(i);
+ QueryWrapper<PumpStatus> queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("target_id",j.getInteger("targetId")).eq("name",j.getString("name"));
+ PumpStatus pumpStatus1 = pumpStatusMapper.selectOne(queryWrapper);
+ if(pumpStatus1==null){
+ PumpStatus pumpStatus = new PumpStatus();
+ pumpStatus.setTargetId(j.getInteger("targetId"));
+ pumpStatus.setName(j.getString("name"));
+ if(j.containsKey("alarmType")){
+ pumpStatus.setAlarmType(j.getString("alarmType"));
+ }else if(j.containsKey("alarm")){
+ pumpStatus.setAlarmType(j.getString("alarm"));
+ }
+ pumpStatus.setAlarmTime(alarmTime);
+ pumpStatusMapper.insert(pumpStatus);
+ }else {
+ String alarmType = pumpStatus1.getAlarmType();
+ Boolean bo = false;
+ if(j.containsKey("alarmType")){
+ if(alarmType.equals(j.getString("alarmType"))){
+ bo = true;
+ }
+ }else if(j.containsKey("alarm")){
+ if(alarmType.equals(j.getString("alarm"))){
+ bo = true;
+ }
+ }
+ if(!bo){
+ pumpStatus1.setAlarmType(j.getString("alarmType"));
+ pumpStatus1.setAlarmTime(alarmTime);
+ pumpStatusMapper.updateById(pumpStatus1);
+ }
+ }
+ }
+ }
+ }
+
public List<CountVo> es(List<CountVo> list){
List<CountVo> countVoList = new ArrayList<>();
for (int i = 1; i <= 12 ; i++) {
diff --git a/ard-work/src/main/java/com/ruoyi/utils/mqtt/MqttConsumerCallback.java b/ard-work/src/main/java/com/ruoyi/utils/mqtt/MqttConsumerCallback.java
index 9aa003f..7e2a2d3 100644
--- a/ard-work/src/main/java/com/ruoyi/utils/mqtt/MqttConsumerCallback.java
+++ b/ard-work/src/main/java/com/ruoyi/utils/mqtt/MqttConsumerCallback.java
@@ -2,6 +2,7 @@
import com.ruoyi.alarm.global.service.impl.GlobalAlarmServiceImpl;
import com.ruoyi.common.utils.spring.SpringUtils;
+import com.ruoyi.statistical.service.StatisticalService;
import com.ruoyi.storage.minio.service.IStorageMinioEventService;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.*;
@@ -80,8 +81,9 @@
}
if (topic.equals("radarWellData"))
{
- IStorageMinioEventService storageMinioEventService = SpringUtils.getBean(IStorageMinioEventService.class);
- storageMinioEventService.parseStorageMinioEvent(new String(message.getPayload(), StandardCharsets.UTF_8));
+// System.out.println(new String(message.getPayload(), StandardCharsets.UTF_8));
+ StatisticalService statisticalService = SpringUtils.getBean(StatisticalService.class);
+ statisticalService.data(new String(message.getPayload(), StandardCharsets.UTF_8));
}
} catch (Exception e) {
log.debug("澶勭悊mqtt娑堟伅寮傚父:" + e);
--
Gitblit v1.9.3