|
@@ -10,6 +10,7 @@ import com.huimv.env.dao.repo.BaseWarningInfoRepo;
|
|
|
import com.huimv.env.service.IAlarm;
|
|
|
import com.huimv.env.utils.Const;
|
|
|
import com.huimv.env.utils.DateUtil;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.*;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
@@ -29,6 +30,7 @@ import java.util.List;
|
|
|
* @Create : 2020-12-25
|
|
|
**/
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class AlarmImpl implements IAlarm {
|
|
|
@Autowired
|
|
|
private BaseWarningInfoRepo warningInfoRepo;
|
|
@@ -194,6 +196,16 @@ public class AlarmImpl implements IAlarm {
|
|
|
return count;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @Method : getAlarmRate
|
|
|
+ * @Description : 计算今日报警占比数量
|
|
|
+ * @Params : [farmId]
|
|
|
+ * @Return : com.huimv.common.utils.Result
|
|
|
+ *
|
|
|
+ * @Author : ZhuoNing
|
|
|
+ * @Date : 2021/12/5
|
|
|
+ * @Time : 18:29
|
|
|
+ */
|
|
|
@Override
|
|
|
public Result getAlarmRate(Integer farmId) throws ParseException {
|
|
|
String todayText = dateUtil.getTodayDateText();
|
|
@@ -201,29 +213,58 @@ public class AlarmImpl implements IAlarm {
|
|
|
List<BaseWarningInfoEntity> warningInfoEntityList = warningInfoRepo.findTodayAllAlarm(farmId,todayText);
|
|
|
if(warningInfoEntityList.size()>0){
|
|
|
JSONArray outJa = new JSONArray();
|
|
|
+ //生态监测
|
|
|
+ int stjcQuantity = _countRateQuantity("7,8,9,10",warningInfoEntityList);
|
|
|
+ //环境监测
|
|
|
+ int hjjcQuantity = _countRateQuantity("15,16,17,18",warningInfoEntityList);
|
|
|
+ //人员违规
|
|
|
+ int rywgQuantity = 0;
|
|
|
+ //报警总量
|
|
|
+ int total = stjcQuantity + hjjcQuantity + rywgQuantity;
|
|
|
//
|
|
|
JSONObject dataJo1 = new JSONObject();
|
|
|
outJa.add(dataJo1);
|
|
|
dataJo1.put("name","生态监测");
|
|
|
- dataJo1.put("value",25);
|
|
|
+ dataJo1.put("value",stjcQuantity);
|
|
|
//
|
|
|
JSONObject dataJo2 = new JSONObject();
|
|
|
outJa.add(dataJo2);
|
|
|
dataJo2.put("name","环境监测");
|
|
|
- dataJo2.put("value",30);
|
|
|
+ dataJo2.put("value",hjjcQuantity);
|
|
|
//
|
|
|
JSONObject dataJo3 = new JSONObject();
|
|
|
outJa.add(dataJo3);
|
|
|
dataJo3.put("name","人员违规");
|
|
|
- dataJo3.put("value",45);
|
|
|
- //
|
|
|
- JSONObject dataJo4 = new JSONObject();
|
|
|
- outJa.add(dataJo4);
|
|
|
- dataJo4.put("name","报警总量");
|
|
|
- dataJo4.put("value",100);
|
|
|
+ dataJo3.put("value",rywgQuantity);
|
|
|
+// //
|
|
|
+// JSONObject dataJo4 = new JSONObject();
|
|
|
+// outJa.add(dataJo4);
|
|
|
+// dataJo4.put("name","报警总量");
|
|
|
+// dataJo4.put("value",total);
|
|
|
return new Result(ResultCode.SUCCESS,outJa);
|
|
|
}else{
|
|
|
return new Result(Const.ERROR_CODE_NOTEXIST,Const.ERROR_MSG_NOTEXIST,false);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //计算占比数量
|
|
|
+ public Integer _countRateQuantity(String alarmType,List<BaseWarningInfoEntity> warningInfoEntityList){
|
|
|
+ if(alarmType == null || alarmType.trim().length()==0){
|
|
|
+ log.error("警报类型alarmType不能为空或null.");
|
|
|
+ }
|
|
|
+ String[] alarmArray = alarmType.split(",");
|
|
|
+ int count=0;
|
|
|
+ for(int a=0;a<warningInfoEntityList.size();a++){
|
|
|
+ BaseWarningInfoEntity warningInfoEntity = warningInfoEntityList.get(a);
|
|
|
+ for(int b=0;b<alarmArray.length;b++){
|
|
|
+ if(warningInfoEntity.getAlarmType() == Integer.parseInt(alarmArray[b]))
|
|
|
+ {
|
|
|
+ count++;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return count;
|
|
|
+ }
|
|
|
+
|
|
|
}
|