| | |
| | | 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_TIME){ |
| | | count05+=1; |
| | | } |
| | | //5-10分钟 |
| | | if (czTime-alarmTime>=AlarmTimeConstant.FIVE_TIME && czTime-alarmTime<AlarmTimeConstant.TEN_TIME){ |
| | | count0510+=1; |
| | | } |
| | | //10-30分钟 |
| | | if (czTime-alarmTime>=AlarmTimeConstant.TEN_TIME && czTime-alarmTime<AlarmTimeConstant.THIRTY_TIME){ |
| | | count1030+=1; |
| | | } |
| | | //30分钟以上 |
| | | if (czTime-alarmTime>=AlarmTimeConstant.THIRTY_TIME){ |
| | | 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_TIME){ |
| | | count05+=1; |
| | | } |
| | | //5-10分钟 |
| | | if (nowTime-alarmTime>=AlarmTimeConstant.FIVE_TIME && nowTime-alarmTime<AlarmTimeConstant.TEN_TIME){ |
| | | count0510+=1; |
| | | } |
| | | //10-30分钟 |
| | | if (nowTime-alarmTime>=AlarmTimeConstant.TEN_TIME && nowTime-alarmTime<AlarmTimeConstant.THIRTY_TIME){ |
| | | count1030+=1; |
| | | } |
| | | //30分钟以上 |
| | | if (nowTime-alarmTime>=AlarmTimeConstant.THIRTY_TIME){ |
| | | count30+=1; |
| | | } |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | //封装数据 |
| | | list.add(count05); |
| | | list.add(count0510); |
| | | list.add(count1030); |
| | | list.add(count30); |
| | | //返回数据 |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 查询当前时间段区间时间一键求助报警个数 |
| | | * @param conditionVo |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Integer> selAlarmTimeDis(ConditionVo conditionVo) { |
| | | //查询当前时间段内一键求助报警的数据集合 |
| | | List<Alarm> alarmList = baseMapper.selectAlarmList(conditionVo); |
| | | if (alarmList.size()>0) { |
| | | List<Integer> list = new ArrayList<>(); |
| | | int count02 = 0; |
| | | int count0204 = 0; |
| | | int count0406 = 0; |
| | | int count0608 = 0; |
| | | int count0810 = 0; |
| | | int count1012 = 0; |
| | | int count1214 = 0; |
| | | int count1416 = 0; |
| | | int count1618 = 0; |
| | | int count1820 = 0; |
| | | int count2022 = 0; |
| | | int count2224 = 0; |
| | | //遍历集合 |
| | | for (Alarm alarm : alarmList) { |
| | | try { |
| | | int hours = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(alarm.getAlarmTime()).getHours(); |
| | | if (hours > 0 && hours < AlarmTimeConstant.TWO) { |
| | | count02 += 1; |
| | | } |
| | | if (hours >= AlarmTimeConstant.TWO && hours < AlarmTimeConstant.FOUR) { |
| | | count0204 += 1; |
| | | } |
| | | if (hours >= AlarmTimeConstant.FOUR && hours < AlarmTimeConstant.SIX) { |
| | | count0406 += 1; |
| | | } |
| | | if (hours >= AlarmTimeConstant.SIX && hours < AlarmTimeConstant.EIGHT) { |
| | | count0608 += 1; |
| | | } |
| | | if (hours >= AlarmTimeConstant.EIGHT && hours < AlarmTimeConstant.TEN) { |
| | | count0810 += 1; |
| | | } |
| | | if (hours >= AlarmTimeConstant.TEN && hours < AlarmTimeConstant.TWEKVE) { |
| | | count1012 += 1; |
| | | } |
| | | if (hours >= AlarmTimeConstant.TWEKVE && hours < AlarmTimeConstant.FOURTEEN) { |
| | | count1214 += 1; |
| | | } |
| | | if (hours >= AlarmTimeConstant.FOURTEEN && hours < AlarmTimeConstant.SIXTEEN) { |
| | | count1416 += 1; |
| | | } |
| | | if (hours >= AlarmTimeConstant.SIXTEEN && hours < AlarmTimeConstant.EIGHTEEN) { |
| | | count1618 += 1; |
| | | } |
| | | if (hours >= AlarmTimeConstant.EIGHTEEN && hours < AlarmTimeConstant.TWENTY) { |
| | | count1820 += 1; |
| | | } |
| | | if (hours >= AlarmTimeConstant.TWENTY && hours < AlarmTimeConstant.TWENTY_TWO) { |
| | | count2022 += 1; |
| | | } |
| | | if (hours >= AlarmTimeConstant.TWENTY_TWO && hours < AlarmTimeConstant.TWENTY_FOUR) { |
| | | count2224 += 1; |
| | | } |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | //封装数据 |
| | | list.add(count02); |
| | | list.add(count0204); |
| | | list.add(count0406); |
| | | list.add(count0608); |
| | | list.add(count0810); |
| | | list.add(count1012); |
| | | list.add(count1214); |
| | | list.add(count1416); |
| | | list.add(count1618); |
| | | list.add(count1820); |
| | | list.add(count2022); |
| | | list.add(count2224); |
| | | //返回数据 |
| | | return list; |
| | | } |
| | | return Arrays.asList(0,0,0,0,0,0,0,0,0,0,0,0); |
| | | } |
| | | } |