|
|
|
@ -2,12 +2,15 @@ package com.mh.system.service.operation.impl;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.mh.common.core.domain.entity.AlarmRecords; |
|
|
|
|
import com.mh.common.utils.StringUtils; |
|
|
|
|
import com.mh.system.mapper.operation.AlarmRecordsMapper; |
|
|
|
|
import com.mh.system.service.operation.IAlarmRecordsService; |
|
|
|
|
import jakarta.annotation.Resource; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.time.LocalDate; |
|
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -56,40 +59,48 @@ public class AlarmRecordsServiceImpl implements IAlarmRecordsService {
|
|
|
|
|
} |
|
|
|
|
QueryWrapper<AlarmRecords> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
// 报警类型
|
|
|
|
|
if (!alarmRecords.getAlarmType().isEmpty()) { |
|
|
|
|
if (!StringUtils.isEmpty(alarmRecords.getAlarmType())) { |
|
|
|
|
queryWrapper.eq("alarm_type", alarmRecords.getAlarmType()); |
|
|
|
|
} |
|
|
|
|
// 事件类型
|
|
|
|
|
if (!alarmRecords.getEventType().isEmpty()) { |
|
|
|
|
if (!StringUtils.isEmpty(alarmRecords.getEventType())) { |
|
|
|
|
queryWrapper.eq("event_type", alarmRecords.getEventType()); |
|
|
|
|
} |
|
|
|
|
// 报警等级
|
|
|
|
|
if (!alarmRecords.getAlarmLevel().isEmpty()) { |
|
|
|
|
if (!StringUtils.isEmpty(alarmRecords.getAlarmLevel())) { |
|
|
|
|
queryWrapper.eq("alarm_level", alarmRecords.getAlarmLevel()); |
|
|
|
|
} |
|
|
|
|
// 设备名称
|
|
|
|
|
if (!alarmRecords.getDeviceName().isEmpty()) { |
|
|
|
|
if (!StringUtils.isEmpty(alarmRecords.getDeviceName())) { |
|
|
|
|
queryWrapper.like("device_name", alarmRecords.getDeviceName()); |
|
|
|
|
} |
|
|
|
|
// 报警时间
|
|
|
|
|
if (alarmRecords.getCreateTime() != null) { |
|
|
|
|
queryWrapper.apply("to_char(create_time, 'YYYY-MM-DD HH24') = {0}", |
|
|
|
|
new SimpleDateFormat("yyyy-MM-dd HH").format(alarmRecords.getCreateTime())); |
|
|
|
|
// 报警时间范围
|
|
|
|
|
if (alarmRecords.getParams() != null && !alarmRecords.getParams().isEmpty()) { |
|
|
|
|
String beginTimeStr = (String) alarmRecords.getParams().get("beginTime"); |
|
|
|
|
String endTimeStr = (String) alarmRecords.getParams().get("endTime"); |
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(beginTimeStr) && StringUtils.isNotEmpty(endTimeStr)) { |
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
|
|
|
|
LocalDate beginTime = LocalDate.parse(beginTimeStr, formatter); |
|
|
|
|
LocalDate endTime = LocalDate.parse(endTimeStr, formatter); |
|
|
|
|
|
|
|
|
|
queryWrapper.between("create_time", java.sql.Date.valueOf(beginTime), java.sql.Date.valueOf(endTime)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 台账id
|
|
|
|
|
if (!alarmRecords.getLedgerId().isEmpty()) { |
|
|
|
|
if (!StringUtils.isEmpty(alarmRecords.getLedgerId())) { |
|
|
|
|
queryWrapper.eq("ledger_id", alarmRecords.getLedgerId()); |
|
|
|
|
} |
|
|
|
|
// 仪表参数id
|
|
|
|
|
if (!alarmRecords.getCpmId().isEmpty()) { |
|
|
|
|
if (!StringUtils.isEmpty(alarmRecords.getCpmId())) { |
|
|
|
|
queryWrapper.eq("cpm_id", alarmRecords.getCpmId()); |
|
|
|
|
} |
|
|
|
|
// 仪表参数名称
|
|
|
|
|
if (!alarmRecords.getCpmName().isEmpty()) { |
|
|
|
|
if (!StringUtils.isEmpty(alarmRecords.getCpmName())) { |
|
|
|
|
queryWrapper.like("cpm_name", alarmRecords.getCpmName()); |
|
|
|
|
} |
|
|
|
|
// 报警内容
|
|
|
|
|
if (!alarmRecords.getContent().isEmpty()) { |
|
|
|
|
if (!StringUtils.isEmpty(alarmRecords.getContent())) { |
|
|
|
|
queryWrapper.like("content", alarmRecords.getContent()); |
|
|
|
|
} |
|
|
|
|
queryWrapper.orderByDesc("create_time"); |
|
|
|
|