|
|
@@ -3,34 +3,26 @@ package com.hfln.portal.infrastructure.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.hfln.portal.common.dto.data.event.EventsDTO;
|
|
|
import com.hfln.portal.common.dto.data.stat.ScreenAlarmDTO;
|
|
|
import com.hfln.portal.common.request.event.WapEventsParams;
|
|
|
import com.hfln.portal.common.request.event.WebEventsParams;
|
|
|
-import com.hfln.portal.common.vo.PageRecord;
|
|
|
import com.hfln.portal.domain.customer.AdminUserType;
|
|
|
-import com.hfln.portal.domain.customer.util.CopyUtils;
|
|
|
import com.hfln.portal.infrastructure.mapper.EventsMapper;
|
|
|
-import com.hfln.portal.infrastructure.po.DevInfo;
|
|
|
import com.hfln.portal.infrastructure.po.Events;
|
|
|
-import com.hfln.portal.infrastructure.service.DevInfoService;
|
|
|
import com.hfln.portal.infrastructure.service.EventsService;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.temporal.TemporalAdjusters;
|
|
|
-import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
@Service
|
|
|
public class EventsServiceImpl extends ServiceImpl<EventsMapper, Events> implements EventsService {
|
|
|
|
|
|
|
|
|
- @Autowired
|
|
|
- private DevInfoService devInfoService;
|
|
|
-
|
|
|
/**
|
|
|
* 小程序查询设备事件列表
|
|
|
*
|
|
|
@@ -81,7 +73,7 @@ public class EventsServiceImpl extends ServiceImpl<EventsMapper, Events> impleme
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public PageRecord<EventsDTO> queryEvents(WebEventsParams params, String userType, Long tenantId) {
|
|
|
+ public Page<Events> queryEvents(WebEventsParams params, String userType, Long tenantId) {
|
|
|
|
|
|
Page<Events> page = new Page<>(params.getPageNo(), params.getPageSize());
|
|
|
LambdaQueryWrapper<Events> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
@@ -115,16 +107,7 @@ public class EventsServiceImpl extends ServiceImpl<EventsMapper, Events> impleme
|
|
|
queryWrapper.orderByDesc(Events::getCreateTime);
|
|
|
|
|
|
// 6. 分页查询
|
|
|
- page = this.baseMapper.selectPage(page, queryWrapper);
|
|
|
-
|
|
|
- // 7. 转换为 DTO
|
|
|
- List<EventsDTO> dtoList = CopyUtils.copyList(page.getRecords(), EventsDTO.class);
|
|
|
-
|
|
|
- // 8. 填充 devName
|
|
|
- fillDevNames(dtoList);
|
|
|
-
|
|
|
- // 9. 封装返回
|
|
|
- return CopyUtils.copyPage(page, dtoList);
|
|
|
+ return this.baseMapper.selectPage(page, queryWrapper);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -162,19 +145,4 @@ public class EventsServiceImpl extends ServiceImpl<EventsMapper, Events> impleme
|
|
|
LocalDate startDate = today.minusDays(6);
|
|
|
return this.baseMapper.queryEventsInSevenDays(tenantId, startDate);
|
|
|
}
|
|
|
-
|
|
|
- // 辅助方法:填充 devName
|
|
|
- public void fillDevNames(List<EventsDTO> dtoList) {
|
|
|
- Set<String> allClientIds = dtoList.stream()
|
|
|
- .map(EventsDTO::getClientId)
|
|
|
- .collect(Collectors.toSet());
|
|
|
-
|
|
|
- if (!allClientIds.isEmpty()) {
|
|
|
- Map<String, String> devIdNameMap = devInfoService.queryByIds(allClientIds)
|
|
|
- .stream()
|
|
|
- .collect(Collectors.toMap(DevInfo::getClientId, DevInfo::getDevName));
|
|
|
-
|
|
|
- dtoList.forEach(dto -> dto.setDevName(devIdNameMap.get(dto.getClientId())));
|
|
|
- }
|
|
|
- }
|
|
|
}
|