Parcourir la source

Merge branch 'master' into test

李进 il y a 1 an
Parent
commit
3f8bb4b4a1

+ 12 - 7
device-api-service/src/main/java/com/xy/service/DeviceInfoServiceImpl.java

@@ -107,24 +107,29 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
 
     @PostMapping("eventList")
     @ApiOperation("根据事件编码查询设备")
-    public R<List<DeviceInfoDto.EventListVo>> eventList(@RequestBody @Validated DeviceInfoDto.EventList eventList) {
+    public R<PageBean<DeviceInfoDto.EventListVo>> eventList(@RequestBody @Validated DeviceInfoDto.EventList eventList) {
         String countAs = "id";
         QueryWrapper<DeviceEventMsg> queryWrapper = new QueryWrapper<DeviceEventMsg>()
-                .select(LambdaUtils.getUnderlineCaseName(DeviceEventMsg::getDeviceId) + "as " + LambdaUtils.getProperty(DeviceEventMsg::getDeviceId), "count(*) as " + countAs)
+                .select(LambdaUtils.getUnderlineCaseName(DeviceEventMsg::getDeviceId) + " as " + LambdaUtils.getProperty(DeviceEventMsg::getDeviceId), "count(*) as " + countAs)
                 .eq(LambdaUtils.getUnderlineCaseName(DeviceEventMsg::getCode), eventList.getCode())
                 .between(LambdaUtils.getUnderlineCaseName(DeviceEventMsg::getCreateTime), eventList.getBeginTime(), eventList.getEndTime())
                 .groupBy(LambdaUtils.getUnderlineCaseName(DeviceEventMsg::getDeviceId))
-                .last(countAs + " >= " + eventList.getSize());
-        List<DeviceEventMsg> list = deviceEventMsgService.list(queryWrapper);
-        if(!Emptys.check(list)) {
-            return R.ok();
+                .last("HAVING " + countAs + " >= " + eventList.getSize());
+        IPage<DeviceEventMsg> iPage = deviceEventMsgService.page(toIPage(eventList.getPage()), queryWrapper);
+        PageBean<DeviceInfoDto.EventListVo> pageBean = new PageBean<DeviceInfoDto.EventListVo>()
+                .setSize(iPage.getSize())
+                .setCurrent(iPage.getCurrent())
+                .setTotal(iPage.getTotal());
+        List<DeviceEventMsg> list = iPage.getRecords();
+        if (!Emptys.check(list)) {
+            return R.ok(pageBean);
         }
         List<DeviceInfo> deviceInfos = listByIds(new JArrayList<>(list).getProperty(DeviceEventMsg::getDeviceId));
         List<DeviceInfoDto.EventListVo> eventListVos = copy(DeviceInfoDto.EventListVo.class, deviceInfos);
         List<DeviceInfoDto.EventListVo> builder = copy(eventListVos)
                 .target(list, DeviceInfoDto.EventListVo::getDeviceId, DeviceInfoDto.EventListVo::getSize, DeviceEventMsg::getDeviceId, DeviceEventMsg::getId)
                 .builder();
-        return R.ok(builder);
+        return R.ok(pageBean.setRecords(builder));
     }
 
 

+ 4 - 0
device-api/src/main/java/com/xy/dto/DeviceInfoDto.java

@@ -66,6 +66,10 @@ public class DeviceInfoDto {
     @Accessors(chain = true)
     public static class EventList {
 
+        @NotNull(message = "分页对象不能空")
+        @ApiModelProperty(value = "分页对象", required = true)
+        private PageBean page;
+
         @NotBlank(message = "code不能为空")
         @ApiModelProperty(value = "事件编码", required = true)
         private String code;