|
@@ -1,5 +1,6 @@
|
|
|
package com.huimv.env.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.huimv.common.utils.Result;
|
|
@@ -138,10 +139,8 @@ public class AlarmImpl implements IAlarm {
|
|
|
@Override
|
|
|
public Result getAlarm(Integer farmId, Integer quantity) throws ParseException {
|
|
|
String today = dateUtil.getTodayDateText();
|
|
|
- System.out.println("today>>"+today);
|
|
|
//
|
|
|
List<Object[]> warningInfoEntityList = warningInfoRepo.findTodayAlarm(farmId,today,quantity);
|
|
|
- System.out.println("size>>"+warningInfoEntityList.size());
|
|
|
if(warningInfoEntityList.size()>0){
|
|
|
JSONArray alarmJa = new JSONArray();
|
|
|
for(int a=0;a<warningInfoEntityList.size();a++){
|
|
@@ -157,4 +156,46 @@ public class AlarmImpl implements IAlarm {
|
|
|
return new Result(Const.ERROR_CODE_NOTEXIST,Const.ERROR_MSG_NOTEXIST,false);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Method : getOneWeekAlarm
|
|
|
+ * @Description : 报警级别分布
|
|
|
+ * @Params : [farmId]
|
|
|
+ * @Return : com.huimv.common.utils.Result
|
|
|
+ *
|
|
|
+ * @Author : ZhuoNing
|
|
|
+ * @Date : 2021/12/5
|
|
|
+ * @Time : 17:02
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Result getOneWeekAlarm(Integer farmId) throws ParseException {
|
|
|
+ //倒序查询最近7天警报数据
|
|
|
+ String startDate = dateUtil.getPastDate(6);
|
|
|
+ String endDate = dateUtil.getTodayDateText();
|
|
|
+ //
|
|
|
+ List<BaseWarningInfoEntity> warningInfoEntityList = warningInfoRepo.findLastSevenDaysAlarm(farmId,startDate,endDate);
|
|
|
+ JSONObject outJo = new JSONObject();
|
|
|
+ outJo.put("one",_countAlarmTotal("一级",warningInfoEntityList));
|
|
|
+ outJo.put("two",_countAlarmTotal("二级",warningInfoEntityList));
|
|
|
+ outJo.put("three",_countAlarmTotal("三级",warningInfoEntityList));
|
|
|
+ return new Result(ResultCode.SUCCESS,outJo);
|
|
|
+ }
|
|
|
+
|
|
|
+ //计算警报数量
|
|
|
+ public Integer _countAlarmTotal(String typeName,List<BaseWarningInfoEntity> warningInfoEntityList){
|
|
|
+ int count = 0;
|
|
|
+ for(int a=0;a<warningInfoEntityList.size();a++){
|
|
|
+ BaseWarningInfoEntity warningInfoEntity = warningInfoEntityList.get(a);
|
|
|
+ if(warningInfoEntity.getLevelName().indexOf(typeName) != -1){
|
|
|
+ count++;
|
|
|
+// warningInfoEntityList.remove(warningInfoEntity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return count;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result getAlarmRate(Integer farmId) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|