Browse Source

故障次数

wangb@gyee-china.com 1 year ago
parent
commit
8793845a1b

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

@@ -108,7 +108,7 @@ public class ApplicationController {
     })
     public AjaxResult getshutdown(String type,String wpId) throws Exception {
 
-        Map<Integer,Object>  list = new HashMap<>();
+        List<Map<String, Object>>   list = new ArrayList<>();
         if (wpId!=null) {
             list = applicationService.shutdown(type, wpId);
         }

+ 14 - 1
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/mapper/auto/ProEconAlarmTypeMapper.java

@@ -1,7 +1,11 @@
 package com.gyee.runeconomy.mapper.auto;
 
-import com.gyee.runeconomy.model.auto.ProEconAlarmType;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.runeconomy.model.auto.ProEconAlarmType;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -13,4 +17,13 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface ProEconAlarmTypeMapper extends BaseMapper<ProEconAlarmType> {
 
+    @Select("SELECT pro_econ_alarm_type.nem_code, COUNT(pro_econ_shutdown_event.warning_id) AS num_of_warnings " +
+            "FROM pro_econ_alarm_type " +
+            "LEFT JOIN pro_econ_alarm_configuration ON pro_econ_alarm_type.nem_code = pro_econ_alarm_configuration.components " +
+            "LEFT JOIN pro_econ_shutdown_event ON pro_econ_alarm_configuration.id = pro_econ_shutdown_event.warning_id " +
+            "WHERE pro_econ_shutdown_event.stop_time::date = current_date " +
+            "GROUP BY pro_econ_alarm_type.nem_code")
+    List<Map<String, Object>> getAlarmTypeCounts();
+
+
 }

+ 12 - 41
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/Application/ApplicationService.java

@@ -6,6 +6,7 @@ import com.gyee.common.model.PointData;
 import com.gyee.common.model.StringUtils;
 import com.gyee.common.util.DateUtils;
 import com.gyee.runeconomy.init.CacheContext;
+import com.gyee.runeconomy.mapper.auto.ProEconAlarmTypeMapper;
 import com.gyee.runeconomy.model.auto.*;
 import com.gyee.runeconomy.model.vo.YcdlVo;
 import com.gyee.runeconomy.service.auto.*;
@@ -14,9 +15,6 @@ 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;
@@ -43,6 +41,9 @@ public class ApplicationService {
 
     @Resource
     private IProEconShutdownEventService shutdownEventService;
+
+   @Resource
+   private ProEconAlarmTypeMapper proEconAlarmTypeMapper;
     @Resource
     private IEdosUtil edosUtil;
 
@@ -386,7 +387,11 @@ public class ApplicationService {
 
             vo.setName(wpls.get(0).getName());
             vo.setWpid(wpls.get(0).getNemCode());
-            vo.setDate(qwt.get(0).getRecordDate());
+            if (qwt.size()>0) {
+                vo.setDate(qwt.get(0).getRecordDate());
+            }else {
+                vo.setDate(LocalDate.ofEpochDay(2023-12-12));
+            }
             vo.setRfdl(bq.getPointValueInDouble());
             if (qwt.size()>0) {
                 vo.setYcdl(qwt.get(0).getDayPowerForecast().doubleValue());
@@ -423,45 +428,11 @@ public class ApplicationService {
     }
 
 
-    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();
-        int totalSize = 0;
-        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());
-
-            totalSize += collect.stream()
-                    .flatMap(c -> {
-                        QueryWrapper<ProEconShutdownEvent> qw = new QueryWrapper<>();
-                        qw.lambda().ge(ProEconShutdownEvent::getStartTime, startTime);
-                        qw.lambda().eq(ProEconShutdownEvent::getWarningId, c.getId());
-                        return shutdownEventService.list(qw).stream();
-                    })
-                    .collect(Collectors.toList())
-                    .size(); // 累加每个列表的大小
+    public  List<Map<String, Object>>  shutdown(String type,String wpId) throws Exception {
 
+        List<Map<String, Object>> typeCounts = proEconAlarmTypeMapper.getAlarmTypeCounts();
 
-            zb.put("name",ty.getName());
-            zb.put("rgzcs",totalSize);
-//                    zb.put("rgzcs",qwt.size());
-//                    zb.put("rgzcs",qwt.size());
-
-        }
+        List<String> typee = new ArrayList<>();
 
         return null;
     }