Просмотр исходного кода

出生总磷的真实值 也要从化验库获取,不再从工业库获取

wangmiaomiao 9 месяцев назад
Родитель
Сommit
39e613075f

+ 86 - 38
slibra-quartz/src/main/java/com/slibra/quartz/task/AsyncTask.java

@@ -132,13 +132,14 @@ public class AsyncTask {
                         tXinyiForecastComparison.setYyErrorRateOne((csTn.subtract(yyForecastOne)).divide(csTn, NUMBER_SCALE_4, RoundingMode.HALF_UP));
                     }
                 }
-                if("出水总磷".equals(tXinyiForecastComparison.getCategory())){
+                //2024年6月20日11:16:55 出水总磷的真实值从化验室获取
+                /*if("出水总磷".equals(tXinyiForecastComparison.getCategory())){
                     tXinyiForecastComparison.setRealOne(csTp);
                     if(!Objects.isNull(csTp) && csTp.compareTo(BigDecimal.ZERO) > 0){
                         tXinyiForecastComparison.setHsErrorRateOne((csTp.subtract(hsForecastOne)).divide(csTp, NUMBER_SCALE_4, RoundingMode.HALF_UP));
                         tXinyiForecastComparison.setYyErrorRateOne((csTp.subtract(yyForecastOne)).divide(csTp, NUMBER_SCALE_4, RoundingMode.HALF_UP));
                     }
-                }
+                }*/
                 if("出水氨氮".equals(tXinyiForecastComparison.getCategory())){
                     tXinyiForecastComparison.setRealOne(csNh3);
                     if(!Objects.isNull(csNh3) && csNh3.compareTo(BigDecimal.ZERO) > 0){
@@ -176,13 +177,14 @@ public class AsyncTask {
                         tXinyiForecastComparison.setYyErrorRateTwo((csTn.subtract(yyForecastTwo)).divide(csTn, NUMBER_SCALE_4, RoundingMode.HALF_UP));
                     }
                 }
-                if("出水总磷".equals(tXinyiForecastComparison.getCategory())){
+                //2024年6月20日11:16:55 出水总磷的真实值从化验室获取
+                /*if("出水总磷".equals(tXinyiForecastComparison.getCategory())){
                     tXinyiForecastComparison.setRealTwo(csTp);
                     if(!Objects.isNull(csTp) && csTp.compareTo(BigDecimal.ZERO) > 0){
                         tXinyiForecastComparison.setHsErrorRateTwo((csTp.subtract(hsForecastTwo)).divide(csTp, NUMBER_SCALE_4, RoundingMode.HALF_UP));
                         tXinyiForecastComparison.setYyErrorRateTwo((csTp.subtract(yyForecastTwo)).divide(csTp, NUMBER_SCALE_4, RoundingMode.HALF_UP));
                     }
-                }
+                }*/
                 if("出水氨氮".equals(tXinyiForecastComparison.getCategory())){
                     tXinyiForecastComparison.setRealTwo(csNh3);
                     if(!Objects.isNull(csNh3) && csNh3.compareTo(BigDecimal.ZERO) > 0){
@@ -220,13 +222,14 @@ public class AsyncTask {
                         tXinyiForecastComparison.setYyErrorRateThree((csTn.subtract(yyForecastThree)).divide(csTn, NUMBER_SCALE_4, RoundingMode.HALF_UP));
                     }
                 }
-                if("出水总磷".equals(tXinyiForecastComparison.getCategory())){
+                //2024年6月20日11:16:55 出水总磷的真实值从化验室获取
+                /*if("出水总磷".equals(tXinyiForecastComparison.getCategory())){
                     tXinyiForecastComparison.setRealThree(csTp);
                     if(!Objects.isNull(csTp) && csTp.compareTo(BigDecimal.ZERO) > 0){
                         tXinyiForecastComparison.setHsErrorRateThree((csTp.subtract(hsForecastThree)).divide(csTp, NUMBER_SCALE_4, RoundingMode.HALF_UP));
                         tXinyiForecastComparison.setYyErrorRateThree((csTp.subtract(yyForecastThree)).divide(csTp, NUMBER_SCALE_4, RoundingMode.HALF_UP));
                     }
-                }
+                }*/
                 if("出水氨氮".equals(tXinyiForecastComparison.getCategory())){
                     tXinyiForecastComparison.setRealThree(csNh3);
                     if(!Objects.isNull(csNh3) && csNh3.compareTo(BigDecimal.ZERO) > 0){
@@ -244,11 +247,17 @@ public class AsyncTask {
      * 额外计算一下预测的准确度
      * @param tXinyiRobot
      */
-    private void updateForecastComparisonByRobot(TXinyiRobot tXinyiRobot) {
+    public void updateForecastComparisonByRobot(TXinyiRobot tXinyiRobot) {
         BigDecimal no3Hlj1Jqr = tXinyiRobot.getNo3Hlj1Jqr();
         BigDecimal no3Hlj2Jqr = tXinyiRobot.getNo3Hlj2Jqr();
         String testHour = tXinyiRobot.getTestHour();
 
+        BigDecimal tpRccJqr = tXinyiRobot.getTpRccJqr();
+        BigDecimal csTp = null;
+        if(!Objects.isNull(tpRccJqr)){
+            csTp = tpRccJqr.divide(ROBOT_HY_DIVIDE, NUMBER_SCALE_4, RoundingMode.HALF_UP);
+        }
+
         //时间段1
         List<TXinyiForecastComparison> tXinyiForecastComparisons1 = this.xinyiForecastComparisonMapper.selectTXinyiForecastComparisonList(TXinyiForecastComparison.builder().forecastTimeOne(testHour).build());
         if(!CollectionUtils.isEmpty(tXinyiForecastComparisons1)){
@@ -258,15 +267,29 @@ public class AsyncTask {
                 if("xsy1".equals(tXinyiForecastComparison.getCategory())){
                     tXinyiForecastComparison.setRealOne(no3Hlj1Jqr);
                     if(!Objects.isNull(no3Hlj1Jqr) && no3Hlj1Jqr.compareTo(BigDecimal.ZERO) > 0){
-                        tXinyiForecastComparison.setHsErrorRateOne((no3Hlj1Jqr.subtract(hsForecastOne)).divide(no3Hlj1Jqr, NUMBER_SCALE_4, RoundingMode.HALF_UP));
-                        tXinyiForecastComparison.setYyErrorRateOne((no3Hlj1Jqr.subtract(yyForecastOne)).divide(no3Hlj1Jqr, NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                        if(!Objects.isNull(hsForecastOne))
+                            tXinyiForecastComparison.setHsErrorRateOne((no3Hlj1Jqr.subtract(hsForecastOne)).divide(no3Hlj1Jqr, NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                        if(!Objects.isNull(yyForecastOne))
+                            tXinyiForecastComparison.setYyErrorRateOne((no3Hlj1Jqr.subtract(yyForecastOne)).divide(no3Hlj1Jqr, NUMBER_SCALE_4, RoundingMode.HALF_UP));
                     }
                 }
                 if("xsy2".equals(tXinyiForecastComparison.getCategory())){
                     tXinyiForecastComparison.setRealOne(no3Hlj2Jqr);
                     if(!Objects.isNull(no3Hlj2Jqr) && no3Hlj2Jqr.compareTo(BigDecimal.ZERO) > 0){
-                        tXinyiForecastComparison.setHsErrorRateOne((no3Hlj2Jqr.subtract(hsForecastOne)).divide(no3Hlj2Jqr, NUMBER_SCALE_4, RoundingMode.HALF_UP));
-                        tXinyiForecastComparison.setYyErrorRateOne((no3Hlj2Jqr.subtract(yyForecastOne)).divide(no3Hlj2Jqr, NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                        if(!Objects.isNull(hsForecastOne))
+                            tXinyiForecastComparison.setHsErrorRateOne((no3Hlj2Jqr.subtract(hsForecastOne)).divide(no3Hlj2Jqr, NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                        if(!Objects.isNull(yyForecastOne))
+                            tXinyiForecastComparison.setYyErrorRateOne((no3Hlj2Jqr.subtract(yyForecastOne)).divide(no3Hlj2Jqr, NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                    }
+                }
+                //2024年6月20日11:14:42  总磷的真实值也从化验室获取
+                if("出水总磷".equals(tXinyiForecastComparison.getCategory())){
+                    tXinyiForecastComparison.setRealOne(csTp);
+                    if(!Objects.isNull(csTp) && csTp.compareTo(BigDecimal.ZERO) > 0){
+                        if(!Objects.isNull(hsForecastOne))
+                            tXinyiForecastComparison.setHsErrorRateOne((csTp.subtract(hsForecastOne)).divide(csTp, NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                        if(!Objects.isNull(yyForecastOne))
+                            tXinyiForecastComparison.setYyErrorRateOne((csTp.subtract(yyForecastOne)).divide(csTp, NUMBER_SCALE_4, RoundingMode.HALF_UP));
                     }
                 }
                 this.xinyiForecastComparisonMapper.updateTXinyiForecastComparison(tXinyiForecastComparison);
@@ -281,15 +304,29 @@ public class AsyncTask {
                 if("xsy1".equals(tXinyiForecastComparison.getCategory())){
                     tXinyiForecastComparison.setRealTwo(no3Hlj1Jqr);
                     if(!Objects.isNull(no3Hlj1Jqr) && no3Hlj1Jqr.compareTo(BigDecimal.ZERO) > 0){
-                        tXinyiForecastComparison.setHsErrorRateTwo((no3Hlj1Jqr.subtract(hsForecastTwo)).divide(no3Hlj1Jqr, NUMBER_SCALE_4, RoundingMode.HALF_UP));
-                        tXinyiForecastComparison.setYyErrorRateTwo((no3Hlj1Jqr.subtract(yyForecastTwo)).divide(no3Hlj1Jqr, NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                        if(!Objects.isNull(hsForecastTwo))
+                            tXinyiForecastComparison.setHsErrorRateTwo((no3Hlj1Jqr.subtract(hsForecastTwo)).divide(no3Hlj1Jqr, NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                        if(!Objects.isNull(yyForecastTwo))
+                            tXinyiForecastComparison.setYyErrorRateTwo((no3Hlj1Jqr.subtract(yyForecastTwo)).divide(no3Hlj1Jqr, NUMBER_SCALE_4, RoundingMode.HALF_UP));
                     }
                 }
                 if("xsy2".equals(tXinyiForecastComparison.getCategory())){
                     tXinyiForecastComparison.setRealTwo(no3Hlj2Jqr);
                     if(!Objects.isNull(no3Hlj2Jqr) && no3Hlj2Jqr.compareTo(BigDecimal.ZERO) > 0){
-                        tXinyiForecastComparison.setHsErrorRateTwo((no3Hlj2Jqr.subtract(hsForecastTwo)).divide(no3Hlj2Jqr, NUMBER_SCALE_4, RoundingMode.HALF_UP));
-                        tXinyiForecastComparison.setYyErrorRateTwo((no3Hlj2Jqr.subtract(yyForecastTwo)).divide(no3Hlj2Jqr, NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                        if(!Objects.isNull(hsForecastTwo))
+                            tXinyiForecastComparison.setHsErrorRateTwo((no3Hlj2Jqr.subtract(hsForecastTwo)).divide(no3Hlj2Jqr, NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                        if(!Objects.isNull(yyForecastTwo))
+                            tXinyiForecastComparison.setYyErrorRateTwo((no3Hlj2Jqr.subtract(yyForecastTwo)).divide(no3Hlj2Jqr, NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                    }
+                }
+                //2024年6月20日11:14:42  总磷的真实值也从化验室获取
+                if("出水总磷".equals(tXinyiForecastComparison.getCategory())){
+                    tXinyiForecastComparison.setRealTwo(csTp);
+                    if(!Objects.isNull(csTp) && csTp.compareTo(BigDecimal.ZERO) > 0){
+                        if(!Objects.isNull(hsForecastTwo))
+                            tXinyiForecastComparison.setHsErrorRateTwo((csTp.subtract(hsForecastTwo)).divide(csTp, NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                        if(!Objects.isNull(yyForecastTwo))
+                            tXinyiForecastComparison.setYyErrorRateTwo((csTp.subtract(yyForecastTwo)).divide(csTp, NUMBER_SCALE_4, RoundingMode.HALF_UP));
                     }
                 }
                 this.xinyiForecastComparisonMapper.updateTXinyiForecastComparison(tXinyiForecastComparison);
@@ -304,15 +341,29 @@ public class AsyncTask {
                 if("xsy1".equals(tXinyiForecastComparison.getCategory())){
                     tXinyiForecastComparison.setRealThree(no3Hlj1Jqr);
                     if(!Objects.isNull(no3Hlj1Jqr) && no3Hlj1Jqr.compareTo(BigDecimal.ZERO) > 0){
-                        tXinyiForecastComparison.setHsErrorRateThree((no3Hlj1Jqr.subtract(hsForecastThree)).divide(no3Hlj1Jqr, NUMBER_SCALE_4, RoundingMode.HALF_UP));
-                        tXinyiForecastComparison.setYyErrorRateThree((no3Hlj1Jqr.subtract(yyForecastThree)).divide(no3Hlj1Jqr, NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                        if(!Objects.isNull(hsForecastThree))
+                            tXinyiForecastComparison.setHsErrorRateThree((no3Hlj1Jqr.subtract(hsForecastThree)).divide(no3Hlj1Jqr, NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                        if(!Objects.isNull(yyForecastThree))
+                            tXinyiForecastComparison.setYyErrorRateThree((no3Hlj1Jqr.subtract(yyForecastThree)).divide(no3Hlj1Jqr, NUMBER_SCALE_4, RoundingMode.HALF_UP));
                     }
                 }
                 if("xsy2".equals(tXinyiForecastComparison.getCategory())){
                     tXinyiForecastComparison.setRealThree(no3Hlj2Jqr);
                     if(!Objects.isNull(no3Hlj2Jqr) && no3Hlj2Jqr.compareTo(BigDecimal.ZERO) > 0){
-                        tXinyiForecastComparison.setHsErrorRateThree((no3Hlj2Jqr.subtract(hsForecastThree)).divide(no3Hlj2Jqr, NUMBER_SCALE_4, RoundingMode.HALF_UP));
-                        tXinyiForecastComparison.setYyErrorRateThree((no3Hlj2Jqr.subtract(yyForecastThree)).divide(no3Hlj2Jqr, NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                        if(!Objects.isNull(hsForecastThree))
+                            tXinyiForecastComparison.setHsErrorRateThree((no3Hlj2Jqr.subtract(hsForecastThree)).divide(no3Hlj2Jqr, NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                        if(!Objects.isNull(yyForecastThree))
+                            tXinyiForecastComparison.setYyErrorRateThree((no3Hlj2Jqr.subtract(yyForecastThree)).divide(no3Hlj2Jqr, NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                    }
+                }
+                //2024年6月20日11:14:42  总磷的真实值也从化验室获取
+                if("出水总磷".equals(tXinyiForecastComparison.getCategory())){
+                    tXinyiForecastComparison.setRealThree(csTp);
+                    if(!Objects.isNull(csTp) && csTp.compareTo(BigDecimal.ZERO) > 0){
+                        if(!Objects.isNull(hsForecastThree))
+                            tXinyiForecastComparison.setHsErrorRateThree((csTp.subtract(hsForecastThree)).divide(csTp, NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                        if(!Objects.isNull(yyForecastThree))
+                            tXinyiForecastComparison.setYyErrorRateThree((csTp.subtract(yyForecastThree)).divide(csTp, NUMBER_SCALE_4, RoundingMode.HALF_UP));
                     }
                 }
                 this.xinyiForecastComparisonMapper.updateTXinyiForecastComparison(tXinyiForecastComparison);
@@ -775,18 +826,22 @@ public class AsyncTask {
                 //如果是机器人化验室的报警,需要把总磷和总氮,获取化验室对应的数据且计算
                 if(isSpecial){
                     List<TXinyiRobot> xinyiRobots = this.xinyiRobotMapper.selectTXinyiRobotList(TXinyiRobot.builder().testHour(tXinyiIndustry.getTestHour()).build());
-                    TXinyiRobot tXinyiRobot = xinyiRobots.get(0);
-                    //总氮
-                    BigDecimal no3Hlj1Jqr = tXinyiRobot.getNo3Hlj1Jqr();
-                    BigDecimal no3Hlj2Jqr = tXinyiRobot.getNo3Hlj2Jqr();
-                    if(!Objects.isNull(no3Hlj1Jqr) && !Objects.isNull(no3Hlj2Jqr)){
-                        decisionReq.setTnOff((no3Hlj1Jqr.add(no3Hlj2Jqr)).divide((new BigDecimal("2").multiply(ROBOT_HY_DIVIDE)), NUMBER_SCALE_4, RoundingMode.HALF_UP));
-                    }
+                    if(CollectionUtils.isEmpty(xinyiRobots)){
+                        log.error("{}获取化验室数据失败", tXinyiIndustry.getTestHour());
+                    }else{
+                        TXinyiRobot tXinyiRobot = xinyiRobots.get(0);
+                        //总氮
+                        BigDecimal no3Hlj1Jqr = tXinyiRobot.getNo3Hlj1Jqr();
+                        BigDecimal no3Hlj2Jqr = tXinyiRobot.getNo3Hlj2Jqr();
+                        if(!Objects.isNull(no3Hlj1Jqr) && !Objects.isNull(no3Hlj2Jqr)){
+                            decisionReq.setTnOff((no3Hlj1Jqr.add(no3Hlj2Jqr)).divide((new BigDecimal("2").multiply(ROBOT_HY_DIVIDE)), NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                        }
 
-                    //总磷
-                    BigDecimal tpRccJqr = tXinyiRobot.getTpRccJqr();
-                    if(!Objects.isNull(tpRccJqr)){
-                        decisionReq.setTpOff(tpRccJqr.divide(ROBOT_HY_DIVIDE, NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                        //总磷
+                        BigDecimal tpRccJqr = tXinyiRobot.getTpRccJqr();
+                        if(!Objects.isNull(tpRccJqr)){
+                            decisionReq.setTpOff(tpRccJqr.divide(ROBOT_HY_DIVIDE, NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                        }
                     }
                 }
             }
@@ -1175,6 +1230,7 @@ public class AsyncTask {
     public static void main(String[] args) {
         System.out.println(CCCDCHRT_LAST);
         System.out.println(GSLS_LAST);
+        System.out.println(BigDecimal.valueOf(1).subtract(null));
     }
 
     /**
@@ -1195,14 +1251,6 @@ public class AsyncTask {
 
         //处理数据
         for (TXinyiRobot tXinyiRobot : uniqueList) {
-
-            //2024年6月18日10:45:20 额外计算一下预测的准确度
-            try {
-                this.updateForecastComparisonByRobot(tXinyiRobot);
-            } catch (Exception e) {
-                log.error("~~~~~~~~~~~~~~~~~~~~~~~~~更新预测准确度的时候异常,异常信息为{}", e.getMessage());
-            }
-
             //处理总氮和总磷报警
             //总氮
             BigDecimal no3Hlj1Jqr = tXinyiRobot.getNo3Hlj1Jqr();

+ 4 - 1
slibra-quartz/src/main/java/com/slibra/quartz/task/RyTask.java

@@ -1222,8 +1222,11 @@ public class RyTask
                 //判断是否添加过了(小时)
                 String testHour = tXinyiRobot.getTestHour();
                 List<TXinyiRobot> tXinyiRobotList = this.xinyiRobotMapper.selectTXinyiRobotList(TXinyiRobot.builder().testHour(testHour).build());
-                if(CollectionUtils.isEmpty(tXinyiRobotList))
+                if(CollectionUtils.isEmpty(tXinyiRobotList)){
                     this.xinyiRobotMapper.insertTXinyiRobot(tXinyiRobot);
+                    //2024年6月18日10:45:20 额外计算一下预测的准确度
+                    asyncTask.updateForecastComparisonByRobot(tXinyiRobot);
+                }
                 else
                     log.info("{}已经吧保存过了,无需重复保存***&&&···", testHour);
             }