123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690 |
- package com.gyee.generation.service;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- 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.DoubleUtils;
- import com.gyee.generation.init.CacheContext;
- import com.gyee.generation.model.auto.*;
- import com.gyee.generation.service.auto.IMeterpointvalueService;
- import com.gyee.generation.util.realtimesource.IEdosUtil;
- import org.apache.commons.logging.Log;
- import org.apache.commons.logging.LogFactory;
- import org.springframework.stereotype.Service;
- import javax.annotation.Resource;
- import java.util.*;
- import java.util.concurrent.atomic.AtomicReference;
- /**
- * @ClassName : GenerationService
- * @Author : xieshengjie
- * @Date: 2022/2/28 15:23
- * @Description :
- */
- @Service
- public class GenerationService {
- private Log log = LogFactory.getLog(GenerationService.class);
- @Resource
- private IEdosUtil edosUtil;
- @Resource
- private IMeterpointvalueService meterpointvalueService;
- /**
- * 保存电计量电量,场用电量,购网电量,上网电量
- * @throws Exception
- */
- public void saveGenerationDatas() throws Exception {
- List<PointData> resultList = new ArrayList<>();
- List<PointData> fdlList = new ArrayList<>();
- List<Windpowerstation> wpls = CacheContext.wpls;
- List<Line> lines = CacheContext.lines;
- Map<String, List<Project>> wppromap = CacheContext.wppromap;
- Map<String, List<Line>> prolinemap = CacheContext.prolinemap;
- List<Meterpoint> meterpoints = CacheContext.meterpoints;
- Map<String, Map<String, Windpowerstationpointnew>> wppointmap = CacheContext.wppointmap;
- Map<String, Map<String, Windpowerstationpointnew>> linepointmap = CacheContext.linepointmap;
- Map<String, Map<String, Windpowerstationpointnew>> propointmap = CacheContext.propointmap;
- Date samedayZero = DateUtils.getSamedayZero();
- Date monthFirstZero = DateUtils.getMonthFirstZero();
- Date yearFirstZero = DateUtils.getYearFirstZero();
- Date currentDate = DateUtils.getCurrentDate();
- Date tomorrow = DateUtils.addDays(samedayZero,1);
- lines.stream().forEach(line->{
- Map<String, Windpowerstationpointnew> linemap = linepointmap.get(line.getId());
- //线路发电量
- Optional<Meterpoint> fdlOptional = meterpoints.stream().filter(me -> me.getLineid().equals(line.getId()) && me.getUniformcode().equals("ZXYG") && me.getMetertype().equals("进线") && me.getMetersort().equals("主")).findFirst();
- computeFdl(fdlList, tomorrow,samedayZero, monthFirstZero, yearFirstZero, currentDate, linemap, fdlOptional);
- });
- wpls.stream().forEach(wp->{
- Map<String, Windpowerstationpointnew> wpmap = wppointmap.get(wp.getId());
- AtomicReference<Double> fcrfdl = new AtomicReference<>((double) 0);
- AtomicReference<Double> fcyfdl = new AtomicReference<>((double) 0);
- AtomicReference<Double> fcnfdl = new AtomicReference<>((double) 0);
- AtomicReference<Double> fcrswdl = new AtomicReference<>((double) 0);
- AtomicReference<Double> fcyswdl = new AtomicReference<>((double) 0);
- AtomicReference<Double> fcnswdl = new AtomicReference<>((double) 0);
- AtomicReference<Double> fcrgwdl = new AtomicReference<>((double) 0);
- AtomicReference<Double> fcygwdl = new AtomicReference<>((double) 0);
- AtomicReference<Double> fcngwdl = new AtomicReference<>((double) 0);
- AtomicReference<Double> fcrcydl = new AtomicReference<>((double) 0);
- AtomicReference<Double> fcycydl = new AtomicReference<>((double) 0);
- AtomicReference<Double> fcncydl = new AtomicReference<>((double) 0);
- wppromap.get(wp.getId()).stream().forEach(project -> {
- Map<String, Windpowerstationpointnew> projectmap = propointmap.get(project.getId());
- AtomicReference<Double> qcrfdl = new AtomicReference<>(0.0);
- AtomicReference<Double> qcyfdl = new AtomicReference<>(0.0);
- AtomicReference<Double> qcnfdl = new AtomicReference<>(0.0);
- AtomicReference<Double> qcrswdl = new AtomicReference<>(0.0);
- AtomicReference<Double> qcyswdl = new AtomicReference<>(0.0);
- AtomicReference<Double> qcnswdl = new AtomicReference<>(0.0);
- AtomicReference<Double> qcrgwdl = new AtomicReference<>(0.0);
- AtomicReference<Double> qcygwdl = new AtomicReference<>(0.0);
- AtomicReference<Double> qcngwdl = new AtomicReference<>(0.0);
- AtomicReference<Double> qcrcydl = new AtomicReference<>(0.0);
- AtomicReference<Double> qcycydl = new AtomicReference<>(0.0);
- AtomicReference<Double> qcncydl = new AtomicReference<>(0.0);
- prolinemap.get(project.getId()).stream().forEach(line -> {
- Map<String, Windpowerstationpointnew> linemap = linepointmap.get(line.getId());
- //线路发电量
- Optional<Meterpoint> fdlOptional = meterpoints.stream().filter(me -> me.getLineid().equals(line.getId()) && me.getUniformcode().equals("ZXYG") && me.getMetertype().equals("进线") && me.getMetersort().equals("主")).findFirst();
- lineFdl(resultList,tomorrow, samedayZero, monthFirstZero, yearFirstZero, currentDate, qcrfdl, qcyfdl, qcnfdl, linemap, fdlOptional);
- log.info(line.getName()+"电计量电量计算完毕!");
- //线路上网电量
- Optional<Meterpoint> swdlOptional= null;
- Optional<Meterpoint> gwdlOptional=null;
- if (wp.getId().equals("GJY_FDC")){
- swdlOptional = meterpoints.stream().filter(me -> me.getUniformcode().equals("ZXYG") && me.getMetertype().equals("主变高压侧") && me.getMetersort().equals("主") && me.getLineid().contains(line.getId())).findFirst();
- gwdlOptional = meterpoints.stream().filter(me -> me.getUniformcode().equals("FXYG") && me.getMetertype().equals("主变高压侧") && me.getMetersort().equals("主") && me.getLineid().contains(line.getId())).findFirst();
- }else{
- swdlOptional = meterpoints.stream().filter(me -> me.getUniformcode().equals("ZXYG") && me.getMetertype().equals("出线") && me.getMetersort().equals("主") && me.getLineid().contains(line.getId())).findFirst();
- gwdlOptional = meterpoints.stream().filter(me -> me.getUniformcode().equals("FXYG") && me.getMetertype().equals("出线") && me.getMetersort().equals("主") && me.getLineid().contains(line.getId())).findFirst();
- }
- lineOrtherdl(fdlList,tomorrow,resultList, linepointmap, samedayZero, monthFirstZero, yearFirstZero, currentDate, qcrswdl, qcyswdl, qcnswdl, line, linemap, swdlOptional,Contant.SWDLB,Contant.SWDLY,Contant.SWDLN);
- log.info(line.getName()+"上网电量计算完毕!");
- //线路购网电量
- lineOrtherdl(fdlList,tomorrow,resultList, linepointmap, samedayZero, monthFirstZero, yearFirstZero, currentDate, qcrgwdl, qcygwdl, qcngwdl, line, linemap, gwdlOptional,Contant.GWGWB,Contant.GWGWY,Contant.GWGWN);
- log.info(line.getName()+"工网购网电量计算完毕!");
- //厂用电量
- Optional<Meterpoint> zybOptional = meterpoints.stream().filter(me-> me.getUniformcode().equals("ZXYG") && me.getMetertype().equals("站用变") && me.getMetersort().equals("主") && me.getLineid().contains(line.getId())).findFirst();
- lineOrtherdl(fdlList,tomorrow,resultList, linepointmap, samedayZero, monthFirstZero, yearFirstZero, currentDate, qcrcydl, qcycydl, qcncydl, line, linemap, zybOptional,Contant.CYDLB,Contant.CYDLY,Contant.CYDLN);
- log.info(line.getName()+"场用电量计算完毕!");
- //农网购网电量
- setZero(resultList,currentDate,linemap,Contant.NWGWB,Contant.NWGWY,Contant.NWGWN);
- log.info(line.getName()+"农网购网电量计算完毕!");
- });
- //期次发电量
- projectFdl(resultList, currentDate, fcrfdl, fcyfdl, fcnfdl, projectmap, qcrfdl, qcyfdl, qcnfdl);
- log.info(project.getName()+"发电量计算完毕!");
- //期次上网电量
- projectOrther(resultList, currentDate, fcrswdl, fcyswdl, fcnswdl, projectmap, qcrswdl, qcyswdl, qcnswdl,Contant.SWDLB,Contant.SWDLY,Contant.SWDLN);
- log.info(project.getName()+"上网电量计算完毕!");
- //期次购网电量
- projectOrther(resultList, currentDate, fcrgwdl, fcygwdl, fcngwdl, projectmap, qcrgwdl, qcygwdl, qcngwdl,Contant.GWGWB,Contant.GWGWY,Contant.GWGWN);
- log.info(project.getName()+"工网购网电量计算完毕!");
- //期次厂用电量
- projectOrther(resultList, currentDate, fcrcydl, fcycydl, fcncydl, projectmap, qcrcydl, qcycydl, qcncydl,Contant.CYDLB,Contant.CYDLY,Contant.CYDLN);
- log.info(project.getName()+"场用电量计算完毕!");
- //期次农网电量
- setZero(resultList,currentDate,projectmap,Contant.NWGWB,Contant.NWGWY,Contant.NWGWN);
- log.info(project.getName()+"农网电量计算完毕!");
- });
- //场站发电量
- windpowerFdl(resultList, currentDate, wpmap, fcrfdl, fcyfdl, fcnfdl,Contant.RFDLB,Contant.YFDLB,Contant.NFDLB);
- log.info(wp.getName()+"发电量计算完毕!");
- //场站上网电量
- windpowerFdl(resultList, currentDate, wpmap, fcrswdl, fcyswdl, fcnswdl,Contant.SWDLB,Contant.SWDLY,Contant.SWDLN);
- log.info(wp.getName()+"上网电量计算完毕!");
- //场站购网电量
- windpowerFdl(resultList, currentDate, wpmap, fcrgwdl, fcygwdl, fcngwdl,Contant.GWGWB,Contant.GWGWY,Contant.GWGWN);
- log.info(wp.getName()+"工网购网电量计算完毕!");
- //场站场用电量
- windpowerFdl(resultList, currentDate, wpmap, fcrcydl, fcycydl, fcncydl,Contant.CYDLB,Contant.CYDLY,Contant.CYDLN);
- log.info(wp.getName()+"场用电量计算完毕!");
- //场站农网电量
- setZero(resultList,currentDate,wpmap,Contant.NWGWB,Contant.NWGWY,Contant.NWGWN);
- log.info(wp.getName()+"农网购网电量计算完毕!");
- });
- edosUtil.sendMultiPoint(resultList);
- }
- /**
- * 存储meterpointvalue表
- * 实时+0点算前一天
- */
- public void saveMeterpointValueRealtime(String beginDate,String endDate){
- List<Meterpoint> meterpoints = CacheContext.meterpoints;
- List<String> days = DateUtils.getDays(beginDate, endDate);
- days.stream().forEach(day->{
- Date samedayZero = DateUtils.getSamedayZero(day);
- Date monthFirstZero = DateUtils.getMonthFirstZero(day);
- Date yearFirstZero = DateUtils.getYearFirstZero(day);
- Date date = DateUtils.addDays(samedayZero, 1);
- List<Meterpointvalue> resultList = new ArrayList<>();
- QueryWrapper<Meterpointvalue> qw = new QueryWrapper();
- qw.eq("recorddate",date);
- meterpointvalueService.remove(qw);
- meterpoints.stream().forEach(meterpoint -> {
- String meterid = meterpoint.getId();
- Double magnification = meterpoint.getMagnification();
- Double xs = meterpoint.getXs();
- Meterpointvalue meterpointvalue = new Meterpointvalue();
- meterpointvalue.setRecorddate(date);
- meterpointvalue.setMeterid(meterpoint.getId());
- Double real = 0.0;
- Double sameday = 0.0;
- Double month = 0.0;
- Double year = 0.0;
- try {
- real = edosUtil.getSectionData(meterid,date.getTime()).getPointValueInDouble();
- sameday = edosUtil.getSectionData(meterid,samedayZero.getTime()).getPointValueInDouble();
- month = edosUtil.getSectionData(meterid,monthFirstZero.getTime()).getPointValueInDouble();
- year = edosUtil.getSectionData(meterid,yearFirstZero.getTime()).getPointValueInDouble();
- } catch (Exception e) {
- e.printStackTrace();
- }
- meterpointvalue.setYear(DoubleUtils.keepPrecision(year/xs,2));
- meterpointvalue.setYear4(DoubleUtils.keepPrecision(year/xs,4));
- meterpointvalue.setMonth(DoubleUtils.keepPrecision(month/xs,2));
- meterpointvalue.setMonth4(DoubleUtils.keepPrecision(month/xs,4));
- meterpointvalue.setDay(DoubleUtils.keepPrecision(sameday/xs,2));
- meterpointvalue.setDay4(DoubleUtils.keepPrecision(sameday/xs,4));
- meterpointvalue.setNow(DoubleUtils.keepPrecision(real/xs,2));
- meterpointvalue.setNow4(DoubleUtils.keepPrecision(real/xs,4));
- Double yearvalue = (real/xs - year/xs) * magnification;
- Double monthvalue = (real/xs - month/xs) * magnification;
- Double dayvalue = (real/xs - sameday/xs) * magnification;
- meterpointvalue.setYearvalue(yearvalue);
- meterpointvalue.setMonthvalue(monthvalue);
- meterpointvalue.setDayvalue(dayvalue);
- resultList.add(meterpointvalue);
- });
- meterpointvalueService.saveBatch(resultList);
- });
- }
- public void updateMeterpointValueHistory(String beginDate,String endDate){
- List<Meterpointvalue> resultLsit = new ArrayList<>();
- Map<String,Meterpoint> meterpointMap = CacheContext.meterpointMap;
- List<String> days = DateUtils.getDays(beginDate, endDate);
- days.stream().forEach(day->{
- Date date = DateUtils.parseDate(beginDate);
- Date date1 = DateUtils.addDays(date, 1);
- Date date2= DateUtils.addDays(date1, 1);
- QueryWrapper<Meterpointvalue> qw = new QueryWrapper<>();
- qw.eq("recorddate",date1);
- List<Meterpointvalue> meterpointvalues = meterpointvalueService.list(qw);
- meterpointvalues.stream().forEach(meterpointvalue -> {
- Meterpoint meterpoint = meterpointMap.get(meterpointvalue.getMeterid());
- Double magnification = meterpoint.getMagnification();
- Double xs = meterpoint.getXs();
- Double real = 0.0;
- try {
- real = edosUtil.getSectionData(meterpointvalue.getMeterid(),date1.getTime()).getPointValueInDouble();
- } catch (Exception e) {
- e.printStackTrace();
- }
- Double yearvalue = (real/xs - meterpointvalue.getYear4()) * magnification;
- Double monthvalue = (real/xs - meterpointvalue.getMonth4()) * magnification;
- Double dayvalue = (real/xs - meterpointvalue.getDay4()) * magnification;
- meterpointvalue.setNow(DoubleUtils.keepPrecision(real,2));
- meterpointvalue.setNow4(DoubleUtils.keepPrecision(real,4));
- meterpointvalue.setYearvalue(yearvalue);
- meterpointvalue.setMonthvalue(monthvalue);
- meterpointvalue.setDayvalue(dayvalue);
- resultLsit.add(meterpointvalue);
- });
- meterpointvalueService.saveOrUpdateBatch(resultLsit);
- });
- }
- private void setGsZero(List<PointData> resultList,Date currentDate,Map<String, Map<String, Windpowerstationpointnew>> linemap,String foreignkeyid,String rcode,String ycode,String ncode) {
- //线路日发电量
- PointData r = new PointData();
- r.setPointTime(currentDate.getTime());
- r.setPointValue("0");
- r.setPointValueInDouble(0);
- r.setEdnaId(linemap.get(foreignkeyid).get(rcode).getCode());
- r.setPointName(linemap.get(foreignkeyid).get(rcode).getName());
- resultList.add(r);
- //线路月发电量
- PointData y = new PointData();
- y.setPointTime(currentDate.getTime());
- y.setPointValue("0");
- y.setPointValueInDouble(0);
- y.setEdnaId(linemap.get(foreignkeyid).get(ycode).getCode());
- y.setPointName(linemap.get(foreignkeyid).get(ycode).getName());
- resultList.add(y);
- //线路年发电量
- PointData n = new PointData();
- n.setPointTime(currentDate.getTime());
- n.setPointValue("0");
- n.setPointValueInDouble(0);
- n.setEdnaId(linemap.get(foreignkeyid).get(ncode).getCode());
- n.setPointName(linemap.get(foreignkeyid).get(ncode).getName());
- resultList.add(n);
- }
- private void setZero(List<PointData> resultList,Date currentDate,Map<String, Windpowerstationpointnew> linemap,String rcode,String ycode,String ncode) {
- //线路日发电量
- PointData r = new PointData();
- r.setPointTime(currentDate.getTime());
- r.setPointValue("0");
- r.setPointValueInDouble(0);
- r.setEdnaId(linemap.get(rcode).getCode());
- r.setPointName(linemap.get(rcode).getName());
- resultList.add(r);
- //线路月发电量
- PointData y = new PointData();
- y.setPointTime(currentDate.getTime());
- y.setPointValue("0");
- y.setPointValueInDouble(0);
- y.setEdnaId(linemap.get(ycode).getCode());
- y.setPointName(linemap.get(ycode).getName());
- resultList.add(y);
- //线路年发电量
- PointData n = new PointData();
- n.setPointTime(currentDate.getTime());
- n.setPointValue("0");
- n.setPointValueInDouble(0);
- n.setEdnaId(linemap.get(ncode).getCode());
- n.setPointName(linemap.get(ncode).getName());
- resultList.add(n);
- }
- private Map<String,Double> getPercentage(List<PointData> fdlList,Meterpoint swdlMeterpoint,List<PointData> resultList,Map<String, Map<String, Windpowerstationpointnew>> linepointmap,Line line){
- Map<String,Double> percentageMap = new HashMap<>();
- String[] swdlLines = swdlMeterpoint.getLineid().split("\\|");
- AtomicReference<Double> xldl = new AtomicReference<>((double) 0);
- AtomicReference<Double> xlzdl = new AtomicReference<>((double) 0);
- AtomicReference<Double> xlydl = new AtomicReference<>((double) 0);
- AtomicReference<Double> xlzydl = new AtomicReference<>((double) 0);
- AtomicReference<Double> xlndl = new AtomicReference<>((double) 0);
- AtomicReference<Double> xlzndl = new AtomicReference<>((double) 0);
- Arrays.stream(swdlLines).forEach(l->{
- Optional<PointData> xldlfirst = fdlList.stream().filter(res -> res.getEdnaId().equals(linepointmap.get(l).get(Contant.RFDLB).getCode())).findFirst();
- if (xldlfirst.isPresent()){
- if (l.equals(line.getId())){
- xldl.set(xldlfirst.get().getPointValueInDouble());
- xlzdl.updateAndGet(v -> new Double((double) (v + xldlfirst.get().getPointValueInDouble())));
- }else{
- xlzdl.updateAndGet(v -> new Double((double) (v + xldlfirst.get().getPointValueInDouble())));
- }
- }
- Optional<PointData> xlydlfirst = fdlList.stream().filter(res -> res.getEdnaId().equals(linepointmap.get(l).get(Contant.YFDLB).getCode())).findFirst();
- if (xlydlfirst.isPresent()){
- if (l.equals(line.getId())){
- xlydl.set(xlydlfirst.get().getPointValueInDouble());
- xlzydl.updateAndGet(v -> new Double((double) (v + xlydlfirst.get().getPointValueInDouble())));
- }else{
- xlzydl.updateAndGet(v -> new Double((double) (v + xlydlfirst.get().getPointValueInDouble())));
- }
- }
- Optional<PointData> xlndlfirst = fdlList.stream().filter(res -> res.getEdnaId().equals(linepointmap.get(l).get(Contant.NFDLB).getCode())).findFirst();
- if (xlndlfirst.isPresent()){
- if (l.equals(line.getId())){
- xlndl.set(xlndlfirst.get().getPointValueInDouble());
- xlzndl.updateAndGet(v -> new Double((double) (v + xlndlfirst.get().getPointValueInDouble())));
- }else{
- xlzndl.updateAndGet(v -> new Double((double) (v + xlndlfirst.get().getPointValueInDouble())));
- }
- }
- });
- //电量百分比
- double percentage = xlzdl.get() != 0 ? xldl.get() / xlzdl.get() : 0;
- percentageMap.put("percentage",percentage);
- double ypercentage = xlzydl.get() != 0 ? xlydl.get() / xlzydl.get() : 0;
- percentageMap.put("ypercentage",ypercentage);
- double npercentage = xlzndl.get() != 0 ? xlndl.get() / xlzndl.get() : 0;
- percentageMap.put("npercentage",npercentage);
- return percentageMap;
- }
- private void lineOrtherdl(List<PointData> fdlList,Date tomorrow,List<PointData> resultList, Map<String, Map<String, Windpowerstationpointnew>> linepointmap, Date samedayZero, Date monthFirstZero, Date yearFirstZero, Date currentDate, AtomicReference<Double> qcrswdl, AtomicReference<Double> qcyswdl, AtomicReference<Double> qcnswdl, Line line, Map<String, Windpowerstationpointnew> linemap, Optional<Meterpoint> optionalMeterpoint,String rcode,String ycode,String ncode) {
- if (optionalMeterpoint.isPresent()){
- Meterpoint swdlMeterpoint = optionalMeterpoint.get();
- //获取电量百分比,算其他电量
- Map<String, Double> percentageMap = getPercentage(fdlList,swdlMeterpoint, resultList, linepointmap, line);
- String pointid = swdlMeterpoint.getId();
- Double real = 0.0;
- Double sameday = 0.0;
- Double month = 0.0;
- Double year = 0.0;
- try {
- real = edosUtil.getSectionData(pointid,tomorrow.getTime()).getPointValueInDouble();
- sameday = edosUtil.getSectionData(pointid,samedayZero.getTime()).getPointValueInDouble();
- month = edosUtil.getSectionData(pointid,monthFirstZero.getTime()).getPointValueInDouble();
- year = edosUtil.getSectionData(pointid,yearFirstZero.getTime()).getPointValueInDouble();
- Double magnification = optionalMeterpoint.get().getMagnification();
- Double xs = optionalMeterpoint.get().getXs();
- double xlswdl = (real - sameday) * magnification / xs * percentageMap.get("percentage");
- qcrswdl.updateAndGet(v -> new Double((double) (v + xlswdl)));
- //线路上网电量
- PointData r = new PointData();
- r.setPointTime(currentDate.getTime());
- r.setPointValue(String.valueOf(xlswdl));
- r.setPointValueInDouble(xlswdl);
- r.setEdnaId(linemap.get(rcode).getCode());
- r.setPointName(linemap.get(rcode).getName());
- resultList.add(r);
- //线路月上网发电量
- double xlyswdl = (real - month) * magnification / xs * percentageMap.get("ypercentage");
- qcyswdl.updateAndGet(v -> new Double((double) (v + xlyswdl)));
- PointData y = new PointData();
- y.setPointTime(currentDate.getTime());
- y.setPointValue(String.valueOf(xlyswdl));
- y.setPointValueInDouble(xlyswdl);
- y.setEdnaId(linemap.get(ycode).getCode());
- y.setPointName(linemap.get(ycode).getName());
- resultList.add(y);
- //线路年上网发电量
- double xlnswfdl = (real - year) * magnification / xs * percentageMap.get("npercentage");
- qcnswdl.updateAndGet(v -> new Double((double) (v + xlnswfdl)));
- PointData n = new PointData();
- n.setPointTime(currentDate.getTime());
- n.setPointValue(String.valueOf(xlnswfdl));
- n.setPointValueInDouble(xlnswfdl);
- n.setEdnaId(linemap.get(ncode).getCode());
- n.setPointName(linemap.get(ncode).getName());
- resultList.add(n);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- private void computeFdl(List<PointData> fdlList, Date tomorrow,Date samedayZero, Date monthFirstZero, Date yearFirstZero, Date currentDate, Map<String, Windpowerstationpointnew> linemap, Optional<Meterpoint> fdlOptional) {
- if (fdlOptional.isPresent()){
- String pointid = fdlOptional.get().getId();
- Double real = 0.0;
- Double sameday = 0.0;
- Double month = 0.0;
- Double year = 0.0;
- try {
- real = edosUtil.getSectionData(pointid,tomorrow.getTime()).getPointValueInDouble();
- sameday = edosUtil.getSectionData(pointid,samedayZero.getTime()).getPointValueInDouble();
- month = edosUtil.getSectionData(pointid,monthFirstZero.getTime()).getPointValueInDouble();
- year = edosUtil.getSectionData(pointid,yearFirstZero.getTime()).getPointValueInDouble();
- Double magnification = fdlOptional.get().getMagnification();
- Double xs = fdlOptional.get().getXs();
- double xlrfdl = (real - sameday) * magnification / xs;
- //线路日发电量
- PointData r = new PointData();
- r.setPointTime(currentDate.getTime());
- r.setPointValue(String.valueOf(xlrfdl));
- r.setPointValueInDouble(xlrfdl);
- r.setEdnaId(linemap.get(Contant.RFDLB).getCode());
- r.setPointName(linemap.get(Contant.RFDLB).getName());
- fdlList.add(r);
- //线路月发电量
- double xlyfdl = (real - month) * magnification / xs;
- PointData y = new PointData();
- y.setPointTime(currentDate.getTime());
- y.setPointValue(String.valueOf(xlyfdl));
- y.setPointValueInDouble(xlyfdl);
- y.setEdnaId(linemap.get(Contant.YFDLB).getCode());
- y.setPointName(linemap.get(Contant.YFDLB).getName());
- fdlList.add(y);
- //线路年发电量
- double xlnfdl = (real - year) * magnification / xs;
- PointData n = new PointData();
- n.setPointTime(currentDate.getTime());
- n.setPointValue(String.valueOf(xlnfdl));
- n.setPointValueInDouble(xlnfdl);
- n.setEdnaId(linemap.get(Contant.NFDLB).getCode());
- n.setPointName(linemap.get(Contant.NFDLB).getName());
- fdlList.add(n);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- private void lineFdl(List<PointData> resultList, Date tomorrow,Date samedayZero, Date monthFirstZero, Date yearFirstZero, Date currentDate, AtomicReference<Double> qcrfdl, AtomicReference<Double> qcyfdl, AtomicReference<Double> qcnfdl, Map<String, Windpowerstationpointnew> linemap, Optional<Meterpoint> optionalMeterpoint) {
- if (optionalMeterpoint.isPresent()){
- String pointid = optionalMeterpoint.get().getId();
- Double real = 0.0;
- Double sameday = 0.0;
- Double month = 0.0;
- Double year = 0.0;
- try {
- real = edosUtil.getSectionData(pointid,tomorrow.getTime()).getPointValueInDouble();
- sameday = edosUtil.getSectionData(pointid,samedayZero.getTime()).getPointValueInDouble();
- month = edosUtil.getSectionData(pointid,monthFirstZero.getTime()).getPointValueInDouble();
- year = edosUtil.getSectionData(pointid,yearFirstZero.getTime()).getPointValueInDouble();
- Double magnification = optionalMeterpoint.get().getMagnification();
- Double xs = optionalMeterpoint.get().getXs();
- double xlrfdl = (real - sameday) * magnification / xs;
- qcrfdl.updateAndGet(v -> new Double((double) (v + xlrfdl)));
- //线路日发电量
- PointData r = new PointData();
- r.setPointTime(currentDate.getTime());
- r.setPointValue(String.valueOf(xlrfdl));
- r.setPointValueInDouble(xlrfdl);
- r.setEdnaId(linemap.get(Contant.RFDLB).getCode());
- r.setPointName(linemap.get(Contant.RFDLB).getName());
- resultList.add(r);
- //线路月发电量
- double xlyfdl = (real - month) * magnification / xs;
- qcyfdl.updateAndGet(v -> new Double((double) (v + xlyfdl)));
- PointData y = new PointData();
- y.setPointTime(currentDate.getTime());
- y.setPointValue(String.valueOf(xlyfdl));
- y.setPointValueInDouble(xlyfdl);
- y.setEdnaId(linemap.get(Contant.YFDLB).getCode());
- y.setPointName(linemap.get(Contant.YFDLB).getName());
- resultList.add(y);
- //线路年发电量
- double xlnfdl = (real - year) * magnification / xs;
- qcnfdl.updateAndGet(v -> new Double((double) (v + xlnfdl)));
- PointData n = new PointData();
- n.setPointTime(currentDate.getTime());
- n.setPointValue(String.valueOf(xlnfdl));
- n.setPointValueInDouble(xlnfdl);
- n.setEdnaId(linemap.get(Contant.NFDLB).getCode());
- n.setPointName(linemap.get(Contant.NFDLB).getName());
- resultList.add(n);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- private void windpowerFdl(List<PointData> resultList, Date currentDate, Map<String, Windpowerstationpointnew> wpmap, AtomicReference<Double> fcrswdl, AtomicReference<Double> fcyswdl, AtomicReference<Double> fcnswdl,String rcode,String ycode,String ncode) {
- //风场日上网发电量
- PointData r = new PointData();
- r.setPointTime(currentDate.getTime());
- r.setPointValue(String.valueOf(fcrswdl.get()));
- r.setPointValueInDouble(fcrswdl.get());
- r.setEdnaId(wpmap.get(rcode).getCode());
- r.setPointName(wpmap.get(rcode).getName());
- resultList.add(r);
- //风场月上网发电量
- PointData y = new PointData();
- y.setPointTime(currentDate.getTime());
- y.setPointValue(String.valueOf(fcyswdl.get()));
- y.setPointValueInDouble(fcyswdl.get());
- y.setEdnaId(wpmap.get(ycode).getCode());
- y.setPointName(wpmap.get(ycode).getName());
- resultList.add(y);
- //风场年上网发电量
- PointData n = new PointData();
- n.setPointTime(currentDate.getTime());
- n.setPointValue(String.valueOf(fcnswdl.get()));
- n.setPointValueInDouble(fcnswdl.get());
- n.setEdnaId(wpmap.get(ncode).getCode());
- n.setPointName(wpmap.get(ncode).getName());
- resultList.add(n);
- }
- private void qygsFdl(List<PointData> resultList, Map<String, Map<String, Windpowerstationpointnew>> wppointmap, Date currentDate, Double gsrfdl, Double gsyfdl, Double gsnfdl, AtomicReference<Double> fdrfdl, AtomicReference<Double> fdyfdl, AtomicReference<Double> fdnfdl, AtomicReference<Double> gfrfdl, AtomicReference<Double> gfyfdl, AtomicReference<Double> gfnfdl, String rcode, String ycode, String ncode) {
- if (StringUtils.isNotEmpty(wppointmap.get("-1"))){
- PointData fdr = new PointData();
- fdr.setPointTime(currentDate.getTime());
- fdr.setPointValue(String.valueOf(fdrfdl.get()));
- fdr.setPointValueInDouble(fdrfdl.get());
- fdr.setEdnaId(wppointmap.get("-1").get(rcode).getCode());
- fdr.setPointName(wppointmap.get("-1").get(rcode).getName());
- resultList.add(fdr);
- //风电月发电量
- PointData fdy = new PointData();
- fdy.setPointTime(currentDate.getTime());
- fdy.setPointValue(String.valueOf(fdyfdl.get()));
- fdy.setPointValueInDouble(fdyfdl.get());
- fdy.setEdnaId(wppointmap.get("-1").get(ycode).getCode());
- fdy.setPointName(wppointmap.get("-1").get(ycode).getName());
- resultList.add(fdy);
- //风电年发电量
- PointData fdn = new PointData();
- fdn.setPointTime(currentDate.getTime());
- fdn.setPointValue(String.valueOf(fdnfdl.get()));
- fdn.setPointValueInDouble(fdnfdl.get());
- fdn.setEdnaId(wppointmap.get("-1").get(ncode).getCode());
- fdn.setPointName(wppointmap.get("-1").get(ncode).getName());
- resultList.add(fdn);
- }
- if (StringUtils.isNotEmpty(wppointmap.get("-2"))){
- //光伏日发电量
- PointData gfr = new PointData();
- gfr.setPointTime(currentDate.getTime());
- gfr.setPointValue(String.valueOf(gfrfdl.get()));
- gfr.setPointValueInDouble(gfrfdl.get());
- gfr.setEdnaId(wppointmap.get("-2").get(rcode).getCode());
- gfr.setPointName(wppointmap.get("-2").get(rcode).getName());
- resultList.add(gfr);
- //光伏月发电量
- PointData gfy = new PointData();
- gfy.setPointTime(currentDate.getTime());
- gfy.setPointValue(String.valueOf(gfyfdl.get()));
- gfy.setPointValueInDouble(gfyfdl.get());
- gfy.setEdnaId(wppointmap.get("-2").get(ycode).getCode());
- gfy.setPointName(wppointmap.get("-2").get(ycode).getName());
- resultList.add(gfy);
- //光伏年发电量
- PointData gfn = new PointData();
- gfn.setPointTime(currentDate.getTime());
- gfn.setPointValue(String.valueOf(gfnfdl.get()));
- gfn.setPointValueInDouble(gfnfdl.get());
- gfn.setEdnaId(wppointmap.get("-2").get(ncode).getCode());
- gfn.setPointName(wppointmap.get("-2").get(ncode).getName());
- resultList.add(gfn);
- }
- //风场日发电量
- gsrfdl = fdrfdl.get()+gfrfdl.get();
- gsyfdl = fdyfdl.get()+gfyfdl.get();
- gsnfdl = fdnfdl.get()+gfnfdl.get();
- PointData r = new PointData();
- r.setPointTime(currentDate.getTime());
- r.setPointValue(String.valueOf(gsrfdl));
- r.setPointValueInDouble(gsrfdl);
- r.setEdnaId(wppointmap.get("0").get(rcode).getCode());
- r.setPointName(wppointmap.get("0").get(rcode).getName());
- resultList.add(r);
- //风场月发电量
- PointData y = new PointData();
- y.setPointTime(currentDate.getTime());
- y.setPointValue(String.valueOf(gsyfdl));
- y.setPointValueInDouble(gsyfdl);
- y.setEdnaId(wppointmap.get("0").get(ycode).getCode());
- y.setPointName(wppointmap.get("0").get(ycode).getName());
- resultList.add(y);
- //风场年发电量
- PointData n = new PointData();
- n.setPointTime(currentDate.getTime());
- n.setPointValue(String.valueOf(gsnfdl));
- n.setPointValueInDouble(gsnfdl);
- n.setEdnaId(wppointmap.get("0").get(ncode).getCode());
- n.setPointName(wppointmap.get("0").get(ncode).getName());
- resultList.add(n);
- }
- private void projectOrther(List<PointData> resultList, Date currentDate, AtomicReference<Double> fcrswdl, AtomicReference<Double> fcyswdl, AtomicReference<Double> fcnswdl, Map<String, Windpowerstationpointnew> projectmap, AtomicReference<Double> qcrswdl, AtomicReference<Double> qcyswdl, AtomicReference<Double> qcnswdl,String rcode,String ycode,String ncode) {
- //-------------------------------------------期次上网电量
- fcrswdl.updateAndGet(v -> new Double((double) (v + qcrswdl.get())));
- //期次日上网发电量
- PointData r = new PointData();
- r.setPointTime(currentDate.getTime());
- r.setPointValue(String.valueOf(qcrswdl.get()));
- r.setPointValueInDouble(qcrswdl.get());
- r.setEdnaId(projectmap.get(rcode).getCode());
- r.setPointName(projectmap.get(rcode).getName());
- resultList.add(r);
- fcyswdl.updateAndGet(v -> new Double((double) (v + qcyswdl.get())));
- //期次月上网发电量
- PointData y = new PointData();
- y.setPointTime(currentDate.getTime());
- y.setPointValue(String.valueOf(qcyswdl.get()));
- y.setPointValueInDouble(qcyswdl.get());
- y.setEdnaId(projectmap.get(ycode).getCode());
- y.setPointName(projectmap.get(ycode).getName());
- resultList.add(y);
- fcnswdl.updateAndGet(v -> new Double((double) (v + qcnswdl.get())));
- //期次年上网发电量
- PointData n = new PointData();
- n.setPointTime(currentDate.getTime());
- n.setPointValue(String.valueOf(qcnswdl.get()));
- n.setPointValueInDouble(qcnswdl.get());
- n.setEdnaId(projectmap.get(ncode).getCode());
- n.setPointName(projectmap.get(ncode).getName());
- resultList.add(n);
- }
- private void projectFdl(List<PointData> resultList, Date currentDate, AtomicReference<Double> fcrfdl, AtomicReference<Double> fcyfdl, AtomicReference<Double> fcnfdl, Map<String, Windpowerstationpointnew> projectmap, AtomicReference<Double> qcrfdl, AtomicReference<Double> qcyfdl, AtomicReference<Double> qcnfdl) {
- //-------------------------------------------期次发电量
- fcrfdl.updateAndGet(v -> new Double((double) (v + qcrfdl.get())));
- //期次日发电量
- PointData r = new PointData();
- r.setPointTime(currentDate.getTime());
- r.setPointValue(String.valueOf(qcrfdl.get()));
- r.setPointValueInDouble(qcrfdl.get());
- r.setEdnaId(projectmap.get(Contant.RFDLB).getCode());
- r.setPointName(projectmap.get(Contant.RFDLB).getName());
- resultList.add(r);
- fcyfdl.updateAndGet(v -> new Double((double) (v + qcyfdl.get())));
- //期次月发电量
- PointData y = new PointData();
- y.setPointTime(currentDate.getTime());
- y.setPointValue(String.valueOf(qcyfdl.get()));
- y.setPointValueInDouble(qcyfdl.get());
- y.setEdnaId(projectmap.get(Contant.YFDLB).getCode());
- y.setPointName(projectmap.get(Contant.YFDLB).getName());
- resultList.add(y);
- fcnfdl.updateAndGet(v -> new Double((double) (v + qcnfdl.get())));
- //期次年发电量
- PointData n = new PointData();
- n.setPointTime(currentDate.getTime());
- n.setPointValue(String.valueOf(qcnfdl.get()));
- n.setPointValueInDouble(qcnfdl.get());
- n.setEdnaId(projectmap.get(Contant.NFDLB).getCode());
- n.setPointName(projectmap.get(Contant.NFDLB).getName());
- resultList.add(n);
- }
- }
|