feat: 天然气六个数据从redis中获取数据
This commit is contained in:
+2
-7
@@ -49,18 +49,13 @@ public class KhNgRealtimeDataController extends JeroController<KhNgRealtimeData,
|
|||||||
/**
|
/**
|
||||||
* 返回动态数据
|
* 返回动态数据
|
||||||
*
|
*
|
||||||
* @param id
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@AutoLog(value = "天然气数据远传终端实时数据-返回动态数据")
|
@AutoLog(value = "天然气数据远传终端实时数据-返回动态数据")
|
||||||
@ApiOperation(value = "天然气数据远传终端实时数据-返回动态数据", notes = "油井实时数据-返回动态数据")
|
@ApiOperation(value = "天然气数据远传终端实时数据-返回动态数据", notes = "油井实时数据-返回动态数据")
|
||||||
@GetMapping(value = "/realtimeDataResults")
|
@GetMapping(value = "/realtimeDataResults")
|
||||||
public Results<Map<String, List<KhNgRealtimeData>>> realtimeDataResults(@RequestParam(name = "id", required = true) String id) {
|
public Results<List<KhNgRealtimeData>> realtimeDataResults() {
|
||||||
if (!id.equals("default")) {
|
return Results.OK(khNgRealtimeDataService.mockKhNgRealtimeRedisData());
|
||||||
return Results.error("未找到对应数据");
|
|
||||||
}
|
|
||||||
Map<String, List<KhNgRealtimeData>> khOilRealtimeData = khNgRealtimeDataService.realtimeDataResults(id);
|
|
||||||
return Results.OK(khOilRealtimeData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package com.jero.modules.entity;
|
package com.jero.modules.entity;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
@@ -57,41 +58,34 @@ public class KhNgRealtimeData implements Serializable {
|
|||||||
@Excel(name = "设备编号", width = 15)
|
@Excel(name = "设备编号", width = 15)
|
||||||
@ApiModelProperty(value = "设备编号")
|
@ApiModelProperty(value = "设备编号")
|
||||||
private String deviceNo;
|
private String deviceNo;
|
||||||
|
/**设备编号*/
|
||||||
|
@Excel(name = "通道编号", width = 15)
|
||||||
|
@ApiModelProperty(value = "通道编号")
|
||||||
|
private String channelNo;
|
||||||
/**实时温度*/
|
/**实时温度*/
|
||||||
@Excel(name = "实时温度", width = 15)
|
@Excel(name = "实时温度", width = 15)
|
||||||
@ApiModelProperty(value = "实时温度")
|
@ApiModelProperty(value = "实时温度")
|
||||||
private Double realTimeTemp;
|
private String realTimeTemp;
|
||||||
/**累计流量*/
|
/**累计流量*/
|
||||||
@Excel(name = "累计流量", width = 15)
|
@Excel(name = "累计流量", width = 15)
|
||||||
@ApiModelProperty(value = "累计流量")
|
@ApiModelProperty(value = "累计流量")
|
||||||
private Double cumulativeFlow;
|
private String cumulativeFlow;
|
||||||
/**实时压力*/
|
/**实时压力*/
|
||||||
@Excel(name = "实时压力", width = 15)
|
@Excel(name = "实时压力", width = 15)
|
||||||
@ApiModelProperty(value = "实时压力")
|
@ApiModelProperty(value = "实时压力")
|
||||||
private Double realTimePressure;
|
private String realTimePressure;
|
||||||
/**标况瞬时*/
|
/**标况瞬时*/
|
||||||
@Excel(name = "标况瞬时", width = 15)
|
@Excel(name = "标况瞬时", width = 15)
|
||||||
@ApiModelProperty(value = "标况瞬时")
|
@ApiModelProperty(value = "标况瞬时")
|
||||||
private Double stdInstant;
|
private String stdInstant;
|
||||||
/**工况瞬时*/
|
/**工况瞬时*/
|
||||||
@Excel(name = "工况瞬时", width = 15)
|
@Excel(name = "工况瞬时", width = 15)
|
||||||
@ApiModelProperty(value = "工况瞬时")
|
@ApiModelProperty(value = "工况瞬时")
|
||||||
private Double operationalInstant;
|
private String operationalInstant;
|
||||||
/**同步时间*/
|
/**同步时间*/
|
||||||
@Excel(name = "同步时间", width = 15, format = "yyyy-MM-dd")
|
@Excel(name = "同步时间", width = 15, format = "yyyy-MM-dd")
|
||||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||||
@ApiModelProperty(value = "同步时间")
|
@ApiModelProperty(value = "同步时间")
|
||||||
private Date syncDate;
|
private Date syncDate;
|
||||||
|
|
||||||
public void mockKhOilRealtimeData() {
|
|
||||||
this.setId("default");
|
|
||||||
this.setDeviceNo("default");
|
|
||||||
this.setRealTimeTemp(RandomNumberUtil.getRandomDouble());
|
|
||||||
this.setRealTimePressure(RandomNumberUtil.getRandomDouble());
|
|
||||||
this.setCumulativeFlow(RandomNumberUtil.getRandomDouble());
|
|
||||||
this.setRealTimePressure(RandomNumberUtil.getRandomDouble());
|
|
||||||
this.setStdInstant(RandomNumberUtil.getRandomDouble());
|
|
||||||
this.setOperationalInstant(RandomNumberUtil.getRandomDouble());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,4 +37,13 @@ public interface IKhNgRealtimeDataService extends IService<KhNgRealtimeData> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Map<String, List<KhNgRealtimeData>> realtimeDataResults(String id);
|
Map<String, List<KhNgRealtimeData>> realtimeDataResults(String id);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实时数据
|
||||||
|
* @param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<KhNgRealtimeData> mockKhNgRealtimeRedisData();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+35
-1
@@ -1,5 +1,8 @@
|
|||||||
package com.jero.modules.service.impl;
|
package com.jero.modules.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.jero.modules.entity.KhNgRealtimeData;
|
import com.jero.modules.entity.KhNgRealtimeData;
|
||||||
import com.jero.modules.entity.KhOilRealtimeData;
|
import com.jero.modules.entity.KhOilRealtimeData;
|
||||||
@@ -17,6 +20,7 @@ import com.jero.common.system.query.QueryGenerator;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import redis.clients.jedis.Jedis;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,9 +61,39 @@ public class KhNgRealtimeDataServiceImpl extends ServiceImpl<KhNgRealtimeDataMap
|
|||||||
Map<String, List<KhNgRealtimeData>> result = new HashMap<>();
|
Map<String, List<KhNgRealtimeData>> result = new HashMap<>();
|
||||||
List<KhNgRealtimeData> dataList = new ArrayList<>();
|
List<KhNgRealtimeData> dataList = new ArrayList<>();
|
||||||
KhNgRealtimeData khNgRealtimeData = new KhNgRealtimeData();
|
KhNgRealtimeData khNgRealtimeData = new KhNgRealtimeData();
|
||||||
khNgRealtimeData.mockKhOilRealtimeData();
|
|
||||||
dataList.add(khNgRealtimeData);
|
dataList.add(khNgRealtimeData);
|
||||||
result.put("实时运行参数", dataList);
|
result.put("实时运行参数", dataList);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<KhNgRealtimeData> mockKhNgRealtimeRedisData() {
|
||||||
|
Map<String, List<Double>> map = new HashMap<>();
|
||||||
|
JSONArray data = new JSONArray();
|
||||||
|
List<KhNgRealtimeData> resultList = new ArrayList<>();
|
||||||
|
// 连接到Redis服务器
|
||||||
|
try (Jedis jedis = new Jedis("1.15.107.30", 6379)) {
|
||||||
|
jedis.auth("kld4....");
|
||||||
|
jedis.select(3);
|
||||||
|
|
||||||
|
// 获取名为 flowmeter 的 JSON 字符串
|
||||||
|
String jsonData = jedis.get("flowmeter");
|
||||||
|
// 使用 Fastjson 反序列化 JSON 字符串
|
||||||
|
data = JSON.parseArray(jsonData);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Object item : data) {
|
||||||
|
KhNgRealtimeData realData = new KhNgRealtimeData();
|
||||||
|
JSONObject jsonObject = (JSONObject) item;
|
||||||
|
realData.setChannelNo(jsonObject.getString("name"));
|
||||||
|
realData.setRealTimeTemp(jsonObject.getString("temperature"));
|
||||||
|
realData.setCumulativeFlow(jsonObject.getString("totalflow"));
|
||||||
|
realData.setRealTimePressure(jsonObject.getString("pressure"));
|
||||||
|
realData.setStdInstant(jsonObject.getString("standard"));
|
||||||
|
realData.setOperationalInstant(jsonObject.getString("acture"));
|
||||||
|
resultList.add(realData);
|
||||||
|
}
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user