Kaynağa Gözat

增添 小程序查询跌倒时间列表 接口

hxd 1 ay önce
ebeveyn
işleme
6586ecfc30

+ 8 - 1
portal-service-application/src/main/java/com/hfln/portal/application/controller/wap/StatsController.java

@@ -6,6 +6,7 @@ import cn.hfln.framework.dto.ApiResult;
 import com.hfln.portal.common.dto.data.event.AlarmEventDTO;
 import com.hfln.portal.common.dto.data.event.EventListDTO;
 import com.hfln.portal.common.request.event.AlarmEventParams;
+import com.hfln.portal.common.request.event.WapEventListParams;
 import com.hfln.portal.common.vo.PageRecord;
 import com.hfln.portal.domain.gateway.StatsGateway;
 import io.swagger.v3.oas.annotations.Operation;
@@ -34,8 +35,14 @@ public class StatsController {
     }
 
     @GetMapping("/fallingEventsQuery")
-    @Operation(summary = "跌倒事件查询")
+    @Operation(summary = "10分钟内跌倒事件查询")
     public ApiResult<List<EventListDTO>> fallingEventsQuery(@RequestParam("user_id") Long userId) {
         return ApiResult.success(statsGateway.fallingEventsQuery(userId));
     }
+
+    @PostMapping("/fallQuery")
+    @Operation(summary = "跌倒统计查询")
+    public ApiResult<PageRecord<EventListDTO>> fallQuery(@Valid @RequestBody WapEventListParams params) {
+        return ApiResult.success(statsGateway.fallQuery(params));
+    }
 }

+ 26 - 0
portal-service-common/src/main/java/com/hfln/portal/common/request/event/WapEventListParams.java

@@ -0,0 +1,26 @@
+package com.hfln.portal.common.request.event;
+
+import com.hfln.portal.common.vo.PageVo;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import javax.validation.constraints.NotNull;
+import java.time.LocalDate;
+
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Schema(description = "跌倒事件列表查询")
+public class WapEventListParams extends PageVo {
+
+    @Schema(description = "设备ID")
+    @NotNull
+    private Long devId;
+
+    @Schema(description = "起始时间 格式yyyy-MM-dd")
+    private LocalDate createTimeStart;
+
+    @Schema(description = "结束时间 格式yyyy-MM-dd")
+    private LocalDate createTimeEnd;
+}

+ 3 - 0
portal-service-domain/src/main/java/com/hfln/portal/domain/gateway/StatsGateway.java

@@ -3,6 +3,7 @@ package com.hfln.portal.domain.gateway;
 import com.hfln.portal.common.dto.data.event.AlarmEventDTO;
 import com.hfln.portal.common.dto.data.event.EventListDTO;
 import com.hfln.portal.common.request.event.AlarmEventParams;
+import com.hfln.portal.common.request.event.WapEventListParams;
 import com.hfln.portal.common.vo.PageRecord;
 import org.springframework.web.bind.annotation.RequestParam;
 
@@ -13,4 +14,6 @@ public interface StatsGateway {
     PageRecord<AlarmEventDTO> alarmRetentionQuery(AlarmEventParams params);
 
     List<EventListDTO> fallingEventsQuery(@RequestParam("user_id") Long userId);
+
+    PageRecord<EventListDTO> fallQuery(WapEventListParams params);
 }

+ 19 - 0
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/gateway/impl/StatsGatewayImpl.java

@@ -7,11 +7,13 @@ 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.request.event.AlarmEventParams;
+import com.hfln.portal.common.request.event.WapEventListParams;
 import com.hfln.portal.common.vo.PageRecord;
 import com.hfln.portal.domain.customer.util.CopyUtils;
 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.service.AlarmEventService;
 import com.hfln.portal.infrastructure.service.DevInfoService;
 import com.hfln.portal.infrastructure.service.DevShareService;
@@ -133,4 +135,21 @@ public class StatsGatewayImpl implements StatsGateway {
 
         return filteredEvents;
     }
+
+    /**
+     * 小程序端跌倒统计查询
+     * @param params
+     * @return
+     */
+    @Override
+    public PageRecord<EventListDTO> fallQuery(WapEventListParams params) {
+        //调用返回Page<EventList>
+        Page<EventList> page = eventListService.WapQueryEventList(params);
+
+        //转化为DTO
+        List<EventListDTO> dtoList = CopyUtils.copyList(page.getRecords(), EventListDTO.class);
+
+        // 封装成 PageRecord 返回
+        return CopyUtils.copyPage(page, dtoList);
+    }
 }

+ 1 - 1
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/gateway/impl/WebStatsGatewayImpl.java

@@ -70,7 +70,7 @@ public class WebStatsGatewayImpl implements WebStatsGateway {
         // 如果tenantId为0或null,则不添加租户ID查询条件,查询所有事件(超管权限)
 
         //调用返回Page<EventList>
-        Page<EventList> page = eventListService.queryEventList(params, devIdList);
+        Page<EventList> page = eventListService.WebQueryEventList(params, devIdList);
 
         //转化为DTO
         List<EventListDTO> dtoList = CopyUtils.copyList(page.getRecords(), EventListDTO.class);

+ 4 - 1
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/service/EventListService.java

@@ -4,13 +4,16 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.hfln.portal.common.dto.data.event.EventListDTO;
 import com.hfln.portal.common.request.event.EventListParams;
+import com.hfln.portal.common.request.event.WapEventListParams;
 import com.hfln.portal.infrastructure.po.EventList;
 
 import java.util.List;
 
 public interface EventListService extends IService<EventList> {
 
-    Page<EventList> queryEventList(EventListParams params, List<Long> devIdList);
+    Page<EventList> WebQueryEventList(EventListParams params, List<Long> devIdList);
 
     List<EventListDTO> queryFallingEvents(List<Long> devIdList);
+
+    Page<EventList> WapQueryEventList(WapEventListParams params);
 }

+ 24 - 1
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/service/impl/EventListServiceImpl.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.hfln.portal.common.dto.data.event.EventListDTO;
 import com.hfln.portal.common.request.event.EventListParams;
+import com.hfln.portal.common.request.event.WapEventListParams;
 import com.hfln.portal.infrastructure.mapper.EventListMapper;
 import com.hfln.portal.infrastructure.po.EventList;
 import com.hfln.portal.infrastructure.service.EventListService;
@@ -20,7 +21,7 @@ import java.util.stream.Collectors;
 @Service
 public class EventListServiceImpl extends ServiceImpl<EventListMapper, EventList> implements EventListService {
     @Override
-    public Page<EventList> queryEventList(EventListParams params, List<Long> devIdList) {
+    public Page<EventList> WebQueryEventList(EventListParams params, List<Long> devIdList) {
         Page<EventList> page = new Page<>(params.getPageNo(), params.getPageSize());
 
         // 2. 构建查询条件
@@ -68,4 +69,26 @@ public class EventListServiceImpl extends ServiceImpl<EventListMapper, EventList
                 })
                 .collect(Collectors.toList());
     }
+
+    @Override
+    public Page<EventList> WapQueryEventList(WapEventListParams params) {
+        Page<EventList> page = new Page<>(params.getPageNo(), params.getPageSize());
+
+        // 2. 构建查询条件,根据devId查询记录
+        LambdaQueryWrapper<EventList> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(EventList::getDevId, params.getDevId());
+
+        // 3. 添加日期条件
+        if (Objects.nonNull(params.getCreateTimeStart())) {
+            queryWrapper.ge(EventList::getCreateTime, params.getCreateTimeStart());
+        }
+        if (Objects.nonNull(params.getCreateTimeEnd())) {
+            queryWrapper.lt(EventList::getCreateTime, params.getCreateTimeEnd().plusDays(1));
+        }
+
+
+        // 4. 设置排序
+        queryWrapper.orderByDesc(EventList::getCreateTime);
+        return this.baseMapper.selectPage(page, queryWrapper);
+    }
 }