Browse Source

Merge remote-tracking branch 'origin/master'

宁檬 1 year ago
parent
commit
93e0fa2b3b

+ 72 - 4
web/runeconomy-jjyx/src/main/java/com/gyee/runeconomy/controller/Economic/EconomicController.java

@@ -1,16 +1,18 @@
 package com.gyee.runeconomy.controller.Economic;
 
+import com.gyee.common.model.StringUtils;
+import com.gyee.runeconomy.dto.Glqx;
+import com.gyee.runeconomy.dto.PowercurveVo;
 import com.gyee.runeconomy.dto.R;
 import com.gyee.runeconomy.dto.ResultMsg;
 import com.gyee.runeconomy.service.Economic.EconomicService;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.log4j.Log4j2;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
+import java.util.Date;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -53,4 +55,70 @@ public class EconomicController {
             return R.error(ResultMsg.error());
         }
     }
+
+
+    @GetMapping(value = "/powercurve")
+    @ApiOperation(value = "经济运行-首页", notes = "经济运行-首页")
+    public R powercurve(@RequestParam(value = "type", required = true) String type,
+                        @RequestParam(value = "wpid", required = true) String wpid,
+                        @RequestParam(value = "starttime", required = true) Date starttime,
+                        @RequestParam(value = "endtime", required = true) Date endtime
+    ) throws Exception {
+
+        List<PowercurveVo> map = economicService.powercurve(type,wpid, starttime, endtime);
+        if (null != map) {
+            return R.data(ResultMsg.ok(map));
+        } else {
+            return R.error(ResultMsg.error());
+        }
+    }
+
+    /**
+     * 功率列表
+     * @param windturbineids 风机ids
+     * @param type 0:全部;-1:风电;-2:光伏(暂时默认 -1;没有光伏的功率曲线)
+     * @param dateType 1:日;2:月;3:年
+     * @return
+     */
+    @GetMapping("/curvefitting")
+    @ResponseBody
+    @CrossOrigin(origins = "*", maxAge = 3600)
+    public R curvefittinglist(@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 {
+        Map<String, List<List<Glqx>>> curvefitting = null;
+        if(StringUtils.isEmpty(type)) type = "-2";
+        if(StringUtils.isEmpty(dateType)) dateType = "1";
+//        try {
+//            if (StringUtils.isNotEmpty(windturbineids)) {
+//
+//            } else if (StringUtils.isNotEmpty(wpids)) {
+//                windturbineids = CacheContext.organizeEquipmentList.stream().filter(oe -> wpids.contains(oe.getWindpowerstationId()))
+//                        .map(oe -> oe.getWindturbineId()).collect(Collectors.joining(","));
+//            } else if (StringUtils.isNotEmpty(companys)) {
+//                String[] split = companys.split(",");
+//                if (companys.contains("RGN")) {
+//                    for (String s : split) {
+//                        if(s.endsWith("RGN")){
+//                            windturbineids = CacheContext.organizeEquipmentList.stream().filter(oe -> s.equals(oe.getRegionId()))
+//                                    .map(oe -> oe.getWindturbineId()).collect(Collectors.joining(","));
+//                        }
+//                    }
+//                } else {
+//                    windturbineids = CacheContext.organizeEquipmentList.stream().filter(oe -> companys.contains(oe.getCompanyId()))
+//                            .map(oe -> oe.getWindturbineId()).collect(Collectors.joining(","));
+//                }
+//            }
+
+            curvefitting = economicService.curveFittingList(wpids, type, starttime,endtime,dateType);
+            return R.data(ResultMsg.ok(curvefitting));
+//        } catch (Exception e) {
+//            e.printStackTrace();
+        //        }
+    }
 }

+ 49 - 0
web/runeconomy-jjyx/src/main/java/com/gyee/runeconomy/dto/Glqx.java

@@ -0,0 +1,49 @@
+package com.gyee.runeconomy.dto;
+
+public class Glqx {
+    private String id;
+    private String name;
+    private Double sjgl;
+    private Double ycgl;
+    private String time;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Double getSjgl() {
+        return sjgl;
+    }
+
+    public void setSjgl(Double sjgl) {
+        this.sjgl = sjgl;
+    }
+
+    public Double getYcgl() {
+        return ycgl;
+    }
+
+    public void setYcgl(Double ycgl) {
+        this.ycgl = ycgl;
+    }
+
+    public String getTime() {
+        return time;
+    }
+
+    public void setTime(String time) {
+        this.time = time;
+    }
+}

+ 119 - 3
web/runeconomy-jjyx/src/main/java/com/gyee/runeconomy/service/Economic/EconomicService.java

@@ -1,17 +1,24 @@
 package com.gyee.runeconomy.service.Economic;
 
+import com.gyee.common.contant.ContantXk;
+import com.gyee.common.model.PointData;
 import com.gyee.runeconomy.dto.EconomicVo;
+import com.gyee.runeconomy.dto.Glqx;
+import com.gyee.runeconomy.dto.PowercurveVo;
 import com.gyee.runeconomy.dto.WxssVo;
 import com.gyee.runeconomy.init.CacheContext;
+import com.gyee.runeconomy.model.auto.ProBasicEquipmentPoint;
 import com.gyee.runeconomy.model.auto.ProBasicOrganizeTree;
+import com.gyee.runeconomy.model.auto.ProBasicPowerstationPoint;
 import com.gyee.runeconomy.model.auto.ProEconPowerstationInfoDay1;
-import com.gyee.runeconomy.service.auto.IProEconPowerstationInfoDay1Service;
-import com.gyee.runeconomy.service.auto.IProEconPowerstationInfoDay4Service;
-import com.gyee.runeconomy.service.auto.IProEconPowerstationInfoDay7Service;
+import com.gyee.runeconomy.service.auto.*;
 import com.gyee.runeconomy.util.DateUtils;
+import com.gyee.runeconomy.util.StringUtils;
+import com.gyee.runeconomy.util.realtimesource.IEdosUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.text.ParseException;
 import java.util.*;
@@ -32,6 +39,14 @@ public class EconomicService {
     @Autowired
     private IProEconPowerstationInfoDay4Service proEconPowerstationInfoDay4Service;//场站三率mtbf
 
+    @Resource
+    private IProBasicPowerstationPointService proBasicPowerstationPointService;
+
+    @Resource
+    private IProBasicEquipmentPointService proBasicEquipmentPointService;
+
+    @Resource
+    private IEdosUtil edosUtil;
 
     /**
      * @param companyId
@@ -290,4 +305,105 @@ public class EconomicService {
 
         return map;
     }
+
+    public List<PowercurveVo> powercurve(String wpid, String type, Date starttime,Date endtime) throws Exception {
+
+        Date beginDate = com.gyee.common.util.DateUtils.getSamedayZero();   //当日零点
+        Date endDate = com.gyee.common.util.DateUtils.getCurrentDate();   //当前时间
+
+        int day = com.gyee.common.util.DateUtils.getCurrentHour();//4
+
+        List<PowercurveVo> vos = new ArrayList<PowercurveVo>();
+
+        for (int i = 0; i < 24; i++) {
+            PowercurveVo vo = new PowercurveVo();
+            vo.setLlgl(0.0); //理论功率
+            vo.setSjgl(0.0); //实际功率
+            vo.setHours(i);  //时间戳
+            vo.setName(wpid);
+            vos.add(vo);
+        }
+
+        ProBasicPowerstationPoint sjgl = proBasicPowerstationPointService.getPowerstationPoint(wpid, ContantXk.SSZGL);
+        ProBasicPowerstationPoint ycgl = proBasicPowerstationPointService.getPowerstationPoint(wpid, ContantXk.ZYCGL);
+
+        List<PointData> sjglls = edosUtil.getHistoryDatasSnap(sjgl, beginDate.getTime() / 1000, endDate.getTime() / 1000, null, 900L);
+        double temp1 = 0;
+        for (int i = 0; i < sjglls.size(); i++) {
+            temp1 = sjglls.get(i).getPointValueInDouble();
+            vos.get(i).setSjgl(StringUtils.round(temp1, 2));
+        }
+
+        List<PointData> llglls = edosUtil.getHistoryDatasSnap(ycgl, beginDate.getTime() / 1000, endDate.getTime() / 1000, null, 900L);
+        double temp2 = 0;
+        for (int i = 0; i < llglls.size(); i++) {
+            temp2 = llglls.get(i).getPointValueInDouble();
+            vos.get(i).setLlgl(StringUtils.round(temp2, 2));
+        }
+
+        return vos;
+    }
+
+
+
+    public Map<String, List<List<Glqx>>> curveFittingList(String wpids, String type, String starttime, String endtime, String dateType) throws Exception {
+        Map<String, List<List<Glqx>>> resultMap = new HashMap<>();
+        Map<String, ProBasicOrganizeTree> wtmap = CacheContext.wtmap;
+
+        List<ProBasicOrganizeTree> wtls = CacheContext.wtls;
+        List<EconomicVo> wt = new ArrayList<>();
+
+//        Date beginDate = com.gyee.common.util.DateUtils.getSamedayZero();   //当日零点
+//        Date endDate = com.gyee.common.util.DateUtils.getCurrentDate();   //当前时间
+
+        Date beginDate = DateUtils.parseDate(starttime);
+        Date endDate = DateUtils.parseDate(endtime);
+
+        if (type.equals("-2")) {
+
+            for (ProBasicOrganizeTree wt1: wtls){
+                if (wpids.contains(wt1.getParentCode())){
+                    EconomicVo vo = new EconomicVo();
+                    vo.setId(wt1.getId());
+                    wt.add(vo);
+                }
+            }
+
+            for ( EconomicVo wt2 : wt) {
+
+                ProBasicEquipmentPoint sjgl = proBasicEquipmentPointService.getEquipmentPoint(wt2.getId(), ContantXk.AIG007);
+                List<Glqx> vo = new ArrayList<Glqx>();
+                List<List<Glqx>> tempList = new ArrayList<>();
+                List<PointData> sjglls = edosUtil.getHistoryDatasSnap(sjgl, beginDate.getTime() / 1000, endDate.getTime() / 1000, null, 900L);
+                double temp1 = 0;
+                for (int i = 0; i < sjglls.size(); i++) {
+                    temp1 = sjglls.get(i).getPointValueInDouble();
+                    vo.get(i).setId(sjgl.getId());
+                    vo.get(i).setName(wtmap.get(sjgl.getNemCode()).getAname());
+                    vo.get(i).setSjgl(StringUtils.round(temp1, 2));
+                }
+
+
+//            ProBasicPowerstationPoint ycgl = proBasicPowerstationPointService.getPowerstationPoint(windturbineIds, ContantXk.ZYCGL);
+
+
+//            List<PointData> llglls = edosUtil.getHistoryDatasSnap(ycgl, beginDate.getTime() / 1000, endDate.getTime() / 1000, null, 900L);
+//            double temp2 = 0;
+//            for (int i = 0; i < llglls.size(); i++) {
+//                temp2 = llglls.get(i).getPointValueInDouble();
+//                vo.get(i).setWtid(sjgl.getId());
+//                vo.get(i).setNemCode(wtmap.get(sjgl.getNemCode()).getAname());
+//                vo.get(i).setEnsurepower(StringUtils.round(temp2, 2));
+//                tempList.add(vo);
+//            }
+
+//            List<ProEconWtPowerCurveFitting> collect = CacheContext.wtPowerCurveFittingList.stream().filter(wpcf -> windturbineIds.contains(wpcf.getWindturbineId())).collect(Collectors.toList());
+
+                resultMap.put("list", tempList);
+
+            }
+        }
+
+        return resultMap;
+    }
 }