|
@@ -0,0 +1,256 @@
|
|
|
+package com.gyee.runeconomy.service.monitor;
|
|
|
+/*
|
|
|
+@author 谢生杰
|
|
|
+@date 2023/3/28-8:49
|
|
|
+*/
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.gyee.common.contant.ContantXk;
|
|
|
+import com.gyee.common.model.PointData;
|
|
|
+import com.gyee.common.util.DoubleUtils;
|
|
|
+import com.gyee.common.util.SortUtils;
|
|
|
+import com.gyee.common.vo.monitor.*;
|
|
|
+import com.gyee.runeconomy.init.CacheContext;
|
|
|
+import com.gyee.runeconomy.model.auto.*;
|
|
|
+import com.gyee.runeconomy.service.auto.IProBasicPowerPointService;
|
|
|
+import com.gyee.runeconomy.util.StringUtils;
|
|
|
+import com.gyee.runeconomy.util.realtimesource.IEdosUtil;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class MatrixHAService {
|
|
|
+ @Resource
|
|
|
+ private IEdosUtil edosUtil;
|
|
|
+ @Resource
|
|
|
+ private IProBasicPowerPointService powerPointService;
|
|
|
+
|
|
|
+ public Map<String, Object> matrixMX(String company, String type) throws Exception {
|
|
|
+
|
|
|
+ List<ProBasicPowerstation> wpls = CacheContext.wpls;
|
|
|
+
|
|
|
+ Map<String, Double> modelpower = CacheContext.modelpower;
|
|
|
+
|
|
|
+ if (company.endsWith("ZGS")) {
|
|
|
+ wpls = wpls.stream().filter(wp -> wp.getCompanyId().equals(company)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ if (type.equals("-1")) {
|
|
|
+ wpls = wpls.stream().filter(wp -> wp.getWindType().equals("-1")).collect(Collectors.toList());
|
|
|
+ } else if (type.equals("-2")) {
|
|
|
+ wpls = wpls.stream().filter(wp -> wp.getWindType().equals("-2")).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Map<String, ProBasicPowerstationPoint>> wppointmap = CacheContext.wppointmap;
|
|
|
+ Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
|
|
|
+ Map<String, List<ProBasicEquipment>> wpwtmap = CacheContext.wpwtmap;
|
|
|
+
|
|
|
+ List<MatrixHAPowerVo> powerVos = new ArrayList<>();
|
|
|
+ AtomicInteger jrts = new AtomicInteger();//接入台数
|
|
|
+
|
|
|
+ wpls.parallelStream().forEach(wp -> {
|
|
|
+ List<MatrixVo> volist = new ArrayList<>();
|
|
|
+ List<String> wpPoints = new ArrayList<>();
|
|
|
+ List<String> wtPoints = new ArrayList<>();
|
|
|
+ List<String> fjztPoints = new ArrayList<>();//二期风机状态
|
|
|
+ List<String> zktjPoints = new ArrayList<>();//中控停机
|
|
|
+ List<String> xglyxPoints = new ArrayList<>();//限功率运行
|
|
|
+ List<String> jlztPoints = new ArrayList<>();//解缆状态
|
|
|
+ List<String> wtPoints1 = new ArrayList<>();
|
|
|
+ Map<String, ProBasicPowerstationPoint> pointMap = wppointmap.get(wp.getId());
|
|
|
+ wpPoints.add(pointMap.get(ContantXk.SSZYGGL).getNemCode());
|
|
|
+ wpPoints.add(pointMap.get(ContantXk.SSZLLGL).getNemCode());
|
|
|
+
|
|
|
+
|
|
|
+ List<ProBasicEquipment> equipments = wpwtmap.get(wp.getId());
|
|
|
+ equipments.stream().forEach(wt -> {
|
|
|
+ Map<String, ProBasicEquipmentPoint> equipmentPointMap = wtpAimap.get(wt.getId());
|
|
|
+ if (wt.getProjectId().equals("NX_FGS_HAF01_EG")) {
|
|
|
+ wtPoints.add(equipmentPointMap.get(ContantXk.JKZT).getNemCode());//一期状态
|
|
|
+ } else {
|
|
|
+ fjztPoints.add(equipmentPointMap.get(ContantXk.FJZT).getNemCode());//二期状态
|
|
|
+ jlztPoints.add(equipmentPointMap.get(ContantXk.JLZT).getNemCode());//解缆状态
|
|
|
+ xglyxPoints.add(equipmentPointMap.get(ContantXk.XGLYX).getNemCode());//限功率运行
|
|
|
+ zktjPoints.add(equipmentPointMap.get(ContantXk.ZGTJ).getNemCode());//中控停机
|
|
|
+ }
|
|
|
+ });
|
|
|
+ equipments.stream().forEach(wt -> {
|
|
|
+ Map<String, ProBasicEquipmentPoint> equipmentPointMap = wtpAimap.get(wt.getId());
|
|
|
+ wtPoints1.add(equipmentPointMap.get(ContantXk.CJ_SSGL).getNemCode());
|
|
|
+ if (wt.getEquipmentCategory() == -1) {
|
|
|
+ wtPoints1.add(equipmentPointMap.get(ContantXk.CJ_SSFS).getNemCode());
|
|
|
+ wtPoints1.add(equipmentPointMap.get(ContantXk.CJ_SSZS).getNemCode());
|
|
|
+ } else if (wt.getEquipmentCategory() == -2) {
|
|
|
+ wtPoints1.add(equipmentPointMap.get(ContantXk.JLDL).getNemCode());
|
|
|
+ wtPoints1.add(equipmentPointMap.get(ContantXk.JLDY).getNemCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ try {
|
|
|
+ List<PointData> wtRealdatas = edosUtil.getRealData(wtPoints);
|
|
|
+ List<PointData> wpRealdatas = edosUtil.getRealData(wpPoints);
|
|
|
+ List<PointData> wtRealdatas1 = edosUtil.getRealData(wtPoints1);
|
|
|
+
|
|
|
+ MatrixHAPowerVo powerVo = new MatrixHAPowerVo();
|
|
|
+ powerVo.setWpid(wp.getId());
|
|
|
+ powerVo.setWpname(wp.getAname());
|
|
|
+ powerVo.setOrderNum(wp.getOrderNum());
|
|
|
+ powerVo.setJrts(wp.getJrwindQuantityHs() + wp.getJrwindQuantityLd() + wp.getJrquantityJz() + wp.getJrquantityZc());
|
|
|
+
|
|
|
+
|
|
|
+ if (wp.getWindType().equals("-1")) {
|
|
|
+ PointData speed = edosUtil.getRealData(pointMap.get(ContantXk.SSZPJFS).getNemCode());
|
|
|
+ powerVo.setSpped(StringUtils.round(speed.getPointValueInDouble(), 2));
|
|
|
+ } else if (wp.getWindType().equals("-2")) {
|
|
|
+ PointData speed = edosUtil.getRealData(pointMap.get(ContantXk.GCGZQD).getNemCode());
|
|
|
+ powerVo.setSpped(StringUtils.round(speed.getPointValueInDouble(), 2));
|
|
|
+ }
|
|
|
+
|
|
|
+ powerVo.setLlgl(StringUtils.round(wpRealdatas.get(1).getPointValueInDouble(),2));//千瓦
|
|
|
+ powerVo.setSjgl(StringUtils.round(wpRealdatas.get(0).getPointValueInDouble() * 1000,2));//千瓦
|
|
|
+
|
|
|
+
|
|
|
+ jrts.addAndGet(powerVo.getJrts());
|
|
|
+
|
|
|
+ int index = 3;
|
|
|
+ for (int j = 0; j < equipments.size(); j++) {
|
|
|
+
|
|
|
+ MatrixVo vo = new MatrixVo();
|
|
|
+ vo.setWtid(equipments.get(j).getId());
|
|
|
+ vo.setWtname(equipments.get(j).getAname());
|
|
|
+
|
|
|
+ if (equipments.get(j).getProjectId().equals("NX_FGS_HAF01_EG")) {
|
|
|
+ vo.setStatus(wtRealdatas.get(j).getPointValueInDouble());
|
|
|
+ }
|
|
|
+ vo.setPower(DoubleUtils.keepPrecision(wtRealdatas1.get(j * index).getPointValueInDouble(), 2));
|
|
|
+ if (equipments.get(j).getEquipmentCategory() == -1) {
|
|
|
+ vo.setSpeed(DoubleUtils.keepPrecision(wtRealdatas1.get(j * index + 1).getPointValueInDouble(), 2));
|
|
|
+ vo.setTransfer(DoubleUtils.keepPrecision(wtRealdatas1.get(j * index + 2).getPointValueInDouble(), 2));
|
|
|
+ } else if (equipments.get(j).getEquipmentCategory() == -2) {
|
|
|
+ vo.setCurrent(DoubleUtils.keepPrecision(wtRealdatas1.get(j * index + 1).getPointValueInDouble(), 2));
|
|
|
+ vo.setVoltage(DoubleUtils.keepPrecision(wtRealdatas1.get(j * index + 2).getPointValueInDouble(), 2));
|
|
|
+ }
|
|
|
+ vo.setRate(DoubleUtils.keepPrecision(modelpower.containsKey(equipments.get(j).getId()) ? vo.getPower() / modelpower.get(equipments.get(j).getId()) * 100 : 0, 2));
|
|
|
+ vo.setProject(equipments.get(j).getProjectId());
|
|
|
+ volist.add(vo);
|
|
|
+ }
|
|
|
+ for (MatrixVo ztvo: volist){
|
|
|
+ if (ztvo.getProject().equals("NX_FGS_HAF02_EG")){
|
|
|
+ List<String> fjztstream = fjztPoints.stream().filter(c -> c.contains(ztvo.getWtname())).collect(Collectors.toList());
|
|
|
+ List<PointData> ztls = edosUtil.getRealData(fjztstream);
|
|
|
+ List<String> zktjstream = zktjPoints.stream().filter(c -> c.contains(ztvo.getWtname())).collect(Collectors.toList());
|
|
|
+ List<PointData> zktjls = edosUtil.getRealData(zktjstream);
|
|
|
+ List<String> jlztstream = jlztPoints.stream().filter(c -> c.contains(ztvo.getWtname())).collect(Collectors.toList());
|
|
|
+ List<PointData> jlls = edosUtil.getRealData(jlztstream);
|
|
|
+ List<String> xglyxstream = xglyxPoints.stream().filter(c -> c.contains(ztvo.getWtname())).collect(Collectors.toList());
|
|
|
+ List<PointData> xglls = edosUtil.getRealData(xglyxstream);
|
|
|
+
|
|
|
+ //计算状态 0==待机 1==停机 2==发电 4==故障 6==检修 8==限电 12==离线
|
|
|
+
|
|
|
+ //集控总状态 -1==通讯中断 0==正常运行 1==限功运行 2==待机状态 3==故障停机 4==电网故障 5==正常停机 6==天气停机 7==停机维护
|
|
|
+ // 8==限功停机 9==计划停机 10==启动 11==解缆状态
|
|
|
+
|
|
|
+ //一期集控状态 -1==离线 0==正常发电 1==限功发电 2==风机待命 3==故障停机 4==电网故障 5==正常停机 6==天气停机
|
|
|
+ // 7==服务 8==限功停机 9==计划停机
|
|
|
+
|
|
|
+ //二期集控状态 0==离线(通讯中断) 1==故障(故障停机) 2==检修(停机维护) 3==待机(待机状态) 4==启动 5==并网(正常运行)
|
|
|
+ // 限功运行==true 解缆==true 中控停机==true
|
|
|
+
|
|
|
+ if (xglls.get(0).getPointValue().equals("true")){
|
|
|
+ ztvo.setStatus(1.0);
|
|
|
+ } else if (jlls.get(0).getPointValue().equals("true")) {
|
|
|
+ ztvo.setStatus(11.0);//解缆
|
|
|
+ } else if (zktjls.get(0).getPointValue().equals("true")) {
|
|
|
+ ztvo.setStatus(7.0);
|
|
|
+ } else if (ztls.get(0).getPointValueInDouble() == 0.0) {
|
|
|
+ ztvo.setStatus(-1.0);
|
|
|
+ } else if (ztls.get(0).getPointValueInDouble() == 1.0) {
|
|
|
+ ztvo.setStatus(3.0);
|
|
|
+ } else if (ztls.get(0).getPointValueInDouble() == 2.0) {
|
|
|
+ ztvo.setStatus(7.0);
|
|
|
+ } else if (ztls.get(0).getPointValueInDouble() == 3.0) {
|
|
|
+ ztvo.setStatus(2.0);
|
|
|
+ } else if (ztls.get(0).getPointValueInDouble() == 4.0) {
|
|
|
+ ztvo.setStatus(10.0);//启动
|
|
|
+ } else if (ztls.get(0).getPointValueInDouble() == 5.0) {
|
|
|
+ ztvo.setStatus(0.0);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //集控总状态 -1==通讯中断 0==正常运行 1==限功运行 2==待机状态 3==故障停机 4==电网故障 5==正常停机 6==天气停机 7==停机维护
|
|
|
+ // 8==限功停机 9==计划停机 10==启动 11==解缆状态
|
|
|
+ Double txzdts = 0.0;
|
|
|
+ Double zcyxts = 0.0;
|
|
|
+ Double xgyxts = 0.0;
|
|
|
+ Double djztts = 0.0;
|
|
|
+ Double gztjts = 0.0;
|
|
|
+ Double dwgzts = 0.0;
|
|
|
+ Double zctjts = 0.0;
|
|
|
+ Double tqtjts = 0.0;
|
|
|
+ Double tjwhts = 0.0;
|
|
|
+ Double xgtjts = 0.0;
|
|
|
+ Double jhtjts = 0.0;
|
|
|
+ Double qdztts = 0.0;
|
|
|
+ Double jlztts = 0.0;
|
|
|
+ for (MatrixVo zt : volist){
|
|
|
+ if (zt.getStatus() == 0.0){
|
|
|
+ zcyxts++;
|
|
|
+ } else if (zt.getStatus() == 1.0){
|
|
|
+ xgyxts++;
|
|
|
+ } else if (zt.getStatus() == 2.0){
|
|
|
+ djztts++;
|
|
|
+ } else if (zt.getStatus() == 3.0){
|
|
|
+ gztjts++;
|
|
|
+ } else if (zt.getStatus() == 4.0){
|
|
|
+ dwgzts++;
|
|
|
+ } else if (zt.getStatus() == 5.0){
|
|
|
+ zctjts++;
|
|
|
+ } else if (zt.getStatus() == 6.0){
|
|
|
+ tqtjts++;
|
|
|
+ } else if (zt.getStatus() == 7.0) {
|
|
|
+ tjwhts++;
|
|
|
+ } else if (zt.getStatus() == 8.0) {
|
|
|
+ xgtjts++;
|
|
|
+ } else if (zt.getStatus() == 9.0) {
|
|
|
+ jhtjts++;
|
|
|
+ } else if (zt.getStatus() == 10.0) {
|
|
|
+ qdztts++;
|
|
|
+ } else if (zt.getStatus() == 11.0) {
|
|
|
+ jlztts++;
|
|
|
+ } else if (zt.getStatus() == -1.0) {
|
|
|
+ txzdts++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ powerVo.setZcyxts(zcyxts);
|
|
|
+ powerVo.setXgyxts(xgyxts);
|
|
|
+ powerVo.setDjztts(djztts);
|
|
|
+ powerVo.setGztjts(gztjts);
|
|
|
+ powerVo.setDwgzts(dwgzts);
|
|
|
+ powerVo.setZctjts(zctjts);
|
|
|
+ powerVo.setTqtjts(tqtjts);
|
|
|
+ powerVo.setTjwhts(tjwhts);
|
|
|
+ powerVo.setXgtjts(xgtjts);
|
|
|
+ powerVo.setJhtjts(jhtjts);
|
|
|
+ powerVo.setQdztts(qdztts);
|
|
|
+ powerVo.setJlztts(jlztts);
|
|
|
+ powerVo.setTxzdts(txzdts);
|
|
|
+ powerVo.setWtlist(volist);
|
|
|
+ powerVos.add(powerVo);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+ SortUtils.sort(powerVos, "orderNum", SortUtils.ASC);
|
|
|
+ Map<String, Object> dataMap = new HashMap<>();
|
|
|
+ dataMap.put("jrts", jrts.doubleValue());
|
|
|
+ dataMap.put("powerVos", powerVos);
|
|
|
+ return dataMap;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|