|
@@ -0,0 +1,239 @@
|
|
|
+package com.gyee.runeconomy.service.Electricity;
|
|
|
+
|
|
|
+import com.gyee.common.contant.ContantXk;
|
|
|
+import com.gyee.common.util.DateUtils;
|
|
|
+import com.gyee.common.util.SortUtils;
|
|
|
+import com.gyee.runeconomy.dto.ElectricityVo;
|
|
|
+import com.gyee.runeconomy.init.CacheContext;
|
|
|
+import com.gyee.runeconomy.model.auto.*;
|
|
|
+import com.gyee.runeconomy.service.auto.*;
|
|
|
+import com.gyee.runeconomy.service.auto.impl.ProEconStationPowerServiceImpl;
|
|
|
+import com.gyee.runeconomy.util.MathUtil;
|
|
|
+import com.gyee.runeconomy.util.StringUtils;
|
|
|
+import com.gyee.runeconomy.util.realtimesource.IEdosUtil;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class Electricityservice {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IProBasicPowerstationPointService proBasicPowerstationPointService;
|
|
|
+ @Resource
|
|
|
+ private IProEconTargetdataService proEconTargetdataService;
|
|
|
+ @Resource
|
|
|
+ private IProEconTargetdataFristService proEconTargetdataFristService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IProEconPowerstationInfoDay1Service proEconPowerstationInfoDay1Service;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ProEconStationPowerServiceImpl powerService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IEdosUtil edosUtil;
|
|
|
+ @Resource
|
|
|
+ private IProBasicProjectPlanService proBasicProjectPlanService;
|
|
|
+ private final String QS = "0";
|
|
|
+ private final String FD = "-1";
|
|
|
+ private final String GF = "-2";
|
|
|
+
|
|
|
+ public Map<String, Object> planvalue(String wpId, String timetype) throws Exception {
|
|
|
+
|
|
|
+ List<ElectricityVo> vos = new ArrayList<ElectricityVo>();
|
|
|
+ Map<String, Object> map = new LinkedHashMap<>();
|
|
|
+ Map<String, Object> map1 = new LinkedHashMap<>();
|
|
|
+
|
|
|
+ List<String> hjlist = new ArrayList<>();
|
|
|
+ if (wpId.endsWith(QS) || wpId.endsWith(FD) || wpId.endsWith(GF) || CacheContext.wpmapls.containsKey(wpId)) {
|
|
|
+
|
|
|
+ List<ProBasicPowerstation> wplist = new ArrayList<>();
|
|
|
+ if (CacheContext.wpmapls.containsKey(wpId)) {
|
|
|
+ wplist = CacheContext.wpmapls.get(wpId);
|
|
|
+ }
|
|
|
+// HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
|
|
|
+// List<ProBasicPowerstation> wplsToken = tokenService.getWpls(request);
|
|
|
+ for (ProBasicPowerstation wp : CacheContext.wpls) {
|
|
|
+ if (wpId.contains(FD)) {
|
|
|
+ if (wp.getId().endsWith("FDC_STA")) {
|
|
|
+ wplist.add(wp);
|
|
|
+ }
|
|
|
+ } else if (wpId.contains(GF)) {
|
|
|
+ if (wp.getId().endsWith("GDC_STA")) {
|
|
|
+ wplist.add(wp);
|
|
|
+ }
|
|
|
+ } else if (wpId.contains(QS)) {
|
|
|
+ wplist.add(wp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, ProBasicPowerstationPoint> wtpointmap = null;
|
|
|
+ Map<String, Map<String, ProBasicPowerstationPoint>> pointwpmap = CacheContext.wppointmap;
|
|
|
+ Map<String, Map<String, ProBasicPowerstationPoint>> pointwpmap1 = CacheContext.companypointmap;
|
|
|
+ Map<String, Map<String, ProBasicPowerstationPoint>> pointwpmap2 = CacheContext.regionpointmap;
|
|
|
+ Map<String, Map<String, ProBasicPowerstationPoint>> pointwpmap3 = CacheContext.grouppointmap;
|
|
|
+
|
|
|
+ if (pointwpmap.containsKey(wpId)) {
|
|
|
+ wtpointmap = pointwpmap.get(wpId);
|
|
|
+ } else if (pointwpmap1.containsKey(wpId)) {
|
|
|
+ wtpointmap = pointwpmap1.get(wpId);
|
|
|
+ } else if (pointwpmap2.containsKey(wpId)) {
|
|
|
+ wtpointmap = pointwpmap2.get(wpId);
|
|
|
+ } else if (pointwpmap3.containsKey(wpId)) {
|
|
|
+ wtpointmap = pointwpmap3.get(wpId);
|
|
|
+ }
|
|
|
+
|
|
|
+ String month = wtpointmap.get(ContantXk.YFDL).getNemCode();
|
|
|
+ String rfdl = wtpointmap.get(ContantXk.RFDL).getNemCode();
|
|
|
+ String nfdl = wtpointmap.get(ContantXk.NFDL).getNemCode();
|
|
|
+
|
|
|
+
|
|
|
+ if (timetype.contains("month")) {
|
|
|
+
|
|
|
+ if (!wplist.isEmpty()) {
|
|
|
+ int day = 0;
|
|
|
+ //当前天数
|
|
|
+ int month2 = DateUtils.getMonth(new Date());
|
|
|
+ //当前年份
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+ int currentyear = cal.get(Calendar.YEAR);//本年
|
|
|
+
|
|
|
+
|
|
|
+ //当月第一天0点值
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(new Date());
|
|
|
+ calendar.set(Calendar.DAY_OF_MONTH, 1);
|
|
|
+ calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
+ calendar.set(Calendar.MINUTE, 0);
|
|
|
+ calendar.set(Calendar.SECOND, 0);
|
|
|
+ calendar.set(Calendar.MILLISECOND, 0);
|
|
|
+
|
|
|
+ Date firstDayZeroHour = calendar.getTime();
|
|
|
+ Date yearHour = calendar.getTime();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ for (int i = month2; i > 0; i--) {
|
|
|
+ double bnjhdlsum = 0.0;
|
|
|
+ double yeardlsum = 0.0;
|
|
|
+ double bysjdlhjsum = 0.0;
|
|
|
+ BigDecimal cdqzqlsum = null;
|
|
|
+ double number = 100;
|
|
|
+ day = i;
|
|
|
+ for (ProBasicPowerstation wpls : wplist) {
|
|
|
+ List<ProBasicProjectPlan> currentls = proBasicProjectPlanService.getmonthList(String.valueOf(day)); //本月所有集合
|
|
|
+
|
|
|
+ List<ProBasicProjectPlan> yearls = proBasicProjectPlanService.getList(String.valueOf(currentyear));
|
|
|
+ List<ProBasicProjectPlan> yearjh = yearls.stream().filter(wp -> wp.getWindpowerstationId().equals(wpls.getId())).collect(Collectors.toList());
|
|
|
+
|
|
|
+ yeardlsum += yearjh.stream().mapToDouble(ProBasicProjectPlan::getGeneratingCapacity).sum(); //本年计划电量合
|
|
|
+
|
|
|
+
|
|
|
+ //本年所有集合
|
|
|
+ List<ProBasicProjectPlan> currentjh = currentls.stream().filter(wp -> wp.getWindpowerstationId().equals(wpls.getId())).collect(Collectors.toList());
|
|
|
+ bnjhdlsum += currentjh.stream().mapToDouble(ProBasicProjectPlan::getGeneratingCapacity).sum(); //本月计划电量合
|
|
|
+
|
|
|
+ List<ProEconPowerstationInfoDay1> sjdlls = proEconPowerstationInfoDay1Service.getmax(wpls.getId(),firstDayZeroHour);
|
|
|
+ if (!sjdlls.isEmpty() && sjdlls !=null) {
|
|
|
+ bysjdlhjsum += sjdlls.get(0).getYfdl().doubleValue();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ProEconStationPower> dqycls = powerService.getlist(wpls.getId(),firstDayZeroHour);
|
|
|
+
|
|
|
+ if (!dqycls.isEmpty() && dqycls != null){
|
|
|
+ cdqzqlsum = dqycls.stream().map(ProEconStationPower::getPowerAccuracy).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ElectricityVo vo = new ElectricityVo();
|
|
|
+
|
|
|
+ //添加计划电量
|
|
|
+ vo.setJhdl(StringUtils.round(bnjhdlsum, 2));
|
|
|
+ vo.setHours(i);
|
|
|
+
|
|
|
+ // 获取当前月份的最后一天的最大时间
|
|
|
+// Calendar calendar = Calendar.getInstance();
|
|
|
+// calendar.setTime(date1);
|
|
|
+// calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
|
|
|
+// calendar.set(Calendar.HOUR_OF_DAY, 23);
|
|
|
+// calendar.set(Calendar.MINUTE, 59);
|
|
|
+// calendar.set(Calendar.SECOND, 59);
|
|
|
+// Date endOfDayOfLastDayOfMonth = calendar.getTime();
|
|
|
+//
|
|
|
+// //添加实际电量
|
|
|
+// PointData data = edosUtil.getSectionData(month, endOfDayOfLastDayOfMonth.getTime());
|
|
|
+// PointData data = edosUtil.getSectionData(month, date1.getTime());
|
|
|
+ vo.setSjdl(StringUtils.round(bysjdlhjsum /10000,2));
|
|
|
+
|
|
|
+
|
|
|
+ //添加当月占比
|
|
|
+ vo.setDyzb(MathUtil.twoBit((bysjdlhjsum / 10000)/bnjhdlsum));
|
|
|
+
|
|
|
+ //添加全年占比
|
|
|
+ vo.setQnzb(MathUtil.twoBit(((bysjdlhjsum / 10000) / yeardlsum)));
|
|
|
+
|
|
|
+ //添加超短期准确率
|
|
|
+ vo.setCdqzql(cdqzqlsum);
|
|
|
+
|
|
|
+ firstDayZeroHour = DateUtils.addMonths(firstDayZeroHour, -1);
|
|
|
+
|
|
|
+ vos.add(vo);
|
|
|
+ SortUtils.sort(vos, "hours", SortUtils.ASC);
|
|
|
+ map.put("value",vos);
|
|
|
+ }
|
|
|
+
|
|
|
+ double yeardlsum = 0.0;
|
|
|
+ double bnsjdlhjsum = 0.0;
|
|
|
+ BigDecimal cdqzqlhjsum = null;
|
|
|
+ double cdqyc = 0.0;
|
|
|
+
|
|
|
+ for (ProBasicPowerstation wpls : wplist) {
|
|
|
+ //计划电量合计
|
|
|
+ List<ProBasicProjectPlan> yearls = proBasicProjectPlanService.getList(String.valueOf(currentyear));
|
|
|
+ List<ProBasicProjectPlan> yearjh = yearls.stream().filter(wp -> wp.getWindpowerstationId().equals(wpls.getId())).collect(Collectors.toList());
|
|
|
+
|
|
|
+ yeardlsum += yearjh.stream().mapToDouble(ProBasicProjectPlan::getGeneratingCapacity).sum(); //本年计划电量合
|
|
|
+
|
|
|
+ //实际电量合计
|
|
|
+// PointData bnsjdlhj = edosUtil.getHistMatrix(nfdl, currentDate.getTime() / 1000);
|
|
|
+// bnsjdlhjsum += bnsjdlhj.getPointValueInDouble();
|
|
|
+
|
|
|
+ List<ProEconPowerstationInfoDay1> sjdlls = proEconPowerstationInfoDay1Service.getmax(wpls.getId(),yearHour);
|
|
|
+ bnsjdlhjsum += sjdlls.get(0).getNfdl().doubleValue();
|
|
|
+
|
|
|
+ Calendar calendar1 = Calendar.getInstance();
|
|
|
+ calendar1.set(Calendar.DAY_OF_YEAR, 1);
|
|
|
+ calendar1.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
+ calendar1.set(Calendar.MINUTE, 0);
|
|
|
+ calendar1.set(Calendar.SECOND, 0);
|
|
|
+ calendar1.set(Calendar.MILLISECOND, 0);
|
|
|
+
|
|
|
+ Date firstDayOfYearZeroHour = calendar1.getTime();
|
|
|
+
|
|
|
+ List<ProEconStationPower> dqyc = powerService.getlist1(wpls.getId(),firstDayOfYearZeroHour);
|
|
|
+ if (!dqyc.isEmpty() && dqyc!=null) {
|
|
|
+ cdqzqlhjsum = dqyc.stream().map(ProEconStationPower::getPowerAccuracy).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put("bnsjdlhj",MathUtil.twoBit(bnsjdlhjsum / 10000));
|
|
|
+ map.put("bnjhdlhj",MathUtil.twoBit(yeardlsum));
|
|
|
+ map.put("qnzbhj",MathUtil.twoBit((bnsjdlhjsum / 10000) /yeardlsum));
|
|
|
+ map.put("cdqzqlhj",cdqzqlhjsum);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|