|
@@ -1,12 +1,25 @@
|
|
|
package com.ruoyi.framework.task;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.ruoyi.common.sendEmail.IMailService;
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.framework.web.controller.BaseController;
|
|
|
import com.ruoyi.project.sems.domain.*;
|
|
|
import com.ruoyi.project.sems.service.*;
|
|
|
+import com.ruoyi.project.system.domain.SysUser;
|
|
|
+import com.ruoyi.project.system.domain.TAlarmPrincipal;
|
|
|
+import com.ruoyi.project.system.domain.TAlarmhistory;
|
|
|
+import com.ruoyi.project.system.domain.TAlarmtype;
|
|
|
+import com.ruoyi.project.system.service.ISysUserService;
|
|
|
+import com.ruoyi.project.system.service.ITAlarmPrincipalService;
|
|
|
+import com.ruoyi.project.system.service.ITAlarmhistoryService;
|
|
|
+import com.ruoyi.project.system.service.ITAlarmtypeService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -15,47 +28,88 @@ import java.util.List;
|
|
|
|
|
|
@Component("tSpecdevAllTask")
|
|
|
public class TSpecdevAllTask extends BaseController {
|
|
|
-
|
|
|
+ //注入发送邮件的接口
|
|
|
+ @Autowired
|
|
|
+ private IMailService mailService;
|
|
|
//注入叉车台账接口
|
|
|
@Autowired
|
|
|
private ITSpecdevCcService specdevCcService;
|
|
|
-
|
|
|
//注入电梯台账接口
|
|
|
@Autowired
|
|
|
private ITSpecdevDtService specdevDtService;
|
|
|
-
|
|
|
//注入锅炉台账接口
|
|
|
@Autowired
|
|
|
private ITSpecdevGlService specdevGlService;
|
|
|
-
|
|
|
//注入起重机械台账接口
|
|
|
@Autowired
|
|
|
private ITSpecdevDzsbService specdevDzsbService;
|
|
|
-
|
|
|
//注入压力管道台账接口
|
|
|
@Autowired
|
|
|
private ITSpecdevYlgdService specdevYlgdService;
|
|
|
-
|
|
|
//注入压力容器台账接口
|
|
|
@Autowired
|
|
|
private ITSpecdevYlrqService specdevYlrqService;
|
|
|
+ //注入特种设备预警接口
|
|
|
+ @Autowired
|
|
|
+ private ITAlarmtypeService tAlarmtypeService;
|
|
|
+ //注入预警管理负责人接口
|
|
|
+ @Autowired
|
|
|
+ private ITAlarmPrincipalService tAlarmPrincipalService;
|
|
|
+ //注入用户接口
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService sysUserService;
|
|
|
+ //注入报警记录管理的接口
|
|
|
+ @Autowired
|
|
|
+ private ITAlarmhistoryService alarmhistoryService;
|
|
|
+
|
|
|
+ private final String glAlarmType = "特种设备-锅炉-在用";
|
|
|
+ private final String glUrlSuffix = "sems/devgl/specGl";
|
|
|
+ private final String ccAlarmType = "特种设备-叉车-在用";
|
|
|
+ private final String ccUrlSuffix = "sems/devcc/specCc";
|
|
|
+ private final String dtAlarmType = "特种设备-电梯-在用";
|
|
|
+ private final String dtUrlSuffix = "sems/devdt/specDt";
|
|
|
+ private final String dzsbAlarmType = "特种设备-起重机械-在用";
|
|
|
+ private final String dzsbUrlSuffix = "sems/devdzsb/specDzsb";
|
|
|
+ private final String ylgdAlarmType = "特种设备-压力管道-在用";
|
|
|
+ private final String ylgdUrlSuffix = "sems/devylgd/specYlgd";
|
|
|
+ private final String ylrqAlarmType = "特种设备-压力容器-在用";
|
|
|
+ private final String ylrqUrlSuffix = "sems/devylrq/specYlrq";
|
|
|
+
|
|
|
+ private final String firstWarningLevel = "1级预警";
|
|
|
+ private final String secondWarningLevel = "2级预警";
|
|
|
+ private final String thirdWarningLevel = "3级预警";
|
|
|
+
|
|
|
+ private final Long alarmtype = 1080L;//特种设备预警ID
|
|
|
+
|
|
|
+ private final String contentFormat = "(装置名称,单元,位号,下次检查时间)";
|
|
|
|
|
|
/**
|
|
|
- * 检查叉车预警标识状态
|
|
|
+ * 检查预警标识状态
|
|
|
* 3天检查一次
|
|
|
*/
|
|
|
public void checkWarnFlag() {
|
|
|
- this.checkWarnFlagForGl();
|
|
|
- this.checkWarnFlagForCc();
|
|
|
- this.checkWarnFlagForDt();
|
|
|
- this.checkWarnFlagForDzsb();
|
|
|
- this.checkWarnFlagForYlgd();
|
|
|
- this.checkWarnFlagForYlrq();
|
|
|
+ //获取动态处理预警级别
|
|
|
+ TAlarmtype tAlarmtype = this.tAlarmtypeService.selectTAlarmtypeById(this.alarmtype);
|
|
|
+ Long firstlevel = tAlarmtype.getFirstlevel();//1级
|
|
|
+ Long secondlevel = tAlarmtype.getSecondlevel();//2级
|
|
|
+ Long thirdlevel = tAlarmtype.getThirdlevel();//3级
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ this.checkWarnFlagForGl(firstlevel, secondlevel, thirdlevel, sdf);
|
|
|
+ this.checkWarnFlagForCc(firstlevel, secondlevel, thirdlevel, sdf);
|
|
|
+ this.checkWarnFlagForDt(firstlevel, secondlevel, thirdlevel, sdf);
|
|
|
+ this.checkWarnFlagForDzsb(firstlevel, secondlevel, thirdlevel, sdf);
|
|
|
+ this.checkWarnFlagForYlgd(firstlevel, secondlevel, thirdlevel, sdf);
|
|
|
+ this.checkWarnFlagForYlrq(firstlevel, secondlevel, thirdlevel, sdf);
|
|
|
}
|
|
|
|
|
|
- private void checkWarnFlagForGl() {
|
|
|
+ private void checkWarnFlagForGl(Long firstlevel, Long secondlevel, Long thirdlevel, SimpleDateFormat sdf) {
|
|
|
List<TSpecdevGl> list = this.specdevGlService.list(new QueryWrapper<TSpecdevGl>()
|
|
|
.eq("del_flag", 0).eq("status", "1"));
|
|
|
+ //获取动态处理预警级别
|
|
|
+ TAlarmtype tAlarmtype = this.tAlarmtypeService.selectTAlarmtypeById(this.alarmtype);
|
|
|
+ List<TSpecdevGl> firstList = new ArrayList<>();
|
|
|
+ List<TSpecdevGl> secondList = new ArrayList<>();
|
|
|
+ List<TSpecdevGl> thirdList = new ArrayList<>();
|
|
|
for (TSpecdevGl tSpecdevGl : list) {
|
|
|
if (tSpecdevGl.getNextWarnDate() != null) {
|
|
|
long now = System.currentTimeMillis();
|
|
@@ -63,27 +117,50 @@ public class TSpecdevAllTask extends BaseController {
|
|
|
long nd = 1000 * 24 * 60 * 60;
|
|
|
long day = diff / nd;
|
|
|
// 半年内 预警标识为2级
|
|
|
- if (day > 0 && day <= 180) {
|
|
|
+ if (day > 0 && day <= secondlevel) {
|
|
|
this.updateForGl(2L, tSpecdevGl);
|
|
|
+ firstList.add(tSpecdevGl);
|
|
|
continue;
|
|
|
}
|
|
|
// 半年-一年 预警标识为1级
|
|
|
- if (day > 180 && day <= 365) {
|
|
|
+ if (day > secondlevel && day <= thirdlevel) {
|
|
|
this.updateForGl(1L, tSpecdevGl);
|
|
|
+ secondList.add(tSpecdevGl);
|
|
|
continue;
|
|
|
}
|
|
|
// 超时 预警标识为3级
|
|
|
- if (day < 0) {
|
|
|
+ if (day < firstlevel) {
|
|
|
this.updateForGl(3L, tSpecdevGl);
|
|
|
+ thirdList.add(tSpecdevGl);
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //获取需要发送邮件的人员信息
|
|
|
+ TAlarmPrincipal tAlarmPrincipal = new TAlarmPrincipal();
|
|
|
+ tAlarmPrincipal.setTypeId(this.alarmtype);
|
|
|
+ List<TAlarmPrincipal> userList = this.tAlarmPrincipalService.selectList(tAlarmPrincipal);
|
|
|
+ for (TAlarmPrincipal t : userList) {
|
|
|
+ SysUser user = this.sysUserService.selectUserByStaffId(t.getStaffid());
|
|
|
+ if (user != null) {
|
|
|
+ t.setPrincipalName(user.getNickName());
|
|
|
+ t.setPrincipalEmail(user.getEmail());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ userList.add(tAlarmPrincipal);
|
|
|
+ for (TAlarmPrincipal o : userList) {
|
|
|
+ glSendEmail(sdf, firstList, o, this.glWarningContent(firstList, sdf), this.firstWarningLevel);
|
|
|
+ glSendEmail(sdf, secondList, o, this.glWarningContent(secondList, sdf), this.secondWarningLevel);
|
|
|
+ glSendEmail(sdf, thirdList, o, this.glWarningContent(thirdList, sdf), this.thirdWarningLevel);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- private void checkWarnFlagForCc() {
|
|
|
+ private void checkWarnFlagForCc(Long firstlevel, Long secondlevel, Long thirdlevel, SimpleDateFormat sdf) {
|
|
|
List<TSpecdevCc> list = this.specdevCcService.list(new QueryWrapper<TSpecdevCc>()
|
|
|
.eq("del_flag", 0).eq("status", "1"));
|
|
|
+ List<TSpecdevCc> firstList = new ArrayList<>();
|
|
|
+ List<TSpecdevCc> secondList = new ArrayList<>();
|
|
|
+ List<TSpecdevCc> thirdList = new ArrayList<>();
|
|
|
for (TSpecdevCc tSpecdevCc : list) {
|
|
|
if (tSpecdevCc.getNextWarnDate() != null) {
|
|
|
long now = System.currentTimeMillis();
|
|
@@ -91,27 +168,49 @@ public class TSpecdevAllTask extends BaseController {
|
|
|
long nd = 1000 * 24 * 60 * 60;
|
|
|
long day = diff / nd;
|
|
|
// 半年内 预警标识为2级
|
|
|
- if (day > 0 && day <= 180) {
|
|
|
+ if (day > 0 && day <= secondlevel) {
|
|
|
this.updateForCc(2L, tSpecdevCc);
|
|
|
+ firstList.add(tSpecdevCc);
|
|
|
continue;
|
|
|
}
|
|
|
// 半年-一年 预警标识为1级
|
|
|
- if (day > 180 && day <= 365) {
|
|
|
+ if (day > secondlevel && day <= thirdlevel) {
|
|
|
this.updateForCc(1L, tSpecdevCc);
|
|
|
+ secondList.add(tSpecdevCc);
|
|
|
continue;
|
|
|
}
|
|
|
// 超时 预警标识为3级
|
|
|
- if (day < 0) {
|
|
|
+ if (day < firstlevel) {
|
|
|
this.updateForCc(3L, tSpecdevCc);
|
|
|
+ thirdList.add(tSpecdevCc);
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //获取需要发送邮件的人员信息
|
|
|
+ TAlarmPrincipal tAlarmPrincipal = new TAlarmPrincipal();
|
|
|
+ tAlarmPrincipal.setTypeId(this.alarmtype);
|
|
|
+ List<TAlarmPrincipal> userList = this.tAlarmPrincipalService.selectList(tAlarmPrincipal);
|
|
|
+ for (TAlarmPrincipal t : userList) {
|
|
|
+ SysUser user = this.sysUserService.selectUserByStaffId(t.getStaffid());
|
|
|
+ if (user != null) {
|
|
|
+ t.setPrincipalName(user.getNickName());
|
|
|
+ t.setPrincipalEmail(user.getEmail());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (TAlarmPrincipal o : userList) {
|
|
|
+ ccSendEmail(sdf, firstList, o, this.ccWarningContent(firstList, sdf), this.firstWarningLevel);
|
|
|
+ ccSendEmail(sdf, secondList, o, this.ccWarningContent(secondList, sdf), this.secondWarningLevel);
|
|
|
+ ccSendEmail(sdf, thirdList, o, this.ccWarningContent(thirdList, sdf), this.thirdWarningLevel);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- private void checkWarnFlagForDzsb() {
|
|
|
+ private void checkWarnFlagForDzsb(Long firstlevel, Long secondlevel, Long thirdlevel, SimpleDateFormat sdf) {
|
|
|
List<TSpecdevDzsb> list = this.specdevDzsbService.list(new QueryWrapper<TSpecdevDzsb>()
|
|
|
.eq("del_flag", 0).eq("status", "1"));
|
|
|
+ List<TSpecdevDzsb> firstList = new ArrayList<>();
|
|
|
+ List<TSpecdevDzsb> secondList = new ArrayList<>();
|
|
|
+ List<TSpecdevDzsb> thirdList = new ArrayList<>();
|
|
|
for (TSpecdevDzsb tSpecdevDzsb : list) {
|
|
|
if (tSpecdevDzsb.getNextWarnDate() != null) {
|
|
|
long now = System.currentTimeMillis();
|
|
@@ -119,27 +218,49 @@ public class TSpecdevAllTask extends BaseController {
|
|
|
long nd = 1000 * 24 * 60 * 60;
|
|
|
long day = diff / nd;
|
|
|
// 半年内 预警标识为2级
|
|
|
- if (day > 0 && day <= 180) {
|
|
|
+ if (day > 0 && day <= secondlevel) {
|
|
|
this.updateForDzsb(2L, tSpecdevDzsb);
|
|
|
+ firstList.add(tSpecdevDzsb);
|
|
|
continue;
|
|
|
}
|
|
|
// 半年-一年 预警标识为1级
|
|
|
- if (day > 180 && day <= 365) {
|
|
|
+ if (day > secondlevel && day <= thirdlevel) {
|
|
|
this.updateForDzsb(1L, tSpecdevDzsb);
|
|
|
+ secondList.add(tSpecdevDzsb);
|
|
|
continue;
|
|
|
}
|
|
|
// 超时 预警标识为3级
|
|
|
- if (day < 0) {
|
|
|
+ if (day < firstlevel) {
|
|
|
this.updateForDzsb(3L, tSpecdevDzsb);
|
|
|
+ thirdList.add(tSpecdevDzsb);
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //获取需要发送邮件的人员信息
|
|
|
+ TAlarmPrincipal tAlarmPrincipal = new TAlarmPrincipal();
|
|
|
+ tAlarmPrincipal.setTypeId(this.alarmtype);
|
|
|
+ List<TAlarmPrincipal> userList = this.tAlarmPrincipalService.selectList(tAlarmPrincipal);
|
|
|
+ for (TAlarmPrincipal t : userList) {
|
|
|
+ SysUser user = this.sysUserService.selectUserByStaffId(t.getStaffid());
|
|
|
+ if (user != null) {
|
|
|
+ t.setPrincipalName(user.getNickName());
|
|
|
+ t.setPrincipalEmail(user.getEmail());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (TAlarmPrincipal o : userList) {
|
|
|
+ dzsbSendEmail(sdf, firstList, o, this.dzsbWarningContent(firstList, sdf), this.firstWarningLevel);
|
|
|
+ dzsbSendEmail(sdf, secondList, o, this.dzsbWarningContent(secondList, sdf), this.secondWarningLevel);
|
|
|
+ dzsbSendEmail(sdf, thirdList, o, this.dzsbWarningContent(thirdList, sdf), this.thirdWarningLevel);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- private void checkWarnFlagForYlrq() {
|
|
|
+ private void checkWarnFlagForYlrq(Long firstlevel, Long secondlevel, Long thirdlevel, SimpleDateFormat sdf) {
|
|
|
List<TSpecdevYlrq> list = this.specdevYlrqService.list(new QueryWrapper<TSpecdevYlrq>()
|
|
|
.eq("del_flag", 0).eq("status", "1"));
|
|
|
+ List<TSpecdevYlrq> firstList = new ArrayList<>();
|
|
|
+ List<TSpecdevYlrq> secondList = new ArrayList<>();
|
|
|
+ List<TSpecdevYlrq> thirdList = new ArrayList<>();
|
|
|
for (TSpecdevYlrq tSpecdevYlrq : list) {
|
|
|
if (tSpecdevYlrq.getNextWarnDate() != null) {
|
|
|
long now = System.currentTimeMillis();
|
|
@@ -147,27 +268,49 @@ public class TSpecdevAllTask extends BaseController {
|
|
|
long nd = 1000 * 24 * 60 * 60;
|
|
|
long day = diff / nd;
|
|
|
// 半年内 预警标识为2级
|
|
|
- if (day > 0 && day <= 180) {
|
|
|
+ if (day > 0 && day <= secondlevel) {
|
|
|
this.updateForYlrq(2L, tSpecdevYlrq);
|
|
|
+ firstList.add(tSpecdevYlrq);
|
|
|
continue;
|
|
|
}
|
|
|
// 半年-一年 预警标识为1级
|
|
|
- if (day > 180 && day <= 365) {
|
|
|
+ if (day > secondlevel && day <= thirdlevel) {
|
|
|
this.updateForYlrq(1L, tSpecdevYlrq);
|
|
|
+ secondList.add(tSpecdevYlrq);
|
|
|
continue;
|
|
|
}
|
|
|
// 超时 预警标识为3级
|
|
|
- if (day < 0) {
|
|
|
+ if (day < firstlevel) {
|
|
|
this.updateForYlrq(3L, tSpecdevYlrq);
|
|
|
+ thirdList.add(tSpecdevYlrq);
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //获取需要发送邮件的人员信息
|
|
|
+ TAlarmPrincipal tAlarmPrincipal = new TAlarmPrincipal();
|
|
|
+ tAlarmPrincipal.setTypeId(this.alarmtype);
|
|
|
+ List<TAlarmPrincipal> userList = this.tAlarmPrincipalService.selectList(tAlarmPrincipal);
|
|
|
+ for (TAlarmPrincipal t : userList) {
|
|
|
+ SysUser user = this.sysUserService.selectUserByStaffId(t.getStaffid());
|
|
|
+ if (user != null) {
|
|
|
+ t.setPrincipalName(user.getNickName());
|
|
|
+ t.setPrincipalEmail(user.getEmail());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (TAlarmPrincipal o : userList) {
|
|
|
+ ylrqSendEmail(sdf, firstList, o, this.ylrqWarningContent(firstList, sdf), this.firstWarningLevel);
|
|
|
+ ylrqSendEmail(sdf, secondList, o, this.ylrqWarningContent(secondList, sdf), this.secondWarningLevel);
|
|
|
+ ylrqSendEmail(sdf, thirdList, o, this.ylrqWarningContent(thirdList, sdf), this.thirdWarningLevel);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- private void checkWarnFlagForYlgd() {
|
|
|
+ private void checkWarnFlagForYlgd(Long firstlevel, Long secondlevel, Long thirdlevel, SimpleDateFormat sdf) {
|
|
|
List<TSpecdevYlgd> list = this.specdevYlgdService.list(new QueryWrapper<TSpecdevYlgd>()
|
|
|
.eq("del_flag", 0).eq("status", "1"));
|
|
|
+ List<TSpecdevYlgd> firstList = new ArrayList<>();
|
|
|
+ List<TSpecdevYlgd> secondList = new ArrayList<>();
|
|
|
+ List<TSpecdevYlgd> thirdList = new ArrayList<>();
|
|
|
for (TSpecdevYlgd tSpecdevYlgd : list) {
|
|
|
if (tSpecdevYlgd.getNextWarnDate() != null) {
|
|
|
long now = System.currentTimeMillis();
|
|
@@ -175,27 +318,49 @@ public class TSpecdevAllTask extends BaseController {
|
|
|
long nd = 1000 * 24 * 60 * 60;
|
|
|
long day = diff / nd;
|
|
|
// 半年内 预警标识为2级
|
|
|
- if (day > 0 && day <= 180) {
|
|
|
+ if (day > 0 && day <= secondlevel) {
|
|
|
this.updateForYlgd(2L, tSpecdevYlgd);
|
|
|
+ firstList.add(tSpecdevYlgd);
|
|
|
continue;
|
|
|
}
|
|
|
// 半年-一年 预警标识为1级
|
|
|
- if (day > 180 && day <= 365) {
|
|
|
+ if (day > secondlevel && day <= thirdlevel) {
|
|
|
this.updateForYlgd(1L, tSpecdevYlgd);
|
|
|
+ secondList.add(tSpecdevYlgd);
|
|
|
continue;
|
|
|
}
|
|
|
// 超时 预警标识为3级
|
|
|
- if (day < 0) {
|
|
|
+ if (day < firstlevel) {
|
|
|
this.updateForYlgd(3L, tSpecdevYlgd);
|
|
|
+ thirdList.add(tSpecdevYlgd);
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //获取需要发送邮件的人员信息
|
|
|
+ TAlarmPrincipal tAlarmPrincipal = new TAlarmPrincipal();
|
|
|
+ tAlarmPrincipal.setTypeId(this.alarmtype);
|
|
|
+ List<TAlarmPrincipal> userList = this.tAlarmPrincipalService.selectList(tAlarmPrincipal);
|
|
|
+ for (TAlarmPrincipal t : userList) {
|
|
|
+ SysUser user = this.sysUserService.selectUserByStaffId(t.getStaffid());
|
|
|
+ if (user != null) {
|
|
|
+ t.setPrincipalName(user.getNickName());
|
|
|
+ t.setPrincipalEmail(user.getEmail());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (TAlarmPrincipal o : userList) {
|
|
|
+ ylgdSendEmail(sdf, firstList, o, this.ylgdWarningContent(firstList, sdf), this.firstWarningLevel);
|
|
|
+ ylgdSendEmail(sdf, secondList, o, this.ylgdWarningContent(secondList, sdf), this.secondWarningLevel);
|
|
|
+ ylgdSendEmail(sdf, thirdList, o, this.ylgdWarningContent(thirdList, sdf), this.thirdWarningLevel);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- private void checkWarnFlagForDt() {
|
|
|
+ private void checkWarnFlagForDt(Long firstlevel, Long secondlevel, Long thirdlevel, SimpleDateFormat sdf) {
|
|
|
List<TSpecdevDt> list = this.specdevDtService.list(new QueryWrapper<TSpecdevDt>()
|
|
|
.eq("del_flag", 0).eq("status", "1"));
|
|
|
+ List<TSpecdevDt> firstList = new ArrayList<>();
|
|
|
+ List<TSpecdevDt> secondList = new ArrayList<>();
|
|
|
+ List<TSpecdevDt> thirdList = new ArrayList<>();
|
|
|
for (TSpecdevDt tSpecdevDt : list) {
|
|
|
if (tSpecdevDt.getNextWarnDate() != null) {
|
|
|
long now = System.currentTimeMillis();
|
|
@@ -203,22 +368,233 @@ public class TSpecdevAllTask extends BaseController {
|
|
|
long nd = 1000 * 24 * 60 * 60;
|
|
|
long day = diff / nd;
|
|
|
// 半年内 预警标识为2级
|
|
|
- if (day > 0 && day <= 180) {
|
|
|
+ if (day > 0 && day <= secondlevel) {
|
|
|
this.updateForDt(2L, tSpecdevDt);
|
|
|
+ firstList.add(tSpecdevDt);
|
|
|
continue;
|
|
|
}
|
|
|
// 半年-一年 预警标识为1级
|
|
|
- if (day > 180 && day <= 365) {
|
|
|
+ if (day > secondlevel && day <= thirdlevel) {
|
|
|
this.updateForDt(1L, tSpecdevDt);
|
|
|
+ secondList.add(tSpecdevDt);
|
|
|
continue;
|
|
|
}
|
|
|
// 超时 预警标识为3级
|
|
|
- if (day < 0) {
|
|
|
+ if (day < firstlevel) {
|
|
|
this.updateForDt(3L, tSpecdevDt);
|
|
|
+ thirdList.add(tSpecdevDt);
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //获取需要发送邮件的人员信息
|
|
|
+ TAlarmPrincipal tAlarmPrincipal = new TAlarmPrincipal();
|
|
|
+ tAlarmPrincipal.setTypeId(this.alarmtype);
|
|
|
+ List<TAlarmPrincipal> userList = this.tAlarmPrincipalService.selectList(tAlarmPrincipal);
|
|
|
+ for (TAlarmPrincipal t : userList) {
|
|
|
+ SysUser user = this.sysUserService.selectUserByStaffId(t.getStaffid());
|
|
|
+ if (user != null) {
|
|
|
+ t.setPrincipalName(user.getNickName());
|
|
|
+ t.setPrincipalEmail(user.getEmail());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (TAlarmPrincipal o : userList) {
|
|
|
+ dtSendEmail(sdf, firstList, o, this.dtWarningContent(firstList, sdf), this.firstWarningLevel);
|
|
|
+ dtSendEmail(sdf, secondList, o, this.dtWarningContent(secondList, sdf), this.secondWarningLevel);
|
|
|
+ dtSendEmail(sdf, thirdList, o, this.dtWarningContent(thirdList, sdf), this.thirdWarningLevel);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 锅炉发送邮件公共方法
|
|
|
+ *
|
|
|
+ * @param sdf 日期转换
|
|
|
+ * @param gl 锅炉集合
|
|
|
+ * @param o 负责人信息
|
|
|
+ * @param warningContent 预警内容详情
|
|
|
+ * @param level 预警等级
|
|
|
+ */
|
|
|
+ private void glSendEmail(SimpleDateFormat sdf, List<TSpecdevGl> gl, TAlarmPrincipal o, String warningContent, String level) {
|
|
|
+ if (gl.size() > 0) {
|
|
|
+ this.sendEmail(o.getPrincipalName(), o.getPrincipalEmail(), this.glAlarmType, level,
|
|
|
+ this.contentFormat, this.glWarningContent(gl, sdf), this.glUrlSuffix);
|
|
|
+ insertHistory(o, level.substring(0, 1), warningContent, this.alarmtype + "", this.glAlarmType);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 电梯发送邮件公共方法
|
|
|
+ *
|
|
|
+ * @param sdf 日期转换
|
|
|
+ * @param dt 电梯集合
|
|
|
+ * @param o 负责人信息
|
|
|
+ * @param warningContent 预警内容详情
|
|
|
+ * @param level 预警等级
|
|
|
+ */
|
|
|
+ private void dtSendEmail(SimpleDateFormat sdf, List<TSpecdevDt> dt, TAlarmPrincipal o, String warningContent, String level) {
|
|
|
+ if (dt.size() > 0) {
|
|
|
+ this.sendEmail(o.getPrincipalName(), o.getPrincipalEmail(), this.glAlarmType, level,
|
|
|
+ this.contentFormat, this.dtWarningContent(dt, sdf), this.glUrlSuffix);
|
|
|
+ insertHistory(o, level.substring(0, 1), warningContent, this.alarmtype + "", this.glAlarmType);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 叉车发送邮件公共方法
|
|
|
+ *
|
|
|
+ * @param sdf 日期转换
|
|
|
+ * @param cc 叉车集合
|
|
|
+ * @param o 负责人信息
|
|
|
+ * @param warningContent 预警内容详情
|
|
|
+ * @param level 预警等级
|
|
|
+ */
|
|
|
+ private void ccSendEmail(SimpleDateFormat sdf, List<TSpecdevCc> cc, TAlarmPrincipal o, String warningContent, String level) {
|
|
|
+ if (cc.size() > 0) {
|
|
|
+ this.sendEmail(o.getPrincipalName(), o.getPrincipalEmail(), this.ccAlarmType, level,
|
|
|
+ this.contentFormat, this.ccWarningContent(cc, sdf), this.ccUrlSuffix);
|
|
|
+ insertHistory(o, level.substring(0, 1), warningContent, this.alarmtype + "", this.ccAlarmType);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 吊装设备发送邮件公共方法
|
|
|
+ *
|
|
|
+ * @param sdf 日期转换
|
|
|
+ * @param dzsb 吊装设备集合
|
|
|
+ * @param o 负责人信息
|
|
|
+ * @param warningContent 预警内容详情
|
|
|
+ * @param level 预警等级
|
|
|
+ */
|
|
|
+ private void dzsbSendEmail(SimpleDateFormat sdf, List<TSpecdevDzsb> dzsb, TAlarmPrincipal o, String warningContent, String level) {
|
|
|
+ if (dzsb.size() > 0) {
|
|
|
+ this.sendEmail(o.getPrincipalName(), o.getPrincipalEmail(), this.dzsbAlarmType, level,
|
|
|
+ this.contentFormat, this.dzsbWarningContent(dzsb, sdf), this.dzsbUrlSuffix);
|
|
|
+ insertHistory(o, level.substring(0, 1), warningContent, this.alarmtype + "", this.dzsbAlarmType);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 压力管道发送邮件公共方法
|
|
|
+ *
|
|
|
+ * @param sdf 日期转换
|
|
|
+ * @param ylgd 压力管道集合
|
|
|
+ * @param o 负责人信息
|
|
|
+ * @param warningContent 预警内容详情
|
|
|
+ * @param level 预警等级
|
|
|
+ */
|
|
|
+ private void ylgdSendEmail(SimpleDateFormat sdf, List<TSpecdevYlgd> ylgd, TAlarmPrincipal o, String warningContent, String level) {
|
|
|
+ if (ylgd.size() > 0) {
|
|
|
+ this.sendEmail(o.getPrincipalName(), o.getPrincipalEmail(), this.ylgdAlarmType, level,
|
|
|
+ this.contentFormat, this.ylgdWarningContent(ylgd, sdf), this.ylgdUrlSuffix);
|
|
|
+ insertHistory(o, level.substring(0, 1), warningContent, this.alarmtype + "", this.ylgdAlarmType);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 压力容器发送邮件公共方法
|
|
|
+ *
|
|
|
+ * @param sdf 日期转换
|
|
|
+ * @param ylrq 压力容器集合
|
|
|
+ * @param o 负责人信息
|
|
|
+ * @param warningContent 预警内容详情
|
|
|
+ * @param level 预警等级
|
|
|
+ */
|
|
|
+ private void ylrqSendEmail(SimpleDateFormat sdf, List<TSpecdevYlrq> ylrq, TAlarmPrincipal o, String warningContent, String level) {
|
|
|
+ if (ylrq.size() > 0) {
|
|
|
+ this.sendEmail(o.getPrincipalName(), o.getPrincipalEmail(), this.ylrqAlarmType, level,
|
|
|
+ this.contentFormat, this.ylrqWarningContent(ylrq, sdf), this.ylrqUrlSuffix);
|
|
|
+ insertHistory(o, level.substring(0, 1), warningContent, this.alarmtype + "", this.ylrqAlarmType);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理电梯预警内容详情
|
|
|
+ *
|
|
|
+ * @param list 电梯数据集合
|
|
|
+ * @param sdf 日期转换
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String dtWarningContent(List<TSpecdevDt> list, SimpleDateFormat sdf) {
|
|
|
+ String str = "";
|
|
|
+ for (TSpecdevDt t : list) {
|
|
|
+ str += "<br>" + t.getPlantCode() + "," + t.getDevno() + "," + sdf.format(t.getNextWarnDate());
|
|
|
+ }
|
|
|
+ return str;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理吊装设备预警内容详情
|
|
|
+ *
|
|
|
+ * @param list 吊装设备数据集合
|
|
|
+ * @param sdf 日期转换
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String dzsbWarningContent(List<TSpecdevDzsb> list, SimpleDateFormat sdf) {
|
|
|
+ String str = "";
|
|
|
+ for (TSpecdevDzsb t : list) {
|
|
|
+ str += "<br>" + t.getPlantCode() + "," + t.getDevno() + "," + sdf.format(t.getNextWarnDate());
|
|
|
+ }
|
|
|
+ return str;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理叉车预警内容详情
|
|
|
+ *
|
|
|
+ * @param list 叉车数据集合
|
|
|
+ * @param sdf 日期转换
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String ccWarningContent(List<TSpecdevCc> list, SimpleDateFormat sdf) {
|
|
|
+ String str = "";
|
|
|
+ for (TSpecdevCc t : list) {
|
|
|
+ str += "<br>" + t.getPlantCode() + "," + t.getDevno() + "," + sdf.format(t.getNextWarnDate());
|
|
|
+ }
|
|
|
+ return str;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理压力管道预警内容详情
|
|
|
+ *
|
|
|
+ * @param list 压力管道数据集合
|
|
|
+ * @param sdf 日期转换
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String ylgdWarningContent(List<TSpecdevYlgd> list, SimpleDateFormat sdf) {
|
|
|
+ String str = "";
|
|
|
+ for (TSpecdevYlgd t : list) {
|
|
|
+ str += "<br>" + t.getPlantCode() + "," + t.getDevno() + "," + sdf.format(t.getNextWarnDate());
|
|
|
+ }
|
|
|
+ return str;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理压力容器预警内容详情
|
|
|
+ *
|
|
|
+ * @param list 压力容器数据集合
|
|
|
+ * @param sdf 日期转换
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String ylrqWarningContent(List<TSpecdevYlrq> list, SimpleDateFormat sdf) {
|
|
|
+ String str = "";
|
|
|
+ for (TSpecdevYlrq t : list) {
|
|
|
+ str += "<br>" + t.getPlantCode() + "," + t.getDevno() + "," + sdf.format(t.getNextWarnDate());
|
|
|
+ }
|
|
|
+ return str;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理锅炉预警内容详情
|
|
|
+ *
|
|
|
+ * @param list 锅炉数据集合
|
|
|
+ * @param sdf 日期转换
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String glWarningContent(List<TSpecdevGl> list, SimpleDateFormat sdf) {
|
|
|
+ String str = "";
|
|
|
+ for (TSpecdevGl t : list) {
|
|
|
+ str += "<br>" + t.getPlantCode() + "," + t.getDevno() + "," + sdf.format(t.getNextWarnDate());
|
|
|
+ }
|
|
|
+ return str;
|
|
|
}
|
|
|
|
|
|
private void updateForCc(Long flag, TSpecdevCc tSpecdevCc) {
|
|
@@ -250,4 +626,76 @@ public class TSpecdevAllTask extends BaseController {
|
|
|
tSpecdevYlrq.setWarnFlag(flag);
|
|
|
this.specdevYlrqService.updateTSpecdevYlrq(tSpecdevYlrq);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 特种设备预警-邮件发送
|
|
|
+ *
|
|
|
+ * @param username 负责人姓名
|
|
|
+ * @param email 负责人邮箱
|
|
|
+ * @param alarmType 预警类型
|
|
|
+ * @param warningLevel 预警等级
|
|
|
+ * @param contenFormat 预警内容
|
|
|
+ * @param warningContent 预警内容详细
|
|
|
+ * @param urlSuffix 链接跳转对应路径
|
|
|
+ */
|
|
|
+ private void sendEmail(String username, String email, String alarmType, String warningLevel, String contenFormat, String warningContent, String urlSuffix) {
|
|
|
+ //写html开始内容
|
|
|
+ String start = "<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title></title></head><body><div style=\"background-color:#ECECEC; padding: 35px;\">" +
|
|
|
+ "<table cellpadding=\"0\" align=\"center\"" +
|
|
|
+ "style=\"width: 600px; margin: 0px auto; text-align: left; position: relative; border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; font-size: 14px; font-family:微软雅黑, 黑体; line-height: 1.5; box-shadow: rgb(153, 153, 153) 0px 0px 5px; border-collapse: collapse; background-position: initial initial; background-repeat: initial initial;background:#fff;\">" +
|
|
|
+ "<tbody><tr><th valign=\"middle\" style=\"height: 25px; line-height: 25px; padding: 15px 35px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #42a3d3; background-color: #49bcff; border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px;\">" +
|
|
|
+ "<font face=\"微软雅黑\" size=\"5\" style=\"color: rgb(255, 255, 255); \">化工装置管理系统 </font><font face=\"微软雅黑\" size=\"3\" style=\"color: rgb(255, 255, 255); \">Chemical Plant Management System(CPMS)</font></th></tr>";
|
|
|
+ //写html结尾内容
|
|
|
+ String end = "</tbody></table></div></body></html>";
|
|
|
+ //表html中间内容
|
|
|
+ String prime = "";
|
|
|
+ String firstcenter = "<tr><td><div style=\"padding:25px 35px 40px; background-color:#fff;\"><h2 style=\"margin: 5px 0px; \">" +
|
|
|
+ "<font color=\"#333333\" style=\"line-height: 20px; \"><font style=\"line-height: 22px; \" size=\"4\">" +
|
|
|
+ "亲爱的 username</font><br><font style=\"line-height: 22px; \" size=\"4\">" +
|
|
|
+ "<p>您有一条预警信息:<br>" +
|
|
|
+ "预警类型:<b>alarmType</b><br>" +
|
|
|
+ "预警等级:<b>warningLevel</b><br>" +
|
|
|
+ "预警内容contenFormat:<b>warningContent</b><br>" +
|
|
|
+ "请前往<a href=\"http://47.114.101.16:8080/cpms/index.html#/urlSuffix\">alarmType</a>查看。<br>" +
|
|
|
+ "<p align=\"right\">date</p>" +
|
|
|
+ "<div style=\"width:700px;margin:0 auto;\">" +
|
|
|
+ "<div style=\"padding:10px 10px 0;border-top:1px solid #ccc;color:#747474;margin-bottom:20px;line-height:1.3em;font-size:12px;\">" +
|
|
|
+ "<p>此为系统邮件,请勿回复<br>This e-Mail is an automatic reminder sent by CPMS, please do not reply</p>" +
|
|
|
+ "</div></div></div></td></tr>";
|
|
|
+ String one = firstcenter.replaceFirst("username", username);
|
|
|
+ String two = one.replaceFirst("alarmType", alarmType);
|
|
|
+ String three = two.replaceFirst("warningLevel", warningLevel);
|
|
|
+ String four = three.replaceFirst("contenFormat", contenFormat);
|
|
|
+ String five = four.replaceFirst("warningContent", warningContent);
|
|
|
+ String six = five.replaceFirst("urlSuffix", urlSuffix);
|
|
|
+ String seven = six.replaceFirst("alarmType", alarmType);
|
|
|
+ String result = seven.replaceFirst("date", String.valueOf(new Date()));
|
|
|
+ prime = prime + result;
|
|
|
+ //拼接html
|
|
|
+ String html = start + prime + end;
|
|
|
+ this.mailService.sendHtmlMail(email, "CPMS:您有一条预警信息", html);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 预警记录管理新增
|
|
|
+ */
|
|
|
+ public void insertHistory(TAlarmPrincipal a, String warningLevel, String warningContent, String typeId, String alarmType) {
|
|
|
+ //预警记录管理新增
|
|
|
+ TAlarmhistory alarmhistory = new TAlarmhistory();
|
|
|
+ alarmhistory.setPlantCode(a.getPlantCode());
|
|
|
+ alarmhistory.setTableName(alarmType);
|
|
|
+ alarmhistory.setStaffid(a.getStaffid());
|
|
|
+ alarmhistory.setDeptId(a.getDeptId());
|
|
|
+ alarmhistory.setTypeId(Long.parseLong(typeId));
|
|
|
+ alarmhistory.setAlarmLevel(warningLevel);
|
|
|
+ alarmhistory.setAlarmContent(StringUtils.remove(warningContent, "<br>"));
|
|
|
+ String[] content = StringUtils.remove(warningContent, "<br>").split(";");
|
|
|
+ if (content.length == 0) {
|
|
|
+ alarmhistory.setAlarmNum(Long.parseLong(String.valueOf("1")));
|
|
|
+ } else {
|
|
|
+ alarmhistory.setAlarmNum(Long.parseLong(String.valueOf(content.length)));
|
|
|
+ }
|
|
|
+ alarmhistory.setSendTime(new Date());
|
|
|
+ alarmhistoryService.insertTAlarmhistory(alarmhistory);
|
|
|
+ }
|
|
|
}
|