wangb@gyee-china.com vor 1 Jahr
Ursprung
Commit
c5cc376f39

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

@@ -11,9 +11,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
 @RestController
@@ -67,7 +65,7 @@ public class ApplicationController {
     })
     public AjaxResult getforecast(String type,String wpId) throws Exception {
 
-        List<Map> list = new ArrayList<>();
+        Map<Integer,Object>  list = new HashMap<>();
         if (wpId!=null) {
             list = applicationService.forecast(type, wpId);
         }
@@ -79,4 +77,25 @@ public class ApplicationController {
 
     }
 
+
+    @GetMapping(value = "/shutdown")
+    @ApiOperation(value = "故障次数", notes = "故障次数")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "type", value = "场站编号", required = true, dataType = "string", paramType = "query"),
+            @ApiImplicitParam(name = "wpId", value = "场站编号", required = false, dataType = "string", paramType = "query")
+    })
+    public AjaxResult getshutdown(String type,String wpId) throws Exception {
+
+        Map<Integer,Object>  list = new HashMap<>();
+        if (wpId!=null) {
+            list = applicationService.shutdown(type, wpId);
+        }
+        if (null != list) {
+            return AjaxResult.successData(200, list);
+        } else {
+            return AjaxResult.error(500, "操作失败");
+        }
+
+    }
+
 }

+ 125 - 21
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/Application/ApplicationService.java

@@ -6,15 +6,15 @@ import com.gyee.common.model.StringUtils;
 import com.gyee.common.util.DateUtils;
 import com.gyee.runeconomy.init.CacheContext;
 import com.gyee.runeconomy.model.auto.*;
-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.auto.IProEconStationPowerService;
+import com.gyee.runeconomy.service.auto.*;
 import com.gyee.runeconomy.util.MathUtil;
 import com.gyee.runeconomy.util.realtimesource.IEdosUtil;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -33,8 +33,15 @@ public class ApplicationService {
 
     @Resource
     private IProEconStationPowerService powerService;
+    @Resource
+    private IProEconAlarmTypeService alarmTypeService;
+
+    @Resource
+    private IProEconAlarmConfigurationService alarmConfigurationService;
 
     @Resource
+    private IProEconShutdownEventService shutdownEventService;
+    @Resource
     private IEdosUtil edosUtil;
 
 
@@ -136,23 +143,19 @@ public class ApplicationService {
         Map<String,Object> zb = new HashMap<>();
         List<ProBasicPowerstation> wpls =  CacheContext.wpls;
 
-
-        double rfdl = 0.0;
-        double yfdl = 0.0;
-        double nfdl = 0.0;
-
-        double rjhdl = 0.0;
-        double yjhdl = 0.0;
-        double njhdl = 0.0;
-
-
         List<ProBasicProjectPlan> plans = planService.getmonthList(String.valueOf(currentMonth));
         List<ProBasicProjectPlan> planyear = planService.getList(String.valueOf(dqnf));
 
         for (ProBasicPowerstation wp : wpls){
 
             zb = new HashMap<>();
+            double rfdl = 0.0;
+            double yfdl = 0.0;
+            double nfdl = 0.0;
 
+            double rjhdl = 0.0;
+            double yjhdl = 0.0;
+            double njhdl = 0.0;
             //日发电量
             ProBasicPowerstationPoint rfdlvalue = proBasicPowerstationPointService.getPowerstationPoint(wp.getId(), ContantXk.RFDL);
             rfdl = edosUtil.getRealData(rfdlvalue).getPointValueInDouble();
@@ -175,9 +178,9 @@ public class ApplicationService {
             zb.put("yfdl",MathUtil.twoBit(yfdl / 10000));
             zb.put("nfdl",MathUtil.twoBit(nfdl / 10000));
 
-            zb.put("rjhdl",rjhdl);
-            zb.put("yjhdl",yjhdl);
-            zb.put("njhdl",njhdl);
+            zb.put("rjhdl",MathUtil.twoBit(rjhdl));
+            zb.put("yjhdl",MathUtil.twoBit(yjhdl));
+            zb.put("njhdl",MathUtil.twoBit(njhdl));
 
             map.put(wp.getId(),zb);
         }
@@ -186,7 +189,70 @@ public class ApplicationService {
         return map;
     }
 
-    public List<Map> forecast(String type,String wpId) throws Exception {
+
+    public  Map<String, Object>[] electricityc() throws Exception {
+        long longDate = System.currentTimeMillis();
+        Date nowDate = new Date(longDate);
+
+        //当前月份
+        LocalDate currentDate = LocalDate.now();
+        int currentMonth = currentDate.getMonthValue();
+
+        //当前年份
+        Calendar cal = Calendar.getInstance();
+        int dqnf = cal.get(Calendar.YEAR);//本年
+
+        List<Double> list = new ArrayList<>();
+        List<Map<String, Object>> resultList = new ArrayList<>();
+        List<ProBasicPowerstation> wpls =  CacheContext.wpls;
+
+        double rfdl = 0.0;
+        double yfdl = 0.0;
+        double nfdl = 0.0;
+        double rjhdl = 0.0;
+        double yjhdl = 0.0;
+        double njhdl = 0.0;
+
+        List<ProBasicProjectPlan> plans = planService.getmonthList(String.valueOf(currentMonth));
+        List<ProBasicProjectPlan> planyear = planService.getList(String.valueOf(dqnf));
+        @SuppressWarnings("unchecked")
+        Map<String, Object>[] resultArray = new Map[wpls.size()];
+        int i = 0;
+        for (ProBasicPowerstation wp : wpls){
+            Map<String, Object> zb = new HashMap<>();
+
+            //日发电量
+            ProBasicPowerstationPoint rfdlvalue = proBasicPowerstationPointService.getPowerstationPoint(wp.getId(), ContantXk.RFDL);
+            rfdl = edosUtil.getRealData(rfdlvalue).getPointValueInDouble();
+
+            List<ProEconPowerstationInfoDay5> getdrlist = proEconPowerstationInfoDay5Service.getdrlist(wp.getId());
+            for (ProEconPowerstationInfoDay5 dr : getdrlist){
+                yfdl += dr.getYfdldb().doubleValue();
+                nfdl += dr.getNfdldb().doubleValue();
+            }
+
+            List<ProBasicProjectPlan> collect = plans.stream().filter(p -> p.getWindpowerstationId().equals(wp.getId())).collect(Collectors.toList());
+            List<ProBasicProjectPlan> year = planyear.stream().filter(p -> p.getWindpowerstationId().equals(wp.getId())).collect(Collectors.toList());
+            yjhdl =  collect.stream().mapToDouble(ProBasicProjectPlan::getGeneratingCapacity).sum();
+            njhdl = year.stream().mapToDouble(ProBasicProjectPlan::getGeneratingCapacity).sum();
+            rjhdl = yjhdl / 30;
+
+            zb.put("wpid", wp.getId());
+            zb.put("name", wp.getName());
+            zb.put("rfdl", MathUtil.twoBit(rfdl / 10000));
+            zb.put("yfdl", MathUtil.twoBit(yfdl / 10000));
+            zb.put("nfdl", MathUtil.twoBit(nfdl / 10000));
+            zb.put("rjhdl", rjhdl);
+            zb.put("yjhdl", yjhdl);
+            zb.put("njhdl", njhdl);
+
+            resultArray[i++] = zb;
+        }
+
+        return resultArray;
+    }
+
+    public  Map<Integer,Object> forecast(String type,String wpId) throws Exception {
 
         List<Map> list = new ArrayList<>();
         Map<Integer,Object> zb = new HashMap<>();
@@ -195,7 +261,7 @@ public class ApplicationService {
 
         List<ProEconStationPower> qwt = null;
         for (int i = 0; i < 3; i++) {
-            zb = new HashMap<>();
+//            zb = new HashMap<>();
             if (type.equals("0")) {
                 QueryWrapper<ProEconStationPower> qw = new QueryWrapper<>();
                 qw.lambda().eq(ProEconStationPower::getRecordDate, nowDate);
@@ -208,13 +274,51 @@ public class ApplicationService {
                 qwt = powerService.list(qw);
                 zb.put(i,qwt);
             }
-            list.add(zb);
+//            list.add(zb);
             nowDate = DateUtils.addDays(nowDate, +1);
         }
+        return zb;
+    }
+
+
+    public  Map<Integer,Object> shutdown(String type,String wpId) throws Exception {
+
+        long longDate = System.currentTimeMillis();
+        Date nowDate = new Date(longDate);
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        String formattedDate = dateFormat.format(nowDate);
+        Timestamp startTime = Timestamp.valueOf(formattedDate + " 00:00:00");
+
+        Map<String,Object> zb = new HashMap<>();
 
+        List<ProEconAlarmType> types =  alarmTypeService.list();
+        List<ProEconAlarmConfiguration> configurations = alarmConfigurationService.list();
 
+        for (ProEconAlarmType ty :types) {
 
+            List<ProEconShutdownEvent> qwt = null;
+            zb = new HashMap<>();
+
+            List<ProEconAlarmConfiguration> collect = configurations.stream()
+                    .filter(c -> ty.getNemCode().equals(c.getComponents()))
+                    .collect(Collectors.toList());
+
+            for (ProEconAlarmConfiguration c : collect){
+
+                    QueryWrapper<ProEconShutdownEvent> qw = new QueryWrapper<>();
+                    qw.lambda().eq(ProEconShutdownEvent::getStartTime,startTime);
+                    qw.lambda().eq(ProEconShutdownEvent::getWarningId,c.getId());
+                    qwt = shutdownEventService.list(qw);
+
+                    zb.put("name",ty.getName());
+                    zb.put("rgzcs",qwt.size());
+//                    zb.put("rgzcs",qwt.size());
+//                    zb.put("rgzcs",qwt.size());
+
+            }
+
+        }
 
-        return list;
+        return null;
     }
 }