package com.ruoyi.aibrain.service.impl;
|
|
import java.util.*;
|
|
import com.ruoyi.common.utils.DateUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import com.ruoyi.aibrain.mapper.AiAlarmInfoMapper;
|
import com.ruoyi.aibrain.domain.AiAlarmInfo;
|
import com.ruoyi.aibrain.service.IAiAlarmInfoService;
|
|
/**
|
* 报警信息管理Service业务层处理
|
*
|
* @author wf
|
* @date 2023-03-08
|
*/
|
@Service
|
public class AiAlarmInfoServiceImpl implements IAiAlarmInfoService
|
{
|
@Autowired
|
private AiAlarmInfoMapper aiAlarmInfoMapper;
|
|
/**
|
* 查询报警信息管理
|
*
|
* @param id 报警信息管理主键
|
* @return 报警信息管理
|
*/
|
@Override
|
public AiAlarmInfo selectAiAlarmInfoById(Long id)
|
{
|
return aiAlarmInfoMapper.selectAiAlarmInfoById(id);
|
}
|
|
/**
|
* 查询报警信息管理列表
|
*
|
* @param aiAlarmInfo 报警信息管理
|
* @return 报警信息管理
|
*/
|
@Override
|
public List<AiAlarmInfo> selectAiAlarmInfoList(AiAlarmInfo aiAlarmInfo)
|
{
|
return aiAlarmInfoMapper.selectAiAlarmInfoList(aiAlarmInfo);
|
}
|
|
/**
|
* 新增报警信息管理
|
*
|
* @param aiAlarmInfo 报警信息管理
|
* @return 结果
|
*/
|
@Override
|
public int insertAiAlarmInfo(AiAlarmInfo aiAlarmInfo)
|
{
|
return aiAlarmInfoMapper.insertAiAlarmInfo(aiAlarmInfo);
|
}
|
|
/**
|
* 修改报警信息管理
|
*
|
* @param aiAlarmInfo 报警信息管理
|
* @return 结果
|
*/
|
@Override
|
public int updateAiAlarmInfo(AiAlarmInfo aiAlarmInfo)
|
{
|
return aiAlarmInfoMapper.updateAiAlarmInfo(aiAlarmInfo);
|
}
|
|
/**
|
* 批量删除报警信息管理
|
*
|
* @param ids 需要删除的报警信息管理主键
|
* @return 结果
|
*/
|
@Override
|
public int deleteAiAlarmInfoByIds(Long[] ids)
|
{
|
return aiAlarmInfoMapper.deleteAiAlarmInfoByIds(ids);
|
}
|
|
/**
|
* 删除报警信息管理信息
|
*
|
* @param id 报警信息管理主键
|
* @return 结果
|
*/
|
@Override
|
public int deleteAiAlarmInfoById(Long id)
|
{
|
return aiAlarmInfoMapper.deleteAiAlarmInfoById(id);
|
}
|
|
/**
|
* 三违报警统计
|
*
|
* @param aiAlarmInfo 报警信息管理
|
* @return 结果
|
*/
|
@Override
|
public int countSanWeiAlarm(AiAlarmInfo aiAlarmInfo) {
|
return aiAlarmInfoMapper.countSanWeiAlarm(aiAlarmInfo);
|
}
|
|
/**
|
* 隐患报警统计
|
*
|
* @param aiAlarmInfo 报警信息管理
|
* @return 结果
|
*/
|
@Override
|
public int countYinHuanAlarm(AiAlarmInfo aiAlarmInfo) {
|
return aiAlarmInfoMapper.countYinHuanAlarm(aiAlarmInfo);
|
}
|
|
/**
|
* 智能识别仪报警统计
|
*
|
* @param aiAlarmInfo 报警信息管理
|
* @return 结果
|
*/
|
@Override
|
public int countAllAlarm(AiAlarmInfo aiAlarmInfo) {
|
return aiAlarmInfoMapper.countAllAlarm(aiAlarmInfo);
|
}
|
|
/**
|
* 报警信息分析统计
|
* @param aiAlarmInfo 报警信息管理
|
* @return 结果
|
*/
|
@Override
|
public Map<String, Object> countAlarmByTimeAndType(AiAlarmInfo aiAlarmInfo) {
|
Map<String, Object> result = new HashMap<>();
|
List<Map<String,Object>> personResult = new ArrayList<>();
|
List<Map<String,Object>> thingResult = new ArrayList<>();
|
List<Map<String,Object>> ambientResult = new ArrayList<>();
|
aiAlarmInfo.setSmallClass("1");
|
List<Map<String,Object>> persons = aiAlarmInfoMapper.countAlarmByTimeAndType(aiAlarmInfo);//人员
|
aiAlarmInfo.setSmallClass("3");
|
List<Map<String,Object>> things = aiAlarmInfoMapper.countAlarmByTimeAndType(aiAlarmInfo);//异物
|
aiAlarmInfo.setSmallClass("2");
|
List<Map<String,Object>> ambients = aiAlarmInfoMapper.countAlarmByTimeAndType(aiAlarmInfo);//环境
|
|
for (int i = aiAlarmInfo.getDays(); i >= 0; i--) {
|
String days = DateUtils.getDateTime(new Date(),i);
|
Map<String,Object> per = new HashMap<>();
|
per.put("days",days);
|
Map<String,Object> thi = new HashMap<>();
|
thi.put("days",days);
|
Map<String,Object> amb = new HashMap<>();
|
amb.put("days",days);
|
for (Map<String,Object> person : persons){
|
if (days.equals(person.get("days").toString())){
|
per.put("value",person.get("count"));
|
break;
|
}
|
}
|
if (!per.containsKey("value")){
|
per.put("value",0);
|
}
|
personResult.add(per);
|
for (Map<String,Object> thing : things){
|
if (days.equals(thing.get("days").toString())){
|
thi.put("value",thing.get("count"));
|
break;
|
}
|
}
|
if (!thi.containsKey("value")){
|
thi.put("value",0);
|
}
|
thingResult.add(thi);
|
for (Map<String,Object> ambient : ambients){
|
if (days.equals(ambient.get("days").toString())){
|
amb.put("value",ambient.get("count"));
|
break;
|
}
|
}
|
if (!amb.containsKey("value")){
|
amb.put("value",0);
|
}
|
ambientResult.add(amb);
|
}
|
result.put("person",personResult);
|
result.put("thing",thingResult);
|
result.put("ambient",ambientResult);
|
return result;
|
}
|
|
/**
|
* 年度报警统计
|
* @return 结果
|
*/
|
@Override
|
public int countAlarmInYear() {
|
return aiAlarmInfoMapper.countAlarmInYear();
|
}
|
|
/**
|
* 月度报警统计
|
* @return 结果
|
*/
|
@Override
|
public int countAlarmInMonth() {
|
return aiAlarmInfoMapper.countAlarmInMonth();
|
}
|
|
/**
|
* 本年区域报警Top排序
|
* @return 结果
|
*/
|
@Override
|
public List<Map<String, Object>> selectCountAlarmByRegion() {
|
return aiAlarmInfoMapper.selectCountAlarmByRegion();
|
}
|
|
/**
|
* 本年报警类型统计
|
* @return 结果
|
*/
|
@Override
|
public List<Map<String, Object>> selectCountAlarmBySmall() {
|
return aiAlarmInfoMapper.selectCountAlarmBySmall();
|
}
|
|
/**
|
* 实时报警:未处理的最新十条
|
* @return 结果
|
*/
|
@Override
|
public List<AiAlarmInfo> selectAlarmInfoNew() {
|
return aiAlarmInfoMapper.selectAlarmInfoNew();
|
}
|
|
/**
|
* 根据报警参数查询最新日期的报警
|
* @return 结果
|
*/
|
@Override
|
public AiAlarmInfo selectAlarmInfo(AiAlarmInfo aiAlarmInfo) {
|
return aiAlarmInfoMapper.selectAlarmInfo(aiAlarmInfo);
|
}
|
}
|