Jelajahi Sumber

裂解炉炉管测压 - PASS数据提交时检查ratio,<0.45或>0.9时,邮件通知主管和四个班长

wangggziwen 1 tahun lalu
induk
melakukan
57fd80d3cc

+ 5 - 2
master/src/main/java/com/ruoyi/common/thread/furnance/FurnancePressureThread.java

@@ -30,14 +30,17 @@ public class FurnancePressureThread implements Runnable {
 
     private String loginName;
 
+    String msg;
+
     public FurnancePressureThread() {}
 
-    public FurnancePressureThread(IMailService mailService, TStaffmgr staffmgr, String loginName) throws PinyinException {
+    public FurnancePressureThread(IMailService mailService, TStaffmgr staffmgr, String loginName, String msg) 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;
+        this.msg = msg;
     }
 
     @Override
@@ -59,7 +62,7 @@ public class FurnancePressureThread implements Runnable {
                 "<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>" +
+                "<p>裂解炉炉管测压FVP数值异常:"  + msg +  ",请及时查看。<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>" +

+ 76 - 11
master/src/main/java/com/ruoyi/project/production/controller/TFurnancePressureController.java

@@ -9,12 +9,17 @@ import java.util.*;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.github.stuxuhai.jpinyin.PinyinException;
+import com.ruoyi.common.sendEmail.IMailService;
+import com.ruoyi.common.thread.furnance.FurnancePressureThread;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.file.FileUploadUtils;
 import com.ruoyi.framework.config.RuoYiConfig;
 import com.ruoyi.framework.task.FurnanceTask;
 import com.ruoyi.project.common.domain.TCommonfile;
 import com.ruoyi.project.common.service.ITCommonfileService;
+import com.ruoyi.project.plant.domain.TStaffmgr;
+import com.ruoyi.project.plant.service.ITStaffmgrService;
 import com.ruoyi.project.production.controller.vo.FurnancePressureFvpVO;
 import com.ruoyi.project.production.controller.vo.FurnancePressureVO;
 import com.ruoyi.project.production.controller.vo.FurnanceSummaryVO;
@@ -22,6 +27,10 @@ import com.ruoyi.project.production.controller.vo.FvpAnalysisQueryVO;
 import com.ruoyi.project.production.domain.TFurnanceTemperature;
 import com.ruoyi.project.production.mapper.TFurnancePressureMapper;
 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 net.sf.jsqlparser.statement.select.ExceptOp;
 import org.apache.http.HttpEntity;
 import org.apache.http.client.methods.CloseableHttpResponse;
@@ -74,6 +83,18 @@ public class TFurnancePressureController extends BaseController {
     @Autowired
     private RuoYiConfig ruoyiConfig;
 
+    @Autowired
+    private ISysDictTypeService iSysDictTypeService;
+
+    @Autowired
+    private IMailService mailService;
+
+    @Autowired
+    private ITStaffmgrService staffmgrService;
+
+    @Autowired
+    private ISysUserService userService;
+
     /**
      * 删除裂解炉Pass图片(APP)
      */
@@ -3543,7 +3564,7 @@ public class TFurnancePressureController extends BaseController {
     @PreAuthorize("@ss.hasPermi('production:pressure:edit')")
     @Log(title = "裂解炉炉管测压", businessType = BusinessType.UPDATE)
     @PutMapping("/editWeb")
-    public AjaxResult editWeb(@RequestBody TFurnancePressure tFurnancePressure) {
+    public AjaxResult editWeb(@RequestBody TFurnancePressure tFurnancePressure) throws PinyinException {
         // 检查数据是否包含负值或为Null
         if (!this.isNegativeOrNull(tFurnancePressure)) {
             //更新
@@ -3600,12 +3621,23 @@ public class TFurnancePressureController extends BaseController {
                     break;
                 case "H130":
                     FurnancePressureFvpVO furnancePressureFvpVO130 = this.calcRatio130(list);
-                    msg = this.checkRatio(furnancePressureFvpVO130, pressure);
+                    msg = this.checkRatio130(furnancePressureFvpVO130, pressure);
                     break;
             }
             if (!"".equals(msg)) {
                 msg = msg.substring(0, msg.length() - 1);
-                msg += "压差过高,请注意处理。";
+                msg += "压差<0.45或>0.9,请注意处理。";
+                // 发邮件
+                String mailMsg = furnanceName + msg;
+                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(), mailMsg);
+                    Thread thread = new Thread(mailThread);
+                    thread.start();
+                }
             }
             //更新
             int result = tFurnancePressureService.updateTFurnancePressure(pressure);
@@ -3625,49 +3657,49 @@ public class TFurnancePressureController extends BaseController {
         double pass6Ratio = vo.getPass6Ratio();
         double pass7Ratio = vo.getPass7Ratio();
         double pass8Ratio = vo.getPass8Ratio();
-        if (pass1Ratio > 0.9) {
+        if (pass1Ratio > 0.9 || pass1Ratio < 0.45) {
             pressure.setPass1RatioExceeded(true);
             msg += "PASS 1、";
         } else {
             pressure.setPass1RatioExceeded(false);
         }
-        if (pass2Ratio > 0.9) {
+        if (pass2Ratio > 0.9 || pass2Ratio < 0.45) {
             pressure.setPass2RatioExceeded(true);
             msg += "PASS 2、";
         } else {
             pressure.setPass2RatioExceeded(false);
         }
-        if (pass3Ratio > 0.9) {
+        if (pass3Ratio > 0.9 || pass3Ratio < 0.45) {
             msg += "PASS 3、";
             pressure.setPass3RatioExceeded(true);
         } else {
             pressure.setPass3RatioExceeded(false);
         }
-        if (pass4Ratio > 0.9) {
+        if (pass4Ratio > 0.9 || pass4Ratio < 0.45) {
             msg += "PASS 4、";
             pressure.setPass4RatioExceeded(true);
         } else {
             pressure.setPass4RatioExceeded(false);
         }
-        if (pass5Ratio > 0.9) {
+        if (pass5Ratio > 0.9 || pass5Ratio < 0.45) {
             msg += "PASS 5、";
             pressure.setPass5RatioExceeded(true);
         } else {
             pressure.setPass5RatioExceeded(false);
         }
-        if (pass6Ratio > 0.9) {
+        if (pass6Ratio > 0.9 || pass6Ratio < 0.45) {
             msg += "PASS 6、";
             pressure.setPass6RatioExceeded(true);
         } else {
             pressure.setPass6RatioExceeded(false);
         }
-        if (pass7Ratio > 0.9) {
+        if (pass7Ratio > 0.9 || pass7Ratio < 0.45) {
             msg += "PASS 7、";
             pressure.setPass7RatioExceeded(true);
         } else {
             pressure.setPass7RatioExceeded(false);
         }
-        if (pass8Ratio > 0.9) {
+        if (pass8Ratio > 0.9 || pass8Ratio < 0.45) {
             msg += "PASS 8、";
             pressure.setPass8RatioExceeded(true);
         } else {
@@ -3676,6 +3708,39 @@ public class TFurnancePressureController extends BaseController {
         return msg;
     }
 
+    public String checkRatio130(FurnancePressureFvpVO vo, TFurnancePressure pressure) {
+        String msg = "";
+        double pass1Ratio = vo.getPass1Ratio();
+        double pass2Ratio = vo.getPass2Ratio();
+        double pass3Ratio = vo.getPass3Ratio();
+        double pass4Ratio = vo.getPass4Ratio();
+        if (pass1Ratio > 0.9 || pass1Ratio < 0.45) {
+            pressure.setPass1RatioExceeded(true);
+            msg += "PASS 1、";
+        } else {
+            pressure.setPass1RatioExceeded(false);
+        }
+        if (pass2Ratio > 0.9 || pass2Ratio < 0.45) {
+            pressure.setPass2RatioExceeded(true);
+            msg += "PASS 2、";
+        } else {
+            pressure.setPass2RatioExceeded(false);
+        }
+        if (pass3Ratio > 0.9 || pass3Ratio < 0.45) {
+            msg += "PASS 3、";
+            pressure.setPass3RatioExceeded(true);
+        } else {
+            pressure.setPass3RatioExceeded(false);
+        }
+        if (pass4Ratio > 0.9 || pass4Ratio < 0.45) {
+            msg += "PASS 4、";
+            pressure.setPass4RatioExceeded(true);
+        } else {
+            pressure.setPass4RatioExceeded(false);
+        }
+        return msg;
+    }
+
     /**
      * 删除裂解炉炉管测压
      */