瀏覽代碼

利用小时分析

wangb@gyee-china.com 1 年之前
父節點
當前提交
869f055020

+ 40 - 0
web/runeconomy-jjyx/src/main/java/com/gyee/runeconomy/controller/Economic/EconomicController.java

@@ -137,4 +137,44 @@ public class EconomicController {
         }
 
     }
+
+
+    /**
+     * 利用小时分析
+     * @param companys
+     * @param type
+     * @param wpids
+     * @param windturbineids
+     * @param starttime
+     * @param endtime
+     * @param dateType
+     * @return
+     * @throws Exception
+     */
+
+    @GetMapping("/Utilization")
+    @ResponseBody
+    @CrossOrigin(origins = "*", maxAge = 3600)
+    public R Utilization(@RequestParam(value = "companys", required = true) String companys,
+                        @RequestParam(value = "type", required = true) String type,
+                        @RequestParam(value = "wpids", required = false) String wpids,
+                        @RequestParam(value = "windturbineids", required = false) String windturbineids,
+                        @RequestParam(value = "starttime", required = false) String starttime,
+                        @RequestParam(value = "endtime", required = false) String endtime,
+                        @RequestParam(value = "dateType", required = false) String dateType
+    ) throws Exception {
+        List<Glqx>  Utilization  = null;
+        if (StringUtils.isEmpty(type)) type = "-2";
+        if (StringUtils.isEmpty(dateType)) dateType = "1";
+
+        Utilization  = economicService.Utilization (companys,wpids, type, starttime, endtime, dateType, windturbineids);
+        if (StringUtils.isNotNull(Utilization )) {
+            return R.data(ResultMsg.ok(Utilization ));
+        } else {
+            return R.error(ResultMsg.error());
+        }
+
+    }
+
+
 }

+ 21 - 1
web/runeconomy-jjyx/src/main/java/com/gyee/runeconomy/controller/specific/SpecificController.java

@@ -6,7 +6,6 @@ package com.gyee.runeconomy.controller.specific;/*
 import com.gyee.common.model.StringUtils;
 import com.gyee.common.vo.specific.SpecificCenterVo;
 import com.gyee.common.vo.specific.SpecificTarget;
-import com.gyee.common.vo.specific.SpecificTargetVo;
 import com.gyee.common.vo.specific.SpecificTopVo;
 import com.gyee.runeconomy.dto.R;
 import com.gyee.runeconomy.dto.ResultMsg;
@@ -373,4 +372,25 @@ public class SpecificController {
              return R.error(ResultMsg.error());
         }
     }
+
+
+    /**
+     * 利用小时分析
+     * @return
+     */
+    @GetMapping("/Utilization")
+    @ResponseBody
+    @ApiOperation(value = "专题分析-发电量", notes = "专题分析-发电量")
+    public R Utilization(@RequestParam(value = "companys",required = true) String companys,
+                     @RequestParam(value = "type",required = true) String type,
+                     @RequestParam(value = "year",required = true) String year) throws ParseException {
+
+        List<SpecificTarget> resultList = specificService.Utilization(companys,type,year);
+        if (StringUtils.isNotNull(resultList)) {
+            return R.data(ResultMsg.ok(resultList));
+        }else{
+            return R.error(ResultMsg.error());
+        }
+    }
+
 }

+ 55 - 6
web/runeconomy-jjyx/src/main/java/com/gyee/runeconomy/service/Economic/EconomicService.java

@@ -82,7 +82,7 @@ public class EconomicService {
         if (companyId.startsWith("JS_RGN") && type.equals("-1")) {
             qyls = station1ls.stream().filter(wp -> "JS_RGN-1".equals(wp.getForeignKeyId()) && date.equals(wp.getRecordDate())).collect(Collectors.toList());
         } else if (companyId.startsWith("JS_RGN") && type.equals("-2")) {
-            qyls = station1ls.stream().filter(wp ->"JS_RGN-2".equals(wp.getForeignKeyId()) && date.equals(wp.getRecordDate())).collect(Collectors.toList());
+            qyls = station1ls.stream().filter(wp -> "JS_RGN-2".equals(wp.getForeignKeyId()) && date.equals(wp.getRecordDate())).collect(Collectors.toList());
         } else {
             qyls = station1ls.stream().filter(wp -> wp.getForeignKeyId().contains(companyId) && date.equals(wp.getRecordDate())).collect(Collectors.toList());
         }
@@ -94,11 +94,11 @@ public class EconomicService {
             trls = treels.stream().filter(wp -> wp.getId().endsWith("ZGS")).collect(Collectors.toList());
         } else if (companyId.startsWith("JS_RGN") && type.equals("-2")) {
             gsls = station1ls.stream()
-                    .filter(wp ->"JS_RGN-2".equals(wp.getRegionId()) && date.equals(wp.getRecordDate()))
+                    .filter(wp -> "JS_RGN-2".equals(wp.getRegionId()) && date.equals(wp.getRecordDate()))
                     .collect(Collectors.toList());
             trls = treels.stream().filter(wp -> wp != null && wp.getId().endsWith("ZGS")).collect(Collectors.toList());
 
-        //statype判断
+            //statype判断
         } else if (companyId.startsWith("JS_RGN") && statype.equals("-1")) {
             gsls = station1ls.stream().filter(wp -> "JS_RGN-1".equals(wp.getRegionId()) && date.equals(wp.getRecordDate())).collect(Collectors.toList());
             trls = treels.stream().filter(wp -> wp.getId().endsWith("STA")).collect(Collectors.toList());
@@ -453,12 +453,12 @@ public class EconomicService {
 
         List<ProBasicOrganizeTree> wtls = null;
 
-        if (wpids.isEmpty()){
+        if (wpids.isEmpty()) {
 
             wtls = eqs.stream()
                     .filter(v -> "EMI".equals(v.getEqType()))
                     .collect(Collectors.toList());
-        }else {
+        } else {
 
             wtls = eqs.stream()
                     .filter(v -> "EMI".equals(v.getEqType()) && wpids.contains(v.getParentCode()))
@@ -491,7 +491,7 @@ public class EconomicService {
                 vo1.setId(wt1.getNemCode());
                 vo1.setName(wt1.getNemName());
                 wt.add(vo1);
-            }else if (wpids.isEmpty()&& wt1.getPcodes().contains(companys)){
+            } else if (wpids.isEmpty() && wt1.getPcodes().contains(companys)) {
                 EconomicVo vo1 = new EconomicVo();
                 vo1.setId(wt1.getNemCode());
                 vo1.setName(wt1.getNemName());
@@ -578,5 +578,54 @@ public class EconomicService {
         return map;
     }
 
+    public List<Glqx> Utilization(String companys, String wpids, String type, String starttime, String endtime, String dateType, String windturbineids) throws Exception {
+
+        List<ProBasicOrganizeTree> wpls = CacheContext.wpls;
+        List<Glqx> vo = new ArrayList<>();
+
+        Date beginDate = DateUtils.parseDate1(starttime);
+        Date endDate = DateUtils.parseDate1(endtime);
+        Date current = com.gyee.common.util.DateUtils.getCurrentDate();
+        if (endDate.after(current)) {
+            endDate = current;
+        }
+
+        if (type.equals("-2")) {
+            for (ProBasicOrganizeTree wp : wpls) {
+                if (wpids.contains(wp.getId())) {
+
+//                    ProBasicPowerstationPoint fdl = proBasicPowerstationPointService.getPowerstationPoint(wpids, ContantXk.NFDL);
+                    Optional<ProBasicPowerstationPoint> nfdl = CacheContext.proBasicPowerstationPoint.stream().
+                            filter(pbpp -> "NFDL".equals(pbpp.getUniformCode()) && wpids.equals(pbpp.getWindpowerstationId())).findFirst();
+
+                    String nfdlcd = null;
+                    if (nfdl.isPresent()) {
+                        nfdlcd = nfdl.get().getNemCode();
+                    }
+
+                    List<PointData> nfdlls = edosUtil.getHistoryDatasSnap(nfdlcd, beginDate.getTime() / 1000, endDate.getTime() / 1000, null, 900L);
+
+                    double temp1 = 0;
+                    for (int i = 0; i < nfdlls.size(); i++) {
+                        Glqx vos = new Glqx();
+                        vos.setPjgzd(0.0);
+                        vos.setName("0");
+                        vos.setId("0");
+                        vos.setTime(2023);
+                        temp1 = nfdlls.get(i).getPointValueInDouble();
+                        vos.setTime(nfdlls.get(i).getPointTime());
+                        vos.setId(wp.getId());
+                        vos.setName(wp.getAname());
+                        vos.setPjgzd(StringUtils.round(temp1 /wp.getJrCapacity(), 2));
+                        vo.add(vos);
+                    }
+
+                }
+            }
+        }
+        return vo;
+    }
+
+
 
 }

+ 164 - 0
web/runeconomy-jjyx/src/main/java/com/gyee/runeconomy/service/specific/SpecificService.java

@@ -3044,4 +3044,168 @@ public class SpecificService {
 
         return resultendList;
     }
+
+
+    public List<SpecificTarget> Utilization(String companys, String type, String year) {
+
+        List<ProBasicOrganizeTree> wpls = CacheContext.wpls;
+
+        //获取年份所有当月的数据
+        QueryWrapper<ProEconPowerstationInfoDay1> currentqw = new QueryWrapper<>();
+        currentqw.select("foreign_key_id,max(record_date) record_date,max(yfdl) yfdl");
+        currentqw.eq("location","wp");
+        currentqw.eq("to_char(record_date,'yyyy')",year);
+        if (type.equals("-1")){
+            currentqw.like("foreign_key_id","_FDC_");
+        }else {
+            currentqw.like("foreign_key_id","_GDC_");
+        }
+        if (companys.endsWith("ZGS")){
+            currentqw.eq("company_id",companys);
+        }else {
+            currentqw.eq("region_id",companys);
+        }
+        currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
+        List<ProEconPowerstationInfoDay1> currentList = proEconPowerstationInfoDay1Service.list(currentqw);
+        currentqw.clear();
+        currentqw.select("foreign_key_id,max(record_date) record_date,max(yfdl) yfdl");
+        currentqw.eq("foreign_key_id",companys+type);
+        currentqw.eq("to_char(record_date,'yyyy')",year);
+        currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
+        currentList.addAll(proEconPowerstationInfoDay1Service.list(currentqw));
+
+        int subYear = Integer.parseInt(year) - 1;
+        QueryWrapper<ProEconPowerstationInfoDay1> sameperiodqw = new QueryWrapper<>();
+        sameperiodqw.select("foreign_key_id,max(record_date) record_date,max(yfdl) yfdl");
+        sameperiodqw.eq("location","wp");
+        if (type.equals("-1")){
+            currentqw.like("foreign_key_id","_FDC_");
+        }else {
+            currentqw.like("foreign_key_id","_GDC_");
+        }
+        if (companys.endsWith("ZGS")){
+            currentqw.eq("company_id",companys);
+        }else {
+            currentqw.eq("region_id",companys);
+        }
+        sameperiodqw.eq("to_char(record_date,'yyyy')",String.valueOf(subYear));
+        sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
+        List<ProEconPowerstationInfoDay1> sameperiodList = proEconPowerstationInfoDay1Service.list(sameperiodqw);
+        sameperiodqw.clear();
+        sameperiodqw.select("foreign_key_id,max(record_date) record_date,max(yfdl) yfdl");
+        sameperiodqw.eq("foreign_key_id",companys+type);
+        sameperiodqw.eq("to_char(record_date,'yyyy')",String.valueOf(subYear));
+        sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
+        sameperiodList.addAll(proEconPowerstationInfoDay1Service.list(sameperiodqw));
+
+        //合并当月与同期数据为返回结果
+        List<SpecificTargetVo> resultList = new ArrayList<>();
+
+        currentList.stream().forEach(i->{
+            SpecificTargetVo vo = new SpecificTargetVo();
+            String wpid = i.getForeignKeyId();
+            vo.setWpid(wpid);
+            if(wpid.contains("_ZGS")){
+                vo.setWpname(CacheContext.cpmap.get(companys).getAname());
+            }else if(wpid.contains("_RGN")){
+                vo.setWpname(CacheContext.rgmap.get(companys).getAname());
+            }else{
+                vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
+            }
+            vo.setYear(DateUtils.getYear(i.getRecordDate()));
+            vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
+            for (ProBasicOrganizeTree wp : wpls) {
+                if (i.getForeignKeyId().equals(wp.getId())) {
+                    vo.setCurrent(DoubleUtils.keepPrecision((i.getYfdl().doubleValue() / 10000)/wp.getJrCapacity(), 2));
+                }
+            }
+            resultList.add(vo);
+        });
+
+        resultList.stream().forEach(i->{
+            Optional<ProEconPowerstationInfoDay1> optional = sameperiodList.stream()
+                    .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && DateUtils.getMonth(j.getRecordDate())==(i.getMonth()))
+                    .findFirst();
+            if (optional.isPresent()){
+                ProEconPowerstationInfoDay1 tqinfoday = optional.get();
+                for (ProBasicOrganizeTree wp : wpls) {
+                    if (i.getWpid().equals(wp.getId())) {
+                        i.setSameperiod(DoubleUtils.keepPrecision((tqinfoday.getYfdl().doubleValue() / 10000) /wp.getJrCapacity(), 2));
+                    }
+                }
+                if (i.getSameperiod()==null) {
+                    i.setSameperiod(0.0);
+                }else {
+                    i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
+                }
+            }else {
+                i.setSameperiod(0.0);
+                i.setCompare(0);
+            }
+        });
+        List<SpecificTarget> resultendList = new ArrayList<>();
+
+        Map<String,Map<Integer,SpecificTargetVo>> map = new HashMap<>();
+
+        resultList.stream().forEach(i->{
+            if (map.containsKey(i.getWpid())){
+                Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
+                if (!integerListMap.containsKey(i.getMonth())){
+                    map.get(i.getWpid()).put(i.getMonth(),i);
+                }else {
+
+                }
+            }else {
+                Map<Integer,SpecificTargetVo> tempMap = new HashMap<>();
+                tempMap.put(i.getMonth(),i);
+                map.put(i.getWpid(),tempMap);
+            }
+        });
+        Set<String> wpids = map.keySet();
+        if (StringUtils.isNotNull(wpids)){
+            wpids.stream().forEach(wpid->{
+                SpecificTarget vo = new SpecificTarget();
+                vo.setWpid(wpid);
+                int orderNum = 100;
+                if(wpid.contains("_ZGS")){
+                    vo.setWpname(CacheContext.cpmap.get(companys).getAname());
+                }else if(wpid.contains("_RGN")){
+                    vo.setWpname(CacheContext.rgmap.get(companys).getAname());
+                }else{
+                    vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
+                    orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
+                }
+                vo.setOrderNum(orderNum);
+                List<SpecificTargetVo> tempList = new ArrayList<>();
+
+                Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
+                for(int x = 1;x<=12;x++){
+                    if (listMap.containsKey(x)){
+                        tempList.add(listMap.get(x));
+                    }else {
+                        SpecificTargetVo vo1 = new SpecificTargetVo();
+                        vo1.setWpid(wpid);
+                        if(wpid.contains("_ZGS")){
+                            vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
+                        }else if(wpid.contains("_RGN")){
+                            vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
+                        }else{
+                            vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
+                        }
+                        vo1.setYear(Integer.parseInt(year));
+                        vo1.setMonth(x);
+                        tempList.add(vo1);
+                    }
+                }
+
+
+                vo.setTargetList(tempList);
+                resultendList.add(vo);
+            });
+        }
+        SortUtils.sort(resultendList,"orderNum",SortUtils.ASC);
+
+        return resultendList;
+    }
+
 }