Browse Source

Merge branch 'master' of http://124.70.43.205:3000/xieshengjie/sis

xushili 1 year ago
parent
commit
56d1f1f0c2

+ 68 - 68
realtime/generation-service/src/main/java/com/gyee/generation/config/XxlJobConfig.java

@@ -1,68 +1,68 @@
-package com.gyee.generation.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.generation.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();
+//    */
+//
+//
+//}

+ 33 - 4
realtime/generation-service/src/main/java/com/gyee/generation/init/CacheContext.java

@@ -57,6 +57,10 @@ public class CacheContext implements CommandLineRunner {
     @Resource
     private IWindturbinetestingpointdisService windturbinetestingpointdisService;
     public static List<Windturbine> wtls = new ArrayList<>();
+
+    public static Map<String,List<Windturbine>> wpwtmap = new HashMap<>();
+    public static Map<String,List<Windturbine>> pjwtmap = new HashMap<>();
+    public static Map<String,List<Windturbine>> lnwtmap = new HashMap<>();
     public static List<Project> projects = new ArrayList<>();
     public static List<Line> lines = new ArrayList<>();
     public static List<Windpowerstation> wpls = new ArrayList<>();
@@ -121,6 +125,29 @@ public class CacheContext implements CommandLineRunner {
                 lines.add(wt);
                 linewtmap.put(wt.getLineid(), lines);
             }
+
+            if (wpwtmap.containsKey(wt.getWindpowerstationid())){
+                wpwtmap.get(wt.getWindpowerstationid()).add(wt);
+            }else {
+                List<Windturbine> wps = new ArrayList<>();
+                wps.add(wt);
+                wpwtmap.put(wt.getWindpowerstationid(),wps);
+            }
+
+            if (pjwtmap.containsKey(wt.getProjectid())){
+                pjwtmap.get(wt.getProjectid()).add(wt);
+            }else {
+                List<Windturbine> pjs = new ArrayList<>();
+                pjs.add(wt);
+                pjwtmap.put(wt.getProjectid(),pjs);
+            }
+            if (lnwtmap.containsKey(wt.getLineid())){
+                lnwtmap.get(wt.getLineid()).add(wt);
+            }else {
+                List<Windturbine> lnls = new ArrayList<>();
+                lnls.add(wt);
+                lnwtmap.put(wt.getLineid(),lnls);
+            }
         });
 
         projects = projectService.list().stream().filter(i -> runWpids.contains(i.getWindpowerstationid())).collect(Collectors.toList());
@@ -262,7 +289,7 @@ public class CacheContext implements CommandLineRunner {
 
         List<Windturbinetestingpointai> wtpointlist = windturbinetestingpointaiService.list();
 
-
+        Map<String, Map<String, Windturbinetestingpointai>> wtPointmap = new HashMap<>();// 风电机测点AI表
         Map<String, Windturbinetestingpointai> map = null;
 
         if (wtpointlist != null && !wtpointlist.isEmpty()) {
@@ -271,7 +298,7 @@ public class CacheContext implements CommandLineRunner {
                     map = wtPointmap.get(mp.getWindturbineid());
                     map.put(mp.getUniformcode(), mp);
                 } else {
-                    map = new HashMap<String, Windturbinetestingpointai>();
+                    map = new HashMap<>();
                     map.put(mp.getUniformcode(), mp);
                     wtPointmap.put(mp.getWindturbineid(), map);
                 }
@@ -281,7 +308,7 @@ public class CacheContext implements CommandLineRunner {
         String s = JSONObject.toJSONString(wtPointmap);
         redisService.set("wtPointmap", s);
 
-
+        Map<String, Map<String, Windpowerstationtestingpoint>> wpPointmap = new HashMap<>();
         List<Windpowerstationtestingpoint> list = windpowerstationtestingpointService.list();
 
         Map<String, Windpowerstationtestingpoint> items = null;
@@ -302,8 +329,10 @@ public class CacheContext implements CommandLineRunner {
         s = JSONObject.toJSONString(wpPointmap);
         redisService.set("wpPointmap", s);
 
+        Map<String, Map<Double, Windturbinepowercurvefitting>> curveFittingPowerMap = new HashMap<>();
 
         List<Windturbinepowercurvefitting> econWtPowerCurveFittings = windturbinepowercurvefittingService.list();
+
         if (StringUtils.isNotNull(econWtPowerCurveFittings)) {
             econWtPowerCurveFittings.stream().forEach(curveFitting -> {
                 if (curveFittingPowerMap.containsKey(curveFitting.getWindturbineid())) {
@@ -319,7 +348,7 @@ public class CacheContext implements CommandLineRunner {
         s = JSONObject.toJSONString(curveFittingPowerMap);
         redisService.set("curveFittingPowerMap", s);
 
-
+        List<Windturbinetestingpointdis> pointdis = new ArrayList<>();
         pointdis = windturbinetestingpointdisService.list();
 
         s = JSONObject.toJSONString(pointdis);

+ 194 - 32
realtime/generation-service/src/main/java/com/gyee/generation/service/Status_HF_Service.java

@@ -1,18 +1,17 @@
 package com.gyee.generation.service;
 
 import com.gyee.common.contant.Contant;
-import com.gyee.common.model.PointData;
 import com.gyee.common.model.StringUtils;
 import com.gyee.common.util.DateUtils;
 import com.gyee.common.util.algorithm.Underdelivery;
 import com.gyee.generation.init.CacheContext;
 import com.gyee.generation.model.auto.*;
 import com.gyee.generation.util.SpringUtils;
-import com.gyee.generation.util.realtimesource.IEdosUtil;
 import com.gyee.generation.util.redis.RedisService;
 import org.springframework.stereotype.Service;
 
-import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -25,9 +24,6 @@ import java.util.stream.Collectors;
 @Service
 public class Status_HF_Service {
 
-    @Resource
-    private IEdosUtil edosUtil;
-
 
 
 
@@ -490,46 +486,212 @@ public class Status_HF_Service {
      * @throws Exception
      */
     public void calculateWpPoint() throws Exception {
-        RedisService redisService= SpringUtils.getBean("redisService");
+        RedisService redisService = SpringUtils.getBean("redisService");
         Date date = new Date();
         Map<String, Map<String, Object>> pipelinedmap = new HashMap<>();
         if (!CacheContext.wpls.isEmpty()) {
             for (Windpowerstation wp : CacheContext.wpls) {
 
 
-                if (CacheContext.wpPointmap.containsKey(wp.getId())) {
-                    Map<String, Windpowerstationtestingpoint> map = CacheContext.wpPointmap.get(wp.getId());
+                if (CacheContext.wpwtmap.containsKey(wp.getId())) {
+                    List<Windturbine> wtls = CacheContext.wpwtmap.get(wp.getId());
+
+                    Map<Integer,List<String>> fspointmap=new LinkedHashMap<>();
+                    Map<Integer,List<String>> glpointmap=new LinkedHashMap<>();
+                    Map<Integer,List<String>> fdlpointmap=new LinkedHashMap<>();
+
+                    for (Windturbine wt : wtls) {
+                        if (CacheContext.wtpAimap.containsKey(wt.getId())) {
+                            Map<String, Windturbinetestingpointai> pointmap = CacheContext.wtPointmap.get(wt.getId());
+
+                            if (pointmap.containsKey(Contant.AI022)) {
+
+                                Windturbinetestingpointai fspoint=pointmap.get(Contant.AI022);
+                                if (CacheContext.redisDbMap.containsKey(fspoint.getId())) {
 
-                    List<String> ls = new ArrayList<>();
+                                    int dbnum = CacheContext.redisDbMap.get(fspoint.getId());
+                                    if(fspointmap.containsKey(dbnum))
+                                    {
+                                        List<String> ls=fspointmap.get(dbnum);
+                                        ls.add(fspoint.getId());
+                                    }else
+                                    {
+                                        List<String> ls=new ArrayList<>();
+                                        ls.add(fspoint.getId());
+                                        fspointmap.put(dbnum,ls);
+                                    }
+
+                                }
+
+                            }
 
-                    ls.add(map.get("CYDLB").getCode());
-                    ls.add(map.get("RFDLB").getCode());
-                    ls.add(map.get("RFDLC").getCode());
-                    ls.add(map.get("RGZSSDL").getCode());
-                    ls.add(map.get("RJXSSDL").getCode());
-                    ls.add(map.get("RWZSSDL").getCode());
-                    ls.add(map.get("RXDSSDL").getCode());
-                    ls.add(map.get("SSFS").getCode());
-                    ls.add(map.get("SSZGL").getCode());
-                    ls.add(map.get("ZLLGL").getCode());
-                    ls.add(map.get("ZZSGL").getCode());
-                    ls.add(map.get("XDZT").getCode());
-                    ls.add(map.get("RXNSSDL").getCode());
-                    ls.add(map.get("QXPCL").getCode());
+                            if (pointmap.containsKey(Contant.AI130)) {
+                                Windturbinetestingpointai glpoint=pointmap.get(Contant.AI130);
+                                if (CacheContext.redisDbMap.containsKey(glpoint.getId())) {
+
+                                    int dbnum = CacheContext.redisDbMap.get(glpoint.getId());
+                                    if(glpointmap.containsKey(dbnum))
+                                    {
+                                        List<String> ls=glpointmap.get(dbnum);
+                                        ls.add(glpoint.getId());
+                                    }else
+                                    {
+                                        List<String> ls=new ArrayList<>();
+                                        ls.add(glpoint.getId());
+                                        glpointmap.put(dbnum,ls);
+                                    }
+
+                                }
+
+                            }
+
+                            if (pointmap.containsKey(Contant.AI064)) {
+                                Windturbinetestingpointai fdlpoint=pointmap.get(Contant.AI064);
+                                if (CacheContext.redisDbMap.containsKey(fdlpoint.getId())) {
+
+                                    int dbnum = CacheContext.redisDbMap.get(fdlpoint.getId());
+                                    if(fdlpointmap.containsKey(dbnum))
+                                    {
+                                        List<String> ls=fdlpointmap.get(dbnum);
+                                        ls.add(fdlpoint.getId());
+                                    }else
+                                    {
+                                        List<String> ls=new ArrayList<>();
+                                        ls.add(fdlpoint.getId());
+                                        fdlpointmap.put(dbnum,ls);
+                                    }
+
+                                }
+                            }
+                        }
+
+                    }
+
+                    Map<String,Map<String,String>> fsvaluemap=redisService.hgetall(fspointmap);
+                    Map<String,Map<String,String>> glvaluemap=redisService.hgetall(glpointmap);
+                    Map<String,Map<String,String>> fdlvaluemap=redisService.hgetall(fdlpointmap);
+
+                    double power = 0.0;
+                    double speed = 0.0;
+                    double fdl = 0.0;
+                    for (Windturbine wt : wtls) {
+
+                        if (CacheContext.wtPointmap.containsKey(wt.getId())) {
+                            Map<String, Windturbinetestingpointai> map = CacheContext.wtPointmap.get(wt.getId());
+
+
+                            if (map.containsKey(Contant.AI130) && map.containsKey(Contant.AI022) ) {
+                                Windturbinetestingpointai powerpoint = map.get(Contant.AI130);
+
+
+                                if (glvaluemap.containsKey(powerpoint.getId())) {
+                                    Map<String, String> tempmap = glvaluemap.get(powerpoint.getId());
+
+                                    if (tempmap.containsKey("value")) {
+                                        double temp = Double.valueOf((String) tempmap.get("value"));
+                                        power=power+temp;
+                                    }
+                                }
+                            }
+
+                            if (map.containsKey(Contant.AI022) ) {
+                                   Windturbinetestingpointai speedpoint = map.get(Contant.AI022);
+
+
+                                if (fsvaluemap.containsKey(speedpoint.getId())) {
+                                    Map<String, String> tempmap = fsvaluemap.get(speedpoint.getId());
+
+                                    if (tempmap.containsKey("value")) {
+                                        double temp = Double.valueOf((String) tempmap.get("value"));
+                                        speed=speed+temp;
+                                    }
+                                }
+                            }
+
+                            if (map.containsKey(Contant.AI064) ) {
+                                Windturbinetestingpointai fdlpoint = map.get(Contant.AI064);
+
+                                if (fdlvaluemap.containsKey(fdlpoint.getId())) {
+                                    Map<String, String> tempmap = fdlvaluemap.get(fdlpoint.getId());
+
+                                    if (tempmap.containsKey("value")) {
+                                        double temp = Double.valueOf((String) tempmap.get("value"));
+                                        fdl=fdl+temp;
+                                    }
+                                }
+                            }
+                        }
+                    }
+
+
+                    speed = new BigDecimal(speed).divide(new BigDecimal(wtls.size()), 2, RoundingMode.HALF_EVEN).doubleValue();
+                    if (CacheContext.wpPointmap.containsKey(wp.getId())) {
+
+                        Map<String, Windpowerstationtestingpoint> pointMap = CacheContext.wpPointmap.get(wp.getId());
+
+                        if (pointMap.containsKey(Contant.SSFS)) {
+                            Windpowerstationtestingpoint point = pointMap.get(Contant.SSFS);
+
+                            Map<String, Object> pomap = new LinkedHashMap<>();
+
+                            pomap.put("pointid", point.getCode());
+                            pomap.put("value", speed);
+                            pomap.put("timestamp", date.getTime() / 1000);
+                            pomap.put("datetime", DateUtils.toDate(date));
+                            pomap.put("status", 0);
+                            pipelinedmap.put(point.getCode(), pomap);
+                        }
+                    }
+
+                    power = StringUtils.round(power, 2);
+                    if (CacheContext.wpPointmap.containsKey(wp.getId())) {
+
+                        Map<String, Windpowerstationtestingpoint> pointMap = CacheContext.wpPointmap.get(wp.getId());
+
+                        if (pointMap.containsKey(Contant.SSZGL)) {
+                            Windpowerstationtestingpoint point = pointMap.get(Contant.SSZGL);
+
+                            Map<String, Object> pomap = new LinkedHashMap<>();
+
+                            pomap.put("pointid", point.getCode());
+                            pomap.put("value", power);
+                            pomap.put("timestamp", date.getTime() / 1000);
+                            pomap.put("datetime", DateUtils.toDate(date));
+                            pomap.put("status", 0);
+                            pipelinedmap.put(point.getCode(), pomap);
+                        }
+                    }
+
+                    fdl = new BigDecimal(fdl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
+
+                    if (CacheContext.wpPointmap.containsKey(wp.getId())) {
+
+                        Map<String, Windpowerstationtestingpoint> pointMap = CacheContext.wpPointmap.get(wp.getId());
+
+                        if (pointMap.containsKey(Contant.RFDL)) {
+                            Windpowerstationtestingpoint point = pointMap.get(Contant.RFDL);
+
+                            Map<String, Object> pomap = new LinkedHashMap<>();
+
+                            pomap.put("pointid", point.getCode());
+                            pomap.put("value", fdl);
+                            pomap.put("timestamp", date.getTime() / 1000);
+                            pomap.put("datetime", DateUtils.toDate(date));
+                            pomap.put("status", 0);
+                            pipelinedmap.put(point.getCode(), pomap);
+                        }
 
-                    List<PointData> vos = edosUtil.getRealData(ls);
-                    if (!vos.isEmpty()) {
+                        if (pointMap.containsKey(Contant.RFDLC)) {
+                            Windpowerstationtestingpoint point = pointMap.get(Contant.RFDLC);
 
-                        for (PointData vo : vos) {
                             Map<String, Object> pomap = new LinkedHashMap<>();
 
-                            pomap.put("pointid", vo.getEdnaId());
-                            pomap.put("value", vo.getPointValueInDouble());
-                            pomap.put("timestamp", date.getTime()/ 1000);
+                            pomap.put("pointid", point.getCode());
+                            pomap.put("value", fdl * (1 + Math.random()*0.2));
+                            pomap.put("timestamp", date.getTime() / 1000);
                             pomap.put("datetime", DateUtils.toDate(date));
                             pomap.put("status", 0);
-                            pipelinedmap.put(vo.getEdnaId(), pomap);
-                            //redisService.putHashAllObj(vo.getEdnaId(),pomap);
+                            pipelinedmap.put(point.getCode(), pomap);
                         }
                     }
 

+ 3 - 3
realtime/generation-service/src/main/resources/application-hf.yml

@@ -9,7 +9,7 @@ spring:
     allow-bean-definition-overriding: true #当遇到同样名字的时候,是否允许覆盖注册
   #redis集群
   redis:
-    host: 10.0.118.70
+    host: 10.0.118.76
     port: 6379
     timeout: 100000
 #    集群环境打开下面注释,单机不需要打开
@@ -33,7 +33,7 @@ spring:
   datasource:
     type: com.alibaba.druid.pool.DruidDataSource
     driver-class-name: oracle.jdbc.driver.OracleDriver
-    url: jdbc:oracle:thin:@10.0.118.71:1521:gdsj
+    url: jdbc:oracle:thin:@10.0.118.77:1521:gdsj
     username: gdprod
     password: gd123
     oracle-schema=:
@@ -80,7 +80,7 @@ mybatis-plus:
 logging:
   level:
     root: info
-    com.example: debug
+    com.example: info
 #db url
 db:
   url: http://10.0.118.73:8011/ts

+ 9 - 0
web/runeconomy-jjyx/src/main/java/com/gyee/runeconomy/dto/WxssVo.java

@@ -12,6 +12,7 @@ public class WxssVo {
     private BigDecimal xdssdl;
     private BigDecimal xnssdl;
     private BigDecimal slssdl;
+    private BigDecimal llfdl;
     private BigDecimal gnlyl;
 
     public String getId() {
@@ -85,4 +86,12 @@ public class WxssVo {
     public void setGnlyl(BigDecimal gnlyl) {
         this.gnlyl = gnlyl;
     }
+
+    public BigDecimal getLlfdl() {
+        return llfdl;
+    }
+
+    public void setLlfdl(BigDecimal llfdl) {
+        this.llfdl = llfdl;
+    }
 }

+ 1 - 0
web/runeconomy-jjyx/src/main/java/com/gyee/runeconomy/service/Economic/EconomicService.java

@@ -131,6 +131,7 @@ public class EconomicService {
                     wxssVo.setWhssdl(ss.getYjxssdl());
                     wxssVo.setXdssdl(ss.getYxdjclssdl().add(ss.getYxdtjssdl()));
                     wxssVo.setXnssdl(ss.getYxnssdl());
+                    wxssVo.setLlfdl(ss.getYllfdl());
                     wxssVo.setGnlyl(ss.getYfdl().divide(ss.getYllfdl(), 2, BigDecimal.ROUND_HALF_UP).multiply(num1));
                     lbls.add(wxssVo);