Browse Source

新增性能接口

wangchangsheng 3 years ago
parent
commit
fff9d5c97d

+ 20 - 0
gyee-sample-impala/src/main/java/com/gyee/sampleimpala/common/config/UniformcodeConfig.java

@@ -0,0 +1,20 @@
+package com.gyee.sampleimpala.common.config;
+
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * 数据测点
+ */
+@Data
+@Component
+@ConfigurationProperties(prefix = "point")
+public class UniformcodeConfig {
+
+    private List<String> uniformcode;
+
+}

+ 8 - 4
gyee-sample-impala/src/main/java/com/gyee/sampleimpala/controller/CaseperformanceController.java

@@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
+import java.util.Map;
 
 
 /**
@@ -111,12 +112,15 @@ public class CaseperformanceController {
      * @param interval 数据时间间隔
      * @return
      */
-    public JSONObject getCurve(
-            @RequestParam(value = "id",required = false) Integer[] id,
-            @RequestParam(value = "interval",required = false) Integer interval
+    @GetMapping("/performance/scatter")
+    public JSONObject getCurveScatter(
+            @RequestParam(value = "id") Integer[] id,
+            @RequestParam(value = "interval") Integer interval
     ) {
 
-        return null;
+        Map<String,List> maps  = goldenService.getCurveScatter(id,interval);
+
+        return JsonResult.successData(ResultCode.SUCCESS, maps);
     }
 
 }

+ 1 - 4
gyee-sample-impala/src/main/java/com/gyee/sampleimpala/controller/WindturbinePointController.java

@@ -2,11 +2,8 @@ package com.gyee.sampleimpala.controller;
 
 
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gyee.sampleimpala.common.result.JsonResult;
 import com.gyee.sampleimpala.common.result.ResultCode;
-import com.gyee.sampleimpala.model.custom.TsPointData;
-import com.gyee.sampleimpala.model.kudu.Casefault;
 import com.gyee.sampleimpala.model.kudu.Windturbinepoint;
 import com.gyee.sampleimpala.service.custom.GoldenService;
 import com.gyee.sampleimpala.service.kudu.WindturbinepointService;
@@ -65,7 +62,7 @@ public class WindturbinePointController {
             @RequestParam(value = "startTs",required = false) long startTs,
             @RequestParam(value = "endTs",required = false) long endTs,
             @RequestParam(value = "interval",required = false) int interval) {
-        List<Map> list = goldenService.getOriginalData(point, startTs, endTs, interval);
+        List<Map> list = goldenService.getCurveScatter(point, startTs, endTs, interval);
         return JsonResult.successData(ResultCode.SUCCESS, list);
     }
 

+ 59 - 23
gyee-sample-impala/src/main/java/com/gyee/sampleimpala/service/custom/GoldenService.java

@@ -1,9 +1,11 @@
 package com.gyee.sampleimpala.service.custom;
 
 
+import com.gyee.sampleimpala.common.config.UniformcodeConfig;
 import com.gyee.sampleimpala.common.exception.CustomException;
 import com.gyee.sampleimpala.common.feign.RemoteServiceBuilder;
 import com.gyee.sampleimpala.common.result.ResultCode;
+import com.gyee.sampleimpala.common.util.DateUtil;
 import com.gyee.sampleimpala.model.custom.TsPointData;
 import com.gyee.sampleimpala.model.kudu.Caseperformance;
 import com.gyee.sampleimpala.model.kudu.Windturbinepoint;
@@ -13,10 +15,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 @Slf4j
 @Service
@@ -31,39 +30,42 @@ public class GoldenService {
 
     @Autowired
     private CaseperformanceService caseperformanceService;
+    @Autowired
+    private UniformcodeConfig uniformcodeConfig;
 
 
     /**
      * 查询原始数据
+     *
      * @param points
      * @param startTs  精确到毫秒
      * @param endTs
      * @param interval
      * @return
      */
-    public List<Map> getOriginalData(String[] points, long startTs, long endTs, int interval){
+    public List<Map> getCurveScatter(String[] points, long startTs, long endTs, int interval) {
 
         List<Map> list = new ArrayList<>();
 
-        try{
+        try {
 
-            for (String point :points){
-                Windturbinepoint w =  windturbinepointService.getByPoint(point);
+            for (String point : points) {
+                Windturbinepoint w = windturbinepointService.getByPoint(point);
                 List<TsPointData> data = new ArrayList<>();
                 Map m = new HashMap();
-                if (interval <= 0){
+                if (interval <= 0) {
                     data = remoteService.ShardingService().getHistoryRaw(point, startTs, endTs);
-                }else {
+                } else {
                     data = remoteService.ShardingService().getHistorySnap(point, startTs, endTs, interval);
                 }
-                m.put("name",w.getPointdes());
-                m.put("code",w.getWidgetcode());
-                m.put("point",w.getPoint());
-                m.put("list",data);
+                m.put("name", w.getPointdes());
+                m.put("code", w.getWidgetcode());
+                m.put("point", w.getPoint());
+                m.put("list", data);
                 list.add(m);
             }
 
-        } catch (Exception e){
+        } catch (Exception e) {
             log.error(e.getMessage());
             throw new CustomException(ResultCode.ERROR_DATA);
         }
@@ -72,16 +74,50 @@ public class GoldenService {
     }
 
 
+    /**
+     * H获取风速和转速的曲线数据
+     *
+     * @param ids      ids
+     * @param interval 数据时间间隔
+     * @return
+     */
+    public Map<String, List> getCurveScatter(Integer[] ids, int interval) {
+
+
+        try {
+            Map<String, List> maps = new HashMap<>();
+            for (Integer id : ids) {
+                List<String> codeList = uniformcodeConfig.getUniformcode();
+                String[] codes = codeList.toArray(new String[codeList.size()]);
+                Caseperformance cp = caseperformanceService.getPerformanceByid(id);
+                List<Windturbinepoint> windturbinepoints = windturbinepointService.getListByStationAndWtIdAndUniformCode(cp.getStationen(), cp.getWindturbineid(), codes);
+                List<TsPointData> data1 = remoteService.ShardingService().getHistorySnap(windturbinepoints.get(0).getPoint(), DateUtil.covertDateTimestamp(cp.getStarttime()),
+                        DateUtil.covertDateTimestamp(cp.getEndtime()), interval);
+                List<TsPointData> data2 = remoteService.ShardingService().getHistorySnap(windturbinepoints.get(1).getPoint(), DateUtil.covertDateTimestamp(cp.getStarttime()),
+                        DateUtil.covertDateTimestamp(cp.getEndtime()), interval);
+                if (null != data1 && null != data2 && data1.size() == data2.size()) {
+                    List list = new ArrayList();
+                    List<Map> lp = new ArrayList<>();
+                    for (int i = 0; i < data1.size(); i++) {
+                        List l = new ArrayList();
+                        Map c = new HashMap();
+                        l.add(data1.get(i).getDoubleValue());
+                        l.add(data2.get(i).getDoubleValue());
+                        c.put("fs", data1.get(i).getDoubleValue());
+                        c.put("zs", data2.get(i).getDoubleValue());
+                        list.add(l);
+                        lp.add(c);
+                    }
+                    maps.put("S_" + id + "_" + cp.getWindturbineid(), list);
+                    maps.put("C_" + id + "_" + cp.getWindturbineid(), lp);
+                }
+            }
 
-
-    public List<Map> getOriginalData(Integer[] id, int interval){
-        for (Integer i :id ){
-            Caseperformance cp = caseperformanceService.getPerformanceByid(i);
-
-//            data = remoteService.ShardingService().getHistorySnap(point, startTs, endTs, interval);
+            return maps;
+        } catch (Exception e) {
+            log.error(e.getMessage());
+            throw new CustomException(ResultCode.ERROR_DATA);
         }
 
-        return null;
-
     }
 }

+ 29 - 5
gyee-sample-impala/src/main/java/com/gyee/sampleimpala/service/impl/kudu/WindturbinepointServiceImpl.java

@@ -45,7 +45,7 @@ public class WindturbinepointServiceImpl extends ServiceImpl<WindturbinepointMap
 
             list = baseMapper.selectList(wrapper);
 
-        } catch (CustomException e){
+        } catch (CustomException e) {
             log.error(e.getMessage());
             throw new CustomException(ResultCode.ERROR_DATA);
         }
@@ -65,7 +65,7 @@ public class WindturbinepointServiceImpl extends ServiceImpl<WindturbinepointMap
 
             list = baseMapper.selectList(wrapper);
 
-        } catch (CustomException e){
+        } catch (CustomException e) {
             log.error(e.getMessage());
             throw new CustomException(ResultCode.ERROR_DATA);
         }
@@ -89,7 +89,7 @@ public class WindturbinepointServiceImpl extends ServiceImpl<WindturbinepointMap
         try {
             baseMapper.insert(obj);
             return true;
-        } catch (CustomException e){
+        } catch (CustomException e) {
             log.error(e.getMessage());
             throw new CustomException(ResultCode.ERROR_DATA);
         }
@@ -103,7 +103,7 @@ public class WindturbinepointServiceImpl extends ServiceImpl<WindturbinepointMap
         try {
             baseMapper.delete(wrapper);
             return true;
-        } catch (CustomException e){
+        } catch (CustomException e) {
             log.error(e.getMessage());
             throw new CustomException(ResultCode.ERROR_DATA);
         }
@@ -133,10 +133,34 @@ public class WindturbinepointServiceImpl extends ServiceImpl<WindturbinepointMap
 
             list = baseMapper.selectList(wrapper);
 
-        } catch (CustomException e){
+        } catch (CustomException e) {
             log.error(e.getMessage());
             throw new CustomException(ResultCode.ERROR_DATA);
         }
         return list.get(0);
     }
+
+    @Override
+    public List<Windturbinepoint> getListByStationAndWtIdAndUniformCode(String station, String wtId, String[] uniformCode) {
+        List<Windturbinepoint> list = new ArrayList<>();
+
+        try {
+            ExcludeQueryWrapper<Windturbinepoint> wrapper = new ExcludeQueryWrapper<>();
+            wrapper.eq("stationen", station)
+                    .eq("windturbineid", wtId)
+                    .in("uniformcode", uniformCode)
+            .orderByAsc("uniformcode");
+
+            list = baseMapper.selectList(wrapper);
+            if (null != list && list.size() > 0) {
+                return list;
+            }
+
+        } catch (CustomException e) {
+            log.error(e.getMessage());
+            throw new CustomException(ResultCode.ERROR_DATA);
+        }
+        return null;
+
+    }
 }

+ 28 - 10
gyee-sample-impala/src/main/java/com/gyee/sampleimpala/service/kudu/WindturbinepointService.java

@@ -8,7 +8,7 @@ import java.util.List;
 
 /**
  * <p>
- *  服务类
+ * 服务类
  * </p>
  *
  * @author chenmh
@@ -18,14 +18,16 @@ public interface WindturbinepointService extends IService<Windturbinepoint> {
 
     /**
      * 查询部件关联的测点
-     * @param wtId    风机编号
-     * @param widget  部件代码
+     *
+     * @param wtId   风机编号
+     * @param widget 部件代码
      * @return
      */
     List<Windturbinepoint> getAll(String wtId, String widget);
 
     /**
      * 通过场站和统一编码查询测点
+     *
      * @param station     场站
      * @param uniformCode 统一编码
      * @return
@@ -34,6 +36,7 @@ public interface WindturbinepointService extends IService<Windturbinepoint> {
 
     /**
      * 编辑数据
+     *
      * @param obj
      * @return
      */
@@ -41,6 +44,7 @@ public interface WindturbinepointService extends IService<Windturbinepoint> {
 
     /**
      * 新建数据
+     *
      * @param obj
      * @return
      */
@@ -48,6 +52,7 @@ public interface WindturbinepointService extends IService<Windturbinepoint> {
 
     /**
      * 通过id删除数据
+     *
      * @param id
      * @return
      */
@@ -56,21 +61,34 @@ public interface WindturbinepointService extends IService<Windturbinepoint> {
 
     /**
      * 查询故障数据的原始点数据
-     * @param station  场站
-     * @param wtId     风机Id
-     * @param model    模型
-     * @param widget   部件
-     * @param startTs  开始时间
-     * @param endTs    结束时间
-     * @param type     测点类型
+     *
+     * @param station 场站
+     * @param wtId    风机Id
+     * @param model   模型
+     * @param widget  部件
+     * @param startTs 开始时间
+     * @param endTs   结束时间
+     * @param type    测点类型
      */
     List<Object> getPointDataAll(String station, String wtId,
                                  String[] model, String[] widget, String startTs, String endTs, String type);
 
     /**
      * 通过point获取一条数据
+     *
      * @param point
      * @return
      */
     Windturbinepoint getByPoint(String point);
+
+
+    /**
+     * 通过场风机编码站和统一编码查询测点
+     *
+     * @param station     场站
+     * @param wtId        风机编码
+     * @param uniformCode 统一编码
+     * @return
+     */
+    List<Windturbinepoint> getListByStationAndWtIdAndUniformCode(String station, String wtId, String[] uniformCode);
 }

+ 4 - 0
gyee-sample-impala/src/main/resources/application.yaml

@@ -61,6 +61,10 @@ logging:
 databases:
     basictables: windpowerstation,windturbinemetrics,windturbinepoint
 
+# 测点统一编码
+point:
+  uniformcode: AI005,AI012
+