فهرست منبع

预测预警 新增逻辑:防止工业库挂掉重复预警

wangmiaomiao 9 ماه پیش
والد
کامیت
03b95a1952
1فایلهای تغییر یافته به همراه16 افزوده شده و 14 حذف شده
  1. 16 14
      slibra-quartz/src/main/java/com/slibra/quartz/task/RyTask.java

+ 16 - 14
slibra-quartz/src/main/java/com/slibra/quartz/task/RyTask.java

@@ -1274,7 +1274,7 @@ public class RyTask
         List<TXinyiIndustry> tXinyiIndustries6 = this.xinyiIndustryMapper.selectNIndustry(6);
         List<TXinyiRobot> tXinyiRobots6 = this.xinyiRobotMapper.selectNRobot(6);
         for (int i = 0; i < predictorArr.length; i++) {
-            String result = testPredictor(predictorArr[i]);
+            String result = getPredictor(predictorArr[i]);
             if(StringUtils.isBlank(result) || "error".equals(result)){
                 log.info("预测数据返回结果不符合解析条件,返回结果为{}", result);
                 continue;
@@ -1316,6 +1316,19 @@ public class RyTask
         //2024年6月20日14:28:31  增加字段,方便查询
         tXinyiForecastComparison.setRemark(DateUtil.format(DateUtils.getNowDate(), DateUtils.YYYYMMDDHH_TS));
 
+        //防止工业库挂掉以后持续预测同一数据
+        //2024年6月20日14:59:23 因为预测bug 判断是否生成过了否则不生成
+        String remark = tXinyiForecastComparison.getRemark();
+        String category = tXinyiForecastComparison.getCategory();
+        TXinyiForecastComparison tXinyiForecastComparisonReq = new TXinyiForecastComparison();
+        tXinyiForecastComparisonReq.setRemark(remark);
+        tXinyiForecastComparisonReq.setCategory(category);
+        List<TXinyiForecastComparison> tXinyiForecastComparisons = this.xinyiForecastComparisonService.selectTXinyiForecastComparisonList(tXinyiForecastComparisonReq);
+        if(!CollectionUtils.isEmpty(tXinyiForecastComparisons)){
+            log.error("预测已经进行过了,无需重复运行~~~~~~~~~~~@@@@@@@,时间为{}\n类型为{}", remark, category);
+            return;
+        }
+
         //获取配置表
         List<TXinyiNormConfig> tXinyiNormConfigs = this.xinyiNormConfigMapper.selectTXinyiNormConfigList(null);
         if(CollectionUtils.isEmpty(tXinyiNormConfigs)) {
@@ -1530,18 +1543,7 @@ public class RyTask
             log.error("暂未支持的类型{}", task);
         }
         //插入到数据库
-        //2024年6月20日14:59:23 因为预测bug 判断是否生成过了否则不生成
-        String remark = tXinyiForecastComparison.getRemark();
-        String category = tXinyiForecastComparison.getCategory();
-        TXinyiForecastComparison tXinyiForecastComparisonReq = new TXinyiForecastComparison();
-        tXinyiForecastComparisonReq.setRemark(remark);
-        tXinyiForecastComparisonReq.setCategory(category);
-        List<TXinyiForecastComparison> tXinyiForecastComparisons = this.xinyiForecastComparisonService.selectTXinyiForecastComparisonList(tXinyiForecastComparisonReq);
-        if(CollectionUtils.isEmpty(tXinyiForecastComparisons))
-            this.xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison);
-        else
-            log.error("预测已经进行过了,无需重复运行~~~~~~~~~~~@@@@@@@,时间为{}\n类型为{}", remark, category);
-
+        this.xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison);
     }
 
     private void handleXinYiWarningsYC(BigDecimal csBzz, String[] split, BigDecimal csGkz, String category, String hour, TXinyiNormConfig normConfig, BigDecimal currentVal, TXinyiIndustry tXinyiIndustry, List<ChartBasic> chartsDataList, String date) {
@@ -1694,7 +1696,7 @@ public class RyTask
     }
 
 
-    public static String testPredictor(String type){
+    public static String getPredictor(String type){
         // 获取输出流
         ManagedChannel channel = null;
         try {