MsgAlarmServiceImpl.java 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. package com.ozs.service.impl;
  2. import com.baomidou.mybatisplus.core.metadata.IPage;
  3. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  4. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  5. import com.github.pagehelper.PageHelper;
  6. import com.ozs.entity.MsgAlarm;
  7. import com.ozs.entity.vo.*;
  8. import com.ozs.mapper.BaseCameraManagementMapper;
  9. import com.ozs.mapper.MsgAlarmMapper;
  10. import com.ozs.service.MsgAlarmService;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.stereotype.Service;
  13. import java.util.ArrayList;
  14. import java.util.HashMap;
  15. import java.util.List;
  16. import java.util.Map;
  17. /**
  18. * <p>
  19. * 报警信息表 服务实现类
  20. * </p>
  21. *
  22. * @author ozs
  23. * @since 2023-02-22
  24. */
  25. @Service
  26. public class MsgAlarmServiceImpl extends ServiceImpl<MsgAlarmMapper, MsgAlarm> implements MsgAlarmService {
  27. @Autowired
  28. private MsgAlarmMapper msgAlarmMapper;
  29. @Autowired
  30. private BaseCameraManagementMapper baseCameraManagementMapper;
  31. public IPage listToPage(List list, int pageNum, int pageSize) {
  32. List pageList = new ArrayList<>();
  33. int curIdx = pageNum > 1 ? (pageNum - 1) * pageSize : 0;
  34. for (int i = 0; i < pageSize && curIdx + i < list.size(); i++) {
  35. pageList.add(list.get(curIdx + i));
  36. }
  37. IPage page = new Page<>(pageNum, pageSize);
  38. page.setRecords(pageList);
  39. page.setTotal(list.size());
  40. return page;
  41. }
  42. //web数据统计 报警数据详情
  43. @Override
  44. public List<AlarmStatisticDto> list(String railwayCode, Integer currentYear, Integer currentMonth, Integer pageNum, Integer pageSize) {
  45. List<AlarmStatisticDto> list = msgAlarmMapper.list(railwayCode, currentYear, currentMonth);
  46. return list;
  47. }
  48. @Override
  49. public List<AlarmStatisticMonthDto> getCount(String railwayCode, Integer currentYear, Integer currentMonth) {
  50. List<AlarmStatisticMonthDto> list = msgAlarmMapper.listDtoMonth(railwayCode, currentYear, currentMonth);
  51. return list;
  52. }
  53. @Override
  54. public List<AlarmStatisticMonthDto> getDayCount(String railwayCode, Integer currentYear, Integer currentMonth) {
  55. List<AlarmStatisticMonthDto> list = msgAlarmMapper.listDtoDay(railwayCode, currentYear, currentMonth);
  56. return list;
  57. }
  58. @Override
  59. public List<AlarmStatisticMonthDto> getAlarmTypeCount(String railwayCode, Integer currentYear, Integer currentMonth) {
  60. List<AlarmStatisticMonthDto> list = msgAlarmMapper.alarmTypeCount(railwayCode, currentYear, currentMonth);
  61. return list;
  62. }
  63. @Override
  64. public List<AlarmFreqArea> alarmTypeAreaCount(String railwayCode, Integer currentYear, Integer currentMonth) {
  65. List<AlarmFreqArea> list = msgAlarmMapper.alarmTypeAreaCount(railwayCode, currentYear, currentMonth);
  66. return list;
  67. }
  68. @Override
  69. public List<AlarmStatisticDto> exportExcel(AlarmStatisticResVo alarmStatisticResVo) {
  70. List<AlarmStatisticDto> listDto = msgAlarmMapper.list(alarmStatisticResVo.getRailwayCode(), alarmStatisticResVo.getCurrentYear(),
  71. alarmStatisticResVo.getCurrentMonth());
  72. return listDto;
  73. }
  74. @Override
  75. public Long getAlarmNum() {
  76. Long alarmNum = msgAlarmMapper.getAlarmNum();
  77. return alarmNum;
  78. }
  79. @Override
  80. public MsgAlarm selectByCameraCode(String cameraCode) {
  81. return msgAlarmMapper.selectByCameraCode(cameraCode);
  82. }
  83. @Override
  84. public IPage<MsgAlarm> queryPage(MsgAlarmVo vo) {
  85. int pageNum = Integer.parseInt(vo.getPageNum().toString());
  86. int pageSize = Integer.parseInt(vo.getPageSize().toString());
  87. com.github.pagehelper.Page<MsgAlarm> page = PageHelper.startPage(pageNum, pageSize)
  88. .doSelectPage(() -> msgAlarmMapper.selectMsgAlarmList(vo));
  89. Page<MsgAlarm> pageR = new Page<>(pageNum, pageSize);
  90. pageR.setRecords(page.getResult());
  91. pageR.setTotal(page.getTotal());
  92. return pageR;
  93. }
  94. @Override
  95. public MsgAlarm getByAlarmId(String alarmId) {
  96. return msgAlarmMapper.getByAlarmId(alarmId);
  97. }
  98. @Override
  99. public Map<String, Integer> statisticsNum(MsgAlarmVo msgAlarmVo) {
  100. Map<String, Integer> map = new HashMap<>();
  101. // 相机数量
  102. Integer countCamera = baseCameraManagementMapper.countCamera(msgAlarmVo);
  103. // 累计报警次数
  104. Integer countMsg = msgAlarmMapper.countMsg(msgAlarmVo);
  105. // 解除报警
  106. // LambdaQueryWrapper<MsgAlarm> lwJC = new LambdaQueryWrapper<MsgAlarm>();
  107. // lwJC.eq(MsgAlarm::getIsLock, "1");
  108. Integer countJC = msgAlarmMapper.countJC(msgAlarmVo);
  109. // 未解除报警
  110. // LambdaQueryWrapper<MsgAlarm> lwWJC = new LambdaQueryWrapper<MsgAlarm>();
  111. // lwWJC.eq(MsgAlarm::getIsLock, "2");
  112. Integer countWJC = msgAlarmMapper.countWJC(msgAlarmVo);
  113. map.put("countCamera", countCamera);
  114. map.put("countMsg", countMsg);
  115. map.put("countJC", countJC);
  116. map.put("countWJC", countWJC);
  117. return map;
  118. }
  119. @Override
  120. public Integer appAlarmNum(MsgAlarmVo msgAlarmVo) {
  121. return msgAlarmMapper.countWJC(msgAlarmVo);
  122. }
  123. @Override
  124. public List<MsgAlarm> msgAlarmList(MsgAlarmVo msgAlarmVo) {
  125. return msgAlarmMapper.selectMsgAlarmList(msgAlarmVo);
  126. }
  127. }