|
@@ -0,0 +1,41 @@
|
|
|
|
+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.request.event.StayTimeParams;
|
|
|
|
+import com.hfln.portal.infrastructure.mapper.StayTimeMapper;
|
|
|
|
+import com.hfln.portal.infrastructure.po.StayTime;
|
|
|
|
+import com.hfln.portal.infrastructure.service.StayTimeService;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Objects;
|
|
|
|
+
|
|
|
|
+@Service
|
|
|
|
+public class StayTimeServiceImpl extends ServiceImpl<StayTimeMapper, StayTime> implements StayTimeService {
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Page<StayTime> queryStayTime(StayTimeParams params, List<Long> devIdList) {
|
|
|
|
+ Page<StayTime> page = new Page<>(params.getPageNo(), params.getPageSize());
|
|
|
|
+
|
|
|
|
+ // 2. 构建查询条件
|
|
|
|
+ LambdaQueryWrapper<StayTime> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ if (devIdList != null && !devIdList.isEmpty()){
|
|
|
|
+ queryWrapper.in(StayTime::getDevId, devIdList);
|
|
|
|
+ }
|
|
|
|
+ // 如果devIdList为空,则不添加设备ID查询条件,查询所有事件
|
|
|
|
+
|
|
|
|
+ // 3. 添加日期条件
|
|
|
|
+ if (Objects.nonNull(params.getCreateTimeStart())) {
|
|
|
|
+ queryWrapper.ge(StayTime::getCreateTime, params.getCreateTimeStart());
|
|
|
|
+ }
|
|
|
|
+ if (Objects.nonNull(params.getCreateTimeEnd())) {
|
|
|
|
+ queryWrapper.le(StayTime::getCreateTime, params.getCreateTimeEnd());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 4. 设置排序
|
|
|
|
+ queryWrapper.orderByDesc(StayTime::getCreateTime);
|
|
|
|
+ return this.baseMapper.selectPage(page, queryWrapper);
|
|
|
|
+ }
|
|
|
|
+}
|