|
@@ -5,14 +5,14 @@ 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 java.io.*;
|
|
|
-import java.net.HttpURLConnection;
|
|
|
-import java.net.URL;
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.util.*;
|
|
|
|
|
@@ -20,101 +20,53 @@ import java.util.*;
|
|
|
public class RedarService {
|
|
|
private static final Logger log = LoggerFactory.getLogger(RedarService.class);
|
|
|
|
|
|
- public List<Map> hitch(String stId, String Date) {
|
|
|
- String url = "http://192.168.1.18:8075/shutdown/list?stId=MHS_FDC&endDate=2021-11-21&startDate=2021-11-22";
|
|
|
+ @Resource
|
|
|
+ private RemoteServiceBuilder remoteService;
|
|
|
|
|
|
- String str = doGet(url);
|
|
|
- List<Map> object = parseJSON(str);
|
|
|
+ public List<List<Map>> hitch(String stId, String Date) {
|
|
|
|
|
|
+ Map<String, String> TimeMap = new LinkedHashMap<>();
|
|
|
|
|
|
- String[] splitdata = Date.split("-");
|
|
|
-
|
|
|
- Map<String, String> TimeMap = new HashMap<>();
|
|
|
- //月份
|
|
|
- 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("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.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));
|
|
|
|
|
|
- url = url.replaceAll("startDate=[0-9\\-]*", "startDate=" + TimeMap.get("yearstarttime"))
|
|
|
- .replaceAll("endDate=[0-9\\-]*", "endDate=" + TimeMap.get("yearendtime"))
|
|
|
- + "&startmonth=" + TimeMap.get("monthstarttime") + "&endmonth=" + TimeMap.get("monthendtime")
|
|
|
- + "&beginday=" + TimeMap.get("daystarttime") + "&endday=" + TimeMap.get("dayendtime");
|
|
|
+ AjaxResult year = remoteService.earlyService().getHith(stId,TimeMap.get("yearstarttime"),TimeMap.get("yearendtime"));
|
|
|
|
|
|
- return object;
|
|
|
- }
|
|
|
+ AjaxResult month = remoteService.earlyService().getHith(stId,TimeMap.get("monthstarttime"),TimeMap.get("monthendtime"));
|
|
|
|
|
|
- /**
|
|
|
- * Http get请求
|
|
|
- *
|
|
|
- * @param httpUrl 连接
|
|
|
- * @return 响应数据
|
|
|
- */
|
|
|
- public String doGet(String httpUrl) {
|
|
|
- //链接
|
|
|
- HttpURLConnection connection = null;
|
|
|
- InputStream is = null;
|
|
|
- BufferedReader br = null;
|
|
|
- StringBuffer result = new StringBuffer();
|
|
|
- try {
|
|
|
- //创建连接
|
|
|
- URL url = new URL(httpUrl);
|
|
|
- connection = (HttpURLConnection) url.openConnection();
|
|
|
- //设置请求方式
|
|
|
- connection.setRequestMethod("GET");
|
|
|
- //设置连接超时时间
|
|
|
- connection.setReadTimeout(15000);
|
|
|
- //开始连接
|
|
|
- connection.connect();
|
|
|
- //获取响应数据
|
|
|
- if (connection.getResponseCode() == 200) {
|
|
|
- //获取返回的数据
|
|
|
- is = connection.getInputStream();
|
|
|
- if (null != is) {
|
|
|
- br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
|
|
- String temp = null;
|
|
|
- while (null != (temp = br.readLine())) {
|
|
|
- result.append(temp);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- if (null != br) {
|
|
|
- try {
|
|
|
- br.close();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- if (null != is) {
|
|
|
- try {
|
|
|
- is.close();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- //关闭远程连接
|
|
|
- connection.disconnect();
|
|
|
- }
|
|
|
- return result.toString();
|
|
|
+ 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 stationId = 0;
|
|
|
- int windturbineId = 0;
|
|
|
- int type = 0;
|
|
|
- int typeID = 0;
|
|
|
int time = 0;
|
|
|
|
|
|
int bj = 0;
|
|
@@ -174,80 +126,28 @@ public class RedarService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- JSONObject jsonObject1 = new JSONObject();
|
|
|
- jsonObject1.put("bj", bj);
|
|
|
- jsonObject1.put("fjqt", fjqt);
|
|
|
- jsonObject1.put("fdj", fdj);
|
|
|
- jsonObject1.put("clx", clx);
|
|
|
- jsonObject1.put("bpq", bpq);
|
|
|
- jsonObject1.put("zz", zz);
|
|
|
- jsonObject1.put("hh", hh);
|
|
|
- jsonObject1.put("ph", ph);
|
|
|
- jsonObject1.put("yy", yy);
|
|
|
- jsonObject1.put("lq", lq);
|
|
|
- jsonObject1.put("rh", rh);
|
|
|
- jsonObject1.put("kz", kz);
|
|
|
- jsonObject1.put("jcjr", jcjr);
|
|
|
- jsonObject1.put("count", count);
|
|
|
- jsonObject1.put("time", time);
|
|
|
|
|
|
List<Map> conver = new ArrayList<>();
|
|
|
|
|
|
DecimalFormat df = new DecimalFormat("0.00");
|
|
|
|
|
|
- Map<String, String> year = new HashMap<>();
|
|
|
- year.put("变桨", df.format(bj / count));
|
|
|
- year.put("风机其它", df.format(fjqt / count));
|
|
|
- year.put("齿轮箱", df.format(clx / count));
|
|
|
- year.put("变频器", df.format(bpq / count));
|
|
|
- year.put("主轴", df.format(zz / count));
|
|
|
- year.put("滑环", df.format(hh / count));
|
|
|
- year.put("偏航", df.format(ph / count));
|
|
|
- year.put("液压", df.format(yy / count));
|
|
|
- year.put("冷却", df.format(lq / count));
|
|
|
- year.put("润滑", df.format(rh / count));
|
|
|
- year.put("控制", df.format(kz / count));
|
|
|
- year.put("机舱加热", df.format(jcjr / count));
|
|
|
-
|
|
|
- JSONObject year1 = new JSONObject();
|
|
|
- year1.put("year", year);
|
|
|
- conver.add(year1);
|
|
|
-
|
|
|
- Map<String, String> month = new HashMap<>();
|
|
|
- month.put("变桨", df.format(bj / count));
|
|
|
- month.put("风机其它", df.format(fjqt / count));
|
|
|
- month.put("齿轮箱", df.format(clx / count));
|
|
|
- month.put("变频器", df.format(bpq / count));
|
|
|
- month.put("主轴", df.format(zz / count));
|
|
|
- month.put("滑环", df.format(hh / count));
|
|
|
- month.put("偏航", df.format(ph / count));
|
|
|
- month.put("液压", df.format(yy / count));
|
|
|
- month.put("冷却", df.format(lq / count));
|
|
|
- month.put("润滑", df.format(rh / count));
|
|
|
- month.put("控制", df.format(kz / count));
|
|
|
- month.put("机舱加热", df.format(jcjr / count));
|
|
|
- JSONObject month1 = new JSONObject();
|
|
|
- month1.put("month", month);
|
|
|
- conver.add(month1);
|
|
|
-
|
|
|
- Map<String, String> day = new HashMap<>();
|
|
|
- day.put("变桨", df.format(bj / count));
|
|
|
- day.put("风机其它", df.format(fjqt / count));
|
|
|
- day.put("齿轮箱", df.format(clx / count));
|
|
|
- day.put("变频器", df.format(bpq / count));
|
|
|
- day.put("主轴", df.format(zz / count));
|
|
|
- day.put("滑环", df.format(hh / count));
|
|
|
- day.put("偏航", df.format(ph / count));
|
|
|
- day.put("液压", df.format(yy / count));
|
|
|
- day.put("冷却", df.format(lq / count));
|
|
|
- day.put("润滑", df.format(rh / count));
|
|
|
- day.put("控制", df.format(kz / count));
|
|
|
- day.put("机舱加热", df.format(jcjr / count));
|
|
|
- JSONObject day1 = new JSONObject();
|
|
|
- day1.put("day", day);
|
|
|
- conver.add(day1);
|
|
|
-
|
|
|
- return conver;
|
|
|
+ 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());
|
|
@@ -257,30 +157,39 @@ public class RedarService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public List<Map> warning(String stationid, String date) {
|
|
|
- String url1 = "http://192.168.1.18:8075/alarm/count/query/new?stationid=MHS_FDC&startdate=2021-11-23&enddate=2021-11-24";
|
|
|
- String st = doGet(url1);
|
|
|
- List<Map> object = pron(st);
|
|
|
-
|
|
|
- String[] splitdata = date.split("-");
|
|
|
+ public List<List<Map>> warning(String stationid, String date) {
|
|
|
|
|
|
- Map<String, String> timeMap = new HashMap<>();
|
|
|
- //月份
|
|
|
- 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));
|
|
|
+ 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("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.parseDate(date)), DatePattern.NORM_DATETIME_MINUTE_PATTERN));
|
|
|
- timeMap.put("dayendtime", DateUtil.format(DateUtil.endOfDay(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);
|
|
|
|
|
|
- url1 = url1.replaceAll("startdate=[0-9\\-]*", "startdate=" + timeMap.get("yearstarttime"))
|
|
|
- .replaceAll("enddate=[0-9\\-]*", "enddate=" + timeMap.get("yearendtime"))
|
|
|
- + "&startmonth=" + timeMap.get("monthstarttime") + "&endmonth=" + timeMap.get("monthendtime")
|
|
|
- + "&beginday=" + timeMap.get("daystarttime") + "&endday=" + timeMap.get("dayendtime");
|
|
|
+ String jsonStr3 = JSON.toJSONString(day);
|
|
|
+ List<Map> day1 = pron(jsonStr3);
|
|
|
|
|
|
- return object;
|
|
|
+ fh.add(year1);
|
|
|
+ fh.add(month1);
|
|
|
+ fh.add(day1);
|
|
|
+ return fh;
|
|
|
}
|
|
|
|
|
|
public List<Map> pron(String jsonData1) {
|
|
@@ -339,70 +248,24 @@ public class RedarService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- JSONObject jsonObject2 = new JSONObject();
|
|
|
- jsonObject2.put("CFXT", CFXT);
|
|
|
- jsonObject2.put("CDL", CDL);
|
|
|
- jsonObject2.put("FDJ", FDJ);
|
|
|
- jsonObject2.put("BJXT", BJXT);
|
|
|
- jsonObject2.put("CLX", CLX);
|
|
|
- jsonObject2.put("YYXT", YYXT);
|
|
|
- jsonObject2.put("PHXT", PHXT);
|
|
|
- jsonObject2.put("JC", JC);
|
|
|
- jsonObject2.put("QT", QT);
|
|
|
- jsonObject2.put("TDG", TDG);
|
|
|
- jsonObject2.put("count", count);
|
|
|
- jsonObject2.put("time", time);
|
|
|
|
|
|
List<Map> conver = new ArrayList<>();
|
|
|
|
|
|
DecimalFormat df = new DecimalFormat("0.00");
|
|
|
|
|
|
- Map<String, String> year = new HashMap<>();
|
|
|
- year.put("测风系统", df.format(CFXT / count));
|
|
|
- year.put("传动链", df.format(CDL / count));
|
|
|
- year.put("发电机", df.format(FDJ / count));
|
|
|
- year.put("变桨系统", df.format(BJXT / count));
|
|
|
- year.put("齿轮箱", df.format(CLX / count));
|
|
|
- year.put("液压系统", df.format(YYXT / count));
|
|
|
- year.put("偏航系统", df.format(PHXT / count));
|
|
|
- year.put("机舱", df.format(JC / count));
|
|
|
- year.put("其它", df.format(QT / count));
|
|
|
- year.put("塔底柜", df.format(TDG / count));
|
|
|
-
|
|
|
- JSONObject year1 = new JSONObject();
|
|
|
- year1.put("year", year);
|
|
|
- conver.add(year1);
|
|
|
-
|
|
|
- Map<String, String> month = new HashMap<>();
|
|
|
- month.put("测风系统", df.format(CFXT / count));
|
|
|
- month.put("传动链", df.format(CDL / count));
|
|
|
- month.put("发电机", df.format(FDJ / count));
|
|
|
- month.put("变桨系统", df.format(BJXT / count));
|
|
|
- month.put("齿轮箱", df.format(CLX / count));
|
|
|
- month.put("液压系统", df.format(YYXT / count));
|
|
|
- month.put("偏航系统", df.format(PHXT / count));
|
|
|
- month.put("机舱", df.format(JC / count));
|
|
|
- month.put("其它", df.format(QT / count));
|
|
|
- month.put("塔底柜", df.format(TDG / count));
|
|
|
-
|
|
|
- JSONObject month1 = new JSONObject();
|
|
|
- month1.put("month", month);
|
|
|
- conver.add(month1);
|
|
|
-
|
|
|
- Map<String, String> day = new HashMap<>();
|
|
|
- day.put("测风系统", df.format(CFXT / count));
|
|
|
- day.put("传动链", df.format(CDL / count));
|
|
|
- day.put("发电机", df.format(FDJ / count));
|
|
|
- day.put("变桨系统", df.format(BJXT / count));
|
|
|
- day.put("齿轮箱", df.format(CLX / count));
|
|
|
- day.put("液压系统", df.format(YYXT / count));
|
|
|
- day.put("偏航系统", df.format(PHXT / count));
|
|
|
- day.put("机舱", df.format(JC / count));
|
|
|
- day.put("其它", df.format(QT / count));
|
|
|
- day.put("塔底柜", df.format(TDG / count));
|
|
|
- JSONObject day1 = new JSONObject();
|
|
|
- day1.put("day", day);
|
|
|
- conver.add(day1);
|
|
|
+ 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;
|
|
|
}
|