Pārlūkot izejas kodu

优化后台计算算法

shilin 1 gadu atpakaļ
vecāks
revīzija
e17fab4a9b
16 mainītis faili ar 807 papildinājumiem un 84 dzēšanām
  1. 13 1
      realtime/healthmodel-server/pom.xml
  2. 67 67
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/config/XxlJobConfig.java
  3. 11 4
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/init/CacheContext.java
  4. 393 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/init/InitialRedis.java
  5. 3 3
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/ProEconRecommenMainMapper.java
  6. 1 1
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/ProEconWtPowerCurveFitting.java
  7. 1 1
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/HealthReportService.java
  8. 1 1
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IProEconRecommenMainService.java
  9. 2 2
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/ProEconRecommenMainServiceImpl.java
  10. 19 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/task/SaticScheduleTask.java
  11. 44 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/util/redis/RedisAutoConfiguration.java
  12. 47 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/util/redis/RedisConfig.java
  13. 51 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/util/redis/RedisService.java
  14. 125 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/util/redis/RedisServiceImpl.java
  15. 21 0
      realtime/healthmodel-server/src/main/resources/application-jn.yml
  16. 8 4
      realtime/healthmodel-server/src/test/java/HealthTest.java

+ 13 - 1
realtime/healthmodel-server/pom.xml

@@ -26,7 +26,19 @@
 
     </properties>
     <dependencies>
-
+        <dependency>
+            <groupId>redis.clients</groupId>
+            <artifactId>jedis</artifactId>
+            <version>3.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.data</groupId>
+            <artifactId>spring-data-redis</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>

+ 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();
+//     */
+//
+//
+//}

+ 11 - 4
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/init/CacheContext.java

@@ -1,6 +1,7 @@
 package com.gyee.healthmodel.init;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.gyee.healthmodel.model.auto.*;
 import com.gyee.healthmodel.service.auto.*;
 import org.slf4j.Logger;
@@ -108,8 +109,9 @@ public class CacheContext implements CommandLineRunner {
  //       wptempls.stream().filter(i->i.getId().equals("FS_FDC")).forEach(i->{
         wptempls.stream().forEach(i->{
 
-            if(i.getId().contains("FDC"))
+            if(i.getId().contains("FDC") && !i.getId().contains("MLJ"))
             {
+
                 wpls.add(i);
                 wpmap.put(i.getId(),i);
             }
@@ -168,7 +170,11 @@ public class CacheContext implements CommandLineRunner {
                 }
             }
         }
-        List<ProBasicEquipmentPoint> WindturbinetestingpointaiList = proBasicEquipmentPointService.list();
+
+        QueryWrapper<ProBasicEquipmentPoint> queryWrapper = new QueryWrapper<>();
+        queryWrapper.like("windpowerstation_id","FDC");
+
+        List<ProBasicEquipmentPoint> WindturbinetestingpointaiList = proBasicEquipmentPointService.list(queryWrapper);
         Map<String, ProBasicEquipmentPoint> map = null;
 
         if(WindturbinetestingpointaiList != null && !WindturbinetestingpointaiList.isEmpty()){
@@ -184,8 +190,9 @@ public class CacheContext implements CommandLineRunner {
             }
         }
 
-
-        List<ProBasicPowerstationPoint> wplist = proBasicPowerstationPointService.list();
+        QueryWrapper<ProBasicPowerstationPoint> queryWrapper2 = new QueryWrapper<>();
+        queryWrapper2.like("windpowerstation_id","FDC");
+        List<ProBasicPowerstationPoint> wplist = proBasicPowerstationPointService.list(queryWrapper2);
         for (ProBasicPowerstationPoint ProBasicPowerstationPoint : wplist) {
             if (wppointmap.containsKey(ProBasicPowerstationPoint.getWindpowerstationId())){
                 wppointmap.get(ProBasicPowerstationPoint.getWindpowerstationId()).put(ProBasicPowerstationPoint.getUniformCode(),ProBasicPowerstationPoint);

+ 393 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/init/InitialRedis.java

@@ -0,0 +1,393 @@
+package com.gyee.healthmodel.init;
+
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.gyee.common.contant.ContantXk;
+import com.gyee.common.model.PointData;
+import com.gyee.healthmodel.model.auto.*;
+import com.gyee.healthmodel.service.auto.IProBasicEquipmentPointService;
+import com.gyee.healthmodel.service.auto.IProBasicPowerstationPointService;
+import com.gyee.healthmodel.service.auto.IProEconWtPowerCurveFittingService;
+import com.gyee.healthmodel.util.DateUtils;
+import com.gyee.healthmodel.util.IRealTimeDataBaseUtil;
+import com.gyee.healthmodel.util.RealTimeDataBaseFactory;
+import com.gyee.healthmodel.util.redis.RedisService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.text.DecimalFormat;
+import java.util.*;
+
+@Service
+public  class InitialRedis {
+    
+    @Resource
+    private IProBasicPowerstationPointService proBasicPowerstationPointService;
+    @Resource
+    private IProBasicEquipmentPointService proBasicEquipmentPointService;
+    @Resource
+    private IProEconWtPowerCurveFittingService proEconWtPowerCurveFittingService;
+    @Resource
+    private RedisService redisService;
+    public static Map<String, Map<Double, ProEconWtPowerCurveFitting>> wpcmap = new HashMap<>();
+
+
+    IRealTimeDataBaseUtil realApiUtil = RealTimeDataBaseFactory.createRealTimeDataBase();
+
+
+    public  void initialRedisAll() throws Exception {
+
+        System.out.println("初始化开始!");
+        intialWpScatter();
+        intialPjScatter();
+        intialLnScatter();
+        intialWtScatter();
+        System.out.println("初始化完成!");
+
+    }
+
+    public  void intialWindturbinepowercurvefitting() throws Exception {
+
+
+        QueryWrapper<ProEconWtPowerCurveFitting> queryWrapper = new QueryWrapper<>();
+        queryWrapper.orderByAsc("windturbine_id").orderByAsc("speed");
+        List<ProEconWtPowerCurveFitting> wpclist = proEconWtPowerCurveFittingService.list(queryWrapper);
+
+        if (!wpclist.isEmpty()) {
+            for (ProEconWtPowerCurveFitting wc : wpclist) {
+                if (wpcmap.containsKey(wc.getWindturbineId())) {
+                    Map<Double, ProEconWtPowerCurveFitting> map = wpcmap.get(wc.getWindturbineId());
+                    map.put(wc.getSpeed(), wc);
+                } else {
+                    Map<Double, ProEconWtPowerCurveFitting> map = new HashMap<Double, ProEconWtPowerCurveFitting>();
+                    map.put(wc.getSpeed(), wc);
+                    wpcmap.put(wc.getWindturbineId(), map);
+                }
+            }
+        }
+
+        redisService.set("wpcmap", JSON.toJSONString(wpcmap));
+    }
+
+
+    public  void intialWpScatter() throws Exception {
+
+
+
+        Calendar cal = Calendar.getInstance();
+        cal.set(Calendar.HOUR_OF_DAY, 0);
+        cal.set(Calendar.MINUTE, 0);
+        cal.set(Calendar.SECOND, 0);
+
+        int month=cal.get(Calendar.MONTH)+1;
+
+
+        cal.set(Calendar.MONTH, 0);
+
+        for(int j=0;j<month;j++)
+        {
+            List<List<Double>> vos = new ArrayList<List<Double>>();
+            cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH));
+            Date beginDate = cal.getTime();
+            Date endDate =null;
+            if(month-1==cal.get(Calendar.MONTH))
+            {
+                cal = Calendar.getInstance();
+               //cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
+                endDate = cal.getTime();
+            }else
+            {
+                cal.add(Calendar.MONTH,1);;
+                endDate = cal.getTime();
+            }
+
+
+            for(ProBasicPowerstation wp:CacheContext.wpls)
+            {
+                String wpId=wp.getId();
+                ProBasicPowerstationPoint gl = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.SSZGL);
+                ProBasicPowerstationPoint fs = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.SSPJFS);
+
+                int daynum = DateUtils.daysDiff(beginDate, endDate);
+                long pried = 600 ;
+                long count = 6 * 24 * daynum;
+
+                DecimalFormat dcmFmt = new DecimalFormat("0.00");
+                List<PointData> gls = realApiUtil.getHistoryDatasSnap(gl, beginDate.getTime() / 1000, endDate.getTime() / 1000, count, pried);
+
+                List<PointData> fss = realApiUtil.getHistoryDatasSnap(fs, beginDate.getTime() / 1000, endDate.getTime() / 1000, count, pried);
+
+
+                if (!gls.isEmpty() && !fss.isEmpty()) {
+                    for (int i = 0; i < fss.size(); i++) {
+
+                        List<Double> ds = new ArrayList<Double>();
+
+                        double f = fss.get(i).getPointValueInDouble();
+                        ds.add(Double.valueOf(dcmFmt.format(f)));
+                        f = gls.get(i).getPointValueInDouble();
+                        ds.add(Double.valueOf(dcmFmt.format(f)));
+                        vos.add(ds);
+                    }
+                }
+
+               // cal.add(Calendar.MONTH,1);
+                StringBuilder sb=new StringBuilder();
+                sb.append("scatter_").append(wpId).append("_").append(j+1);
+                redisService.set(String.valueOf(sb), JSON.toJSONString(vos));
+                System.out.println(String.valueOf(sb.append("完成")));
+            }
+        }
+
+
+
+    }
+
+
+
+    public  void intialPjScatter() throws Exception {
+
+
+
+
+
+        Calendar cal = Calendar.getInstance();
+        cal.set(Calendar.HOUR_OF_DAY, 0);
+        cal.set(Calendar.MINUTE, 0);
+        cal.set(Calendar.SECOND, 0);
+
+        int month=cal.get(Calendar.MONTH)+1;
+
+
+        cal.set(Calendar.MONTH, 0);
+
+        for(int j=0;j<month;j++)
+        {
+            List<List<Double>> vos = new ArrayList<List<Double>>();
+            cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH));
+            Date beginDate = cal.getTime();
+            Date endDate =null;
+            if(month-1==cal.get(Calendar.MONTH))
+            {
+                cal = Calendar.getInstance();
+                //cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
+                endDate = cal.getTime();
+            }else
+            {
+                cal.add(Calendar.MONTH,1);;
+                endDate = cal.getTime();
+            }
+
+
+            for(ProBasicProject pj:CacheContext.projects)
+            {
+                String wpId=pj.getId();
+                ProBasicPowerstationPoint gl = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.SSZGL);
+                ProBasicPowerstationPoint fs = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.SSPJFS);
+
+                int daynum = DateUtils.daysDiff(beginDate, endDate);
+                long pried = 600 ;
+                long count = 6 * 24 * daynum;
+
+                DecimalFormat dcmFmt = new DecimalFormat("0.00");
+                List<PointData> gls = realApiUtil.getHistoryDatasSnap(gl, beginDate.getTime() / 1000, endDate.getTime() / 1000, count, pried);
+
+                List<PointData> fss = realApiUtil.getHistoryDatasSnap(fs, beginDate.getTime() / 1000, endDate.getTime() / 1000, count, pried);
+
+
+                if (!gls.isEmpty() && !fss.isEmpty()) {
+                    for (int i = 0; i < fss.size(); i++) {
+
+                        List<Double> ds = new ArrayList<Double>();
+
+                        double f = fss.get(i).getPointValueInDouble();
+                        ds.add(Double.valueOf(dcmFmt.format(f)));
+                        f = gls.get(i).getPointValueInDouble();
+                        ds.add(Double.valueOf(dcmFmt.format(f)));
+                        vos.add(ds);
+                    }
+                }
+
+                // cal.add(Calendar.MONTH,1);
+                StringBuilder sb=new StringBuilder();
+                sb.append("scatter_").append(wpId).append("_").append(j+1);
+                redisService.set(String.valueOf(sb), JSON.toJSONString(vos));
+                System.out.println(String.valueOf(sb.append("完成")));
+            }
+        }
+
+
+
+    }
+
+
+
+    public  void intialLnScatter() throws Exception {
+
+
+
+
+        Calendar cal = Calendar.getInstance();
+        cal.set(Calendar.HOUR_OF_DAY, 0);
+        cal.set(Calendar.MINUTE, 0);
+        cal.set(Calendar.SECOND, 0);
+
+        int month=cal.get(Calendar.MONTH)+1;
+
+
+        cal.set(Calendar.MONTH, 0);
+
+        for(int j=0;j<month;j++)
+        {
+            List<List<Double>> vos = new ArrayList<List<Double>>();
+            cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH));
+            Date beginDate = cal.getTime();
+            Date endDate =null;
+            if(month-1==cal.get(Calendar.MONTH))
+            {
+                cal = Calendar.getInstance();
+                //cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
+                endDate = cal.getTime();
+            }else
+            {
+                cal.add(Calendar.MONTH,1);;
+                endDate = cal.getTime();
+            }
+
+
+            for(ProBasicLine wp:CacheContext.lines)
+            {
+                String wpId=wp.getId();
+                ProBasicPowerstationPoint gl = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.SSZGL);
+                ProBasicPowerstationPoint fs = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.SSPJFS);
+
+                int daynum = DateUtils.daysDiff(beginDate, endDate);
+                long pried = 600 ;
+                long count = 6 * 24 * daynum;
+
+                DecimalFormat dcmFmt = new DecimalFormat("0.00");
+                List<PointData> gls = realApiUtil.getHistoryDatasSnap(gl, beginDate.getTime() / 1000, endDate.getTime() / 1000, count, pried);
+
+                List<PointData> fss = realApiUtil.getHistoryDatasSnap(fs, beginDate.getTime() / 1000, endDate.getTime() / 1000, count, pried);
+
+
+                if (!gls.isEmpty() && !fss.isEmpty()) {
+                    for (int i = 0; i < fss.size(); i++) {
+
+                        List<Double> ds = new ArrayList<Double>();
+
+                        double f = fss.get(i).getPointValueInDouble();
+                        ds.add(Double.valueOf(dcmFmt.format(f)));
+                        f = gls.get(i).getPointValueInDouble();
+                        ds.add(Double.valueOf(dcmFmt.format(f)));
+                        vos.add(ds);
+                    }
+                }
+
+                // cal.add(Calendar.MONTH,1);
+                StringBuilder sb=new StringBuilder();
+                sb.append("scatter_").append(wpId).append("_").append(j+1);
+                redisService.set(String.valueOf(sb), JSON.toJSONString(vos));
+                System.out.println(String.valueOf(sb.append("完成")));
+            }
+        }
+
+
+
+    }
+
+
+    public  void intialWtScatter() throws Exception {
+
+
+   
+
+
+        Calendar cal = Calendar.getInstance();
+        cal.set(Calendar.HOUR_OF_DAY, 0);
+        cal.set(Calendar.MINUTE, 0);
+        cal.set(Calendar.SECOND, 0);
+
+        int month=cal.get(Calendar.MONTH)+1;
+
+
+//        cal.set(Calendar.MONTH, 0);
+
+
+            List<List<Double>> vos = new ArrayList<>();
+            cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH));
+            Date beginDate = cal.getTime();
+            Date endDate =null;
+            if(month-1==cal.get(Calendar.MONTH))
+            {
+                cal = Calendar.getInstance();
+                //cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
+                endDate = cal.getTime();
+            }else
+            {
+                cal.add(Calendar.MONTH,1);
+                endDate = cal.getTime();
+            }
+
+
+            for(ProBasicEquipment wt:CacheContext.wtls)
+            {
+                String wpId=wt.getId();
+                ProBasicEquipmentPoint gl = proBasicEquipmentPointService.getEquipmentPoint(wpId, ContantXk.CJ_SSGL);
+                ProBasicEquipmentPoint fs = proBasicEquipmentPointService.getEquipmentPoint(wpId, ContantXk.CJ_SSFS);
+
+                int daynum = DateUtils.daysDiff(beginDate, endDate);
+                long pried = 600 ;
+                long count = 6 * 24 * daynum;
+
+                DecimalFormat dcmFmt = new DecimalFormat("0.00");
+                List<PointData> gls = realApiUtil.getHistoryDatasSnap(gl, beginDate.getTime() / 1000, endDate.getTime() / 1000, count, pried);
+
+                List<PointData> fss = realApiUtil.getHistoryDatasSnap(fs, beginDate.getTime() / 1000, endDate.getTime() / 1000, count, pried);
+
+
+                if (!gls.isEmpty() && !fss.isEmpty() && gls.size() ==fss.size()) {
+                    for (int i = 0; i < fss.size(); i++) {
+
+                        List<Double> ds = new ArrayList<Double>();
+
+                        double f = fss.get(i).getPointValueInDouble();
+                        ds.add(Double.valueOf(dcmFmt.format(f)));
+                        f = gls.get(i).getPointValueInDouble();
+                        ds.add(Double.valueOf(dcmFmt.format(f)));
+                        vos.add(ds);
+                    }
+                }else
+                {
+                    System.out.println("begin-"+DateUtils.format(beginDate));
+                    System.out.println("end-"+DateUtils.format(endDate));
+                    System.out.println("gl-"+gl.getNemCode());
+                    System.out.println("fs-"+fs.getNemCode());
+                    System.out.println("glsl-"+gls.size());
+                    System.out.println("fssl-"+fss.size());
+                }
+
+                // cal.add(Calendar.MONTH,1);
+                StringBuilder sb=new StringBuilder();
+                sb.append("scatter_").append(wpId).append("_").append(month);
+                redisService.set(String.valueOf(sb), JSON.toJSONString(vos));
+                System.out.println(String.valueOf(sb.append("完成")));
+            }
+
+
+
+
+    }
+
+    public static void main(String[]args) throws Exception {
+
+//        SpringApplication.run(SpringbootStart.class, args);
+//
+//        InitialRedis initialRedis=new InitialRedis();
+//        //初始化风机拟合功率
+//      // initialRedis.intialWindturbinepowercurvefitting();
+//
+//        //初始化场站没有散点图
+//        initialRedis.intialWpScatter();
+    }
+}

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 3 - 3
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/ProEconRecommenMainMapper.java


+ 1 - 1
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/ProEconWtPowerCurveFitting.java

@@ -27,7 +27,7 @@ public class ProEconWtPowerCurveFitting extends Model {
      * 编号
      */
     @TableId(value = "ID",type = IdType.ASSIGN_ID)
-    private Integer id;
+    private Long id;
 
     /**
      * 风机编号

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

@@ -272,7 +272,7 @@ public class HealthReportService {
 
         if (StringUtils.notEmp(recordDate) && StringUtils.notEmp(wtId)) {
 
-            List<ProEconRecommenMain> sjls = proEconRecommenMainService.findRecommenmainList(wtId,recordDate);
+            List<ProEconRecommenMain> sjls = proEconRecommenMainService.findRecommenmainListByWt(wtId,recordDate);
 
             if (!sjls.isEmpty()) {
 

+ 1 - 1
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IProEconRecommenMainService.java

@@ -28,6 +28,6 @@ public interface IProEconRecommenMainService extends IService<ProEconRecommenMai
 
     public List<ProEconRecommenMain> findRecommenmainList(Date beginDate,Date endDate);
 
-    public List<ProEconRecommenMain> findRecommenmainList(String wtId,  Date recordDate);
+    public List<ProEconRecommenMain> findRecommenmainListByWt(String wtId,  Date recordDate);
 
 }

+ 2 - 2
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/ProEconRecommenMainServiceImpl.java

@@ -86,8 +86,8 @@ public class ProEconRecommenMainServiceImpl extends ServiceImpl<ProEconRecommenM
         return proEconRecommenMainMapper.findRecommenmainList(beginDate, endDate);
     }
     @Override
-    public List<ProEconRecommenMain> findRecommenmainList(String wtId,  Date recordDate)
+    public List<ProEconRecommenMain> findRecommenmainListByWt(String wtId,  Date recordDate)
     {
-        return proEconRecommenMainMapper.findRecommenmainList(wtId, recordDate);
+        return proEconRecommenMainMapper.findRecommenmainListByWt(wtId, recordDate);
     }
 }

+ 19 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/task/SaticScheduleTask.java

@@ -1,6 +1,7 @@
 package com.gyee.healthmodel.task;
 
 
+import com.gyee.healthmodel.init.InitialRedis;
 import com.gyee.healthmodel.service.HealthJudgeService;
 import com.gyee.healthmodel.service.HealthReportService;
 import com.gyee.healthmodel.service.RecommenmainsService;
@@ -36,8 +37,26 @@ public class SaticScheduleTask {
     //3.添加定时任务
 
 
+    @Resource
+    private InitialRedis initialRedis;
+
+
+    @XxlJob("healthmodel-initialRedis")
+    public void configureTasks0()  {
+
+
+        XxlJobHelper.log("redis数据调度程序执行开始!........");
+
+        try {
+
+            initialRedis.initialRedisAll();
+        } catch (Exception e) {
 
+            e.printStackTrace();
+        }
 
+        XxlJobHelper.log("redis数据调度程序执行完成!........");
+    }
     @XxlJob("healthmodel-wtHealthModelValue")
     public void configureTasks1()  {
 

+ 44 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/util/redis/RedisAutoConfiguration.java

@@ -0,0 +1,44 @@
+package com.gyee.healthmodel.util.redis;
+
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisOperations;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.StringRedisTemplate;
+
+import java.net.UnknownHostException;
+
+@Configuration
+@ConditionalOnClass(RedisOperations.class)
+@EnableConfigurationProperties(RedisProperties.class)
+public class RedisAutoConfiguration {
+
+
+    @Bean
+    @ConditionalOnMissingBean(name = "redisTemplate")
+    public RedisTemplate<Object, Object> redisTemplate(
+            RedisConnectionFactory redisConnectionFactory) throws UnknownHostException {
+        RedisTemplate<Object, Object> template = new RedisTemplate<>();
+        template.setConnectionFactory(redisConnectionFactory);
+        return template;
+
+    }
+
+
+    @Bean
+    @ConditionalOnMissingBean
+    public StringRedisTemplate stringRedisTemplate(
+            RedisConnectionFactory redisConnectionFactory) throws UnknownHostException {
+        StringRedisTemplate template = new StringRedisTemplate();
+        template.setConnectionFactory(redisConnectionFactory);
+        return template;
+
+    }
+
+
+}

+ 47 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/util/redis/RedisConfig.java

@@ -0,0 +1,47 @@
+package com.gyee.healthmodel.util.redis;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+
+/**
+
+/**
+ *@ClassName RedisConfig
+ *@Description TODO
+ *@Author 谢生杰
+ *@Date 2020/9/14 10:42
+ *@Version 1.0
+ **/
+@Configuration
+public class RedisConfig {
+    @Bean
+    @SuppressWarnings("all")
+    public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
+        RedisTemplate<String, Object> template = new RedisTemplate<String, Object>();
+        template.setConnectionFactory(factory);
+        Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
+        ObjectMapper om = new ObjectMapper();
+        om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
+        om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
+        jackson2JsonRedisSerializer.setObjectMapper(om);
+        StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
+        // key采用String的序列化方式
+        template.setKeySerializer(stringRedisSerializer);
+        // hash的key也采用String的序列化方式
+        template.setHashKeySerializer(stringRedisSerializer);
+        // value序列化方式采用jackson
+        template.setValueSerializer(jackson2JsonRedisSerializer);
+        // hash的value序列化方式采用jackson
+        template.setHashValueSerializer(jackson2JsonRedisSerializer);
+        template.afterPropertiesSet();
+        return template;
+    }
+}

+ 51 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/util/redis/RedisService.java

@@ -0,0 +1,51 @@
+package com.gyee.healthmodel.util.redis;
+
+public interface RedisService {
+
+    /**
+     * set存数据
+     * @param key
+     * @param value
+     * @return
+     */
+    boolean set(String key, String value);
+
+
+
+    /**
+     * get获取数据
+     * @param key
+     * @return
+     */
+    String get(String key);
+
+//    void getList(String key,int start,int end);
+
+    /**
+     * 设置有效天数
+     * @param key
+     * @param expire
+     * @return
+     */
+    boolean expire(String key, long expire);
+
+    /**
+     * 移除数据
+     * @param key
+     * @return
+     */
+    boolean remove(String key);
+
+
+    /**
+     * 插入对象
+     */
+    void setObject(Object o);
+
+
+    boolean hasKey(String key);
+
+
+    void select(Integer dbIndex);
+
+}

+ 125 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/util/redis/RedisServiceImpl.java

@@ -0,0 +1,125 @@
+package com.gyee.healthmodel.util.redis;
+
+import org.springframework.dao.DataAccessException;
+import org.springframework.data.redis.connection.RedisConnection;
+import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
+import org.springframework.data.redis.core.RedisCallback;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.RedisSerializer;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.lang.reflect.Field;
+import java.util.concurrent.TimeUnit;
+
+@Service("redisService")
+public class RedisServiceImpl implements RedisService {
+
+    @Resource
+    private RedisTemplate<String, ?> redisTemplate;
+
+    @Override
+    public boolean set(final String key, final String value) {;
+        boolean result = redisTemplate.execute(new RedisCallback<Boolean>() {
+            @Override
+            public Boolean doInRedis(RedisConnection connection) throws DataAccessException {
+                RedisSerializer<String> serializer = redisTemplate.getStringSerializer();
+                connection.set(serializer.serialize(key), serializer.serialize(value));
+                return true;
+            }
+        });
+        return result;
+    }
+
+
+    @Override
+    public String get(final String key) {
+        String result = redisTemplate.execute(new RedisCallback<String>() {
+            @Override
+            public String doInRedis(RedisConnection connection) throws DataAccessException {
+                RedisSerializer<String> serializer = redisTemplate.getStringSerializer();
+                byte[] value = connection.get(serializer.serialize(key));
+                return serializer.deserialize(value);
+            }
+        });
+        return result;
+    }
+
+
+
+    @Override
+    public boolean expire(final String key, long expire) {
+        return redisTemplate.expire(key, expire, TimeUnit.SECONDS);
+    }
+
+    @Override
+    public boolean remove(final String key) {
+        boolean result = redisTemplate.execute(new RedisCallback<Boolean>() {
+            @Override
+            public Boolean doInRedis(RedisConnection connection) throws DataAccessException {
+                RedisSerializer<String> serializer = redisTemplate.getStringSerializer();
+                connection.del(key.getBytes());
+                return true;
+            }
+        });
+        return result;
+    }
+
+    @Override
+    public boolean hasKey(final String key) {
+        try {
+            return redisTemplate.hasKey(key);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    @Override
+    public void setObject(Object obj) {
+        Field[] fields = obj.getClass().getDeclaredFields();
+        for(int i = 0 , len = fields.length; i < len; i++) {
+            // 对于每个属性,获取属性名
+            String varName = fields[i].getName();
+            try {
+                // 获取原来的访问控制权限
+                boolean accessFlag = fields[i].isAccessible();
+                // 修改访问控制权限
+                fields[i].setAccessible(true);
+                // 获取在对象f中属性fields[i]对应的对象中的变量
+                Object o;
+                try {
+                    o = fields[i].get(obj);
+                    if (o!=null){
+                        set(varName, String.valueOf(o));
+                    }else {
+                        set(varName,"");
+                    }
+
+                    //System.err.println("传入的对象中包含一个如下的变量:" + varName + " = " + o);
+                } catch (IllegalAccessException e) {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                }
+                // 恢复访问控制权限
+                fields[i].setAccessible(accessFlag);
+            } catch (IllegalArgumentException ex) {
+                ex.printStackTrace();
+            }
+        }
+
+    }
+
+    public void select(Integer dbIndex) {
+        if (dbIndex == null || dbIndex > 15 || dbIndex < 0) {
+            dbIndex = 0;
+        }
+        LettuceConnectionFactory jedisConnectionFactory = (LettuceConnectionFactory) redisTemplate
+                .getConnectionFactory();
+        jedisConnectionFactory.setDatabase(dbIndex);
+        redisTemplate.setConnectionFactory(jedisConnectionFactory);
+        jedisConnectionFactory.afterPropertiesSet();
+//        jedisConnectionFactory.resetConnection();
+
+    }
+}

+ 21 - 0
realtime/healthmodel-server/src/main/resources/application-jn.yml

@@ -34,6 +34,27 @@ mybatis-plus:
 spring:
   main:
     allow-bean-definition-overriding: true #当遇到同样名字的时候,是否允许覆盖注册
+  redis:
+    #host: 127.0.0.1
+    host: 10.81.3.155
+    port: 6379
+    timeout: 100000
+    #    集群环境打开下面注释,单机不需要打开
+    #    cluster:
+    #      #集群信息
+    #      nodes: 10.83.68.151:6379,10.83.68.152:6379,10.83.68.153:6379,10.83.68.154:6379,10.83.68.155:6379,10.83.68.156:6379,10.83.68.157:6379,10.83.68.158:6379,10.83.68.159:6379
+    #      #默认值是5 一般当此值设置过大时,容易报:Too many Cluster redirections
+    #      maxRedirects: 3
+    password:
+    application:
+      name: test
+    jedis:
+      pool:
+        max-active: 8
+        min-idle: 0
+        max-idle: 8
+        max-wait: -1
+    database: 9
   autoconfigure:
     exclude: org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration
   datasource:

+ 8 - 4
realtime/healthmodel-server/src/test/java/HealthTest.java

@@ -1,6 +1,4 @@
 import com.gyee.healthmodel.HealthmodelMain;
-import com.gyee.healthmodel.service.HealthJudgeService;
-import com.gyee.healthmodel.util.SpringUtils;
 import lombok.SneakyThrows;
 import org.springframework.boot.SpringApplication;
 
@@ -13,8 +11,8 @@ 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();
@@ -25,6 +23,12 @@ public class HealthTest {
 //
 //        HealthReportService healthReportService= SpringUtils.getBean("healthReportService");
 //        healthReportService.createHealthReport(new Date());
+
+
+//        InitialRedis initialRedis= SpringUtils.getBean("initialRedis");
+////        initialRedis.initialRedisAll();
+//
+//        initialRedis.intialWindturbinepowercurvefitting();
          System.out.println("调度任务处理完成!........");