123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- package com.gyee.generation.service;
- import com.gyee.common.contant.Contant;
- import com.gyee.common.model.PointData;
- import com.gyee.common.util.DateUtils;
- import com.gyee.generation.init.CacheContext;
- import com.gyee.generation.model.auto.*;
- import com.gyee.generation.util.realtimesource.IEdosUtil;
- import org.springframework.stereotype.Service;
- import javax.annotation.Resource;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.List;
- import java.util.Map;
- import java.util.concurrent.atomic.AtomicReference;
- /**
- * @ClassName : RealtimeSpeedPowerService
- * @Author : xieshengjie
- * @Date: 2022/4/24 8:49
- * @Description : 场站实时风速,实时功率
- */
- @Service
- public class RealtimeSpeedPowerService {
- @Resource
- private IEdosUtil edosUtil;
- private List<Windpowerstation> wpls;
- private Map<String, List<Project>> wppromap;
- private Map<String, List<Line>> prolinemap;
- private Map<String, List<Inverter>> linewtmap;
- private Date currentDate;
- private Map<String, Map<String, Windpowerstationpointnew>> wppointmap;
- private Map<String, Map<String, Windpowerstationpointnew>> linepointmap;
- private Map<String, Map<String, Windpowerstationpointnew>> propointmap;
- private Map<String, Map<String, Photovoltaictestingpointnew>> wtpAimap;
- private void init(){
- wpls = CacheContext.wpls;
- wppromap = CacheContext.wppromap;
- prolinemap = CacheContext.prolinemap;
- linewtmap = CacheContext.linewtmap;
- wppointmap = CacheContext.wppointmap;
- linepointmap = CacheContext.linepointmap;
- propointmap = CacheContext.propointmap;
- wtpAimap = CacheContext.wtpAimap;
- currentDate = DateUtils.getCurrentDate();
- }
- /**
- * 计算场站实时风速功率
- */
- public void calculateRealtimeSpeedPower() throws Exception {
- init();
- List<PointData> resultList = new ArrayList<>();
- wpls.stream().forEach(wp->{
- AtomicReference<Double> wpPower = new AtomicReference<>(0.0);
- Map<String, Windpowerstationpointnew> wppointnewMap = wppointmap.get(wp.getId());
- Windpowerstationpointnew wppowerpointnew = wppointnewMap.get(Contant.SSZGL);
- AtomicReference<Double> wpcount = new AtomicReference<>(0.0);
- wppromap.get(wp.getId()).stream().forEach(project -> {
- AtomicReference<Double> projectPower = new AtomicReference<>(0.0);
- Map<String, Windpowerstationpointnew> propointnewMap = propointmap.get(project.getId());
- Windpowerstationpointnew propowerpointnew = propointnewMap.get(Contant.SSZGL);
- AtomicReference<Double> procount = new AtomicReference<>(0.0);
- prolinemap.get(project.getId()).stream().forEach(line->{
- AtomicReference<Double> linePower = new AtomicReference<>(0.0);
- Map<String, Windpowerstationpointnew> linepointnewMap = linepointmap.get(line.getId());
- Windpowerstationpointnew linepowerpointnew = linepointnewMap.get(Contant.SSZGL);
- AtomicReference<Double> count = new AtomicReference<>(0.0);
- if ( linewtmap.containsKey(line.getId())) {
- List<Inverter> inverters = linewtmap.get(line.getId());
- inverters.stream().forEach(wt -> {
- Map<String, Photovoltaictestingpointnew> windturbinetestingpointnewMap = wtpAimap.get(wt.getId());
- Photovoltaictestingpointnew powerpoint = windturbinetestingpointnewMap.get(Contant.AIG013);
- Photovoltaictestingpointnew ztpoint = windturbinetestingpointnewMap.get(Contant.ZTMX);
- Boolean isOffline = false;
- try {
- Double ztvalue = edosUtil.getRealData(ztpoint).getPointValueInDouble();
- if (ztvalue == 12.0) {
- isOffline = true;
- }
- if (!isOffline) {
- count.getAndSet(count.get() + 1);
- procount.getAndSet(procount.get() + 1);
- wpcount.getAndSet(wpcount.get() + 1);
- Double wtpower = 0.0;
- try {
- wtpower = edosUtil.getRealData(powerpoint).getPointValueInDouble();
- Double finalWtpower = wtpower;
- linePower.updateAndGet(v -> new Double((double) (v + finalWtpower)));
- projectPower.updateAndGet(v -> new Double((double) (v + finalWtpower)));
- wpPower.updateAndGet(v -> new Double((double) (v + finalWtpower)));
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- });
- }else {
- }
- PointData linepowerPointData = createWpPointData(linepowerpointnew, linePower.get());
- resultList.add(linepowerPointData);
- });
- PointData projectpowerPointData = createWpPointData(propowerpointnew, projectPower.get());
- resultList.add(projectpowerPointData);
- });
- PointData wppowerPointData = createWpPointData(wppowerpointnew, wpPower.get());
- resultList.add(wppowerPointData);
- });
- edosUtil.sendMultiPoint(resultList);
- }
- private PointData createWpPointData(Windpowerstationpointnew linepointnew, double linespeed) {
- PointData pointData = new PointData();
- pointData.setEdnaId(linepointnew.getCode());
- pointData.setPointTime(currentDate.getTime());
- pointData.setPointName(linepointnew.getName());
- pointData.setPointValue(String.valueOf(linespeed));
- pointData.setPointValueInDouble(linespeed);
- return pointData;
- }
- }
|