Kaynağa Gözat

裂解炉炉管测温测压
- 文丘里压力比值大于等于0.9时,邮件提醒
- 温度COIL测量温度大于等于1080时,邮件提醒

wangggziwen 1 yıl önce
ebeveyn
işleme
bce850e283

+ 81 - 0
master/src/main/java/com/ruoyi/common/thread/furnance/FurnancePressureThread.java

@@ -0,0 +1,81 @@
+package com.ruoyi.common.thread.furnance;
+
+import com.github.stuxuhai.jpinyin.PinyinException;
+import com.github.stuxuhai.jpinyin.PinyinFormat;
+import com.github.stuxuhai.jpinyin.PinyinHelper;
+import com.ruoyi.common.sendEmail.IMailService;
+import com.ruoyi.project.plant.domain.TStaffmgr;
+import com.ruoyi.project.production.domain.TSaiApply;
+import com.ruoyi.project.system.domain.SysMessage;
+import com.ruoyi.project.system.service.ISysMessageService;
+import org.activiti.engine.task.Task;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * @author Wang Zi Wen
+ * @email wangggziwen@163.com
+ * @date 2024/05/22 15:25:22
+ */
+public class FurnancePressureThread implements Runnable {
+
+    private IMailService mailService;
+
+    private String email;
+
+    private String staffName;
+
+    private String staffNameEN;
+
+    private String loginName;
+
+    public FurnancePressureThread() {}
+
+    public FurnancePressureThread(IMailService mailService, TStaffmgr staffmgr, String loginName) throws PinyinException {
+        this.mailService = mailService;
+        this.email = staffmgr.getMail();
+        this.staffName = staffmgr.getName();
+        this.staffNameEN = PinyinHelper.convertToPinyinString(staffName.trim(), " ", PinyinFormat.WITHOUT_TONE);
+        this.loginName =  loginName;
+    }
+
+    @Override
+    public void run() {
+        this.sendMail();
+    }
+
+    private void sendMail() {
+        String jumpUrl = "/production/pressure";
+        //写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); \">CPMS管理系统 </font><font face=\"微软雅黑\" size=\"3\" style=\"color: rgb(255, 255, 255); \">CPMS System</font></th></tr>";
+        //表html中间内容
+        String prime = "";
+        String center = "<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\">" +
+                "亲爱的staffName</font><br><font style=\"line-height: 22px; \" size=\"4\">" +
+                "Dear staffNameEN(loginName)</font></font></h2>" +
+                "<p>裂解炉炉管测压FVP数值异常,请及时查看。<br>" +
+                "请登录<a href=\"https://cpms.basf-ypc.net.cn/cpms/index.html#jumpUrl\">CPMS管理系统</a>查看。<br>" +
+                "Please log in the <a href=\"https://cpms.basf-ypc.net.cn/cpms/index.html#jumpUrl\">CPMS</a> to handle it.</p>" +
+                "<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 = center.replaceFirst("staffName", staffName);
+        String two = one.replaceFirst("staffNameEN", staffNameEN);
+        String three = two.replaceFirst("loginName", loginName);
+        String result = three.replaceFirst("date", String.valueOf(new Date())).replaceFirst("jumpUrl",jumpUrl).replaceFirst("jumpUrl",jumpUrl);
+        prime = prime + result;
+        //写html结尾内容
+        String end = "</tbody></table></div></body></html>";
+        //拼接html
+        String html = start + prime + end;
+        mailService.sendHtmlMail(email, "CPMS:裂解炉炉管测压FVP数值异常", html);
+    }
+}

+ 75 - 0
master/src/main/java/com/ruoyi/common/thread/furnance/FurnanceTemperatureThread.java

@@ -0,0 +1,75 @@
+package com.ruoyi.common.thread.furnance;
+
+import com.github.stuxuhai.jpinyin.PinyinException;
+import com.github.stuxuhai.jpinyin.PinyinFormat;
+import com.github.stuxuhai.jpinyin.PinyinHelper;
+import com.ruoyi.common.sendEmail.IMailService;
+import com.ruoyi.project.plant.domain.TStaffmgr;
+import java.util.Date;
+
+/**
+ * @author Wang Zi Wen
+ * @email wangggziwen@163.com
+ * @date 2024/05/22 15:25:40
+ */
+public class FurnanceTemperatureThread implements Runnable {
+
+    private IMailService mailService;
+
+    private String email;
+
+    private String staffName;
+
+    private String staffNameEN;
+
+    private String loginName;
+
+    public FurnanceTemperatureThread() {}
+
+    public FurnanceTemperatureThread(IMailService mailService, TStaffmgr staffmgr, String loginName) throws PinyinException {
+        this.mailService = mailService;
+        this.email = staffmgr.getMail();
+        this.staffName = staffmgr.getName();
+        this.staffNameEN = PinyinHelper.convertToPinyinString(staffName.trim(), " ", PinyinFormat.WITHOUT_TONE);
+        this.loginName =  loginName;
+    }
+
+    @Override
+    public void run() {
+        this.sendMail();
+    }
+
+    private void sendMail() {
+        String jumpUrl = "/production/temperature";
+        //写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); \">CPMS管理系统 </font><font face=\"微软雅黑\" size=\"3\" style=\"color: rgb(255, 255, 255); \">CPMS System</font></th></tr>";
+        //表html中间内容
+        String prime = "";
+        String center = "<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\">" +
+                "亲爱的staffName</font><br><font style=\"line-height: 22px; \" size=\"4\">" +
+                "Dear staffNameEN(loginName)</font></font></h2>" +
+                "<p>裂解炉炉管测温COIL数值异常,请及时查看。<br>" +
+                "请登录<a href=\"https://cpms.basf-ypc.net.cn/cpms/index.html#jumpUrl\">CPMS管理系统</a>查看。<br>" +
+                "Please log in the <a href=\"https://cpms.basf-ypc.net.cn/cpms/index.html#jumpUrl\">CPMS</a> to handle it.</p>" +
+                "<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 = center.replaceFirst("staffName", staffName);
+        String two = one.replaceFirst("staffNameEN", staffNameEN);
+        String three = two.replaceFirst("loginName", loginName);
+        String result = three.replaceFirst("date", String.valueOf(new Date())).replaceFirst("jumpUrl",jumpUrl).replaceFirst("jumpUrl",jumpUrl);
+        prime = prime + result;
+        //写html结尾内容
+        String end = "</tbody></table></div></body></html>";
+        //拼接html
+        String html = start + prime + end;
+        mailService.sendHtmlMail(email, "CPMS:裂解炉炉管测温COIL数值异常", html);
+    }
+}

+ 154 - 0
master/src/main/java/com/ruoyi/framework/task/FurnanceTask.java

@@ -1,14 +1,34 @@
 package com.ruoyi.framework.task;
 
+import com.github.stuxuhai.jpinyin.PinyinException;
+import com.ruoyi.common.sendEmail.IMailService;
+import com.ruoyi.common.thread.furnance.FurnancePressureThread;
+import com.ruoyi.common.thread.furnance.FurnanceTemperatureThread;
+import com.ruoyi.common.thread.sai.SaiApplyDueMailThread;
+import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.framework.web.controller.BaseController;
+import com.ruoyi.framework.web.domain.AjaxResult;
+import com.ruoyi.project.plant.domain.TStaffmgr;
+import com.ruoyi.project.plant.service.ITStaffmgrService;
+import com.ruoyi.project.production.controller.TFurnancePressureController;
+import com.ruoyi.project.production.controller.TFurnanceTemperatureController;
+import com.ruoyi.project.production.controller.vo.FurnancePressureFvpVO;
+import com.ruoyi.project.production.controller.vo.FurnanceTemperatureVO;
 import com.ruoyi.project.production.domain.TFurnancePressure;
 import com.ruoyi.project.production.domain.TFurnanceTemperature;
 import com.ruoyi.project.production.service.ITFurnancePressureService;
 import com.ruoyi.project.production.service.ITFurnanceTemperatureService;
+import com.ruoyi.project.system.domain.SysDictData;
+import com.ruoyi.project.system.domain.SysUser;
+import com.ruoyi.project.system.service.ISysDictTypeService;
+import com.ruoyi.project.system.service.ISysUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.List;
 
 /**
  * 定时任务 - 裂解炉管测温测压
@@ -26,6 +46,24 @@ public class FurnanceTask extends BaseController {
     @Autowired
     private ITFurnanceTemperatureService temperatureService;
 
+    @Autowired
+    private TFurnancePressureController pressureController;
+
+    @Autowired
+    private TFurnanceTemperatureController temperatureController;
+
+    @Autowired
+    private ISysDictTypeService iSysDictTypeService;
+
+    @Autowired
+    private IMailService mailService;
+
+    @Autowired
+    private ITStaffmgrService staffmgrService;
+
+    @Autowired
+    private ISysUserService userService;
+
     /**
      * 每日巡检数据生成
      */
@@ -65,4 +103,120 @@ public class FurnanceTask extends BaseController {
         }
     }
 
+    /**
+     * FVP邮件提醒
+     */
+    public void alertFvp() throws ParseException, PinyinException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Date date = new Date();
+        date.setHours(0);
+        date.setMinutes(0);
+        date.setSeconds(0);
+        Date parse = sdf.parse(sdf.format(date));
+        TFurnancePressure pressure = new TFurnancePressure();
+        pressure.setRecordTime(parse);
+        AjaxResult fvp = pressureController.fvp(pressure);
+        Object obj = fvp.get("data");
+        if (obj != null) {
+            List<FurnancePressureFvpVO> data = (List<FurnancePressureFvpVO>) obj;
+            boolean flag = false;
+            for (FurnancePressureFvpVO datum : data) {
+                double pass1Ratio = datum.getPass1Ratio();
+                double pass2Ratio = datum.getPass2Ratio();
+                double pass3Ratio = datum.getPass3Ratio();
+                double pass4Ratio = datum.getPass4Ratio();
+                double pass5Ratio = datum.getPass5Ratio();
+                double pass6Ratio = datum.getPass6Ratio();
+                double pass7Ratio = datum.getPass7Ratio();
+                double pass8Ratio = datum.getPass8Ratio();
+                double allPassMaxRatio = datum.getAllPassMaxRatio();
+                if (Double.compare(pass1Ratio, 0.9) >= 0 || Double.compare(pass2Ratio, 0.9) >= 0
+                        || Double.compare(pass3Ratio, 0.9) >= 0 || Double.compare(pass4Ratio, 0.9) >= 0
+                        || Double.compare(pass5Ratio, 0.9) >= 0 || Double.compare(pass6Ratio, 0.9) >= 0
+                        || Double.compare(pass7Ratio, 0.9) >= 0 || Double.compare(pass8Ratio, 0.9) >= 0
+                        || Double.compare(allPassMaxRatio, 0.9) >= 0) {
+                    flag = true;
+                }
+            }
+            if (flag) {
+                List<SysDictData> furnanceRecipientDict = iSysDictTypeService.selectDictDataByType("FURNANCE_RECIPIENT");
+                for (SysDictData sysDictData : furnanceRecipientDict) {
+                    String dictValue = sysDictData.getDictValue();
+                    TStaffmgr staffmgr = staffmgrService.selectTStaffmgrByStaffId(dictValue);
+                    SysUser sysUser = userService.selectUserByStaffId(dictValue);
+                    FurnancePressureThread mailThread = new FurnancePressureThread(mailService, staffmgr, sysUser.getUserName());
+                    Thread thread = new Thread(mailThread);
+                    thread.start();
+                }
+            }
+        }
+    }
+
+    /**
+     * COIL邮件提醒
+     */
+    public void alertCoil() throws ParseException, PinyinException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Date date = new Date();
+        date.setDate(1);
+        Date parse = sdf.parse(sdf.format(date));
+        TFurnanceTemperature temperature = new TFurnanceTemperature();
+        temperature.setRecordTime(parse);
+        AjaxResult coil = temperatureController.coil(temperature);
+        Object obj = coil.get("data");
+        if (obj != null) {
+            List<FurnanceTemperatureVO> data = (List<FurnanceTemperatureVO>) obj;
+            boolean flag = false;
+            for (FurnanceTemperatureVO datum : data) {
+                String h109Out = datum.getH109Out();
+                String h110Out = datum.getH110Out();
+                String h111Out = datum.getH111Out();
+                String h112Out = datum.getH112Out();
+                String h113Out = datum.getH113Out();
+                String h114Out = datum.getH114Out();
+                String h115Out = datum.getH115Out();
+                String h116Out = datum.getH116Out();
+                String h117Out = datum.getH117Out();
+                String h118Out = datum.getH118Out();
+                String h130Out = datum.getH130Out();
+                if (this.compare1080(h109Out)) { flag = true; }
+                if (this.compare1080(h110Out)) { flag = true; }
+                if (this.compare1080(h111Out)) { flag = true; }
+                if (this.compare1080(h112Out)) { flag = true; }
+                if (this.compare1080(h113Out)) { flag = true; }
+                if (this.compare1080(h114Out)) { flag = true; }
+                if (this.compare1080(h115Out)) { flag = true; }
+                if (this.compare1080(h116Out)) { flag = true; }
+                if (this.compare1080(h117Out)) { flag = true; }
+                if (this.compare1080(h118Out)) { flag = true; }
+                if (this.compare1080(h130Out)) { flag = true; }
+            }
+            if (flag) {
+                List<SysDictData> furnanceRecipientDict = iSysDictTypeService.selectDictDataByType("FURNANCE_RECIPIENT");
+                for (SysDictData sysDictData : furnanceRecipientDict) {
+                    String dictValue = sysDictData.getDictValue();
+                    TStaffmgr staffmgr = staffmgrService.selectTStaffmgrByStaffId(dictValue);
+                    SysUser sysUser = userService.selectUserByStaffId(dictValue);
+                    FurnanceTemperatureThread mailThread = new FurnanceTemperatureThread(mailService, staffmgr, sysUser.getUserName());
+                    Thread thread = new Thread(mailThread);
+                    thread.start();
+                }
+            }
+        }
+    }
+
+    private boolean compare1080(String string) {
+        boolean flag = false;
+        if (StringUtils.isNotNull(string) && StringUtils.isNotEmpty(string)) {
+            String[] split = string.split(",");
+            for (int i = 0; i < split.length; i++) {
+                int element = Integer.parseInt(split[i]);
+                if (element > 1080) {
+                    flag = true;
+                }
+            }
+        }
+        return flag;
+    }
+
 }

+ 0 - 2
master/src/main/java/com/ruoyi/project/production/mapper/TFurnanceTemperatureMapper.java

@@ -1,7 +1,6 @@
 package com.ruoyi.project.production.mapper;
 
 import java.util.List;
-import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
 import com.ruoyi.project.production.domain.TFurnanceTemperature;
 
 /**
@@ -26,7 +25,6 @@ public interface TFurnanceTemperatureMapper
      * @param tFurnanceTemperature 裂解炉炉管测温
      * @return 裂解炉炉管测温集合
      */
-    @DataScope(deptAlias = "d")
     public List<TFurnanceTemperature> selectTFurnanceTemperatureList(TFurnanceTemperature tFurnanceTemperature);
 
     /**

+ 1 - 2
master/src/main/resources/mybatis/production/TFurnanceTemperatureMapper.xml

@@ -44,8 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <where>  
             <if test="furnanceName != null  and furnanceName != ''"> and furnance_name = #{furnanceName}</if>
             <if test="recordTime != null ">
-                and extract (year from record_time) = extract (year from #{recordTime})
-                and extract (month from record_time) = extract (month from #{recordTime})
+                and trunc(record_time, 'MM') = #{recordTime}
             </if>
             <if test="pass1 != null  and pass1 != ''"> and pass1 = #{pass1}</if>
             <if test="pass2 != null  and pass2 != ''"> and pass2 = #{pass2}</if>