/*
|
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
*
|
* Redistribution and use in source and binary forms, with or without
|
* modification, are permitted provided that the following conditions are met:
|
*
|
* Redistributions of source code must retain the above copyright notice,
|
* this list of conditions and the following disclaimer.
|
* Redistributions in binary form must reproduce the above copyright
|
* notice, this list of conditions and the following disclaimer in the
|
* documentation and/or other materials provided with the distribution.
|
* Neither the name of the dreamlu.net developer nor the names of its
|
* contributors may be used to endorse or promote products derived from
|
* this software without specific prior written permission.
|
* Author: Chill 庄骞 (smallchill@163.com)
|
*/
|
package org.springblade.jfpt.alarm.service.impl;
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import org.springblade.jfpt.alarm.constant.AlarmTimeConstant;
|
import org.springblade.jfpt.alarm.entity.Alarm;
|
import org.springblade.jfpt.alarm.mapper.AlarmMapper;
|
import org.springblade.jfpt.alarm.service.IAlarmService;
|
import org.springblade.jfpt.alarm.vo.AlarmVO;
|
import org.springblade.jfpt.parcel.util.DateUtils;
|
import org.springblade.jfpt.parcel.vo.ConditionVo;
|
import org.springframework.stereotype.Service;
|
|
import java.text.ParseException;
|
import java.text.SimpleDateFormat;
|
import java.util.*;
|
|
/**
|
* 服务实现类
|
*
|
* @author BladeX
|
* @since 2020-07-04
|
*/
|
@Service
|
public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, Alarm> implements IAlarmService {
|
|
@Override
|
public IPage<AlarmVO> selectAlarmPage(IPage<AlarmVO> page, AlarmVO alarm) {
|
return page.setRecords(baseMapper.selectAlarmPage(page, alarm));
|
}
|
|
@Override
|
public List<AlarmVO> listAll() {
|
return baseMapper.listAll();
|
}
|
|
@Override
|
public List<AlarmVO> selectList(String jtype,String district,String waringType,String beginTime,String endTime) {
|
return baseMapper.selectList(jtype,district,waringType,beginTime,endTime);
|
}
|
|
@Override
|
public List<AlarmVO> getLimit() {
|
return baseMapper.getLimit();
|
}
|
|
@Override
|
public List<AlarmVO> selectInfo(String id) {
|
return baseMapper.selectInfo(id);
|
}
|
|
@Override
|
public List<AlarmVO> selecttx(String id) {
|
return baseMapper.selecttx(id);
|
}
|
|
@Override
|
public void deletejj(String id) {
|
baseMapper.deletejj(id);
|
}
|
|
@Override
|
public void s(Alarm alarm) {
|
baseMapper.s(alarm);
|
}
|
|
@Override
|
public void updateOne(Alarm alarm) {
|
baseMapper.updateOne(alarm);
|
}
|
|
@Override
|
public List<Map<String, Object>> selectScount(String time) {
|
return baseMapper.selectScount(time);
|
}
|
|
@Override
|
public List<AlarmVO> selectListSe(String beginTime, String endTime) {
|
return baseMapper.selectListSe(beginTime, endTime);
|
}
|
|
@Override
|
public void updateJtype(String id,String jtype,String bz) {
|
baseMapper.updateJtype(id,jtype,bz);
|
}
|
|
@Override
|
public void updateVaddress(String vaddress, String jid) {
|
baseMapper.updateVaddress(vaddress, jid);
|
}
|
|
@Override
|
public void updatePoliceStatus(String id,String status) {
|
baseMapper.updatePoliceStatus(id,status);
|
}
|
|
@Override
|
public void updateAaddress(String aaddress, String jid) {
|
baseMapper.updateAaddress(aaddress, jid);
|
}
|
|
@Override
|
public List<Map<String, Object>> selectEq(String time) {
|
return baseMapper.selectEq(time);
|
}
|
|
/**
|
* 查询警情总数
|
* @param conditionVo status 0:本日 1:本周 2:本月
|
* @return
|
*/
|
@Override
|
public Integer selectAlarmCount(ConditionVo conditionVo) {
|
return baseMapper.selectAlarmCount(conditionVo);
|
}
|
|
/**
|
* 查询7天内主动报警(紧急求助)每天的数量
|
* @return
|
*/
|
@Override
|
public Map<String, Object> selectAlarmData() {
|
Map<String, Object> map = new HashMap<>();
|
//查询数据
|
List<Integer> list = baseMapper.selectAlarmData();
|
//封装数据
|
map.put("alarmData",list);
|
//返回数据
|
return map;
|
}
|
|
/**
|
* 主动报警统计 饼图展示
|
* @param conditionVo status 0:本日 1:本月 2:本月
|
* @return
|
*/
|
@Override
|
public List<Map<String, Object>> selectAlarmSum(ConditionVo conditionVo) {
|
//status 不为空时
|
if (null!=conditionVo.getStatus()){
|
return baseMapper.selectAlarmSum(conditionVo);
|
}
|
//返回数据
|
return null;
|
}
|
|
@Override
|
public List<Map<String, Object>> queryPolice() {
|
return baseMapper.queryPolice();
|
}
|
|
@Override
|
public List<Map<String, Object>> queryPoliceTime(List policeIdArr) {
|
return baseMapper.queryPoliceTime(policeIdArr);
|
}
|
|
@Override
|
public List<Map<String, Object>> queryBa() {
|
return baseMapper.queryBa();
|
}
|
|
/**
|
* 查询当前时间段一键求助报警总次数
|
* @param conditionVo
|
* @return
|
*/
|
@Override
|
public Integer selAlarmTimeCount(ConditionVo conditionVo) {
|
return baseMapper.selAlarmTimeCount(conditionVo);
|
}
|
|
/**
|
* 一键求助报警确认时间占比
|
* @param conditionVo 条件
|
* @return
|
*/
|
@Override
|
public Object selConfirmTimePro(ConditionVo conditionVo) {
|
//查询当前时间段内一键求助报警的数据集合
|
List<Alarm> alarmList = baseMapper.selectAlarmList(conditionVo);
|
List<Integer> list = new ArrayList<>();
|
//一键求助报警总数
|
int count = alarmList.size();
|
int count05 = 0;
|
int count0510 = 0;
|
int count1030 = 0;
|
int count30 = 0;
|
//遍历集合
|
for (Alarm alarm:alarmList) {
|
if (null!=alarm.getCzTime() && alarm.getCzTime()!=""){
|
try {
|
long czTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(alarm.getCzTime()).getTime();
|
long alarmTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(alarm.getAlarmTime()).getTime();
|
//0-5分钟
|
if (czTime-alarmTime>0 && czTime-alarmTime<AlarmTimeConstant.FIVE){
|
count05+=1;
|
}
|
//5-10分钟
|
if (czTime-alarmTime>=AlarmTimeConstant.FIVE && czTime-alarmTime<AlarmTimeConstant.TEN){
|
count0510+=1;
|
}
|
//10-30分钟
|
if (czTime-alarmTime>=AlarmTimeConstant.TEN && czTime-alarmTime<AlarmTimeConstant.THIRTY){
|
count1030+=1;
|
}
|
//30分钟以上
|
if (czTime-alarmTime>=AlarmTimeConstant.THIRTY){
|
count30+=1;
|
}
|
} catch (ParseException e) {
|
e.printStackTrace();
|
}
|
}else {
|
long nowTime = new Date().getTime();
|
try {
|
long alarmTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(alarm.getAlarmTime()).getTime();
|
//0-5分钟
|
if (nowTime-alarmTime>0 && nowTime-alarmTime<AlarmTimeConstant.FIVE){
|
count05+=1;
|
}
|
//5-10分钟
|
if (nowTime-alarmTime>=AlarmTimeConstant.FIVE && nowTime-alarmTime<AlarmTimeConstant.TEN){
|
count0510+=1;
|
}
|
//10-30分钟
|
if (nowTime-alarmTime>=AlarmTimeConstant.TEN && nowTime-alarmTime<AlarmTimeConstant.THIRTY){
|
count1030+=1;
|
}
|
//30分钟以上
|
if (nowTime-alarmTime>=AlarmTimeConstant.THIRTY){
|
count30+=1;
|
}
|
} catch (ParseException e) {
|
e.printStackTrace();
|
}
|
}
|
}
|
//封装数据
|
list.add(count05);
|
list.add(count0510);
|
list.add(count1030);
|
list.add(count30);
|
//返回数据
|
return list;
|
}
|
}
|