فهرست منبع

优化后台计算算法

shilin 1 سال پیش
والد
کامیت
5c20fd7f60

+ 2 - 1
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/HealthmodelMain.java

@@ -14,7 +14,7 @@ public class HealthmodelMain {
         SpringApplication.run(HealthmodelMain.class, args);
 
 
-        System.out.println("开始");
+//        System.out.println("开始");
 //        SaticScheduleTask saticScheduleTask= SpringUtils.getBean("saticScheduleTask");
 //        saticScheduleTask.configureTasks1();
 //        saticScheduleTask.configureTasks2();
@@ -24,5 +24,6 @@ public class HealthmodelMain {
 //        saticScheduleTask.configureTasks7();
 //
 //        System.out.println("结束");
+        System.out.println("完成");
     }
 }

+ 67 - 67
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/config/XxlJobConfig.java

@@ -1,67 +1,67 @@
-//package com.gyee.healthmodel.config;
-//
-//import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
-//import org.slf4j.Logger;
-//import org.slf4j.LoggerFactory;
-//import org.springframework.context.EnvironmentAware;
-//import org.springframework.context.annotation.Bean;
-//import org.springframework.context.annotation.Configuration;
-//import org.springframework.context.annotation.PropertySource;
-//import org.springframework.core.env.Environment;
-//
-///**
-// * xxl-job config
-// *
-// * @author xuxueli 2017-04-28
-// */
-//
-//
-//    @Configuration
-//    @PropertySource("classpath:xxl-job-executor.properties")
-//    public class XxlJobConfig implements EnvironmentAware {
-//        private Environment env;
-//
-//        @Override
-//        public void setEnvironment(Environment environment) {
-//            this.env=environment;
-//        }
-//
-//    private Logger logger = LoggerFactory.getLogger(XxlJobConfig.class);
-//
-//
-//
-//    @Bean
-//    public XxlJobSpringExecutor xxlJobExecutor() {
-//        logger.info(">>>>>>>>>>> xxl-job config init.");
-//        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
-//        xxlJobSpringExecutor.setAdminAddresses(env.getProperty("xxl.job.admin.addresses"));
-//        xxlJobSpringExecutor.setAppname(env.getProperty("xxl.job.executor.appname"));
-//        xxlJobSpringExecutor.setAddress(env.getProperty("xxl.job.executor.address"));
-//        xxlJobSpringExecutor.setIp(env.getProperty("xxl.job.executor.ip"));
-//        xxlJobSpringExecutor.setPort(Integer.parseInt(env.getProperty("xxl.job.executor.port")));
-//        xxlJobSpringExecutor.setAccessToken(env.getProperty("xxl.job.accessToken"));
-//        xxlJobSpringExecutor.setLogPath(env.getProperty("xxl.job.executor.logpath"));
-//        xxlJobSpringExecutor.setLogRetentionDays(Integer.parseInt(env.getProperty("xxl.job.executor.logretentiondays")));
-//
-//        return xxlJobSpringExecutor;
-//    }
-//
-//    /**
-//     * 针对多网卡、容器内部署等情况,可借助 "spring-cloud-commons" 提供的 "InetUtils" 组件灵活定制注册IP;
-//     *
-//     *      1、引入依赖:
-//     *          <dependency>
-//     *             <groupId>org.springframework.cloud</groupId>
-//     *             <artifactId>spring-cloud-commons</artifactId>
-//     *             <version>${version}</version>
-//     *         </dependency>
-//     *
-//     *      2、配置文件,或者容器启动变量
-//     *          spring.cloud.inetutils.preferred-networks: 'xxx.xxx.xxx.'
-//     *
-//     *      3、获取IP
-//     *          String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
-//     */
-//
-//
-//}
+package com.gyee.healthmodel.config;
+
+import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.EnvironmentAware;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.core.env.Environment;
+
+/**
+ * xxl-job config
+ *
+ * @author xuxueli 2017-04-28
+ */
+
+
+    @Configuration
+    @PropertySource("classpath:xxl-job-executor.properties")
+    public class XxlJobConfig implements EnvironmentAware {
+        private Environment env;
+
+        @Override
+        public void setEnvironment(Environment environment) {
+            this.env=environment;
+        }
+
+    private Logger logger = LoggerFactory.getLogger(XxlJobConfig.class);
+
+
+
+    @Bean
+    public XxlJobSpringExecutor xxlJobExecutor() {
+        logger.info(">>>>>>>>>>> xxl-job config init.");
+        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
+        xxlJobSpringExecutor.setAdminAddresses(env.getProperty("xxl.job.admin.addresses"));
+        xxlJobSpringExecutor.setAppname(env.getProperty("xxl.job.executor.appname"));
+        xxlJobSpringExecutor.setAddress(env.getProperty("xxl.job.executor.address"));
+        xxlJobSpringExecutor.setIp(env.getProperty("xxl.job.executor.ip"));
+        xxlJobSpringExecutor.setPort(Integer.parseInt(env.getProperty("xxl.job.executor.port")));
+        xxlJobSpringExecutor.setAccessToken(env.getProperty("xxl.job.accessToken"));
+        xxlJobSpringExecutor.setLogPath(env.getProperty("xxl.job.executor.logpath"));
+        xxlJobSpringExecutor.setLogRetentionDays(Integer.parseInt(env.getProperty("xxl.job.executor.logretentiondays")));
+
+        return xxlJobSpringExecutor;
+    }
+
+    /**
+     * 针对多网卡、容器内部署等情况,可借助 "spring-cloud-commons" 提供的 "InetUtils" 组件灵活定制注册IP;
+     *
+     *      1、引入依赖:
+     *          <dependency>
+     *             <groupId>org.springframework.cloud</groupId>
+     *             <artifactId>spring-cloud-commons</artifactId>
+     *             <version>${version}</version>
+     *         </dependency>
+     *
+     *      2、配置文件,或者容器启动变量
+     *          spring.cloud.inetutils.preferred-networks: 'xxx.xxx.xxx.'
+     *
+     *      3、获取IP
+     *          String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
+     */
+
+
+}

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1 - 1
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/ProEconRecommenMainMapper.java


+ 2 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/ProEconHealthReportMain.java

@@ -165,5 +165,7 @@ public class ProEconHealthReportMain extends Model {
      */
     private String name;
 
+    private String wpName;
 
+    private String nemCode;
 }

+ 84 - 94
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/HealthJudgeService.java

@@ -144,7 +144,7 @@ public class HealthJudgeService {
 
                 // 出现故障状态,直接降到10分 差
                 if (fjzt ==StatusDetailValue.GZ.getCode() || fjzt ==StatusDetailValue.JX.getCode()) {
-                    score = 10.0;
+                    score = 9.0;
                     statejudgment.append("1-");
                 } else {
                     statejudgment.append("0-");
@@ -152,11 +152,11 @@ public class HealthJudgeService {
 
                 if(clxzt==4 || fdjzt==4 || bjzt==4 || zkzt==4)
                 {
-                    score = setScoreValue(score);
+                    score =  score=setScoreValue(score);
                     statejudgment.append("1-");
                 }else if(clxzt==3 || fdjzt==3 || bjzt==3 || zkzt==3)
                 {
-                    score = setScoreValue(score);
+                    score =  score=setScoreValue(score);
                     statejudgment.append("1-");
                 }else {
                     statejudgment.append("0-");
@@ -168,7 +168,7 @@ public class HealthJudgeService {
                 if (xnmap.containsKey(wt.getId())) {
                     double djpgscore = xnmap.get(wt.getId());
                     if (djpgscore < 60) {
-                        setScoreValue(score);
+                         score=setScoreValue(score);
                         statejudgment.append("1-");
                     }else {
                         statejudgment.append("0-");
@@ -192,7 +192,7 @@ public class HealthJudgeService {
                     double xfqrqc =xfpdmap.get(wt.getId());
                     //小风曲线偏差
                     if (xfqrqc > 5) {
-                        setScoreValue(score);
+                         score=setScoreValue(score);
                         statejudgment.append("1-");
                     } else {
                         statejudgment.append("0-");
@@ -211,7 +211,7 @@ public class HealthJudgeService {
                     double zcclqc =clpdmap.get(wt.getId());
                     //正常出力曲线偏差
                     if (zcclqc > 5) {
-                        setScoreValue(score);
+                         score=setScoreValue(score);
                         statejudgment.append("1-");
                     } else {
                         statejudgment.append("0-");
@@ -230,7 +230,7 @@ public class HealthJudgeService {
                     double dfqrqc =dfpdmap.get(wt.getId());
                     //大风曲线偏差
                     if (dfqrqc > 5) {
-                        setScoreValue(score);
+                         score=setScoreValue(score);
                         statejudgment.append("1-");
                     } else {
                         statejudgment.append("0-");
@@ -240,6 +240,7 @@ public class HealthJudgeService {
                 }
 
 
+
                 po.setStateJudgment(String.valueOf(statejudgment.substring(0, statejudgment.length() - 1)));
 
                 pols.add(po);
@@ -264,12 +265,16 @@ public class HealthJudgeService {
     }
 
     private double setScoreValue(double score) {
-        if (score >= 60) {
-            score = score - 20.0;
+        if (score >= 90) {
+            score = score - 12.0;
+        } else if (score < 90 && score >= 60) {
+            score = score -9;
         } else if (score < 60 && score >= 30) {
-            score = score -10;
+            score = score -6;
+        } else if (score < 30 && score >= 10) {
+            score = score -3;
         } else {
-            score = 10.0;
+            score = 9.0;
         }
         return score;
     }
@@ -400,106 +405,91 @@ public class HealthJudgeService {
 
         }
         if (polist != null && polist.size() > 0) {
-            for (ProEconHealthSystem hs : hsls) {
-                List<ProEconStateJudgmentDay> rlist = new ArrayList<>();
-                for (ProEconStateJudgmentDay po : polist) {
-                    if (hs.getModelId().equals(CacheContext.wtmap.get(po.getWtId()).getModelId()) && hs.getWpId().equals(po.getWpId())) {
-                        rlist.add(po);
-
+            Collections.sort(polist, new Comparator<ProEconStateJudgmentDay>() {
+                @Override
+                public int compare(ProEconStateJudgmentDay o1, ProEconStateJudgmentDay o2) {
+                    // 从小到大
+                    return o1.getScore().compareTo(o2.getScore());
 
-                    }
                 }
-                if (rlist != null && rlist.size() > 0) {
-                    Collections.sort(rlist, new Comparator<ProEconStateJudgmentDay>() {
-                        @Override
-                        public int compare(ProEconStateJudgmentDay o1, ProEconStateJudgmentDay o2) {
-                            // 从小到大
-                            return o1.getScore().compareTo(o2.getScore());
 
-                        }
-
-                    });
+            });
 
-                    for (int i = 0; i < rlist.size(); i++) {
-                        ProEconStateJudgmentDay po = rlist.get(i);
-                        Boolean isHave = false;
+            for (int i = 0; i < polist.size(); i++) {
+                ProEconStateJudgmentDay po = polist.get(i);
+                Boolean isHave = false;
 
 //						Boolean isHave = wobugeqsService
 //								.isQueryThreeDayWobugeqs(po.getWtId());
-                        List<String> parts = relevancePartTopThree(CacheContext.wtmap.get(po.getWtId()));
-                        int size = parts.size();
-                        if (size > 0) {
-                            if (size == 3) {
-                                if (parts.get(0) != null) {
-                                    po.setTop1(parts.get(0));
-                                } else {
-                                    po.setTop1(null);
-                                }
-                                if (parts.get(1) != null) {
-                                    po.setTop2(parts.get(1));
-                                } else {
-                                    po.setTop2(null);
-                                }
-                                if (parts.get(2) != null) {
-                                    po.setTop3(parts.get(2));
-                                } else {
-                                    po.setTop3(null);
-                                }
-                            } else if (size == 2) {
-                                if (parts.get(0) != null) {
-                                    po.setTop1(parts.get(0));
-                                } else {
-                                    po.setTop1(null);
-                                }
-                                if (parts.get(1) != null) {
-                                    po.setTop2(parts.get(1));
-                                } else {
-                                    po.setTop2(null);
-                                }
-                                po.setTop3(null);
-                            } else if (size == 1) {
-                                if (parts.get(0) != null) {
-                                    po.setTop1(parts.get(0));
-                                } else {
-                                    po.setTop1(null);
-                                }
-                                po.setTop2(null);
-                                po.setTop3(null);
-                            }
+                List<String> parts = relevancePartTopThree(CacheContext.wtmap.get(po.getWtId()));
+                int size = parts.size();
+                if (size > 0) {
+                    if (size == 3) {
+                        if (parts.get(0) != null) {
+                            po.setTop1(parts.get(0));
+                        } else {
+                            po.setTop1(null);
                         }
-                        if (isHave == true) {
-                            po.setJudgmentDescribe("此风机近期有故障记录,故不在推荐范围之内!");
-                        } else if (po.getScore() <= judgescore) {
-
-                            if (maps.containsKey(po.getWpId())) {
-                                int temp = maps.get(po.getWpId()) + 1;
-                                if (temp > 2) {
-                                    po.setJudgmentDescribe("设备健康情况不良,但推荐等级偏低,还需继续观察!");
-                                } else {
-                                    po.setJudgmentDescribe("健康报告达到推荐级别,推荐检修!");
-                                }
-                                maps.put(po.getWpId(), temp);
-                            } else {
-                                po.setJudgmentDescribe("健康报告达到推荐级别,推荐检修!");
-                                maps.put(po.getWpId(), 1);
-                            }
-                            //po.setJudgmentDescribe("健康报告达到推荐级别,推荐检修!");
+                        if (parts.get(1) != null) {
+                            po.setTop2(parts.get(1));
                         } else {
-                            po.setJudgmentDescribe("健康指标未达到推荐级别,不予推荐!");
+                            po.setTop2(null);
                         }
-
-
-                     //  proEconStateJudgmentDayService.save(po);
+                        if (parts.get(2) != null) {
+                            po.setTop3(parts.get(2));
+                        } else {
+                            po.setTop3(null);
+                        }
+                    } else if (size == 2) {
+                        if (parts.get(0) != null) {
+                            po.setTop1(parts.get(0));
+                        } else {
+                            po.setTop1(null);
+                        }
+                        if (parts.get(1) != null) {
+                            po.setTop2(parts.get(1));
+                        } else {
+                            po.setTop2(null);
+                        }
+                        po.setTop3(null);
+                    } else if (size == 1) {
+                        if (parts.get(0) != null) {
+                            po.setTop1(parts.get(0));
+                        } else {
+                            po.setTop1(null);
+                        }
+                        po.setTop2(null);
+                        po.setTop3(null);
                     }
-
-                    proEconStateJudgmentDayService.saveOrUpdateBatch(rlist);
+                }
+                if (isHave == true) {
+                    po.setJudgmentDescribe("此风机近期有故障记录,故不在推荐范围之内!");
+                } else if (po.getScore() <= judgescore) {
+
+                    if (maps.containsKey(po.getWpId())) {
+                        int temp = maps.get(po.getWpId()) + 1;
+                        if (temp > 2) {
+                            po.setJudgmentDescribe("设备健康情况不良,但推荐等级偏低,还需继续观察!");
+                        } else {
+                            po.setJudgmentDescribe("健康报告达到推荐级别,推荐检修!");
+                        }
+                        maps.put(po.getWpId(), temp);
+                    } else {
+                        po.setJudgmentDescribe("健康报告达到推荐级别,推荐检修!");
+                        maps.put(po.getWpId(), 1);
+                    }
+                    //po.setJudgmentDescribe("健康报告达到推荐级别,推荐检修!");
+                } else {
+                    po.setJudgmentDescribe("健康指标未达到推荐级别,不予推荐!");
                 }
 
+
+                //  proEconStateJudgmentDayService.save(po);
             }
 
+            proEconStateJudgmentDayService.saveOrUpdateBatch(polist);
         }
 
-
     }
 
     /**

+ 5 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/HealthReportService.java

@@ -166,6 +166,11 @@ public class HealthReportService {
 
             ProEconHealthReportMain po = totalProEconHealthReportMain(recordDate, eid1map, eid2map, eid4map, eidTopmap, eid1LastMonth1map, eid2LastMonth1map, eid4LastMonth1map, eidTopLastMonth1map, eid1LastMonth2map, eid2LastMonth2map, eid4LastMonth2map, eidTopLastMonth2map, sjmap, whmap, stmap, rlxs, syrlxs, wt);
            po.setId(StringUtils.getUUID());
+           if(CacheContext.wpmap.containsKey(wt.getWindpowerstationId()))
+           {
+               po.setWpName(CacheContext.wpmap.get(wt.getWindpowerstationId()).getName());
+           }
+           po.setNemCode(wt.getNemCode());
             hrmls.add(po);
             Map<String, ProEconHealthReportTarget> hrmap = new LinkedHashMap<>();
             for (String name : namels) {

+ 1 - 2
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/RecommenmainsService.java

@@ -111,7 +111,6 @@ public class RecommenmainsService {
                 rm.setIsmain(0);
 
 
-
                 if (sjmap.containsKey(wt.getId())) {
 
 
@@ -155,7 +154,7 @@ public class RecommenmainsService {
 
             rm.setSpeed(RandomUtil.getRandomForDoubleBounded(1.2,3.2));
             Calendar c = Calendar.getInstance();
-            c.set(Calendar.HOUR_OF_DAY, 11);
+            c.set(Calendar.HOUR_OF_DAY, RandomUtil.getRandomForIntegerBounded(9,16));
             c.set(Calendar.MINUTE, 0);
             c.set(Calendar.SECOND, 0);
 

+ 7 - 9
realtime/healthmodel-server/src/test/java/HealthTest.java

@@ -1,11 +1,9 @@
 import com.gyee.healthmodel.HealthmodelMain;
-import com.gyee.healthmodel.service.HealthReportService;
+import com.gyee.healthmodel.service.HealthJudgeService;
 import com.gyee.healthmodel.util.SpringUtils;
 import lombok.SneakyThrows;
 import org.springframework.boot.SpringApplication;
 
-import java.util.Date;
-
 public class HealthTest {
 
     @SneakyThrows
@@ -15,18 +13,18 @@ public class HealthTest {
 
         System.out.println("调度程序执行开始!........");
 
-//        HealthJudgeService healthJudgeService= SpringUtils.getBean("healthJudgeService");
-//        healthJudgeService.healthJudge();
+        HealthJudgeService healthJudgeService= SpringUtils.getBean("healthJudgeService");
+        healthJudgeService.healthJudge();
 //        healthJudgeService.changeHealthModelValue();
 //       RecommenmainsService recommenmainsService= SpringUtils.getBean("recommenmainsService");
 //        Calendar cal = Calendar.getInstance();
-////        recommenmainsService.deleteList(cal.getTime());
+//        recommenmainsService.deleteList(cal.getTime());
 ////        recommenmainsService.recommenMainWt();
 //        healthJudgeService.saveWindturbineBjCount();
 // healthJudgeService.savePartbjcount();
-
-        HealthReportService healthReportService= SpringUtils.getBean("healthReportService");
-        healthReportService.createHealthReport(new Date());
+//
+//        HealthReportService healthReportService= SpringUtils.getBean("healthReportService");
+//        healthReportService.createHealthReport(new Date());
          System.out.println("调度任务处理完成!........");