|
@@ -2,6 +2,9 @@ package com.gyee.monitor.service.matrix;
|
|
|
|
|
|
import com.gyee.common.contant.Contant;
|
|
|
import com.gyee.common.model.PointData;
|
|
|
+import com.gyee.common.model.StringUtils;
|
|
|
+import com.gyee.common.util.SortUtils;
|
|
|
+import com.gyee.common.vo.matrix.MatrixVo;
|
|
|
import com.gyee.monitor.init.CacheContext;
|
|
|
import com.gyee.monitor.model.auto.Windpowerstation;
|
|
|
import com.gyee.monitor.model.auto.Windpowerstationpointnew;
|
|
@@ -30,35 +33,60 @@ public class MatrixService {
|
|
|
private IEdosUtil edosUtil;
|
|
|
|
|
|
|
|
|
- public Map<String,Map<String,Double>> matrixDatas() {
|
|
|
- Map<String,Map<String,Double>> resultMap = new HashMap<>();
|
|
|
- Map<String,Double> wpMap = Collections.synchronizedMap(new HashMap<>());
|
|
|
- Map<String,Double> wtMap = Collections.synchronizedMap(new HashMap<>());
|
|
|
+ public Map<String,Object> matrixDatas() {
|
|
|
+ Map<String,Object> resultMap = new HashMap<>();
|
|
|
+ Map<String,Map<String,Object>> wpresultMap = new HashMap<>();
|
|
|
+
|
|
|
+ Map<String,List<MatrixVo>> wtMap = Collections.synchronizedMap(new HashMap<>());
|
|
|
+
|
|
|
+
|
|
|
Map<String, Map<String, Windpowerstationpointnew>> wpPointmap = CacheContext.wpPointmap;
|
|
|
Map<String, Map<String, Windturbinetestingpointnew>> wtPointmap = CacheContext.wtPointmap;
|
|
|
|
|
|
List<Windpowerstation> wpls = CacheContext.wpls;
|
|
|
- Windpowerstation windpowerstation = new Windpowerstation();
|
|
|
- windpowerstation.setId("0");
|
|
|
- windpowerstation.setQuantity(wpls.stream().mapToDouble(Windpowerstation::getQuantity).sum());
|
|
|
- wpls.add(windpowerstation);
|
|
|
- wpls.parallelStream().forEach(wp-> {
|
|
|
- wpMap.put(wp.getId()+"_jrts",wp.getQuantity());
|
|
|
+ List<Windpowerstation> companyWp = wpls.stream().filter(wp -> wp.getId().equals("0") || wp.getId().equals("-1") || wp.getId().equals("-2")).collect(Collectors.toList());
|
|
|
+ if (!StringUtils.isNotEmpty(companyWp)){
|
|
|
+ Windpowerstation comany = new Windpowerstation();
|
|
|
+ comany.setId("0");
|
|
|
+ comany.setQuantity(wpls.stream().mapToDouble(Windpowerstation::getQuantity).sum());
|
|
|
+ comany.setOrdernum(0.0);
|
|
|
+ wpls.add(comany);
|
|
|
+ //如果有光伏将下面注释打开
|
|
|
+// Windpowerstation fd = new Windpowerstation();
|
|
|
+// fd.setId("-1");
|
|
|
+// fd.setQuantity(wpls.stream().filter(i->i.getId().endsWith("FDC")).mapToDouble(Windpowerstation::getQuantity).sum());
|
|
|
+// wpls.add(fd);
|
|
|
+// Windpowerstation gf = new Windpowerstation();
|
|
|
+// gf.setId("-2");
|
|
|
+// gf.setQuantity(wpls.stream().filter(i->i.getId().endsWith("GDC")).mapToDouble(Windpowerstation::getQuantity).sum());
|
|
|
+// wpls.add(gf);
|
|
|
+ }
|
|
|
+ SortUtils.sort(wpls,"ordernum",SortUtils.ASC);
|
|
|
+ wpls.stream().forEach(wp-> {
|
|
|
+ Map<String,Object> wpMap = Collections.synchronizedMap(new HashMap<>());
|
|
|
+ wpMap.put("JRTS",wp.getQuantity());
|
|
|
+ wpMap.put("WPNAME",wp.getName());
|
|
|
List<String> pointList = new ArrayList<>();
|
|
|
Map<String,String> pointMap = new HashMap<>();
|
|
|
Map<String, Windpowerstationpointnew> stringWindpowerstationtestingpointMap = wpPointmap.get(wp.getId());
|
|
|
String[] wppoints = Contant.TPOINT_WP_MATRIX.split(",");
|
|
|
Arrays.stream(wppoints).forEach(uniformcode -> {
|
|
|
- Windpowerstationpointnew windpowerstationtestingpoint = stringWindpowerstationtestingpointMap.get(uniformcode);
|
|
|
- if (!windpowerstationtestingpoint.getCode().trim().equals("INITIAL")){
|
|
|
- pointList.add(windpowerstationtestingpoint.getCode());
|
|
|
+ if (stringWindpowerstationtestingpointMap.containsKey(uniformcode)){
|
|
|
+ Windpowerstationpointnew windpowerstationtestingpoint = stringWindpowerstationtestingpointMap.get(uniformcode);
|
|
|
+ if (!windpowerstationtestingpoint.getCode().trim().equals("INITIAL")){
|
|
|
+ pointList.add(windpowerstationtestingpoint.getCode());
|
|
|
+ }
|
|
|
+ pointMap.put(windpowerstationtestingpoint.getCode(),uniformcode);
|
|
|
}
|
|
|
- pointMap.put(windpowerstationtestingpoint.getCode(),wp.getId()+"_"+uniformcode);
|
|
|
});
|
|
|
try {
|
|
|
List<PointData> realData = edosUtil.getRealData(pointList);
|
|
|
realData.parallelStream().forEach(i -> {
|
|
|
- wpMap.put(pointMap.get(i.getEdnaId()), i.getPointValueInDouble());
|
|
|
+ String uniform = pointMap.get(i.getEdnaId());
|
|
|
+ if (uniform.equals(Contant.TPOINT_WP_BZGL) || uniform.equals(Contant.TPOINT_WP_YFGL))
|
|
|
+ wpMap.put(pointMap.get(i.getEdnaId()), i.getPointValueInDouble()/1000);
|
|
|
+ else
|
|
|
+ wpMap.put(pointMap.get(i.getEdnaId()), i.getPointValueInDouble());
|
|
|
});
|
|
|
List<String> pointids = realData.stream().map(i -> i.getEdnaId()).collect(Collectors.toList());
|
|
|
Set<String> totalpointids = pointMap.keySet();
|
|
@@ -67,11 +95,15 @@ public class MatrixService {
|
|
|
notexists.stream().forEach(n->{
|
|
|
wpMap.put(pointMap.get(n),0.0);
|
|
|
});
|
|
|
+ wpresultMap.put(wp.getId(),wpMap);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
});
|
|
|
- resultMap.put("wp",wpMap);
|
|
|
+
|
|
|
+ resultMap.put("wp",wpresultMap);
|
|
|
+
|
|
|
+
|
|
|
List<Windturbine> wtls = CacheContext.wtls;
|
|
|
List<String> synchronizedList = Collections.synchronizedList(new ArrayList<>());
|
|
|
Map<String,String> synchronizedMap = Collections.synchronizedMap(new HashMap<>());
|
|
@@ -79,20 +111,49 @@ public class MatrixService {
|
|
|
Windturbinetestingpointnew windturbinetestingpointnew = wtPointmap.get(wt.getId()).get(Contant.TPOINT_WT_FJZT);
|
|
|
if (!windturbinetestingpointnew.getCode().trim().equals("INITIAL")){
|
|
|
synchronizedList.add(windturbinetestingpointnew.getCode());
|
|
|
- synchronizedMap.put(windturbinetestingpointnew.getCode(),wt.getId());
|
|
|
}else{
|
|
|
log.info(windturbinetestingpointnew);
|
|
|
}
|
|
|
+ synchronizedMap.put(windturbinetestingpointnew.getCode(),wt.getId()+"!"+wt.getWindpowerstationid());
|
|
|
});
|
|
|
try {
|
|
|
List<PointData> realData = edosUtil.getRealData(synchronizedList);
|
|
|
- realData.parallelStream().forEach(i -> {
|
|
|
- wtMap.put(synchronizedMap.get(i.getEdnaId()), i.getPointValueInDouble());
|
|
|
+ realData.stream().forEach(i -> {
|
|
|
+ String[] split = synchronizedMap.get(i.getEdnaId()).split("!");
|
|
|
+ MatrixVo vo = new MatrixVo(split[0],i.getPointValueInDouble(),split[1]);
|
|
|
+ if (wtMap.containsKey(split[1])){
|
|
|
+ wtMap.get(split[1]).add(vo);
|
|
|
+ }else {
|
|
|
+ List<MatrixVo> wtResultList = new ArrayList<>();
|
|
|
+ wtResultList.add(vo);
|
|
|
+ wtMap.put(split[1],wtResultList);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ List<String> pointids = realData.stream().map(i -> i.getEdnaId()).collect(Collectors.toList());
|
|
|
+ Set<String> totalpointids = synchronizedMap.keySet();
|
|
|
+ Collection notexists=new ArrayList<String>(totalpointids);
|
|
|
+ notexists.removeAll(pointids);
|
|
|
+ notexists.stream().forEach(n->{
|
|
|
+ String[] split = synchronizedMap.get(n).split("!");
|
|
|
+ MatrixVo vo = new MatrixVo(split[0],0.0,split[1]);
|
|
|
+ if (wtMap.containsKey(split[1])){
|
|
|
+ wtMap.get(split[1]).add(vo);
|
|
|
+ }else {
|
|
|
+ List<MatrixVo> wtResultList = new ArrayList<>();
|
|
|
+ wtResultList.add(vo);
|
|
|
+ wtMap.put(split[1],wtResultList);
|
|
|
+ }
|
|
|
});
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
+ Set<String> wpids = wtMap.keySet();
|
|
|
+ wpids.stream().forEach(i->{
|
|
|
+ SortUtils.sort(wtMap.get(i),"wtid",SortUtils.ASC);
|
|
|
+ });
|
|
|
resultMap.put("wt",wtMap);
|
|
|
return resultMap;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|