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 resultList = new ArrayList<>(); List fdlList = new ArrayList<>(); List wpls = CacheContext.wpls; List lines = CacheContext.lines; Map> wppromap = CacheContext.wppromap; Map> prolinemap = CacheContext.prolinemap; List meterpoints = CacheContext.meterpoints; Map> wppointmap = CacheContext.wppointmap; Map> linepointmap = CacheContext.linepointmap; Map> 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 linemap = linepointmap.get(line.getId()); //线路发电量 Optional 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 wpmap = wppointmap.get(wp.getId()); AtomicReference fcrfdl = new AtomicReference<>((double) 0); AtomicReference fcyfdl = new AtomicReference<>((double) 0); AtomicReference fcnfdl = new AtomicReference<>((double) 0); AtomicReference fcrswdl = new AtomicReference<>((double) 0); AtomicReference fcyswdl = new AtomicReference<>((double) 0); AtomicReference fcnswdl = new AtomicReference<>((double) 0); AtomicReference fcrgwdl = new AtomicReference<>((double) 0); AtomicReference fcygwdl = new AtomicReference<>((double) 0); AtomicReference fcngwdl = new AtomicReference<>((double) 0); AtomicReference fcrcydl = new AtomicReference<>((double) 0); AtomicReference fcycydl = new AtomicReference<>((double) 0); AtomicReference fcncydl = new AtomicReference<>((double) 0); wppromap.get(wp.getId()).stream().forEach(project -> { Map projectmap = propointmap.get(project.getId()); AtomicReference qcrfdl = new AtomicReference<>(0.0); AtomicReference qcyfdl = new AtomicReference<>(0.0); AtomicReference qcnfdl = new AtomicReference<>(0.0); AtomicReference qcrswdl = new AtomicReference<>(0.0); AtomicReference qcyswdl = new AtomicReference<>(0.0); AtomicReference qcnswdl = new AtomicReference<>(0.0); AtomicReference qcrgwdl = new AtomicReference<>(0.0); AtomicReference qcygwdl = new AtomicReference<>(0.0); AtomicReference qcngwdl = new AtomicReference<>(0.0); AtomicReference qcrcydl = new AtomicReference<>(0.0); AtomicReference qcycydl = new AtomicReference<>(0.0); AtomicReference qcncydl = new AtomicReference<>(0.0); prolinemap.get(project.getId()).stream().forEach(line -> { Map linemap = linepointmap.get(line.getId()); //线路发电量 Optional 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 swdlOptional= null; Optional 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 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 meterpoints = CacheContext.meterpoints; List 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 resultList = new ArrayList<>(); QueryWrapper 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 resultLsit = new ArrayList<>(); Map meterpointMap = CacheContext.meterpointMap; List 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 qw = new QueryWrapper<>(); qw.eq("recorddate",date1); List 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 resultList,Date currentDate,Map> 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 resultList,Date currentDate,Map 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 getPercentage(List fdlList,Meterpoint swdlMeterpoint,List resultList,Map> linepointmap,Line line){ Map percentageMap = new HashMap<>(); String[] swdlLines = swdlMeterpoint.getLineid().split("\\|"); AtomicReference xldl = new AtomicReference<>((double) 0); AtomicReference xlzdl = new AtomicReference<>((double) 0); AtomicReference xlydl = new AtomicReference<>((double) 0); AtomicReference xlzydl = new AtomicReference<>((double) 0); AtomicReference xlndl = new AtomicReference<>((double) 0); AtomicReference xlzndl = new AtomicReference<>((double) 0); Arrays.stream(swdlLines).forEach(l->{ Optional 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 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 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 fdlList,Date tomorrow,List resultList, Map> linepointmap, Date samedayZero, Date monthFirstZero, Date yearFirstZero, Date currentDate, AtomicReference qcrswdl, AtomicReference qcyswdl, AtomicReference qcnswdl, Line line, Map linemap, Optional optionalMeterpoint,String rcode,String ycode,String ncode) { if (optionalMeterpoint.isPresent()){ Meterpoint swdlMeterpoint = optionalMeterpoint.get(); //获取电量百分比,算其他电量 Map 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 fdlList, Date tomorrow,Date samedayZero, Date monthFirstZero, Date yearFirstZero, Date currentDate, Map linemap, Optional 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 resultList, Date tomorrow,Date samedayZero, Date monthFirstZero, Date yearFirstZero, Date currentDate, AtomicReference qcrfdl, AtomicReference qcyfdl, AtomicReference qcnfdl, Map linemap, Optional 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 resultList, Date currentDate, Map wpmap, AtomicReference fcrswdl, AtomicReference fcyswdl, AtomicReference 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 resultList, Map> wppointmap, Date currentDate, Double gsrfdl, Double gsyfdl, Double gsnfdl, AtomicReference fdrfdl, AtomicReference fdyfdl, AtomicReference fdnfdl, AtomicReference gfrfdl, AtomicReference gfyfdl, AtomicReference 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 resultList, Date currentDate, AtomicReference fcrswdl, AtomicReference fcyswdl, AtomicReference fcnswdl, Map projectmap, AtomicReference qcrswdl, AtomicReference qcyswdl, AtomicReference 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 resultList, Date currentDate, AtomicReference fcrfdl, AtomicReference fcyfdl, AtomicReference fcnfdl, Map projectmap, AtomicReference qcrfdl, AtomicReference qcyfdl, AtomicReference 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); } }