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

设备推送数据接口更改设备状态字段

parent 1675c09d
......@@ -10,7 +10,9 @@ public class TDetectorReportData implements Serializable {
private String detectorCode;
private String detectorStatus;
private String detectorStatusId;
private String statusName;
private Float reportValue;
......@@ -54,12 +56,20 @@ public class TDetectorReportData implements Serializable {
this.detectorCode = detectorCode;
}
public String getDetectorStatus() {
return detectorStatus;
public String getDetectorStatusId() {
return detectorStatusId;
}
public void setDetectorStatusId(String detectorStatusId) {
this.detectorStatusId = detectorStatusId;
}
public String getStatusName() {
return statusName;
}
public void setDetectorStatus(String detectorStatus) {
this.detectorStatus = detectorStatus;
public void setStatusName(String statusName) {
this.statusName = statusName;
}
public Float getReportValue() {
......
......@@ -5,11 +5,11 @@ import lombok.Data;
@Data
public class TDetectorInfoDTO {
private String detectorType; // 1探测器、2安全用电设备
private String detectorCode;
private String deviceType; // 1探测器、2安全用电设备
private String deviceCode;
//探测器 推送数据(1正常,7、9离线,其他值预警) 用电推送数据(E正常,0正常,1故障,2预警)
private String detectorStatus;
private String deviceStatus;
private String alarmTime;
}
package com.zehong.system.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
/**
* 推送的报警数据信息
* @author zhangzhizhong
*
*/
public class TDetectorAlarmInfoVO {
// 设备编号
private String detectorCode;
// 监测单位
private String unitName;
// 设备类型
private String detectorType;
// 预警类型
private String statusName;
// 预警时间
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date alarmTime;
// 处理状态
private String handledStatus;
public String getDetectorCode() {
return detectorCode;
}
public void setDetectorCode(String detectorCode) {
this.detectorCode = detectorCode;
}
public String getUnitName() {
return unitName;
}
public void setUnitName(String unitName) {
this.unitName = unitName;
}
public String getDetectorType() {
return detectorType;
}
public void setDetectorType(String detectorType) {
this.detectorType = detectorType;
}
public String getStatusName() {
return statusName;
}
public void setStatusName(String statusName) {
this.statusName = statusName;
}
public Date getAlarmTime() {
return alarmTime;
}
public void setAlarmTime(Date alarmTime) {
this.alarmTime = alarmTime;
}
public String getHandledStatus() {
return handledStatus;
}
public void setHandledStatus(String handledStatus) {
this.handledStatus = handledStatus;
}
}
......@@ -3,6 +3,7 @@ package com.zehong.system.mapper;
import java.util.List;
import com.zehong.system.domain.TDetectorReportData;
import com.zehong.system.domain.vo.TDetectorAlarmInfoVO;
/**
* 设备上报的数据Mapper接口
......@@ -25,6 +26,8 @@ public interface TDetectorReportDataMapper
public List<TDetectorReportData> countDetector(List<String> list);
public List<TDetectorAlarmInfoVO> selectTDetectorAlarm();
public List<TDetectorReportData> selectRealtimeDataList();
/**
......
......@@ -3,6 +3,7 @@ package com.zehong.system.service;
import java.util.List;
import com.zehong.system.domain.TDetectorReportData;
import com.github.pagehelper.PageInfo;
import com.zehong.system.domain.vo.TDetectorAlarmInfoVO;
/**
* 设备上报的数据Service接口
......@@ -25,6 +26,8 @@ public interface ITDetectorReportDataService
public List<TDetectorReportData> selectRealtimeDataList();
public List<TDetectorAlarmInfoVO> selectTDetectorAlarm();
public List<TDetectorReportData> countDetector(List<String> list);
/**
......
......@@ -45,7 +45,7 @@ public class TDetectorInfoServiceImpl implements ITDetectorInfoService
for(TDetectorInfo detector : list){
if("0".equals(detector.getDetectorStatus())){
detector.setDetectorStatus("正常");
} else if("1".equals(detector.getDetectorStatus())){
} else {
detector.setDetectorStatus("离线");
}
}
......
......@@ -3,6 +3,7 @@ package com.zehong.system.service.impl;
import java.util.List;
import com.github.pagehelper.PageInfo;
import com.zehong.common.utils.DateUtils;
import com.zehong.system.domain.vo.TDetectorAlarmInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TDetectorReportDataMapper;
......@@ -39,6 +40,12 @@ public class TDetectorReportDataServiceImpl implements ITDetectorReportDataServi
return tDetectorReportDataMapper.selectTDetectorReportDataByCode(detectorCode);
}
@Override
public List<TDetectorAlarmInfoVO> selectTDetectorAlarm()
{
return tDetectorReportDataMapper.selectTDetectorAlarm();
}
@Override
public List<TDetectorReportData> selectRealtimeDataList()
{
......
......@@ -8,7 +8,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="id" column="id" />
<result property="sourceId" column="source_id" />
<result property="detectorCode" column="detector_code" />
<result property="deviceStatus" column="device_status" />
<result property="detectorStatusId" column="detector_status_id" />
<result property="statusName" column="status_name" />
<result property="reportValue" column="report_value" />
<result property="zhHostStatusId" column="zh_host_status_id" />
<result property="netPoint" column="net_point" />
......@@ -20,7 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectTDetectorReportDataVo">
select id, source_id, detector_code, detector_status, report_value, zh_host_status_id, net_point, signal_strength, ip_address, create_time, is_cancel_alarm, cancel_time from t_detector_report_data
select id, source_id, detector_code, detector_status_id, status_name, report_value, zh_host_status_id, net_point, signal_strength, ip_address, create_time, is_cancel_alarm, cancel_time from t_detector_report_data
</sql>
<select id="selectTDetectorReportDataList" parameterType="TDetectorReportData" resultMap="TDetectorReportDataResult">
......@@ -28,7 +29,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where>
<if test="sourceId != null and sourceId != ''"> and source_id = #{sourceId}</if>
<if test="detectorCode != null and detectorCode != ''"> and detector_code = #{detectorCode}</if>
<if test="detectorStatus != null and detectorStatus != ''"> and detector_status = #{detectorStatus}</if>
<if test="detectorStatusId != null and detectorStatusId != ''"> and detector_status_id = #{detectorStatusId}</if>
<if test="statusName != null and statusName != ''"> and status_name = #{statusName}</if>
<if test="reportValue != null "> and report_value = #{reportValue}</if>
<if test="zhHostStatusId != null "> and zh_host_status_id = #{zhHostStatusId}</if>
<if test="netPoint != null "> and net_point = #{netPoint}</if>
......@@ -50,13 +52,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by create_time DESC LIMIT 1
</select>
<select id="selectTDetectorAlarm" resultType="TDetectorAlarmInfoVO">
SELECT
rd.detector_code detectorCode,
CONCAT_WS("#",IFNULL(u.nick_name,IFNULL(di.linkman,di.detector_addr)),di.linkman) unitName,
di.detector_type detectorType,
rd.status_name statusName,
rd.create_time alarmTime,
IF (
rd.is_cancel_alarm = 0,
'未消除',
'已消除'
) handledStatus
FROM
t_detector_report_data rd
LEFT JOIN t_detector_info di ON rd.detector_code = di.detector_code
LEFT JOIN t_detector_user u ON u.user_id = di.user_id
WHERE u.nick_name is not NULL
ORDER BY rd.create_time DESC LIMIT 50
</select>
<select id="selectRealtimeDataList" resultMap="TDetectorReportDataResult">
SELECT * FROM
(
SELECT
t.source_id,
t.detector_code,
t.detector_status,
t.detector_status_id,
t.status_name,
t.report_value,
t.zh_host_status_id,
t.net_point,
......@@ -72,7 +96,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
t_detector_report_data t
LEFT JOIN t_detector_info d ON t.detector_code = d.detector_code
WHERE
t.detector_status != '1'
t.detector_status_id != '1'
ORDER BY t.create_time DESC
)data
GROUP BY data.detector_id LIMIT 50
......@@ -80,7 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="countDetector" parameterType="List" resultMap="TDetectorReportDataResult" >
<include refid="selectTDetectorReportDataVo"/>
where detector_status != '1' and detector_code in
where detector_status_id != '1' and detector_code in
<foreach collection="list" item="detectorCode" index="index" open="(" close=")" separator=",">
#{detectorCode}
</foreach>
......@@ -91,7 +115,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sourceId != null">source_id,</if>
<if test="detectorCode != null and detectorCode != ''">detector_code,</if>
<if test="detectorStatus != null">detector_status,</if>
<if test="detectorStatusId != null">detector_status_id,</if>
<if test="statusName != null">status_name,</if>
<if test="reportValue != null">report_value,</if>
<if test="zhHostStatusId != null">zh_host_status_id,</if>
<if test="netPoint != null">net_point,</if>
......@@ -104,7 +129,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sourceId != null">#{sourceId},</if>
<if test="detectorCode != null and detectorCode != ''">#{detectorCode},</if>
<if test="detectorStatus != null">#{detectorStatus},</if>
<if test="detectorStatusId != null">#{detectorStatusId},</if>
<if test="statusName != null">#{statusName},</if>
<if test="reportValue != null">#{reportValue},</if>
<if test="zhHostStatusId != null">#{zhHostStatusId},</if>
<if test="netPoint != null">#{netPoint},</if>
......@@ -121,7 +147,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="SET" suffixOverrides=",">
<if test="sourceId != null">source_id = #{sourceId},</if>
<if test="detectorCode != null and detectorCode != ''">detector_code = #{detectorCode},</if>
<if test="detectorStatus != null">detector_status = #{detectorStatus},</if>
<if test="detectorStatusId != null">detector_status_id = #{detectorStatusId},</if>
<if test="statusName != null">status_name = #{statusName},</if>
<if test="reportValue != null">report_value = #{reportValue},</if>
<if test="zhHostStatusId != null">zh_host_status_id = #{zhHostStatusId},</if>
<if test="netPoint != null">net_point = #{netPoint},</if>
......
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