chenminghua il y a 2 ans
Parent
commit
e2a957e3f7

+ 6 - 3
gyee-sample-impala/src/main/java/com/gyee/impala/common/feign/IShardingService.java

@@ -12,11 +12,14 @@ import java.util.List;
 
 public interface IShardingService {
 
-  @RequestLine("GET /fault/history/list?pagenum=1&pagesize=500&stationid={stationid}&starttime={starttime}&endtime={endtime}&messagetype=1")
+  @RequestLine("GET /fault/history/list?category1={category1}&category2={category2}&pagenum=1&pagesize=5000&stationid={stationid}&starttime={starttime}&endtime={endtime}&messagetype={messagetype}")
   List<FaultInfo> getFaultInfoList(
-          @Param(value = "stationid") String stationid,
+          @Param(value = "category1") String category1,
+          @Param(value = "category2") String category2,
           @Param(value = "starttime") String starttime,
-          @Param(value = "endtime") String endtime);
+          @Param(value = "endtime") String endtime,
+          @Param(value = "stationid") String stationid,
+          @Param(value = "messagetype") int messagetype);
 
   @RequestLine("GET /fault/recent?faulttime={faulttime}")
   List<FaultInfo> getFaultRecent(@Param(value = "faulttime") String faulttime);

+ 6 - 16
gyee-sample-impala/src/main/java/com/gyee/impala/controller/diagnose/DiagnoseFaultController.java

@@ -48,27 +48,17 @@ public class DiagnoseFaultController {
                               @RequestParam(value = "algcode", required = false) String algcode,
                               @RequestParam(value = "confirm", required = false) Optional<Boolean> confirm){
         boolean conf = confirm.isPresent() ? confirm.get() : false;
+        List<Casefaultalg> list = casefaultalgService.getAll(station, wtId, id, faultid, model, faultcode, st, et, algcode, conf);
         if (conf){
-            List<Casefaultalg> list = casefaultalgService.getAll(station, wtId, id, faultid, model, faultcode, st, et, algcode, false);
             return JsonResult.successData(ResultCode.SUCCESS, list);
         }else{
             List<Casefaultalg> array = new ArrayList<>();
-            List<Casefaultalg> list = casefaultalgService.getAll(station, wtId, id, faultid, model, faultcode, st, et, algcode, false);
-            List<FaultInfo> faults = remoteServiceBuilder.sharding().getFaultRecent(et);
-            List<FaultInfo> collect = faults.stream()
-                    .filter(f -> f.getCategory1().equals("FJ") && f.getCategory2().equals("GZ"))
-                    .filter(a -> StringUtils.isEmpty(station) || a.getStationId().equals(station))
-                    .filter(a -> StringUtils.isEmpty(wtId) || a.getWindturbineId().equals(wtId))
-                    .collect(Collectors.toList());
-            for (int i = 0; i < collect.size(); i++){
-                FaultInfo info = collect.get(i);
-                if (list == null || list.size() == 0){
+            Map<Long, List<Casefaultalg>> map = list.stream().collect(Collectors.groupingBy(Casefaultalg::getFaultid));
+            List<FaultInfo> faults = remoteServiceBuilder.sharding().getFaultInfoList("FJ", "GZ", st, et, station, 1);
+            for (int i = 0; i < faults.size(); i++){
+                FaultInfo info = faults.get(i);
+                if (!map.containsKey(info.getIdString()))
                     array.add(format(info));
-                }else{
-                    List<Casefaultalg> ls = list.stream().filter(a -> a.getFaultid().equals(info.getId())).collect(Collectors.toList());
-                    if (ls.size() == 0)
-                        array.add(format(info));
-                }
             }
             return JsonResult.successData(ResultCode.SUCCESS, array);
         }

+ 6 - 2
gyee-sample-impala/src/main/java/com/gyee/impala/controller/diagnose/DiagnoseReportController.java

@@ -16,6 +16,7 @@ import com.gyee.impala.model.master.diagnose.Diagnosetrainhistory;
 import com.gyee.impala.service.custom.diagnose.AlarmService;
 import com.gyee.impala.service.master.CasefaultalgService;
 import com.gyee.impala.service.master.diagnose.DiagnosereportService;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.CrossOrigin;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -72,11 +73,13 @@ public class DiagnoseReportController {
             if (mappoint.containsKey(t.getMeasuring_point()))
                 collect.add(t);
         }
-        history.get(0).setPointweight(JSON.toJSONString(collect));
+
+        Diagnosetrainhistory h = (Diagnosetrainhistory) history.get(0).clone();
+        h.setPointweight(JSON.toJSONString(collect));
 
         Map<String, Object> map = new HashMap<>();
         map.put("fault", fault);
-        map.put("info", history);
+        map.put("info", h);
         map.put("alarm", alarm);
         map.put("curve", mappoint);
         return JsonResult.successData(ResultCode.SUCCESS, map);
@@ -131,4 +134,5 @@ public class DiagnoseReportController {
 
         return JsonResult.successData(ResultCode.SUCCESS, map);
     }
+
 }

+ 4 - 198
gyee-sample-impala/src/main/java/com/gyee/impala/model/custom/diagnose/FaultInfo.java

@@ -1,8 +1,11 @@
 package com.gyee.impala.model.custom.diagnose;
 
+import lombok.Data;
+
 /**
  * @author xysn
  */
+@Data
 public class FaultInfo {
     private long id;
     //报警时间
@@ -54,205 +57,8 @@ public class FaultInfo {
 
     private String modelId;
 
-    public long getId() {
-        return id;
-    }
-
-    public void setId(long id) {
-        this.id = id;
-    }
-
-    public String getFaultTime() {
-        return faultTime;
-    }
-
-    public void setFaultTime(String faultTime) {
-        this.faultTime = faultTime;
-    }
-
-    public int getMessageType() {
-        return messageType;
-    }
-
-    public void setMessageType(int messageType) {
-        this.messageType = messageType;
-    }
-
-    public long getSnapID() {
-        return snapID;
-    }
-
-    public void setSnapID(long snapID) {
-        this.snapID = snapID;
-    }
-
-    public Integer getConfirmType() {
-        return confirmType;
-    }
-
-    public void setConfirmType(Integer confirmType) {
-        this.confirmType = confirmType;
-    }
-
-    public String getConfirmTime() {
-        return confirmTime;
-    }
-
-    public void setConfirmTime(String confirmTime) {
-        this.confirmTime = confirmTime;
-    }
-
-    public String getConfirmPerson() {
-        return confirmPerson;
-    }
-
-    public void setConfirmPerson(String confirmPerson) {
-        this.confirmPerson = confirmPerson;
-    }
-
-    public String getStationId() {
-        return stationId;
-    }
-
-    public void setStationId(String stationId) {
-        this.stationId = stationId;
-    }
-
-    public String getProjectId() {
-        return projectId;
-    }
-
-    public void setProjectId(String projectId) {
-        this.projectId = projectId;
-    }
-
-    public String getLineId() {
-        return lineId;
-    }
-
-    public void setLineId(String lineId) {
-        this.lineId = lineId;
-    }
-
-    public String getWindturbineId() {
-        return windturbineId;
-    }
-
-    public void setWindturbineId(String windturbineId) {
-        this.windturbineId = windturbineId;
-    }
-
-    public long getAlertValue() {
-        return alertValue;
-    }
-
-    public void setAlertValue(long alertValue) {
-        this.alertValue = alertValue;
-    }
-
-    public String getRank() {
-        return rank;
-    }
+    private String idString;
 
-    public void setRank(String rank) {
-        this.rank = rank;
-    }
-
-    public String getCategory1() {
-        return category1;
-    }
-
-    public void setCategory1(String category1) {
-        this.category1 = category1;
-    }
-
-    public String getCategory2() {
-        return category2;
-    }
-
-    public void setCategory2(String category2) {
-        this.category2 = category2;
-    }
-
-    public String getCategory3() {
-        return category3;
-    }
-
-    public void setCategory3(String category3) {
-        this.category3 = category3;
-    }
-
-    public boolean isOpened() {
-        return isOpened;
-    }
-
-    public void setOpened(boolean opened) {
-        isOpened = opened;
-    }
-
-    public String getLastUpdateTime() {
-        return lastUpdateTime;
-    }
-
-    public void setLastUpdateTime(String lastUpdateTime) {
-        this.lastUpdateTime = lastUpdateTime;
-    }
-
-    public String getLastUpdatePerson() {
-        return lastUpdatePerson;
-    }
-
-    public void setLastUpdatePerson(String lastUpdatePerson) {
-        this.lastUpdatePerson = lastUpdatePerson;
-    }
-
-    public String getStationName() {
-        return stationName;
-    }
-
-    public void setStationName(String stationName) {
-        this.stationName = stationName;
-    }
-
-    public String getProjectName() {
-        return projectName;
-    }
-
-    public void setProjectName(String projectName) {
-        this.projectName = projectName;
-    }
-
-    public String getLineName() {
-        return lineName;
-    }
-
-    public void setLineName(String lineName) {
-        this.lineName = lineName;
-    }
-
-    public String getWindturbineName() {
-        return windturbineName;
-    }
-
-    public void setWindturbineName(String windturbineName) {
-        this.windturbineName = windturbineName;
-    }
-
-    public String getAlertText() {
-        return alertText;
-    }
-
-    public void setAlertText(String alertText) {
-        this.alertText = alertText;
-    }
-
-    public String getModelId() {
-        return modelId;
-    }
-
-    public void setModelId(String modelId) {
-        this.modelId = modelId;
-    }
 
     @Override
     public String toString() {

+ 6 - 8
gyee-sample-impala/src/main/java/com/gyee/impala/model/custom/diagnose/TrainPointWeight.java

@@ -1,18 +1,16 @@
 package com.gyee.impala.model.custom.diagnose;
 
-import com.alibaba.fastjson.annotation.JSONField;
 import lombok.Data;
 
 @Data
 public class TrainPointWeight {
 
-    @JSONField(name = "Importance")
-    private String Importance;
-    @JSONField(name = "UniformCode")
-    private String UniformCode;
-    @JSONField(name = "Measuring_point")
-    private String Measuring_point;
-    @JSONField(name = "index")
+    private String importance;
+
+    private String uniformCode;
+
+    private String measuring_point;
+
     private int index;
 
 }

+ 12 - 1
gyee-sample-impala/src/main/java/com/gyee/impala/model/master/diagnose/Diagnosetrainhistory.java

@@ -14,7 +14,7 @@ import lombok.EqualsAndHashCode;
 @Data
 @EqualsAndHashCode(callSuper = false)
 @TableName("diagnosetrainhistory")
-public class Diagnosetrainhistory extends Model<Diagnosetrainhistory> {
+public class Diagnosetrainhistory extends Model<Diagnosetrainhistory> implements Cloneable{
 
     private String id;
 
@@ -85,4 +85,15 @@ public class Diagnosetrainhistory extends Model<Diagnosetrainhistory> {
      */
     @TableField(exist = false)
     private double precision;
+
+    @Override
+    public Object clone() {
+        Diagnosetrainhistory h = null;
+        try {
+            h = (Diagnosetrainhistory) super.clone();
+        } catch (CloneNotSupportedException e) {
+            e.printStackTrace();
+        }
+        return h;
+    }
 }

+ 2 - 2
gyee-sample-impala/src/main/java/com/gyee/impala/service/impl/master/diagnose/DiagnosereportServiceImpl.java

@@ -87,8 +87,8 @@ public class DiagnosereportServiceImpl extends ServiceImpl<DiagnosereportMapper,
         List<Diagnosepoint> newpoint = new ArrayList<>();
         for (Iterator iterator = jarr.iterator(); iterator.hasNext(); ) {
             JSONObject job = (JSONObject) iterator.next();
-            String uniformCode = job.get("UniformCode").toString();
-            Double importance  = Double.valueOf(job.get("Importance").toString());
+            String uniformCode = job.get("uniformCode").toString();
+            Double importance  = Double.valueOf(job.get("importance").toString());
             if(importance<1){
                 continue;
             }