|
@@ -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));
|
|
|
}
|
|
|
|
|
|
|