Commit 45986835 authored by 王晓倩's avatar 王晓倩

实时数据详情

parent 7550f64f
......@@ -74,13 +74,20 @@ public class TDeviceReportDataController extends BaseController
}
/**
* 获取设备监控详细信息
* 获取设备监控数据详细信息
*/
@PreAuthorize("@ss.hasPermi('dataMonitoring:reportData:query')")
@GetMapping(value = "/{deviceReportDataId}")
public AjaxResult getInfo(@PathVariable("deviceReportDataId") Long deviceReportDataId)
@GetMapping(value = "/{deviceId}")
public AjaxResult getInfo(@PathVariable("deviceId") int deviceId) throws Exception
{
return AjaxResult.success(tDeviceReportDataService.selectTDeviceReportDataById(deviceReportDataId));
DeviceReportDataVo deviceReportDataVo = null;
try {
deviceReportDataVo = tDeviceReportDataService.selectTDeviceReportDataByDeviceId(deviceId);
} catch (Exception e) {
e.printStackTrace();
throw new Exception("获取设备监控数据详细信息失败");
}
return AjaxResult.success(deviceReportDataVo);
}
/**
......
......@@ -3,11 +3,13 @@ package com.zehong.system.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zehong.common.annotation.Excel;
import com.zehong.common.core.domain.BaseEntity;
import com.zehong.system.domain.TDeviceReportData;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* 设备监控对象 t_device_report_data
......@@ -24,6 +26,10 @@ public class DeviceReportDataVo extends BaseEntity
@Excel(name = "设备物联网编号")
private String deviceNum;
/** 设备id */
@Excel(name = "设备id")
private Integer deviceId;
/** 设备编号 */
@Excel(name = "设备编号")
private String deviceCode;
......@@ -40,6 +46,15 @@ public class DeviceReportDataVo extends BaseEntity
@Excel(name = "设备型号")
private String deviceModel;
/** 经度 */
private BigDecimal longitude;
/** 纬度 */
private BigDecimal latitude;
/** 设备监控数据列表(用于详情折线图) */
private List<TDeviceReportData> deviceReportDataList;
/** 标况累计量 */
@Excel(name = "标况累计量")
private BigDecimal standardConditionAccumulation;
......@@ -90,6 +105,7 @@ public class DeviceReportDataVo extends BaseEntity
{
return deviceReportDataId;
}
public void setDeviceNum(String deviceNum)
{
this.deviceNum = deviceNum;
......@@ -100,6 +116,14 @@ public class DeviceReportDataVo extends BaseEntity
return deviceNum;
}
public Integer getDeviceId() {
return deviceId;
}
public void setDeviceId(Integer deviceId) {
this.deviceId = deviceId;
}
public String getDeviceCode() {
return deviceCode;
}
......@@ -132,6 +156,30 @@ public class DeviceReportDataVo extends BaseEntity
this.deviceModel = deviceModel;
}
public BigDecimal getLongitude() {
return longitude;
}
public void setLongitude(BigDecimal longitude) {
this.longitude = longitude;
}
public BigDecimal getLatitude() {
return latitude;
}
public void setLatitude(BigDecimal latitude) {
this.latitude = latitude;
}
public List<TDeviceReportData> getDeviceReportDataList() {
return deviceReportDataList;
}
public void setDeviceReportDataList(List<TDeviceReportData> deviceReportDataList) {
this.deviceReportDataList = deviceReportDataList;
}
public void setStandardConditionAccumulation(BigDecimal standardConditionAccumulation)
{
this.standardConditionAccumulation = standardConditionAccumulation;
......
......@@ -16,14 +16,22 @@ public interface TDeviceReportDataMapper
/**
* 查询设备监控
*
* @param deviceReportDataId 设备监控ID
* @param deviceNum 物联网编号
* @return 设备监控
*/
public DeviceReportDataVo selectTDeviceReportDataById(Long deviceReportDataId);
public TDeviceReportData selectTDeviceReportDataByDeviceNum(String deviceNum);
/**
* 查询设备监控列表
*
* @param deviceNum 物联网编号
* @return 设备监控集合
*/
public List<TDeviceReportData> getTDeviceReportDataList(String deviceNum);
/**
* 查询设备监控列表
*
* @param deviceReportDataForm 设备监控
* @return 设备监控集合
*/
......
......@@ -16,10 +16,10 @@ public interface ITDeviceReportDataService
/**
* 查询设备监控
*
* @param deviceReportDataId 设备监控ID
* @param deviceId 设备ID
* @return 设备监控
*/
public DeviceReportDataVo selectTDeviceReportDataById(Long deviceReportDataId);
public DeviceReportDataVo selectTDeviceReportDataByDeviceId(int deviceId) throws Exception;
/**
* 查询设备监控列表
......
......@@ -50,6 +50,7 @@ public class TDeviceAlarmServiceImpl implements ITDeviceAlarmService
{
DeviceAlarmVo deviceAlarmVo = new DeviceAlarmVo();
TDeviceAlarm tDeviceAlarm = tDeviceAlarmMapper.selectTDeviceAlarmById(alarmId);
BeanUtils.copyProperties(tDeviceAlarm, deviceAlarmVo);
if (StringUtils.isNotEmpty(tDeviceAlarm.getAlarmType())) {
List<SysDictData> sysDictDataList = iSysDictTypeService.selectDictDataByType("t_alarm_type");
......@@ -60,8 +61,6 @@ public class TDeviceAlarmServiceImpl implements ITDeviceAlarmService
}
}
BeanUtils.copyProperties(tDeviceAlarm, deviceAlarmVo);
if("0".equals(tDeviceAlarm.getDeviceType())){
TPipe pipe = tPipeMapper.selectTPipeById(tDeviceAlarm.getDeviceId());
deviceAlarmVo.setDeviceCode(pipe.getPipeCode());
......
......@@ -2,8 +2,11 @@ package com.zehong.system.service.impl;
import java.util.List;
import com.zehong.common.utils.DateUtils;
import com.zehong.system.domain.TDeviceInfo;
import com.zehong.system.domain.form.DeviceReportDataForm;
import com.zehong.system.domain.vo.DeviceReportDataVo;
import com.zehong.system.mapper.TDeviceInfoMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TDeviceReportDataMapper;
......@@ -21,17 +24,38 @@ public class TDeviceReportDataServiceImpl implements ITDeviceReportDataService
{
@Autowired
private TDeviceReportDataMapper tDeviceReportDataMapper;
@Autowired
private TDeviceInfoMapper tDeviceInfoMapper;
/**
* 查询设备监控
*
* @param deviceReportDataId 设备监控ID
* @param deviceId 设备ID
* @return 设备监控
*/
@Override
public DeviceReportDataVo selectTDeviceReportDataById(Long deviceReportDataId)
public DeviceReportDataVo selectTDeviceReportDataByDeviceId(int deviceId) throws Exception
{
return tDeviceReportDataMapper.selectTDeviceReportDataById(deviceReportDataId);
DeviceReportDataVo deviceReportDataVo = new DeviceReportDataVo();
TDeviceInfo tDeviceInfo = tDeviceInfoMapper.selectTDeviceInfoById(deviceId);
TDeviceReportData tDeviceReportData = tDeviceReportDataMapper.selectTDeviceReportDataByDeviceNum(tDeviceInfo.getIotNo());
BeanUtils.copyProperties(tDeviceReportData, deviceReportDataVo);
deviceReportDataVo.setDeviceId(tDeviceInfo.getDeviceId());
deviceReportDataVo.setDeviceCode(tDeviceInfo.getDeviceCode());
deviceReportDataVo.setDeviceName(tDeviceInfo.getDeviceName());
deviceReportDataVo.setDeviceType(tDeviceInfo.getDeviceType());
deviceReportDataVo.setDeviceModel(tDeviceInfo.getDeviceModel());
deviceReportDataVo.setLongitude(tDeviceInfo.getLongitude());
deviceReportDataVo.setLatitude(tDeviceInfo.getLatitude());
// 查询当前设备两小时内的数据
List<TDeviceReportData> deviceReportDataList = tDeviceReportDataMapper.getTDeviceReportDataList(tDeviceInfo.getIotNo());
if(deviceReportDataList.size() != 0) {
deviceReportDataVo.setDeviceReportDataList(deviceReportDataList);
}
return deviceReportDataVo;
}
/**
......
......@@ -4,9 +4,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zehong.system.mapper.TDeviceReportDataMapper">
<resultMap type="DeviceReportDataVo" id="TDeviceReportDataResult">
<resultMap type="TDeviceReportData" id="TDeviceReportDataResult">
<result property="deviceReportDataId" column="device_report_data_id" />
<result property="deviceNum" column="device_num" />
<result property="standardConditionAccumulation" column="standard_condition_accumulation" />
<result property="workingConditionAccumulation" column="working_condition_accumulation" />
<result property="residualQuantity" column="residual_quantity" />
<result property="standardConditionFlow" column="standard_condition_flow" />
<result property="workingConditionFlow" column="working_condition_flow" />
<result property="temperature" column="temperature" />
<result property="pressure" column="pressure" />
<result property="reportTime" column="report_time" />
<result property="communicationStatus" column="communication_status" />
<result property="deviceStatus" column="device_status" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
</resultMap>
<resultMap type="DeviceReportDataVo" id="TDeviceReportDataResultVo">
<result property="deviceReportDataId" column="device_report_data_id" />
<result property="deviceNum" column="device_num" />
<result property="deviceId" column="device_id" />
<result property="deviceCode" column="device_code" />
<result property="deviceType" column="device_type" />
<result property="deviceName" column="device_name" />
......@@ -30,7 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from t_device_report_data
</sql>
<select id="selectTDeviceReportDataList" parameterType="DeviceReportDataForm" resultMap="TDeviceReportDataResult">
<select id="selectTDeviceReportDataList" parameterType="DeviceReportDataForm" resultMap="TDeviceReportDataResultVo">
select t.report_time, t.device_report_data_id, t.device_num, t.standard_condition_accumulation, t.working_condition_accumulation, t.residual_quantity, t.standard_condition_flow, t.working_condition_flow, t.temperature, t.pressure, t.communication_status, t.device_status, t.create_time, t.update_time,
d.device_name, d.device_code, d.device_type, d.device_model
from t_device_report_data t
......@@ -45,11 +63,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="selectRealtimeDataList" parameterType="DeviceReportDataForm" resultMap="TDeviceReportDataResult">
<select id="selectRealtimeDataList" parameterType="DeviceReportDataForm" resultMap="TDeviceReportDataResultVo">
select max(t.report_time) report_time, t.device_report_data_id, t.device_num, t.standard_condition_accumulation, t.working_condition_accumulation, t.residual_quantity, t.standard_condition_flow, t.working_condition_flow, t.temperature, t.pressure, t.communication_status, t.device_status, t.create_time, t.update_time,
d.device_name, d.device_code, d.device_type, d.device_model
from t_device_report_data t
left join t_device_info d on t.device_num = d.iot_no
right join t_device_info d on t.device_num = d.iot_no
<where>
<if test="deviceCode != null "> and d.device_code like concat('%',#{deviceCode},'%')</if>
<if test="deviceType != null "> and d.device_type = #{deviceType}</if>
......@@ -58,17 +76,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="communicationStatus != null and communicationStatus != ''"> and t.communication_status = #{communicationStatus}</if>
<if test="deviceStatus != null and deviceStatus != ''"> and t.device_status = #{deviceStatus}</if>
</where>
group by t.device_num
group by d.device_id
</select>
<select id="selectTDeviceReportDataById" parameterType="Long" resultMap="TDeviceReportDataResult">
select t.report_time, t.device_report_data_id, t.device_num, t.standard_condition_accumulation, t.working_condition_accumulation, t.residual_quantity, t.standard_condition_flow, t.working_condition_flow, t.temperature, t.pressure, t.communication_status, t.device_status, t.create_time, t.update_time,
d.device_name, d.device_code, d.device_type, d.device_model
from t_device_report_data t
left join t_device_info d on t.device_num = d.iot_no
where t.device_report_data_id = #{deviceReportDataId}
<select id="selectTDeviceReportDataByDeviceNum" parameterType="String" resultMap="TDeviceReportDataResult">
select max(report_time) report_time, device_report_data_id, device_num, standard_condition_accumulation, working_condition_accumulation, residual_quantity, standard_condition_flow, working_condition_flow, temperature, pressure, communication_status, device_status, create_time, update_time
from t_device_report_data
where device_num = #{deviceNum}
</select>
<select id="getTDeviceReportDataList" parameterType="String" resultMap="TDeviceReportDataResult">
select report_time, device_report_data_id, device_num, standard_condition_accumulation, working_condition_accumulation, residual_quantity, standard_condition_flow, working_condition_flow, temperature, pressure, communication_status, device_status, create_time, update_time
from t_device_report_data
where device_num = #{deviceNum} and report_time &gt;= DATE_SUB(NOW(),INTERVAL 2 HOUR)
</select>
<insert id="insertTDeviceReportData" parameterType="TDeviceReportData" useGeneratedKeys="true" keyProperty="deviceReportDataId">
insert into t_device_report_data
<trim prefix="(" suffix=")" suffixOverrides=",">
......
......@@ -26,7 +26,7 @@
ref="queryForm"
:inline="true"
v-show="showSearch"
label-width="100"
label-width="100px"
>
<el-form-item label="设备编号" prop="deviceCode">
<el-input
......
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