|
@@ -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);
|
|
|
}
|
|
|
}
|
|
|
|