Koishi 1 год назад
Родитель
Сommit
ec6d87f55c

+ 2 - 2
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/controller/Application/ApplicationController.java

@@ -15,8 +15,8 @@ import java.util.HashMap;
 import java.util.Map;
 
 @RestController
-@RequestMapping("//benchmarking")
-@Api(value = "对标管理", tags = "对标管理")
+@RequestMapping("//bulletinapp")
+@Api(value = "手机APP", tags = "手机APP")
 public class ApplicationController {
 
     @Resource

+ 97 - 27
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/Application/ApplicationService.java

@@ -1,50 +1,120 @@
 package com.gyee.runeconomy.service.Application;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.gyee.common.contant.ContantXk;
+import com.gyee.common.model.StringUtils;
+import com.gyee.common.util.DateUtils;
+import com.gyee.common.util.algorithm.MathUtils;
+import com.gyee.runeconomy.model.auto.ProBasicPowerstationPoint;
+import com.gyee.runeconomy.model.auto.ProBasicProjectPlan;
 import com.gyee.runeconomy.model.auto.ProEconPowerstationInfoDay5;
+import com.gyee.runeconomy.service.auto.IProBasicPowerstationPointService;
+import com.gyee.runeconomy.service.auto.IProBasicProjectPlanService;
 import com.gyee.runeconomy.service.auto.IProEconPowerstationInfoDay5Service;
+import com.gyee.runeconomy.service.monitor.MonitorprojectplanService;
+import com.gyee.runeconomy.util.MathUtil;
+import com.gyee.runeconomy.util.realtimesource.IEdosUtil;
+import com.gyee.runeconomy.util.realtimesource.StringUtil;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.time.LocalDate;
+import java.util.*;
+import java.util.stream.Collectors;
 
 @Service
 public class ApplicationService {
 
     @Resource
     private IProEconPowerstationInfoDay5Service proEconPowerstationInfoDay5Service;
+
+    @Resource
+    private IProBasicPowerstationPointService proBasicPowerstationPointService;
+
+    @Resource
+    private IProBasicProjectPlanService planService;
+
+    @Resource
+    private IEdosUtil edosUtil;
+
+
     public Map bulletin(String wpId) throws Exception {
 
-        Map<String,List> map = new HashMap<>();
-        // 获取当前日期 暂时
-        Date currentDate = new Date();
-
-        List<ProEconPowerstationInfoDay5> qwt = null;
-        QueryWrapper<ProEconPowerstationInfoDay5> qw = new QueryWrapper<>();
-        if (wpId.equals("KGDL_FGS0")){
-            qw.lambda().in(ProEconPowerstationInfoDay5::getForeignKeyId, "SXJ_KGDL_GFFD_ZGS-1", "SXJ_KGDL_FLFD_ZGS-2");
-        } else if (wpId.equals("KGDL_FGS-1")) {
-            qw.lambda().eq(ProEconPowerstationInfoDay5::getForeignKeyId, "SXJ_KGDL_FLFD_ZGS-1");
-        } else if (wpId.equals("KGDL_FGS-2")) {
-            qw.lambda().eq(ProEconPowerstationInfoDay5::getForeignKeyId, "SXJ_KGDL_GFFD_ZGS-2");
-        } else if (wpId.equals("SXJ_RGN0")) {
-            qw.lambda().in(ProEconPowerstationInfoDay5::getForeignKeyId, "SXJ_RGN-1", "SXJ_RGN-2");
-        } else if (wpId.equals("SXJ_RGN-1")) {
-            qw.lambda().eq(ProEconPowerstationInfoDay5::getForeignKeyId, "SXJ_RGN-1");
-        }else if (wpId.equals("SXJ_RGN-2")) {
-            qw.lambda().eq(ProEconPowerstationInfoDay5::getForeignKeyId, "SXJ_RGN-2");
+        Map<String,Object> map = new HashMap<>();
+
+
+
+        double rpjfs = 0.0;
+        double rswdl = 0.0;
+        double rgwdl = 0.0;
+        double rfdl = 0.0;
+        double rjhdl = 0.0;
+        double rwcl = 0.0;
+
+        double ypjfs = 0.0;
+        double yswdl = 0.0;
+        double ygwdl = 0.0;
+        double yfdl = 0.0;
+        double yjhdl = 0.0;
+        double ywcl = 0.0;
+
+        double npjfs = 0.0;
+        double nswdl = 0.0;
+        double ngwdl = 0.0;
+        double nfdl = 0.0;
+        double njhdl = 0.0;
+        double nwcl = 0.0;
+
+        //当前月份
+        LocalDate currentDate = LocalDate.now();
+        int currentMonth = currentDate.getMonthValue();
+
+        //当前年份
+        Calendar cal = Calendar.getInstance();
+        int dqnf = cal.get(Calendar.YEAR);//本年
+
+        //月发电量
+        ProBasicPowerstationPoint rfdlvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.RFDL);
+        rfdl = edosUtil.getRealData(rfdlvalue).getPointValueInDouble();
+
+
+        List<ProEconPowerstationInfoDay5> getdrlist = proEconPowerstationInfoDay5Service.getdrlist(wpId);
+        for (ProEconPowerstationInfoDay5  dr : getdrlist){
+
+            yfdl += dr.getYfdldb().doubleValue();
+            nfdl += dr.getNfdldb().doubleValue();
         }
-//        qw.lambda().between(ProEconPowerstationInfoDay5::getRecordDate, beginDate8, endDate8);
-        qw.lambda().like(ProEconPowerstationInfoDay5::getRecordDate,currentDate);
 
-        qwt = proEconPowerstationInfoDay5Service.list(qw);
+        List<ProBasicProjectPlan> plans = planService.getmonthList(String.valueOf(currentMonth));
+        List<ProBasicProjectPlan> planyear = planService.getList(String.valueOf(dqnf));
+
+        if (!wpId.endsWith("STA")){
 
-        map.put("ri",qwt);
+            yjhdl = plans.stream().mapToDouble(ProBasicProjectPlan::getGeneratingCapacity).sum();
+            njhdl = planyear.stream().mapToDouble(ProBasicProjectPlan::getGeneratingCapacity).sum();
+            rjhdl = yjhdl / 30;
+        }else {
+            List<ProBasicProjectPlan> collect = plans.stream().filter(p -> p.getWindpowerstationId().equals(wpId)).collect(Collectors.toList());
+            List<ProBasicProjectPlan> year = planyear.stream().filter(p -> p.getWindpowerstationId().equals(wpId)).collect(Collectors.toList());
+            yjhdl =  collect.stream().mapToDouble(ProBasicProjectPlan::getGeneratingCapacity).sum();
+            njhdl = year.stream().mapToDouble(ProBasicProjectPlan::getGeneratingCapacity).sum();
+            rjhdl = yjhdl / 30;
+        }
+        List<ProEconPowerstationInfoDay5> getzrlist = proEconPowerstationInfoDay5Service.getzrlist(wpId);
+        for (ProEconPowerstationInfoDay5  zr : getzrlist){
+
+        }
 
+        map.put("日发电量", MathUtil.twoBit(rfdl / 10000));
+        map.put("月发电量", MathUtil.twoBit(yfdl / 10000));
+        map.put("年发电量", MathUtil.twoBit(nfdl / 10000));
+        map.put("日计划发电量",MathUtil.twoBit(rjhdl));
+        map.put("月计划发电量",MathUtil.twoBit(yjhdl));
+        map.put("年计划发电量",MathUtil.twoBit(njhdl));
+        map.put("日完成率", StringUtils.round(((rfdl/10000)/rjhdl) *100,0) + "%");
+        map.put("月完成率",StringUtils.round(((yfdl/10000)/yjhdl) *100 ,0)+ "%");
+        map.put("年完成率",StringUtils.round(((nfdl/10000)/njhdl) *100 ,0)+ "%");
 
-        return null;
+        return map;
     }
 }

+ 3 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/IProEconPowerstationInfoDay5Service.java

@@ -24,4 +24,7 @@ public interface IProEconPowerstationInfoDay5Service extends IService<ProEconPow
     List<ProEconPowerstationInfoDay5> getEconZhcydldb(String foreignKeyId, String staType, String dateType, Date date);
 
     List<ProEconPowerstationInfoDay5> getmax(String foreignKeyId , Date date);
+
+    List<ProEconPowerstationInfoDay5> getdrlist(String wpId);
+    List<ProEconPowerstationInfoDay5> getzrlist(String wpId);
 }

+ 85 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/impl/ProEconPowerstationInfoDay5ServiceImpl.java

@@ -144,4 +144,89 @@ public class ProEconPowerstationInfoDay5ServiceImpl extends ServiceImpl<ProEconP
         }
         return currlist;
     }
+
+    @Override
+    public List<ProEconPowerstationInfoDay5> getdrlist(String wpId) {
+
+        //当前日期
+        long longDate = System.currentTimeMillis();
+        Date nowDate = new Date(longDate);
+        List<ProEconPowerstationInfoDay5> qwt = null;
+
+        QueryWrapper<ProEconPowerstationInfoDay5> qw = new QueryWrapper<>();
+
+        if (wpId.equals("KGDL_FGS0")){
+            qw.lambda().in(ProEconPowerstationInfoDay5::getForeignKeyId, "SXJ_KGDL_GFFD_ZGS-2", "SXJ_KGDL_FLFD_ZGS-1");
+
+        } else if (wpId.equals("KGDL_FGS-1")) {
+            qw.lambda().eq(ProEconPowerstationInfoDay5::getForeignKeyId, "SXJ_KGDL_FLFD_ZGS-1");
+
+        } else if (wpId.equals("KGDL_FGS-2")) {
+            qw.lambda().eq(ProEconPowerstationInfoDay5::getForeignKeyId, "SXJ_KGDL_GFFD_ZGS-2");
+
+        } else if (wpId.equals("SXJ_RGN0")) {
+            qw.lambda().in(ProEconPowerstationInfoDay5::getForeignKeyId, "SXJ_RGN-1", "SXJ_RGN-2");
+
+        } else if (wpId.equals("SXJ_RGN-1")) {
+            qw.lambda().eq(ProEconPowerstationInfoDay5::getForeignKeyId, "SXJ_RGN-1");
+
+        }else if (wpId.equals("SXJ_RGN-2")) {
+            qw.lambda().eq(ProEconPowerstationInfoDay5::getForeignKeyId, "SXJ_RGN-2");
+
+        } else if (wpId.endsWith("STA")){
+            qw.lambda().eq(ProEconPowerstationInfoDay5::getForeignKeyId, wpId);
+
+        }
+
+        qw.lambda().eq(ProEconPowerstationInfoDay5::getRecordDate,nowDate);
+        qwt = baseMapper.selectList(qw);
+        return qwt;
+    }
+
+    @Override
+    public List<ProEconPowerstationInfoDay5> getzrlist(String wpId) {
+
+        // 获取当前日期 暂时
+        Date currentDate8 = new Date();
+
+        // 创建 Calendar 对象,并设置为当前日期
+        Calendar calendar8 = Calendar.getInstance();
+        calendar8.setTime(currentDate8);
+        // 设置 beginDate 为前一天的早上六点
+        calendar8.add(Calendar.DAY_OF_MONTH, -1);
+        calendar8.set(Calendar.HOUR_OF_DAY, 6);
+        calendar8.set(Calendar.MINUTE, 0);
+        calendar8.set(Calendar.SECOND, 0);
+        calendar8.set(Calendar.MILLISECOND, 0);
+        Date beginDate = calendar8.getTime();
+
+        // 设置 endDate 为当天的23点59分59秒
+        calendar8.set(Calendar.HOUR_OF_DAY, 23);
+        calendar8.set(Calendar.MINUTE, 59);
+        calendar8.set(Calendar.SECOND, 59);
+        calendar8.set(Calendar.MILLISECOND, 999);
+        Date endDate = calendar8.getTime();
+
+
+        List<ProEconPowerstationInfoDay5> qwt = null;
+        QueryWrapper<ProEconPowerstationInfoDay5> qw = new QueryWrapper<>();
+        if (wpId.equals("KGDL_FGS0")){
+            qw.lambda().in(ProEconPowerstationInfoDay5::getForeignKeyId, "SXJ_KGDL_GFFD_ZGS-2", "SXJ_KGDL_FLFD_ZGS-1");
+        } else if (wpId.equals("KGDL_FGS-1")) {
+            qw.lambda().eq(ProEconPowerstationInfoDay5::getForeignKeyId, "SXJ_KGDL_FLFD_ZGS-1");
+        } else if (wpId.equals("KGDL_FGS-2")) {
+            qw.lambda().eq(ProEconPowerstationInfoDay5::getForeignKeyId, "SXJ_KGDL_GFFD_ZGS-2");
+        } else if (wpId.equals("SXJ_RGN0")) {
+            qw.lambda().in(ProEconPowerstationInfoDay5::getForeignKeyId, "SXJ_RGN-1", "SXJ_RGN-2");
+        } else if (wpId.equals("SXJ_RGN-1")) {
+            qw.lambda().eq(ProEconPowerstationInfoDay5::getForeignKeyId, "SXJ_RGN-1");
+        }else if (wpId.equals("SXJ_RGN-2")) {
+            qw.lambda().eq(ProEconPowerstationInfoDay5::getForeignKeyId, "SXJ_RGN-2");
+        } else if (wpId.endsWith("STA")){
+            qw.lambda().eq(ProEconPowerstationInfoDay5::getForeignKeyId, wpId);
+        }
+        qw.lambda().between(ProEconPowerstationInfoDay5::getRecordDate, beginDate, endDate);
+        qwt = baseMapper.selectList(qw);
+        return qwt;
+    }
 }