فهرست منبع

自来水/江津预测模块升级 更改预测小时值的预测调用

1037015548@qq.com 2 ماه پیش
والد
کامیت
46a59e2a14

+ 30 - 24
src/main/java/com/shkpr/service/aimodelpower/bizmgr/KprAimWaterCollecationBizFun.java

@@ -1031,36 +1031,42 @@ public class KprAimWaterCollecationBizFun {
             LocalDateTime startDate = LocalDateTime.now().withYear(Integer.valueOf(yearStr))
                     .withMonth(Integer.valueOf(monthStr)).withHour(0).withMinute(0).withSecond(0).withNano(0);
             //TODO 总体逻辑: 先查询指定月上一年的每日平均值,再按平均值的上下啊百分比去插入指定的浮动百分比数据
+            List<Map<String,Object>> orgConfig = getWaterTapWaterApi().getOrgConfig(false,0,0," AND org_name not like '%水厂'");
+            if("water_volume_prediction_jiangjin2".equals(databaseName)){
+                orgConfig = getWaterTapWaterApi().getOrgConfig(false,0,0,"");
+            }
             for (int i = 0;i<=3;i++){
                 LocalDateTime dateNow = startDate.minusDays(-i);//当前循环时间
                  //TODO 数据库操作 A 调用对应时间预测接口 B 在修改实际值
                  DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                  String dateStr = dateNow.withYear(LocalDateTime.now().getYear()).toLocalDate().format(formatter2);
                  //TODO A
-                 JP3TPHour tpHour = new JP3TPHour();
-                 tpHour.setOrgId("");
-                 tpHour.setDate(dateStr);
-                 LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO
-                        , mStrClassName
-                        , mStrClassName
-                        , String.format("执行未来预测小时数据" + FastJsonUtil.toJSON(tpHour) + "调用"));
-                 try {
-                     ResponseRes<String> tpRes = ServiceMgrProxy.getInstance()
-                             .applyCloud3tpServiceApi().dayHourPredictSupply(tpHour);
-                     if(ResponseCode.RESULT_BAD.toStrCode().equals(tpRes.getRescode())){
-                         LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR
-                                 , mStrClassName
-                                 , mStrClassName
-                                 , String.format("预测小时数据"+dateStr+"调用失败 ERROR:{%s} ",
-                                         tpRes.getResdata()));
-                     }
-                 }catch(Exception ex){
-                     LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR
-                             , mStrClassName
-                             , mStrClassName
-                             , String.format("预测小时数据"+dateStr+"调用异常 ERROR:{%s} ",
-                                     ex.getLocalizedMessage()));
-                 }
+                for (Map<String,Object> org : orgConfig) {
+                    JP3TPHour tpHour = new JP3TPHour();
+                    tpHour.setOrgId(org.get("org_id").toString());
+                    tpHour.setDate(dateStr);
+                    LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO
+                            , mStrClassName
+                            , mStrClassName
+                            , String.format("执行未来预测小时数据" + FastJsonUtil.toJSON(tpHour) + "调用"));
+                    try {
+                        ResponseRes<String> tpRes = ServiceMgrProxy.getInstance()
+                                .applyCloud3tpServiceApi().dayHourPredictSupply(tpHour);
+                        if (ResponseCode.RESULT_BAD.toStrCode().equals(tpRes.getRescode())) {
+                            LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR
+                                    , mStrClassName
+                                    , mStrClassName
+                                    , String.format("预测小时数据" + dateStr + "调用失败 ERROR:{%s} ",
+                                            tpRes.getResdata()));
+                        }
+                    } catch (Exception ex) {
+                        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR
+                                , mStrClassName
+                                , mStrClassName
+                                , String.format("预测小时数据" + dateStr + "调用异常 ERROR:{%s} ",
+                                        ex.getLocalizedMessage()));
+                    }
+                }
             }
             System.out.println("调用预测模型小时数据结束"+ TimeTool.convertUTC2DateStr(TimeTool.getCurMsUTC(),TimeTool.TIMESTAMP_FORMAT));
         }catch(Exception ex){

+ 29 - 29
src/main/java/com/shkpr/service/aimodelpower/globalmgr/ScheduleTaskMgr.java

@@ -293,35 +293,35 @@ public class ScheduleTaskMgr {
 //    }
 
     //TODO 自来水的注释以下俩方法initPumpRecordAll checkPumpRecordAll
-    @PostConstruct
-    public void initPumpRecordAll(){
-        new Timer().schedule(new TimerTask() {
-            @Override
-            public void run() {
-                //当前时间到去年对应月份1号0点开始
-                LocalDateTime firstDayOfLastMonth = LocalDateTime.now().minusMonths(1) // 减去一个月
-                        .toLocalDate()   // 转换为 LocalDate
-                        .withDayOfMonth(1) // 设置为当月的第一天
-                        .atStartOfDay(); // 转换为当天的起始时间
-                String formattedDate = firstDayOfLastMonth.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
-                KprAimTapWaterBizFun.initWaterPumpReacordAll(formattedDate);
-            }
-        },5000);
-    }
-
-    //TODO 每小时的10分执行原始小时泵数据计算
-    @Scheduled(cron = "0 10 * * * *")
-    public void checkPumpRecordAll(){
-        new Timer().schedule(new TimerTask() {
-            @Override
-            public void run() {
-                //当前时间到今天的0点开始
-                LocalDateTime firstDayOfLastMonth = LocalDate.now().atStartOfDay();//上个月0点
-                String formattedDate = firstDayOfLastMonth.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
-                KprAimTapWaterBizFun.initWaterPumpReacordAll(formattedDate);
-            }
-        },5000);
-    }
+//    @PostConstruct
+//    public void initPumpRecordAll(){
+//        new Timer().schedule(new TimerTask() {
+//            @Override
+//            public void run() {
+//                //当前时间到去年对应月份1号0点开始
+//                LocalDateTime firstDayOfLastMonth = LocalDateTime.now().minusMonths(1) // 减去一个月
+//                        .toLocalDate()   // 转换为 LocalDate
+//                        .withDayOfMonth(1) // 设置为当月的第一天
+//                        .atStartOfDay(); // 转换为当天的起始时间
+//                String formattedDate = firstDayOfLastMonth.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+//                KprAimTapWaterBizFun.initWaterPumpReacordAll(formattedDate);
+//            }
+//        },5000);
+//    }
+//
+//    //TODO 每小时的10分执行原始小时泵数据计算
+//    @Scheduled(cron = "0 10 * * * *")
+//    public void checkPumpRecordAll(){
+//        new Timer().schedule(new TimerTask() {
+//            @Override
+//            public void run() {
+//                //当前时间到今天的0点开始
+//                LocalDateTime firstDayOfLastMonth = LocalDate.now().atStartOfDay();//上个月0点
+//                String formattedDate = firstDayOfLastMonth.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+//                KprAimTapWaterBizFun.initWaterPumpReacordAll(formattedDate);
+//            }
+//        },5000);
+//    }
 
     @PostConstruct
     public void initDatabaseName(){