Bläddra i källkod

1:新增预警首页风机部件查询
2:自定义预警规则查询接口增加风机部件和场站查询功能

tianye 2 år sedan
förälder
incheckning
315537aced

+ 3 - 2
warning-web/src/main/java/com/gyee/wisdom/alarm/sharding/controller/Alertrule2Controller.java

@@ -99,10 +99,11 @@ public class Alertrule2Controller {
             @RequestParam(value = "modelId", required = false) String modelId,
             @RequestParam(value = "rank", required = false) String rank,
             @RequestParam(value = "category", required = false) String category,
-            @RequestParam(value = "enabled",required = false) String enabled
+            @RequestParam(value = "enabled",required = false) String enabled,
+            @RequestParam(value = "relatedparts",required = false) String relatedparts
     ) {
         Page<Alertrule2> page = new Page(pageNum, pageSize);
-        IPage<Alertrule2> pageResult = alertrule2Service.pageQueryAll(page, name,station,modelId,rank,category,enabled);
+        IPage<Alertrule2> pageResult = alertrule2Service.pageQueryAll(page, name,station,modelId,rank,category,enabled,relatedparts);
 
         return pageResult;
     }

+ 31 - 3
warning-web/src/main/java/com/gyee/wisdom/alarm/sharding/controller/HomeController.java

@@ -1,10 +1,15 @@
 package com.gyee.wisdom.alarm.sharding.controller;
 
 import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gyee.wisdom.alarm.sharding.entity.Alertrule2;
 import com.gyee.wisdom.alarm.sharding.model.AlarmHome;
 import com.gyee.wisdom.alarm.sharding.service.AlarmSnapService;
+import com.gyee.wisdom.alarm.sharding.service.Alertrule2Service;
 import com.gyee.wisdom.alarm.sharding.service.RiskSnapService;
 import com.gyee.wisdom.alarm.sharding.util.ResponseWrapper;
+import com.sun.org.apache.bcel.internal.generic.ARETURN;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.tags.Tag;
@@ -32,15 +37,20 @@ public class HomeController {
     @Autowired
     private RiskSnapService riskSnapService;
 
+    @Autowired
+    private Alertrule2Service alertrule2Service;
+
+
     @Operation(description = "报警总数查询")
     @GetMapping("early/latest")
     public ResponseWrapper selectAlarmCount(
-            @Parameter(name = "stationId", description = "场站id") @RequestParam(value = "stationId") String stationId
-    ){
+            @Parameter(name = "stationId", description = "场站id")
+            @RequestParam(value = "stationId") String stationId
+    ) {
 
         ResponseWrapper wrapper = null;
         try {
-            Map<String,List<AlarmHome>> stringListMap = alarmSnapService.selectAlarmSnapCount(stationId);
+            Map<String, List<AlarmHome>> stringListMap = alarmSnapService.selectAlarmSnapCount(stationId);
             Map<String, List<AlarmHome>> stringListMap2 = riskSnapService.selectRiskSnapCount(stationId);
             stringListMap.putAll(stringListMap2);
             wrapper = ResponseWrapper.success("请求成功", stringListMap);
@@ -51,5 +61,23 @@ public class HomeController {
 
     }
 
+    @Operation(description = "风机部件查询接口")
+    @GetMapping("alertrule")
+    public ResponseWrapper selectAlertrule2(
+            @RequestParam(value = "station") String station,
+            @RequestParam(value = "modelid") String modelid
+    ) {
+
+        ResponseWrapper wrapper = null;
+        try {
+            Map<String,Integer> alertrule2s = alertrule2Service.queryList(station,modelid);
+            wrapper = ResponseWrapper.success("请求成功", alertrule2s);
+        } catch (Exception ex) {
+            wrapper = ResponseWrapper.error("请求失败", JSON.toJSONString(ex.getStackTrace()));
+        }
+        return wrapper;
+
+    }
 
 }
+

+ 8 - 1
warning-web/src/main/java/com/gyee/wisdom/alarm/sharding/mapper/Alertrule2Mapper.java

@@ -23,12 +23,19 @@ public interface Alertrule2Mapper extends BaseMapper<Alertrule2> {
                                    @Param("modelId")String modelId,
                                    @Param("rank")String rank,
                                    @Param("category")String category,
-                                   @Param("enabled") String enabled);
+                                   @Param("enabled") String enabled,
+                                   @Param("relatedParts")String relatedparts);
 
     Integer getMaxEdnaValue();
 
     List<Alertrule2> getAllByStationIdAndModelId(@Param("idString") String idString);
 
+    List<Alertrule2> getAllByStationIdAndModelId2(
+            @Param("station") String station,
+            @Param("modelid") String modelId
+    );
+
+
     List<Alertrule2> getById(@Param("idString") String idString);
 
     List<Alertrule2> queryTree();

+ 75 - 2
warning-web/src/main/java/com/gyee/wisdom/alarm/sharding/service/Alertrule2Service.java

@@ -1,12 +1,16 @@
 package com.gyee.wisdom.alarm.sharding.service;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.wisdom.alarm.sharding.controller.AlertRuleEventLogController;
 import com.gyee.wisdom.alarm.sharding.entity.*;
 import com.gyee.wisdom.alarm.sharding.logtool.LogService;
 import com.gyee.wisdom.alarm.sharding.mapper.AlarmSnapMapper;
 import com.gyee.wisdom.alarm.sharding.mapper.Alertrule2Mapper;
+import com.gyee.wisdom.alarm.sharding.mapper.WindturbinePartsMapper;
+import com.gyee.wisdom.alarm.sharding.model.AlarmHome;
 import com.gyee.wisdom.alarm.sharding.model.Alertrule2Example;
 import com.gyee.wisdom.alarm.sharding.model.TreeNode;
 import com.gyee.wisdom.alarm.sharding.util.DateUtils;
@@ -20,8 +24,10 @@ import org.apache.logging.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.security.Key;
 import java.util.*;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 
 @Service
@@ -39,6 +45,7 @@ public class Alertrule2Service extends ServiceImpl<Alertrule2Mapper, Alertrule2>
     private RuleUpdateEventService eventService;
 
 
+
     public int saveAndUpdateAlertrule2(Alertrule2 alertrule2,String userName) {
 
         int result = 0;
@@ -93,8 +100,8 @@ public class Alertrule2Service extends ServiceImpl<Alertrule2Mapper, Alertrule2>
         return alertrule2Mapper.deleteById(alertrule2.getId());
     }
 
-    public IPage<Alertrule2> pageQueryAll(Page page, String name,String station,String modelId,String rank,String category,String enabled) {
-        return alertrule2Mapper.pageQueryAll(page, name,station,modelId,rank,category,enabled);
+    public IPage<Alertrule2> pageQueryAll(Page page, String name,String station,String modelId,String rank,String category,String enabled, String relatedparts) {
+        return alertrule2Mapper.pageQueryAll(page, name,station,modelId,rank,category,enabled,relatedparts);
     }
 
     //根据场站风机型号生成最新自定义报警规则ID
@@ -121,11 +128,77 @@ public class Alertrule2Service extends ServiceImpl<Alertrule2Mapper, Alertrule2>
     }
 
 
+
     public List<Alertrule2> queryTree() {
         List<Alertrule2> dsList = alertrule2Mapper.queryTree();
         return dsList;
     }
 
+//首页风机部件查询
+    public  Map<String,Integer> queryList(String station, String modelId) {
+        Map<String,Integer> map2 = new HashMap<>();
+        map2.put("CLX",0);
+        map2.put("YP",0);
+        map2.put("YY",0);
+        map2.put("BJXT",0);
+        map2.put("PHXT",0);
+        map2.put("BPXT",0);
+        map2.put("CFXT",0);
+        map2.put("ZZ",0);
+        map2.put("FDJ",0);
+        map2.put("QT",0);
+
+        List<Alertrule2> dslist = alertrule2Mapper.getAllByStationIdAndModelId2(station,modelId);
+        map2.put("SUM",dslist.size());
+        for(Alertrule2 ar : dslist) {
+            int cnt= 0;
+            switch (ar.getRelatedParts()) {
+                case "CLX":
+                    cnt = map2.get("CLX").intValue();
+                    map2.put("CLX", ++cnt);
+                    break;
+                case "YP":
+                    cnt = map2.get("YP").intValue();
+                    map2.put("YP", ++cnt);
+                    break;
+                case "YY":
+                    cnt = map2.get("YY").intValue();
+                    map2.put("YY", ++cnt);
+                    break;
+                case "BJXT":
+                    cnt = map2.get("BJXT").intValue();
+                    map2.put("BJXT", ++cnt);
+                    break;
+                case "PHXT":
+                    cnt = map2.get("PHXT").intValue();
+                    map2.put("PHXT", ++cnt);
+                    break;
+                case "BPXT":
+                    cnt = map2.get("BPXT").intValue();
+                    map2.put("BPXT",++cnt);
+                    break;
+                case "CFXT":
+                    cnt = map2.get("CFXT").intValue();
+                    map2.put("CFXT", ++cnt);
+                    break;
+                case "ZZ":
+                    cnt = map2.get("ZZ").intValue();
+                    map2.put("ZZ", ++cnt);
+                    break;
+                case "FDJ":
+                    cnt = map2.get("FDJ").intValue();
+                    map2.put("FDJ",++cnt);
+                    break;
+                default:
+                    cnt = map2.get("QT").intValue();
+                    map2.put("QT", ++cnt);
+                    break;
+            }
+        }
+        return map2;
+    }
+
+
     public List<Map<String, Alertrule2>> queryTree2(String relatedParts) {
         List<Map<String, Alertrule2>> dsList = alertrule2Mapper.quertByrelatedParts(relatedParts);
         return dsList;

+ 24 - 1
warning-web/src/main/resources/mappers-postgresql/Alertrule2Mapper.xml

@@ -90,6 +90,9 @@
                     and a.enabled = false
                 </if>
             </if>
+            <if test="relatedParts !=null and relatedParts !=''">
+                and a.relatedparts = #{relatedParts}
+            </if>
 
             <!--            and a.range = 0-->
         </where>
@@ -109,6 +112,19 @@
             </if>
         </where>
     </select>
+    <select id="getAllByStationIdAndModelId2" parameterType="java.util.Map"
+            resultMap="alertRule2ResultToPostgreSql">
+        select *, (case a.enabled WHEN 't' then 1 when 'f' then 0 else 0 end) as specialenable from ALERTRULE2 a
+        <where>
+            1=1
+            <if test="station !=null and station !=''">
+                and a.station = #{station}
+            </if>
+            <if test="modelid !=null and modelid !=''">
+                and a.modelid = #{modelid}
+            </if>
+        </where>
+    </select>
     <select id="getById" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.Alertrule2">
         select *, (case a.enabled WHEN 't' then 1 when 'f' then 0 else 0 end) as specialenable from ALERTRULE2 a
         <where>
@@ -119,6 +135,13 @@
         </where>
     </select>
 
+    <select id="selectListAll" parameterType="java.util.Map" resultMap="alertRule2ResultToPostgreSql">
+        select *, (case a.enabled WHEN 't' then 1 when 'f' then 0 else 0 end) as specialenable from ALERTRULE2 a
+        <where>
+            enabled = true
+        </where>
+    </select>
+
     <select id="quertByrelatedParts" resultType="java.util.HashMap">
         select a.name from ALERTRULE2 a
         where a.relatedparts = #{relatedParts}
@@ -301,4 +324,4 @@
             </foreach>
         </where>
     </sql>
-</mapper>
+</mapper>