123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- package com.ozs.service.impl;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.github.pagehelper.PageHelper;
- import com.ozs.entity.MsgAlarm;
- import com.ozs.entity.vo.*;
- import com.ozs.mapper.BaseCameraManagementMapper;
- import com.ozs.mapper.MsgAlarmMapper;
- import com.ozs.service.MsgAlarmService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- /**
- * <p>
- * 报警信息表 服务实现类
- * </p>
- *
- * @author ozs
- * @since 2023-02-22
- */
- @Service
- public class MsgAlarmServiceImpl extends ServiceImpl<MsgAlarmMapper, MsgAlarm> implements MsgAlarmService {
- @Autowired
- private MsgAlarmMapper msgAlarmMapper;
- @Autowired
- private BaseCameraManagementMapper baseCameraManagementMapper;
- public IPage listToPage(List list, int pageNum, int pageSize) {
- List pageList = new ArrayList<>();
- int curIdx = pageNum > 1 ? (pageNum - 1) * pageSize : 0;
- for (int i = 0; i < pageSize && curIdx + i < list.size(); i++) {
- pageList.add(list.get(curIdx + i));
- }
- IPage page = new Page<>(pageNum, pageSize);
- page.setRecords(pageList);
- page.setTotal(list.size());
- return page;
- }
- //web数据统计 报警数据详情
- @Override
- public List<AlarmStatisticDto> list(String railwayCode, Integer currentYear, Integer currentMonth, Integer pageNum, Integer pageSize) {
- List<AlarmStatisticDto> list = msgAlarmMapper.list(railwayCode, currentYear, currentMonth);
- return list;
- }
- @Override
- public List<AlarmStatisticMonthDto> getCount(String railwayCode, Integer currentYear, Integer currentMonth) {
- List<AlarmStatisticMonthDto> list = msgAlarmMapper.listDtoMonth(railwayCode, currentYear, currentMonth);
- return list;
- }
- @Override
- public List<AlarmStatisticMonthDto> getDayCount(String railwayCode, Integer currentYear, Integer currentMonth) {
- List<AlarmStatisticMonthDto> list = msgAlarmMapper.listDtoDay(railwayCode, currentYear, currentMonth);
- return list;
- }
- @Override
- public List<AlarmStatisticMonthDto> getAlarmTypeCount(String railwayCode, Integer currentYear, Integer currentMonth) {
- List<AlarmStatisticMonthDto> list = msgAlarmMapper.alarmTypeCount(railwayCode, currentYear, currentMonth);
- return list;
- }
- @Override
- public List<AlarmFreqArea> alarmTypeAreaCount(String railwayCode, Integer currentYear, Integer currentMonth) {
- List<AlarmFreqArea> list = msgAlarmMapper.alarmTypeAreaCount(railwayCode, currentYear, currentMonth);
- return list;
- }
- @Override
- public List<AlarmStatisticDto> exportExcel(AlarmStatisticResVo alarmStatisticResVo) {
- List<AlarmStatisticDto> listDto = msgAlarmMapper.list(alarmStatisticResVo.getRailwayCode(), alarmStatisticResVo.getCurrentYear(),
- alarmStatisticResVo.getCurrentMonth());
- return listDto;
- }
- @Override
- public Long getAlarmNum() {
- Long alarmNum = msgAlarmMapper.getAlarmNum();
- return alarmNum;
- }
- @Override
- public MsgAlarm selectByCameraCode(String cameraCode) {
- return msgAlarmMapper.selectByCameraCode(cameraCode);
- }
- @Override
- public IPage<MsgAlarm> queryPage(MsgAlarmVo vo) {
- int pageNum = Integer.parseInt(vo.getPageNum().toString());
- int pageSize = Integer.parseInt(vo.getPageSize().toString());
- com.github.pagehelper.Page<MsgAlarm> page = PageHelper.startPage(pageNum, pageSize)
- .doSelectPage(() -> msgAlarmMapper.selectMsgAlarmList(vo));
- Page<MsgAlarm> pageR = new Page<>(pageNum, pageSize);
- pageR.setRecords(page.getResult());
- pageR.setTotal(page.getTotal());
- return pageR;
- }
- @Override
- public MsgAlarm getByAlarmId(String alarmId) {
- return msgAlarmMapper.getByAlarmId(alarmId);
- }
- @Override
- public Map<String, Integer> statisticsNum(MsgAlarmVo msgAlarmVo) {
- Map<String, Integer> map = new HashMap<>();
- // 相机数量
- Integer countCamera = baseCameraManagementMapper.countCamera(msgAlarmVo);
- // 累计报警次数
- Integer countMsg = msgAlarmMapper.countMsg(msgAlarmVo);
- // 解除报警
- // LambdaQueryWrapper<MsgAlarm> lwJC = new LambdaQueryWrapper<MsgAlarm>();
- // lwJC.eq(MsgAlarm::getIsLock, "1");
- Integer countJC = msgAlarmMapper.countJC(msgAlarmVo);
- // 未解除报警
- // LambdaQueryWrapper<MsgAlarm> lwWJC = new LambdaQueryWrapper<MsgAlarm>();
- // lwWJC.eq(MsgAlarm::getIsLock, "2");
- Integer countWJC = msgAlarmMapper.countWJC(msgAlarmVo);
- map.put("countCamera", countCamera);
- map.put("countMsg", countMsg);
- map.put("countJC", countJC);
- map.put("countWJC", countWJC);
- return map;
- }
- @Override
- public Integer appAlarmNum(MsgAlarmVo msgAlarmVo) {
- return msgAlarmMapper.countWJC(msgAlarmVo);
- }
- @Override
- public List<MsgAlarm> msgAlarmList(MsgAlarmVo msgAlarmVo) {
- return msgAlarmMapper.selectMsgAlarmList(msgAlarmVo);
- }
- }
|