Browse Source

添加表 stationinfo,存储风场名称,风机型号,风机测点型号等信息,风机测点型号来源于windturbinetestingpointAI/DI表,风机型号,和风机测点型号使用双逗号分割(,,)解决报警配置工具(自定义报警规则,风机报警)因型号混乱导致的测点加载问题
2.修改故障报警快照表更新问题,faultsnap batchUpdate 批量更新,oracle方言问题

wanghs 2 years ago
parent
commit
1610a61c94

+ 47 - 47
warning-web/src/main/java/com/gyee/wisdom/alarm/sharding/config/InterceptorConfig.java

@@ -1,47 +1,47 @@
-package com.gyee.wisdom.alarm.sharding.config;
-
-import com.gyee.wisdom.alarm.sharding.filter.LoginInterceptor;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.bind.annotation.ControllerAdvice;
-import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
-
-/**
- * @descrition:
- * @author:Wanghs
- * @date:2020-05-21
- */
-@Configuration
-public class InterceptorConfig implements WebMvcConfigurer {
-
-    @Bean
-    LoginInterceptor loginInterceptor() {
-        return new LoginInterceptor();
-    }
-
-    /**
-     * @Function: 配置生成器:添加一个拦截器,拦截路径为login以后的路径
-     * @author: YangXueFeng
-     * @Date: 2019/4/14 13:10
-     */
-    @Override
-    public void addInterceptors(InterceptorRegistry registry) {
-        registry.addInterceptor(loginInterceptor()).addPathPatterns("/**").excludePathPatterns("/login",
-                "/register",
-                "/static",
-                "/swagger**/**",
-                "/swagger-ui.html",
-                "/swagger-ui/**",
-                "/swagger-resources/**",
-                "/v2/api-docs",
-                "/v3/api-docs",
-                "/v3/api-docs/swagger-config",
-                "/webjars/**",
-                "/doc.html",
-                "/**/api-docs/**"
-        );
-
-    }
-
-}
+//package com.gyee.wisdom.alarm.sharding.config;
+//
+//import com.gyee.wisdom.alarm.sharding.filter.LoginInterceptor;
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.web.bind.annotation.ControllerAdvice;
+//import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+//
+///**
+// * @descrition:
+// * @author:Wanghs
+// * @date:2020-05-21
+// */
+//@Configuration
+//public class InterceptorConfig implements WebMvcConfigurer {
+//
+//    @Bean
+//    LoginInterceptor loginInterceptor() {
+//        return new LoginInterceptor();
+//    }
+//
+//    /**
+//     * @Function: 配置生成器:添加一个拦截器,拦截路径为login以后的路径
+//     * @author: YangXueFeng
+//     * @Date: 2019/4/14 13:10
+//     */
+//    @Override
+//    public void addInterceptors(InterceptorRegistry registry) {
+//        registry.addInterceptor(loginInterceptor()).addPathPatterns("/**").excludePathPatterns("/login",
+//                "/register",
+//                "/static",
+//                "/swagger**/**",
+//                "/swagger-ui.html",
+//                "/swagger-ui/**",
+//                "/swagger-resources/**",
+//                "/v2/api-docs",
+//                "/v3/api-docs",
+//                "/v3/api-docs/swagger-config",
+//                "/webjars/**",
+//                "/doc.html",
+//                "/**/api-docs/**"
+//        );
+//
+//    }
+//
+//}

+ 33 - 20
warning-web/src/main/java/com/gyee/wisdom/alarm/sharding/controller/InfoController.java

@@ -8,6 +8,7 @@ import com.gyee.wisdom.alarm.sharding.RSA.RSAService;
 import com.gyee.wisdom.alarm.sharding.entity.*;
 import com.gyee.wisdom.alarm.sharding.mapper.*;
 import com.gyee.wisdom.alarm.sharding.service.DeviceService;
+import com.gyee.wisdom.alarm.sharding.service.StationInfoService;
 import com.gyee.wisdom.alarm.sharding.service.WindturbineService;
 import com.gyee.wisdom.alarm.sharding.util.ResponseWrapper;
 
@@ -36,7 +37,7 @@ import java.util.Map;
 @RestController
 @RequestMapping("/info")
 @CrossOrigin
-@Tag(name="获取基础数据,如风场,风机,测点等")
+@Tag(name = "获取基础数据,如风场,风机,测点等")
 public class InfoController {
 
     @Autowired
@@ -72,7 +73,10 @@ public class InfoController {
     @Autowired
     private DeviceService deviceService;
 
-    @RequestMapping(value = "/station")
+    @Autowired
+    private StationInfoService stationInfoService;
+
+    @GetMapping(value = "/station")
     @ResponseBody
     @Operation(description = "获取风场")
     public List<WindPowerStation> getAllWindStation(@RequestParam(value = "id", required = false) String id) {
@@ -84,7 +88,7 @@ public class InfoController {
         return lst;
     }
 
-    @RequestMapping(value = "/station/all")
+    @GetMapping(value = "/station/all")
     @ResponseBody
     @Operation(description = "获取风场和光电场")
     public List<WindPowerStation> getAllStation(@RequestParam(value = "id", required = false) String id) {
@@ -94,14 +98,14 @@ public class InfoController {
 
 
     @Operation(description = "根据场站名称查询所有风机编号")
-    @RequestMapping(value = "/windturbine")
+    @GetMapping(value = "/windturbine")
     @ResponseBody
-    public List<Windturbine> getWindturbineByStation( @Parameter(name ="stationId",description = "场站名称") @RequestParam(value = "stationId", required = false) String stationId) {
+    public List<Windturbine> getWindturbineByStation(@Parameter(name = "stationId", description = "场站名称") @RequestParam(value = "stationId", required = false) String stationId) {
         List<Windturbine> lst = windturbineService.selectWindturbineByStationid(stationId);
         return lst;
     }
 
-    @RequestMapping(value = "/testing_point_ai")
+    @GetMapping(value = "/testing_point_ai")
     @ResponseBody
     public List<TestingPointAI> getTestingPointAIByStationIdAndModelId(
             @RequestParam(value = "stationId") String stationId,
@@ -116,7 +120,7 @@ public class InfoController {
         return lst;
     }
 
-    @RequestMapping(value = "/testing_point_di")
+    @GetMapping(value = "/testing_point_di")
     @ResponseBody
     public List<TestingPointDI> getTestingPointDIByStationIdAndModelId(
             @RequestParam(value = "stationId", required = false) String stationId,
@@ -133,13 +137,13 @@ public class InfoController {
 
     }
 
-    @RequestMapping(value = "/electrical_point_ai")
+    @GetMapping(value = "/electrical_point_ai")
     @ResponseBody
     public List<ElectricalTestingPointAI> getElectricaTestingPointAIByStationId(@RequestParam(value = "stationId") String stationId) {
         return electricalTestingPointAIMapper.selectPointByStation(stationId);
     }
 
-    @RequestMapping(value = "/electrical_point_di")
+    @GetMapping(value = "/electrical_point_di")
     @ResponseBody
     public List<ElectricalTestingPointDI> getElectricaTestingPointDIByStationId(@RequestParam(value = "stationId") String stationId) {
         return electricalTestingPointDIMapper.selectPointByStation(stationId);
@@ -159,7 +163,7 @@ public class InfoController {
         }
     }
 
-    @RequestMapping(value = "/warning_type")
+    @GetMapping(value = "/warning_type")
     public List<WarningType> getWarningType() {
         List<WarningType> lst = new ArrayList<>();
         try {
@@ -172,7 +176,7 @@ public class InfoController {
         }
     }
 
-    @RequestMapping(value = "/warning_classify")
+    @GetMapping(value = "/warning_classify")
     public List<WarningClassify> getWarningClassify() {
         List<WarningClassify> lst = new ArrayList<>();
         try {
@@ -185,7 +189,7 @@ public class InfoController {
         }
     }
 
-    @RequestMapping(value = "/publickey")
+    @GetMapping(value = "/publickey")
     public String getPublicKey() throws Exception {
         //获得密钥对Map
         Map<String, byte[]> keyMap = rsaService.getKeyMap();
@@ -217,23 +221,32 @@ public class InfoController {
 
     }
 
-    @RequestMapping(value = "/point")
+    @GetMapping(value = "/point")
     @ResponseBody
     public JSONObject getPointList(@RequestParam(value = "deviceId", required = true) String deviceid,
-                                  @RequestParam(value = "structcode", required = false) String structCode,
-                                  @RequestParam(value = "stationId", required = true) String stationId,
-                                  @RequestParam(value = "windturbineId", required = true) String windturbineId,
-                                  @RequestParam(value = "pageSize", required = false) Integer pageSize,
-                                  @RequestParam(value = "pageNum", required = false) Integer pageNum
+                                   @RequestParam(value = "structcode", required = false) String structCode,
+                                   @RequestParam(value = "stationId", required = true) String stationId,
+                                   @RequestParam(value = "windturbineId", required = true) String windturbineId,
+                                   @RequestParam(value = "pageSize", required = false) Integer pageSize,
+                                   @RequestParam(value = "pageNum", required = false) Integer pageNum
     ) {
 
-        if (pageSize==null||pageSize == 0)
+        if (pageSize == null || pageSize == 0)
             pageSize = 100;
-        if (pageNum==null||pageNum == 0)
+        if (pageNum == null || pageNum == 0)
             pageNum = 1;
         JSONObject testingPoint = deviceService.getTestingPointByStructCode(deviceid, structCode, windturbineId, pageSize, pageNum);
         return testingPoint;
 
 
     }
+
+    @GetMapping("/stationinfo")
+    public ResponseWrapper getStationInfo(@Parameter(name = "stationId", description = "风场id") @RequestParam(value = "stationId", required = false) String stationId) {
+        List<StationInfo> stationInfoList = stationInfoService.getStationInfo(stationId);
+
+        ResponseWrapper responseWrapper = ResponseWrapper.success("获取成功", stationInfoList);
+        return responseWrapper;
+    }
 }
+

+ 80 - 6
warning-web/src/main/java/com/gyee/wisdom/alarm/sharding/controller/TestController.java

@@ -1,18 +1,19 @@
 package com.gyee.wisdom.alarm.sharding.controller;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.gyee.wisdom.alarm.sharding.entity.Windturbine;
 import com.gyee.wisdom.alarm.sharding.service.AlarmReportService;
 import com.gyee.wisdom.alarm.sharding.service.AlarmSnapService;
+import com.gyee.wisdom.alarm.sharding.util.SnowflakeGenerator;
+import com.gyee.wisdom.alarm.sharding.util.StringUtil;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.CrossOrigin;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
 
 /**
  * @description:
@@ -59,4 +60,77 @@ public class TestController {
         System.out.println(JSON.toJSONString(mp));
         return mp;
     }
+
+    @GetMapping("/id")
+    @Operation(description = "根据字典类型获取字典集合")
+    public JSONObject getSnowId() {
+
+        JSONObject obj=new JSONObject();
+        obj.put("id", SnowflakeGenerator.generateId());
+        obj.put("name","wanghs");
+        obj.put("age","32");
+        return obj;
+    }
+
+    public static void main(String[] args) {
+
+        List<Windturbine> lst = new ArrayList<>();
+
+        Windturbine w1 = new Windturbine();
+        Windturbine w2 = new Windturbine();
+        Windturbine w3 = new Windturbine();
+        Windturbine w4 = new Windturbine();
+        Windturbine w5 = new Windturbine();
+
+        w1.setId("1");
+        w2.setId("2");
+        w3.setId("3");
+        w4.setId("4");
+        w5.setId("1");
+
+        w1.setName("风机1");
+        w2.setName("风机2");
+        w3.setName("风机3");
+        w4.setName("风机4");
+        w5.setName("风机5");
+        lst.add(w2);
+        lst.add(w1);
+        lst.add(w3);
+        lst.add(w4);
+        lst.add(w5);
+
+        lst.forEach(s -> System.out.println(s.getName()));
+        System.out.println("==========");
+        lst.sort((u1, u2) -> u1.getId().compareTo(u2.getId()));
+        lst.forEach(s -> System.out.println(s.getName()));
+        System.out.println("==========");
+        lst.sort(Comparator.comparing(Windturbine::getId).thenComparing(Windturbine::getName));
+        lst.forEach(s -> System.out.println(s.getName()));
+
+        String difference = StringUtil.difference(w2.getName(), w1.getName());
+        String s = StringUtil.prependIfMissing("456张三", "123", "456");
+
+        System.out.println("123");
+
+        boolean b = stringCompare();
+        System.out.println(b);
+    }
+
+    public static boolean stringCompare(){
+        String code="wanghs";
+        char[] chr=code.toCharArray();
+        for (int i = 0; i < chr.length; i++) {
+
+            char key=chr[i];
+
+            for (int j = i+1; j < chr.length; j++) {
+
+                if(key==chr[j])
+                    return false;
+            }
+
+
+        }
+        return true;
+    }
 }

+ 72 - 0
warning-web/src/main/java/com/gyee/wisdom/alarm/sharding/entity/StationInfo.java

@@ -0,0 +1,72 @@
+package com.gyee.wisdom.alarm.sharding.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.AccessLevel;
+import lombok.Data;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @description:
+ * @auther: Wanghs
+ * @date: 2022-06-17
+ */
+
+@Data
+@TableName("STATIONINFO")
+public class StationInfo implements Serializable {
+    //风场id 如XXX_FDC
+    @TableId("ID")
+    private String id;
+
+    //风场名称
+    @TableField("NAME")
+    private String name;
+
+    //风机型号 双逗号隔开
+    @TableField("MODELS")
+    @Setter(AccessLevel.NONE)
+    private String models;
+
+    //风机小型号 双逗号隔开 小型号来源于windturbinetestingpointAI/DI表,主要是因为历史包袱,因点表配置不完整导致
+    @TableField("POINT_MODELS")
+    @Setter(AccessLevel.NONE)
+    private String pointModels;
+
+    @TableField("CATEGORY1")
+    private String category1;
+
+    @TableField("CATEGORY1")
+    private String category2;
+
+    @TableField("CATEGORY1")
+    private String category3;
+
+    @TableField(exist = false)
+    private List<String> modelList;
+
+    @TableField(exist = false)
+    private List<String> pointModelList;
+
+
+    public void setModels(String models) {
+        this.models = models;
+        String[] split = models.split(",,");
+        this.modelList = Arrays.asList(split);
+    }
+
+    public void setPointModels(String pointModels) {
+        this.pointModels = pointModels;
+        String[] split = pointModels.split(",,");
+        this.pointModelList = Arrays.asList(split);
+    }
+
+
+}

+ 17 - 0
warning-web/src/main/java/com/gyee/wisdom/alarm/sharding/mapper/StationInfoMapper.java

@@ -0,0 +1,17 @@
+package com.gyee.wisdom.alarm.sharding.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.wisdom.alarm.sharding.entity.StationInfo;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @description:
+ * @auther: Wanghs
+ * @date: 2022-06-17
+ */
+
+@Repository
+@Mapper
+public interface StationInfoMapper extends BaseMapper<StationInfo> {
+}

+ 27 - 0
warning-web/src/main/java/com/gyee/wisdom/alarm/sharding/service/StationInfoService.java

@@ -0,0 +1,27 @@
+package com.gyee.wisdom.alarm.sharding.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.wisdom.alarm.sharding.entity.StationInfo;
+import com.gyee.wisdom.alarm.sharding.mapper.StationInfoMapper;
+import com.gyee.wisdom.alarm.sharding.util.StringUtil;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @description:
+ * @auther: Wanghs
+ * @date: 2022-06-17
+ */
+@Service
+public class StationInfoService extends ServiceImpl<StationInfoMapper, StationInfo> {
+
+    public List<StationInfo> getStationInfo(String stationId) {
+        QueryWrapper<StationInfo> wrapper = new QueryWrapper<>();
+        if (StringUtil.isNotBlank(stationId))
+            wrapper.eq("ID", stationId);
+        List<StationInfo> stationInfos = baseMapper.selectList(wrapper);
+        return stationInfos;
+    }
+}

+ 1 - 1
warning-web/src/main/resources/mappers-oracle/FaultSnapMapper.xml

@@ -16,7 +16,7 @@
     </insert>
 
     <update id="batchUpdate" parameterType="java.util.List">
-        <foreach collection="list" item="item" index="index" open="" close="" separator=";">
+        <foreach collection="list" item="item" index="index" open="begin" close=";end;" separator=";">
             UPDATE faultsnap
             <set>
                 <if test="item.isOpened != null">ISOPENED = #{item.isOpened},</if>