Browse Source

解决冲突

chenminghua 3 years ago
parent
commit
17c00c3d93
15 changed files with 492 additions and 66 deletions
  1. 31 20
      gyee-sample-impala/src/main/java/com/gyee/sampleimpala/common/base/ExcludeQueryWrapper.java
  2. 44 0
      gyee-sample-impala/src/main/java/com/gyee/sampleimpala/controller/CaseFaultAlgController.java
  3. 2 1
      gyee-sample-impala/src/main/java/com/gyee/sampleimpala/controller/CaseFaultController.java
  4. 0 14
      gyee-sample-impala/src/main/java/com/gyee/sampleimpala/controller/CasePerformanceController.java
  5. 122 0
      gyee-sample-impala/src/main/java/com/gyee/sampleimpala/controller/CaseperformanceController.java
  6. 20 13
      gyee-sample-impala/src/main/java/com/gyee/sampleimpala/controller/WindturbinePointController.java
  7. 3 3
      gyee-sample-impala/src/main/java/com/gyee/sampleimpala/model/kudu/Caseperformance.java
  8. 5 3
      gyee-sample-impala/src/main/java/com/gyee/sampleimpala/model/kudu/Windturbine.java
  9. 46 7
      gyee-sample-impala/src/main/java/com/gyee/sampleimpala/service/custom/GoldenService.java
  10. 43 3
      gyee-sample-impala/src/main/java/com/gyee/sampleimpala/service/impl/kudu/CasefaultalgServiceImpl.java
  11. 84 1
      gyee-sample-impala/src/main/java/com/gyee/sampleimpala/service/impl/kudu/CaseperformanceServiceImpl.java
  12. 15 0
      gyee-sample-impala/src/main/java/com/gyee/sampleimpala/service/impl/kudu/WindturbinepointServiceImpl.java
  13. 19 0
      gyee-sample-impala/src/main/java/com/gyee/sampleimpala/service/kudu/CasefaultalgService.java
  14. 52 1
      gyee-sample-impala/src/main/java/com/gyee/sampleimpala/service/kudu/CaseperformanceService.java
  15. 6 0
      gyee-sample-impala/src/main/java/com/gyee/sampleimpala/service/kudu/WindturbinepointService.java

+ 31 - 20
gyee-sample-impala/src/main/java/com/gyee/sampleimpala/common/base/ExcludeQueryWrapper.java

@@ -1,92 +1,103 @@
 package com.gyee.sampleimpala.common.base;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 
+import java.util.Collection;
 import java.util.Objects;
 
 public class ExcludeQueryWrapper<T> extends QueryWrapper<T> {
 
     @Override
     public QueryWrapper<T> eq(boolean condition, String column, Object val) {
-        condition = !Objects.isNull(val);
+        condition = !ObjectUtils.isEmpty(val);
         return super.eq(condition, column, val);
     }
 
     @Override
+    public QueryWrapper<T> in(boolean condition, String column, Collection<?> val) {
+        condition = !(null == val || val.size() <= 0);
+//        condition = !ObjectUtils.isEmpty(val);
+        return super.in(condition, column, val);
+    }
+
+    @Override
     public QueryWrapper<T> ne(boolean condition, String column, Object val) {
-        condition = !Objects.isNull(val);
+        condition = !ObjectUtils.isEmpty(val);
         return super.ne(condition, column, val);
     }
 
     @Override
     public QueryWrapper<T> gt(boolean condition, String column, Object val) {
-        condition = !Objects.isNull(val);
+        condition = !ObjectUtils.isEmpty(val);
         return super.gt(condition, column, val);
     }
 
     @Override
     public QueryWrapper<T> ge(boolean condition, String column, Object val) {
-        condition = !Objects.isNull(val);
+        condition = !ObjectUtils.isEmpty(val);
         return super.ge(condition, column, val);
     }
 
     @Override
     public QueryWrapper<T> lt(boolean condition, String column, Object val) {
-        condition = !Objects.isNull(val);
+        condition = !ObjectUtils.isEmpty(val);
         return super.lt(condition, column, val);
     }
 
     @Override
     public QueryWrapper<T> le(boolean condition, String column, Object val) {
-        condition = !Objects.isNull(val);
+        condition = !ObjectUtils.isEmpty(val);
         return super.le(condition, column, val);
     }
 
     @Override
     public QueryWrapper<T> like(boolean condition, String column, Object val) {
-        condition = !Objects.isNull(val);
+        condition = !ObjectUtils.isEmpty(val);
         return super.like(condition, column, val);
     }
 
     @Override
     public QueryWrapper<T> notLike(boolean condition, String column, Object val) {
-        condition = !Objects.isNull(val);
+        condition = !ObjectUtils.isEmpty(val);
         return super.notLike(condition, column, val);
     }
 
     @Override
     public QueryWrapper<T> likeLeft(boolean condition, String column, Object val) {
-        condition = !Objects.isNull(val);
+        condition = !ObjectUtils.isEmpty(val);
         return super.likeLeft(condition, column, val);
     }
 
     @Override
     public QueryWrapper<T> likeRight(boolean condition, String column, Object val) {
-        condition = !Objects.isNull(val);
+        condition = !ObjectUtils.isEmpty(val);
         return super.likeRight(condition, column, val);
     }
 
     @Override
     public QueryWrapper<T> between(boolean condition, String column, Object val1, Object val2) {
-        if(Objects.isNull(val1) && Objects.isNull(val2)){
+        if (ObjectUtils.isEmpty(val1) && ObjectUtils.isEmpty(val2)) {
             condition = false;
-        }else if(Objects.isNull(val1)){
-            return super.lt(true,column,val2);
-        }else if(Objects.isNull(val2)){
-            return super.ge(true,column,val1);
+        } else if (ObjectUtils.isEmpty(val1)) {
+            return super.lt(true, column, val2);
+        } else if (ObjectUtils.isEmpty(val2)) {
+            return super.ge(true, column, val1);
         }
         return super.between(condition, column, val1, val2);
     }
 
     @Override
     public QueryWrapper<T> notBetween(boolean condition, String column, Object val1, Object val2) {
-        if(Objects.isNull(val1) && Objects.isNull(val2)){
+        if (ObjectUtils.isEmpty(val1) && ObjectUtils.isEmpty(val2)) {
             condition = false;
-        }else if(Objects.isNull(val1)){
-            return super.lt(true,column,val2);
-        }else if(Objects.isNull(val2)){
-            return super.ge(true,column,val1);
+        } else if (ObjectUtils.isEmpty(val1)) {
+            return super.lt(true, column, val2);
+        } else if (ObjectUtils.isEmpty(val2)) {
+            return super.ge(true, column, val1);
         }
         return super.notBetween(condition, column, val1, val2);
     }
+
+
 }

+ 44 - 0
gyee-sample-impala/src/main/java/com/gyee/sampleimpala/controller/CaseFaultAlgController.java

@@ -1,8 +1,10 @@
 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.kudu.Casefault;
 import com.gyee.sampleimpala.model.kudu.Casefaultalg;
 import com.gyee.sampleimpala.model.kudu.Knowfaultfix;
 import com.gyee.sampleimpala.service.kudu.CasefaultalgService;
@@ -48,4 +50,46 @@ public class CaseFaultAlgController {
 
         return JsonResult.error(ResultCode.ERROR);
     }
+
+
+
+
+    /**
+     * 删除样本案例
+     * @param id
+     * @return
+     */
+    @PostMapping("/faultalg/removealgbyid")
+    @ResponseBody
+    public JSONObject stationRemove(@RequestParam(value = "id", required = true) String id){
+
+        boolean flag = casefaultalgService.removeFaultAlgById(id);
+        if (flag){
+            return JsonResult.success(ResultCode.SUCCESS);
+        }
+
+        return JsonResult.error(ResultCode.ERROR);
+    }
+
+
+    /**
+     * 根据条件查询故障
+     * @param station  场站
+     * @param model    风机型号
+     * @param widget   故障部件
+     * @param st       开始时间
+     * @param et       结束时间
+     * @return
+     */
+    @GetMapping("/faultalg/list")
+    public JSONObject faultAlgList(String station, String[] model, String[] widget,
+                                 String st, String et){
+
+        Page<Casefaultalg> page =new Page(1,10);
+        List<Casefaultalg> list = casefaultalgService.getAll(station, model, widget, st, et);
+        return JsonResult.successData(ResultCode.SUCCESS, list);
+    }
+
+
+
 }

+ 2 - 1
gyee-sample-impala/src/main/java/com/gyee/sampleimpala/controller/CaseFaultController.java

@@ -1,6 +1,7 @@
 package com.gyee.sampleimpala.controller;
 
 import com.alibaba.fastjson.JSONObject;
+import com.cloudera.impala.jdbc41.internal.com.cloudera.altus.shaded.javax.ws.rs.HEAD;
 import com.gyee.sampleimpala.common.result.JsonResult;
 import com.gyee.sampleimpala.common.result.ResultCode;
 import com.gyee.sampleimpala.model.kudu.Casefault;
@@ -33,7 +34,7 @@ public class CaseFaultController {
      * @param ids      oracle关联的faultid
      * @return
      */
-    @GetMapping("/fault/all")
+    @GetMapping("/fault/list")
     public JSONObject faultAll(String station, String[] model, String[] widget,
                                  String st, String et, String[] ids){
         List<Casefault> list = casefaultService.getAll(station, model, widget, st, et, ids);

+ 0 - 14
gyee-sample-impala/src/main/java/com/gyee/sampleimpala/controller/CasePerformanceController.java

@@ -1,14 +0,0 @@
-package com.gyee.sampleimpala.controller;
-
-import org.springframework.web.bind.annotation.CrossOrigin;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * 性能下降样本库
- */
-@CrossOrigin
-@RestController
-@RequestMapping("/case")
-public class CasePerformanceController {
-}

+ 122 - 0
gyee-sample-impala/src/main/java/com/gyee/sampleimpala/controller/CaseperformanceController.java

@@ -0,0 +1,122 @@
+package com.gyee.sampleimpala.controller;
+
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.gyee.sampleimpala.common.result.JsonResult;
+import com.gyee.sampleimpala.common.result.ResultCode;
+import com.gyee.sampleimpala.model.kudu.Caseperformance;
+import com.gyee.sampleimpala.service.custom.GoldenService;
+import com.gyee.sampleimpala.service.kudu.CaseperformanceService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+
+/**
+ * 性能样本
+ *
+ * @author w
+ * @since 2021-11-17
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 性能下降样本库
+ */
+@CrossOrigin
+@RestController
+@RequestMapping("/case")
+public class CaseperformanceController {
+
+
+    @Autowired
+    private CaseperformanceService caseperformanceService;
+
+    @Autowired
+    private GoldenService goldenService;
+
+    /**
+     * 获取样本数据
+     *
+     * @param station 场站
+     * @param model   风机模型
+     * @param tag     样本类型
+     * @param st      开始时间
+     * @param et      结束时间
+     * @return
+     */
+    @GetMapping("/performance/list")
+    public JSONObject getPerformanceList(String station, String[] model, Integer tag,
+                                         String st, String et) {
+        List<Caseperformance> list = caseperformanceService.getPerformanceList(station, model, tag, st, et);
+        return JsonResult.successData(ResultCode.SUCCESS, list);
+    }
+
+
+    /**
+     * 新增样本
+     *
+     * @param performance 样本对象
+     * @return
+     */
+    @PostMapping("/performance/add")
+    public JSONObject addPerformance(@RequestBody Caseperformance performance) {
+        boolean flag = caseperformanceService.addPerformance(performance);
+
+        if (flag) {
+            return JsonResult.success(ResultCode.SUCCESS);
+        }
+        return JsonResult.error(ResultCode.ERROR);
+    }
+
+
+    /**
+     * 编辑样本
+     *
+     * @param performance 样本对象
+     * @return
+     */
+    @PostMapping("/performance/edit")
+    public JSONObject editPerformance(@RequestBody Caseperformance performance) {
+        boolean flag = caseperformanceService.editPerformance(performance);
+
+        if (flag) {
+            return JsonResult.success(ResultCode.SUCCESS);
+        }
+        return JsonResult.error(ResultCode.ERROR);
+    }
+
+    /**
+     * 删除样本
+     *
+     * @param id 样本id
+     * @return
+     */
+    @PostMapping("/performance/remove")
+    public JSONObject removePerformance(Integer id) {
+        boolean flag = caseperformanceService.removePerformance(id);
+        if (flag) {
+            return JsonResult.success(ResultCode.SUCCESS);
+        }
+        return JsonResult.error(ResultCode.ERROR);
+    }
+
+
+    /**
+     *
+     * @param id 样本id(数组)
+     * @param interval 数据时间间隔
+     * @return
+     */
+    public JSONObject getCurve(
+            @RequestParam(value = "id",required = false) Integer[] id,
+            @RequestParam(value = "interval",required = false) Integer interval
+    ) {
+
+        return null;
+    }
+
+}

+ 20 - 13
gyee-sample-impala/src/main/java/com/gyee/sampleimpala/controller/WindturbinePointController.java

@@ -2,6 +2,7 @@ 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;
@@ -10,12 +11,10 @@ import com.gyee.sampleimpala.model.kudu.Windturbinepoint;
 import com.gyee.sampleimpala.service.custom.GoldenService;
 import com.gyee.sampleimpala.service.kudu.WindturbinepointService;
 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.List;
+import java.util.Map;
 
 /**
  * 故障样本库操作
@@ -37,10 +36,15 @@ public class WindturbinePointController {
      *
      * @param wtId     风机ID  NG01_01
      * @param widget   部件code  clx
+     * @param wtId 风机编号
+     * @param widget 部件编码
      * @return
      */
-    @GetMapping("/all")
-    public JSONObject pointAll(String wtId, String widget) {
+    @GetMapping("/list")
+    public JSONObject pointAll(
+            @RequestParam(value = "wtId",required = false) String wtId,
+            @RequestParam(value = "widget",required = false) String widget
+    ) {
         List<Windturbinepoint> list = windturbinepointService.getAll(wtId, widget);
         return JsonResult.successData(ResultCode.SUCCESS, list);
     }
@@ -49,19 +53,22 @@ public class WindturbinePointController {
     /**
      * 获取golden原始点数据
      *
-     * @param point    测点
-     * @param startTs
-     * @param endTs
-     * @param interval 等间隔时间  s
+     * @param point []   测点
+     * @param startTs 开始时间(毫秒)
+     * @param endTs 结束时间(毫秒)
+     * @param interval 等间隔时间(秒)
      * @return
      */
     @GetMapping("/item")
-    public JSONObject pointAll(String point, long startTs, long endTs, int interval) {
-        List<TsPointData> list = goldenService.getOriginalData(point, startTs, endTs, interval);
+    public JSONObject pointAll(
+            @RequestParam(value = "point",required = false) String[] point,
+            @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);
         return JsonResult.successData(ResultCode.SUCCESS, list);
     }
 
-
     /**
      * 查询原始点数据
      * @param station

+ 3 - 3
gyee-sample-impala/src/main/java/com/gyee/sampleimpala/model/kudu/Caseperformance.java

@@ -8,7 +8,7 @@ import lombok.EqualsAndHashCode;
 
 /**
  * <p>
- * 
+ *
  * </p>
  *
  * @author chenmh
@@ -19,9 +19,9 @@ import lombok.EqualsAndHashCode;
 @TableName("caseperformance")
 public class Caseperformance extends Model<Caseperformance> {
 
-    private static final long serialVersionUID=1L;
+    private static final long serialVersionUID = 1L;
 
-      private Integer id;
+    private Long id;
 
     private Integer tag;
 

+ 5 - 3
gyee-sample-impala/src/main/java/com/gyee/sampleimpala/model/kudu/Windturbine.java

@@ -2,13 +2,15 @@ package com.gyee.sampleimpala.model.kudu;
 
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
+
 import java.io.Serializable;
+
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
 /**
  * <p>
- * 
+ *
  * </p>
  *
  * @author chenmh
@@ -19,9 +21,9 @@ import lombok.EqualsAndHashCode;
 @TableName("windturbine")
 public class Windturbine extends Model<Windturbine> {
 
-    private static final long serialVersionUID=1L;
+    private static final long serialVersionUID = 1L;
 
-      private String id;
+    private String id;
 
     private String station;
 

+ 46 - 7
gyee-sample-impala/src/main/java/com/gyee/sampleimpala/service/custom/GoldenService.java

@@ -5,12 +5,18 @@ 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.model.custom.TsPointData;
+import com.gyee.sampleimpala.model.kudu.Caseperformance;
+import com.gyee.sampleimpala.model.kudu.Windturbinepoint;
+import com.gyee.sampleimpala.service.kudu.CaseperformanceService;
+import com.gyee.sampleimpala.service.kudu.WindturbinepointService;
 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;
 
 @Slf4j
 @Service
@@ -19,25 +25,44 @@ public class GoldenService {
     @Autowired
     private RemoteServiceBuilder remoteService;
 
+    @Autowired
+    private WindturbinepointService windturbinepointService;
+
+
+    @Autowired
+    private CaseperformanceService caseperformanceService;
+
 
     /**
      * 查询原始数据
-     * @param point
+     * @param points
      * @param startTs  精确到毫秒
      * @param endTs
      * @param interval
      * @return
      */
-    public List<TsPointData> getOriginalData(String point, long startTs, long endTs, int interval){
+    public List<Map> getOriginalData(String[] points, long startTs, long endTs, int interval){
 
-        List<TsPointData> list = new ArrayList<>();
+        List<Map> list = new ArrayList<>();
 
         try{
-            if (interval <= 0){
-                list = remoteService.ShardingService().getHistoryRaw(point, startTs, endTs);
-            }else {
-                list = remoteService.ShardingService().getHistorySnap(point, startTs, endTs, interval);
+
+            for (String point :points){
+                Windturbinepoint w =  windturbinepointService.getByPoint(point);
+                List<TsPointData> data = new ArrayList<>();
+                Map m = new HashMap();
+                if (interval <= 0){
+                    data = remoteService.ShardingService().getHistoryRaw(point, startTs, endTs);
+                }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);
+                list.add(m);
             }
+
         } catch (Exception e){
             log.error(e.getMessage());
             throw new CustomException(ResultCode.ERROR_DATA);
@@ -45,4 +70,18 @@ public class GoldenService {
 
         return list;
     }
+
+
+
+
+    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 null;
+
+    }
 }

+ 43 - 3
gyee-sample-impala/src/main/java/com/gyee/sampleimpala/service/impl/kudu/CasefaultalgServiceImpl.java

@@ -1,10 +1,13 @@
 package com.gyee.sampleimpala.service.impl.kudu;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.gyee.sampleimpala.common.base.ExcludeQueryWrapper;
 import com.gyee.sampleimpala.common.exception.CustomException;
 import com.gyee.sampleimpala.common.result.ResultCode;
 import com.gyee.sampleimpala.mapper.kudu.CasefaultalgMapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.sampleimpala.model.kudu.Casefault;
 import com.gyee.sampleimpala.model.kudu.Casefaultalg;
 import com.gyee.sampleimpala.service.kudu.CasefaultalgService;
 import org.springframework.stereotype.Service;
@@ -17,7 +20,7 @@ import java.util.stream.Collectors;
 
 /**
  * <p>
- *  服务实现类
+ * 服务实现类
  * </p>
  *
  * @author chenmh
@@ -32,7 +35,7 @@ public class CasefaultalgServiceImpl extends ServiceImpl<CasefaultalgMapper, Cas
         if (StringUtils.isEmpty(ids))
             return list;
 
-        try{
+        try {
             // string数组转成List<Integer>
             List<Integer> ls = Arrays.stream(ids).map(s -> Integer.parseInt(s.trim())).collect(Collectors.toList());
             list = baseMapper.selectBatchIds(ls);
@@ -49,7 +52,7 @@ public class CasefaultalgServiceImpl extends ServiceImpl<CasefaultalgMapper, Cas
     public boolean insertOrUpdate(List<Casefaultalg> list) {
         boolean flag = false;
 
-        try{
+        try {
             flag = saveOrUpdateBatch(list);
         } catch (CustomException e) {
             log.error(e.getMessage());
@@ -58,4 +61,41 @@ public class CasefaultalgServiceImpl extends ServiceImpl<CasefaultalgMapper, Cas
 
         return flag;
     }
+
+    @Override
+    public List<Casefaultalg> getAll(String station, String[] model, String[] widget, String st, String et) {
+
+        ExcludeQueryWrapper<Casefaultalg> wrapper = new ExcludeQueryWrapper<>();
+        wrapper.eq("stationid", station)
+                .in("modelid", model)
+                .in("labels", widget)
+                .ge("faultTime", st)
+                .le("faultTime", et);
+
+        List<Casefaultalg> list = new ArrayList<>();
+        try {
+            list = baseMapper.selectList(wrapper);
+        } catch (Exception e) {
+            log.error(e.getMessage());
+            throw new CustomException(ResultCode.ERROR_DATA);
+        }
+
+        return list;
+    }
+
+    @Override
+    public boolean removeFaultAlgById(String id) {
+        QueryWrapper<Casefaultalg> query = new QueryWrapper<>();
+        query.eq("id", id);
+
+        try {
+            baseMapper.delete(query);
+            return true;
+        } catch (CustomException e) {
+            log.error(e.getMessage());
+            throw new CustomException(ResultCode.ERROR_DATA);
+        }
+    }
+
+
 }

+ 84 - 1
gyee-sample-impala/src/main/java/com/gyee/sampleimpala/service/impl/kudu/CaseperformanceServiceImpl.java

@@ -2,14 +2,21 @@ package com.gyee.sampleimpala.service.impl.kudu;
 
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.sampleimpala.common.base.ExcludeQueryWrapper;
+import com.gyee.sampleimpala.common.exception.CustomException;
+import com.gyee.sampleimpala.common.result.ResultCode;
+import com.gyee.sampleimpala.common.util.SnowFlakeGenerator;
 import com.gyee.sampleimpala.mapper.kudu.CaseperformanceMapper;
 import com.gyee.sampleimpala.model.kudu.Caseperformance;
 import com.gyee.sampleimpala.service.kudu.CaseperformanceService;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * <p>
- *  服务实现类
+ * 服务实现类
  * </p>
  *
  * @author chenmh
@@ -18,4 +25,80 @@ import org.springframework.stereotype.Service;
 @Service
 public class CaseperformanceServiceImpl extends ServiceImpl<CaseperformanceMapper, Caseperformance> implements CaseperformanceService {
 
+    @Override
+    public List<Caseperformance> getPerformanceList(String station, String[] model, Integer tag, String st, String et) {
+        ExcludeQueryWrapper<Caseperformance> wrapper = new ExcludeQueryWrapper<>();
+        wrapper.eq("stationen", station)
+                .in("model", model)
+                .eq("tag", tag)
+                .ge("starttime", st)
+                .le("endtime", et);
+
+        List<Caseperformance> list = new ArrayList<>();
+        try {
+            list = baseMapper.selectList(wrapper);
+        } catch (Exception e) {
+            log.error(e.getMessage());
+            throw new CustomException(ResultCode.ERROR_DATA);
+        }
+        return list;
+    }
+
+    @Override
+    public boolean addPerformance(Caseperformance performance) {
+        try {
+            // 设置一个新ID
+            if (performance != null && performance.getId() <= 0)
+                performance.setId(Long.valueOf(SnowFlakeGenerator.generateId()));
+
+            int code = baseMapper.insert(performance);
+            if (code > 0) {
+                return true;
+            }
+            return false;
+        } catch (CustomException e) {
+            log.error(e.getMessage());
+            throw new CustomException(ResultCode.ERROR_DATA);
+        }
+    }
+
+    @Override
+    public boolean removePerformance(Integer id) {
+
+        int code = 0;
+        try {
+            code = baseMapper.deleteById(id);
+            if (code > 0) {
+                return true;
+            }
+            return false;
+        } catch (CustomException e) {
+            log.error(e.getMessage());
+            throw new CustomException(ResultCode.ERROR_DATA);
+        }
+
+    }
+
+    @Override
+    public boolean editPerformance(Caseperformance performance) {
+        try {
+            int code = baseMapper.updateById(performance);
+            if (code > 0) {
+                return true;
+            }
+            return false;
+
+        } catch (CustomException e) {
+            log.error(e.getMessage());
+            throw new CustomException(ResultCode.ERROR_DATA);
+        }
+    }
+
+    @Override
+    public Caseperformance getPerformanceByid(Integer id) {
+        Caseperformance cp = baseMapper.selectById(id);
+        return cp;
+    }
+
+
 }

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

@@ -124,4 +124,19 @@ public class WindturbinepointServiceImpl extends ServiceImpl<WindturbinepointMap
 //        }
         return null;
     }
+
+    public Windturbinepoint getByPoint(String point) {
+        List<Windturbinepoint> list = new ArrayList<>();
+        try {
+            ExcludeQueryWrapper<Windturbinepoint> wrapper = new ExcludeQueryWrapper<>();
+            wrapper.eq("point", point);
+
+            list = baseMapper.selectList(wrapper);
+
+        } catch (CustomException e){
+            log.error(e.getMessage());
+            throw new CustomException(ResultCode.ERROR_DATA);
+        }
+        return list.get(0);
+    }
 }

+ 19 - 0
gyee-sample-impala/src/main/java/com/gyee/sampleimpala/service/kudu/CasefaultalgService.java

@@ -28,4 +28,23 @@ public interface CasefaultalgService extends IService<Casefaultalg> {
      * @return
      */
     boolean insertOrUpdate(List<Casefaultalg> list);
+
+    /**
+     * 根据条查询故障
+     * @param station  场站
+     * @param model    风机型号
+     * @param widget   故障部件
+     * @param st       开始时间
+     * @param et       结束时间
+     * @return
+     */
+    List<Casefaultalg> getAll(String station, String[] model, String[] widget, String st, String et);
+
+
+    /**
+     * 通过id删除数据
+     * @param id ID
+     * @return
+     */
+    boolean removeFaultAlgById(String id);
 }

+ 52 - 1
gyee-sample-impala/src/main/java/com/gyee/sampleimpala/service/kudu/CaseperformanceService.java

@@ -3,9 +3,11 @@ package com.gyee.sampleimpala.service.kudu;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.gyee.sampleimpala.model.kudu.Caseperformance;
 
+import java.util.List;
+
 /**
  * <p>
- *  服务类
+ * 服务类
  * </p>
  *
  * @author chenmh
@@ -13,4 +15,53 @@ import com.gyee.sampleimpala.model.kudu.Caseperformance;
  */
 public interface CaseperformanceService extends IService<Caseperformance> {
 
+    /**
+     * 获取样本数据
+     *
+     * @param station 场站
+     * @param model   风机模型
+     * @param tag     样本类型
+     * @param st      开始时间
+     * @param et      结束时间
+     * @return
+     */
+    List<Caseperformance> getPerformanceList(String station, String[] model, Integer tag,
+                                             String st, String et);
+
+
+    /**
+     * 编辑样本
+     *
+     * @param performance 样本对象
+     * @return
+     */
+    boolean addPerformance(Caseperformance performance);
+
+
+    /**
+     * 删除样本
+     *
+     * @param id 样本id
+     * @return
+     */
+    boolean removePerformance(Integer id);
+
+
+    /**
+     * 编辑样本
+     *
+     * @param performance 样本对象
+     * @return
+     */
+    boolean editPerformance(Caseperformance performance);
+
+    /**
+     * 根据id获取样本
+     *
+     * @param id 样本id
+     * @return
+     */
+    Caseperformance getPerformanceByid(Integer id);
+
+
 }

+ 6 - 0
gyee-sample-impala/src/main/java/com/gyee/sampleimpala/service/kudu/WindturbinepointService.java

@@ -67,4 +67,10 @@ public interface WindturbinepointService extends IService<Windturbinepoint> {
     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);
 }