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

设备预警信息过滤

parent d7c554ef
......@@ -156,7 +156,7 @@ public class TDetectorInfoController extends BaseController
int handledNum = 0;
for(TDetectorReportData data : dataList){
if(!StringUtils.isEmpty(data.getIsCancelAlarm()) && data.getIsCancelAlarm().equals("1")){
if(!StringUtils.isEmpty(data.getIsCancelAlarm()) && !data.getIsCancelAlarm().equals("0")){
++handledNum;
}
}
......
......@@ -371,22 +371,47 @@ public class TDetectorReportController extends BaseController
//报警设备类型,1探测器,2智慧用电 E+原始类型
if(!StringUtils.isEmpty(tDetectorReportDataForm.getDeviceType()) && tDetectorReportDataForm.getDeviceType().equals("1") && !StringUtils.isEmpty(tDetectorReportDataForm.getDeviceStatusId()) && !tDetectorReportDataForm.getDeviceStatusId().equals("1")){
List<TDetectorReportData> reportDataList = tDetectorReportDataService.selectTDetectorReportDataByCode(tDetectorReportDataForm.getDeviceNo());
// 有未消警的数据
if(reportDataList.size()>0){
// 对比未消警数据与新推送数据的状态
if(!reportDataList.get(0).getDetectorStatusId().equals(tDetectorReportDataForm.getDeviceStatusId())) {
TDetectorReportData temp = reportDataList.get(0);
temp.setIsCancelAlarm("1");
temp.setCancelTime(new Date());
tDetectorReportDataService.updateTDetectorReportData(temp);
TDetectorReportData datas = new TDetectorReportData();
datas.setSourceId(tDetectorReportDataForm.getSourceId());
datas.setDetectorCode(tDetectorReportDataForm.getDeviceNo());
datas.setDetectorStatusId(tDetectorReportDataForm.getDeviceStatusId());
datas.setStatusName(tDetectorReportDataForm.getStatusName());
datas.setReportValue(StringUtils.isEmpty(tDetectorReportDataForm.getReportValue()) ? null : Float.parseFloat(tDetectorReportDataForm.getReportValue()));
datas.setZhHostStatusId(StringUtils.isEmpty(tDetectorReportDataForm.getZhHostStatusId()) ? null : Integer.parseInt(tDetectorReportDataForm.getZhHostStatusId()));
datas.setSignalStrength(StringUtils.isEmpty(tDetectorReportDataForm.getSignalStrength()) ? null : Integer.parseInt(tDetectorReportDataForm.getSignalStrength()));
datas.setNetPoint(StringUtils.isEmpty(tDetectorReportDataForm.getNetPoint()) ? null : Integer.parseInt(tDetectorReportDataForm.getNetPoint()));
datas.setIpAddress(StringUtils.isEmpty(tDetectorReportDataForm.getIpAddress()) ? null : tDetectorReportDataForm.getIpAddress());
datas.setCreateTime(StringUtils.isEmpty(tDetectorReportDataForm.getCreateTime()) ? null : new Date());
tDetectorReportDataService.insertTDetectorReportData(datas);
}
TDetectorReportData datas = new TDetectorReportData();
datas.setSourceId(tDetectorReportDataForm.getSourceId());
datas.setDetectorCode(tDetectorReportDataForm.getDeviceNo());
datas.setDetectorStatusId(tDetectorReportDataForm.getDeviceStatusId());
datas.setStatusName(tDetectorReportDataForm.getStatusName());
datas.setReportValue(StringUtils.isEmpty(tDetectorReportDataForm.getReportValue())?null:Float.parseFloat(tDetectorReportDataForm.getReportValue()));
datas.setZhHostStatusId(StringUtils.isEmpty(tDetectorReportDataForm.getZhHostStatusId())?null:Integer.parseInt(tDetectorReportDataForm.getZhHostStatusId()));
datas.setSignalStrength(StringUtils.isEmpty(tDetectorReportDataForm.getSignalStrength())?null:Integer.parseInt(tDetectorReportDataForm.getSignalStrength()));
datas.setNetPoint(StringUtils.isEmpty(tDetectorReportDataForm.getNetPoint())?null:Integer.parseInt(tDetectorReportDataForm.getNetPoint()));
datas.setIpAddress(StringUtils.isEmpty(tDetectorReportDataForm.getIpAddress())?null:tDetectorReportDataForm.getIpAddress());
datas.setCreateTime(StringUtils.isEmpty(tDetectorReportDataForm.getCreateTime())?null:new Date());
tDetectorReportDataService.insertTDetectorReportData(datas);
} else {
TDetectorReportData datas = new TDetectorReportData();
datas.setSourceId(tDetectorReportDataForm.getSourceId());
datas.setDetectorCode(tDetectorReportDataForm.getDeviceNo());
datas.setDetectorStatusId(tDetectorReportDataForm.getDeviceStatusId());
datas.setStatusName(tDetectorReportDataForm.getStatusName());
datas.setReportValue(StringUtils.isEmpty(tDetectorReportDataForm.getReportValue()) ? null : Float.parseFloat(tDetectorReportDataForm.getReportValue()));
datas.setZhHostStatusId(StringUtils.isEmpty(tDetectorReportDataForm.getZhHostStatusId()) ? null : Integer.parseInt(tDetectorReportDataForm.getZhHostStatusId()));
datas.setSignalStrength(StringUtils.isEmpty(tDetectorReportDataForm.getSignalStrength()) ? null : Integer.parseInt(tDetectorReportDataForm.getSignalStrength()));
datas.setNetPoint(StringUtils.isEmpty(tDetectorReportDataForm.getNetPoint()) ? null : Integer.parseInt(tDetectorReportDataForm.getNetPoint()));
datas.setIpAddress(StringUtils.isEmpty(tDetectorReportDataForm.getIpAddress()) ? null : tDetectorReportDataForm.getIpAddress());
datas.setCreateTime(StringUtils.isEmpty(tDetectorReportDataForm.getCreateTime()) ? null : new Date());
tDetectorReportDataService.insertTDetectorReportData(datas);
}
}
// else if(!StringUtils.isEmpty(tDetectorReportDataForm.getDeviceType()) && tDetectorReportDataForm.getDeviceType().equals("2") && !StringUtils.isEmpty(tDetectorReportDataForm.getDeviceStatusId()) && !tDetectorReportDataForm.getDeviceStatusId().equals("E")){
// TDetectorReportData datas = new TDetectorReportData();
......@@ -437,12 +462,14 @@ public class TDetectorReportController extends BaseController
//
// List<ZHDeviceReportDatas> dataList = zHDeviceReportDataService.selectByExample(zhDeviceReportDatasExample);
// 查询该设备最新的一条
TDetectorReportData data = tDetectorReportDataService.selectTDetectorReportDataByCode(tDetectorReportDataForm.getDeviceNo());
if(data != null){
data.setIsCancelAlarm("1"); // 1自动消警
data.setCancelTime(StringUtils.isEmpty(tDetectorReportDataForm.getCreateTime())?null: new Date());
tDetectorReportDataService.updateTDetectorReportData(data);
// 查询该设备所有未消警的数据
List<TDetectorReportData> dataList = tDetectorReportDataService.selectTDetectorReportDataByCode(tDetectorReportDataForm.getDeviceNo());
if(dataList.size() > 0){
for(TDetectorReportData data : dataList) {
data.setIsCancelAlarm("1"); // 1自动消警
data.setCancelTime(StringUtils.isEmpty(tDetectorReportDataForm.getCreateTime()) ? null : new Date());
tDetectorReportDataService.updateTDetectorReportData(data);
}
}
}
......
......@@ -71,7 +71,7 @@ public class TDetectorInfo extends BaseEntity
/** 报警时间 */
private String alarmTime;
/** 设备状态 */
/** 设备状态(0正常,1离线,2报警) */
@Excel(name = "设备状态")
private String detectorStatus;
......
......@@ -26,6 +26,7 @@ public class TDetectorReportData implements Serializable {
private Date createTime;
// 是否销警,默认0, 1自动销警,2手动销警
private String isCancelAlarm;
private Date cancelTime;
......
......@@ -22,7 +22,7 @@ public interface TDetectorReportDataMapper
public TDetectorReportData selectTDetectorReportDataById(Long id);
public TDetectorReportData selectTDetectorReportDataByCode(String detectorCode);
public List<TDetectorReportData> selectTDetectorReportDataByCode(String detectorCode);
public List<TDetectorReportData> countDetector(List<String> list);
......
......@@ -22,7 +22,7 @@ public interface ITDetectorReportDataService
public TDetectorReportData selectTDetectorReportDataById(Long id);
public TDetectorReportData selectTDetectorReportDataByCode(String detectorCode);
public List<TDetectorReportData> selectTDetectorReportDataByCode(String detectorCode);
public List<TDetectorReportData> selectRealtimeDataList();
......
......@@ -35,7 +35,7 @@ public class TDetectorReportDataServiceImpl implements ITDetectorReportDataServi
}
@Override
public TDetectorReportData selectTDetectorReportDataByCode(String detectorCode)
public List<TDetectorReportData> selectTDetectorReportDataByCode(String detectorCode)
{
return tDetectorReportDataMapper.selectTDetectorReportDataByCode(detectorCode);
}
......
......@@ -49,7 +49,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectTDetectorReportDataByCode" parameterType="String" resultMap="TDetectorReportDataResult">
<include refid="selectTDetectorReportDataVo"/>
where detector_code = #{detectorCode}
order by create_time DESC LIMIT 1
and is_cancel_alarm = '0'
ORDER BY create_time DESC
</select>
<select id="selectTDetectorAlarm" resultType="TDetectorAlarmInfoVO">
......
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