| | |
| | | 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.parcel.vo.ConditionVo; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 服务实现类 |
| | |
| | | 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; |
| | | } |
| | | } |