Pārlūkot izejas kodu

预警原始数据接口

chenminghua 3 gadi atpakaļ
vecāks
revīzija
a22bd92967

+ 7 - 0
src/main/java/com/gyee/frame/common/feign/IAdapterService.java

@@ -2,9 +2,12 @@ package com.gyee.frame.common.feign;
 
 import com.alibaba.fastjson.JSONObject;
 import com.gyee.frame.model.custom.export.TsPointData;
+import com.gyee.frame.util.golden.timeseries.TsData;
 import feign.Headers;
 import feign.Param;
 import feign.RequestLine;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 
 import java.util.List;
 
@@ -22,6 +25,10 @@ public interface IAdapterService {
     List<TsPointData> getHistorySnap(@Param(value = "tagName") String tagName, @Param(value = "startTs") long startTs,
                                      @Param(value = "endTs") long endTs, @Param(value = "interval") Integer interval);
 
+    @Headers({"Content-Type: application/json", "Accept: application/json"})
+    @RequestLine("GET /ts/history/raw?tagName={tagName}&startTs={startTs}&endTs={endTs}")
+    List<TsPointData> getHistoryRaw(@Param(value = "tagName") String tagName, @Param(value = "startTs") long startTs,
+                                     @Param(value = "endTs") long endTs);
 
     @Headers({"Content-Type: application/json", "Accept: application/json"})
     @RequestLine("GET /ts/history/section?tagNames={tagNames}&ts={ts}")

+ 31 - 8
src/main/java/com/gyee/frame/controller/health/ReliabilityAnalysisController.java

@@ -10,6 +10,7 @@ import com.gyee.frame.model.auto.MetricsUniformCode;
 import com.gyee.frame.model.auto.WindTurbineTestingPointAi2;
 import com.gyee.frame.model.auto.WindTurbineTestingPointDi2;
 import com.gyee.frame.model.custom.export.TsPointData;
+import com.gyee.frame.model.custom.weather.Sys;
 import com.gyee.frame.service.Alertrule2ervice;
 import com.gyee.frame.service.WindTurbineTestingPointAiService;
 import com.gyee.frame.service.WindTurbineTestingPointDiService;
@@ -19,12 +20,10 @@ import io.swagger.annotations.Api;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 @RestController
+@CrossOrigin
 @RequestMapping("/analysis")
 @Api(value = "可靠性分析" ,tags =  "可靠性分析")
 public class ReliabilityAnalysisController {
@@ -58,7 +57,8 @@ public class ReliabilityAnalysisController {
             @RequestParam(name = "wtId") String wtId,
             @RequestParam(name = "name") String name,
             @RequestParam(name = "startTs") long startTs,
-            @RequestParam(name = "endTs") long endTs){
+            @RequestParam(name = "endTs") long endTs,
+            @RequestParam(name = "interval", required = false) Optional<Integer> interval){
 
         List<Object> list = new ArrayList<>();
 
@@ -70,11 +70,15 @@ public class ReliabilityAnalysisController {
             Map<String, Object> map = new HashMap<>();
             if (code.startsWith("AI")){
                 WindTurbineTestingPointAi2 windAI = windAIService.getWindTurbineTestingPointAi2(wtId, code);
-                List<TsPointData> data = remoteService.ShardingService().getHistorySnap(windAI.getId(), startTs, endTs, 60);
+                List<TsPointData> data = null;
+                if (interval.isPresent() && interval.get() > 0)
+                    data = remoteService.ShardingService().getHistorySnap(windAI.getId(), startTs, endTs, interval.get());
+                else
+                    data = remoteService.ShardingService().getHistoryRaw(windAI.getId(), startTs, endTs);
 
                 // 查询点的单位和描述属性
-                String unit = "";
-                String desc = "";
+                String unit = "--";
+                String desc = "----";
                 List<MetricsUniformCode> metricsList = uniformCodeService.getListByStationAndUniforCode(station, windAI.getUniformcode());
                 if (metricsList != null && metricsList.size() > 0) {
                     MetricsUniformCode metricsUniformCode = metricsList.get(0);
@@ -95,4 +99,23 @@ public class ReliabilityAnalysisController {
         return AjaxResult.successData(AjaxStatus.success.code, list);
     }
 
+
+    @Resource
+    WindTurbineTestingPointAiService windTurbineTestingPointAiService;
+
+    @GetMapping("/test")
+    public AjaxResult get(){
+        List<String> list = alertrule2ervice.getUniformCodeByNameAndStations();
+
+        List<String> modelID = alertrule2ervice.getModelID();
+
+
+//        for (String model : modelID)
+//            System.out.println(model);
+
+        List<String> winds = windTurbineTestingPointAiService.findPointByUniformcode(list, modelID);
+
+        return AjaxResult.successData(AjaxStatus.success.code, winds);
+    }
+
 }

+ 38 - 0
src/main/java/com/gyee/frame/service/Alertrule2ervice.java

@@ -261,4 +261,42 @@ public class Alertrule2ervice implements BaseService<Alertrule2, Alertrule2Examp
 
         return list;
     }
+
+    public List<String> getUniformCodeByNameAndStations(){
+        Alertrule2Example example = new Alertrule2Example();
+
+        List<Alertrule2> rules = alertrule2Mapper.selectByExample(example);
+        if (rules == null || rules.size() == 0)
+            return null;
+
+        List<String> list = new ArrayList<>();
+        for (Alertrule2 rule : rules){
+            String expression = "[AI,DI](.{4})";
+            List<String> lists = StringUtils.pattern(rule.getExpression(), expression);
+            for (String ls : lists){
+                if (!list.contains(ls) && (ls.startsWith("AI") || ls.startsWith("DI")))
+                    list.add(ls);
+            }
+        }
+
+        return list;
+    }
+
+    public List<String> getModelID(){
+        Alertrule2Example example = new Alertrule2Example();
+
+        List<Alertrule2> rules = alertrule2Mapper.selectByExample(example);
+        if (rules == null || rules.size() == 0)
+            return null;
+
+        List<String> list = new ArrayList<>();
+        for (Alertrule2 rule : rules){
+            String modelis = rule.getModelid();
+            if (!list.contains(modelis))
+                list.add(modelis);
+
+        }
+
+        return list;
+    }
 }

+ 29 - 0
src/main/java/com/gyee/frame/service/WindTurbineTestingPointAiService.java

@@ -9,6 +9,7 @@ import com.gyee.frame.mapper.auto.WindTurbineTestingPointAi2Mapper;
 import com.gyee.frame.model.auto.WindTurbineTestingPointAi2;
 import com.gyee.frame.model.auto.WindTurbineTestingPointAi2Example;
 import com.gyee.frame.model.custom.Tablepar;
+import com.gyee.frame.model.custom.weather.Sys;
 import com.gyee.frame.model.custom.weather.Wind;
 import com.gyee.frame.util.SnowflakeIdWorker;
 import com.gyee.frame.util.StringUtils;
@@ -17,6 +18,7 @@ import org.springframework.cache.annotation.CacheConfig;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -180,4 +182,31 @@ public class WindTurbineTestingPointAiService implements BaseService<WindTurbine
 
 		return list;
 	}
+
+	public List<String> findPointByUniformcode(List<String> list,List<String> models){
+		List<String> lists = new ArrayList<>();
+
+		for (String model : models){
+			for (String ls : list){
+				WindTurbineTestingPointAi2Example example = new WindTurbineTestingPointAi2Example();
+				example.createCriteria().andUniformcodeEqualTo(ls).andModelidLike("%"+model+"%");
+
+				List<WindTurbineTestingPointAi2> winds = windTurbineTestingPointAi2Mapper.selectByExample(example);
+
+				if (winds == null || winds.size() == 0)
+					continue;
+
+				for (WindTurbineTestingPointAi2 wind : winds) {
+					if (wind != null && wind.getId().contains("FJ")) {
+						lists.add(wind.getId() + "$" + wind.getName() + "@" + wind.getModelid());
+//						System.out.println(wind.getId() + "," + wind.getModelid());
+						break;
+					}
+				}
+			}
+		}
+
+
+		return lists;
+	}
 }