|
|
|
@ -3,6 +3,7 @@ package com.topsail.scheduletask.task; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.topsail.scheduletask.mapper.InformLogDao; |
|
|
|
import com.topsail.scheduletask.mapper.TopsailTransmitLogDao; |
|
|
|
import com.topsail.scheduletask.pojo.DeviceOnlineInfo; |
|
|
|
import com.topsail.scheduletask.pojo.FocusDeviceOnline; |
|
|
|
import com.topsail.scheduletask.service.AmqpService; |
|
|
|
import com.topsail.scheduletask.util.MaiSenderlUtil; |
|
|
|
@ -16,6 +17,7 @@ import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
@Component |
|
|
|
@Configuration //1.主要用于标记配置类,兼备Component的效果。 |
|
|
|
@ -85,15 +87,33 @@ public class CheckRabbitMqScheduleTask { |
|
|
|
} |
|
|
|
} |
|
|
|
//2.查询设备离线数量 |
|
|
|
long count = topsailTransmitLogDao.getOfflineDeviceCount(imeiList, focusDeviceOnline.getProjectId()); |
|
|
|
if (count > 0) { |
|
|
|
String subject = "紧急--设备离线通知"+"-" + focusDeviceOnline.getUserName(); |
|
|
|
List<DeviceOnlineInfo> offlineDevices = topsailTransmitLogDao.getOfflineDevice(imeiList, focusDeviceOnline.getProjectId()); |
|
|
|
if (offlineDevices != null && offlineDevices.size() > 0) { |
|
|
|
//将离线的设备号码转成json字符串 |
|
|
|
Map<String, String> offlineDeviceMap = offlineDevices.stream() |
|
|
|
.collect(Collectors.toMap(DeviceOnlineInfo::getImei, DeviceOnlineInfo::getOfflineTime)); |
|
|
|
String json = JSON.toJSONString(offlineDeviceMap); |
|
|
|
String subject = "紧急--设备离线通知" + "-" + focusDeviceOnline.getUserName(); |
|
|
|
String today = new SimpleDateFormat("yyyy-MM-dd HH:00:00").format(new Date()); |
|
|
|
Integer logCount = informLogDao.getNewInformLogCount(subject, today); |
|
|
|
if (logCount == null || (logCount != null && logCount < 1)) { |
|
|
|
//3.发送邮件 |
|
|
|
String content = "客户:" + focusDeviceOnline.getUserName() + ",设备离线数量:" + count + "个,请进入系统查看原因"; |
|
|
|
maiSenderlUtil.sendMail("1129801211@qq.com", subject, content, true, null, subject); |
|
|
|
if (focusDeviceOnline.getSendMails() != null) { |
|
|
|
if (focusDeviceOnline.getSendMails().contains(",")) { |
|
|
|
String[] mails = focusDeviceOnline.getSendMails().split(","); |
|
|
|
for (String mail : mails) { |
|
|
|
//验证邮箱格式 |
|
|
|
if (!maiSenderlUtil.isEmail(mail)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
//3.发送邮件 |
|
|
|
String content = "客户:" + focusDeviceOnline.getUserName() + ",设备离线数量:" + offlineDevices.size() + "个,"+"报警设备和预离线时间信息:"+json+"。请进入系统查看原因"; |
|
|
|
maiSenderlUtil.sendMail(mail, subject, content, true, null, subject); |
|
|
|
} |
|
|
|
} else { |
|
|
|
String content = "客户:" + focusDeviceOnline.getUserName() + ",设备离线数量:" + offlineDevices.size() + "个,"+"报警设备和预离线时间信息:"+json+"。请进入系统查看原因"; |
|
|
|
maiSenderlUtil.sendMail(maiSenderlUtil.isEmail(focusDeviceOnline.getSendMails()) ? focusDeviceOnline.getSendMails() : "1129801211@qq.com", subject, content, true, null, subject); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|