Bläddra i källkod

修正装机容量初始值和报警信息非空验证

shilin 3 år sedan
förälder
incheckning
984982d214

+ 21 - 0
web/health-hb/src/main/java/com/gyee/frame/common/conf/V2Config.java

@@ -56,6 +56,27 @@ public class V2Config
     /**测点初始码**/
     private  static  String initialcode;
 
+
+    private  static  String adapterUrl;
+
+    private  static  String alarmUrl;
+
+    public static String getAdapterUrl() {
+        return adapterUrl;
+    }
+
+    public  void setAdapterUrl(String adapterUrl) {
+        V2Config.adapterUrl = adapterUrl;
+    }
+
+    public static String getAlarmUrl() {
+        return alarmUrl;
+    }
+
+    public  void setAlarmUrl(String alarmUrl) {
+        V2Config.alarmUrl = alarmUrl;
+    }
+
     public static String getInitialcode() {
         return initialcode;
     }

+ 28 - 4
web/health-hb/src/main/java/com/gyee/frame/common/feign/IAdapterService.java

@@ -1,13 +1,11 @@
 package com.gyee.frame.common.feign;
 
 import com.alibaba.fastjson.JSONObject;
+import com.gyee.frame.common.domain.AjaxResult;
 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;
 
@@ -28,10 +26,36 @@ public interface IAdapterService {
     @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);
+                                    @Param(value = "endTs") long endTs);
 
     @Headers({"Content-Type: application/json", "Accept: application/json"})
     @RequestLine("GET /ts/history/section?tagNames={tagNames}&ts={ts}")
     List<TsPointData> getHistorySection(@Param(value = "tagNames") String tagNames, @Param(value = "ts") long ts);
 
+    @Headers({"Content-Type: application/json", "Accept: application/json"})
+    @RequestLine("GET /alarm/count/query/new2?stationid={stationid}&startdate={startdate}&enddate={enddate}")
+    AjaxResult getEarlyWarning(@Param(value = "stationid") String stationid, @Param(value = "startdate") String startdate,
+                               @Param(value = "enddate") String enddate);
+
+    @Headers({"Content-Type: application/json", "Accept: application/json"})
+    @RequestLine("GET /shutdown/list?stId={stId}&endDate={endDate}&startDate={startDate}")
+    AjaxResult getHith(@Param(value = "stId") String stId, @Param(value = "endDate") String endDate,
+                       @Param(value = "startDate") String startDate);
+
+    @Headers({"Content-Type: application/json", "Accept: application/json"})
+    @RequestLine("GET /alarm/history/page2?pagenum={pagenum}&pagesize={pagesize}&stationid={stationid}&windturbineid={windturbineid}" +
+            "&category1={category1}&category2={category2}&rank={rank}&modelid={modelid}&snapid={snapid}&messagetype={messagetype}" +
+            "&keyword={keyword}&starttime={starttime}&endtime={endtime}")
+    AjaxResult getPage(@Param(value = "pagenum") Integer pagenum, @Param(value = "pagesize") Integer pagesize,
+                       @Param(value = "stationid") String stationid,
+                       @Param(value = "windturbineid") String windturbineid,
+                       @Param(value = "category1") String category1,
+                       @Param(value = "category2") String category2,
+                       @Param(value = "rank") String rank,
+                       @Param(value = "modelid") String modelid,
+                       @Param(value = "snapid") Long snapid,
+                       @Param(value = "messagetype") Integer messagetype,
+                       @Param(value = "keyword") String keyword,
+                       @Param(value = "starttime") String starttime,
+                       @Param(value = "endtime") String endtime);
 }

+ 13 - 5
web/health-hb/src/main/java/com/gyee/frame/common/feign/RemoteServiceBuilder.java

@@ -1,12 +1,12 @@
 package com.gyee.frame.common.feign;
 
+import com.gyee.frame.common.conf.V2Config;
 import feign.Feign;
 import feign.Request;
 import feign.Retryer;
 import feign.jackson.JacksonDecoder;
 import feign.jackson.JacksonEncoder;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
@@ -15,9 +15,6 @@ import org.springframework.context.annotation.Configuration;
 @Configuration
 public class RemoteServiceBuilder {
 
-    @Value("${goldenUrl:http://10.155.32.4:8011}")
-    private String shardingUrlString;
-
     @Bean
     public IAdapterService ShardingService() {
         return Feign.builder()
@@ -25,6 +22,17 @@ public class RemoteServiceBuilder {
                 .decoder(new JacksonDecoder())
                 .options(new Request.Options(5000, 600000))
                 .retryer(new Retryer.Default(10000, 10000, 3))
-                .target(IAdapterService.class, shardingUrlString);
+                .target(IAdapterService.class, V2Config.getAdapterUrl());
+    }
+
+    @Bean
+    public IAdapterService earlyService() {
+        return Feign.builder()
+                .encoder(new JacksonEncoder())
+                .decoder(new JacksonDecoder())
+                .options(new Request.Options(5000, 600000))
+                .retryer(new Retryer.Default(10000, 10000, 3))
+                .target(IAdapterService.class, V2Config.getAlarmUrl());
     }
+
 }

+ 44 - 0
web/health-hb/src/main/java/com/gyee/frame/controller/radar/RadarController.java

@@ -0,0 +1,44 @@
+package com.gyee.frame.controller.radar;
+
+import com.gyee.frame.common.domain.AjaxResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+
+@Controller
+@RequestMapping("/radar")
+@Api(value = "故障与预警分类统计", tags = "故障与预警分类统计")
+public class RadarController {
+    @Resource
+    private com.gyee.frame.service.redar.RedarService RedarService;
+
+
+    @GetMapping("/gzfx")
+    @ResponseBody
+    @ApiOperation(value = "故障分析雷达图", notes = "故障分析雷达图")
+    public AjaxResult gzfx(@RequestParam(value = "stationid", required = true) String stationid,
+                           @RequestParam(value = "date", required = true) String date) {
+        List<List<Map>> hitch = RedarService.hitch(stationid,date);
+
+        return AjaxResult.successData(200, hitch);
+    }
+
+    @GetMapping("/yjfx")
+    @ResponseBody
+    @ApiOperation(value = "预警分析雷达图", notes = "预警分析雷达图")
+    public AjaxResult yjfx(@RequestParam(value = "stationid", required = true) String stationid,
+                           @RequestParam(value = "date", required = true) String date){
+        List<List<Map>> warning = RedarService.warning(stationid,date);
+
+        return AjaxResult.successData(200, warning);
+    }
+
+}

+ 273 - 0
web/health-hb/src/main/java/com/gyee/frame/service/redar/RedarService.java

@@ -0,0 +1,273 @@
+package com.gyee.frame.service.redar;
+
+import cn.hutool.core.date.DatePattern;
+import cn.hutool.core.date.DateUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.gyee.frame.common.domain.AjaxResult;
+import com.gyee.frame.common.feign.RemoteServiceBuilder;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.text.DecimalFormat;
+import java.util.*;
+
+@Service
+public class RedarService {
+    private static final Logger log = LoggerFactory.getLogger(RedarService.class);
+
+    @Resource
+    private RemoteServiceBuilder remoteService;
+
+    public List<List<Map>> hitch(String stId, String Date) {
+
+        Map<String, String> TimeMap = new LinkedHashMap<>();
+
+        //年份
+        TimeMap.put("yearstarttime", DateUtil.format(DateUtil.beginOfYear(DateUtil.parseDate(Date)), DatePattern.NORM_DATETIME_MINUTE_PATTERN));
+        TimeMap.put("yearendtime", DateUtil.format(DateUtil.endOfYear(DateUtil.parseDate(Date)), DatePattern.NORM_DATETIME_MINUTE_PATTERN));
+        //月份
+        TimeMap.put("monthstarttime", DateUtil.format(DateUtil.beginOfMonth(DateUtil.parseDate(Date)), DatePattern.NORM_DATETIME_MINUTE_PATTERN));
+        TimeMap.put("monthendtime", DateUtil.format(DateUtil.endOfMonth(DateUtil.parseDate(Date)), DatePattern.NORM_DATETIME_MINUTE_PATTERN));
+        //一天
+        TimeMap.put("daystarttime", DateUtil.format(DateUtil.beginOfDay(DateUtil.offsetDay(DateUtil.parseDate(Date),-1)), DatePattern.NORM_DATETIME_MINUTE_PATTERN));
+        TimeMap.put("dayendtime", DateUtil.format(DateUtil.endOfDay(DateUtil.parseDate(Date)), DatePattern.NORM_DATETIME_MINUTE_PATTERN));
+
+        AjaxResult year = remoteService.earlyService().getHith(stId,TimeMap.get("yearstarttime"),TimeMap.get("yearendtime"));
+
+        AjaxResult month = remoteService.earlyService().getHith(stId,TimeMap.get("monthstarttime"),TimeMap.get("monthendtime"));
+
+        AjaxResult day = remoteService.earlyService().getHith(stId,TimeMap.get("daystarttime"),TimeMap.get("dayendtime"));
+
+
+        String jsonStr = JSON.toJSONString(year);
+        List<Map> year1 = parseJSON(jsonStr);
+
+        String jsonStr1 = JSON.toJSONString(month);
+        List<Map> month1 = parseJSON(jsonStr1);
+
+        String jsonStr2 = JSON.toJSONString(day);
+        List<Map> day1 = parseJSON(jsonStr2);
+
+        List<List<Map>> ui = new ArrayList<>();
+        ui.add(year1);
+        ui.add(month1);
+        ui.add(day1);
+        return ui;
+    }
+
+
+    public List<Map> parseJSON(String jsonData) {
+        try {
+            JSONObject object = JSON.parseObject(jsonData);
+            JSONArray data1 = object.getJSONArray("data");
+
+            double count = 0;
+            int time = 0;
+
+            int bj = 0;
+            int fjqt = 0;
+            int fdj = 0;
+            int clx = 0;
+            int bpq = 0;
+            int zz = 0;
+            int hh = 0;
+            int ph = 0;
+            int yy = 0;
+            int lq = 0;
+            int rh = 0;
+            int kz = 0;
+            int jcjr = 0;
+
+            for (int i = 0; i < data1.size(); i++) {
+                JSONObject objecti = data1.getJSONObject(i);
+                Set<String> keys = objecti.keySet();
+                for (String key : keys) {
+                    JSONArray array = objecti.getJSONArray(key);
+                    for (int j = 0; j < array.size(); j++) {
+                        JSONObject jsonObject = array.getJSONObject(j);
+
+                        count += jsonObject.getInteger("count");
+                        time += jsonObject.getInteger("time");
+
+                        String c = jsonObject.getString("typeID");
+
+                        if (c.equals("bj")) {
+                            bj += jsonObject.getInteger("count");
+                        } else if (c.equals("fjqt")) {
+                            fjqt += jsonObject.getInteger("count");
+                        } else if (c.equals("fdj")) {
+                            fdj += jsonObject.getInteger("count");
+                        } else if (c.equals("clx")) {
+                            clx += jsonObject.getInteger("count");
+                        } else if (c.equals("bpq")) {
+                            bpq += jsonObject.getInteger("count");
+                        } else if (c.equals("zz")) {
+                            zz += jsonObject.getInteger("count");
+                        } else if (c.equals("hh")) {
+                            hh += jsonObject.getInteger("count");
+                        } else if (c.equals("ph")) {
+                            ph += jsonObject.getInteger("count");
+                        } else if (c.equals("yy")) {
+                            yy += jsonObject.getInteger("count");
+                        } else if (c.equals("lq")) {
+                            lq += jsonObject.getInteger("count");
+                        } else if (c.equals("rh")) {
+                            rh += jsonObject.getInteger("count");
+                        } else if (c.equals("kz")) {
+                            kz += jsonObject.getInteger("count");
+                        } else if (c.equals("jcjr")) {
+                            jcjr += jsonObject.getInteger("count");
+                        }
+                    }
+                }
+            }
+
+            List<Map> conver = new ArrayList<>();
+
+            DecimalFormat df = new DecimalFormat("0.00");
+
+            Map<String, String> year = new LinkedHashMap<>();
+            year.put("bj", count!=0 ?df.format(bj / count):0.0+"");
+            year.put("fjqt", count!=0 ?df.format(fjqt / count):0.0+"");
+            year.put("fdj", count!=0 ?df.format(fdj / count):0.0+"");
+            year.put("clx", count!=0 ?df.format(clx / count):0.0+"");
+            year.put("bpq", count!=0 ?df.format(bpq / count):0.0+"");
+            year.put("zz", count!=0 ?df.format(zz / count):0.0+"");
+            year.put("hh", count!=0 ?df.format(hh / count):0.0+"");
+            year.put("ph", count!=0 ?df.format(ph / count):0.0+"");
+            year.put("yy", count!=0 ?df.format(yy / count):0.0+"");
+            year.put("lq", count!=0 ?df.format(lq / count):0.0+"");
+            year.put("rh", count!=0 ?df.format(rh / count):0.0+"");
+            year.put("kz", count!=0 ?df.format(kz / count):0.0+"");
+            year.put("jcjr", count!=0 ?df.format(jcjr / count):0.0+"");
+
+            conver.add(year);
+            return  conver;
+
+        } catch (Exception e) {
+            System.out.println(e.getMessage());
+        }
+
+        return null;
+    }
+
+
+    public List<List<Map>> warning(String stationid, String date) {
+
+        Map<String, String> TimeMap = new LinkedHashMap<>();
+        //年份
+        TimeMap.put("yearstarttime", DateUtil.format(DateUtil.beginOfYear(DateUtil.parseDate(date)), DatePattern.NORM_DATETIME_MINUTE_PATTERN));
+        TimeMap.put("yearendtime", DateUtil.format(DateUtil.endOfYear(DateUtil.parseDate(date)), DatePattern.NORM_DATETIME_MINUTE_PATTERN));
+        //月份
+        TimeMap.put("monthstarttime", DateUtil.format(DateUtil.beginOfMonth(DateUtil.parseDate(date)), DatePattern.NORM_DATETIME_MINUTE_PATTERN));
+        TimeMap.put("monthendtime", DateUtil.format(DateUtil.endOfMonth(DateUtil.parseDate(date)), DatePattern.NORM_DATETIME_MINUTE_PATTERN));
+        //一天
+        TimeMap.put("daystarttime", DateUtil.format(DateUtil.beginOfDay(DateUtil.offsetDay(DateUtil.parseDate(date),-1)), DatePattern.NORM_DATETIME_MINUTE_PATTERN));
+        TimeMap.put("dayendtime", DateUtil.format(DateUtil.endOfDay(DateUtil.parseDate(date)), DatePattern.NORM_DATETIME_MINUTE_PATTERN));
+
+        AjaxResult year = remoteService.earlyService().getEarlyWarning(stationid,TimeMap.get("yearstarttime"),TimeMap.get("yearendtime"));
+
+        AjaxResult month = remoteService.earlyService().getEarlyWarning(stationid,TimeMap.get("monthstarttime"),TimeMap.get("monthendtime"));
+
+        AjaxResult day = remoteService.earlyService().getEarlyWarning(stationid,TimeMap.get("daystarttime"),TimeMap.get("dayendtime"));
+
+        List<List<Map>> fh = new ArrayList<>();
+        String jsonStr1 = JSON.toJSONString(year);
+        List<Map> year1 = pron(jsonStr1);
+
+        String jsonStr2 = JSON.toJSONString(month);
+        List<Map> month1 = pron(jsonStr2);
+
+        String jsonStr3 = JSON.toJSONString(day);
+        List<Map> day1 = pron(jsonStr3);
+
+        fh.add(year1);
+        fh.add(month1);
+        fh.add(day1);
+        return fh;
+    }
+
+    public List<Map> pron(String jsonData1) {
+        JSONObject object = JSON.parseObject(jsonData1);
+        JSONArray data2 = object.getJSONArray("data");
+
+        double count = 0;
+        int time = 0;
+
+        int CFXT = 0;
+        int CDL = 0;
+        int FDJ = 0;
+        int BJXT = 0;
+        int CLX = 0;
+        int YYXT = 0;
+        int PHXT = 0;
+        int JC = 0;
+        int QT = 0;
+        int TDG = 0;
+        for (int i = 0; i < data2.size(); i++) {
+            JSONObject objecti = data2.getJSONObject(i);
+            Set<String> keys = objecti.keySet();
+            for (String key : keys) {
+                JSONArray array = objecti.getJSONArray(key);
+                for (int j = 0; j < array.size(); j++) {
+                    JSONObject jsonObject = array.getJSONObject(j);
+
+                    count += jsonObject.getInteger("count");
+                    time += jsonObject.getInteger("time");
+
+                    String c = jsonObject.getString("relateParts");
+                    if (StringUtils.isEmpty(c))
+                        continue;
+
+                    if (c.equals("CFXT")) {
+                        CFXT += jsonObject.getInteger("count");
+                    } else if (c.equals("CDL")) {
+                        CDL += jsonObject.getInteger("count");
+                    } else if (c.equals("FDJ")) {
+                        FDJ += jsonObject.getInteger("count");
+                    } else if (c.equals("BJXT")) {
+                        BJXT += jsonObject.getInteger("count");
+                    } else if (c.equals("CLX")) {
+                        CLX += jsonObject.getInteger("count");
+                    } else if (c.equals("YYXT")) {
+                        YYXT += jsonObject.getInteger("count");
+                    } else if (c.equals("PHXT")) {
+                        PHXT += jsonObject.getInteger("count");
+                    } else if (c.equals("JC")) {
+                        JC += jsonObject.getInteger("count");
+                    } else if (c.equals("QT")) {
+                        QT += jsonObject.getInteger("count");
+                    } else if (c.equals("TDG")) {
+                        TDG += jsonObject.getInteger("count");
+                    }
+                }
+            }
+        }
+
+        List<Map> conver = new ArrayList<>();
+
+        DecimalFormat df = new DecimalFormat("0.00");
+
+        Map<String, String> year = new LinkedHashMap<>();
+        year.put("CFXT",count!=0 ? df.format(CFXT / count):0.0+"");
+        year.put("CDL",count!=0 ? df.format(CDL / count):0.0+"");
+        year.put("FDJ",count!=0 ? df.format(FDJ / count):0.0+"");
+        year.put("BJXT",count!=0 ? df.format(BJXT / count):0.0+"");
+        year.put("CLX",count!=0 ? df.format(CLX / count):0.0+"");
+        year.put("YYXT",count!=0 ? df.format(YYXT / count):0.0+"");
+        year.put("PHXT",count!=0 ? df.format(PHXT / count):0.0+"");
+        year.put("JC",count!=0 ? df.format(JC / count):0.0+"");
+        year.put("QT",count!=0 ? df.format(QT / count):0.0+"");
+        year.put("TDG",count!=0 ? df.format(TDG / count):0.0+"");
+
+        conver.add(year);
+
+        return conver;
+    }
+
+}

+ 1 - 1
web/health-hb/src/main/java/com/gyee/frame/service/websocket/GenreSetPushService.java

@@ -82,7 +82,7 @@ public class GenreSetPushService {
         if (StringUtils.notEmp(id)) {
 
 
-            Double zjrl = 0.0;
+            Double zjrl = 1.0;
             Double zjts = 0.0;
 
             Double sjgl = 0.0;

+ 2 - 2
web/health-hb/src/main/java/com/gyee/frame/service/websocket/WpInfoPushService.java

@@ -116,7 +116,7 @@ public class WpInfoPushService {
 
             String id = wp.getId();
             double scadafdl = 0.0;
-            Double zjrl = 0.0;
+            Double zjrl = 1.0;
             Double zjts = 0.0;
 
             Double sjgl = 0.0;
@@ -1157,7 +1157,7 @@ public class WpInfoPushService {
             Map<String, Object> jczbmap = new HashMap<String, Object>();
             String id = wp.getId();
 
-            Double zjrl = 0.0;
+            Double zjrl = 1.0;
             Double zjts = 0.0;
 
             Double sjgl = 0.0;

+ 2 - 0
web/health-hb/src/main/resources/application.yml

@@ -29,6 +29,8 @@ gyee:
   #baseurl: http://10.0.118.73:8011/ts
   #baseurl: http://10.83.68.97:8011/ts
   baseurl: http://192.168.2.198:8011/ts
+  adapterUrl: http://192.168.2.198:8011
+  alarmUrl: http://192.168.2.198:8176
   #baseurl: http://123.60.213.70:8011/ts
   #API访问ip
   #swaggerip: 49.4.50.80:8082