|
@@ -1,143 +1,150 @@
|
|
|
-//package com.gyee.generation.service;
|
|
|
-//
|
|
|
-//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.EdosUtil;
|
|
|
-//import com.gyee.generation.util.realtimesource.IEdosUtil;
|
|
|
-//import org.springframework.stereotype.Service;
|
|
|
-//
|
|
|
-//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 IEdosUtil edosUtil = new EdosUtil();
|
|
|
-//
|
|
|
-// public void saveGenerationDatas(){
|
|
|
-// List<Windpowerstation> wpls = CacheContext.wpls;
|
|
|
-// 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;
|
|
|
-// Date samedayZero = DateUtils.getSamedayZero();
|
|
|
-// Date monthFirstZero = DateUtils.getMonthFirstZero();
|
|
|
-// Date yearFirstZero = DateUtils.getYearFirstZero();
|
|
|
-// Date currentDate = DateUtils.getCurrentDate();
|
|
|
-// wpls.stream().forEach(wp->{
|
|
|
-// AtomicReference<Double> fcrfdl = new AtomicReference<>((double) 0);
|
|
|
-// AtomicReference<Double> fcyfdl = new AtomicReference<>((double) 0);
|
|
|
-// AtomicReference<Double> fcnfdl = new AtomicReference<>((double) 0);
|
|
|
-// wppromap.get(wp.getId()).stream().forEach(project -> {
|
|
|
-// AtomicReference<Double> qcrfdl = new AtomicReference<>(0.0);
|
|
|
-// AtomicReference<Double> qcyfdl = new AtomicReference<>(0.0);
|
|
|
-// AtomicReference<Double> qcnfdl = new AtomicReference<>(0.0);
|
|
|
-// prolinemap.get(project.getId()).stream().forEach(line -> {
|
|
|
-// Optional<Meterpoint> optionalMeterpoint = meterpoints.stream().filter(me -> me.getUniformcode().equals("ZXYG") && me.getMetertype().equals("进线") && me.getMetersort().equals("主")).findFirst();
|
|
|
-// 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.getRealData(pointid).getPointValueInDouble();
|
|
|
-// Optional<PointData> dayFirst = edosUtil.getHistoryDatasSnap(pointid, samedayZero.getTime() / 1000, samedayZero.getTime() / 1000, 1l, null).stream().findFirst();
|
|
|
-// if (dayFirst.isPresent()){
|
|
|
-// sameday = dayFirst.get().getPointValueInDouble();
|
|
|
-// }
|
|
|
-// Optional<PointData> monthFirst = edosUtil.getHistoryDatasSnap(pointid, monthFirstZero.getTime() / 1000, monthFirstZero.getTime() / 1000, 1l, null).stream().findFirst();
|
|
|
-// if (monthFirst.isPresent()){
|
|
|
-// month = monthFirst.get().getPointValueInDouble();
|
|
|
-// }
|
|
|
-// Optional<PointData> yearFirst = edosUtil.getHistoryDatasSnap(pointid, yearFirstZero.getTime() / 1000, yearFirstZero.getTime() / 1000, 1l, null).stream().findFirst();
|
|
|
-// if (yearFirst.isPresent()){
|
|
|
-// year = yearFirst.get().getPointValueInDouble();
|
|
|
-// }
|
|
|
-// Double magnification = optionalMeterpoint.get().getMagnification();
|
|
|
-// double xlrfdl = (real - sameday) * magnification;
|
|
|
-// 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();
|
|
|
-// r.setPointName();
|
|
|
-//
|
|
|
-// double xlyfdl = (real - month) * magnification;
|
|
|
-// 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();
|
|
|
-// y.setPointName();
|
|
|
-//
|
|
|
-// double xlnfdl = (real - year) * magnification;
|
|
|
-// 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();
|
|
|
-// n.setPointName();
|
|
|
-// } catch (Exception e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
-// }
|
|
|
-// });
|
|
|
-// 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();
|
|
|
-// r.setPointName();
|
|
|
-//
|
|
|
-// 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();
|
|
|
-// y.setPointName();
|
|
|
-//
|
|
|
-// 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();
|
|
|
-// n.setPointName();
|
|
|
-// });
|
|
|
-// PointData r = new PointData();
|
|
|
-// r.setPointTime(currentDate.getTime());
|
|
|
-// r.setPointValue(String.valueOf(fcrfdl.get()));
|
|
|
-// r.setPointValueInDouble(fcrfdl.get());
|
|
|
-// r.setEdnaId();
|
|
|
-// r.setPointName();
|
|
|
-//
|
|
|
-// PointData y = new PointData();
|
|
|
-// y.setPointTime(currentDate.getTime());
|
|
|
-// y.setPointValue(String.valueOf(fcyfdl.get()));
|
|
|
-// y.setPointValueInDouble(fcyfdl.get());
|
|
|
-// y.setEdnaId();
|
|
|
-// y.setPointName();
|
|
|
-//
|
|
|
-// PointData n = new PointData();
|
|
|
-// n.setPointTime(currentDate.getTime());
|
|
|
-// n.setPointValue(String.valueOf(fcnfdl.get()));
|
|
|
-// n.setPointValueInDouble(fcnfdl.get());
|
|
|
-// n.setEdnaId();
|
|
|
-// n.setPointName();
|
|
|
-// });
|
|
|
-// }
|
|
|
-//}
|
|
|
+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.EdosUtil;
|
|
|
+import com.gyee.generation.util.realtimesource.IEdosUtil;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+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 IEdosUtil edosUtil = new EdosUtil();
|
|
|
+
|
|
|
+ public void saveGenerationDatas(){
|
|
|
+ List<Windpowerstation> wpls = CacheContext.wpls;
|
|
|
+ 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();
|
|
|
+ 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);
|
|
|
+ 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);
|
|
|
+ prolinemap.get(project.getId()).stream().forEach(line -> {
|
|
|
+ Map<String, Windpowerstationpointnew> linemap = linepointmap.get(line.getId());
|
|
|
+ Optional<Meterpoint> optionalMeterpoint = meterpoints.stream().filter(me -> me.getUniformcode().equals("ZXYG") && me.getMetertype().equals("进线") && me.getMetersort().equals("主")).findFirst();
|
|
|
+ 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.getRealData(pointid).getPointValueInDouble();
|
|
|
+ Optional<PointData> dayFirst = edosUtil.getHistoryDatasSnap(pointid, samedayZero.getTime() / 1000, samedayZero.getTime() / 1000, 1l, null).stream().findFirst();
|
|
|
+ if (dayFirst.isPresent()){
|
|
|
+ sameday = dayFirst.get().getPointValueInDouble();
|
|
|
+ }
|
|
|
+ Optional<PointData> monthFirst = edosUtil.getHistoryDatasSnap(pointid, monthFirstZero.getTime() / 1000, monthFirstZero.getTime() / 1000, 1l, null).stream().findFirst();
|
|
|
+ if (monthFirst.isPresent()){
|
|
|
+ month = monthFirst.get().getPointValueInDouble();
|
|
|
+ }
|
|
|
+ Optional<PointData> yearFirst = edosUtil.getHistoryDatasSnap(pointid, yearFirstZero.getTime() / 1000, yearFirstZero.getTime() / 1000, 1l, null).stream().findFirst();
|
|
|
+ if (yearFirst.isPresent()){
|
|
|
+ year = yearFirst.get().getPointValueInDouble();
|
|
|
+ }
|
|
|
+ Double magnification = optionalMeterpoint.get().getMagnification();
|
|
|
+ double xlrfdl = (real - sameday) * magnification;
|
|
|
+ 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());
|
|
|
+ //线路月发电量
|
|
|
+ double xlyfdl = (real - month) * magnification;
|
|
|
+ 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());
|
|
|
+ //线路年发电量
|
|
|
+ double xlnfdl = (real - year) * magnification;
|
|
|
+ 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());
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ 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());
|
|
|
+
|
|
|
+ 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());
|
|
|
+
|
|
|
+ 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());
|
|
|
+ });
|
|
|
+ PointData r = new PointData();
|
|
|
+ r.setPointTime(currentDate.getTime());
|
|
|
+ r.setPointValue(String.valueOf(fcrfdl.get()));
|
|
|
+ r.setPointValueInDouble(fcrfdl.get());
|
|
|
+ r.setEdnaId(wpmap.get(Contant.RFDLB).getCode());
|
|
|
+ r.setPointName(wpmap.get(Contant.RFDLB).getName());
|
|
|
+
|
|
|
+ PointData y = new PointData();
|
|
|
+ y.setPointTime(currentDate.getTime());
|
|
|
+ y.setPointValue(String.valueOf(fcyfdl.get()));
|
|
|
+ y.setPointValueInDouble(fcyfdl.get());
|
|
|
+ y.setEdnaId(wpmap.get(Contant.YFDLB).getCode());
|
|
|
+ y.setPointName(wpmap.get(Contant.YFDLB).getName());
|
|
|
+
|
|
|
+ PointData n = new PointData();
|
|
|
+ n.setPointTime(currentDate.getTime());
|
|
|
+ n.setPointValue(String.valueOf(fcnfdl.get()));
|
|
|
+ n.setPointValueInDouble(fcnfdl.get());
|
|
|
+ n.setEdnaId(wpmap.get(Contant.NFDLB).getCode());
|
|
|
+ n.setPointName(wpmap.get(Contant.NFDLB).getName());
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|