| | |
| | | package com.yssh.service; |
| | | |
| | | import com.yssh.mapper.QxshMapper; |
| | | import com.yssh.utils.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.mail.*; |
| | | import javax.mail.internet.InternetAddress; |
| | | import javax.mail.internet.MimeMessage; |
| | |
| | | @Value("${email.hours}") |
| | | private Integer hours; |
| | | |
| | | @Value("${email.names}") |
| | | private String names; |
| | | |
| | | @Value("${email.title}") |
| | | private String title; |
| | | |
| | | @Value("${email.enable}") |
| | | private Boolean enable; |
| | | |
| | | @Resource |
| | | private QxshMapper qxshMapper; |
| | | |
| | | private final static SimpleDateFormat YMDH = new SimpleDateFormat("yyyyMMddHH"); |
| | | |
| | | private final static SimpleDateFormat Y_M_D_H = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | |
| | | |
| | | public Boolean send(String title, String text) { |
| | | try { |
| | | if (!enable) { |
| | | return null; |
| | | } |
| | | |
| | | // 创建Session会话 |
| | | Session session = createSession(); |
| | | |
| | |
| | | public int calcData() { |
| | | List<String> list = new ArrayList<>(); |
| | | |
| | | String[] strs = names.split(","); |
| | | int count = countCsv(bigPath, hours); |
| | | if (0 == count) { |
| | | list.add("大CSV近 " + hours + " 小时存在文件缺失,"); |
| | | list.add(strs[0]); |
| | | } |
| | | count = countCsv(filePath, hours); |
| | | if (0 == count) { |
| | | list.add("中CSV近 " + hours + " 小时存在文件缺失,"); |
| | | list.add(strs[1]); |
| | | } |
| | | count = countCsv(vocPath, hours); |
| | | if (0 == count) { |
| | | list.add("小CSV近 " + hours + " 小时存在文件缺失,"); |
| | | list.add(strs[2]); |
| | | } |
| | | |
| | | Calendar calendar = getCalendar(1); |
| | | calendar = getCalendar(0); |
| | | Calendar calendar = getCalendar(0); |
| | | Integer iEnd = Integer.parseInt(YMDH.format(calendar.getTime())); |
| | | String sEnd = Y_M_D_H.format(calendar.getTime()); |
| | | calendar.add(Calendar.HOUR, 1 - hours); |
| | | Integer iStart = Integer.parseInt(YMDH.format(calendar.getTime())); |
| | | String sStart = Y_M_D_H.format(calendar.getTime()); |
| | | |
| | | count = qxshMapper.countGcsjByTime(iStart, iEnd); |
| | | if (0 == count) { |
| | | list.add(strs[3]); |
| | | } |
| | | count = qxshMapper.countQxshByTime(iStart, iEnd); |
| | | if (0 == count) { |
| | | list.add(strs[4]); |
| | | } |
| | | count = qxshMapper.countSuYuan46ByTime(sStart, sEnd); |
| | | if (0 == count) { |
| | | list.add(strs[5]); |
| | | } |
| | | count = qxshMapper.countSuYuan70ByTime(sStart, sEnd); |
| | | if (0 == count) { |
| | | list.add(strs[6]); |
| | | } |
| | | count = qxshMapper.countSuYuanFastByTime(sStart, sEnd); |
| | | if (0 == count) { |
| | | list.add(strs[7]); |
| | | } |
| | | |
| | | int size = list.size(); |
| | | if (size > 0) { |
| | | String text = String.join("、", list.toArray(new String[list.size()])) + ",近" + hours + "小时内存在数据缺失。"; |
| | | send(title, text); |
| | | } |
| | | |
| | | return size; |
| | | } |