Browse Source

修改配置信息和多适配器切换

shilin 2 years ago
parent
commit
3ea0980f06

+ 32 - 27
web/alarm-hb/src/main/java/com/gyee/wisdom/alarm/sharding/service/ShutdownEventService.java

@@ -107,37 +107,42 @@ public class ShutdownEventService  extends ServiceImpl<ShutdownEventMapper, Shut
         List<ShutdownEvent> list = shutdownEventMapper.queryShutdownEventCurrentDate(stId,currentDate);
 
         List<StopType> stopTypes =   stopTypeMapper.queryStopTypeList("gz");
-        List<String> oritypes =  stopTypes.stream().map(StopType::getId).collect(Collectors.toList());
-        Map<String, String> maps = stopTypes.stream().collect(Collectors.toMap(StopType::getId, StopType::getName, (key1, key2) -> key2));
-        Map<String, List<ShutdownEvent>> groupbyTypes = list.stream().collect(Collectors.groupingBy(ShutdownEvent::getStoptypeId));
-        double hours = 0;
         Map<String, StopTypeCount> resultMap = new TreeMap<>();
-        List <String> types = new ArrayList<>();
-        StopTypeCount count = null;
-        for (Map.Entry<String, List<ShutdownEvent>> groupbyType : groupbyTypes.entrySet()) {
-            count = new StopTypeCount();
-            hours = groupbyType.getValue().stream().mapToDouble(ShutdownEvent::getStopHours).sum();
-            count.setTime(hours);
-            count.setCount(groupbyType.getValue().size());
-            count.setType(null == maps.get(groupbyType.getKey())? "": maps.get(groupbyType.getKey()));
-            count.setTypeID(groupbyType.getKey());
-            resultMap.put(groupbyType.getKey(),count);
-            types.add(groupbyType.getKey());
-        }
-
-        List<String> subList = oritypes.stream().filter(item -> !types.contains(item)).collect(Collectors.toList());
+        if(!list.isEmpty())
+        {
+            List<String> oritypes =  stopTypes.stream().map(StopType::getId).collect(Collectors.toList());
+            Map<String, String> maps = stopTypes.stream().collect(Collectors.toMap(StopType::getId, StopType::getName, (key1, key2) -> key2));
+            Map<String, List<ShutdownEvent>> groupbyTypes = list.stream().collect(Collectors.groupingBy(ShutdownEvent::getStoptypeId));
+            double hours = 0;
+
+            List <String> types = new ArrayList<>();
+            StopTypeCount count = null;
+            for (Map.Entry<String, List<ShutdownEvent>> groupbyType : groupbyTypes.entrySet()) {
+                count = new StopTypeCount();
+                hours = groupbyType.getValue().stream().mapToDouble(ShutdownEvent::getStopHours).sum();
+                count.setTime(hours);
+                count.setCount(groupbyType.getValue().size());
+                count.setType(null == maps.get(groupbyType.getKey())? "": maps.get(groupbyType.getKey()));
+                count.setTypeID(groupbyType.getKey());
+                resultMap.put(groupbyType.getKey(),count);
+                types.add(groupbyType.getKey());
+            }
 
-        for (String s:subList) {
-            if("gzbmq".equals(s)){
-                continue;
+            List<String> subList = oritypes.stream().filter(item -> !types.contains(item)).collect(Collectors.toList());
+
+            for (String s:subList) {
+                if("gzbmq".equals(s)){
+                    continue;
+                }
+                count = new StopTypeCount();
+                count.setTime(0);
+                count.setCount(0);
+                count.setType(null == maps.get(s)? "": maps.get(s));
+                count.setTypeID(s);
+                resultMap.put(s,count);
             }
-            count = new StopTypeCount();
-            count.setTime(0);
-            count.setCount(0);
-            count.setType(null == maps.get(s)? "": maps.get(s));
-            count.setTypeID(s);
-            resultMap.put(s,count);
         }
+
         return resultMap;
     }
 

+ 5 - 4
web/alarm-hb/src/main/resources/application-hwy.yml

@@ -9,7 +9,7 @@ spring:
     cloud:
       nacos:
         discovery:
-          server-addr: 123.60.213.70:8848
+          server-addr: 192.168.56.1:8848
           #指定yaml格式的配置
           file-extension: yaml
           cluster-name: master
@@ -20,9 +20,10 @@ spring:
   datasource:
     type: com.alibaba.druid.pool.DruidDataSource
     driver-class-name: oracle.jdbc.OracleDriver
-    url: jdbc:oracle:thin:@123.60.213.70:1521:gdnxfd
-    username: nxfdprod
-    password: gdnxfd123
+    url: jdbc:oracle:thin:@10.0.118.71:1521:gdsj
+    username: gdprod
+    password: gd123
+
     oracle-schema=:
     #    type: com.alibaba.druid.pool.DruidDataSource
     #    url: jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf8&serverTimezone=UTC

+ 0 - 3
web/alarm-hb/src/main/resources/mappers/ShutdownEventMapper.xml

@@ -8,11 +8,9 @@
             *
         FROM
         Shutdownevent s
-        LEFT JOIN Warning2 w ON s.warningid = w.id
         <where>
             s.windpowerstationid = #{stId}
             and s.statuscode = '2'
-            and s.stoptypeid in (select id from stoptype where parentid= 'gz' and id != 'gzbmq')
             and s.windpowerstationid is not null
             and s.stoptime &lt;= #{startdate,jdbcType=DATE}
             and s.stoptime &gt; #{edtend,jdbcType=DATE}
@@ -28,7 +26,6 @@
         <where>
             and s.stoptime &gt;= #{currentDate,jdbcType=DATE}
             and s.statuscode = '2'
-            and s.stoptypeid in (select id from stoptype where parentid= 'gz' and id != 'gzbmq')
             and s.windpowerstationid is not null
             <if test="stId !=null and stId !=''">
                 and  s.windpowerstationid = #{stId}