|
@@ -4,27 +4,25 @@ import cn.dev33.satoken.stp.StpUtil;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.hfln.portal.common.constant.UserConstants;
|
|
import com.hfln.portal.common.constant.UserConstants;
|
|
|
import com.hfln.portal.common.constant.redis.RedisCacheConstant;
|
|
import com.hfln.portal.common.constant.redis.RedisCacheConstant;
|
|
|
-import com.hfln.portal.common.dto.data.event.AlarmEventDTO;
|
|
|
|
|
import com.hfln.portal.common.dto.data.event.EventListDTO;
|
|
import com.hfln.portal.common.dto.data.event.EventListDTO;
|
|
|
-import com.hfln.portal.common.request.event.AlarmEventParams;
|
|
|
|
|
|
|
+import com.hfln.portal.common.dto.data.event.EventsDTO;
|
|
|
import com.hfln.portal.common.request.event.WapEventListParams;
|
|
import com.hfln.portal.common.request.event.WapEventListParams;
|
|
|
|
|
+import com.hfln.portal.common.request.event.WapEventsParams;
|
|
|
import com.hfln.portal.common.vo.PageRecord;
|
|
import com.hfln.portal.common.vo.PageRecord;
|
|
|
import com.hfln.portal.domain.customer.util.CopyUtils;
|
|
import com.hfln.portal.domain.customer.util.CopyUtils;
|
|
|
import com.hfln.portal.domain.gateway.StatsGateway;
|
|
import com.hfln.portal.domain.gateway.StatsGateway;
|
|
|
-import com.hfln.portal.infrastructure.po.AlarmEvent;
|
|
|
|
|
-import com.hfln.portal.infrastructure.po.DevInfo;
|
|
|
|
|
import com.hfln.portal.infrastructure.po.EventList;
|
|
import com.hfln.portal.infrastructure.po.EventList;
|
|
|
-import com.hfln.portal.infrastructure.service.AlarmEventService;
|
|
|
|
|
|
|
+import com.hfln.portal.infrastructure.po.Events;
|
|
|
import com.hfln.portal.infrastructure.service.DevInfoService;
|
|
import com.hfln.portal.infrastructure.service.DevInfoService;
|
|
|
import com.hfln.portal.infrastructure.service.DevShareService;
|
|
import com.hfln.portal.infrastructure.service.DevShareService;
|
|
|
import com.hfln.portal.infrastructure.service.EventListService;
|
|
import com.hfln.portal.infrastructure.service.EventListService;
|
|
|
|
|
+import com.hfln.portal.infrastructure.service.EventsService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
|
|
import java.util.Optional;
|
|
import java.util.Optional;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
import java.util.stream.Stream;
|
|
@@ -40,17 +38,24 @@ public class StatsGatewayImpl implements StatsGateway {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private DevInfoService devInfoService;
|
|
private DevInfoService devInfoService;
|
|
|
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private AlarmEventService alarmEventService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private EventListService eventListService;
|
|
private EventListService eventListService;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
|
|
+ private EventsService eventsService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
private org.springframework.data.redis.core.RedisTemplate<String, Object> redisTemplate;
|
|
private org.springframework.data.redis.core.RedisTemplate<String, Object> redisTemplate;
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 小程序告警事件统计查询
|
|
|
|
|
+ * @param params
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
- public PageRecord<AlarmEventDTO> alarmRetentionQuery(AlarmEventParams params) {
|
|
|
|
|
|
|
+ public PageRecord<EventsDTO> alarmEventsQuery(WapEventsParams params) {
|
|
|
// 1.从会话中获取当前用户的id
|
|
// 1.从会话中获取当前用户的id
|
|
|
Long userId = StpUtil.getSession().getLong(UserConstants.SA_USER_ID);
|
|
Long userId = StpUtil.getSession().getLong(UserConstants.SA_USER_ID);
|
|
|
|
|
|
|
@@ -68,9 +73,12 @@ public class StatsGatewayImpl implements StatsGateway {
|
|
|
).distinct() //去重 + 顺序
|
|
).distinct() //去重 + 顺序
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
log.info("用户设备id集合: {}", allDevIds);
|
|
log.info("用户设备id集合: {}", allDevIds);
|
|
|
|
|
+ //2.4 将devIds集合转换成clientIds集合
|
|
|
|
|
+ List<String> clientIds = devInfoService.devIdsChangeClientIds(allDevIds);
|
|
|
|
|
+ log.info("用户设备clientId集合: {}", clientIds);
|
|
|
|
|
|
|
|
- if (allDevIds.isEmpty()){
|
|
|
|
|
- PageRecord<AlarmEventDTO> pr = new PageRecord<>();
|
|
|
|
|
|
|
+ if (clientIds.isEmpty()){
|
|
|
|
|
+ PageRecord<EventsDTO> pr = new PageRecord<>();
|
|
|
pr.setPageNum(params.getPageNo());
|
|
pr.setPageNum(params.getPageNo());
|
|
|
pr.setPageSize(params.getPageSize());
|
|
pr.setPageSize(params.getPageSize());
|
|
|
pr.setRows(Collections.emptyList());
|
|
pr.setRows(Collections.emptyList());
|
|
@@ -79,17 +87,13 @@ public class StatsGatewayImpl implements StatsGateway {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 3.分页查询设备
|
|
// 3.分页查询设备
|
|
|
- Page<AlarmEvent> page = alarmEventService.QueryAlarmEvent(params, allDevIds);
|
|
|
|
|
|
|
+ Page<Events> page = eventsService.QueryEvents(params, clientIds);
|
|
|
|
|
|
|
|
//转化为DTO
|
|
//转化为DTO
|
|
|
- List<AlarmEventDTO> dtoList = CopyUtils.copyList(page.getRecords(), AlarmEventDTO.class);
|
|
|
|
|
|
|
+ List<EventsDTO> dtoList = CopyUtils.copyList(page.getRecords(), EventsDTO.class);
|
|
|
|
|
|
|
|
//新增 填充devName
|
|
//新增 填充devName
|
|
|
- Map<Long, String> devIdNameMap = devInfoService.queryByIds(
|
|
|
|
|
- dtoList.stream().map(AlarmEventDTO::getDevId).collect(Collectors.toSet())
|
|
|
|
|
- ).stream().collect(Collectors.toMap(DevInfo::getDevId, DevInfo::getDevName));
|
|
|
|
|
-
|
|
|
|
|
- dtoList.forEach(dto -> dto.setDevName(devIdNameMap.get(dto.getDevId())));
|
|
|
|
|
|
|
+ eventsService.fillDevNames(dtoList);
|
|
|
|
|
|
|
|
// 封装成 PageRecord 返回
|
|
// 封装成 PageRecord 返回
|
|
|
return CopyUtils.copyPage(page, dtoList);
|
|
return CopyUtils.copyPage(page, dtoList);
|