|
@@ -0,0 +1,48 @@
|
|
|
+package com.gyee.impala.controller.diagnose;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.gyee.impala.common.feign.RemoteServiceBuilder;
|
|
|
+import com.gyee.impala.common.result.JsonResult;
|
|
|
+import com.gyee.impala.common.result.ResultCode;
|
|
|
+import com.gyee.impala.common.util.DateUtil;
|
|
|
+import com.gyee.impala.model.custom.AlertHistory;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+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 java.util.Calendar;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@CrossOrigin
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api/warning")
|
|
|
+public class AlarmHistoryController {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RemoteServiceBuilder remoteService;
|
|
|
+
|
|
|
+ @GetMapping("/info")
|
|
|
+ public JSONObject getWarning(String station, String wtId, String faultTime){
|
|
|
+ if (StringUtils.isEmpty(station) || StringUtils.isEmpty(wtId) || StringUtils.isEmpty(faultTime)){
|
|
|
+ return JsonResult.error(ResultCode.PARAM_NOT_VALID);
|
|
|
+ }
|
|
|
+
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+ cal.setTime(DateUtil.parseStrtoDate(faultTime, DateUtil.YYYY_MM_DD_HH_MM_SS));
|
|
|
+ cal.add(Calendar.HOUR, -10);
|
|
|
+ String st = DateUtil.format(cal.getTime(), DateUtil.YYYY_MM_DD_HH_MM_SS);
|
|
|
+ cal.add(Calendar.HOUR, 10);
|
|
|
+ String et = DateUtil.format(cal.getTime(), DateUtil.YYYY_MM_DD_HH_MM_SS);
|
|
|
+
|
|
|
+ JSONObject data = remoteService.sharding().getAlertHistory("windturbine", st, et, station, wtId, 1);
|
|
|
+ JSONArray records = data.getJSONArray("records");
|
|
|
+ List<AlertHistory> list = JSONArray.parseArray(records.toString(), AlertHistory.class);
|
|
|
+
|
|
|
+ return JsonResult.successData(ResultCode.SUCCESS, list);
|
|
|
+ }
|
|
|
+}
|